Integrate with mainperl.
[p5sagit/p5-mst-13.2.git] / Configure
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 Mon Jul  5 02:09:55 EET DST 1999 [metaconfig 3.0 PL70]
24 # (with additional metaconfig patches by perlbug@perl.com)
25
26 cat >/tmp/c1$$ <<EOF
27 ARGGGHHHH!!!!!
28
29 SCO csh still thinks true is false.  Write to SCO today and tell them that next
30 year 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
33 we'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...]
36 EOF
37 cat >/tmp/c2$$ <<EOF
38
39 OOPS!  You naughty creature!  You didn't run Configure with sh!
40 I will attempt to remedy the situation by running sh for you...
41 EOF
42
43 true || cat /tmp/c1$$ /tmp/c2$$
44 true || exec sh $0 $argv:q
45
46 (exit $?0) || cat /tmp/c2$$
47 (exit $?0) || exec sh $0 $argv:q
48 rm -f /tmp/c1$$ /tmp/c2$$
49
50 : compute my invocation name
51 me=$0
52 case "$0" in
53 */*)
54         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55         test "$me" || me=$0
56         ;;
57 esac
58
59 : Proper separator for the PATH environment variable
60 p_=:
61 : On OS/2 this directory should exist if this is not floppy only system :-]
62 if 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
70 fi
71
72 : Proper PATH setting
73 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
74 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
75 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
76 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
77 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80 paths="$paths /sbin /usr/sbin /usr/libexec"
81
82 for p in $paths
83 do
84         case "$p_$PATH$p_" in
85         *$p_$p$p_*) ;;
86         *) test -d $p && PATH=$PATH$p_$p ;;
87         esac
88 done
89
90 PATH=.$p_$PATH
91 export PATH
92
93 : shall we be using ksh?
94 inksh=''
95 needksh=''
96 avoidksh=''
97 newsh=/bin/ksh
98 changesh=''
99 if (PATH=.; alias -x) >/dev/null 2>&1; then
100                 inksh=true
101 fi
102 if test -f /hp-ux -a -f /bin/ksh; then
103         needksh='to avoid sh bug in "here document" expansion'
104 fi
105 if 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
110 fi
111 if 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
117 fi
118 case "$inksh/$needksh" in
119 /[a-z]*)
120                 ENV=''
121                 changesh=true
122                 reason="$needksh"
123         ;;
124 esac
125 case "$inksh/$avoidksh" in
126 true/[a-z]*)
127         changesh=true
128         reason="$avoidksh"
129         ;;
130 esac
131 case "$inksh/$needksh-$avoidksh-" in
132 true/--)
133                 cat <<EOM
134 (I see you are using the Korn shell.  Some ksh's blow up on $me,
135 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
136 EOM
137         ;;
138 esac
139 case "$changesh" in
140 true)
141         echo "(Feeding myself to $newsh $reason.)"
142         case "$0" in
143         Configure|*/Configure) exec $newsh $0 "$@";;
144         *) exec $newsh Configure "$@";;
145         esac
146         ;;
147 esac
148
149 : if needed set CDPATH to a harmless value that is not chatty
150 : avoid bash 2.02 problems with empty CDPATH.
151 case "$CDPATH" in
152 '')     ;;
153 *)      case "$SHELL" in
154         *bash*) CDPATH='.' ;;
155         *)              CDPATH='' ;;
156         esac
157         ;;
158 esac
159 : Configure runs within the UU subdirectory
160 test -d UU || mkdir UU
161 cd UU && rm -f ./*
162
163 ccsymbols=''
164 cppccsymbols=''
165 cppsymbols=''
166 dynamic_ext=''
167 extensions=''
168 known_extensions=''
169 nonxs_ext=''
170 static_ext=''
171 useopcode=''
172 useposix=''
173 d_bsd=''
174 d_eunice=''
175 d_xenix=''
176 eunicefix=''
177 Mcc=''
178 ar=''
179 awk=''
180 bash=''
181 bison=''
182 byacc=''
183 cat=''
184 chgrp=''
185 chmod=''
186 chown=''
187 comm=''
188 compress=''
189 cp=''
190 cpio=''
191 cpp=''
192 csh=''
193 date=''
194 echo=''
195 egrep=''
196 emacs=''
197 expr=''
198 find=''
199 flex=''
200 grep=''
201 gzip=''
202 inews=''
203 ksh=''
204 less=''
205 line=''
206 lint=''
207 ln=''
208 lp=''
209 lpr=''
210 ls=''
211 mail=''
212 mailx=''
213 make=''
214 mkdir=''
215 more=''
216 mv=''
217 nm=''
218 nroff=''
219 perl=''
220 pg=''
221 pmake=''
222 pr=''
223 rm=''
224 rmail=''
225 sed=''
226 sendmail=''
227 shar=''
228 sleep=''
229 smail=''
230 sort=''
231 submit=''
232 tail=''
233 tar=''
234 tbl=''
235 tee=''
236 test=''
237 touch=''
238 tr=''
239 troff=''
240 uname=''
241 uniq=''
242 uuname=''
243 vi=''
244 zcat=''
245 zip=''
246 full_ar=''
247 full_sed=''
248 libswanted=''
249 hint=''
250 myuname=''
251 osname=''
252 osvers=''
253 Author=''
254 Date=''
255 Header=''
256 Id=''
257 Locker=''
258 Log=''
259 RCSfile=''
260 Revision=''
261 Source=''
262 State=''
263 _a=''
264 _exe=''
265 _o=''
266 archobjs=''
267 exe_ext=''
268 firstmakefile=''
269 lib_ext=''
270 obj_ext=''
271 path_sep=''
272 afs=''
273 alignbytes=''
274 ansi2knr=''
275 archlib=''
276 archlibexp=''
277 d_archlib=''
278 installarchlib=''
279 archname=''
280 myarchname=''
281 baserev=''
282 bin=''
283 binexp=''
284 installbin=''
285 byteorder=''
286 cc=''
287 gccversion=''
288 ccflags=''
289 cppflags=''
290 ldflags=''
291 lkflags=''
292 locincpth=''
293 optimize=''
294 cf_email=''
295 cf_by=''
296 cf_time=''
297 contains=''
298 cpp_stuff=''
299 cpplast=''
300 cppminus=''
301 cpprun=''
302 cppstdin=''
303 crosscompile=''
304 d_access=''
305 d_accessx=''
306 d_alarm=''
307 d_attribut=''
308 d_bcmp=''
309 d_bcopy=''
310 d_bzero=''
311 d_casti32=''
312 castflags=''
313 d_castneg=''
314 d_chown=''
315 d_chroot=''
316 d_chsize=''
317 d_closedir=''
318 d_void_closedir=''
319 d_const=''
320 cryptlib=''
321 d_crypt=''
322 d_csh=''
323 full_csh=''
324 d_cuserid=''
325 d_dbl_dig=''
326 d_difftime=''
327 d_dlerror=''
328 d_dlopen=''
329 d_dlsymun=''
330 d_dosuid=''
331 d_suidsafe=''
332 d_drand48proto=''
333 d_dup2=''
334 d_eaccess=''
335 d_endgrent=''
336 d_endhent=''
337 d_endnent=''
338 d_endpent=''
339 d_endpwent=''
340 d_endsent=''
341 d_endspent=''
342 d_fchmod=''
343 d_fchown=''
344 d_fcntl=''
345 d_fd_macros=''
346 d_fd_set=''
347 d_fds_bits=''
348 d_fgetpos=''
349 d_flexfnam=''
350 d_flock=''
351 d_fork=''
352 d_fseeko=''
353 d_fsetpos=''
354 d_ftello=''
355 d_ftime=''
356 d_gettimeod=''
357 d_Gconvert=''
358 d_getgrent=''
359 d_getgrps=''
360 d_gethbyaddr=''
361 d_gethbyname=''
362 d_gethent=''
363 aphostname=''
364 d_gethname=''
365 d_phostname=''
366 d_uname=''
367 d_gethostprotos=''
368 d_getlogin=''
369 d_getmntent=''
370 d_getnbyaddr=''
371 d_getnbyname=''
372 d_getnent=''
373 d_getnetprotos=''
374 d_getpent=''
375 d_getpgid=''
376 d_getpgrp2=''
377 d_bsdgetpgrp=''
378 d_getpgrp=''
379 d_getppid=''
380 d_getprior=''
381 d_getpbyname=''
382 d_getpbynumber=''
383 d_getprotoprotos=''
384 d_getpwent=''
385 d_getsent=''
386 d_getservprotos=''
387 d_getspent=''
388 d_getspnam=''
389 d_getsbyname=''
390 d_getsbyport=''
391 d_gnulibc=''
392 d_hasmntopt=''
393 d_htonl=''
394 d_inetaton=''
395 d_isascii=''
396 d_killpg=''
397 d_lchown=''
398 d_link=''
399 d_locconv=''
400 d_lockf=''
401 d_longdbl=''
402 longdblsize=''
403 d_longlong=''
404 longlongsize=''
405 d_lstat=''
406 d_madvise=''
407 d_mblen=''
408 d_mbstowcs=''
409 d_mbtowc=''
410 d_memchr=''
411 d_memcmp=''
412 d_memcpy=''
413 d_memmove=''
414 d_memset=''
415 d_mkdir=''
416 d_mkfifo=''
417 d_mktime=''
418 d_mmap=''
419 mmaptype=''
420 d_mprotect=''
421 d_msg=''
422 d_msgctl=''
423 d_msgget=''
424 d_msgrcv=''
425 d_msgsnd=''
426 d_msync=''
427 d_munmap=''
428 d_nice=''
429 d_open3=''
430 d_fpathconf=''
431 d_pathconf=''
432 d_pause=''
433 d_pipe=''
434 d_poll=''
435 d_portable=''
436 d_old_pthread_create_joinable=''
437 old_pthread_create_joinable=''
438 d_pthread_yield=''
439 d_sched_yield=''
440 sched_yield=''
441 d_readdir=''
442 d_rewinddir=''
443 d_seekdir=''
444 d_telldir=''
445 d_readlink=''
446 d_readv=''
447 d_rename=''
448 d_rmdir=''
449 d_safebcpy=''
450 d_safemcpy=''
451 d_sanemcmp=''
452 d_select=''
453 d_sem=''
454 d_semctl=''
455 d_semget=''
456 d_semop=''
457 d_setegid=''
458 d_seteuid=''
459 d_setgrent=''
460 d_setgrps=''
461 d_sethent=''
462 d_setlinebuf=''
463 d_setlocale=''
464 d_setnent=''
465 d_setpent=''
466 d_setpgid=''
467 d_setpgrp2=''
468 d_bsdsetpgrp=''
469 d_setpgrp=''
470 d_setprior=''
471 d_setpwent=''
472 d_setregid=''
473 d_setresgid=''
474 d_setresuid=''
475 d_setreuid=''
476 d_setrgid=''
477 d_setruid=''
478 d_setsent=''
479 d_setsid=''
480 d_setspent=''
481 d_setvbuf=''
482 d_sfio=''
483 usesfio=''
484 d_shm=''
485 d_shmat=''
486 d_shmatprototype=''
487 shmattype=''
488 d_shmctl=''
489 d_shmdt=''
490 d_shmget=''
491 d_sigaction=''
492 d_sigsetjmp=''
493 d_cmsghdr_s=''
494 d_msg_ctrunc=''
495 d_msg_dontroute=''
496 d_msg_oob=''
497 d_msg_peek=''
498 d_msg_proxy=''
499 d_msghdr_s=''
500 d_oldsock=''
501 d_recvmsg=''
502 d_scm_rights=''
503 d_sendmsg=''
504 d_socket=''
505 d_sockpair=''
506 sockethdr=''
507 socketlib=''
508 d_statblks=''
509 d_fstatfs=''
510 d_statfs=''
511 d_statfsflags=''
512 d_fstatvfs=''
513 d_statvfs=''
514 d_stdio_cnt_lval=''
515 d_stdio_ptr_lval=''
516 d_stdiobase=''
517 d_stdstdio=''
518 stdio_base=''
519 stdio_bufsiz=''
520 stdio_cnt=''
521 stdio_filbuf=''
522 stdio_ptr=''
523 d_index=''
524 d_strchr=''
525 d_strcoll=''
526 d_strctcpy=''
527 d_strerrm=''
528 d_strerror=''
529 d_sysernlst=''
530 d_syserrlst=''
531 d_strtod=''
532 d_strtol=''
533 d_strtoul=''
534 d_strxfrm=''
535 d_symlink=''
536 d_syscall=''
537 d_sysconf=''
538 d_system=''
539 d_tcgetpgrp=''
540 d_tcsetpgrp=''
541 d_telldirproto=''
542 d_time=''
543 timetype=''
544 clocktype=''
545 d_times=''
546 d_truncate=''
547 d_tzname=''
548 d_umask=''
549 d_semctl_semid_ds=''
550 d_semctl_semun=''
551 d_union_semun=''
552 d_vfork=''
553 usevfork=''
554 d_voidsig=''
555 signal_t=''
556 d_volatile=''
557 d_charvspr=''
558 d_vprintf=''
559 d_wait4=''
560 d_waitpid=''
561 d_wcstombs=''
562 d_wctomb=''
563 d_writev=''
564 d_dbmclose64=''
565 d_dbminit64=''
566 d_delete64=''
567 d_fetch64=''
568 d_firstkey64=''
569 d_nextkey64=''
570 d_store64=''
571 dlext=''
572 cccdlflags=''
573 ccdlflags=''
574 dlsrc=''
575 ld=''
576 lddlflags=''
577 usedl=''
578 doublesize=''
579 ebcdic=''
580 fflushNULL=''
581 fflushall=''
582 fpostype=''
583 gidtype=''
584 groupstype=''
585 h_fcntl=''
586 h_sysfile=''
587 i_arpainet=''
588 db_hashtype=''
589 db_prefixtype=''
590 i_db=''
591 i_dbm=''
592 i_rpcsvcdbm=''
593 d_dirnamlen=''
594 direntrytype=''
595 i_dirent=''
596 i_dld=''
597 i_dlfcn=''
598 i_fcntl=''
599 i_float=''
600 i_gdbm=''
601 d_grpasswd=''
602 i_grp=''
603 d_int64t=''
604 i_inttypes=''
605 i_limits=''
606 i_locale=''
607 i_machcthr=''
608 i_malloc=''
609 i_math=''
610 i_memory=''
611 i_mntent=''
612 i_ndbm=''
613 i_netdb=''
614 i_neterrno=''
615 i_netinettcp=''
616 i_niin=''
617 i_sysin=''
618 i_poll=''
619 i_pthread=''
620 d_pwage=''
621 d_pwchange=''
622 d_pwclass=''
623 d_pwcomment=''
624 d_pwexpire=''
625 d_pwgecos=''
626 d_pwpasswd=''
627 d_pwquota=''
628 i_pwd=''
629 i_sfio=''
630 i_shadow=''
631 i_socks=''
632 i_stddef=''
633 i_stdlib=''
634 i_string=''
635 strings=''
636 i_sysaccess=''
637 i_sysdir=''
638 i_sysfile=''
639 d_voidtty=''
640 i_bsdioctl=''
641 i_sysfilio=''
642 i_sysioctl=''
643 i_syssockio=''
644 i_sysmman=''
645 i_sysmount=''
646 i_sysndir=''
647 i_sysparam=''
648 i_sysresrc=''
649 i_syssecrt=''
650 i_sysselct=''
651 i_sysstat=''
652 i_sysstatvfs=''
653 i_systimes=''
654 i_systypes=''
655 d_iovec_s=''
656 i_sysuio=''
657 i_sysun=''
658 i_syswait=''
659 i_sgtty=''
660 i_termio=''
661 i_termios=''
662 i_systime=''
663 i_systimek=''
664 i_time=''
665 timeincl=''
666 i_unistd=''
667 i_utime=''
668 i_values=''
669 i_stdarg=''
670 i_varargs=''
671 i_varhdr=''
672 i_vfork=''
673 installusrbinperl=''
674 intsize=''
675 longsize=''
676 shortsize=''
677 d_dirent64_s=''
678 d_flock64_s=''
679 d_fstat64=''
680 d_ftruncate64=''
681 d_ino64_t=''
682 d_llseek=''
683 d_lockf64=''
684 d_lseek64=''
685 d_lstat64=''
686 d_off64_t=''
687 d_offset_t=''
688 d_open64=''
689 d_opendir64=''
690 d_readdir64=''
691 d_seekdir64=''
692 d_stat64=''
693 d_telldir64=''
694 d_truncate64=''
695 libc=''
696 libperl=''
697 shrpenv=''
698 useshrplib=''
699 glibpth=''
700 libpth=''
701 loclibpth=''
702 plibpth=''
703 xlibpth=''
704 ignore_versioned_solibs=''
705 libs=''
706 lns=''
707 lseeksize=''
708 lseektype=''
709 make_set_make=''
710 d_mymalloc=''
711 freetype=''
712 mallocobj=''
713 mallocsrc=''
714 malloctype=''
715 usemymalloc=''
716 installman1dir=''
717 man1dir=''
718 man1direxp=''
719 man1ext=''
720 installman3dir=''
721 man3dir=''
722 man3direxp=''
723 man3ext=''
724 huge=''
725 large=''
726 medium=''
727 models=''
728 small=''
729 split=''
730 modetype=''
731 multiarch=''
732 mydomain=''
733 myhostname=''
734 phostname=''
735 c=''
736 n=''
737 d_eofnblk=''
738 eagain=''
739 o_nonblock=''
740 rd_nodata=''
741 netdb_hlen_type=''
742 netdb_host_type=''
743 netdb_name_type=''
744 netdb_net_type=''
745 groupcat=''
746 hostcat=''
747 passcat=''
748 orderlib=''
749 ranlib=''
750 package=''
751 spackage=''
752 pager=''
753 apiversion=''
754 patchlevel=''
755 subversion=''
756 version=''
757 perladmin=''
758 perlpath=''
759 pidtype=''
760 prefix=''
761 prefixexp=''
762 installprivlib=''
763 privlib=''
764 privlibexp=''
765 prototype=''
766 ptrsize=''
767 drand01=''
768 randbits=''
769 randfunc=''
770 randseedtype=''
771 seedfunc=''
772 installscript=''
773 scriptdir=''
774 scriptdirexp=''
775 selectminbits=''
776 selecttype=''
777 sh=''
778 sig_count=''
779 sig_name=''
780 sig_name_init=''
781 sig_num=''
782 sig_num_init=''
783 installsitearch=''
784 sitearch=''
785 sitearchexp=''
786 installsitelib=''
787 sitelib=''
788 sitelibexp=''
789 sizetype=''
790 so=''
791 sharpbang=''
792 shsharp=''
793 spitshell=''
794 src=''
795 ssizetype=''
796 startperl=''
797 startsh=''
798 stdchar=''
799 d_fgetpos64=''
800 d_fopen64=''
801 d_freopen64=''
802 d_fseek64=''
803 d_fseeko64=''
804 d_fsetpos64=''
805 d_ftell64=''
806 d_ftello64=''
807 d_tmpfile64=''
808 d_stdio_stream_array=''
809 stdio_stream_array=''
810 sysman=''
811 trnl=''
812 uidtype=''
813 archname64=''
814 use64bits=''
815 usemultiplicity=''
816 nm_opt=''
817 nm_so_opt=''
818 runnm=''
819 usenm=''
820 useperlio=''
821 d_oldpthreads=''
822 usethreads=''
823 incpath=''
824 mips=''
825 mips_type=''
826 usrinc=''
827 defvoidused=''
828 voidflags=''
829 CONFIG=''
830
831 define='define'
832 undef='undef'
833 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
834 rmlist=''
835
836 : We must find out about Eunice early
837 eunicefix=':'
838 if test -f /etc/unixtovms; then
839         eunicefix=/etc/unixtovms
840 fi
841 if test -f /etc/unixtovms.exe; then
842         eunicefix=/etc/unixtovms.exe
843 fi
844
845 i_whoami=''
846 : Possible local include directories to search.
847 : Set locincpth to "" in a hint file to defeat local include searches.
848 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
849 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
850 :
851 : no include file wanted by default
852 inclwanted=''
853
854 : list of known cpp symbols, sorted alphabetically
855 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
856 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
857 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
858 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
859 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
860 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
861 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
862 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
863 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
864 al="$al VMS Xenix286"
865 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
866 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
867 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
868 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
869 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
870 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
871 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
872 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
873 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
874 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
875 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
876 al="$al __SVR4_2__ __UMAXV__"
877 al="$al ____386BSD____ __alpha __alpha__ __amiga"
878 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
879 al="$al __host_mips__"
880 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
881 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
882 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
883 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
884 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
885 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
886 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
887 al="$al __mc88100 __mc88100__ __mips __mips__"
888 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
889 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
890 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
891 al="$al _host_mips _mips _unix"
892 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
893 al="$al apollo ardent att386 att3b"
894 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
895 al="$al cadmus clipper concurrent convex cray ctix"
896 al="$al dmert encore gcos gcx gimpel gould"
897 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
898 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
899 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
900 al="$al i186 i286 i386 i486 i8086"
901 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
902 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
903 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
904 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
905 al="$al mc88000 mc88100 merlin mert mips mvs n16"
906 al="$al ncl_el ncl_mr"
907 al="$al news1500 news1700 news1800 news1900 news3700"
908 al="$al news700 news800 news900 ns16000 ns32000"
909 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
910 al="$al parisc pc532 pdp11 plexus posix pyr"
911 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
912 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
913 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
914 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
915 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
916 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
917 al="$al xenix z8000"
918
919 : Trailing extension.  Override this in a hint file, if needed.
920 _exe=''
921 : Extra object files, if any, needed on this platform.
922 archobjs=''
923 groupstype=''
924 : change the next line if compiling for Xenix/286 on Xenix/386
925 xlibpth='/usr/lib/386 /lib/386'
926
927 : Possible local library directories to search.
928 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
929 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
930
931 : general looking path for locating libraries
932 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
933 glibpth="$glibpth /lib /usr/lib $xlibpth"
934 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
935 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
936
937 : Private path used by Configure to find libraries.  Its value
938 : is prepended to libpth. This variable takes care of special
939 : machines, like the mips.  Usually, it should be empty.
940 plibpth=''
941
942 : default library list
943 libswanted=''
944 : some systems want to use only the non-versioned libso:s
945 ignore_versioned_solibs=''
946 : full support for void wanted by default
947 defvoidused=15
948
949 : set useposix=false in your hint file to disable the POSIX extension.
950 useposix=true
951 : set useopcode=false in your hint file to disable the Opcode extension.
952 useopcode=true
953 : set usemultiplicity on the Configure command line to enable multiplicity.
954 : set usethreads on the Configure command line to enable threads.
955 : List of libraries we want.
956 : If anyone needs -lnet, put it in a hint file.
957 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
958 libswanted="$libswanted dld ld sun m rt c cposix posix"
959 libswanted="$libswanted ndir dir crypt sec"
960 libswanted="$libswanted ucb bsd BSD PW x"
961 : We probably want to search /usr/shlib before most other libraries.
962 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
963 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
964 glibpth="/usr/shlib $glibpth"
965 : Do not use vfork unless overridden by a hint file.
966 usevfork=false
967
968 : Find the basic shell for Bourne shell scripts
969 case "$sh" in
970 '')
971         case "$SYSTYPE" in
972         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
973         *) xxx='/bin/sh';;
974         esac
975         if test -f "$xxx"; then
976                 sh="$xxx"
977         else
978                 : Build up a list and do a single loop so we can 'break' out.
979                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
980                 for xxx in sh bash ksh pdksh ash; do
981                         for p in $pth; do
982                                 try="$try ${p}/${xxx}"
983                         done
984                 done
985                 for xxx in $try; do
986                         if test -f "$xxx"; then
987                                 sh="$xxx";
988                                 break
989                         elif test -f "$xxx.exe"; then
990                                 sh="$xxx";
991                                 break
992                         fi
993                 done
994         fi
995         ;;
996 esac
997
998 case "$sh" in
999 '')     cat <<EOM >&2
1000 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
1001
1002 Usually it's in /bin/sh.  How did you even get this far?
1003 Please contact me (Perl Maintainers) at perlbug@perl.com and 
1004 we'll try to straighten this all out.
1005 EOM
1006         exit 1
1007         ;;
1008 esac
1009
1010 : see if sh knows # comments
1011 if `$sh -c '#' >/dev/null 2>&1`; then
1012         shsharp=true
1013         spitshell=cat
1014         xcat=/bin/cat
1015         test -f $xcat || xcat=/usr/bin/cat
1016         echo "#!$xcat" >try
1017         $eunicefix try
1018         chmod +x try
1019         ./try > today
1020         if test -s today; then
1021                 sharpbang='#!'
1022         else
1023                 echo "#! $xcat" > try
1024                 $eunicefix try
1025                 chmod +x try
1026                 ./try > today
1027                 if test -s today; then
1028                         sharpbang='#! '
1029                 else
1030                         sharpbang=': use '
1031                 fi
1032         fi
1033 else
1034         echo " "
1035         echo "Your $sh doesn't grok # comments--I will strip them later on."
1036         shsharp=false
1037         cd ..
1038         echo "exec grep -v '^[  ]*#'" >spitshell
1039         chmod +x spitshell
1040         $eunicefix spitshell
1041         spitshell=`pwd`/spitshell
1042         cd UU
1043         echo "I presume that if # doesn't work, #! won't work either!"
1044         sharpbang=': use '
1045 fi
1046 rm -f try today
1047
1048 : figure out how to guarantee sh startup
1049 case "$startsh" in
1050 '') startsh=${sharpbang}${sh} ;;
1051 *)
1052 esac
1053 cat >try <<EOSS
1054 $startsh
1055 set abc
1056 test "$?abc" != 1
1057 EOSS
1058
1059 chmod +x try
1060 $eunicefix try
1061 if ./try; then
1062         : echo "Yup, it does."
1063 else
1064         echo "Hmm... '$startsh' does not guarantee sh startup..."
1065         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1066 fi
1067 rm -f try
1068
1069
1070 : Save command line options in file UU/cmdline.opt for later use in
1071 : generating config.sh.
1072 cat > cmdline.opt <<EOSH
1073 # Configure command line arguments.
1074 config_arg0='$0'
1075 config_args='$*'
1076 config_argc=$#
1077 EOSH
1078 argn=1
1079 for arg in "$@"; do
1080         cat >>cmdline.opt <<EOSH
1081 config_arg$argn='$arg'
1082 EOSH
1083         argn=`expr $argn + 1`
1084 done
1085
1086 : produce awk script to parse command line options
1087 cat >options.awk <<'EOF'
1088 BEGIN {
1089         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1090
1091         len = length(optstr);
1092         for (i = 1; i <= len; i++) {
1093                 c = substr(optstr, i, 1);
1094                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1095                 if (a == ":") {
1096                         arg[c] = 1;
1097                         i++;
1098                 }
1099                 opt[c] = 1;
1100         }
1101 }
1102 {
1103         expect = 0;
1104         str = $0;
1105         if (substr(str, 1, 1) != "-") {
1106                 printf("'%s'\n", str);
1107                 next;
1108         }
1109         len = length($0);
1110         for (i = 2; i <= len; i++) {
1111                 c = substr(str, i, 1);
1112                 if (!opt[c]) {
1113                         printf("-%s\n", substr(str, i));
1114                         next;
1115                 }
1116                 printf("-%s\n", c);
1117                 if (arg[c]) {
1118                         if (i < len)
1119                                 printf("'%s'\n", substr(str, i + 1));
1120                         else
1121                                 expect = 1;
1122                         next;
1123                 }
1124         }
1125 }
1126 END {
1127         if (expect)
1128                 print "?";
1129 }
1130 EOF
1131
1132 : process the command line options
1133 set X `for arg in "$@"; do echo "X$arg"; done |
1134         sed -e s/X// | awk -f options.awk`
1135 eval "set $*"
1136 shift
1137 rm -f options.awk
1138
1139 : set up default values
1140 fastread=''
1141 reuseval=false
1142 config_sh=''
1143 alldone=''
1144 error=''
1145 silent=''
1146 extractsh=''
1147 override=''
1148 knowitall=''
1149 rm -f optdef.sh
1150 cat >optdef.sh <<EOS
1151 $startsh
1152 EOS
1153
1154
1155 : option parsing
1156 while test $# -gt 0; do
1157         case "$1" in
1158         -d) shift; fastread=yes;;
1159         -e) shift; alldone=cont;;
1160         -f)
1161                 shift
1162                 cd ..
1163                 if test -r "$1"; then
1164                         config_sh="$1"
1165                 else
1166                         echo "$me: cannot read config file $1." >&2
1167                         error=true
1168                 fi
1169                 cd UU
1170                 shift;;
1171         -h) shift; error=true;;
1172         -r) shift; reuseval=true;;
1173         -s) shift; silent=true; realsilent=true;;
1174         -E) shift; alldone=exit;;
1175         -K) shift; knowitall=true;;
1176         -O) shift; override=true;;
1177         -S) shift; silent=true; extractsh=true;;
1178         -D)
1179                 shift
1180                 case "$1" in
1181                 *=)
1182                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1183                         echo "$me: ignoring -D $1" >&2
1184                         ;;
1185                 *=*) echo "$1" | \
1186                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1187                 *) echo "$1='define'" >> optdef.sh;;
1188                 esac
1189                 shift
1190                 ;;
1191         -U)
1192                 shift
1193                 case "$1" in
1194                 *=) echo "$1" >> optdef.sh;;
1195                 *=*)
1196                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1197                         echo "$me: ignoring -U $1" >&2
1198                         ;;
1199                 *) echo "$1='undef'" >> optdef.sh;;
1200                 esac
1201                 shift
1202                 ;;
1203         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1204                 exit 0;;
1205         --) break;;
1206         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1207         *) break;;
1208         esac
1209 done
1210
1211 case "$error" in
1212 true)
1213         cat >&2 <<EOM
1214 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1215                  [-U symbol] [-U symbol=]
1216   -d : use defaults for all answers.
1217   -e : go on without questioning past the production of config.sh.
1218   -f : specify an alternate default configuration file.
1219   -h : print this help message and exit (with an error status).
1220   -r : reuse C symbols value if possible (skips costly nm extraction).
1221   -s : silent mode, only echoes questions and essential information.
1222   -D : define symbol to have some value:
1223          -D symbol         symbol gets the value 'define'
1224          -D symbol=value   symbol gets the value 'value'
1225   -E : stop at the end of questions, after having produced config.sh.
1226   -K : do not use unless you know what you are doing.
1227   -O : let -D and -U override definitions from loaded configuration file.
1228   -S : perform variable substitutions on all .SH files (can mix with -f)
1229   -U : undefine symbol:
1230          -U symbol    symbol gets the value 'undef'
1231          -U symbol=   symbol gets completely empty
1232   -V : print version number and exit (with a zero status).
1233 EOM
1234         exit 1
1235         ;;
1236 esac
1237
1238 : Sanity checks
1239 case "$fastread$alldone" in
1240 yescont|yesexit) ;;
1241 *)
1242         if test ! -t 0; then
1243                 echo "Say 'sh Configure', not 'sh <Configure'"
1244                 exit 1
1245         fi
1246         ;;
1247 esac
1248
1249 exec 4>&1
1250 case "$silent" in
1251 true) exec 1>/dev/null;;
1252 esac
1253
1254 : run the defines and the undefines, if any, but leave the file out there...
1255 touch optdef.sh
1256 . ./optdef.sh
1257
1258 : set package name
1259 package=perl5
1260 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1261 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1262 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1263 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1264 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1265 esac
1266
1267 : Some greps do not return status, grrr.
1268 echo "grimblepritz" >grimble
1269 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1270         contains=contains
1271 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1272         contains=grep
1273 else
1274         contains=contains
1275 fi
1276 rm -f grimble
1277 : the following should work in any shell
1278 case "$contains" in
1279 contains*)
1280         echo " "
1281         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1282         cat >contains <<'EOSS'
1283 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1284 EOSS
1285 chmod +x contains
1286 esac
1287
1288 : Find the path to the source tree
1289 case "$src" in
1290 '') case "$0" in
1291     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1292     *)   src='.';;
1293     esac;;
1294 esac
1295 case "$src" in
1296 '')     src=/
1297         rsrc=/
1298         ;;
1299 /*) rsrc="$src";;
1300 *) rsrc="../$src";;
1301 esac
1302 if test -f $rsrc/Configure && \
1303         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1304 then
1305    : found it, so we are ok.
1306 else
1307         rsrc=''
1308         for src in . .. ../.. ../../.. ../../../..; do
1309                 if test -f ../$src/Configure && \
1310                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1311                 then
1312                         rsrc=../$src
1313                         break
1314                 fi
1315         done
1316 fi
1317 case "$rsrc" in
1318 '')
1319         cat <<EOM >&4
1320
1321 Sorry, I can't seem to locate the source dir for $package.  Please start
1322 Configure with an explicit path -- i.e. /some/path/Configure.
1323
1324 EOM
1325         exit 1
1326         ;;
1327 ../.)   rsrc='..';;
1328 *)
1329         echo " "
1330         echo "Sources for $package found in \"$src\"." >&4
1331         ;;
1332 esac
1333
1334 : script used to extract .SH files with variable substitutions
1335 cat >extract <<'EOS'
1336 CONFIGDOTSH=true
1337 echo "Doing variable substitutions on .SH files..."
1338 if test -f $src/MANIFEST; then
1339         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1340 else
1341         echo "(Looking for .SH files under the source directory.)"
1342         set x `(cd $src; find . -name "*.SH" -print)`
1343 fi
1344 shift
1345 case $# in
1346 0) set x `(cd $src; echo *.SH)`; shift;;
1347 esac
1348 if test ! -f $src/$1; then
1349         shift
1350 fi
1351 mkdir_p='
1352 name=$1;
1353 create="";
1354 while test $name; do
1355         if test ! -d "$name"; then
1356                 create="$name $create";
1357                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1358                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1359         else
1360                 name="";
1361         fi;
1362 done;
1363 for file in $create; do
1364         mkdir $file;
1365 done
1366 '
1367 for file in $*; do
1368         case "$src" in
1369         ".")
1370                 case "$file" in
1371                 */*)
1372                         dir=`expr X$file : 'X\(.*\)/'`
1373                         file=`expr X$file : 'X.*/\(.*\)'`
1374                         (cd $dir && . ./$file)
1375                         ;;
1376                 *)
1377                         . ./$file
1378                         ;;
1379                 esac
1380                 ;;
1381         *)
1382                 case "$file" in
1383                 */*)
1384                         dir=`expr X$file : 'X\(.*\)/'`
1385                         file=`expr X$file : 'X.*/\(.*\)'`
1386                         (set x $dir; shift; eval $mkdir_p)
1387                         sh <$src/$dir/$file
1388                         ;;
1389                 *)
1390                         sh <$src/$file
1391                         ;;
1392                 esac
1393                 ;;
1394         esac
1395 done
1396 if test -f $src/config_h.SH; then
1397         if test ! -f config.h; then
1398         : oops, they left it out of MANIFEST, probably, so do it anyway.
1399         . $src/config_h.SH
1400         fi
1401 fi
1402 EOS
1403
1404 : extract files and exit if asked to do so
1405 case "$extractsh" in
1406 true)
1407         case "$realsilent" in
1408         true) ;;
1409         *) exec 1>&4;;
1410         esac
1411         case "$config_sh" in
1412         '') config_sh='config.sh';;
1413         esac
1414         echo " "
1415         echo "Fetching answers from $config_sh..."
1416         cd ..
1417         . $config_sh
1418         test "$override" && . ./optdef.sh
1419         echo " "
1420         . UU/extract
1421         rm -rf UU
1422         echo "Done."
1423         exit 0
1424         ;;
1425 esac
1426
1427 : Eunice requires " " instead of "", can you believe it
1428 echo " "
1429 : Here we go...
1430 echo "Beginning of configuration questions for $package."
1431
1432 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1433
1434 : first determine how to suppress newline on echo command
1435 echo " "
1436 echo "Checking echo to see how to suppress newlines..."
1437 (echo "hi there\c" ; echo " ") >.echotmp
1438 if $contains c .echotmp >/dev/null 2>&1 ; then
1439         echo "...using -n."
1440         n='-n'
1441         c=''
1442 else
1443         cat <<'EOM'
1444 ...using \c
1445 EOM
1446         n=''
1447         c='\c'
1448 fi
1449 echo $n "The star should be here-->$c"
1450 echo '*'
1451 rm -f .echotmp
1452
1453 : Now test for existence of everything in MANIFEST
1454 echo " "
1455 if test -f $rsrc/MANIFEST; then
1456         echo "First let's make sure your kit is complete.  Checking..." >&4
1457         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1458         rm -f missing
1459         tmppwd=`pwd`
1460         for filelist in x??; do
1461                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1462         done
1463         if test -s missing; then
1464                 cat missing >&4
1465                 cat >&4 <<'EOM'
1466
1467 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1468
1469 You have the option of continuing the configuration process, despite the
1470 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1471 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1472 and contact the author (perlbug@perl.com).
1473
1474 EOM
1475                 echo $n "Continue? [n] $c" >&4
1476                 read ans
1477                 case "$ans" in
1478                 y*)
1479                         echo "Continuing..." >&4
1480                         rm -f missing
1481                         ;;
1482                 *)
1483                         echo "ABORTING..." >&4
1484                         kill $$
1485                         ;;
1486                 esac
1487         else
1488                 echo "Looks good..."
1489         fi
1490 else
1491         echo "There is no MANIFEST file.  I hope your kit is complete !"
1492 fi
1493 rm -f missing x??
1494
1495 echo " "
1496 : Find the appropriate value for a newline for tr
1497 if test -n "$DJGPP"; then
1498        trnl='\012'
1499 fi
1500 if test X"$trnl" = X; then
1501         case "`echo foo|tr '\n' x 2>/dev/null`" in
1502         foox) trnl='\n' ;;
1503         esac
1504 fi
1505 if test X"$trnl" = X; then
1506         case "`echo foo|tr '\012' x 2>/dev/null`" in
1507         foox) trnl='\012' ;;
1508         esac
1509 fi
1510 if test X"$trnl" = X; then
1511         cat <<EOM >&2
1512
1513 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1514
1515 EOM
1516         exit 1
1517 fi
1518
1519 : compute the number of columns on the terminal for proper question formatting
1520 case "$COLUMNS" in
1521 '') COLUMNS='80';;
1522 esac
1523
1524 : set up the echo used in my read
1525 myecho="case \"\$xxxm\" in
1526 '') echo $n \"\$rp $c\" >&4;;
1527 *) case \"\$rp\" in
1528         '') echo $n \"[\$xxxm] $c\";;
1529         *)
1530                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1531                         echo \"\$rp\" >&4
1532                         echo $n \"[\$xxxm] $c\" >&4
1533                 else
1534                         echo $n \"\$rp [\$xxxm] $c\" >&4
1535                 fi
1536                 ;;
1537         esac;;
1538 esac"
1539
1540 : now set up to do reads with possible shell escape and default assignment
1541 cat <<EOSC >myread
1542 $startsh
1543 xxxm=\$dflt
1544 $myecho
1545 ans='!'
1546 case "\$fastread" in
1547 yes) case "\$dflt" in
1548         '') ;;
1549         *) ans='';
1550                 case "\$silent-\$rp" in
1551                 true-) ;;
1552                 *) echo " " >&4;;
1553                 esac;;
1554         esac;;
1555 *) case "\$silent" in
1556         true) case "\$rp" in
1557                 '') ans='';;
1558                 esac;;
1559         esac;;
1560 esac
1561 while expr "X\$ans" : "X!" >/dev/null; do
1562         read answ
1563         set x \$xxxm
1564         shift
1565         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1566         case  "\$answ" in
1567         "!")
1568                 sh 1>&4
1569                 echo " "
1570                 $myecho
1571                 ;;
1572         !*)
1573                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1574                 shift
1575                 sh 1>&4 -c "\$*"
1576                 echo " "
1577                 $myecho
1578                 ;;
1579         "\$ans")
1580                 case "\$ans" in
1581                 \\&*)
1582                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1583                         shift
1584                         case "\$1" in
1585                         -d)
1586                                 fastread=yes
1587                                 echo "(OK, I'll run with -d after this question.)" >&4
1588                                 ;;
1589                         -*)
1590                                 echo "*** Sorry, \$1 not supported yet." >&4
1591                                 ;;
1592                         esac
1593                         $myecho
1594                         ans=!
1595                         ;;
1596                 esac;;
1597         *)
1598                 case "\$aok" in
1599                 y)
1600                         echo "*** Substitution done -- please confirm."
1601                         xxxm="\$ans"
1602                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1603                         xxxm="\$ans"
1604                         ans=!
1605                         ;;
1606                 *)
1607                         echo "*** Error -- try again."
1608                         ans=!
1609                         ;;
1610                 esac
1611                 $myecho
1612                 ;;
1613         esac
1614         case "\$ans\$xxxm\$nostick" in
1615         '')
1616                 ans=!
1617                 $myecho
1618                 ;;
1619         esac
1620 done
1621 case "\$ans" in
1622 '') ans="\$xxxm";;
1623 esac
1624 EOSC
1625
1626 : create .config dir to save info across Configure sessions
1627 test -d ../.config || mkdir ../.config
1628 cat >../.config/README <<EOF
1629 This directory created by Configure to save information that should
1630 persist across sessions for $package.
1631
1632 You may safely delete it if you wish.
1633 EOF
1634
1635 : general instructions
1636 needman=true
1637 firsttime=true
1638 user=`(logname) 2>/dev/null`
1639 case "$user" in
1640 '') user=`whoami 2>&1`;;
1641 esac
1642 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1643         firsttime=false
1644         echo " "
1645         rp='Would you like to see the instructions?'
1646         dflt=n
1647         . ./myread
1648         case "$ans" in
1649         [yY]*) ;;
1650         *) needman=false;;
1651         esac
1652 fi
1653 if $needman; then
1654         cat <<EOH
1655
1656 This installation shell script will examine your system and ask you questions
1657 to determine how the perl5 package should be installed. If you get
1658 stuck on a question, you may use a ! shell escape to start a subshell or
1659 execute a command.  Many of the questions will have default answers in square
1660 brackets; typing carriage return will give you the default.
1661
1662 On some of the questions which ask for file or directory names you are allowed
1663 to use the ~name construct to specify the login directory belonging to "name",
1664 even if you don't have a shell which knows about that.  Questions where this is
1665 allowed will be marked "(~name ok)".
1666
1667 EOH
1668         rp=''
1669         dflt='Type carriage return to continue'
1670         . ./myread
1671         cat <<'EOH'
1672
1673 The prompter used in this script allows you to use shell variables and
1674 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1675 in the default answer, as if the default line was a set of arguments given to a
1676 script shell.  This means you may also use $* to repeat the whole default line,
1677 so you do not have to re-type everything to add something to the default.
1678
1679 Everytime there is a substitution, you will have to confirm.  If there is an
1680 error (e.g. an unmatched backtick), the default answer will remain unchanged
1681 and you will be prompted again.
1682
1683 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1684 the questions and use the computed defaults (or the previous answers if there
1685 was already a config.sh file). Type 'Configure -h' for a list of options.
1686 You may also start interactively and then answer '& -d' at any prompt to turn
1687 on the non-interactive behaviour for the remainder of the execution.
1688
1689 EOH
1690         . ./myread
1691         cat <<EOH
1692
1693 Much effort has been expended to ensure that this shell script will run on any
1694 Unix system.  If despite that it blows up on yours, your best bet is to edit
1695 Configure and run it again.  If you can't run Configure for some reason,
1696 you'll have to generate a config.sh file by hand.  Whatever problems you
1697 have, let me (perlbug@perl.com) know how I blew it.
1698
1699 This installation script affects things in two ways:
1700
1701 1) it may do direct variable substitutions on some of the files included
1702    in this kit.
1703 2) it builds a config.h file for inclusion in C programs.  You may edit
1704    any of these files as the need arises after running this script.
1705
1706 If you make a mistake on a question, there is no easy way to back up to it
1707 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1708 files.  Configure will offer to let you do this before it runs the SH files.
1709
1710 EOH
1711         dflt='Type carriage return to continue'
1712         . ./myread
1713         case "$firsttime" in
1714         true) echo $user >>../.config/instruct;;
1715         esac
1716 fi
1717
1718 : find out where common programs are
1719 echo " "
1720 echo "Locating common programs..." >&4
1721 cat <<EOSC >loc
1722 $startsh
1723 case \$# in
1724 0) exit 1;;
1725 esac
1726 thing=\$1
1727 shift
1728 dflt=\$1
1729 shift
1730 for dir in \$*; do
1731         case "\$thing" in
1732         .)
1733         if test -d \$dir/\$thing; then
1734                 echo \$dir
1735                 exit 0
1736         fi
1737         ;;
1738         *)
1739         for thisthing in \$dir/\$thing; do
1740                 : just loop through to pick last item
1741         done
1742         if test -f \$thisthing; then
1743                 echo \$thisthing
1744                 exit 0
1745         elif test -f \$dir/\$thing.exe; then
1746                 if test -n "$DJGPP"; then
1747                         echo \$dir/\$thing.exe
1748                 else
1749                         : on Eunice apparently
1750                         echo \$dir/\$thing
1751                 fi
1752                 exit 0
1753         fi
1754         ;;
1755         esac
1756 done
1757 echo \$dflt
1758 exit 1
1759 EOSC
1760 chmod +x loc
1761 $eunicefix loc
1762 loclist="
1763 awk
1764 cat
1765 comm
1766 cp
1767 echo
1768 expr
1769 grep
1770 ls
1771 make
1772 mkdir
1773 rm
1774 sed
1775 sort
1776 touch
1777 tr
1778 uniq
1779 "
1780 trylist="
1781 Mcc
1782 ar
1783 byacc
1784 cpp
1785 csh
1786 date
1787 egrep
1788 gzip
1789 less
1790 ln
1791 more
1792 nm
1793 nroff
1794 pg
1795 test
1796 uname
1797 zip
1798 "
1799 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1800 pth="$pth /lib /usr/lib"
1801 for file in $loclist; do
1802         eval xxx=\$$file
1803         case "$xxx" in
1804         /*|?:[\\/]*)
1805                 if test -f "$xxx"; then
1806                         : ok
1807                 else
1808                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1809                         xxx=`./loc $file $file $pth`
1810                 fi
1811                 ;;
1812         '') xxx=`./loc $file $file $pth`;;
1813         *) xxx=`./loc $xxx $xxx $pth`;;
1814         esac
1815         eval $file=$xxx
1816         eval _$file=$xxx
1817         case "$xxx" in
1818         /*)
1819                 echo $file is in $xxx.
1820                 ;;
1821         ?:[\\/]*)
1822                 echo $file is in $xxx.
1823                 ;;
1824         *)
1825                 echo "I don't know where '$file' is, and my life depends on it." >&4
1826                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1827                 exit 1
1828                 ;;
1829         esac
1830 done
1831 echo " "
1832 echo "Don't worry if any of the following aren't found..."
1833 say=offhand
1834 for file in $trylist; do
1835         eval xxx=\$$file
1836         case "$xxx" in
1837         /*|?:[\\/]*)
1838                 if test -f "$xxx"; then
1839                         : ok
1840                 else
1841                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1842                         xxx=`./loc $file $file $pth`
1843                 fi
1844                 ;;
1845         '') xxx=`./loc $file $file $pth`;;
1846         *) xxx=`./loc $xxx $xxx $pth`;;
1847         esac
1848         eval $file=$xxx
1849         eval _$file=$xxx
1850         case "$xxx" in
1851         /*)
1852                 echo $file is in $xxx.
1853                 ;;
1854         ?:[\\/]*)
1855                 echo $file is in $xxx.
1856                 ;;
1857         *)
1858                 echo "I don't see $file out there, $say."
1859                 say=either
1860                 ;;
1861         esac
1862 done
1863 case "$egrep" in
1864 egrep)
1865         echo "Substituting grep for egrep."
1866         egrep=$grep
1867         ;;
1868 esac
1869 case "$ln" in
1870 ln)
1871         echo "Substituting cp for ln."
1872         ln=$cp
1873         ;;
1874 esac
1875 case "$test" in
1876 test)
1877         echo "Hopefully test is built into your sh."
1878         ;;
1879 *)
1880         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1881                 echo "Using the test built into your sh."
1882                 test=test
1883                 _test=test
1884         fi
1885         ;;
1886 esac
1887 case "$echo" in
1888 echo)
1889         echo "Hopefully echo is built into your sh."
1890         ;;
1891 '') ;;
1892 *)
1893         echo " "
1894 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1895         $echo $n "hi there$c" >foo1
1896         echo $n "hi there$c" >foo2
1897         if cmp foo1 foo2 >/dev/null 2>&1; then
1898                 echo "They are compatible.  In fact, they may be identical."
1899         else
1900                 case "$n" in
1901                 '-n') n='' c='\c';;
1902                 *) n='-n' c='';;
1903                 esac
1904                 cat <<FOO
1905 They are not compatible!  You are probably running ksh on a non-USG system.
1906 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1907 have echo built in and we may have to run some Bourne shell scripts.  That
1908 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1909
1910 FOO
1911                 $echo $n "The star should be here-->$c"
1912                 $echo "*"
1913         fi
1914         $rm -f foo1 foo2
1915         ;;
1916 esac
1917
1918 : determine whether symbolic links are supported
1919 echo " "
1920 $touch blurfl
1921 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1922         echo "Symbolic links are supported." >&4
1923         lns="$ln -s"
1924 else
1925         echo "Symbolic links are NOT supported." >&4
1926         lns="$ln"
1927 fi
1928 $rm -f blurfl sym
1929
1930 : see whether [:lower:] and [:upper:] are supported character classes
1931 echo " "
1932 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1933 ABYZ)
1934         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1935         up='[:upper:]'
1936         low='[:lower:]'
1937         ;;
1938 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1939         # (0xc9 and 0xd1), therefore that is a nice testing point.
1940         if test "X$up" = X -o "X$low" = X; then
1941             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1942             ij) up='[A-Z]'
1943                 low='[a-z]'
1944                 ;;
1945             esac
1946         fi
1947         if test "X$up" = X -o "X$low" = X; then
1948             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1949             ij) up='A-Z'
1950                 low='a-z'
1951                 ;;
1952             esac
1953         fi
1954         if test "X$up" = X -o "X$low" = X; then
1955             case "`echo IJ | od -x 2>/dev/null`" in
1956             *C9D1*|*c9d1*)
1957                 echo "Hey, this might be EBCDIC." >&4
1958                 if test "X$up" = X -o "X$low" = X; then
1959                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1960                     ij) up='[A-IJ-RS-Z]'
1961                         low='[a-ij-rs-z]'
1962                         ;;
1963                     esac
1964                 fi
1965                 if test "X$up" = X -o "X$low" = X; then
1966                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1967                     ij) up='A-IJ-RS-Z'
1968                         low='a-ij-rs-z'
1969                         ;;
1970                     esac
1971                 fi
1972                 ;;
1973             esac
1974         fi
1975 esac
1976 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1977 ij)
1978     echo "Using $up and $low to convert case." >&4
1979     ;;
1980 *)
1981     echo "I don't know how to translate letters from upper to lower case." >&4
1982     echo "Your tr is not acting any way I know of." >&4
1983     exit 1
1984     ;;
1985 esac
1986 : set up the translation script tr, must be called with ./tr of course
1987 cat >tr <<EOSC
1988 $startsh
1989 case "\$1\$2" in
1990 '[A-Z][a-z]') exec $tr '$up' '$low';;
1991 '[a-z][A-Z]') exec $tr '$low' '$up';;
1992 esac
1993 exec $tr "\$@"
1994 EOSC
1995 chmod +x tr
1996 $eunicefix tr
1997
1998 : Try to determine whether config.sh was made on this system
1999 case "$config_sh" in
2000 '')
2001 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
2002 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
2003 # because the A-Z/a-z are not consecutive.
2004 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
2005         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
2006 newmyuname="$myuname"
2007 dflt=n
2008 case "$knowitall" in
2009 '')
2010         if test -f ../config.sh; then
2011                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
2012                         eval "`grep myuname= ../config.sh`"
2013                 fi
2014                 if test "X$myuname" = "X$newmyuname"; then
2015                         dflt=y
2016                 fi
2017         fi
2018         ;;
2019 *) dflt=y;;
2020 esac
2021
2022 : Get old answers from old config file if Configure was run on the
2023 : same system, otherwise use the hints.
2024 hint=default
2025 cd ..
2026 if test -f config.sh; then
2027         echo " "
2028         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2029         . UU/myread
2030         case "$ans" in
2031         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2032         *)  echo "Fetching default answers from your old config.sh file..." >&4
2033                 tmp_n="$n"
2034                 tmp_c="$c"
2035                 tmp_sh="$sh"
2036                 . ./config.sh
2037                 cp config.sh UU
2038                 n="$tmp_n"
2039                 c="$tmp_c"
2040                 : Older versions did not always set $sh.  Catch re-use of such
2041                 : an old config.sh.
2042                 case "$sh" in
2043                 '') sh="$tmp_sh" ;;
2044                 esac
2045                 hint=previous
2046                 ;;
2047         esac
2048 fi
2049 if test ! -f config.sh; then
2050         $cat <<EOM
2051
2052 First time through, eh?  I have some defaults handy for some systems
2053 that need some extra help getting the Configure answers right:
2054
2055 EOM
2056         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2057         dflt=''
2058         : Half the following guesses are probably wrong... If you have better
2059         : tests or hints, please send them to perlbug@perl.com
2060         : The metaconfig authors would also appreciate a copy...
2061         $test -f /irix && osname=irix
2062         $test -f /xenix && osname=sco_xenix
2063         $test -f /dynix && osname=dynix
2064         $test -f /dnix && osname=dnix
2065         $test -f /lynx.os && osname=lynxos
2066         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2067         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2068         $test -f /bin/mips && /bin/mips && osname=mips
2069         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2070                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2071         $test -d /usr/apollo/bin && osname=apollo
2072         $test -f /etc/saf/_sactab && osname=svr4
2073         $test -d /usr/include/minix && osname=minix
2074         if $test -d /MachTen -o -d /MachTen_Folder; then
2075                 osname=machten
2076                 if $test -x /sbin/version; then
2077                         osvers=`/sbin/version | $awk '{print $2}' |
2078                         $sed -e 's/[A-Za-z]$//'`
2079                 elif $test -x /usr/etc/version; then
2080                         osvers=`/usr/etc/version | $awk '{print $2}' |
2081                         $sed -e 's/[A-Za-z]$//'`
2082                 else
2083                         osvers="$2.$3"
2084                 fi
2085         fi
2086        $test -f /sys/posix.dll &&
2087                $test -f /usr/bin/what &&
2088                set X `/usr/bin/what /sys/posix.dll` &&
2089                $test "$3" = UWIN &&
2090                osname=uwin &&
2091                osvers="$5"
2092         if $test -f $uname; then
2093                 set X $myuname
2094                 shift
2095
2096                 case "$5" in
2097                 fps*) osname=fps ;;
2098                 mips*)
2099                         case "$4" in
2100                         umips) osname=umips ;;
2101                         *) osname=mips ;;
2102                         esac;;
2103                 [23]100) osname=mips ;;
2104                 next*) osname=next ;;
2105                 i386*)
2106                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2107                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2108                                 osname='sco'
2109                                 osvers=$tmp
2110                         elif $test -f /etc/kconfig; then
2111                                 osname=isc
2112                                 if test "$lns" = "$ln -s"; then
2113                                         osvers=4
2114                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2115                                         osvers=3
2116                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2117                                         osvers=2
2118                                 fi
2119                         fi
2120                         tmp=''
2121                         ;;
2122                 pc*)
2123                         if test -n "$DJGPP"; then
2124                                 osname=dos
2125                                 osvers=djgpp
2126                         fi
2127                         ;;
2128                 esac
2129
2130                 case "$1" in
2131                 aix) osname=aix
2132                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2133                         case "$tmp" in
2134                         'not found') osvers="$4"."$3" ;;
2135                         '<3240'|'<>3240') osvers=3.2.0 ;;
2136                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2137                         '=3250'|'>3250') osvers=3.2.5 ;;
2138                         *) osvers=$tmp;;
2139                         esac
2140                         ;;
2141                 *dc.osx) osname=dcosx
2142                         osvers="$3"
2143                         ;;
2144                 dnix) osname=dnix
2145                         osvers="$3"
2146                         ;;
2147                 domainos) osname=apollo
2148                         osvers="$3"
2149                         ;;
2150                 dgux) osname=dgux 
2151                         osvers="$3"
2152                         ;;
2153                 dynixptx*) osname=dynixptx
2154                         osvers=`echo "$4"|sed 's/^v//'`
2155                         ;;
2156                 freebsd) osname=freebsd 
2157                         osvers="$3" ;;
2158                 genix) osname=genix ;;
2159                 hp*) osname=hpux 
2160                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2161                         ;;
2162                 irix*) osname=irix
2163                         case "$3" in
2164                         4*) osvers=4 ;;
2165                         5*) osvers=5 ;;
2166                         *)      osvers="$3" ;;
2167                         esac
2168                         ;;
2169                 linux) osname=linux
2170                         case "$3" in
2171                         *)      osvers="$3" ;;
2172                         esac
2173                         ;;
2174                 MiNT) osname=mint
2175                         ;;
2176                 netbsd*) osname=netbsd
2177                         osvers="$3"
2178                         ;;
2179                 news-os) osvers="$3"
2180                         case "$3" in
2181                         4*) osname=newsos4 ;;
2182                         *) osname=newsos ;;
2183                         esac
2184                         ;;
2185                 bsd386) osname=bsd386
2186                         osvers=`$uname -r`
2187                         ;;
2188                 POSIX-BC | posix-bc ) osname=posix-bc
2189                         osvers="$3"
2190                         ;;
2191                 powerux | power_ux | powermax_os | powermaxos | \
2192                 powerunix | power_unix) osname=powerux
2193                         osvers="$3"
2194                         ;;
2195                 next*) osname=next ;;
2196                 solaris) osname=solaris
2197                         case "$3" in
2198                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2199                         *)      osvers="$3" ;;
2200                         esac
2201                         ;;
2202                 sunos) osname=sunos
2203                         case "$3" in
2204                         5*) osname=solaris
2205                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2206                         *)      osvers="$3" ;;
2207                         esac
2208                         ;;
2209                 titanos) osname=titanos
2210                         case "$3" in
2211                         1*) osvers=1 ;;
2212                         2*) osvers=2 ;;
2213                         3*) osvers=3 ;;
2214                         4*) osvers=4 ;;
2215                         *)      osvers="$3" ;;
2216                         esac
2217                         ;;
2218                 ultrix) osname=ultrix
2219                         osvers="$3"
2220                         ;;
2221                 osf1|mls+)      case "$5" in
2222                                 alpha)
2223                                         osname=dec_osf
2224                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2225                                         ;;
2226                         hp*)    osname=hp_osf1  ;;
2227                         mips)   osname=mips_osf1 ;;
2228                         esac
2229                         ;;
2230                 uts) osname=uts 
2231                         osvers="$3"
2232                         ;;
2233                 qnx) osname=qnx
2234                         osvers="$4"
2235                         ;;
2236                 $2) case "$osname" in
2237                         *isc*) ;;
2238                         *freebsd*) ;;
2239                         svr*)
2240                                 : svr4.x or possibly later
2241                                 case "svr$3" in 
2242                                 ${osname}*)
2243                                         osname=svr$3
2244                                         osvers=$4
2245                                         ;;
2246                                 esac
2247                                 case "$osname" in
2248                                 svr4.0)
2249                                         : Check for ESIX
2250                                         if test -f /stand/boot ; then
2251                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2252                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2253                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2254                                                         if test -n "$isesix"; then
2255                                                                 osname=esix4
2256                                                         fi
2257                                                 fi
2258                                         fi
2259                                         ;;
2260                                 esac
2261                                 ;;
2262                         *)      if test -f /etc/systemid; then
2263                                         osname=sco
2264                                         set `echo $3 | $sed 's/\./ /g'` $4
2265                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2266                                                 osvers=$1.$2.$3
2267                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2268                                                 osvers=$1.$2
2269                                         elif $test -f $src/hints/sco_$1.sh; then
2270                                                 osvers=$1
2271                                         fi
2272                                 else
2273                                         case "$osname" in
2274                                         '') : Still unknown.  Probably a generic Sys V.
2275                                                 osname="sysv"
2276                                                 osvers="$3"
2277                                                 ;;
2278                                         esac
2279                                 fi
2280                                 ;;
2281                         esac
2282                         ;;
2283                 *)      case "$osname" in
2284                         '') : Still unknown.  Probably a generic BSD.
2285                                 osname="$1"
2286                                 osvers="$3"
2287                                 ;;
2288                         esac
2289                         ;;
2290                 esac
2291         else
2292                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2293                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2294                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2295                                 osname=news_os
2296                         fi
2297                         $rm -f UU/kernel.what
2298                 elif test -d c:/.; then
2299                         set X $myuname
2300                         osname=os2
2301                         osvers="$5"
2302                 fi
2303         fi
2304         
2305         : Now look for a hint file osname_osvers, unless one has been
2306         : specified already.
2307         case "$hintfile" in
2308         ''|' ')
2309                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2310                 : Also try without trailing minor version numbers.
2311                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2312                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2313                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2314                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2315                 case "$file" in
2316                 '') dflt=none ;;
2317                 *)  case "$osvers" in
2318                         '') dflt=$file
2319                                 ;;
2320                         *)  if $test -f $src/hints/$file.sh ; then
2321                                         dflt=$file
2322                                 elif $test -f $src/hints/$xfile.sh ; then
2323                                         dflt=$xfile
2324                                 elif $test -f $src/hints/$xxfile.sh ; then
2325                                         dflt=$xxfile
2326                                 elif $test -f $src/hints/$xxxfile.sh ; then
2327                                         dflt=$xxxfile
2328                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2329                                         dflt=$xxxxfile
2330                                 elif $test -f "$src/hints/${osname}.sh" ; then
2331                                         dflt="${osname}"
2332                                 else
2333                                         dflt=none
2334                                 fi
2335                                 ;;
2336                         esac
2337                         ;;
2338                 esac
2339                 if $test -f Policy.sh ; then
2340                         case "$dflt" in
2341                         *Policy*) ;;
2342                         none) dflt="Policy" ;;
2343                         *) dflt="Policy $dflt" ;;
2344                         esac
2345                 fi
2346                 ;;
2347         *)
2348                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2349                 ;;
2350         esac
2351
2352         if $test -f Policy.sh ; then
2353                 $cat <<EOM
2354
2355 There's also a Policy hint file available, which should make the
2356 site-specific (policy) questions easier to answer.
2357 EOM
2358
2359         fi
2360
2361         $cat <<EOM
2362
2363 You may give one or more space-separated answers, or "none" if appropriate.
2364 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2365 is a good thing.  DO NOT give a wrong version.
2366
2367 EOM
2368
2369         rp="Which of these apply, if any?"
2370         . UU/myread
2371         tans=$ans
2372         for file in $tans; do
2373                 if $test X$file = XPolicy -a -f Policy.sh; then
2374                         . Policy.sh
2375                         $cat Policy.sh >> UU/config.sh
2376                 elif $test -f $src/hints/$file.sh; then
2377                         . $src/hints/$file.sh
2378                         $cat $src/hints/$file.sh >> UU/config.sh
2379                 elif $test X$tans = X -o X$tans = Xnone ; then
2380                         : nothing
2381                 else
2382                         : Give one chance to correct a possible typo.
2383                         echo "$file.sh does not exist"
2384                         dflt=$file
2385                         rp="hint to use instead?"
2386                         . UU/myread
2387                         for file in $ans; do
2388                                 if $test -f "$src/hints/$file.sh"; then
2389                                         . $src/hints/$file.sh
2390                                         $cat $src/hints/$file.sh >> UU/config.sh
2391                                 elif $test X$ans = X -o X$ans = Xnone ; then
2392                                         : nothing
2393                                 else
2394                                         echo "$file.sh does not exist -- ignored."
2395                                 fi
2396                         done
2397                 fi
2398         done
2399
2400         hint=recommended
2401         : Remember our hint file for later.
2402         if $test -f "$src/hints/$file.sh" ; then
2403                 hintfile="$file"
2404         else
2405                 hintfile=''
2406         fi
2407 fi
2408 cd UU
2409 ;;
2410 *)
2411         echo " "
2412         echo "Fetching default answers from $config_sh..." >&4
2413         tmp_n="$n"
2414         tmp_c="$c"
2415         cd ..
2416         cp $config_sh config.sh 2>/dev/null
2417         chmod +w config.sh
2418         . ./config.sh
2419         cd UU
2420         cp ../config.sh .
2421         n="$tmp_n"
2422         c="$tmp_c"
2423         hint=previous
2424         ;;
2425 esac
2426 test "$override" && . ./optdef.sh
2427 myuname="$newmyuname"
2428
2429 : Restore computed paths
2430 for file in $loclist $trylist; do
2431         eval $file="\$_$file"
2432 done
2433
2434 cat << EOM
2435
2436 Configure uses the operating system name and version to set some defaults.
2437 The default value is probably right if the name rings a bell. Otherwise,
2438 since spelling matters for me, either accept the default or answer "none"
2439 to leave it blank.
2440
2441 EOM
2442 case "$osname" in
2443         ''|' ')
2444                 case "$hintfile" in
2445                 ''|' '|none) dflt=none ;;
2446                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2447                 esac
2448                 ;;
2449         *) dflt="$osname" ;;
2450 esac
2451 rp="Operating system name?"
2452 . ./myread
2453 case "$ans" in
2454 none)  osname='' ;;
2455 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2456 esac
2457 echo " "
2458 case "$osvers" in
2459         ''|' ')
2460                 case "$hintfile" in
2461                 ''|' '|none) dflt=none ;;
2462                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2463                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2464                         case "$dflt" in
2465                         ''|' ') dflt=none ;;
2466                         esac
2467                         ;;
2468                 esac
2469                 ;;
2470         *) dflt="$osvers" ;;
2471 esac
2472 rp="Operating system version?"
2473 . ./myread
2474 case "$ans" in
2475 none)  osvers='' ;;
2476 *) osvers="$ans" ;;
2477 esac
2478
2479 : who configured the system
2480 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2481 cf_by=`(logname) 2>/dev/null`
2482 case "$cf_by" in
2483 "")
2484         cf_by=`(whoami) 2>/dev/null`
2485         case "$cf_by" in
2486         "") cf_by=unknown ;;
2487         esac ;;
2488 esac
2489
2490 : set up the script used to warn in case of inconsistency
2491 cat <<EOS >whoa
2492 $startsh
2493 EOS
2494 cat <<'EOSC' >>whoa
2495 dflt=y
2496 echo " "
2497 echo "*** WHOA THERE!!! ***" >&4
2498 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2499 rp="    Keep the $hint value?"
2500 . ./myread
2501 case "$ans" in
2502 y) td=$was; tu=$was;;
2503 esac
2504 EOSC
2505
2506 : function used to set $1 to $val
2507 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2508 case "$val$was" in
2509 $define$undef) . ./whoa; eval "$var=\$td";;
2510 $undef$define) . ./whoa; eval "$var=\$tu";;
2511 *) eval "$var=$val";;
2512 esac'
2513
2514 cat <<EOM
2515
2516 Perl can be built to take advantage of threads, on some systems.
2517 To do so, Configure must be run with -Dusethreads.
2518
2519 Note that threading is a highly experimental feature, and
2520 some known race conditions still remain.  If you choose to try
2521 it, be very sure to not actually deploy it for production
2522 purposes.  README.threads has more details, and is required
2523 reading if you enable threads.
2524 EOM
2525 case "$usethreads" in
2526 $define|true|[yY]*)     dflt='y';;
2527 *) dflt='n';;
2528 esac
2529 rp='Build a threading Perl?'
2530 . ./myread
2531 case "$ans" in
2532 y|Y)    val="$define" ;;     
2533 *)      val="$undef" ;;
2534 esac
2535 set usethreads
2536 eval $setvar 
2537
2538 case "$d_oldpthreads" in
2539 '')     : Configure tests would be welcome here.  For now, assume undef.
2540         val="$undef" ;;
2541 *)      val="$d_oldpthreads" ;;
2542 esac
2543 set d_oldpthreads
2544 eval $setvar
2545
2546
2547 case "$usethreads" in
2548 "$define"|true|[yY]*)
2549 : Look for a hint-file generated 'call-back-unit'.  If the
2550 : user has specified that a threading perl is to be built,
2551 : we may need to set or change some other defaults.
2552         if $test -f usethreads.cbu; then
2553                 . ./usethreads.cbu
2554         fi
2555         case "$osname" in
2556         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2557                 # Known thread-capable platforms.
2558                 ;;
2559         *)
2560                 cat >&4 <<EOM
2561 $osname is not known to support threads.
2562 Please let perlbug@perl.com know how to do that.
2563
2564 Cannot continue, aborting.
2565 EOM
2566                 exit 1
2567         ;;
2568         esac # $osname
2569     ;;
2570 esac # $usethreads
2571
2572 cat <<EOM
2573
2574 Perl can be built so that multiple Perl interpreters can coexist
2575 within the same Perl executable.  To do so, Configure must be run with
2576 -Dusemultiplicity.
2577
2578 Normally you do not need this and you should answer no.
2579
2580 EOM
2581 case "$usemultiplicity" in
2582 $define|true|[yY]*)     dflt='y';;
2583 *) dflt='n';;
2584 esac
2585 rp='Build Perl for multiplicity?'
2586 . ./myread
2587 case "$ans" in
2588 y|Y)    val="$define" ;;     
2589 *)      val="$undef" ;;
2590 esac
2591 set usemultiplicity
2592 eval $setvar 
2593
2594 cat <<EOM
2595
2596 Perl can be built to take advantage of explicit 64-bit interfaces,
2597 on some systems.  To do so, Configure must be run with -Duse64bits.
2598
2599 If this doesn't make any sense to you, just accept the default 'n'.
2600 EOM
2601 case "$use64bits" in
2602 $define|true|[yY]*)     dflt='y';;
2603 *) dflt='n';;
2604 esac
2605 rp='Try to use explicit 64-bit interfaces, if available?'
2606 . ./myread
2607 case "$ans" in
2608 y|Y) 
2609         val="$define"
2610         ;;     
2611 *)      
2612         val="$undef"
2613         ;;
2614 esac
2615 set use64bits
2616 eval $setvar
2617
2618 case "$archname64" in
2619 '') archname64='' ;;    # not a typo
2620 esac
2621
2622 case "$use64bits" in
2623 "$define"|true|[yY]*)
2624 : Look for a hint-file generated 'call-back-unit'.  If the
2625 : user has specified that a threading perl is to be built,
2626 : we may need to set or change some other defaults.
2627         if $test -f use64bits.cbu; then
2628                 . ./use64bits.cbu
2629         fi
2630         case "$osname" in
2631         aix|dec_osf|hpux|irix|solaris|unicos)
2632                 # Known 64-bit capable platforms.
2633                 ;;
2634         *)
2635                 cat >&4 <<EOM
2636 $osname is not known to support 64-bit interfaces.
2637 Please let perlbug@perl.com know how to do that.
2638
2639 Cannot continue, aborting.
2640 EOM
2641                 exit 1
2642                 ;;
2643         esac
2644         ;;
2645 esac
2646
2647 : determine the architecture name
2648 echo " "
2649 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2650         tarch=`arch`"-$osname"
2651 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2652         if uname -m > tmparch 2>&1 ; then
2653                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2654                         -e 's/$/'"-$osname/" tmparch`
2655         else
2656                 tarch="$osname"
2657         fi
2658         $rm -f tmparch
2659 else
2660         tarch="$osname"
2661 fi
2662 case "$myarchname" in
2663 ''|"$tarch") ;;
2664 *)
2665         echo "(Your architecture name used to be $myarchname.)"
2666         archname=''
2667         ;;
2668 esac
2669 myarchname="$tarch"
2670 case "$archname" in
2671 '') dflt="$tarch";;
2672 *) dflt="$archname";;
2673 esac
2674 rp='What is your architecture name'
2675 . ./myread
2676 archname="$ans"
2677 case "$usethreads" in
2678 $define)
2679         echo "Threads selected." >&4
2680         case "$archname" in
2681         *-thread*) echo "...and architecture name already has -thread." >&4
2682                 ;;
2683         *)      archname="$archname-thread"
2684                 echo "...setting architecture name to $archname." >&4
2685                 ;;
2686         esac
2687         ;;
2688 esac
2689 case "$usemultiplicity" in
2690 $define)
2691         echo "Multiplicity selected." >&4
2692         case "$archname" in
2693         *-multi*) echo "...and architecture name already has -multi." >&4
2694                 ;;
2695         *)      archname="$archname-multi"
2696                 echo "...setting architecture name to $archname." >&4
2697                 ;;
2698         esac
2699         ;;
2700 esac
2701 case "$use64bits" in
2702 $define)
2703         echo "Explicit 64-bitness selected." >&4
2704         case "$archname64" in
2705         '')
2706                 ;;
2707         *)
2708                 case "$archname" in
2709                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2710                         ;;
2711                 *)      archname="$archname-$archname64"
2712                         echo "...setting architecture name to $archname." >&4
2713                         ;;
2714                 esac
2715                 ;;
2716         esac
2717 esac
2718
2719 : is AFS running?
2720 echo " "
2721 case "$afs" in
2722 $define|true)   afs=true ;;
2723 $undef|false)   afs=false ;;
2724 *)      if test -d /afs; then
2725                 afs=true
2726         else
2727                 afs=false
2728         fi
2729         ;;
2730 esac
2731 if $afs; then
2732         echo "AFS may be running... I'll be extra cautious then..." >&4
2733 else
2734         echo "AFS does not seem to be running..." >&4
2735 fi
2736
2737 : decide how portable to be.  Allow command line overrides.
2738 case "$d_portable" in
2739 "$undef") ;;
2740 *)      d_portable="$define" ;;
2741 esac
2742
2743 : set up shell script to do ~ expansion
2744 cat >filexp <<EOSS
2745 $startsh
2746 : expand filename
2747 case "\$1" in
2748  ~/*|~)
2749         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2750         ;;
2751  ~*)
2752         if $test -f /bin/csh; then
2753                 /bin/csh -f -c "glob \$1"
2754                 failed=\$?
2755                 echo ""
2756                 exit \$failed
2757         else
2758                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2759                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2760                 if $test ! -d "\$dir"; then
2761                         me=\`basename \$0\`
2762                         echo "\$me: can't locate home directory for: \$name" >&2
2763                         exit 1
2764                 fi
2765                 case "\$1" in
2766                 */*)
2767                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2768                         ;;
2769                 *)
2770                         echo \$dir
2771                         ;;
2772                 esac
2773         fi
2774         ;;
2775 *)
2776         echo \$1
2777         ;;
2778 esac
2779 EOSS
2780 chmod +x filexp
2781 $eunicefix filexp
2782
2783 : now set up to get a file name
2784 cat <<EOS >getfile
2785 $startsh
2786 EOS
2787 cat <<'EOSC' >>getfile
2788 tilde=''
2789 fullpath=''
2790 already=''
2791 skip=''
2792 none_ok=''
2793 exp_file=''
2794 nopath_ok=''
2795 orig_rp="$rp"
2796 orig_dflt="$dflt"
2797
2798 case "$fn" in
2799 *\(*)
2800         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2801         fn=`echo $fn | sed 's/(.*)//'`
2802         ;;
2803 esac
2804
2805 case "$fn" in
2806 *:*)
2807         loc_file=`expr $fn : '.*:\(.*\)'`
2808         fn=`expr $fn : '\(.*\):.*'`
2809         ;;
2810 esac
2811
2812 case "$fn" in
2813 *~*) tilde=true;;
2814 esac
2815 case "$fn" in
2816 */*) fullpath=true;;
2817 esac
2818 case "$fn" in
2819 *+*) skip=true;;
2820 esac
2821 case "$fn" in
2822 *n*) none_ok=true;;
2823 esac
2824 case "$fn" in
2825 *e*) exp_file=true;;
2826 esac
2827 case "$fn" in
2828 *p*) nopath_ok=true;;
2829 esac
2830
2831 case "$fn" in
2832 *f*) type='File';;
2833 *d*) type='Directory';;
2834 *l*) type='Locate';;
2835 esac
2836
2837 what="$type"
2838 case "$what" in
2839 Locate) what='File';;
2840 esac
2841
2842 case "$exp_file" in
2843 '')
2844         case "$d_portable" in
2845         "$define") ;;
2846         *) exp_file=true;;
2847         esac
2848         ;;
2849 esac
2850
2851 cd ..
2852 while test "$type"; do
2853         redo=''
2854         rp="$orig_rp"
2855         dflt="$orig_dflt"
2856         case "$tilde" in
2857         true) rp="$rp (~name ok)";;
2858         esac
2859         . UU/myread
2860         if test -f UU/getfile.ok && \
2861                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2862         then
2863                 value="$ans"
2864                 ansexp="$ans"
2865                 break
2866         fi
2867         case "$ans" in
2868         none)
2869                 value=''
2870                 ansexp=''
2871                 case "$none_ok" in
2872                 true) type='';;
2873                 esac
2874                 ;;
2875         *)
2876                 case "$tilde" in
2877                 '') value="$ans"
2878                         ansexp="$ans";;
2879                 *)
2880                         value=`UU/filexp $ans`
2881                         case $? in
2882                         0)
2883                                 if test "$ans" != "$value"; then
2884                                         echo "(That expands to $value on this system.)"
2885                                 fi
2886                                 ;;
2887                         *) value="$ans";;
2888                         esac
2889                         ansexp="$value"
2890                         case "$exp_file" in
2891                         '') value="$ans";;
2892                         esac
2893                         ;;
2894                 esac
2895                 case "$fullpath" in
2896                 true)
2897                         case "$ansexp" in
2898                         /*) value="$ansexp" ;;
2899                         *)
2900                                 redo=true
2901                                 case "$already" in
2902                                 true)
2903                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2904                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2905                                         ;;
2906                                 *)
2907                                 echo "Please give a full path name, starting with slash." >&4
2908                                         case "$tilde" in
2909                                         true)
2910                                 echo "Note that using ~name is ok provided it expands well." >&4
2911                                                 already=true
2912                                                 ;;
2913                                         esac
2914                                 esac
2915                                 ;;
2916                         esac
2917                         ;;
2918                 esac
2919                 case "$redo" in
2920                 '')
2921                         case "$type" in
2922                         File)
2923                                 if test -f "$ansexp"; then
2924                                         type=''
2925                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2926                                 then
2927                                         echo "($value is not a plain file, but that's ok.)"
2928                                         type=''
2929                                 fi
2930                                 ;;
2931                         Directory)
2932                                 if test -d "$ansexp"; then
2933                                         type=''
2934                                 fi
2935                                 ;;
2936                         Locate)
2937                                 if test -d "$ansexp"; then
2938                                         echo "(Looking for $loc_file in directory $value.)"
2939                                         value="$value/$loc_file"
2940                                         ansexp="$ansexp/$loc_file"
2941                                 fi
2942                                 if test -f "$ansexp"; then
2943                                         type=''
2944                                 fi
2945                                 case "$nopath_ok" in
2946                                 true)   case "$value" in
2947                                         */*) ;;
2948                                         *)      echo "Assuming $value will be in people's path."
2949                                                 type=''
2950                                                 ;;
2951                                         esac
2952                                         ;;
2953                                 esac
2954                                 ;;
2955                         esac
2956
2957                         case "$skip" in
2958                         true) type='';
2959                         esac
2960
2961                         case "$type" in
2962                         '') ;;
2963                         *)
2964                                 if test "$fastread" = yes; then
2965                                         dflt=y
2966                                 else
2967                                         dflt=n
2968                                 fi
2969                                 rp="$what $value doesn't exist.  Use that name anyway?"
2970                                 . UU/myread
2971                                 dflt=''
2972                                 case "$ans" in
2973                                 y*) type='';;
2974                                 *) echo " ";;
2975                                 esac
2976                                 ;;
2977                         esac
2978                         ;;
2979                 esac
2980                 ;;
2981         esac
2982 done
2983 cd UU
2984 ans="$value"
2985 rp="$orig_rp"
2986 dflt="$orig_dflt"
2987 rm -f getfile.ok
2988 EOSC
2989
2990 : determine root of directory hierarchy where package will be installed.
2991 case "$prefix" in
2992 '')
2993         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2994         ;;
2995 *)
2996         dflt="$prefix"
2997         ;;
2998 esac
2999 $cat <<EOM
3000
3001 By default, $package will be installed in $dflt/bin, manual
3002 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
3003 all installation directories. Typically set to /usr/local, but you
3004 may choose /usr if you wish to install $package among your system
3005 binaries. If you wish to have binaries under /bin but manual pages
3006 under /usr/local/man, that's ok: you will be prompted separately
3007 for each of the installation directories, the prefix being only used
3008 to set the defaults.
3009
3010 EOM
3011 fn=d~
3012 rp='Installation prefix to use?'
3013 . ./getfile
3014 oldprefix=''
3015 case "$prefix" in
3016 '') ;;
3017 *)
3018         case "$ans" in
3019         "$prefix") ;;
3020         *) oldprefix="$prefix";;
3021         esac
3022         ;;
3023 esac
3024 prefix="$ans"
3025 prefixexp="$ansexp"
3026
3027 : set the prefixit variable, to compute a suitable default value
3028 prefixit='case "$3" in
3029 ""|none)
3030         case "$oldprefix" in
3031         "") eval "$1=\"\$$2\"";;
3032         *)
3033                 case "$3" in
3034                 "") eval "$1=";;
3035                 none)
3036                         eval "tp=\"\$$2\"";
3037                         case "$tp" in
3038                         ""|" ") eval "$1=\"\$$2\"";;
3039                         *) eval "$1=";;
3040                         esac;;
3041                 esac;;
3042         esac;;
3043 *)
3044         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3045         case "$tp" in
3046         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3047         /*-$oldprefix/*|\~*-$oldprefix/*)
3048                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3049         *) eval "$1=\"\$$2\"";;
3050         esac;;
3051 esac'
3052
3053 : set the base revision
3054 baserev=5.0
3055
3056 : get the patchlevel
3057 echo " "
3058 echo "Getting the current patchlevel..." >&4
3059 if $test -r $rsrc/patchlevel.h;then
3060         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3061         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3062 else
3063         patchlevel=0
3064         subversion=0
3065 fi
3066 $echo $n "(You have $package" $c
3067 case "$package" in
3068 "*$baserev")    ;;
3069 *)              $echo $n " $baserev" $c ;;
3070 esac
3071 $echo $n " patchlevel $patchlevel" $c
3072 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3073 echo ".)"
3074
3075 if test 0 -eq "$subversion"; then
3076         version=`LC_ALL=C; export LC_ALL; \
3077                  echo $baserev $patchlevel | \
3078                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3079 else
3080         version=`LC_ALL=C; export LC_ALL; \
3081                  echo $baserev $patchlevel $subversion | \
3082                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3083 fi
3084 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3085 if test "$subversion" -lt 50; then
3086         apiversion=`LC_ALL=C; export LC_ALL; \
3087                  LANGUAGE=C; export LANGUAGE; \
3088                  echo $baserev $patchlevel | \
3089                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3090 else
3091         apiversion="$version"
3092 fi
3093
3094 : determine where private library files go
3095 : Usual default is /usr/local/lib/perl5/$version.
3096 : Also allow things like /opt/perl/lib/$version, since 
3097 : /opt/perl/lib/perl5... would be redundant.
3098 case "$prefix" in
3099 *perl*) set dflt privlib lib/$version ;;
3100 *)       set dflt privlib lib/$package/$version ;;
3101 esac
3102 eval $prefixit
3103 $cat <<EOM
3104
3105 There are some auxiliary files for $package that need to be put into a
3106 private library directory that is accessible by everyone.
3107
3108 EOM
3109 fn=d~+
3110 rp='Pathname where the private library files will reside?'
3111 . ./getfile
3112 if $test "X$privlibexp" != "X$ansexp"; then
3113         installprivlib=''
3114 fi
3115 privlib="$ans"
3116 privlibexp="$ansexp"
3117 if $afs; then
3118         $cat <<EOM
3119
3120 Since you are running AFS, I need to distinguish the directory in which
3121 private files reside from the directory in which they are installed (and from
3122 which they are presumably copied to the former directory by occult means).
3123
3124 EOM
3125         case "$installprivlib" in
3126         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3127         *) dflt="$installprivlib";;
3128         esac
3129         fn=de~
3130         rp='Where will private files be installed?'
3131         . ./getfile
3132         installprivlib="$ans"
3133 else
3134         installprivlib="$privlibexp"
3135 fi
3136
3137 : set the prefixup variable, to restore leading tilda escape
3138 prefixup='case "$prefixexp" in
3139 "$prefix") ;;
3140 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3141 esac'
3142
3143 : determine where public architecture dependent libraries go
3144 set archlib archlib
3145 eval $prefixit
3146 : privlib default is /usr/local/lib/$package/$version
3147 : archlib default is /usr/local/lib/$package/$version/$archname
3148 : privlib may have an optional trailing /share.
3149 tdflt=`echo $privlib | $sed 's,/share$,,'`
3150 tdflt=$tdflt/$archname
3151 case "$archlib" in
3152 '')     dflt=$tdflt
3153         ;;
3154 *)      dflt="$archlib"
3155     ;;
3156 esac
3157 cat <<EOM
3158
3159 $spackage contains architecture-dependent library files.  If you are
3160 sharing libraries in a heterogeneous environment, you might store
3161 these files in a separate location.  Otherwise, you can just include
3162 them with the rest of the public library files.
3163
3164 EOM
3165 fn=d+~
3166 rp='Where do you want to put the public architecture-dependent libraries?'
3167 . ./getfile
3168 archlib="$ans"
3169 archlibexp="$ansexp"
3170
3171 if $afs; then
3172         $cat <<EOM
3173
3174 Since you are running AFS, I need to distinguish the directory in
3175 which architecture-dependent library files reside from the directory
3176 in which they are installed (and from which they are presumably copied
3177 to the former directory by occult means).
3178
3179 EOM
3180         case "$installarchlib" in
3181         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3182         *) dflt="$installarchlib";;
3183         esac
3184         fn=de~
3185         rp='Where will architecture-dependent library files be installed?'
3186         . ./getfile
3187         installarchlib="$ans"
3188 else
3189         installarchlib="$archlibexp"
3190 fi
3191 if $test X"$archlib" = X"$privlib"; then
3192         d_archlib="$undef"
3193 else
3194         d_archlib="$define"
3195 fi
3196
3197 : make some quick guesses about what we are up against
3198 echo " "
3199 $echo $n "Hmm...  $c"
3200 echo exit 1 >bsd
3201 echo exit 1 >usg
3202 echo exit 1 >v7
3203 echo exit 1 >osf1
3204 echo exit 1 >eunice
3205 echo exit 1 >xenix
3206 echo exit 1 >venix
3207 echo exit 1 >os2
3208 d_bsd="$undef"
3209 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3210 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3211 then
3212         echo "Looks kind of like an OSF/1 system, but we'll see..."
3213         echo exit 0 >osf1
3214 elif test `echo abc | tr a-z A-Z` = Abc ; then
3215         xxx=`./loc addbib blurfl $pth`
3216         if $test -f $xxx; then
3217         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3218                 echo exit 0 >bsd
3219                 echo exit 0 >usg
3220         else
3221                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3222                         echo "Looks kind of like an extended USG system, but we'll see..."
3223                 else
3224                         echo "Looks kind of like a USG system, but we'll see..."
3225                 fi
3226                 echo exit 0 >usg
3227         fi
3228 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3229         echo "Looks kind of like a BSD system, but we'll see..."
3230         d_bsd="$define"
3231         echo exit 0 >bsd
3232 else
3233         echo "Looks kind of like a Version 7 system, but we'll see..."
3234         echo exit 0 >v7
3235 fi
3236 case "$eunicefix" in
3237 *unixtovms*)
3238         $cat <<'EOI'
3239 There is, however, a strange, musty smell in the air that reminds me of
3240 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3241 EOI
3242         echo exit 0 >eunice
3243         d_eunice="$define"
3244 : it so happens the Eunice I know will not run shell scripts in Unix format
3245         ;;
3246 *)
3247         echo " "
3248         echo "Congratulations.  You aren't running Eunice."
3249         d_eunice="$undef"
3250         ;;
3251 esac
3252 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3253 case "$p_" in
3254 :) ;;
3255 *)
3256         $cat <<'EOI'
3257 I have the feeling something is not exactly right, however...don't tell me...
3258 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3259 EOI
3260         echo exit 0 >os2
3261         ;;
3262 esac
3263 if test -f /xenix; then
3264         echo "Actually, this looks more like a XENIX system..."
3265         echo exit 0 >xenix
3266         d_xenix="$define"
3267 else
3268         echo " "
3269         echo "It's not Xenix..."
3270         d_xenix="$undef"
3271 fi
3272 chmod +x xenix
3273 $eunicefix xenix
3274 if test -f /venix; then
3275         echo "Actually, this looks more like a VENIX system..."
3276         echo exit 0 >venix
3277 else
3278         echo " "
3279         if ./xenix; then
3280                 : null
3281         else
3282                 echo "Nor is it Venix..."
3283         fi
3284 fi
3285 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3286 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3287 $rm -f foo
3288
3289 : see if setuid scripts can be secure
3290 $cat <<EOM
3291
3292 Some kernels have a bug that prevents setuid #! scripts from being
3293 secure.  Some sites have disabled setuid #! scripts because of this.
3294
3295 First let's decide if your kernel supports secure setuid #! scripts.
3296 (If setuid #! scripts would be secure but have been disabled anyway,
3297 don't say that they are secure if asked.)
3298
3299 EOM
3300
3301 val="$undef"
3302 if $test -d /dev/fd; then
3303         echo "#!$ls" >reflect
3304         chmod +x,u+s reflect
3305         ./reflect >flect 2>&1
3306         if $contains "/dev/fd" flect >/dev/null; then
3307                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3308                 val="$define"
3309         else
3310                 $cat <<EOM
3311 If you are not sure if they are secure, I can check but I'll need a
3312 username and password different from the one you are using right now.
3313 If you don't have such a username or don't want me to test, simply
3314 enter 'none'.
3315
3316 EOM
3317                 rp='Other username to test security of setuid scripts with?'
3318                 dflt='none'
3319                 . ./myread
3320                 case "$ans" in
3321                 n|none)
3322                         case "$d_suidsafe" in
3323                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3324                                 dflt=n;;
3325                         "$undef")
3326                                 echo "Well, the $hint value is *not* secure." >&4
3327                                 dflt=n;;
3328                         *)      echo "Well, the $hint value *is* secure." >&4
3329                                 dflt=y;;
3330                         esac
3331                         ;;
3332                 *)
3333                         $rm -f reflect flect
3334                         echo "#!$ls" >reflect
3335                         chmod +x,u+s reflect
3336                         echo >flect
3337                         chmod a+w flect
3338                         echo '"su" will (probably) prompt you for '"$ans's password."
3339                         su $ans -c './reflect >flect'
3340                         if $contains "/dev/fd" flect >/dev/null; then
3341                                 echo "Okay, it looks like setuid scripts are secure." >&4
3342                                 dflt=y
3343                         else
3344                                 echo "I don't think setuid scripts are secure." >&4
3345                                 dflt=n
3346                         fi
3347                         ;;
3348                 esac
3349                 rp='Does your kernel have *secure* setuid scripts?'
3350                 . ./myread
3351                 case "$ans" in
3352                 [yY]*)  val="$define";;
3353                 *)      val="$undef";;
3354                 esac
3355         fi
3356 else
3357         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3358         echo "(That's for file descriptors, not floppy disks.)"
3359         val="$undef"
3360 fi
3361 set d_suidsafe
3362 eval $setvar
3363
3364 $rm -f reflect flect
3365
3366 : now see if they want to do setuid emulation
3367 echo " "
3368 val="$undef"
3369 case "$d_suidsafe" in
3370 "$define")
3371         val="$undef"
3372         echo "No need to emulate SUID scripts since they are secure here." >& 4
3373         ;;
3374 *)
3375         $cat <<EOM
3376 Some systems have disabled setuid scripts, especially systems where
3377 setuid scripts cannot be secure.  On systems where setuid scripts have
3378 been disabled, the setuid/setgid bits on scripts are currently
3379 useless.  It is possible for $package to detect those bits and emulate
3380 setuid/setgid in a secure fashion.  This emulation will only work if
3381 setuid scripts have been disabled in your kernel.
3382
3383 EOM
3384         case "$d_dosuid" in
3385         "$define") dflt=y ;;
3386         *) dflt=n ;;
3387         esac
3388         rp="Do you want to do setuid/setgid emulation?"
3389         . ./myread
3390         case "$ans" in
3391         [yY]*)  val="$define";;
3392         *)      val="$undef";;
3393         esac
3394         ;;
3395 esac
3396 set d_dosuid
3397 eval $setvar
3398
3399 : determine where manual pages are on this system
3400 echo " "
3401 case "$sysman" in
3402 '') 
3403         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3404         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3405         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3406         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3407         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3408         sysman=`./loc . /usr/man/man1 $syspath`
3409         ;;
3410 esac
3411 if $test -d "$sysman"; then
3412         echo "System manual is in $sysman." >&4
3413 else
3414         echo "Could not find manual pages in source form." >&4
3415 fi
3416
3417 : see what memory models we can support
3418 case "$models" in
3419 '')
3420         $cat >pdp11.c <<'EOP'
3421 int main() {
3422 #ifdef pdp11
3423         exit(0);
3424 #else
3425         exit(1);
3426 #endif
3427 }
3428 EOP
3429         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3430         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3431                 dflt='unsplit split'
3432         else
3433                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3434                 case "$tans" in
3435                 X) dflt='none';;
3436                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3437                                 dflt='small'
3438                         else
3439                                 dflt=''
3440                         fi
3441                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3442                                 dflt="$dflt medium"
3443                         fi
3444                         if $test -d /lib/large || $test -d /usr/lib/large; then
3445                                 dflt="$dflt large"
3446                         fi
3447                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3448                                 dflt="$dflt huge"
3449                         fi
3450                 esac
3451         fi;;
3452 *) dflt="$models";;
3453 esac
3454 $cat <<EOM
3455  
3456 Some systems have different model sizes.  On most systems they are called
3457 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3458 split.  If your system doesn't support different memory models, say "none".
3459 If you wish to force everything to one memory model, say "none" here and
3460 put the appropriate flags later when it asks you for other cc and ld flags.
3461 Venix systems may wish to put "none" and let the compiler figure things out.
3462 (In the following question multiple model names should be space separated.)
3463
3464 The default for most systems is "none".
3465
3466 EOM
3467 rp="Which memory models are supported?"
3468 . ./myread
3469 models="$ans"
3470
3471 case "$models" in
3472 none)
3473         small=''
3474         medium=''
3475         large=''
3476         huge=''
3477         unsplit=''
3478         split=''
3479         ;;
3480 *split)
3481         case "$split" in
3482         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3483                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3484                         dflt='-i'
3485                 else
3486                         dflt='none'
3487                 fi;;
3488         *) dflt="$split";;
3489         esac
3490         rp="What flag indicates separate I and D space?"
3491         . ./myread
3492         tans="$ans"
3493         case "$tans" in
3494         none) tans='';;
3495         esac
3496         split="$tans"
3497         unsplit='';;
3498 *large*|*small*|*medium*|*huge*)
3499         case "$models" in
3500         *large*)
3501                 case "$large" in
3502                 '') dflt='-Ml';;
3503                 *) dflt="$large";;
3504                 esac
3505         rp="What flag indicates large model?"
3506         . ./myread
3507         tans="$ans"
3508         case "$tans" in
3509         none) tans='';
3510         esac
3511         large="$tans";;
3512         *) large='';;
3513         esac
3514         case "$models" in
3515         *huge*) case "$huge" in
3516                 '') dflt='-Mh';;
3517                 *) dflt="$huge";;
3518                 esac
3519                 rp="What flag indicates huge model?"
3520                 . ./myread
3521                 tans="$ans"
3522                 case "$tans" in
3523                 none) tans='';
3524                 esac
3525                 huge="$tans";;
3526         *) huge="$large";;
3527         esac
3528         case "$models" in
3529         *medium*) case "$medium" in
3530                 '') dflt='-Mm';;
3531                 *) dflt="$medium";;
3532                 esac
3533                 rp="What flag indicates medium model?"
3534                 . ./myread
3535                 tans="$ans"
3536                 case "$tans" in
3537                 none) tans='';
3538                 esac
3539                 medium="$tans";;
3540         *) medium="$large";;
3541         esac
3542         case "$models" in
3543         *small*) case "$small" in
3544                 '') dflt='none';;
3545                 *) dflt="$small";;
3546                 esac
3547                 rp="What flag indicates small model?"
3548                 . ./myread
3549                 tans="$ans"
3550                 case "$tans" in
3551                 none) tans='';
3552                 esac
3553                 small="$tans";;
3554         *) small='';;
3555         esac
3556         ;;
3557 *)
3558         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3559         ;;
3560 esac
3561 $rm -f pdp11.* pdp11
3562
3563 : see if we need a special compiler
3564 echo " "
3565 if ./usg; then
3566         case "$cc" in
3567         '') case "$Mcc" in
3568                 /*) dflt='Mcc';;
3569                 *) case "$large" in
3570                         -M*) dflt='cc';;
3571                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3572                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3573                                                 dflt='cc'
3574                                         else
3575                                                 dflt='cc -M'
3576                                         fi
3577                                 else
3578                                         dflt='cc'
3579                                 fi;;
3580                         esac;;
3581                 esac;;
3582         *)  dflt="$cc";;
3583         esac
3584         case "$dflt" in
3585         *M*)    $cat <<'EOM'
3586 On some older systems the default C compiler will not resolve multiple global
3587 references that happen to have the same name.  On some such systems the "Mcc"
3588 command may be used to force these to be resolved.  On other systems a "cc -M"
3589 command is required.  (Note that the -M flag on other systems indicates a
3590 memory model to use!) If you have the Gnu C compiler, you might wish to use
3591 that instead.
3592
3593 EOM
3594         ;;
3595         esac
3596         rp="Use which C compiler?"
3597         . ./myread
3598         cc="$ans"
3599 else
3600         case "$cc" in
3601         '') dflt=cc;;
3602         *) dflt="$cc";;
3603         esac
3604         rp="Use which C compiler?"
3605         . ./myread
3606         cc="$ans"
3607 fi
3608 : Look for a hint-file generated 'call-back-unit'.  Now that the
3609 : user has specified the compiler, we may need to set or change some
3610 : other defaults.
3611 if $test -f cc.cbu; then
3612     . ./cc.cbu
3613 fi
3614 echo " "
3615 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3616 $cat >gccvers.c <<EOM
3617 #include <stdio.h>
3618 int main() {
3619 #ifdef __GNUC__
3620 #ifdef __VERSION__
3621         printf("%s\n", __VERSION__);
3622 #else
3623         printf("%s\n", "1");
3624 #endif
3625 #endif
3626         exit(0);
3627 }
3628 EOM
3629 if $cc -o gccvers gccvers.c; then
3630         gccversion=`./gccvers`
3631         case "$gccversion" in
3632         '') echo "You are not using GNU cc." ;;
3633         *)  echo "You are using GNU cc $gccversion." ;;
3634         esac
3635 else
3636         echo " "
3637         echo "*** WHOA THERE!!! ***" >&4
3638         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3639         case "$knowitall" in
3640         '')
3641         echo "    You'd better start hunting for one and let me know about it." >&4
3642                 exit 1
3643                 ;;
3644         esac
3645 fi
3646 $rm -f gccvers*
3647 case "$gccversion" in
3648 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3649 esac
3650
3651 : What should the include directory be ?
3652 echo " "
3653 $echo $n "Hmm...  $c"
3654 dflt='/usr/include'
3655 incpath=''
3656 mips_type=''
3657 if $test -f /bin/mips && /bin/mips; then
3658         echo "Looks like a MIPS system..."
3659         $cat >usr.c <<'EOCP'
3660 #ifdef SYSTYPE_BSD43
3661 /bsd43
3662 #endif
3663 EOCP
3664         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3665                 dflt='/bsd43/usr/include'
3666                 incpath='/bsd43'
3667                 mips_type='BSD 4.3'
3668         else
3669                 mips_type='System V'
3670         fi
3671         $rm -f usr.c usr.out
3672         echo "and you're compiling with the $mips_type compiler and libraries."
3673         xxx_prompt=y
3674         echo "exit 0" >mips
3675 else
3676         echo "Doesn't look like a MIPS system."
3677         xxx_prompt=n
3678         echo "exit 1" >mips
3679 fi
3680 chmod +x mips
3681 $eunicefix mips
3682 case "$usrinc" in
3683 '') ;;
3684 *) dflt="$usrinc";;
3685 esac
3686 case "$xxx_prompt" in
3687 y)      fn=d/
3688         echo " "
3689         rp='Where are the include files you want to use?'
3690         . ./getfile
3691         usrinc="$ans"
3692         ;;
3693 *)      usrinc="$dflt"
3694         ;;
3695 esac
3696
3697 : see how we invoke the C preprocessor
3698 echo " "
3699 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3700 cat <<'EOT' >testcpp.c
3701 #define ABC abc
3702 #define XYZ xyz
3703 ABC.XYZ
3704 EOT
3705 cd ..
3706 if test ! -f cppstdin; then
3707         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3708 else
3709         echo "Keeping your $hint cppstdin wrapper."
3710 fi
3711 chmod 755 cppstdin
3712 wrapper=`pwd`/cppstdin
3713 ok='false'
3714 cd UU
3715
3716 if $test "X$cppstdin" != "X" && \
3717         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3718         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3719 then
3720         echo "You used to use $cppstdin $cppminus so we'll use that again."
3721         case "$cpprun" in
3722         '') echo "But let's see if we can live without a wrapper..." ;;
3723         *)
3724                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3725                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3726                 then
3727                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3728                         ok='true'
3729                 else
3730                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3731                 fi
3732                 ;;
3733         esac
3734 else
3735         case "$cppstdin" in
3736         '') ;;
3737         *)
3738                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3739                 ;;
3740         esac
3741 fi
3742
3743 if $ok; then
3744         : nothing
3745 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3746         $cc -E <testcpp.c >testcpp.out 2>&1; \
3747         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3748         echo "Yup, it does."
3749         x_cpp="$cc -E"
3750         x_minus='';
3751 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3752         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3753         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3754         echo "Yup, it does."
3755         x_cpp="$cc -E"
3756         x_minus='-';
3757 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3758         $cc -P <testcpp.c >testcpp.out 2>&1; \
3759         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3760         echo "Yipee, that works!"
3761         x_cpp="$cc -P"
3762         x_minus='';
3763 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3764         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3765         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3766         echo "At long last!"
3767         x_cpp="$cc -P"
3768         x_minus='-';
3769 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3770         $cpp <testcpp.c >testcpp.out 2>&1; \
3771         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3772         echo "It works!"
3773         x_cpp="$cpp"
3774         x_minus='';
3775 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3776         $cpp - <testcpp.c >testcpp.out 2>&1; \
3777         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3778         echo "Hooray, it works!  I was beginning to wonder."
3779         x_cpp="$cpp"
3780         x_minus='-';
3781 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3782         $wrapper <testcpp.c >testcpp.out 2>&1; \
3783         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3784         x_cpp="$wrapper"
3785         x_minus=''
3786         echo "Eureka!"
3787 else
3788         dflt=''
3789         rp="No dice.  I can't find a C preprocessor.  Name one:"
3790         . ./myread
3791         x_cpp="$ans"
3792         x_minus=''
3793         $x_cpp <testcpp.c >testcpp.out 2>&1
3794         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3795                 echo "OK, that will do." >&4
3796         else
3797 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3798                 exit 1
3799         fi
3800 fi
3801
3802 case "$ok" in
3803 false)
3804         cppstdin="$x_cpp"
3805         cppminus="$x_minus"
3806         cpprun="$x_cpp"
3807         cpplast="$x_minus"
3808         set X $x_cpp
3809         shift
3810         case "$1" in
3811         "$cpp")
3812                 echo "Perhaps can we force $cc -E using a wrapper..."
3813                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3814                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3815                 then
3816                         echo "Yup, we can."
3817                         cppstdin="$wrapper"
3818                         cppminus='';
3819                 else
3820                         echo "Nope, we'll have to live without it..."
3821                 fi
3822                 ;;
3823         esac
3824         case "$cpprun" in
3825         "$wrapper")
3826                 cpprun=''
3827                 cpplast=''
3828                 ;;
3829         esac
3830         ;;
3831 esac
3832
3833 case "$cppstdin" in
3834 "$wrapper"|'cppstdin') ;;
3835 *) $rm -f $wrapper;;
3836 esac
3837 $rm -f testcpp.c testcpp.out
3838
3839 : Set private lib path
3840 case "$plibpth" in
3841 '') if ./mips; then
3842                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3843         fi;;
3844 esac
3845 case "$libpth" in
3846 ' ') dlist='';;
3847 '') dlist="$loclibpth $plibpth $glibpth";;
3848 *) dlist="$libpth";;
3849 esac
3850
3851 : Now check and see which directories actually exist, avoiding duplicates
3852 libpth=''
3853 for xxx in $dlist
3854 do
3855     if $test -d $xxx; then
3856                 case " $libpth " in
3857                 *" $xxx "*) ;;
3858                 *) libpth="$libpth $xxx";;
3859                 esac
3860     fi
3861 done
3862 $cat <<'EOM'
3863
3864 Some systems have incompatible or broken versions of libraries.  Among
3865 the directories listed in the question below, please remove any you
3866 know not to be holding relevant libraries, and add any that are needed.
3867 Say "none" for none.
3868
3869 EOM
3870 case "$libpth" in
3871 '') dflt='none';;
3872 *)
3873         set X $libpth
3874         shift
3875         dflt=${1+"$@"}
3876         ;;
3877 esac
3878 rp="Directories to use for library searches?"
3879 . ./myread
3880 case "$ans" in
3881 none) libpth=' ';;
3882 *) libpth="$ans";;
3883 esac
3884
3885 : compute shared library extension
3886 case "$so" in
3887 '')
3888         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3889                 dflt='sl'
3890         else
3891                 dflt='so'
3892         fi
3893         ;;
3894 *) dflt="$so";;
3895 esac
3896 $cat <<EOM
3897
3898 On some systems, shared libraries may be available.  Answer 'none' if
3899 you want to suppress searching of shared libraries for the remaining
3900 of this configuration.
3901
3902 EOM
3903 rp='What is the file extension used for shared libraries?'
3904 . ./myread
3905 so="$ans"
3906
3907 : Define several unixisms.
3908 : Hints files or command line option can be used to override them.
3909 : The convoluted testing is in case hints files set either the old
3910 : or the new name.
3911 case "$_exe" in
3912 '')     case "$exe_ext" in
3913     '') ;;
3914         *)      _exe="$exe_ext" ;;
3915         esac
3916         ;;
3917 esac
3918 case "$_a" in
3919 '')     case "$lib_ext" in
3920     '') _a='.a';;
3921         *)      _a="$lib_ext" ;;
3922         esac
3923         ;;
3924 esac
3925 case "$_o" in
3926 '') case "$obj_ext" in
3927         '')     _o='.o';;
3928         *)      _o="$obj_ext";;
3929         esac
3930         ;;
3931 esac
3932 case "$p_" in
3933 '') case "$path_sep" in
3934         '')     p_=':';;
3935         *)      p_="$path_sep";;
3936         esac
3937         ;;
3938 esac
3939 exe_ext=$_exe
3940 lib_ext=$_a
3941 obj_ext=$_o
3942 path_sep=$p_
3943
3944 : Which makefile gets called first.  This is used by make depend.
3945 case "$firstmakefile" in
3946 '') firstmakefile='makefile';;
3947 esac
3948
3949 : Looking for optional libraries
3950 echo " "
3951 echo "Checking for optional libraries..." >&4
3952 case "$libs" in
3953 ' '|'') dflt='';;
3954 *) dflt="$libs";;
3955 esac
3956 case "$libswanted" in
3957 '') libswanted='c_s';;
3958 esac
3959 for thislib in $libswanted; do
3960         
3961         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3962                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3963                 echo "Found -l$thislib (shared)."
3964                 case " $dflt " in
3965                 *"-l$thislib "*);;
3966                 *) dflt="$dflt -l$thislib";;
3967                 esac
3968         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3969                 echo "Found -l$thislib (shared)."
3970                 case " $dflt " in
3971                 *"-l$thislib "*);;
3972                 *) dflt="$dflt -l$thislib";;
3973                 esac
3974         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
3975                 echo "Found -l$thislib."
3976                 case " $dflt " in
3977                 *"-l$thislib "*);;
3978                 *) dflt="$dflt -l$thislib";;
3979                 esac
3980         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
3981                 echo "Found -l$thislib."
3982                 case " $dflt " in
3983                 *"-l$thislib "*);;
3984                 *) dflt="$dflt -l$thislib";;
3985                 esac
3986         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
3987                 echo "Found -l${thislib}_s."
3988                 case " $dflt " in
3989                 *"-l$thislib "*);;
3990                 *) dflt="$dflt -l${thislib}_s";;
3991                 esac
3992         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
3993                 echo "Found -l$thislib."
3994                 case " $dflt " in
3995                 *"-l$thislib "*);;
3996                 *) dflt="$dflt -l$thislib";;
3997                 esac
3998         else
3999                 echo "No -l$thislib."
4000         fi
4001 done
4002 set X $dflt
4003 shift
4004 dflt="$*"
4005 case "$libs" in
4006 '') dflt="$dflt";;
4007 *) dflt="$libs";;
4008 esac
4009 case "$dflt" in
4010 ' '|'') dflt='none';;
4011 esac
4012
4013 $cat <<EOM
4014  
4015 Some versions of Unix support shared libraries, which make executables smaller
4016 but make load time slightly longer.
4017
4018 On some systems, mostly System V Release 3's, the shared library is included
4019 by putting the option "-lc_s" as the last thing on the cc command line when
4020 linking.  Other systems use shared libraries by default.  There may be other
4021 libraries needed to compile $package on your machine as well.  If your system
4022 needs the "-lc_s" option, include it here.  Include any other special libraries
4023 here as well.  Say "none" for none.
4024 EOM
4025
4026 echo " "
4027 rp="Any additional libraries?"
4028 . ./myread
4029 case "$ans" in
4030 none) libs=' ';;
4031 *) libs="$ans";;
4032 esac
4033
4034 : determine optimize, if desired, or use for debug flag also
4035 case "$optimize" in
4036 ' '|$undef) dflt='none';;
4037 '') dflt='-O';;
4038 *) dflt="$optimize";;
4039 esac
4040 $cat <<EOH
4041
4042 Some C compilers have problems with their optimizers.  By default, $package
4043 compiles with the -O flag to use the optimizer.  Alternately, you might want
4044 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4045 systems).  Either flag can be specified here.  To use neither flag, specify
4046 the word "none".
4047
4048 EOH
4049 rp="What optimizer/debugger flag should be used?"
4050 . ./myread
4051 optimize="$ans"
4052 case "$optimize" in
4053 'none') optimize=" ";;
4054 esac
4055
4056 dflt=''
4057 : We will not override a previous value, but we might want to
4058 : augment a hint file
4059 case "$hint" in
4060 none|recommended)
4061         case "$gccversion" in
4062         1*) dflt='-fpcc-struct-return' ;;
4063         esac
4064         case "$optimize" in
4065         *-g*) dflt="$dflt -DDEBUGGING";;
4066         esac
4067         case "$gccversion" in
4068         2*) if test -d /etc/conf/kconfig.d &&
4069                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4070                 then
4071                         dflt="$dflt -posix"
4072                 fi
4073                 ;;
4074         esac
4075         ;;
4076 esac
4077
4078 case "$mips_type" in
4079 *BSD*|'') inclwanted="$locincpth $usrinc";;
4080 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4081 esac
4082 for thisincl in $inclwanted; do
4083         if $test -d $thisincl; then
4084                 if $test x$thisincl != x$usrinc; then
4085                         case "$dflt" in
4086                         *$thisincl*);;
4087                         *) dflt="$dflt -I$thisincl";;
4088                         esac
4089                 fi
4090         fi
4091 done
4092
4093 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4094         xxx=true;
4095 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4096         xxx=true;
4097 else
4098         xxx=false;
4099 fi;
4100 if $xxx; then
4101         case "$dflt" in
4102         *$2*);;
4103         *) dflt="$dflt -D$2";;
4104         esac;
4105 fi'
4106
4107 set signal.h LANGUAGE_C; eval $inctest
4108
4109 case "$hint" in
4110 none|recommended) dflt="$ccflags $dflt" ;;
4111 *) dflt="$ccflags";;
4112 esac
4113
4114 case "$dflt" in
4115 ''|' ') dflt=none;;
4116 esac
4117 $cat <<EOH
4118
4119 Your C compiler may want other flags.  For this question you should include
4120 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4121 but you should NOT include libraries or ld flags like -lwhatever.  If you
4122 want $package to honor its debug switch, you should include -DDEBUGGING here.
4123 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4124
4125 To use no flags, specify the word "none".
4126
4127 EOH
4128 set X $dflt
4129 shift
4130 dflt=${1+"$@"}
4131 rp="Any additional cc flags?"
4132 . ./myread
4133 case "$ans" in
4134 none) ccflags='';;
4135 *) ccflags="$ans";;
4136 esac
4137
4138 : the following weeds options from ccflags that are of no interest to cpp
4139 cppflags="$ccflags"
4140 case "$gccversion" in
4141 1*) cppflags="$cppflags -D__GNUC__"
4142 esac
4143 case "$mips_type" in
4144 '');;
4145 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4146 esac
4147 case "$cppflags" in
4148 '');;
4149 *)
4150         echo " "
4151         echo "Let me guess what the preprocessor flags are..." >&4
4152         set X $cppflags
4153         shift
4154         cppflags=''
4155         $cat >cpp.c <<'EOM'
4156 #define BLURFL foo
4157
4158 BLURFL xx LFRULB
4159 EOM
4160         previous=''
4161         for flag in $*
4162         do
4163                 case "$flag" in
4164                 -*) ftry="$flag";;
4165                 *) ftry="$previous $flag";;
4166                 esac
4167                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4168                         >cpp1.out 2>/dev/null && \
4169                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4170                         >cpp2.out 2>/dev/null && \
4171                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4172                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4173                 then
4174                         cppflags="$cppflags $ftry"
4175                         previous=''
4176                 else
4177                         previous="$flag"
4178                 fi
4179         done
4180         set X $cppflags
4181         shift
4182         cppflags=${1+"$@"}
4183         case "$cppflags" in
4184         *-*)  echo "They appear to be: $cppflags";;
4185         esac
4186         $rm -f cpp.c cpp?.out
4187         ;;
4188 esac
4189
4190 : flags used in final linking phase
4191 case "$ldflags" in
4192 '') if ./venix; then
4193                 dflt='-i -z'
4194         else
4195                 dflt=''
4196         fi
4197         case "$ccflags" in
4198         *-posix*) dflt="$dflt -posix" ;;
4199         esac
4200         ;;
4201 *) dflt="$ldflags";;
4202 esac
4203
4204 : Try to guess additional flags to pick up local libraries.
4205 for thislibdir in $libpth; do
4206         case " $loclibpth " in
4207         *" $thislibdir "*)
4208                 case "$dflt " in 
4209                 *"-L$thislibdir "*) ;;
4210                 *)  dflt="$dflt -L$thislibdir" ;;
4211                 esac
4212                 ;;
4213         esac
4214 done
4215
4216 case "$dflt" in
4217 '') dflt='none' ;;
4218 esac
4219
4220 $cat <<EOH
4221
4222 Your C linker may need flags.  For this question you should
4223 include -L/whatever and any other flags used by the C linker, but you
4224 should NOT include libraries like -lwhatever.
4225
4226 Make sure you include the appropriate -L/path flags if your C linker
4227 does not normally search all of the directories you specified above,
4228 namely
4229         $libpth
4230 To use no flags, specify the word "none".
4231
4232 EOH
4233
4234 rp="Any additional ld flags (NOT including libraries)?"
4235 . ./myread
4236 case "$ans" in
4237 none) ldflags='';;
4238 *) ldflags="$ans";;
4239 esac
4240 rmlist="$rmlist pdp11"
4241
4242 : coherency check
4243 echo " "
4244 echo "Checking your choice of C compiler and flags for coherency..." >&4
4245 $cat > try.c <<'EOF'
4246 #include <stdio.h>
4247 int main() { printf("Ok\n"); exit(0); }
4248 EOF
4249 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4250 shift
4251 $cat >try.msg <<'EOM'
4252 I've tried to compile and run the following simple program:
4253
4254 EOM
4255 $cat try.c >> try.msg
4256
4257 $cat >> try.msg <<EOM
4258
4259 I used the command:
4260
4261         $*
4262         ./try
4263
4264 and I got the following output:
4265
4266 EOM
4267 dflt=y
4268 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4269         if sh -c './try' >>try.msg 2>&1; then
4270                 xxx=`./try`
4271                 case "$xxx" in
4272                 "Ok") dflt=n ;;
4273                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4274                         case " $libs " in
4275                         *" -lsfio "*)
4276                                 cat >> try.msg <<'EOQS'
4277 If $libs contains -lsfio, and sfio is mis-configured, then it
4278 sometimes (apparently) runs and exits with a 0 status, but with no
4279 output!  It may have to do with sfio's use of _exit vs. exit.
4280
4281 EOQS
4282                                 rp="You have a big problem.  Shall I abort Configure"
4283                                 dflt=y
4284                                 ;;
4285                         esac
4286                         ;;
4287                 esac
4288         else
4289                 echo "The program compiled OK, but exited with status $?." >>try.msg
4290                 rp="You have a problem.  Shall I abort Configure"
4291                 dflt=y
4292         fi
4293 else
4294         echo "I can't compile the test program." >>try.msg
4295         rp="You have a BIG problem.  Shall I abort Configure"
4296         dflt=y
4297 fi
4298 case "$dflt" in
4299 y)
4300         $cat try.msg >&4
4301         case "$knowitall" in
4302         '')
4303                 echo "(The supplied flags or libraries might be incorrect.)"
4304                 ;;
4305         *) dflt=n;;
4306         esac
4307         echo " "
4308         . ./myread
4309         case "$ans" in
4310         n*|N*) ;;
4311         *)      echo "Ok.  Stopping Configure." >&4
4312                 exit 1
4313                 ;;
4314         esac
4315         ;;
4316 n) echo "OK, that should do.";;
4317 esac
4318 $rm -f try try.* core
4319
4320 : determine filename position in cpp output
4321 echo " "
4322 echo "Computing filename position in cpp output for #include directives..." >&4
4323 echo '#include <stdio.h>' > foo.c
4324 $cat >fieldn <<EOF
4325 $startsh
4326 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4327 $grep '^[       ]*#.*stdio\.h' | \
4328 while read cline; do
4329         pos=1
4330         set \$cline
4331         while $test \$# -gt 0; do
4332                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4333                         echo "\$pos"
4334                         exit 0
4335                 fi
4336                 shift
4337                 pos=\`expr \$pos + 1\`
4338         done
4339 done
4340 EOF
4341 chmod +x fieldn
4342 fieldn=`./fieldn`
4343 $rm -f foo.c fieldn
4344 case $fieldn in
4345 '') pos='???';;
4346 1) pos=first;;
4347 2) pos=second;;
4348 3) pos=third;;
4349 *) pos="${fieldn}th";;
4350 esac
4351 echo "Your cpp writes the filename in the $pos field of the line."
4352
4353 : locate header file
4354 $cat >findhdr <<EOF
4355 $startsh
4356 wanted=\$1
4357 name=''
4358 for usrincdir in $usrinc
4359 do
4360         if test -f \$usrincdir/\$wanted; then
4361                 echo "\$usrincdir/\$wanted"
4362                 exit 0
4363         fi
4364 done
4365 awkprg='{ print \$$fieldn }'
4366 echo "#include <\$wanted>" > foo\$\$.c
4367 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4368 $grep "^[       ]*#.*\$wanted" | \
4369 while read cline; do
4370         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4371         case "\$name" in
4372         *[/\\\\]\$wanted) echo "\$name"; exit 1;;
4373         *[\\\\/]\$wanted) echo "\$name"; exit 1;;
4374         *) exit 2;;
4375         esac;
4376 done;
4377 #
4378 #status=0: grep returned 0 lines, case statement not executed
4379 #status=1: headerfile found
4380 #status=2: while loop executed, no headerfile found
4381 #
4382 status=\$?
4383 $rm -f foo\$\$.c;
4384 if test \$status -eq 1; then
4385         exit 0;
4386 fi
4387 exit 1
4388 EOF
4389 chmod +x findhdr
4390
4391
4392 : define an alternate in-header-list? function
4393 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4394 cont=true; xxf="echo \"<\$1> found.\" >&4";
4395 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4396 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4397 esac;
4398 case $# in 4) instead=instead;; *) instead="at last";; esac;
4399 while $test "$cont"; do
4400         xxx=`./findhdr $1`
4401         var=$2; eval "was=\$$2";
4402         if $test "$xxx" && $test -r "$xxx";
4403         then eval $xxf;
4404         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4405                 cont="";
4406         else eval $xxnf;
4407         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4408         set $yyy; shift; shift; yyy=$@;
4409         case $# in 0) cont="";;
4410         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4411                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4412         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4413                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4414         esac;
4415 done;
4416 while $test "$yyy";
4417 do set $yyy; var=$2; eval "was=\$$2";
4418         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4419         set $yyy; shift; shift; yyy=$@;
4420 done'
4421
4422 : see if this is a malloc.h system
4423 set malloc.h i_malloc
4424 eval $inhdr
4425
4426 : see if stdlib is available
4427 set stdlib.h i_stdlib
4428 eval $inhdr
4429
4430 : determine which malloc to compile in
4431 echo " "
4432 case "$usemymalloc" in
4433 ''|[yY]*|true|$define)  dflt='y' ;;
4434 *)      dflt='n' ;;
4435 esac
4436 rp="Do you wish to attempt to use the malloc that comes with $package?"
4437 . ./myread
4438 usemymalloc="$ans"
4439 case "$ans" in
4440 y*|true)
4441         usemymalloc='y'
4442         mallocsrc='malloc.c'
4443         mallocobj="malloc$_o"
4444         d_mymalloc="$define"
4445         case "$libs" in
4446         *-lmalloc*)
4447                 : Remove malloc from list of libraries to use
4448                 echo "Removing unneeded -lmalloc from library list" >&4
4449                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4450                 shift
4451                 libs="$*"
4452                 echo "libs = $libs" >&4
4453                 ;;
4454         esac
4455         ;;
4456 *)
4457         usemymalloc='n'
4458         mallocsrc=''
4459         mallocobj=''
4460         d_mymalloc="$undef"
4461         ;;
4462 esac
4463
4464 : compute the return types of malloc and free
4465 echo " "
4466 $cat >malloc.c <<END
4467 #$i_malloc I_MALLOC
4468 #$i_stdlib I_STDLIB
4469 #include <stdio.h>
4470 #include <sys/types.h>
4471 #ifdef I_MALLOC
4472 #include <malloc.h>
4473 #endif
4474 #ifdef I_STDLIB
4475 #include <stdlib.h>
4476 #endif
4477 #ifdef TRY_MALLOC
4478 void *malloc();
4479 #endif
4480 #ifdef TRY_FREE
4481 void free();
4482 #endif
4483 END
4484 case "$malloctype" in
4485 '')
4486         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4487                 malloctype='void *'
4488         else
4489                 malloctype='char *'
4490         fi
4491         ;;
4492 esac
4493 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4494
4495 case "$freetype" in
4496 '')
4497         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4498                 freetype='void'
4499         else
4500                 freetype='int'
4501         fi
4502         ;;
4503 esac
4504 echo "Your system uses $freetype free(), it would seem." >&4
4505 $rm -f malloc.[co]
4506 : Cruising for prototypes
4507 echo " "
4508 echo "Checking out function prototypes..." >&4
4509 $cat >prototype.c <<'EOCP'
4510 int main(int argc, char *argv[]) {
4511         exit(0);}
4512 EOCP
4513 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4514         echo "Your C compiler appears to support function prototypes."
4515         val="$define"
4516 else
4517         echo "Your C compiler doesn't seem to understand function prototypes."
4518         val="$undef"
4519 fi
4520 set prototype
4521 eval $setvar
4522 $rm -f prototype*
4523
4524 case "$prototype" in
4525 "$define") ;;
4526 *)      ansi2knr='ansi2knr'
4527         echo " "
4528         cat <<EOM >&4
4529
4530 $me:  FATAL ERROR:
4531 This version of $package can only be compiled by a compiler that 
4532 understands function prototypes.  Unfortunately, your C compiler 
4533         $cc $ccflags
4534 doesn't seem to understand them.  Sorry about that.
4535
4536 If GNU cc is available for your system, perhaps you could try that instead.  
4537
4538 Eventually, we hope to support building Perl with pre-ANSI compilers.
4539 If you would like to help in that effort, please contact <perlbug@perl.org>.
4540
4541 Aborting Configure now.
4542 EOM
4543         exit 2
4544         ;;
4545 esac
4546
4547 : determine where public executables go
4548 echo " "
4549 set dflt bin bin
4550 eval $prefixit
4551 fn=d~
4552 rp='Pathname where the public executables will reside?'
4553 . ./getfile
4554 if $test "X$ansexp" != "X$binexp"; then
4555         installbin=''
4556 fi
4557 bin="$ans"
4558 binexp="$ansexp"
4559 if $afs; then
4560         $cat <<EOM
4561
4562 Since you are running AFS, I need to distinguish the directory in which
4563 executables reside from the directory in which they are installed (and from
4564 which they are presumably copied to the former directory by occult means).
4565
4566 EOM
4567         case "$installbin" in
4568         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4569         *) dflt="$installbin";;
4570         esac
4571         fn=de~
4572         rp='Where will public executables be installed?'
4573         . ./getfile
4574         installbin="$ans"
4575 else
4576         installbin="$binexp"
4577 fi
4578
4579 : determine whether to install perl also as /usr/bin/perl
4580
4581 echo " "
4582 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4583         $cat <<EOM
4584 Many scripts expect to perl to be installed as /usr/bin/perl.
4585 I can install the perl you are about to compile also as /usr/bin/perl
4586 (in addition to $installbin/perl).
4587 EOM
4588         case "$installusrbinperl" in
4589         "$undef"|[nN]*) dflt='n';;
4590         *)              dflt='y';;
4591         esac
4592         rp="Do you want to install perl as /usr/bin/perl?"
4593         . ./myread
4594         case "$ans" in
4595         [yY]*)  val="$define";;
4596         *)      val="$undef" ;;
4597         esac
4598 else
4599         val="$undef"
4600 fi
4601 set installusrbinperl
4602 eval $setvar
4603
4604 : define a shorthand compile call
4605 compile='
4606 mc_file=$1;
4607 shift;
4608 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4609 : define a shorthand compile call for compilations that should be ok.
4610 compile_ok='
4611 mc_file=$1;
4612 shift;
4613 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4614
4615 echo " "
4616 echo "Checking for GNU C Library..." >&4
4617 cat >gnulibc.c <<EOM
4618 #include <stdio.h>
4619 int main()
4620 {
4621 #ifdef __GLIBC__
4622     exit(0);
4623 #else
4624     exit(1);
4625 #endif
4626 }
4627 EOM
4628 set gnulibc
4629 if eval $compile_ok && ./gnulibc; then
4630         val="$define"
4631         echo "You are using the GNU C Library"
4632 else
4633         val="$undef"
4634         echo "You are not using the GNU C Library"
4635 fi
4636 $rm -f gnulibc*
4637 set d_gnulibc
4638 eval $setvar
4639
4640 : see if nm is to be used to determine whether a symbol is defined or not
4641 case "$usenm" in
4642 '')
4643         dflt=''
4644         case "$d_gnulibc" in
4645         "$define")
4646                 echo " "
4647                 echo "nm probably won't work on the GNU C Library." >&4
4648                 dflt=n
4649                 ;;
4650         esac
4651         case "$dflt" in
4652         '') 
4653                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4654                         echo " "
4655                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4656                         echo "'nm' won't be sufficient on this sytem." >&4
4657                         dflt=n
4658                 fi
4659                 ;;
4660         esac
4661         case "$dflt" in
4662         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4663                 if $test $dflt -gt 20; then
4664                         dflt=y
4665                 else
4666                         dflt=n
4667                 fi
4668                 ;;
4669         esac
4670         ;;
4671 *)
4672         case "$usenm" in
4673         true|$define) dflt=y;;
4674         *) dflt=n;;
4675         esac
4676         ;;
4677 esac
4678 $cat <<EOM
4679
4680 I can use $nm to extract the symbols from your C libraries. This
4681 is a time consuming task which may generate huge output on the disk (up
4682 to 3 megabytes) but that should make the symbols extraction faster. The
4683 alternative is to skip the 'nm' extraction part and to compile a small
4684 test program instead to determine whether each symbol is present. If
4685 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4686 this may be the best solution.
4687
4688 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4689
4690 EOM
4691 rp="Shall I use $nm to extract C symbols from the libraries?"
4692 . ./myread
4693 case "$ans" in
4694 [Nn]*) usenm=false;;
4695 *) usenm=true;;
4696 esac
4697
4698 runnm=$usenm
4699 case "$reuseval" in
4700 true) runnm=false;;
4701 esac
4702
4703 : nm options which may be necessary
4704 case "$nm_opt" in
4705 '') if $test -f /mach_boot; then
4706                 nm_opt=''       # Mach
4707         elif $test -d /usr/ccs/lib; then
4708                 nm_opt='-p'     # Solaris (and SunOS?)
4709         elif $test -f /dgux; then
4710                 nm_opt='-p'     # DG-UX
4711         elif $test -f /lib64/rld; then
4712                 nm_opt='-p'     # 64-bit Irix
4713         else
4714                 nm_opt=''
4715         fi;;
4716 esac
4717
4718 : nm options which may be necessary for shared libraries but illegal
4719 : for archive libraries.  Thank you, Linux.
4720 case "$nm_so_opt" in
4721 '')     case "$myuname" in
4722         *linux*)
4723                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4724                         nm_so_opt='--dynamic'
4725                 fi
4726                 ;;
4727         esac
4728         ;;
4729 esac
4730
4731 case "$runnm" in
4732 true)
4733 : get list of predefined functions in a handy place
4734 echo " "
4735 case "$libc" in
4736 '') libc=unknown
4737         case "$libs" in
4738         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4739         esac
4740         ;;
4741 esac
4742 libnames='';
4743 case "$libs" in
4744 '') ;;
4745 *)  for thislib in $libs; do
4746         case "$thislib" in
4747         -lc|-lc_s)
4748                 : Handle C library specially below.
4749                 ;;
4750         -l*)
4751                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4752                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4753                         :
4754                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4755                         :
4756                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4757                         :
4758                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4759                         :
4760                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4761                         :
4762                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4763                         :
4764                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4765                         :
4766                 else
4767                         try=''
4768                 fi
4769                 libnames="$libnames $try"
4770                 ;;
4771         *) libnames="$libnames $thislib" ;;
4772         esac
4773         done
4774         ;;
4775 esac
4776 xxx=normal
4777 case "$libc" in
4778 unknown)
4779         set /lib/libc.$so
4780         for xxx in $libpth; do
4781                 $test -r $1 || set $xxx/libc.$so
4782                 : The messy sed command sorts on library version numbers.
4783                 $test -r $1 || \
4784                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4785                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4786                                 h
4787                                 s/[0-9][0-9]*/0000&/g
4788                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4789                                 G
4790                                 s/\n/ /' | \
4791                          sort | $sed -e 's/^.* //'`
4792                 eval set \$$#
4793         done
4794         $test -r $1 || set /usr/ccs/lib/libc.$so
4795         $test -r $1 || set /lib/libsys_s$_a
4796         ;;
4797 *)
4798         set blurfl
4799         ;;
4800 esac
4801 if $test -r "$1"; then
4802         echo "Your (shared) C library seems to be in $1."
4803         libc="$1"
4804 elif $test -r /lib/libc && $test -r /lib/clib; then
4805         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4806         xxx=apollo
4807         libc='/lib/clib /lib/libc'
4808         if $test -r /lib/syslib; then
4809                 echo "(Your math library is in /lib/syslib.)"
4810                 libc="$libc /lib/syslib"
4811         fi
4812 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4813         echo "Your C library seems to be in $libc, as you said before."
4814 elif $test -r $incpath/usr/lib/libc$_a; then
4815         libc=$incpath/usr/lib/libc$_a;
4816         echo "Your C library seems to be in $libc.  That's fine."
4817 elif $test -r /lib/libc$_a; then
4818         libc=/lib/libc$_a;
4819         echo "Your C library seems to be in $libc.  You're normal."
4820 else
4821         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4822                 :
4823         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4824                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4825         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4826                 :
4827         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4828                 :
4829         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4830                 :
4831         else
4832                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4833         fi
4834         if $test -r "$tans"; then
4835                 echo "Your C library seems to be in $tans, of all places."
4836                 libc=$tans
4837         else
4838                 libc='blurfl'
4839         fi
4840 fi
4841 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4842         dflt="$libc"
4843         cat <<EOM
4844
4845 If the guess above is wrong (which it might be if you're using a strange
4846 compiler, or your machine supports multiple models), you can override it here.
4847
4848 EOM
4849 else
4850         dflt=''
4851         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4852         cat >&4 <<EOM
4853 I can't seem to find your C library.  I've looked in the following places:
4854
4855 EOM
4856         $sed 's/^/      /' libpath
4857         cat <<EOM
4858
4859 None of these seems to contain your C library. I need to get its name...
4860
4861 EOM
4862 fi
4863 fn=f
4864 rp='Where is your C library?'
4865 . ./getfile
4866 libc="$ans"
4867
4868 echo " "
4869 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4870 set X `cat libnames`
4871 shift
4872 xxx=files
4873 case $# in 1) xxx=file; esac
4874 echo "Extracting names from the following $xxx for later perusal:" >&4
4875 echo " "
4876 $sed 's/^/      /' libnames >&4
4877 echo " "
4878 $echo $n "This may take a while...$c" >&4
4879
4880 for file in $*; do
4881         case $file in
4882         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4883         *) $nm $nm_opt $file 2>/dev/null;;
4884         esac
4885 done >libc.tmp
4886
4887 $echo $n ".$c"
4888 $grep fprintf libc.tmp > libc.ptf
4889 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4890 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4891 xxx='[ADTSIW]'
4892 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4893         eval $xscan;\
4894         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4895                 eval $xrun
4896 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4897         eval $xscan;\
4898         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4899                 eval $xrun
4900 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4901         eval $xscan;\
4902         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4903                 eval $xrun
4904 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4905         eval $xscan;\
4906         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4907                 eval $xrun
4908 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4909         eval $xscan;\
4910         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4911                 eval $xrun
4912 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4913         eval $xscan;\
4914         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4915                 eval $xrun
4916 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4917                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4918         eval $xscan;\
4919         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4920                 eval $xrun
4921 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4922         eval $xscan;\
4923         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4924                 eval $xrun
4925 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4926         eval $xscan;\
4927         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4928                 eval $xrun
4929 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4930         eval $xscan;\
4931         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4932                 eval $xrun
4933 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4934         eval $xscan;\
4935         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4936                 eval $xrun
4937 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4938         eval $xscan;\
4939         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4940                 eval $xrun
4941 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4942         eval $xscan;\
4943         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4944                 eval $xrun
4945 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4946         eval $xscan;\
4947         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4948                 eval $xrun
4949 else
4950         $nm -p $* 2>/dev/null >libc.tmp
4951         $grep fprintf libc.tmp > libc.ptf
4952         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4953                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4954         then
4955                 nm_opt='-p'
4956                 eval $xrun
4957         else
4958                 echo " "
4959                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4960                 com=''
4961                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4962                         for thisname in $libnames $libc; do
4963                                 $ar t $thisname >>libc.tmp
4964                         done
4965                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4966                         echo "Ok." >&4
4967                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4968                         # Repeat libc to extract forwarders to DLL entries too
4969                         for thisname in $libnames $libc; do
4970                                 $ar tv $thisname >>libc.tmp
4971                                 # Revision 50 of EMX has bug in $ar.
4972                                 # it will not extract forwarders to DLL entries
4973                                 # Use emximp which will extract exactly them.
4974                                 emximp -o tmp.imp $thisname \
4975                                     2>/dev/null && \
4976                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4977                                     < tmp.imp >>libc.tmp
4978                                 $rm tmp.imp
4979                         done
4980                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
4981                         echo "Ok." >&4
4982                 else
4983                         echo "$ar didn't seem to work right." >&4
4984                         echo "Maybe this is a Cray...trying bld instead..." >&4
4985                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
4986                         then
4987                                 for thisname in $libnames; do
4988                                         bld t $libnames | \
4989                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
4990                                         $ar t $thisname >>libc.tmp
4991                                 done
4992                                 echo "Ok." >&4
4993                         else
4994                                 echo "That didn't work either.  Giving up." >&4
4995                                 exit 1
4996                         fi
4997                 fi
4998         fi
4999 fi
5000 nm_extract="$com"
5001 if $test -f /lib/syscalls.exp; then
5002         echo " "
5003         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
5004         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
5005 fi
5006 ;;
5007 esac
5008 $rm -f libnames libpath
5009
5010 : see if dld is available
5011 set dld.h i_dld
5012 eval $inhdr
5013
5014 : is a C symbol defined?
5015 csym='tlook=$1;
5016 case "$3" in
5017 -v) tf=libc.tmp; tc=""; tdc="";;
5018 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5019 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5020 esac;
5021 tx=yes;
5022 case "$reuseval-$4" in
5023 true-) ;;
5024 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5025 esac;
5026 case "$tx" in
5027 yes)
5028         case "$runnm" in
5029         true)
5030                 if $contains $tlook $tf >/dev/null 2>&1;
5031                 then tval=true;
5032                 else tval=false;
5033                 fi;;
5034         *)
5035                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5036                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5037                 then tval=true;
5038                 else tval=false;
5039                 fi;
5040                 $rm -f t t.c;;
5041         esac;;
5042 *)
5043         case "$tval" in
5044         $define) tval=true;;
5045         *) tval=false;;
5046         esac;;
5047 esac;
5048 eval "$2=$tval"'
5049
5050 : define an is-in-libc? function
5051 inlibc='echo " "; td=$define; tu=$undef;
5052 sym=$1; var=$2; eval "was=\$$2";
5053 tx=yes;
5054 case "$reuseval$was" in
5055 true) ;;
5056 true*) tx=no;;
5057 esac;
5058 case "$tx" in
5059 yes)
5060         set $sym tres -f;
5061         eval $csym;
5062         case "$tres" in
5063         true)
5064                 echo "$sym() found." >&4;
5065                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5066         *)
5067                 echo "$sym() NOT found." >&4;
5068                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5069         esac;;
5070 *)
5071         case "$was" in
5072         $define) echo "$sym() found." >&4;;
5073         *) echo "$sym() NOT found." >&4;;
5074         esac;;
5075 esac'
5076
5077 : see if dlopen exists
5078 xxx_runnm="$runnm"
5079 runnm=false
5080 set dlopen d_dlopen
5081 eval $inlibc
5082 runnm="$xxx_runnm"
5083
5084 : determine which dynamic loading, if any, to compile in
5085 echo " "
5086 dldir="ext/DynaLoader"
5087 case "$usedl" in
5088 $define|y|true)
5089         dflt='y'
5090         usedl="$define"
5091         ;;
5092 $undef|n|false)
5093         dflt='n'
5094         usedl="$undef"
5095         ;;
5096 *) 
5097         dflt='n'
5098         case "$d_dlopen" in
5099             $define) dflt='y' ;;
5100         esac
5101         case "$i_dld" in
5102             $define) dflt='y' ;;
5103         esac
5104         : Does a dl_xxx.xs file exist for this operating system
5105         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5106         ;;
5107 esac
5108 rp="Do you wish to use dynamic loading?"
5109 . ./myread
5110 usedl="$ans"
5111 case "$ans" in
5112 y*) usedl="$define"
5113         case "$dlsrc" in
5114         '')
5115                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5116                         dflt="$dldir/dl_${osname}.xs"
5117                 elif $test "$d_dlopen" = "$define" ; then
5118                         dflt="$dldir/dl_dlopen.xs"
5119                 elif $test "$i_dld" = "$define" ; then
5120                         dflt="$dldir/dl_dld.xs"
5121                 else
5122                         dflt=''
5123                 fi
5124                 ;;
5125         *)      dflt="$dldir/$dlsrc"
5126                 ;;
5127         esac
5128     echo "The following dynamic loading files are available:"
5129         : Can not go over to $dldir because getfile has path hard-coded in.
5130         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5131         rp="Source file to use for dynamic loading"
5132         fn="fne"
5133         # XXX This getfile call will fail the existence check if you try 
5134         # building away from $src (this is not supported yet).
5135         . ./getfile
5136         usedl="$define"
5137         : emulate basename
5138         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5139
5140         $cat << EOM
5141
5142 Some systems may require passing special flags to $cc -c to
5143 compile modules that will be used to create a shared library.
5144 To use no flags, say "none".
5145
5146 EOM
5147     case "$cccdlflags" in
5148     '') case "$gccversion" in
5149                 '') case "$osname" in
5150                         hpux)   dflt='+z' ;;
5151                         next)   dflt='none' ;;
5152                         irix*)  dflt='-KPIC' ;;
5153                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5154                         sunos)  dflt='-pic' ;;
5155                         *)      dflt='none' ;;
5156                     esac
5157                         ;;
5158                 *)  case "$osname" in
5159                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5160                         *)      dflt='-fpic' ;;
5161                     esac ;;
5162             esac ;;
5163         ' ') dflt='none' ;;
5164     *)  dflt="$cccdlflags" ;;
5165     esac
5166     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5167     . ./myread
5168     case "$ans" in
5169     none) cccdlflags=' ' ;;
5170     *) cccdlflags="$ans" ;;
5171     esac
5172
5173     cat << EOM
5174
5175 Some systems use ld to create libraries that can be dynamically loaded,
5176 while other systems (such as those using ELF) use $cc.
5177
5178 EOM
5179         case "$ld" in
5180         '')     $cat >try.c <<'EOM'
5181 /* Test for whether ELF binaries are produced */
5182 #include <fcntl.h>
5183 #include <stdlib.h>
5184 int main() {
5185         char b[4];
5186         int i = open("a.out",O_RDONLY);
5187         if(i == -1) 
5188                 exit(1); /* fail */
5189         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5190                 exit(0); /* succeed (yes, it's ELF) */
5191         else
5192                 exit(1); /* fail */
5193 }
5194 EOM
5195                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5196                         cat <<EOM
5197 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5198 EOM
5199                         dflt="$cc"
5200                 else
5201                         echo "I'll use ld to build dynamic libraries."
5202                         dflt='ld'
5203                 fi
5204                 rm -f try.c a.out
5205                 ;;
5206         *)      dflt="$ld"
5207                 ;;
5208         esac
5209
5210     rp="What command should be used to create dynamic libraries?"
5211     . ./myread
5212         ld="$ans"
5213
5214     cat << EOM
5215
5216 Some systems may require passing special flags to $ld to create a
5217 library that can be dynamically loaded.  If your ld flags include
5218 -L/other/path options to locate libraries outside your loader's normal
5219 search path, you may need to specify those -L options here as well.  To
5220 use no flags, say "none".
5221
5222 EOM
5223     case "$lddlflags" in
5224     '') case "$osname" in
5225                         beos) dflt='-nostart' ;;
5226                         hpux)  dflt='-b' ;;
5227                         linux|irix*)    dflt='-shared' ;;
5228                         next)  dflt='none' ;;
5229                         solaris) dflt='-G' ;;
5230                         sunos) dflt='-assert nodefinitions' ;;
5231                         svr4*|esix*) dflt="-G $ldflags" ;;
5232                 *)     dflt='none' ;;
5233                         esac
5234                         ;;
5235     *) dflt="$lddlflags" ;;
5236     esac
5237
5238         : Try to guess additional flags to pick up local libraries.
5239         : Be careful not to append to a plain 'none'
5240         case "$dflt" in
5241         none) dflt='' ;;
5242         esac
5243         for thisflag in $ldflags; do
5244                 case "$thisflag" in
5245                 -L*)
5246                         case " $dflt " in
5247                         *" $thisflag "*) ;;
5248                         *) dflt="$dflt $thisflag" ;;
5249                         esac
5250                         ;;
5251                 esac
5252         done
5253
5254         case "$dflt" in
5255         ''|' ') dflt='none' ;;
5256         esac
5257
5258     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5259     . ./myread
5260     case "$ans" in
5261     none) lddlflags=' ' ;;
5262     *) lddlflags="$ans" ;;
5263     esac
5264
5265         cat <<EOM
5266
5267 Some systems may require passing special flags to $cc to indicate that
5268 the resulting executable will use dynamic linking.  To use no flags,
5269 say "none".
5270
5271 EOM
5272     case "$ccdlflags" in
5273     '') case "$osname" in
5274                 hpux)   dflt='-Wl,-E' ;;
5275                 linux)  dflt='-rdynamic' ;;
5276                 next)   dflt='none' ;;
5277                 sunos)  dflt='none' ;;
5278                 *)      dflt='none' ;;
5279             esac ;;
5280     ' ')  dflt='none' ;;
5281     *)  dflt="$ccdlflags" ;;
5282     esac
5283     rp="Any special flags to pass to $cc to use dynamic loading?"
5284     . ./myread
5285     case "$ans" in
5286     none) ccdlflags=' ' ;;
5287     *) ccdlflags="$ans" ;;
5288     esac
5289     ;;
5290 *)  usedl="$undef"
5291         ld='ld'
5292     dlsrc='dl_none.xs'
5293     lddlflags=''
5294     ccdlflags=''
5295     ;;
5296 esac
5297
5298 also=''
5299 case "$usedl" in
5300 $undef)
5301         # No dynamic loading being used, so don't bother even to prompt.
5302         useshrplib='false'
5303         ;;
5304 *)      case "$useshrplib" in
5305         '')     case "$osname" in
5306                 svr4*|dgux|dynixptx|esix|powerux|beos)
5307                         dflt=y
5308                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5309                         ;;
5310                 next*)
5311                         case "$osvers" in
5312                         4*)     dflt=y
5313                                 also='Building a shared libperl is needed for MAB support.'
5314                                 ;;
5315                         *)      dflt=n
5316                                 ;;
5317                         esac
5318                         ;;
5319                 *)      dflt=n
5320                         ;;
5321                 esac
5322                 ;;
5323         $define|true|[Yy]*)
5324                 dflt=y
5325                 ;;
5326         *)      dflt=n
5327                 ;;
5328         esac
5329         $cat << EOM
5330
5331 The perl executable is normally obtained by linking perlmain.c with
5332 libperl${_a}, any static extensions (usually just DynaLoader), and
5333 any other libraries needed on this system (such as -lm, etc.).  Since
5334 your system supports dynamic loading, it is probably possible to build
5335 a shared libperl.$so.  If you will have more than one executable linked
5336 to libperl.$so, this will significantly reduce the size of each
5337 executable, but it may have a noticeable affect on performance.  The
5338 default is probably sensible for your system.
5339 $also
5340
5341 EOM
5342         rp="Build a shared libperl.$so (y/n)"
5343         . ./myread
5344         case "$ans" in
5345         true|$define|[Yy]*)
5346                 useshrplib='true'
5347                 # Why does next4 have to be so different?
5348                 case "${osname}${osvers}" in
5349                 next4*|rhapsody*)
5350                         xxx='DYLD_LIBRARY_PATH' ;;
5351                 os2*)   xxx='' ;; # Nothing special needed.
5352                 beos*)  xxx='' ;;
5353                 *)              xxx='LD_LIBRARY_PATH' ;;
5354                 esac
5355                 ;;
5356         *)      useshrplib='false' ;;
5357         esac
5358         ;;
5359 esac
5360
5361 case "$useshrplib" in
5362 true)
5363         case "$libperl" in
5364         '')
5365                 # Figure out a good name for libperl.so.  Since it gets stored in
5366                 # a version-specific architecture-dependent library, the version
5367                 # number isn't really that important, except for making cc/ld happy.
5368                 #
5369                 # A name such as libperl.so.3.1
5370                 majmin="libperl.$so.$patchlevel.$subversion"
5371                 # A name such as libperl.so.301
5372                 majonly=`echo $patchlevel $subversion |
5373                         $awk '{printf "%d%02d", $1, $2}'`
5374                 majonly=libperl.$so.$majonly
5375                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5376                 # rely on figuring it out from the naming of libc.
5377                 case "${osname}${osvers}" in
5378                 next4*)
5379                         dflt=libperl.5.$so
5380                         # XXX How handle the --version stuff for MAB?
5381                         ;;
5382                 linux*)  # ld won't link with a bare -lperl otherwise.
5383                         dflt=libperl.$so
5384                         ;;
5385                 *)      # Try to guess based on whether libc has major.minor.
5386                         case "$libc" in
5387                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5388                         *libc.$so.[0-9]*) dflt=$majonly ;;
5389                         *)      dflt=libperl.$so ;;
5390                         esac
5391                         ;;
5392                 esac
5393                 ;;
5394         *)      dflt=$libperl
5395                 ;;
5396         esac
5397         cat << EOM
5398
5399 I need to select a good name for the shared libperl.  If your system uses
5400 library names with major and minor numbers, then you might want something
5401 like $majmin.  Alternatively, if your system uses a single version
5402 number for shared libraries, then you might want to use $majonly.
5403 Or, your system might be quite happy with a simple libperl.$so.
5404
5405 Since the shared libperl will get installed into a version-specific
5406 architecture-dependent directory, the version number of the shared perl
5407 library probably isn't important, so the default should be o.k.
5408
5409 EOM
5410         rp='What name do you want to give to the shared libperl?'
5411         . ./myread
5412         libperl=$ans
5413         echo "Ok, I'll use $libperl"
5414         ;;
5415 *)
5416         libperl="libperl${_a}"
5417         ;;
5418 esac
5419
5420 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5421 case "$shrpdir" in
5422 '') ;;
5423 *)      $cat >&4 <<EOM
5424 WARNING:  Use of the shrpdir variable for the installation location of
5425 the shared $libperl is not supported.  It was never documented and
5426 will not work in this version.  Let me (perlbug@perl.com)
5427 know of any problems this may cause.
5428
5429 EOM
5430         case "$shrpdir" in
5431         "$archlibexp/CORE")
5432                 $cat >&4 <<EOM
5433 But your current setting of $shrpdir is
5434 the default anyway, so it's harmless.
5435 EOM
5436                 ;;
5437         *)
5438                 $cat >&4 <<EOM
5439 Further, your current attempted setting of $shrpdir
5440 conflicts with the value of $archlibexp/CORE
5441 that installperl will use.
5442 EOM
5443                 ;;
5444         esac
5445         ;;
5446 esac
5447
5448 # How will the perl executable find the installed shared $libperl?
5449 # Add $xxx to ccdlflags.
5450 # If we can't figure out a command-line option, use $shrpenv to
5451 # set env LD_RUN_PATH.  The main perl makefile uses this.
5452 shrpdir=$archlibexp/CORE
5453 xxx=''
5454 tmp_shrpenv=''
5455 if "$useshrplib"; then
5456     case "$osname" in 
5457         aix)
5458                 # We'll set it in Makefile.SH...
5459                 ;;
5460         solaris|netbsd)
5461                 xxx="-R $shrpdir"
5462                 ;;
5463         freebsd)
5464                 xxx="-Wl,-R$shrpdir"
5465                 ;;
5466         linux|irix*|dec_osf)
5467                 xxx="-Wl,-rpath,$shrpdir"
5468                 ;;
5469         next)
5470                 # next doesn't like the default...
5471                 ;;
5472         beos)
5473                 # beos doesn't like the default, either.
5474                 ;;
5475         hpux*)
5476                 # hpux doesn't like the default, either.
5477                 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
5478                 ;;
5479         *)
5480                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5481                 ;;
5482         esac
5483         case "$xxx" in
5484         '') ;;
5485         *)      
5486                 # Only add $xxx if it isn't already in ccdlflags.
5487                 case " $ccdlflags " in
5488                 *" $xxx "*)     ;;
5489                 *)      ccdlflags="$ccdlflags $xxx"
5490                         cat <<EOM >&4
5491
5492 Adding $xxx to the flags
5493 passed to $ld so that the perl executable will find the 
5494 installed shared $libperl.
5495
5496 EOM
5497                         ;;
5498                 esac
5499                 ;;
5500         esac
5501 fi
5502 # Respect a hint or command-line value.
5503 case "$shrpenv" in
5504 '') shrpenv="$tmp_shrpenv" ;;
5505 esac
5506
5507 : determine where manual pages go
5508 set man1dir man1dir none
5509 eval $prefixit
5510 $cat <<EOM
5511
5512 $spackage has manual pages available in source form.
5513 EOM
5514 case "$nroff" in
5515 nroff)
5516         echo "However, you don't have nroff, so they're probably useless to you."
5517         case "$man1dir" in
5518         '') man1dir="none";;
5519         esac;;
5520 esac
5521 echo "If you don't want the manual sources installed, answer 'none'."
5522 case "$man1dir" in
5523 ' ') dflt=none
5524         ;;
5525 '')
5526         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5527         lookpath="$lookpath $prefixexp/man/p_man/man1"
5528         lookpath="$lookpath $prefixexp/man/u_man/man1"
5529         lookpath="$lookpath $prefixexp/man/man.1"
5530         case "$sysman" in
5531         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5532         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5533         esac
5534         set dflt
5535         eval $prefixup
5536         ;;
5537 *)  dflt="$man1dir"
5538         ;;
5539 esac
5540 echo " "
5541 fn=dn+~
5542 rp="Where do the main $spackage manual pages (source) go?"
5543 . ./getfile
5544 if $test "X$man1direxp" != "X$ansexp"; then
5545         installman1dir=''
5546 fi
5547 man1dir="$ans"
5548 man1direxp="$ansexp"
5549 case "$man1dir" in
5550 '') man1dir=' '
5551         installman1dir='';;
5552 esac
5553 if $afs; then
5554         $cat <<EOM
5555
5556 Since you are running AFS, I need to distinguish the directory in which
5557 manual pages reside from the directory in which they are installed (and from
5558 which they are presumably copied to the former directory by occult means).
5559
5560 EOM
5561         case "$installman1dir" in
5562         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5563         *) dflt="$installman1dir";;
5564         esac
5565         fn=de~
5566         rp='Where will man pages be installed?'
5567         . ./getfile
5568         installman1dir="$ans"
5569 else
5570         installman1dir="$man1direxp"
5571 fi
5572
5573 : What suffix to use on installed man pages
5574
5575 case "$man1dir" in
5576 ' ')
5577         man1ext='0'
5578         ;;
5579 *)
5580         rp="What suffix should be used for the main $spackage man pages?"
5581         case "$man1ext" in
5582         '')     case "$man1dir" in
5583                 *1)  dflt=1 ;;
5584                 *1p) dflt=1p ;;
5585                 *1pm) dflt=1pm ;;
5586                 *l) dflt=l;;
5587                 *n) dflt=n;;
5588                 *o) dflt=o;;
5589                 *p) dflt=p;;
5590                 *C) dflt=C;;
5591                 *L) dflt=L;;
5592                 *L1) dflt=L1;;
5593                 *) dflt=1;;
5594                 esac
5595                 ;;
5596         *)      dflt="$man1ext";;
5597         esac
5598         . ./myread
5599         man1ext="$ans"
5600         ;;
5601 esac
5602
5603 : see if we can have long filenames
5604 echo " "
5605 rmlist="$rmlist /tmp/cf$$"
5606 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5607 first=123456789abcdef
5608 second=/tmp/cf$$/$first
5609 $rm -f $first $second
5610 if (echo hi >$first) 2>/dev/null; then
5611         if $test -f 123456789abcde; then
5612                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5613                 val="$undef"
5614         else
5615                 if (echo hi >$second) 2>/dev/null; then
5616                         if $test -f /tmp/cf$$/123456789abcde; then
5617                                 $cat <<'EOM'
5618 That's peculiar... You can have filenames longer than 14 characters, but only
5619 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5620 I shall consider your system cannot support long filenames at all.
5621 EOM
5622                                 val="$undef"
5623                         else
5624                                 echo 'You can have filenames longer than 14 characters.' >&4
5625                                 val="$define"
5626                         fi
5627                 else
5628                         $cat <<'EOM'
5629 How confusing! Some of your filesystems are sane enough to allow filenames
5630 longer than 14 characters but some others like /tmp can't even think about them.
5631 So, for now on, I shall assume your kernel does not allow them at all.
5632 EOM
5633                         val="$undef"
5634                 fi
5635         fi
5636 else
5637         $cat <<'EOM'
5638 You can't have filenames longer than 14 chars.  You can't even think about them!
5639 EOM
5640         val="$undef"
5641 fi 
5642 set d_flexfnam
5643 eval $setvar
5644 $rm -rf /tmp/cf$$ 123456789abcde*
5645
5646 : determine where library module manual pages go
5647 set man3dir man3dir none
5648 eval $prefixit
5649 $cat <<EOM
5650
5651 $spackage has manual pages for many of the library modules.
5652 EOM
5653
5654 case "$nroff" in
5655 nroff)
5656         $cat <<'EOM'
5657 However, you don't have nroff, so they're probably useless to you.
5658 EOM
5659         case "$man3dir" in
5660         '') man3dir="none";;
5661         esac;;
5662 esac
5663
5664 case "$d_flexfnam" in
5665 undef)
5666         $cat <<'EOM'
5667 However, your system can't handle the long file names like File::Basename.3. 
5668 EOM
5669         case "$man3dir" in
5670         '') man3dir="none";;
5671         esac;;
5672 esac
5673
5674 echo "If you don't want the manual sources installed, answer 'none'."
5675 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5676 case "$man3dir" in
5677 '')     case "$prefix" in 
5678         *$prog*) dflt=`echo $man1dir | 
5679                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5680         *)      dflt="$privlib/man/man3" ;;
5681         esac
5682         ;;
5683 ' ') dflt=none;;
5684 *)      dflt="$man3dir" ;;
5685 esac
5686 echo " "
5687
5688 fn=dn+~
5689 rp="Where do the $package library man pages (source) go?"
5690 . ./getfile
5691 if test "X$man3direxp" != "X$ansexp"; then
5692         installman3dir=''
5693 fi
5694
5695 man3dir="$ans"
5696 man3direxp="$ansexp"
5697 case "$man3dir" in
5698 '') man3dir=' '
5699         installman3dir='';;
5700 esac
5701 if $afs; then
5702         $cat <<EOM
5703
5704 Since you are running AFS, I need to distinguish the directory in which
5705 manual pages reside from the directory in which they are installed (and from
5706 which they are presumably copied to the former directory by occult means).
5707
5708 EOM
5709         case "$installman3dir" in
5710         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5711         *) dflt="$installman3dir";;
5712         esac
5713         fn=de~
5714         rp='Where will man pages be installed?'
5715         . ./getfile
5716         installman3dir="$ans"
5717 else
5718         installman3dir="$man3direxp"
5719 fi
5720
5721 : What suffix to use on installed man pages
5722
5723 case "$man3dir" in
5724 ' ')
5725         man3ext='0'
5726         ;;
5727 *)
5728         rp="What suffix should be used for the $package library man pages?"
5729         case "$man3ext" in
5730         '')     case "$man3dir" in
5731                 *3)  dflt=3 ;;
5732                 *3p) dflt=3p ;;
5733                 *3pm) dflt=3pm ;;
5734                 *l) dflt=l;;
5735                 *n) dflt=n;;
5736                 *o) dflt=o;;
5737                 *p) dflt=p;;
5738                 *C) dflt=C;;
5739                 *L) dflt=L;;
5740                 *L3) dflt=L3;;
5741                 *) dflt=3;;
5742                 esac
5743                 ;;
5744         *)      dflt="$man3ext";;
5745         esac
5746         . ./myread
5747         man3ext="$ans"
5748         ;;
5749 esac
5750
5751 : see if we have to deal with yellow pages, now NIS.
5752 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5753         if $test -f /usr/etc/nibindd; then
5754                 echo " "
5755                 echo "I'm fairly confident you're on a NeXT."
5756                 echo " "
5757                 rp='Do you get the hosts file via NetInfo?'
5758                 dflt=y
5759                 case "$hostcat" in
5760                 nidump*) ;;
5761                 '') ;;
5762                 *) dflt=n;;
5763                 esac
5764                 . ./myread
5765                 case "$ans" in
5766                 y*) hostcat='nidump hosts .';;
5767                 *)      case "$hostcat" in
5768                         nidump*) hostcat='';;
5769                         esac
5770                         ;;
5771                 esac
5772         fi
5773         case "$hostcat" in
5774         nidump*) ;;
5775         *)
5776                 case "$hostcat" in
5777                 *ypcat*) dflt=y;;
5778                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5779                                 dflt=y
5780                         else
5781                                 dflt=n
5782                         fi;;
5783                 *) dflt=n;;
5784                 esac
5785                 echo " "
5786                 rp='Are you getting the hosts file via yellow pages?'
5787                 . ./myread
5788                 case "$ans" in
5789                 y*) hostcat='ypcat hosts';;
5790                 *) hostcat='cat /etc/hosts';;
5791                 esac
5792                 ;;
5793         esac
5794 fi
5795 case "$hostcat" in
5796 '') hostcat='cat /etc/hosts';;
5797 esac
5798 case "$groupcat" in
5799 '') groupcat='cat /etc/group';;
5800 esac
5801 case "$passcat" in
5802 '') passcat='cat /etc/passwd';;
5803 esac
5804
5805 : now get the host name
5806 echo " "
5807 echo "Figuring out host name..." >&4
5808 case "$myhostname" in
5809 '') cont=true
5810         echo 'Maybe "hostname" will work...'
5811         if tans=`sh -c hostname 2>&1` ; then
5812                 myhostname=$tans
5813                 phostname=hostname
5814                 cont=''
5815         fi
5816         ;;
5817 *) cont='';;
5818 esac
5819 if $test "$cont"; then
5820         if ./xenix; then
5821                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5822                 if tans=`cat /etc/systemid 2>&1` ; then
5823                         myhostname=$tans
5824                         phostname='cat /etc/systemid'
5825                         echo "Whadyaknow.  Xenix always was a bit strange..."
5826                         cont=''
5827                 fi
5828         elif $test -r /etc/systemid; then
5829                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5830         fi
5831 fi
5832 if $test "$cont"; then
5833         echo 'No, maybe "uuname -l" will work...'
5834         if tans=`sh -c 'uuname -l' 2>&1` ; then
5835                 myhostname=$tans
5836                 phostname='uuname -l'
5837         else
5838                 echo 'Strange.  Maybe "uname -n" will work...'
5839                 if tans=`sh -c 'uname -n' 2>&1` ; then
5840                         myhostname=$tans
5841                         phostname='uname -n'
5842                 else
5843                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5844                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5845                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5846                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5847                         else
5848                                 case "$myhostname" in
5849                                 '') echo "Does this machine have an identity crisis or something?"
5850                                         phostname='';;
5851                                 *)
5852                                         echo "Well, you said $myhostname before..."
5853                                         phostname='echo $myhostname';;
5854                                 esac
5855                         fi
5856                 fi
5857         fi
5858 fi
5859 : you do not want to know about this
5860 set $myhostname
5861 myhostname=$1
5862
5863 : verify guess
5864 if $test "$myhostname" ; then
5865         dflt=y
5866         rp='Your host name appears to be "'$myhostname'".'" Right?"
5867         . ./myread
5868         case "$ans" in
5869         y*) ;;
5870         *) myhostname='';;
5871         esac
5872 fi
5873
5874 : bad guess or no guess
5875 while $test "X$myhostname" = X ; do
5876         dflt=''
5877         rp="Please type the (one word) name of your host:"
5878         . ./myread
5879         myhostname="$ans"
5880 done
5881
5882 : translate upper to lower if necessary
5883 case "$myhostname" in
5884 *[A-Z]*)
5885         echo "(Normalizing case in your host name)"
5886         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5887         ;;
5888 esac
5889
5890 case "$myhostname" in
5891 *.*)
5892         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5893         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5894         echo "(Trimming domain name from host name--host name is now $myhostname)"
5895         ;;
5896 *) case "$mydomain" in
5897         '')
5898                 {
5899                         test "X$hostcat" = "Xypcat hosts" &&
5900                         ypmatch "$myhostname" hosts 2>/dev/null |\
5901                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5902                         $test -s hosts
5903                 } || {
5904                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5905                                         /[       ]$myhostname[  . ]/p" > hosts
5906                 }
5907                 tmp_re="[       . ]"
5908                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5909                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5910                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5911                         hosts | $sort | $uniq | \
5912                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5913                 case `$echo X$dflt` in
5914                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5915                         dflt=.
5916                         ;;
5917                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5918                         ;;
5919                 esac
5920                 case "$dflt" in
5921                 .)
5922                         tans=`./loc resolv.conf X /etc /usr/etc`
5923                         if $test -f "$tans"; then
5924                                 echo "(Attempting domain name extraction from $tans)"
5925                                 dflt=.`$sed -n -e 's/   / /g' \
5926                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5927                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5928                                 case "$dflt" in
5929                                 .) dflt=.`$sed -n -e 's/        / /g' \
5930                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5931                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5932                                         ;;
5933                                 esac
5934                         fi
5935                         ;;
5936                 esac
5937                 case "$dflt" in
5938                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5939                         dflt=.`sh -c domainname 2>/dev/null`
5940                         case "$dflt" in
5941                         '') dflt='.';;
5942                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5943                         esac
5944                         ;;
5945                 esac
5946                 case "$dflt" in
5947                 .) echo "(Lost all hope -- silly guess then)"
5948                         dflt='.uucp'
5949                         ;;
5950                 esac
5951                 $rm -f hosts
5952                 ;;
5953         *) dflt="$mydomain";;
5954         esac;;
5955 esac
5956 echo " "
5957 rp="What is your domain name?"
5958 . ./myread
5959 tans="$ans"
5960 case "$ans" in
5961 '') ;;
5962 .*) ;;
5963 *) tans=".$tans";;
5964 esac
5965 mydomain="$tans"
5966
5967 : translate upper to lower if necessary
5968 case "$mydomain" in
5969 *[A-Z]*)
5970         echo "(Normalizing case in your domain name)"
5971         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5972         ;;
5973 esac
5974
5975 : a little sanity check here
5976 case "$phostname" in
5977 '') ;;
5978 *)
5979         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
5980         $myhostname$mydomain|$myhostname) ;;
5981         *)
5982                 case "$phostname" in
5983                 sed*)
5984                         echo "(That doesn't agree with your whoami.h file, by the way.)"
5985                         ;;
5986                 *)
5987                         echo "(That doesn't agree with your $phostname command, by the way.)"
5988                         ;;
5989                 esac
5990         ;;
5991         esac
5992         ;;
5993 esac
5994
5995 $cat <<EOM
5996
5997 I need to get your e-mail address in Internet format if possible, i.e.
5998 something like user@host.domain. Please answer accurately since I have
5999 no easy means to double check it. The default value provided below
6000 is most probably close to the reality but may not be valid from outside
6001 your organization...
6002
6003 EOM
6004 cont=x
6005 while test "$cont"; do
6006         case "$cf_email" in
6007         '') dflt="$cf_by@$myhostname$mydomain";;
6008         *) dflt="$cf_email";;
6009         esac
6010         rp='What is your e-mail address?'
6011         . ./myread
6012         cf_email="$ans"
6013         case "$cf_email" in
6014         *@*.*) cont='' ;;
6015         *)
6016                 rp='Address does not look like an Internet one.  Use it anyway?'
6017                 case "$fastread" in
6018                 yes) dflt=y ;;
6019                 *) dflt=n ;;
6020                 esac
6021                 . ./myread
6022                 case "$ans" in
6023                 y*) cont='' ;;
6024                 *) echo " " ;;
6025                 esac
6026                 ;;
6027         esac
6028 done
6029
6030 $cat <<EOM
6031
6032 If you or somebody else will be maintaining perl at your site, please
6033 fill in the correct e-mail address here so that they may be contacted
6034 if necessary. Currently, the "perlbug" program included with perl
6035 will send mail to this address in addition to perlbug@perl.com. You may
6036 enter "none" for no administrator.
6037
6038 EOM
6039 case "$perladmin" in
6040 '') dflt="$cf_email";;
6041 *) dflt="$perladmin";;
6042 esac
6043 rp='Perl administrator e-mail address'
6044 . ./myread
6045 perladmin="$ans"
6046
6047 : figure out how to guarantee perl startup
6048 case "$startperl" in
6049 '')
6050         case "$sharpbang" in
6051         *!)
6052                 $cat <<EOH
6053
6054 I can use the #! construct to start perl on your system. This will
6055 make startup of perl scripts faster, but may cause problems if you
6056 want to share those scripts and perl is not in a standard place
6057 ($binexp/perl) on all your platforms. The alternative is to force
6058 a shell by starting the script with a single ':' character.
6059
6060 EOH
6061                 dflt="$binexp/perl"
6062                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6063                 . ./myread
6064                 case "$ans" in
6065                 none)   startperl=": # use perl";;
6066                 *)      startperl="#!$ans"
6067                         if $test 30 -lt `echo "$ans" | wc -c`; then
6068                                 $cat >&4 <<EOM
6069
6070 WARNING:  Some systems limit the #! command to 32 characters.
6071 If you experience difficulty running Perl scripts with #!, try
6072 installing Perl in a directory with a shorter pathname.
6073
6074 EOM
6075                         fi ;;
6076                 esac
6077                 ;;
6078         *) startperl=": # use perl"
6079                 ;;
6080         esac
6081         ;;
6082 esac
6083 echo "I'll use $startperl to start perl scripts."
6084
6085 : figure best path for perl in scripts
6086 case "$perlpath" in
6087 '')
6088         perlpath="$binexp/perl"
6089         case "$startperl" in
6090         *!*) ;;
6091         *)
6092                 $cat <<EOH
6093
6094 I will use the "eval 'exec'" idiom to start Perl on your system.
6095 I can use the full path of your Perl binary for this purpose, but
6096 doing so may cause problems if you want to share those scripts and
6097 Perl is not always in a standard place ($binexp/perl).
6098
6099 EOH
6100                 dflt="$binexp/perl"
6101                 rp="What path shall I use in \"eval 'exec'\"?"
6102                 . ./myread
6103                 perlpath="$ans"
6104                 ;;
6105         esac
6106         ;;
6107 esac
6108 case "$startperl" in
6109 *!*)    ;;
6110 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6111 esac
6112
6113 : determine where public executable scripts go
6114 set scriptdir scriptdir
6115 eval $prefixit
6116 case "$scriptdir" in
6117 '')
6118         dflt="$bin"
6119         : guess some guesses
6120         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6121         $test -d /usr/share/bin && dflt=/usr/share/bin
6122         $test -d /usr/local/script && dflt=/usr/local/script
6123         $test -d $prefixexp/script && dflt=$prefixexp/script
6124         set dflt
6125         eval $prefixup
6126         ;;
6127 *)  dflt="$scriptdir"
6128         ;;
6129 esac
6130 $cat <<EOM
6131  
6132 Some installations have a separate directory just for executable scripts so
6133 that they can mount it across multiple architectures but keep the scripts in
6134 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6135 Or you might just lump your scripts in with all your other executables.
6136  
6137 EOM
6138 fn=d~
6139 rp='Where do you keep publicly executable scripts?'
6140 . ./getfile
6141 if $test "X$ansexp" != "X$scriptdirexp"; then
6142         installscript=''
6143 fi
6144 scriptdir="$ans"
6145 scriptdirexp="$ansexp"
6146 if $afs; then
6147         $cat <<EOM
6148
6149 Since you are running AFS, I need to distinguish the directory in which
6150 scripts reside from the directory in which they are installed (and from
6151 which they are presumably copied to the former directory by occult means).
6152
6153 EOM
6154         case "$installscript" in
6155         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6156         *) dflt="$installscript";;
6157         esac
6158         fn=de~
6159         rp='Where will public scripts be installed?'
6160         . ./getfile
6161         installscript="$ans"
6162 else
6163         installscript="$scriptdirexp"
6164 fi
6165
6166 : determine where site specific libraries go.
6167 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6168 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6169 case "$prefix" in
6170 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6171 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6172 esac
6173 eval $prefixit
6174 $cat <<EOM
6175
6176 The installation process will also create a directory for
6177 site-specific extensions and modules.  Some users find it convenient
6178 to place all site-specific files in this directory rather than in the
6179 main distribution directory.
6180
6181 EOM
6182 fn=d~+
6183 rp='Pathname for the site-specific library files?'
6184 . ./getfile
6185 if $test "X$sitelibexp" != "X$ansexp"; then
6186         installsitelib=''
6187 fi
6188 sitelib="$ans"
6189 sitelibexp="$ansexp"
6190 if $afs; then
6191         $cat <<EOM
6192
6193 Since you are running AFS, I need to distinguish the directory in
6194 which site-specific files reside from the directory in which they are
6195 installed (and from which they are presumably copied to the former
6196 directory by occult means).
6197
6198 EOM
6199         case "$installsitelib" in
6200         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6201         *) dflt="$installsitelib";;
6202         esac
6203         fn=de~
6204         rp='Where will site-specific files be installed?'
6205         . ./getfile
6206         installsitelib="$ans"
6207 else
6208         installsitelib="$sitelibexp"
6209 fi
6210
6211 : determine where site specific architecture-dependent libraries go.
6212 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6213 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6214 : sitelib may have an optional trailing /share.
6215 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6216 tdflt="$tdflt/$archname"
6217 set sitearch sitearch none
6218 eval $prefixit
6219 case "$sitearch" in
6220 '')     dflt="$tdflt" ;;
6221 *)      dflt="$sitearch" ;;
6222 esac
6223 $cat <<EOM
6224
6225 The installation process will also create a directory for
6226 architecture-dependent site-specific extensions and modules.
6227
6228 EOM
6229 fn=nd~+
6230 rp='Pathname for the site-specific architecture-dependent library files?'
6231 . ./getfile
6232 if $test "X$sitearchexp" != "X$ansexp"; then
6233         installsitearch=''
6234 fi
6235 sitearch="$ans"
6236 sitearchexp="$ansexp"
6237 if $afs; then
6238         $cat <<EOM
6239
6240 Since you are running AFS, I need to distinguish the directory in
6241 which site-specific architecture-dependent library files reside from
6242 the directory in which they are installed (and from which they are
6243 presumably copied to the former directory by occult means).
6244
6245 EOM
6246         case "$installsitearch" in
6247         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6248         *) dflt="$installsitearch";;
6249         esac
6250         fn=de~
6251         rp='Where will site-specific architecture-dependent files be installed?'
6252         . ./getfile
6253         installsitearch="$ans"
6254 else
6255         installsitearch="$sitearchexp"
6256 fi
6257
6258 cat <<EOM
6259
6260 Previous version of $package used the standard IO mechanisms as defined
6261 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6262 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6263 the default.  This abstraction layer can use AT&T's sfio (if you already
6264 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6265 problems with some extension modules.  Using PerlIO with stdio is safe,
6266 but it is slower than plain stdio and therefore is not the default.
6267
6268 If this doesn't make any sense to you, just accept the default 'n'.
6269 EOM
6270 case "$useperlio" in
6271 $define|true|[yY]*)     dflt='y';;
6272 *) dflt='n';;
6273 esac
6274 rp='Use the experimental PerlIO abstraction layer?'
6275 . ./myread
6276 case "$ans" in
6277 y|Y) 
6278         val="$define"
6279         ;;     
6280 *)      
6281         echo "Ok, doing things the stdio way"
6282         val="$undef"
6283         ;;
6284 esac
6285 set useperlio
6286 eval $setvar 
6287
6288 : Check how to convert floats to strings.
6289 if test "X$d_Gconvert" = X; then
6290         echo " "
6291         echo "Checking for an efficient way to convert floats to strings."
6292         $cat >try.c <<'EOP'
6293 #ifdef TRY_gconvert
6294 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6295 char *myname = "gconvert";
6296 #endif
6297 #ifdef TRY_gcvt
6298 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6299 char *myname = "gcvt";
6300 #endif
6301 #ifdef TRY_sprintf
6302 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6303 char *myname = "sprintf";
6304 #endif
6305
6306 #include <stdio.h>
6307
6308 int
6309 checkit(expect, got)
6310 char *expect;
6311 char *got;
6312 {
6313     if (strcmp(expect, got)) {
6314                 printf("%s oddity:  Expected %s, got %s\n",
6315                         myname, expect, got);
6316                 exit(1);
6317         }
6318 }
6319
6320 int main()
6321
6322         char buf[64]; 
6323         buf[63] = '\0';
6324
6325         /* This must be 1st test on (which?) platform */
6326         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6327         Gconvert(0.1, 8, 0, buf);
6328         checkit("0.1", buf);
6329
6330         Gconvert(1.0, 8, 0, buf); 
6331         checkit("1", buf);
6332
6333         Gconvert(0.0, 8, 0, buf); 
6334         checkit("0", buf);
6335
6336         Gconvert(-1.0, 8, 0, buf); 
6337         checkit("-1", buf);
6338
6339         /* Some Linux gcvt's give 1.e+5 here. */
6340         Gconvert(100000.0, 8, 0, buf); 
6341         checkit("100000", buf);
6342         
6343         /* Some Linux gcvt's give -1.e+5 here. */
6344         Gconvert(-100000.0, 8, 0, buf); 
6345         checkit("-100000", buf);
6346
6347         exit(0);
6348 }
6349 EOP
6350         case "$d_Gconvert" in
6351         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6352         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6353         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6354         *) xxx_list='gconvert gcvt sprintf' ;;
6355         esac
6356
6357         for xxx_convert in $xxx_list; do
6358                 echo "Trying $xxx_convert"
6359                 $rm -f try try$_o
6360                 set try -DTRY_$xxx_convert
6361                 if eval $compile; then
6362                         echo "$xxx_convert" found. >&4
6363                         if ./try; then
6364                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6365                                 break;
6366                         else
6367                                 echo "...But $xxx_convert didn't work as I expected."
6368                         fi
6369                 else
6370                         echo "$xxx_convert NOT found." >&4
6371                 fi
6372         done
6373                 
6374         case "$xxx_convert" in
6375         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6376         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6377         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6378         esac
6379 fi
6380
6381 : Initialize h_fcntl
6382 h_fcntl=false
6383
6384 : Initialize h_sysfile
6385 h_sysfile=false
6386
6387 : access call always available on UNIX
6388 set access d_access
6389 eval $inlibc
6390
6391 : locate the flags for 'access()'
6392 case "$d_access" in
6393 "$define")
6394         echo " "
6395         $cat >access.c <<'EOCP'
6396 #include <sys/types.h>
6397 #ifdef I_FCNTL
6398 #include <fcntl.h>
6399 #endif
6400 #ifdef I_SYS_FILE
6401 #include <sys/file.h>
6402 #endif
6403 #ifdef I_UNISTD
6404 #include <unistd.h>
6405 #endif
6406 int main() {
6407         exit(R_OK);
6408 }
6409 EOCP
6410         : check sys/file.h first, no particular reason here
6411         if $test `./findhdr sys/file.h` && \
6412                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6413                 h_sysfile=true;
6414                 echo "<sys/file.h> defines the *_OK access constants." >&4
6415         elif $test `./findhdr fcntl.h` && \
6416                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6417                 h_fcntl=true;
6418                 echo "<fcntl.h> defines the *_OK access constants." >&4
6419         elif $test `./findhdr unistd.h` && \
6420                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6421                 echo "<unistd.h> defines the *_OK access constants." >&4
6422         else
6423                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6424         fi
6425         ;;
6426 esac
6427 $rm -f access*
6428
6429 : see if accessx exists
6430 set accessx d_accessx
6431 eval $inlibc
6432
6433 : see if alarm exists
6434 set alarm d_alarm
6435 eval $inlibc
6436
6437 : Look for GNU-cc style attribute checking
6438 echo " "
6439 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6440 $cat >attrib.c <<'EOCP'
6441 #include <stdio.h>
6442 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6443 EOCP
6444 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6445         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6446                 echo "Your C compiler doesn't fully support __attribute__."
6447                 val="$undef"
6448         else
6449                 echo "Your C compiler supports __attribute__."
6450                 val="$define"
6451         fi
6452 else
6453         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6454         val="$undef"
6455 fi
6456 set d_attribut
6457 eval $setvar
6458 $rm -f attrib*
6459
6460 : see if bcmp exists
6461 set bcmp d_bcmp
6462 eval $inlibc
6463
6464 : see if bcopy exists
6465 set bcopy d_bcopy
6466 eval $inlibc
6467
6468 : see if this is a unistd.h system
6469 set unistd.h i_unistd
6470 eval $inhdr
6471
6472 : see if getpgrp exists
6473 set getpgrp d_getpgrp
6474 eval $inlibc
6475
6476 case "$d_getpgrp" in
6477 "$define")
6478         echo " "
6479         echo "Checking to see which flavor of getpgrp is in use..."
6480         $cat >set.c <<EOP
6481 #$i_unistd I_UNISTD
6482 #include <sys/types.h>
6483 #ifdef I_UNISTD
6484 #  include <unistd.h>
6485 #endif
6486 int main()
6487 {
6488         if (getuid() == 0) {
6489                 printf("(I see you are running Configure as super-user...)\n");
6490                 setuid(1);
6491         }
6492 #ifdef TRY_BSD_PGRP
6493         if (getpgrp(1) == 0)
6494                 exit(0);
6495 #else
6496         if (getpgrp() > 0)
6497                 exit(0);
6498 #endif
6499         exit(1);
6500 }
6501 EOP
6502         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6503                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6504                 val="$define"
6505         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6506                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6507                 val="$undef"
6508         else
6509                 echo "I can't seem to compile and run the test program."
6510                 if ./usg; then
6511                         xxx="a USG one, i.e. you use getpgrp()."
6512                 else
6513                         # SVR4 systems can appear rather BSD-ish.
6514                         case "$i_unistd" in
6515                         $undef)
6516                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6517                                 val="$define"
6518                                 ;;
6519                         $define)
6520                                 xxx="probably a USG one, i.e. you use getpgrp()."
6521                                 val="$undef"
6522                                 ;;
6523                         esac
6524                 fi
6525                 echo "Assuming your getpgrp is $xxx" >&4
6526         fi
6527         ;;
6528 *) val="$undef";;
6529 esac
6530 set d_bsdgetpgrp
6531 eval $setvar
6532 $rm -f set set.c
6533
6534 : see if setpgrp exists
6535 set setpgrp d_setpgrp
6536 eval $inlibc
6537
6538 case "$d_setpgrp" in
6539 "$define")
6540         echo " "
6541         echo "Checking to see which flavor of setpgrp is in use..."
6542         $cat >set.c <<EOP
6543 #$i_unistd I_UNISTD
6544 #include <sys/types.h>
6545 #ifdef I_UNISTD
6546 #  include <unistd.h>
6547 #endif
6548 int main()
6549 {
6550         if (getuid() == 0) {
6551                 printf("(I see you are running Configure as super-user...)\n");
6552                 setuid(1);
6553         }
6554 #ifdef TRY_BSD_PGRP
6555         if (-1 == setpgrp(1, 1))
6556                 exit(0);
6557 #else
6558         if (setpgrp() != -1)
6559                 exit(0);
6560 #endif
6561         exit(1);
6562 }
6563 EOP
6564         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6565                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6566                 val="$define"
6567         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6568                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6569                 val="$undef"
6570         else
6571                 echo "(I can't seem to compile and run the test program.)"
6572                 if ./usg; then
6573                         xxx="a USG one, i.e. you use setpgrp()."
6574                 else
6575                         # SVR4 systems can appear rather BSD-ish.
6576                         case "$i_unistd" in
6577                         $undef)
6578                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6579                                 val="$define"
6580                                 ;;
6581                         $define)
6582                                 xxx="probably a USG one, i.e. you use setpgrp()."
6583                                 val="$undef"
6584                                 ;;
6585                         esac
6586                 fi
6587                 echo "Assuming your setpgrp is $xxx" >&4
6588         fi
6589         ;;
6590 *) val="$undef";;
6591 esac
6592 set d_bsdsetpgrp
6593 eval $setvar
6594 $rm -f set set.c
6595 : see if bzero exists
6596 set bzero d_bzero
6597 eval $inlibc
6598
6599 : check for lengths of integral types
6600 echo " "
6601 case "$intsize" in
6602 '')
6603         echo "Checking to see how big your integers are..." >&4
6604         $cat >intsize.c <<'EOCP'
6605 #include <stdio.h>
6606 int main()
6607 {
6608         printf("intsize=%d;\n", sizeof(int));
6609         printf("longsize=%d;\n", sizeof(long));
6610         printf("shortsize=%d;\n", sizeof(short));
6611         exit(0);
6612 }
6613 EOCP
6614         set intsize
6615         if eval $compile_ok && ./intsize > /dev/null; then
6616                 eval `./intsize`
6617                 echo "Your integers are $intsize bytes long."
6618                 echo "Your long integers are $longsize bytes long."
6619                 echo "Your short integers are $shortsize bytes long."
6620         else
6621                 $cat >&4 <<EOM
6622 !
6623 Help! I can't compile and run the intsize test program: please enlighten me!
6624 (This is probably a misconfiguration in your system or libraries, and
6625 you really ought to fix it.  Still, I'll try anyway.)
6626 !
6627 EOM
6628                 dflt=4
6629                 rp="What is the size of an integer (in bytes)?"
6630                 . ./myread
6631                 intsize="$ans"
6632                 dflt=$intsize
6633                 rp="What is the size of a long integer (in bytes)?"
6634                 . ./myread
6635                 longsize="$ans"
6636                 dflt=2
6637                 rp="What is the size of a short integer (in bytes)?"
6638                 . ./myread
6639                 shortsize="$ans"
6640         fi
6641         ;;
6642 esac
6643 $rm -f intsize intsize.*
6644
6645 : see if signal is declared as pointer to function returning int or void
6646 echo " "
6647 xxx=`./findhdr signal.h`
6648 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6649 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6650         echo "You have int (*signal())() instead of void." >&4
6651         val="$undef"
6652 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6653         echo "You have void (*signal())()." >&4
6654         val="$define"
6655 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6656         echo "You have int (*signal())() instead of void." >&4
6657         val="$undef"
6658 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6659         echo "You have void (*signal())()." >&4
6660         val="$define"
6661 else
6662         case "$d_voidsig" in
6663         '')
6664         echo "I can't determine whether signal handler returns void or int..." >&4
6665                 dflt=void
6666                 rp="What type does your signal handler return?"
6667                 . ./myread
6668                 case "$ans" in
6669                 v*) val="$define";;
6670                 *) val="$undef";;
6671                 esac;;
6672         "$define")
6673                 echo "As you already told me, signal handler returns void." >&4
6674                 val="$define"
6675                 ;;
6676         *)      echo "As you already told me, signal handler returns int." >&4
6677                 val="$undef"
6678                 ;;
6679         esac
6680 fi
6681 set d_voidsig
6682 eval $setvar
6683 case "$d_voidsig" in
6684 "$define") signal_t="void";;
6685 *) signal_t="int";;
6686 esac
6687 $rm -f $$.tmp
6688
6689 : check for ability to cast large floats to 32-bit ints.
6690 echo " "
6691 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6692 if $test "$intsize" -ge 4; then
6693         xxx=int
6694 else
6695         xxx=long
6696 fi
6697 $cat >try.c <<EOCP
6698 #include <stdio.h>
6699 #include <sys/types.h>
6700 #include <signal.h>
6701 $signal_t blech(s) int s; { exit(3); }
6702 int main()
6703 {
6704         $xxx i32;
6705         double f, g;
6706         int result = 0;
6707         char str[16];
6708         signal(SIGFPE, blech);
6709
6710         /* Don't let compiler optimize the test away.  Store the number 
6711            in a writable string for gcc to pass to sscanf under HP/UX.
6712         */
6713         sprintf(str, "2147483647");
6714         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6715         g = 10 * f;
6716         i32  = ($xxx) g;
6717
6718         /* x86 processors will probably give 0x8000 0000, which is a
6719        sign change.  We don't want that.  We want to mimic SPARC
6720            behavior here, which is to preserve the sign and give
6721            back 0x7fff ffff.
6722         */
6723         if (i32 != ($xxx) f)
6724                 result |= 1;
6725         exit(result);
6726 }
6727 EOCP
6728 set try
6729 if eval $compile_ok; then
6730         ./try
6731         yyy=$?
6732 else
6733         echo "(I can't seem to compile the test program--assuming it can't)"
6734         yyy=1
6735 fi
6736 case "$yyy" in
6737 0)      val="$define"
6738         echo "Yup, it can."
6739         ;;
6740 *)      val="$undef"
6741         echo "Nope, it can't."
6742         ;;
6743 esac
6744 set d_casti32
6745 eval $setvar
6746 $rm -f try try.*
6747
6748 : check for ability to cast negative floats to unsigned
6749 echo " "
6750 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6751 $cat >try.c <<EOCP
6752 #include <stdio.h>
6753 #include <sys/types.h>
6754 #include <signal.h>
6755 $signal_t blech(s) int s; { exit(7); }
6756 $signal_t blech_in_list(s) int s; { exit(4); }
6757 unsigned long dummy_long(p) unsigned long p; { return p; }
6758 unsigned int dummy_int(p) unsigned int p; { return p; }
6759 unsigned short dummy_short(p) unsigned short p; { return p; }
6760 int main()
6761 {
6762         double f;
6763         unsigned long along;
6764         unsigned int aint;
6765         unsigned short ashort;
6766         int result = 0;
6767         char str[16];
6768         
6769         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6770            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6771            optimized the whole file away
6772         */
6773         /* Store the number in a writable string for gcc to pass to 
6774            sscanf under HP/UX.
6775         */
6776         sprintf(str, "-123");
6777         sscanf(str, "%lf", &f);  /* f = -123.; */
6778
6779         signal(SIGFPE, blech);
6780         along = (unsigned long)f;
6781         aint = (unsigned int)f;
6782         ashort = (unsigned short)f;
6783         if (along != (unsigned long)-123)
6784                 result |= 1;
6785         if (aint != (unsigned int)-123)
6786                 result |= 1;
6787         if (ashort != (unsigned short)-123)
6788                 result |= 1;
6789         sprintf(str, "1073741824.");
6790         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6791         f = f + f;
6792         along = 0;
6793         along = (unsigned long)f;
6794         if (along != 0x80000000)
6795                 result |= 2;
6796         f -= 1.;
6797         along = 0;
6798         along = (unsigned long)f;
6799         if (along != 0x7fffffff)
6800                 result |= 1;
6801         f += 2.;
6802         along = 0;
6803         along = (unsigned long)f;
6804         if (along != 0x80000001)
6805                 result |= 2;
6806         if (result)
6807                 exit(result);
6808         signal(SIGFPE, blech_in_list);
6809         sprintf(str, "123.");
6810         sscanf(str, "%lf", &f);  /* f = 123.; */
6811         along = dummy_long((unsigned long)f);
6812         aint = dummy_int((unsigned int)f);
6813         ashort = dummy_short((unsigned short)f);
6814         if (along != (unsigned long)123)
6815                 result |= 4;
6816         if (aint != (unsigned int)123)
6817                 result |= 4;
6818         if (ashort != (unsigned short)123)
6819                 result |= 4;
6820         exit(result);
6821
6822 }
6823 EOCP
6824 set try
6825 if eval $compile_ok; then
6826         ./try
6827         castflags=$?
6828 else
6829         echo "(I can't seem to compile the test program--assuming it can't)"
6830         castflags=7
6831 fi
6832 case "$castflags" in
6833 0)      val="$define"
6834         echo "Yup, it can."
6835         ;;
6836 *)      val="$undef"
6837         echo "Nope, it can't."
6838         ;;
6839 esac
6840 set d_castneg
6841 eval $setvar
6842 $rm -f try.*
6843
6844 : see if vprintf exists
6845 echo " "
6846 if set vprintf val -f d_vprintf; eval $csym; $val; then
6847         echo 'vprintf() found.' >&4
6848         val="$define"
6849         $cat >vprintf.c <<'EOF'
6850 #include <varargs.h>
6851
6852 int main() { xxx("foo"); }
6853
6854 xxx(va_alist)
6855 va_dcl
6856 {
6857         va_list args;
6858         char buf[10];
6859
6860         va_start(args);
6861         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6862 }
6863 EOF
6864         set vprintf
6865         if eval $compile && ./vprintf; then
6866                 echo "Your vsprintf() returns (int)." >&4
6867                 val2="$undef"
6868         else
6869                 echo "Your vsprintf() returns (char*)." >&4
6870                 val2="$define"
6871         fi
6872 else
6873         echo 'vprintf() NOT found.' >&4
6874                 val="$undef"
6875                 val2="$undef"
6876 fi
6877 set d_vprintf
6878 eval $setvar
6879 val=$val2
6880 set d_charvspr
6881 eval $setvar
6882
6883 : see if chown exists
6884 set chown d_chown
6885 eval $inlibc
6886
6887 : see if chroot exists
6888 set chroot d_chroot
6889 eval $inlibc
6890
6891 : see if chsize exists
6892 set chsize d_chsize
6893 eval $inlibc
6894
6895 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6896 while $test $# -ge 2; do
6897         case "$1" in
6898         $define) echo "#include <$2>";;
6899         esac ;
6900     shift 2;
6901 done > try.c;
6902 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6903 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6904         val="$define";
6905 else
6906         val="$undef";
6907 fi;
6908 set $varname;
6909 eval $setvar;
6910 $rm -f try.c try.o'
6911
6912 : see if this is a sys/uio.h system
6913 set sys/uio.h i_sysuio
6914 eval $inhdr
6915
6916 echo "Checking to see if your system supports struct iovec..." >&4
6917 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6918 eval $hasfield
6919 case "$d_iovec_s" in
6920 "$define")      echo "Yup, it does." >&4
6921                 ;;
6922 *)              echo "Nope, it doesn't." >&4
6923                 ;;
6924 esac
6925
6926 socketlib=''
6927 sockethdr=''
6928 : see whether socket exists
6929 echo " "
6930 $echo $n "Hmm... $c" >&4
6931 if set socket val -f d_socket; eval $csym; $val; then
6932         echo "Looks like you have Berkeley networking support." >&4
6933         d_socket="$define"
6934         if set setsockopt val -f; eval $csym; $val; then
6935                 d_oldsock="$undef"
6936         else
6937                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6938                 d_oldsock="$define"
6939         fi
6940 else
6941         if $contains socklib libc.list >/dev/null 2>&1; then
6942                 echo "Looks like you have Berkeley networking support." >&4
6943                 d_socket="$define"
6944                 : we will have to assume that it supports the 4.2 BSD interface
6945                 d_oldsock="$undef"
6946         else
6947                 echo "You don't have Berkeley networking in libc$_a..." >&4
6948                 if test "X$d_socket" = "X$define"; then
6949                    echo "...but you seem to believe that you have sockets." >&4
6950                 else
6951                         for net in net socket
6952                         do
6953                                 if test -f /usr/lib/lib$net$_a; then
6954                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6955                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6956                                         if $contains socket libc.list >/dev/null 2>&1; then
6957                                                 d_socket="$define"
6958                                                 socketlib="-l$net"
6959                                                 case "$net" in
6960                                                 net)
6961                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6962                                                         sockethdr="-I/usr/netinclude"
6963                                                         ;;
6964                                                 esac
6965                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6966                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6967                                                         d_oldsock="$undef"
6968                                                 else
6969                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6970                                                         d_oldsock="$define"
6971                                                 fi
6972                                                 break
6973                                         fi
6974                                 fi
6975                         done
6976                         if test "X$d_socket" != "X$define"; then
6977                            echo "or anywhere else I see." >&4
6978                            d_socket="$undef"
6979                            d_oldsock="$undef"
6980                         fi
6981                 fi
6982         fi
6983 fi
6984
6985 : see if socketpair exists
6986 set socketpair d_sockpair
6987 eval $inlibc
6988
6989
6990 echo " "
6991 echo "Checking the availability of certain socket constants..." >& 4
6992 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
6993         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
6994         $cat >try.c <<EOF
6995 #include <sys/types.h>
6996 #include <sys/socket.h>
6997 int main() {
6998     int i = $ENUM;
6999 }
7000 EOF
7001         val="$undef"
7002         set try; if eval $compile; then
7003                 val="$define"
7004         fi
7005         set d_${enum}; eval $setvar
7006         $rm -f try.c try
7007 done
7008
7009 set sendmsg d_sendmsg
7010 eval $inlibc
7011
7012 set recvmsg d_recvmsg
7013 eval $inlibc
7014
7015 echo " "
7016 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
7017 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7018 eval $hasfield
7019 case "$d_msghdr_s" in
7020 "$define")      echo "Yup, it does." >&4
7021                 ;;
7022 *)              echo "Nope, it doesn't." >&4
7023                 ;;
7024 esac
7025
7026 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7027 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7028 eval $hasfield
7029 case "$d_cmsghdr_s" in
7030 "$define")      echo "Yup, it does." >&4
7031                 ;;
7032 *)              echo "Nope, it doesn't." >&4
7033                 ;;
7034 esac
7035
7036 : check for const keyword
7037 echo " "
7038 echo 'Checking to see if your C compiler knows about "const"...' >&4
7039 $cat >const.c <<'EOCP'
7040 typedef struct spug { int drokk; } spug;
7041 int main()
7042 {
7043         const char *foo;
7044         const spug y;
7045 }
7046 EOCP
7047 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7048         val="$define"
7049         echo "Yup, it does."
7050 else
7051         val="$undef"
7052         echo "Nope, it doesn't."
7053 fi
7054 set d_const
7055 eval $setvar
7056
7057 : see if crypt exists
7058 echo " "
7059 if set crypt val -f d_crypt; eval $csym; $val; then
7060         echo 'crypt() found.' >&4
7061         val="$define"
7062         cryptlib=''
7063 else
7064         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7065         if $test -z "$cryptlib"; then
7066                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7067         else
7068                 cryptlib=-lcrypt
7069         fi
7070         if $test -z "$cryptlib"; then
7071                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7072         else
7073                 cryptlib=-lcrypt
7074         fi
7075         if $test -z "$cryptlib"; then
7076                 cryptlib=`./loc libcrypt$_a "" $libpth`
7077         else
7078                 cryptlib=-lcrypt
7079         fi
7080         if $test -z "$cryptlib"; then
7081                 echo 'crypt() NOT found.' >&4
7082                 val="$undef"
7083         else
7084                 val="$define"
7085         fi
7086 fi
7087 set d_crypt
7088 eval $setvar
7089
7090 : get csh whereabouts
7091 case "$csh" in
7092 'csh') val="$undef" ;;
7093 *) val="$define" ;;
7094 esac
7095 set d_csh
7096 eval $setvar
7097 : Respect a hint or command line value for full_csh.
7098 case "$full_csh" in
7099 '') full_csh=$csh ;;
7100 esac
7101
7102 : see if cuserid exists
7103 set cuserid d_cuserid
7104 eval $inlibc
7105
7106 : see if this is a limits.h system
7107 set limits.h i_limits
7108 eval $inhdr
7109
7110 : see if this is a float.h system
7111 set float.h i_float
7112 eval $inhdr
7113
7114 : See if number of significant digits in a double precision number is known
7115 echo " "
7116 $cat >dbl_dig.c <<EOM
7117 #$i_limits I_LIMITS
7118 #$i_float I_FLOAT
7119 #ifdef I_LIMITS
7120 #include <limits.h>
7121 #endif
7122 #ifdef I_FLOAT
7123 #include <float.h>
7124 #endif
7125 #ifdef DBL_DIG
7126 printf("Contains DBL_DIG");
7127 #endif
7128 EOM
7129 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7130 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7131         echo "DBL_DIG found." >&4
7132         val="$define"
7133 else
7134         echo "DBL_DIG NOT found." >&4
7135         val="$undef"
7136 fi
7137 $rm -f dbl_dig.?
7138 set d_dbl_dig
7139 eval $setvar
7140
7141
7142 if $test X"$use64bits" = X"$define"; then
7143         : see if dbminit64 exists
7144         set dbminit64 d_dbminit64
7145         eval $inlibc
7146
7147         : see if dbmclose64 exists
7148         set dbmclose64 d_dbmclose64
7149         eval $inlibc
7150
7151         : see if fetch64 exists
7152         set fetch64 d_fetch64
7153         eval $inlibc
7154
7155         : see if store64 exists
7156         set store64 d_store64
7157         eval $inlibc
7158
7159         : see if delete64 exists
7160         set delete64 d_delete64
7161         eval $inlibc
7162
7163         : see if firstkey64 exists
7164         set firstkey64 d_firstkey64
7165         eval $inlibc
7166
7167         : see if nextkey64 exists
7168         set nextkey64 d_nextkey64
7169         eval $inlibc
7170 else
7171         val="$undef"
7172         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7173         do
7174                 set $xxx
7175                 eval $setvar
7176         done
7177 fi
7178
7179 : see if difftime exists
7180 set difftime d_difftime
7181 eval $inlibc
7182
7183 : see if sys/stat.h is available
7184 set sys/stat.h i_sysstat
7185 eval $inhdr
7186
7187 : see if this is a dirent system
7188 echo " "
7189 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7190         val="$define"
7191         echo "<dirent.h> found." >&4
7192 else
7193         val="$undef"
7194         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7195                 echo "<sys/dir.h> found." >&4
7196                 echo " "
7197         else
7198                 xinc=`./findhdr sys/ndir.h`
7199         fi
7200         echo "<dirent.h> NOT found." >&4
7201 fi
7202 set i_dirent
7203 eval $setvar
7204
7205 : Look for type of directory structure.
7206 echo " "
7207 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7208
7209 case "$direntrytype" in
7210 ''|' ')
7211         case "$i_dirent" in
7212         $define) guess1='struct dirent' ;;
7213         *) guess1='struct direct'  ;;
7214         esac
7215         ;;
7216 *)      guess1="$direntrytype"
7217         ;;
7218 esac
7219
7220 case "$guess1" in
7221 'struct dirent') guess2='struct direct' ;;
7222 *) guess2='struct dirent' ;;
7223 esac
7224                 
7225 if $contains "$guess1" try.c >/dev/null 2>&1; then
7226         direntrytype="$guess1"
7227         echo "Your directory entries are $direntrytype." >&4
7228 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7229         direntrytype="$guess2"
7230         echo "Your directory entries seem to be $direntrytype." >&4
7231 else
7232         echo "I don't recognize your system's directory entries." >&4
7233         rp="What type is used for directory entries on this system?"
7234         dflt="$guess1"
7235         . ./myread
7236         direntrytype="$ans"
7237 fi
7238 $rm -f try.c
7239
7240
7241 : see if the directory entry stores field length
7242 echo " "
7243 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7244 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7245         echo "Good, your directory entry keeps length information in d_namlen." >&4
7246         val="$define"
7247 else
7248         echo "Your directory entry does not know about the d_namlen field." >&4
7249         val="$undef"
7250 fi
7251 set d_dirnamlen
7252 eval $setvar
7253 $rm -f try.c
7254
7255
7256 if $test X"$use64bits" = X"$define"; then
7257         : see if fstat64 exists
7258         set fstat64 d_fstat64
7259         eval $inlibc
7260
7261         : see if ftruncate64 exists
7262         set ftruncate64 d_ftruncate64
7263         eval $inlibc
7264
7265         : see if lockf64 exists
7266         set lockf64 d_lockf64
7267         eval $inlibc
7268
7269         : see if llseek exists
7270         set llseek d_llseek
7271         eval $inlibc
7272
7273         : see if lseek64 exists
7274         set lseek64 d_lseek64
7275         eval $inlibc
7276
7277         : see if lstat64 exists
7278         set lstat64 d_lstat64
7279         eval $inlibc
7280
7281         : see if open64 exists
7282         set open64 d_open64
7283         eval $inlibc
7284
7285         : see if opendir64 exists
7286         set opendir64 d_opendir64
7287         eval $inlibc
7288
7289         : see if readdir64 exists
7290         set readdir64 d_readdir64
7291         eval $inlibc
7292
7293         : see if seekdir64 exists
7294         set seekdir64 d_seekdir64
7295         eval $inlibc
7296
7297         : see if stat64 exists
7298         set stat64 d_stat64
7299         eval $inlibc
7300
7301         : see if telldir64 exists
7302         set telldir64 d_telldir64
7303         eval $inlibc
7304
7305         : see if truncate64 exists
7306         set truncate64 d_truncate64
7307         eval $inlibc
7308
7309         : check for off64_t
7310         echo " "
7311         echo $n "Checking to see if your system supports off64_t...$c" >&4
7312         $cat >try.c <<EOCP
7313 #include <sys/types.h>
7314 #include <unistd.h>
7315 off64_t foo() { off64_t x; x = 7; return x; }'
7316 EOCP
7317         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7318                 val="$define"
7319                 echo " Yup, it does." >&4
7320         else
7321                 val="$undef"
7322                 echo " Nope, it doesn't." >&4
7323         fi
7324         $rm -f try.*
7325         set d_off64_t
7326         eval $setvar
7327
7328         : check for offset_t
7329         echo " "
7330         echo $n "Checking to see if your system supports offset_t...$c" >&4
7331         $cat >try.c <<EOCP
7332 #include <sys/types.h>
7333 #include <unistd.h>
7334 offset_t foo() { offset_t x; x = 7; return x; }'
7335 EOCP
7336         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7337                 val="$define"
7338                 echo " Yup, it does." >&4
7339         else
7340                 val="$undef"
7341                 echo " Nope, it doesn't." >&4
7342         fi
7343         $rm -f try.*
7344         set d_offset_t
7345         eval $setvar
7346
7347         : check for ino64_t
7348         echo " "
7349         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7350         val="$undef"
7351         case "$i_sysstat" in
7352         "$define" )
7353                 $cat >try.c <<EOCP
7354 #include <sys/types.h>
7355 #include <sys/stat.h>
7356 ino64_t foo() { ino64_t x; x = 7; return x; }'
7357 EOCP
7358                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7359                         val="$define"
7360                 fi
7361                 $rm -f try.*
7362                 ;;
7363         esac
7364         if $test "X$val" = X"$define"; then
7365                 echo " Yup, it does." >&4
7366         else
7367                 echo " Nope, it doesn't." >&4
7368         fi
7369         set d_ino64_t
7370         eval $setvar
7371
7372         : check for struct flock64
7373         echo " "
7374         echo "Checking to see if your system supports struct flock64..." >&4
7375         if $h_fcntl; then
7376                 set d_flock64_s flock64 l_len define fcntl.h
7377                 eval $hasfield
7378         else
7379                 val="$undef"
7380                 set d_flock64_s
7381                 eval $setvar
7382         fi
7383         case "$d_flock64_s" in
7384         "$define")      echo "Yup, it does." >&4
7385                         ;;
7386         *)              echo "Nope, it doesn't." >&4
7387                         ;;
7388         esac
7389
7390         : check for struct dirent64
7391         echo " "
7392         echo "Checking to see if your system supports struct dirent64..." >&4
7393         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7394         eval $hasfield
7395         case "$d_dirent64_s" in
7396         "$define")      echo "Yup, it does." >&4
7397                         ;;
7398         *)              echo "Nope, it doesn't." >&4
7399                         ;;
7400         esac
7401
7402 else
7403         val="$undef"
7404         for xxx in d_fstat64 d_ftruncate64 d_lockf64 d_lseek64 d_lstat64 d_open64 d_opendir64 d_readdir64 d_seekdir64 d_stat64 d_telldir64 d_truncate64 d_off64_t d_offset_t d_ino64_t d_flock64_s d_dirent64_s
7405         do
7406                 set $xxx
7407                 eval $setvar
7408         done
7409 fi
7410
7411 : see if dlerror exists
7412 xxx_runnm="$runnm"
7413 runnm=false
7414 set dlerror d_dlerror
7415 eval $inlibc
7416 runnm="$xxx_runnm"
7417
7418 : see if dlfcn is available
7419 set dlfcn.h i_dlfcn
7420 eval $inhdr
7421
7422 case "$usedl" in
7423 $define|y|true)
7424         $cat << EOM
7425
7426 On a few systems, the dynamically loaded modules that perl generates and uses
7427 will need a different extension than shared libs. The default will probably
7428 be appropriate.
7429
7430 EOM
7431         case "$dlext" in
7432         '')     dflt="$so" ;;
7433         *)      dflt="$dlext" ;;
7434         esac
7435         rp='What is the extension of dynamically loaded modules'
7436         . ./myread
7437         dlext="$ans"
7438         ;;
7439 *)
7440         dlext="none"
7441         ;;
7442 esac
7443
7444 : Check if dlsym need a leading underscore
7445 echo " "
7446 val="$undef"
7447
7448 case "$dlsrc" in
7449 dl_dlopen.xs)
7450         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7451         $cat >dyna.c <<'EOM'
7452 fred () { }
7453 EOM
7454
7455 $cat >fred.c<<EOM
7456
7457 #include <stdio.h>
7458 #$i_dlfcn I_DLFCN
7459 #ifdef I_DLFCN
7460 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7461 #else
7462 #include <sys/types.h>
7463 #include <nlist.h>
7464 #include <link.h>
7465 #endif
7466
7467 extern int fred() ;
7468
7469 int main()
7470 {
7471     void * handle ;
7472     void * symbol ;
7473 #ifndef RTLD_LAZY
7474     int mode = 1 ;
7475 #else
7476     int mode = RTLD_LAZY ;
7477 #endif
7478     handle = dlopen("./dyna.$dlext", mode) ;
7479     if (handle == NULL) {
7480         printf ("1\n") ;
7481         fflush (stdout) ;
7482         exit(0);
7483     }
7484     symbol = dlsym(handle, "fred") ;
7485     if (symbol == NULL) {
7486         /* try putting a leading underscore */
7487         symbol = dlsym(handle, "_fred") ;
7488         if (symbol == NULL) {
7489             printf ("2\n") ;
7490             fflush (stdout) ;
7491             exit(0);
7492         }
7493         printf ("3\n") ;
7494     }
7495     else
7496         printf ("4\n") ;
7497     fflush (stdout) ;
7498     exit(0);
7499 }
7500 EOM
7501         : Call the object file tmp-dyna.o in case dlext=o.
7502         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7503                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7504                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7505                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7506                 xxx=`./fred`
7507                 case $xxx in
7508                 1)      echo "Test program failed using dlopen." >&4
7509                         echo "Perhaps you should not use dynamic loading." >&4;;
7510                 2)      echo "Test program failed using dlsym." >&4
7511                         echo "Perhaps you should not use dynamic loading." >&4;;
7512                 3)      echo "dlsym needs a leading underscore" >&4
7513                         val="$define" ;;
7514                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7515                 esac
7516         else
7517                 echo "I can't compile and run the test program." >&4
7518         fi
7519         ;;
7520 esac
7521                 
7522 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7523
7524 set d_dlsymun
7525 eval $setvar
7526
7527 hasproto='varname=$1; func=$2; shift; shift;
7528 while $test $# -ge 2; do
7529         case "$1" in
7530         $define) echo "#include <$2>";;
7531         esac ;
7532     shift 2;
7533 done > try.c;
7534 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7535 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7536         echo "$func() prototype found.";
7537         val="$define";
7538 else
7539         echo "$func() prototype NOT found.";
7540         val="$undef";
7541 fi;
7542 set $varname;
7543 eval $setvar;
7544 $rm -f try.c tryout.c'
7545
7546 : see if prototype for drand48 is available
7547 echo " "
7548 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7549 eval $hasproto
7550
7551 : see if dup2 exists
7552 set dup2 d_dup2
7553 eval $inlibc
7554
7555 : see if eaccess exists
7556 set eaccess d_eaccess
7557 eval $inlibc
7558
7559 : see if endgrent exists
7560 set endgrent d_endgrent
7561 eval $inlibc
7562
7563 : see if endhostent exists
7564 set endhostent d_endhent
7565 eval $inlibc
7566
7567 : see if endnetent exists
7568 set endnetent d_endnent
7569 eval $inlibc
7570
7571 : see if endprotoent exists
7572 set endprotoent d_endpent
7573 eval $inlibc
7574
7575 : see if endpwent exists
7576 set endpwent d_endpwent
7577 eval $inlibc
7578
7579 : see if endservent exists
7580 set endservent d_endsent
7581 eval $inlibc
7582
7583 : see if endspent exists
7584 set endspent d_endspent
7585 eval $inlibc
7586
7587 : Locate the flags for 'open()'
7588 echo " "
7589 $cat >open3.c <<'EOCP'
7590 #include <sys/types.h>
7591 #ifdef I_FCNTL
7592 #include <fcntl.h>
7593 #endif
7594 #ifdef I_SYS_FILE
7595 #include <sys/file.h>
7596 #endif
7597 int main() {
7598         if(O_RDONLY);
7599 #ifdef O_TRUNC
7600         exit(0);
7601 #else
7602         exit(1);
7603 #endif
7604 }
7605 EOCP
7606 : check sys/file.h first to get FREAD on Sun
7607 if $test `./findhdr sys/file.h` && \
7608                 set open3 -DI_SYS_FILE && eval $compile; then
7609         h_sysfile=true;
7610         echo "<sys/file.h> defines the O_* constants..." >&4
7611         if ./open3; then
7612                 echo "and you have the 3 argument form of open()." >&4
7613                 val="$define"
7614         else
7615                 echo "but not the 3 argument form of open().  Oh, well." >&4
7616                 val="$undef"
7617         fi
7618 elif $test `./findhdr fcntl.h` && \
7619                 set open3 -DI_FCNTL && eval $compile; then
7620         h_fcntl=true;
7621         echo "<fcntl.h> defines the O_* constants..." >&4
7622         if ./open3; then
7623                 echo "and you have the 3 argument form of open()." >&4
7624                 val="$define"
7625         else
7626                 echo "but not the 3 argument form of open().  Oh, well." >&4
7627                 val="$undef"
7628         fi
7629 else
7630         val="$undef"
7631         echo "I can't find the O_* constant definitions!  You got problems." >&4
7632 fi
7633 set d_open3
7634 eval $setvar
7635 $rm -f open3*
7636
7637 : check for non-blocking I/O stuff
7638 case "$h_sysfile" in
7639 true) echo "#include <sys/file.h>" > head.c;;
7640 *)
7641         case "$h_fcntl" in
7642         true) echo "#include <fcntl.h>" > head.c;;
7643         *) echo "#include <sys/fcntl.h>" > head.c;;
7644         esac
7645         ;;
7646 esac
7647 echo " "
7648 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7649 case "$o_nonblock" in
7650 '')
7651         $cat head.c > try.c
7652         $cat >>try.c <<'EOCP'
7653 int main() {
7654 #ifdef O_NONBLOCK
7655         printf("O_NONBLOCK\n");
7656         exit(0);
7657 #endif
7658 #ifdef O_NDELAY
7659         printf("O_NDELAY\n");
7660         exit(0);
7661 #endif
7662 #ifdef FNDELAY
7663         printf("FNDELAY\n");
7664         exit(0);
7665 #endif
7666         exit(0);
7667 }
7668 EOCP
7669         set try
7670         if eval $compile_ok; then
7671                 o_nonblock=`./try`
7672                 case "$o_nonblock" in
7673                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7674                 *) echo "Seems like we can use $o_nonblock.";;
7675                 esac
7676         else
7677                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7678         fi
7679         ;;
7680 *) echo "Using $hint value $o_nonblock.";;
7681 esac
7682 $rm -f try try.* .out core
7683
7684 echo " "
7685 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7686 case "$eagain" in
7687 '')
7688         $cat head.c > try.c
7689         $cat >>try.c <<EOCP
7690 #include <errno.h>
7691 #include <sys/types.h>
7692 #include <signal.h>
7693 #define MY_O_NONBLOCK $o_nonblock
7694 #ifndef errno  /* XXX need better Configure test */
7695 extern int errno;
7696 #endif
7697 $signal_t blech(x) int x; { exit(3); }
7698 EOCP
7699         $cat >> try.c <<'EOCP'
7700 int main()
7701 {
7702         int pd[2];
7703         int pu[2];
7704         char buf[1];
7705         char string[100];
7706
7707         pipe(pd);       /* Down: child -> parent */
7708         pipe(pu);       /* Up: parent -> child */
7709         if (0 != fork()) {
7710                 int ret;
7711                 close(pd[1]);   /* Parent reads from pd[0] */
7712                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7713                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7714                         exit(1);
7715                 signal(SIGALRM, blech);
7716                 alarm(5);
7717                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7718                         exit(2);
7719                 sprintf(string, "%d\n", ret);
7720                 write(2, string, strlen(string));
7721                 alarm(0);
7722 #ifdef EAGAIN
7723                 if (errno == EAGAIN) {
7724                         printf("EAGAIN\n");
7725                         goto ok;
7726                 }
7727 #endif
7728 #ifdef EWOULDBLOCK
7729                 if (errno == EWOULDBLOCK)
7730                         printf("EWOULDBLOCK\n");
7731 #endif
7732         ok:
7733                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7734                 sleep(2);                               /* Give it time to close our pipe */
7735                 alarm(5);
7736                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7737                 alarm(0);
7738                 sprintf(string, "%d\n", ret);
7739                 write(3, string, strlen(string));
7740                 exit(0);
7741         }
7742
7743         close(pd[0]);                   /* We write to pd[1] */
7744         close(pu[1]);                   /* We read from pu[0] */
7745         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7746         close(pd[1]);                   /* Pipe pd is now fully closed! */
7747         exit(0);                                /* Bye bye, thank you for playing! */
7748 }
7749 EOCP
7750         set try
7751         if eval $compile_ok; then
7752                 echo "$startsh" >mtry
7753                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7754                 chmod +x mtry
7755                 ./mtry >/dev/null 2>&1
7756                 case $? in
7757                 0) eagain=`$cat try.out`;;
7758                 1) echo "Could not perform non-blocking setting!";;
7759                 2) echo "I did a successful read() for something that was not there!";;
7760                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7761                 *) echo "Something terribly wrong happened during testing.";;
7762                 esac
7763                 rd_nodata=`$cat try.ret`
7764                 echo "A read() system call with no data present returns $rd_nodata."
7765                 case "$rd_nodata" in
7766                 0|-1) ;;
7767                 *)
7768                         echo "(That's peculiar, fixing that to be -1.)"
7769                         rd_nodata=-1
7770                         ;;
7771                 esac
7772                 case "$eagain" in
7773                 '')
7774                         echo "Forcing errno EAGAIN on read() with no data available."
7775                         eagain=EAGAIN
7776                         ;;
7777                 *)
7778                         echo "Your read() sets errno to $eagain when no data is available."
7779                         ;;
7780                 esac
7781                 status=`$cat try.err`
7782                 case "$status" in
7783                 0) echo "And it correctly returns 0 to signal EOF.";;
7784                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7785                 *) echo "However, your read() returns '$status' on EOF??";;
7786                 esac
7787                 val="$define"
7788                 if test "$status" = "$rd_nodata"; then
7789                         echo "WARNING: you can't distinguish between EOF and no data!"
7790                         val="$undef"
7791                 fi
7792         else
7793                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7794                 eagain=EAGAIN
7795         fi
7796         set d_eofnblk
7797         eval $setvar
7798         ;;
7799 *)
7800         echo "Using $hint value $eagain."
7801         echo "Your read() returns $rd_nodata when no data is present."
7802         case "$d_eofnblk" in
7803         "$define") echo "And you can see EOF because read() returns 0.";;
7804         "$undef") echo "But you can't see EOF status from read() returned value.";;
7805         *)
7806                 echo "(Assuming you can't see EOF status from read anyway.)"
7807                 d_eofnblk=$undef
7808                 ;;
7809         esac
7810         ;;
7811 esac
7812 $rm -f try try.* .out core head.c mtry
7813
7814 : see if fchmod exists
7815 set fchmod d_fchmod
7816 eval $inlibc
7817
7818 : see if fchown exists
7819 set fchown d_fchown
7820 eval $inlibc
7821
7822 : see if this is an fcntl system
7823 set fcntl d_fcntl
7824 eval $inlibc
7825
7826 : see if sys/select.h has to be included
7827 set sys/select.h i_sysselct
7828 eval $inhdr
7829
7830 : see if we should include time.h, sys/time.h, or both
7831 echo " "
7832 if test "X$timeincl" = X; then
7833         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7834         $echo $n "I'm now running the test program...$c"
7835         $cat >try.c <<'EOCP'
7836 #include <sys/types.h>
7837 #ifdef I_TIME
7838 #include <time.h>
7839 #endif
7840 #ifdef I_SYSTIME
7841 #ifdef SYSTIMEKERNEL
7842 #define KERNEL
7843 #endif
7844 #include <sys/time.h>
7845 #endif
7846 #ifdef I_SYSSELECT
7847 #include <sys/select.h>
7848 #endif
7849 int main()
7850 {
7851         struct tm foo;
7852 #ifdef S_TIMEVAL
7853         struct timeval bar;
7854 #endif
7855 #ifdef S_TIMEZONE
7856         struct timezone tzp;
7857 #endif
7858         if (foo.tm_sec == foo.tm_sec)
7859                 exit(0);
7860 #ifdef S_TIMEVAL
7861         if (bar.tv_sec == bar.tv_sec)
7862                 exit(0);
7863 #endif
7864         exit(1);
7865 }
7866 EOCP
7867         flags=''
7868         for s_timezone in '-DS_TIMEZONE' ''; do
7869         sysselect=''
7870         for s_timeval in '-DS_TIMEVAL' ''; do
7871         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7872         for i_time in '' '-DI_TIME'; do
7873         for i_systime in '-DI_SYSTIME' ''; do
7874                 case "$flags" in
7875                 '') $echo $n ".$c"
7876                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7877                         if eval $compile; then
7878                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7879                                 shift
7880                                 flags="$*"
7881                                 echo " "
7882                                 $echo $n "Succeeded with $flags$c"
7883                         fi
7884                         ;;
7885                 esac
7886         done
7887         done
7888         done
7889         done
7890         done
7891         timeincl=''
7892         echo " "
7893         case "$flags" in
7894         *SYSTIMEKERNEL*) i_systimek="$define"
7895                 timeincl=`./findhdr sys/time.h`
7896                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7897         *) i_systimek="$undef";;
7898         esac
7899         case "$flags" in
7900         *I_TIME*) i_time="$define"
7901                 timeincl=`./findhdr time.h`" $timeincl"
7902                 echo "We'll include <time.h>." >&4;;
7903         *) i_time="$undef";;
7904         esac
7905         case "$flags" in
7906         *I_SYSTIME*) i_systime="$define"
7907                 timeincl=`./findhdr sys/time.h`" $timeincl"
7908                 echo "We'll include <sys/time.h>." >&4;;
7909         *) i_systime="$undef";;
7910         esac
7911         $rm -f try.c try
7912 fi
7913
7914 : check for fd_set items
7915 $cat <<EOM
7916
7917 Checking to see how well your C compiler handles fd_set and friends ...
7918 EOM
7919 $cat >fd_set.c <<EOCP
7920 #$i_systime I_SYS_TIME
7921 #$i_sysselct I_SYS_SELECT
7922 #$d_socket HAS_SOCKET
7923 #include <sys/types.h>
7924 #ifdef HAS_SOCKET
7925 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7926 #endif
7927 #ifdef I_SYS_TIME
7928 #include <sys/time.h>
7929 #endif
7930 #ifdef I_SYS_SELECT
7931 #include <sys/select.h>
7932 #endif
7933 int main() {
7934         fd_set fds;
7935
7936 #ifdef TRYBITS
7937         if(fds.fds_bits);
7938 #endif
7939
7940 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7941         exit(0);
7942 #else
7943         exit(1);
7944 #endif
7945 }
7946 EOCP
7947 set fd_set -DTRYBITS
7948 if eval $compile; then
7949         d_fds_bits="$define"
7950         d_fd_set="$define"
7951         echo "Well, your system knows about the normal fd_set typedef..." >&4
7952         if ./fd_set; then
7953                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7954                 d_fd_macros="$define"
7955         else
7956                 $cat >&4 <<'EOM'
7957 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7958 EOM
7959                 d_fd_macros="$undef"
7960         fi
7961 else
7962         $cat <<'EOM'
7963 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7964 EOM
7965         set fd_set
7966         if eval $compile; then
7967                 d_fds_bits="$undef"
7968                 d_fd_set="$define"
7969                 echo "Well, your system has some sort of fd_set available..." >&4
7970                 if ./fd_set; then
7971                         echo "and you have the normal fd_set macros." >&4
7972                         d_fd_macros="$define"
7973                 else
7974                         $cat <<'EOM'
7975 but not the normal fd_set macros!  Gross!  More work for me...
7976 EOM
7977                         d_fd_macros="$undef"
7978                 fi
7979         else
7980         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7981                 d_fd_set="$undef"
7982                 d_fds_bits="$undef"
7983                 d_fd_macros="$undef"
7984         fi
7985 fi
7986 $rm -f fd_set*
7987
7988 : see if fgetpos exists
7989 set fgetpos d_fgetpos
7990 eval $inlibc
7991
7992
7993 if $test X"$use64bits" = X"$define"; then
7994         : see if fgetpos64 exists
7995         set fgetpos64 d_fgetpos64
7996         eval $inlibc
7997
7998         : see if fopen64 exists
7999         set freopen64 d_fopen64
8000         eval $inlibc
8001
8002         : see if freopen64 exists
8003         set freopen64 d_freopen64
8004         eval $inlibc
8005
8006         : see if fseek64 exists
8007         set fseek64 d_fseek64
8008         eval $inlibc
8009
8010         : see if fseeko64 exists
8011         set fseeko64 d_fseeko64
8012         eval $inlibc
8013
8014         : see if fsetpos64 exists
8015         set fsetpos64 d_fsetpos64
8016         eval $inlibc
8017
8018         : see if ftell64 exists
8019         set ftell64 d_ftell64
8020         eval $inlibc
8021
8022         : see if ftello64 exists
8023         set ftello64 d_ftello64
8024         eval $inlibc
8025
8026         : see if tmpfile64 exists
8027         set tmpfile64 d_tmpfile64
8028         eval $inlibc
8029 else
8030         val="$undef"
8031         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
8032         do
8033                 set $xxx
8034                 eval $setvar
8035         done
8036 fi
8037
8038 : see if flock exists
8039 set flock d_flock
8040 eval $inlibc
8041
8042 : see if fork exists
8043 set fork d_fork
8044 eval $inlibc
8045
8046 : see if pathconf exists
8047 set pathconf d_pathconf
8048 eval $inlibc
8049
8050 : see if fpathconf exists
8051 set fpathconf d_fpathconf
8052 eval $inlibc
8053
8054 : see if fseeko exists
8055 set fseeko d_fseeko
8056 eval $inlibc
8057
8058 : see if fsetpos exists
8059 set fsetpos d_fsetpos
8060 eval $inlibc
8061
8062 : see if this is a sys/param system
8063 set sys/param.h i_sysparam
8064 eval $inhdr
8065
8066 : see if this is a sys/mount.h system
8067 set sys/mount.h i_sysmount
8068 eval $inhdr
8069
8070
8071 : see if statfs exists
8072 set statfs d_statfs
8073 eval $inlibc
8074
8075 : see if fstatfs exists
8076 set fstatfs d_fstatfs
8077 eval $inlibc
8078
8079 : see if statfs knows about mount flags
8080 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8081 eval $hasfield
8082
8083
8084 : see if statvfs exists
8085 set statvfs d_statvfs
8086 eval $inlibc
8087
8088 : see if fstatvfs exists
8089 set fstatvfs d_fstatvfs
8090 eval $inlibc
8091
8092
8093 : see if ftello exists
8094 set ftello d_ftello
8095 eval $inlibc
8096
8097 : see if getgrent exists
8098 set getgrent d_getgrent
8099 eval $inlibc
8100
8101 : see if gethostbyaddr exists
8102 set gethostbyaddr d_gethbyaddr
8103 eval $inlibc
8104
8105 : see if gethostbyname exists
8106 set gethostbyname d_gethbyname
8107 eval $inlibc
8108
8109 : see if gethostent exists
8110 set gethostent d_gethent
8111 eval $inlibc
8112
8113 : see how we will look up host name
8114 echo " "
8115 call=''
8116 if set gethostname val -f d_gethname; eval $csym; $val; then
8117         echo 'gethostname() found.' >&4
8118         d_gethname="$define"
8119         call=gethostname
8120 fi
8121 if set uname val -f d_uname; eval $csym; $val; then
8122         if ./xenix; then
8123                 $cat <<'EOM'
8124 uname() was found, but you're running xenix, and older versions of xenix
8125 have a broken uname(). If you don't really know whether your xenix is old
8126 enough to have a broken system call, use the default answer.
8127
8128 EOM
8129                 dflt=y
8130                 case "$d_uname" in
8131                 "$define") dflt=n;;
8132                 esac
8133                 rp='Is your uname() broken?'
8134                 . ./myread
8135                 case "$ans" in
8136                 n*) d_uname="$define"; call=uname;;
8137                 esac
8138         else
8139                 echo 'uname() found.' >&4
8140                 d_uname="$define"
8141                 case "$call" in
8142                 '') call=uname ;;
8143                 esac
8144         fi
8145 fi
8146 case "$d_gethname" in
8147 '') d_gethname="$undef";;
8148 esac
8149 case "$d_uname" in
8150 '') d_uname="$undef";;
8151 esac
8152 case "$d_uname$d_gethname" in
8153 *define*)
8154         dflt=n
8155         cat <<EOM
8156  
8157 Every now and then someone has a $call() that lies about the hostname
8158 but can't be fixed for political or economic reasons.  If you wish, I can
8159 pretend $call() isn't there and maybe compute hostname at run-time
8160 thanks to the '$phostname' command.
8161
8162 EOM
8163         rp="Shall I ignore $call() from now on?"
8164         . ./myread
8165         case "$ans" in
8166         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8167         esac;;
8168 esac
8169 case "$phostname" in
8170 '') aphostname='';;
8171 *) case "$aphostname" in
8172         /*) ;;
8173         *) set X $phostname
8174                 shift
8175                 file=$1
8176                 shift
8177                 file=`./loc $file $file $pth`
8178                 aphostname=`echo $file $*`
8179                 ;;
8180         esac
8181         ;;
8182 esac
8183 case "$d_uname$d_gethname" in
8184 *define*) ;;
8185 *)
8186         case "$phostname" in
8187         '')
8188                 echo "There will be no way for $package to get your hostname." >&4;;
8189         *)
8190         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8191                 ;;
8192         esac;;
8193 esac
8194 case "$d_phostname" in
8195 '') d_phostname="$undef";;
8196 esac
8197
8198 : see if this is a netdb.h system
8199 set netdb.h i_netdb
8200 eval $inhdr
8201
8202 : see if prototypes for various gethostxxx netdb.h functions are available
8203 echo " "
8204 set d_gethostprotos gethostent $i_netdb netdb.h
8205 eval $hasproto
8206
8207 : see if getlogin exists
8208 set getlogin d_getlogin
8209 eval $inlibc
8210
8211 : see if getmntent exists
8212 set getmntent d_getmntent
8213 eval $inlibc
8214
8215 : see if getnetbyaddr exists
8216 set getnetbyaddr d_getnbyaddr
8217 eval $inlibc
8218
8219 : see if getnetbyname exists
8220 set getnetbyname d_getnbyname
8221 eval $inlibc
8222
8223 : see if getnetent exists
8224 set getnetent d_getnent
8225 eval $inlibc
8226
8227 : see if prototypes for various getnetxxx netdb.h functions are available
8228 echo " "
8229 set d_getnetprotos getnetent $i_netdb netdb.h
8230 eval $hasproto
8231
8232
8233 : see if getprotobyname exists
8234 set getprotobyname d_getpbyname
8235 eval $inlibc
8236
8237 : see if getprotobynumber exists
8238 set getprotobynumber d_getpbynumber
8239 eval $inlibc
8240
8241 : see if getprotoent exists
8242 set getprotoent d_getpent
8243 eval $inlibc
8244
8245 : see if getpgid exists
8246 set getpgid d_getpgid
8247 eval $inlibc
8248
8249 : see if getpgrp2 exists
8250 set getpgrp2 d_getpgrp2
8251 eval $inlibc
8252
8253 : see if getppid exists
8254 set getppid d_getppid
8255 eval $inlibc
8256
8257 : see if getpriority exists
8258 set getpriority d_getprior
8259 eval $inlibc
8260
8261 : see if prototypes for various getprotoxxx netdb.h functions are available
8262 echo " "
8263 set d_getprotoprotos getprotoent $i_netdb netdb.h
8264 eval $hasproto
8265
8266 : see if getpwent exists
8267 set getpwent d_getpwent
8268 eval $inlibc
8269
8270
8271 : see if getservbyname exists
8272 set getservbyname d_getsbyname
8273 eval $inlibc
8274
8275 : see if getservbyport exists
8276 set getservbyport d_getsbyport
8277 eval $inlibc
8278
8279 : see if getservent exists
8280 set getservent d_getsent
8281 eval $inlibc
8282
8283 : see if prototypes for various getservxxx netdb.h functions are available
8284 echo " "
8285 set d_getservprotos getservent $i_netdb netdb.h
8286 eval $hasproto
8287
8288 : see if getspent exists
8289 set getspent d_getspent
8290 eval $inlibc
8291
8292 : see if getspnam exists
8293 set getspnam d_getspnam
8294 eval $inlibc
8295
8296 : see if gettimeofday or ftime exists
8297 set gettimeofday d_gettimeod
8298 eval $inlibc
8299 case "$d_gettimeod" in
8300 "$undef")
8301         set ftime d_ftime 
8302         eval $inlibc
8303         ;;
8304 *)
8305         val="$undef"; set d_ftime; eval $setvar
8306         ;;
8307 esac
8308 case "$d_gettimeod$d_ftime" in
8309 "$undef$undef")
8310         echo " "
8311         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8312         ;;
8313 esac
8314
8315 : see if this is an grp system
8316 set grp.h i_grp
8317 eval $inhdr
8318
8319 case "$i_grp" in
8320 $define)
8321         xxx=`./findhdr grp.h`
8322         $cppstdin $cppflags $cppminus < $xxx >$$.h
8323
8324         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8325                 val="$define"
8326         else
8327                 val="$undef"
8328         fi
8329         set d_grpasswd
8330         eval $setvar
8331
8332         $rm -f $$.h
8333         ;;
8334 *)
8335         val="$undef";
8336         set d_grpasswd; eval $setvar
8337         ;;
8338 esac
8339
8340 : see if hasmntopt exists
8341 set hasmntopt d_hasmntopt
8342 eval $inlibc
8343
8344 : see if this is a netinet/in.h or sys/in.h system
8345 set netinet/in.h i_niin sys/in.h i_sysin
8346 eval $inhdr
8347
8348 : see if arpa/inet.h has to be included
8349 set arpa/inet.h i_arpainet
8350 eval $inhdr
8351
8352 : see if htonl --and friends-- exists
8353 val=''
8354 set htonl val
8355 eval $inlibc
8356
8357 : Maybe they are macros.
8358 case "$val" in
8359 $undef)
8360         $cat >htonl.c <<EOM
8361 #include <stdio.h>
8362 #include <sys/types.h>
8363 #$i_niin I_NETINET_IN
8364 #$i_sysin I_SYS_IN
8365 #$i_arpainet I_ARPA_INET
8366 #ifdef I_NETINET_IN
8367 #include <netinet/in.h>
8368 #endif
8369 #ifdef I_SYS_IN
8370 #include <sys/in.h>
8371 #endif
8372 #ifdef I_ARPA_INET
8373 #include <arpa/inet.h>
8374 #endif
8375 #ifdef htonl
8376 printf("Defined as a macro.");
8377 #endif
8378 EOM
8379         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8380         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8381                 val="$define"
8382                 echo "But it seems to be defined as a macro." >&4
8383         fi
8384         $rm -f htonl.?
8385         ;;
8386 esac
8387 set d_htonl
8388 eval $setvar
8389
8390 : see which of string.h or strings.h is needed
8391 echo " "
8392 strings=`./findhdr string.h`
8393 if $test "$strings" && $test -r "$strings"; then
8394         echo "Using <string.h> instead of <strings.h>." >&4
8395         val="$define"
8396 else
8397         val="$undef"
8398         strings=`./findhdr strings.h`
8399         if $test "$strings" && $test -r "$strings"; then
8400                 echo "Using <strings.h> instead of <string.h>." >&4
8401         else
8402                 echo "No string header found -- You'll surely have problems." >&4
8403         fi
8404 fi
8405 set i_string
8406 eval $setvar
8407 case "$i_string" in
8408 "$undef") strings=`./findhdr strings.h`;;
8409 *)        strings=`./findhdr string.h`;;
8410 esac
8411
8412 : index or strchr
8413 echo " "
8414 if set index val -f; eval $csym; $val; then
8415         if set strchr val -f d_strchr; eval $csym; $val; then
8416                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8417                         val="$define"
8418                         vali="$undef"
8419                         echo "strchr() found." >&4
8420                 else
8421                         val="$undef"
8422                         vali="$define"
8423                         echo "index() found." >&4
8424                 fi
8425         else
8426                 val="$undef"
8427                 vali="$define"
8428                 echo "index() found." >&4
8429         fi
8430 else
8431         if set strchr val -f d_strchr; eval $csym; $val; then
8432                 val="$define"
8433                 vali="$undef"
8434                 echo "strchr() found." >&4
8435         else
8436                 echo "No index() or strchr() found!" >&4
8437                 val="$undef"
8438                 vali="$undef"
8439         fi
8440 fi
8441 set d_strchr; eval $setvar
8442 val="$vali"
8443 set d_index; eval $setvar
8444
8445 : check whether inet_aton exists
8446 set inet_aton d_inetaton
8447 eval $inlibc
8448
8449 : see if inttypes.h is available
8450 : we want a real compile instead of Inhdr because some systems
8451 : have an inttypes.h which includes non-existent headers
8452 echo " "
8453 $cat >try.c <<EOCP
8454 #include <inttypes.h>
8455 int main() {
8456         static int32_t foo32 = 0x12345678;
8457 }
8458 EOCP
8459 set try
8460 if eval $compile; then
8461         echo "<inttypes.h> found." >&4
8462         val="$define"
8463 else
8464         echo "<inttypes.h> NOT found." >&4
8465         val="$undef"
8466 fi
8467 $rm -f try.c try
8468 set i_inttypes
8469 eval $setvar
8470
8471 : check for int64_t
8472 case "$use64bits" in
8473 "$define" )
8474         echo " "
8475         echo $n "Checking to see if your system supports int64_t...$c" >&4
8476         $cat >try.c <<EOCP
8477 #include <sys/types.h>
8478 #$i_inttypes I_INTTYPES
8479 #ifdef I_INTTYPES
8480 #include <inttypes.h>
8481 #endif
8482 int64_t foo() { int64_t x; x = 7; return x; }
8483 EOCP
8484         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8485                 val="$define"
8486                 echo " Yup, it does." >&4
8487         else
8488                 val="$undef"
8489                 echo " Nope, it doesn't." >&4
8490         fi
8491         $rm -f try.*
8492         ;;
8493 *)      val="$undef"
8494         ;;
8495 esac
8496 set d_int64t
8497 eval $setvar
8498
8499
8500 : Look for isascii
8501 echo " "
8502 $cat >isascii.c <<'EOCP'
8503 #include <stdio.h>
8504 #include <ctype.h>
8505 int main() {
8506         int c = 'A';
8507         if (isascii(c))
8508                 exit(0);
8509         else
8510                 exit(1);
8511 }
8512 EOCP
8513 set isascii
8514 if eval $compile; then
8515         echo "isascii() found." >&4
8516         val="$define"
8517 else
8518         echo "isascii() NOT found." >&4
8519         val="$undef"
8520 fi
8521 set d_isascii
8522 eval $setvar
8523 $rm -f isascii*
8524
8525 : see if killpg exists
8526 set killpg d_killpg
8527 eval $inlibc
8528
8529 : see if lchown exists
8530 echo " "
8531 $cat > try.c <<'EOCP'
8532 /* System header to define __stub macros and hopefully few prototypes,
8533     which can conflict with char lchown(); below.  */
8534 #include <assert.h>
8535 /* Override any gcc2 internal prototype to avoid an error.  */
8536 /* We use char because int might match the return type of a gcc2
8537    builtin and then its argument prototype would still apply.  */
8538 char lchown();
8539 int main() {
8540     /*  The GNU C library defines this for functions which it implements
8541         to always fail with ENOSYS.  Some functions are actually named
8542         something starting with __ and the normal name is an alias.  */
8543 #if defined (__stub_lchown) || defined (__stub___lchown)
8544 choke me
8545 #else
8546 lchown();
8547 #endif
8548 ; return 0; }
8549 EOCP
8550 set try
8551 if eval $compile; then
8552     $echo "lchown() found." >&4
8553     val="$define"
8554 else
8555     $echo "lchown() NOT found." >&4
8556     val="$undef"
8557 fi
8558 set d_lchown
8559 eval $setvar
8560
8561 : see if link exists
8562 set link d_link
8563 eval $inlibc
8564
8565 : see if localeconv exists
8566 set localeconv d_locconv
8567 eval $inlibc
8568
8569 : see if lockf exists
8570 set lockf d_lockf
8571 eval $inlibc
8572
8573 : check for length of double
8574 echo " "
8575 case "$doublesize" in
8576 '')
8577         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8578         $cat >try.c <<'EOCP'
8579 #include <stdio.h>
8580 int main()
8581 {
8582         printf("%d\n", sizeof(double));
8583 }
8584 EOCP
8585         set try
8586         if eval $compile_ok; then
8587                 doublesize=`./try`
8588                 $echo " $doublesize bytes." >&4
8589         else
8590                 dflt='8'
8591                 echo "(I can't seem to compile the test program.  Guessing...)"
8592                 rp="What is the size of a double precision number (in bytes)?"
8593                 . ./myread
8594                 doublesize="$ans"
8595         fi
8596         ;;
8597 esac
8598 $rm -f try.c try
8599
8600 : check for long doubles
8601 echo " "
8602 echo $n "Checking to see if your system supports long doubles...$c" >&4
8603 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8604 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8605         val="$define"
8606         echo " Yup, it does." >&4
8607 else
8608         val="$undef"
8609         echo " Nope, it doesn't." >&4
8610 fi
8611 $rm try.*
8612 set d_longdbl
8613 eval $setvar
8614
8615 : check for length of long double
8616 case "${d_longdbl}${longdblsize}" in
8617 $define)
8618         echo " "
8619         $echo $n "Checking to see how big your long doubles are...$c" >&4
8620         $cat >try.c <<'EOCP'
8621 #include <stdio.h>
8622 int main()
8623 {
8624         printf("%d\n", sizeof(long double));
8625 }
8626 EOCP
8627         set try
8628         if eval $compile; then
8629                 longdblsize=`./try`
8630                 $echo " $longdblsize bytes." >&4
8631         else
8632                 dflt='8'
8633                 echo " "
8634                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8635                 rp="What is the size of a long double (in bytes)?"
8636                 . ./myread
8637                 longdblsize="$ans"
8638         fi
8639         if $test "X$doublesize" = "X$longdblsize"; then
8640                 echo "(That isn't any different from an ordinary double.)"
8641         fi      
8642         ;;
8643 esac
8644 $rm -f try.c try
8645
8646 : check for long long
8647 echo " "
8648 echo $n "Checking to see if your system supports long long...$c" >&4
8649 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8650 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8651         val="$define"
8652         echo " Yup, it does." >&4
8653 else
8654         val="$undef"
8655         echo " Nope, it doesn't." >&4
8656 fi
8657 $rm try.*
8658 set d_longlong
8659 eval $setvar
8660
8661 : check for length of long long
8662 case "${d_longlong}${longlongsize}" in
8663 $define)
8664         echo " "
8665         $echo $n "Checking to see how big your long longs are...$c" >&4
8666         $cat >try.c <<'EOCP'
8667 #include <stdio.h>
8668 int main()
8669 {
8670         printf("%d\n", sizeof(long long));
8671 }
8672 EOCP
8673         set try
8674         if eval $compile_ok; then
8675                 longlongsize=`./try`
8676                 $echo " $longlongsize bytes." >&4
8677         else
8678                 dflt='8'
8679                 echo " "
8680                 echo "(I can't seem to compile the test program.  Guessing...)"
8681                 rp="What is the size of a long long (in bytes)?"
8682                 . ./myread
8683                 longlongsize="$ans"
8684         fi
8685         if $test "X$longsize" = "X$longlongsize"; then
8686                 echo "(That isn't any different from an ordinary long.)"
8687         fi      
8688         ;;
8689 esac
8690 $rm -f try.c try
8691
8692 : see if lstat exists
8693 set lstat d_lstat
8694 eval $inlibc
8695
8696 : see if madvise exists
8697 set madvise d_madvise
8698 eval $inlibc
8699
8700 : see if mblen exists
8701 set mblen d_mblen
8702 eval $inlibc
8703
8704 : see if mbstowcs exists
8705 set mbstowcs d_mbstowcs
8706 eval $inlibc
8707
8708 : see if mbtowc exists
8709 set mbtowc d_mbtowc
8710 eval $inlibc
8711
8712 : see if memchr exists
8713 set memchr d_memchr
8714 eval $inlibc
8715
8716 : see if memcmp exists
8717 set memcmp d_memcmp
8718 eval $inlibc
8719
8720 : see if memcpy exists
8721 set memcpy d_memcpy
8722 eval $inlibc
8723
8724 : see if memmove exists
8725 set memmove d_memmove
8726 eval $inlibc
8727
8728 : see if memset exists
8729 set memset d_memset
8730 eval $inlibc
8731
8732 : see if mkdir exists
8733 set mkdir d_mkdir
8734 eval $inlibc
8735
8736 : see if mkfifo exists
8737 set mkfifo d_mkfifo
8738 eval $inlibc
8739
8740 : see if mktime exists
8741 set mktime d_mktime
8742 eval $inlibc
8743
8744 : see if this is a sys/mman.h system
8745 set sys/mman.h i_sysmman
8746 eval $inhdr
8747
8748 : see if mmap exists
8749 set mmap d_mmap
8750 eval $inlibc
8751 : see what shmat returns
8752 : default to something harmless
8753 mmaptype='void *'
8754 case "$i_sysmman$d_mmap" in
8755 "$define$define")
8756         $cat >mmap.c <<'END'
8757 #include <sys/mman.h>
8758 void *mmap();
8759 END
8760         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8761                 mmaptype='void *'
8762         else
8763                 mmaptype='caddr_t'
8764         fi
8765         echo "and it returns ($mmaptype)." >&4
8766         ;;
8767 esac
8768
8769
8770
8771 : see if mprotect exists
8772 set mprotect d_mprotect
8773 eval $inlibc
8774
8775 : see if msgctl exists
8776 set msgctl d_msgctl
8777 eval $inlibc
8778
8779 : see if msgget exists
8780 set msgget d_msgget
8781 eval $inlibc
8782
8783 : see if msgsnd exists
8784 set msgsnd d_msgsnd
8785 eval $inlibc
8786
8787 : see if msgrcv exists
8788 set msgrcv d_msgrcv
8789 eval $inlibc
8790
8791 : see how much of the 'msg*(2)' library is present.
8792 h_msg=true
8793 echo " "
8794 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8795 *"$undef"*) h_msg=false;;
8796 esac
8797 case "$osname" in
8798 freebsd)
8799     case "`ipcs 2>&1`" in
8800     "SVID messages"*"not configured"*)
8801         echo "Your $osname does not have the msg*(2) configured." >&4
8802         h_msg=false
8803         val="$undef"
8804         set msgctl d_msgctl
8805         eval $setvar
8806         set msgget d_msgget
8807         eval $setvar
8808         set msgsnd d_msgsnd
8809         eval $setvar
8810         set msgrcv d_msgrcv
8811         eval $setvar
8812         ;;
8813     esac
8814     ;;
8815 esac
8816 : we could also check for sys/ipc.h ...
8817 if $h_msg && $test `./findhdr sys/msg.h`; then
8818         echo "You have the full msg*(2) library." >&4
8819         val="$define"
8820 else
8821         echo "You don't have the full msg*(2) library." >&4
8822         val="$undef"
8823 fi
8824 set d_msg
8825 eval $setvar
8826
8827 : see if msync exists
8828 set msync d_msync
8829 eval $inlibc
8830
8831 : see if munmap exists
8832 set munmap d_munmap
8833 eval $inlibc
8834
8835 : see if nice exists
8836 set nice d_nice
8837 eval $inlibc
8838
8839 : see if POSIX threads are available
8840 if test "X$usethreads" = "X$define"; then
8841         set pthread.h i_pthread
8842         eval $inhdr
8843 else
8844         i_pthread="$undef"
8845 fi
8846
8847
8848
8849 : how to create joinable pthreads
8850 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
8851         echo " "
8852         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8853         $cat >try.c <<'EOCP'
8854 #include <pthread.h>
8855 int main() {
8856     int detachstate = JOINABLE;
8857 }
8858 EOCP
8859         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8860         if eval $compile; then
8861                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8862                 val="$undef" # Yes, undef.
8863                 set d_old_pthread_create_joinable
8864                 eval $setvar
8865                 val=""
8866                 set old_pthread_create_joinable
8867                 eval $setvar
8868         else
8869                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8870                 if eval $compile; then
8871                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8872                         val="$define"
8873                         set d_old_pthread_create_joinable
8874                         eval $setvar
8875                         val=PTHREAD_CREATE_UNDETACHED
8876                         set old_pthread_create_joinable
8877                         eval $setvar
8878                 else            
8879                         set try -DJOINABLE=__UNDETACHED
8880                         if eval $compile; then
8881                                 echo "You seem to use __UNDETACHED." >&4
8882                                 val="$define"
8883                                 set d_old_pthread_create_joinable
8884                                 eval $setvar
8885                                 val=__UNDETACHED
8886                                 set old_pthread_create_joinable
8887                                 eval $setvar
8888                         else
8889                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8890                                 val="$define"
8891                                 set d_old_pthread_create_joinable
8892                                 eval $setvar
8893                                 val=0
8894                                 set old_pthread_create_joinable
8895                                 eval $setvar
8896                         fi
8897                 fi
8898         fi
8899         $rm -f try try.*
8900 else
8901     d_old_pthread_create_joinable="$undef"
8902     old_pthread_create_joinable=""
8903 fi
8904
8905 : see if pause exists
8906 set pause d_pause
8907 eval $inlibc
8908
8909 : see if pipe exists
8910 set pipe d_pipe
8911 eval $inlibc
8912
8913 : see if poll exists
8914 set poll d_poll
8915 eval $inlibc
8916
8917
8918 : see whether the various POSIXish _yields exist
8919 $cat >try.c <<EOP
8920 #include <pthread.h>
8921 #include <stdio.h>
8922 int main() {
8923 #ifdef SCHED_YIELD
8924         sched_yield();
8925 #else
8926 #ifdef PTHREAD_YIELD
8927         pthread_yield();
8928 #else
8929 #ifdef PTHREAD_YIELD_NULL
8930         pthread_yield(NULL);
8931 #endif
8932 #endif
8933 #endif
8934 }
8935 EOP
8936 : see if sched_yield exists
8937 set try -DSCHED_YIELD
8938 if eval $compile; then
8939     val="$define"
8940     sched_yield='sched_yield()'
8941 else
8942     val="$undef"
8943 fi
8944 case "$usethreads" in
8945 $define)
8946         case "$val" in
8947         $define) echo 'sched_yield() found.' >&4        ;;
8948         *)       echo 'sched_yield() NOT found.' >&4    ;;
8949         esac
8950 esac
8951 set d_sched_yield
8952 eval $setvar
8953
8954 : see if pthread_yield exists
8955 set try -DPTHREAD_YIELD
8956 if eval $compile; then
8957     val="$define"
8958     case "$sched_yield" in
8959     '') sched_yield='pthread_yield()' ;;
8960     esac
8961 else
8962     set try -DPTHREAD_YIELD_NULL
8963     if eval $compile; then
8964         val="$define"
8965         case "$sched_yield" in
8966         '') sched_yield='pthread_yield(NULL)' ;;
8967         esac
8968     else
8969         val="$undef"
8970     fi
8971 fi
8972 case "$usethreads" in
8973 $define)
8974         case "$val" in
8975         $define) echo 'pthread_yield() found.' >&4      ;;
8976         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8977         esac
8978         ;;
8979 esac
8980 set d_pthread_yield
8981 eval $setvar
8982
8983 case "$sched_yield" in
8984 '') sched_yield=undef ;;
8985 esac
8986
8987 $rm -f try try.*
8988
8989 : see if this is a pwd.h system
8990 set pwd.h i_pwd
8991 eval $inhdr
8992
8993 case "$i_pwd" in
8994 $define)
8995         xxx=`./findhdr pwd.h`
8996         $cppstdin $cppflags $cppminus < $xxx >$$.h
8997
8998         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8999                 val="$define"
9000         else
9001                 val="$undef"
9002         fi
9003         set d_pwquota
9004         eval $setvar
9005
9006         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
9007                 val="$define"
9008         else
9009                 val="$undef"
9010         fi
9011         set d_pwage
9012         eval $setvar
9013
9014         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
9015                 val="$define"
9016         else
9017                 val="$undef"
9018         fi
9019         set d_pwchange
9020         eval $setvar
9021
9022         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
9023                 val="$define"
9024         else
9025                 val="$undef"
9026         fi
9027         set d_pwclass
9028         eval $setvar
9029
9030         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
9031                 val="$define"
9032         else
9033                 val="$undef"
9034         fi
9035         set d_pwexpire
9036         eval $setvar
9037
9038         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
9039                 val="$define"
9040         else
9041                 val="$undef"
9042         fi
9043         set d_pwcomment
9044         eval $setvar
9045
9046         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
9047                 val="$define"
9048         else
9049                 val="$undef"
9050         fi
9051         set d_pwgecos
9052         eval $setvar
9053
9054         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
9055                 val="$define"
9056         else
9057                 val="$undef"
9058         fi
9059         set d_pwpasswd
9060         eval $setvar
9061
9062         $rm -f $$.h
9063         ;;
9064 *)
9065         val="$undef"; 
9066         set d_pwquota; eval $setvar
9067         set d_pwage; eval $setvar
9068         set d_pwchange; eval $setvar
9069         set d_pwclass; eval $setvar
9070         set d_pwexpire; eval $setvar
9071         set d_pwcomment; eval $setvar
9072         set d_pwgecos; eval $setvar
9073         set d_pwpasswd; eval $setvar
9074         ;;
9075 esac
9076
9077 : see if readdir and friends exist
9078 set readdir d_readdir
9079 eval $inlibc
9080 set seekdir d_seekdir
9081 eval $inlibc
9082 set telldir d_telldir
9083 eval $inlibc
9084 set rewinddir d_rewinddir
9085 eval $inlibc
9086
9087 : see if readlink exists
9088 set readlink d_readlink
9089 eval $inlibc
9090
9091 : see if readv exists
9092 set readv d_readv
9093 eval $inlibc
9094
9095 : see if rename exists
9096 set rename d_rename
9097 eval $inlibc
9098
9099 : see if rmdir exists
9100 set rmdir d_rmdir
9101 eval $inlibc
9102
9103 : see if memory.h is available.
9104 val=''
9105 set memory.h val
9106 eval $inhdr
9107
9108 : See if it conflicts with string.h
9109 case "$val" in
9110 $define)
9111         case "$strings" in
9112         '') ;;
9113         *)
9114                 $cppstdin $cppflags $cppminus < $strings > mem.h
9115                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9116                         echo " "
9117                         echo "We won't be including <memory.h>."
9118                         val="$undef"
9119                 fi
9120                 $rm -f mem.h
9121                 ;;
9122         esac
9123 esac
9124 set i_memory
9125 eval $setvar
9126
9127 : can bcopy handle overlapping blocks?
9128 val="$undef"
9129 case "$d_bcopy" in
9130 "$define")
9131         echo " "
9132         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9133         $cat >try.c <<EOCP
9134 #$i_memory I_MEMORY
9135 #$i_stdlib I_STDLIB
9136 #$i_string I_STRING
9137 #$i_unistd I_UNISTD
9138 EOCP
9139         $cat >>try.c <<'EOCP'
9140 #include <stdio.h>
9141 #ifdef I_MEMORY
9142 #  include <memory.h>
9143 #endif
9144 #ifdef I_STDLIB
9145 #  include <stdlib.h>
9146 #endif
9147 #ifdef I_STRING
9148 #  include <string.h>
9149 #else
9150 #  include <strings.h>
9151 #endif
9152 #ifdef I_UNISTD
9153 #  include <unistd.h>  /* Needed for NetBSD */
9154 #endif
9155 int main()
9156 {
9157 char buf[128], abc[128];
9158 char *b;
9159 int len;
9160 int off;
9161 int align;
9162
9163 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9164
9165 for (align = 7; align >= 0; align--) {
9166         for (len = 36; len; len--) {
9167                 b = buf+align;
9168                 bcopy(abc, b, len);
9169                 for (off = 1; off <= len; off++) {
9170                         bcopy(b, b+off, len);
9171                         bcopy(b+off, b, len);
9172                         if (bcmp(b, abc, len))
9173                                 exit(1);
9174                 }
9175         }
9176 }
9177 exit(0);
9178 }
9179 EOCP
9180         set try
9181         if eval $compile_ok; then
9182                 if ./try 2>/dev/null; then
9183                         echo "Yes, it can."
9184                         val="$define"
9185                 else
9186                         echo "It can't, sorry."
9187                         case "$d_memmove" in
9188                         "$define") echo "But that's Ok since you have memmove()." ;;
9189                         esac
9190                 fi
9191         else
9192                 echo "(I can't compile the test program, so we'll assume not...)"
9193                 case "$d_memmove" in
9194                 "$define") echo "But that's Ok since you have memmove()." ;;
9195                 esac
9196         fi
9197         ;;
9198 esac
9199 $rm -f try.* try core
9200 set d_safebcpy
9201 eval $setvar
9202
9203 : can memcpy handle overlapping blocks?
9204 val="$undef"
9205 case "$d_memcpy" in
9206 "$define")
9207         echo " "
9208         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9209         $cat >try.c <<EOCP
9210 #$i_memory I_MEMORY
9211 #$i_stdlib I_STDLIB
9212 #$i_string I_STRING
9213 #$i_unistd I_UNISTD
9214 EOCP
9215         $cat >>try.c <<'EOCP'
9216 #include <stdio.h>
9217 #ifdef I_MEMORY
9218 #  include <memory.h>
9219 #endif
9220 #ifdef I_STDLIB
9221 #  include <stdlib.h>
9222 #endif
9223 #ifdef I_STRING
9224 #  include <string.h>
9225 #else
9226 #  include <strings.h>
9227 #endif
9228 #ifdef I_UNISTD
9229 #  include <unistd.h>  /* Needed for NetBSD */
9230 #endif
9231 int main()
9232 {
9233 char buf[128], abc[128];
9234 char *b;
9235 int len;
9236 int off;
9237 int align;
9238
9239 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9240    try to store the string in read-only memory. */
9241 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9242
9243 for (align = 7; align >= 0; align--) {
9244         for (len = 36; len; len--) {
9245                 b = buf+align;
9246                 memcpy(b, abc, len);
9247                 for (off = 1; off <= len; off++) {
9248                         memcpy(b+off, b, len);
9249                         memcpy(b, b+off, len);
9250                         if (memcmp(b, abc, len))
9251                                 exit(1);
9252                 }
9253         }
9254 }
9255 exit(0);
9256 }
9257 EOCP
9258         set try
9259         if eval $compile_ok; then
9260                 if ./try 2>/dev/null; then
9261                         echo "Yes, it can."
9262                         val="$define"
9263                 else
9264                         echo "It can't, sorry."
9265                         case "$d_memmove" in
9266                         "$define") echo "But that's Ok since you have memmove()." ;;
9267                         esac
9268                 fi
9269         else
9270                 echo "(I can't compile the test program, so we'll assume not...)"
9271                 case "$d_memmove" in
9272                 "$define") echo "But that's Ok since you have memmove()." ;;
9273                 esac
9274         fi
9275         ;;
9276 esac
9277 $rm -f try.* try core
9278 set d_safemcpy
9279 eval $setvar
9280
9281 : can memcmp be trusted to compare relative magnitude?
9282 val="$undef"
9283 case "$d_memcmp" in
9284 "$define")
9285         echo " "
9286         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9287         $cat >try.c <<EOCP
9288 #$i_memory I_MEMORY
9289 #$i_stdlib I_STDLIB
9290 #$i_string I_STRING
9291 #$i_unistd I_UNISTD
9292 EOCP
9293         $cat >>try.c <<'EOCP'
9294 #include <stdio.h>
9295 #ifdef I_MEMORY
9296 #  include <memory.h>
9297 #endif
9298 #ifdef I_STDLIB
9299 #  include <stdlib.h>
9300 #endif
9301 #ifdef I_STRING
9302 #  include <string.h>
9303 #else
9304 #  include <strings.h>
9305 #endif
9306 #ifdef I_UNISTD
9307 #  include <unistd.h>  /* Needed for NetBSD */
9308 #endif
9309 int main()
9310 {
9311 char a = -1;
9312 char b = 0;
9313 if ((a < b) && memcmp(&a, &b, 1) < 0)
9314         exit(1);
9315 exit(0);
9316 }
9317 EOCP
9318         set try
9319         if eval $compile_ok; then
9320                 if ./try 2>/dev/null; then
9321                         echo "Yes, it can."
9322                         val="$define"
9323                 else
9324                         echo "No, it can't (it uses signed chars)."
9325                 fi
9326         else
9327                 echo "(I can't compile the test program, so we'll assume not...)"
9328         fi
9329         ;;
9330 esac
9331 $rm -f try.* try core
9332 set d_sanemcmp
9333 eval $setvar
9334
9335 : see if select exists
9336 set select d_select
9337 eval $inlibc
9338
9339 : see if semctl exists
9340 set semctl d_semctl
9341 eval $inlibc
9342
9343 : see if semget exists
9344 set semget d_semget
9345 eval $inlibc
9346
9347 : see if semop exists
9348 set semop d_semop
9349 eval $inlibc
9350
9351 : see how much of the 'sem*(2)' library is present.
9352 h_sem=true
9353 echo " "
9354 case "$d_semctl$d_semget$d_semop" in
9355 *"$undef"*) h_sem=false;;
9356 esac
9357 case "$osname" in
9358 freebsd)
9359     case "`ipcs 2>&1`" in
9360     "SVID messages"*"not configured"*)
9361         echo "Your $osname does not have the sem*(2) configured." >&4
9362         h_sem=false
9363         val="$undef"
9364         set semctl d_semctl
9365         eval $setvar
9366         set semget d_semget
9367         eval $setvar
9368         set semop d_semop
9369         eval $setvar
9370         ;;
9371     esac
9372     ;;
9373 esac
9374 : we could also check for sys/ipc.h ...
9375 if $h_sem && $test `./findhdr sys/sem.h`; then
9376         echo "You have the full sem*(2) library." >&4
9377         val="$define"
9378 else
9379         echo "You don't have the full sem*(2) library." >&4
9380         val="$undef"
9381 fi
9382 set d_sem
9383 eval $setvar
9384
9385 : see whether sys/sem.h defines union semun
9386 echo " "
9387 $cat > try.c <<'END'
9388 #include <sys/types.h>
9389 #include <sys/ipc.h>
9390 #include <sys/sem.h>
9391 int main () { union semun semun; semun.buf = 0; }
9392 END
9393 set try
9394 if eval $compile; then
9395     echo "You have union semun in <sys/sem.h>." >&4
9396     val="$define"
9397 else
9398     echo "You do not have union semun in <sys/sem.h>." >&4
9399     val="$undef"
9400 fi
9401 $rm -f try try.c try.h
9402 set d_union_semun
9403 eval $setvar
9404
9405 : see how to do semctl IPC_STAT
9406 case "$d_sem" in
9407 $define)
9408     : see whether semctl IPC_STAT can use union semun
9409     echo " "
9410     $cat > try.h <<END
9411 #ifndef S_IRUSR
9412 #   ifdef S_IREAD
9413 #       define S_IRUSR S_IREAD
9414 #       define S_IWUSR S_IWRITE
9415 #       define S_IXUSR S_IEXEC
9416 #   else
9417 #       define S_IRUSR 0400
9418 #       define S_IWUSR 0200
9419 #       define S_IXUSR 0100
9420 #   endif
9421 #   define S_IRGRP (S_IRUSR>>3)
9422 #   define S_IWGRP (S_IWUSR>>3)
9423 #   define S_IXGRP (S_IXUSR>>3)
9424 #   define S_IROTH (S_IRUSR>>6)
9425 #   define S_IWOTH (S_IWUSR>>6)
9426 #   define S_IXOTH (S_IXUSR>>6)
9427 #endif
9428 #ifndef S_IRWXU
9429 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9430 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9431 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9432 #endif
9433 END
9434
9435     $cat > try.c <<END
9436 #include <sys/types.h>
9437 #include <sys/ipc.h>
9438 #include <sys/sem.h>
9439 #include <sys/stat.h>
9440 #include <stdio.h>
9441 #include <errno.h>
9442 #include "try.h"
9443 #ifndef errno
9444 extern int errno;
9445 #endif
9446 #$d_union_semun HAS_UNION_SEMUN
9447 int main() {
9448     union semun
9449 #ifndef HAS_UNION_SEMUN
9450     {
9451         int val;
9452         struct semid_ds *buf;
9453         unsigned short *array;
9454     }
9455 #endif
9456     arg;
9457     int sem, st;
9458
9459 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9460     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9461     if (sem > -1) {
9462         struct semid_ds argbuf;
9463         arg.buf = &argbuf;
9464 #       ifdef IPC_STAT
9465         st = semctl(sem, 0, IPC_STAT, arg);
9466         if (st == 0)
9467             printf("semun\n");
9468         else
9469 #       endif /* IPC_STAT */
9470             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9471 #       ifdef IPC_RMID
9472         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9473 #       endif /* IPC_RMID */
9474             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9475     } else
9476 #endif /* IPC_PRIVATE && ... */
9477         printf("semget failed: errno = %d\n", errno);
9478   return 0;
9479 }
9480 END
9481     val="$undef"
9482     set try
9483     if eval $compile; then
9484         xxx=`./try`
9485         case "$xxx" in
9486         semun) val="$define" ;;
9487         esac
9488     fi
9489     $rm -f try try.c
9490     set d_semctl_semun
9491     eval $setvar
9492     case "$d_semctl_semun" in
9493     $define)
9494         echo "You can use union semun for semctl IPC_STAT." >&4
9495         also='also'
9496         ;;
9497     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9498         also=''
9499         ;;
9500     esac
9501
9502     : see whether semctl IPC_STAT can use struct semid_ds pointer
9503     $cat > try.c <<'END'
9504 #include <sys/types.h>
9505 #include <sys/ipc.h>
9506 #include <sys/sem.h>
9507 #include <sys/stat.h>
9508 #include "try.h"
9509 #include <stdio.h>
9510 #include <errno.h>
9511 #ifndef errno
9512 extern int errno;
9513 #endif
9514 int main() {
9515     struct semid_ds arg;
9516     int sem, st;
9517
9518 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9519     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9520     if (sem > -1) {
9521 #       ifdef IPC_STAT
9522         st = semctl(sem, 0, IPC_STAT, &arg);
9523         if (st == 0)
9524             printf("semid_ds\n");
9525         else
9526 #       endif /* IPC_STAT */
9527             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9528 #       ifdef IPC_RMID
9529         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9530 #       endif /* IPC_RMID */
9531             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9532     } else
9533 #endif /* IPC_PRIVATE && ... */
9534         printf("semget failed: errno = %d\n", errno);
9535
9536     return 0;
9537 }
9538 END
9539     val="$undef"
9540     set try
9541     if eval $compile; then
9542         xxx=`./try`
9543         case "$xxx" in
9544         semid_ds) val="$define" ;;
9545         esac
9546     fi
9547     $rm -f try try.c
9548     set d_semctl_semid_ds
9549     eval $setvar
9550     case "$d_semctl_semid_ds" in
9551     $define)
9552         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9553         ;;
9554     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9555         ;;
9556     esac
9557     $rm -f try.h
9558     ;;
9559 *)  val="$undef"
9560
9561     # We do not have the full sem*(2) library, so assume we can not
9562     # use either.
9563
9564     set d_semctl_semun
9565     eval $setvar
9566
9567     set d_semctl_semid_ds
9568     eval $setvar
9569     ;;
9570 esac
9571
9572 : see if setegid exists
9573 set setegid d_setegid
9574 eval $inlibc
9575
9576 : see if seteuid exists
9577 set seteuid d_seteuid
9578 eval $inlibc
9579
9580 : see if setgrent exists
9581 set setgrent d_setgrent
9582 eval $inlibc
9583
9584 : see if sethostent exists
9585 set sethostent d_sethent
9586 eval $inlibc
9587
9588 : see if setlinebuf exists
9589 set setlinebuf d_setlinebuf
9590 eval $inlibc
9591
9592 : see if setlocale exists
9593 set setlocale d_setlocale
9594 eval $inlibc
9595
9596 : see if setnetent exists
9597 set setnetent d_setnent
9598 eval $inlibc
9599
9600 : see if setprotoent exists
9601 set setprotoent d_setpent
9602 eval $inlibc
9603
9604 : see if setpgid exists
9605 set setpgid d_setpgid
9606 eval $inlibc
9607
9608 : see if setpgrp2 exists
9609 set setpgrp2 d_setpgrp2
9610 eval $inlibc
9611
9612 : see if setpriority exists
9613 set setpriority d_setprior
9614 eval $inlibc
9615
9616 : see if setpwent exists
9617 set setpwent d_setpwent
9618 eval $inlibc
9619
9620 : see if setregid exists
9621 set setregid d_setregid
9622 eval $inlibc
9623 set setresgid d_setresgid
9624 eval $inlibc
9625
9626 : see if setreuid exists
9627 set setreuid d_setreuid
9628 eval $inlibc
9629 set setresuid d_setresuid
9630 eval $inlibc
9631
9632 : see if setrgid exists
9633 set setrgid d_setrgid
9634 eval $inlibc
9635
9636 : see if setruid exists
9637 set setruid d_setruid
9638 eval $inlibc
9639
9640 : see if setservent exists
9641 set setservent d_setsent
9642 eval $inlibc
9643
9644 : see if setsid exists
9645 set setsid d_setsid
9646 eval $inlibc
9647
9648 : see if setspent exists
9649 set setspent d_setspent
9650 eval $inlibc
9651
9652 : see if setvbuf exists
9653 set setvbuf d_setvbuf
9654 eval $inlibc
9655
9656 : see if sfio.h is available
9657 set sfio.h i_sfio
9658 eval $inhdr
9659
9660
9661 : see if sfio library is available
9662 case "$i_sfio" in
9663 $define)
9664         val=''
9665         set sfreserve val
9666         eval $inlibc
9667         ;;
9668 *)
9669         val="$undef"
9670         ;;
9671 esac
9672 : Ok, but do we want to use it.
9673 case "$val" in
9674 $define)
9675         case "$usesfio" in
9676         true|$define|[yY]*) dflt='y';;
9677         *) dflt='n';;
9678         esac
9679         echo "$package can use the sfio library, but it is experimental."
9680         rp="You seem to have sfio available, do you want to try using it?"
9681         . ./myread
9682         case "$ans" in
9683         y|Y) ;;
9684         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9685                 val="$undef"
9686                 : Remove sfio from list of libraries to use
9687                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9688                 shift
9689                 libs="$*"
9690                 echo "libs = $libs" >&4
9691                 ;;
9692         esac
9693         ;;
9694 *)      case "$usesfio" in
9695         true|$define|[yY]*)
9696                 echo "Sorry, cannot find sfio on this machine" >&4
9697                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9698                 ;;
9699         esac
9700         ;;
9701 esac
9702 set d_sfio
9703 eval $setvar
9704 case "$d_sfio" in
9705 $define) usesfio='true';;
9706 *) usesfio='false';;
9707 esac
9708
9709 : see if shmctl exists
9710 set shmctl d_shmctl
9711 eval $inlibc
9712
9713 : see if shmget exists
9714 set shmget d_shmget
9715 eval $inlibc
9716
9717 : see if shmat exists
9718 set shmat d_shmat
9719 eval $inlibc
9720 : see what shmat returns
9721 case "$d_shmat" in
9722 "$define")
9723         $cat >shmat.c <<'END'
9724 #include <sys/shm.h>
9725 void *shmat();
9726 END
9727         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9728                 shmattype='void *'
9729         else
9730                 shmattype='char *'
9731         fi
9732         echo "and it returns ($shmattype)." >&4
9733         : see if a prototype for shmat is available
9734         xxx=`./findhdr sys/shm.h`
9735         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9736         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9737                 val="$define"
9738         else
9739                 val="$undef"
9740         fi
9741         $rm -f shmat.[co]
9742         ;;
9743 *)
9744         val="$undef"
9745         ;;
9746 esac
9747 set d_shmatprototype
9748 eval $setvar
9749
9750 : see if shmdt exists
9751 set shmdt d_shmdt
9752 eval $inlibc
9753
9754 : see how much of the 'shm*(2)' library is present.
9755 h_shm=true
9756 echo " "
9757 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9758 *"$undef"*) h_shm=false;;
9759 esac
9760 case "$osname" in
9761 freebsd)
9762     case "`ipcs 2>&1`" in
9763     "SVID shared memory"*"not configured"*)
9764         echo "Your $osname does not have the shm*(2) configured." >&4
9765         h_shm=false
9766         val="$undef"
9767         set shmctl d_shmctl
9768         evat $setvar
9769         set shmget d_shmget
9770         evat $setvar
9771         set shmat d_shmat
9772         evat $setvar
9773         set shmdt d_shmdt
9774         evat $setvar
9775         ;;
9776     esac
9777     ;;
9778 esac
9779 : we could also check for sys/ipc.h ...
9780 if $h_shm && $test `./findhdr sys/shm.h`; then
9781         echo "You have the full shm*(2) library." >&4
9782         val="$define"
9783 else
9784         echo "You don't have the full shm*(2) library." >&4
9785         val="$undef"
9786 fi
9787 set d_shm
9788 eval $setvar
9789
9790 echo " "
9791 : see if we have sigaction
9792 if set sigaction val -f d_sigaction; eval $csym; $val; then
9793         echo 'sigaction() found.' >&4
9794         $cat > try.c <<'EOP'
9795 #include <stdio.h>
9796 #include <sys/types.h>
9797 #include <signal.h>
9798 int main()
9799 {
9800     struct sigaction act, oact;
9801 }
9802 EOP
9803         set try
9804         if eval $compile_ok; then
9805                 val="$define"
9806         else
9807                 echo "But you don't seem to have a useable struct sigaction." >&4
9808                 val="$undef"
9809         fi
9810 else
9811         echo 'sigaction NOT found.' >&4
9812         val="$undef"
9813 fi
9814 set d_sigaction; eval $setvar
9815 $rm -f try try$_o try.c
9816
9817 : see if sigsetjmp exists
9818 echo " "
9819 case "$d_sigsetjmp" in
9820 '')
9821         $cat >try.c <<'EOP'
9822 #include <setjmp.h>
9823 sigjmp_buf env;
9824 int set = 1;
9825 int main()
9826 {
9827         if (sigsetjmp(env,1))
9828                 exit(set);
9829         set = 0;
9830         siglongjmp(env, 1);
9831         exit(1);
9832 }
9833 EOP
9834         set try
9835         if eval $compile; then
9836                 if ./try >/dev/null 2>&1; then
9837                         echo "POSIX sigsetjmp found." >&4
9838                         val="$define"
9839                 else
9840                         $cat >&4 <<EOM
9841 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9842 I'll ignore them.
9843 EOM
9844                         val="$undef"
9845                 fi
9846         else
9847                 echo "sigsetjmp not found." >&4
9848                 val="$undef"
9849         fi
9850         ;;
9851 *) val="$d_sigsetjmp"
9852         case "$d_sigsetjmp" in
9853         $define) echo "POSIX sigsetjmp found." >&4;;
9854         $undef) echo "sigsetjmp not found." >&4;;
9855         esac
9856         ;;
9857 esac
9858 set d_sigsetjmp
9859 eval $setvar
9860 $rm -f try.c try
9861
9862 : see if stat knows about block sizes
9863 echo " "
9864 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9865 eval $hasfield
9866
9867 : see if _ptr and _cnt from stdio act std
9868 echo " "
9869 if $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
9870         echo "(Looks like you have stdio.h from Linux.)"
9871         case "$stdio_ptr" in
9872         '') stdio_ptr='((fp)->_IO_read_ptr)'
9873                 ptr_lval=$define
9874                 ;;
9875         *)      ptr_lval=$d_stdio_ptr_lval;;
9876         esac
9877         case "$stdio_cnt" in
9878         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9879                 cnt_lval=$undef
9880                 ;;
9881         *)      cnt_lval=$d_stdio_cnt_lval;;
9882         esac
9883         case "$stdio_base" in
9884         '') stdio_base='((fp)->_IO_read_base)';;
9885         esac
9886         case "$stdio_bufsiz" in
9887         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9888         esac
9889 else
9890         case "$stdio_ptr" in
9891         '') stdio_ptr='((fp)->_ptr)'
9892                 ptr_lval=$define
9893                 ;;
9894         *)      ptr_lval=$d_stdio_ptr_lval;;
9895         esac
9896         case "$stdio_cnt" in
9897         '') stdio_cnt='((fp)->_cnt)'
9898                 cnt_lval=$define
9899                 ;;
9900         *)      cnt_lval=$d_stdio_cnt_lval;;
9901         esac
9902         case "$stdio_base" in
9903         '') stdio_base='((fp)->_base)';;
9904         esac
9905         case "$stdio_bufsiz" in
9906         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9907         esac
9908 fi
9909 : test whether _ptr and _cnt really work
9910 echo "Checking how std your stdio is..." >&4
9911 $cat >try.c <<EOP
9912 #include <stdio.h>
9913 #define FILE_ptr(fp)    $stdio_ptr
9914 #define FILE_cnt(fp)    $stdio_cnt
9915 int main() {
9916         FILE *fp = fopen("try.c", "r");
9917         char c = getc(fp);
9918         if (
9919                 18 <= FILE_cnt(fp) &&
9920                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9921         )
9922                 exit(0);
9923         exit(1);
9924 }
9925 EOP
9926 val="$undef"
9927 set try
9928 if eval $compile; then
9929         if ./try; then
9930                 echo "Your stdio acts pretty std."
9931                 val="$define"
9932         else
9933                 echo "Your stdio isn't very std."
9934         fi
9935 else
9936         echo "Your stdio doesn't appear very std."
9937 fi
9938 $rm -f try.c try
9939 set d_stdstdio
9940 eval $setvar
9941
9942 : Can _ptr be used as an lvalue?
9943 case "$d_stdstdio$ptr_lval" in
9944 $define$define) val=$define ;;
9945 *) val=$undef ;;
9946 esac
9947 set d_stdio_ptr_lval
9948 eval $setvar
9949
9950 : Can _cnt be used as an lvalue?
9951 case "$d_stdstdio$cnt_lval" in
9952 $define$define) val=$define ;;
9953 *) val=$undef ;;
9954 esac
9955 set d_stdio_cnt_lval
9956 eval $setvar
9957
9958 : see if _base is also standard
9959 val="$undef"
9960 case "$d_stdstdio" in
9961 $define)
9962         $cat >try.c <<EOP
9963 #include <stdio.h>
9964 #define FILE_base(fp)   $stdio_base
9965 #define FILE_bufsiz(fp) $stdio_bufsiz
9966 int main() {
9967         FILE *fp = fopen("try.c", "r");
9968         char c = getc(fp);
9969         if (
9970                 19 <= FILE_bufsiz(fp) &&
9971                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9972         )
9973                 exit(0);
9974         exit(1);
9975 }
9976 EOP
9977         set try
9978         if eval $compile; then
9979                 if ./try; then
9980                         echo "And its _base field acts std."
9981                         val="$define"
9982                 else
9983                         echo "But its _base field isn't std."
9984                 fi
9985         else
9986                 echo "However, it seems to be lacking the _base field."
9987         fi
9988         $rm -f try.c try
9989         ;;
9990 esac
9991 set d_stdiobase
9992 eval $setvar
9993
9994 $cat >&4 <<EOM
9995 Checking how to access stdio streams by file descriptor number...
9996 EOM
9997 case "$stdio_stream_array" in
9998 '')     $cat >try.c <<EOCP
9999 #include <stdio.h>
10000 int main() {
10001   if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
10002     printf("yes\n");
10003 }
10004 EOCP
10005         for s in _iob __iob __sF
10006         do
10007                 set try -DSTDIO_STREAM_ARRAY=$s
10008                 if eval $compile; then
10009                         case "`./try$exe_ext`" in
10010                         yes)    stdio_stream_array=$s; break ;;
10011                         esac
10012                 fi
10013         done
10014         $rm -f try.* try$exe_ext
10015 esac
10016 case "$stdio_stream_array" in
10017 '')     $cat >&4 <<EOM
10018 I can't figure out how to access stdio streams by file descriptor number.
10019 EOM
10020         d_stdio_stream_array="$undef"
10021         ;;
10022 *)      $cat >&4 <<EOM
10023 You can access stdio streams by file descriptor number by the $stdio_stream_array array.
10024 EOM
10025         d_stdio_stream_array="$define"
10026         ;;
10027 esac
10028
10029 : see if strcoll exists
10030 set strcoll d_strcoll
10031 eval $inlibc
10032
10033 : check for structure copying
10034 echo " "
10035 echo "Checking to see if your C compiler can copy structs..." >&4
10036 $cat >try.c <<'EOCP'
10037 int main()
10038 {
10039         struct blurfl {
10040                 int dyick;
10041         } foo, bar;
10042
10043         foo = bar;
10044 }
10045 EOCP
10046 if $cc -c try.c >/dev/null 2>&1 ; then
10047         val="$define"
10048         echo "Yup, it can."
10049 else
10050         val="$undef"
10051         echo "Nope, it can't."
10052 fi
10053 set d_strctcpy
10054 eval $setvar
10055 $rm -f try.*
10056
10057 : see if strerror and/or sys_errlist[] exist
10058 echo " "
10059 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
10060     if set strerror val -f d_strerror; eval $csym; $val; then
10061                 echo 'strerror() found.' >&4
10062                 d_strerror="$define"
10063                 d_strerrm='strerror(e)'
10064                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10065                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
10066                         d_syserrlst="$define"
10067                 else
10068                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
10069                         d_syserrlst="$undef"
10070                 fi
10071     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
10072                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
10073                 echo 'strerror() found in string header.' >&4
10074                 d_strerror="$define"
10075                 d_strerrm='strerror(e)'
10076                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10077                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
10078                                 d_syserrlst="$define"
10079                 else
10080                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
10081                         d_syserrlst="$undef"
10082                 fi
10083     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
10084                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
10085                 d_strerror="$undef"
10086                 d_syserrlst="$define"
10087                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
10088     else
10089                 echo 'strerror() and sys_errlist[] NOT found.' >&4
10090                 d_strerror="$undef"
10091                 d_syserrlst="$undef"
10092                 d_strerrm='"unknown"'
10093     fi
10094 fi
10095
10096 : see if strtod exists
10097 set strtod d_strtod
10098 eval $inlibc
10099
10100 : see if strtol exists
10101 set strtol d_strtol
10102 eval $inlibc
10103
10104 : see if strtoul exists
10105 set strtoul d_strtoul
10106 eval $inlibc
10107
10108 : see if strxfrm exists
10109 set strxfrm d_strxfrm
10110 eval $inlibc
10111
10112 : see if symlink exists
10113 set symlink d_symlink
10114 eval $inlibc
10115
10116 : see if syscall exists
10117 set syscall d_syscall
10118 eval $inlibc
10119
10120 : see if sysconf exists
10121 set sysconf d_sysconf
10122 eval $inlibc
10123
10124 : see if system exists
10125 set system d_system
10126 eval $inlibc
10127
10128 : see if tcgetpgrp exists
10129 set tcgetpgrp d_tcgetpgrp
10130 eval $inlibc
10131
10132 : see if tcsetpgrp exists
10133 set tcsetpgrp d_tcsetpgrp
10134 eval $inlibc
10135
10136 : see if sys/types.h has to be included
10137 set sys/types.h i_systypes
10138 eval $inhdr
10139
10140 : see if prototype for telldir is available
10141 echo " "
10142 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10143 eval $hasproto
10144
10145 : define an is-a-typedef? function
10146 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10147 case "$inclist" in
10148 "") inclist="sys/types.h";;
10149 esac;
10150 eval "varval=\$$var";
10151 case "$varval" in
10152 "")
10153         $rm -f temp.c;
10154         for inc in $inclist; do
10155                 echo "#include <$inc>" >>temp.c;
10156         done;
10157         echo "#ifdef $type" >> temp.c;
10158         echo "printf(\"We have $type\");" >> temp.c;
10159         echo "#endif" >> temp.c;
10160         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10161         if $contains $type temp.E >/dev/null 2>&1; then
10162                 eval "$var=\$type";
10163         else
10164                 eval "$var=\$def";
10165         fi;
10166         $rm -f temp.?;;
10167 *) eval "$var=\$varval";;
10168 esac'
10169
10170 : define an is-a-typedef? function that prompts if the type is not available.
10171 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10172 case "$inclist" in
10173 "") inclist="sys/types.h";;
10174 esac;
10175 eval "varval=\$$var";
10176 case "$varval" in
10177 "")
10178         $rm -f temp.c;
10179         for inc in $inclist; do
10180                 echo "#include <$inc>" >>temp.c;
10181         done;
10182         echo "#ifdef $type" >> temp.c;
10183         echo "printf(\"We have $type\");" >> temp.c;
10184         echo "#endif" >> temp.c;
10185         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10186         echo " " ;
10187         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10188         if $contains $type temp.E >/dev/null 2>&1; then
10189                 echo "$type found." >&4;
10190                 eval "$var=\$type";
10191         else
10192                 echo "$type NOT found." >&4;
10193                 dflt="$def";
10194                 . ./myread ;
10195                 eval "$var=\$ans";
10196         fi;
10197         $rm -f temp.?;;
10198 *) eval "$var=\$varval";;
10199 esac'
10200
10201 : see if this is a sys/times.h system
10202 set sys/times.h i_systimes
10203 eval $inhdr
10204
10205 : see if times exists
10206 echo " "
10207 if set times val -f d_times; eval $csym; $val; then
10208         echo 'times() found.' >&4
10209         d_times="$define"
10210         inc=''
10211         case "$i_systimes" in
10212         "$define") inc='sys/times.h';;
10213         esac
10214         rp="What is the type returned by times() on this system?"
10215         set clock_t clocktype long stdio.h sys/types.h $inc
10216         eval $typedef_ask
10217 else
10218         echo 'times() NOT found, hope that will do.' >&4
10219         d_times="$undef"
10220         clocktype='int'
10221 fi
10222
10223 : see if truncate exists
10224 set truncate d_truncate
10225 eval $inlibc
10226
10227 : see if tzname[] exists
10228 echo " "
10229 if set tzname val -a d_tzname; eval $csym; $val; then
10230         val="$define"
10231         echo 'tzname[] found.' >&4
10232 else
10233         val="$undef"
10234         echo 'tzname[] NOT found.' >&4
10235 fi
10236 set d_tzname
10237 eval $setvar
10238
10239 : see if umask exists
10240 set umask d_umask
10241 eval $inlibc
10242
10243 : backward compatibility for d_hvfork
10244 if test X$d_hvfork != X; then
10245         d_vfork="$d_hvfork"
10246         d_hvfork=''
10247 fi
10248 : see if there is a vfork
10249 val=''
10250 set vfork val
10251 eval $inlibc
10252
10253 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10254 : perl on Solaris 2.x, and probably elsewhere.
10255 case "$val" in
10256 $define)
10257         echo " "
10258         case "$usevfork" in
10259         false) dflt='n';;
10260         *) dflt='y';;
10261         esac
10262         cat <<'EOM'
10263  
10264 Perl can only use a vfork() that doesn't suffer from strict
10265 restrictions on calling functions or modifying global data in
10266 the child.  For example, glibc-2.1 contains such a vfork()
10267 that is unsuitable.  If your system provides a proper fork()
10268 call, chances are that you do NOT want perl to use vfork().
10269
10270 EOM
10271         rp="Do you still want to use vfork()?"
10272         . ./myread
10273         case "$ans" in
10274         y|Y) ;;
10275         *)
10276                 echo "Ok, we won't use vfork()."
10277                 val="$undef"
10278                 ;;
10279         esac
10280         ;;
10281 esac
10282 set d_vfork
10283 eval $setvar
10284 case "$d_vfork" in
10285 $define) usevfork='true';;
10286 *) usevfork='false';;
10287 esac
10288
10289 : see if this is an sysdir system
10290 set sys/dir.h i_sysdir
10291 eval $inhdr
10292
10293 : see if this is an sysndir system
10294 set sys/ndir.h i_sysndir
10295 eval $inhdr
10296
10297 : see if closedir exists
10298 set closedir d_closedir
10299 eval $inlibc
10300
10301 case "$d_closedir" in
10302 "$define")
10303         echo " "
10304         echo "Checking whether closedir() returns a status..." >&4
10305         cat > closedir.c <<EOM
10306 #$i_dirent I_DIRENT             /**/
10307 #$i_sysdir I_SYS_DIR            /**/
10308 #$i_sysndir I_SYS_NDIR          /**/
10309 #$i_systypes I_SYS_TYPES        /**/
10310
10311 #if defined(I_SYS_TYPES)
10312 #include <sys/types.h>
10313 #endif
10314 #if defined(I_DIRENT)
10315 #include <dirent.h>
10316 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10317 #include <sys/dir.h>
10318 #endif
10319 #else
10320 #ifdef I_SYS_NDIR
10321 #include <sys/ndir.h>
10322 #else
10323 #ifdef I_SYS_DIR
10324 #ifdef hp9000s500
10325 #include <ndir.h>       /* may be wrong in the future */
10326 #else
10327 #include <sys/dir.h>
10328 #endif
10329 #endif
10330 #endif
10331 #endif 
10332 int main() { return closedir(opendir(".")); }
10333 EOM
10334         set closedir
10335         if eval $compile_ok; then
10336                 if ./closedir > /dev/null 2>&1 ; then
10337                         echo "Yes, it does."
10338                         val="$undef"
10339                 else
10340                         echo "No, it doesn't."
10341                         val="$define"
10342                 fi
10343         else
10344                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10345                 val="$define"
10346         fi
10347         ;;
10348 *)
10349         val="$undef";
10350         ;;
10351 esac
10352 set d_void_closedir
10353 eval $setvar
10354 $rm -f closedir*
10355 : check for volatile keyword
10356 echo " "
10357 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10358 $cat >try.c <<'EOCP'
10359 int main()
10360 {
10361         typedef struct _goo_struct goo_struct;
10362         goo_struct * volatile goo = ((goo_struct *)0);
10363         struct _goo_struct {
10364                 long long_int;
10365                 int reg_int;
10366                 char char_var;
10367         };
10368         typedef unsigned short foo_t;
10369         char *volatile foo;
10370         volatile int bar;
10371         volatile foo_t blech;
10372         foo = foo;
10373 }
10374 EOCP
10375 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10376         val="$define"
10377         echo "Yup, it does."
10378 else
10379         val="$undef"
10380         echo "Nope, it doesn't."
10381 fi
10382 set d_volatile
10383 eval $setvar
10384 $rm -f try.*
10385
10386 : see if there is a wait4
10387 set wait4 d_wait4
10388 eval $inlibc
10389
10390 : see if waitpid exists
10391 set waitpid d_waitpid
10392 eval $inlibc
10393
10394 : see if wcstombs exists
10395 set wcstombs d_wcstombs
10396 eval $inlibc
10397
10398 : see if wctomb exists
10399 set wctomb d_wctomb
10400 eval $inlibc
10401
10402 : see if writev exists
10403 set writev d_writev
10404 eval $inlibc
10405
10406 : preserve RCS keywords in files with variable substitution, grrr
10407 Date='$Date'
10408 Id='$Id'
10409 Log='$Log'
10410 RCSfile='$RCSfile'
10411 Revision='$Revision'
10412
10413 case "$crosscompile" in
10414 ''|[nN]*) crosscompile="$undef" ;;
10415 esac
10416
10417 case "$osname" in
10418 next|rhapsody) multiarch="$define" ;;
10419 esac
10420 case "$multiarch" in
10421 ''|[nN]*) multiarch="$undef" ;;
10422 esac
10423
10424 : check for alignment requirements
10425 echo " "
10426 case "$crosscompile$multiarch" in
10427 *$define*)
10428         $cat <<EOM
10429 You seem to be either cross-compiling or doing a multiarchitecture build,
10430 skipping the memory alignment check.
10431
10432 EOM
10433         case "$alignbytes" in
10434         '') alignbytes=8 ;;
10435         esac
10436         ;;
10437 *)
10438         case "$alignbytes" in
10439         '') echo "Checking alignment constraints..." >&4
10440                 $cat >try.c <<'EOCP'
10441 struct foobar {
10442         char foo;
10443         double bar;
10444 } try_algn;
10445 int main()
10446 {
10447         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10448 }
10449 EOCP
10450                 set try
10451                 if eval $compile_ok; then
10452                         dflt=`./try`
10453                 else
10454                         dflt='8'
10455                         echo "(I can't seem to compile the test program...)"
10456                 fi
10457                 ;;
10458         *) dflt="$alignbytes"
10459                 ;;
10460         esac
10461         rp="Doubles must be aligned on a how-many-byte boundary?"
10462         . ./myread
10463         alignbytes="$ans"
10464         $rm -f try.c try
10465         ;;
10466 esac
10467
10468
10469 : check for ordering of bytes in a long
10470 echo " "
10471 case "$crosscompile$multiarch" in
10472 *$define*)
10473         $cat <<EOM
10474 You seem to be either cross-compiling or doing a multiarchitecture build,
10475 skipping the byteorder check.
10476
10477 EOM
10478         byteorder=''
10479         ;;
10480 *)
10481         case "$byteorder" in
10482         '')
10483                 $cat <<'EOM'
10484 In the following, larger digits indicate more significance.  A big-endian
10485 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10486 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10487 machines may have weird orders like 3412.  A Cray will report 87654321. If
10488 the test program works the default is probably right.
10489 I'm now running the test program...
10490 EOM
10491                 $cat >try.c <<'EOCP'
10492 #include <stdio.h>
10493 int main()
10494 {
10495         int i;
10496         union {
10497                 unsigned long l;
10498                 char c[sizeof(long)];
10499         } u;
10500
10501         if (sizeof(long) > 4)
10502                 u.l = (0x08070605L << 32) | 0x04030201L;
10503         else
10504                 u.l = 0x04030201L;
10505         for (i = 0; i < sizeof(long); i++)
10506                 printf("%c", u.c[i]+'0');
10507         printf("\n");
10508         exit(0);
10509 }
10510 EOCP
10511                 xxx_prompt=y
10512                 set try
10513                 if eval $compile && ./try > /dev/null; then
10514                         dflt=`./try`
10515                         case "$dflt" in
10516                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10517                                 echo "(The test program ran ok.)"
10518                                 echo "byteorder=$dflt"
10519                                 xxx_prompt=n
10520                         ;;
10521                         ????|????????) echo "(The test program ran ok.)" ;;
10522                         *) echo "(The test program didn't run right for some reason.)" ;;
10523                         esac
10524                 else
10525                         dflt='4321'
10526                         cat <<'EOM'
10527 (I can't seem to compile the test program.  Guessing big-endian...)
10528 EOM
10529                 fi
10530                 case "$xxx_prompt" in
10531                 y)
10532                         rp="What is the order of bytes in a long?"
10533                         . ./myread
10534                         byteorder="$ans"
10535                         ;;
10536                 *)      byteorder=$dflt
10537                         ;;
10538                 esac
10539                 ;;
10540         esac
10541         $rm -f try.c try
10542         ;;
10543 esac
10544
10545
10546 : how do we catenate cpp tokens here?
10547 echo " "
10548 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10549 $cat >cpp_stuff.c <<'EOCP'
10550 #define RCAT(a,b)a/**/b
10551 #define ACAT(a,b)a ## b
10552 RCAT(Rei,ser)
10553 ACAT(Cir,cus)
10554 EOCP
10555 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10556 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10557         echo "Oh!  Smells like ANSI's been here." >&4
10558         echo "We can catify or stringify, separately or together!"
10559         cpp_stuff=42
10560 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10561         echo "Ah, yes!  The good old days!" >&4
10562         echo "However, in the good old days we don't know how to stringify and"
10563         echo "catify at the same time."
10564         cpp_stuff=1
10565 else
10566         $cat >&4 <<EOM
10567 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10568 to have to edit the values of CAT[2-5] in config.h...
10569 EOM
10570         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10571 fi
10572 $rm -f cpp_stuff.*
10573
10574 : see if this is a db.h system
10575 set db.h i_db
10576 eval $inhdr
10577
10578 case "$i_db" in
10579 $define)
10580         : Check db version.
10581         echo " "
10582         echo "Checking Berkeley DB version ..." >&4
10583         $cat >try.c <<EOCP
10584 #$d_const HASCONST
10585 #ifndef HASCONST
10586 #define const
10587 #endif
10588 #include <sys/types.h>
10589 #include <stdio.h>
10590 #include <db.h>
10591 int main()
10592 {
10593 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10594     int Major, Minor, Patch ;
10595     unsigned long Version ;
10596     (void)db_version(&Major, &Minor, &Patch) ;
10597     printf("You have Berkeley DB Version 2 or greater\n");
10598
10599     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10600                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10601     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10602                 Major, Minor, Patch) ;
10603
10604     /* check that db.h & libdb are compatible */
10605     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10606         printf("db.h and libdb are incompatible\n") ;
10607         exit(3);        
10608     }
10609
10610     printf("db.h and libdb are compatible\n") ;
10611
10612     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10613                 + DB_VERSION_PATCH ;
10614
10615     /* needs to be >= 2.3.4 */
10616     if (Version < 2003004) {
10617     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10618         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10619         exit(2);        
10620     }
10621
10622     exit(0);
10623 #else
10624 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10625     printf("You have Berkeley DB Version 1\n");
10626     exit(0);    /* DB version < 2: the coast is clear. */
10627 #else
10628     exit(1);    /* <db.h> not Berkeley DB? */
10629 #endif
10630 #endif
10631 }
10632 EOCP
10633         set try
10634         if eval $compile && ./try; then
10635                 echo 'Looks OK.' >&4
10636         else
10637                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10638                 i_db=$undef
10639                 case " $libs " in
10640                 *"-ldb "*)
10641                         : Remove db from list of libraries to use
10642                         echo "Removing unusable -ldb from library list" >&4
10643                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10644                         shift
10645                         libs="$*"
10646                         echo "libs = $libs" >&4
10647                         ;;
10648                 esac
10649         fi
10650         $rm -f try.*
10651         ;;
10652 esac
10653
10654 case "$i_db" in
10655 define)
10656         : Check the return type needed for hash 
10657         echo " "
10658         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10659         $cat >try.c <<EOCP
10660 #$d_const HASCONST
10661 #ifndef HASCONST
10662 #define const
10663 #endif
10664 #include <sys/types.h>
10665 #include <db.h>
10666
10667 #ifndef DB_VERSION_MAJOR
10668 u_int32_t hash_cb (ptr, size)
10669 const void *ptr;
10670 size_t size;
10671 {
10672 }
10673 HASHINFO info;
10674 int main()
10675 {
10676         info.hash = hash_cb;
10677 }
10678 #endif
10679 EOCP
10680         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10681                 if $contains warning try.out >>/dev/null 2>&1 ; then
10682                         db_hashtype='int'
10683                 else
10684                         db_hashtype='u_int32_t'
10685                 fi
10686         else
10687                 : XXX Maybe we should just give up here.
10688                 db_hashtype=u_int32_t
10689                 $cat try.out >&4
10690                 echo "Help:  I can't seem to compile the db test program." >&4
10691                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10692         fi
10693         $rm -f try.*
10694         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10695         ;;
10696 *)      db_hashtype=u_int32_t
10697         ;;
10698 esac
10699 case "$i_db" in
10700 define)
10701         : Check the return type needed for prefix 
10702         echo " "
10703         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10704         cat >try.c <<EOCP
10705 #$d_const HASCONST
10706 #ifndef HASCONST
10707 #define const
10708 #endif
10709 #include <sys/types.h>
10710 #include <db.h>
10711
10712 #ifndef DB_VERSION_MAJOR
10713 size_t prefix_cb (key1, key2)
10714 const DBT *key1;
10715 const DBT *key2;
10716 {
10717 }
10718 BTREEINFO info;
10719 int main()
10720 {
10721         info.prefix = prefix_cb;
10722 }
10723 #endif
10724 EOCP
10725         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10726                 if $contains warning try.out >>/dev/null 2>&1 ; then
10727                         db_prefixtype='int'
10728                 else
10729                         db_prefixtype='size_t'
10730                 fi
10731         else
10732                 db_prefixtype='size_t'
10733                 : XXX Maybe we should just give up here.
10734                 $cat try.out >&4
10735                 echo "Help:  I can't seem to compile the db test program." >&4
10736                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10737         fi
10738         $rm -f try.*
10739         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10740         ;;
10741 *)      db_prefixtype='size_t'
10742         ;;
10743 esac
10744
10745 : check for void type
10746 echo " "
10747 echo "Checking to see how well your C compiler groks the void type..." >&4
10748 case "$voidflags" in
10749 '')
10750         $cat >try.c <<'EOCP'
10751 #if TRY & 1
10752 void sub() {
10753 #else
10754 sub() {
10755 #endif
10756         extern void moo();      /* function returning void */
10757         void (*goo)();          /* ptr to func returning void */
10758 #if TRY & 8
10759         void *hue;              /* generic ptr */
10760 #endif
10761 #if TRY & 2
10762         void (*foo[10])();
10763 #endif
10764
10765 #if TRY & 4
10766         if(goo == moo) {
10767                 exit(0);
10768         }
10769 #endif
10770         exit(0);
10771 }
10772 int main() { sub(); }
10773 EOCP
10774         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10775                 voidflags=$defvoidused
10776         echo "Good.  It appears to support void to the level $package wants.">&4
10777                 if $contains warning .out >/dev/null 2>&1; then
10778                         echo "However, you might get some warnings that look like this:"
10779                         $cat .out
10780                 fi
10781         else
10782 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10783                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10784                         echo "It supports 1..."
10785                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10786                                 echo "It also supports 2..."
10787                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10788                                         voidflags=7
10789                                         echo "And it supports 4 but not 8 definitely."
10790                                 else
10791                                         echo "It doesn't support 4..."
10792                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10793                                                 voidflags=11
10794                                                 echo "But it supports 8."
10795                                         else
10796                                                 voidflags=3
10797                                                 echo "Neither does it support 8."
10798                                         fi
10799                                 fi
10800                         else
10801                                 echo "It does not support 2..."
10802                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10803                                         voidflags=13
10804                                         echo "But it supports 4 and 8."
10805                                 else
10806                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10807                                                 voidflags=5
10808                                                 echo "And it supports 4 but has not heard about 8."
10809                                         else
10810                                                 echo "However it supports 8 but not 4."
10811                                         fi
10812                                 fi
10813                         fi
10814                 else
10815                         echo "There is no support at all for void."
10816                         voidflags=0
10817                 fi
10818         fi
10819 esac
10820 case "$voidflags" in
10821 "$defvoidused") ;;
10822 *)      $cat >&4 <<'EOM'
10823   Support flag bits are:
10824     1: basic void declarations.
10825     2: arrays of pointers to functions returning void.
10826     4: operations between pointers to and addresses of void functions.
10827     8: generic void pointers.
10828 EOM
10829         dflt="$voidflags";
10830         rp="Your void support flags add up to what?"
10831         . ./myread
10832         voidflags="$ans"
10833         ;;
10834 esac
10835 $rm -f try.* .out
10836
10837
10838 : How can we generate normalized random numbers ?
10839 echo " "
10840 echo "Looking for a random number function..." >&4
10841 case "$randfunc" in
10842 '')
10843         if set drand48 val -f; eval $csym; $val; then
10844                 dflt="drand48"
10845                 echo "Good, found drand48()." >&4
10846         elif set random val -f; eval $csym; $val; then
10847                 dflt="random"
10848                 echo "OK, found random()." >&4
10849         else
10850                 dflt="rand"
10851                 echo "Yick, looks like I have to use rand()." >&4
10852         fi
10853         echo " "
10854         ;;
10855 *)
10856         dflt="$randfunc"
10857         ;;
10858 esac
10859 cont=true
10860
10861 case "$ccflags" in
10862 *-Dmy_rand=*|*-Dmy_srand=*)
10863         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10864         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10865         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10866         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10867         ;;
10868 esac
10869
10870 while $test "$cont"; do
10871         rp="Use which function to generate random numbers?"
10872         . ./myread
10873         if $test "$ans" = "$dflt"; then
10874                 : null
10875         else
10876                 randbits=''
10877         fi
10878         randfunc="$ans"
10879         if set $ans val -f; eval $csym; $val; then
10880                 cont=''
10881         else
10882                 dflt=y
10883                 rp="I cannot find function $ans. Use that name anyway?"
10884                 . ./myread
10885                 dflt=rand
10886                 case "$ans" in
10887                         [yY]*) cont='';;
10888                 esac
10889         fi
10890         case "$cont" in
10891         '')
10892                 case "$randfunc" in
10893                 drand48)
10894                         drand01="drand48()"
10895                         seedfunc="srand48"
10896                         randbits=48
10897                         randseedtype=long
10898                         ;;
10899                 rand|random)
10900                         case "$randbits" in
10901                         '')
10902 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10903                                 $cat >try.c <<EOCP
10904 #$i_unistd I_UNISTD
10905 #$i_stdlib I_STDLIB
10906 #include <stdio.h>
10907 #ifdef I_UNISTD
10908 #  include <unistd.h>
10909 #endif
10910 #ifdef I_STDLIB
10911 #  include <stdlib.h>
10912 #endif
10913 int main()
10914 {
10915         register int i;
10916         register unsigned long tmp;
10917         register unsigned long max = 0L;
10918
10919         for (i = 1000; i; i--) {
10920                 tmp = (unsigned long) $randfunc();
10921                 if (tmp > max) max = tmp;
10922         }
10923         for (i = 0; max; i++)
10924                 max /= 2;
10925         printf("%d\n",i);
10926 }
10927 EOCP
10928                                 set try
10929                                 if eval $compile_ok; then
10930                                         dflt=`try`
10931                                 else
10932                                         dflt='?'
10933                                         echo "(I can't seem to compile the test program...)"
10934                                 fi
10935                                 ;;
10936                         *)
10937                                 dflt="$randbits"
10938                                 ;;
10939                         esac
10940                         rp="How many bits does your $randfunc() function produce?"
10941                         . ./myread
10942                         randbits="$ans"
10943                         $rm -f try.c try
10944                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10945                         seedfunc="s$randfunc"
10946                         randseedtype=unsigned
10947                         ;;
10948                 *)
10949                         dflt="31"
10950                         rp="How many bits does your $randfunc() function produce?"
10951                         . ./myread
10952                         randbits="$ans"
10953                         seedfunc="s$randfunc"
10954                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10955                         if set $seedfunc val -f; eval $csym; $val; then
10956                                 echo "(Using $seedfunc() to seed random generator)"
10957                         else
10958                                 echo "(Warning: no $seedfunc() to seed random generator)"
10959                                 seedfunc=rand
10960                         fi
10961                         randseedtype=unsigned
10962                         ;;
10963                 esac
10964                 ;;
10965         esac
10966 done
10967
10968 echo " "
10969 echo "Determining whether or not we are on an EBCDIC system..." >&4
10970 $cat >tebcdic.c <<'EOM'
10971 int main()
10972 {
10973   if ('M'==0xd4) return 0;
10974   return 1;
10975 }
10976 EOM
10977
10978 val=$undef
10979 set tebcdic
10980 if eval $compile_ok; then
10981         if ./tebcdic; then
10982                 echo "You have EBCDIC." >&4
10983                 val="$define"
10984         else
10985                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10986         fi
10987 else
10988         echo "I'm unable to compile the test program." >&4
10989         echo "I'll assume ASCII or some ISO Latin." >&4
10990 fi
10991 $rm -f tebcdic.c tebcdic
10992 set ebcdic
10993 eval $setvar
10994
10995 $cat >&4 <<EOM
10996 Checking how to flush all pending stdio output...
10997 EOM
10998 # I only know how to find the first 32 possibly open files on SunOS.
10999 # See also hints/sunos_4_1.sh and util.c  --AD
11000 case "$osname" in
11001 sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
11002 esac
11003 $cat >>try.c <<EOCP
11004 #include <stdio.h>
11005 #$i_unistd I_UNISTD
11006 #ifdef I_UNISTD
11007 # include <unistd.h>
11008 #endif
11009 #$d_sysconf HAS_SYSCONF
11010 #$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
11011 #ifdef HAS_STDIO_STREAM_ARRAY
11012 # define STDIO_STREAM_ARRAY $stdio_stream_array
11013 #endif
11014 int main() {
11015   FILE* p = fopen("try.out", "w");
11016 #ifdef TRY_FPUTC
11017   fputc('x', p);
11018 #else
11019 # ifdef TRY_FPRINTF
11020   fprintf(p, "x");
11021 # endif
11022 #endif
11023 #ifdef TRY_FFLUSH_NULL
11024   fflush(NULL);
11025 #endif
11026 #ifdef TRY_FFLUSH_ALL
11027   {
11028     long open_max = -1;
11029 # ifdef PERL_FFLUSH_ALL_FOPEN_MAX
11030     open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
11031 # else
11032 #  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
11033     open_max = sysconf(_SC_OPEN_MAX);
11034 #  else
11035 #   ifdef FOPEN_MAX
11036     open_max = FOPEN_MAX;
11037 #   else
11038 #    ifdef OPEN_MAX
11039     open_max = OPEN_MAX;
11040 #    else
11041 #     ifdef _NFILE
11042     open_max = _NFILE;
11043 #     endif
11044 #    endif
11045 #   endif
11046 #  endif
11047 # endif 
11048 # ifdef HAS_STDIO_STREAM_ARRAY
11049     if (open_max > 0) {
11050       long i;
11051       for (i = 0; i < open_max; i++)
11052             if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
11053                 STDIO_STREAM_ARRAY[i]._file < open_max &&
11054                 STDIO_STREAM_ARRAY[i]._flag)
11055                 fflush(&STDIO_STREAM_ARRAY[i]);
11056     }   
11057   }
11058 # endif
11059 #endif
11060   _exit(42);
11061 }
11062 EOCP
11063 : first we have to find out how _not_ to flush
11064 if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
11065     output=''
11066     set try -DTRY_FPUTC
11067     if eval $compile; then
11068             $rm -f try.out
11069             ./try$exe_ext 2>/dev/null
11070             if $test ! -s try.out -a "X$?" = X42; then
11071                 output=-DTRY_FPUTC
11072             fi
11073     fi
11074     case "$output" in
11075     '')
11076             set try -DTRY_FPRINTF
11077             $rm -f try.out
11078             if eval $compile; then
11079                     $rm -f try.out
11080                     ./try$exe_ext 2>/dev/null
11081                     if $test ! -s try.out -a "X$?" = X42; then
11082                         output=-DTRY_FPRINTF
11083                     fi
11084             fi
11085         ;;
11086     esac
11087 fi
11088 : check for fflush NULL behaviour
11089 case "$fflushNULL" in
11090 '')     set try -DTRY_FFLUSH_NULL $output
11091         if eval $compile; then
11092                 $rm -f try.out
11093                 ./try$exe_ext 2>/dev/null
11094                 code="$?"
11095                 if $test -s try.out -a "X$code" = X42; then
11096                         fflushNULL="`$cat try.out`"
11097                 else
11098                         if $test "X$code" != X42; then
11099                                 $cat >&4 <<EOM
11100 (If this test failed, don't worry, we'll try another method shortly.)
11101 EOM
11102                         fi
11103                 fi
11104         fi
11105         $rm -f core try.core core.try.*
11106         case "$fflushNULL" in
11107         x)      $cat >&4 <<EOM
11108 Your fflush(NULL) works okay.
11109 EOM
11110                 fflushNULL="$define"
11111                 ;;
11112         '')     $cat >&4 <<EOM
11113 Your fflush(NULL) isn't working (contrary to ANSI C).
11114 EOM
11115                 fflushNULL="$undef"
11116                 ;;
11117         *)      $cat >&4 <<EOM
11118 Cannot figure out whether your fflush(NULL) works or not.
11119 I'm assuming it doesn't (contrary to ANSI C).
11120 EOM
11121                 fflushNULL="$undef"
11122                 ;;
11123         esac
11124         ;;
11125 $define|true|[yY]*)
11126         fflushNULL="$define"
11127         ;;
11128 *)
11129         fflushNULL="$undef"
11130         ;;
11131 esac
11132 : check explicit looping only if NULL did not work
11133 case "$fflushNULL" in
11134 "$undef")
11135         : check for fflush all behaviour
11136         case "$fflushall" in
11137         '')     set try -DTRY_FFLUSH_ALL $output
11138                 if eval $compile; then
11139                         $cat >&4 <<EOM
11140 (Now testing the other method--but note that also this may fail.)
11141 EOM
11142                         $rm -f try.out
11143                         ./try$exe_ext 2>/dev/null
11144                         if $test -s try.out -a "X$?" = X42; then
11145                                 fflushall="`$cat try.out`"
11146                         fi
11147                 fi
11148                 $rm -f core try.core core.try.*
11149                 case "$fflushall" in
11150                 x)      $cat >&4 <<EOM
11151 Whew. Flushing explicitly all the stdio streams works.
11152 EOM
11153                         fflushall="$define"
11154                         ;;
11155                 '')     $cat >&4 <<EOM
11156 Sigh. Flushing explicitly all the stdio streams doesn't work.
11157 EOM
11158                         fflushall="$undef"
11159                         ;;
11160                 *)      $cat >&4 <<EOM
11161 Cannot figure out whether flushing stdio streams explicitly works or not.
11162 I'm assuming it doesn't.
11163 EOM
11164                         fflushall="$undef"
11165                         ;;
11166                 esac
11167                 ;;
11168         "$define"|true|[yY]*)
11169                 fflushall="$define"
11170                 ;;
11171         *)
11172                 fflushall="$undef"
11173                 ;;
11174         esac
11175         ;;
11176 *)      fflushall="$undef"      
11177         ;;
11178 esac
11179 case "$fflushNULL$fflushall" in
11180 undefundef)
11181         $cat <<EOM
11182 I cannot figure out how to flush pending stdio output.
11183 EOM
11184         ;;
11185 esac
11186 $rm -f try.* try$exe_ext
11187
11188 : see what type file positions are declared as in the library
11189 rp="What is the type for file position used by fsetpos()?"
11190 set fpos_t fpostype long stdio.h sys/types.h
11191 eval $typedef_ask
11192
11193 : Store the full pathname to the ar program for use in the C program
11194 : Respect a hint or command line value for full_ar.
11195 case "$full_ar" in
11196 '') full_ar=$ar ;;
11197 esac
11198
11199 : Store the full pathname to the sed program for use in the C program
11200 full_sed=$sed
11201
11202 : see what type gids are declared as in the kernel
11203 echo " "
11204 echo "Looking for the type for group ids returned by getgid()."
11205 set gid_t gidtype xxx stdio.h sys/types.h
11206 eval $typedef
11207 case "$gidtype" in
11208 xxx)
11209         xxx=`./findhdr sys/user.h`
11210         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
11211         case $1 in
11212         unsigned) dflt="$1 $2" ;;
11213         *) dflt="$1" ;;
11214         esac
11215         ;;
11216 *) dflt="$gidtype";;
11217 esac
11218 case "$gidtype" in
11219 gid_t) echo "gid_t found." ;;
11220 *)      rp="What is the type for group ids returned by getgid()?"
11221         . ./myread
11222         gidtype="$ans"
11223         ;;
11224 esac
11225
11226 : see if getgroups exists
11227 set getgroups d_getgrps
11228 eval $inlibc
11229
11230 : see if setgroups exists
11231 set setgroups d_setgrps
11232 eval $inlibc
11233
11234
11235 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11236 echo " "
11237 case "$d_getgrps$d_setgrps" in
11238 *define*)
11239         case "$groupstype" in
11240         '') dflt="$gidtype" ;;
11241         *)  dflt="$groupstype" ;;
11242         esac
11243         $cat <<EOM
11244 What type of pointer is the second argument to getgroups() and setgroups()?
11245 Usually this is the same as group ids, $gidtype, but not always.
11246
11247 EOM
11248         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11249         . ./myread
11250         groupstype="$ans"
11251         ;;
11252 *)  groupstype="$gidtype";;
11253 esac
11254
11255 : see what type lseek is declared as in the kernel
11256 rp="What is the type used for lseek's offset on this system?"
11257 set off_t lseektype long stdio.h sys/types.h
11258 eval $typedef_ask
11259
11260 echo " "
11261 $echo $n "Checking to see how big your file offsets are...$c" >&4
11262 $cat >try.c <<EOCP
11263 #include <sys/types.h>
11264 #include <stdio.h>
11265 int main()
11266 {
11267         printf("%d\n", sizeof($lseektype));
11268 }
11269 EOCP
11270 set try
11271 if eval $compile_ok; then
11272         lseeksize=`./try`
11273         $echo " $lseeksize bytes." >&4
11274 else
11275         dflt='4'
11276         echo " "
11277         echo "(I can't seem to compile the test program.  Guessing...)"
11278         rp="What is the size of your file offsets (in bytes)?"
11279         . ./myread
11280         lseeksize="$ans"
11281 fi
11282 $rm -f try.c try
11283
11284 echo " "
11285 echo "Checking if your $make program sets \$(MAKE)..." >&4
11286 case "$make_set_make" in
11287 '')
11288         $sed 's/^X //' > testmake.mak << 'EOF'
11289 Xall:
11290 X       @echo 'maketemp="$(MAKE)"'
11291 EOF
11292         case "`$make -f testmake.mak 2>/dev/null`" in
11293         *maketemp=*) make_set_make='#' ;;
11294         *)      make_set_make="MAKE=$make" ;;
11295         esac
11296         $rm -f testmake.mak
11297         ;;
11298 esac
11299 case "$make_set_make" in
11300 '#') echo "Yup, it does.";;
11301 *) echo "Nope, it doesn't.";;
11302 esac
11303
11304 : see what type is used for mode_t
11305 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11306 set mode_t modetype int stdio.h sys/types.h
11307 eval $typedef_ask
11308
11309 : define a fucntion to check prototypes
11310 $cat > protochk <<EOSH
11311 $startsh
11312 cc="$cc"
11313 optimize="$optimize"
11314 ccflags="$ccflags"
11315 prototype="$prototype"
11316 define="$define"
11317 rm=$rm
11318 EOSH
11319
11320 $cat >> protochk <<'EOSH'
11321
11322 $rm -f try.c
11323 foo="$1"
11324 shift
11325 while test $# -ge 2; do
11326         case "$1" in
11327                 $define) echo "#include <$2>" >> try.c ;;
11328                 literal) echo "$2" >> try.c ;;
11329         esac
11330     shift 2
11331 done
11332 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11333 cat >> try.c <<'EOCP'
11334 #ifdef CAN_PROTOTYPE
11335 #define _(args) args
11336 #else
11337 #define _(args) ()
11338 #endif
11339 EOCP
11340 echo "$foo" >> try.c
11341 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11342 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11343 status=$?
11344 $rm -f try.[co]
11345 exit $status
11346 EOSH
11347 chmod +x protochk
11348 $eunicefix protochk
11349
11350 : see what type is used for size_t
11351 rp="What is the type used for the length parameter for string functions?"
11352 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11353 eval $typedef_ask
11354
11355 : check for type of arguments to gethostbyaddr. 
11356 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11357         case "$d_gethbyaddr" in
11358         $define)
11359                 $cat <<EOM
11360
11361 Checking to see what type of arguments are accepted by gethostbyaddr().
11362 EOM
11363                 hdrs="$define sys/types.h
11364                         $d_socket sys/socket.h 
11365                         $i_niin netinet/in.h 
11366                         $i_netdb netdb.h
11367                         $i_unistd unistd.h"
11368                 : The first arg can 'char *' or 'void *'
11369                 : The second arg is some of integral type
11370                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11371                         for yyy in size_t long int; do
11372                                 case "$netdb_host_type" in
11373                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11374                                         if ./protochk "$try" $hdrs; then
11375                                                 echo "Your system accepts $xxx for the first arg."
11376                                                 echo "...and $yyy for the second arg."
11377                                                 netdb_host_type="$xxx"
11378                                                 netdb_hlen_type="$yyy"
11379                                         fi
11380                                         ;;
11381                                 esac
11382                         done
11383                 done
11384                 : In case none of those worked, prompt the user.
11385                 case "$netdb_host_type" in
11386                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11387                         dflt='char *'
11388                         . ./myread
11389                         netdb_host_type=$ans
11390                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11391                         dflt="$sizetype"
11392                         . ./myread
11393                         netdb_hlen_type=$ans
11394                         ;;
11395                 esac
11396                 ;;
11397         *)      : no gethostbyaddr, so pick harmless defaults
11398                 netdb_host_type='char *'
11399                 netdb_hlen_type="$sizetype"
11400                 ;;
11401         esac
11402         # Remove the "const" if needed. -- but then we'll have a 
11403         # prototype clash!
11404         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11405 fi
11406
11407 : check for type of argument to gethostbyname. 
11408 if test "X$netdb_name_type" = X ; then
11409         case "$d_gethbyname" in
11410         $define)
11411                 $cat <<EOM
11412
11413 Checking to see what type of argument is accepted by gethostbyname().
11414 EOM
11415                 hdrs="$define sys/types.h
11416                         $d_socket sys/socket.h 
11417                         $i_niin netinet/in.h 
11418                         $i_netdb netdb.h
11419                         $i_unistd unistd.h"
11420                 for xxx in "const char *" "char *"; do
11421                         case "$netdb_name_type" in
11422                         '')     try="extern struct hostent *gethostbyname($xxx);"
11423                                 if ./protochk "$try" $hdrs; then
11424                                         echo "Your system accepts $xxx."
11425                                         netdb_name_type="$xxx"
11426                                 fi
11427                                 ;;
11428                         esac
11429                 done
11430                 : In case none of those worked, prompt the user.
11431                 case "$netdb_name_type" in
11432                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11433                         dflt='char *'
11434                         . ./myread
11435                         netdb_name_type=$ans
11436                         ;;
11437                 esac
11438                 ;;
11439         *)      : no gethostbyname, so pick harmless default
11440                 netdb_name_type='char *'
11441                 ;;
11442         esac
11443 fi
11444
11445 : check for type of 1st argument to getnetbyaddr. 
11446 if test "X$netdb_net_type" = X ; then
11447         case "$d_getnbyaddr" in
11448         $define)
11449                 $cat <<EOM
11450
11451 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11452 EOM
11453                 hdrs="$define sys/types.h
11454                         $d_socket sys/socket.h 
11455                         $i_niin netinet/in.h 
11456                         $i_netdb netdb.h
11457                         $i_unistd unistd.h"
11458                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11459                         case "$netdb_net_type" in
11460                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11461                                 if ./protochk "$try" $hdrs; then
11462                                         echo "Your system accepts $xxx."
11463                                         netdb_net_type="$xxx"
11464                                 fi
11465                                 ;;
11466                         esac
11467                 done
11468                 : In case none of those worked, prompt the user.
11469                 case "$netdb_net_type" in
11470                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11471                         dflt='long'
11472                         . ./myread
11473                         netdb_net_type=$ans
11474                         ;;
11475                 esac
11476                 ;;
11477         *)      : no getnetbyaddr, so pick harmless default
11478                 netdb_net_type='long'
11479                 ;;
11480         esac
11481 fi
11482 : locate the preferred pager for this system
11483 case "$pager" in
11484 '')
11485         dflt=''
11486         case "$pg" in
11487         /*) dflt=$pg;;
11488         esac
11489         case "$more" in
11490         /*) dflt=$more;;
11491         esac
11492         case "$less" in
11493         /*) dflt=$less;;
11494         esac
11495         case "$dflt" in
11496         '') dflt=/usr/ucb/more;;
11497         esac
11498         ;;
11499 *) dflt="$pager";;
11500 esac
11501 echo " "
11502 fn=f/
11503 rp='What pager is used on your system?'
11504 . ./getfile
11505 pager="$ans"
11506
11507 : see what type pids are declared as in the kernel
11508 rp="What is the type of process ids on this system?"
11509 set pid_t pidtype int stdio.h sys/types.h
11510 eval $typedef_ask
11511
11512 : check for length of pointer
11513 echo " "
11514 case "$ptrsize" in
11515 '')
11516         $echo $n "Checking to see how big your pointers are...$c" >&4
11517         if test "$voidflags" -gt 7; then
11518                 echo '#define VOID_PTR char *' > try.c
11519         else
11520                 echo '#define VOID_PTR void *' > try.c
11521         fi
11522         $cat >>try.c <<'EOCP'
11523 #include <stdio.h>
11524 int main()
11525 {
11526         printf("%d\n", sizeof(VOID_PTR));
11527         exit(0);
11528 }
11529 EOCP
11530         set try
11531         if eval $compile_ok; then
11532                 ptrsize=`./try`
11533                 $echo " $ptrsize bytes." >&4
11534         else
11535                 dflt='4'
11536                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11537                 rp="What is the size of a pointer (in bytes)?"
11538                 . ./myread
11539                 ptrsize="$ans"
11540         fi
11541         ;;
11542 esac
11543 $rm -f try.c try
11544
11545 : see if ar generates random libraries by itself
11546 echo " "
11547 echo "Checking how to generate random libraries on your machine..." >&4
11548 echo 'int bar1() { return bar2(); }' > bar1.c
11549 echo 'int bar2() { return 2; }' > bar2.c
11550 $cat > foo.c <<'EOP'
11551 int main() { printf("%d\n", bar1()); exit(0); }
11552 EOP
11553 $cc $ccflags -c bar1.c >/dev/null 2>&1
11554 $cc $ccflags -c bar2.c >/dev/null 2>&1
11555 $cc $ccflags -c foo.c >/dev/null 2>&1
11556 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11557 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11558         ./foobar >/dev/null 2>&1; then
11559         echo "$ar appears to generate random libraries itself."
11560         orderlib=false
11561         ranlib=":"
11562 elif $ar ts bar$_a >/dev/null 2>&1 &&
11563         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11564         ./foobar >/dev/null 2>&1; then
11565                 echo "a table of contents needs to be added with '$ar ts'."
11566                 orderlib=false
11567                 ranlib="$ar ts"
11568 else
11569         case "$ranlib" in
11570         :) ranlib='';;
11571         '')
11572                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11573                 $test -f $ranlib || ranlib=''
11574                 ;;
11575         esac
11576         if $test -n "$ranlib"; then
11577                 echo "your system has '$ranlib'; we'll use that."
11578                 orderlib=false
11579         else
11580                 echo "your system doesn't seem to support random libraries"
11581                 echo "so we'll use lorder and tsort to order the libraries."
11582                 orderlib=true
11583                 ranlib=":"
11584         fi
11585 fi
11586 $rm -f foo* bar* 
11587
11588 : check for type of arguments to select. 
11589 case "$selecttype" in
11590 '') case "$d_select" in
11591         $define)
11592                 $cat <<EOM
11593 Checking to see what type of arguments are accepted by select().
11594 EOM
11595                 hdrs="$define sys/types.h
11596                         $i_systime sys/time.h 
11597                         $i_sysselct sys/select.h
11598                         $d_socket sys/socket.h"
11599                 : The first arg can be int, unsigned, or size_t
11600                 : The last arg may or may not be 'const'
11601                 val=''
11602                 : void pointer has been seen but using that
11603                 : breaks the selectminbits test
11604                 for xxx in 'fd_set *' 'int *'; do
11605                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11606                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11607                                         case "$val" in
11608                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11609                                                 if ./protochk "$try" $hdrs; then
11610                                                         echo "Your system accepts $xxx."
11611                                                         val="$xxx"
11612                                                 fi
11613                                                 ;;
11614                                         esac
11615                                 done
11616                         done
11617                 done
11618                 case "$val" in
11619                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11620                         case "$d_fd_set" in
11621                                 $define) dflt="fd_set *" ;;
11622                                 *)              dflt="int *" ;;
11623                         esac
11624                         . ./myread
11625                         val=$ans
11626                         ;;
11627                 esac
11628                 selecttype="$val"
11629                 ;;
11630         *)      : no select, so pick a harmless default
11631                 selecttype='int *'
11632                 ;;
11633         esac
11634         ;;
11635 esac
11636
11637 : check for the select 'width'
11638 case "$selectminbits" in
11639 '') case "$d_select" in
11640         $define)
11641                 $cat <<EOM
11642
11643 Checking to see on how many bits at a time your select() operates...
11644 EOM
11645                 $cat >try.c <<EOCP
11646 #include <sys/types.h>
11647 #$i_time I_TIME
11648 #$i_systime I_SYS_TIME
11649 #$i_systimek I_SYS_TIME_KERNEL
11650 #ifdef I_TIME
11651 #   include <time.h>
11652 #endif
11653 #ifdef I_SYS_TIME
11654 #   ifdef I_SYS_TIME_KERNEL
11655 #       define KERNEL
11656 #   endif
11657 #   include <sys/time.h>
11658 #   ifdef I_SYS_TIME_KERNEL
11659 #       undef KERNEL
11660 #   endif
11661 #endif
11662 #$i_sysselct I_SYS_SELECT
11663 #ifdef I_SYS_SELECT
11664 #include <sys/select.h>
11665 #endif
11666 #$d_socket HAS_SOCKET
11667 #ifdef HAS_SOCKET
11668 #   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
11669 #endif
11670 #include <stdio.h>
11671 $selecttype b;
11672 #define S sizeof(*(b))
11673 #define MINBITS 64
11674 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11675 #define NBITS  (NBYTES * 8)
11676 int main() {
11677     char s[NBYTES];
11678     struct timeval t;
11679     int i;
11680     FILE* fp;
11681     int fd;
11682
11683     fclose(stdin);
11684     fp = fopen("try.c", "r");
11685     if (fp == 0)
11686       exit(1);
11687     fd = fileno(fp);
11688     if (fd < 0)
11689       exit(2);
11690     b = ($selecttype)s;
11691     for (i = 0; i < NBITS; i++)
11692         FD_SET(i, b);
11693     t.tv_sec  = 0;
11694     t.tv_usec = 0;
11695     select(fd + 1, b, 0, 0, &t);
11696     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11697     printf("%d\n", i + 1);
11698     return 0;
11699 }
11700 EOCP
11701                 set try
11702                 if eval $compile_ok; then
11703                         selectminbits=`./try`
11704                         case "$selectminbits" in
11705                         '')     cat >&4 <<EOM
11706 Cannot figure out on how many bits at a time your select() operates.
11707 I'll play safe and guess it is 32 bits.
11708 EOM
11709                                 selectminbits=32
11710                                 bits="32 bits"
11711                                 ;;
11712                         1)      bits="1 bit" ;;
11713                         *)      bits="$selectminbits bits" ;;
11714                         esac
11715                         echo "Your select() operates on $bits at a time." >&4
11716                 else
11717                         rp='What is the minimum number of bits your select() operates on?'
11718                         case "$byteorder" in
11719                         1234|12345678)  dflt=32 ;;
11720                         *)              dflt=1  ;;
11721                         esac
11722                         . ./myread
11723                         val=$ans
11724                         selectminbits="$val"
11725                 fi
11726                 $rm -f try.* try
11727                 ;;
11728         *)      : no select, so pick a harmless default
11729                 selectminbits='32'
11730                 ;;
11731         esac
11732         ;;
11733 esac
11734
11735 : Trace out the files included by signal.h, then look for SIGxxx names.
11736 : Remove SIGARRAYSIZE used by HPUX.
11737 : Remove SIGSTKSIZE used by Linux.
11738 : Remove SIGSTKSZ used by Posix.
11739 : Remove SIGTYP void lines used by OS2.
11740 xxx=`echo '#include <signal.h>' |
11741         $cppstdin $cppminus $cppflags 2>/dev/null |
11742         $grep '^[       ]*#.*include' | 
11743         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11744 : Check this list of files to be sure we have parsed the cpp output ok.
11745 : This will also avoid potentially non-existent files, such 
11746 : as ../foo/bar.h
11747 xxxfiles=''
11748 for xx in $xxx /dev/null ; do
11749         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11750 done
11751 : If we have found no files, at least try signal.h
11752 case "$xxxfiles" in
11753 '')     xxxfiles=`./findhdr signal.h` ;;
11754 esac
11755 xxx=`awk '
11756 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11757         print substr($2, 4, 20)
11758 }
11759 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11760         print substr($3, 4, 20)
11761 }' $xxxfiles`
11762 : Append some common names just in case the awk scan failed.
11763 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11764 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11765 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11766 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11767 : generate a few handy files for later
11768 $cat > signal.c <<'EOCP'
11769 #include <sys/types.h>
11770 #include <signal.h>
11771 #include <stdio.h>
11772 int main() {
11773
11774 /* Strange style to avoid deeply-nested #if/#else/#endif */
11775 #ifndef NSIG
11776 #  ifdef _NSIG
11777 #    define NSIG (_NSIG)
11778 #  endif
11779 #endif
11780
11781 #ifndef NSIG
11782 #  ifdef SIGMAX
11783 #    define NSIG (SIGMAX+1)
11784 #  endif
11785 #endif
11786
11787 #ifndef NSIG
11788 #  ifdef SIG_MAX
11789 #    define NSIG (SIG_MAX+1)
11790 #  endif
11791 #endif
11792
11793 #ifndef NSIG
11794 #  ifdef MAXSIG
11795 #    define NSIG (MAXSIG+1)
11796 #  endif
11797 #endif
11798
11799 #ifndef NSIG
11800 #  ifdef MAX_SIG
11801 #    define NSIG (MAX_SIG+1)
11802 #  endif
11803 #endif
11804
11805 #ifndef NSIG
11806 #  ifdef SIGARRAYSIZE
11807 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11808 #  endif
11809 #endif
11810
11811 #ifndef NSIG
11812 #  ifdef _sys_nsig
11813 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11814 #  endif
11815 #endif
11816
11817 /* Default to some arbitrary number that's big enough to get most
11818    of the common signals.
11819 */
11820 #ifndef NSIG
11821 #    define NSIG 50
11822 #endif
11823
11824 printf("NSIG %d\n", NSIG);
11825
11826 #ifndef JUST_NSIG
11827
11828 EOCP
11829
11830 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11831 {
11832         printf "#ifdef SIG"; printf $1; printf "\n"
11833         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11834         printf $1; printf ");\n"
11835         printf "#endif\n"
11836 }
11837 END {
11838         printf "#endif /* JUST_NSIG */\n";
11839         printf "}\n";
11840 }
11841 ' >>signal.c
11842 $cat >signal.awk <<'EOP'
11843 BEGIN { ndups = 0 }
11844 $1 ~ /^NSIG$/ { nsig = $2 }
11845 ($1 !~ /^NSIG$/) && (NF == 2) {
11846     if ($2 > maxsig) { maxsig = $2 }
11847     if (sig_name[$2]) {
11848         dup_name[ndups] = $1
11849         dup_num[ndups] = $2
11850         ndups++ 
11851     }
11852     else {
11853         sig_name[$2] = $1
11854         sig_num[$2] = $2
11855     }
11856 }
11857 END { 
11858     if (nsig == 0) {
11859         nsig = maxsig + 1
11860     }
11861     printf("NSIG %d\n", nsig);
11862     for (n = 1; n < nsig; n++) {
11863         if (sig_name[n]) {
11864             printf("%s %d\n", sig_name[n], sig_num[n])
11865         }
11866         else {
11867             printf("NUM%d %d\n", n, n) 
11868         }
11869     }
11870     for (n = 0; n < ndups; n++) {
11871         printf("%s %d\n", dup_name[n], dup_num[n])
11872     }
11873 }
11874 EOP
11875 $cat >signal_cmd <<EOS
11876 $startsh
11877 if $test -s signal.lst; then
11878     echo "Using your existing signal.lst file"
11879         exit 0
11880 fi
11881 xxx="$xxx"
11882 EOS
11883 $cat >>signal_cmd <<'EOS'
11884
11885 set signal
11886 if eval $compile_ok; then
11887         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11888 else
11889         echo "(I can't seem be able to compile the whole test program)" >&4
11890         echo "(I'll try it in little pieces.)" >&4
11891         set signal -DJUST_NSIG
11892         if eval $compile_ok; then
11893                 ./signal$_exe > signal.nsg
11894                 $cat signal.nsg
11895         else
11896                 echo "I can't seem to figure out how many signals you have." >&4
11897                 echo "Guessing 50." >&4
11898                 echo 'NSIG 50' > signal.nsg
11899         fi
11900         : Now look at all the signal names, one at a time.
11901         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11902                 $cat > signal.c <<EOCP
11903 #include <sys/types.h>
11904 #include <signal.h>
11905 #include <stdio.h>
11906 int main() {
11907 printf("$xx %d\n", SIG${xx});
11908 return 0;
11909 }
11910 EOCP
11911                 set signal
11912                 if eval $compile; then
11913                         echo "SIG${xx} found."
11914                         ./signal$_exe  >> signal.ls1
11915                 else
11916                         echo "SIG${xx} NOT found."
11917                 fi
11918         done
11919         if $test -s signal.ls1; then
11920                 $cat signal.nsg signal.ls1 |
11921                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11922         fi
11923
11924 fi
11925 if $test -s signal.lst; then
11926         :
11927 else
11928         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11929         echo 'kill -l' >signal
11930         set X `csh -f <signal`
11931         $rm -f signal
11932         shift
11933         case $# in
11934         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11935         esac
11936         echo $@ | $tr ' ' $trnl | \
11937             $awk '{ printf "%s %d\n", $1, ++s; }
11938                   END { printf "NSIG %d\n", ++s }' >signal.lst
11939 fi
11940 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11941 EOS
11942 chmod a+x signal_cmd
11943 $eunicefix signal_cmd
11944
11945 : generate list of signal names
11946 echo " "
11947 case "$sig_name_init" in
11948 '') doinit=yes ;;
11949 *)  case "$sig_num_init" in
11950     ''|*,*) doinit=yes ;;
11951     esac ;;
11952 esac
11953 case "$doinit" in
11954 yes)
11955         echo "Generating a list of signal names and numbers..." >&4
11956         . ./signal_cmd
11957         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11958         sig_name=`$awk 'BEGIN { printf "ZERO " }
11959                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11960         sig_num=`$awk  'BEGIN { printf "0 " }
11961                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11962         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11963                              !/^NSIG/   { printf "\"%s\", ", $1 }
11964                              END        { printf "0\n" }' signal.lst`
11965         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11966                              !/^NSIG/   { printf "%d, ", $2}
11967                              END        { printf "0\n"}' signal.lst`
11968         ;;
11969 esac
11970 echo "The following $sig_count signals are available:"
11971 echo " "
11972 echo $sig_name | $awk \
11973 'BEGIN { linelen = 0 }
11974 {
11975         for (i = 1; i <= NF; i++) {
11976                 name = "SIG" $i " "
11977                 linelen = linelen + length(name)
11978                 if (linelen > 70) {
11979                         printf "\n"
11980                         linelen = length(name)
11981                 }
11982                 printf "%s", name
11983         }
11984         printf "\n"
11985 }'
11986 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11987
11988 : see what type is used for signed size_t
11989 set ssize_t ssizetype int stdio.h sys/types.h
11990 eval $typedef
11991 dflt="$ssizetype"
11992 $cat > ssize.c <<EOM
11993 #include <stdio.h>
11994 #include <sys/types.h>
11995 #define Size_t $sizetype
11996 #define SSize_t $dflt
11997 int main()
11998 {
11999         if (sizeof(Size_t) == sizeof(SSize_t))
12000                 printf("$dflt\n");
12001         else if (sizeof(Size_t) == sizeof(int))
12002                 printf("int\n");
12003         else 
12004                 printf("long\n");
12005         exit(0);
12006 }
12007 EOM
12008 echo " "
12009 set ssize
12010 if eval $compile_ok && ./ssize > /dev/null; then
12011         ssizetype=`./ssize`
12012         echo "I'll be using $ssizetype for functions returning a byte count." >&4
12013 else
12014         $cat >&4 <<EOM
12015 Help! I can't compile and run the ssize_t test program: please enlighten me!
12016 (This is probably a misconfiguration in your system or libraries, and
12017 you really ought to fix it.  Still, I'll try anyway.)
12018
12019 I need a type that is the same size as $sizetype, but is guaranteed to
12020 be signed.  Common values are ssize_t, int and long.
12021
12022 EOM
12023         rp="What signed type is the same size as $sizetype?"
12024         . ./myread
12025         ssizetype="$ans"
12026 fi
12027 $rm -f ssize ssize.*
12028
12029 : see what type of char stdio uses.
12030 echo " "
12031 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
12032         echo "Your stdio uses unsigned chars." >&4
12033         stdchar="unsigned char"
12034 else
12035         echo "Your stdio uses signed chars." >&4
12036         stdchar="char"
12037 fi
12038
12039 : see if time exists
12040 echo " "
12041 if test "X$d_time" = X -o X"$timetype" = X; then
12042     if set time val -f d_time; eval $csym; $val; then
12043                 echo 'time() found.' >&4
12044                 val="$define"
12045                 rp="What is the type returned by time() on this system?"
12046                 set time_t timetype long stdio.h sys/types.h
12047                 eval $typedef_ask
12048     else
12049                 echo 'time() not found, hope that will do.' >&4
12050                 val="$undef"
12051                 timetype='int';
12052     fi
12053     set d_time
12054     eval $setvar
12055 fi
12056
12057 : see what type uids are declared as in the kernel
12058 echo " "
12059 echo "Looking for the type for user ids returned by getuid()."
12060 set uid_t uidtype xxx stdio.h sys/types.h
12061 eval $typedef
12062 case "$uidtype" in
12063 xxx)
12064         xxx=`./findhdr sys/user.h`
12065         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
12066         case $1 in
12067         unsigned) dflt="$1 $2" ;;
12068         *) dflt="$1" ;;
12069         esac
12070         ;;
12071 *) dflt="$uidtype";;
12072 esac
12073 case "$uidtype" in
12074 uid_t)  echo "uid_t found." ;;
12075 *)      rp="What is the type for user ids returned by getuid()?"
12076         . ./myread
12077         uidtype="$ans"
12078         ;;
12079 esac
12080
12081 : see if dbm.h is available
12082 : see if dbmclose exists
12083 set dbmclose d_dbmclose
12084 eval $inlibc
12085
12086 case "$d_dbmclose" in
12087 $define)
12088         set dbm.h i_dbm
12089         eval $inhdr
12090         case "$i_dbm" in
12091         $define)
12092                 val="$undef"
12093                 set i_rpcsvcdbm
12094                 eval $setvar
12095                 ;;
12096         *)      set rpcsvc/dbm.h i_rpcsvcdbm
12097                 eval $inhdr
12098                 ;;
12099         esac
12100         ;;
12101 *)      echo "We won't be including <dbm.h>"
12102         val="$undef"
12103         set i_dbm
12104         eval $setvar
12105         val="$undef"
12106         set i_rpcsvcdbm
12107         eval $setvar
12108         ;;
12109 esac
12110
12111 : see if this is a sys/file.h system
12112 val=''
12113 set sys/file.h val
12114 eval $inhdr
12115
12116 : do we need to include sys/file.h ?
12117 case "$val" in
12118 "$define")
12119         echo " "
12120         if $h_sysfile; then
12121                 val="$define"
12122                 echo "We'll be including <sys/file.h>." >&4
12123         else
12124                 val="$undef"
12125                 echo "We won't be including <sys/file.h>." >&4
12126         fi
12127         ;;
12128 *)
12129         h_sysfile=false
12130         ;;
12131 esac
12132 set i_sysfile
12133 eval $setvar
12134
12135 : see if fcntl.h is there
12136 val=''
12137 set fcntl.h val
12138 eval $inhdr
12139
12140 : see if we can include fcntl.h
12141 case "$val" in
12142 "$define")
12143         echo " "
12144         if $h_fcntl; then
12145                 val="$define"
12146                 echo "We'll be including <fcntl.h>." >&4
12147         else
12148                 val="$undef"
12149                 if $h_sysfile; then
12150         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12151                 else
12152                         echo "We won't be including <fcntl.h>." >&4
12153                 fi
12154         fi
12155         ;;
12156 *)
12157         h_fcntl=false
12158         val="$undef"
12159         ;;
12160 esac
12161 set i_fcntl
12162 eval $setvar
12163
12164 : see if locale.h is available
12165 set locale.h i_locale
12166 eval $inhdr
12167
12168 : see if mach cthreads are available
12169 if test "X$usethreads" = "X$define"; then
12170         set mach/cthreads.h i_machcthr
12171         eval $inhdr
12172 else
12173         i_machcthr="$undef"
12174 fi
12175
12176
12177
12178 : see if this is a math.h system
12179 set math.h i_math
12180 eval $inhdr
12181
12182 : see if this is a mntent.h system
12183 set mntent.h i_mntent
12184 eval $inhdr
12185
12186 : see if ndbm.h is available
12187 set ndbm.h t_ndbm
12188 eval $inhdr
12189 case "$t_ndbm" in
12190 $define)
12191         : see if dbm_open exists
12192         set dbm_open d_dbm_open
12193         eval $inlibc
12194         case "$d_dbm_open" in
12195         $undef)
12196                 t_ndbm="$undef"
12197                 echo "We won't be including <ndbm.h>"
12198                 ;;
12199         esac
12200         ;;
12201 esac
12202 val="$t_ndbm"
12203 set i_ndbm
12204 eval $setvar
12205
12206 : see if net/errno.h is available
12207 val=''
12208 set net/errno.h val
12209 eval $inhdr
12210
12211 : Unfortunately, it causes problems on some systems.  Arrgh.
12212 case "$val" in
12213 $define)
12214         cat > try.c <<'EOM'
12215 #include <stdio.h>
12216 #include <errno.h>
12217 #include <net/errno.h>
12218 int func()
12219 {
12220         return ENOTSOCK;
12221 }
12222 EOM
12223         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12224                 echo "We'll be including <net/errno.h>." >&4
12225         else
12226                 echo "We won't be including <net/errno.h>." >&4
12227                 val="$undef"
12228         fi
12229         $rm -f try.* try
12230         ;;
12231 esac
12232 set i_neterrno
12233 eval $setvar
12234
12235 : see if netinet/tcp.h is available
12236 set netinet/tcp.h i_netinettcp
12237 eval $inhdr
12238
12239 : see if this is a poll.h system
12240 set poll.h i_poll
12241 eval $inhdr
12242
12243 : get C preprocessor symbols handy
12244 echo " "
12245 $echo $n "Hmm... $c"
12246 echo $al | $tr ' ' $trnl >Cppsym.know
12247 $cat <<EOSS >Cppsym
12248 $startsh
12249 case "\$1" in
12250 -l) list=true
12251         shift
12252         ;;
12253 esac
12254 unknown=''
12255 case "\$list\$#" in
12256 1|2)
12257         for sym do
12258                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12259                         exit 0
12260                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12261                         :
12262                 else
12263                         unknown="\$unknown \$sym"
12264                 fi
12265         done
12266         set X \$unknown
12267         shift
12268         ;;
12269 esac
12270 case \$# in
12271 0) exit 1;;
12272 esac
12273 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12274 #ifdef \1\\
12275 exit 0; _ _ _ _\1\\      \1\\
12276 #endif\\
12277 /' >Cppsym\$\$
12278 echo "exit 1; _ _ _" >>Cppsym\$\$
12279 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12280 case "\$list" in
12281 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12282 *)
12283         sh Cppsym2\$\$
12284         status=\$?
12285         ;;
12286 esac
12287 $rm -f Cppsym\$\$ Cppsym2\$\$
12288 exit \$status
12289 EOSS
12290 chmod +x Cppsym
12291 $eunicefix Cppsym
12292 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12293
12294 : now check the C compiler for additional symbols
12295 postprocess_cc_v=''
12296 case "$osname" in
12297 aix) postprocess_cc_v="|$tr , ' '" ;;
12298 esac
12299 $cat >ccsym <<EOS
12300 $startsh
12301 $cat >tmp.c <<EOF
12302 extern int foo;
12303 EOF
12304 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12305 do
12306         case "\$i" in
12307         -D*) echo "\$i" | $sed 's/^-D//';;
12308         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12309         esac
12310 done
12311 $rm -f try.c
12312 EOS
12313 postprocess_cc_v=''
12314 chmod +x ccsym
12315 $eunicefix ccsym
12316 ./ccsym > ccsym1.raw
12317 if $test -s ccsym1.raw; then
12318        $sort ccsym1.raw | $uniq >ccsym.raw
12319 else
12320        mv ccsym1.raw ccsym.raw
12321 fi
12322
12323 $awk '/\=/ { print $0; next }
12324         { print $0"=1" }' ccsym.raw >ccsym.list
12325 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12326 $comm -13 ccsym.true ccsym.list >ccsym.own
12327 $comm -12 ccsym.true ccsym.list >ccsym.com
12328 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12329 also=''
12330 if $test -z ccsym.raw; then
12331         echo "Your C compiler doesn't seem to define any symbols!" >&4
12332         echo " "
12333         echo "However, your C preprocessor defines the following symbols:"
12334         $cat Cppsym.true
12335         ccsymbols=''
12336         cppsymbols=`$cat Cppsym.true`
12337         cppsymbols=`echo $cppsymbols`
12338         cppccsymbols="$cppsymbols"
12339 else
12340         if $test -s ccsym.com; then
12341                 echo "Your C compiler and pre-processor define these symbols:"
12342                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12343                 also='also '
12344                 symbols='ones'
12345                 cppccsymbols=`$cat ccsym.com`
12346                 cppccsymbols=`echo $cppccsymbols`
12347                 $test "$silent" || sleep 1
12348         fi
12349         if $test -s ccsym.cpp; then
12350                 $test "$also" && echo " "
12351                 echo "Your C pre-processor ${also}defines the following symbols:"
12352                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12353                 also='further '
12354                 cppsymbols=`$cat ccsym.cpp`
12355                 cppsymbols=`echo $cppsymbols`
12356                 $test "$silent" || sleep 1
12357         fi
12358         if $test -s ccsym.own; then
12359                 $test "$also" && echo " "
12360                 echo "Your C compiler ${also}defines the following cpp symbols:"
12361                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12362                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12363                 ccsymbols=`$cat ccsym.own`
12364                 ccsymbols=`echo $ccsymbols`
12365                 $test "$silent" || sleep 1
12366         fi
12367 fi
12368 $rm -f ccsym*
12369
12370 : see if this is a termio system
12371 val="$undef"
12372 val2="$undef"
12373 val3="$undef"
12374 if $test `./findhdr termios.h`; then
12375         set tcsetattr i_termios
12376         eval $inlibc
12377         val3="$i_termios"
12378 fi
12379 echo " "
12380 case "$val3" in
12381 "$define") echo "You have POSIX termios.h... good!" >&4;;
12382 *) if ./Cppsym pyr; then
12383                 case "`/bin/universe`" in
12384                 ucb) if $test `./findhdr sgtty.h`; then
12385                                 val2="$define"
12386                                 echo "<sgtty.h> found." >&4
12387                         else
12388                                 echo "System is pyramid with BSD universe."
12389                                 echo "<sgtty.h> not found--you could have problems." >&4
12390                         fi;;
12391                 *) if $test `./findhdr termio.h`; then
12392                                 val="$define"
12393                                 echo "<termio.h> found." >&4
12394                         else
12395                                 echo "System is pyramid with USG universe."
12396                                 echo "<termio.h> not found--you could have problems." >&4
12397                         fi;;
12398                 esac
12399         elif ./usg; then
12400                 if $test `./findhdr termio.h`; then
12401                         echo "<termio.h> found." >&4
12402                         val="$define"
12403                 elif $test `./findhdr sgtty.h`; then
12404                         echo "<sgtty.h> found." >&4
12405                         val2="$define"
12406                 else
12407 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12408                 fi
12409         else
12410                 if $test `./findhdr sgtty.h`; then
12411                         echo "<sgtty.h> found." >&4
12412                         val2="$define"
12413                 elif $test `./findhdr termio.h`; then
12414                         echo "<termio.h> found." >&4
12415                         val="$define"
12416                 else
12417 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12418                 fi
12419         fi;;
12420 esac
12421 set i_termio; eval $setvar
12422 val=$val2; set i_sgtty; eval $setvar
12423 val=$val3; set i_termios; eval $setvar
12424
12425 : see if this is a shadow.h system
12426 set shadow.h i_shadow
12427 eval $inhdr
12428
12429 : see if this is a socks.h system
12430 set socks.h i_socks
12431 eval $inhdr
12432
12433 : see if stdarg is available
12434 echo " "
12435 if $test `./findhdr stdarg.h`; then
12436         echo "<stdarg.h> found." >&4
12437         valstd="$define"
12438 else
12439         echo "<stdarg.h> NOT found." >&4
12440         valstd="$undef"
12441 fi
12442
12443 : see if varags is available
12444 echo " "
12445 if $test `./findhdr varargs.h`; then
12446         echo "<varargs.h> found." >&4
12447 else
12448         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12449 fi
12450
12451 : set up the varargs testing programs
12452 $cat > varargs.c <<EOP
12453 #ifdef I_STDARG
12454 #include <stdarg.h>
12455 #endif
12456 #ifdef I_VARARGS
12457 #include <varargs.h>
12458 #endif
12459
12460 #ifdef I_STDARG
12461 int f(char *p, ...)
12462 #else
12463 int f(va_alist)
12464 va_dcl
12465 #endif
12466 {
12467         va_list ap;
12468 #ifndef I_STDARG
12469         char *p;
12470 #endif
12471 #ifdef I_STDARG
12472         va_start(ap,p);
12473 #else
12474         va_start(ap);
12475         p = va_arg(ap, char *);
12476 #endif
12477         va_end(ap);
12478 }
12479 EOP
12480 $cat > varargs <<EOP
12481 $startsh
12482 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12483         echo "true"
12484 else
12485         echo "false"
12486 fi
12487 $rm -f varargs$_o
12488 EOP
12489 chmod +x varargs
12490
12491 : now check which varargs header should be included
12492 echo " "
12493 i_varhdr=''
12494 case "$valstd" in
12495 "$define")
12496         if `./varargs I_STDARG`; then
12497                 val='stdarg.h'
12498         elif `./varargs I_VARARGS`; then
12499                 val='varargs.h'
12500         fi
12501         ;;
12502 *)
12503         if `./varargs I_VARARGS`; then
12504                 val='varargs.h'
12505         fi
12506         ;;
12507 esac
12508 case "$val" in
12509 '')
12510 echo "I could not find the definition for va_dcl... You have problems..." >&4
12511         val="$undef"; set i_stdarg; eval $setvar
12512         val="$undef"; set i_varargs; eval $setvar
12513         ;;
12514 *) 
12515         set i_varhdr
12516         eval $setvar
12517         case "$i_varhdr" in
12518         stdarg.h)
12519                 val="$define"; set i_stdarg; eval $setvar
12520                 val="$undef"; set i_varargs; eval $setvar
12521                 ;;
12522         varargs.h)
12523                 val="$undef"; set i_stdarg; eval $setvar
12524                 val="$define"; set i_varargs; eval $setvar
12525                 ;;
12526         esac
12527         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12528 esac
12529 $rm -f varargs*
12530
12531 : see if stddef is available
12532 set stddef.h i_stddef
12533 eval $inhdr
12534
12535 : see if sys/access.h is available
12536 set sys/access.h i_sysaccess
12537 eval $inhdr
12538
12539 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12540 set sys/filio.h i_sysfilio
12541 eval $inhdr
12542 echo " "
12543 if $test `./findhdr sys/ioctl.h`; then
12544         val="$define"
12545         echo '<sys/ioctl.h> found.' >&4
12546 else
12547         val="$undef"
12548         if $test $i_sysfilio = "$define"; then
12549             echo '<sys/ioctl.h> NOT found.' >&4
12550         else
12551                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12552                 $test $i_termio = "$define" && xxx="termio.h"
12553                 $test $i_termios = "$define" && xxx="termios.h"
12554 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12555         fi
12556 fi
12557 set i_sysioctl
12558 eval $setvar
12559
12560 : see if sys/resource.h has to be included
12561 set sys/resource.h i_sysresrc
12562 eval $inhdr
12563
12564 : see if sys/security.h is available
12565 set sys/security.h i_syssecrt
12566 eval $inhdr
12567
12568 : see if this is a sys/statvfs.h system
12569 set sys/statvfs.h i_sysstatvfs
12570 eval $inhdr
12571
12572 : see if this is a sys/un.h system
12573 set sys/un.h i_sysun
12574 eval $inhdr
12575
12576 : see if this is a syswait system
12577 set sys/wait.h i_syswait
12578 eval $inhdr
12579
12580 : see if this is an utime system
12581 set utime.h i_utime
12582 eval $inhdr
12583
12584 : see if this is a values.h system
12585 set values.h i_values
12586 eval $inhdr
12587
12588 : see if this is a vfork system
12589 case "$d_vfork" in
12590 "$define")
12591         set vfork.h i_vfork
12592         eval $inhdr
12593         ;;
12594 *)
12595         i_vfork="$undef"
12596         ;;
12597 esac
12598
12599 : see if gdbm.h is available
12600 set gdbm.h t_gdbm
12601 eval $inhdr
12602 case "$t_gdbm" in
12603 $define)
12604         : see if gdbm_open exists
12605         set gdbm_open d_gdbm_open
12606         eval $inlibc
12607         case "$d_gdbm_open" in
12608         $undef)
12609                 t_gdbm="$undef"
12610                 echo "We won't be including <gdbm.h>"
12611                 ;;
12612         esac
12613         ;;
12614 esac
12615 val="$t_gdbm"
12616 set i_gdbm
12617 eval $setvar
12618
12619 echo " "
12620 echo "Looking for extensions..." >&4
12621 tdir=`pwd`
12622 cd $rsrc/ext
12623 : If we are using the old config.sh, known_extensions may contain
12624 : old or inaccurate or duplicate values.
12625 known_extensions=''
12626 nonxs_extensions=''
12627 : We do not use find because it might not be available.
12628 : We do not just use MANIFEST because the user may have dropped
12629 : some additional extensions into the source tree and expect them
12630 : to be built.
12631 for xxx in * ; do
12632         case "$xxx" in
12633         DynaLoader|dynaload) ;;
12634         *)      if $test -f $xxx/$xxx.xs; then
12635                         known_extensions="$known_extensions $xxx"
12636                 elif $test -f $xxx/Makefile.PL; then
12637                         nonxs_extensions="$nonxs_extensions $xxx"
12638                 else
12639                         if $test -d $xxx; then
12640                                 # Look for nested extensions, eg. Devel/Dprof.
12641                                 cd $xxx
12642                                 for yyy in * ; do
12643                                 if $test -f $yyy/$yyy.xs; then
12644                                         known_extensions="$known_extensions $xxx/$yyy"
12645                                 elif $test -f $yyy/Makefile.PL; then
12646                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12647                                 fi
12648                                 done
12649                                 cd ..
12650                         fi
12651                 fi 
12652                 ;;
12653         esac
12654 done
12655 set X $nonxs_extensions
12656 shift
12657 nonxs_extensions="$*"
12658 set X $known_extensions
12659 shift
12660 known_extensions="$*"
12661 cd $tdir
12662
12663 : Now see which are supported on this system.
12664 avail_ext=''
12665 for xxx in $known_extensions ; do
12666         case "$xxx" in
12667         DB_File|db_file)
12668                 case "$i_db" in
12669                 $define) avail_ext="$avail_ext $xxx" ;;
12670                 esac
12671                 ;;
12672         GDBM_File|gdbm_fil)
12673                 case "$i_gdbm" in 
12674                 $define) avail_ext="$avail_ext $xxx" ;;
12675                 esac
12676                 ;;
12677         NDBM_File|ndbm_fil)
12678                 case "$i_ndbm" in
12679                 $define) avail_ext="$avail_ext $xxx" ;;
12680                 esac
12681                 ;;
12682         ODBM_File|odbm_fil) 
12683                 case "${i_dbm}${i_rpcsvcdbm}" in
12684                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12685                 esac
12686                 ;;
12687         POSIX|posix)
12688                 case "$useposix" in
12689                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12690                 esac
12691                 ;;
12692         Opcode|opcode)
12693                 case "$useopcode" in
12694                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12695                 esac
12696                 ;;
12697         Socket|socket)
12698                 case "$d_socket" in 
12699                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12700                 esac
12701                 ;;
12702         Thread|thread)
12703                 case "$usethreads" in 
12704                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12705                 esac
12706                 ;;
12707         IPC/SysV|ipc/sysv)
12708                 : XXX Do we need a useipcsysv variable here
12709                 case "${d_msg}${d_sem}${d_shm}" in 
12710                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12711                 esac
12712                 ;;
12713         *)      avail_ext="$avail_ext $xxx"
12714                 ;;
12715         esac
12716 done
12717
12718 set X $avail_ext
12719 shift
12720 avail_ext="$*"
12721
12722 : Now see which nonxs extensions are supported on this system.
12723 : For now assume all are.
12724 nonxs_ext=''
12725 for xxx in $nonxs_extensions ; do
12726         case "$xxx" in
12727         *)      nonxs_ext="$nonxs_ext $xxx"
12728                 ;;
12729         esac
12730 done
12731
12732 set X $nonxs_ext
12733 shift
12734 nonxs_ext="$*"
12735
12736 case $usedl in
12737 $define)
12738         $cat <<EOM
12739 A number of extensions are supplied with $package.  You may choose to
12740 compile these extensions for dynamic loading (the default), compile
12741 them into the $package executable (static loading), or not include
12742 them at all.  Answer "none" to include no extensions.
12743 Note that DynaLoader is always built and need not be mentioned here.
12744
12745 EOM
12746         case "$dynamic_ext" in
12747         '') dflt="$avail_ext" ;;
12748         *)      dflt="$dynamic_ext"
12749                 # Perhaps we are reusing an old out-of-date config.sh.
12750                 case "$hint" in
12751                 previous)
12752                         if test X"$dynamic_ext" != X"$avail_ext"; then
12753                                 $cat <<EOM
12754 NOTICE:  Your previous config.sh list may be incorrect. 
12755 The extensions now available to you are 
12756         ${avail_ext}
12757 but the default list from your previous config.sh is
12758         ${dynamic_ext} 
12759
12760 EOM
12761                         fi
12762                         ;;
12763                 esac
12764                 ;;
12765         esac
12766         case "$dflt" in
12767         '')     dflt=none;;
12768         esac
12769         rp="What extensions do you wish to load dynamically?"
12770         . ./myread
12771         case "$ans" in
12772         none) dynamic_ext=' ' ;;
12773         *) dynamic_ext="$ans" ;;
12774         esac
12775
12776         case "$static_ext" in
12777         '')
12778                 : Exclude those already listed in dynamic linking
12779                 dflt=''
12780                 for xxx in $avail_ext; do
12781                         case " $dynamic_ext " in
12782                         *" $xxx "*) ;;
12783                         *) dflt="$dflt $xxx" ;;
12784                         esac
12785                 done
12786                 set X $dflt
12787                 shift
12788                 dflt="$*"
12789                 ;;
12790         *)  dflt="$static_ext" 
12791                 ;;
12792         esac
12793
12794         case "$dflt" in
12795         '')     dflt=none;;
12796         esac
12797         rp="What extensions do you wish to load statically?"
12798         . ./myread
12799         case "$ans" in
12800         none) static_ext=' ' ;;
12801         *) static_ext="$ans" ;;
12802         esac
12803         ;;
12804 *)
12805         $cat <<EOM
12806 A number of extensions are supplied with $package.  Answer "none" 
12807 to include no extensions. 
12808 Note that DynaLoader is always built and need not be mentioned here.
12809
12810 EOM
12811         case "$static_ext" in
12812         '') dflt="$avail_ext" ;;
12813         *)      dflt="$static_ext"
12814                 # Perhaps we are reusing an old out-of-date config.sh.
12815                 case "$hint" in
12816                 previous)
12817                         if test X"$static_ext" != X"$avail_ext"; then
12818                                 $cat <<EOM
12819 NOTICE:  Your previous config.sh list may be incorrect. 
12820 The extensions now available to you are 
12821         ${avail_ext}
12822 but the default list from your previous config.sh is
12823         ${static_ext} 
12824
12825 EOM
12826                         fi
12827                         ;;
12828                 esac
12829                 ;;
12830         esac
12831         : Exclude those that are not xs extensions
12832         case "$dflt" in
12833         '')     dflt=none;;
12834         esac
12835         rp="What extensions do you wish to include?"
12836         . ./myread
12837         case "$ans" in
12838         none) static_ext=' ' ;;
12839         *) static_ext="$ans" ;;
12840         esac
12841         ;;
12842 esac
12843
12844 set X $dynamic_ext $static_ext $nonxs_ext
12845 shift
12846 extensions="$*"
12847
12848 : Remove build directory name from cppstdin so it can be used from
12849 : either the present location or the final installed location.
12850 echo " "
12851 : Get out of the UU directory to get correct path name.
12852 cd ..
12853 case "$cppstdin" in
12854 `pwd`/cppstdin)
12855         echo "Stripping down cppstdin path name"
12856         cppstdin=cppstdin
12857         ;;
12858 esac
12859 cd UU
12860
12861 : end of configuration questions
12862 echo " "
12863 echo "End of configuration questions."
12864 echo " "
12865
12866 : back to where it started
12867 if test -d ../UU; then
12868         cd ..
12869 fi
12870
12871 : configuration may be patched via a 'config.over' file
12872 if $test -f config.over; then
12873         echo " "
12874         dflt=y
12875         rp='I see a config.over file.  Do you wish to load it?'
12876         . UU/myread
12877         case "$ans" in
12878         n*) echo "OK, I'll ignore it.";;
12879         *)      . ./config.over
12880                 echo "Configuration override changes have been loaded."
12881                 ;;
12882         esac
12883 fi
12884
12885 : in case they want portability, strip down executable paths
12886 case "$d_portable" in
12887 "$define")
12888         echo " "
12889         echo "Stripping down executable paths..." >&4
12890         for file in $loclist $trylist; do
12891                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12892                         eval $file="\$file"
12893                 fi
12894         done
12895         ;;
12896 esac
12897
12898 : create config.sh file
12899 echo " "
12900 echo "Creating config.sh..." >&4
12901 $spitshell <<EOT >config.sh
12902 $startsh
12903 #
12904 # This file was produced by running the Configure script. It holds all the
12905 # definitions figured out by Configure. Should you modify one of these values,
12906 # do not forget to propagate your changes by running "Configure -der". You may
12907 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12908 #
12909
12910 # Package name      : $package
12911 # Source directory  : $src
12912 # Configuration time: $cf_time
12913 # Configured by     : $cf_by
12914 # Target system     : $myuname
12915
12916 Author='$Author'
12917 Date='$Date'
12918 Header='$Header'
12919 Id='$Id'
12920 Locker='$Locker'
12921 Log='$Log'
12922 Mcc='$Mcc'
12923 RCSfile='$RCSfile'
12924 Revision='$Revision'
12925 Source='$Source'
12926 State='$State'
12927 _a='$_a'
12928 _exe='$_exe'
12929 _o='$_o'
12930 afs='$afs'
12931 alignbytes='$alignbytes'
12932 ansi2knr='$ansi2knr'
12933 aphostname='$aphostname'
12934 apiversion='$apiversion'
12935 ar='$ar'
12936 archlib='$archlib'
12937 archlibexp='$archlibexp'
12938 archname64='$archname64'
12939 archname='$archname'
12940 archobjs='$archobjs'
12941 awk='$awk'
12942 baserev='$baserev'
12943 bash='$bash'
12944 bin='$bin'
12945 binexp='$binexp'
12946 bison='$bison'
12947 byacc='$byacc'
12948 byteorder='$byteorder'
12949 c='$c'
12950 castflags='$castflags'
12951 cat='$cat'
12952 cc='$cc'
12953 cccdlflags='$cccdlflags'
12954 ccdlflags='$ccdlflags'
12955 ccflags='$ccflags'
12956 ccsymbols='$ccsymbols'
12957 cf_by='$cf_by'
12958 cf_email='$cf_email'
12959 cf_time='$cf_time'
12960 chgrp='$chgrp'
12961 chmod='$chmod'
12962 chown='$chown'
12963 clocktype='$clocktype'
12964 comm='$comm'
12965 compress='$compress'
12966 contains='$contains'
12967 cp='$cp'
12968 cpio='$cpio'
12969 cpp='$cpp'
12970 cpp_stuff='$cpp_stuff'
12971 cppccsymbols='$cppccsymbols'
12972 cppflags='$cppflags'
12973 cpplast='$cpplast'
12974 cppminus='$cppminus'
12975 cpprun='$cpprun'
12976 cppstdin='$cppstdin'
12977 cppsymbols='$cppsymbols'
12978 crosscompile='$crosscompile'
12979 cryptlib='$cryptlib'
12980 csh='$csh'
12981 d_Gconvert='$d_Gconvert'
12982 d_access='$d_access'
12983 d_accessx='$d_accessx'
12984 d_alarm='$d_alarm'
12985 d_archlib='$d_archlib'
12986 d_attribut='$d_attribut'
12987 d_bcmp='$d_bcmp'
12988 d_bcopy='$d_bcopy'
12989 d_bsd='$d_bsd'
12990 d_bsdgetpgrp='$d_bsdgetpgrp'
12991 d_bsdsetpgrp='$d_bsdsetpgrp'
12992 d_bzero='$d_bzero'
12993 d_casti32='$d_casti32'
12994 d_castneg='$d_castneg'
12995 d_charvspr='$d_charvspr'
12996 d_chown='$d_chown'
12997 d_chroot='$d_chroot'
12998 d_chsize='$d_chsize'
12999 d_closedir='$d_closedir'
13000 d_cmsghdr_s='$d_cmsghdr_s'
13001 d_const='$d_const'
13002 d_crypt='$d_crypt'
13003 d_csh='$d_csh'
13004 d_cuserid='$d_cuserid'
13005 d_dbl_dig='$d_dbl_dig'
13006 d_dbmclose64='$d_dbmclose64'
13007 d_dbminit64='$d_dbminit64'
13008 d_delete64='$d_delete64'
13009 d_difftime='$d_difftime'
13010 d_dirent64_s='$d_dirent64_s'
13011 d_dirnamlen='$d_dirnamlen'
13012 d_dlerror='$d_dlerror'
13013 d_dlopen='$d_dlopen'
13014 d_dlsymun='$d_dlsymun'
13015 d_dosuid='$d_dosuid'
13016 d_drand48proto='$d_drand48proto'
13017 d_dup2='$d_dup2'
13018 d_eaccess='$d_eaccess'
13019 d_endgrent='$d_endgrent'
13020 d_endhent='$d_endhent'
13021 d_endnent='$d_endnent'
13022 d_endpent='$d_endpent'
13023 d_endpwent='$d_endpwent'
13024 d_endsent='$d_endsent'
13025 d_endspent='$d_endspent'
13026 d_eofnblk='$d_eofnblk'
13027 d_eunice='$d_eunice'
13028 d_fchmod='$d_fchmod'
13029 d_fchown='$d_fchown'
13030 d_fcntl='$d_fcntl'
13031 d_fd_macros='$d_fd_macros'
13032 d_fd_set='$d_fd_set'
13033 d_fds_bits='$d_fds_bits'
13034 d_fetch64='$d_fetch64'
13035 d_fgetpos64='$d_fgetpos64'
13036 d_fgetpos='$d_fgetpos'
13037 d_firstkey64='$d_firstkey64'
13038 d_flexfnam='$d_flexfnam'
13039 d_flock64_s='$d_flock64_s'
13040 d_flock='$d_flock'
13041 d_fopen64='$d_fopen64'
13042 d_fork='$d_fork'
13043 d_fpathconf='$d_fpathconf'
13044 d_freopen64='$d_freopen64'
13045 d_fseek64='$d_fseek64'
13046 d_fseeko64='$d_fseeko64'
13047 d_fseeko='$d_fseeko'
13048 d_fsetpos64='$d_fsetpos64'
13049 d_fsetpos='$d_fsetpos'
13050 d_fstat64='$d_fstat64'
13051 d_fstatfs='$d_fstatfs'
13052 d_fstatvfs='$d_fstatvfs'
13053 d_ftell64='$d_ftell64'
13054 d_ftello64='$d_ftello64'
13055 d_ftello='$d_ftello'
13056 d_ftime='$d_ftime'
13057 d_ftruncate64='$d_ftruncate64'
13058 d_getgrent='$d_getgrent'
13059 d_getgrps='$d_getgrps'
13060 d_gethbyaddr='$d_gethbyaddr'
13061 d_gethbyname='$d_gethbyname'
13062 d_gethent='$d_gethent'
13063 d_gethname='$d_gethname'
13064 d_gethostprotos='$d_gethostprotos'
13065 d_getlogin='$d_getlogin'
13066 d_getmntent='$d_getmntent'
13067 d_getnbyaddr='$d_getnbyaddr'
13068 d_getnbyname='$d_getnbyname'
13069 d_getnent='$d_getnent'
13070 d_getnetprotos='$d_getnetprotos'
13071 d_getpbyname='$d_getpbyname'
13072 d_getpbynumber='$d_getpbynumber'
13073 d_getpent='$d_getpent'
13074 d_getpgid='$d_getpgid'
13075 d_getpgrp2='$d_getpgrp2'
13076 d_getpgrp='$d_getpgrp'
13077 d_getppid='$d_getppid'
13078 d_getprior='$d_getprior'
13079 d_getprotoprotos='$d_getprotoprotos'
13080 d_getpwent='$d_getpwent'
13081 d_getsbyname='$d_getsbyname'
13082 d_getsbyport='$d_getsbyport'
13083 d_getsent='$d_getsent'
13084 d_getservprotos='$d_getservprotos'
13085 d_getspent='$d_getspent'
13086 d_getspnam='$d_getspnam'
13087 d_gettimeod='$d_gettimeod'
13088 d_gnulibc='$d_gnulibc'
13089 d_grpasswd='$d_grpasswd'
13090 d_hasmntopt='$d_hasmntopt'
13091 d_htonl='$d_htonl'
13092 d_index='$d_index'
13093 d_inetaton='$d_inetaton'
13094 d_ino64_t='$d_ino64_t'
13095 d_int64t='$d_int64t'
13096 d_iovec_s='$d_iovec_s'
13097 d_isascii='$d_isascii'
13098 d_killpg='$d_killpg'
13099 d_lchown='$d_lchown'
13100 d_link='$d_link'
13101 d_llseek='$d_llseek'
13102 d_locconv='$d_locconv'
13103 d_lockf64='$d_lockf64'
13104 d_lockf='$d_lockf'
13105 d_longdbl='$d_longdbl'
13106 d_longlong='$d_longlong'
13107 d_lseek64='$d_lseek64'
13108 d_lstat64='$d_lstat64'
13109 d_lstat='$d_lstat'
13110 d_madvise='$d_madvise'
13111 d_mblen='$d_mblen'
13112 d_mbstowcs='$d_mbstowcs'
13113 d_mbtowc='$d_mbtowc'
13114 d_memchr='$d_memchr'
13115 d_memcmp='$d_memcmp'
13116 d_memcpy='$d_memcpy'
13117 d_memmove='$d_memmove'
13118 d_memset='$d_memset'
13119 d_mkdir='$d_mkdir'
13120 d_mkfifo='$d_mkfifo'
13121 d_mktime='$d_mktime'
13122 d_mmap='$d_mmap'
13123 d_mprotect='$d_mprotect'
13124 d_msg='$d_msg'
13125 d_msg_ctrunc='$d_msg_ctrunc'
13126 d_msg_dontroute='$d_msg_dontroute'
13127 d_msg_oob='$d_msg_oob'
13128 d_msg_peek='$d_msg_peek'
13129 d_msg_proxy='$d_msg_proxy'
13130 d_msgctl='$d_msgctl'
13131 d_msgget='$d_msgget'
13132 d_msghdr_s='$d_msghdr_s'
13133 d_msgrcv='$d_msgrcv'
13134 d_msgsnd='$d_msgsnd'
13135 d_msync='$d_msync'
13136 d_munmap='$d_munmap'
13137 d_mymalloc='$d_mymalloc'
13138 d_nextkey64='$d_nextkey64'
13139 d_nice='$d_nice'
13140 d_off64_t='$d_off64_t'
13141 d_offset_t='$d_offset_t'
13142 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
13143 d_oldpthreads='$d_oldpthreads'
13144 d_oldsock='$d_oldsock'
13145 d_open3='$d_open3'
13146 d_open64='$d_open64'
13147 d_opendir64='$d_opendir64'
13148 d_pathconf='$d_pathconf'
13149 d_pause='$d_pause'
13150 d_phostname='$d_phostname'
13151 d_pipe='$d_pipe'
13152 d_poll='$d_poll'
13153 d_portable='$d_portable'
13154 d_pthread_yield='$d_pthread_yield'
13155 d_pwage='$d_pwage'
13156 d_pwchange='$d_pwchange'
13157 d_pwclass='$d_pwclass'
13158 d_pwcomment='$d_pwcomment'
13159 d_pwexpire='$d_pwexpire'
13160 d_pwgecos='$d_pwgecos'
13161 d_pwpasswd='$d_pwpasswd'
13162 d_pwquota='$d_pwquota'
13163 d_readdir64='$d_readdir64'
13164 d_readdir='$d_readdir'
13165 d_readlink='$d_readlink'
13166 d_readv='$d_readv'
13167 d_recvmsg='$d_recvmsg'
13168 d_rename='$d_rename'
13169 d_rewinddir='$d_rewinddir'
13170 d_rmdir='$d_rmdir'
13171 d_safebcpy='$d_safebcpy'
13172 d_safemcpy='$d_safemcpy'
13173 d_sanemcmp='$d_sanemcmp'
13174 d_sched_yield='$d_sched_yield'
13175 d_scm_rights='$d_scm_rights'
13176 d_seekdir64='$d_seekdir64'
13177 d_seekdir='$d_seekdir'
13178 d_select='$d_select'
13179 d_sem='$d_sem'
13180 d_semctl='$d_semctl'
13181 d_semctl_semid_ds='$d_semctl_semid_ds'
13182 d_semctl_semun='$d_semctl_semun'
13183 d_semget='$d_semget'
13184 d_semop='$d_semop'
13185 d_sendmsg='$d_sendmsg'
13186 d_setegid='$d_setegid'
13187 d_seteuid='$d_seteuid'
13188 d_setgrent='$d_setgrent'
13189 d_setgrps='$d_setgrps'
13190 d_sethent='$d_sethent'
13191 d_setlinebuf='$d_setlinebuf'
13192 d_setlocale='$d_setlocale'
13193 d_setnent='$d_setnent'
13194 d_setpent='$d_setpent'
13195 d_setpgid='$d_setpgid'
13196 d_setpgrp2='$d_setpgrp2'
13197 d_setpgrp='$d_setpgrp'
13198 d_setprior='$d_setprior'
13199 d_setpwent='$d_setpwent'
13200 d_setregid='$d_setregid'
13201 d_setresgid='$d_setresgid'
13202 d_setresuid='$d_setresuid'
13203 d_setreuid='$d_setreuid'
13204 d_setrgid='$d_setrgid'
13205 d_setruid='$d_setruid'
13206 d_setsent='$d_setsent'
13207 d_setsid='$d_setsid'
13208 d_setspent='$d_setspent'
13209 d_setvbuf='$d_setvbuf'
13210 d_sfio='$d_sfio'
13211 d_shm='$d_shm'
13212 d_shmat='$d_shmat'
13213 d_shmatprototype='$d_shmatprototype'
13214 d_shmctl='$d_shmctl'
13215 d_shmdt='$d_shmdt'
13216 d_shmget='$d_shmget'
13217 d_sigaction='$d_sigaction'
13218 d_sigsetjmp='$d_sigsetjmp'
13219 d_socket='$d_socket'
13220 d_sockpair='$d_sockpair'
13221 d_stat64='$d_stat64'
13222 d_statblks='$d_statblks'
13223 d_statfs='$d_statfs'
13224 d_statfsflags='$d_statfsflags'
13225 d_statvfs='$d_statvfs'
13226 d_stdio_cnt_lval='$d_stdio_cnt_lval'
13227 d_stdio_ptr_lval='$d_stdio_ptr_lval'
13228 d_stdio_stream_array='$d_stdio_stream_array'
13229 d_stdiobase='$d_stdiobase'
13230 d_stdstdio='$d_stdstdio'
13231 d_store64='$d_store64'
13232 d_strchr='$d_strchr'
13233 d_strcoll='$d_strcoll'
13234 d_strctcpy='$d_strctcpy'
13235 d_strerrm='$d_strerrm'
13236 d_strerror='$d_strerror'
13237 d_strtod='$d_strtod'
13238 d_strtol='$d_strtol'
13239 d_strtoul='$d_strtoul'
13240 d_strxfrm='$d_strxfrm'
13241 d_suidsafe='$d_suidsafe'
13242 d_symlink='$d_symlink'
13243 d_syscall='$d_syscall'
13244 d_sysconf='$d_sysconf'
13245 d_sysernlst='$d_sysernlst'
13246 d_syserrlst='$d_syserrlst'
13247 d_system='$d_system'
13248 d_tcgetpgrp='$d_tcgetpgrp'
13249 d_tcsetpgrp='$d_tcsetpgrp'
13250 d_telldir64='$d_telldir64'
13251 d_telldir='$d_telldir'
13252 d_telldirproto='$d_telldirproto'
13253 d_time='$d_time'
13254 d_times='$d_times'
13255 d_tmpfile64='$d_tmpfile64'
13256 d_truncate64='$d_truncate64'
13257 d_truncate='$d_truncate'
13258 d_tzname='$d_tzname'
13259 d_umask='$d_umask'
13260 d_uname='$d_uname'
13261 d_union_semun='$d_union_semun'
13262 d_vfork='$d_vfork'
13263 d_void_closedir='$d_void_closedir'
13264 d_voidsig='$d_voidsig'
13265 d_voidtty='$d_voidtty'
13266 d_volatile='$d_volatile'
13267 d_vprintf='$d_vprintf'
13268 d_wait4='$d_wait4'
13269 d_waitpid='$d_waitpid'
13270 d_wcstombs='$d_wcstombs'
13271 d_wctomb='$d_wctomb'
13272 d_writev='$d_writev'
13273 d_xenix='$d_xenix'
13274 date='$date'
13275 db_hashtype='$db_hashtype'
13276 db_prefixtype='$db_prefixtype'
13277 defvoidused='$defvoidused'
13278 direntrytype='$direntrytype'
13279 dlext='$dlext'
13280 dlsrc='$dlsrc'
13281 doublesize='$doublesize'
13282 drand01='$drand01'
13283 dynamic_ext='$dynamic_ext'
13284 eagain='$eagain'
13285 ebcdic='$ebcdic'
13286 echo='$echo'
13287 egrep='$egrep'
13288 emacs='$emacs'
13289 eunicefix='$eunicefix'
13290 exe_ext='$exe_ext'
13291 expr='$expr'
13292 extensions='$extensions'
13293 fflushNULL='$fflushNULL'
13294 fflushall='$fflushall'
13295 find='$find'
13296 firstmakefile='$firstmakefile'
13297 flex='$flex'
13298 fpostype='$fpostype'
13299 freetype='$freetype'
13300 full_ar='$full_ar'
13301 full_csh='$full_csh'
13302 full_sed='$full_sed'
13303 gccversion='$gccversion'
13304 gidtype='$gidtype'
13305 glibpth='$glibpth'
13306 grep='$grep'
13307 groupcat='$groupcat'
13308 groupstype='$groupstype'
13309 gzip='$gzip'
13310 h_fcntl='$h_fcntl'
13311 h_sysfile='$h_sysfile'
13312 hint='$hint'
13313 hostcat='$hostcat'
13314 huge='$huge'
13315 i_arpainet='$i_arpainet'
13316 i_bsdioctl='$i_bsdioctl'
13317 i_db='$i_db'
13318 i_dbm='$i_dbm'
13319 i_dirent='$i_dirent'
13320 i_dld='$i_dld'
13321 i_dlfcn='$i_dlfcn'
13322 i_fcntl='$i_fcntl'
13323 i_float='$i_float'
13324 i_gdbm='$i_gdbm'
13325 i_grp='$i_grp'
13326 i_inttypes='$i_inttypes'
13327 i_limits='$i_limits'
13328 i_locale='$i_locale'
13329 i_machcthr='$i_machcthr'
13330 i_malloc='$i_malloc'
13331 i_math='$i_math'
13332 i_memory='$i_memory'
13333 i_mntent='$i_mntent'
13334 i_ndbm='$i_ndbm'
13335 i_netdb='$i_netdb'
13336 i_neterrno='$i_neterrno'
13337 i_netinettcp='$i_netinettcp'
13338 i_niin='$i_niin'
13339 i_poll='$i_poll'
13340 i_pthread='$i_pthread'
13341 i_pwd='$i_pwd'
13342 i_rpcsvcdbm='$i_rpcsvcdbm'
13343 i_sfio='$i_sfio'
13344 i_sgtty='$i_sgtty'
13345 i_shadow='$i_shadow'
13346 i_socks='$i_socks'
13347 i_stdarg='$i_stdarg'
13348 i_stddef='$i_stddef'
13349 i_stdlib='$i_stdlib'
13350 i_string='$i_string'
13351 i_sysaccess='$i_sysaccess'
13352 i_sysdir='$i_sysdir'
13353 i_sysfile='$i_sysfile'
13354 i_sysfilio='$i_sysfilio'
13355 i_sysin='$i_sysin'
13356 i_sysioctl='$i_sysioctl'
13357 i_sysmman='$i_sysmman'
13358 i_sysmount='$i_sysmount'
13359 i_sysndir='$i_sysndir'
13360 i_sysparam='$i_sysparam'
13361 i_sysresrc='$i_sysresrc'
13362 i_syssecrt='$i_syssecrt'
13363 i_sysselct='$i_sysselct'
13364 i_syssockio='$i_syssockio'
13365 i_sysstat='$i_sysstat'
13366 i_sysstatvfs='$i_sysstatvfs'
13367 i_systime='$i_systime'
13368 i_systimek='$i_systimek'
13369 i_systimes='$i_systimes'
13370 i_systypes='$i_systypes'
13371 i_sysuio='$i_sysuio'
13372 i_sysun='$i_sysun'
13373 i_syswait='$i_syswait'
13374 i_termio='$i_termio'
13375 i_termios='$i_termios'
13376 i_time='$i_time'
13377 i_unistd='$i_unistd'
13378 i_utime='$i_utime'
13379 i_values='$i_values'
13380 i_varargs='$i_varargs'
13381 i_varhdr='$i_varhdr'
13382 i_vfork='$i_vfork'
13383 ignore_versioned_solibs='$ignore_versioned_solibs'
13384 incpath='$incpath'
13385 inews='$inews'
13386 installarchlib='$installarchlib'
13387 installbin='$installbin'
13388 installman1dir='$installman1dir'
13389 installman3dir='$installman3dir'
13390 installprivlib='$installprivlib'
13391 installscript='$installscript'
13392 installsitearch='$installsitearch'
13393 installsitelib='$installsitelib'
13394 installusrbinperl='$installusrbinperl'
13395 intsize='$intsize'
13396 known_extensions='$known_extensions'
13397 ksh='$ksh'
13398 large='$large'
13399 ld='$ld'
13400 lddlflags='$lddlflags'
13401 ldflags='$ldflags'
13402 less='$less'
13403 lib_ext='$lib_ext'
13404 libc='$libc'
13405 libperl='$libperl'
13406 libpth='$libpth'
13407 libs='$libs'
13408 libswanted='$libswanted'
13409 line='$line'
13410 lint='$lint'
13411 lkflags='$lkflags'
13412 ln='$ln'
13413 lns='$lns'
13414 locincpth='$locincpth'
13415 loclibpth='$loclibpth'
13416 longdblsize='$longdblsize'
13417 longlongsize='$longlongsize'
13418 longsize='$longsize'
13419 lp='$lp'
13420 lpr='$lpr'
13421 ls='$ls'
13422 lseeksize='$lseeksize'
13423 lseektype='$lseektype'
13424 mail='$mail'
13425 mailx='$mailx'
13426 make='$make'
13427 make_set_make='$make_set_make'
13428 mallocobj='$mallocobj'
13429 mallocsrc='$mallocsrc'
13430 malloctype='$malloctype'
13431 man1dir='$man1dir'
13432 man1direxp='$man1direxp'
13433 man1ext='$man1ext'
13434 man3dir='$man3dir'
13435 man3direxp='$man3direxp'
13436 man3ext='$man3ext'
13437 medium='$medium'
13438 mips='$mips'
13439 mips_type='$mips_type'
13440 mkdir='$mkdir'
13441 mmaptype='$mmaptype'
13442 models='$models'
13443 modetype='$modetype'
13444 more='$more'
13445 multiarch='$multiarch'
13446 mv='$mv'
13447 myarchname='$myarchname'
13448 mydomain='$mydomain'
13449 myhostname='$myhostname'
13450 myuname='$myuname'
13451 n='$n'
13452 netdb_hlen_type='$netdb_hlen_type'
13453 netdb_host_type='$netdb_host_type'
13454 netdb_name_type='$netdb_name_type'
13455 netdb_net_type='$netdb_net_type'
13456 nm='$nm'
13457 nm_opt='$nm_opt'
13458 nm_so_opt='$nm_so_opt'
13459 nonxs_ext='$nonxs_ext'
13460 nroff='$nroff'
13461 o_nonblock='$o_nonblock'
13462 obj_ext='$obj_ext'
13463 old_pthread_create_joinable='$old_pthread_create_joinable'
13464 optimize='$optimize'
13465 orderlib='$orderlib'
13466 osname='$osname'
13467 osvers='$osvers'
13468 package='$package'
13469 pager='$pager'
13470 passcat='$passcat'
13471 patchlevel='$patchlevel'
13472 path_sep='$path_sep'
13473 perl='$perl'
13474 perladmin='$perladmin'
13475 perlpath='$perlpath'
13476 pg='$pg'
13477 phostname='$phostname'
13478 pidtype='$pidtype'
13479 plibpth='$plibpth'
13480 pmake='$pmake'
13481 pr='$pr'
13482 prefix='$prefix'
13483 prefixexp='$prefixexp'
13484 privlib='$privlib'
13485 privlibexp='$privlibexp'
13486 prototype='$prototype'
13487 ptrsize='$ptrsize'
13488 randbits='$randbits'
13489 randfunc='$randfunc'
13490 randseedtype='$randseedtype'
13491 ranlib='$ranlib'
13492 rd_nodata='$rd_nodata'
13493 rm='$rm'
13494 rmail='$rmail'
13495 runnm='$runnm'
13496 sched_yield='$sched_yield'
13497 scriptdir='$scriptdir'
13498 scriptdirexp='$scriptdirexp'
13499 sed='$sed'
13500 seedfunc='$seedfunc'
13501 selectminbits='$selectminbits'
13502 selecttype='$selecttype'
13503 sendmail='$sendmail'
13504 sh='$sh'
13505 shar='$shar'
13506 sharpbang='$sharpbang'
13507 shmattype='$shmattype'
13508 shortsize='$shortsize'
13509 shrpenv='$shrpenv'
13510 shsharp='$shsharp'
13511 sig_count='$sig_count'
13512 sig_name='$sig_name'
13513 sig_name_init='$sig_name_init'
13514 sig_num='$sig_num'
13515 sig_num_init='$sig_num_init'
13516 signal_t='$signal_t'
13517 sitearch='$sitearch'
13518 sitearchexp='$sitearchexp'
13519 sitelib='$sitelib'
13520 sitelibexp='$sitelibexp'
13521 sizetype='$sizetype'
13522 sleep='$sleep'
13523 smail='$smail'
13524 small='$small'
13525 so='$so'
13526 sockethdr='$sockethdr'
13527 socketlib='$socketlib'
13528 sort='$sort'
13529 spackage='$spackage'
13530 spitshell='$spitshell'
13531 split='$split'
13532 src='$src'
13533 ssizetype='$ssizetype'
13534 startperl='$startperl'
13535 startsh='$startsh'
13536 static_ext='$static_ext'
13537 stdchar='$stdchar'
13538 stdio_base='$stdio_base'
13539 stdio_bufsiz='$stdio_bufsiz'
13540 stdio_cnt='$stdio_cnt'
13541 stdio_filbuf='$stdio_filbuf'
13542 stdio_ptr='$stdio_ptr'
13543 stdio_stream_array='$stdio_stream_array'
13544 strings='$strings'
13545 submit='$submit'
13546 subversion='$subversion'
13547 sysman='$sysman'
13548 tail='$tail'
13549 tar='$tar'
13550 tbl='$tbl'
13551 tee='$tee'
13552 test='$test'
13553 timeincl='$timeincl'
13554 timetype='$timetype'
13555 touch='$touch'
13556 tr='$tr'
13557 trnl='$trnl'
13558 troff='$troff'
13559 uidtype='$uidtype'
13560 uname='$uname'
13561 uniq='$uniq'
13562 use64bits='$use64bits'
13563 usedl='$usedl'
13564 usemultiplicity='$usemultiplicity'
13565 usemymalloc='$usemymalloc'
13566 usenm='$usenm'
13567 useopcode='$useopcode'
13568 useperlio='$useperlio'
13569 useposix='$useposix'
13570 usesfio='$usesfio'
13571 useshrplib='$useshrplib'
13572 usethreads='$usethreads'
13573 usevfork='$usevfork'
13574 usrinc='$usrinc'
13575 uuname='$uuname'
13576 version='$version'
13577 vi='$vi'
13578 voidflags='$voidflags'
13579 xlibpth='$xlibpth'
13580 zcat='$zcat'
13581 zip='$zip'
13582 EOT
13583
13584 : Add in command line options if available
13585 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13586
13587 : add special variables
13588 $test -f $src/patchlevel.h && \
13589 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13590 echo "CONFIGDOTSH=true" >>config.sh
13591
13592 : propagate old symbols
13593 if $test -f UU/config.sh; then
13594         <UU/config.sh sort | uniq >UU/oldconfig.sh
13595         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13596         sort | uniq -u >UU/oldsyms
13597         set X `cat UU/oldsyms`
13598         shift
13599         case $# in
13600         0) ;;
13601         *)
13602                 cat <<EOM
13603 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13604 EOM
13605                 echo "# Variables propagated from previous config.sh file." >>config.sh
13606                 for sym in `cat UU/oldsyms`; do
13607                         echo "    Propagating $hint variable "'$'"$sym..."
13608                         eval 'tmp="$'"${sym}"'"'
13609                         echo "$tmp" | \
13610                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13611                 done
13612                 ;;
13613         esac
13614 fi
13615
13616 : Finish up by extracting the .SH files
13617 case "$alldone" in
13618 exit)
13619         $rm -rf UU
13620         echo "Done."
13621         exit 0
13622         ;;
13623 cont)
13624         ;;
13625 '')
13626         dflt=''
13627         nostick=true
13628         $cat <<EOM
13629
13630 If you'd like to make any changes to the config.sh file before I begin
13631 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13632
13633 EOM
13634         rp="Press return or use a shell escape to edit config.sh:"
13635         . UU/myread
13636         nostick=''
13637         case "$ans" in
13638         '') ;;
13639         *) : in case they cannot read
13640                 sh 1>&4 -c "$ans";;
13641         esac
13642         ;;
13643 esac
13644
13645 : if this fails, just run all the .SH files by hand
13646 . ./config.sh
13647
13648 echo " "
13649 exec 1>&4
13650 . ./UU/extract
13651
13652 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13653         dflt=y
13654         case "$silent" in
13655         true) ;;
13656         *)
13657                 $cat <<EOM
13658
13659 Now you need to generate make dependencies by running "$make depend".
13660 You might prefer to run it in background: "$make depend > makedepend.out &"
13661 It can take a while, so you might not want to run it right now.
13662
13663 EOM
13664                 ;;
13665         esac
13666         rp="Run $make depend now?"
13667         . UU/myread
13668         case "$ans" in
13669         y*)
13670                 $make depend && echo "Now you must run a $make."
13671                 ;;
13672         *)
13673                 echo "You must run '$make depend' then '$make'."
13674                 ;;
13675         esac
13676 elif test -f [Mm]akefile; then
13677         echo " "
13678         echo "Now you must run a $make."
13679 else
13680         echo "Done."
13681 fi
13682
13683 if $test -f Policy.sh; then
13684     $cat <<EOM
13685
13686 If you compile $package on a different machine or from a different object
13687 directory, copy the Policy.sh file from this object directory to the
13688 new one before you run Configure -- this will help you with most of
13689 the policy defaults.
13690
13691 EOM
13692 fi
13693 if $test -f config.msg; then
13694     echo "Hmm.  I also noted the following information while running:"
13695     echo " "
13696     $cat config.msg >&4
13697     $rm -f config.msg
13698 fi
13699 $rm -f kit*isdone ark*isdone
13700 $rm -rf UU
13701
13702 : End of Configure
13703