xref: /openbsd-src/gnu/usr.bin/perl/Configure (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1#! /bin/sh
2#
3# If these # comments don't work, trim them. Don't worry about any other
4# shell scripts, Configure will trim # comments from them for you.
5#
6# (If you are trying to port this package to a machine without sh,
7# I would suggest you have a look at the prototypical config_h.SH file
8# and edit it to reflect your system. Some packages may include samples
9# of config.h for certain machines, so you might look for one of those.)
10#
11# Yes, you may rip this off to use in other distribution packages. This
12# script belongs to the public domain and cannot be copyrighted.
13#
14# (Note: this Configure script was generated automatically. Rather than
15# working with this copy of Configure, you may wish to get metaconfig.
16# The dist-3.0 package (which contains metaconfig) was posted in
17# comp.sources.misc and is available on CPAN under authors/id/RAM so
18# you may fetch it yourself from your nearest archive site.)
19#
20
21# $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
22#
23# Generated on Tue Mar 13 05:21:04 EET 2001 [metaconfig 3.0 PL70]
24# (with additional metaconfig patches by perlbug@perl.org)
25
26cat >c1$$ <<EOF
27ARGGGHHHH!!!!!
28
29SCO csh still thinks true is false.  Write to SCO today and tell them that next
30year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
31
32(Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
33we'd have to do is go in and swap the && and || tokens, wherever they are.)
34
35[End of diatribe. We now return you to your regularly scheduled programming...]
36EOF
37cat >c2$$ <<EOF
38
39OOPS!  You naughty creature!  You didn't run Configure with sh!
40I will attempt to remedy the situation by running sh for you...
41EOF
42
43true || cat c1$$ c2$$
44true || exec sh $0 $argv:q
45
46(exit $?0) || cat c2$$
47(exit $?0) || exec sh $0 $argv:q
48rm -f c1$$ c2$$
49
50: compute my invocation name
51me=$0
52case "$0" in
53*/*)
54	me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55	test "$me" || me=$0
56	;;
57esac
58
59: Proper separator for the PATH environment variable
60p_=:
61: On OS/2 this directory should exist if this is not floppy only system :-]
62if test -d c:/. ; then
63    if test -n "$OS2_SHELL"; then
64		p_=\;
65		PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
66		OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
67	elif test -n "$DJGPP"; then
68		p_=\;
69	fi
70fi
71
72: Proper PATH setting
73paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
74paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
75paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
76paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
77paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80paths="$paths /sbin /usr/sbin /usr/libexec"
81
82for p in $paths
83do
84	case "$p_$PATH$p_" in
85	*$p_$p$p_*) ;;
86	*) test -d $p && PATH=$PATH$p_$p ;;
87	esac
88done
89
90PATH=.$p_$PATH
91export PATH
92
93: shall we be using ksh?
94inksh=''
95needksh=''
96avoidksh=''
97newsh=/bin/ksh
98changesh=''
99if (PATH=.; alias -x) >/dev/null 2>&1; then
100		inksh=true
101fi
102if test -f /hp-ux -a -f /bin/ksh; then
103	needksh='to avoid sh bug in "here document" expansion'
104fi
105if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
106	if test X`/usr/bin/uname -v` = X4; then
107		avoidksh="to avoid AIX 4's /bin/sh"
108		newsh=/usr/bin/bsh
109	fi
110fi
111if test -f /osf_boot -a -f /usr/sbin/setld; then
112	if test X`/usr/bin/uname -s` = XOSF1; then
113	        avoidksh="to avoid Digital UNIX' ksh"
114	        newsh=/bin/sh
115	        unset BIN_SH # if this is 'xpg4' sh will start up ksh
116	fi
117fi
118case "$inksh/$needksh" in
119/[a-z]*)
120		ENV=''
121		changesh=true
122		reason="$needksh"
123	;;
124esac
125case "$inksh/$avoidksh" in
126true/[a-z]*)
127	changesh=true
128	reason="$avoidksh"
129	;;
130esac
131case "$inksh/$needksh-$avoidksh-" in
132true/--)
133		cat <<EOM
134(I see you are using the Korn shell.  Some ksh's blow up on $me,
135mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
136EOM
137	;;
138esac
139case "$changesh" in
140true)
141	echo "(Feeding myself to $newsh $reason.)"
142	case "$0" in
143	Configure|*/Configure) exec $newsh $0 "$@";;
144	*) exec $newsh Configure "$@";;
145	esac
146	;;
147esac
148
149: if needed set CDPATH to a harmless value that is not chatty
150: avoid bash 2.02 problems with empty CDPATH.
151case "$CDPATH" in
152'')	;;
153*)	case "$SHELL" in
154	*bash*)	CDPATH='.' ;;
155	*)		CDPATH='' ;;
156	esac
157	;;
158esac
159: Configure runs within the UU subdirectory
160test -d UU || mkdir UU
161cd UU && rm -f ./*
162
163ccname=''
164ccversion=''
165ccsymbols=''
166cppccsymbols=''
167cppsymbols=''
168perllibs=''
169dynamic_ext=''
170extensions=''
171known_extensions=''
172nonxs_ext=''
173static_ext=''
174useopcode=''
175useposix=''
176d_bsd=''
177d_eunice=''
178d_xenix=''
179eunicefix=''
180Mcc=''
181ar=''
182awk=''
183bash=''
184bison=''
185byacc=''
186cat=''
187chgrp=''
188chmod=''
189chown=''
190comm=''
191compress=''
192cp=''
193cpio=''
194cpp=''
195csh=''
196date=''
197echo=''
198egrep=''
199emacs=''
200expr=''
201find=''
202flex=''
203grep=''
204gzip=''
205inews=''
206ksh=''
207less=''
208line=''
209lint=''
210ln=''
211lp=''
212lpr=''
213ls=''
214mail=''
215mailx=''
216make=''
217mkdir=''
218more=''
219mv=''
220nm=''
221nroff=''
222perl=''
223pg=''
224pmake=''
225pr=''
226rm=''
227rmail=''
228sed=''
229sendmail=''
230shar=''
231sleep=''
232smail=''
233sort=''
234submit=''
235tail=''
236tar=''
237tbl=''
238tee=''
239test=''
240touch=''
241tr=''
242troff=''
243uname=''
244uniq=''
245uuname=''
246vi=''
247zcat=''
248zip=''
249full_ar=''
250full_sed=''
251libswanted=''
252hint=''
253myuname=''
254osname=''
255osvers=''
256Author=''
257Date=''
258Header=''
259Id=''
260Locker=''
261Log=''
262RCSfile=''
263Revision=''
264Source=''
265State=''
266_a=''
267_exe=''
268_o=''
269archobjs=''
270exe_ext=''
271firstmakefile=''
272lib_ext=''
273obj_ext=''
274path_sep=''
275afs=''
276alignbytes=''
277ansi2knr=''
278archlib=''
279archlibexp=''
280d_archlib=''
281installarchlib=''
282archname=''
283myarchname=''
284d_atolf=''
285d_atoll=''
286baserev=''
287bin=''
288binexp=''
289installbin=''
290bincompat5005=''
291d_bincompat5005=''
292byteorder=''
293cc=''
294ccflags=''
295cppflags=''
296ldflags=''
297lkflags=''
298locincpth=''
299optimize=''
300cf_email=''
301cf_by=''
302cf_time=''
303charsize=''
304contains=''
305cpp_stuff=''
306cpplast=''
307cppminus=''
308cpprun=''
309cppstdin=''
310crosscompile=''
311d__fwalk=''
312d_access=''
313d_accessx=''
314d_alarm=''
315d_attribut=''
316d_bcmp=''
317d_bcopy=''
318d_bzero=''
319d_casti32=''
320castflags=''
321d_castneg=''
322d_chown=''
323d_chroot=''
324d_chsize=''
325d_closedir=''
326d_void_closedir=''
327d_const=''
328cryptlib=''
329d_crypt=''
330d_csh=''
331full_csh=''
332d_cuserid=''
333d_dbl_dig=''
334d_difftime=''
335d_dlerror=''
336d_dlopen=''
337d_dlsymun=''
338d_dosuid=''
339d_suidsafe=''
340d_drand48proto=''
341d_dup2=''
342d_eaccess=''
343d_endgrent=''
344d_endhent=''
345d_endnent=''
346d_endpent=''
347d_endpwent=''
348d_endsent=''
349d_fchmod=''
350d_fchown=''
351d_fcntl=''
352d_fcntl_can_lock=''
353d_fd_macros=''
354d_fd_set=''
355d_fds_bits=''
356d_fgetpos=''
357d_flexfnam=''
358d_flock=''
359d_fork=''
360d_fpos64_t=''
361d_frexpl=''
362d_fs_data_s=''
363d_fseeko=''
364d_fsetpos=''
365d_fstatfs=''
366d_fsync=''
367d_ftello=''
368d_ftime=''
369d_gettimeod=''
370d_Gconvert=''
371d_getcwd=''
372d_getespwnam=''
373d_getfsstat=''
374d_getgrent=''
375d_getgrps=''
376d_gethbyaddr=''
377d_gethbyname=''
378d_gethent=''
379aphostname=''
380d_gethname=''
381d_phostname=''
382d_uname=''
383d_gethostprotos=''
384d_getlogin=''
385d_getmnt=''
386d_getmntent=''
387d_getnbyaddr=''
388d_getnbyname=''
389d_getnent=''
390d_getnetprotos=''
391d_getpagsz=''
392d_getpent=''
393d_getpgid=''
394d_getpgrp2=''
395d_bsdgetpgrp=''
396d_getpgrp=''
397d_getppid=''
398d_getprior=''
399d_getpbyname=''
400d_getpbynumber=''
401d_getprotoprotos=''
402d_getprpwnam=''
403d_getpwent=''
404d_getsent=''
405d_getservprotos=''
406d_getspnam=''
407d_getsbyname=''
408d_getsbyport=''
409d_gnulibc=''
410d_hasmntopt=''
411d_htonl=''
412d_iconv=''
413d_inetaton=''
414d_int64_t=''
415d_isascii=''
416d_isnan=''
417d_isnanl=''
418d_killpg=''
419d_lchown=''
420d_ldbl_dig=''
421d_link=''
422d_locconv=''
423d_lockf=''
424d_longdbl=''
425longdblsize=''
426d_longlong=''
427longlongsize=''
428d_lseekproto=''
429d_lstat=''
430d_madvise=''
431d_mblen=''
432d_mbstowcs=''
433d_mbtowc=''
434d_memchr=''
435d_memcmp=''
436d_memcpy=''
437d_memmove=''
438d_memset=''
439d_mkdir=''
440d_mkdtemp=''
441d_mkfifo=''
442d_mkstemp=''
443d_mkstemps=''
444d_mktime=''
445d_mmap=''
446mmaptype=''
447d_modfl=''
448d_mprotect=''
449d_msg=''
450d_msgctl=''
451d_msgget=''
452d_msgrcv=''
453d_msgsnd=''
454d_msync=''
455d_munmap=''
456d_nice=''
457d_off64_t=''
458d_open3=''
459d_fpathconf=''
460d_pathconf=''
461d_pause=''
462d_pipe=''
463d_poll=''
464d_portable=''
465d_old_pthread_create_joinable=''
466old_pthread_create_joinable=''
467d_pthread_yield=''
468d_sched_yield=''
469sched_yield=''
470d_qgcvt=''
471d_readdir=''
472d_rewinddir=''
473d_seekdir=''
474d_telldir=''
475d_readlink=''
476d_rename=''
477d_rmdir=''
478d_safebcpy=''
479d_safemcpy=''
480d_sanemcmp=''
481d_sbrkproto=''
482d_select=''
483d_sem=''
484d_semctl=''
485d_semget=''
486d_semop=''
487d_setegid=''
488d_seteuid=''
489d_setgrent=''
490d_setgrps=''
491d_sethent=''
492d_setlinebuf=''
493d_setlocale=''
494d_setnent=''
495d_setpent=''
496d_setpgid=''
497d_setpgrp2=''
498d_bsdsetpgrp=''
499d_setpgrp=''
500d_setprior=''
501d_setproctitle=''
502d_setpwent=''
503d_setregid=''
504d_setresgid=''
505d_setresuid=''
506d_setreuid=''
507d_setrgid=''
508d_setruid=''
509d_setsent=''
510d_setsid=''
511d_setvbuf=''
512d_sfio=''
513usesfio=''
514d_shm=''
515d_shmat=''
516d_shmatprototype=''
517shmattype=''
518d_shmctl=''
519d_shmdt=''
520d_shmget=''
521d_sigaction=''
522d_sigsetjmp=''
523d_msg_ctrunc=''
524d_msg_dontroute=''
525d_msg_oob=''
526d_msg_peek=''
527d_msg_proxy=''
528d_oldsock=''
529d_scm_rights=''
530d_socket=''
531d_sockpair=''
532sockethdr=''
533socketlib=''
534d_socklen_t=''
535d_socks5_init=''
536d_sqrtl=''
537d_statblks=''
538d_statfs_f_flags=''
539d_statfs_s=''
540d_fstatvfs=''
541d_statvfs=''
542d_stdio_cnt_lval=''
543d_stdio_ptr_lval=''
544d_stdio_ptr_lval_nochange_cnt=''
545d_stdio_ptr_lval_sets_cnt=''
546d_stdiobase=''
547d_stdstdio=''
548stdio_base=''
549stdio_bufsiz=''
550stdio_cnt=''
551stdio_filbuf=''
552stdio_ptr=''
553d_index=''
554d_strchr=''
555d_strcoll=''
556d_strctcpy=''
557d_strerrm=''
558d_strerror=''
559d_sysernlst=''
560d_syserrlst=''
561d_strtod=''
562d_strtol=''
563d_strtold=''
564d_strtoll=''
565d_strtoul=''
566d_strtoull=''
567d_strtouq=''
568d_strxfrm=''
569d_symlink=''
570d_syscall=''
571d_sysconf=''
572d_system=''
573d_tcgetpgrp=''
574d_tcsetpgrp=''
575d_telldirproto=''
576d_time=''
577timetype=''
578clocktype=''
579d_times=''
580d_truncate=''
581d_tzname=''
582d_umask=''
583d_semctl_semid_ds=''
584d_semctl_semun=''
585d_union_semun=''
586d_ustat=''
587d_vfork=''
588usevfork=''
589d_voidsig=''
590signal_t=''
591d_volatile=''
592d_charvspr=''
593d_vprintf=''
594d_wait4=''
595d_waitpid=''
596d_wcstombs=''
597d_wctomb=''
598dlext=''
599cccdlflags=''
600ccdlflags=''
601dlsrc=''
602ld=''
603lddlflags=''
604usedl=''
605doublesize=''
606ebcdic=''
607fflushNULL=''
608fflushall=''
609fpossize=''
610fpostype=''
611gccosandvers=''
612gccversion=''
613gidformat=''
614gidsign=''
615gidsize=''
616gidtype=''
617groupstype=''
618h_fcntl=''
619h_sysfile=''
620i_arpainet=''
621db_hashtype=''
622db_prefixtype=''
623i_db=''
624i_dbm=''
625i_rpcsvcdbm=''
626d_dirnamlen=''
627direntrytype=''
628i_dirent=''
629i_dld=''
630i_dlfcn=''
631i_fcntl=''
632i_float=''
633i_gdbm=''
634d_grpasswd=''
635i_grp=''
636i_iconv=''
637i_ieeefp=''
638i_inttypes=''
639i_libutil=''
640i_limits=''
641i_locale=''
642i_machcthr=''
643i_malloc=''
644i_math=''
645i_memory=''
646i_mntent=''
647i_ndbm=''
648i_netdb=''
649i_neterrno=''
650i_netinettcp=''
651i_niin=''
652i_sysin=''
653i_poll=''
654i_prot=''
655i_pthread=''
656d_pwage=''
657d_pwchange=''
658d_pwclass=''
659d_pwcomment=''
660d_pwexpire=''
661d_pwgecos=''
662d_pwpasswd=''
663d_pwquota=''
664i_pwd=''
665i_sfio=''
666i_shadow=''
667i_socks=''
668i_stddef=''
669i_stdlib=''
670i_string=''
671strings=''
672i_sunmath=''
673i_sysaccess=''
674i_sysdir=''
675i_sysfile=''
676d_voidtty=''
677i_bsdioctl=''
678i_sysfilio=''
679i_sysioctl=''
680i_syssockio=''
681i_syslog=''
682i_sysmman=''
683i_sysmode=''
684i_sysmount=''
685i_sysndir=''
686i_sysparam=''
687i_sysresrc=''
688i_syssecrt=''
689i_sysselct=''
690i_sysstat=''
691i_sysstatfs=''
692i_sysstatvfs=''
693i_systimes=''
694i_systypes=''
695i_sysuio=''
696i_sysun=''
697i_sysutsname=''
698i_sysvfs=''
699i_syswait=''
700i_sgtty=''
701i_termio=''
702i_termios=''
703i_systime=''
704i_systimek=''
705i_time=''
706timeincl=''
707i_unistd=''
708i_ustat=''
709i_utime=''
710i_values=''
711i_stdarg=''
712i_varargs=''
713i_varhdr=''
714i_vfork=''
715inc_version_list=''
716inc_version_list_init=''
717installprefix=''
718installprefixexp=''
719installstyle=''
720installusrbinperl=''
721intsize=''
722longsize=''
723shortsize=''
724issymlink=''
725libc=''
726ldlibpthname=''
727libperl=''
728shrpenv=''
729useshrplib=''
730glibpth=''
731libpth=''
732loclibpth=''
733plibpth=''
734xlibpth=''
735ignore_versioned_solibs=''
736libs=''
737libsdirs=''
738libsfiles=''
739libsfound=''
740libspath=''
741lns=''
742d_PRIEUldbl=''
743d_PRIFUldbl=''
744d_PRIGUldbl=''
745d_PRIeldbl=''
746d_PRIfldbl=''
747d_PRIgldbl=''
748d_SCNfldbl=''
749sPRIEUldbl=''
750sPRIFUldbl=''
751sPRIGUldbl=''
752sPRIeldbl=''
753sPRIfldbl=''
754sPRIgldbl=''
755sSCNfldbl=''
756lseeksize=''
757lseektype=''
758make_set_make=''
759d_mymalloc=''
760freetype=''
761mallocobj=''
762mallocsrc=''
763malloctype=''
764usemymalloc=''
765installman1dir=''
766man1dir=''
767man1direxp=''
768man1ext=''
769installman3dir=''
770man3dir=''
771man3direxp=''
772man3ext=''
773modetype=''
774multiarch=''
775mydomain=''
776myhostname=''
777phostname=''
778c=''
779n=''
780d_eofnblk=''
781eagain=''
782o_nonblock=''
783rd_nodata=''
784netdb_hlen_type=''
785netdb_host_type=''
786netdb_name_type=''
787netdb_net_type=''
788groupcat=''
789hostcat=''
790passcat=''
791orderlib=''
792ranlib=''
793d_perl_otherlibdirs=''
794otherlibdirs=''
795package=''
796spackage=''
797pager=''
798api_revision=''
799api_subversion=''
800api_version=''
801api_versionstring=''
802patchlevel=''
803revision=''
804subversion=''
805version=''
806perl5=''
807perladmin=''
808perlpath=''
809d_nv_preserves_uv=''
810d_nv_preserves_uv_bits=''
811i16size=''
812i16type=''
813i32size=''
814i32type=''
815i64size=''
816i64type=''
817i8size=''
818i8type=''
819ivsize=''
820ivtype=''
821nvsize=''
822nvtype=''
823u16size=''
824u16type=''
825u32size=''
826u32type=''
827u64size=''
828u64type=''
829u8size=''
830u8type=''
831uvsize=''
832uvtype=''
833ivdformat=''
834nvEUformat=''
835nvFUformat=''
836nvGUformat=''
837nveformat=''
838nvfformat=''
839nvgformat=''
840uvXUformat=''
841uvoformat=''
842uvuformat=''
843uvxformat=''
844pidtype=''
845prefix=''
846prefixexp=''
847installprivlib=''
848privlib=''
849privlibexp=''
850prototype=''
851ptrsize=''
852d_PRIXU64=''
853d_PRId64=''
854d_PRIi64=''
855d_PRIo64=''
856d_PRIu64=''
857d_PRIx64=''
858sPRIXU64=''
859sPRId64=''
860sPRIi64=''
861sPRIo64=''
862sPRIu64=''
863sPRIx64=''
864d_quad=''
865quadkind=''
866quadtype=''
867uquadtype=''
868drand01=''
869randbits=''
870randfunc=''
871randseedtype=''
872seedfunc=''
873installscript=''
874scriptdir=''
875scriptdirexp=''
876selectminbits=''
877selecttype=''
878sh=''
879sig_count=''
880sig_name=''
881sig_name_init=''
882sig_num=''
883sig_num_init=''
884installsitearch=''
885sitearch=''
886sitearchexp=''
887installsitebin=''
888sitebin=''
889sitebinexp=''
890installsitelib=''
891sitelib=''
892sitelib_stem=''
893sitelibexp=''
894siteprefix=''
895siteprefixexp=''
896sizesize=''
897sizetype=''
898so=''
899socksizetype=''
900sharpbang=''
901shsharp=''
902spitshell=''
903src=''
904ssizetype=''
905startperl=''
906startsh=''
907stdchar=''
908d_stdio_stream_array=''
909stdio_stream_array=''
910sysman=''
911trnl=''
912uidformat=''
913uidsign=''
914uidsize=''
915uidtype=''
916archname64=''
917use64bitall=''
918use64bitint=''
919ccflags_uselargefiles=''
920ldflags_uselargefiles=''
921libswanted_uselargefiles=''
922uselargefiles=''
923uselongdouble=''
924usemorebits=''
925usemultiplicity=''
926nm_opt=''
927nm_so_opt=''
928runnm=''
929usenm=''
930useperlio=''
931usesocks=''
932d_oldpthreads=''
933use5005threads=''
934useithreads=''
935usethreads=''
936incpath=''
937mips_type=''
938usrinc=''
939d_vendorarch=''
940installvendorarch=''
941vendorarch=''
942vendorarchexp=''
943d_vendorbin=''
944installvendorbin=''
945vendorbin=''
946vendorbinexp=''
947d_vendorlib=''
948installvendorlib=''
949vendorlib=''
950vendorlib_stem=''
951vendorlibexp=''
952usevendorprefix=''
953vendorprefix=''
954vendorprefixexp=''
955versiononly=''
956defvoidused=''
957voidflags=''
958pm_apiversion=''
959xs_apiversion=''
960yacc=''
961yaccflags=''
962CONFIG=''
963
964define='define'
965undef='undef'
966smallmach='pdp11 i8086 z8000 i80286 iAPX286'
967rmlist=''
968
969: We must find out about Eunice early
970eunicefix=':'
971if test -f /etc/unixtovms; then
972	eunicefix=/etc/unixtovms
973fi
974if test -f /etc/unixtovms.exe; then
975	eunicefix=/etc/unixtovms.exe
976fi
977
978i_whoami=''
979ccname=''
980ccversion=''
981perllibs=''
982: set useposix=false in your hint file to disable the POSIX extension.
983useposix=true
984: set useopcode=false in your hint file to disable the Opcode extension.
985useopcode=true
986: Trailing extension.  Override this in a hint file, if needed.
987_exe=''
988: Extra object files, if any, needed on this platform.
989archobjs=''
990archname=''
991: Possible local include directories to search.
992: Set locincpth to "" in a hint file to defeat local include searches.
993locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
994locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
995:
996: no include file wanted by default
997inclwanted=''
998
999groupstype=''
1000: change the next line if compiling for Xenix/286 on Xenix/386
1001xlibpth='/usr/lib/386 /lib/386'
1002: Possible local library directories to search.
1003loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1004loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1005
1006: general looking path for locating libraries
1007glibpth="/lib /usr/lib $xlibpth"
1008glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
1009test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
1010test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
1011
1012: Private path used by Configure to find libraries.  Its value
1013: is prepended to libpth. This variable takes care of special
1014: machines, like the mips.  Usually, it should be empty.
1015plibpth=''
1016
1017: default library list
1018libswanted=''
1019: some systems want to use only the non-versioned libso:s
1020ignore_versioned_solibs=''
1021archname64=''
1022ccflags_uselargefiles=''
1023ldflags_uselargefiles=''
1024libswanted_uselargefiles=''
1025: set usemultiplicity on the Configure command line to enable multiplicity.
1026: set usesocks on the Configure command line to enable socks.
1027: set usethreads on the Configure command line to enable threads.
1028: full support for void wanted by default
1029defvoidused=15
1030
1031: List of libraries we want.
1032: If anyone needs -lnet, put it in a hint file.
1033libswanted='sfio socket bind inet nsl nm ndbm gdbm dbm db malloc dl'
1034libswanted="$libswanted dld ld sun m c cposix posix"
1035libswanted="$libswanted ndir dir crypt sec"
1036libswanted="$libswanted ucb bsd BSD PW x iconv util"
1037: We probably want to search /usr/shlib before most other libraries.
1038: This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
1039glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
1040glibpth="/usr/shlib $glibpth"
1041: Do not use vfork unless overridden by a hint file.
1042usevfork=false
1043
1044: Find the basic shell for Bourne shell scripts
1045case "$sh" in
1046'')
1047	case "$SYSTYPE" in
1048	*bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
1049	*) xxx='/bin/sh';;
1050	esac
1051	if test -f "$xxx"; then
1052		sh="$xxx"
1053	else
1054		: Build up a list and do a single loop so we can 'break' out.
1055		pth=`echo $PATH | sed -e "s/$p_/ /g"`
1056		for xxx in sh bash ksh pdksh ash; do
1057			for p in $pth; do
1058				try="$try ${p}/${xxx}"
1059			done
1060		done
1061		for xxx in $try; do
1062			if test -f "$xxx"; then
1063				sh="$xxx";
1064				break
1065			elif test -f "$xxx.exe"; then
1066				sh="$xxx";
1067				break
1068			fi
1069		done
1070	fi
1071	;;
1072esac
1073
1074case "$sh" in
1075'')	cat <<EOM >&2
1076$me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
1077
1078Usually it's in /bin/sh.  How did you even get this far?
1079Please contact me (Perl Maintainers) at perlbug@perl.org and 
1080we'll try to straighten this all out.
1081EOM
1082	exit 1
1083	;;
1084esac
1085
1086: see if sh knows # comments
1087if `$sh -c '#' >/dev/null 2>&1`; then
1088	shsharp=true
1089	spitshell=cat
1090	xcat=/bin/cat
1091	test -f $xcat || xcat=/usr/bin/cat
1092	echo "#!$xcat" >try
1093	$eunicefix try
1094	chmod +x try
1095	./try > today
1096	if test -s today; then
1097		sharpbang='#!'
1098	else
1099		echo "#! $xcat" > try
1100		$eunicefix try
1101		chmod +x try
1102		./try > today
1103		if test -s today; then
1104			sharpbang='#! '
1105		else
1106			sharpbang=': use '
1107		fi
1108	fi
1109else
1110	echo " "
1111	echo "Your $sh doesn't grok # comments--I will strip them later on."
1112	shsharp=false
1113	cd ..
1114	echo "exec grep -v '^[ 	]*#'" >spitshell
1115	chmod +x spitshell
1116	$eunicefix spitshell
1117	spitshell=`pwd`/spitshell
1118	cd UU
1119	echo "I presume that if # doesn't work, #! won't work either!"
1120	sharpbang=': use '
1121fi
1122rm -f try today
1123
1124: figure out how to guarantee sh startup
1125case "$startsh" in
1126'') startsh=${sharpbang}${sh} ;;
1127*)
1128esac
1129cat >try <<EOSS
1130$startsh
1131set abc
1132test "$?abc" != 1
1133EOSS
1134
1135chmod +x try
1136$eunicefix try
1137if ./try; then
1138	: echo "Yup, it does."
1139else
1140	echo "Hmm... '$startsh' does not guarantee sh startup..."
1141	echo "You may have to fix up the shell scripts to make sure $sh runs them."
1142fi
1143rm -f try
1144
1145
1146: Save command line options in file UU/cmdline.opt for later use in
1147: generating config.sh.
1148cat > cmdline.opt <<EOSH
1149# Configure command line arguments.
1150config_arg0='$0'
1151config_args='$*'
1152config_argc=$#
1153EOSH
1154argn=1
1155for arg in "$@"; do
1156	cat >>cmdline.opt <<EOSH
1157config_arg$argn='$arg'
1158EOSH
1159	argn=`expr $argn + 1`
1160done
1161
1162: produce awk script to parse command line options
1163cat >options.awk <<'EOF'
1164BEGIN {
1165	optstr = "A:dD:eEf:hKOrsSU:V";	# getopt-style specification
1166
1167	len = length(optstr);
1168	for (i = 1; i <= len; i++) {
1169		c = substr(optstr, i, 1);
1170		if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1171		if (a == ":") {
1172			arg[c] = 1;
1173			i++;
1174		}
1175		opt[c] = 1;
1176	}
1177}
1178{
1179	expect = 0;
1180	str = $0;
1181	if (substr(str, 1, 1) != "-") {
1182		printf("'%s'\n", str);
1183		next;
1184	}
1185	len = length($0);
1186	for (i = 2; i <= len; i++) {
1187		c = substr(str, i, 1);
1188		if (!opt[c]) {
1189			printf("-%s\n", substr(str, i));
1190			next;
1191		}
1192		printf("-%s\n", c);
1193		if (arg[c]) {
1194			if (i < len)
1195				printf("'%s'\n", substr(str, i + 1));
1196			else
1197				expect = 1;
1198			next;
1199		}
1200	}
1201}
1202END {
1203	if (expect)
1204		print "?";
1205}
1206EOF
1207
1208: process the command line options
1209set X `for arg in "$@"; do echo "X$arg"; done |
1210	sed -e s/X// | awk -f options.awk`
1211eval "set $*"
1212shift
1213rm -f options.awk
1214
1215: set up default values
1216fastread=''
1217reuseval=false
1218config_sh=''
1219alldone=''
1220error=''
1221silent=''
1222extractsh=''
1223override=''
1224knowitall=''
1225rm -f optdef.sh posthint.sh
1226cat >optdef.sh <<EOS
1227$startsh
1228EOS
1229
1230
1231: option parsing
1232while test $# -gt 0; do
1233	case "$1" in
1234	-d) shift; fastread=yes;;
1235	-e) shift; alldone=cont;;
1236	-f)
1237		shift
1238		cd ..
1239		if test -r "$1"; then
1240			config_sh="$1"
1241		else
1242			echo "$me: cannot read config file $1." >&2
1243			error=true
1244		fi
1245		cd UU
1246		shift;;
1247	-h) shift; error=true;;
1248	-r) shift; reuseval=true;;
1249	-s) shift; silent=true; realsilent=true;;
1250	-E) shift; alldone=exit;;
1251	-K) shift; knowitall=true;;
1252	-O) shift; override=true;;
1253	-S) shift; silent=true; extractsh=true;;
1254	-D)
1255		shift
1256		case "$1" in
1257		*=)
1258			echo "$me: use '-U symbol=', not '-D symbol='." >&2
1259			echo "$me: ignoring -D $1" >&2
1260			;;
1261		*=*) echo "$1" | \
1262				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1263		*) echo "$1='define'" >> optdef.sh;;
1264		esac
1265		shift
1266		;;
1267	-U)
1268		shift
1269		case "$1" in
1270		*=) echo "$1" >> optdef.sh;;
1271		*=*)
1272			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1273			echo "$me: ignoring -U $1" >&2
1274			;;
1275		*) echo "$1='undef'" >> optdef.sh;;
1276		esac
1277		shift
1278		;;
1279	-A)
1280	    shift
1281	    xxx=''
1282	    yyy="$1"
1283	    zzz=''
1284	    uuu=undef
1285	    case "$yyy" in
1286            *=*) zzz=`echo $yyy|sed 's!=.*!!'`
1287                 case "$zzz" in
1288                 *:*) zzz='' ;;
1289                 *)   xxx=append
1290                      zzz=" "`echo $yyy|sed 's!^[^=]*=!!'`
1291                      yyy=`echo $yyy|sed 's!=.*!!'` ;;
1292                 esac
1293                 ;;
1294            esac
1295            case "$xxx" in
1296            '')  case "$yyy" in
1297                 *:*) xxx=`echo $yyy|sed 's!:.*!!'`
1298                      yyy=`echo $yyy|sed 's!^[^:]*:!!'`
1299                      zzz=`echo $yyy|sed 's!^[^=]*=!!'`
1300                      yyy=`echo $yyy|sed 's!=.*!!'` ;;
1301                 *)   xxx=`echo $yyy|sed 's!:.*!!'`
1302                      yyy=`echo $yyy|sed 's!^[^:]*:!!'` ;;
1303                 esac
1304                 ;;
1305            esac
1306	    case "$xxx" in
1307	    append)
1308		echo "$yyy=\"\${$yyy}$zzz\""	>> posthint.sh ;;
1309	    clear)
1310		echo "$yyy=''"			>> posthint.sh ;;
1311	    define)
1312	        case "$zzz" in
1313		'') zzz=define ;;
1314		esac
1315		echo "$yyy='$zzz'"		>> posthint.sh ;;
1316	    eval)
1317		echo "eval \"$yyy=$zzz\""	>> posthint.sh ;;
1318	    prepend)
1319		echo "$yyy=\"$zzz\${$yyy}\""	>> posthint.sh ;;
1320	    undef)
1321	        case "$zzz" in
1322		'') zzz="$uuu" ;;
1323		esac
1324		echo "$yyy=$zzz"		>> posthint.sh ;;
1325            *)  echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1326	    esac
1327	    shift
1328	    ;;
1329	-V) echo "$me generated by metaconfig 3.0 PL70." >&2
1330	    exit 0;;
1331	--) break;;
1332	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
1333	*) break;;
1334	esac
1335done
1336
1337case "$error" in
1338true)
1339	cat >&2 <<EOM
1340Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1341                 [-U symbol] [-U symbol=] [-A command:symbol...]
1342  -d : use defaults for all answers.
1343  -e : go on without questioning past the production of config.sh.
1344  -f : specify an alternate default configuration file.
1345  -h : print this help message and exit (with an error status).
1346  -r : reuse C symbols value if possible (skips costly nm extraction).
1347  -s : silent mode, only echoes questions and essential information.
1348  -D : define symbol to have some value:
1349         -D symbol         symbol gets the value 'define'
1350         -D symbol=value   symbol gets the value 'value'
1351  -E : stop at the end of questions, after having produced config.sh.
1352  -K : do not use unless you know what you are doing.
1353  -O : let -D and -U override definitions from loaded configuration file.
1354  -S : perform variable substitutions on all .SH files (can mix with -f)
1355  -U : undefine symbol:
1356         -U symbol    symbol gets the value 'undef'
1357         -U symbol=   symbol gets completely empty
1358  -A : manipulate symbol after the platform specific hints have been applied:
1359	 -A symbol=value		append " "value to symbol
1360	 -A append:symbol=value		append value to symbol
1361	 -A define:symbol=value		define symbol to have value
1362         -A clear:symbol		define symbol to be ''
1363	 -A define:symbol		define symbol to be 'define'
1364	 -A eval:symbol=value		define symbol to be eval of value
1365	 -A prepend:symbol=value	prepend value to symbol
1366	 -A undef:symbol		define symbol to be 'undef'
1367	 -A undef:symbol=		define symbol to be ''
1368  -V : print version number and exit (with a zero status).
1369EOM
1370	exit 1
1371	;;
1372esac
1373
1374: Sanity checks
1375case "$fastread$alldone" in
1376yescont|yesexit) ;;
1377*)
1378	case "$extractsh" in
1379	true) ;;
1380	*)
1381		if test ! -t 0; then
1382			echo "Say 'sh Configure', not 'sh <Configure'"
1383			exit 1
1384		fi
1385		;;
1386	esac
1387	;;
1388esac
1389
1390exec 4>&1
1391case "$silent" in
1392true) exec 1>/dev/null;;
1393esac
1394
1395: run the defines and the undefines, if any, but leave the file out there...
1396touch optdef.sh
1397. ./optdef.sh
1398: create the posthint manipulation script and leave the file out there...
1399touch posthint.sh
1400
1401: set package name
1402package=perl5
1403first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1404last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1405case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1406ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1407*) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1408esac
1409
1410: Some greps do not return status, grrr.
1411echo "grimblepritz" >grimble
1412if grep blurfldyick grimble >/dev/null 2>&1 ; then
1413	contains=contains
1414elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1415	contains=grep
1416else
1417	contains=contains
1418fi
1419rm -f grimble
1420: the following should work in any shell
1421case "$contains" in
1422contains*)
1423	echo " "
1424	echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1425	cat >contains <<'EOSS'
1426grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1427EOSS
1428chmod +x contains
1429esac
1430
1431: Find the path to the source tree
1432case "$src" in
1433'') case "$0" in
1434    */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
1435         case "$src" in
1436	 /*)	;;
1437	 .)	;;
1438         *)	src=`cd ../$src && pwd` ;;
1439	 esac
1440         ;;
1441    *)   src='.';;
1442    esac;;
1443esac
1444case "$src" in
1445'')	src=/
1446	rsrc=/
1447	;;
1448/*) rsrc="$src";;
1449*) rsrc="../$src";;
1450esac
1451if test -f $rsrc/Configure && \
1452	$contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1453then
1454   : found it, so we are ok.
1455else
1456	rsrc=''
1457	for src in . .. ../.. ../../.. ../../../..; do
1458		if test -f ../$src/Configure && \
1459			$contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1460		then
1461			rsrc=../$src
1462			break
1463		fi
1464	done
1465fi
1466case "$rsrc" in
1467'')
1468	cat <<EOM >&4
1469
1470Sorry, I can't seem to locate the source dir for $package.  Please start
1471Configure with an explicit path -- i.e. /some/path/Configure.
1472
1473EOM
1474	exit 1
1475	;;
1476../.)	rsrc='..';;
1477*)
1478	echo " "
1479	echo "Sources for $package found in \"$src\"." >&4
1480	;;
1481esac
1482
1483: script used to extract .SH files with variable substitutions
1484cat >extract <<'EOS'
1485CONFIGDOTSH=true
1486echo "Doing variable substitutions on .SH files..."
1487if test -f $src/MANIFEST; then
1488	set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1489else
1490	echo "(Looking for .SH files under the source directory.)"
1491	set x `(cd $src; find . -name "*.SH" -print)`
1492fi
1493shift
1494case $# in
14950) set x `(cd $src; echo *.SH)`; shift;;
1496esac
1497if test ! -f $src/$1; then
1498	shift
1499fi
1500mkdir_p='
1501name=$1;
1502create="";
1503while test $name; do
1504	if test ! -d "$name"; then
1505		create="$name $create";
1506		name=`echo $name | sed -e "s|^[^/]*$||"`;
1507		name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1508	else
1509		name="";
1510	fi;
1511done;
1512for file in $create; do
1513	mkdir $file;
1514done
1515'
1516for file in $*; do
1517	case "$src" in
1518	".")
1519		case "$file" in
1520		*/*)
1521			dir=`expr X$file : 'X\(.*\)/'`
1522			file=`expr X$file : 'X.*/\(.*\)'`
1523			(cd $dir && . ./$file)
1524			;;
1525		*)
1526			. ./$file
1527			;;
1528		esac
1529		;;
1530	*)
1531		case "$file" in
1532		*/*)
1533			dir=`expr X$file : 'X\(.*\)/'`
1534			file=`expr X$file : 'X.*/\(.*\)'`
1535			(set x $dir; shift; eval $mkdir_p)
1536			sh <$src/$dir/$file
1537			;;
1538		*)
1539			sh <$src/$file
1540			;;
1541		esac
1542		;;
1543	esac
1544done
1545if test -f $src/config_h.SH; then
1546	if test ! -f config.h; then
1547	: oops, they left it out of MANIFEST, probably, so do it anyway.
1548	. $src/config_h.SH
1549	fi
1550fi
1551EOS
1552
1553: extract files and exit if asked to do so
1554case "$extractsh" in
1555true)
1556	case "$realsilent" in
1557	true) ;;
1558	*) exec 1>&4;;
1559	esac
1560	case "$config_sh" in
1561	'') config_sh='config.sh';;
1562	esac
1563	echo " "
1564	echo "Fetching answers from $config_sh..."
1565	cd ..
1566	. $config_sh
1567	test "$override" && . ./optdef.sh
1568	echo " "
1569	. UU/extract
1570	rm -rf UU
1571	echo "Done."
1572	exit 0
1573	;;
1574esac
1575
1576: Eunice requires " " instead of "", can you believe it
1577echo " "
1578: Here we go...
1579echo "Beginning of configuration questions for $package."
1580
1581trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1582
1583: first determine how to suppress newline on echo command
1584echo " "
1585echo "Checking echo to see how to suppress newlines..."
1586(echo "hi there\c" ; echo " ") >.echotmp
1587if $contains c .echotmp >/dev/null 2>&1 ; then
1588	echo "...using -n."
1589	n='-n'
1590	c=''
1591else
1592	cat <<'EOM'
1593...using \c
1594EOM
1595	n=''
1596	c='\c'
1597fi
1598echo $n "The star should be here-->$c"
1599echo '*'
1600rm -f .echotmp
1601
1602: Now test for existence of everything in MANIFEST
1603echo " "
1604if test -f $rsrc/MANIFEST; then
1605	echo "First let's make sure your kit is complete.  Checking..." >&4
1606	awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1607	rm -f missing
1608	tmppwd=`pwd`
1609	for filelist in x??; do
1610		(cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1611	done
1612	if test -s missing; then
1613		cat missing >&4
1614		cat >&4 <<'EOM'
1615
1616THIS PACKAGE SEEMS TO BE INCOMPLETE.
1617
1618You have the option of continuing the configuration process, despite the
1619distinct possibility that your kit is damaged, by typing 'y'es.  If you
1620do, don't blame me if something goes wrong.  I advise you to type 'n'o
1621and contact the author (perlbug@perl.org).
1622
1623EOM
1624		echo $n "Continue? [n] $c" >&4
1625		read ans
1626		case "$ans" in
1627		y*)
1628			echo "Continuing..." >&4
1629			rm -f missing
1630			;;
1631		*)
1632			echo "ABORTING..." >&4
1633			kill $$
1634			;;
1635		esac
1636	else
1637		echo "Looks good..."
1638	fi
1639else
1640	echo "There is no MANIFEST file.  I hope your kit is complete !"
1641fi
1642rm -f missing x??
1643
1644echo " "
1645: Find the appropriate value for a newline for tr
1646if test -n "$DJGPP"; then
1647       trnl='\012'
1648fi
1649if test X"$trnl" = X; then
1650	case "`echo foo|tr '\n' x 2>/dev/null`" in
1651	foox) trnl='\n' ;;
1652	esac
1653fi
1654if test X"$trnl" = X; then
1655	case "`echo foo|tr '\012' x 2>/dev/null`" in
1656	foox) trnl='\012' ;;
1657	esac
1658fi
1659if test X"$trnl" = X; then
1660	cat <<EOM >&2
1661
1662$me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1663
1664EOM
1665	exit 1
1666fi
1667
1668: compute the number of columns on the terminal for proper question formatting
1669case "$COLUMNS" in
1670'') COLUMNS='80';;
1671esac
1672
1673: set up the echo used in my read
1674myecho="case \"\$xxxm\" in
1675'') echo $n \"\$rp $c\" >&4;;
1676*) case \"\$rp\" in
1677	'') echo $n \"[\$xxxm] $c\";;
1678	*)
1679		if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1680			echo \"\$rp\" >&4
1681			echo $n \"[\$xxxm] $c\" >&4
1682		else
1683			echo $n \"\$rp [\$xxxm] $c\" >&4
1684		fi
1685		;;
1686	esac;;
1687esac"
1688
1689: now set up to do reads with possible shell escape and default assignment
1690cat <<EOSC >myread
1691$startsh
1692xxxm=\$dflt
1693$myecho
1694ans='!'
1695case "\$fastread" in
1696yes) case "\$dflt" in
1697	'') ;;
1698	*) ans='';
1699		case "\$silent-\$rp" in
1700		true-) ;;
1701		*) echo " " >&4;;
1702		esac;;
1703	esac;;
1704*) case "\$silent" in
1705	true) case "\$rp" in
1706		'') ans='';;
1707		esac;;
1708	esac;;
1709esac
1710while expr "X\$ans" : "X!" >/dev/null; do
1711	read answ
1712	set x \$xxxm
1713	shift
1714	aok=''; eval "ans=\\"\$answ\\"" && aok=y
1715	case  "\$answ" in
1716	"!")
1717		sh 1>&4
1718		echo " "
1719		$myecho
1720		;;
1721	!*)
1722		set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1723		shift
1724		sh 1>&4 -c "\$*"
1725		echo " "
1726		$myecho
1727		;;
1728	"\$ans")
1729		case "\$ans" in
1730		\\&*)
1731			set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1732			shift
1733			case "\$1" in
1734			-d)
1735				fastread=yes
1736				echo "(OK, I'll run with -d after this question.)" >&4
1737				;;
1738			-*)
1739				echo "*** Sorry, \$1 not supported yet." >&4
1740				;;
1741			esac
1742			$myecho
1743			ans=!
1744			;;
1745		esac;;
1746	*)
1747		case "\$aok" in
1748		y)
1749			echo "*** Substitution done -- please confirm."
1750			xxxm="\$ans"
1751			ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1752			xxxm="\$ans"
1753			ans=!
1754			;;
1755		*)
1756			echo "*** Error -- try again."
1757			ans=!
1758			;;
1759		esac
1760		$myecho
1761		;;
1762	esac
1763	case "\$ans\$xxxm\$nostick" in
1764	'')
1765		ans=!
1766		$myecho
1767		;;
1768	esac
1769done
1770case "\$ans" in
1771'') ans="\$xxxm";;
1772esac
1773EOSC
1774
1775: create .config dir to save info across Configure sessions
1776test -d ../.config || mkdir ../.config
1777cat >../.config/README <<EOF
1778This directory created by Configure to save information that should
1779persist across sessions for $package.
1780
1781You may safely delete it if you wish.
1782EOF
1783
1784xversion=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
1785case "$usedevel" in
1786$define|true|[yY]*) ;;
1787*) case "$xversion" in
1788   *[13579])
1789	cat >&4 <<EOH
1790*** WHOA THERE!!! ***
1791
1792    This is an UNSTABLE DEVELOPMENT release.
1793    The version of this $package distribution is $xversion, that is, odd,
1794    (as opposed to even) and that signifies a development release.
1795    If you want a maintenance release, you want an even-numbered version.
1796
1797    Do ***NOT*** install this into production use.
1798    Data corruption and crashes are possible.
1799
1800    It is most seriously suggested that you do not continue any further
1801    unless you want to help in developing and debugging Perl.
1802
1803    If you *still* want to build perl, you can answer 'y' now,
1804    or pass -Dusedevel to Configure.
1805
1806EOH
1807	rp='Do you really want to continue?'
1808	dflt='n'
1809	. ./myread
1810	case "$ans" in
1811	[yY]) echo >&4 "Okay, continuing." ;;
1812	*) echo >&4 "Okay, bye."
1813	   exit 1
1814	   ;;
1815	esac
1816	;;
1817    esac
1818    ;;
1819esac
1820
1821: general instructions
1822needman=true
1823firsttime=true
1824user=`(logname) 2>/dev/null`
1825case "$user" in
1826'') user=`whoami 2>&1`;;
1827esac
1828if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1829	firsttime=false
1830	echo " "
1831	rp='Would you like to see the instructions?'
1832	dflt=n
1833	. ./myread
1834	case "$ans" in
1835	[yY]*) ;;
1836	*) needman=false;;
1837	esac
1838fi
1839if $needman; then
1840	cat <<EOH
1841
1842This installation shell script will examine your system and ask you questions
1843to determine how the perl5 package should be installed. If you get
1844stuck on a question, you may use a ! shell escape to start a subshell or
1845execute a command.  Many of the questions will have default answers in square
1846brackets; typing carriage return will give you the default.
1847
1848On some of the questions which ask for file or directory names you are allowed
1849to use the ~name construct to specify the login directory belonging to "name",
1850even if you don't have a shell which knows about that.  Questions where this is
1851allowed will be marked "(~name ok)".
1852
1853EOH
1854	rp=''
1855	dflt='Type carriage return to continue'
1856	. ./myread
1857	cat <<'EOH'
1858
1859The prompter used in this script allows you to use shell variables and
1860backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1861in the default answer, as if the default line was a set of arguments given to a
1862script shell.  This means you may also use $* to repeat the whole default line,
1863so you do not have to re-type everything to add something to the default.
1864
1865Everytime there is a substitution, you will have to confirm.  If there is an
1866error (e.g. an unmatched backtick), the default answer will remain unchanged
1867and you will be prompted again.
1868
1869If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1870the questions and use the computed defaults (or the previous answers if there
1871was already a config.sh file). Type 'Configure -h' for a list of options.
1872You may also start interactively and then answer '& -d' at any prompt to turn
1873on the non-interactive behaviour for the remainder of the execution.
1874
1875EOH
1876	. ./myread
1877	cat <<EOH
1878
1879Much effort has been expended to ensure that this shell script will run on any
1880Unix system.  If despite that it blows up on yours, your best bet is to edit
1881Configure and run it again.  If you can't run Configure for some reason,
1882you'll have to generate a config.sh file by hand.  Whatever problems you
1883have, let me (perlbug@perl.org) know how I blew it.
1884
1885This installation script affects things in two ways:
1886
18871) it may do direct variable substitutions on some of the files included
1888   in this kit.
18892) it builds a config.h file for inclusion in C programs.  You may edit
1890   any of these files as the need arises after running this script.
1891
1892If you make a mistake on a question, there is no easy way to back up to it
1893currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1894files.  Configure will offer to let you do this before it runs the SH files.
1895
1896EOH
1897	dflt='Type carriage return to continue'
1898	. ./myread
1899	case "$firsttime" in
1900	true) echo $user >>../.config/instruct;;
1901	esac
1902fi
1903
1904: find out where common programs are
1905echo " "
1906echo "Locating common programs..." >&4
1907cat <<EOSC >loc
1908$startsh
1909case \$# in
19100) exit 1;;
1911esac
1912thing=\$1
1913shift
1914dflt=\$1
1915shift
1916for dir in \$*; do
1917	case "\$thing" in
1918	.)
1919	if test -d \$dir/\$thing; then
1920		echo \$dir
1921		exit 0
1922	fi
1923	;;
1924	*)
1925	for thisthing in \$dir/\$thing; do
1926		: just loop through to pick last item
1927	done
1928	if test -f \$thisthing; then
1929		echo \$thisthing
1930		exit 0
1931	elif test -f \$dir/\$thing.exe; then
1932		if test -n "$DJGPP"; then
1933			echo \$dir/\$thing.exe
1934		else
1935			: on Eunice apparently
1936			echo \$dir/\$thing
1937		fi
1938		exit 0
1939	fi
1940	;;
1941	esac
1942done
1943echo \$dflt
1944exit 1
1945EOSC
1946chmod +x loc
1947$eunicefix loc
1948loclist="
1949awk
1950cat
1951comm
1952cp
1953echo
1954expr
1955grep
1956ls
1957make
1958mkdir
1959rm
1960sed
1961sort
1962touch
1963tr
1964uniq
1965"
1966trylist="
1967Mcc
1968ar
1969bison
1970byacc
1971cpp
1972csh
1973date
1974egrep
1975gzip
1976less
1977ln
1978more
1979nm
1980nroff
1981pg
1982test
1983uname
1984zip
1985"
1986pth=`echo $PATH | sed -e "s/$p_/ /g"`
1987pth="$pth /lib /usr/lib"
1988for file in $loclist; do
1989	eval xxx=\$$file
1990	case "$xxx" in
1991	/*|?:[\\/]*)
1992		if test -f "$xxx"; then
1993			: ok
1994		else
1995			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1996			xxx=`./loc $file $file $pth`
1997		fi
1998		;;
1999	'') xxx=`./loc $file $file $pth`;;
2000	*) xxx=`./loc $xxx $xxx $pth`;;
2001	esac
2002	eval $file=$xxx
2003	eval _$file=$xxx
2004	case "$xxx" in
2005	/*)
2006		echo $file is in $xxx.
2007		;;
2008	?:[\\/]*)
2009		echo $file is in $xxx.
2010		;;
2011	*)
2012		echo "I don't know where '$file' is, and my life depends on it." >&4
2013		echo "Go find a public domain implementation or fix your PATH setting!" >&4
2014		exit 1
2015		;;
2016	esac
2017done
2018echo " "
2019echo "Don't worry if any of the following aren't found..."
2020say=offhand
2021for file in $trylist; do
2022	eval xxx=\$$file
2023	case "$xxx" in
2024	/*|?:[\\/]*)
2025		if test -f "$xxx"; then
2026			: ok
2027		else
2028			echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2029			xxx=`./loc $file $file $pth`
2030		fi
2031		;;
2032	'') xxx=`./loc $file $file $pth`;;
2033	*) xxx=`./loc $xxx $xxx $pth`;;
2034	esac
2035	eval $file=$xxx
2036	eval _$file=$xxx
2037	case "$xxx" in
2038	/*)
2039		echo $file is in $xxx.
2040		;;
2041	?:[\\/]*)
2042		echo $file is in $xxx.
2043		;;
2044	*)
2045		echo "I don't see $file out there, $say."
2046		say=either
2047		;;
2048	esac
2049done
2050case "$egrep" in
2051egrep)
2052	echo "Substituting grep for egrep."
2053	egrep=$grep
2054	;;
2055esac
2056case "$ln" in
2057ln)
2058	echo "Substituting cp for ln."
2059	ln=$cp
2060	;;
2061esac
2062case "$test" in
2063test)
2064	echo "Hopefully test is built into your sh."
2065	;;
2066*)
2067	if `sh -c "PATH= test true" >/dev/null 2>&1`; then
2068		echo "Using the test built into your sh."
2069		echo "Using the test built into your sh."
2070		test=test
2071		_test=test
2072	fi
2073	;;
2074esac
2075case "$echo" in
2076echo)
2077	echo "Hopefully echo is built into your sh."
2078	;;
2079'') ;;
2080*)
2081	echo " "
2082echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
2083	$echo $n "hi there$c" >foo1
2084	echo $n "hi there$c" >foo2
2085	if cmp foo1 foo2 >/dev/null 2>&1; then
2086		echo "They are compatible.  In fact, they may be identical."
2087	else
2088		case "$n" in
2089		'-n') n='' c='\c';;
2090		*) n='-n' c='';;
2091		esac
2092		cat <<FOO
2093They are not compatible!  You are probably running ksh on a non-USG system.
2094I'll have to use $echo instead of the builtin, since Bourne shell doesn't
2095have echo built in and we may have to run some Bourne shell scripts.  That
2096means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
2097
2098FOO
2099		$echo $n "The star should be here-->$c"
2100		$echo "*"
2101	fi
2102	$rm -f foo1 foo2
2103	;;
2104esac
2105
2106cat <<EOS >checkcc
2107$startsh
2108EOS
2109cat <<'EOSC' >>checkcc
2110case "$cc" in
2111'') ;;
2112*)  $rm -f try try.*
2113    $cat >try.c <<EOM
2114int main(int argc, char *argv[]) {
2115  return 0;
2116}
2117EOM
2118    if $cc -o try $ccflags try.c; then
2119       :
2120    else
2121        echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2122        despair=yes
2123        trygcc=yes
2124        case "$cc" in
2125        *gcc*) trygcc=no ;;
2126        esac
2127        case "`$cc -v -c try.c 2>&1`" in
2128        *gcc*) trygcc=no ;;
2129        esac
2130        if $test X"$trygcc" = Xyes; then
2131            if gcc -o try -c try.c; then
2132                echo " "
2133                echo "You seem to have a working gcc, though." >&4
2134                rp="Would you like to use it?"
2135                dflt=y
2136                if $test -f myread; then
2137                    . ./myread
2138                else
2139                    if $test -f UU/myread; then
2140                        . ./UU/myread
2141                    else
2142                        echo "Cannot find myread, sorry.  Aborting." >&2
2143                        exit 1
2144                    fi
2145                fi
2146                case "$ans" in
2147                [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no ;;
2148                esac
2149            fi
2150        fi
2151        if $test X"$despair" = Xyes; then
2152	    $cat >&4 <<EOM
2153You need to find a working C compiler.
2154Either (purchase and) install the C compiler supplied by your OS vendor,
2155or for a free C compiler try http://gcc.gnu.org/
2156I cannot continue any further, aborting.
2157EOM
2158            exit 1
2159        fi
2160    fi
2161    $rm -f try try.*
2162    ;;
2163esac
2164EOSC
2165
2166: determine whether symbolic links are supported
2167echo " "
2168$touch blurfl
2169if $ln -s blurfl sym > /dev/null 2>&1 ; then
2170	echo "Symbolic links are supported." >&4
2171	lns="$ln -s"
2172else
2173	echo "Symbolic links are NOT supported." >&4
2174	lns="$ln"
2175fi
2176$rm -f blurfl sym
2177
2178: determine whether symbolic links are supported
2179echo " "
2180case "$lns" in
2181*"ln -s")
2182	echo "Checking how to test for symbolic links..." >&4
2183	$lns blurfl sym
2184	if $test "X$issymlink" = X; then
2185		sh -c "PATH= test -h sym" >/dev/null 2>&1
2186		if test $? = 0; then
2187			issymlink="test -h"
2188		fi
2189	fi
2190	if $test "X$issymlink" = X; then
2191		if  $test -h >/dev/null 2>&1; then
2192			issymlink="$test -h"
2193			echo "Your builtin 'test -h' may be broken, I'm using external '$test -h'." >&4
2194		fi
2195	fi
2196	if $test "X$issymlink" = X; then
2197		if $test -L sym 2>/dev/null; then
2198			issymlink="$test -L"
2199		fi
2200	fi
2201	if $test "X$issymlink" != X; then
2202		echo "You can test for symbolic links with '$issymlink'." >&4
2203	else
2204		echo "I do not know how you can test for symbolic links." >&4
2205	fi
2206	$rm -f blurfl sym
2207	;;
2208*)	echo "No symbolic links, so not testing for their testing..." >&4
2209	;;
2210esac
2211echo " "
2212
2213
2214case "$mksymlinks" in
2215$define|true|[yY]*)
2216	case "$src" in
2217	''|'.')	echo "Cannot create symlinks in the original directory." >&4
2218		exit 1
2219		;;
2220	*)	case "$lns:$issymlink" in
2221		*"ln -s:"*"test -"?)
2222			echo "Creating the symbolic links..." >&4
2223			echo "(First creating the subdirectories...)" >&4
2224			cd ..
2225			awk '{print $1}' $src/MANIFEST | grep / | sed 's:/[^/]*$::' | sort -u | while true; do
2226				read directory
2227				test -z "$directory" && break
2228				mkdir -p $directory
2229			done
2230			# Sanity check 1.
2231			if test ! -d t/base; then
2232				echo "Failed to create the subdirectories.  Aborting." >&4
2233				exit 1
2234			fi
2235			echo "(Then creating the symlinks...)" >&4
2236			awk '{print $1}' $src/MANIFEST | while true; do
2237				read filename
2238				test -z "$filename" && break
2239				if test -f $filename; then
2240					if $issymlink $filename; then
2241						rm -f $filename
2242					fi
2243				fi
2244				if test -f $filename; then
2245					echo "$filename already exists, not symlinking."
2246				else
2247					ln -s $src/$filename $filename
2248				fi
2249			done
2250			# Sanity check 2.
2251			if test ! -f t/base/cond.t; then
2252				echo "Failed to create the symlinks.  Aborting." >&4
2253				exit 1
2254			fi
2255			cd UU
2256			;;
2257		*)	echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
2258			;;
2259		esac
2260		;;
2261	esac
2262	;;
2263esac
2264
2265: see whether [:lower:] and [:upper:] are supported character classes
2266echo " "
2267case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
2268ABYZ)
2269	echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
2270	up='[:upper:]'
2271	low='[:lower:]'
2272	;;
2273*)	# There is a discontinuity in EBCDIC between 'I' and 'J'
2274        # (0xc9 and 0xd1), therefore that is a nice testing point.
2275        if test "X$up" = X -o "X$low" = X; then
2276	    case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
2277	    ij) up='[A-Z]'
2278	        low='[a-z]'
2279		;;
2280	    esac
2281        fi
2282	if test "X$up" = X -o "X$low" = X; then
2283	    case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
2284	    ij) up='A-Z'
2285		low='a-z'
2286		;;
2287	    esac
2288        fi
2289	if test "X$up" = X -o "X$low" = X; then
2290	    case "`echo IJ | od -x 2>/dev/null`" in
2291	    *C9D1*|*c9d1*)
2292		echo "Hey, this might be EBCDIC." >&4
2293		if test "X$up" = X -o "X$low" = X; then
2294		    case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
2295		    ij) up='[A-IJ-RS-Z]'
2296		        low='[a-ij-rs-z]'
2297			;;
2298		    esac
2299		fi
2300		if test "X$up" = X -o "X$low" = X; then
2301		    case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
2302		    ij) up='A-IJ-RS-Z'
2303		        low='a-ij-rs-z'
2304			;;
2305		    esac
2306		fi
2307		;;
2308	    esac
2309	fi
2310esac
2311case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
2312ij)
2313    echo "Using $up and $low to convert case." >&4
2314    ;;
2315*)
2316    echo "I don't know how to translate letters from upper to lower case." >&4
2317    echo "Your tr is not acting any way I know of." >&4
2318    exit 1
2319    ;;
2320esac
2321: set up the translation script tr, must be called with ./tr of course
2322cat >tr <<EOSC
2323$startsh
2324case "\$1\$2" in
2325'[A-Z][a-z]') exec $tr '$up' '$low';;
2326'[a-z][A-Z]') exec $tr '$low' '$up';;
2327esac
2328exec $tr "\$@"
2329EOSC
2330chmod +x tr
2331$eunicefix tr
2332
2333: Try to determine whether config.sh was made on this system
2334case "$config_sh" in
2335'')
2336myuname=`$uname -a 2>/dev/null`
2337$test -z "$myuname" && myuname=`hostname 2>/dev/null`
2338# tr '[A-Z]' '[a-z]' would not work in EBCDIC
2339# because the A-Z/a-z are not consecutive.
2340myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
2341	./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
2342newmyuname="$myuname"
2343dflt=n
2344case "$knowitall" in
2345'')
2346	if test -f ../config.sh; then
2347		if $contains myuname= ../config.sh >/dev/null 2>&1; then
2348			eval "`grep myuname= ../config.sh`"
2349		fi
2350		if test "X$myuname" = "X$newmyuname"; then
2351			dflt=y
2352		fi
2353	fi
2354	;;
2355*) dflt=y;;
2356esac
2357
2358: Get old answers from old config file if Configure was run on the
2359: same system, otherwise use the hints.
2360hint=default
2361cd ..
2362if test -f config.sh; then
2363	echo " "
2364	rp="I see a config.sh file.  Shall I use it to set the defaults?"
2365	. UU/myread
2366	case "$ans" in
2367	n*|N*) echo "OK, I'll ignore it."
2368		mv config.sh config.sh.old
2369		myuname="$newmyuname"
2370		;;
2371	*)  echo "Fetching default answers from your old config.sh file..." >&4
2372		tmp_n="$n"
2373		tmp_c="$c"
2374		tmp_sh="$sh"
2375		. ./config.sh
2376		cp config.sh UU
2377		n="$tmp_n"
2378		c="$tmp_c"
2379		: Older versions did not always set $sh.  Catch re-use of such
2380		: an old config.sh.
2381		case "$sh" in
2382		'') sh="$tmp_sh" ;;
2383		esac
2384		hint=previous
2385		;;
2386	esac
2387fi
2388. ./UU/checkcc
2389if test ! -f config.sh; then
2390	$cat <<EOM
2391
2392First time through, eh?  I have some defaults handy for some systems
2393that need some extra help getting the Configure answers right:
2394
2395EOM
2396	(cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2397	dflt=''
2398	: Half the following guesses are probably wrong... If you have better
2399	: tests or hints, please send them to perlbug@perl.org
2400	: The metaconfig authors would also appreciate a copy...
2401	$test -f /irix && osname=irix
2402	$test -f /xenix && osname=sco_xenix
2403	$test -f /dynix && osname=dynix
2404	$test -f /dnix && osname=dnix
2405	$test -f /lynx.os && osname=lynxos
2406	$test -f /unicos && osname=unicos && osvers=`$uname -r`
2407	$test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
2408	$test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2409	$test -f /bin/mips && /bin/mips && osname=mips
2410	$test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2411		$sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2412	$test -d /usr/apollo/bin && osname=apollo
2413	$test -f /etc/saf/_sactab && osname=svr4
2414	$test -d /usr/include/minix && osname=minix
2415	if $test -d /MachTen -o -d /MachTen_Folder; then
2416		osname=machten
2417		if $test -x /sbin/version; then
2418			osvers=`/sbin/version | $awk '{print $2}' |
2419			$sed -e 's/[A-Za-z]$//'`
2420		elif $test -x /usr/etc/version; then
2421			osvers=`/usr/etc/version | $awk '{print $2}' |
2422			$sed -e 's/[A-Za-z]$//'`
2423		else
2424			osvers="$2.$3"
2425		fi
2426	fi
2427
2428	$test -f /sys/posix.dll &&
2429		$test -f /usr/bin/what &&
2430		set X `/usr/bin/what /sys/posix.dll` &&
2431		$test "$3" = UWIN &&
2432		osname=uwin &&
2433		osvers="$5"
2434
2435	if $test -f $uname; then
2436		set X $myuname
2437		shift
2438
2439		case "$5" in
2440		fps*) osname=fps ;;
2441		mips*)
2442			case "$4" in
2443			umips) osname=umips ;;
2444			*) osname=mips ;;
2445			esac;;
2446		[23]100) osname=mips ;;
2447		next*) osname=next ;;
2448		i386*)
2449			tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2450			if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2451				osname='sco'
2452				osvers=$tmp
2453			elif $test -f /etc/kconfig; then
2454				osname=isc
2455				if test "$lns" = "$ln -s"; then
2456					osvers=4
2457				elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2458					osvers=3
2459				elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2460					osvers=2
2461				fi
2462			fi
2463			tmp=''
2464			;;
2465		pc*)
2466			if test -n "$DJGPP"; then
2467				osname=dos
2468				osvers=djgpp
2469			fi
2470			;;
2471		esac
2472
2473		case "$1" in
2474		aix) osname=aix
2475			tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2476			case "$tmp" in
2477			'not found') osvers="$4"."$3" ;;
2478			'<3240'|'<>3240') osvers=3.2.0 ;;
2479			'=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2480			'=3250'|'>3250') osvers=3.2.5 ;;
2481			*) osvers=$tmp;;
2482			esac
2483			;;
2484		bsd386) osname=bsd386
2485			osvers=`$uname -r`
2486			;;
2487		cygwin*) osname=cygwin
2488			osvers="$3"
2489			;;
2490		*dc.osx) osname=dcosx
2491			osvers="$3"
2492			;;
2493		dnix) osname=dnix
2494			osvers="$3"
2495			;;
2496		domainos) osname=apollo
2497			osvers="$3"
2498			;;
2499		dgux) osname=dgux
2500			osvers="$3"
2501			;;
2502		dynixptx*) osname=dynixptx
2503			osvers=`echo "$4"|sed 's/^v//'`
2504			;;
2505		freebsd) osname=freebsd
2506			osvers="$3" ;;
2507		genix) osname=genix ;;
2508		hp*) osname=hpux
2509			osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2510			;;
2511		irix*) osname=irix
2512			case "$3" in
2513			4*) osvers=4 ;;
2514			5*) osvers=5 ;;
2515			*)	osvers="$3" ;;
2516			esac
2517			;;
2518		linux) osname=linux
2519			case "$3" in
2520			*)	osvers="$3" ;;
2521			esac
2522			;;
2523		MiNT) osname=mint
2524			;;
2525		netbsd*) osname=netbsd
2526			osvers="$3"
2527			;;
2528		news-os) osvers="$3"
2529			case "$3" in
2530			4*) osname=newsos4 ;;
2531			*) osname=newsos ;;
2532			esac
2533			;;
2534		next*) osname=next ;;
2535		nonstop-ux) osname=nonstopux ;;
2536		POSIX-BC | posix-bc ) osname=posix-bc
2537			osvers="$3"
2538			;;
2539		powerux | power_ux | powermax_os | powermaxos | \
2540		powerunix | power_unix) osname=powerux
2541			osvers="$3"
2542			;;
2543		qnx) osname=qnx
2544			osvers="$4"
2545			;;
2546		solaris) osname=solaris
2547			case "$3" in
2548			5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2549			*)	osvers="$3" ;;
2550			esac
2551			;;
2552		sunos) osname=sunos
2553			case "$3" in
2554			5*) osname=solaris
2555				osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2556			*)	osvers="$3" ;;
2557			esac
2558			;;
2559		titanos) osname=titanos
2560			case "$3" in
2561			1*) osvers=1 ;;
2562			2*) osvers=2 ;;
2563			3*) osvers=3 ;;
2564			4*) osvers=4 ;;
2565			*)	osvers="$3" ;;
2566			esac
2567			;;
2568		ultrix) osname=ultrix
2569			osvers="$3"
2570			;;
2571		osf1|mls+)	case "$5" in
2572				alpha)
2573					osname=dec_osf
2574					osvers=`echo "$3" | sed 's/^[xvt]//'`
2575					;;
2576			hp*)	osname=hp_osf1	;;
2577			mips)	osname=mips_osf1 ;;
2578			esac
2579			;;
2580		unixware) osname=svr5
2581			osvers="$4"
2582			;;
2583		uts) osname=uts
2584			osvers="$3"
2585			;;
2586		$2) case "$osname" in
2587			*isc*) ;;
2588			*freebsd*) ;;
2589			svr*)
2590				: svr4.x or possibly later
2591				case "svr$3" in
2592				${osname}*)
2593					osname=svr$3
2594					osvers=$4
2595					;;
2596				esac
2597				case "$osname" in
2598				svr4.0)
2599					: Check for ESIX
2600					if test -f /stand/boot ; then
2601						eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2602						if test -n "$INITPROG" -a -f "$INITPROG"; then
2603			isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2604							if test -n "$isesix"; then
2605								osname=esix4
2606							fi
2607						fi
2608					fi
2609					;;
2610				esac
2611				;;
2612			*)	if test -f /etc/systemid; then
2613					osname=sco
2614					set `echo $3 | $sed 's/\./ /g'` $4
2615					if $test -f $src/hints/sco_$1_$2_$3.sh; then
2616						osvers=$1.$2.$3
2617					elif $test -f $src/hints/sco_$1_$2.sh; then
2618						osvers=$1.$2
2619					elif $test -f $src/hints/sco_$1.sh; then
2620						osvers=$1
2621					fi
2622				else
2623					case "$osname" in
2624					'') : Still unknown.  Probably a generic Sys V.
2625						osname="sysv"
2626						osvers="$3"
2627						;;
2628					esac
2629				fi
2630				;;
2631			esac
2632			;;
2633		*)	case "$osname" in
2634			'') : Still unknown.  Probably a generic BSD.
2635				osname="$1"
2636				osvers="$3"
2637				;;
2638			esac
2639			;;
2640		esac
2641	else
2642		if test -f /vmunix -a -f $src/hints/news_os.sh; then
2643			(what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2644			if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2645				osname=news_os
2646			fi
2647			$rm -f UU/kernel.what
2648		elif test -d c:/.; then
2649			set X $myuname
2650			osname=os2
2651			osvers="$5"
2652		fi
2653	fi
2654
2655	: Now look for a hint file osname_osvers, unless one has been
2656	: specified already.
2657	case "$hintfile" in
2658	''|' ')
2659		file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'`
2660		: Also try without trailing minor version numbers.
2661		xfile=`echo $file | $sed -e 's%_[^_]*$%%'`
2662		xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'`
2663		xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'`
2664		xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'`
2665		case "$file" in
2666		'') dflt=none ;;
2667		*)  case "$osvers" in
2668			'') dflt=$file
2669				;;
2670			*)  if $test -f $src/hints/$file.sh ; then
2671					dflt=$file
2672				elif $test -f $src/hints/$xfile.sh ; then
2673					dflt=$xfile
2674				elif $test -f $src/hints/$xxfile.sh ; then
2675					dflt=$xxfile
2676				elif $test -f $src/hints/$xxxfile.sh ; then
2677					dflt=$xxxfile
2678				elif $test -f $src/hints/$xxxxfile.sh ; then
2679					dflt=$xxxxfile
2680				elif $test -f "$src/hints/${osname}.sh" ; then
2681					dflt="${osname}"
2682				else
2683					dflt=none
2684				fi
2685				;;
2686			esac
2687			;;
2688		esac
2689		if $test -f Policy.sh ; then
2690			case "$dflt" in
2691			*Policy*) ;;
2692			none) dflt="Policy" ;;
2693			*) dflt="Policy $dflt" ;;
2694			esac
2695		fi
2696		;;
2697	*)
2698		dflt=`echo $hintfile | $sed 's/\.sh$//'`
2699		;;
2700	esac
2701
2702	if $test -f Policy.sh ; then
2703		$cat <<EOM
2704
2705There's also a Policy hint file available, which should make the
2706site-specific (policy) questions easier to answer.
2707EOM
2708
2709	fi
2710
2711	$cat <<EOM
2712
2713You may give one or more space-separated answers, or "none" if appropriate.
2714A well-behaved OS will have no hints, so answering "none" or just "Policy"
2715is a good thing.  DO NOT give a wrong version or a wrong OS.
2716
2717EOM
2718
2719	rp="Which of these apply, if any?"
2720	. UU/myread
2721	tans=$ans
2722	for file in $tans; do
2723		if $test X$file = XPolicy -a -f Policy.sh; then
2724			. Policy.sh
2725			$cat Policy.sh >> UU/config.sh
2726		elif $test -f $src/hints/$file.sh; then
2727			. $src/hints/$file.sh
2728			$cat $src/hints/$file.sh >> UU/config.sh
2729		elif $test X$tans = X -o X$tans = Xnone ; then
2730			: nothing
2731		else
2732			: Give one chance to correct a possible typo.
2733			echo "$file.sh does not exist"
2734			dflt=$file
2735			rp="hint to use instead?"
2736			. UU/myread
2737			for file in $ans; do
2738				if $test -f "$src/hints/$file.sh"; then
2739					. $src/hints/$file.sh
2740					$cat $src/hints/$file.sh >> UU/config.sh
2741				elif $test X$ans = X -o X$ans = Xnone ; then
2742					: nothing
2743				else
2744					echo "$file.sh does not exist -- ignored."
2745				fi
2746			done
2747		fi
2748	done
2749
2750	hint=recommended
2751	: Remember our hint file for later.
2752	if $test -f "$src/hints/$file.sh" ; then
2753		hintfile="$file"
2754	else
2755		hintfile=''
2756	fi
2757fi
2758cd UU
2759;;
2760*)
2761	echo " "
2762	echo "Fetching default answers from $config_sh..." >&4
2763	tmp_n="$n"
2764	tmp_c="$c"
2765	cd ..
2766	cp $config_sh config.sh 2>/dev/null
2767	chmod +w config.sh
2768	. ./config.sh
2769	cd UU
2770	cp ../config.sh .
2771	n="$tmp_n"
2772	c="$tmp_c"
2773	hint=previous
2774	;;
2775esac
2776test "$override" && . ./optdef.sh
2777
2778: Restore computed paths
2779for file in $loclist $trylist; do
2780	eval $file="\$_$file"
2781done
2782
2783cat << EOM
2784
2785Configure uses the operating system name and version to set some defaults.
2786The default value is probably right if the name rings a bell. Otherwise,
2787since spelling matters for me, either accept the default or answer "none"
2788to leave it blank.
2789
2790EOM
2791case "$osname" in
2792	''|' ')
2793		case "$hintfile" in
2794		''|' '|none) dflt=none ;;
2795		*)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2796		esac
2797		;;
2798	*) dflt="$osname" ;;
2799esac
2800rp="Operating system name?"
2801. ./myread
2802case "$ans" in
2803none)  osname='' ;;
2804*) osname=`echo "$ans" | $sed -e 's/[ 	][	]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2805esac
2806echo " "
2807case "$osvers" in
2808	''|' ')
2809		case "$hintfile" in
2810		''|' '|none) dflt=none ;;
2811		*)	dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2812			dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2813			case "$dflt" in
2814			''|' ') dflt=none ;;
2815			esac
2816			;;
2817		esac
2818		;;
2819	*) dflt="$osvers" ;;
2820esac
2821rp="Operating system version?"
2822. ./myread
2823case "$ans" in
2824none)  osvers='' ;;
2825*) osvers="$ans" ;;
2826esac
2827
2828
2829. ./posthint.sh
2830
2831: who configured the system
2832cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2833cf_by=`(logname) 2>/dev/null`
2834case "$cf_by" in
2835"")
2836	cf_by=`(whoami) 2>/dev/null`
2837	case "$cf_by" in
2838	"") cf_by=unknown ;;
2839	esac ;;
2840esac
2841
2842: set up the script used to warn in case of inconsistency
2843cat <<EOS >whoa
2844$startsh
2845EOS
2846cat <<'EOSC' >>whoa
2847dflt=y
2848echo " "
2849echo "*** WHOA THERE!!! ***" >&4
2850echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2851rp="    Keep the $hint value?"
2852. ./myread
2853case "$ans" in
2854y) td=$was; tu=$was;;
2855esac
2856EOSC
2857
2858: function used to set $1 to $val
2859setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2860case "$val$was" in
2861$define$undef) . ./whoa; eval "$var=\$td";;
2862$undef$define) . ./whoa; eval "$var=\$tu";;
2863*) eval "$var=$val";;
2864esac'
2865
2866case "$usethreads" in
2867$define|true|[yY]*)     dflt='y';;
2868*) dflt='n';;
2869esac
2870cat <<EOM
2871
2872Perl can be built to take advantage of threads on some systems.
2873To do so, Configure can be run with -Dusethreads.
2874
2875Note that threading is a highly experimental feature, and
2876some known race conditions still remain.  If you choose to try
2877it, be very sure to not actually deploy it for production
2878purposes.  README.threads has more details, and is required
2879reading if you enable threads.
2880
2881If this doesn't make any sense to you, just accept the default '$dflt'.
2882EOM
2883rp='Build a threading Perl?'
2884. ./myread
2885case "$ans" in
2886y|Y)    val="$define" ;;
2887*)      val="$undef" ;;
2888esac
2889set usethreads
2890eval $setvar
2891
2892case "$usethreads" in
2893$define)
2894	$cat <<EOM
2895
2896As of 5.5.640, Perl has two different internal threading implementations,
2897the 5.005 version (5005threads) and an interpreter-based version
2898(ithreads) that has one interpreter per thread.  Both are very
2899experimental.  This arrangement exists to help developers work out
2900which one is better.
2901
2902If you're a casual user, you probably don't want interpreter-threads
2903at this time.  There doesn't yet exist a way to create threads from
2904within Perl in this model, i.e., "use Thread;" will NOT work.
2905EOM
2906	: Default to ithreads unless overridden on command line or with
2907	: old config.sh
2908	dflt='y'
2909	case "$use5005threads" in
2910		$define|true|[yY]*) dflt='n';;
2911	esac
2912	case "$useithreads" in
2913		$undef|false|[nN]*) dflt='n';;
2914	esac
2915	rp='Use interpreter-based ithreads?'
2916	. ./myread
2917	case "$ans" in
2918	y|Y)    val="$define" ;;
2919	*)      val="$undef" ;;
2920	esac
2921	set useithreads
2922	eval $setvar
2923	: Now set use5005threads to the opposite value.
2924	case "$useithreads" in
2925	$define) val="$undef" ;;
2926	*) val="$define" ;;
2927	esac
2928	set use5005threads
2929	eval $setvar
2930	;;
2931*)
2932	useithreads="$undef"
2933	use5005threads="$undef"
2934	;;
2935esac
2936
2937case "$useithreads$use5005threads" in
2938"$define$define")
2939	$cat >&4 <<EOM
2940
2941You cannot have both the ithreads and the 5.005 threads enabled
2942at the same time.  Disabling the 5.005 threads since they are
2943much less stable than the ithreads.
2944
2945EOM
2946	use5005threads="$undef"
2947	;;
2948esac
2949
2950case "$d_oldpthreads" in
2951'')	: Configure tests would be welcome here.  For now, assume undef.
2952	val="$undef" ;;
2953*)	val="$d_oldpthreads" ;;
2954esac
2955set d_oldpthreads
2956eval $setvar
2957
2958
2959case "$usethreads" in
2960"$define"|true|[yY]*)
2961: Look for a hint-file generated 'call-back-unit'.  If the
2962: user has specified that a threading perl is to be built,
2963: we may need to set or change some other defaults.
2964	if $test -f usethreads.cbu; then
2965		echo "Your platform has some specific hints for threaded builds, using them..."
2966		. ./usethreads.cbu
2967	else
2968		$cat <<EOM
2969(Your platform doesn't have any specific hints for threaded builds.
2970 Assuming POSIX threads, then.)
2971EOM
2972	fi
2973	;;
2974esac
2975
2976cat <<EOM
2977
2978Perl can be built so that multiple Perl interpreters can coexist
2979within the same Perl executable.
2980EOM
2981
2982case "$useithreads" in
2983$define)
2984	cat <<EOM
2985This multiple interpreter support is required for interpreter-based threads.
2986EOM
2987	val="$define"
2988	;;
2989*)	case "$usemultiplicity" in
2990	$define|true|[yY]*)	dflt='y';;
2991	*) dflt='n';;
2992	esac
2993	echo " "
2994	echo "If this doesn't make any sense to you, just accept the default '$dflt'."
2995	rp='Build Perl for multiplicity?'
2996	. ./myread
2997	case "$ans" in
2998	y|Y)	val="$define" ;;
2999	*)      val="$undef" ;;
3000	esac
3001	;;
3002esac
3003set usemultiplicity
3004eval $setvar
3005
3006: make some quick guesses about what we are up against
3007echo " "
3008$echo $n "Hmm...  $c"
3009echo exit 1 >bsd
3010echo exit 1 >usg
3011echo exit 1 >v7
3012echo exit 1 >osf1
3013echo exit 1 >eunice
3014echo exit 1 >xenix
3015echo exit 1 >venix
3016echo exit 1 >os2
3017d_bsd="$undef"
3018$cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3019if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3020then
3021	echo "Looks kind of like an OSF/1 system, but we'll see..."
3022	echo exit 0 >osf1
3023elif test `echo abc | $tr a-z A-Z` = Abc ; then
3024	xxx=`./loc addbib blurfl $pth`
3025	if $test -f $xxx; then
3026	echo "Looks kind of like a USG system with BSD features, but we'll see..."
3027		echo exit 0 >bsd
3028		echo exit 0 >usg
3029	else
3030		if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3031			echo "Looks kind of like an extended USG system, but we'll see..."
3032		else
3033			echo "Looks kind of like a USG system, but we'll see..."
3034		fi
3035		echo exit 0 >usg
3036	fi
3037elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3038	echo "Looks kind of like a BSD system, but we'll see..."
3039	d_bsd="$define"
3040	echo exit 0 >bsd
3041else
3042	echo "Looks kind of like a Version 7 system, but we'll see..."
3043	echo exit 0 >v7
3044fi
3045case "$eunicefix" in
3046*unixtovms*)
3047	$cat <<'EOI'
3048There is, however, a strange, musty smell in the air that reminds me of
3049something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3050EOI
3051	echo exit 0 >eunice
3052	d_eunice="$define"
3053: it so happens the Eunice I know will not run shell scripts in Unix format
3054	;;
3055*)
3056	echo " "
3057	echo "Congratulations.  You aren't running Eunice."
3058	d_eunice="$undef"
3059	;;
3060esac
3061: Detect OS2.  The p_ variable is set above in the Head.U unit.
3062: Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
3063: semicolon as a patch separator
3064case "$p_" in
3065:) ;;
3066*)
3067	$cat <<'EOI'
3068I have the feeling something is not exactly right, however...don't tell me...
3069lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3070(Or you may be running DOS with DJGPP.)
3071EOI
3072	echo exit 0 >os2
3073	;;
3074esac
3075if test -f /xenix; then
3076	echo "Actually, this looks more like a XENIX system..."
3077	echo exit 0 >xenix
3078	d_xenix="$define"
3079else
3080	echo " "
3081	echo "It's not Xenix..."
3082	d_xenix="$undef"
3083fi
3084chmod +x xenix
3085$eunicefix xenix
3086if test -f /venix; then
3087	echo "Actually, this looks more like a VENIX system..."
3088	echo exit 0 >venix
3089else
3090	echo " "
3091	if ./xenix; then
3092		: null
3093	else
3094		echo "Nor is it Venix..."
3095	fi
3096fi
3097chmod +x bsd usg v7 osf1 eunice xenix venix os2
3098$eunicefix bsd usg v7 osf1 eunice xenix venix os2
3099$rm -f foo
3100
3101case "$cc" in
3102'') dflt=cc;;
3103*) dflt="$cc";;
3104esac
3105rp="Use which C compiler?"
3106. ./myread
3107cc="$ans"
3108: Look for a hint-file generated 'call-back-unit'.  Now that the
3109: user has specified the compiler, we may need to set or change some
3110: other defaults.
3111if $test -f cc.cbu; then
3112    . ./cc.cbu
3113fi
3114. ./checkcc
3115
3116echo " "
3117echo "Checking for GNU cc in disguise and/or its version number..." >&4
3118$cat >gccvers.c <<EOM
3119#include <stdio.h>
3120int main() {
3121#ifdef __GNUC__
3122#ifdef __VERSION__
3123	printf("%s\n", __VERSION__);
3124#else
3125	printf("%s\n", "1");
3126#endif
3127#endif
3128	exit(0);
3129}
3130EOM
3131if $cc -o gccvers $ccflags $ldflags gccvers.c; then
3132	gccversion=`./gccvers`
3133	case "$gccversion" in
3134	'') echo "You are not using GNU cc." ;;
3135	*)  echo "You are using GNU cc $gccversion."
3136	    ccname=gcc
3137	    ;;
3138	esac
3139else
3140	echo " "
3141	echo "*** WHOA THERE!!! ***" >&4
3142	echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3143	case "$knowitall" in
3144	'')
3145	echo "    You'd better start hunting for one and let me know about it." >&4
3146		exit 1
3147		;;
3148	esac
3149fi
3150$rm -f gccvers*
3151case "$gccversion" in
31521*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3153esac
3154case "$gccversion" in
3155'') gccosandvers='' ;;
3156*) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
3157   gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
3158   gccshortvers=''
3159   case "$gccosandvers" in
3160   $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
3161   $osname$osvers) ;; # looking good
3162   $osname*) cat <<EOM >&4
3163
3164*** WHOA THERE!!! ***
3165
3166    Your gcc has not been compiled for the exact release of
3167    your operating system ($gccosandvers versus $osname$osvers).
3168
3169    In general it is a good idea to keep gcc synchronized with
3170    the operating system because otherwise serious problems
3171    may ensue when trying to compile software, like Perl.
3172
3173    I'm trying to be optimistic here, though, and will continue.
3174    If later during the configuration and build icky compilation
3175    problems appear (headerfile conflicts being the most common
3176    manifestation), I suggest reinstalling the gcc to match
3177    your operating system release.
3178
3179EOM
3180      ;;
3181   *) gccosandvers='' ;; # failed to parse, better be silent
3182   esac
3183   ;;
3184esac
3185case "$ccname" in
3186'') ccname="$cc" ;;
3187esac
3188
3189: see how we invoke the C preprocessor
3190echo " "
3191echo "Now, how can we feed standard input to your C preprocessor..." >&4
3192cat <<'EOT' >testcpp.c
3193#define ABC abc
3194#define XYZ xyz
3195ABC.XYZ
3196EOT
3197cd ..
3198if test ! -f cppstdin; then
3199	if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
3200		# AIX cc -E doesn't show the absolute headerfile
3201		# locations but we'll cheat by using the -M flag.
3202		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
3203	else
3204		echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3205	fi
3206else
3207	echo "Keeping your $hint cppstdin wrapper."
3208fi
3209chmod 755 cppstdin
3210wrapper=`pwd`/cppstdin
3211ok='false'
3212cd UU
3213
3214if $test "X$cppstdin" != "X" && \
3215	$cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3216	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3217then
3218	echo "You used to use $cppstdin $cppminus so we'll use that again."
3219	case "$cpprun" in
3220	'') echo "But let's see if we can live without a wrapper..." ;;
3221	*)
3222		if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3223			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3224		then
3225			echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3226			ok='true'
3227		else
3228			echo "(However, $cpprun $cpplast does not work, let's see...)"
3229		fi
3230		;;
3231	esac
3232else
3233	case "$cppstdin" in
3234	'') ;;
3235	*)
3236		echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3237		;;
3238	esac
3239fi
3240
3241if $ok; then
3242	: nothing
3243elif echo 'Maybe "'"$cc"' -E" will work...'; \
3244	$cc -E <testcpp.c >testcpp.out 2>&1; \
3245	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3246	echo "Yup, it does."
3247	x_cpp="$cc -E"
3248	x_minus='';
3249elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3250	$cc -E - <testcpp.c >testcpp.out 2>&1; \
3251	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3252	echo "Yup, it does."
3253	x_cpp="$cc -E"
3254	x_minus='-';
3255elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3256	$cc -P <testcpp.c >testcpp.out 2>&1; \
3257	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3258	echo "Yipee, that works!"
3259	x_cpp="$cc -P"
3260	x_minus='';
3261elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3262	$cc -P - <testcpp.c >testcpp.out 2>&1; \
3263	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3264	echo "At long last!"
3265	x_cpp="$cc -P"
3266	x_minus='-';
3267elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3268	$cpp <testcpp.c >testcpp.out 2>&1; \
3269	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3270	echo "It works!"
3271	x_cpp="$cpp"
3272	x_minus='';
3273elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3274	$cpp - <testcpp.c >testcpp.out 2>&1; \
3275	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3276	echo "Hooray, it works!  I was beginning to wonder."
3277	x_cpp="$cpp"
3278	x_minus='-';
3279elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3280	$wrapper <testcpp.c >testcpp.out 2>&1; \
3281	$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3282	x_cpp="$wrapper"
3283	x_minus=''
3284	echo "Eureka!"
3285else
3286	dflt=''
3287	rp="No dice.  I can't find a C preprocessor.  Name one:"
3288	. ./myread
3289	x_cpp="$ans"
3290	x_minus=''
3291	$x_cpp <testcpp.c >testcpp.out 2>&1
3292	if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3293		echo "OK, that will do." >&4
3294	else
3295echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3296		exit 1
3297	fi
3298fi
3299
3300case "$ok" in
3301false)
3302	cppstdin="$x_cpp"
3303	cppminus="$x_minus"
3304	cpprun="$x_cpp"
3305	cpplast="$x_minus"
3306	set X $x_cpp
3307	shift
3308	case "$1" in
3309	"$cpp")
3310		echo "Perhaps can we force $cc -E using a wrapper..."
3311		if $wrapper <testcpp.c >testcpp.out 2>&1; \
3312			$contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3313		then
3314			echo "Yup, we can."
3315			cppstdin="$wrapper"
3316			cppminus='';
3317		else
3318			echo "Nope, we'll have to live without it..."
3319		fi
3320		;;
3321	esac
3322	case "$cpprun" in
3323	"$wrapper")
3324		cpprun=''
3325		cpplast=''
3326		;;
3327	esac
3328	;;
3329esac
3330
3331case "$cppstdin" in
3332"$wrapper"|'cppstdin') ;;
3333*) $rm -f $wrapper;;
3334esac
3335$rm -f testcpp.c testcpp.out
3336
3337: decide how portable to be.  Allow command line overrides.
3338case "$d_portable" in
3339"$undef") ;;
3340*)	d_portable="$define" ;;
3341esac
3342
3343: set up shell script to do ~ expansion
3344cat >filexp <<EOSS
3345$startsh
3346: expand filename
3347case "\$1" in
3348 ~/*|~)
3349	echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
3350	;;
3351 ~*)
3352	if $test -f /bin/csh; then
3353		/bin/csh -f -c "glob \$1"
3354		failed=\$?
3355		echo ""
3356		exit \$failed
3357	else
3358		name=\`$expr x\$1 : '..\([^/]*\)'\`
3359		dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
3360		if $test ! -d "\$dir"; then
3361			me=\`basename \$0\`
3362			echo "\$me: can't locate home directory for: \$name" >&2
3363			exit 1
3364		fi
3365		case "\$1" in
3366		*/*)
3367			echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
3368			;;
3369		*)
3370			echo \$dir
3371			;;
3372		esac
3373	fi
3374	;;
3375*)
3376	echo \$1
3377	;;
3378esac
3379EOSS
3380chmod +x filexp
3381$eunicefix filexp
3382
3383: now set up to get a file name
3384cat <<EOS >getfile
3385$startsh
3386EOS
3387cat <<'EOSC' >>getfile
3388tilde=''
3389fullpath=''
3390already=''
3391skip=''
3392none_ok=''
3393exp_file=''
3394nopath_ok=''
3395orig_rp="$rp"
3396orig_dflt="$dflt"
3397case "$gfpth" in
3398'') gfpth='.' ;;
3399esac
3400
3401case "$fn" in
3402*\(*)
3403	expr $fn : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
3404	fn=`echo $fn | sed 's/(.*)//'`
3405	;;
3406esac
3407
3408case "$fn" in
3409*:*)
3410	loc_file=`expr $fn : '.*:\(.*\)'`
3411	fn=`expr $fn : '\(.*\):.*'`
3412	;;
3413esac
3414
3415case "$fn" in
3416*~*) tilde=true;;
3417esac
3418case "$fn" in
3419*/*) fullpath=true;;
3420esac
3421case "$fn" in
3422*+*) skip=true;;
3423esac
3424case "$fn" in
3425*n*) none_ok=true;;
3426esac
3427case "$fn" in
3428*e*) exp_file=true;;
3429esac
3430case "$fn" in
3431*p*) nopath_ok=true;;
3432esac
3433
3434case "$fn" in
3435*f*) type='File';;
3436*d*) type='Directory';;
3437*l*) type='Locate';;
3438esac
3439
3440what="$type"
3441case "$what" in
3442Locate) what='File';;
3443esac
3444
3445case "$exp_file" in
3446'')
3447	case "$d_portable" in
3448	"$define") ;;
3449	*) exp_file=true;;
3450	esac
3451	;;
3452esac
3453
3454cd ..
3455while test "$type"; do
3456	redo=''
3457	rp="$orig_rp"
3458	dflt="$orig_dflt"
3459	case "$tilde" in
3460	true) rp="$rp (~name ok)";;
3461	esac
3462	. UU/myread
3463	if test -f UU/getfile.ok && \
3464		$contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
3465	then
3466		value="$ans"
3467		ansexp="$ans"
3468		break
3469	fi
3470	case "$ans" in
3471	none)
3472		value=''
3473		ansexp=''
3474		case "$none_ok" in
3475		true) type='';;
3476		esac
3477		;;
3478	*)
3479		case "$tilde" in
3480		'') value="$ans"
3481			ansexp="$ans";;
3482		*)
3483			value=`UU/filexp $ans`
3484			case $? in
3485			0)
3486				if test "$ans" != "$value"; then
3487					echo "(That expands to $value on this system.)"
3488				fi
3489				;;
3490			*) value="$ans";;
3491			esac
3492			ansexp="$value"
3493			case "$exp_file" in
3494			'') value="$ans";;
3495			esac
3496			;;
3497		esac
3498		case "$fullpath" in
3499		true)
3500			case "$ansexp" in
3501			/*) value="$ansexp" ;;
3502			[a-zA-Z]:/*) value="$ansexp" ;;
3503			*)
3504				redo=true
3505				case "$already" in
3506				true)
3507				echo "I shall only accept a full path name, as in /bin/ls." >&4
3508				echo "Use a ! shell escape if you wish to check pathnames." >&4
3509					;;
3510				*)
3511				echo "Please give a full path name, starting with slash." >&4
3512					case "$tilde" in
3513					true)
3514				echo "Note that using ~name is ok provided it expands well." >&4
3515						already=true
3516						;;
3517					esac
3518				esac
3519				;;
3520			esac
3521			;;
3522		esac
3523		case "$redo" in
3524		'')
3525			case "$type" in
3526			File)
3527				for fp in $gfpth; do
3528					if test "X$fp" = X.; then
3529					    pf="$ansexp"
3530					else
3531					    pf="$fp/$ansexp"
3532					fi
3533					if test -f "$pf"; then
3534						type=''
3535					elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
3536					then
3537						echo "($value is not a plain file, but that's ok.)"
3538						type=''
3539					fi
3540					if test X"$type" = X; then
3541					    value="$pf"
3542					    break
3543					fi
3544				done
3545				;;
3546			Directory)
3547				for fp in $gfpth; do
3548					if test "X$fp" = X.; then
3549					    dir="$ans"
3550					    direxp="$ansexp"
3551					else
3552					    dir="$fp/$ansexp"
3553					    direxp="$fp/$ansexp"
3554					fi
3555					if test -d "$direxp"; then
3556						type=''
3557						value="$dir"
3558						break
3559					fi
3560				done
3561				;;
3562			Locate)
3563				if test -d "$ansexp"; then
3564					echo "(Looking for $loc_file in directory $value.)"
3565					value="$value/$loc_file"
3566					ansexp="$ansexp/$loc_file"
3567				fi
3568				if test -f "$ansexp"; then
3569					type=''
3570				fi
3571				case "$nopath_ok" in
3572				true)	case "$value" in
3573					*/*) ;;
3574					*)	echo "Assuming $value will be in people's path."
3575						type=''
3576						;;
3577					esac
3578					;;
3579				esac
3580				;;
3581			esac
3582
3583			case "$skip" in
3584			true) type='';
3585			esac
3586
3587			case "$type" in
3588			'') ;;
3589			*)
3590				if test "$fastread" = yes; then
3591					dflt=y
3592				else
3593					dflt=n
3594				fi
3595				rp="$what $value doesn't exist.  Use that name anyway?"
3596				. UU/myread
3597				dflt=''
3598				case "$ans" in
3599				y*) type='';;
3600				*) echo " ";;
3601				esac
3602				;;
3603			esac
3604			;;
3605		esac
3606		;;
3607	esac
3608done
3609cd UU
3610ans="$value"
3611rp="$orig_rp"
3612dflt="$orig_dflt"
3613rm -f getfile.ok
3614test "X$gfpthkeep" != Xy && gfpth=""
3615EOSC
3616
3617: What should the include directory be ?
3618echo " "
3619$echo $n "Hmm...  $c"
3620dflt='/usr/include'
3621incpath=''
3622mips_type=''
3623if $test -f /bin/mips && /bin/mips; then
3624	echo "Looks like a MIPS system..."
3625	$cat >usr.c <<'EOCP'
3626#ifdef SYSTYPE_BSD43
3627/bsd43
3628#endif
3629EOCP
3630	if cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3631		dflt='/bsd43/usr/include'
3632		incpath='/bsd43'
3633		mips_type='BSD 4.3'
3634	else
3635		mips_type='System V'
3636	fi
3637	$rm -f usr.c usr.out
3638	echo "and you're compiling with the $mips_type compiler and libraries."
3639	xxx_prompt=y
3640	echo "exit 0" >mips
3641else
3642	echo "Doesn't look like a MIPS system."
3643	xxx_prompt=n
3644	echo "exit 1" >mips
3645fi
3646chmod +x mips
3647$eunicefix mips
3648case "$usrinc" in
3649'') ;;
3650*) dflt="$usrinc";;
3651esac
3652case "$xxx_prompt" in
3653y)	fn=d/
3654	echo " "
3655	rp='Where are the include files you want to use?'
3656	. ./getfile
3657	usrinc="$ans"
3658	;;
3659*)	usrinc="$dflt"
3660	;;
3661esac
3662
3663: Set private lib path
3664case "$plibpth" in
3665'') if ./mips; then
3666		plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3667	fi;;
3668esac
3669case "$libpth" in
3670' ') dlist='';;
3671'') dlist="$loclibpth $plibpth $glibpth";;
3672*) dlist="$libpth";;
3673esac
3674
3675: Now check and see which directories actually exist, avoiding duplicates
3676libpth=''
3677for xxx in $dlist
3678do
3679    if $test -d $xxx; then
3680		case " $libpth " in
3681		*" $xxx "*) ;;
3682		*) libpth="$libpth $xxx";;
3683		esac
3684    fi
3685done
3686$cat <<'EOM'
3687
3688Some systems have incompatible or broken versions of libraries.  Among
3689the directories listed in the question below, please remove any you
3690know not to be holding relevant libraries, and add any that are needed.
3691Say "none" for none.
3692
3693EOM
3694case "$libpth" in
3695'') dflt='none';;
3696*)
3697	set X $libpth
3698	shift
3699	dflt=${1+"$@"}
3700	;;
3701esac
3702rp="Directories to use for library searches?"
3703. ./myread
3704case "$ans" in
3705none) libpth=' ';;
3706*) libpth="$ans";;
3707esac
3708
3709: compute shared library extension
3710case "$so" in
3711'')
3712	if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3713		dflt='sl'
3714	else
3715		dflt='so'
3716	fi
3717	;;
3718*) dflt="$so";;
3719esac
3720$cat <<EOM
3721
3722On some systems, shared libraries may be available.  Answer 'none' if
3723you want to suppress searching of shared libraries for the remainder
3724of this configuration.
3725
3726EOM
3727rp='What is the file extension used for shared libraries?'
3728. ./myread
3729so="$ans"
3730
3731: Define several unixisms.
3732: Hints files or command line option can be used to override them.
3733: The convoluted testing is in case hints files set either the old
3734: or the new name.
3735case "$_exe" in
3736'')	case "$exe_ext" in
3737    '')	;;
3738	*)	_exe="$exe_ext" ;;
3739	esac
3740	;;
3741esac
3742case "$_a" in
3743'')	case "$lib_ext" in
3744    '')	_a='.a';;
3745	*)	_a="$lib_ext" ;;
3746	esac
3747	;;
3748esac
3749case "$_o" in
3750'') case "$obj_ext" in
3751	'')	_o='.o';;
3752	*)	_o="$obj_ext";;
3753	esac
3754	;;
3755esac
3756case "$p_" in
3757'') case "$path_sep" in
3758	'')	p_=':';;
3759	*)	p_="$path_sep";;
3760	esac
3761	;;
3762esac
3763exe_ext=$_exe
3764lib_ext=$_a
3765obj_ext=$_o
3766path_sep=$p_
3767
3768: Which makefile gets called first.  This is used by make depend.
3769case "$firstmakefile" in
3770'') firstmakefile='makefile';;
3771esac
3772
3773case "$usesocks" in
3774$define|true|[yY]*)	dflt='y';;
3775*) dflt='n';;
3776esac
3777cat <<EOM
3778
3779Perl can be built to use the SOCKS proxy protocol library.  To do so,
3780Configure must be run with -Dusesocks.
3781
3782If this doesn't make any sense to you, just accept the default '$dflt'.
3783EOM
3784rp='Build Perl for SOCKS?'
3785. ./myread
3786case "$ans" in
3787y|Y)	val="$define" ;;
3788*)      val="$undef" ;;
3789esac
3790set usesocks
3791eval $setvar
3792
3793: Looking for optional libraries
3794echo " "
3795echo "Checking for optional libraries..." >&4
3796case "$libs" in
3797' '|'') dflt='';;
3798*) dflt="$libs";;
3799esac
3800case "$libswanted" in
3801'') libswanted='c_s';;
3802esac
3803case "$usesocks" in
3804"$define") libswanted="$libswanted socks5 socks5_sh" ;;
3805esac
3806libsfound=''
3807libsfiles=''
3808libsdirs=''
3809libspath=''
3810for thisdir in $libpth $xlibpth; do
3811  test -d $thisdir && libspath="$libspath $thisdir"
3812done
3813for thislib in $libswanted; do
3814	for thisdir in $libspath; do
3815	    xxx=''
3816	    if $test ! -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3817		xxx=`ls $thisdir/lib$thislib.$so.[0-9] 2>/dev/null|tail -1`
3818	        $test -f "$xxx" && eval $libscheck
3819		$test -f "$xxx" && libstyle=shared
3820	    fi
3821	    if test ! -f "$xxx"; then
3822		xxx=$thisdir/lib$thislib.$so
3823	        $test -f "$xxx" && eval $libscheck
3824		$test -f "$xxx" && libstyle=shared
3825	    fi
3826	    if test ! -f "$xxx"; then
3827		xxx=$thisdir/lib$thislib$_a
3828	        $test -f "$xxx" && eval $libscheck
3829		$test -f "$xxx" && libstyle=static
3830	    fi
3831	    if test ! -f "$xxx"; then
3832		xxx=$thisdir/$thislib$_a
3833	        $test -f "$xxx" && eval $libscheck
3834		$test -f "$xxx" && libstyle=static
3835	    fi
3836	    if test ! -f "$xxx"; then
3837		xxx=$thisdir/lib${thislib}_s$_a
3838	        $test -f "$xxx" && eval $libscheck
3839		$test -f "$xxx" && libstyle=static
3840		$test -f "$xxx" && thislib=${thislib}_s
3841	    fi
3842	    if test ! -f "$xxx"; then
3843		xxx=$thisdir/Slib$thislib$_a
3844	        $test -f "$xxx" && eval $libscheck
3845		$test -f "$xxx" && libstyle=static
3846	    fi
3847	    if $test -f "$xxx"; then
3848		case "$libstyle" in
3849		shared) echo "Found -l$thislib (shared)." ;;
3850		static) echo "Found -l$thislib." ;;
3851		*)      echo "Found -l$thislib ($libstyle)." ;;
3852		esac
3853		case " $dflt " in
3854		*"-l$thislib "*);;
3855		*) dflt="$dflt -l$thislib"
3856                   libsfound="$libsfound $xxx"
3857                   yyy=`basename $xxx`
3858                   libsfiles="$libsfiles $yyy"
3859                   yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"`
3860                   case " $libsdirs " in
3861                   *" $yyy "*) ;;
3862                   *) libsdirs="$libsdirs $yyy" ;;
3863                   esac
3864		   ;;
3865		esac
3866		break
3867	    fi
3868	done
3869	if $test ! -f "$xxx"; then
3870	    echo "No -l$thislib."
3871	fi
3872done
3873set X $dflt
3874shift
3875dflt="$*"
3876case "$libs" in
3877'') dflt="$dflt";;
3878*) dflt="$libs";;
3879esac
3880case "$dflt" in
3881' '|'') dflt='none';;
3882esac
3883
3884$cat <<EOM
3885
3886In order to compile $package on your machine, a number of libraries
3887are usually needed.  Include any other special libraries here as well.
3888Say "none" for none.  The default list is almost always right.
3889EOM
3890
3891echo " "
3892rp="What libraries to use?"
3893. ./myread
3894case "$ans" in
3895none) libs=' ';;
3896*) libs="$ans";;
3897esac
3898
3899: determine optimization, if desired, or use for debug flag also
3900case "$optimize" in
3901' '|$undef) dflt='none';;
3902'') dflt='-O';;
3903*) dflt="$optimize";;
3904esac
3905$cat <<EOH
3906
3907By default, $package compiles with the -O flag to use the optimizer.
3908Alternately, you might want to use the symbolic debugger, which uses
3909the -g flag (on traditional Unix systems).  Either flag can be
3910specified here.  To use neither flag, specify the word "none".
3911
3912EOH
3913rp="What optimizer/debugger flag should be used?"
3914. ./myread
3915optimize="$ans"
3916case "$optimize" in
3917'none') optimize=" ";;
3918esac
3919
3920dflt=''
3921: We will not override a previous value, but we might want to
3922: augment a hint file
3923case "$hint" in
3924default|recommended)
3925	case "$gccversion" in
3926	1*) dflt='-fpcc-struct-return' ;;
3927	esac
3928	case "$optimize" in
3929	*-g*) dflt="$dflt -DDEBUGGING";;
3930	esac
3931	case "$gccversion" in
3932	2*) if test -d /etc/conf/kconfig.d &&
3933			$contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
3934		then
3935			dflt="$dflt -posix"
3936		fi
3937		;;
3938	esac
3939	case "$gccversion" in
3940	1*) ;;
3941	2.[0-8]*) ;;
3942	?*) 	echo " "
3943		echo "Checking if your compiler accepts -fno-strict-aliasing" 2>&1
3944		echo 'int main(void) { return 0; }' > gcctest.c
3945		if $cc -O2 -fno-strict-aliasing -o gcctest gcctest.c; then
3946			echo "Yes, it does." 2>&1
3947			case "$ccflags" in
3948			*strict-aliasing*)
3949				echo "Leaving current flags $ccflags alone." 2>&1
3950				;;
3951			*) dflt="$dflt -fno-strict-aliasing" ;;
3952			esac
3953		else
3954			echo "Nope, it doesn't, but that's ok." 2>&1
3955		fi
3956		;;
3957	esac
3958	;;
3959esac
3960
3961case "$mips_type" in
3962*BSD*|'') inclwanted="$locincpth $usrinc";;
3963*) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
3964esac
3965for thisincl in $inclwanted; do
3966	if $test -d $thisincl; then
3967		if $test x$thisincl != x$usrinc; then
3968			case "$dflt" in
3969                        *" -I$thisincl "*);;
3970                        *) dflt="$dflt -I$thisincl ";;
3971			esac
3972		fi
3973	fi
3974done
3975
3976inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
3977	xxx=true;
3978elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
3979	xxx=true;
3980else
3981	xxx=false;
3982fi;
3983if $xxx; then
3984	case "$dflt" in
3985	*$2*);;
3986	*) dflt="$dflt -D$2";;
3987	esac;
3988fi'
3989
3990set signal.h LANGUAGE_C; eval $inctest
3991
3992case "$usesocks" in
3993$define)
3994	ccflags="$ccflags -DSOCKS"
3995	;;
3996esac
3997
3998case "$hint" in
3999default|recommended) dflt="$ccflags $dflt" ;;
4000*) dflt="$ccflags";;
4001esac
4002
4003case "$dflt" in
4004''|' ') dflt=none;;
4005esac
4006
4007$cat <<EOH
4008
4009Your C compiler may want other flags.  For this question you should include
4010-I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4011but you should NOT include libraries or ld flags like -lwhatever.  If you
4012want $package to honor its debug switch, you should include -DDEBUGGING here.
4013Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4014
4015To use no flags, specify the word "none".
4016
4017EOH
4018set X $dflt
4019shift
4020dflt=${1+"$@"}
4021rp="Any additional cc flags?"
4022. ./myread
4023case "$ans" in
4024none) ccflags='';;
4025*) ccflags="$ans";;
4026esac
4027
4028: the following weeds options from ccflags that are of no interest to cpp
4029cppflags="$ccflags"
4030case "$gccversion" in
40311*) cppflags="$cppflags -D__GNUC__"
4032esac
4033case "$mips_type" in
4034'');;
4035*BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4036esac
4037case "$cppflags" in
4038'');;
4039*)
4040	echo " "
4041	echo "Let me guess what the preprocessor flags are..." >&4
4042	set X $cppflags
4043	shift
4044	cppflags=''
4045	$cat >cpp.c <<'EOM'
4046#define BLURFL foo
4047
4048BLURFL xx LFRULB
4049EOM
4050	previous=''
4051	for flag in $*
4052	do
4053		case "$flag" in
4054		-*) ftry="$flag";;
4055		*) ftry="$previous $flag";;
4056		esac
4057		if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4058			>cpp1.out 2>/dev/null && \
4059			$cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4060			>cpp2.out 2>/dev/null && \
4061			$contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4062			$contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4063		then
4064			cppflags="$cppflags $ftry"
4065			previous=''
4066		else
4067			previous="$flag"
4068		fi
4069	done
4070	set X $cppflags
4071	shift
4072	cppflags=${1+"$@"}
4073	case "$cppflags" in
4074	*-*)  echo "They appear to be: $cppflags";;
4075	esac
4076	$rm -f cpp.c cpp?.out
4077	;;
4078esac
4079
4080: flags used in final linking phase
4081case "$ldflags" in
4082'') if ./venix; then
4083		dflt='-i -z'
4084	else
4085		dflt=''
4086	fi
4087	case "$ccflags" in
4088	*-posix*) dflt="$dflt -posix" ;;
4089	esac
4090	;;
4091*) dflt="$ldflags";;
4092esac
4093
4094: Try to guess additional flags to pick up local libraries.
4095for thislibdir in $libpth; do
4096	case " $loclibpth " in
4097	*" $thislibdir "*)
4098		case "$dflt " in
4099		*"-L$thislibdir "*) ;;
4100		*)  dflt="$dflt -L$thislibdir" ;;
4101		esac
4102		;;
4103	esac
4104done
4105
4106case "$dflt" in
4107'') dflt='none' ;;
4108esac
4109
4110$cat <<EOH
4111
4112Your C linker may need flags.  For this question you should
4113include -L/whatever and any other flags used by the C linker, but you
4114should NOT include libraries like -lwhatever.
4115
4116Make sure you include the appropriate -L/path flags if your C linker
4117does not normally search all of the directories you specified above,
4118namely
4119	$libpth
4120To use no flags, specify the word "none".
4121
4122EOH
4123
4124rp="Any additional ld flags (NOT including libraries)?"
4125. ./myread
4126case "$ans" in
4127none) ldflags='';;
4128*) ldflags="$ans";;
4129esac
4130rmlist="$rmlist pdp11"
4131
4132: coherency check
4133echo " "
4134echo "Checking your choice of C compiler and flags for coherency..." >&4
4135$cat > try.c <<'EOF'
4136#include <stdio.h>
4137int main() { printf("Ok\n"); exit(0); }
4138EOF
4139set X $cc -o try $optimize $ccflags $ldflags try.c $libs
4140shift
4141$cat >try.msg <<'EOM'
4142I've tried to compile and run the following simple program:
4143
4144EOM
4145$cat try.c >> try.msg
4146
4147$cat >> try.msg <<EOM
4148
4149I used the command:
4150
4151	$*
4152	./try
4153
4154and I got the following output:
4155
4156EOM
4157dflt=y
4158if $sh -c "$cc -o try $optimize $ccflags $ldflags try.c $libs" >>try.msg 2>&1; then
4159	if $sh -c './try' >>try.msg 2>&1; then
4160		xxx=`./try`
4161		case "$xxx" in
4162		"Ok") dflt=n ;;
4163		*)	echo 'The program compiled OK, but produced no output.' >> try.msg
4164			case " $libs " in
4165			*" -lsfio "*)
4166				cat >> try.msg <<'EOQS'
4167If $libs contains -lsfio, and sfio is mis-configured, then it
4168sometimes (apparently) runs and exits with a 0 status, but with no
4169output!  It may have to do with sfio's use of _exit vs. exit.
4170
4171EOQS
4172				rp="You have a big problem.  Shall I abort Configure"
4173				dflt=y
4174				;;
4175			esac
4176			;;
4177		esac
4178	else
4179		echo "The program compiled OK, but exited with status $?." >>try.msg
4180		rp="You have a problem.  Shall I abort Configure"
4181		dflt=y
4182	fi
4183else
4184	echo "I can't compile the test program." >>try.msg
4185	rp="You have a BIG problem.  Shall I abort Configure"
4186	dflt=y
4187fi
4188case "$dflt" in
4189y)
4190	$cat try.msg >&4
4191	case "$knowitall" in
4192	'')
4193		echo "(The supplied flags or libraries might be incorrect.)"
4194		;;
4195	*) dflt=n;;
4196	esac
4197	echo " "
4198	. ./myread
4199	case "$ans" in
4200	n*|N*) ;;
4201	*)	echo "Ok.  Stopping Configure." >&4
4202		exit 1
4203		;;
4204	esac
4205	;;
4206n) echo "OK, that should do.";;
4207esac
4208$rm -f try try.* core
4209
4210: define an is-a-typedef? function
4211typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
4212case "$inclist" in
4213"") inclist="sys/types.h";;
4214esac;
4215eval "varval=\$$var";
4216case "$varval" in
4217"")
4218	$rm -f temp.c;
4219	for inc in $inclist; do
4220		echo "#include <$inc>" >>temp.c;
4221	done;
4222	echo "#ifdef $type" >> temp.c;
4223	echo "printf(\"We have $type\");" >> temp.c;
4224	echo "#endif" >> temp.c;
4225	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
4226	if $contains $type temp.E >/dev/null 2>&1; then
4227		eval "$var=\$type";
4228	else
4229		eval "$var=\$def";
4230	fi;
4231	$rm -f temp.?;;
4232*) eval "$var=\$varval";;
4233esac'
4234
4235: define an is-a-typedef? function that prompts if the type is not available.
4236typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
4237case "$inclist" in
4238"") inclist="sys/types.h";;
4239esac;
4240eval "varval=\$$var";
4241case "$varval" in
4242"")
4243	$rm -f temp.c;
4244	for inc in $inclist; do
4245		echo "#include <$inc>" >>temp.c;
4246	done;
4247	echo "#ifdef $type" >> temp.c;
4248	echo "printf(\"We have $type\");" >> temp.c;
4249	echo "#endif" >> temp.c;
4250	$cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
4251	echo " " ;
4252	echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
4253	if $contains $type temp.E >/dev/null 2>&1; then
4254		echo "$type found." >&4;
4255		eval "$var=\$type";
4256	else
4257		echo "$type NOT found." >&4;
4258		dflt="$def";
4259		. ./myread ;
4260		eval "$var=\$ans";
4261	fi;
4262	$rm -f temp.?;;
4263*) eval "$var=\$varval";;
4264esac'
4265
4266: define a shorthand compile call
4267compile='
4268mc_file=$1;
4269shift;
4270$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs > /dev/null 2>&1;'
4271: define a shorthand compile call for compilations that should be ok.
4272compile_ok='
4273mc_file=$1;
4274shift;
4275$cc -o ${mc_file} $optimize $ccflags $ldflags $* ${mc_file}.c $libs;'
4276
4277: check for lengths of integral types
4278echo " "
4279case "$intsize" in
4280'')
4281	echo "Checking to see how big your integers are..." >&4
4282	$cat >intsize.c <<'EOCP'
4283#include <stdio.h>
4284int main()
4285{
4286	printf("intsize=%d;\n", (int)sizeof(int));
4287	printf("longsize=%d;\n", (int)sizeof(long));
4288	printf("shortsize=%d;\n", (int)sizeof(short));
4289	exit(0);
4290}
4291EOCP
4292	set intsize
4293	if eval $compile_ok && ./intsize > /dev/null; then
4294		eval `./intsize`
4295		echo "Your integers are $intsize bytes long."
4296		echo "Your long integers are $longsize bytes long."
4297		echo "Your short integers are $shortsize bytes long."
4298	else
4299		$cat >&4 <<EOM
4300!
4301Help! I can't compile and run the intsize test program: please enlighten me!
4302(This is probably a misconfiguration in your system or libraries, and
4303you really ought to fix it.  Still, I'll try anyway.)
4304!
4305EOM
4306		dflt=4
4307		rp="What is the size of an integer (in bytes)?"
4308		. ./myread
4309		intsize="$ans"
4310		dflt=$intsize
4311		rp="What is the size of a long integer (in bytes)?"
4312		. ./myread
4313		longsize="$ans"
4314		dflt=2
4315		rp="What is the size of a short integer (in bytes)?"
4316		. ./myread
4317		shortsize="$ans"
4318	fi
4319	;;
4320esac
4321$rm -f intsize intsize.*
4322
4323: see what type lseek is declared as in the kernel
4324rp="What is the type used for lseek's offset on this system?"
4325set off_t lseektype long stdio.h sys/types.h
4326eval $typedef_ask
4327
4328echo " "
4329echo "Checking to see how big your file offsets are..." >&4
4330$cat >try.c <<EOCP
4331#include <sys/types.h>
4332#include <stdio.h>
4333int main()
4334{
4335    printf("%d\n", (int)sizeof($lseektype));
4336    return(0); 
4337}
4338EOCP
4339set try
4340if eval $compile_ok; then
4341	lseeksize=`./try`
4342	echo "Your file offsets are $lseeksize bytes long."
4343else
4344	dflt=$longsize
4345	echo " "
4346	echo "(I can't seem to compile the test program.  Guessing...)"
4347	rp="What is the size of your file offsets (in bytes)?"
4348	. ./myread
4349	lseeksize="$ans"
4350fi
4351$rm -f try.c try
4352
4353: see what type file positions are declared as in the library
4354rp="What is the type for file position used by fsetpos()?"
4355set fpos_t fpostype long stdio.h sys/types.h
4356eval $typedef_ask
4357
4358echo " "
4359case "$fpostype" in
4360*_t) zzz="$fpostype"	;;
4361*)   zzz="fpos_t"	;;
4362esac
4363echo "Checking the size of $zzz..." >&4
4364cat > try.c <<EOCP
4365#include <sys/types.h>
4366#include <stdio.h>
4367int main() {
4368    printf("%d\n", (int)sizeof($fpostype));
4369    exit(0);
4370}
4371EOCP
4372set try
4373if eval $compile_ok; then
4374	yyy=`./try`
4375	case "$yyy" in
4376	'')	fpossize=4
4377		echo "(I can't execute the test program--guessing $fpossize.)" >&4
4378		;;
4379	*)	fpossize=$yyy
4380		echo "Your $zzz is $fpossize bytes long."
4381		;;
4382	esac
4383else
4384	dflt="$longsize"
4385	echo " " >&4
4386	echo "(I can't compile the test program.  Guessing...)" >&4
4387	rp="What is the size of your file positions (in bytes)?"
4388	. ./myread
4389	fpossize="$ans"
4390fi
4391
4392
4393
4394# Backward compatibility (uselfs is deprecated).
4395case "$uselfs" in
4396"$define"|true|[yY]*)
4397	cat <<EOM >&4
4398
4399*** Configure -Duselfs is deprecated, using -Duselargefiles instead.
4400EOM
4401	uselargefiles="$define"
4402	;;
4403esac
4404
4405case "$lseeksize:$fpossize" in
44068:8) cat <<EOM
4407
4408You can have files larger than 2 gigabytes.
4409EOM
4410   val="$define" ;;
4411*)    case "$uselargefiles" in
4412   "$undef"|false|[nN]*) dflt='n' ;;
4413   *)	dflt='y' ;;
4414   esac
4415   cat <<EOM
4416
4417Perl can be built to understand large files (files larger than 2 gigabytes)
4418on some systems.  To do so, Configure can be run with -Duselargefiles.
4419
4420If this doesn't make any sense to you, just accept the default '$dflt'.
4421EOM
4422   rp='Try to understand large files, if available?'
4423   . ./myread
4424   case "$ans" in
4425   y|Y) 	val="$define" ;;
4426   *)   	val="$undef"  ;;
4427   esac
4428   ;;
4429esac
4430set uselargefiles
4431eval $setvar
4432case "$uselargefiles" in
4433"$define")
4434: Look for a hint-file generated 'call-back-unit'.  If the
4435: user has specified that a large files perl is to be built,
4436: we may need to set or change some other defaults.
4437	if $test -f uselargefiles.cbu; then
4438		echo "Your platform has some specific hints for large file builds, using them..."
4439		. ./uselargefiles.cbu
4440		echo " "
4441		echo "Rechecking to see how big your file offsets are..." >&4
4442		$cat >try.c <<EOCP
4443#include <sys/types.h>
4444#include <stdio.h>
4445int main()
4446{
4447    printf("%d\n", (int)sizeof($lseektype));
4448    return(0); 
4449}
4450EOCP
4451		set try
4452		if eval $compile_ok; then
4453			lseeksize=`./try`
4454			$echo "Your file offsets are now $lseeksize bytes long."
4455		else
4456			dflt="$lseeksize"
4457			echo " "
4458			echo "(I can't seem to compile the test program.  Guessing...)"
4459			rp="What is the size of your file offsets (in bytes)?"
4460			. ./myread
4461			lseeksize="$ans"
4462		fi
4463		case "$fpostype" in
4464		*_t) zzz="$fpostype"	;;
4465		*)   zzz="fpos_t"	;;
4466		esac
4467		$echo $n "Rechecking the size of $zzz...$c" >&4
4468		$cat > try.c <<EOCP
4469#include <sys/types.h>
4470#include <stdio.h>
4471int main() {
4472    printf("%d\n", (int)sizeof($fpostype));
4473    exit(0);
4474}
4475EOCP
4476		set try
4477		if eval $compile_ok; then
4478			yyy=`./try`
4479			dflt="$lseeksize"
4480			case "$yyy" in
4481			'')	echo " "
4482				echo "(I can't execute the test program--guessing $fpossize.)" >&4
4483				;;
4484			*)	fpossize=$yyy
4485				echo " $fpossize bytes." >&4
4486				;;
4487			esac
4488		else
4489			dflt="$fpossize"
4490			echo " "
4491			echo "(I can't compile the test program.  Guessing...)" >&4
4492			rp="What is the size of your file positions (in bytes)?"
4493			. ./myread
4494			fpossize="$ans"
4495		fi
4496		$rm -f try.c try
4497	fi
4498	;;
4499esac
4500
4501
4502case "$usemorebits" in
4503"$define"|true|[yY]*)
4504	use64bitint="$define"
4505	uselongdouble="$define"
4506	usemorebits="$define"
4507	;;
4508*)	usemorebits="$undef"
4509	;;
4510esac
4511
4512
4513case "$uselonglong" in
4514"$define"|true|[yY]*)
4515	cat <<EOM >&4
4516
4517*** Configure -Duselonglong is deprecated, using -Duse64bitint instead.
4518EOM
4519	use64bitint="$define"
4520	;;
4521esac
4522case "$use64bits" in
4523"$define"|true|[yY]*)
4524	cat <<EOM >&4
4525
4526*** Configure -Duse64bits is deprecated, using -Duse64bitint instead.
4527EOM
4528	use64bitint="$define"
4529	;;
4530esac
4531case "$use64bitints" in
4532"$define"|true|[yY]*)
4533	cat <<EOM >&4
4534
4535*** There is no Configure -Duse64bitints, using -Duse64bitint instead.
4536EOM
4537	use64bitint="$define"
4538	;;
4539esac
4540case "$use64bitsint" in
4541"$define"|true|[yY]*)
4542	cat <<EOM >&4
4543
4544*** There is no Configure -Duse64bitsint, using -Duse64bitint instead.
4545EOM
4546	use64bitint="$define"
4547	;;
4548esac
4549case "$uselonglongs" in
4550"$define"|true|[yY]*)
4551	cat <<EOM >&4
4552
4553*** There is no Configure -Duselonglongs, using -Duse64bitint instead.
4554EOM
4555	use64bitint="$define"
4556	;;
4557esac
4558case "$use64bitsall" in
4559"$define"|true|[yY]*)
4560	cat <<EOM >&4
4561
4562*** There is no Configure -Duse64bitsall, using -Duse64bitall instead.
4563EOM
4564	use64bitall="$define"
4565	;;
4566esac
4567
4568case "$ccflags" in
4569*-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
4570esac
4571case "$use64bitall" in
4572"$define"|true|[yY]*) use64bitint="$define" ;;
4573esac
4574
4575case "$longsize" in
45768) cat <<EOM
4577
4578You have natively 64-bit long integers.
4579EOM
4580   val="$define"
4581   ;;
4582*) case "$use64bitint" in
4583   "$define"|true|[yY]*) dflt='y';;
4584   *) dflt='n';;
4585   esac
4586   cat <<EOM
4587
4588Perl can be built to take advantage of 64-bit integer types
4589on some systems.  To do so, Configure can be run with -Duse64bitint.
4590Choosing this option will most probably introduce binary incompatibilities.
4591
4592If this doesn't make any sense to you, just accept the default '$dflt'.
4593EOM
4594   rp='Try to use 64-bit integers, if available?'
4595   . ./myread
4596   case "$ans" in
4597   [yY]*) val="$define" ;;
4598   *)     val="$undef"  ;;
4599   esac
4600   ;;
4601esac
4602set use64bitint
4603eval $setvar
4604
4605case "$use64bitall" in
4606"$define"|true|[yY]*) dflt='y' ;;
4607*) case "$longsize" in
4608   8) dflt='y' ;;
4609   *) dflt='n' ;;
4610   esac
4611   ;;
4612esac
4613cat <<EOM
4614
4615You may also choose to try maximal 64-bitness.  It means using as much
461664-bitness as possible on the platform.  This in turn means even more
4617binary incompatibilities.  On the other hand, your platform may not
4618have any more 64-bitness available than what you already have chosen.
4619
4620If this doesn't make any sense to you, just accept the default '$dflt'.
4621EOM
4622rp='Try to use maximal 64-bit support, if available?'
4623. ./myread
4624case "$ans" in
4625[yY]*) val="$define" ;;
4626*)     val="$undef"  ;;
4627esac
4628set use64bitall
4629eval $setvar
4630case "$use64bitall" in
4631"$define")
4632	case "$use64bitint" in
4633	"$undef")
4634		cat <<EOM
4635
4636Since you have chosen a maximally 64-bit build, I'm also turning on
4637the use of 64-bit integers.
4638EOM
4639		use64bitint="$define" ;;
4640	esac
4641	;;
4642esac
4643
4644case "$use64bitint" in
4645"$define"|true|[yY]*)
4646: Look for a hint-file generated 'call-back-unit'.  If the
4647: user has specified that a 64-bit perl is to be built,
4648: we may need to set or change some other defaults.
4649	if $test -f use64bitint.cbu; then
4650		echo "Your platform has some specific hints for 64-bit integers, using them..."
4651		. ./use64bitint.cbu
4652	fi
4653	case "$longsize" in
4654	4) case "$archname64" in
4655	   '') archname64=64int ;;
4656	   esac
4657	   ;;
4658	esac
4659	;;
4660esac
4661
4662case "$use64bitall" in
4663"$define"|true|[yY]*)
4664: Look for a hint-file generated 'call-back-unit'.  If the
4665: user has specified that a maximally 64-bit perl is to be built,
4666: we may need to set or change some other defaults.
4667	if $test -f use64bitall.cbu; then
4668		echo "Your platform has some specific hints for 64-bit builds, using them..."
4669		. ./use64bitall.cbu
4670	fi
4671	case "$longsize" in
4672	4) case "$archname64" in
4673	   ''|64int) archname64=64all ;;
4674	   esac
4675	   ;;
4676	esac
4677	;;
4678esac
4679
4680echo " "
4681echo "Checking for GNU C Library..." >&4
4682cat >gnulibc.c <<EOM
4683#include <stdio.h>
4684int main()
4685{
4686#ifdef __GLIBC__
4687    exit(0);
4688#else
4689    exit(1);
4690#endif
4691}
4692EOM
4693set gnulibc
4694if eval $compile_ok && ./gnulibc; then
4695	val="$define"
4696	echo "You are using the GNU C Library"
4697else
4698	val="$undef"
4699	echo "You are not using the GNU C Library"
4700fi
4701$rm -f gnulibc*
4702set d_gnulibc
4703eval $setvar
4704
4705: see if nm is to be used to determine whether a symbol is defined or not
4706case "$usenm" in
4707'')
4708	dflt=''
4709	case "$d_gnulibc" in
4710	"$define")
4711		echo " "
4712		echo "nm probably won't work on the GNU C Library." >&4
4713		dflt=n
4714		;;
4715	esac
4716	case "$dflt" in
4717	'')
4718		if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4719			echo " "
4720			echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4721			echo "'nm' won't be sufficient on this sytem." >&4
4722			dflt=n
4723		fi
4724		;;
4725	esac
4726	case "$dflt" in
4727	'') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4728		if $test $dflt -gt 20; then
4729			dflt=y
4730		else
4731			dflt=n
4732		fi
4733		;;
4734	esac
4735	;;
4736*)
4737	case "$usenm" in
4738	true|$define) dflt=y;;
4739	*) dflt=n;;
4740	esac
4741	;;
4742esac
4743$cat <<EOM
4744
4745I can use $nm to extract the symbols from your C libraries. This
4746is a time consuming task which may generate huge output on the disk (up
4747to 3 megabytes) but that should make the symbols extraction faster. The
4748alternative is to skip the 'nm' extraction part and to compile a small
4749test program instead to determine whether each symbol is present. If
4750you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4751this may be the best solution.
4752
4753You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4754
4755EOM
4756rp="Shall I use $nm to extract C symbols from the libraries?"
4757. ./myread
4758case "$ans" in
4759[Nn]*) usenm=false;;
4760*) usenm=true;;
4761esac
4762
4763runnm=$usenm
4764case "$reuseval" in
4765true) runnm=false;;
4766esac
4767
4768: nm options which may be necessary
4769case "$nm_opt" in
4770'') if $test -f /mach_boot; then
4771		nm_opt=''	# Mach
4772	elif $test -d /usr/ccs/lib; then
4773		nm_opt='-p'	# Solaris (and SunOS?)
4774	elif $test -f /dgux; then
4775		nm_opt='-p'	# DG-UX
4776	elif $test -f /lib64/rld; then
4777		nm_opt='-p'	# 64-bit Irix
4778	else
4779		nm_opt=''
4780	fi;;
4781esac
4782
4783: nm options which may be necessary for shared libraries but illegal
4784: for archive libraries.  Thank you, Linux.
4785case "$nm_so_opt" in
4786'')	case "$myuname" in
4787	*linux*)
4788		if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4789			nm_so_opt='--dynamic'
4790		fi
4791		;;
4792	esac
4793	;;
4794esac
4795
4796case "$runnm" in
4797true)
4798: get list of predefined functions in a handy place
4799echo " "
4800case "$libc" in
4801'') libc=unknown
4802	case "$libs" in
4803	*-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4804	esac
4805	;;
4806esac
4807libnames='';
4808case "$libs" in
4809'') ;;
4810*)  for thislib in $libs; do
4811	case "$thislib" in
4812	-lc|-lc_s)
4813		: Handle C library specially below.
4814		;;
4815	-l*)
4816		thislib=`echo $thislib | $sed -e 's/^-l//'`
4817		if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4818			:
4819		elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4820			:
4821		elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4822			:
4823		elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4824			:
4825		elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4826			:
4827		elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4828			:
4829		elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4830			:
4831		else
4832			try=''
4833		fi
4834		libnames="$libnames $try"
4835		;;
4836	*) libnames="$libnames $thislib" ;;
4837	esac
4838	done
4839	;;
4840esac
4841xxx=normal
4842case "$libc" in
4843unknown)
4844	set /lib/libc.$so
4845	for xxx in $libpth; do
4846		$test -r $1 || set $xxx/libc.$so
4847		: The messy sed command sorts on library version numbers.
4848		$test -r $1 || \
4849			set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4850			tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4851				h
4852				s/[0-9][0-9]*/0000&/g
4853				s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4854				G
4855				s/\n/ /' | \
4856			 $sort | $sed -e 's/^.* //'`
4857		eval set \$$#
4858	done
4859	$test -r $1 || set /usr/ccs/lib/libc.$so
4860	$test -r $1 || set /lib/libsys_s$_a
4861	;;
4862*)
4863	set blurfl
4864	;;
4865esac
4866if $test -r "$1"; then
4867	echo "Your (shared) C library seems to be in $1."
4868	libc="$1"
4869elif $test -r /lib/libc && $test -r /lib/clib; then
4870	echo "Your C library seems to be in both /lib/clib and /lib/libc."
4871	xxx=apollo
4872	libc='/lib/clib /lib/libc'
4873	if $test -r /lib/syslib; then
4874		echo "(Your math library is in /lib/syslib.)"
4875		libc="$libc /lib/syslib"
4876	fi
4877elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4878	echo "Your C library seems to be in $libc, as you said before."
4879elif $test -r $incpath/usr/lib/libc$_a; then
4880	libc=$incpath/usr/lib/libc$_a;
4881	echo "Your C library seems to be in $libc.  That's fine."
4882elif $test -r /lib/libc$_a; then
4883	libc=/lib/libc$_a;
4884	echo "Your C library seems to be in $libc.  You're normal."
4885else
4886	if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4887		:
4888	elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4889		libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4890	elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4891		:
4892	elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4893		:
4894	elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4895		:
4896	else
4897		tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4898	fi
4899	if $test -r "$tans"; then
4900		echo "Your C library seems to be in $tans, of all places."
4901		libc=$tans
4902	else
4903		libc='blurfl'
4904	fi
4905fi
4906if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4907	dflt="$libc"
4908	cat <<EOM
4909
4910If the guess above is wrong (which it might be if you're using a strange
4911compiler, or your machine supports multiple models), you can override it here.
4912
4913EOM
4914else
4915	dflt=''
4916	echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
4917	cat >&4 <<EOM
4918I can't seem to find your C library.  I've looked in the following places:
4919
4920EOM
4921	$sed 's/^/	/' libpath
4922	cat <<EOM
4923
4924None of these seems to contain your C library. I need to get its name...
4925
4926EOM
4927fi
4928fn=f
4929rp='Where is your C library?'
4930. ./getfile
4931libc="$ans"
4932
4933echo " "
4934echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
4935set X `cat libnames`
4936shift
4937xxx=files
4938case $# in 1) xxx=file; esac
4939echo "Extracting names from the following $xxx for later perusal:" >&4
4940echo " "
4941$sed 's/^/	/' libnames >&4
4942echo " "
4943$echo $n "This may take a while...$c" >&4
4944
4945for file in $*; do
4946	case $file in
4947	*$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4948	*) $nm $nm_opt $file 2>/dev/null;;
4949	esac
4950done >libc.tmp
4951
4952$echo $n ".$c"
4953$grep fprintf libc.tmp > libc.ptf
4954xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4955xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4956xxx='[ADTSIW]'
4957if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4958	eval $xscan;\
4959	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4960		eval $xrun
4961elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4962	eval $xscan;\
4963	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4964		eval $xrun
4965elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4966	eval $xscan;\
4967	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4968		eval $xrun
4969elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4970	eval $xscan;\
4971	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4972		eval $xrun
4973elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4974	eval $xscan;\
4975	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4976		eval $xrun
4977elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4978	eval $xscan;\
4979	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4980		eval $xrun
4981elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4982				-e '/ file/d' -e 's/^\([^ 	]*\).*/\1/p'";\
4983	eval $xscan;\
4984	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4985		eval $xrun
4986elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4987	eval $xscan;\
4988	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4989		eval $xrun
4990elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4991	eval $xscan;\
4992	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4993		eval $xrun
4994elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4995	eval $xscan;\
4996	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
4997		eval $xrun
4998elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4999	eval $xscan;\
5000	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
5001		eval $xrun
5002elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
5003	eval $xscan;\
5004	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
5005		eval $xrun
5006elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
5007	eval $xscan;\
5008	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
5009		eval $xrun
5010elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
5011	eval $xscan;\
5012	$contains '^fprintf$' libc.list >/dev/null 2>&1; then
5013		eval $xrun
5014else
5015	$nm -p $* 2>/dev/null >libc.tmp
5016	$grep fprintf libc.tmp > libc.ptf
5017	if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
5018		eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
5019	then
5020		nm_opt='-p'
5021		eval $xrun
5022	else
5023		echo " "
5024		echo "$nm didn't seem to work right. Trying $ar instead..." >&4
5025		com=''
5026		if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
5027			for thisname in $libnames $libc; do
5028				$ar t $thisname >>libc.tmp
5029			done
5030			$sed -e "s/\\$_o\$//" < libc.tmp > libc.list
5031			echo "Ok." >&4
5032		elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
5033			# Repeat libc to extract forwarders to DLL entries too
5034			for thisname in $libnames $libc; do
5035				$ar tv $thisname >>libc.tmp
5036				# Revision 50 of EMX has bug in $ar.
5037				# it will not extract forwarders to DLL entries
5038				# Use emximp which will extract exactly them.
5039				emximp -o tmp.imp $thisname \
5040				    2>/dev/null && \
5041				    $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
5042				    < tmp.imp >>libc.tmp
5043				$rm tmp.imp
5044			done
5045			$sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
5046			echo "Ok." >&4
5047		else
5048			echo "$ar didn't seem to work right." >&4
5049			echo "Maybe this is a Cray...trying bld instead..." >&4
5050			if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
5051			then
5052				for thisname in $libnames; do
5053					bld t $libnames | \
5054					$sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
5055					$ar t $thisname >>libc.tmp
5056				done
5057				echo "Ok." >&4
5058			else
5059				echo "That didn't work either.  Giving up." >&4
5060				exit 1
5061			fi
5062		fi
5063	fi
5064fi
5065nm_extract="$com"
5066if $test -f /lib/syscalls.exp; then
5067	echo " "
5068	echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
5069	$sed -n 's/^\([^ 	]*\)[ 	]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
5070fi
5071;;
5072esac
5073$rm -f libnames libpath
5074
5075: is a C symbol defined?
5076csym='tlook=$1;
5077case "$3" in
5078-v) tf=libc.tmp; tc=""; tdc="";;
5079-a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5080*) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5081esac;
5082tx=yes;
5083case "$reuseval-$4" in
5084true-) ;;
5085true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5086esac;
5087case "$tx" in
5088yes)
5089	case "$runnm" in
5090	true)
5091		if $contains $tlook $tf >/dev/null 2>&1;
5092		then tval=true;
5093		else tval=false;
5094		fi;;
5095	*)
5096		echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5097		if $cc -o t $optimize $ccflags $ldflags t.c $libs >/dev/null 2>&1;
5098		then tval=true;
5099		else tval=false;
5100		fi;
5101		$rm -f t t.c;;
5102	esac;;
5103*)
5104	case "$tval" in
5105	$define) tval=true;;
5106	*) tval=false;;
5107	esac;;
5108esac;
5109eval "$2=$tval"'
5110
5111: define an is-in-libc? function
5112inlibc='echo " "; td=$define; tu=$undef;
5113sym=$1; var=$2; eval "was=\$$2";
5114tx=yes;
5115case "$reuseval$was" in
5116true) ;;
5117true*) tx=no;;
5118esac;
5119case "$tx" in
5120yes)
5121	set $sym tres -f;
5122	eval $csym;
5123	case "$tres" in
5124	true)
5125		echo "$sym() found." >&4;
5126		case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5127	*)
5128		echo "$sym() NOT found." >&4;
5129		case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5130	esac;;
5131*)
5132	case "$was" in
5133	$define) echo "$sym() found." >&4;;
5134	*) echo "$sym() NOT found." >&4;;
5135	esac;;
5136esac'
5137
5138: see if sqrtl exists
5139set sqrtl d_sqrtl
5140eval $inlibc
5141
5142case "$ccflags" in
5143*-DUSE_LONG_DOUBLE*|*-DUSE_MORE_BITS*) uselongdouble="$define" ;;
5144esac
5145
5146case "$uselongdouble" in
5147$define|true|[yY]*)	dflt='y';;
5148*) dflt='n';;
5149esac
5150cat <<EOM
5151
5152Perl can be built to take advantage of long doubles which
5153(if available) may give more accuracy and range for floating point numbers.
5154
5155If this doesn't make any sense to you, just accept the default '$dflt'.
5156EOM
5157rp='Try to use long doubles if available?'
5158. ./myread
5159case "$ans" in
5160y|Y) 	val="$define"	;;
5161*)      val="$undef"	;;
5162esac
5163set uselongdouble
5164eval $setvar
5165
5166case "$uselongdouble" in
5167true|[yY]*) uselongdouble="$define" ;;
5168esac
5169
5170case "$uselongdouble" in
5171$define)
5172: Look for a hint-file generated 'call-back-unit'.  If the
5173: user has specified that long doubles should be used,
5174: we may need to set or change some other defaults.
5175	if $test -f uselongdouble.cbu; then
5176		echo "Your platform has some specific hints for long doubles, using them..."
5177		. ./uselongdouble.cbu
5178	else
5179		$cat <<EOM
5180(Your platform doesn't have any specific hints for long doubles.)
5181EOM
5182	fi
5183	;;
5184esac
5185
5186case "$uselongdouble:$d_sqrtl" in
5187$define:$undef)
5188		$cat <<EOM >&4
5189
5190*** You requested the use of long doubles but you do not seem to have
5191*** the mathematic functions for long doubles.  I'm disabling the use
5192*** of long doubles.
5193
5194EOM
5195	uselongdouble=$undef
5196	;;
5197esac
5198
5199: check for length of double
5200echo " "
5201case "$doublesize" in
5202'')
5203	echo "Checking to see how big your double precision numbers are..." >&4
5204	$cat >try.c <<'EOCP'
5205#include <stdio.h>
5206int main()
5207{
5208    printf("%d\n", (int)sizeof(double));
5209    exit(0);
5210}
5211EOCP
5212	set try
5213	if eval $compile_ok; then
5214		doublesize=`./try`
5215		echo "Your double is $doublesize bytes long."
5216	else
5217		dflt='8'
5218		echo "(I can't seem to compile the test program.  Guessing...)"
5219		rp="What is the size of a double precision number (in bytes)?"
5220		. ./myread
5221		doublesize="$ans"
5222	fi
5223	;;
5224esac
5225$rm -f try.c try
5226
5227: check for long doubles
5228echo " "
5229echo "Checking to see if you have long double..." >&4
5230echo 'int main() { long double x = 7.0; }' > try.c
5231set try
5232if eval $compile; then
5233	val="$define"
5234	echo "You have long double."
5235else
5236	val="$undef"
5237	echo "You do not have long double."
5238fi
5239$rm try.*
5240set d_longdbl
5241eval $setvar
5242
5243: check for length of long double
5244case "${d_longdbl}${longdblsize}" in
5245$define)
5246	echo " "
5247	echo "Checking to see how big your long doubles are..." >&4
5248	$cat >try.c <<'EOCP'
5249#include <stdio.h>
5250int main()
5251{
5252	printf("%d\n", sizeof(long double));
5253}
5254EOCP
5255	set try
5256	set try
5257	if eval $compile; then
5258		longdblsize=`./try$exe_ext`
5259		echo "Your long doubles are $longdblsize bytes long."
5260	else
5261		dflt='8'
5262		echo " "
5263		echo "(I can't seem to compile the test program.  Guessing...)" >&4
5264		rp="What is the size of a long double (in bytes)?"
5265		. ./myread
5266		longdblsize="$ans"
5267	fi
5268	if $test "X$doublesize" = "X$longdblsize"; then
5269		echo "(That isn't any different from an ordinary double.)"
5270	fi
5271	;;
5272esac
5273$rm -f try.* try
5274
5275: determine the architecture name
5276echo " "
5277if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
5278	tarch=`arch`"-$osname"
5279elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
5280	if uname -m > tmparch 2>&1 ; then
5281		tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
5282			-e 's/$/'"-$osname/" tmparch`
5283	else
5284		tarch="$osname"
5285	fi
5286	$rm -f tmparch
5287else
5288	tarch="$osname"
5289fi
5290case "$myarchname" in
5291''|"$tarch") ;;
5292*)
5293	echo "(Your architecture name used to be $myarchname.)"
5294	archname=''
5295	;;
5296esac
5297myarchname="$tarch"
5298case "$archname" in
5299'') dflt="$tarch";;
5300*) dflt="$archname";;
5301esac
5302rp='What is your architecture name'
5303. ./myread
5304archname="$ans"
5305case "$usethreads" in
5306$define)
5307	echo "Threads selected." >&4
5308	case "$archname" in
5309        *-thread*) echo "...and architecture name already has -thread." >&4
5310                ;;
5311        *)      archname="$archname-thread"
5312                echo "...setting architecture name to $archname." >&4
5313                ;;
5314        esac
5315	;;
5316esac
5317case "$usemultiplicity" in
5318$define)
5319	echo "Multiplicity selected." >&4
5320	case "$archname" in
5321        *-multi*) echo "...and architecture name already has -multi." >&4
5322                ;;
5323        *)      archname="$archname-multi"
5324                echo "...setting architecture name to $archname." >&4
5325                ;;
5326        esac
5327	;;
5328esac
5329case "$use64bitint$use64bitall" in
5330*"$define"*)
5331	case "$archname64" in
5332	'')
5333		echo "This architecture is naturally 64-bit, not changing architecture name." >&4
5334		;;
5335	*)
5336		case "$use64bitint" in
5337		"$define") echo "64 bit integers selected." >&4 ;;
5338		esac
5339		case "$use64bitall" in
5340		"$define") echo "Maximal 64 bitness selected." >&4 ;;
5341		esac
5342		case "$archname" in
5343	        *-$archname64*) echo "...and architecture name already has $archname64." >&4
5344	                ;;
5345	        *)      archname="$archname-$archname64"
5346	                echo "...setting architecture name to $archname." >&4
5347	                ;;
5348	        esac
5349		;;
5350	esac
5351esac
5352case "$uselongdouble" in
5353$define)
5354	echo "Long doubles selected." >&4
5355	case "$longdblsize" in
5356	$doublesize)
5357		"...but long doubles are equal to doubles, not changing architecture name." >&4
5358		;;
5359	*)
5360		case "$archname" in
5361	        *-ld*) echo "...and architecture name already has -ld." >&4
5362	                ;;
5363	        *)      archname="$archname-ld"
5364	                echo "...setting architecture name to $archname." >&4
5365        	        ;;
5366	        esac
5367		;;
5368	esac
5369	;;
5370esac
5371case "$useperlio" in
5372$define)
5373	echo "Perlio selected." >&4
5374	case "$archname" in
5375        *-perlio*) echo "...and architecture name already has -perlio." >&4
5376                ;;
5377        *)      archname="$archname-perlio"
5378                echo "...setting architecture name to $archname." >&4
5379                ;;
5380        esac
5381	;;
5382esac
5383
5384: determine root of directory hierarchy where package will be installed.
5385case "$prefix" in
5386'')
5387	dflt=`./loc . /usr/local /usr/local /local /opt /usr`
5388	;;
5389*)
5390	dflt="$prefix"
5391	;;
5392esac
5393$cat <<EOM
5394
5395By default, $package will be installed in $dflt/bin, manual pages
5396under $dflt/man, etc..., i.e. with $dflt as prefix for all
5397installation directories. Typically this is something like /usr/local.
5398If you wish to have binaries under /usr/bin but other parts of the
5399installation under /usr/local, that's ok: you will be prompted
5400separately for each of the installation directories, the prefix being
5401only used to set the defaults.
5402
5403EOM
5404fn=d~
5405rp='Installation prefix to use?'
5406. ./getfile
5407oldprefix=''
5408case "$prefix" in
5409'') ;;
5410*)
5411	case "$ans" in
5412	"$prefix") ;;
5413	*) oldprefix="$prefix";;
5414	esac
5415	;;
5416esac
5417prefix="$ans"
5418prefixexp="$ansexp"
5419
5420: is AFS running?
5421echo " "
5422case "$afs" in
5423$define|true)	afs=true ;;
5424$undef|false)	afs=false ;;
5425*)	if test -d /afs; then
5426		afs=true
5427	else
5428		afs=false
5429	fi
5430	;;
5431esac
5432if test $afs = "true"; then
5433	echo "AFS may be running... I'll be extra cautious then..." >&4
5434else
5435	echo "AFS does not seem to be running..." >&4
5436fi
5437
5438: determine installation prefix for where package is to be installed.
5439if $afs; then
5440$cat <<EOM
5441
5442Since you are running AFS, I need to distinguish the directory in which
5443files will reside from the directory in which they are installed (and from
5444which they are presumably copied to the former directory by occult means).
5445
5446EOM
5447	case "$installprefix" in
5448	'') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
5449	*) dflt="$installprefix";;
5450	esac
5451else
5452$cat <<EOM
5453
5454In some special cases, particularly when building $package for distribution,
5455it is convenient to distinguish between the directory in which files should 
5456be installed from the directory ($prefix) in which they 
5457will eventually reside.  For most users, these two directories are the same.
5458
5459EOM
5460	case "$installprefix" in
5461	'') dflt=$prefix ;;
5462	*) dflt=$installprefix;;
5463	esac
5464fi
5465fn=d~
5466rp='What installation prefix should I use for installing files?'
5467. ./getfile
5468installprefix="$ans"
5469installprefixexp="$ansexp"
5470
5471: set the prefixit variable, to compute a suitable default value
5472prefixit='case "$3" in
5473""|none)
5474	case "$oldprefix" in
5475	"") eval "$1=\"\$$2\"";;
5476	*)
5477		case "$3" in
5478		"") eval "$1=";;
5479		none)
5480			eval "tp=\"\$$2\"";
5481			case "$tp" in
5482			""|" ") eval "$1=\"\$$2\"";;
5483			*) eval "$1=";;
5484			esac;;
5485		esac;;
5486	esac;;
5487*)
5488	eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
5489	case "$tp" in
5490	--|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
5491	/*-$oldprefix/*|\~*-$oldprefix/*)
5492		eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
5493	*) eval "$1=\"\$$2\"";;
5494	esac;;
5495esac'
5496
5497
5498: get the patchlevel
5499echo " "
5500echo "Getting the current patchlevel..." >&4
5501if $test -r $rsrc/patchlevel.h;then
5502	revision=`awk '/define[ 	]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
5503	patchlevel=`awk '/define[ 	]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
5504	subversion=`awk '/define[ 	]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
5505	api_revision=`awk '/define[ 	]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
5506	api_version=`awk '/define[ 	]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
5507	api_subversion=`awk '/define[ 	]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
5508else
5509	revision=0
5510	patchlevel=0
5511	subversion=0
5512	api_revision=0
5513	api_version=0
5514	api_subversion=0
5515fi
5516$echo "(You have $package version $patchlevel subversion $subversion.)"
5517case "$osname" in
5518dos|vms)
5519	: XXX Should be a Configure test for double-dots in filenames.
5520	version=`echo $revision $patchlevel $subversion | \
5521		 $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
5522	api_versionstring=`echo $api_revision $api_version $api_subversion | \
5523		 $awk '{ printf "%d_%d_%d\n", $1, $2, $3 }'`
5524	;;
5525*)
5526	version=`echo $revision $patchlevel $subversion | \
5527		 $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
5528	api_versionstring=`echo $api_revision $api_version $api_subversion | \
5529		 $awk '{ printf "%d.%d.%d\n", $1, $2, $3 }'`
5530	;;
5531esac
5532: Special case the 5.005_xx maintenance series, which used 5.005
5533: without any subversion label as a subdirectory in $sitelib
5534if test "${api_revision}${api_version}${api_subversion}" = "550"; then
5535	api_versionstring='5.005'
5536fi
5537
5538: determine installation style
5539: For now, try to deduce it from prefix unless it is already set.
5540: Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
5541case "$installstyle" in
5542'')	case "$prefix" in
5543		*perl*) dflt='lib';;
5544		*) dflt='lib/perl5' ;;
5545	esac
5546	;;
5547*)	dflt="$installstyle" ;;
5548esac
5549: Probably not worth prompting for this since we prompt for all
5550: the directories individually, and the prompt would be too long and
5551: confusing anyway.
5552installstyle=$dflt
5553
5554: determine where private library files go
5555: Usual default is /usr/local/lib/perl5/$version.
5556: Also allow things like /opt/perl/lib/$version, since
5557: /opt/perl/lib/perl5... would be redundant.
5558: The default "style" setting is made in installstyle.U
5559case "$installstyle" in
5560*lib/perl5*) set dflt privlib lib/$package/$version ;;
5561*)	 set dflt privlib lib/$version ;;
5562esac
5563eval $prefixit
5564$cat <<EOM
5565
5566There are some auxiliary files for $package that need to be put into a
5567private library directory that is accessible by everyone.
5568
5569EOM
5570fn=d~+
5571rp='Pathname where the private library files will reside?'
5572. ./getfile
5573privlib="$ans"
5574privlibexp="$ansexp"
5575: Change installation prefix, if necessary.
5576if $test X"$prefix" != X"$installprefix"; then
5577	installprivlib=`echo $privlibexp | sed "s#^$prefix#$installprefix#"`
5578else
5579	installprivlib="$privlibexp"
5580fi
5581
5582: set the prefixup variable, to restore leading tilda escape
5583prefixup='case "$prefixexp" in
5584"$prefix") ;;
5585*) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
5586esac'
5587
5588: determine where public architecture dependent libraries go
5589set archlib archlib
5590eval $prefixit
5591: privlib default is /usr/local/lib/$package/$version
5592: archlib default is /usr/local/lib/$package/$version/$archname
5593: privlib may have an optional trailing /share.
5594tdflt=`echo $privlib | $sed 's,/share$,,'`
5595tdflt=$tdflt/$archname
5596case "$archlib" in
5597'')	dflt=$tdflt
5598	;;
5599*)	dflt="$archlib"
5600    ;;
5601esac
5602$cat <<EOM
5603
5604$spackage contains architecture-dependent library files.  If you are
5605sharing libraries in a heterogeneous environment, you might store
5606these files in a separate location.  Otherwise, you can just include
5607them with the rest of the public library files.
5608
5609EOM
5610fn=d+~
5611rp='Where do you want to put the public architecture-dependent libraries?'
5612. ./getfile
5613archlib="$ans"
5614archlibexp="$ansexp"
5615if $test X"$archlib" = X"$privlib"; then
5616	d_archlib="$undef"
5617else
5618	d_archlib="$define"
5619fi
5620: Change installation prefix, if necessary.
5621if $test X"$prefix" != X"$installprefix"; then
5622	installarchlib=`echo $archlibexp | sed "s#^$prefix#$installprefix#"`
5623else
5624	installarchlib="$archlibexp"
5625fi
5626
5627
5628: Binary compatibility with 5.005 is not possible for builds
5629: with advanced features
5630case "$usethreads$usemultiplicity" in
5631*define*)
5632	bincompat5005="$undef"
5633	d_bincompat5005="$undef"
5634	;;
5635*)	$cat <<EOM
5636
5637This version of Perl can be compiled for binary compatibility with 5.005.
5638If you decide to do so, you will be able to continue using most of the
5639extensions that were compiled for Perl 5.005.
5640
5641EOM
5642	case "$bincompat5005$d_bincompat5005" in
5643	*"$undef"*) dflt=n ;;
5644	*) dflt=y ;;
5645	esac
5646	rp='Binary compatibility with Perl 5.005?'
5647	. ./myread
5648	case "$ans" in
5649	y*) val="$define" ;;
5650	*)  val="$undef" ;;
5651	esac
5652	set d_bincompat5005
5653	eval $setvar
5654	case "$d_bincompat5005" in
5655	"$define")
5656		bincompat5005="$define"
5657		;;
5658	*)	bincompat5005="$undef"
5659		d_bincompat5005="$undef"
5660		;;
5661	esac
5662	;;
5663esac
5664
5665
5666: see if setuid scripts can be secure
5667$cat <<EOM
5668
5669Some kernels have a bug that prevents setuid #! scripts from being
5670secure.  Some sites have disabled setuid #! scripts because of this.
5671
5672First let's decide if your kernel supports secure setuid #! scripts.
5673(If setuid #! scripts would be secure but have been disabled anyway,
5674don't say that they are secure if asked.)
5675
5676EOM
5677
5678val="$undef"
5679if $test -d /dev/fd; then
5680	echo "#!$ls" >reflect
5681	chmod +x,u+s reflect
5682	./reflect >flect 2>&1
5683	if $contains "/dev/fd" flect >/dev/null; then
5684		echo "Congratulations, your kernel has secure setuid scripts!" >&4
5685		val="$define"
5686	else
5687		$cat <<EOM
5688If you are not sure if they are secure, I can check but I'll need a
5689username and password different from the one you are using right now.
5690If you don't have such a username or don't want me to test, simply
5691enter 'none'.
5692
5693EOM
5694		rp='Other username to test security of setuid scripts with?'
5695		dflt='none'
5696		. ./myread
5697		case "$ans" in
5698		n|none)
5699			case "$d_suidsafe" in
5700			'')	echo "I'll assume setuid scripts are *not* secure." >&4
5701				dflt=n;;
5702			"$undef")
5703				echo "Well, the $hint value is *not* secure." >&4
5704				dflt=n;;
5705			*)	echo "Well, the $hint value *is* secure." >&4
5706				dflt=y;;
5707			esac
5708			;;
5709		*)
5710			$rm -f reflect flect
5711			echo "#!$ls" >reflect
5712			chmod +x,u+s reflect
5713			echo >flect
5714			chmod a+w flect
5715			echo '"su" will (probably) prompt you for '"$ans's password."
5716			su $ans -c './reflect >flect'
5717			if $contains "/dev/fd" flect >/dev/null; then
5718				echo "Okay, it looks like setuid scripts are secure." >&4
5719				dflt=y
5720			else
5721				echo "I don't think setuid scripts are secure." >&4
5722				dflt=n
5723			fi
5724			;;
5725		esac
5726		rp='Does your kernel have *secure* setuid scripts?'
5727		. ./myread
5728		case "$ans" in
5729		[yY]*)	val="$define";;
5730		*)	val="$undef";;
5731		esac
5732	fi
5733else
5734	echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
5735	echo "(That's for file descriptors, not floppy disks.)"
5736	val="$undef"
5737fi
5738set d_suidsafe
5739eval $setvar
5740
5741$rm -f reflect flect
5742
5743: now see if they want to do setuid emulation
5744echo " "
5745val="$undef"
5746case "$d_suidsafe" in
5747"$define")
5748	val="$undef"
5749	echo "No need to emulate SUID scripts since they are secure here." >& 4
5750	;;
5751*)
5752	$cat <<EOM
5753Some systems have disabled setuid scripts, especially systems where
5754setuid scripts cannot be secure.  On systems where setuid scripts have
5755been disabled, the setuid/setgid bits on scripts are currently
5756useless.  It is possible for $package to detect those bits and emulate
5757setuid/setgid in a secure fashion.  This emulation will only work if
5758setuid scripts have been disabled in your kernel.
5759
5760EOM
5761	case "$d_dosuid" in
5762	"$define") dflt=y ;;
5763	*) dflt=n ;;
5764	esac
5765	rp="Do you want to do setuid/setgid emulation?"
5766	. ./myread
5767	case "$ans" in
5768	[yY]*)	val="$define";;
5769	*)	val="$undef";;
5770	esac
5771	;;
5772esac
5773set d_dosuid
5774eval $setvar
5775
5776: determine filename position in cpp output
5777echo " "
5778echo "Computing filename position in cpp output for #include directives..." >&4
5779echo '#include <stdio.h>' > foo.c
5780$cat >fieldn <<EOF
5781$startsh
5782$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
5783$grep '^[ 	]*#.*stdio\.h' | \
5784while read cline; do
5785	pos=1
5786	set \$cline
5787	while $test \$# -gt 0; do
5788		if $test -r \`echo \$1 | $tr -d '"'\`; then
5789			echo "\$pos"
5790			exit 0
5791		fi
5792		shift
5793		pos=\`expr \$pos + 1\`
5794	done
5795done
5796EOF
5797chmod +x fieldn
5798fieldn=`./fieldn`
5799$rm -f foo.c fieldn
5800case $fieldn in
5801'') pos='???';;
58021) pos=first;;
58032) pos=second;;
58043) pos=third;;
5805*) pos="${fieldn}th";;
5806esac
5807echo "Your cpp writes the filename in the $pos field of the line."
5808
5809: locate header file
5810$cat >findhdr <<EOF
5811$startsh
5812wanted=\$1
5813name=''
5814for usrincdir in $usrinc
5815do
5816	if test -f \$usrincdir/\$wanted; then
5817		echo "\$usrincdir/\$wanted"
5818		exit 0
5819	fi
5820done
5821awkprg='{ print \$$fieldn }'
5822echo "#include <\$wanted>" > foo\$\$.c
5823$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
5824$grep "^[ 	]*#.*\$wanted" | \
5825while read cline; do
5826	name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
5827	case "\$name" in
5828	*[/\\\\]\$wanted) echo "\$name"; exit 1;;
5829	*[\\\\/]\$wanted) echo "\$name"; exit 1;;
5830	*) exit 2;;
5831	esac;
5832done;
5833#
5834# status = 0: grep returned 0 lines, case statement not executed
5835# status = 1: headerfile found
5836# status = 2: while loop executed, no headerfile found
5837#
5838status=\$?
5839$rm -f foo\$\$.c;
5840if test \$status -eq 1; then
5841	exit 0;
5842fi
5843exit 1
5844EOF
5845chmod +x findhdr
5846
5847: define an alternate in-header-list? function
5848inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
5849cont=true; xxf="echo \"<\$1> found.\" >&4";
5850case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
5851*) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
5852esac;
5853case $# in 4) instead=instead;; *) instead="at last";; esac;
5854while $test "$cont"; do
5855	xxx=`./findhdr $1`
5856	var=$2; eval "was=\$$2";
5857	if $test "$xxx" && $test -r "$xxx";
5858	then eval $xxf;
5859	eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
5860		cont="";
5861	else eval $xxnf;
5862	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
5863	set $yyy; shift; shift; yyy=$@;
5864	case $# in 0) cont="";;
5865	2) xxf="echo \"but I found <\$1> $instead.\" >&4";
5866		xxnf="echo \"and I did not find <\$1> either.\" >&4";;
5867	*) xxf="echo \"but I found <\$1\> instead.\" >&4";
5868		xxnf="echo \"there is no <\$1>, ...\" >&4";;
5869	esac;
5870done;
5871while $test "$yyy";
5872do set $yyy; var=$2; eval "was=\$$2";
5873	eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
5874	set $yyy; shift; shift; yyy=$@;
5875done'
5876
5877: see if this is a malloc.h system
5878set malloc.h i_malloc
5879eval $inhdr
5880
5881: see if stdlib is available
5882set stdlib.h i_stdlib
5883eval $inhdr
5884
5885: determine which malloc to compile in
5886echo " "
5887case "$usemymalloc" in
5888''|[yY]*|true|$define)	dflt='y' ;;
5889*)	dflt='n' ;;
5890esac
5891rp="Do you wish to attempt to use the malloc that comes with $package?"
5892. ./myread
5893usemymalloc="$ans"
5894case "$ans" in
5895y*|true)
5896	usemymalloc='y'
5897	mallocsrc='malloc.c'
5898	mallocobj="malloc$_o"
5899	d_mymalloc="$define"
5900	case "$libs" in
5901	*-lmalloc*)
5902		: Remove malloc from list of libraries to use
5903		echo "Removing unneeded -lmalloc from library list" >&4
5904		set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
5905		shift
5906		libs="$*"
5907		echo "libs = $libs" >&4
5908		;;
5909	esac
5910	;;
5911*)
5912	usemymalloc='n'
5913	mallocsrc=''
5914	mallocobj=''
5915	d_mymalloc="$undef"
5916	;;
5917esac
5918
5919: compute the return types of malloc and free
5920echo " "
5921$cat >malloc.c <<END
5922#$i_malloc I_MALLOC
5923#$i_stdlib I_STDLIB
5924#include <stdio.h>
5925#include <sys/types.h>
5926#ifdef I_MALLOC
5927#include <malloc.h>
5928#endif
5929#ifdef I_STDLIB
5930#include <stdlib.h>
5931#endif
5932#ifdef TRY_MALLOC
5933void *malloc();
5934#endif
5935#ifdef TRY_FREE
5936void free();
5937#endif
5938END
5939case "$malloctype" in
5940'')
5941	if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
5942		malloctype='void *'
5943	else
5944		malloctype='char *'
5945	fi
5946	;;
5947esac
5948echo "Your system wants malloc to return '$malloctype', it would seem." >&4
5949
5950case "$freetype" in
5951'')
5952	if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
5953		freetype='void'
5954	else
5955		freetype='int'
5956	fi
5957	;;
5958esac
5959echo "Your system uses $freetype free(), it would seem." >&4
5960$rm -f malloc.[co]
5961$cat <<EOM
5962
5963After $package is installed, you may wish to install various
5964add-on modules and utilities.  Typically, these add-ons will
5965be installed under $prefix with the rest
5966of this package.  However, you may wish to install such add-ons
5967elsewhere under a different prefix.
5968
5969If you do not wish to put everything under a single prefix, that's
5970ok.  You will be prompted for the individual locations; this siteprefix
5971is only used to suggest the defaults.
5972
5973The default should be fine for most people.
5974
5975EOM
5976fn=d~+
5977rp='Installation prefix to use for add-on modules and utilities?'
5978: XXX Here might be another good place for an installstyle setting.
5979case "$siteprefix" in
5980'') dflt=$prefix ;;
5981*)  dflt=$siteprefix ;;
5982esac
5983. ./getfile
5984: XXX Prefixit unit does not yet support siteprefix and vendorprefix
5985oldsiteprefix=''
5986case "$siteprefix" in
5987'') ;;
5988*)	case "$ans" in
5989	"$prefix") ;;
5990	*) oldsiteprefix="$prefix";;
5991	esac
5992	;;
5993esac
5994siteprefix="$ans"
5995siteprefixexp="$ansexp"
5996
5997: determine where site specific libraries go.
5998: Usual default is /usr/local/lib/perl5/site_perl/$version
5999: The default "style" setting is made in installstyle.U
6000: XXX No longer works with Prefixit stuff.
6001prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6002case "$sitelib" in
6003'') case "$installstyle" in
6004	*lib/perl5*) dflt=$siteprefix/lib/$package/site_$prog/$version ;;
6005	*)	 dflt=$siteprefix/lib/site_$prog/$version ;;
6006	esac
6007	;;
6008*)	dflt="$sitelib"
6009	;;
6010esac
6011$cat <<EOM
6012
6013The installation process will create a directory for
6014site-specific extensions and modules.  Most users find it convenient
6015to place all site-specific files in this directory rather than in the
6016main distribution directory.
6017
6018EOM
6019fn=d~+
6020rp='Pathname for the site-specific library files?'
6021. ./getfile
6022sitelib="$ans"
6023sitelibexp="$ansexp"
6024sitelib_stem=`echo "$sitelibexp" | sed "s,/$version$,,"`
6025: Change installation prefix, if necessary.
6026if $test X"$prefix" != X"$installprefix"; then
6027	installsitelib=`echo $sitelibexp | $sed "s#^$prefix#$installprefix#"`
6028else
6029	installsitelib="$sitelibexp"
6030fi
6031
6032: determine where site specific architecture-dependent libraries go.
6033: sitelib  default is /usr/local/lib/perl5/site_perl/$version
6034: sitearch default is /usr/local/lib/perl5/site_perl/$version/$archname
6035: sitelib may have an optional trailing /share.
6036case "$sitearch" in
6037'')	dflt=`echo $sitelib | $sed 's,/share$,,'`
6038	dflt="$dflt/$archname"
6039	;;
6040*)	dflt="$sitearch"
6041	;;
6042esac
6043set sitearch sitearch none
6044eval $prefixit
6045$cat <<EOM
6046
6047The installation process will also create a directory for
6048architecture-dependent site-specific extensions and modules.
6049
6050EOM
6051fn=d~+
6052rp='Pathname for the site-specific architecture-dependent library files?'
6053. ./getfile
6054sitearch="$ans"
6055sitearchexp="$ansexp"
6056: Change installation prefix, if necessary.
6057if $test X"$prefix" != X"$installprefix"; then
6058	installsitearch=`echo $sitearchexp | sed "s#^$prefix#$installprefix#"`
6059else
6060	installsitearch="$sitearchexp"
6061fi
6062
6063$cat <<EOM
6064
6065The installation process will also create a directory for
6066vendor-supplied add-ons.  Vendors who supply perl with their system
6067may find it convenient to place all vendor-supplied files in this
6068directory rather than in the main distribution directory.  This will
6069ease upgrades between binary-compatible maintenance versions of perl.
6070
6071Of course you may also use these directories in whatever way you see
6072fit.  For example, you might use them to access modules shared over a
6073company-wide network.
6074
6075The default answer should be fine for most people.
6076This causes further questions about vendor add-ons to be skipped
6077and no vendor-specific directories will be configured for perl.
6078
6079EOM
6080rp='Do you want to configure vendor-specific add-on directories?'
6081case "$usevendorprefix" in
6082define|true|[yY]*) dflt=y ;;
6083*)	: User may have set vendorprefix directly on Configure command line.
6084	case "$vendorprefix" in
6085	''|' ') dflt=n ;;
6086	*)	dflt=y ;;
6087	esac
6088	;;
6089esac
6090. ./myread
6091case "$ans" in
6092[yY]*)	fn=d~+
6093	rp='Installation prefix to use for vendor-supplied add-ons?'
6094	case "$vendorprefix" in
6095	'') dflt='' ;;
6096	*)  dflt=$vendorprefix ;;
6097	esac
6098	. ./getfile
6099	: XXX Prefixit unit does not yet support siteprefix and vendorprefix
6100	oldvendorprefix=''
6101	case "$vendorprefix" in
6102	'') ;;
6103	*)	case "$ans" in
6104		"$prefix") ;;
6105		*) oldvendorprefix="$prefix";;
6106		esac
6107		;;
6108	esac
6109	usevendorprefix="$define"
6110	vendorprefix="$ans"
6111	vendorprefixexp="$ansexp"
6112	;;
6113*)	usevendorprefix="$undef"
6114	vendorprefix=''
6115	vendorprefixexp=''
6116	;;
6117esac
6118
6119case "$vendorprefix" in
6120'')	d_vendorlib="$undef"
6121	vendorlib=''
6122	vendorlibexp=''
6123	;;
6124*)	d_vendorlib="$define"
6125	: determine where vendor-supplied modules go.
6126	: Usual default is /usr/local/lib/perl5/vendor_perl/$version
6127	case "$vendorlib" in
6128	'')
6129		prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6130		case "$installstyle" in
6131		*lib/perl5*) dflt=$vendorprefix/lib/$package/vendor_$prog/$version ;;
6132		*)	     dflt=$vendorprefix/lib/vendor_$prog/$version ;;
6133		esac
6134		;;
6135	*)	dflt="$vendorlib"
6136		;;
6137	esac
6138	fn=d~+
6139	rp='Pathname for the vendor-supplied library files?'
6140	. ./getfile
6141	vendorlib="$ans"
6142	vendorlibexp="$ansexp"
6143	;;
6144esac
6145vendorlib_stem=`echo "$vendorlibexp" | sed "s,/$version$,,"`
6146: Change installation prefix, if necessary.
6147if $test X"$prefix" != X"$installprefix"; then
6148	installvendorlib=`echo $vendorlibexp | $sed "s#^$prefix#$installprefix#"`
6149else
6150	installvendorlib="$vendorlibexp"
6151fi
6152
6153case "$vendorprefix" in
6154'')	d_vendorarch="$undef"
6155	vendorarch=''
6156	vendorarchexp=''
6157	;;
6158*)	d_vendorarch="$define"
6159	: determine where vendor-supplied architecture-dependent libraries go.
6160	: vendorlib  default is /usr/local/lib/perl5/vendor_perl/$version
6161	: vendorarch default is /usr/local/lib/perl5/vendor_perl/$version/$archname
6162	: vendorlib may have an optional trailing /share.
6163	case "$vendorarch" in
6164	'')	dflt=`echo $vendorlib | $sed 's,/share$,,'`
6165		dflt="$dflt/$archname"
6166		;;
6167	*)	dflt="$vendorarch" ;;
6168	esac
6169	fn=d~+
6170	rp='Pathname for vendor-supplied architecture-dependent files?'
6171	. ./getfile
6172	vendorarch="$ans"
6173	vendorarchexp="$ansexp"
6174	;;
6175esac
6176: Change installation prefix, if necessary.
6177if $test X"$prefix" != X"$installprefix"; then
6178	installvendorarch=`echo $vendorarchexp | sed "s#^$prefix#$installprefix#"`
6179else
6180	installvendorarch="$vendorarchexp"
6181fi
6182
6183: Final catch-all directories to search
6184$cat <<EOM
6185
6186Lastly, you can have perl look in other directories for extensions and
6187modules in addition to those already specified.
6188These directories will be searched after 
6189	$sitearch 
6190	$sitelib 
6191EOM
6192test X"$vendorlib" != "X" && echo '	' $vendorlib
6193test X"$vendorarch" != "X" && echo '	' $vendorarch
6194echo ' '
6195case "$otherlibdirs" in
6196''|' ') dflt='none' ;;
6197*)	dflt="$otherlibdirs" ;;
6198esac
6199$cat <<EOM
6200Enter a colon-separated set of extra paths to include in perl's @INC
6201search path, or enter 'none' for no extra paths.
6202
6203EOM
6204
6205rp='Colon-separated list of additional directories for perl to search?'
6206. ./myread
6207case "$ans" in
6208' '|''|none)	otherlibdirs=' ' ;;
6209*)	otherlibdirs="$ans" ;;
6210esac
6211case "$otherlibdirs" in
6212' ') val=$undef ;;
6213*)	val=$define ;;
6214esac
6215set d_perl_otherlibdirs
6216eval $setvar
6217
6218: Cruising for prototypes
6219echo " "
6220echo "Checking out function prototypes..." >&4
6221$cat >prototype.c <<'EOCP'
6222int main(int argc, char *argv[]) {
6223	exit(0);}
6224EOCP
6225if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
6226	echo "Your C compiler appears to support function prototypes."
6227	val="$define"
6228else
6229	echo "Your C compiler doesn't seem to understand function prototypes."
6230	val="$undef"
6231fi
6232set prototype
6233eval $setvar
6234$rm -f prototype*
6235
6236case "$prototype" in
6237"$define") ;;
6238*)	ansi2knr='ansi2knr'
6239	echo " "
6240	cat <<EOM >&4
6241
6242$me:  FATAL ERROR:
6243This version of $package can only be compiled by a compiler that 
6244understands function prototypes.  Unfortunately, your C compiler 
6245	$cc $ccflags
6246doesn't seem to understand them.  Sorry about that.
6247
6248If GNU cc is available for your system, perhaps you could try that instead.  
6249
6250Eventually, we hope to support building Perl with pre-ANSI compilers.
6251If you would like to help in that effort, please contact <perlbug@perl.org>.
6252
6253Aborting Configure now.
6254EOM
6255	exit 2
6256	;;
6257esac
6258
6259: determine where public executables go
6260echo " "
6261set dflt bin bin
6262eval $prefixit
6263fn=d~
6264rp='Pathname where the public executables will reside?'
6265. ./getfile
6266if $test "X$ansexp" != "X$binexp"; then
6267	installbin=''
6268fi
6269bin="$ans"
6270binexp="$ansexp"
6271: Change installation prefix, if necessary.
6272: XXX Bug? -- ignores Configure -Dinstallprefix setting.
6273if $test X"$prefix" != X"$installprefix"; then
6274	installbin=`echo $binexp | sed "s#^$prefix#$installprefix#"`
6275else
6276	installbin="$binexp"
6277fi
6278
6279: Find perl5.005 or later.
6280echo "Looking for a previously installed perl5.005 or later... "
6281case "$perl5" in
6282'')	for tdir in `echo "$binexp:$PATH" | $sed "s/$path_sep/ /g"`; do
6283		: Check if this perl is recent and can load a simple module
6284		if $test -x $tdir/perl && $tdir/perl -Mless -e 'use 5.005;' >/dev/null 2>&1; then
6285			perl5=$tdir/perl
6286			break;
6287		elif $test -x $tdir/perl5 && $tdir/perl5 -Mless -e 'use 5.005;' >/dev/null 2>&1; then
6288			perl5=$tdir/perl
6289			break;
6290		fi
6291	done
6292	;;
6293*)	perl5="$perl5"
6294	;;
6295esac
6296case "$perl5" in
6297'')	echo "None found.  That's ok.";;
6298*)	echo "Using $perl5." ;;
6299esac
6300
6301: Determine list of previous versions to include in @INC
6302$cat > getverlist <<EOPL
6303#!$perl5 -w
6304use File::Basename;
6305\$api_versionstring = "$api_versionstring";
6306\$version = "$version";
6307\$stem = "$sitelib_stem";
6308\$archname = "$archname";
6309EOPL
6310	$cat >> getverlist <<'EOPL'
6311# Can't have leading @ because metaconfig interprets it as a command!
6312;@inc_version_list=();
6313# XXX Redo to do opendir/readdir?
6314if (-d $stem) {
6315    chdir($stem);
6316    ;@candidates = glob("5.*");
6317}
6318else {
6319    ;@candidates = ();
6320}
6321
6322# XXX ToDo:  These comparisons must be reworked when two-digit
6323# subversions come along, so that 5.7.10 compares as greater than
6324# 5.7.3!  By that time, hope that 5.6.x is sufficiently
6325# widespread that we can use the built-in version vectors rather
6326# than reinventing them here.  For 5.6.0, however, we must
6327# assume this script will likely be run by 5.005_0x.  --AD 1/2000.
6328foreach $d (@candidates) {
6329    if ($d lt $version) {
6330	if ($d ge $api_versionstring) {
6331	    unshift(@inc_version_list, grep { -d } "$d/$archname", $d);
6332	}
6333	elsif ($d ge "5.005") {
6334	    unshift(@inc_version_list, grep { -d } $d);
6335	}
6336    }
6337    else {
6338	# Skip newer version.  I.e. don't look in
6339	# 5.7.0 if we're installing 5.6.1.
6340    }
6341}
6342
6343if (@inc_version_list) {
6344    print join(' ', @inc_version_list);
6345}
6346else {
6347    # Blank space to preserve value for next Configure run.
6348    print " ";
6349}
6350EOPL
6351chmod +x getverlist
6352case "$inc_version_list" in
6353'')	if test -x "$perl5"; then
6354		dflt=`$perl5 getverlist`
6355	else
6356		dflt='none'
6357	fi
6358	;;
6359$undef) dflt='none' ;;
6360*)  dflt="$inc_version_list" ;;
6361esac
6362case "$dflt" in
6363''|' ') dflt=none ;;
6364esac
6365case "$dflt" in
63665.005) case "$bincompat5005" in
6367       $define|true|[yY]*) ;;
6368       *) dflt=none ;;
6369       esac
6370       ;;
6371esac
6372$cat <<'EOM'
6373
6374In order to ease the process of upgrading, this version of perl
6375can be configured to use modules built and installed with earlier
6376versions of perl that were installed under $prefix.  Specify here
6377the list of earlier versions that this version of perl should check.
6378If Configure detected no earlier versions of perl installed under
6379$prefix, then the list will be empty.  Answer 'none' to tell perl
6380to not search earlier versions.
6381
6382The default should almost always be sensible, so if you're not sure,
6383just accept the default.
6384EOM
6385
6386rp='List of earlier versions to include in @INC?'
6387. ./myread
6388case "$ans" in
6389[Nn]one|''|' ') inc_version_list=' ' ;;
6390*) inc_version_list="$ans" ;;
6391esac
6392case "$inc_version_list" in
6393''|' ')
6394	inc_version_list_init='0';;
6395*)	inc_version_list_init=`echo $inc_version_list |
6396		$sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
6397	;;
6398esac
6399$rm -f getverlist
6400
6401: determine whether to install perl also as /usr/bin/perl
6402
6403echo " "
6404if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
6405	$cat <<EOM
6406Many scripts expect perl to be installed as /usr/bin/perl.
6407I can install the perl you are about to compile also as /usr/bin/perl
6408(in addition to $installbin/perl).
6409EOM
6410	case "$installusrbinperl" in
6411	"$undef"|[nN]*)	dflt='n';;
6412	*)		dflt='y';;
6413	esac
6414	rp="Do you want to install perl as /usr/bin/perl?"
6415	. ./myread
6416	case "$ans" in
6417	[yY]*)	val="$define";;
6418	*)	val="$undef" ;;
6419	esac
6420else
6421	val="$undef"
6422fi
6423set installusrbinperl
6424eval $setvar
6425
6426: see if dld is available
6427set dld.h i_dld
6428eval $inhdr
6429
6430: see if dlopen exists
6431xxx_runnm="$runnm"
6432runnm=false
6433set dlopen d_dlopen
6434eval $inlibc
6435runnm="$xxx_runnm"
6436
6437: determine which dynamic loading, if any, to compile in
6438echo " "
6439dldir="ext/DynaLoader"
6440case "$usedl" in
6441$define|y|true)
6442	dflt='y'
6443	usedl="$define"
6444	;;
6445$undef|n|false)
6446	dflt='n'
6447	usedl="$undef"
6448	;;
6449*)
6450	dflt='n'
6451	case "$d_dlopen" in
6452	    $define) dflt='y' ;;
6453	esac
6454	case "$i_dld" in
6455	    $define) dflt='y' ;;
6456	esac
6457	: Does a dl_xxx.xs file exist for this operating system
6458	$test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
6459	;;
6460esac
6461rp="Do you wish to use dynamic loading?"
6462. ./myread
6463usedl="$ans"
6464case "$ans" in
6465y*) usedl="$define"
6466	case "$dlsrc" in
6467	'')
6468		if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
6469			dflt="$dldir/dl_${osname}.xs"
6470		elif $test "$d_dlopen" = "$define" ; then
6471			dflt="$dldir/dl_dlopen.xs"
6472		elif $test "$i_dld" = "$define" ; then
6473			dflt="$dldir/dl_dld.xs"
6474		else
6475			dflt=''
6476		fi
6477		;;
6478	*)	dflt="$dldir/$dlsrc"
6479		;;
6480	esac
6481    echo "The following dynamic loading files are available:"
6482	: Can not go over to $dldir because getfile has path hard-coded in.
6483	tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
6484	rp="Source file to use for dynamic loading"
6485	fn="fne"
6486	gfpth="$src"
6487	. ./getfile
6488	usedl="$define"
6489	: emulate basename
6490	dlsrc=`echo $ans | $sed -e 's%.*/\([^/]*\)$%\1%'`
6491
6492	$cat << EOM
6493
6494Some systems may require passing special flags to $cc -c to
6495compile modules that will be used to create a shared library.
6496To use no flags, say "none".
6497
6498EOM
6499    case "$cccdlflags" in
6500    '')	case "$gccversion" in
6501		'') case "$osname" in
6502			hpux)	dflt='+z' ;;
6503			next)	dflt='none' ;;
6504			irix*)	dflt='-KPIC' ;;
6505			svr4*|esix*|solaris|nonstopux) dflt='-KPIC' ;;
6506			sunos)	dflt='-pic' ;;
6507			*)	dflt='none' ;;
6508		    esac
6509			;;
6510		*)  case "$osname" in
6511			svr4*|esix*|solaris|nonstopux) dflt='-fPIC' ;;
6512			*)	dflt='-fpic' ;;
6513		    esac ;;
6514	    esac ;;
6515	' ') dflt='none' ;;
6516    *)	dflt="$cccdlflags" ;;
6517    esac
6518    rp="Any special flags to pass to $cc -c to compile shared library modules?"
6519    . ./myread
6520    case "$ans" in
6521    none) cccdlflags=' ' ;;
6522    *) cccdlflags="$ans" ;;
6523    esac
6524
6525    cat << EOM
6526
6527Some systems use ld to create libraries that can be dynamically loaded,
6528while other systems (such as those using ELF) use $cc.
6529
6530EOM
6531	case "$ld" in
6532	'')	$cat >try.c <<'EOM'
6533/* Test for whether ELF binaries are produced */
6534#include <fcntl.h>
6535#include <stdlib.h>
6536int main() {
6537	char b[4];
6538	int i = open("a.out",O_RDONLY);
6539	if(i == -1)
6540		exit(1); /* fail */
6541	if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
6542		exit(0); /* succeed (yes, it's ELF) */
6543	else
6544		exit(1); /* fail */
6545}
6546EOM
6547		if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
6548			cat <<EOM
6549You appear to have ELF support.  I'll use $cc to build dynamic libraries.
6550EOM
6551			dflt="$cc"
6552		else
6553			echo "I'll use ld to build dynamic libraries."
6554			dflt='ld'
6555		fi
6556		rm -f try.c a.out
6557		;;
6558	*)	dflt="$ld"
6559		;;
6560	esac
6561
6562    rp="What command should be used to create dynamic libraries?"
6563    . ./myread
6564	ld="$ans"
6565
6566    cat << EOM
6567
6568Some systems may require passing special flags to $ld to create a
6569library that can be dynamically loaded.  If your ld flags include
6570-L/other/path options to locate libraries outside your loader's normal
6571search path, you may need to specify those -L options here as well.  To
6572use no flags, say "none".
6573
6574EOM
6575    case "$lddlflags" in
6576    '') case "$osname" in
6577  			beos) dflt='-nostart' ;;
6578			hpux) dflt='-b';
6579			      case "$gccversion" in
6580			      '') dflt="$dflt +vnocompatwarnings" ;;
6581			      esac
6582			      ;;
6583			linux|irix*)	dflt='-shared' ;;
6584			next)  dflt='none' ;;
6585			solaris) dflt='-G' ;;
6586			sunos) dflt='-assert nodefinitions' ;;
6587			svr4*|esix*|nonstopux) dflt="-G $ldflags" ;;
6588	        *)     dflt='none' ;;
6589			esac
6590			;;
6591    *) dflt="$lddlflags" ;;
6592    esac
6593
6594	: Try to guess additional flags to pick up local libraries.
6595	: Be careful not to append to a plain 'none'
6596	case "$dflt" in
6597	none) dflt='' ;;
6598	esac
6599	for thisflag in $ldflags; do
6600		case "$thisflag" in
6601		-L*|-R*)
6602			case " $dflt " in
6603			*" $thisflag "*) ;;
6604			*) dflt="$dflt $thisflag" ;;
6605			esac
6606			;;
6607		esac
6608	done
6609
6610	case "$dflt" in
6611	''|' ') dflt='none' ;;
6612	esac
6613
6614    rp="Any special flags to pass to $ld to create a dynamically loaded library?"
6615    . ./myread
6616    case "$ans" in
6617    none) lddlflags=' ' ;;
6618    *) lddlflags="$ans" ;;
6619    esac
6620
6621	cat <<EOM
6622
6623Some systems may require passing special flags to $cc to indicate that
6624the resulting executable will use dynamic linking.  To use no flags,
6625say "none".
6626
6627EOM
6628    case "$ccdlflags" in
6629    '') case "$osname" in
6630		hpux)	dflt='-Wl,-E' ;;
6631		linux)	dflt='-rdynamic' ;;
6632		next)	dflt='none' ;;
6633		sunos)	dflt='none' ;;
6634		*)	dflt='none' ;;
6635	    esac ;;
6636    ' ')  dflt='none' ;;
6637    *)  dflt="$ccdlflags" ;;
6638    esac
6639    rp="Any special flags to pass to $cc to use dynamic linking?"
6640    . ./myread
6641    case "$ans" in
6642    none) ccdlflags=' ' ;;
6643    *) ccdlflags="$ans" ;;
6644    esac
6645    ;;
6646*)  usedl="$undef"
6647	ld='ld'
6648    dlsrc='dl_none.xs'
6649    lddlflags=''
6650    ccdlflags=''
6651    ;;
6652esac
6653
6654also=''
6655case "$usedl" in
6656$undef)
6657	# No dynamic loading being used, so don't bother even to prompt.
6658	useshrplib='false'
6659	;;
6660*)	case "$useshrplib" in
6661	'')	case "$osname" in
6662		svr4*|nonstopux|dgux|dynixptx|esix|powerux|beos|cygwin*)
6663			dflt=y
6664			also='Building a shared libperl is required for dynamic loading to work on your system.'
6665			;;
6666		next*)
6667			case "$osvers" in
6668			4*)	dflt=y
6669				also='Building a shared libperl is needed for MAB support.'
6670				;;
6671			*)	dflt=n
6672				;;
6673			esac
6674			;;
6675		*)	dflt=n
6676			;;
6677		esac
6678		;;
6679	$define|true|[Yy]*)
6680		dflt=y
6681		;;
6682	*)	dflt=n
6683		;;
6684	esac
6685	$cat << EOM
6686
6687The perl executable is normally obtained by linking perlmain.c with
6688libperl${_a}, any static extensions (usually just DynaLoader), and
6689any other libraries needed on this system (such as -lm, etc.).  Since
6690your system supports dynamic loading, it is probably possible to build
6691a shared libperl.$so.  If you will have more than one executable linked
6692to libperl.$so, this will significantly reduce the size of each
6693executable, but it may have a noticeable affect on performance.  The
6694default is probably sensible for your system.
6695$also
6696
6697EOM
6698	rp="Build a shared libperl.$so (y/n)"
6699	. ./myread
6700	case "$ans" in
6701	true|$define|[Yy]*)
6702		useshrplib='true'  ;;
6703	*)	useshrplib='false' ;;
6704	esac
6705	;;
6706esac
6707
6708case "$useshrplib" in
6709true)
6710	case "$libperl" in
6711	'')
6712		# Figure out a good name for libperl.so.  Since it gets stored in
6713		# a version-specific architecture-dependent library, the version
6714		# number isn't really that important, except for making cc/ld happy.
6715		#
6716		# A name such as libperl.so.3.1
6717		majmin="libperl.$so.$patchlevel.$subversion"
6718		# A name such as libperl.so.301
6719		majonly=`echo $patchlevel $subversion |
6720			$awk '{printf "%d%02d", $1, $2}'`
6721		majonly=libperl.$so.$majonly
6722		# I'd prefer to keep the os-specific stuff here to a minimum, and
6723		# rely on figuring it out from the naming of libc.
6724		case "${osname}${osvers}" in
6725		next4*)
6726			dflt=libperl.5.$so
6727			# XXX How handle the --version stuff for MAB?
6728			;;
6729		linux*)  # ld won't link with a bare -lperl otherwise.
6730			dflt=libperl.$so
6731			;;
6732		cygwin*) # include version
6733			dflt=`echo libperl$version | sed -e 's/\./_/g'`$lib_ext
6734			;;
6735		*)	# Try to guess based on whether libc has major.minor.
6736			case "$libc" in
6737			*libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
6738			*libc.$so.[0-9]*) dflt=$majonly ;;
6739			*)	dflt=libperl.$so ;;
6740			esac
6741			;;
6742		esac
6743		;;
6744	*)	dflt=$libperl
6745		;;
6746	esac
6747	cat << EOM
6748
6749I need to select a good name for the shared libperl.  If your system uses
6750library names with major and minor numbers, then you might want something
6751like $majmin.  Alternatively, if your system uses a single version
6752number for shared libraries, then you might want to use $majonly.
6753Or, your system might be quite happy with a simple libperl.$so.
6754
6755Since the shared libperl will get installed into a version-specific
6756architecture-dependent directory, the version number of the shared perl
6757library probably isn't important, so the default should be o.k.
6758
6759EOM
6760	rp='What name do you want to give to the shared libperl?'
6761	. ./myread
6762	libperl=$ans
6763	echo "Ok, I'll use $libperl"
6764	;;
6765*)
6766	libperl="libperl${_a}"
6767	;;
6768esac
6769
6770# Detect old use of shrpdir via undocumented Configure -Dshrpdir
6771case "$shrpdir" in
6772'') ;;
6773*)	$cat >&4 <<EOM
6774WARNING:  Use of the shrpdir variable for the installation location of
6775the shared $libperl is not supported.  It was never documented and
6776will not work in this version.  Let me (perlbug@perl.org)
6777know of any problems this may cause.
6778
6779EOM
6780	case "$shrpdir" in
6781	"$archlibexp/CORE")
6782		$cat >&4 <<EOM
6783But your current setting of $shrpdir is
6784the default anyway, so it's harmless.
6785EOM
6786		;;
6787	*)
6788		$cat >&4 <<EOM
6789Further, your current attempted setting of $shrpdir
6790conflicts with the value of $archlibexp/CORE
6791that installperl will use.
6792EOM
6793		;;
6794	esac
6795	;;
6796esac
6797
6798# How will the perl executable find the installed shared $libperl?
6799# Add $xxx to ccdlflags.
6800# If we can't figure out a command-line option, use $shrpenv to
6801# set env LD_RUN_PATH.  The main perl makefile uses this.
6802shrpdir=$archlibexp/CORE
6803xxx=''
6804tmp_shrpenv=''
6805if "$useshrplib"; then
6806    case "$osname" in
6807	aix)
6808		# We'll set it in Makefile.SH...
6809		;;
6810	solaris|netbsd)
6811		xxx="-R $shrpdir"
6812		;;
6813	freebsd)
6814		xxx="-Wl,-R$shrpdir"
6815		;;
6816	linux|irix*|dec_osf)
6817		xxx="-Wl,-rpath,$shrpdir"
6818		;;
6819	next)
6820		# next doesn't like the default...
6821		;;
6822	beos)
6823		# beos doesn't like the default, either.
6824		;;
6825	hpux*)
6826		# hpux doesn't like the default, either.
6827		tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
6828		;;
6829	*)
6830		tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
6831		;;
6832	esac
6833	case "$xxx" in
6834	'') ;;
6835	*)
6836		# Only add $xxx if it isn't already in ccdlflags.
6837		case " $ccdlflags " in
6838		*" $xxx "*)	;;
6839		*)	ccdlflags="$ccdlflags $xxx"
6840			cat <<EOM >&4
6841
6842Adding $xxx to the flags
6843passed to $ld so that the perl executable will find the 
6844installed shared $libperl.
6845
6846EOM
6847			;;
6848		esac
6849		;;
6850	esac
6851fi
6852# Fix ccdlflags in AIX for building external extensions.
6853# (For building Perl itself bare -bE:perl.exp is needed,
6854#  Makefile.SH takes care of this.)
6855case "$osname" in
6856aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
6857esac
6858# Respect a hint or command-line value.
6859case "$shrpenv" in
6860'') shrpenv="$tmp_shrpenv" ;;
6861esac
6862case "$ldlibpthname" in
6863'')	ldlibpthname=LD_LIBRARY_PATH ;;
6864none)	ldlibpthname='' ;;
6865esac
6866
6867: determine where manual pages are on this system
6868echo " "
6869case "$sysman" in
6870'')
6871	syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
6872	syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
6873	syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
6874	syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
6875	syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
6876	sysman=`./loc . /usr/man/man1 $syspath`
6877	;;
6878esac
6879if $test -d "$sysman"; then
6880	echo "System manual is in $sysman." >&4
6881else
6882	echo "Could not find manual pages in source form." >&4
6883fi
6884
6885: determine where manual pages go
6886set man1dir man1dir none
6887eval $prefixit
6888$cat <<EOM
6889
6890$spackage has manual pages available in source form.
6891EOM
6892case "$nroff" in
6893nroff)
6894	echo "However, you don't have nroff, so they're probably useless to you."
6895	case "$man1dir" in
6896	'') man1dir="none";;
6897	esac;;
6898esac
6899echo "If you don't want the manual sources installed, answer 'none'."
6900case "$man1dir" in
6901' ') dflt=none
6902	;;
6903'')
6904	lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
6905	lookpath="$lookpath $prefixexp/man/p_man/man1"
6906	lookpath="$lookpath $prefixexp/man/u_man/man1"
6907	lookpath="$lookpath $prefixexp/man/man.1"
6908	case "$sysman" in
6909	*/?_man*)	dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
6910	*)	dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
6911	esac
6912	set dflt
6913	eval $prefixup
6914	;;
6915*)  dflt="$man1dir"
6916	;;
6917esac
6918echo " "
6919fn=dn+~
6920rp="Where do the main $spackage manual pages (source) go?"
6921. ./getfile
6922if $test "X$man1direxp" != "X$ansexp"; then
6923	installman1dir=''
6924fi
6925man1dir="$ans"
6926man1direxp="$ansexp"
6927case "$man1dir" in
6928'')	man1dir=' '
6929	installman1dir='';;
6930esac
6931
6932: Change installation prefix, if necessary.
6933if $test X"$prefix" != X"$installprefix"; then
6934	installman1dir=`echo $man1direxp | $sed "s#^$prefix#$installprefix#"`
6935else
6936	installman1dir="$man1direxp"
6937fi
6938
6939: What suffix to use on installed man pages
6940
6941case "$man1dir" in
6942' ')
6943	man1ext='0'
6944	;;
6945*)
6946	rp="What suffix should be used for the main $spackage man pages?"
6947	case "$man1ext" in
6948	'')	case "$man1dir" in
6949		*1)  dflt=1 ;;
6950		*1p) dflt=1p ;;
6951		*1pm) dflt=1pm ;;
6952		*l) dflt=l;;
6953		*n) dflt=n;;
6954		*o) dflt=o;;
6955		*p) dflt=p;;
6956		*C) dflt=C;;
6957		*L) dflt=L;;
6958		*L1) dflt=L1;;
6959		*) dflt=1;;
6960		esac
6961		;;
6962	*)	dflt="$man1ext";;
6963	esac
6964	. ./myread
6965	man1ext="$ans"
6966	;;
6967esac
6968
6969: see if we can have long filenames
6970echo " "
6971first=123456789abcdef
6972$rm -f $first
6973if (echo hi >$first) 2>/dev/null; then
6974	if $test -f 123456789abcde; then
6975		echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
6976		val="$undef"
6977	else
6978 		echo 'You can have filenames longer than 14 characters.'>&4
6979 		val="$define"
6980	fi
6981else
6982	$cat <<'EOM'
6983You can't have filenames longer than 14 chars.
6984You can't even think about them!
6985EOM
6986	val="$undef"
6987fi
6988set d_flexfnam
6989eval $setvar
6990$rm -rf 123456789abcde*
6991
6992: determine where library module manual pages go
6993set man3dir man3dir none
6994eval $prefixit
6995$cat <<EOM
6996
6997$spackage has manual pages for many of the library modules.
6998EOM
6999
7000case "$nroff" in
7001nroff)
7002	$cat <<'EOM'
7003However, you don't have nroff, so they're probably useless to you.
7004EOM
7005	case "$man3dir" in
7006	'') man3dir="none";;
7007	esac;;
7008esac
7009
7010case "$d_flexfnam" in
7011undef)
7012	$cat <<'EOM'
7013However, your system can't handle the long file names like File::Basename.3.
7014EOM
7015	case "$man3dir" in
7016	'') man3dir="none";;
7017	esac;;
7018esac
7019
7020echo "If you don't want the manual sources installed, answer 'none'."
7021prog=`echo $package | $sed 's/-*[0-9.]*$//'`
7022case "$man3dir" in
7023'')	dflt=`echo "$man1dir" | $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'`
7024	if $test -d "$privlib/man/man3"; then
7025		cat <<EOM >&4
7026
7027WARNING:  Previous versions of perl installed man3 pages into
7028$privlib/man/man3.  This version will suggest a
7029new default of $dflt.
7030EOM
7031		tdflt=$dflt
7032		dflt='n'
7033		rp='Do you wish to preserve the old behavior?(y/n)'
7034		. ./myread
7035		case "$ans" in
7036		y*) dflt="$privlib/man/man3" ;;
7037		*)  dflt=$tdflt ;;
7038		esac
7039    fi
7040	;;
7041*)	dflt="$man3dir" ;;
7042esac
7043case "$dflt" in
7044' ') dflt=none ;;
7045esac
7046echo " "
7047fn=dn+~
7048rp="Where do the $package library man pages (source) go?"
7049. ./getfile
7050man3dir="$ans"
7051man3direxp="$ansexp"
7052case "$man3dir" in
7053'')	man3dir=' '
7054	installman3dir='';;
7055esac
7056
7057: Change installation prefix, if necessary.
7058if $test X"$prefix" != X"$installprefix"; then
7059	installman3dir=`echo $man3direxp | $sed "s#^$prefix#$installprefix#"`
7060else
7061	installman3dir="$man3direxp"
7062fi
7063
7064: What suffix to use on installed man pages
7065case "$man3dir" in
7066' ')
7067	man3ext='0'
7068	;;
7069*)
7070	rp="What suffix should be used for the $package library man pages?"
7071	case "$man3ext" in
7072	'')	case "$man3dir" in
7073		*3)  dflt=3 ;;
7074		*3p) dflt=3p ;;
7075		*3pm) dflt=3pm ;;
7076		*l) dflt=l;;
7077		*n) dflt=n;;
7078		*o) dflt=o;;
7079		*p) dflt=p;;
7080		*C) dflt=C;;
7081		*L) dflt=L;;
7082		*L3) dflt=L3;;
7083		*) dflt=3;;
7084		esac
7085		;;
7086	*)	dflt="$man3ext";;
7087	esac
7088	. ./myread
7089	man3ext="$ans"
7090	;;
7091esac
7092
7093: see if we have to deal with yellow pages, now NIS.
7094if $test -d /usr/etc/yp || $test -d /etc/yp; then
7095	if $test -f /usr/etc/nibindd; then
7096		echo " "
7097		echo "I'm fairly confident you're on a NeXT."
7098		echo " "
7099		rp='Do you get the hosts file via NetInfo?'
7100		dflt=y
7101		case "$hostcat" in
7102		nidump*) ;;
7103		'') ;;
7104		*) dflt=n;;
7105		esac
7106		. ./myread
7107		case "$ans" in
7108		y*) hostcat='nidump hosts .';;
7109		*)	case "$hostcat" in
7110			nidump*) hostcat='';;
7111			esac
7112			;;
7113		esac
7114	fi
7115	case "$hostcat" in
7116	nidump*) ;;
7117	*)
7118		case "$hostcat" in
7119		*ypcat*) dflt=y;;
7120		'') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
7121				dflt=y
7122			else
7123				dflt=n
7124			fi;;
7125		*) dflt=n;;
7126		esac
7127		echo " "
7128		rp='Are you getting the hosts file via yellow pages?'
7129		. ./myread
7130		case "$ans" in
7131		y*) hostcat='ypcat hosts';;
7132		*) hostcat='cat /etc/hosts';;
7133		esac
7134		;;
7135	esac
7136fi
7137case "$hostcat" in
7138'') test -f /etc/hosts && hostcat='cat /etc/hosts';;
7139esac
7140case "$groupcat" in
7141'') test -f /etc/group && groupcat='cat /etc/group';;
7142esac
7143case "$passcat" in
7144'') test -f /etc/passwd && passcat='cat /etc/passwd';;
7145esac
7146
7147: now get the host name
7148echo " "
7149echo "Figuring out host name..." >&4
7150case "$myhostname" in
7151'') cont=true
7152	echo 'Maybe "hostname" will work...'
7153	if tans=`sh -c hostname 2>&1` ; then
7154		myhostname=$tans
7155		phostname=hostname
7156		cont=''
7157	fi
7158	;;
7159*) cont='';;
7160esac
7161if $test "$cont"; then
7162	if ./xenix; then
7163		echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
7164		if tans=`cat /etc/systemid 2>&1` ; then
7165			myhostname=$tans
7166			phostname='cat /etc/systemid'
7167			echo "Whadyaknow.  Xenix always was a bit strange..."
7168			cont=''
7169		fi
7170	elif $test -r /etc/systemid; then
7171		echo "(What is a non-Xenix system doing with /etc/systemid?)"
7172	fi
7173fi
7174if $test "$cont"; then
7175	echo 'No, maybe "uuname -l" will work...'
7176	if tans=`sh -c 'uuname -l' 2>&1` ; then
7177		myhostname=$tans
7178		phostname='uuname -l'
7179	else
7180		echo 'Strange.  Maybe "uname -n" will work...'
7181		if tans=`sh -c 'uname -n' 2>&1` ; then
7182			myhostname=$tans
7183			phostname='uname -n'
7184		else
7185			echo 'Oh well, maybe I can mine it out of whoami.h...'
7186			if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
7187				myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
7188				phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
7189			else
7190				case "$myhostname" in
7191				'') echo "Does this machine have an identity crisis or something?"
7192					phostname='';;
7193				*)
7194					echo "Well, you said $myhostname before..."
7195					phostname='echo $myhostname';;
7196				esac
7197			fi
7198		fi
7199	fi
7200fi
7201: you do not want to know about this
7202set $myhostname
7203myhostname=$1
7204
7205: verify guess
7206if $test "$myhostname" ; then
7207	dflt=y
7208	rp='Your host name appears to be "'$myhostname'".'" Right?"
7209	. ./myread
7210	case "$ans" in
7211	y*) ;;
7212	*) myhostname='';;
7213	esac
7214fi
7215
7216: bad guess or no guess
7217while $test "X$myhostname" = X ; do
7218	dflt=''
7219	rp="Please type the (one word) name of your host:"
7220	. ./myread
7221	myhostname="$ans"
7222done
7223
7224: translate upper to lower if necessary
7225case "$myhostname" in
7226*[A-Z]*)
7227	echo "(Normalizing case in your host name)"
7228	myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
7229	;;
7230esac
7231
7232case "$myhostname" in
7233*.*)
7234	dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
7235	myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
7236	echo "(Trimming domain name from host name--host name is now $myhostname)"
7237	;;
7238*) case "$mydomain" in
7239	'')
7240		{
7241			test "X$hostcat" = "Xypcat hosts" &&
7242			ypmatch "$myhostname" hosts 2>/dev/null |\
7243				$sed -e 's/[	 ]*#.*//; s/$/ /' > hosts && \
7244			$test -s hosts
7245		} || {
7246			test "X$hostcat" != "X" &&
7247		     	$hostcat | $sed -n -e "s/[	 ]*#.*//; s/\$/ /
7248					/[	 ]$myhostname[	. ]/p" > hosts
7249		}
7250		tmp_re="[	. ]"
7251		if $test -f hosts; then
7252			$test x`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ { sum++ }
7253			     END { print sum }" hosts` = x1 || tmp_re="[	 ]"
7254			dflt=.`$awk "/[0-9].*[	 ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
7255				hosts | $sort | $uniq | \
7256				$sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
7257			case `$echo X$dflt` in
7258			X*\ *)	echo "(Several hosts in the database matched hostname)"
7259				dflt=.
7260				;;
7261			X.) echo "(You do not have fully-qualified names in the hosts database)"
7262				;;
7263			esac
7264		else
7265			echo "(I cannot locate a hosts database anywhere)"
7266			dflt=.
7267		fi
7268		case "$dflt" in
7269		.)
7270			tans=`./loc resolv.conf X /etc /usr/etc`
7271			if $test -f "$tans"; then
7272				echo "(Attempting domain name extraction from $tans)"
7273				dflt=.`$sed -n -e 's/	/ /g' \
7274				  -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
7275				  | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
7276				case "$dflt" in
7277				.) dflt=.`$sed -n -e 's/	/ /g' \
7278				     -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
7279				     | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
7280  					;;
7281				esac
7282			fi
7283			;;
7284		esac
7285		case "$dflt" in
7286		.) echo "(No help from resolv.conf either -- attempting clever guess)"
7287			dflt=.`sh -c domainname 2>/dev/null`
7288			case "$dflt" in
7289			'') dflt='.';;
7290			.nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
7291			esac
7292			;;
7293		esac
7294		case "$dflt$osname" in
7295		.os390) echo "(Attempting domain name extraction from //'SYS1.TCPPARMS(TCPDATA)')"
7296			dflt=.`awk '/^DOMAINORIGIN/ {print $2}' "//'SYS1.TCPPARMS(TCPDATA)'" 2>/dev/null`
7297			;;
7298		esac
7299		case "$dflt" in
7300		.) echo "(Lost all hope -- silly guess then)"
7301			dflt='.uucp'
7302			;;
7303		esac
7304		$rm -f hosts
7305		;;
7306	*) dflt="$mydomain";;
7307	esac;;
7308esac
7309echo " "
7310rp="What is your domain name?"
7311. ./myread
7312tans="$ans"
7313case "$ans" in
7314'') ;;
7315.*) ;;
7316*) tans=".$tans";;
7317esac
7318mydomain="$tans"
7319
7320: translate upper to lower if necessary
7321case "$mydomain" in
7322*[A-Z]*)
7323	echo "(Normalizing case in your domain name)"
7324	mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
7325	;;
7326esac
7327
7328: a little sanity check here
7329case "$phostname" in
7330'') ;;
7331*)
7332	case `$phostname | ./tr '[A-Z]' '[a-z]'` in
7333	$myhostname$mydomain|$myhostname) ;;
7334	*)
7335		case "$phostname" in
7336		sed*)
7337			echo "(That doesn't agree with your whoami.h file, by the way.)"
7338			;;
7339		*)
7340			echo "(That doesn't agree with your $phostname command, by the way.)"
7341			;;
7342		esac
7343	;;
7344	esac
7345	;;
7346esac
7347
7348$cat <<EOM
7349
7350I need to get your e-mail address in Internet format if possible, i.e.
7351something like user@host.domain. Please answer accurately since I have
7352no easy means to double check it. The default value provided below
7353is most probably close to reality but may not be valid from outside
7354your organization...
7355
7356EOM
7357cont=x
7358while test "$cont"; do
7359	case "$cf_email" in
7360	'') dflt="$cf_by@$myhostname$mydomain";;
7361	*) dflt="$cf_email";;
7362	esac
7363	rp='What is your e-mail address?'
7364	. ./myread
7365	cf_email="$ans"
7366	case "$cf_email" in
7367	*@*.*) cont='' ;;
7368	*)
7369		rp='Address does not look like an Internet one.  Use it anyway?'
7370		case "$fastread" in
7371		yes) dflt=y ;;
7372		*) dflt=n ;;
7373		esac
7374		. ./myread
7375		case "$ans" in
7376		y*) cont='' ;;
7377		*) echo " " ;;
7378		esac
7379		;;
7380	esac
7381done
7382
7383$cat <<EOM
7384
7385If you or somebody else will be maintaining perl at your site, please
7386fill in the correct e-mail address here so that they may be contacted
7387if necessary. Currently, the "perlbug" program included with perl
7388will send mail to this address in addition to perlbug@perl.org. You may
7389enter "none" for no administrator.
7390
7391EOM
7392case "$perladmin" in
7393'') dflt="$cf_email";;
7394*) dflt="$perladmin";;
7395esac
7396rp='Perl administrator e-mail address'
7397. ./myread
7398perladmin="$ans"
7399
7400: determine whether to only install version-specific parts.
7401echo " "
7402$cat <<EOM
7403Do you want to install only the version-specific parts of the perl
7404distribution?  Usually you do *not* want to do this.
7405EOM
7406case "$versiononly" in
7407"$define"|[Yy]*|true) dflt='y' ;;
7408*) dflt='n';
7409esac
7410rp="Do you want to install only the version-specific parts of perl?"
7411. ./myread
7412case "$ans" in
7413[yY]*)	val="$define";;
7414*)	val="$undef" ;;
7415esac
7416set versiononly
7417eval $setvar
7418
7419: figure out how to guarantee perl startup
7420case "$startperl" in
7421'')
7422	case "$sharpbang" in
7423	*!)
7424		$cat <<EOH
7425
7426I can use the #! construct to start perl on your system. This will
7427make startup of perl scripts faster, but may cause problems if you
7428want to share those scripts and perl is not in a standard place
7429($binexp/perl) on all your platforms. The alternative is to force
7430a shell by starting the script with a single ':' character.
7431
7432EOH
7433		case "$versiononly" in
7434		"$define")      dflt="$binexp/perl$version";;
7435		*)              dflt="$binexp/perl";;
7436		esac
7437		rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
7438		. ./myread
7439		case "$ans" in
7440		none)	startperl=": # use perl";;
7441		*)	startperl="#!$ans"
7442			if $test 30 -lt `echo "$ans" | wc -c`; then
7443				$cat >&4 <<EOM
7444
7445WARNING:  Some systems limit the #! command to 32 characters.
7446If you experience difficulty running Perl scripts with #!, try
7447installing Perl in a directory with a shorter pathname.
7448
7449EOM
7450			fi ;;
7451		esac
7452		;;
7453	*) startperl=": # use perl"
7454		;;
7455	esac
7456	;;
7457esac
7458echo "I'll use $startperl to start perl scripts."
7459
7460: figure best path for perl in scripts
7461case "$perlpath" in
7462'')
7463	perlpath="$binexp/perl"
7464	case "$startperl" in
7465	*!*) ;;
7466	*)
7467		$cat <<EOH
7468
7469I will use the "eval 'exec'" idiom to start Perl on your system.
7470I can use the full path of your Perl binary for this purpose, but
7471doing so may cause problems if you want to share those scripts and
7472Perl is not always in a standard place ($binexp/perl).
7473
7474EOH
7475		dflt="$binexp/perl"
7476		rp="What path shall I use in \"eval 'exec'\"?"
7477		. ./myread
7478		perlpath="$ans"
7479		;;
7480	esac
7481	;;
7482esac
7483case "$startperl" in
7484*!*)	;;
7485*)	echo "I'll use $perlpath in \"eval 'exec'\"" ;;
7486esac
7487
7488: determine where public executable scripts go
7489set scriptdir scriptdir
7490eval $prefixit
7491case "$scriptdir" in
7492'')
7493	dflt="$bin"
7494	: guess some guesses
7495	$test -d /usr/share/scripts && dflt=/usr/share/scripts
7496	$test -d /usr/share/bin     && dflt=/usr/share/bin
7497	$test -d /usr/local/script  && dflt=/usr/local/script
7498	$test -d /usr/local/scripts && dflt=/usr/local/scripts
7499	$test -d $prefixexp/script  && dflt=$prefixexp/script
7500	set dflt
7501	eval $prefixup
7502	;;
7503*)  dflt="$scriptdir"
7504	;;
7505esac
7506$cat <<EOM
7507 
7508Some installations have a separate directory just for executable scripts so
7509that they can mount it across multiple architectures but keep the scripts in
7510one spot.  You might, for example, have a subdirectory of /usr/share for this.
7511Or you might just lump your scripts in with all your other executables.
7512 
7513EOM
7514fn=d~
7515rp='Where do you keep publicly executable scripts?'
7516. ./getfile
7517if $test "X$ansexp" != "X$scriptdirexp"; then
7518	installscript=''
7519fi
7520scriptdir="$ans"
7521scriptdirexp="$ansexp"
7522: Change installation prefix, if necessary.
7523if $test X"$prefix" != X"$installprefix"; then
7524	installscript=`echo $scriptdirexp | sed "s#^$prefix#$installprefix#"`
7525else
7526	installscript="$scriptdirexp"
7527fi
7528
7529: determine where add-on public executables go
7530case "$sitebin" in
7531'')	dflt=$siteprefix/bin ;;
7532*)	dflt=$sitebin ;;
7533esac
7534fn=d~
7535rp='Pathname where the add-on public executables should be installed?'
7536. ./getfile
7537sitebin="$ans"
7538sitebinexp="$ansexp"
7539: Change installation prefix, if necessary.
7540if $test X"$prefix" != X"$installprefix"; then
7541	installsitebin=`echo $sitebinexp | sed "s#^$prefix#$installprefix#"`
7542else
7543	installsitebin="$sitebinexp"
7544fi
7545
7546case "$useperlio" in
7547$define|true|[yY]*)	dflt='y';;
7548*) dflt='n';;
7549esac
7550cat <<EOM
7551
7552Previous version of $package used the standard IO mechanisms as defined
7553in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
7554mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
7555the default.  This abstraction layer can use AT&T's sfio (if you already
7556have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
7557problems with some extension modules.  Using PerlIO with stdio is safe,
7558but it is slower than plain stdio and therefore is not the default.
7559
7560If this doesn't make any sense to you, just accept the default '$dflt'.
7561EOM
7562rp='Use the experimental PerlIO abstraction layer?'
7563. ./myread
7564case "$ans" in
7565y|Y)
7566	val="$define"
7567	;;
7568*)
7569	echo "Ok, doing things the stdio way"
7570	val="$undef"
7571	;;
7572esac
7573set useperlio
7574eval $setvar
7575
7576case "$vendorprefix" in
7577'')	d_vendorbin="$undef"
7578	vendorbin=''
7579	vendorbinexp=''
7580	;;
7581*)	d_vendorbin="$define"
7582	: determine where vendor-supplied executables go.
7583	case "$vendorbin" in
7584	'') dflt=$vendorprefix/bin ;;
7585	*)	dflt="$vendorbin" ;;
7586	esac
7587	fn=d~+
7588	rp='Pathname for the vendor-supplied executables directory?'
7589	. ./getfile
7590	vendorbin="$ans"
7591	vendorbinexp="$ansexp"
7592	;;
7593esac
7594: Change installation prefix, if necessary.
7595if $test X"$prefix" != X"$installprefix"; then
7596	installvendorbin=`echo $vendorbinexp | $sed "s#^$prefix#$installprefix#"`
7597else
7598	installvendorbin="$vendorbinexp"
7599fi
7600
7601: see if qgcvt exists
7602set qgcvt d_qgcvt
7603eval $inlibc
7604
7605echo " "
7606
7607if $test X"$d_longdbl" = X"$define"; then
7608
7609echo "Checking how to print long doubles..." >&4
7610
7611if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
7612	$cat >try.c <<'EOCP'
7613#include <sys/types.h>
7614#include <stdio.h>
7615int main() {
7616  double d = 123.456;
7617  printf("%.3f\n", d);
7618}
7619EOCP
7620	set try
7621	if eval $compile; then
7622		yyy=`./try$exe_ext`
7623		case "$yyy" in
7624		123.456)
7625			sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
7626                	sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
7627			echo "We will use %f."
7628			;;
7629		esac
7630	fi
7631fi
7632
7633if $test X"$sPRIfldbl" = X; then
7634	$cat >try.c <<'EOCP'
7635#include <sys/types.h>
7636#include <stdio.h>
7637int main() {
7638  long double d = 123.456;
7639  printf("%.3llf\n", d);
7640}
7641EOCP
7642	set try
7643	if eval $compile; then
7644		yyy=`./try$exe_ext`
7645		case "$yyy" in
7646		123.456)
7647			sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
7648                	sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
7649			echo "We will use %llf."
7650			;;
7651		esac
7652	fi
7653fi
7654
7655if $test X"$sPRIfldbl" = X; then
7656	$cat >try.c <<'EOCP'
7657#include <sys/types.h>
7658#include <stdio.h>
7659int main() {
7660  long double d = 123.456;
7661  printf("%.3Lf\n", d);
7662}
7663EOCP
7664	set try
7665	if eval $compile; then
7666		yyy=`./try$exe_ext`
7667		case "$yyy" in
7668		123.456)
7669			sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
7670                	sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
7671			echo "We will use %Lf."
7672			;;
7673		esac
7674	fi
7675fi
7676
7677if $test X"$sPRIfldbl" = X; then
7678	$cat >try.c <<'EOCP'
7679#include <sys/types.h>
7680#include <stdio.h>
7681int main() {
7682  long double d = 123.456;
7683  printf("%.3lf\n", d);
7684}
7685EOCP
7686	set try
7687	if eval $compile; then
7688		yyy=`./try$exe_ext`
7689		case "$yyy" in
7690		123.456)
7691			sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
7692                	sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
7693			echo "We will use %lf."
7694			;;
7695		esac
7696	fi
7697fi
7698
7699if $test X"$sPRIfldbl" = X; then
7700	echo "Cannot figure out how to print long doubles." >&4
7701else
7702	sSCNfldbl=$sPRIfldbl	# expect consistency
7703fi
7704
7705$rm -f try try.*
7706
7707fi # d_longdbl
7708
7709case "$sPRIfldbl" in
7710'')	d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
7711	d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
7712	d_SCNfldbl="$undef";
7713	;;
7714*)	d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
7715	d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
7716	d_SCNfldbl="$define";
7717	;;
7718esac
7719
7720: Check how to convert floats to strings.
7721echo " "
7722echo "Checking for an efficient way to convert floats to strings."
7723echo " " > try.c
7724case "$uselongdouble" in
7725"$define") echo "#define USE_LONG_DOUBLE" >>try.c ;;
7726esac
7727case "$d_longdbl" in
7728"$define") echo "#define HAS_LONG_DOUBLE" >>try.c ;;
7729esac
7730case "$d_PRIgldbl" in
7731"$define") echo "#define HAS_PRIgldbl"    >>try.c ;;
7732esac
7733$cat >>try.c <<EOP
7734#ifdef TRY_gconvert
7735#define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
7736char *myname = "gconvert";
7737#endif
7738#ifdef TRY_gcvt
7739#define Gconvert(x,n,t,b) gcvt((x),(n),(b))
7740char *myname = "gcvt";
7741#endif
7742#ifdef TRY_qgcvt
7743#define Gconvert(x,n,t,b) qgcvt((x),(n),(b))
7744char *myname = "qgcvt";
7745#define DOUBLETYPE long double
7746#endif
7747#ifdef TRY_sprintf
7748#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && defined(HAS_PRIgldbl)
7749#define Gconvert(x,n,t,b) sprintf((b),"%.*"$sPRIgldbl,(n),(x))
7750#else
7751#define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
7752#endif
7753char *myname = "sprintf";
7754#endif
7755
7756#ifndef DOUBLETYPE
7757#if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
7758#define DOUBLETYPE long double
7759#else
7760#define DOUBLETYPE double
7761#endif
7762#endif
7763
7764#include <stdio.h>
7765
7766#define I_STDLIB $i_stdlib
7767#ifdef I_STDLIB
7768#include <stdlib.h>
7769#endif
7770
7771int
7772checkit(expect, got)
7773char *expect;
7774char *got;
7775{
7776    if (strcmp(expect, got)) {
7777		printf("%s oddity:  Expected %s, got %s\n",
7778			myname, expect, got);
7779		exit(1);
7780	}
7781}
7782
7783int main()
7784{ 
7785	char buf[64]; 
7786	buf[63] = '\0';
7787
7788	/* This must be 1st test on (which?) platform */
7789	/* Alan Burlison <AlanBurlsin@unn.unisys.com> */
7790	Gconvert((DOUBLETYPE)0.1, 8, 0, buf);
7791	checkit("0.1", buf);
7792
7793	Gconvert((DOUBLETYPE)1.0, 8, 0, buf); 
7794	checkit("1", buf);
7795
7796	Gconvert((DOUBLETYPE)1.1, 8, 0, buf); 
7797	checkit("1.1", buf);
7798
7799	Gconvert((DOUBLETYPE)1.01, 8, 0, buf); 
7800	checkit("1.01", buf);
7801
7802	Gconvert((DOUBLETYPE)1.001, 8, 0, buf); 
7803	checkit("1.001", buf);
7804
7805	Gconvert((DOUBLETYPE)1.0001, 8, 0, buf); 
7806	checkit("1.0001", buf);
7807
7808	Gconvert((DOUBLETYPE)1.00001, 8, 0, buf); 
7809	checkit("1.00001", buf);
7810
7811	Gconvert((DOUBLETYPE)1.000001, 8, 0, buf); 
7812	checkit("1.000001", buf);
7813
7814	Gconvert((DOUBLETYPE)0.0, 8, 0, buf); 
7815	checkit("0", buf);
7816
7817	Gconvert((DOUBLETYPE)-1.0, 8, 0, buf); 
7818	checkit("-1", buf);
7819
7820	/* Some Linux gcvt's give 1.e+5 here. */
7821	Gconvert((DOUBLETYPE)100000.0, 8, 0, buf); 
7822	checkit("100000", buf);
7823	
7824	/* Some Linux gcvt's give -1.e+5 here. */
7825	Gconvert((DOUBLETYPE)-100000.0, 8, 0, buf); 
7826	checkit("-100000", buf);
7827
7828	Gconvert((DOUBLETYPE)123.456, 8, 0, buf); 
7829	checkit("123.456", buf);
7830
7831	exit(0);
7832}
7833EOP
7834case "$d_Gconvert" in
7835gconvert*) xxx_list='gconvert gcvt sprintf' ;;
7836gcvt*) xxx_list='gcvt gconvert sprintf' ;;
7837sprintf*) xxx_list='sprintf gconvert gcvt' ;;
7838*) xxx_list='gconvert gcvt sprintf' ;;
7839esac
7840
7841case "$d_longdbl$uselongdouble$d_PRIgldbl" in
7842"$define$define$define")
7843    # for long doubles prefer first qgcvt, then sprintf
7844    xxx_list="`echo $xxx_list|sed s/sprintf//`"
7845    xxx_list="sprintf $xxx_list"
7846    case "$d_qgcvt" in
7847    "$define") xxx_list="qgcvt $xxx_list" ;;
7848    esac
7849    ;;
7850esac
7851
7852for xxx_convert in $xxx_list; do
7853	echo "Trying $xxx_convert..."
7854	$rm -f try try$_o
7855	set try -DTRY_$xxx_convert
7856	if eval $compile; then
7857		echo "$xxx_convert() found." >&4
7858		if ./try; then
7859			echo "I'll use $xxx_convert to convert floats into a string." >&4
7860			break;
7861		else
7862			echo "...But $xxx_convert didn't work as I expected."
7863		fi
7864	else
7865		echo "$xxx_convert NOT found." >&4
7866	fi
7867done
7868
7869case "$xxx_convert" in
7870gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
7871gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
7872qgcvt) d_Gconvert='qgcvt((x),(n),(b))' ;;
7873*) case "$uselongdouble$d_longdbl$d_PRIgldbl" in
7874   "$define$define$define")
7875      d_Gconvert="sprintf((b),\"%.*\"$sPRIgldbl,(n),(x))" ;;
7876   *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
7877   esac
7878   ;;
7879esac
7880
7881: see if _fwalk exists
7882set fwalk d__fwalk
7883eval $inlibc
7884
7885: Initialize h_fcntl
7886h_fcntl=false
7887
7888: Initialize h_sysfile
7889h_sysfile=false
7890
7891: access call always available on UNIX
7892set access d_access
7893eval $inlibc
7894
7895: locate the flags for 'access()'
7896case "$d_access" in
7897"$define")
7898	echo " "
7899	$cat >access.c <<'EOCP'
7900#include <sys/types.h>
7901#ifdef I_FCNTL
7902#include <fcntl.h>
7903#endif
7904#ifdef I_SYS_FILE
7905#include <sys/file.h>
7906#endif
7907#ifdef I_UNISTD
7908#include <unistd.h>
7909#endif
7910int main() {
7911	exit(R_OK);
7912}
7913EOCP
7914	: check sys/file.h first, no particular reason here
7915	if $test `./findhdr sys/file.h` && \
7916		$cc -o access $cppflags -DI_SYS_FILE access.c >/dev/null 2>&1 ; then
7917		h_sysfile=true;
7918		echo "<sys/file.h> defines the *_OK access constants." >&4
7919	elif $test `./findhdr fcntl.h` && \
7920		$cc -o access $cppflags -DI_FCNTL access.c >/dev/null 2>&1 ; then
7921		h_fcntl=true;
7922		echo "<fcntl.h> defines the *_OK access constants." >&4
7923	elif $test `./findhdr unistd.h` && \
7924		$cc -o access $cppflags -DI_UNISTD access.c >/dev/null 2>&1 ; then
7925		echo "<unistd.h> defines the *_OK access constants." >&4
7926	else
7927		echo "I can't find the four *_OK access constants--I'll use mine." >&4
7928	fi
7929	;;
7930esac
7931$rm -f access*
7932
7933: see if accessx exists
7934set accessx d_accessx
7935eval $inlibc
7936
7937: see if alarm exists
7938set alarm d_alarm
7939eval $inlibc
7940
7941: see if atolf exists
7942set atolf d_atolf
7943eval $inlibc
7944
7945: see if atoll exists
7946set atoll d_atoll
7947eval $inlibc
7948
7949: Look for GNU-cc style attribute checking
7950echo " "
7951echo "Checking whether your compiler can handle __attribute__ ..." >&4
7952$cat >attrib.c <<'EOCP'
7953#include <stdio.h>
7954void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
7955EOCP
7956if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
7957	if $contains 'warning' attrib.out >/dev/null 2>&1; then
7958		echo "Your C compiler doesn't fully support __attribute__."
7959		val="$undef"
7960	else
7961		echo "Your C compiler supports __attribute__."
7962		val="$define"
7963	fi
7964else
7965	echo "Your C compiler doesn't seem to understand __attribute__ at all."
7966	val="$undef"
7967fi
7968set d_attribut
7969eval $setvar
7970$rm -f attrib*
7971
7972: see if bcmp exists
7973set bcmp d_bcmp
7974eval $inlibc
7975
7976: see if bcopy exists
7977set bcopy d_bcopy
7978eval $inlibc
7979
7980: see if this is a unistd.h system
7981set unistd.h i_unistd
7982eval $inhdr
7983
7984: see if getpgrp exists
7985set getpgrp d_getpgrp
7986eval $inlibc
7987
7988case "$d_getpgrp" in
7989"$define")
7990	echo " "
7991	echo "Checking to see which flavor of getpgrp is in use..."
7992	$cat >set.c <<EOP
7993#$i_unistd I_UNISTD
7994#include <sys/types.h>
7995#ifdef I_UNISTD
7996#  include <unistd.h>
7997#endif
7998int main()
7999{
8000	if (getuid() == 0) {
8001		printf("(I see you are running Configure as super-user...)\n");
8002		setuid(1);
8003	}
8004#ifdef TRY_BSD_PGRP
8005	if (getpgrp(1) == 0)
8006		exit(0);
8007#else
8008	if (getpgrp() > 0)
8009		exit(0);
8010#endif
8011	exit(1);
8012}
8013EOP
8014	if $cc -o set -DTRY_BSD_PGRP $ccflags $ldflags set.c $libs >/dev/null 2>&1 && ./set; then
8015		echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
8016		val="$define"
8017	elif $cc -o set $ccflags $ldflags set.c $libs >/dev/null 2>&1 && ./set; then
8018		echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
8019		val="$undef"
8020	else
8021		echo "I can't seem to compile and run the test program."
8022		if ./usg; then
8023			xxx="a USG one, i.e. you use getpgrp()."
8024		else
8025			# SVR4 systems can appear rather BSD-ish.
8026			case "$i_unistd" in
8027			$undef)
8028				xxx="a BSD one, i.e. you use getpgrp(pid)."
8029				val="$define"
8030				;;
8031			$define)
8032				xxx="probably a USG one, i.e. you use getpgrp()."
8033				val="$undef"
8034				;;
8035			esac
8036		fi
8037		echo "Assuming your getpgrp is $xxx" >&4
8038	fi
8039	;;
8040*) val="$undef";;
8041esac
8042set d_bsdgetpgrp
8043eval $setvar
8044$rm -f set set.c
8045
8046: see if setpgrp exists
8047set setpgrp d_setpgrp
8048eval $inlibc
8049
8050case "$d_setpgrp" in
8051"$define")
8052	echo " "
8053	echo "Checking to see which flavor of setpgrp is in use..."
8054	$cat >set.c <<EOP
8055#$i_unistd I_UNISTD
8056#include <sys/types.h>
8057#ifdef I_UNISTD
8058#  include <unistd.h>
8059#endif
8060int main()
8061{
8062	if (getuid() == 0) {
8063		printf("(I see you are running Configure as super-user...)\n");
8064		setuid(1);
8065	}
8066#ifdef TRY_BSD_PGRP
8067	if (-1 == setpgrp(1, 1))
8068		exit(0);
8069#else
8070	if (setpgrp() != -1)
8071		exit(0);
8072#endif
8073	exit(1);
8074}
8075EOP
8076	if $cc -o set -DTRY_BSD_PGRP $ccflags $ldflags set.c $libs >/dev/null 2>&1 && ./set; then
8077		echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
8078		val="$define"
8079	elif $cc -o set $ccflags $ldflags set.c $libs >/dev/null 2>&1 && ./set; then
8080		echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
8081		val="$undef"
8082	else
8083		echo "(I can't seem to compile and run the test program.)"
8084		if ./usg; then
8085			xxx="a USG one, i.e. you use setpgrp()."
8086		else
8087			# SVR4 systems can appear rather BSD-ish.
8088			case "$i_unistd" in
8089			$undef)
8090				xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
8091				val="$define"
8092				;;
8093			$define)
8094				xxx="probably a USG one, i.e. you use setpgrp()."
8095				val="$undef"
8096				;;
8097			esac
8098		fi
8099		echo "Assuming your setpgrp is $xxx" >&4
8100	fi
8101	;;
8102*) val="$undef";;
8103esac
8104set d_bsdsetpgrp
8105eval $setvar
8106$rm -f set set.c
8107: see if bzero exists
8108set bzero d_bzero
8109eval $inlibc
8110
8111: see if signal is declared as pointer to function returning int or void
8112echo " "
8113xxx=`./findhdr signal.h`
8114$test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
8115if $contains 'int.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
8116	echo "You have int (*signal())() instead of void." >&4
8117	val="$undef"
8118elif $contains 'void.*\*[ 	]*signal' $$.tmp >/dev/null 2>&1 ; then
8119	echo "You have void (*signal())()." >&4
8120	val="$define"
8121elif $contains 'extern[ 	]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
8122	echo "You have int (*signal())() instead of void." >&4
8123	val="$undef"
8124elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
8125	echo "You have void (*signal())()." >&4
8126	val="$define"
8127else
8128	case "$d_voidsig" in
8129	'')
8130	echo "I can't determine whether signal handler returns void or int..." >&4
8131		dflt=void
8132		rp="What type does your signal handler return?"
8133		. ./myread
8134		case "$ans" in
8135		v*) val="$define";;
8136		*) val="$undef";;
8137		esac;;
8138	"$define")
8139		echo "As you already told me, signal handler returns void." >&4
8140		val="$define"
8141		;;
8142	*)	echo "As you already told me, signal handler returns int." >&4
8143		val="$undef"
8144		;;
8145	esac
8146fi
8147set d_voidsig
8148eval $setvar
8149case "$d_voidsig" in
8150"$define") signal_t="void";;
8151*) signal_t="int";;
8152esac
8153$rm -f $$.tmp
8154
8155: check for ability to cast large floats to 32-bit ints.
8156echo " "
8157echo 'Checking whether your C compiler can cast large floats to int32.' >&4
8158if $test "$intsize" -ge 4; then
8159	xxx=int
8160else
8161	xxx=long
8162fi
8163$cat >try.c <<EOCP
8164#include <stdio.h>
8165#include <sys/types.h>
8166#include <signal.h>
8167$signal_t blech(s) int s; { exit(3); }
8168int main()
8169{
8170	$xxx i32;
8171	double f, g;
8172	int result = 0;
8173	char str[16];
8174	signal(SIGFPE, blech);
8175
8176	/* Don't let compiler optimize the test away.  Store the number 
8177	   in a writable string for gcc to pass to sscanf under HP/UX.
8178	*/
8179	sprintf(str, "2147483647");
8180	sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
8181	g = 10 * f;
8182	i32  = ($xxx) g;
8183
8184	/* x86 processors will probably give 0x8000 0000, which is a
8185       sign change.  We don't want that.  We want to mimic SPARC
8186	   behavior here, which is to preserve the sign and give
8187	   back 0x7fff ffff.
8188	*/
8189	if (i32 != ($xxx) f)
8190		result |= 1;
8191	exit(result);
8192}
8193EOCP
8194set try
8195if eval $compile_ok; then
8196	./try
8197	yyy=$?
8198else
8199	echo "(I can't seem to compile the test program--assuming it can't)"
8200	yyy=1
8201fi
8202case "$yyy" in
82030)	val="$define"
8204	echo "Yup, it can."
8205	;;
8206*)	val="$undef"
8207	echo "Nope, it can't."
8208	;;
8209esac
8210set d_casti32
8211eval $setvar
8212$rm -f try try.*
8213
8214: check for ability to cast negative floats to unsigned
8215echo " "
8216echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
8217$cat >try.c <<EOCP
8218#include <stdio.h>
8219#include <sys/types.h>
8220#include <signal.h>
8221$signal_t blech(s) int s; { exit(7); }
8222$signal_t blech_in_list(s) int s; { exit(4); }
8223unsigned long dummy_long(p) unsigned long p; { return p; }
8224unsigned int dummy_int(p) unsigned int p; { return p; }
8225unsigned short dummy_short(p) unsigned short p; { return p; }
8226int main()
8227{
8228	double f;
8229	unsigned long along;
8230	unsigned int aint;
8231	unsigned short ashort;
8232	int result = 0;
8233	char str[16];
8234	
8235	/* Frustrate gcc-2.7.2's optimizer which failed this test with
8236	   a direct f = -123. assignment.  gcc-2.8.0 reportedly
8237	   optimized the whole file away
8238	*/
8239	/* Store the number in a writable string for gcc to pass to 
8240	   sscanf under HP/UX.
8241	*/
8242	sprintf(str, "-123");
8243	sscanf(str, "%lf", &f);  /* f = -123.; */
8244
8245	signal(SIGFPE, blech);
8246	along = (unsigned long)f;
8247	aint = (unsigned int)f;
8248	ashort = (unsigned short)f;
8249	if (along != (unsigned long)-123)
8250		result |= 1;
8251	if (aint != (unsigned int)-123)
8252		result |= 1;
8253	if (ashort != (unsigned short)-123)
8254		result |= 1;
8255	sprintf(str, "1073741824.");
8256	sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
8257	f = f + f;
8258	along = 0;
8259	along = (unsigned long)f;
8260	if (along != 0x80000000)
8261		result |= 2;
8262	f -= 1.;
8263	along = 0;
8264	along = (unsigned long)f;
8265	if (along != 0x7fffffff)
8266		result |= 1;
8267	f += 2.;
8268	along = 0;
8269	along = (unsigned long)f;
8270	if (along != 0x80000001)
8271		result |= 2;
8272	if (result)
8273		exit(result);
8274	signal(SIGFPE, blech_in_list);
8275	sprintf(str, "123.");
8276	sscanf(str, "%lf", &f);  /* f = 123.; */
8277	along = dummy_long((unsigned long)f);
8278	aint = dummy_int((unsigned int)f);
8279	ashort = dummy_short((unsigned short)f);
8280	if (along != (unsigned long)123)
8281		result |= 4;
8282	if (aint != (unsigned int)123)
8283		result |= 4;
8284	if (ashort != (unsigned short)123)
8285		result |= 4;
8286	exit(result);
8287
8288}
8289EOCP
8290set try
8291if eval $compile_ok; then
8292	./try
8293	castflags=$?
8294else
8295	echo "(I can't seem to compile the test program--assuming it can't)"
8296	castflags=7
8297fi
8298case "$castflags" in
82990)	val="$define"
8300	echo "Yup, it can."
8301	;;
8302*)	val="$undef"
8303	echo "Nope, it can't."
8304	;;
8305esac
8306set d_castneg
8307eval $setvar
8308$rm -f try.*
8309
8310: see if vprintf exists
8311echo " "
8312if set vprintf val -f d_vprintf; eval $csym; $val; then
8313	echo 'vprintf() found.' >&4
8314	val="$define"
8315	$cat >vprintf.c <<'EOF'
8316#include <varargs.h>
8317
8318int main() { xxx("foo"); }
8319
8320xxx(va_alist)
8321va_dcl
8322{
8323	va_list args;
8324	char buf[10];
8325
8326	va_start(args);
8327	exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
8328}
8329EOF
8330	set vprintf
8331	if eval $compile && ./vprintf; then
8332		echo "Your vsprintf() returns (int)." >&4
8333		val2="$undef"
8334	else
8335		echo "Your vsprintf() returns (char*)." >&4
8336		val2="$define"
8337	fi
8338else
8339	echo 'vprintf() NOT found.' >&4
8340		val="$undef"
8341		val2="$undef"
8342fi
8343set d_vprintf
8344eval $setvar
8345val=$val2
8346set d_charvspr
8347eval $setvar
8348
8349: see if chown exists
8350set chown d_chown
8351eval $inlibc
8352
8353: see if chroot exists
8354set chroot d_chroot
8355eval $inlibc
8356
8357: see if chsize exists
8358set chsize d_chsize
8359eval $inlibc
8360
8361: check for const keyword
8362echo " "
8363echo 'Checking to see if your C compiler knows about "const"...' >&4
8364$cat >const.c <<'EOCP'
8365typedef struct spug { int drokk; } spug;
8366int main()
8367{
8368	const char *foo;
8369	const spug y;
8370}
8371EOCP
8372if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
8373	val="$define"
8374	echo "Yup, it does."
8375else
8376	val="$undef"
8377	echo "Nope, it doesn't."
8378fi
8379set d_const
8380eval $setvar
8381
8382: see if crypt exists
8383echo " "
8384if set crypt val -f d_crypt; eval $csym; $val; then
8385	echo 'crypt() found.' >&4
8386	val="$define"
8387	cryptlib=''
8388else
8389	cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
8390	if $test -z "$cryptlib"; then
8391		cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
8392	else
8393		cryptlib=-lcrypt
8394	fi
8395	if $test -z "$cryptlib"; then
8396		cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
8397	else
8398		cryptlib=-lcrypt
8399	fi
8400	if $test -z "$cryptlib"; then
8401		cryptlib=`./loc libcrypt$_a "" $libpth`
8402	else
8403		cryptlib=-lcrypt
8404	fi
8405	if $test -z "$cryptlib"; then
8406		echo 'crypt() NOT found.' >&4
8407		val="$undef"
8408	else
8409		val="$define"
8410	fi
8411fi
8412set d_crypt
8413eval $setvar
8414
8415: get csh whereabouts
8416case "$csh" in
8417'csh') val="$undef" ;;
8418*) val="$define" ;;
8419esac
8420set d_csh
8421eval $setvar
8422: Respect a hint or command line value for full_csh.
8423case "$full_csh" in
8424'') full_csh=$csh ;;
8425esac
8426
8427: see if cuserid exists
8428set cuserid d_cuserid
8429eval $inlibc
8430
8431: see if this is a limits.h system
8432set limits.h i_limits
8433eval $inhdr
8434
8435: see if this is a float.h system
8436set float.h i_float
8437eval $inhdr
8438
8439: See if number of significant digits in a double precision number is known
8440echo " "
8441$cat >dbl_dig.c <<EOM
8442#$i_limits I_LIMITS
8443#$i_float I_FLOAT
8444#ifdef I_LIMITS
8445#include <limits.h>
8446#endif
8447#ifdef I_FLOAT
8448#include <float.h>
8449#endif
8450#ifdef DBL_DIG
8451printf("Contains DBL_DIG");
8452#endif
8453EOM
8454$cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
8455if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
8456	echo "DBL_DIG found." >&4
8457	val="$define"
8458else
8459	echo "DBL_DIG NOT found." >&4
8460	val="$undef"
8461fi
8462$rm -f dbl_dig.?
8463set d_dbl_dig
8464eval $setvar
8465
8466: see if difftime exists
8467set difftime d_difftime
8468eval $inlibc
8469
8470: see if this is a dirent system
8471echo " "
8472if xinc=`./findhdr dirent.h`; $test "$xinc"; then
8473	val="$define"
8474	echo "<dirent.h> found." >&4
8475else
8476	val="$undef"
8477	if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
8478		echo "<sys/dir.h> found." >&4
8479		echo " "
8480	else
8481		xinc=`./findhdr sys/ndir.h`
8482	fi
8483	echo "<dirent.h> NOT found." >&4
8484fi
8485set i_dirent
8486eval $setvar
8487
8488: Look for type of directory structure.
8489echo " "
8490$cppstdin $cppflags $cppminus < "$xinc" > try.c
8491
8492case "$direntrytype" in
8493''|' ')
8494	case "$i_dirent" in
8495	$define) guess1='struct dirent' ;;
8496	*) guess1='struct direct'  ;;
8497	esac
8498	;;
8499*)	guess1="$direntrytype"
8500	;;
8501esac
8502
8503case "$guess1" in
8504'struct dirent') guess2='struct direct' ;;
8505*) guess2='struct dirent' ;;
8506esac
8507
8508if $contains "$guess1" try.c >/dev/null 2>&1; then
8509	direntrytype="$guess1"
8510	echo "Your directory entries are $direntrytype." >&4
8511elif $contains "$guess2" try.c >/dev/null 2>&1; then
8512	direntrytype="$guess2"
8513	echo "Your directory entries seem to be $direntrytype." >&4
8514else
8515	echo "I don't recognize your system's directory entries." >&4
8516	rp="What type is used for directory entries on this system?"
8517	dflt="$guess1"
8518	. ./myread
8519	direntrytype="$ans"
8520fi
8521$rm -f try.c
8522
8523
8524: see if the directory entry stores field length
8525echo " "
8526$cppstdin $cppflags $cppminus < "$xinc" > try.c
8527if $contains 'd_namlen' try.c >/dev/null 2>&1; then
8528	echo "Good, your directory entry keeps length information in d_namlen." >&4
8529	val="$define"
8530else
8531	echo "Your directory entry does not know about the d_namlen field." >&4
8532	val="$undef"
8533fi
8534set d_dirnamlen
8535eval $setvar
8536$rm -f try.c
8537
8538: see if dlerror exists
8539xxx_runnm="$runnm"
8540runnm=false
8541set dlerror d_dlerror
8542eval $inlibc
8543runnm="$xxx_runnm"
8544
8545: see if dlfcn is available
8546set dlfcn.h i_dlfcn
8547eval $inhdr
8548
8549case "$usedl" in
8550$define|y|true)
8551	$cat << EOM
8552
8553On a few systems, the dynamically loaded modules that perl generates and uses
8554will need a different extension than shared libs. The default will probably
8555be appropriate.
8556
8557EOM
8558	case "$dlext" in
8559	'')	dflt="$so" ;;
8560	*)	dflt="$dlext" ;;
8561	esac
8562	rp='What is the extension of dynamically loaded modules'
8563	. ./myread
8564	dlext="$ans"
8565	;;
8566*)
8567	dlext="none"
8568	;;
8569esac
8570
8571: Check if dlsym need a leading underscore
8572echo " "
8573val="$undef"
8574
8575case "$dlsrc" in
8576dl_dlopen.xs)
8577	echo "Checking whether your dlsym() needs a leading underscore ..." >&4
8578	$cat >dyna.c <<'EOM'
8579fred () { }
8580EOM
8581
8582$cat >fred.c<<EOM
8583
8584#include <stdio.h>
8585#$i_dlfcn I_DLFCN
8586#ifdef I_DLFCN
8587#include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
8588#else
8589#include <sys/types.h>
8590#include <nlist.h>
8591#include <link.h>
8592#endif
8593
8594extern int fred() ;
8595
8596int main()
8597{
8598    void * handle ;
8599    void * symbol ;
8600#ifndef RTLD_LAZY
8601    int mode = 1 ;
8602#else
8603    int mode = RTLD_LAZY ;
8604#endif
8605    handle = dlopen("./dyna.$dlext", mode) ;
8606    if (handle == NULL) {
8607	printf ("1\n") ;
8608	fflush (stdout) ;
8609	exit(0);
8610    }
8611    symbol = dlsym(handle, "fred") ;
8612    if (symbol == NULL) {
8613	/* try putting a leading underscore */
8614	symbol = dlsym(handle, "_fred") ;
8615	if (symbol == NULL) {
8616	    printf ("2\n") ;
8617	    fflush (stdout) ;
8618	    exit(0);
8619	}
8620	printf ("3\n") ;
8621    }
8622    else
8623	printf ("4\n") ;
8624    fflush (stdout) ;
8625    exit(0);
8626}
8627EOM
8628	: Call the object file tmp-dyna.o in case dlext=o.
8629	if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 &&
8630		mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 &&
8631		$ld -o dyna.$dlext $lddlflags tmp-dyna${_o} > /dev/null 2>&1 &&
8632		$cc -o fred $ccflags $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
8633		xxx=`./fred`
8634		case $xxx in
8635		1)	echo "Test program failed using dlopen." >&4
8636			echo "Perhaps you should not use dynamic loading." >&4;;
8637		2)	echo "Test program failed using dlsym." >&4
8638			echo "Perhaps you should not use dynamic loading." >&4;;
8639		3)	echo "dlsym needs a leading underscore" >&4
8640			val="$define" ;;
8641		4)	echo "dlsym doesn't need a leading underscore." >&4;;
8642		esac
8643	else
8644		echo "I can't compile and run the test program." >&4
8645                echo "I'm guessing that dlsym doesn't need a leading underscore." >&4
8646	fi
8647	;;
8648esac
8649
8650$rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
8651
8652set d_dlsymun
8653eval $setvar
8654
8655hasproto='varname=$1; func=$2; shift; shift;
8656while $test $# -ge 2; do
8657	case "$1" in
8658	$define) echo "#include <$2>";;
8659	esac ;
8660    shift 2;
8661done > try.c;
8662$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
8663if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
8664	echo "$func() prototype found.";
8665	val="$define";
8666else
8667	echo "$func() prototype NOT found.";
8668	val="$undef";
8669fi;
8670set $varname;
8671eval $setvar;
8672$rm -f try.c tryout.c'
8673
8674: see if prototype for drand48 is available
8675echo " "
8676set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
8677eval $hasproto
8678
8679: see if dup2 exists
8680set dup2 d_dup2
8681eval $inlibc
8682
8683: see if eaccess exists
8684set eaccess d_eaccess
8685eval $inlibc
8686
8687: see if endgrent exists
8688set endgrent d_endgrent
8689eval $inlibc
8690
8691: see if endhostent exists
8692set endhostent d_endhent
8693eval $inlibc
8694
8695: see if endnetent exists
8696set endnetent d_endnent
8697eval $inlibc
8698
8699: see if endprotoent exists
8700set endprotoent d_endpent
8701eval $inlibc
8702
8703: see if endpwent exists
8704set endpwent d_endpwent
8705eval $inlibc
8706
8707: see if endservent exists
8708set endservent d_endsent
8709eval $inlibc
8710
8711: Locate the flags for 'open()'
8712echo " "
8713$cat >open3.c <<'EOCP'
8714#include <sys/types.h>
8715#ifdef I_FCNTL
8716#include <fcntl.h>
8717#endif
8718#ifdef I_SYS_FILE
8719#include <sys/file.h>
8720#endif
8721int main() {
8722	if(O_RDONLY);
8723#ifdef O_TRUNC
8724	exit(0);
8725#else
8726	exit(1);
8727#endif
8728}
8729EOCP
8730: check sys/file.h first to get FREAD on Sun
8731if $test `./findhdr sys/file.h` && \
8732		set open3 -DI_SYS_FILE && eval $compile; then
8733	h_sysfile=true;
8734	echo "<sys/file.h> defines the O_* constants..." >&4
8735	if ./open3; then
8736		echo "and you have the 3 argument form of open()." >&4
8737		val="$define"
8738	else
8739		echo "but not the 3 argument form of open().  Oh, well." >&4
8740		val="$undef"
8741	fi
8742elif $test `./findhdr fcntl.h` && \
8743		set open3 -DI_FCNTL && eval $compile; then
8744	h_fcntl=true;
8745	echo "<fcntl.h> defines the O_* constants..." >&4
8746	if ./open3; then
8747		echo "and you have the 3 argument form of open()." >&4
8748		val="$define"
8749	else
8750		echo "but not the 3 argument form of open().  Oh, well." >&4
8751		val="$undef"
8752	fi
8753else
8754	val="$undef"
8755	echo "I can't find the O_* constant definitions!  You got problems." >&4
8756fi
8757set d_open3
8758eval $setvar
8759$rm -f open3*
8760
8761: see which of string.h or strings.h is needed
8762echo " "
8763strings=`./findhdr string.h`
8764if $test "$strings" && $test -r "$strings"; then
8765	echo "Using <string.h> instead of <strings.h>." >&4
8766	val="$define"
8767else
8768	val="$undef"
8769	strings=`./findhdr strings.h`
8770	if $test "$strings" && $test -r "$strings"; then
8771		echo "Using <strings.h> instead of <string.h>." >&4
8772	else
8773		echo "No string header found -- You'll surely have problems." >&4
8774	fi
8775fi
8776set i_string
8777eval $setvar
8778case "$i_string" in
8779"$undef") strings=`./findhdr strings.h`;;
8780*)	  strings=`./findhdr string.h`;;
8781esac
8782
8783: check for non-blocking I/O stuff
8784case "$h_sysfile" in
8785true) echo "#include <sys/file.h>" > head.c;;
8786*)
8787	case "$h_fcntl" in
8788	true) echo "#include <fcntl.h>" > head.c;;
8789	*) echo "#include <sys/fcntl.h>" > head.c;;
8790	esac
8791	;;
8792esac
8793echo " "
8794echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
8795case "$o_nonblock" in
8796'')
8797	$cat head.c > try.c
8798	$cat >>try.c <<'EOCP'
8799#include <stdio.h>
8800int main() {
8801#ifdef O_NONBLOCK
8802	printf("O_NONBLOCK\n");
8803	exit(0);
8804#endif
8805#ifdef O_NDELAY
8806	printf("O_NDELAY\n");
8807	exit(0);
8808#endif
8809#ifdef FNDELAY
8810	printf("FNDELAY\n");
8811	exit(0);
8812#endif
8813	exit(0);
8814}
8815EOCP
8816	set try
8817	if eval $compile_ok; then
8818		o_nonblock=`./try`
8819		case "$o_nonblock" in
8820		'') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
8821		*) echo "Seems like we can use $o_nonblock.";;
8822		esac
8823	else
8824		echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
8825	fi
8826	;;
8827*) echo "Using $hint value $o_nonblock.";;
8828esac
8829$rm -f try try.* .out core
8830
8831echo " "
8832echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
8833case "$eagain" in
8834'')
8835	$cat head.c > try.c
8836	$cat >>try.c <<EOCP
8837#include <errno.h>
8838#include <sys/types.h>
8839#include <signal.h>
8840#include <stdio.h> 
8841#define MY_O_NONBLOCK $o_nonblock
8842#ifndef errno  /* XXX need better Configure test */
8843extern int errno;
8844#endif
8845#$i_unistd I_UNISTD
8846#ifdef I_UNISTD
8847#include <unistd.h>
8848#endif
8849#$i_string I_STRING
8850#ifdef I_STRING
8851#include <string.h>
8852#else
8853#include <strings.h>
8854#endif
8855$signal_t blech(x) int x; { exit(3); }
8856EOCP
8857	$cat >> try.c <<'EOCP'
8858int main()
8859{
8860	int pd[2];
8861	int pu[2];
8862	char buf[1];
8863	char string[100];
8864
8865	pipe(pd);	/* Down: child -> parent */
8866	pipe(pu);	/* Up: parent -> child */
8867	if (0 != fork()) {
8868		int ret;
8869		close(pd[1]);	/* Parent reads from pd[0] */
8870		close(pu[0]);	/* Parent writes (blocking) to pu[1] */
8871#ifdef F_SETFL
8872		if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
8873			exit(1);
8874#else
8875		exit(4);
8876#endif
8877		signal(SIGALRM, blech);
8878		alarm(5);
8879		if ((ret = read(pd[0], buf, 1)) > 0)	/* Nothing to read! */
8880			exit(2);
8881		sprintf(string, "%d\n", ret);
8882		write(2, string, strlen(string));
8883		alarm(0);
8884#ifdef EAGAIN
8885		if (errno == EAGAIN) {
8886			printf("EAGAIN\n");
8887			goto ok;
8888		}
8889#endif
8890#ifdef EWOULDBLOCK
8891		if (errno == EWOULDBLOCK)
8892			printf("EWOULDBLOCK\n");
8893#endif
8894	ok:
8895		write(pu[1], buf, 1);	/* Unblocks child, tell it to close our pipe */
8896		sleep(2);				/* Give it time to close our pipe */
8897		alarm(5);
8898		ret = read(pd[0], buf, 1);	/* Should read EOF */
8899		alarm(0);
8900		sprintf(string, "%d\n", ret);
8901		write(3, string, strlen(string));
8902		exit(0);
8903	}
8904
8905	close(pd[0]);			/* We write to pd[1] */
8906	close(pu[1]);			/* We read from pu[0] */
8907	read(pu[0], buf, 1);	/* Wait for parent to signal us we may continue */
8908	close(pd[1]);			/* Pipe pd is now fully closed! */
8909	exit(0);				/* Bye bye, thank you for playing! */
8910}
8911EOCP
8912	set try
8913	if eval $compile_ok; then
8914		echo "$startsh" >mtry
8915		echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
8916		chmod +x mtry
8917		./mtry >/dev/null 2>&1
8918		case $? in
8919		0) eagain=`$cat try.out`;;
8920		1) echo "Could not perform non-blocking setting!";;
8921		2) echo "I did a successful read() for something that was not there!";;
8922		3) echo "Hmm... non-blocking I/O does not seem to be working!";;
8923		4) echo "Could not find F_SETFL!";;
8924		*) echo "Something terribly wrong happened during testing.";;
8925		esac
8926		rd_nodata=`$cat try.ret`
8927		echo "A read() system call with no data present returns $rd_nodata."
8928		case "$rd_nodata" in
8929		0|-1) ;;
8930		*)
8931			echo "(That's peculiar, fixing that to be -1.)"
8932			rd_nodata=-1
8933			;;
8934		esac
8935		case "$eagain" in
8936		'')
8937			echo "Forcing errno EAGAIN on read() with no data available."
8938			eagain=EAGAIN
8939			;;
8940		*)
8941			echo "Your read() sets errno to $eagain when no data is available."
8942			;;
8943		esac
8944		status=`$cat try.err`
8945		case "$status" in
8946		0) echo "And it correctly returns 0 to signal EOF.";;
8947		-1) echo "But it also returns -1 to signal EOF, so be careful!";;
8948		*) echo "However, your read() returns '$status' on EOF??";;
8949		esac
8950		val="$define"
8951		if test "$status" = "$rd_nodata"; then
8952			echo "WARNING: you can't distinguish between EOF and no data!"
8953			val="$undef"
8954		fi
8955	else
8956		echo "I can't compile the test program--assuming errno EAGAIN will do."
8957		eagain=EAGAIN
8958	fi
8959	set d_eofnblk
8960	eval $setvar
8961	;;
8962*)
8963	echo "Using $hint value $eagain."
8964	echo "Your read() returns $rd_nodata when no data is present."
8965	case "$d_eofnblk" in
8966	"$define") echo "And you can see EOF because read() returns 0.";;
8967	"$undef") echo "But you can't see EOF status from read() returned value.";;
8968	*)
8969		echo "(Assuming you can't see EOF status from read anyway.)"
8970		d_eofnblk=$undef
8971		;;
8972	esac
8973	;;
8974esac
8975$rm -f try try.* .out core head.c mtry
8976
8977: see if fchmod exists
8978set fchmod d_fchmod
8979eval $inlibc
8980
8981: see if fchown exists
8982set fchown d_fchown
8983eval $inlibc
8984
8985: see if this is an fcntl system
8986set fcntl d_fcntl
8987eval $inlibc
8988
8989echo " "
8990: See if fcntl-based locking works.
8991$cat >try.c <<'EOCP'
8992#include <stdlib.h>
8993#include <unistd.h>
8994#include <fcntl.h>
8995int main() {
8996#if defined(F_SETLK) && defined(F_SETLKW)
8997     struct flock flock;
8998     int retval, fd;
8999     fd = open("try.c", O_RDONLY);
9000     flock.l_type = F_RDLCK;
9001     flock.l_whence = SEEK_SET;
9002     flock.l_start = flock.l_len = 0;
9003     retval = fcntl(fd, F_SETLK, &flock);
9004     close(fd);
9005     (retval < 0 ? exit(2) : exit(0));
9006#else
9007     exit(2);
9008#endif
9009}
9010EOCP
9011echo "Checking if fcntl-based file locking works... "
9012case "$d_fcntl" in
9013"$define")
9014	set try
9015	if eval $compile_ok; then
9016		if ./try; then
9017			echo "Yes, it seems to work."
9018			val="$define"
9019		else
9020			echo "Nope, it didn't work."
9021			val="$undef"
9022		fi
9023	else
9024		echo "I'm unable to compile the test program, so I'll assume not."
9025		val="$undef"
9026	fi
9027	;;
9028*) val="$undef";
9029	echo "Nope, since you don't even have fcntl()."
9030	;;
9031esac
9032set d_fcntl_can_lock
9033eval $setvar
9034$rm -f try*
9035
9036
9037hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
9038while $test $# -ge 2; do
9039	case "$1" in
9040	$define) echo "#include <$2>";;
9041	esac ;
9042    shift 2;
9043done > try.c;
9044echo "int main () { struct $struct foo; char* bar; bar = (char*)foo.$field; }" >> try.c;
9045set try;
9046if eval $compile; then
9047	val="$define";
9048else
9049	val="$undef";
9050fi;
9051set $varname;
9052eval $setvar;
9053$rm -f try.c try.o'
9054
9055socketlib=''
9056sockethdr=''
9057: see whether socket exists
9058echo " "
9059$echo $n "Hmm... $c" >&4
9060if set socket val -f d_socket; eval $csym; $val; then
9061	echo "Looks like you have Berkeley networking support." >&4
9062	d_socket="$define"
9063	if set setsockopt val -f; eval $csym; $val; then
9064		d_oldsock="$undef"
9065	else
9066		echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
9067		d_oldsock="$define"
9068	fi
9069else
9070	if $contains socklib libc.list >/dev/null 2>&1; then
9071		echo "Looks like you have Berkeley networking support." >&4
9072		d_socket="$define"
9073		: we will have to assume that it supports the 4.2 BSD interface
9074		d_oldsock="$undef"
9075	else
9076		echo "You don't have Berkeley networking in libc$_a..." >&4
9077		if test "X$d_socket" = "X$define"; then
9078		   echo "...but you seem to believe that you have sockets." >&4
9079		else
9080			for net in net socket
9081			do
9082				if test -f /usr/lib/lib$net$_a; then
9083					( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
9084					$ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
9085					if $contains socket libc.list >/dev/null 2>&1; then
9086						d_socket="$define"
9087						socketlib="-l$net"
9088						case "$net" in
9089						net)
9090							echo "...but the Wollongong group seems to have hacked it in." >&4
9091							sockethdr="-I/usr/netinclude"
9092							;;
9093						esac
9094						echo "Found Berkeley sockets interface in lib$net." >& 4
9095						if $contains setsockopt libc.list >/dev/null 2>&1; then
9096							d_oldsock="$undef"
9097						else
9098							echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
9099							d_oldsock="$define"
9100						fi
9101						break
9102					fi
9103				fi
9104			done
9105			if test "X$d_socket" != "X$define"; then
9106			   echo "or anywhere else I see." >&4
9107			   d_socket="$undef"
9108			   d_oldsock="$undef"
9109			fi
9110		fi
9111	fi
9112fi
9113
9114: see if socketpair exists
9115set socketpair d_sockpair
9116eval $inlibc
9117
9118
9119echo " "
9120echo "Checking the availability of certain socket constants..." >& 4
9121for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
9122	enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
9123	$cat >try.c <<EOF
9124#include <sys/types.h>
9125#include <sys/socket.h>
9126int main() {
9127    int i = $ENUM;
9128}
9129EOF
9130	val="$undef"
9131	set try; if eval $compile; then
9132		val="$define"
9133	fi
9134	set d_${enum}; eval $setvar
9135	$rm -f try.c try
9136done
9137
9138: see if sys/select.h has to be included
9139set sys/select.h i_sysselct
9140eval $inhdr
9141
9142: see if we should include time.h, sys/time.h, or both
9143echo " "
9144if test "X$timeincl" = X; then
9145	echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
9146	$echo $n "I'm now running the test program...$c"
9147	$cat >try.c <<'EOCP'
9148#include <sys/types.h>
9149#ifdef I_TIME
9150#include <time.h>
9151#endif
9152#ifdef I_SYSTIME
9153#ifdef SYSTIMEKERNEL
9154#define KERNEL
9155#endif
9156#include <sys/time.h>
9157#endif
9158#ifdef I_SYSSELECT
9159#include <sys/select.h>
9160#endif
9161int main()
9162{
9163	struct tm foo;
9164#ifdef S_TIMEVAL
9165	struct timeval bar;
9166#endif
9167#ifdef S_TIMEZONE
9168	struct timezone tzp;
9169#endif
9170	if (foo.tm_sec == foo.tm_sec)
9171		exit(0);
9172#ifdef S_TIMEVAL
9173	if (bar.tv_sec == bar.tv_sec)
9174		exit(0);
9175#endif
9176	exit(1);
9177}
9178EOCP
9179	flags=''
9180	for s_timezone in '-DS_TIMEZONE' ''; do
9181	sysselect=''
9182	for s_timeval in '-DS_TIMEVAL' ''; do
9183	for i_systimek in '' '-DSYSTIMEKERNEL'; do
9184	for i_time in '' '-DI_TIME'; do
9185	for i_systime in '-DI_SYSTIME' ''; do
9186		case "$flags" in
9187		'') $echo $n ".$c"
9188			set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
9189			if eval $compile; then
9190				set X $i_time $i_systime $i_systimek $sysselect $s_timeval
9191				shift
9192				flags="$*"
9193				echo " "
9194				$echo $n "Succeeded with $flags$c"
9195			fi
9196			;;
9197		esac
9198	done
9199	done
9200	done
9201	done
9202	done
9203	timeincl=''
9204	echo " "
9205	case "$flags" in
9206	*SYSTIMEKERNEL*) i_systimek="$define"
9207		timeincl=`./findhdr sys/time.h`
9208		echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
9209	*) i_systimek="$undef";;
9210	esac
9211	case "$flags" in
9212	*I_TIME*) i_time="$define"
9213		timeincl=`./findhdr time.h`" $timeincl"
9214		echo "We'll include <time.h>." >&4;;
9215	*) i_time="$undef";;
9216	esac
9217	case "$flags" in
9218	*I_SYSTIME*) i_systime="$define"
9219		timeincl=`./findhdr sys/time.h`" $timeincl"
9220		echo "We'll include <sys/time.h>." >&4;;
9221	*) i_systime="$undef";;
9222	esac
9223	$rm -f try.c try
9224fi
9225
9226: check for fd_set items
9227$cat <<EOM
9228
9229Checking to see how well your C compiler handles fd_set and friends ...
9230EOM
9231$cat >fd_set.c <<EOCP
9232#$i_systime I_SYS_TIME
9233#$i_sysselct I_SYS_SELECT
9234#$d_socket HAS_SOCKET
9235#include <sys/types.h>
9236#ifdef HAS_SOCKET
9237#include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
9238#endif
9239#ifdef I_SYS_TIME
9240#include <sys/time.h>
9241#endif
9242#ifdef I_SYS_SELECT
9243#include <sys/select.h>
9244#endif
9245int main() {
9246	fd_set fds;
9247
9248#ifdef TRYBITS
9249	if(fds.fds_bits);
9250#endif
9251
9252#if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
9253	exit(0);
9254#else
9255	exit(1);
9256#endif
9257}
9258EOCP
9259set fd_set -DTRYBITS
9260if eval $compile; then
9261	d_fds_bits="$define"
9262	d_fd_set="$define"
9263	echo "Well, your system knows about the normal fd_set typedef..." >&4
9264	if ./fd_set; then
9265		echo "and you have the normal fd_set macros (just as I'd expect)." >&4
9266		d_fd_macros="$define"
9267	else
9268		$cat >&4 <<'EOM'
9269but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
9270EOM
9271		d_fd_macros="$undef"
9272	fi
9273else
9274	$cat <<'EOM'
9275Hmm, your compiler has some difficulty with fd_set.  Checking further...
9276EOM
9277	set fd_set
9278	if eval $compile; then
9279		d_fds_bits="$undef"
9280		d_fd_set="$define"
9281		echo "Well, your system has some sort of fd_set available..." >&4
9282		if ./fd_set; then
9283			echo "and you have the normal fd_set macros." >&4
9284			d_fd_macros="$define"
9285		else
9286			$cat <<'EOM'
9287but not the normal fd_set macros!  Gross!  More work for me...
9288EOM
9289			d_fd_macros="$undef"
9290		fi
9291	else
9292	echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
9293		d_fd_set="$undef"
9294		d_fds_bits="$undef"
9295		d_fd_macros="$undef"
9296	fi
9297fi
9298$rm -f fd_set*
9299
9300: see if fgetpos exists
9301set fgetpos d_fgetpos
9302eval $inlibc
9303
9304: see if flock exists
9305set flock d_flock
9306eval $inlibc
9307
9308: see if fork exists
9309set fork d_fork
9310eval $inlibc
9311
9312: see if pathconf exists
9313set pathconf d_pathconf
9314eval $inlibc
9315
9316: see if fpathconf exists
9317set fpathconf d_fpathconf
9318eval $inlibc
9319
9320
9321: check for fpos64_t
9322echo " "
9323echo "Checking to see if you have fpos64_t..." >&4
9324$cat >try.c <<EOCP
9325#include <stdio.h>
9326int main() { fpos64_t x = 7; }
9327EOCP
9328set try
9329if eval $compile; then
9330	val="$define"
9331	echo "You have fpos64_t."
9332else
9333	val="$undef"
9334	echo "You do not have fpos64_t."
9335	case "$fpossize" in
9336	8) echo "(Your fpos_t is 64 bits, so you could use that.)" ;;
9337	esac
9338fi
9339$rm -f try.* try
9340set d_fpos64_t
9341eval $setvar
9342
9343: see if frexpl exists
9344set frexpl d_frexpl
9345eval $inlibc
9346
9347hasstruct='varname=$1; struct=$2; shift; shift;
9348while $test $# -ge 2; do
9349	case "$1" in
9350	$define) echo "#include <$2>";;
9351	esac ;
9352    shift 2;
9353done > try.c;
9354echo "int main () { struct $struct foo; }" >> try.c;
9355set try;
9356if eval $compile; then
9357	val="$define";
9358else
9359	val="$undef";
9360fi;
9361set $varname;
9362eval $setvar;
9363$rm -f try.c try.o'
9364
9365: see if this is a sys/param system
9366set sys/param.h i_sysparam
9367eval $inhdr
9368
9369: see if this is a sys/mount.h system
9370set sys/mount.h i_sysmount
9371eval $inhdr
9372
9373: see if sys/types.h has to be included
9374set sys/types.h i_systypes
9375eval $inhdr
9376
9377
9378echo " "
9379echo "Checking to see if your system supports struct fs_data..." >&4
9380set d_fs_data_s fs_data $i_systypes sys/types.h $i_sysparam sys/param.h $i_sysmount sys/mount.h
9381eval $hasstruct
9382case "$d_fs_data_s" in
9383"$define")      echo "Yes, it does."   ;;
9384*)              echo "No, it doesn't." ;;
9385esac
9386
9387: see if fseeko exists
9388set fseeko d_fseeko
9389eval $inlibc
9390case "$longsize" in
93918) echo "(Your long is 64 bits, so you could use fseek.)" ;;
9392esac
9393
9394: see if fsetpos exists
9395set fsetpos d_fsetpos
9396eval $inlibc
9397
9398
9399: see if fstatfs exists
9400set fstatfs d_fstatfs
9401eval $inlibc
9402
9403
9404: see if statvfs exists
9405set statvfs d_statvfs
9406eval $inlibc
9407
9408: see if fstatvfs exists
9409set fstatvfs d_fstatvfs
9410eval $inlibc
9411
9412
9413: see if fsync exists
9414set fsync d_fsync
9415eval $inlibc
9416
9417: see if ftello exists
9418set ftello d_ftello
9419eval $inlibc
9420case "$longsize" in
94218) echo "(Your long is 64 bits, so you could use ftell.)" ;;
9422esac
9423
9424: see if getcwd exists
9425set getcwd d_getcwd
9426eval $inlibc
9427
9428: see if getespwnam exists
9429set getespwnam d_getespwnam
9430eval $inlibc
9431
9432
9433: see if getfsstat exists
9434set getfsstat d_getfsstat
9435eval $inlibc
9436
9437: see if getgrent exists
9438set getgrent d_getgrent
9439eval $inlibc
9440
9441: see if gethostbyaddr exists
9442set gethostbyaddr d_gethbyaddr
9443eval $inlibc
9444
9445: see if gethostbyname exists
9446set gethostbyname d_gethbyname
9447eval $inlibc
9448
9449: see if gethostent exists
9450set gethostent d_gethent
9451eval $inlibc
9452
9453: see how we will look up host name
9454echo " "
9455call=''
9456if set gethostname val -f d_gethname; eval $csym; $val; then
9457	echo 'gethostname() found.' >&4
9458	d_gethname="$define"
9459	call=gethostname
9460fi
9461if set uname val -f d_uname; eval $csym; $val; then
9462	if ./xenix; then
9463		$cat <<'EOM'
9464uname() was found, but you're running xenix, and older versions of xenix
9465have a broken uname(). If you don't really know whether your xenix is old
9466enough to have a broken system call, use the default answer.
9467
9468EOM
9469		dflt=y
9470		case "$d_uname" in
9471		"$define") dflt=n;;
9472		esac
9473		rp='Is your uname() broken?'
9474		. ./myread
9475		case "$ans" in
9476		n*) d_uname="$define"; call=uname;;
9477		esac
9478	else
9479		echo 'uname() found.' >&4
9480		d_uname="$define"
9481		case "$call" in
9482		'') call=uname ;;
9483		esac
9484	fi
9485fi
9486case "$d_gethname" in
9487'') d_gethname="$undef";;
9488esac
9489case "$d_uname" in
9490'') d_uname="$undef";;
9491esac
9492case "$d_uname$d_gethname" in
9493*define*)
9494	dflt=n
9495	cat <<EOM
9496
9497Every now and then someone has a $call() that lies about the hostname
9498but can't be fixed for political or economic reasons.  If you wish, I can
9499pretend $call() isn't there and maybe compute hostname at run-time
9500thanks to the '$phostname' command.
9501
9502EOM
9503	rp="Shall I ignore $call() from now on?"
9504	. ./myread
9505	case "$ans" in
9506	y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
9507	esac;;
9508esac
9509case "$phostname" in
9510'') aphostname='';;
9511*) case "$aphostname" in
9512	/*) ;;
9513	*) set X $phostname
9514		shift
9515		file=$1
9516		shift
9517		file=`./loc $file $file $pth`
9518		aphostname=`echo $file $*`
9519		;;
9520	esac
9521	;;
9522esac
9523case "$d_uname$d_gethname" in
9524*define*) ;;
9525*)
9526	case "$phostname" in
9527	'')
9528		echo "There will be no way for $package to get your hostname." >&4;;
9529	*)
9530	echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
9531		;;
9532	esac;;
9533esac
9534case "$d_phostname" in
9535'') d_phostname="$undef";;
9536esac
9537
9538: see if this is a netdb.h system
9539set netdb.h i_netdb
9540eval $inhdr
9541
9542: see if prototypes for various gethostxxx netdb.h functions are available
9543echo " "
9544set d_gethostprotos gethostent $i_netdb netdb.h
9545eval $hasproto
9546
9547: see if getlogin exists
9548set getlogin d_getlogin
9549eval $inlibc
9550
9551: see if getmnt exists
9552set getmnt d_getmnt
9553eval $inlibc
9554
9555: see if getmntent exists
9556set getmntent d_getmntent
9557eval $inlibc
9558
9559: see if getnetbyaddr exists
9560set getnetbyaddr d_getnbyaddr
9561eval $inlibc
9562
9563: see if getnetbyname exists
9564set getnetbyname d_getnbyname
9565eval $inlibc
9566
9567: see if getnetent exists
9568set getnetent d_getnent
9569eval $inlibc
9570
9571: see if prototypes for various getnetxxx netdb.h functions are available
9572echo " "
9573set d_getnetprotos getnetent $i_netdb netdb.h
9574eval $hasproto
9575
9576: see if getpagesize exists
9577set getpagesize d_getpagsz
9578eval $inlibc
9579
9580
9581: see if getprotobyname exists
9582set getprotobyname d_getpbyname
9583eval $inlibc
9584
9585: see if getprotobynumber exists
9586set getprotobynumber d_getpbynumber
9587eval $inlibc
9588
9589: see if getprotoent exists
9590set getprotoent d_getpent
9591eval $inlibc
9592
9593: see if getpgid exists
9594set getpgid d_getpgid
9595eval $inlibc
9596
9597: see if getpgrp2 exists
9598set getpgrp2 d_getpgrp2
9599eval $inlibc
9600
9601: see if getppid exists
9602set getppid d_getppid
9603eval $inlibc
9604
9605: see if getpriority exists
9606set getpriority d_getprior
9607eval $inlibc
9608
9609: see if prototypes for various getprotoxxx netdb.h functions are available
9610echo " "
9611set d_getprotoprotos getprotoent $i_netdb netdb.h
9612eval $hasproto
9613
9614: see if getprpwnam exists
9615set getprpwnam d_getprpwnam
9616eval $inlibc
9617
9618: see if getpwent exists
9619set getpwent d_getpwent
9620eval $inlibc
9621
9622
9623: see if getservbyname exists
9624set getservbyname d_getsbyname
9625eval $inlibc
9626
9627: see if getservbyport exists
9628set getservbyport d_getsbyport
9629eval $inlibc
9630
9631: see if getservent exists
9632set getservent d_getsent
9633eval $inlibc
9634
9635: see if prototypes for various getservxxx netdb.h functions are available
9636echo " "
9637set d_getservprotos getservent $i_netdb netdb.h
9638eval $hasproto
9639
9640: see if getspnam exists
9641set getspnam d_getspnam
9642eval $inlibc
9643
9644: see if gettimeofday or ftime exists
9645set gettimeofday d_gettimeod
9646eval $inlibc
9647case "$d_gettimeod" in
9648"$undef")
9649	set ftime d_ftime
9650	eval $inlibc
9651	;;
9652*)
9653	val="$undef"; set d_ftime; eval $setvar
9654	;;
9655esac
9656case "$d_gettimeod$d_ftime" in
9657"$undef$undef")
9658	echo " "
9659	echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
9660	;;
9661esac
9662
9663: see if this is an grp system
9664set grp.h i_grp
9665eval $inhdr
9666
9667case "$i_grp" in
9668$define)
9669	xxx=`./findhdr grp.h`
9670	$cppstdin $cppflags $cppminus < $xxx >$$.h
9671
9672	if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
9673		val="$define"
9674	else
9675		val="$undef"
9676	fi
9677	set d_grpasswd
9678	eval $setvar
9679
9680	$rm -f $$.h
9681	;;
9682*)
9683	val="$undef";
9684	set d_grpasswd; eval $setvar
9685	;;
9686esac
9687
9688: see if hasmntopt exists
9689set hasmntopt d_hasmntopt
9690eval $inlibc
9691
9692: see if this is a netinet/in.h or sys/in.h system
9693set netinet/in.h i_niin sys/in.h i_sysin
9694eval $inhdr
9695
9696: see if arpa/inet.h has to be included
9697set arpa/inet.h i_arpainet
9698eval $inhdr
9699
9700: see if htonl --and friends-- exists
9701val=''
9702set htonl val
9703eval $inlibc
9704
9705: Maybe they are macros.
9706case "$val" in
9707$undef)
9708	$cat >htonl.c <<EOM
9709#include <stdio.h>
9710#include <sys/types.h>
9711#$i_niin I_NETINET_IN
9712#$i_sysin I_SYS_IN
9713#$i_arpainet I_ARPA_INET
9714#ifdef I_NETINET_IN
9715#include <netinet/in.h>
9716#endif
9717#ifdef I_SYS_IN
9718#include <sys/in.h>
9719#endif
9720#ifdef I_ARPA_INET
9721#include <arpa/inet.h>
9722#endif
9723#ifdef htonl
9724printf("Defined as a macro.");
9725#endif
9726EOM
9727	$cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
9728	if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
9729		val="$define"
9730		echo "But it seems to be defined as a macro." >&4
9731	fi
9732	$rm -f htonl.?
9733	;;
9734esac
9735set d_htonl
9736eval $setvar
9737
9738: see if iconv exists
9739set iconv d_iconv
9740eval $inlibc
9741
9742: index or strchr
9743echo " "
9744if set index val -f; eval $csym; $val; then
9745	if set strchr val -f d_strchr; eval $csym; $val; then
9746		if $contains strchr "$strings" >/dev/null 2>&1 ; then
9747			val="$define"
9748			vali="$undef"
9749			echo "strchr() found." >&4
9750		else
9751			val="$undef"
9752			vali="$define"
9753			echo "index() found." >&4
9754		fi
9755	else
9756		val="$undef"
9757		vali="$define"
9758		echo "index() found." >&4
9759	fi
9760else
9761	if set strchr val -f d_strchr; eval $csym; $val; then
9762		val="$define"
9763		vali="$undef"
9764		echo "strchr() found." >&4
9765	else
9766		echo "No index() or strchr() found!" >&4
9767		val="$undef"
9768		vali="$undef"
9769	fi
9770fi
9771set d_strchr; eval $setvar
9772val="$vali"
9773set d_index; eval $setvar
9774
9775: check whether inet_aton exists
9776set inet_aton d_inetaton
9777eval $inlibc
9778
9779: see if inttypes.h is available
9780: we want a real compile instead of Inhdr because some systems
9781: have an inttypes.h which includes non-existent headers
9782echo " "
9783$cat >try.c <<EOCP
9784#include <inttypes.h>
9785int main() {
9786	static int32_t foo32 = 0x12345678;
9787}
9788EOCP
9789set try
9790if eval $compile; then
9791	echo "<inttypes.h> found." >&4
9792	val="$define"
9793else
9794	echo "<inttypes.h> NOT found." >&4
9795	val="$undef"
9796fi
9797$rm -f try.c try
9798set i_inttypes
9799eval $setvar
9800
9801: check for int64_t
9802echo " "
9803echo "Checking to see if you have int64_t..." >&4
9804$cat >try.c <<EOCP
9805#include <sys/types.h>
9806#$i_inttypes I_INTTYPES
9807#ifdef I_INTTYPES
9808#include <inttypes.h>
9809#endif
9810int main() { int64_t x = 7; }
9811EOCP
9812set try
9813if eval $compile; then
9814	val="$define"
9815	echo "You have int64_t."
9816else
9817	val="$undef"
9818	echo "You do not have int64_t."
9819fi
9820$rm -f try try.*
9821set d_int64_t
9822eval $setvar
9823
9824: Look for isascii
9825echo " "
9826$cat >isascii.c <<'EOCP'
9827#include <stdio.h>
9828#include <ctype.h>
9829int main() {
9830	int c = 'A';
9831	if (isascii(c))
9832		exit(0);
9833	else
9834		exit(1);
9835}
9836EOCP
9837set isascii
9838if eval $compile; then
9839	echo "isascii() found." >&4
9840	val="$define"
9841else
9842	echo "isascii() NOT found." >&4
9843	val="$undef"
9844fi
9845set d_isascii
9846eval $setvar
9847$rm -f isascii*
9848
9849: see if isnan exists
9850set isnan d_isnan
9851eval $inlibc
9852
9853: see if isnanl exists
9854set isnanl d_isnanl
9855eval $inlibc
9856
9857: see if killpg exists
9858set killpg d_killpg
9859eval $inlibc
9860
9861: see if lchown exists
9862echo " "
9863$cat > try.c <<'EOCP'
9864/* System header to define __stub macros and hopefully few prototypes,
9865    which can conflict with char lchown(); below.  */
9866#include <assert.h>
9867/* Override any gcc2 internal prototype to avoid an error.  */
9868/* We use char because int might match the return type of a gcc2
9869   builtin and then its argument prototype would still apply.  */
9870char lchown();
9871int main() {
9872    /*  The GNU C library defines this for functions which it implements
9873        to always fail with ENOSYS.  Some functions are actually named
9874	something starting with __ and the normal name is an alias.  */
9875#if defined (__stub_lchown) || defined (__stub___lchown)
9876choke me
9877#else
9878lchown();
9879#endif
9880; return 0; }
9881EOCP
9882set try
9883if eval $compile; then
9884    $echo "lchown() found." >&4
9885    val="$define"
9886else
9887    $echo "lchown() NOT found." >&4
9888    val="$undef"
9889fi
9890set d_lchown
9891eval $setvar
9892
9893: See if number of significant digits in a double precision number is known
9894echo " "
9895$cat >ldbl_dig.c <<EOM
9896#$i_limits I_LIMITS
9897#$i_float I_FLOAT
9898#ifdef I_LIMITS
9899#include <limits.h>
9900#endif
9901#ifdef I_FLOAT
9902#include <float.h>
9903#endif
9904#ifdef LDBL_DIG
9905printf("Contains LDBL_DIG");
9906#endif
9907EOM
9908$cppstdin $cppflags $cppminus < ldbl_dig.c >ldbl_dig.E 2>/dev/null
9909if $contains 'LDBL_DIG' ldbl_dig.E >/dev/null 2>&1; then
9910	echo "LDBL_DIG found." >&4
9911	val="$define"
9912else
9913	echo "LDBL_DIG NOT found." >&4
9914	val="$undef"
9915fi
9916$rm -f ldbl_dig.?
9917set d_ldbl_dig
9918eval $setvar
9919
9920: see if link exists
9921set link d_link
9922eval $inlibc
9923
9924: see if localeconv exists
9925set localeconv d_locconv
9926eval $inlibc
9927
9928: see if lockf exists
9929set lockf d_lockf
9930eval $inlibc
9931
9932: check for long long
9933echo " "
9934echo "Checking to see if you have long long..." >&4
9935echo 'int main() { long long x = 7; return 0; }' > try.c
9936set try
9937if eval $compile; then
9938	val="$define"
9939	echo "You have long long."
9940else
9941	val="$undef"
9942	echo "You do not have long long."
9943fi
9944$rm try.*
9945set d_longlong
9946eval $setvar
9947
9948: check for length of long long
9949case "${d_longlong}${longlongsize}" in
9950$define)
9951	echo " "
9952	echo "Checking to see how big your long longs are..." >&4
9953	$cat >try.c <<'EOCP'
9954#include <stdio.h>
9955int main()
9956{
9957    printf("%d\n", (int)sizeof(long long));
9958    return(0);
9959}
9960EOCP
9961	set try
9962	if eval $compile_ok; then
9963		longlongsize=`./try$exe_ext`
9964		echo "Your long longs are $longlongsize bytes long."
9965	else
9966		dflt='8'
9967		echo " "
9968		echo "(I can't seem to compile the test program.  Guessing...)"
9969		rp="What is the size of a long long (in bytes)?"
9970		. ./myread
9971		longlongsize="$ans"
9972	fi
9973	if $test "X$longsize" = "X$longlongsize"; then
9974		echo "(That isn't any different from an ordinary long.)"
9975	fi
9976	;;
9977esac
9978$rm -f try.* try
9979
9980: see if prototype for lseek is available
9981echo " "
9982set d_lseekproto lseek $i_systypes sys/types.h $i_unistd unistd.h
9983eval $hasproto
9984
9985: see if lstat exists
9986set lstat d_lstat
9987eval $inlibc
9988
9989: see if madvise exists
9990set madvise d_madvise
9991eval $inlibc
9992
9993: see if mblen exists
9994set mblen d_mblen
9995eval $inlibc
9996
9997: see if mbstowcs exists
9998set mbstowcs d_mbstowcs
9999eval $inlibc
10000
10001: see if mbtowc exists
10002set mbtowc d_mbtowc
10003eval $inlibc
10004
10005: see if memchr exists
10006set memchr d_memchr
10007eval $inlibc
10008
10009: see if memcmp exists
10010set memcmp d_memcmp
10011eval $inlibc
10012
10013: see if memcpy exists
10014set memcpy d_memcpy
10015eval $inlibc
10016
10017: see if memmove exists
10018set memmove d_memmove
10019eval $inlibc
10020
10021: see if memset exists
10022set memset d_memset
10023eval $inlibc
10024
10025: see if mkdir exists
10026set mkdir d_mkdir
10027eval $inlibc
10028
10029: see if mkdtemp exists
10030set mkdtemp d_mkdtemp
10031eval $inlibc
10032
10033: see if mkfifo exists
10034set mkfifo d_mkfifo
10035eval $inlibc
10036
10037: see if mkstemp exists
10038set mkstemp d_mkstemp
10039eval $inlibc
10040
10041: see if mkstemps exists
10042set mkstemps d_mkstemps
10043eval $inlibc
10044
10045: see if mktime exists
10046set mktime d_mktime
10047eval $inlibc
10048
10049: see if this is a sys/mman.h system
10050set sys/mman.h i_sysmman
10051eval $inhdr
10052
10053: see if mmap exists
10054set mmap d_mmap
10055eval $inlibc
10056: see what shmat returns
10057: default to something harmless
10058mmaptype='void *'
10059case "$i_sysmman$d_mmap" in
10060"$define$define")
10061	$cat >mmap.c <<'END'
10062#include <sys/mman.h>
10063void *mmap();
10064END
10065	if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
10066		mmaptype='void *'
10067	else
10068		mmaptype='caddr_t'
10069	fi
10070	echo "and it returns ($mmaptype)." >&4
10071	;;
10072esac
10073
10074
10075
10076: see if modfl exists
10077set modfl d_modfl
10078eval $inlibc
10079
10080: see if mprotect exists
10081set mprotect d_mprotect
10082eval $inlibc
10083
10084: see if msgctl exists
10085set msgctl d_msgctl
10086eval $inlibc
10087
10088: see if msgget exists
10089set msgget d_msgget
10090eval $inlibc
10091
10092: see if msgsnd exists
10093set msgsnd d_msgsnd
10094eval $inlibc
10095
10096: see if msgrcv exists
10097set msgrcv d_msgrcv
10098eval $inlibc
10099
10100: see how much of the 'msg*(2)' library is present.
10101h_msg=true
10102echo " "
10103case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
10104*"$undef"*) h_msg=false;;
10105esac
10106case "$osname" in
10107freebsd)
10108    case "`ipcs 2>&1`" in
10109    "SVID messages"*"not configured"*)
10110	echo "Your $osname does not have the msg*(2) configured." >&4
10111        h_msg=false
10112	val="$undef"
10113	set msgctl d_msgctl
10114	eval $setvar
10115	set msgget d_msgget
10116	eval $setvar
10117	set msgsnd d_msgsnd
10118	eval $setvar
10119	set msgrcv d_msgrcv
10120	eval $setvar
10121	;;
10122    esac
10123    ;;
10124esac
10125: we could also check for sys/ipc.h ...
10126if $h_msg && $test `./findhdr sys/msg.h`; then
10127	echo "You have the full msg*(2) library." >&4
10128	val="$define"
10129else
10130	echo "You don't have the full msg*(2) library." >&4
10131	val="$undef"
10132fi
10133set d_msg
10134eval $setvar
10135
10136: see if msync exists
10137set msync d_msync
10138eval $inlibc
10139
10140: see if munmap exists
10141set munmap d_munmap
10142eval $inlibc
10143
10144: see if nice exists
10145set nice d_nice
10146eval $inlibc
10147
10148
10149echo " "
10150echo "Checking which 64-bit integer type we could use..." >&4
10151
10152case "$intsize" in
101538) val=int
10154   set quadtype
10155   eval $setvar
10156   val='"unsigned int"'
10157   set uquadtype
10158   eval $setvar
10159   quadkind=1
10160   ;;
10161*) case "$longsize" in
10162   8) val=long
10163      set quadtype
10164      eval $setvar
10165      val='"unsigned long"'
10166      set uquadtype
10167      eval $setvar
10168      quadkind=2
10169      ;;
10170   *) case "$d_longlong:$longlongsize" in
10171      define:8)
10172        val='"long long"'
10173        set quadtype
10174        eval $setvar
10175        val='"unsigned long long"'
10176        set uquadtype
10177        eval $setvar
10178        quadkind=3
10179        ;;
10180      *) case "$d_int64_t" in
10181         define)
10182           val=int64_t
10183           set quadtype
10184           eval $setvar
10185           val=uint64_t
10186           set uquadtype
10187           eval $setvar
10188           quadkind=4
10189           ;;
10190         esac
10191         ;;
10192      esac
10193      ;;
10194   esac
10195   ;;
10196esac
10197
10198case "$quadtype" in
10199'')	echo "Alas, no 64-bit integer types in sight." >&4
10200	d_quad="$undef"
10201	;;
10202*)	if test X"$use64bitint" = Xdefine -o X"$longsize" = X8; then
10203	    verb="will"
10204	else
10205	    verb="could"
10206	fi
10207	echo "We $verb use '$quadtype' for 64-bit integers." >&4
10208	d_quad="$define"
10209	;;
10210esac
10211
10212: check for length of character
10213echo " "
10214case "$charsize" in
10215'')
10216	echo "Checking to see how big your characters are (hey, you never know)..." >&4
10217	$cat >try.c <<'EOCP'
10218#include <stdio.h>
10219int main()
10220{
10221    printf("%d\n", (int)sizeof(char));
10222    exit(0);
10223}
10224EOCP
10225	set try
10226	if eval $compile_ok; then
10227		dflt=`./try`
10228	else
10229		dflt='1'
10230		echo "(I can't seem to compile the test program.  Guessing...)"
10231	fi
10232	;;
10233*)
10234	dflt="$charsize"
10235	;;
10236esac
10237rp="What is the size of a character (in bytes)?"
10238. ./myread
10239charsize="$ans"
10240$rm -f try.c try
10241
10242: check for volatile keyword
10243echo " "
10244echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10245$cat >try.c <<'EOCP'
10246int main()
10247{
10248	typedef struct _goo_struct goo_struct;
10249	goo_struct * volatile goo = ((goo_struct *)0);
10250	struct _goo_struct {
10251		long long_int;
10252		int reg_int;
10253		char char_var;
10254	};
10255	typedef unsigned short foo_t;
10256	char *volatile foo;
10257	volatile int bar;
10258	volatile foo_t blech;
10259	foo = foo;
10260}
10261EOCP
10262if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10263	val="$define"
10264	echo "Yup, it does."
10265else
10266	val="$undef"
10267	echo "Nope, it doesn't."
10268fi
10269set d_volatile
10270eval $setvar
10271$rm -f try.*
10272
10273
10274echo " "
10275$echo "Choosing the C types to be used for Perl's internal types..." >&4
10276
10277case "$use64bitint:$d_quad:$quadtype" in
10278define:define:?*)
10279	ivtype="$quadtype"
10280	uvtype="$uquadtype"
10281	ivsize=8
10282	uvsize=8
10283	;;
10284*)	ivtype="long"
10285	uvtype="unsigned long"
10286	ivsize=$longsize
10287	uvsize=$longsize
10288	;;
10289esac
10290
10291case "$uselongdouble:$d_longdbl" in
10292define:define)
10293	nvtype="long double"
10294	nvsize=$longdblsize
10295	;;
10296*)	nvtype=double
10297	nvsize=$doublesize
10298	;;
10299esac
10300
10301$echo "(IV will be "$ivtype", $ivsize bytes)"
10302$echo "(UV will be "$uvtype", $uvsize bytes)"
10303$echo "(NV will be "$nvtype", $nvsize bytes)"
10304
10305$cat >try.c <<EOCP
10306#$i_inttypes I_INTTYPES
10307#ifdef I_INTTYPES
10308#include <inttypes.h>
10309#endif
10310#include <stdio.h>
10311int main() {
10312#ifdef INT8
10313   int8_t i =  INT8_MAX;
10314  uint8_t u = UINT8_MAX;
10315  printf("int8_t\n");
10316#endif
10317#ifdef INT16
10318   int16_t i =  INT16_MAX;
10319  uint16_t i = UINT16_MAX;
10320  printf("int16_t\n");
10321#endif
10322#ifdef INT32
10323   int32_t i =  INT32_MAX;
10324  uint32_t u = UINT32_MAX;
10325  printf("int32_t\n");
10326#endif
10327}
10328EOCP
10329
10330case "$i8type" in
10331'')	case "$charsize" in
10332	1)	i8type=char
10333		u8type="unsigned char"
10334		i8size=$charsize
10335		u8size=$charsize
10336		;;
10337	esac
10338	;;
10339esac
10340case "$i8type" in
10341'')	set try -DINT8
10342	if eval $compile; then
10343		case "`./try$exe_ext`" in
10344		int8_t)	i8type=int8_t
10345			u8type=uint8_t
10346			i8size=1
10347			u8size=1
10348			;;
10349		esac
10350	fi
10351	;;
10352esac
10353case "$i8type" in
10354'')	if $test $charsize -ge 1; then
10355		i8type=char
10356		u8type="unsigned char"
10357		i8size=$charsize
10358		u8size=$charsize
10359	fi
10360	;;
10361esac
10362
10363case "$i16type" in
10364'')	case "$shortsize" in
10365	2)	i16type=short
10366		u16type="unsigned short"
10367		i16size=$shortsize
10368		u16size=$shortsize
10369		;;
10370	esac
10371	;;
10372esac
10373case "$i16type" in
10374'')	set try -DINT16
10375	if eval $compile; then
10376		case "`./try$exe_ext`" in
10377		int16_t)
10378			i16type=int16_t
10379			u16type=uint16_t
10380			i16size=2
10381			u16size=2
10382			;;
10383		esac
10384	fi
10385	;;
10386esac
10387case "$i16type" in
10388'')	if $test $shortsize -ge 2; then
10389		i16type=short
10390		u16type="unsigned short"
10391		i16size=$shortsize
10392		u16size=$shortsize
10393	fi
10394	;;
10395esac
10396
10397case "$i32type" in
10398'')	case "$longsize" in
10399	4)	i32type=long
10400		u32type="unsigned long"
10401		i32size=$longsize
10402		u32size=$longsize
10403		;;
10404	*)	case "$intsize" in
10405		4)	i32type=int
10406			u32type="unsigned int"
10407			i32size=$intsize
10408			u32size=$intsize
10409			;;
10410		esac
10411		;;
10412	esac
10413	;;
10414esac
10415case "$i32type" in
10416'')	set try -DINT32
10417	if eval $compile; then
10418		case "`./try$exe_ext`" in
10419		int32_t)
10420			i32type=int32_t
10421			u32type=uint32_t
10422			i32size=4
10423			u32size=4
10424			;;
10425		esac
10426	fi
10427	;;
10428esac
10429case "$i32type" in
10430'')	if $test $intsize -ge 4; then
10431		i32type=int
10432		u32type="unsigned int"
10433		i32size=$intsize
10434		u32size=$intsize
10435	fi
10436	;;
10437esac
10438
10439case "$i64type" in
10440'')	case "$d_quad:$quadtype" in
10441	define:?*)
10442		i64type="$quadtype"
10443		u64type="$uquadtype"
10444		i64size=8
10445		u64size=8
10446		;;
10447	esac
10448	;;
10449esac
10450
10451$echo "Checking how many bits of your UVs your NVs can preserve..." >&4
10452: volatile so that the compiler has to store it out to memory.
10453if test X"$d_volatile" = X"$define"; then
10454	volatile=volatile
10455fi
10456$cat <<EOP >try.c
10457#include <stdio.h>
10458#include <sys/types.h>
10459#include <signal.h>
10460#ifdef SIGFPE
10461$volatile int bletched = 0;
10462$signal_t blech(s) int s; { bletched = 1; }
10463#endif
10464int main() {
10465    $uvtype u = 0;
10466    $nvtype d;
10467    int     n = 8 * $uvsize;
10468    int     i;
10469#ifdef SIGFPE
10470    signal(SIGFPE, blech);
10471#endif
10472
10473    for (i = 0; i < n; i++) {
10474      u = u << 1 | ($uvtype)1;
10475      d = ($nvtype)u;
10476      if (($uvtype)d != u)
10477        break;
10478      if (d <= 0)
10479	break;
10480      d = ($nvtype)(u - 1);
10481      if (($uvtype)d != (u - 1))
10482        break;
10483#ifdef SIGFPE
10484      if (bletched) {
10485	break;
10486#endif
10487      }
10488    }
10489    printf("%d\n", ((i == n) ? -n : i));
10490    exit(0);
10491}
10492EOP
10493set try
10494
10495d_nv_preserves_uv="$undef"
10496if eval $compile; then
10497	d_nv_preserves_uv_bits="`./try$exe_ext`"
10498fi
10499case "$d_nv_preserves_uv_bits" in
10500\-[1-9]*)
10501	d_nv_preserves_uv_bits=`expr 0 - $d_nv_preserves_uv_bits`
10502	$echo "Your NVs can preserve all $d_nv_preserves_uv_bits bits of your UVs."  2>&1
10503	d_nv_preserves_uv="$define"
10504	;;
10505[1-9]*)	$echo "Your NVs can preserve only $d_nv_preserves_uv_bits bits of your UVs."  2>&1
10506	d_nv_preserves_uv="$undef" ;;
10507*)	$echo "Can't figure out how many bits your NVs preserve." 2>&1
10508	d_nv_preserves_uv_bits="$undef" ;;
10509esac
10510
10511$rm -f try.* try
10512
10513
10514: check for off64_t
10515echo " "
10516echo "Checking to see if you have off64_t..." >&4
10517$cat >try.c <<EOCP
10518#include <sys/types.h>
10519#include <unistd.h>
10520int main() { off64_t x = 7; }
10521EOCP
10522set try
10523if eval $compile; then
10524	val="$define"
10525	echo "You have off64_t."
10526else
10527	val="$undef"
10528	echo "You do not have off64_t."
10529	case "$lseeksize" in
10530	8) echo "(Your off_t is 64 bits, so you could use that.)" ;;
10531	esac
10532fi
10533$rm -f try.* try
10534set d_off64_t
10535eval $setvar
10536
10537: see if POSIX threads are available
10538set pthread.h i_pthread
10539eval $inhdr
10540
10541
10542
10543
10544: how to create joinable pthreads
10545if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
10546	echo " "
10547	echo "Checking what constant to use for creating joinable pthreads..." >&4
10548	$cat >try.c <<'EOCP'
10549#include <pthread.h>
10550int main() {
10551    int detachstate = JOINABLE;
10552}
10553EOCP
10554	set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
10555	if eval $compile; then
10556		echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
10557		val="$undef" # Yes, undef.
10558		set d_old_pthread_create_joinable
10559		eval $setvar
10560		val=""
10561		set old_pthread_create_joinable
10562		eval $setvar
10563	else
10564		set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
10565		if eval $compile; then
10566			echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
10567			val="$define"
10568			set d_old_pthread_create_joinable
10569			eval $setvar
10570			val=PTHREAD_CREATE_UNDETACHED
10571			set old_pthread_create_joinable
10572			eval $setvar
10573		else
10574			set try -DJOINABLE=__UNDETACHED
10575			if eval $compile; then
10576				echo "You seem to use __UNDETACHED." >&4
10577				val="$define"
10578				set d_old_pthread_create_joinable
10579				eval $setvar
10580				val=__UNDETACHED
10581				set old_pthread_create_joinable
10582				eval $setvar
10583			else
10584				echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
10585				val="$define"
10586				set d_old_pthread_create_joinable
10587				eval $setvar
10588				val=0
10589				set old_pthread_create_joinable
10590				eval $setvar
10591			fi
10592		fi
10593	fi
10594	$rm -f try try.*
10595else
10596    d_old_pthread_create_joinable="$undef"
10597    old_pthread_create_joinable=""
10598fi
10599
10600: see if pause exists
10601set pause d_pause
10602eval $inlibc
10603
10604: see if pipe exists
10605set pipe d_pipe
10606eval $inlibc
10607
10608: see if poll exists
10609set poll d_poll
10610eval $inlibc
10611
10612
10613: see whether the various POSIXish _yields exist
10614$cat >try.c <<EOP
10615#include <pthread.h>
10616#include <stdio.h>
10617int main() {
10618#ifdef SCHED_YIELD
10619	sched_yield();
10620#else
10621#ifdef PTHREAD_YIELD
10622	pthread_yield();
10623#else
10624#ifdef PTHREAD_YIELD_NULL
10625	pthread_yield(NULL);
10626#endif
10627#endif
10628#endif
10629}
10630EOP
10631: see if sched_yield exists
10632set try -DSCHED_YIELD
10633if eval $compile; then
10634    val="$define"
10635    sched_yield='sched_yield()'
10636else
10637    val="$undef"
10638fi
10639case "$usethreads" in
10640$define)
10641	case "$val" in
10642	$define) echo 'sched_yield() found.' >&4	;;
10643	*)	 echo 'sched_yield() NOT found.' >&4	;;
10644	esac
10645esac
10646set d_sched_yield
10647eval $setvar
10648
10649: see if pthread_yield exists
10650set try -DPTHREAD_YIELD
10651if eval $compile; then
10652    val="$define"
10653    case "$sched_yield" in
10654    '') sched_yield='pthread_yield()' ;;
10655    esac
10656else
10657    set try -DPTHREAD_YIELD_NULL
10658    if eval $compile; then
10659	val="$define"
10660	case "$sched_yield" in
10661	'') sched_yield='pthread_yield(NULL)' ;;
10662	esac
10663    else
10664	val="$undef"
10665    fi
10666fi
10667case "$usethreads" in
10668$define)
10669	case "$val" in
10670	$define) echo 'pthread_yield() found.' >&4	;;
10671	*)	 echo 'pthread_yield() NOT found.' >&4	;;
10672	esac
10673	;;
10674esac
10675set d_pthread_yield
10676eval $setvar
10677
10678case "$sched_yield" in
10679'') sched_yield=undef ;;
10680esac
10681
10682$rm -f try try.*
10683
10684: see if this is a pwd.h system
10685set pwd.h i_pwd
10686eval $inhdr
10687
10688case "$i_pwd" in
10689$define)
10690	xxx=`./findhdr pwd.h`
10691	$cppstdin $cppflags $cppminus < $xxx >$$.h
10692
10693	if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
10694		val="$define"
10695	else
10696		val="$undef"
10697	fi
10698	set d_pwquota
10699	eval $setvar
10700
10701	if $contains 'pw_age' $$.h >/dev/null 2>&1; then
10702		val="$define"
10703	else
10704		val="$undef"
10705	fi
10706	set d_pwage
10707	eval $setvar
10708
10709	if $contains 'pw_change' $$.h >/dev/null 2>&1; then
10710		val="$define"
10711	else
10712		val="$undef"
10713	fi
10714	set d_pwchange
10715	eval $setvar
10716
10717	if $contains 'pw_class' $$.h >/dev/null 2>&1; then
10718		val="$define"
10719	else
10720		val="$undef"
10721	fi
10722	set d_pwclass
10723	eval $setvar
10724
10725	if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
10726		val="$define"
10727	else
10728		val="$undef"
10729	fi
10730	set d_pwexpire
10731	eval $setvar
10732
10733	if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
10734		val="$define"
10735	else
10736		val="$undef"
10737	fi
10738	set d_pwcomment
10739	eval $setvar
10740
10741	if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
10742		val="$define"
10743	else
10744		val="$undef"
10745	fi
10746	set d_pwgecos
10747	eval $setvar
10748
10749	if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
10750		val="$define"
10751	else
10752		val="$undef"
10753	fi
10754	set d_pwpasswd
10755	eval $setvar
10756
10757	$rm -f $$.h
10758	;;
10759*)
10760	val="$undef";
10761	set d_pwquota; eval $setvar
10762	set d_pwage; eval $setvar
10763	set d_pwchange; eval $setvar
10764	set d_pwclass; eval $setvar
10765	set d_pwexpire; eval $setvar
10766	set d_pwcomment; eval $setvar
10767	set d_pwgecos; eval $setvar
10768	set d_pwpasswd; eval $setvar
10769	;;
10770esac
10771
10772: see if readdir and friends exist
10773set readdir d_readdir
10774eval $inlibc
10775set seekdir d_seekdir
10776eval $inlibc
10777set telldir d_telldir
10778eval $inlibc
10779set rewinddir d_rewinddir
10780eval $inlibc
10781
10782: see if readlink exists
10783set readlink d_readlink
10784eval $inlibc
10785
10786: see if rename exists
10787set rename d_rename
10788eval $inlibc
10789
10790: see if rmdir exists
10791set rmdir d_rmdir
10792eval $inlibc
10793
10794: see if memory.h is available.
10795val=''
10796set memory.h val
10797eval $inhdr
10798
10799: See if it conflicts with string.h
10800case "$val" in
10801$define)
10802	case "$strings" in
10803	'') ;;
10804	*)
10805		$cppstdin $cppflags $cppminus < $strings > mem.h
10806		if $contains 'memcpy' mem.h >/dev/null 2>&1; then
10807			echo " "
10808			echo "We won't be including <memory.h>."
10809			val="$undef"
10810		fi
10811		$rm -f mem.h
10812		;;
10813	esac
10814esac
10815set i_memory
10816eval $setvar
10817
10818: can bcopy handle overlapping blocks?
10819val="$undef"
10820case "$d_bcopy" in
10821"$define")
10822	echo " "
10823	echo "Checking to see if your bcopy() can do overlapping copies..." >&4
10824	$cat >try.c <<EOCP
10825#$i_memory I_MEMORY
10826#$i_stdlib I_STDLIB
10827#$i_string I_STRING
10828#$i_unistd I_UNISTD
10829EOCP
10830	$cat >>try.c <<'EOCP'
10831#include <stdio.h>
10832#ifdef I_MEMORY
10833#  include <memory.h>
10834#endif
10835#ifdef I_STDLIB
10836#  include <stdlib.h>
10837#endif
10838#ifdef I_STRING
10839#  include <string.h>
10840#else
10841#  include <strings.h>
10842#endif
10843#ifdef I_UNISTD
10844#  include <unistd.h>  /* Needed for NetBSD */
10845#endif
10846int main()
10847{
10848char buf[128], abc[128];
10849char *b;
10850int len;
10851int off;
10852int align;
10853
10854bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
10855
10856for (align = 7; align >= 0; align--) {
10857	for (len = 36; len; len--) {
10858		b = buf+align;
10859		bcopy(abc, b, len);
10860		for (off = 1; off <= len; off++) {
10861			bcopy(b, b+off, len);
10862			bcopy(b+off, b, len);
10863			if (bcmp(b, abc, len))
10864				exit(1);
10865		}
10866	}
10867}
10868exit(0);
10869}
10870EOCP
10871	set try
10872	if eval $compile_ok; then
10873		if ./try 2>/dev/null; then
10874			echo "Yes, it can."
10875			val="$define"
10876		else
10877			echo "It can't, sorry."
10878			case "$d_memmove" in
10879			"$define") echo "But that's Ok since you have memmove()." ;;
10880			esac
10881		fi
10882	else
10883		echo "(I can't compile the test program, so we'll assume not...)"
10884		case "$d_memmove" in
10885		"$define") echo "But that's Ok since you have memmove()." ;;
10886		esac
10887	fi
10888	;;
10889esac
10890$rm -f try.* try core
10891set d_safebcpy
10892eval $setvar
10893
10894: can memcpy handle overlapping blocks?
10895val="$undef"
10896case "$d_memcpy" in
10897"$define")
10898	echo " "
10899	echo "Checking to see if your memcpy() can do overlapping copies..." >&4
10900	$cat >try.c <<EOCP
10901#$i_memory I_MEMORY
10902#$i_stdlib I_STDLIB
10903#$i_string I_STRING
10904#$i_unistd I_UNISTD
10905EOCP
10906	$cat >>try.c <<'EOCP'
10907#include <stdio.h>
10908#ifdef I_MEMORY
10909#  include <memory.h>
10910#endif
10911#ifdef I_STDLIB
10912#  include <stdlib.h>
10913#endif
10914#ifdef I_STRING
10915#  include <string.h>
10916#else
10917#  include <strings.h>
10918#endif
10919#ifdef I_UNISTD
10920#  include <unistd.h>  /* Needed for NetBSD */
10921#endif
10922int main()
10923{
10924char buf[128], abc[128];
10925char *b;
10926int len;
10927int off;
10928int align;
10929
10930/* Copy "abcde..." string to char abc[] so that gcc doesn't
10931   try to store the string in read-only memory. */
10932memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
10933
10934for (align = 7; align >= 0; align--) {
10935	for (len = 36; len; len--) {
10936		b = buf+align;
10937		memcpy(b, abc, len);
10938		for (off = 1; off <= len; off++) {
10939			memcpy(b+off, b, len);
10940			memcpy(b, b+off, len);
10941			if (memcmp(b, abc, len))
10942				exit(1);
10943		}
10944	}
10945}
10946exit(0);
10947}
10948EOCP
10949	set try
10950	if eval $compile_ok; then
10951		if ./try 2>/dev/null; then
10952			echo "Yes, it can."
10953			val="$define"
10954		else
10955			echo "It can't, sorry."
10956			case "$d_memmove" in
10957			"$define") echo "But that's Ok since you have memmove()." ;;
10958			esac
10959		fi
10960	else
10961		echo "(I can't compile the test program, so we'll assume not...)"
10962		case "$d_memmove" in
10963		"$define") echo "But that's Ok since you have memmove()." ;;
10964		esac
10965	fi
10966	;;
10967esac
10968$rm -f try.* try core
10969set d_safemcpy
10970eval $setvar
10971
10972: can memcmp be trusted to compare relative magnitude?
10973val="$undef"
10974case "$d_memcmp" in
10975"$define")
10976	echo " "
10977	echo "Checking if your memcmp() can compare relative magnitude..." >&4
10978	$cat >try.c <<EOCP
10979#$i_memory I_MEMORY
10980#$i_stdlib I_STDLIB
10981#$i_string I_STRING
10982#$i_unistd I_UNISTD
10983EOCP
10984	$cat >>try.c <<'EOCP'
10985#include <stdio.h>
10986#ifdef I_MEMORY
10987#  include <memory.h>
10988#endif
10989#ifdef I_STDLIB
10990#  include <stdlib.h>
10991#endif
10992#ifdef I_STRING
10993#  include <string.h>
10994#else
10995#  include <strings.h>
10996#endif
10997#ifdef I_UNISTD
10998#  include <unistd.h>  /* Needed for NetBSD */
10999#endif
11000int main()
11001{
11002char a = -1;
11003char b = 0;
11004if ((a < b) && memcmp(&a, &b, 1) < 0)
11005	exit(1);
11006exit(0);
11007}
11008EOCP
11009	set try
11010	if eval $compile_ok; then
11011		if ./try 2>/dev/null; then
11012			echo "Yes, it can."
11013			val="$define"
11014		else
11015			echo "No, it can't (it uses signed chars)."
11016		fi
11017	else
11018		echo "(I can't compile the test program, so we'll assume not...)"
11019	fi
11020	;;
11021esac
11022$rm -f try.* try core
11023set d_sanemcmp
11024eval $setvar
11025
11026: see if prototype for sbrk is available
11027echo " "
11028set d_sbrkproto sbrk $i_unistd unistd.h
11029eval $hasproto
11030
11031: see if select exists
11032set select d_select
11033eval $inlibc
11034
11035: see if semctl exists
11036set semctl d_semctl
11037eval $inlibc
11038
11039: see if semget exists
11040set semget d_semget
11041eval $inlibc
11042
11043: see if semop exists
11044set semop d_semop
11045eval $inlibc
11046
11047: see how much of the 'sem*(2)' library is present.
11048h_sem=true
11049echo " "
11050case "$d_semctl$d_semget$d_semop" in
11051*"$undef"*) h_sem=false;;
11052esac
11053case "$osname" in
11054freebsd)
11055    case "`ipcs 2>&1`" in
11056    "SVID messages"*"not configured"*)
11057	echo "Your $osname does not have the sem*(2) configured." >&4
11058        h_sem=false
11059	val="$undef"
11060	set semctl d_semctl
11061	eval $setvar
11062	set semget d_semget
11063	eval $setvar
11064	set semop d_semop
11065	eval $setvar
11066	;;
11067    esac
11068    ;;
11069esac
11070: we could also check for sys/ipc.h ...
11071if $h_sem && $test `./findhdr sys/sem.h`; then
11072	echo "You have the full sem*(2) library." >&4
11073	val="$define"
11074else
11075	echo "You don't have the full sem*(2) library." >&4
11076	val="$undef"
11077fi
11078set d_sem
11079eval $setvar
11080
11081: see whether sys/sem.h defines union semun
11082echo " "
11083$cat > try.c <<'END'
11084#include <sys/types.h>
11085#include <sys/ipc.h>
11086#include <sys/sem.h>
11087int main () { union semun semun; semun.buf = 0; }
11088END
11089set try
11090if eval $compile; then
11091    echo "You have union semun in <sys/sem.h>." >&4
11092    val="$define"
11093else
11094    echo "You do not have union semun in <sys/sem.h>." >&4
11095    val="$undef"
11096fi
11097$rm -f try try.c try.h
11098set d_union_semun
11099eval $setvar
11100
11101: see how to do semctl IPC_STAT
11102case "$d_sem" in
11103$define)
11104    : see whether semctl IPC_STAT can use union semun
11105    echo " "
11106    $cat > try.h <<END
11107#ifndef S_IRUSR
11108#   ifdef S_IREAD
11109#	define S_IRUSR S_IREAD
11110#	define S_IWUSR S_IWRITE
11111#	define S_IXUSR S_IEXEC
11112#   else
11113#	define S_IRUSR 0400
11114#	define S_IWUSR 0200
11115#	define S_IXUSR 0100
11116#   endif
11117#   define S_IRGRP (S_IRUSR>>3)
11118#   define S_IWGRP (S_IWUSR>>3)
11119#   define S_IXGRP (S_IXUSR>>3)
11120#   define S_IROTH (S_IRUSR>>6)
11121#   define S_IWOTH (S_IWUSR>>6)
11122#   define S_IXOTH (S_IXUSR>>6)
11123#endif
11124#ifndef S_IRWXU
11125#   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
11126#   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
11127#   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
11128#endif
11129END
11130
11131    $cat > try.c <<END
11132#include <sys/types.h>
11133#include <sys/ipc.h>
11134#include <sys/sem.h>
11135#include <sys/stat.h>
11136#include <stdio.h>
11137#include <errno.h>
11138#include "try.h"
11139#ifndef errno
11140extern int errno;
11141#endif
11142#$d_union_semun HAS_UNION_SEMUN
11143int main() {
11144    union semun
11145#ifndef HAS_UNION_SEMUN
11146    {
11147	int val;
11148	struct semid_ds *buf;
11149	unsigned short *array;
11150    }
11151#endif
11152    arg;
11153    int sem, st;
11154
11155#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
11156    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
11157    if (sem > -1) {
11158	struct semid_ds argbuf;
11159	arg.buf = &argbuf;
11160#	ifdef IPC_STAT
11161	st = semctl(sem, 0, IPC_STAT, arg);
11162	if (st == 0)
11163	    printf("semun\n");
11164	else
11165#	endif /* IPC_STAT */
11166	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
11167#	ifdef IPC_RMID
11168	if (semctl(sem, 0, IPC_RMID, arg) != 0)
11169#   	endif /* IPC_RMID */
11170	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
11171    } else
11172#endif /* IPC_PRIVATE && ... */
11173	printf("semget failed: errno = %d\n", errno);
11174  return 0;
11175}
11176END
11177    val="$undef"
11178    set try
11179    if eval $compile; then
11180	xxx=`./try`
11181        case "$xxx" in
11182        semun) val="$define" ;;
11183        esac
11184    fi
11185    $rm -f try try.c
11186    set d_semctl_semun
11187    eval $setvar
11188    case "$d_semctl_semun" in
11189    $define)
11190        echo "You can use union semun for semctl IPC_STAT." >&4
11191	also='also'
11192        ;;
11193    *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
11194	also=''
11195        ;;
11196    esac
11197
11198    : see whether semctl IPC_STAT can use struct semid_ds pointer
11199    $cat > try.c <<'END'
11200#include <sys/types.h>
11201#include <sys/ipc.h>
11202#include <sys/sem.h>
11203#include <sys/stat.h>
11204#include "try.h"
11205#include <stdio.h>
11206#include <errno.h>
11207#ifndef errno
11208extern int errno;
11209#endif
11210int main() {
11211    struct semid_ds arg;
11212    int sem, st;
11213
11214#if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
11215    sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
11216    if (sem > -1) {
11217#	ifdef IPC_STAT
11218	st = semctl(sem, 0, IPC_STAT, &arg);
11219	if (st == 0)
11220	    printf("semid_ds\n");
11221	else
11222#	endif /* IPC_STAT */
11223	    printf("semctl IPC_STAT failed: errno = %d\n", errno);
11224#	ifdef IPC_RMID
11225	if (semctl(sem, 0, IPC_RMID, &arg) != 0)
11226#	endif /* IPC_RMID */
11227	    printf("semctl IPC_RMID failed: errno = %d\n", errno);
11228    } else
11229#endif /* IPC_PRIVATE && ... */
11230	printf("semget failed: errno = %d\n", errno);
11231
11232    return 0;
11233}
11234END
11235    val="$undef"
11236    set try
11237    if eval $compile; then
11238        xxx=`./try`
11239        case "$xxx" in
11240        semid_ds) val="$define" ;;
11241        esac
11242    fi
11243    $rm -f try try.c
11244    set d_semctl_semid_ds
11245    eval $setvar
11246    case "$d_semctl_semid_ds" in
11247    $define)
11248        echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
11249        ;;
11250    *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
11251        ;;
11252    esac
11253    $rm -f try.h
11254    ;;
11255*)  val="$undef"
11256
11257    # We do not have the full sem*(2) library, so assume we can not
11258    # use either.
11259
11260    set d_semctl_semun
11261    eval $setvar
11262
11263    set d_semctl_semid_ds
11264    eval $setvar
11265    ;;
11266esac
11267
11268: see if setegid exists
11269set setegid d_setegid
11270eval $inlibc
11271
11272: see if seteuid exists
11273set seteuid d_seteuid
11274eval $inlibc
11275
11276: see if setgrent exists
11277set setgrent d_setgrent
11278eval $inlibc
11279
11280: see if sethostent exists
11281set sethostent d_sethent
11282eval $inlibc
11283
11284: see if setlinebuf exists
11285set setlinebuf d_setlinebuf
11286eval $inlibc
11287
11288: see if setlocale exists
11289set setlocale d_setlocale
11290eval $inlibc
11291
11292: see if setnetent exists
11293set setnetent d_setnent
11294eval $inlibc
11295
11296: see if setprotoent exists
11297set setprotoent d_setpent
11298eval $inlibc
11299
11300: see if setpgid exists
11301set setpgid d_setpgid
11302eval $inlibc
11303
11304: see if setpgrp2 exists
11305set setpgrp2 d_setpgrp2
11306eval $inlibc
11307
11308: see if setpriority exists
11309set setpriority d_setprior
11310eval $inlibc
11311
11312: see if setproctitle exists
11313set setproctitle d_setproctitle
11314eval $inlibc
11315
11316: see if setpwent exists
11317set setpwent d_setpwent
11318eval $inlibc
11319
11320: see if setregid exists
11321set setregid d_setregid
11322eval $inlibc
11323set setresgid d_setresgid
11324eval $inlibc
11325
11326: see if setreuid exists
11327set setreuid d_setreuid
11328eval $inlibc
11329set setresuid d_setresuid
11330eval $inlibc
11331
11332: see if setrgid exists
11333set setrgid d_setrgid
11334eval $inlibc
11335
11336: see if setruid exists
11337set setruid d_setruid
11338eval $inlibc
11339
11340: see if setservent exists
11341set setservent d_setsent
11342eval $inlibc
11343
11344: see if setsid exists
11345set setsid d_setsid
11346eval $inlibc
11347
11348: see if setvbuf exists
11349set setvbuf d_setvbuf
11350eval $inlibc
11351
11352: see if sfio.h is available
11353set sfio.h i_sfio
11354eval $inhdr
11355
11356
11357: see if sfio library is available
11358case "$i_sfio" in
11359$define)
11360	val=''
11361	set sfreserve val
11362	eval $inlibc
11363	;;
11364*)
11365	val="$undef"
11366	;;
11367esac
11368: Ok, but do we want to use it.
11369case "$val" in
11370$define)
11371	case "$usesfio" in
11372	true|$define|[yY]*) dflt='y';;
11373	*) dflt='n';;
11374	esac
11375	echo "$package can use the sfio library, but it is experimental."
11376	case "$useperlio" in
11377	"$undef")
11378	    echo "For sfio also the PerlIO abstraction layer is needed."
11379	    echo "Earlier you said you wouldn't want that."
11380	    ;;
11381	esac
11382	rp="You seem to have sfio available, do you want to try using it?"
11383	. ./myread
11384	case "$ans" in
11385	y|Y)	echo "Ok, turning on both sfio and PerlIO, then."
11386		useperlio="$define"
11387		val="$define"
11388		;;
11389	*)	echo "Ok, avoiding sfio this time.  I'll use stdio instead."
11390		val="$undef"
11391		;;
11392	esac
11393	;;
11394*)	case "$usesfio" in
11395	true|$define|[yY]*)
11396		echo "Sorry, cannot find sfio on this machine." >&4
11397		echo "Ignoring your setting of usesfio=$usesfio." >&4
11398		val="$undef"
11399		;;
11400	esac
11401	;;
11402esac
11403set d_sfio
11404eval $setvar
11405case "$d_sfio" in
11406$define) usesfio='true';;
11407*) usesfio='false';;
11408esac
11409case "$d_sfio" in
11410$define) ;;
11411*)	: Remove sfio from list of libraries to use
11412	set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
11413	shift
11414	libs="$*"
11415	echo "libs = $libs" >&4
11416;;
11417esac
11418
11419
11420: see if shmctl exists
11421set shmctl d_shmctl
11422eval $inlibc
11423
11424: see if shmget exists
11425set shmget d_shmget
11426eval $inlibc
11427
11428: see if shmat exists
11429set shmat d_shmat
11430eval $inlibc
11431: see what shmat returns
11432case "$d_shmat" in
11433"$define")
11434	$cat >shmat.c <<'END'
11435#include <sys/shm.h>
11436void *shmat();
11437END
11438	if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
11439		shmattype='void *'
11440	else
11441		shmattype='char *'
11442	fi
11443	echo "and it returns ($shmattype)." >&4
11444	: see if a prototype for shmat is available
11445	xxx=`./findhdr sys/shm.h`
11446	$cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
11447	if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
11448		val="$define"
11449	else
11450		val="$undef"
11451	fi
11452	$rm -f shmat.[co]
11453	;;
11454*)
11455	val="$undef"
11456	;;
11457esac
11458set d_shmatprototype
11459eval $setvar
11460
11461: see if shmdt exists
11462set shmdt d_shmdt
11463eval $inlibc
11464
11465: see how much of the 'shm*(2)' library is present.
11466h_shm=true
11467echo " "
11468case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
11469*"$undef"*) h_shm=false;;
11470esac
11471case "$osname" in
11472freebsd)
11473    case "`ipcs 2>&1`" in
11474    "SVID shared memory"*"not configured"*)
11475	echo "Your $osname does not have the shm*(2) configured." >&4
11476        h_shm=false
11477	val="$undef"
11478	set shmctl d_shmctl
11479	evat $setvar
11480	set shmget d_shmget
11481	evat $setvar
11482	set shmat d_shmat
11483	evat $setvar
11484	set shmdt d_shmdt
11485	evat $setvar
11486	;;
11487    esac
11488    ;;
11489esac
11490: we could also check for sys/ipc.h ...
11491if $h_shm && $test `./findhdr sys/shm.h`; then
11492	echo "You have the full shm*(2) library." >&4
11493	val="$define"
11494else
11495	echo "You don't have the full shm*(2) library." >&4
11496	val="$undef"
11497fi
11498set d_shm
11499eval $setvar
11500
11501echo " "
11502: see if we have sigaction
11503if set sigaction val -f d_sigaction; eval $csym; $val; then
11504	echo 'sigaction() found.' >&4
11505	$cat > try.c <<'EOP'
11506#include <stdio.h>
11507#include <sys/types.h>
11508#include <signal.h>
11509int main()
11510{
11511    struct sigaction act, oact;
11512    act.sa_flags = 0;
11513    oact.sa_handler = 0;
11514    /* so that act and oact are used */
11515    exit(act.sa_flags == 0 &&  oact.sa_handler == 0);
11516}
11517EOP
11518	set try
11519	if eval $compile_ok; then
11520		val="$define"
11521	else
11522		echo "But you don't seem to have a useable struct sigaction." >&4
11523		val="$undef"
11524	fi
11525else
11526	echo 'sigaction NOT found.' >&4
11527	val="$undef"
11528fi
11529set d_sigaction; eval $setvar
11530$rm -f try try$_o try.c
11531
11532: see if sigsetjmp exists
11533echo " "
11534case "$d_sigsetjmp" in
11535'')
11536	$cat >try.c <<'EOP'
11537#include <setjmp.h>
11538sigjmp_buf env;
11539int set = 1;
11540int main()
11541{
11542	if (sigsetjmp(env,1))
11543		exit(set);
11544	set = 0;
11545	siglongjmp(env, 1);
11546	exit(1);
11547}
11548EOP
11549	set try
11550	if eval $compile; then
11551		if ./try >/dev/null 2>&1; then
11552			echo "POSIX sigsetjmp found." >&4
11553			val="$define"
11554		else
11555			$cat >&4 <<EOM
11556Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
11557I'll ignore them.
11558EOM
11559			val="$undef"
11560		fi
11561	else
11562		echo "sigsetjmp not found." >&4
11563		val="$undef"
11564	fi
11565	;;
11566*) val="$d_sigsetjmp"
11567	case "$d_sigsetjmp" in
11568	$define) echo "POSIX sigsetjmp found." >&4;;
11569	$undef) echo "sigsetjmp not found." >&4;;
11570	esac
11571	;;
11572esac
11573set d_sigsetjmp
11574eval $setvar
11575$rm -f try.c try
11576
11577: see if socks5_init exists
11578set socks5_init d_socks5_init
11579eval $inlibc
11580
11581: see if sys/stat.h is available
11582set sys/stat.h i_sysstat
11583eval $inhdr
11584
11585
11586: see if stat knows about block sizes
11587echo " "
11588echo "Checking to see if your struct stat has st_blocks field..." >&4
11589set d_statblks stat st_blocks $i_sysstat sys/stat.h
11590eval $hasfield
11591
11592
11593: see if this is a sys/vfs.h system
11594set sys/vfs.h i_sysvfs
11595eval $inhdr
11596
11597
11598: see if this is a sys/statfs.h system
11599set sys/statfs.h i_sysstatfs
11600eval $inhdr
11601
11602
11603echo " "
11604echo "Checking to see if your system supports struct statfs..." >&4
11605set 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
11606eval $hasstruct
11607case "$d_statfs_s" in
11608"$define")      echo "Yes, it does."   ;;
11609*)              echo "No, it doesn't." ;;
11610esac
11611
11612
11613
11614: see if struct statfs knows about f_flags
11615case "$d_statfs_s" in
11616define)
11617	echo " "
11618	echo "Checking to see if your struct statfs has f_flags field..." >&4
11619	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
11620	eval $hasfield
11621	;;
11622*)	val="$undef"
11623	set d_statfs_f_flags
11624	eval $setvar
11625	;;
11626esac
11627case "$d_statfs_f_flags" in
11628"$define")      echo "Yes, it does."   ;;
11629*)              echo "No, it doesn't." ;;
11630esac
11631
11632: see if _ptr and _cnt from stdio act std
11633echo " "
11634
11635if $contains '_lbfsize' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11636	echo "(Looks like you have stdio.h from BSD.)"
11637	case "$stdio_ptr" in
11638	'') stdio_ptr='((fp)->_p)'
11639		ptr_lval=$define
11640		;;
11641	*)	ptr_lval=$d_stdio_ptr_lval;;
11642	esac
11643	case "$stdio_cnt" in
11644	'') stdio_cnt='((fp)->_r)'
11645		cnt_lval=$define
11646		;;
11647	*)	cnt_lval=$d_stdio_cnt_lval;;
11648	esac
11649	case "$stdio_base" in
11650	'') stdio_base='((fp)->_ub._base ? (fp)->_ub._base : (fp)->_bf._base)';;
11651	esac
11652	case "$stdio_bufsiz" in
11653	'') stdio_bufsiz='((fp)->_ub._base ? (fp)->_ub._size : (fp)->_bf._size)';;
11654	esac
11655elif $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
11656	echo "(Looks like you have stdio.h from Linux.)"
11657	case "$stdio_ptr" in
11658	'') stdio_ptr='((fp)->_IO_read_ptr)'
11659		ptr_lval=$define
11660		;;
11661	*)	ptr_lval=$d_stdio_ptr_lval;;
11662	esac
11663	case "$stdio_cnt" in
11664	'') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
11665		cnt_lval=$undef
11666		;;
11667	*)	cnt_lval=$d_stdio_cnt_lval;;
11668	esac
11669	case "$stdio_base" in
11670	'') stdio_base='((fp)->_IO_read_base)';;
11671	esac
11672	case "$stdio_bufsiz" in
11673	'') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
11674	esac
11675else
11676	case "$stdio_ptr" in
11677	'') stdio_ptr='((fp)->_ptr)'
11678		ptr_lval=$define
11679		;;
11680	*)	ptr_lval=$d_stdio_ptr_lval;;
11681	esac
11682	case "$stdio_cnt" in
11683	'') stdio_cnt='((fp)->_cnt)'
11684		cnt_lval=$define
11685		;;
11686	*)	cnt_lval=$d_stdio_cnt_lval;;
11687	esac
11688	case "$stdio_base" in
11689	'') stdio_base='((fp)->_base)';;
11690	esac
11691	case "$stdio_bufsiz" in
11692	'') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
11693	esac
11694fi
11695
11696: test whether _ptr and _cnt really work
11697echo "Checking how std your stdio is..." >&4
11698$cat >try.c <<EOP
11699#include <stdio.h>
11700#define FILE_ptr(fp)	$stdio_ptr
11701#define FILE_cnt(fp)	$stdio_cnt
11702int main() {
11703	FILE *fp = fopen("try.c", "r");
11704	char c = getc(fp);
11705	if (
11706		18 <= FILE_cnt(fp) &&
11707		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
11708	)
11709		exit(0);
11710	exit(1);
11711}
11712EOP
11713val="$undef"
11714set try
11715if eval $compile; then
11716	if ./try; then
11717		echo "Your stdio acts pretty std."
11718		val="$define"
11719	else
11720		echo "Your stdio isn't very std."
11721	fi
11722else
11723	echo "Your stdio doesn't appear very std."
11724fi
11725$rm -f try.c try
11726set d_stdstdio
11727eval $setvar
11728
11729: Can _ptr be used as an lvalue?
11730case "$d_stdstdio$ptr_lval" in
11731$define$define) val=$define ;;
11732*) val=$undef ;;
11733esac
11734set d_stdio_ptr_lval
11735eval $setvar
11736
11737: Can _cnt be used as an lvalue?
11738case "$d_stdstdio$cnt_lval" in
11739$define$define) val=$define ;;
11740*) val=$undef ;;
11741esac
11742set d_stdio_cnt_lval
11743eval $setvar
11744
11745
11746: test whether setting _ptr sets _cnt as a side effect
11747d_stdio_ptr_lval_sets_cnt="$undef"
11748d_stdio_ptr_lval_nochange_cnt="$undef"
11749case "$d_stdio_ptr_lval$d_stdstdio" in
11750$define$define)
11751	echo "Checking to see what happens if we set the stdio ptr..." >&4
11752$cat >try.c <<EOP
11753#include <stdio.h>
11754/* Can we scream? */
11755/* Eat dust sed :-) */
11756/* In the buffer space, no one can hear you scream. */
11757#define FILE_ptr(fp)	$stdio_ptr
11758#define FILE_cnt(fp)	$stdio_cnt
11759#include <sys/types.h>
11760int main() {
11761	FILE *fp = fopen("try.c", "r");
11762	int c;
11763	char *ptr;
11764	size_t cnt;
11765	if (!fp) {
11766	    puts("Fail even to read");
11767	    exit(1);
11768	}
11769	c = getc(fp); /* Read away the first # */
11770	if (c == EOF) {
11771	    puts("Fail even to read");
11772	    exit(1);
11773	}
11774	if (!(
11775		18 <= FILE_cnt(fp) &&
11776		strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
11777	)) {
11778		puts("Fail even to read");
11779		exit (1);
11780	}
11781	ptr = (char*) FILE_ptr(fp);
11782	cnt = (size_t)FILE_cnt(fp);
11783
11784	FILE_ptr(fp) += 42;
11785
11786	if ((char*)FILE_ptr(fp) != (ptr + 42)) {
11787		printf("Fail ptr check %p != %p", FILE_ptr(fp), (ptr + 42));
11788		exit (1);
11789	}
11790	if (FILE_cnt(fp) <= 20) {
11791		printf ("Fail (<20 chars to test)");
11792		exit (1);
11793	}
11794	if (strncmp(FILE_ptr(fp), "Eat dust sed :-) */\n", 20) != 0) {
11795		puts("Fail compare");
11796		exit (1);
11797	}
11798	if (cnt == FILE_cnt(fp)) {
11799		puts("Pass_unchanged");
11800		exit (0);
11801	}	
11802	if (FILE_cnt(fp) == (cnt - 42)) {
11803		puts("Pass_changed");
11804		exit (0);
11805	}
11806	printf("Fail count was %d now %d\n", cnt, FILE_cnt(fp));
11807	return 1;
11808
11809}
11810EOP
11811	set try
11812	if eval $compile; then
11813 		case `./try$exe_ext` in
11814		Pass_changed)
11815			echo "Increasing ptr in your stdio decreases cnt by the same amount.  Good." >&4
11816			d_stdio_ptr_lval_sets_cnt="$define" ;;
11817		Pass_unchanged)
11818			echo "Increasing ptr in your stdio leaves cnt unchanged.  Good." >&4
11819			d_stdio_ptr_lval_nochange_cnt="$define" ;;
11820		Fail*)
11821			echo "Increasing ptr in your stdio didn't do exactly what I expected.  We'll not be doing that then." >&4 ;;
11822		*)
11823			echo "It appears attempting to set ptr in your stdio is a bad plan." >&4 ;;
11824	esac
11825	else
11826		echo "It seems we can't set ptr in your stdio.  Nevermind." >&4
11827	fi
11828	$rm -f try.c try
11829	;;
11830esac
11831
11832: see if _base is also standard
11833val="$undef"
11834case "$d_stdstdio" in
11835$define)
11836	$cat >try.c <<EOP
11837#include <stdio.h>
11838#define FILE_base(fp)	$stdio_base
11839#define FILE_bufsiz(fp)	$stdio_bufsiz
11840int main() {
11841	FILE *fp = fopen("try.c", "r");
11842	char c = getc(fp);
11843	if (
11844		19 <= FILE_bufsiz(fp) &&
11845		strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
11846	)
11847		exit(0);
11848	exit(1);
11849}
11850EOP
11851	set try
11852	if eval $compile; then
11853		if ./try; then
11854			echo "And its _base field acts std."
11855			val="$define"
11856		else
11857			echo "But its _base field isn't std."
11858		fi
11859	else
11860		echo "However, it seems to be lacking the _base field."
11861	fi
11862	$rm -f try.c try
11863	;;
11864esac
11865set d_stdiobase
11866eval $setvar
11867
11868$cat >&4 <<EOM
11869Checking how to access stdio streams by file descriptor number...
11870EOM
11871case "$stdio_stream_array" in
11872'') 	$cat >try.c <<EOCP
11873#include <stdio.h>
11874int main() {
11875  if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
11876    printf("yes\n");
11877}
11878EOCP
11879	for s in _iob __iob __sF
11880	do
11881	        set try -DSTDIO_STREAM_ARRAY=$s
11882		if eval $compile; then
11883		    	case "`./try$exe_ext`" in
11884			yes)	stdio_stream_array=$s; break ;;
11885			esac
11886		fi
11887	done
11888	$rm -f try.* try$exe_ext
11889esac
11890case "$stdio_stream_array" in
11891'')	$cat >&4 <<EOM
11892I can't figure out how to access stdio streams by file descriptor number.
11893EOM
11894	d_stdio_stream_array="$undef"
11895	;;
11896*)	$cat >&4 <<EOM
11897You can access stdio streams by file descriptor number by the $stdio_stream_array array.
11898EOM
11899	d_stdio_stream_array="$define"
11900	;;
11901esac
11902
11903: see if strcoll exists
11904set strcoll d_strcoll
11905eval $inlibc
11906
11907: check for structure copying
11908echo " "
11909echo "Checking to see if your C compiler can copy structs..." >&4
11910$cat >try.c <<'EOCP'
11911int main()
11912{
11913	struct blurfl {
11914		int dyick;
11915	} foo, bar;
11916
11917	foo = bar;
11918}
11919EOCP
11920if $cc -c try.c >/dev/null 2>&1 ; then
11921	val="$define"
11922	echo "Yup, it can."
11923else
11924	val="$undef"
11925	echo "Nope, it can't."
11926fi
11927set d_strctcpy
11928eval $setvar
11929$rm -f try.*
11930
11931: see if strerror and/or sys_errlist[] exist
11932echo " "
11933if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
11934    if set strerror val -f d_strerror; eval $csym; $val; then
11935		echo 'strerror() found.' >&4
11936		d_strerror="$define"
11937		d_strerrm='strerror(e)'
11938		if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
11939			echo "(You also have sys_errlist[], so we could roll our own strerror.)"
11940			d_syserrlst="$define"
11941		else
11942			echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
11943			d_syserrlst="$undef"
11944		fi
11945    elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
11946			$contains '#[ 	]*define.*strerror' "$xxx" >/dev/null 2>&1; then
11947		echo 'strerror() found in string header.' >&4
11948		d_strerror="$define"
11949		d_strerrm='strerror(e)'
11950		if set sys_errlist val -a d_syserrlst; eval $csym; $val; then
11951			echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
11952				d_syserrlst="$define"
11953		else
11954			echo "(You don't appear to have any sys_errlist[], how can this be?)"
11955			d_syserrlst="$undef"
11956		fi
11957    elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
11958		echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
11959		d_strerror="$undef"
11960		d_syserrlst="$define"
11961		d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
11962    else
11963		echo 'strerror() and sys_errlist[] NOT found.' >&4
11964		d_strerror="$undef"
11965		d_syserrlst="$undef"
11966		d_strerrm='"unknown"'
11967    fi
11968fi
11969
11970: see if strtod exists
11971set strtod d_strtod
11972eval $inlibc
11973
11974: see if strtol exists
11975set strtol d_strtol
11976eval $inlibc
11977
11978: see if strtold exists
11979set strtold d_strtold
11980eval $inlibc
11981
11982: see if strtoll exists
11983set strtoll d_strtoll
11984eval $inlibc
11985
11986case "$d_longlong-$d_strtoll" in
11987"$define-$define")
11988	$cat <<EOM
11989Checking whether your strtoll() works okay...
11990EOM
11991	$cat >try.c <<'EOCP'
11992#include <errno.h>
11993#ifdef __hpux
11994#define strtoll __strtoll
11995#endif
11996#ifdef __EMX__
11997#define strtoll _strtoll
11998#endif
11999#include <stdio.h>
12000extern long long int strtoll(char *s, char **, int);
12001static int bad = 0;
12002int check(char *s, long long ell, int een) {
12003	long long gll;
12004	errno = 0;
12005	gll = strtoll(s, 0, 10);
12006	if (!((gll == ell) && (errno == een)))
12007		bad++;
12008}
12009int main() {
12010	check(" 1",                                      1LL, 0);
12011	check(" 0",                                      0LL, 0);
12012	check("-1",                                     -1LL, 0);
12013	check("-9223372036854775808", -9223372036854775808LL, 0);
12014	check("-9223372036854775808", -9223372036854775808LL, 0);
12015	check(" 9223372036854775807",  9223372036854775807LL, 0);
12016	check("-9223372036854775808", -9223372036854775808LL, 0);
12017	check(" 9223372036854775808",  9223372036854775807LL, ERANGE);
12018	check("-9223372036854775809", -9223372036854775808LL, ERANGE);
12019	if (!bad)
12020		printf("ok\n");
12021}
12022EOCP
12023	set try
12024	if eval $compile; then
12025		yyy=`./try`
12026		case "$yyy" in
12027		ok) echo "Your strtoll() seems to be working okay." ;;
12028		*) cat <<EOM >&4
12029Your strtoll() doesn't seem to be working okay.
12030EOM
12031		   d_strtoll="$undef"
12032		   ;;
12033		esac
12034	else
12035		echo "(I can't seem to compile the test program--assuming it doesn't)"
12036		d_strtoll="$undef"
12037	fi
12038	;;
12039esac
12040
12041: see if strtoul exists
12042set strtoul d_strtoul
12043eval $inlibc
12044
12045: see if strtoull exists
12046set strtoull d_strtoull
12047eval $inlibc
12048
12049case "$d_longlong-$d_strtoull" in
12050"$define-$define")
12051	$cat <<EOM
12052Checking whether your strtoull() works okay...
12053EOM
12054	$cat >try.c <<'EOCP'
12055#include <errno.h>
12056#ifdef __hpux
12057#define strtoull __strtoull
12058#endif
12059#include <stdio.h>
12060extern unsigned long long int strtoull(char *s, char **, int);
12061static int bad = 0;
12062int check(char *s, long long eull, int een) {
12063	long long gull;
12064	errno = 0;
12065	gull = strtoull(s, 0, 10);
12066	if (!((gull == eull) && (errno == een)))
12067		bad++;
12068}
12069int main() {
12070	check(" 1",                                       1LL, 0);
12071	check(" 0",                                       0LL, 0);
12072	check("18446744073709551615", 18446744073709551615ULL, 0);
12073	check("18446744073709551616", 18446744073709551615ULL, ERANGE);
12074	if (!bad)
12075		printf("ok\n");
12076}
12077EOCP
12078	set try
12079	if eval $compile; then
12080		case "`./try`" in
12081		ok) echo "Your strtoull() seems to be working okay." ;;
12082		*) cat <<EOM >&4
12083Your strtoull() doesn't seem to be working okay.
12084EOM
12085		   d_strtoull="$undef"
12086		   ;;
12087		esac
12088	fi
12089	;;
12090esac
12091
12092: see if strtouq exists
12093set strtouq d_strtouq
12094eval $inlibc
12095
12096: see if strxfrm exists
12097set strxfrm d_strxfrm
12098eval $inlibc
12099
12100: see if symlink exists
12101set symlink d_symlink
12102eval $inlibc
12103
12104: see if syscall exists
12105set syscall d_syscall
12106eval $inlibc
12107
12108: see if sysconf exists
12109set sysconf d_sysconf
12110eval $inlibc
12111
12112: see if system exists
12113set system d_system
12114eval $inlibc
12115
12116: see if tcgetpgrp exists
12117set tcgetpgrp d_tcgetpgrp
12118eval $inlibc
12119
12120: see if tcsetpgrp exists
12121set tcsetpgrp d_tcsetpgrp
12122eval $inlibc
12123
12124: see if prototype for telldir is available
12125echo " "
12126set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
12127eval $hasproto
12128
12129: see if this is a sys/times.h system
12130set sys/times.h i_systimes
12131eval $inhdr
12132
12133: see if times exists
12134echo " "
12135if set times val -f d_times; eval $csym; $val; then
12136	echo 'times() found.' >&4
12137	d_times="$define"
12138	inc=''
12139	case "$i_systimes" in
12140	"$define") inc='sys/times.h';;
12141	esac
12142	rp="What is the type returned by times() on this system?"
12143	set clock_t clocktype long stdio.h sys/types.h $inc
12144	eval $typedef_ask
12145else
12146	echo 'times() NOT found, hope that will do.' >&4
12147	d_times="$undef"
12148	clocktype='int'
12149fi
12150
12151: see if truncate exists
12152set truncate d_truncate
12153eval $inlibc
12154
12155: see if tzname[] exists
12156echo " "
12157if set tzname val -a d_tzname; eval $csym; $val; then
12158	val="$define"
12159	echo 'tzname[] found.' >&4
12160else
12161	val="$undef"
12162	echo 'tzname[] NOT found.' >&4
12163fi
12164set d_tzname
12165eval $setvar
12166
12167: see if umask exists
12168set umask d_umask
12169eval $inlibc
12170
12171: see if ustat exists
12172set ustat d_ustat
12173eval $inlibc
12174
12175: backward compatibility for d_hvfork
12176if test X$d_hvfork != X; then
12177	d_vfork="$d_hvfork"
12178	d_hvfork=''
12179fi
12180: see if there is a vfork
12181val=''
12182set vfork val
12183eval $inlibc
12184
12185: Ok, but do we want to use it. vfork is reportedly unreliable in
12186: perl on Solaris 2.x, and probably elsewhere.
12187case "$val" in
12188$define)
12189	echo " "
12190	case "$usevfork" in
12191	false) dflt='n';;
12192	*) dflt='y';;
12193	esac
12194	cat <<'EOM'
12195
12196Perl can only use a vfork() that doesn't suffer from strict
12197restrictions on calling functions or modifying global data in
12198the child.  For example, glibc-2.1 contains such a vfork()
12199that is unsuitable.  If your system provides a proper fork()
12200call, chances are that you do NOT want perl to use vfork().
12201
12202EOM
12203	rp="Do you still want to use vfork()?"
12204	. ./myread
12205	case "$ans" in
12206	y|Y) ;;
12207	*)
12208		echo "Ok, we won't use vfork()."
12209		val="$undef"
12210		;;
12211	esac
12212	;;
12213esac
12214set d_vfork
12215eval $setvar
12216case "$d_vfork" in
12217$define) usevfork='true';;
12218*) usevfork='false';;
12219esac
12220
12221: see if this is an sysdir system
12222set sys/dir.h i_sysdir
12223eval $inhdr
12224
12225: see if this is an sysndir system
12226set sys/ndir.h i_sysndir
12227eval $inhdr
12228
12229: see if closedir exists
12230set closedir d_closedir
12231eval $inlibc
12232
12233case "$d_closedir" in
12234"$define")
12235	echo " "
12236	echo "Checking whether closedir() returns a status..." >&4
12237	cat > closedir.c <<EOM
12238#$i_dirent I_DIRENT		/**/
12239#$i_sysdir I_SYS_DIR		/**/
12240#$i_sysndir I_SYS_NDIR		/**/
12241#$i_systypes I_SYS_TYPES	/**/
12242
12243#if defined(I_SYS_TYPES)
12244#include <sys/types.h>
12245#endif
12246#if defined(I_DIRENT)
12247#include <dirent.h>
12248#if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
12249#include <sys/dir.h>
12250#endif
12251#else
12252#ifdef I_SYS_NDIR
12253#include <sys/ndir.h>
12254#else
12255#ifdef I_SYS_DIR
12256#ifdef hp9000s500
12257#include <ndir.h>	/* may be wrong in the future */
12258#else
12259#include <sys/dir.h>
12260#endif
12261#endif
12262#endif
12263#endif
12264int main() { return closedir(opendir(".")); }
12265EOM
12266	set closedir
12267	if eval $compile_ok; then
12268		if ./closedir > /dev/null 2>&1 ; then
12269			echo "Yes, it does."
12270			val="$undef"
12271		else
12272			echo "No, it doesn't."
12273			val="$define"
12274		fi
12275	else
12276		echo "(I can't seem to compile the test program--assuming it doesn't)"
12277		val="$define"
12278	fi
12279	;;
12280*)
12281	val="$undef";
12282	;;
12283esac
12284set d_void_closedir
12285eval $setvar
12286$rm -f closedir*
12287: see if there is a wait4
12288set wait4 d_wait4
12289eval $inlibc
12290
12291: see if waitpid exists
12292set waitpid d_waitpid
12293eval $inlibc
12294
12295: see if wcstombs exists
12296set wcstombs d_wcstombs
12297eval $inlibc
12298
12299: see if wctomb exists
12300set wctomb d_wctomb
12301eval $inlibc
12302
12303: preserve RCS keywords in files with variable substitution, grrr
12304Date='$Date'
12305Id='$Id'
12306Log='$Log'
12307RCSfile='$RCSfile'
12308Revision='$Revision'
12309
12310case "$crosscompile" in
12311''|[nN]*) crosscompile="$undef" ;;
12312esac
12313
12314case "$osname" in
12315next|rhapsody|darwin) multiarch="$define" ;;
12316esac
12317case "$multiarch" in
12318''|[nN]*) multiarch="$undef" ;;
12319esac
12320
12321: check for alignment requirements
12322echo " "
12323case "$crosscompile$multiarch" in
12324*$define*)
12325	$cat <<EOM
12326You seem to be either cross-compiling or doing a multiarchitecture build,
12327skipping the memory alignment check.
12328
12329EOM
12330	case "$alignbytes" in
12331	'') alignbytes=8 ;;
12332	esac
12333	;;
12334*)
12335	case "$alignbytes" in
12336	'') echo "Checking alignment constraints..." >&4
12337		if $test "X$uselongdouble" = Xdefine -a "X$d_longdbl" = Xdefine; then
12338			$cat >try.c <<'EOCP'
12339typedef long double NV;
12340EOCP
12341		else
12342			$cat >try.c <<'EOCP'
12343typedef double NV;
12344EOCP
12345		fi
12346		$cat >>try.c <<'EOCP'
12347#include <stdio.h>
12348struct foobar {
12349	char foo;
12350	NV bar;
12351} try_algn;
12352int main()
12353{
12354    printf("%d\n", (int)((char *)&try_algn.bar - (char *)&try_algn.foo));
12355    return(0);
12356}
12357EOCP
12358		set try
12359		if eval $compile_ok; then
12360			dflt=`./try`
12361		else
12362			dflt='8'
12363			echo "(I can't seem to compile the test program...)"
12364		fi
12365		;;
12366	*) dflt="$alignbytes"
12367		;;
12368	esac
12369	rp="Doubles must be aligned on a how-many-byte boundary?"
12370	. ./myread
12371	alignbytes="$ans"
12372	$rm -f try.c try
12373	;;
12374esac
12375
12376
12377: set the base revision
12378baserev=5.0
12379
12380: check for ordering of bytes in a long
12381echo " "
12382case "$crosscompile$multiarch" in
12383*$define*)
12384	$cat <<EOM
12385You seem to be either cross-compiling or doing a multiarchitecture build,
12386skipping the byteorder check.
12387
12388EOM
12389	byteorder='0xffff'
12390	;;
12391*)
12392	case "$byteorder" in
12393	'')
12394		$cat <<'EOM'
12395In the following, larger digits indicate more significance.  A big-endian
12396machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
12397little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
12398machines may have weird orders like 3412.  A Cray will report 87654321,
12399an Alpha will report 12345678. If the test program works the default is
12400probably right.
12401I'm now running the test program...
12402EOM
12403		$cat >try.c <<'EOCP'
12404#include <stdio.h>
12405int main()
12406{
12407	int i;
12408	union {
12409		unsigned long l;
12410		char c[sizeof(long)];
12411	} u;
12412
12413	if (sizeof(long) > 4)
12414		u.l = (0x08070605L << 32) | 0x04030201L;
12415	else
12416		u.l = 0x04030201L;
12417	for (i = 0; i < sizeof(long); i++)
12418		printf("%c", u.c[i]+'0');
12419	printf("\n");
12420	exit(0);
12421}
12422EOCP
12423		xxx_prompt=y
12424		set try
12425		if eval $compile && ./try > /dev/null; then
12426			dflt=`./try`
12427			case "$dflt" in
12428			[1-4][1-4][1-4][1-4]|12345678|87654321)
12429				echo "(The test program ran ok.)"
12430				echo "byteorder=$dflt"
12431				xxx_prompt=n
12432			;;
12433			????|????????) echo "(The test program ran ok.)" ;;
12434			*) echo "(The test program didn't run right for some reason.)" ;;
12435			esac
12436		else
12437			dflt='4321'
12438			cat <<'EOM'
12439(I can't seem to compile the test program.  Guessing big-endian...)
12440EOM
12441		fi
12442		case "$xxx_prompt" in
12443		y)
12444			rp="What is the order of bytes in a long?"
12445			. ./myread
12446			byteorder="$ans"
12447			;;
12448		*)	byteorder=$dflt
12449			;;
12450		esac
12451		;;
12452	esac
12453	$rm -f try.c try
12454	;;
12455esac
12456
12457
12458: how do we catenate cpp tokens here?
12459echo " "
12460echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
12461$cat >cpp_stuff.c <<'EOCP'
12462#define RCAT(a,b)a/**/b
12463#define ACAT(a,b)a ## b
12464RCAT(Rei,ser)
12465ACAT(Cir,cus)
12466EOCP
12467$cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
12468if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
12469	echo "Oh!  Smells like ANSI's been here." >&4
12470	echo "We can catify or stringify, separately or together!"
12471	cpp_stuff=42
12472elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
12473	echo "Ah, yes!  The good old days!" >&4
12474	echo "However, in the good old days we don't know how to stringify and"
12475	echo "catify at the same time."
12476	cpp_stuff=1
12477else
12478	$cat >&4 <<EOM
12479Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
12480to have to edit the values of CAT[2-5] in config.h...
12481EOM
12482	cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
12483fi
12484$rm -f cpp_stuff.*
12485
12486: see if this is a db.h system
12487set db.h i_db
12488eval $inhdr
12489
12490case "$i_db" in
12491$define)
12492	: Check db version.
12493	echo " "
12494	echo "Checking Berkeley DB version ..." >&4
12495	$cat >try.c <<EOCP
12496#$d_const HASCONST
12497#ifndef HASCONST
12498#define const
12499#endif
12500#include <sys/types.h>
12501#include <stdio.h>
12502#include <db.h>
12503int main()
12504{
12505#ifdef DB_VERSION_MAJOR	/* DB version >= 2 */
12506    int Major, Minor, Patch ;
12507    unsigned long Version ;
12508    (void)db_version(&Major, &Minor, &Patch) ;
12509    printf("You have Berkeley DB Version 2 or greater\n");
12510
12511    printf("db.h is from Berkeley DB Version %d.%d.%d\n",
12512		DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
12513    printf("libdb is from Berkeley DB Version %d.%d.%d\n",
12514		Major, Minor, Patch) ;
12515
12516    /* check that db.h & libdb are compatible */
12517    if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
12518	printf("db.h and libdb are incompatible\n") ;
12519        exit(3);	
12520    }
12521
12522    printf("db.h and libdb are compatible\n") ;
12523
12524    Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
12525		+ DB_VERSION_PATCH ;
12526
12527    /* needs to be >= 2.3.4 */
12528    if (Version < 2003004) {
12529    /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
12530	printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
12531        exit(2);	
12532    }
12533
12534    exit(0);
12535#else
12536#if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
12537    printf("You have Berkeley DB Version 1\n");
12538    exit(0);	/* DB version < 2: the coast is clear. */
12539#else
12540    exit(1);	/* <db.h> not Berkeley DB? */
12541#endif
12542#endif
12543}
12544EOCP
12545	set try
12546	if eval $compile_ok && ./try; then
12547		echo 'Looks OK.' >&4
12548	else
12549		echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
12550		i_db=$undef
12551		case " $libs " in
12552		*"-ldb "*)
12553			: Remove db from list of libraries to use
12554			echo "Removing unusable -ldb from library list" >&4
12555			set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
12556			shift
12557			libs="$*"
12558			echo "libs = $libs" >&4
12559			;;
12560		esac
12561	fi
12562	$rm -f try.*
12563	;;
12564esac
12565
12566case "$i_db" in
12567define)
12568	: Check the return type needed for hash
12569	echo " "
12570	echo "Checking return type needed for hash for Berkeley DB ..." >&4
12571	$cat >try.c <<EOCP
12572#$d_const HASCONST
12573#ifndef HASCONST
12574#define const
12575#endif
12576#include <sys/types.h>
12577#include <db.h>
12578
12579#ifndef DB_VERSION_MAJOR
12580u_int32_t hash_cb (ptr, size)
12581const void *ptr;
12582size_t size;
12583{
12584}
12585HASHINFO info;
12586int main()
12587{
12588	info.hash = hash_cb;
12589}
12590#endif
12591EOCP
12592	if $cc $ccflags -c try.c >try.out 2>&1 ; then
12593		if $contains warning try.out >>/dev/null 2>&1 ; then
12594			db_hashtype='int'
12595		else
12596			db_hashtype='u_int32_t'
12597		fi
12598	else
12599		: XXX Maybe we should just give up here.
12600		db_hashtype=u_int32_t
12601		$cat try.out >&4
12602		echo "Help:  I can't seem to compile the db test program." >&4
12603		echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
12604	fi
12605	$rm -f try.*
12606	echo "Your version of Berkeley DB uses $db_hashtype for hash."
12607	;;
12608*)	db_hashtype=u_int32_t
12609	;;
12610esac
12611case "$i_db" in
12612define)
12613	: Check the return type needed for prefix
12614	echo " "
12615	echo "Checking return type needed for prefix for Berkeley DB ..." >&4
12616	cat >try.c <<EOCP
12617#$d_const HASCONST
12618#ifndef HASCONST
12619#define const
12620#endif
12621#include <sys/types.h>
12622#include <db.h>
12623
12624#ifndef DB_VERSION_MAJOR
12625size_t prefix_cb (key1, key2)
12626const DBT *key1;
12627const DBT *key2;
12628{
12629}
12630BTREEINFO info;
12631int main()
12632{
12633	info.prefix = prefix_cb;
12634}
12635#endif
12636EOCP
12637	if $cc $ccflags -c try.c  >try.out 2>&1 ; then
12638		if $contains warning try.out >>/dev/null 2>&1 ; then
12639			db_prefixtype='int'
12640		else
12641			db_prefixtype='size_t'
12642		fi
12643	else
12644		db_prefixtype='size_t'
12645		: XXX Maybe we should just give up here.
12646		$cat try.out >&4
12647		echo "Help:  I can't seem to compile the db test program." >&4
12648		echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
12649	fi
12650	$rm -f try.*
12651	echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
12652	;;
12653*)	db_prefixtype='size_t'
12654	;;
12655esac
12656
12657: check for void type
12658echo " "
12659echo "Checking to see how well your C compiler groks the void type..." >&4
12660case "$voidflags" in
12661'')
12662	$cat >try.c <<'EOCP'
12663#if TRY & 1
12664void sub() {
12665#else
12666sub() {
12667#endif
12668	extern void moo();	/* function returning void */
12669	void (*goo)();		/* ptr to func returning void */
12670#if TRY & 8
12671	void *hue;		/* generic ptr */
12672#endif
12673#if TRY & 2
12674	void (*foo[10])();
12675#endif
12676
12677#if TRY & 4
12678	if(goo == moo) {
12679		exit(0);
12680	}
12681#endif
12682	exit(0);
12683}
12684int main() { sub(); }
12685EOCP
12686	if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
12687		voidflags=$defvoidused
12688	echo "Good.  It appears to support void to the level $package wants.">&4
12689		if $contains warning .out >/dev/null 2>&1; then
12690			echo "However, you might get some warnings that look like this:"
12691			$cat .out
12692		fi
12693	else
12694echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
12695		if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
12696			echo "It supports 1..."
12697			if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
12698				echo "It also supports 2..."
12699				if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
12700					voidflags=7
12701					echo "And it supports 4 but not 8 definitely."
12702				else
12703					echo "It doesn't support 4..."
12704					if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
12705						voidflags=11
12706						echo "But it supports 8."
12707					else
12708						voidflags=3
12709						echo "Neither does it support 8."
12710					fi
12711				fi
12712			else
12713				echo "It does not support 2..."
12714				if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
12715					voidflags=13
12716					echo "But it supports 4 and 8."
12717				else
12718					if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
12719						voidflags=5
12720						echo "And it supports 4 but has not heard about 8."
12721					else
12722						echo "However it supports 8 but not 4."
12723					fi
12724				fi
12725			fi
12726		else
12727			echo "There is no support at all for void."
12728			voidflags=0
12729		fi
12730	fi
12731esac
12732case "$voidflags" in
12733"$defvoidused") ;;
12734*)	$cat >&4 <<'EOM'
12735  Support flag bits are:
12736    1: basic void declarations.
12737    2: arrays of pointers to functions returning void.
12738    4: operations between pointers to and addresses of void functions.
12739    8: generic void pointers.
12740EOM
12741	dflt="$voidflags";
12742	rp="Your void support flags add up to what?"
12743	. ./myread
12744	voidflags="$ans"
12745	;;
12746esac
12747$rm -f try.* .out
12748
12749
12750: How can we generate normalized random numbers ?
12751echo " "
12752echo "Looking for a random number function..." >&4
12753case "$randfunc" in
12754'')
12755	if set drand48 val -f; eval $csym; $val; then
12756		dflt="drand48"
12757		echo "Good, found drand48()." >&4
12758	elif set random val -f; eval $csym; $val; then
12759		dflt="random"
12760		echo "OK, found random()." >&4
12761	else
12762		dflt="rand"
12763		echo "Yick, looks like I have to use rand()." >&4
12764	fi
12765	echo " "
12766	;;
12767*)
12768	dflt="$randfunc"
12769	;;
12770esac
12771cont=true
12772
12773case "$ccflags" in
12774*-Dmy_rand=*|*-Dmy_srand=*)
12775	echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
12776	ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
12777	ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
12778	ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
12779	;;
12780esac
12781
12782while $test "$cont"; do
12783	rp="Use which function to generate random numbers?"
12784	. ./myread
12785	if $test "$ans" = "$dflt"; then
12786		: null
12787	else
12788		randbits=''
12789	fi
12790	randfunc="$ans"
12791	if set $ans val -f; eval $csym; $val; then
12792		cont=''
12793	else
12794		dflt=y
12795		rp="I cannot find function $ans. Use that name anyway?"
12796		. ./myread
12797		dflt=rand
12798		case "$ans" in
12799			[yY]*) cont='';;
12800		esac
12801	fi
12802	case "$cont" in
12803	'')
12804		case "$randfunc" in
12805		drand48)
12806			drand01="drand48()"
12807			seedfunc="srand48"
12808			randbits=48
12809			randseedtype=long
12810			;;
12811		rand|random)
12812			case "$randbits" in
12813			'')
12814echo "Checking to see how many bits your $randfunc() function produces..." >&4
12815				$cat >try.c <<EOCP
12816#$i_unistd I_UNISTD
12817#$i_stdlib I_STDLIB
12818#include <stdio.h>
12819#ifdef I_UNISTD
12820#  include <unistd.h>
12821#endif
12822#ifdef I_STDLIB
12823#  include <stdlib.h>
12824#endif
12825int main()
12826{
12827	register int i;
12828	register unsigned long tmp;
12829	register unsigned long max = 0L;
12830
12831	for (i = 1000; i; i--) {
12832		tmp = (unsigned long) $randfunc();
12833		if (tmp > max) max = tmp;
12834	}
12835	for (i = 0; max; i++)
12836		max /= 2;
12837	printf("%d\n",i);
12838}
12839EOCP
12840				set try
12841				if eval $compile_ok; then
12842					dflt=`try`
12843				else
12844					dflt='?'
12845					echo "(I can't seem to compile the test program...)"
12846				fi
12847				;;
12848			*)
12849				dflt="$randbits"
12850				;;
12851			esac
12852			rp="How many bits does your $randfunc() function produce?"
12853			. ./myread
12854			randbits="$ans"
12855			$rm -f try.c try
12856			drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
12857			seedfunc="s$randfunc"
12858			randseedtype=unsigned
12859			;;
12860		*)
12861			dflt="31"
12862			rp="How many bits does your $randfunc() function produce?"
12863			. ./myread
12864			randbits="$ans"
12865			seedfunc="s$randfunc"
12866			drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
12867			if set $seedfunc val -f; eval $csym; $val; then
12868				echo "(Using $seedfunc() to seed random generator)"
12869			else
12870				echo "(Warning: no $seedfunc() to seed random generator)"
12871				seedfunc=rand
12872			fi
12873			randseedtype=unsigned
12874			;;
12875		esac
12876		;;
12877	esac
12878done
12879
12880echo " "
12881echo "Determining whether or not we are on an EBCDIC system..." >&4
12882$cat >tebcdic.c <<'EOM'
12883int main()
12884{
12885  if ('M'==0xd4) return 0;
12886  return 1;
12887}
12888EOM
12889
12890val=$undef
12891set tebcdic
12892if eval $compile_ok; then
12893	if ./tebcdic; then
12894		echo "You seem to speak EBCDIC." >&4
12895		val="$define"
12896	else
12897		echo "Nope, no EBCDIC, probably ASCII or some ISO Latin. Or UTF8." >&4
12898	fi
12899else
12900	echo "I'm unable to compile the test program." >&4
12901	echo "I'll assume ASCII or some ISO Latin. Or UTF8." >&4
12902fi
12903$rm -f tebcdic.c tebcdic
12904set ebcdic
12905eval $setvar
12906
12907echo " "
12908$cat >&4 <<EOM
12909Checking how to flush all pending stdio output...
12910EOM
12911# I only know how to find the first 32 possibly open files on SunOS.
12912# See also hints/sunos_4_1.sh and util.c  --AD
12913case "$osname" in
12914sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
12915esac
12916$cat >>try.c <<EOCP
12917#include <stdio.h>
12918#$i_unistd I_UNISTD
12919#ifdef I_UNISTD
12920# include <unistd.h>
12921#endif
12922#$d_sysconf HAS_SYSCONF
12923#$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
12924#ifdef HAS_STDIO_STREAM_ARRAY
12925# define STDIO_STREAM_ARRAY $stdio_stream_array
12926#endif
12927int main() {
12928  FILE* p = fopen("try.out", "w");
12929#ifdef TRY_FPUTC
12930  fputc('x', p);
12931#else
12932# ifdef TRY_FPRINTF
12933  fprintf(p, "x");
12934# endif
12935#endif
12936#ifdef TRY_FFLUSH_NULL
12937  fflush(NULL);
12938#endif
12939#ifdef TRY_FFLUSH_ALL
12940  {
12941    long open_max = -1;
12942# ifdef PERL_FFLUSH_ALL_FOPEN_MAX
12943    open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
12944# else
12945#  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
12946    open_max = sysconf(_SC_OPEN_MAX);
12947#  else
12948#   ifdef FOPEN_MAX
12949    open_max = FOPEN_MAX;
12950#   else
12951#    ifdef OPEN_MAX
12952    open_max = OPEN_MAX;
12953#    else
12954#     ifdef _NFILE
12955    open_max = _NFILE;
12956#     endif
12957#    endif
12958#   endif
12959#  endif
12960# endif 
12961# ifdef HAS_STDIO_STREAM_ARRAY
12962    if (open_max > 0) {
12963      long i;
12964      for (i = 0; i < open_max; i++)
12965	    if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
12966		STDIO_STREAM_ARRAY[i]._file < open_max &&
12967		STDIO_STREAM_ARRAY[i]._flag)
12968		fflush(&STDIO_STREAM_ARRAY[i]);
12969    }	
12970  }
12971# endif
12972#endif
12973  _exit(42);
12974}
12975EOCP
12976: first we have to find out how _not_ to flush
12977if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
12978    output=''
12979    set try -DTRY_FPUTC
12980    if eval $compile; then
12981	    $rm -f try.out
12982 	    ./try$exe_ext 2>/dev/null
12983	    if $test ! -s try.out -a "X$?" = X42; then
12984		output=-DTRY_FPUTC
12985	    fi
12986    fi
12987    case "$output" in
12988    '')
12989	    set try -DTRY_FPRINTF
12990	    $rm -f try.out
12991	    if eval $compile; then
12992		    $rm -f try.out
12993 		    ./try$exe_ext 2>/dev/null
12994		    if $test ! -s try.out -a "X$?" = X42; then
12995			output=-DTRY_FPRINTF
12996		    fi
12997	    fi
12998	;;
12999    esac
13000fi
13001: check for fflush NULL behaviour
13002case "$fflushNULL" in
13003'') 	set try -DTRY_FFLUSH_NULL $output
13004	if eval $compile; then
13005	        $rm -f try.out
13006	    	./try$exe_ext 2>/dev/null
13007		code="$?"
13008		if $test -s try.out -a "X$code" = X42; then
13009			fflushNULL="`$cat try.out`"
13010		else
13011			if $test "X$code" != X42; then
13012				$cat >&4 <<EOM
13013(If this test failed, don't worry, we'll try another method shortly.)
13014EOM
13015			fi
13016		fi
13017	fi
13018	$rm -f core try.core core.try.*
13019	case "$fflushNULL" in
13020	x)	$cat >&4 <<EOM
13021Your fflush(NULL) works okay for output streams.
13022Let's see if it clobbers input pipes...
13023EOM
13024# As of mid-March 2000 all versions of Solaris appear to have a stdio
13025# bug that improperly flushes the input end of pipes.  So we avoid the
13026# autoflush on fork/system/exec support for now. :-(
13027$cat >tryp.c <<EOCP
13028#include <stdio.h>
13029int
13030main(int argc, char **argv)
13031{
13032    char buf[1024];
13033    int i;
13034    char *bp = buf;
13035    while (1) {
13036        while ((i = getc(stdin)) != -1
13037               && (*bp++ = i) != '\n'
13038               && bp < &buf[1024])
13039    	/* DO NOTHING */ ;
13040        *bp = '\0';
13041        fprintf(stdout, "%s", buf);
13042        fflush(NULL);
13043        if (i == -1)
13044	    return 0;
13045        bp = buf;
13046    }
13047}
13048EOCP
13049                fflushNULL="$define"
13050                set tryp
13051                if eval $compile; then
13052                    $rm -f tryp.out
13053                    $cat tryp.c | ./tryp$exe_ext 2>/dev/null > tryp.out
13054                    if cmp tryp.c tryp.out >/dev/null 2>&1; then
13055                       $cat >&4 <<EOM
13056fflush(NULL) seems to behave okay with input streams.
13057EOM
13058			fflushNULL="$define"
13059                    else
13060			$cat >&4 <<EOM
13061Ouch, fflush(NULL) clobbers input pipes!  We will not use it.
13062EOM
13063                        fflushNULL="$undef"
13064                    fi
13065                fi
13066	        $rm -f core tryp.c tryp.core core.tryp.*
13067		;;
13068	'')	$cat >&4 <<EOM
13069Your fflush(NULL) isn't working (contrary to ANSI C).
13070EOM
13071		fflushNULL="$undef"
13072		;;
13073	*)	$cat >&4 <<EOM
13074Cannot figure out whether your fflush(NULL) works or not.
13075I'm assuming it doesn't (contrary to ANSI C).
13076EOM
13077		fflushNULL="$undef"
13078		;;
13079	esac
13080	;;
13081$define|true|[yY]*)
13082	fflushNULL="$define"
13083	;;
13084*)
13085	fflushNULL="$undef"
13086	;;
13087esac
13088: check explicit looping only if NULL did not work, and if the pipe
13089: bug does not show up on an explicit flush too
13090case "$fflushNULL" in
13091"$undef")
13092	$cat >tryp.c <<EOCP
13093#include <stdio.h>
13094int
13095main(int argc, char **argv)
13096{
13097    char buf[1024];
13098    int i;
13099    char *bp = buf;
13100    while (1) {
13101	while ((i = getc(stdin)) != -1
13102	       && (*bp++ = i) != '\n'
13103	       && bp < &buf[1024])
13104	/* DO NOTHING */ ;
13105	*bp = '\0';
13106	fprintf(stdout, "%s", buf);
13107	fflush(stdin);
13108	if (i == -1)
13109	    return 0;
13110	bp = buf;
13111    }
13112}
13113EOCP
13114	set tryp
13115	if eval $compile; then
13116	    $rm -f tryp.out
13117	    $cat tryp.c | ./tryp$exe_ext 2>/dev/null > tryp.out
13118	    if cmp tryp.c tryp.out >/dev/null 2>&1; then
13119	       $cat >&4 <<EOM
13120Good, at least fflush(stdin) seems to behave okay when stdin is a pipe.
13121EOM
13122		: now check for fflushall behaviour
13123		case "$fflushall" in
13124		'') 	set try -DTRY_FFLUSH_ALL $output
13125			if eval $compile; then
13126				$cat >&4 <<EOM
13127(Now testing the other method--but note that this also may fail.)
13128EOM
13129				$rm -f try.out
13130				./try$exe_ext 2>/dev/null
13131				if $test -s try.out -a "X$?" = X42; then
13132					fflushall="`$cat try.out`"
13133				fi
13134			fi
13135			$rm -f core try.core core.try.*
13136			case "$fflushall" in
13137			x)	$cat >&4 <<EOM
13138Whew. Flushing explicitly all the stdio streams works.
13139EOM
13140				fflushall="$define"
13141				;;
13142			'')	$cat >&4 <<EOM
13143Sigh. Flushing explicitly all the stdio streams doesn't work.
13144EOM
13145				fflushall="$undef"
13146				;;
13147			*)	$cat >&4 <<EOM
13148Cannot figure out whether flushing stdio streams explicitly works or not.
13149I'm assuming it doesn't.
13150EOM
13151				fflushall="$undef"
13152				;;
13153			esac
13154			;;
13155		"$define"|true|[yY]*)
13156			fflushall="$define"
13157			;;
13158		*)
13159			fflushall="$undef"
13160			;;
13161		esac
13162	    else
13163		$cat >&4 <<EOM
13164All is futile.  Even fflush(stdin) clobbers input pipes!
13165EOM
13166		fflushall="$undef"
13167	    fi
13168	else
13169	    fflushall="$undef"
13170	fi
13171	$rm -f core tryp.c tryp.core core.tryp.*
13172	;;
13173*)	fflushall="$undef"
13174	;;
13175esac
13176
13177case "$fflushNULL$fflushall" in
13178undefundef)
13179	$cat <<EOM
13180OK, I give up.  I cannot figure out how to flush pending stdio output.
13181We won't be flushing handles at all before fork/exec/popen.
13182EOM
13183	;;
13184esac
13185$rm -f try.* try$exe_ext
13186
13187: Store the full pathname to the ar program for use in the C program
13188: Respect a hint or command line value for full_ar.
13189case "$full_ar" in
13190'') full_ar=$ar ;;
13191esac
13192
13193: Store the full pathname to the sed program for use in the C program
13194full_sed=$sed
13195
13196: see what type gids are declared as in the kernel
13197echo " "
13198echo "Looking for the type for group ids returned by getgid()."
13199set gid_t gidtype xxx stdio.h sys/types.h
13200eval $typedef
13201case "$gidtype" in
13202xxx)
13203	xxx=`./findhdr sys/user.h`
13204	set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
13205	case $1 in
13206	unsigned) dflt="$1 $2" ;;
13207	*) dflt="$1" ;;
13208	esac
13209	;;
13210*) dflt="$gidtype";;
13211esac
13212case "$gidtype" in
13213gid_t) echo "gid_t found." ;;
13214*)	rp="What is the type for group ids returned by getgid()?"
13215	. ./myread
13216	gidtype="$ans"
13217	;;
13218esac
13219
13220echo " "
13221case "$gidtype" in
13222*_t) zzz="$gidtype"	;;
13223*)   zzz="gid"		;;
13224esac
13225echo "Checking the size of $zzz..." >&4
13226cat > try.c <<EOCP
13227#include <sys/types.h>
13228#include <stdio.h>
13229int main() {
13230    printf("%d\n", (int)sizeof($gidtype));
13231    exit(0);
13232}
13233EOCP
13234set try
13235if eval $compile_ok; then
13236	yyy=`./try`
13237	case "$yyy" in
13238	'')	gidsize=4
13239		echo "(I can't execute the test program--guessing $gidsize.)" >&4
13240		;;
13241	*)	gidsize=$yyy
13242		echo "Your $zzz is $gidsize bytes long."
13243		;;
13244	esac
13245else
13246	gidsize=4
13247	echo "(I can't compile the test program--guessing $gidsize.)" >&4
13248fi
13249
13250
13251echo " "
13252case "$gidtype" in
13253*_t) zzz="$gidtype"	;;
13254*)   zzz="gid"		;;
13255esac
13256echo "Checking the sign of $zzz..." >&4
13257cat > try.c <<EOCP
13258#include <sys/types.h>
13259#include <stdio.h>
13260int main() {
13261	$gidtype foo = -1;
13262	if (foo < 0)
13263		printf("-1\n");
13264	else
13265		printf("1\n");
13266}
13267EOCP
13268set try
13269if eval $compile; then
13270	yyy=`./try`
13271	case "$yyy" in
13272	'')	gidsign=1
13273		echo "(I can't execute the test program--guessing unsigned.)" >&4
13274		;;
13275	*)	gidsign=$yyy
13276		case "$gidsign" in
13277		 1) echo "Your $zzz is unsigned." ;;
13278		-1) echo "Your $zzz is signed."   ;;
13279		esac
13280		;;
13281	esac
13282else
13283	gidsign=1
13284	echo "(I can't compile the test program--guessing unsigned.)" >&4
13285fi
13286
13287
13288echo " "
13289
13290if $test X"$quadtype" != X; then
13291
13292echo "Checking how to print 64-bit integers..." >&4
13293
13294if $test X"$sPRId64" = X -a X"$quadtype" = Xint; then
13295	$cat >try.c <<'EOCP'
13296#include <sys/types.h>
13297#include <stdio.h>
13298int main() {
13299  int q = 12345678901;
13300  printf("%ld\n", q);
13301}
13302EOCP
13303	set try
13304	if eval $compile; then
13305		yyy=`./try$exe_ext`
13306		case "$yyy" in
13307		12345678901)
13308			sPRId64='"d"'; sPRIi64='"i"'; sPRIu64='"u"';
13309                	sPRIo64='"o"'; sPRIx64='"x"'; sPRIXU64='"X"';
13310			echo "We will use %d."
13311			;;
13312		esac
13313	fi
13314fi
13315
13316if $test X"$sPRId64" = X -a X"$quadtype" = Xlong; then
13317	$cat >try.c <<'EOCP'
13318#include <sys/types.h>
13319#include <stdio.h>
13320int main() {
13321  long q = 12345678901;
13322  printf("%ld\n", q);
13323}
13324EOCP
13325	set try
13326	if eval $compile; then
13327		yyy=`./try$exe_ext`
13328		case "$yyy" in
13329		12345678901)
13330			sPRId64='"ld"'; sPRIi64='"li"'; sPRIu64='"lu"';
13331                	sPRIo64='"lo"'; sPRIx64='"lx"'; sPRIXU64='"lX"';
13332			echo "We will use %ld."
13333			;;
13334		esac
13335	fi
13336fi
13337
13338if $test X"$sPRId64" = X -a X"$i_inttypes" = X"$define" -a X"$quadtype" = Xint64_t; then
13339	$cat >try.c <<'EOCP'
13340#include <sys/types.h>
13341#include <inttypes.h>
13342#include <stdio.h>
13343int main() {
13344  int64_t q = 12345678901;
13345  printf("%" PRId64 "\n", q);
13346}
13347EOCP
13348	set try
13349	if eval $compile; then
13350		yyy=`./try$exe_ext`
13351		case "$yyy" in
13352		12345678901)
13353			sPRId64=PRId64; sPRIi64=PRIi64; sPRIu64=PRIu64;
13354                	sPRIo64=PRIo64; sPRIx64=PRIx64; sPRIXU64=PRIXU64;
13355			echo "We will use the C9X style."
13356			;;
13357		esac
13358	fi
13359fi
13360
13361if $test X"$sPRId64" = X -a X"$quadtype" = X"long long"; then
13362	$cat >try.c <<'EOCP'
13363#include <sys/types.h>
13364#include <stdio.h>
13365int main() {
13366  long long q = 12345678901LL; /* AIX cc requires the LL suffix. */
13367  printf("%lld\n", q);
13368}
13369EOCP
13370	set try
13371	if eval $compile; then
13372		yyy=`./try$exe_ext`
13373		case "$yyy" in
13374		12345678901)
13375			sPRId64='"lld"'; sPRIi64='"lli"'; sPRIu64='"llu"';
13376                	sPRIo64='"llo"'; sPRIx64='"llx"'; sPRIXU64='"llX"';
13377			echo "We will use the %lld style."
13378			;;
13379		esac
13380	fi
13381fi
13382
13383if $test X"$sPRId64" = X -a X"$quadtype" != X; then
13384	$cat >try.c <<EOCP
13385#include <sys/types.h>
13386#include <stdio.h>
13387int main() {
13388  $quadtype q = 12345678901;
13389  printf("%Ld\n", q);
13390}
13391EOCP
13392	set try
13393	if eval $compile; then
13394		yyy=`./try$exe_ext`
13395		case "$yyy" in
13396		12345678901)
13397			sPRId64='"Ld"'; sPRIi64='"Li"'; sPRIu64='"Lu"';
13398                	sPRIo64='"Lo"'; sPRIx64='"Lx"'; sPRIXU64='"LX"';
13399			echo "We will use %Ld."
13400			;;
13401		esac
13402	fi
13403fi
13404
13405if $test X"$sPRId64" = X -a X"$quadtype" != X; then
13406	$cat >try.c <<EOCP
13407#include <sys/types.h>
13408#include <stdio.h>
13409int main() {
13410  $quadtype q = 12345678901;
13411  printf("%qd\n", q);
13412}
13413EOCP
13414	set try
13415	if eval $compile; then
13416		yyy=`./try$exe_ext`
13417		case "$yyy" in
13418		12345678901)
13419			sPRId64='"qd"'; sPRIi64='"qi"'; sPRIu64='"qu"';
13420                	sPRIo64='"qo"'; sPRIx64='"qx"'; sPRIXU64='"qX"';
13421			echo "We will use %qd."
13422			;;
13423		esac
13424	fi
13425fi
13426
13427if $test X"$sPRId64" = X; then
13428	echo "Cannot figure out how to print 64-bit integers." >&4
13429fi
13430
13431$rm -f try try.*
13432
13433fi
13434
13435case "$sPRId64" in
13436'')	d_PRId64="$undef"; d_PRIi64="$undef"; d_PRIu64="$undef";
13437	d_PRIo64="$undef"; d_PRIx64="$undef"; d_PRIXU64="$undef";
13438	;;
13439*)	d_PRId64="$define"; d_PRIi64="$define"; d_PRIu64="$define";
13440	d_PRIo64="$define"; d_PRIx64="$define"; d_PRIXU64="$define";
13441	;;
13442esac
13443
13444
13445echo " "
13446$echo "Checking the format strings to be used for Perl's internal types..." >&4
13447
13448if $test X"$ivsize" = X8; then
13449	ivdformat="$sPRId64"
13450	uvuformat="$sPRIu64"
13451	uvoformat="$sPRIo64"
13452	uvxformat="$sPRIx64"
13453	uvXUformat="$sPRIXU64"
13454else
13455	if $test X"$ivsize" = X"$longsize"; then
13456		ivdformat='"ld"'
13457		uvuformat='"lu"'
13458		uvoformat='"lo"'
13459		uvxformat='"lx"'
13460		uvXUformat='"lX"'
13461	else
13462		if $test X"$ivsize" = X"$intsize"; then
13463			ivdformat='"d"'
13464			uvuformat='"u"'
13465			uvoformat='"o"'
13466			uvxformat='"x"'
13467			uvXUformat='"X"'
13468		else
13469			: far out
13470			if $test X"$ivsize" = X"$shortsize"; then
13471				ivdformat='"hd"'
13472				uvuformat='"hu"'
13473				uvoformat='"ho"'
13474				uvxformat='"hx"'
13475				uvXUformat='"hX"'
13476			fi
13477		fi
13478	fi
13479fi
13480
13481if $test X"$uselongdouble" = X"$define" -a X"$d_longdbl" = X"$define" -a X"$d_PRIgldbl" = X"$define"; then
13482	nveformat="$sPRIeldbl"
13483	nvfformat="$sPRIfldbl"
13484	nvgformat="$sPRIgldbl"
13485	nvEUformat="$sPRIEUldbl"
13486	nvFUformat="$sPRIFUldbl"
13487	nvGUformat="$sPRIGUldbl"
13488else
13489	nveformat='"e"'
13490	nvfformat='"f"'
13491	nvgformat='"g"'
13492	nvEUformat='"E"'
13493	nvFUformat='"F"'
13494	nvGUformat='"G"'
13495fi
13496
13497case "$ivdformat" in
13498'') echo "$0: Fatal: failed to find format strings, cannot continue." >& 4
13499    exit 1
13500    ;;
13501esac
13502
13503
13504echo " "
13505$echo "Checking the format string to be used for gids..." >&4
13506
13507case "$gidsign" in
13508-1)	if $test X"$gidsize" = X"$ivsize"; then
13509		gidformat="$ivdformat"
13510	else
13511		if $test X"$gidsize" = X"$longsize"; then
13512			gidformat='"ld"'
13513		else
13514			if $test X"$gidsize" = X"$intsize"; then
13515				gidformat='"d"'
13516			else
13517				if $test X"$gidsize" = X"$shortsize"; then
13518					gidformat='"hd"'
13519				fi
13520			fi
13521		fi
13522	fi
13523	;;
13524*)	if $test X"$gidsize" = X"$uvsize"; then
13525		gidformat="$uvuformat"
13526	else
13527		if $test X"$gidsize" = X"$longsize"; then
13528			gidformat='"lu"'
13529		else
13530			if $test X"$gidsize" = X"$intsize"; then
13531				gidformat='"u"'
13532			else
13533				if $test X"$gidsize" = X"$shortsize"; then
13534					gidformat='"hu"'
13535				fi
13536			fi
13537		fi
13538	fi
13539	;;
13540esac
13541
13542: see if getgroups exists
13543set getgroups d_getgrps
13544eval $inlibc
13545
13546: see if setgroups exists
13547set setgroups d_setgrps
13548eval $inlibc
13549
13550
13551: Find type of 2nd arg to 'getgroups()' and 'setgroups()'
13552echo " "
13553case "$d_getgrps$d_setgrps" in
13554*define*)
13555	case "$groupstype" in
13556	'') dflt="$gidtype" ;;
13557	*)  dflt="$groupstype" ;;
13558	esac
13559	$cat <<EOM
13560What type of pointer is the second argument to getgroups() and setgroups()?
13561Usually this is the same as group ids, $gidtype, but not always.
13562
13563EOM
13564	rp='What type pointer is the second argument to getgroups() and setgroups()?'
13565	. ./myread
13566	groupstype="$ans"
13567	;;
13568*)  groupstype="$gidtype";;
13569esac
13570
13571echo " "
13572echo "Checking if your $make program sets \$(MAKE)..." >&4
13573case "$make_set_make" in
13574'')
13575	$sed 's/^X //' > testmake.mak << 'EOF'
13576Xall:
13577X 	@echo 'maketemp="$(MAKE)"'
13578EOF
13579	case "`$make -f testmake.mak 2>/dev/null`" in
13580	*maketemp=*) make_set_make='#' ;;
13581	*)	make_set_make="MAKE=$make" ;;
13582	esac
13583	$rm -f testmake.mak
13584	;;
13585esac
13586case "$make_set_make" in
13587'#') echo "Yup, it does.";;
13588*) echo "Nope, it doesn't.";;
13589esac
13590
13591: see what type is used for mode_t
13592rp="What is the type used for file modes for system calls (e.g. fchmod())?"
13593set mode_t modetype int stdio.h sys/types.h
13594eval $typedef_ask
13595
13596: define a fucntion to check prototypes
13597$cat > protochk <<EOSH
13598$startsh
13599cc="$cc"
13600optimize="$optimize"
13601ccflags="$ccflags"
13602prototype="$prototype"
13603define="$define"
13604rm=$rm
13605EOSH
13606
13607$cat >> protochk <<'EOSH'
13608
13609$rm -f try.c
13610foo="$1"
13611shift
13612while test $# -ge 2; do
13613	case "$1" in
13614		$define) echo "#include <$2>" >> try.c ;;
13615		literal) echo "$2" >> try.c ;;
13616	esac
13617    shift 2
13618done
13619test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
13620cat >> try.c <<'EOCP'
13621#ifdef CAN_PROTOTYPE
13622#define	_(args) args
13623#else
13624#define	_(args) ()
13625#endif
13626EOCP
13627echo "$foo" >> try.c
13628echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
13629$cc $optimize $ccflags -c try.c > /dev/null 2>&1
13630status=$?
13631$rm -f try.[co]
13632exit $status
13633EOSH
13634chmod +x protochk
13635$eunicefix protochk
13636
13637: see what type is used for size_t
13638rp="What is the type used for the length parameter for string functions?"
13639set size_t sizetype 'unsigned int' stdio.h sys/types.h
13640eval $typedef_ask
13641
13642: check for type of arguments to gethostbyaddr.
13643if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
13644	case "$d_gethbyaddr" in
13645	$define)
13646		$cat <<EOM
13647
13648Checking to see what type of arguments are accepted by gethostbyaddr().
13649EOM
13650		hdrs="$define sys/types.h
13651			$d_socket sys/socket.h
13652			$i_niin netinet/in.h
13653			$i_netdb netdb.h
13654			$i_unistd unistd.h"
13655		: The first arg can 'char *' or 'void *'
13656		: The second arg is some of integral type
13657		for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
13658			for yyy in size_t long int; do
13659				case "$netdb_host_type" in
13660				'')	try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
13661					if ./protochk "$try" $hdrs; then
13662						echo "Your system accepts $xxx for the first arg."
13663						echo "...and $yyy for the second arg."
13664						netdb_host_type="$xxx"
13665						netdb_hlen_type="$yyy"
13666					fi
13667					;;
13668				esac
13669			done
13670		done
13671		: In case none of those worked, prompt the user.
13672		case "$netdb_host_type" in
13673		'')	rp='What is the type for the 1st argument to gethostbyaddr?'
13674			dflt='char *'
13675			. ./myread
13676			netdb_host_type=$ans
13677			rp='What is the type for the 2nd argument to gethostbyaddr?'
13678			dflt="$sizetype"
13679			. ./myread
13680			netdb_hlen_type=$ans
13681			;;
13682		esac
13683		;;
13684	*)	: no gethostbyaddr, so pick harmless defaults
13685		netdb_host_type='char *'
13686		netdb_hlen_type="$sizetype"
13687		;;
13688	esac
13689	# Remove the "const" if needed. -- but then we'll have a
13690	# prototype clash!
13691	# netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
13692fi
13693
13694: check for type of argument to gethostbyname.
13695if test "X$netdb_name_type" = X ; then
13696	case "$d_gethbyname" in
13697	$define)
13698		$cat <<EOM
13699
13700Checking to see what type of argument is accepted by gethostbyname().
13701EOM
13702		hdrs="$define sys/types.h
13703			$d_socket sys/socket.h
13704			$i_niin netinet/in.h
13705			$i_netdb netdb.h
13706			$i_unistd unistd.h"
13707		for xxx in "const char *" "char *"; do
13708			case "$netdb_name_type" in
13709			'')	try="extern struct hostent *gethostbyname($xxx);"
13710				if ./protochk "$try" $hdrs; then
13711					echo "Your system accepts $xxx."
13712					netdb_name_type="$xxx"
13713				fi
13714				;;
13715			esac
13716		done
13717		: In case none of those worked, prompt the user.
13718		case "$netdb_name_type" in
13719		'')	rp='What is the type for the 1st argument to gethostbyname?'
13720			dflt='char *'
13721			. ./myread
13722			netdb_name_type=$ans
13723			;;
13724		esac
13725		;;
13726	*)	: no gethostbyname, so pick harmless default
13727		netdb_name_type='char *'
13728		;;
13729	esac
13730fi
13731
13732: check for type of 1st argument to getnetbyaddr.
13733if test "X$netdb_net_type" = X ; then
13734	case "$d_getnbyaddr" in
13735	$define)
13736		$cat <<EOM
13737
13738Checking to see what type of 1st argument is accepted by getnetbyaddr().
13739EOM
13740		hdrs="$define sys/types.h
13741			$d_socket sys/socket.h
13742			$i_niin netinet/in.h
13743			$i_netdb netdb.h
13744			$i_unistd unistd.h"
13745		for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
13746			case "$netdb_net_type" in
13747			'')	try="extern struct netent *getnetbyaddr($xxx, int);"
13748				if ./protochk "$try" $hdrs; then
13749					echo "Your system accepts $xxx."
13750					netdb_net_type="$xxx"
13751				fi
13752				;;
13753			esac
13754		done
13755		: In case none of those worked, prompt the user.
13756		case "$netdb_net_type" in
13757		'')	rp='What is the type for the 1st argument to getnetbyaddr?'
13758			dflt='long'
13759			. ./myread
13760			netdb_net_type=$ans
13761			;;
13762		esac
13763		;;
13764	*)	: no getnetbyaddr, so pick harmless default
13765		netdb_net_type='long'
13766		;;
13767	esac
13768fi
13769: locate the preferred pager for this system
13770case "$pager" in
13771'')
13772	dflt=''
13773	case "$pg" in
13774	/*) dflt=$pg;;
13775	[a-zA-Z]:/*) dflt=$pg;;
13776	esac
13777	case "$more" in
13778	/*) dflt=$more;;
13779	[a-zA-Z]:/*) dflt=$more;;
13780	esac
13781	case "$less" in
13782	/*) dflt=$less;;
13783	[a-zA-Z]:/*) dflt=$less;;
13784	esac
13785	case "$dflt" in
13786	'') dflt=/usr/ucb/more;;
13787	esac
13788	;;
13789*) dflt="$pager";;
13790esac
13791echo " "
13792fn=f/
13793rp='What pager is used on your system?'
13794. ./getfile
13795pager="$ans"
13796
13797: see what type pids are declared as in the kernel
13798rp="What is the type of process ids on this system?"
13799set pid_t pidtype int stdio.h sys/types.h
13800eval $typedef_ask
13801
13802: Find earliest binary compatible site_perl subdirectory perl can use.
13803case "$bincompat5005" in
13804"$define") xs_apiversion='5.005' ;;
13805*) xs_apiversion=$version ;;   # The current site_perl version.
13806esac
13807: Find earliest pure perl site_perl subdirectory perl can use.
13808: The versioned directories started at 5.005.
13809pm_apiversion='5.005'
13810
13811: check for length of pointer
13812echo " "
13813case "$ptrsize" in
13814'')
13815	echo "Checking to see how big your pointers are..." >&4
13816	if test "$voidflags" -gt 7; then
13817		echo '#define VOID_PTR char *' > try.c
13818	else
13819		echo '#define VOID_PTR void *' > try.c
13820	fi
13821	$cat >>try.c <<'EOCP'
13822#include <stdio.h>
13823int main()
13824{
13825    printf("%d\n", (int)sizeof(VOID_PTR));
13826    exit(0);
13827}
13828EOCP
13829	set try
13830	if eval $compile_ok; then
13831		ptrsize=`./try`
13832		echo "Your pointers are $ptrsize bytes long."
13833	else
13834		dflt='4'
13835		echo "(I can't seem to compile the test program.  Guessing...)" >&4
13836		rp="What is the size of a pointer (in bytes)?"
13837		. ./myread
13838		ptrsize="$ans"
13839	fi
13840	;;
13841esac
13842$rm -f try.c try
13843
13844: see if ar generates random libraries by itself
13845echo " "
13846echo "Checking how to generate random libraries on your machine..." >&4
13847echo 'int bar1() { return bar2(); }' > bar1.c
13848echo 'int bar2() { return 2; }' > bar2.c
13849$cat > foo.c <<'EOP'
13850int main() { printf("%d\n", bar1()); exit(0); }
13851EOP
13852$cc $ccflags -c bar1.c >/dev/null 2>&1
13853$cc $ccflags -c bar2.c >/dev/null 2>&1
13854$cc $ccflags -c foo.c >/dev/null 2>&1
13855$ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
13856if $cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
13857	./foobar >/dev/null 2>&1; then
13858	echo "$ar appears to generate random libraries itself."
13859	orderlib=false
13860	ranlib=":"
13861elif $ar ts bar$_a >/dev/null 2>&1 &&
13862	$cc -o foobar $ccflags $ldflags foo$_o bar$_a $libs > /dev/null 2>&1 &&
13863	./foobar >/dev/null 2>&1; then
13864		echo "a table of contents needs to be added with '$ar ts'."
13865		orderlib=false
13866		ranlib="$ar ts"
13867else
13868	case "$ranlib" in
13869	:) ranlib='';;
13870	'')
13871		ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
13872		$test -f $ranlib || ranlib=''
13873		;;
13874	esac
13875	if $test -n "$ranlib"; then
13876		echo "your system has '$ranlib'; we'll use that."
13877		orderlib=false
13878	else
13879		echo "your system doesn't seem to support random libraries"
13880		echo "so we'll use lorder and tsort to order the libraries."
13881		orderlib=true
13882		ranlib=":"
13883	fi
13884fi
13885$rm -f foo* bar*
13886
13887: check for type of arguments to select.
13888case "$selecttype" in
13889'') case "$d_select" in
13890	$define)
13891		echo " "
13892		$cat <<EOM
13893Checking to see what type of arguments are accepted by select().
13894EOM
13895		hdrs="$define sys/types.h
13896			$i_systime sys/time.h
13897			$i_sysselct sys/select.h
13898			$d_socket sys/socket.h"
13899		: The first arg can be int, unsigned, or size_t
13900		: The last arg may or may not be 'const'
13901		val=''
13902		: void pointer has been seen but using that
13903		: breaks the selectminbits test
13904		for xxx in 'fd_set *' 'int *'; do
13905			for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
13906				for tmo in 'struct timeval *' 'const struct timeval *'; do
13907					case "$val" in
13908					'')	try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
13909						if ./protochk "$try" $hdrs; then
13910							echo "Your system accepts $xxx."
13911							val="$xxx"
13912						fi
13913						;;
13914					esac
13915				done
13916			done
13917		done
13918		case "$val" in
13919		'')	rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
13920			case "$d_fd_set" in
13921				$define) dflt="fd_set *" ;;
13922				*)		dflt="int *" ;;
13923			esac
13924			. ./myread
13925			val=$ans
13926			;;
13927		esac
13928		selecttype="$val"
13929		;;
13930	*)	: no select, so pick a harmless default
13931		selecttype='int *'
13932		;;
13933	esac
13934	;;
13935esac
13936
13937: check for the select 'width'
13938case "$selectminbits" in
13939'') case "$d_select" in
13940	$define)
13941		$cat <<EOM
13942
13943Checking to see on how many bits at a time your select() operates...
13944EOM
13945		$cat >try.c <<EOCP
13946#include <sys/types.h>
13947#$i_time I_TIME
13948#$i_systime I_SYS_TIME
13949#$i_systimek I_SYS_TIME_KERNEL
13950#ifdef I_TIME
13951#   include <time.h>
13952#endif
13953#ifdef I_SYS_TIME
13954#   ifdef I_SYS_TIME_KERNEL
13955#	define KERNEL
13956#   endif
13957#   include <sys/time.h>
13958#   ifdef I_SYS_TIME_KERNEL
13959#	undef KERNEL
13960#   endif
13961#endif
13962#$i_sysselct I_SYS_SELECT
13963#ifdef I_SYS_SELECT
13964#include <sys/select.h>
13965#endif
13966#$d_socket HAS_SOCKET
13967#ifdef HAS_SOCKET
13968#   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
13969#endif
13970#include <stdio.h>
13971$selecttype b;
13972#define S sizeof(*(b))
13973#define MINBITS	64
13974#define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
13975#define NBITS  (NBYTES * 8)
13976int main() {
13977    char s[NBYTES];
13978    struct timeval t;
13979    int i;
13980    FILE* fp;
13981    int fd;
13982
13983    fclose(stdin);
13984    fp = fopen("try.c", "r");
13985    if (fp == 0)
13986      exit(1);
13987    fd = fileno(fp);
13988    if (fd < 0)
13989      exit(2);
13990    b = ($selecttype)s;
13991    for (i = 0; i < NBITS; i++)
13992	FD_SET(i, b);
13993    t.tv_sec  = 0;
13994    t.tv_usec = 0;
13995    select(fd + 1, b, 0, 0, &t);
13996    for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
13997    printf("%d\n", i + 1);
13998    return 0;
13999}
14000EOCP
14001		set try
14002		if eval $compile_ok; then
14003			selectminbits=`./try`
14004			case "$selectminbits" in
14005			'')	cat >&4 <<EOM
14006Cannot figure out on how many bits at a time your select() operates.
14007I'll play safe and guess it is 32 bits.
14008EOM
14009				selectminbits=32
14010				bits="32 bits"
14011				;;
14012			1)	bits="1 bit" ;;
14013			*)	bits="$selectminbits bits" ;;
14014			esac
14015			echo "Your select() operates on $bits at a time." >&4
14016		else
14017			rp='What is the minimum number of bits your select() operates on?'
14018			case "$byteorder" in
14019			1234|12345678)	dflt=32 ;;
14020			*)		dflt=1	;;
14021			esac
14022			. ./myread
14023			val=$ans
14024			selectminbits="$val"
14025		fi
14026		$rm -f try.* try
14027		;;
14028	*)	: no select, so pick a harmless default
14029		selectminbits='32'
14030		;;
14031	esac
14032	;;
14033esac
14034
14035: Trace out the files included by signal.h, then look for SIGxxx names.
14036: Remove SIGARRAYSIZE used by HPUX.
14037: Remove SIGSTKSIZE used by Linux.
14038: Remove SIGSTKSZ used by Posix.
14039: Remove SIGTYP void lines used by OS2.
14040: Some cpps, like os390, dont give the file name anywhere
14041if [ "X$fieldn" = X ]; then
14042	: Just make some guesses.  We check them later.
14043	xxx='/usr/include/signal.h /usr/include/sys/signal.h'
14044else
14045	xxx=`echo '#include <signal.h>' |
14046	$cppstdin $cppminus $cppflags 2>/dev/null |
14047	$grep '^[ 	]*#.*include' |
14048	$awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
14049fi
14050: Check this list of files to be sure we have parsed the cpp output ok.
14051: This will also avoid potentially non-existent files, such
14052: as ../foo/bar.h
14053xxxfiles=''
14054for xx in $xxx /dev/null ; do
14055	$test -f "$xx" && xxxfiles="$xxxfiles $xx"
14056done
14057: If we have found no files, at least try signal.h
14058case "$xxxfiles" in
14059'')	xxxfiles=`./findhdr signal.h` ;;
14060esac
14061xxx=`awk '
14062$1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
14063	print substr($2, 4, 20)
14064}
14065$1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
14066	print substr($3, 4, 20)
14067}' $xxxfiles`
14068: Append some common names just in case the awk scan failed.
14069xxx="$xxx ABRT ALRM BUS CANCEL CHLD CLD CONT DIL EMT FPE"
14070xxx="$xxx FREEZE HUP ILL INT IO IOT KILL LOST LWP PHONE"
14071xxx="$xxx PIPE POLL PROF PWR QUIT RTMAX RTMIN SEGV STKFLT STOP"
14072xxx="$xxx SYS TERM THAW TRAP TSTP TTIN TTOU URG USR1 USR2"
14073xxx="$xxx USR3 USR4 VTALRM WAITING WINCH WIND WINDOW XCPU XFSZ"
14074
14075: generate a few handy files for later
14076$cat > signal.c <<'EOCP'
14077#include <sys/types.h>
14078#include <signal.h>
14079#include <stdio.h>
14080int main() {
14081
14082/* Strange style to avoid deeply-nested #if/#else/#endif */
14083#ifndef NSIG
14084#  ifdef _NSIG
14085#    define NSIG (_NSIG)
14086#  endif
14087#endif
14088
14089#ifndef NSIG
14090#  ifdef SIGMAX
14091#    define NSIG (SIGMAX+1)
14092#  endif
14093#endif
14094
14095#ifndef NSIG
14096#  ifdef SIG_MAX
14097#    define NSIG (SIG_MAX+1)
14098#  endif
14099#endif
14100
14101#ifndef NSIG
14102#  ifdef MAXSIG
14103#    define NSIG (MAXSIG+1)
14104#  endif
14105#endif
14106
14107#ifndef NSIG
14108#  ifdef MAX_SIG
14109#    define NSIG (MAX_SIG+1)
14110#  endif
14111#endif
14112
14113#ifndef NSIG
14114#  ifdef SIGARRAYSIZE
14115#    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
14116#  endif
14117#endif
14118
14119#ifndef NSIG
14120#  ifdef _sys_nsig
14121#    define NSIG (_sys_nsig) /* Solaris 2.5 */
14122#  endif
14123#endif
14124
14125/* Default to some arbitrary number that's big enough to get most
14126   of the common signals.
14127*/
14128#ifndef NSIG
14129#    define NSIG 50
14130#endif
14131
14132printf("NSIG %d\n", NSIG);
14133
14134#ifndef JUST_NSIG
14135
14136EOCP
14137
14138echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
14139{
14140	printf "#ifdef SIG"; printf $1; printf "\n"
14141	printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
14142	printf $1; printf ");\n"
14143	printf "#endif\n"
14144}
14145END {
14146	printf "#endif /* JUST_NSIG */\n";
14147	printf "exit(0);\n}\n";
14148}
14149' >>signal.c
14150$cat >signal.awk <<'EOP'
14151BEGIN { ndups = 0 }
14152$1 ~ /^NSIG$/ { nsig = $2 }
14153($1 !~ /^NSIG$/) && (NF == 2) {
14154    if ($2 > maxsig) { maxsig = $2 }
14155    if (sig_name[$2]) {
14156	dup_name[ndups] = $1
14157	dup_num[ndups] = $2
14158	ndups++
14159    }
14160    else {
14161	sig_name[$2] = $1
14162	sig_num[$2] = $2
14163    }
14164}
14165END {
14166    if (nsig == 0) {
14167    	nsig = maxsig + 1
14168    }
14169    printf("NSIG %d\n", nsig);
14170    for (n = 1; n < nsig; n++) {
14171 	if (sig_name[n]) {
14172 	    printf("%s %d\n", sig_name[n], sig_num[n])
14173	}
14174 	else {
14175 	    printf("NUM%d %d\n", n, n)
14176 	}
14177    }
14178    for (n = 0; n < ndups; n++) {
14179 	printf("%s %d\n", dup_name[n], dup_num[n])
14180    }
14181}
14182EOP
14183$cat >signal_cmd <<EOS
14184$startsh
14185if $test -s signal.lst; then
14186    echo "Using your existing signal.lst file"
14187	exit 0
14188fi
14189xxx="$xxx"
14190EOS
14191$cat >>signal_cmd <<'EOS'
14192
14193set signal
14194if eval $compile_ok; then
14195	./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
14196else
14197	echo "(I can't seem be able to compile the whole test program)" >&4
14198	echo "(I'll try it in little pieces.)" >&4
14199	set signal -DJUST_NSIG
14200	if eval $compile_ok; then
14201		./signal$_exe > signal.nsg
14202		$cat signal.nsg
14203	else
14204		echo "I can't seem to figure out how many signals you have." >&4
14205		echo "Guessing 50." >&4
14206		echo 'NSIG 50' > signal.nsg
14207	fi
14208	: Now look at all the signal names, one at a time.
14209	for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
14210		$cat > signal.c <<EOCP
14211#include <sys/types.h>
14212#include <signal.h>
14213#include <stdio.h>
14214int main() {
14215printf("$xx %d\n", SIG${xx});
14216return 0;
14217}
14218EOCP
14219		set signal
14220		if eval $compile; then
14221			echo "SIG${xx} found."
14222			./signal$_exe  >> signal.ls1
14223		else
14224			echo "SIG${xx} NOT found."
14225		fi
14226	done
14227	if $test -s signal.ls1; then
14228		$cat signal.nsg signal.ls1 |
14229			$sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
14230	fi
14231
14232fi
14233if $test -s signal.lst; then
14234	:
14235else
14236	echo "(AAK! I can't compile the test programs -- Guessing)" >&4
14237	echo 'kill -l' >signal
14238	set X `csh -f <signal`
14239	$rm -f signal
14240	shift
14241	case $# in
14242	0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
14243	esac
14244	echo $@ | $tr ' ' $trnl | \
14245 	    $awk '{ printf "%s %d\n", $1, ++s; }
14246 		  END { printf "NSIG %d\n", ++s }' >signal.lst
14247fi
14248$rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
14249EOS
14250chmod a+x signal_cmd
14251$eunicefix signal_cmd
14252
14253: generate list of signal names
14254echo " "
14255case "$sig_name_init" in
14256'') doinit=yes ;;
14257*)  case "$sig_num_init" in
14258    ''|*,*) doinit=yes ;;
14259    esac ;;
14260esac
14261case "$doinit" in
14262yes)
14263	echo "Generating a list of signal names and numbers..." >&4
14264	. ./signal_cmd
14265 	sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
14266 	sig_name=`$awk 'BEGIN { printf "ZERO " }
14267 			!/^NSIG/ { printf "%s ", $1 }' signal.lst`
14268 	sig_num=`$awk  'BEGIN { printf "0 " }
14269 			!/^NSIG/ { printf "%d ", $2 }' signal.lst`
14270 	sig_name_init=`$awk 'BEGIN	{ printf "\"ZERO\", " }
14271 			     !/^NSIG/	{ printf "\"%s\", ", $1 }
14272 			     END	{ printf "0\n" }' signal.lst`
14273 	sig_num_init=`$awk  'BEGIN	{ printf "0, " }
14274 			     !/^NSIG/	{ printf "%d, ", $2}
14275 			     END	{ printf "0\n"}' signal.lst`
14276	;;
14277esac
14278echo "The following $sig_count signals are available:"
14279echo " "
14280echo $sig_name | $awk \
14281'BEGIN { linelen = 0 }
14282{
14283	for (i = 1; i <= NF; i++) {
14284		name = "SIG" $i " "
14285		linelen = linelen + length(name)
14286		if (linelen > 70) {
14287			printf "\n"
14288			linelen = length(name)
14289		}
14290		printf "%s", name
14291	}
14292	printf "\n"
14293}'
14294$rm -f signal signal.c signal.awk signal.lst signal_cmd
14295
14296echo " "
14297case "$sizetype" in
14298*_t) zzz="$sizetype"	;;
14299*)   zzz="filesize"	;;
14300esac
14301echo "Checking the size of $zzz..." >&4
14302cat > try.c <<EOCP
14303#include <sys/types.h>
14304#include <stdio.h>
14305int main() {
14306    printf("%d\n", (int)sizeof($sizetype));
14307    exit(0);
14308}
14309EOCP
14310set try
14311if eval $compile_ok; then
14312	yyy=`./try`
14313	case "$yyy" in
14314	'')	sizesize=4
14315		echo "(I can't execute the test program--guessing $sizesize.)" >&4
14316		;;
14317	*)	sizesize=$yyy
14318		echo "Your $zzz size is $sizesize bytes."
14319		;;
14320	esac
14321else
14322	sizesize=4
14323	echo "(I can't compile the test program--guessing $sizesize.)" >&4
14324fi
14325
14326
14327: check for socklen_t
14328echo " "
14329echo "Checking to see if you have socklen_t..." >&4
14330$cat >try.c <<EOCP
14331#include <sys/types.h>
14332#$d_socket HAS_SOCKET
14333#ifdef HAS_SOCKET
14334#include <sys/socket.h>
14335#endif
14336int main() { socklen_t x = 16; }
14337EOCP
14338set try
14339if eval $compile; then
14340	val="$define"
14341	echo "You have socklen_t."
14342else
14343	val="$undef"
14344	echo "You do not have socklen_t."
14345	case "$sizetype" in
14346	size_t) echo "(You do have size_t, that might work. Some people are happy with just an int.)" ;;
14347	esac
14348fi
14349$rm -f try try.*
14350set d_socklen_t
14351eval $setvar
14352
14353: see if this is a socks.h system
14354set socks.h i_socks
14355eval $inhdr
14356
14357: check for type of the size argument to socket calls
14358case "$d_socket" in
14359"$define")
14360	$cat <<EOM
14361
14362Checking to see what type is the last argument of accept().
14363EOM
14364	yyy=''
14365	case "$d_socklen_t" in
14366	"$define") yyy="$yyy socklen_t"
14367	esac
14368	yyy="$yyy $sizetype int long unsigned"
14369	for xxx in $yyy; do
14370		case "$socksizetype" in
14371		'')	try="extern int accept(int, struct sockaddr *, $xxx *);"
14372			case "$usesocks" in
14373			"$define")
14374				if ./protochk "$try" $i_systypes sys/types.h $d_socket sys/socket.h literal '#define INCLUDE_PROTOTYPES' $i_socks socks.h.; then
14375					echo "Your system accepts '$xxx *' for the last argument of accept()."
14376					socksizetype="$xxx"
14377				fi
14378				;;
14379			*)	if ./protochk "$try"  $i_systypes sys/types.h $d_socket sys/socket.h; then
14380					echo "Your system accepts '$xxx *' for the last argument of accept()."
14381					socksizetype="$xxx"
14382				fi
14383				;;
14384			esac
14385			;;
14386		esac
14387	done
14388: In case none of those worked, prompt the user.
14389	case "$socksizetype" in
14390	'')	rp='What is the type for socket address structure sizes?'
14391		dflt='int'
14392		. ./myread
14393		socksizetype=$ans
14394		;;
14395	esac
14396	;;
14397*)	: no sockets, so pick relatively harmless default
14398	socksizetype='int'
14399	;;
14400esac
14401
14402: see what type is used for signed size_t
14403set ssize_t ssizetype int stdio.h sys/types.h
14404eval $typedef
14405dflt="$ssizetype"
14406$cat > ssize.c <<EOM
14407#include <stdio.h>
14408#include <sys/types.h>
14409#define Size_t $sizetype
14410#define SSize_t $dflt
14411int main()
14412{
14413	if (sizeof(Size_t) == sizeof(SSize_t))
14414		printf("$dflt\n");
14415	else if (sizeof(Size_t) == sizeof(int))
14416		printf("int\n");
14417	else 
14418		printf("long\n");
14419	exit(0);
14420}
14421EOM
14422echo " "
14423set ssize
14424if eval $compile_ok && ./ssize > /dev/null; then
14425	ssizetype=`./ssize`
14426	echo "I'll be using $ssizetype for functions returning a byte count." >&4
14427else
14428	$cat >&4 <<EOM
14429Help! I can't compile and run the ssize_t test program: please enlighten me!
14430(This is probably a misconfiguration in your system or libraries, and
14431you really ought to fix it.  Still, I'll try anyway.)
14432
14433I need a type that is the same size as $sizetype, but is guaranteed to
14434be signed.  Common values are ssize_t, int and long.
14435
14436EOM
14437	rp="What signed type is the same size as $sizetype?"
14438	. ./myread
14439	ssizetype="$ans"
14440fi
14441$rm -f ssize ssize.*
14442
14443: see what type of char stdio uses.
14444echo " "
14445echo '#include <stdio.h>' | $cppstdin $cppminus > stdioh
14446if $contains 'unsigned.*char.*_ptr;' stdioh >/dev/null 2>&1 ; then
14447	echo "Your stdio uses unsigned chars." >&4
14448	stdchar="unsigned char"
14449else
14450	echo "Your stdio uses signed chars." >&4
14451	stdchar="char"
14452fi
14453$rm -f stdioh
14454
14455: see if time exists
14456echo " "
14457if test "X$d_time" = X -o X"$timetype" = X; then
14458    if set time val -f d_time; eval $csym; $val; then
14459		echo 'time() found.' >&4
14460		val="$define"
14461		rp="What is the type returned by time() on this system?"
14462		set time_t timetype long stdio.h sys/types.h
14463		eval $typedef_ask
14464    else
14465		echo 'time() not found, hope that will do.' >&4
14466		val="$undef"
14467		timetype='int';
14468    fi
14469    set d_time
14470    eval $setvar
14471fi
14472
14473: see what type uids are declared as in the kernel
14474echo " "
14475echo "Looking for the type for user ids returned by getuid()."
14476set uid_t uidtype xxx stdio.h sys/types.h
14477eval $typedef
14478case "$uidtype" in
14479xxx)
14480	xxx=`./findhdr sys/user.h`
14481	set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
14482	case $1 in
14483	unsigned) dflt="$1 $2" ;;
14484	*) dflt="$1" ;;
14485	esac
14486	;;
14487*) dflt="$uidtype";;
14488esac
14489case "$uidtype" in
14490uid_t)	echo "uid_t found." ;;
14491*)	rp="What is the type for user ids returned by getuid()?"
14492	. ./myread
14493	uidtype="$ans"
14494	;;
14495esac
14496
14497echo " "
14498case "$uidtype" in
14499*_t) zzz="$uidtype"	;;
14500*)   zzz="uid"		;;
14501esac
14502echo "Checking the size of $zzz..." >&4
14503cat > try.c <<EOCP
14504#include <sys/types.h>
14505#include <stdio.h>
14506int main() {
14507    printf("%d\n", (int)sizeof($uidtype));
14508    exit(0);
14509}
14510EOCP
14511set try
14512if eval $compile_ok; then
14513	yyy=`./try`
14514	case "$yyy" in
14515	'')	uidsize=4
14516		echo "(I can't execute the test program--guessing $uidsize.)" >&4
14517		;;
14518	*)	uidsize=$yyy
14519		echo "Your $zzz is $uidsize bytes long."
14520		;;
14521	esac
14522else
14523	uidsize=4
14524	echo "(I can't compile the test program--guessing $uidsize.)" >&4
14525fi
14526
14527echo " "
14528case "$uidtype" in
14529*_t) zzz="$uidtype"	;;
14530*)   zzz="uid"		;;
14531esac
14532echo "Checking the sign of $zzz..." >&4
14533cat > try.c <<EOCP
14534#include <sys/types.h>
14535#include <stdio.h>
14536int main() {
14537	$uidtype foo = -1;
14538	if (foo < 0)
14539		printf("-1\n");
14540	else
14541		printf("1\n");
14542}
14543EOCP
14544set try
14545if eval $compile; then
14546	yyy=`./try`
14547	case "$yyy" in
14548	'')	uidsign=1
14549		echo "(I can't execute the test program--guessing unsigned.)" >&4
14550		;;
14551	*)	uidsign=$yyy
14552		case "$uidsign" in
14553		 1) echo "Your $zzz is unsigned." ;;
14554		-1) echo "Your $zzz is signed."   ;;
14555		esac
14556		;;
14557	esac
14558else
14559	uidsign=1
14560	echo "(I can't compile the test program--guessing unsigned.)" >&4
14561fi
14562
14563
14564
14565echo " "
14566$echo "Checking the format string to be used for uids..." >&4
14567
14568case "$uidsign" in
14569-1)	if $test X"$uidsize" = X"$ivsize"; then
14570		uidformat="$ivdformat"
14571	else
14572		if $test X"$uidsize" = X"$longsize"; then
14573			uidformat='"ld"'
14574		else
14575			if $test X"$uidsize" = X"$intsize"; then
14576				uidformat='"d"'
14577			else
14578				if $test X"$uidsize" = X"$shortsize"; then
14579					uidformat='"hd"'
14580				fi
14581			fi
14582		fi
14583	fi
14584	;;
14585*)	if $test X"$uidsize" = X"$uvsize"; then
14586		uidformat="$uvuformat"
14587	else
14588		if $test X"$uidsize" = X"$longsize"; then
14589			uidformat='"lu"'
14590		else
14591			if $test X"$uidsize" = X"$intsize"; then
14592				uidformat='"u"'
14593			else
14594				if $test X"$uidsize" = X"$shortsize"; then
14595					uidformat='"hu"'
14596				fi
14597			fi
14598		fi
14599	fi
14600	;;
14601esac
14602
14603: determine compiler compiler
14604case "$yacc" in
14605'')
14606	dflt=yacc;;
14607*)
14608	dflt="$yacc";;
14609esac
14610echo " "
14611comp='yacc'
14612if $test -f "$byacc"; then
14613	dflt="$byacc"
14614	comp="byacc or $comp"
14615fi
14616if $test -f "$bison"; then
14617	comp="$comp or bison -y"
14618fi
14619rp="Which compiler compiler ($comp) shall I use?"
14620. ./myread
14621yacc="$ans"
14622case "$yacc" in
14623*bis*)
14624	case "$yacc" in
14625	*-y*) ;;
14626	*)
14627		yacc="$yacc -y"
14628		echo "(Adding -y option to bison to get yacc-compatible behaviour.)"
14629		;;
14630	esac
14631	;;
14632esac
14633
14634: see if dbm.h is available
14635: see if dbmclose exists
14636set dbmclose d_dbmclose
14637eval $inlibc
14638
14639case "$d_dbmclose" in
14640$define)
14641	set dbm.h i_dbm
14642	eval $inhdr
14643	case "$i_dbm" in
14644	$define)
14645		val="$undef"
14646		set i_rpcsvcdbm
14647		eval $setvar
14648		;;
14649	*)	set rpcsvc/dbm.h i_rpcsvcdbm
14650		eval $inhdr
14651		;;
14652	esac
14653	;;
14654*)	echo "We won't be including <dbm.h>"
14655	val="$undef"
14656	set i_dbm
14657	eval $setvar
14658	val="$undef"
14659	set i_rpcsvcdbm
14660	eval $setvar
14661	;;
14662esac
14663
14664: see if this is a sys/file.h system
14665val=''
14666set sys/file.h val
14667eval $inhdr
14668
14669: do we need to include sys/file.h ?
14670case "$val" in
14671"$define")
14672	echo " "
14673	if $h_sysfile; then
14674		val="$define"
14675		echo "We'll be including <sys/file.h>." >&4
14676	else
14677		val="$undef"
14678		echo "We won't be including <sys/file.h>." >&4
14679	fi
14680	;;
14681*)
14682	h_sysfile=false
14683	;;
14684esac
14685set i_sysfile
14686eval $setvar
14687
14688: see if fcntl.h is there
14689val=''
14690set fcntl.h val
14691eval $inhdr
14692
14693: see if we can include fcntl.h
14694case "$val" in
14695"$define")
14696	echo " "
14697	if $h_fcntl; then
14698		val="$define"
14699		echo "We'll be including <fcntl.h>." >&4
14700	else
14701		val="$undef"
14702		if $h_sysfile; then
14703	echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
14704		else
14705			echo "We won't be including <fcntl.h>." >&4
14706		fi
14707	fi
14708	;;
14709*)
14710	h_fcntl=false
14711	val="$undef"
14712	;;
14713esac
14714set i_fcntl
14715eval $setvar
14716
14717: see if this is a iconv.h system
14718set iconv.h i_iconv
14719eval $inhdr
14720
14721: see if this is a ieeefp.h system
14722set ieeefp.h i_ieeefp
14723eval $inhdr
14724
14725: see if this is a libutil.h system
14726set libutil.h i_libutil
14727eval $inhdr
14728
14729: see if locale.h is available
14730set locale.h i_locale
14731eval $inhdr
14732
14733: see if mach cthreads are available
14734if test "X$usethreads" = "X$define"; then
14735	set mach/cthreads.h i_machcthr
14736	eval $inhdr
14737else
14738	i_machcthr="$undef"
14739fi
14740
14741
14742
14743: see if this is a math.h system
14744set math.h i_math
14745eval $inhdr
14746
14747: see if this is a mntent.h system
14748set mntent.h i_mntent
14749eval $inhdr
14750
14751: see if ndbm.h is available
14752set ndbm.h t_ndbm
14753eval $inhdr
14754case "$t_ndbm" in
14755$define)
14756	: see if dbm_open exists
14757	set dbm_open d_dbm_open
14758	eval $inlibc
14759	case "$d_dbm_open" in
14760	$undef)
14761		t_ndbm="$undef"
14762		echo "We won't be including <ndbm.h>"
14763		;;
14764	esac
14765	;;
14766esac
14767val="$t_ndbm"
14768set i_ndbm
14769eval $setvar
14770
14771: see if net/errno.h is available
14772val=''
14773set net/errno.h val
14774eval $inhdr
14775
14776: Unfortunately, it causes problems on some systems.  Arrgh.
14777case "$val" in
14778$define)
14779	cat > try.c <<'EOM'
14780#include <stdio.h>
14781#include <errno.h>
14782#include <net/errno.h>
14783int func()
14784{
14785	return ENOTSOCK;
14786}
14787EOM
14788	if $cc $ccflags -c try.c >/dev/null 2>&1; then
14789		echo "We'll be including <net/errno.h>." >&4
14790	else
14791		echo "We won't be including <net/errno.h>." >&4
14792		val="$undef"
14793	fi
14794	$rm -f try.* try
14795	;;
14796esac
14797set i_neterrno
14798eval $setvar
14799
14800: see if netinet/tcp.h is available
14801set netinet/tcp.h i_netinettcp
14802eval $inhdr
14803
14804: see if this is a poll.h system
14805set poll.h i_poll
14806eval $inhdr
14807
14808: see if this is a prot.h system
14809set prot.h i_prot
14810eval $inhdr
14811
14812echo " "
14813$echo "Guessing which symbols your C compiler and preprocessor define..." >&4
14814$cat <<'EOSH' > Cppsym.know
14815a29k ABI64 aegis AES_SOURCE AIX AIX32 AIX370
14816AIX41 AIX42 AIX43 AIX_SOURCE aixpc ALL_SOURCE
14817alliant alpha am29000 AM29000 AMD64 amiga AMIGAOS AMIX
14818ansi ANSI_C_SOURCE apollo ardent ARM32 atarist att386 att3b
14819BeOS BIG_ENDIAN BIT_MSF bsd BSD bsd43 bsd4_2 bsd4_3 BSD4_3 bsd4_4
14820BSD_4_3 BSD_4_4 BSD_NET2 BSD_TIME BSD_TYPES BSDCOMPAT bsdi
14821bull c cadmus clipper CMU COFF COMPILER_VERSION
14822concurrent convex cpu cray CRAY CRAYMPP ctix CX_UX
14823CYGWIN DGUX DGUX_SOURCE DJGPP dmert DOLPHIN DPX2 DSO
14824Dynix DynixPTX ELF encore EPI EXTENSIONS FILE_OFFSET_BITS
14825FreeBSD GCC_NEW_VARARGS gcos gcx gimpel
14826GNU_SOURCE GNUC GNUC_MINOR GO32 gould GOULD_PN
14827H3050R H3050RX hbullx20 hcx host_mips
14828hp200 hp300 hp700 HP700 hp800 hp9000
14829hp9000s200 hp9000s300 hp9000s400 hp9000s500
14830hp9000s700 hp9000s800 hp9k8 hp_osf hppa hpux HPUX_SOURCE
14831i186 i286 i386 i486 i586 i686 i8086 i80960 i860 I960
14832IA64 iAPX286 ibm ibm032 ibmesa IBMR2 ibmrt ILP32 ILP64
14833INLINE_INTRINSICS INTRINSICS INT64 interdata is68k ksr1
14834LANGUAGE_C LARGE_FILE_API LARGEFILE64_SOURCE
14835LARGEFILE_SOURCE LFS64_LARGEFILE LFS_LARGEFILE
14836Linux LITTLE_ENDIAN LONG64 LONG_DOUBLE LONG_LONG
14837LONGDOUBLE LONGLONG LP64 luna luna88k Lynx
14838M68000 m68k m88100 m88k M88KBCS_TARGET M_COFF
14839M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM M_SYS3
14840M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX MACH machine MachTen
14841MATH_HAS_NO_SIDE_EFFECTS
14842mc300 mc500 mc68000 mc68010 mc68020 mc68030 mc68040
14843mc68060 mc68k mc68k32 mc700 mc88000 mc88100 merlin
14844mert MiNT mips MIPS_FPSET MIPS_ISA MIPS_SIM MIPS_SZINT
14845MIPS_SZLONG MIPS_SZPTR MIPSEB MIPSEL MODERN_C motorola
14846mpeix MSDOS MTXINU MULTIMAX mvs MVS n16 ncl_el ncl_mr
14847NetBSD news1500 news1700 news1800 news1900 news3700
14848news700 news800 news900 NeXT NLS nonstopux ns16000 ns32000
14849ns32016 ns32332 ns32k nsc32000
14850OCS88 OEMVS OpenBSD os OS2 OS390 osf OSF1 OSF_SOURCE
14851pa_risc PA_RISC1_1 PA_RISC2_0 PARAGON parisc
14852pc532 pdp11 PGC PIC plexus PORTAR posix
14853POSIX1B_SOURCE POSIX2_SOURCE POSIX4_SOURCE
14854POSIX_C_SOURCE POSIX_SOURCE POWER
14855PROTOTYPES PWB pyr QNX R3000 REENTRANT RES Rhapsody RISC6000
14856riscix riscos RT S390 SA110 scs SCO sequent sgi SGI_SOURCE SH3 sinix
14857SIZE_INT SIZE_LONG SIZE_PTR SOCKET_SOURCE SOCKETS_SOURCE
14858sony sony_news sonyrisc sparc sparclite spectrum
14859stardent stdc STDC_EXT stratos sun sun3 sun386
14860Sun386i svr3 svr4 SVR4_2 SVR4_SOURCE svr5
14861SX system SYSTYPE_BSD SYSTYPE_BSD43 SYSTYPE_BSD44
14862SYSTYPE_SVR4 SYSTYPE_SVR5 SYSTYPE_SYSV SYSV SYSV3 SYSV4 SYSV5
14863sysV68 sysV88 Tek4132 Tek4300 titan
14864TM3200 TM5400 TM5600
14865tower tower32 tower32_200 tower32_600 tower32_700
14866tower32_800 tower32_850 tss
14867u370 u3b u3b2 u3b20 u3b200 u3b20d u3b5
14868ultrix UMAXV UnicomPBB UnicomPBD UNICOS UNICOSMK
14869unix UNIX95 UNIX99 unixpc unos USGr4 USGr4_2
14870Utek UTek UTS UWIN uxpm uxps vax venix VMESA vms xenix Xenix286
14871XOPEN_SOURCE XOPEN_SOURCE_EXTENDED XPG2 XPG2_EXTENDED
14872XPG3 XPG3_EXTENDED XPG4 XPG4_EXTENDED
14873z8000
14874EOSH
14875# Maybe put other stuff here too.
14876cat <<EOSH >>Cppsym.know
14877$osname
14878EOSH
14879./tr '[a-z]' '[A-Z]' < Cppsym.know > Cppsym.a
14880./tr '[A-Z]' '[a-z]' < Cppsym.know > Cppsym.b
14881$cat Cppsym.know > Cppsym.c
14882$cat Cppsym.a Cppsym.b Cppsym.c | $tr ' ' $trnl | $sort | $uniq > Cppsym.know
14883$rm -f Cppsym.a Cppsym.b Cppsym.c
14884cat <<EOSH > Cppsym
14885$startsh
14886if $test \$# -gt 0; then
14887    echo \$* | $tr " " "$trnl" | ./Cppsym.try > Cppsym.got
14888    if $test -s Cppsym.got; then
14889        $rm -f Cppsym.got
14890        exit 0
14891    fi
14892    $rm -f Cppsym.got
14893    exit 1
14894else
14895    $tr " " "$trnl" | ./Cppsym.try
14896    exit 0
14897fi
14898EOSH
14899chmod +x Cppsym
14900$eunicefix Cppsym
14901cat <<EOSH > Cppsym.try
14902$startsh
14903cat <<'EOCP' > try.c
14904#include <stdio.h>
14905int main() {
14906EOCP
14907$awk \\
14908EOSH
14909cat <<'EOSH' >> Cppsym.try
14910'length($1) > 0 {
14911    printf "#ifdef %s\n#if %s+0\nprintf(\"%s=%%ld\\n\", %s);\n#else\nprintf(\"%s\\n\");\n#endif\n#endif\n", $1, $1, $1, $1, $1
14912    printf "#ifdef _%s\n#if _%s+0\nprintf(\"_%s=%%ld\\n\", _%s);\n#else\nprintf(\"_%s\\n\");\n#endif\n#endif\n", $1, $1, $1, $1, $1
14913    printf "#ifdef __%s\n#if __%s+0\nprintf(\"__%s=%%ld\\n\", __%s);\n#else\nprintf(\"__%s\\n\");\n#endif\n#endif\n", $1, $1, $1, $1, $1
14914    printf "#ifdef __%s__\n#if __%s__+0\nprintf(\"__%s__=%%ld\\n\", __%s__);\n#else\nprintf(\"__%s__\\n\");\n#endif\n#endif\n", $1, $1, $1, $1, $1
14915}'	 >> try.c
14916echo '}' >> try.c
14917EOSH
14918cat <<EOSH >> Cppsym.try
14919ccflags="$ccflags"
14920case "$osname-$gccversion" in
14921irix-) ccflags="\$ccflags -woff 1178" ;;
14922os2-*) ccflags="\$ccflags -Zlinker /PM:VIO" ;;
14923esac
14924$cc -o try $optimize \$ccflags $ldflags try.c $libs && ./try$exe_ext
14925EOSH
14926chmod +x Cppsym.try
14927$eunicefix Cppsym.try
14928./Cppsym < Cppsym.know > Cppsym.true
14929: now check the C compiler for additional symbols
14930postprocess_cc_v=''
14931case "$osname" in
14932aix) postprocess_cc_v="|$tr , ' '" ;;
14933esac
14934$cat >ccsym <<EOS
14935$startsh
14936$cat >tmp.c <<EOF
14937extern int foo;
14938EOF
14939for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
14940do
14941	case "\$i" in
14942	-D*) echo "\$i" | $sed 's/^-D//';;
14943	-A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
14944	esac
14945done
14946$rm -f try.c
14947EOS
14948postprocess_cc_v=''
14949chmod +x ccsym
14950$eunicefix ccsym
14951./ccsym > ccsym1.raw
14952if $test -s ccsym1.raw; then
14953       $sort ccsym1.raw | $uniq >ccsym.raw
14954else
14955       mv ccsym1.raw ccsym.raw
14956fi
14957
14958$awk '/\=/ { print $0; next }
14959	{ print $0"=1" }' ccsym.raw >ccsym.list
14960$awk '/\=/ { print $0; next }
14961	{ print $0"=1" }' Cppsym.true >ccsym.true
14962$comm -13 ccsym.true ccsym.list >ccsym.own
14963$comm -12 ccsym.true ccsym.list >ccsym.com
14964$comm -23 ccsym.true ccsym.list >ccsym.cpp
14965also=''
14966if $test -z ccsym.raw; then
14967	echo "Your C compiler doesn't seem to define any symbols!" >&4
14968	echo " "
14969	echo "However, your C preprocessor defines the following symbols:"
14970	$cat Cppsym.true
14971    	ccsymbols=''
14972	cppsymbols=`$cat Cppsym.true`
14973        cppsymbols=`echo $cppsymbols`
14974	cppccsymbols="$cppsymbols"
14975else
14976	if $test -s ccsym.com; then
14977		echo "Your C compiler and pre-processor define these symbols:"
14978		$sed -e 's/\(..*\)=.*/\1/' ccsym.com
14979		also='also '
14980		symbols='ones'
14981		cppccsymbols=`$cat ccsym.com`
14982		cppccsymbols=`echo $cppccsymbols`
14983		$test "$silent" || sleep 1
14984	fi
14985	if $test -s ccsym.cpp; then
14986		$test "$also" && echo " "
14987		echo "Your C pre-processor ${also}defines the following symbols:"
14988		$sed -e 's/\(..*\)=.*/\1/' ccsym.cpp
14989		also='further '
14990		cppsymbols=`$cat ccsym.cpp`
14991		cppsymbols=`echo $cppsymbols`
14992		$test "$silent" || sleep 1
14993	fi
14994	if $test -s ccsym.own; then
14995		$test "$also" && echo " "
14996		echo "Your C compiler ${also}defines the following cpp symbols:"
14997		$sed -e 's/\(..*\)=1/\1/' ccsym.own
14998		$sed -e 's/\(..*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
14999	        ccsymbols=`$cat ccsym.own`
15000	        ccsymbols=`echo $ccsymbols`
15001		$test "$silent" || sleep 1
15002	fi
15003fi
15004$rm -f ccsym* Cppsym.*
15005
15006: see if this is a termio system
15007val="$undef"
15008val2="$undef"
15009val3="$undef"
15010if $test `./findhdr termios.h`; then
15011	set tcsetattr i_termios
15012	eval $inlibc
15013	val3="$i_termios"
15014fi
15015echo " "
15016case "$val3" in
15017"$define") echo "You have POSIX termios.h... good!" >&4;;
15018*) if ./Cppsym pyr; then
15019		case "`/bin/universe`" in
15020		ucb) if $test `./findhdr sgtty.h`; then
15021				val2="$define"
15022				echo "<sgtty.h> found." >&4
15023			else
15024				echo "System is pyramid with BSD universe."
15025				echo "<sgtty.h> not found--you could have problems." >&4
15026			fi;;
15027		*) if $test `./findhdr termio.h`; then
15028				val="$define"
15029				echo "<termio.h> found." >&4
15030			else
15031				echo "System is pyramid with USG universe."
15032				echo "<termio.h> not found--you could have problems." >&4
15033			fi;;
15034		esac
15035	elif ./usg; then
15036		if $test `./findhdr termio.h`; then
15037			echo "<termio.h> found." >&4
15038			val="$define"
15039		elif $test `./findhdr sgtty.h`; then
15040			echo "<sgtty.h> found." >&4
15041			val2="$define"
15042		else
15043echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
15044		fi
15045	else
15046		if $test `./findhdr sgtty.h`; then
15047			echo "<sgtty.h> found." >&4
15048			val2="$define"
15049		elif $test `./findhdr termio.h`; then
15050			echo "<termio.h> found." >&4
15051			val="$define"
15052		else
15053echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
15054		fi
15055	fi;;
15056esac
15057set i_termio; eval $setvar
15058val=$val2; set i_sgtty; eval $setvar
15059val=$val3; set i_termios; eval $setvar
15060
15061: see if this is a shadow.h system
15062set shadow.h i_shadow
15063eval $inhdr
15064
15065: see if stdarg is available
15066echo " "
15067if $test `./findhdr stdarg.h`; then
15068	echo "<stdarg.h> found." >&4
15069	valstd="$define"
15070else
15071	echo "<stdarg.h> NOT found." >&4
15072	valstd="$undef"
15073fi
15074
15075: see if varags is available
15076echo " "
15077if $test `./findhdr varargs.h`; then
15078	echo "<varargs.h> found." >&4
15079else
15080	echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
15081fi
15082
15083: set up the varargs testing programs
15084$cat > varargs.c <<EOP
15085#ifdef I_STDARG
15086#include <stdarg.h>
15087#endif
15088#ifdef I_VARARGS
15089#include <varargs.h>
15090#endif
15091
15092#ifdef I_STDARG
15093int f(char *p, ...)
15094#else
15095int f(va_alist)
15096va_dcl
15097#endif
15098{
15099	va_list ap;
15100#ifndef I_STDARG
15101	char *p;
15102#endif
15103#ifdef I_STDARG
15104	va_start(ap,p);
15105#else
15106	va_start(ap);
15107	p = va_arg(ap, char *);
15108#endif
15109	va_end(ap);
15110}
15111EOP
15112$cat > varargs <<EOP
15113$startsh
15114if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
15115	echo "true"
15116else
15117	echo "false"
15118fi
15119$rm -f varargs$_o
15120EOP
15121chmod +x varargs
15122
15123: now check which varargs header should be included
15124echo " "
15125i_varhdr=''
15126case "$valstd" in
15127"$define")
15128	if `./varargs I_STDARG`; then
15129		val='stdarg.h'
15130	elif `./varargs I_VARARGS`; then
15131		val='varargs.h'
15132	fi
15133	;;
15134*)
15135	if `./varargs I_VARARGS`; then
15136		val='varargs.h'
15137	fi
15138	;;
15139esac
15140case "$val" in
15141'')
15142echo "I could not find the definition for va_dcl... You have problems..." >&4
15143	val="$undef"; set i_stdarg; eval $setvar
15144	val="$undef"; set i_varargs; eval $setvar
15145	;;
15146*)
15147	set i_varhdr
15148	eval $setvar
15149	case "$i_varhdr" in
15150	stdarg.h)
15151		val="$define"; set i_stdarg; eval $setvar
15152		val="$undef"; set i_varargs; eval $setvar
15153		;;
15154	varargs.h)
15155		val="$undef"; set i_stdarg; eval $setvar
15156		val="$define"; set i_varargs; eval $setvar
15157		;;
15158	esac
15159	echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
15160esac
15161$rm -f varargs*
15162
15163: see if stddef is available
15164set stddef.h i_stddef
15165eval $inhdr
15166
15167: see if this is a sunmath.h system
15168set sunmath.h i_sunmath
15169eval $inhdr
15170
15171: see if sys/access.h is available
15172set sys/access.h i_sysaccess
15173eval $inhdr
15174
15175: see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
15176set sys/filio.h i_sysfilio
15177eval $inhdr
15178echo " "
15179if $test `./findhdr sys/ioctl.h`; then
15180	val="$define"
15181	echo '<sys/ioctl.h> found.' >&4
15182else
15183	val="$undef"
15184	if $test $i_sysfilio = "$define"; then
15185	    echo '<sys/ioctl.h> NOT found.' >&4
15186	else
15187		$test $i_sgtty = "$define" && xxx="sgtty.h"
15188		$test $i_termio = "$define" && xxx="termio.h"
15189		$test $i_termios = "$define" && xxx="termios.h"
15190echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
15191	fi
15192fi
15193set i_sysioctl
15194eval $setvar
15195
15196
15197: see if this is a syslog.h system
15198set syslog.h i_syslog
15199eval $inhdr
15200
15201
15202: see if this is a sys/mode.h system
15203set sys/mode.h i_sysmode
15204eval $inhdr
15205
15206: see if sys/resource.h has to be included
15207set sys/resource.h i_sysresrc
15208eval $inhdr
15209
15210: see if sys/security.h is available
15211set sys/security.h i_syssecrt
15212eval $inhdr
15213
15214: see if this is a sys/statvfs.h system
15215set sys/statvfs.h i_sysstatvfs
15216eval $inhdr
15217
15218: see if this is a sys/uio.h system
15219set sys/uio.h i_sysuio
15220eval $inhdr
15221
15222: see if this is a sys/un.h system
15223set sys/un.h i_sysun
15224eval $inhdr
15225
15226
15227: see if this is a sys/utsname.h system
15228set sys/utsname.h i_sysutsname
15229eval $inhdr
15230
15231: see if this is a syswait system
15232set sys/wait.h i_syswait
15233eval $inhdr
15234
15235: see if this is a ustat.h system
15236set ustat.h i_ustat
15237eval $inhdr
15238
15239: see if this is an utime system
15240set utime.h i_utime
15241eval $inhdr
15242
15243: see if this is a values.h system
15244set values.h i_values
15245eval $inhdr
15246
15247: see if this is a vfork system
15248case "$d_vfork" in
15249"$define")
15250	set vfork.h i_vfork
15251	eval $inhdr
15252	;;
15253*)
15254	i_vfork="$undef"
15255	;;
15256esac
15257
15258: see if gdbm.h is available
15259set gdbm.h t_gdbm
15260eval $inhdr
15261case "$t_gdbm" in
15262$define)
15263	: see if gdbm_open exists
15264	set gdbm_open d_gdbm_open
15265	eval $inlibc
15266	case "$d_gdbm_open" in
15267	$undef)
15268		t_gdbm="$undef"
15269		echo "We won't be including <gdbm.h>"
15270		;;
15271	esac
15272	;;
15273esac
15274val="$t_gdbm"
15275set i_gdbm
15276eval $setvar
15277
15278echo " "
15279echo "Looking for extensions..." >&4
15280: If we are using the old config.sh, known_extensions may contain
15281: old or inaccurate or duplicate values.
15282known_extensions=''
15283nonxs_extensions=''
15284: We do not use find because it might not be available.
15285: We do not just use MANIFEST because the user may have dropped
15286: some additional extensions into the source tree and expect them
15287: to be built.
15288
15289: Function to recursively find available extensions, ignoring DynaLoader
15290: NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
15291find_extensions='
15292    for xxx in *; do
15293       case "$xxx" in
15294           DynaLoader|dynaload) ;;
15295           *)
15296           if $test -f $xxx/$xxx.xs; then
15297               known_extensions="$known_extensions $1$xxx";
15298           elif $test -f $xxx/Makefile.PL; then
15299               nonxs_extensions="$nonxs_extensions $1$xxx";
15300           else
15301               if $test -d $xxx -a $# -lt 10; then
15302                   set $1$xxx/ $*;
15303                   cd $xxx;
15304                   eval $find_extensions;
15305                   cd ..;
15306                   shift;
15307               fi;
15308           fi
15309           ;;
15310       esac;
15311    done'
15312tdir=`pwd`
15313cd $rsrc/ext
15314set X
15315shift
15316eval $find_extensions
15317set X $nonxs_extensions
15318shift
15319nonxs_extensions="$*"
15320set X $known_extensions
15321shift
15322known_extensions="$*"
15323cd $tdir
15324
15325: Now see which are supported on this system.
15326avail_ext=''
15327for xxx in $known_extensions ; do
15328	case "$xxx" in
15329	DB_File|db_file)
15330		case "$i_db" in
15331		$define) avail_ext="$avail_ext $xxx" ;;
15332		esac
15333		;;
15334	GDBM_File|gdbm_fil)
15335		case "$i_gdbm" in
15336		$define) avail_ext="$avail_ext $xxx" ;;
15337		esac
15338		;;
15339	NDBM_File|ndbm_fil)
15340		case "$i_ndbm" in
15341		$define)
15342		    case "$osname-$use64bitint" in
15343		    hpux-define)
15344			case "$libs" in
15345			*-lndbm*) avail_ext="$avail_ext $xxx" ;;
15346			esac
15347			;;
15348		    *) avail_ext="$avail_ext $xxx" ;;
15349		    esac
15350		    ;;
15351		esac
15352		;;
15353	ODBM_File|odbm_fil)
15354		case "${i_dbm}${i_rpcsvcdbm}" in
15355		*"${define}"*)
15356		    case "$osname-$use64bitint" in
15357		    hpux-define)
15358			case "$libs" in
15359			*-ldbm*) avail_ext="$avail_ext $xxx" ;;
15360			esac
15361			;;
15362		    *) avail_ext="$avail_ext $xxx" ;;
15363		    esac
15364		    ;;
15365		esac
15366		;;
15367	POSIX|posix)
15368		case "$useposix" in
15369		true|define|y) avail_ext="$avail_ext $xxx" ;;
15370		esac
15371		;;
15372	Opcode|opcode)
15373		case "$useopcode" in
15374		true|define|y) avail_ext="$avail_ext $xxx" ;;
15375		esac
15376		;;
15377	Socket|socket)
15378		case "$d_socket" in
15379		true|$define|y) avail_ext="$avail_ext $xxx" ;;
15380		esac
15381		;;
15382	Sys/Syslog|sys/syslog)
15383		: XXX syslog requires socket
15384		case "$d_socket" in
15385		true|$define|y) avail_ext="$avail_ext $xxx" ;;
15386		esac
15387		;;
15388	Thread|thread)
15389		case "$usethreads" in
15390		true|$define|y) avail_ext="$avail_ext $xxx" ;;
15391		esac
15392		;;
15393	IPC/SysV|ipc/sysv)
15394		: XXX Do we need a useipcsysv variable here
15395		case "${d_msg}${d_sem}${d_shm}" in
15396		*"${define}"*) avail_ext="$avail_ext $xxx" ;;
15397		esac
15398		;;
15399	*)	avail_ext="$avail_ext $xxx"
15400		;;
15401	esac
15402done
15403
15404set X $avail_ext
15405shift
15406avail_ext="$*"
15407
15408: Now see which nonxs extensions are supported on this system.
15409: For now assume all are.
15410nonxs_ext=''
15411for xxx in $nonxs_extensions ; do
15412	case "$xxx" in
15413	*)	nonxs_ext="$nonxs_ext $xxx"
15414		;;
15415	esac
15416done
15417
15418set X $nonxs_ext
15419shift
15420nonxs_ext="$*"
15421
15422case $usedl in
15423$define)
15424	$cat <<EOM
15425A number of extensions are supplied with $package.  You may choose to
15426compile these extensions for dynamic loading (the default), compile
15427them into the $package executable (static loading), or not include
15428them at all.  Answer "none" to include no extensions.
15429Note that DynaLoader is always built and need not be mentioned here.
15430
15431EOM
15432	case "$dynamic_ext" in
15433	'') dflt="$avail_ext" ;;
15434	*)	dflt="$dynamic_ext"
15435		# Perhaps we are reusing an old out-of-date config.sh.
15436		case "$hint" in
15437		previous)
15438			if test X"$dynamic_ext" != X"$avail_ext"; then
15439				$cat <<EOM
15440NOTICE:  Your previous config.sh list may be incorrect. 
15441The extensions now available to you are 
15442	${avail_ext}
15443but the default list from your previous config.sh is
15444	${dynamic_ext} 
15445
15446EOM
15447			fi
15448			;;
15449		esac
15450		;;
15451	esac
15452	case "$dflt" in
15453	'')	dflt=none;;
15454	esac
15455	rp="What extensions do you wish to load dynamically?"
15456	. ./myread
15457	case "$ans" in
15458	none) dynamic_ext=' ' ;;
15459	*) dynamic_ext="$ans" ;;
15460	esac
15461
15462	case "$static_ext" in
15463	'')
15464		: Exclude those already listed in dynamic linking
15465		dflt=''
15466		for xxx in $avail_ext; do
15467			case " $dynamic_ext " in
15468			*" $xxx "*) ;;
15469			*) dflt="$dflt $xxx" ;;
15470			esac
15471		done
15472		set X $dflt
15473		shift
15474		dflt="$*"
15475		;;
15476	*)  dflt="$static_ext"
15477		;;
15478	esac
15479
15480	case "$dflt" in
15481	'')	dflt=none;;
15482	esac
15483	rp="What extensions do you wish to load statically?"
15484	. ./myread
15485	case "$ans" in
15486	none) static_ext=' ' ;;
15487	*) static_ext="$ans" ;;
15488	esac
15489	;;
15490*)
15491	$cat <<EOM
15492A number of extensions are supplied with $package.  Answer "none" 
15493to include no extensions. 
15494Note that DynaLoader is always built and need not be mentioned here.
15495
15496EOM
15497	case "$static_ext" in
15498	'') dflt="$avail_ext" ;;
15499	*)	dflt="$static_ext"
15500		# Perhaps we are reusing an old out-of-date config.sh.
15501		case "$hint" in
15502		previous)
15503			if test X"$static_ext" != X"$avail_ext"; then
15504				$cat <<EOM
15505NOTICE:  Your previous config.sh list may be incorrect. 
15506The extensions now available to you are 
15507	${avail_ext}
15508but the default list from your previous config.sh is
15509	${static_ext} 
15510
15511EOM
15512			fi
15513			;;
15514		esac
15515		;;
15516	esac
15517	: Exclude those that are not xs extensions
15518	case "$dflt" in
15519	'')	dflt=none;;
15520	esac
15521	rp="What extensions do you wish to include?"
15522	. ./myread
15523	case "$ans" in
15524	none) static_ext=' ' ;;
15525	*) static_ext="$ans" ;;
15526	esac
15527	;;
15528esac
15529
15530set X $dynamic_ext $static_ext $nonxs_ext
15531shift
15532extensions="$*"
15533
15534: Remove libraries needed only for extensions
15535: The appropriate ext/Foo/Makefile.PL will add them back in, if necessary.
15536: The exception is SunOS 4.x, which needs them.
15537case "${osname}X${osvers}" in
15538sunos*X4*)
15539    perllibs="$libs"
15540    ;;
15541*) case "$usedl" in
15542    $define|true|[yY]*)
15543	    set X `echo " $libs " | sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
15544	    shift
15545	    perllibs="$*"
15546	    ;;
15547    *)	perllibs="$libs"
15548	    ;;
15549    esac
15550    ;;
15551esac
15552
15553: Remove build directory name from cppstdin so it can be used from
15554: either the present location or the final installed location.
15555echo " "
15556: Get out of the UU directory to get correct path name.
15557cd ..
15558case "$cppstdin" in
15559`pwd`/cppstdin)
15560	echo "Stripping down cppstdin path name"
15561	cppstdin=cppstdin
15562	;;
15563esac
15564cd UU
15565
15566: end of configuration questions
15567echo " "
15568echo "End of configuration questions."
15569echo " "
15570
15571: back to where it started
15572if test -d ../UU; then
15573	cd ..
15574fi
15575
15576: configuration may be patched via a 'config.over' file
15577if $test -f config.over; then
15578	echo " "
15579	dflt=y
15580	rp='I see a config.over file.  Do you wish to load it?'
15581	. UU/myread
15582	case "$ans" in
15583	n*) echo "OK, I'll ignore it.";;
15584	*)	. ./config.over
15585		echo "Configuration override changes have been loaded."
15586		;;
15587	esac
15588fi
15589
15590: in case they want portability, strip down executable paths
15591case "$d_portable" in
15592"$define")
15593	echo " "
15594	echo "Stripping down executable paths..." >&4
15595	for file in $loclist $trylist; do
15596		eval temp=\$$file
15597		eval $file=`basename $temp`
15598	done
15599	;;
15600esac
15601
15602: create config.sh file
15603echo " "
15604echo "Creating config.sh..." >&4
15605$spitshell <<EOT >config.sh
15606$startsh
15607#
15608# This file was produced by running the Configure script. It holds all the
15609# definitions figured out by Configure. Should you modify one of these values,
15610# do not forget to propagate your changes by running "Configure -der". You may
15611# instead choose to run each of the .SH files by yourself, or "Configure -S".
15612#
15613
15614# Package name      : $package
15615# Source directory  : $src
15616# Configuration time: $cf_time
15617# Configured by     : $cf_by
15618# Target system     : $myuname
15619
15620Author='$Author'
15621Date='$Date'
15622Header='$Header'
15623Id='$Id'
15624Locker='$Locker'
15625Log='$Log'
15626Mcc='$Mcc'
15627RCSfile='$RCSfile'
15628Revision='$Revision'
15629Source='$Source'
15630State='$State'
15631_a='$_a'
15632_exe='$_exe'
15633_o='$_o'
15634afs='$afs'
15635alignbytes='$alignbytes'
15636ansi2knr='$ansi2knr'
15637aphostname='$aphostname'
15638api_revision='$api_revision'
15639api_subversion='$api_subversion'
15640api_version='$api_version'
15641api_versionstring='$api_versionstring'
15642ar='$ar'
15643archlib='$archlib'
15644archlibexp='$archlibexp'
15645archname64='$archname64'
15646archname='$archname'
15647archobjs='$archobjs'
15648awk='$awk'
15649baserev='$baserev'
15650bash='$bash'
15651bin='$bin'
15652bincompat5005='$bincompat5005'
15653binexp='$binexp'
15654bison='$bison'
15655byacc='$byacc'
15656byteorder='$byteorder'
15657c='$c'
15658castflags='$castflags'
15659cat='$cat'
15660cc='$cc'
15661cccdlflags='$cccdlflags'
15662ccdlflags='$ccdlflags'
15663ccflags='$ccflags'
15664ccflags_uselargefiles='$ccflags_uselargefiles'
15665ccname='$ccname'
15666ccsymbols='$ccsymbols'
15667ccversion='$ccversion'
15668cf_by='$cf_by'
15669cf_email='$cf_email'
15670cf_time='$cf_time'
15671charsize='$charsize'
15672chgrp='$chgrp'
15673chmod='$chmod'
15674chown='$chown'
15675clocktype='$clocktype'
15676comm='$comm'
15677compress='$compress'
15678contains='$contains'
15679cp='$cp'
15680cpio='$cpio'
15681cpp='$cpp'
15682cpp_stuff='$cpp_stuff'
15683cppccsymbols='$cppccsymbols'
15684cppflags='$cppflags'
15685cpplast='$cpplast'
15686cppminus='$cppminus'
15687cpprun='$cpprun'
15688cppstdin='$cppstdin'
15689cppsymbols='$cppsymbols'
15690crosscompile='$crosscompile'
15691cryptlib='$cryptlib'
15692csh='$csh'
15693d_Gconvert='$d_Gconvert'
15694d_PRIEUldbl='$d_PRIEUldbl'
15695d_PRIFUldbl='$d_PRIFUldbl'
15696d_PRIGUldbl='$d_PRIGUldbl'
15697d_PRIXU64='$d_PRIXU64'
15698d_PRId64='$d_PRId64'
15699d_PRIeldbl='$d_PRIeldbl'
15700d_PRIfldbl='$d_PRIfldbl'
15701d_PRIgldbl='$d_PRIgldbl'
15702d_PRIi64='$d_PRIi64'
15703d_PRIo64='$d_PRIo64'
15704d_PRIu64='$d_PRIu64'
15705d_PRIx64='$d_PRIx64'
15706d_SCNfldbl='$d_SCNfldbl'
15707d__fwalk='$d__fwalk'
15708d_access='$d_access'
15709d_accessx='$d_accessx'
15710d_alarm='$d_alarm'
15711d_archlib='$d_archlib'
15712d_atolf='$d_atolf'
15713d_atoll='$d_atoll'
15714d_attribut='$d_attribut'
15715d_bcmp='$d_bcmp'
15716d_bcopy='$d_bcopy'
15717d_bincompat5005='$d_bincompat5005'
15718d_bsd='$d_bsd'
15719d_bsdgetpgrp='$d_bsdgetpgrp'
15720d_bsdsetpgrp='$d_bsdsetpgrp'
15721d_bzero='$d_bzero'
15722d_casti32='$d_casti32'
15723d_castneg='$d_castneg'
15724d_charvspr='$d_charvspr'
15725d_chown='$d_chown'
15726d_chroot='$d_chroot'
15727d_chsize='$d_chsize'
15728d_closedir='$d_closedir'
15729d_const='$d_const'
15730d_crypt='$d_crypt'
15731d_csh='$d_csh'
15732d_cuserid='$d_cuserid'
15733d_dbl_dig='$d_dbl_dig'
15734d_difftime='$d_difftime'
15735d_dirnamlen='$d_dirnamlen'
15736d_dlerror='$d_dlerror'
15737d_dlopen='$d_dlopen'
15738d_dlsymun='$d_dlsymun'
15739d_dosuid='$d_dosuid'
15740d_drand48proto='$d_drand48proto'
15741d_dup2='$d_dup2'
15742d_eaccess='$d_eaccess'
15743d_endgrent='$d_endgrent'
15744d_endhent='$d_endhent'
15745d_endnent='$d_endnent'
15746d_endpent='$d_endpent'
15747d_endpwent='$d_endpwent'
15748d_endsent='$d_endsent'
15749d_eofnblk='$d_eofnblk'
15750d_eunice='$d_eunice'
15751d_fchmod='$d_fchmod'
15752d_fchown='$d_fchown'
15753d_fcntl='$d_fcntl'
15754d_fcntl_can_lock='$d_fcntl_can_lock'
15755d_fd_macros='$d_fd_macros'
15756d_fd_set='$d_fd_set'
15757d_fds_bits='$d_fds_bits'
15758d_fgetpos='$d_fgetpos'
15759d_flexfnam='$d_flexfnam'
15760d_flock='$d_flock'
15761d_fork='$d_fork'
15762d_fpathconf='$d_fpathconf'
15763d_fpos64_t='$d_fpos64_t'
15764d_frexpl='$d_frexpl'
15765d_fs_data_s='$d_fs_data_s'
15766d_fseeko='$d_fseeko'
15767d_fsetpos='$d_fsetpos'
15768d_fstatfs='$d_fstatfs'
15769d_fstatvfs='$d_fstatvfs'
15770d_fsync='$d_fsync'
15771d_ftello='$d_ftello'
15772d_ftime='$d_ftime'
15773d_getcwd='$d_getcwd'
15774d_getespwnam='$d_getespwnam'
15775d_getfsstat='$d_getfsstat'
15776d_getgrent='$d_getgrent'
15777d_getgrps='$d_getgrps'
15778d_gethbyaddr='$d_gethbyaddr'
15779d_gethbyname='$d_gethbyname'
15780d_gethent='$d_gethent'
15781d_gethname='$d_gethname'
15782d_gethostprotos='$d_gethostprotos'
15783d_getlogin='$d_getlogin'
15784d_getmnt='$d_getmnt'
15785d_getmntent='$d_getmntent'
15786d_getnbyaddr='$d_getnbyaddr'
15787d_getnbyname='$d_getnbyname'
15788d_getnent='$d_getnent'
15789d_getnetprotos='$d_getnetprotos'
15790d_getpagsz='$d_getpagsz'
15791d_getpbyname='$d_getpbyname'
15792d_getpbynumber='$d_getpbynumber'
15793d_getpent='$d_getpent'
15794d_getpgid='$d_getpgid'
15795d_getpgrp2='$d_getpgrp2'
15796d_getpgrp='$d_getpgrp'
15797d_getppid='$d_getppid'
15798d_getprior='$d_getprior'
15799d_getprotoprotos='$d_getprotoprotos'
15800d_getprpwnam='$d_getprpwnam'
15801d_getpwent='$d_getpwent'
15802d_getsbyname='$d_getsbyname'
15803d_getsbyport='$d_getsbyport'
15804d_getsent='$d_getsent'
15805d_getservprotos='$d_getservprotos'
15806d_getspnam='$d_getspnam'
15807d_gettimeod='$d_gettimeod'
15808d_gnulibc='$d_gnulibc'
15809d_grpasswd='$d_grpasswd'
15810d_hasmntopt='$d_hasmntopt'
15811d_htonl='$d_htonl'
15812d_iconv='$d_iconv'
15813d_index='$d_index'
15814d_inetaton='$d_inetaton'
15815d_int64_t='$d_int64_t'
15816d_isascii='$d_isascii'
15817d_isnan='$d_isnan'
15818d_isnanl='$d_isnanl'
15819d_killpg='$d_killpg'
15820d_lchown='$d_lchown'
15821d_ldbl_dig='$d_ldbl_dig'
15822d_link='$d_link'
15823d_locconv='$d_locconv'
15824d_lockf='$d_lockf'
15825d_longdbl='$d_longdbl'
15826d_longlong='$d_longlong'
15827d_lseekproto='$d_lseekproto'
15828d_lstat='$d_lstat'
15829d_madvise='$d_madvise'
15830d_mblen='$d_mblen'
15831d_mbstowcs='$d_mbstowcs'
15832d_mbtowc='$d_mbtowc'
15833d_memchr='$d_memchr'
15834d_memcmp='$d_memcmp'
15835d_memcpy='$d_memcpy'
15836d_memmove='$d_memmove'
15837d_memset='$d_memset'
15838d_mkdir='$d_mkdir'
15839d_mkdtemp='$d_mkdtemp'
15840d_mkfifo='$d_mkfifo'
15841d_mkstemp='$d_mkstemp'
15842d_mkstemps='$d_mkstemps'
15843d_mktime='$d_mktime'
15844d_mmap='$d_mmap'
15845d_modfl='$d_modfl'
15846d_mprotect='$d_mprotect'
15847d_msg='$d_msg'
15848d_msg_ctrunc='$d_msg_ctrunc'
15849d_msg_dontroute='$d_msg_dontroute'
15850d_msg_oob='$d_msg_oob'
15851d_msg_peek='$d_msg_peek'
15852d_msg_proxy='$d_msg_proxy'
15853d_msgctl='$d_msgctl'
15854d_msgget='$d_msgget'
15855d_msgrcv='$d_msgrcv'
15856d_msgsnd='$d_msgsnd'
15857d_msync='$d_msync'
15858d_munmap='$d_munmap'
15859d_mymalloc='$d_mymalloc'
15860d_nice='$d_nice'
15861d_nv_preserves_uv='$d_nv_preserves_uv'
15862d_nv_preserves_uv_bits='$d_nv_preserves_uv_bits'
15863d_off64_t='$d_off64_t'
15864d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
15865d_oldpthreads='$d_oldpthreads'
15866d_oldsock='$d_oldsock'
15867d_open3='$d_open3'
15868d_pathconf='$d_pathconf'
15869d_pause='$d_pause'
15870d_perl_otherlibdirs='$d_perl_otherlibdirs'
15871d_phostname='$d_phostname'
15872d_pipe='$d_pipe'
15873d_poll='$d_poll'
15874d_portable='$d_portable'
15875d_pthread_yield='$d_pthread_yield'
15876d_pwage='$d_pwage'
15877d_pwchange='$d_pwchange'
15878d_pwclass='$d_pwclass'
15879d_pwcomment='$d_pwcomment'
15880d_pwexpire='$d_pwexpire'
15881d_pwgecos='$d_pwgecos'
15882d_pwpasswd='$d_pwpasswd'
15883d_pwquota='$d_pwquota'
15884d_qgcvt='$d_qgcvt'
15885d_quad='$d_quad'
15886d_readdir='$d_readdir'
15887d_readlink='$d_readlink'
15888d_rename='$d_rename'
15889d_rewinddir='$d_rewinddir'
15890d_rmdir='$d_rmdir'
15891d_safebcpy='$d_safebcpy'
15892d_safemcpy='$d_safemcpy'
15893d_sanemcmp='$d_sanemcmp'
15894d_sbrkproto='$d_sbrkproto'
15895d_sched_yield='$d_sched_yield'
15896d_scm_rights='$d_scm_rights'
15897d_seekdir='$d_seekdir'
15898d_select='$d_select'
15899d_sem='$d_sem'
15900d_semctl='$d_semctl'
15901d_semctl_semid_ds='$d_semctl_semid_ds'
15902d_semctl_semun='$d_semctl_semun'
15903d_semget='$d_semget'
15904d_semop='$d_semop'
15905d_setegid='$d_setegid'
15906d_seteuid='$d_seteuid'
15907d_setgrent='$d_setgrent'
15908d_setgrps='$d_setgrps'
15909d_sethent='$d_sethent'
15910d_setlinebuf='$d_setlinebuf'
15911d_setlocale='$d_setlocale'
15912d_setnent='$d_setnent'
15913d_setpent='$d_setpent'
15914d_setpgid='$d_setpgid'
15915d_setpgrp2='$d_setpgrp2'
15916d_setpgrp='$d_setpgrp'
15917d_setprior='$d_setprior'
15918d_setproctitle='$d_setproctitle'
15919d_setpwent='$d_setpwent'
15920d_setregid='$d_setregid'
15921d_setresgid='$d_setresgid'
15922d_setresuid='$d_setresuid'
15923d_setreuid='$d_setreuid'
15924d_setrgid='$d_setrgid'
15925d_setruid='$d_setruid'
15926d_setsent='$d_setsent'
15927d_setsid='$d_setsid'
15928d_setvbuf='$d_setvbuf'
15929d_sfio='$d_sfio'
15930d_shm='$d_shm'
15931d_shmat='$d_shmat'
15932d_shmatprototype='$d_shmatprototype'
15933d_shmctl='$d_shmctl'
15934d_shmdt='$d_shmdt'
15935d_shmget='$d_shmget'
15936d_sigaction='$d_sigaction'
15937d_sigsetjmp='$d_sigsetjmp'
15938d_socket='$d_socket'
15939d_socklen_t='$d_socklen_t'
15940d_sockpair='$d_sockpair'
15941d_socks5_init='$d_socks5_init'
15942d_sqrtl='$d_sqrtl'
15943d_statblks='$d_statblks'
15944d_statfs_f_flags='$d_statfs_f_flags'
15945d_statfs_s='$d_statfs_s'
15946d_statvfs='$d_statvfs'
15947d_stdio_cnt_lval='$d_stdio_cnt_lval'
15948d_stdio_ptr_lval='$d_stdio_ptr_lval'
15949d_stdio_ptr_lval_nochange_cnt='$d_stdio_ptr_lval_nochange_cnt'
15950d_stdio_ptr_lval_sets_cnt='$d_stdio_ptr_lval_sets_cnt'
15951d_stdio_stream_array='$d_stdio_stream_array'
15952d_stdiobase='$d_stdiobase'
15953d_stdstdio='$d_stdstdio'
15954d_strchr='$d_strchr'
15955d_strcoll='$d_strcoll'
15956d_strctcpy='$d_strctcpy'
15957d_strerrm='$d_strerrm'
15958d_strerror='$d_strerror'
15959d_strtod='$d_strtod'
15960d_strtol='$d_strtol'
15961d_strtold='$d_strtold'
15962d_strtoll='$d_strtoll'
15963d_strtoul='$d_strtoul'
15964d_strtoull='$d_strtoull'
15965d_strtouq='$d_strtouq'
15966d_strxfrm='$d_strxfrm'
15967d_suidsafe='$d_suidsafe'
15968d_symlink='$d_symlink'
15969d_syscall='$d_syscall'
15970d_sysconf='$d_sysconf'
15971d_sysernlst='$d_sysernlst'
15972d_syserrlst='$d_syserrlst'
15973d_system='$d_system'
15974d_tcgetpgrp='$d_tcgetpgrp'
15975d_tcsetpgrp='$d_tcsetpgrp'
15976d_telldir='$d_telldir'
15977d_telldirproto='$d_telldirproto'
15978d_time='$d_time'
15979d_times='$d_times'
15980d_truncate='$d_truncate'
15981d_tzname='$d_tzname'
15982d_umask='$d_umask'
15983d_uname='$d_uname'
15984d_union_semun='$d_union_semun'
15985d_ustat='$d_ustat'
15986d_vendorarch='$d_vendorarch'
15987d_vendorbin='$d_vendorbin'
15988d_vendorlib='$d_vendorlib'
15989d_vfork='$d_vfork'
15990d_void_closedir='$d_void_closedir'
15991d_voidsig='$d_voidsig'
15992d_voidtty='$d_voidtty'
15993d_volatile='$d_volatile'
15994d_vprintf='$d_vprintf'
15995d_wait4='$d_wait4'
15996d_waitpid='$d_waitpid'
15997d_wcstombs='$d_wcstombs'
15998d_wctomb='$d_wctomb'
15999d_xenix='$d_xenix'
16000date='$date'
16001db_hashtype='$db_hashtype'
16002db_prefixtype='$db_prefixtype'
16003defvoidused='$defvoidused'
16004direntrytype='$direntrytype'
16005dlext='$dlext'
16006dlsrc='$dlsrc'
16007doublesize='$doublesize'
16008drand01='$drand01'
16009dynamic_ext='$dynamic_ext'
16010eagain='$eagain'
16011ebcdic='$ebcdic'
16012echo='$echo'
16013egrep='$egrep'
16014emacs='$emacs'
16015eunicefix='$eunicefix'
16016exe_ext='$exe_ext'
16017expr='$expr'
16018extensions='$extensions'
16019fflushNULL='$fflushNULL'
16020fflushall='$fflushall'
16021find='$find'
16022firstmakefile='$firstmakefile'
16023flex='$flex'
16024fpossize='$fpossize'
16025fpostype='$fpostype'
16026freetype='$freetype'
16027full_ar='$full_ar'
16028full_csh='$full_csh'
16029full_sed='$full_sed'
16030gccosandvers='$gccosandvers'
16031gccversion='$gccversion'
16032gidformat='$gidformat'
16033gidsign='$gidsign'
16034gidsize='$gidsize'
16035gidtype='$gidtype'
16036glibpth='$glibpth'
16037grep='$grep'
16038groupcat='$groupcat'
16039groupstype='$groupstype'
16040gzip='$gzip'
16041h_fcntl='$h_fcntl'
16042h_sysfile='$h_sysfile'
16043hint='$hint'
16044hostcat='$hostcat'
16045i16size='$i16size'
16046i16type='$i16type'
16047i32size='$i32size'
16048i32type='$i32type'
16049i64size='$i64size'
16050i64type='$i64type'
16051i8size='$i8size'
16052i8type='$i8type'
16053i_arpainet='$i_arpainet'
16054i_bsdioctl='$i_bsdioctl'
16055i_db='$i_db'
16056i_dbm='$i_dbm'
16057i_dirent='$i_dirent'
16058i_dld='$i_dld'
16059i_dlfcn='$i_dlfcn'
16060i_fcntl='$i_fcntl'
16061i_float='$i_float'
16062i_gdbm='$i_gdbm'
16063i_grp='$i_grp'
16064i_iconv='$i_iconv'
16065i_ieeefp='$i_ieeefp'
16066i_inttypes='$i_inttypes'
16067i_libutil='$i_libutil'
16068i_limits='$i_limits'
16069i_locale='$i_locale'
16070i_machcthr='$i_machcthr'
16071i_malloc='$i_malloc'
16072i_math='$i_math'
16073i_memory='$i_memory'
16074i_mntent='$i_mntent'
16075i_ndbm='$i_ndbm'
16076i_netdb='$i_netdb'
16077i_neterrno='$i_neterrno'
16078i_netinettcp='$i_netinettcp'
16079i_niin='$i_niin'
16080i_poll='$i_poll'
16081i_prot='$i_prot'
16082i_pthread='$i_pthread'
16083i_pwd='$i_pwd'
16084i_rpcsvcdbm='$i_rpcsvcdbm'
16085i_sfio='$i_sfio'
16086i_sgtty='$i_sgtty'
16087i_shadow='$i_shadow'
16088i_socks='$i_socks'
16089i_stdarg='$i_stdarg'
16090i_stddef='$i_stddef'
16091i_stdlib='$i_stdlib'
16092i_string='$i_string'
16093i_sunmath='$i_sunmath'
16094i_sysaccess='$i_sysaccess'
16095i_sysdir='$i_sysdir'
16096i_sysfile='$i_sysfile'
16097i_sysfilio='$i_sysfilio'
16098i_sysin='$i_sysin'
16099i_sysioctl='$i_sysioctl'
16100i_syslog='$i_syslog'
16101i_sysmman='$i_sysmman'
16102i_sysmode='$i_sysmode'
16103i_sysmount='$i_sysmount'
16104i_sysndir='$i_sysndir'
16105i_sysparam='$i_sysparam'
16106i_sysresrc='$i_sysresrc'
16107i_syssecrt='$i_syssecrt'
16108i_sysselct='$i_sysselct'
16109i_syssockio='$i_syssockio'
16110i_sysstat='$i_sysstat'
16111i_sysstatfs='$i_sysstatfs'
16112i_sysstatvfs='$i_sysstatvfs'
16113i_systime='$i_systime'
16114i_systimek='$i_systimek'
16115i_systimes='$i_systimes'
16116i_systypes='$i_systypes'
16117i_sysuio='$i_sysuio'
16118i_sysun='$i_sysun'
16119i_sysutsname='$i_sysutsname'
16120i_sysvfs='$i_sysvfs'
16121i_syswait='$i_syswait'
16122i_termio='$i_termio'
16123i_termios='$i_termios'
16124i_time='$i_time'
16125i_unistd='$i_unistd'
16126i_ustat='$i_ustat'
16127i_utime='$i_utime'
16128i_values='$i_values'
16129i_varargs='$i_varargs'
16130i_varhdr='$i_varhdr'
16131i_vfork='$i_vfork'
16132ignore_versioned_solibs='$ignore_versioned_solibs'
16133inc_version_list='$inc_version_list'
16134inc_version_list_init='$inc_version_list_init'
16135incpath='$incpath'
16136inews='$inews'
16137installarchlib='$installarchlib'
16138installbin='$installbin'
16139installman1dir='$installman1dir'
16140installman3dir='$installman3dir'
16141installprefix='$installprefix'
16142installprefixexp='$installprefixexp'
16143installprivlib='$installprivlib'
16144installscript='$installscript'
16145installsitearch='$installsitearch'
16146installsitebin='$installsitebin'
16147installsitelib='$installsitelib'
16148installstyle='$installstyle'
16149installusrbinperl='$installusrbinperl'
16150installvendorarch='$installvendorarch'
16151installvendorbin='$installvendorbin'
16152installvendorlib='$installvendorlib'
16153intsize='$intsize'
16154issymlink='$issymlink'
16155ivdformat='$ivdformat'
16156ivsize='$ivsize'
16157ivtype='$ivtype'
16158known_extensions='$known_extensions'
16159ksh='$ksh'
16160ld='$ld'
16161lddlflags='$lddlflags'
16162ldflags='$ldflags'
16163ldflags_uselargefiles='$ldflags_uselargefiles'
16164ldlibpthname='$ldlibpthname'
16165less='$less'
16166lib_ext='$lib_ext'
16167libc='$libc'
16168libperl='$libperl'
16169libpth='$libpth'
16170libs='$libs'
16171libsdirs='$libsdirs'
16172libsfiles='$libsfiles'
16173libsfound='$libsfound'
16174libspath='$libspath'
16175libswanted='$libswanted'
16176libswanted_uselargefiles='$libswanted_uselargefiles'
16177line='$line'
16178lint='$lint'
16179lkflags='$lkflags'
16180ln='$ln'
16181lns='$lns'
16182locincpth='$locincpth'
16183loclibpth='$loclibpth'
16184longdblsize='$longdblsize'
16185longlongsize='$longlongsize'
16186longsize='$longsize'
16187lp='$lp'
16188lpr='$lpr'
16189ls='$ls'
16190lseeksize='$lseeksize'
16191lseektype='$lseektype'
16192mail='$mail'
16193mailx='$mailx'
16194make='$make'
16195make_set_make='$make_set_make'
16196mallocobj='$mallocobj'
16197mallocsrc='$mallocsrc'
16198malloctype='$malloctype'
16199man1dir='$man1dir'
16200man1direxp='$man1direxp'
16201man1ext='$man1ext'
16202man3dir='$man3dir'
16203man3direxp='$man3direxp'
16204man3ext='$man3ext'
16205mips_type='$mips_type'
16206mkdir='$mkdir'
16207mmaptype='$mmaptype'
16208modetype='$modetype'
16209more='$more'
16210multiarch='$multiarch'
16211mv='$mv'
16212myarchname='$myarchname'
16213mydomain='$mydomain'
16214myhostname='$myhostname'
16215myuname='$myuname'
16216n='$n'
16217netdb_hlen_type='$netdb_hlen_type'
16218netdb_host_type='$netdb_host_type'
16219netdb_name_type='$netdb_name_type'
16220netdb_net_type='$netdb_net_type'
16221nm='$nm'
16222nm_opt='$nm_opt'
16223nm_so_opt='$nm_so_opt'
16224nonxs_ext='$nonxs_ext'
16225nroff='$nroff'
16226nvEUformat='$nvEUformat'
16227nvFUformat='$nvFUformat'
16228nvGUformat='$nvGUformat'
16229nveformat='$nveformat'
16230nvfformat='$nvfformat'
16231nvgformat='$nvgformat'
16232nvsize='$nvsize'
16233nvtype='$nvtype'
16234o_nonblock='$o_nonblock'
16235obj_ext='$obj_ext'
16236old_pthread_create_joinable='$old_pthread_create_joinable'
16237optimize='$optimize'
16238orderlib='$orderlib'
16239osname='$osname'
16240osvers='$osvers'
16241otherlibdirs='$otherlibdirs'
16242package='$package'
16243pager='$pager'
16244passcat='$passcat'
16245patchlevel='$patchlevel'
16246path_sep='$path_sep'
16247perl5='$perl5'
16248perl='$perl'
16249perladmin='$perladmin'
16250perllibs='$perllibs'
16251perlpath='$perlpath'
16252pg='$pg'
16253phostname='$phostname'
16254pidtype='$pidtype'
16255plibpth='$plibpth'
16256pm_apiversion='$pm_apiversion'
16257pmake='$pmake'
16258pr='$pr'
16259prefix='$prefix'
16260prefixexp='$prefixexp'
16261privlib='$privlib'
16262privlibexp='$privlibexp'
16263prototype='$prototype'
16264ptrsize='$ptrsize'
16265quadkind='$quadkind'
16266quadtype='$quadtype'
16267randbits='$randbits'
16268randfunc='$randfunc'
16269randseedtype='$randseedtype'
16270ranlib='$ranlib'
16271rd_nodata='$rd_nodata'
16272revision='$revision'
16273rm='$rm'
16274rmail='$rmail'
16275runnm='$runnm'
16276sPRIEUldbl='$sPRIEUldbl'
16277sPRIFUldbl='$sPRIFUldbl'
16278sPRIGUldbl='$sPRIGUldbl'
16279sPRIXU64='$sPRIXU64'
16280sPRId64='$sPRId64'
16281sPRIeldbl='$sPRIeldbl'
16282sPRIfldbl='$sPRIfldbl'
16283sPRIgldbl='$sPRIgldbl'
16284sPRIi64='$sPRIi64'
16285sPRIo64='$sPRIo64'
16286sPRIu64='$sPRIu64'
16287sPRIx64='$sPRIx64'
16288sSCNfldbl='$sSCNfldbl'
16289sched_yield='$sched_yield'
16290scriptdir='$scriptdir'
16291scriptdirexp='$scriptdirexp'
16292sed='$sed'
16293seedfunc='$seedfunc'
16294selectminbits='$selectminbits'
16295selecttype='$selecttype'
16296sendmail='$sendmail'
16297sh='$sh'
16298shar='$shar'
16299sharpbang='$sharpbang'
16300shmattype='$shmattype'
16301shortsize='$shortsize'
16302shrpenv='$shrpenv'
16303shsharp='$shsharp'
16304sig_count='$sig_count'
16305sig_name='$sig_name'
16306sig_name_init='$sig_name_init'
16307sig_num='$sig_num'
16308sig_num_init='$sig_num_init'
16309signal_t='$signal_t'
16310sitearch='$sitearch'
16311sitearchexp='$sitearchexp'
16312sitebin='$sitebin'
16313sitebinexp='$sitebinexp'
16314sitelib='$sitelib'
16315sitelib_stem='$sitelib_stem'
16316sitelibexp='$sitelibexp'
16317siteprefix='$siteprefix'
16318siteprefixexp='$siteprefixexp'
16319sizesize='$sizesize'
16320sizetype='$sizetype'
16321sleep='$sleep'
16322smail='$smail'
16323so='$so'
16324sockethdr='$sockethdr'
16325socketlib='$socketlib'
16326socksizetype='$socksizetype'
16327sort='$sort'
16328spackage='$spackage'
16329spitshell='$spitshell'
16330src='$src'
16331ssizetype='$ssizetype'
16332startperl='$startperl'
16333startsh='$startsh'
16334static_ext='$static_ext'
16335stdchar='$stdchar'
16336stdio_base='$stdio_base'
16337stdio_bufsiz='$stdio_bufsiz'
16338stdio_cnt='$stdio_cnt'
16339stdio_filbuf='$stdio_filbuf'
16340stdio_ptr='$stdio_ptr'
16341stdio_stream_array='$stdio_stream_array'
16342strings='$strings'
16343submit='$submit'
16344subversion='$subversion'
16345sysman='$sysman'
16346tail='$tail'
16347tar='$tar'
16348tbl='$tbl'
16349tee='$tee'
16350test='$test'
16351timeincl='$timeincl'
16352timetype='$timetype'
16353touch='$touch'
16354tr='$tr'
16355trnl='$trnl'
16356troff='$troff'
16357u16size='$u16size'
16358u16type='$u16type'
16359u32size='$u32size'
16360u32type='$u32type'
16361u64size='$u64size'
16362u64type='$u64type'
16363u8size='$u8size'
16364u8type='$u8type'
16365uidformat='$uidformat'
16366uidsign='$uidsign'
16367uidsize='$uidsize'
16368uidtype='$uidtype'
16369uname='$uname'
16370uniq='$uniq'
16371uquadtype='$uquadtype'
16372use5005threads='$use5005threads'
16373use64bitall='$use64bitall'
16374use64bitint='$use64bitint'
16375usedl='$usedl'
16376useithreads='$useithreads'
16377uselargefiles='$uselargefiles'
16378uselongdouble='$uselongdouble'
16379usemorebits='$usemorebits'
16380usemultiplicity='$usemultiplicity'
16381usemymalloc='$usemymalloc'
16382usenm='$usenm'
16383useopcode='$useopcode'
16384useperlio='$useperlio'
16385useposix='$useposix'
16386usesfio='$usesfio'
16387useshrplib='$useshrplib'
16388usesocks='$usesocks'
16389usethreads='$usethreads'
16390usevendorprefix='$usevendorprefix'
16391usevfork='$usevfork'
16392usrinc='$usrinc'
16393uuname='$uuname'
16394uvXUformat='$uvXUformat'
16395uvoformat='$uvoformat'
16396uvsize='$uvsize'
16397uvtype='$uvtype'
16398uvuformat='$uvuformat'
16399uvxformat='$uvxformat'
16400vendorarch='$vendorarch'
16401vendorarchexp='$vendorarchexp'
16402vendorbin='$vendorbin'
16403vendorbinexp='$vendorbinexp'
16404vendorlib='$vendorlib'
16405vendorlib_stem='$vendorlib_stem'
16406vendorlibexp='$vendorlibexp'
16407vendorprefix='$vendorprefix'
16408vendorprefixexp='$vendorprefixexp'
16409version='$version'
16410versiononly='$versiononly'
16411vi='$vi'
16412voidflags='$voidflags'
16413xlibpth='$xlibpth'
16414xs_apiversion='$xs_apiversion'
16415yacc='$yacc'
16416yaccflags='$yaccflags'
16417zcat='$zcat'
16418zip='$zip'
16419EOT
16420
16421: Add in command line options if available
16422$test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
16423
16424: add special variables
16425$test -f $src/patchlevel.h && \
16426awk '/^#define[ 	]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
16427echo "CONFIGDOTSH=true" >>config.sh
16428
16429: propagate old symbols
16430if $test -f UU/config.sh; then
16431	<UU/config.sh $sort | $uniq >UU/oldconfig.sh
16432	sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
16433	$sort | $uniq -u >UU/oldsyms
16434	set X `cat UU/oldsyms`
16435	shift
16436	case $# in
16437	0) ;;
16438	*)
16439		cat <<EOM
16440Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
16441EOM
16442		echo "# Variables propagated from previous config.sh file." >>config.sh
16443		for sym in `cat UU/oldsyms`; do
16444			echo "    Propagating $hint variable "'$'"$sym..."
16445			eval 'tmp="$'"${sym}"'"'
16446			echo "$tmp" | \
16447				sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
16448		done
16449		;;
16450	esac
16451fi
16452
16453: Finish up by extracting the .SH files
16454case "$alldone" in
16455exit)
16456	$rm -rf UU
16457	echo "Done."
16458	exit 0
16459	;;
16460cont)
16461	;;
16462'')
16463	dflt=''
16464	nostick=true
16465	$cat <<EOM
16466
16467If you'd like to make any changes to the config.sh file before I begin
16468to configure things, do it as a shell escape now (e.g. !vi config.sh).
16469
16470EOM
16471	rp="Press return or use a shell escape to edit config.sh:"
16472	. UU/myread
16473	nostick=''
16474	case "$ans" in
16475	'') ;;
16476	*) : in case they cannot read
16477		sh 1>&4 -c "$ans";;
16478	esac
16479	;;
16480esac
16481
16482: if this fails, just run all the .SH files by hand
16483. ./config.sh
16484
16485echo " "
16486exec 1>&4
16487. ./UU/extract
16488
16489if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
16490	dflt=y
16491	case "$silent" in
16492	true) ;;
16493	*)
16494		$cat <<EOM
16495
16496Now you need to generate make dependencies by running "$make depend".
16497You might prefer to run it in background: "$make depend > makedepend.out &"
16498It can take a while, so you might not want to run it right now.
16499
16500EOM
16501		;;
16502	esac
16503	rp="Run $make depend now?"
16504	. UU/myread
16505	case "$ans" in
16506	y*)
16507		$make depend && echo "Now you must run '$make'."
16508		;;
16509	*)
16510		echo "You must run '$make depend' then '$make'."
16511		;;
16512	esac
16513elif test -f [Mm]akefile; then
16514	echo " "
16515	echo "Now you must run a $make."
16516else
16517	echo "Done."
16518fi
16519
16520if $test -f Policy.sh; then
16521    $cat <<EOM
16522
16523If you compile $package on a different machine or from a different object
16524directory, copy the Policy.sh file from this object directory to the
16525new one before you run Configure -- this will help you with most of
16526the policy defaults.
16527
16528EOM
16529fi
16530if $test -f config.msg; then
16531    echo "Hmm.  I also noted the following information while running:"
16532    echo " "
16533    $cat config.msg >&4
16534    $rm -f config.msg
16535fi
16536$rm -f kit*isdone ark*isdone
16537$rm -rf UU
16538
16539: End of Configure
16540
16541