15409e76866d0d646de10d35408b4bde7189018f
[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 Sun Jul 25 13:33:52 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 installprefix=''
674 installprefixexp=''
675 installstyle=''
676 installusrbinperl=''
677 intsize=''
678 longsize=''
679 shortsize=''
680 d_dirent64_s=''
681 d_flock64_s=''
682 d_fstat64=''
683 d_ftruncate64=''
684 d_ino64_t=''
685 d_llseek=''
686 d_lockf64=''
687 d_lseek64=''
688 d_lstat64=''
689 d_off64_t=''
690 d_offset_t=''
691 d_open64=''
692 d_opendir64=''
693 d_readdir64=''
694 d_seekdir64=''
695 d_stat64=''
696 d_telldir64=''
697 d_truncate64=''
698 libc=''
699 ldlibpthname=''
700 libperl=''
701 shrpenv=''
702 useshrplib=''
703 glibpth=''
704 libpth=''
705 loclibpth=''
706 plibpth=''
707 xlibpth=''
708 ignore_versioned_solibs=''
709 libs=''
710 lns=''
711 lseeksize=''
712 lseektype=''
713 make_set_make=''
714 d_mymalloc=''
715 freetype=''
716 mallocobj=''
717 mallocsrc=''
718 malloctype=''
719 usemymalloc=''
720 installman1dir=''
721 man1dir=''
722 man1direxp=''
723 man1ext=''
724 installman3dir=''
725 man3dir=''
726 man3direxp=''
727 man3ext=''
728 huge=''
729 large=''
730 medium=''
731 models=''
732 small=''
733 split=''
734 modetype=''
735 multiarch=''
736 mydomain=''
737 myhostname=''
738 phostname=''
739 c=''
740 n=''
741 d_eofnblk=''
742 eagain=''
743 o_nonblock=''
744 rd_nodata=''
745 netdb_hlen_type=''
746 netdb_host_type=''
747 netdb_name_type=''
748 netdb_net_type=''
749 groupcat=''
750 hostcat=''
751 passcat=''
752 orderlib=''
753 ranlib=''
754 package=''
755 spackage=''
756 pager=''
757 apiversion=''
758 patchlevel=''
759 subversion=''
760 version=''
761 perladmin=''
762 perlpath=''
763 pidtype=''
764 prefix=''
765 prefixexp=''
766 installprivlib=''
767 privlib=''
768 privlibexp=''
769 prototype=''
770 ptrsize=''
771 drand01=''
772 randbits=''
773 randfunc=''
774 randseedtype=''
775 seedfunc=''
776 installscript=''
777 scriptdir=''
778 scriptdirexp=''
779 selectminbits=''
780 selecttype=''
781 sh=''
782 sig_count=''
783 sig_name=''
784 sig_name_init=''
785 sig_num=''
786 sig_num_init=''
787 installsitearch=''
788 sitearch=''
789 sitearchexp=''
790 installsitelib=''
791 sitelib=''
792 sitelibexp=''
793 siteprefix=''
794 siteprefixexp=''
795 sizetype=''
796 so=''
797 sharpbang=''
798 shsharp=''
799 spitshell=''
800 src=''
801 ssizetype=''
802 startperl=''
803 startsh=''
804 stdchar=''
805 d_fgetpos64=''
806 d_fopen64=''
807 d_freopen64=''
808 d_fseek64=''
809 d_fseeko64=''
810 d_fsetpos64=''
811 d_ftell64=''
812 d_ftello64=''
813 d_tmpfile64=''
814 d_stdio_stream_array=''
815 stdio_stream_array=''
816 sysman=''
817 trnl=''
818 uidtype=''
819 archname64=''
820 use64bits=''
821 usemultiplicity=''
822 nm_opt=''
823 nm_so_opt=''
824 runnm=''
825 usenm=''
826 useperlio=''
827 usesocks=''
828 d_oldpthreads=''
829 usethreads=''
830 incpath=''
831 mips=''
832 mips_type=''
833 usrinc=''
834 defvoidused=''
835 voidflags=''
836 CONFIG=''
837
838 define='define'
839 undef='undef'
840 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
841 rmlist=''
842
843 : We must find out about Eunice early
844 eunicefix=':'
845 if test -f /etc/unixtovms; then
846         eunicefix=/etc/unixtovms
847 fi
848 if test -f /etc/unixtovms.exe; then
849         eunicefix=/etc/unixtovms.exe
850 fi
851
852 i_whoami=''
853 : Possible local include directories to search.
854 : Set locincpth to "" in a hint file to defeat local include searches.
855 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
856 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
857 :
858 : no include file wanted by default
859 inclwanted=''
860
861 : list of known cpp symbols, sorted alphabetically
862 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
863 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
864 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
865 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
866 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
867 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
868 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
869 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
870 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
871 al="$al VMS Xenix286"
872 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
873 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
874 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
875 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
876 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
877 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
878 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
879 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
880 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
881 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
882 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
883 al="$al __SVR4_2__ __UMAXV__"
884 al="$al ____386BSD____ __alpha __alpha__ __amiga"
885 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
886 al="$al __host_mips__"
887 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
888 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
889 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
890 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
891 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
892 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
893 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
894 al="$al __mc88100 __mc88100__ __mips __mips__"
895 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
896 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
897 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
898 al="$al _host_mips _mips _unix"
899 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
900 al="$al apollo ardent att386 att3b"
901 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
902 al="$al cadmus clipper concurrent convex cray ctix"
903 al="$al dmert encore gcos gcx gimpel gould"
904 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
905 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
906 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
907 al="$al i186 i286 i386 i486 i8086"
908 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
909 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
910 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
911 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
912 al="$al mc88000 mc88100 merlin mert mips mvs n16"
913 al="$al ncl_el ncl_mr"
914 al="$al news1500 news1700 news1800 news1900 news3700"
915 al="$al news700 news800 news900 ns16000 ns32000"
916 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
917 al="$al parisc pc532 pdp11 plexus posix pyr"
918 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
919 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
920 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
921 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
922 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
923 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
924 al="$al xenix z8000"
925
926 : Trailing extension.  Override this in a hint file, if needed.
927 _exe=''
928 : Extra object files, if any, needed on this platform.
929 archobjs=''
930 groupstype=''
931 : change the next line if compiling for Xenix/286 on Xenix/386
932 xlibpth='/usr/lib/386 /lib/386'
933
934 : Possible local library directories to search.
935 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
936 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
937
938 : general looking path for locating libraries
939 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
940 glibpth="$glibpth /lib /usr/lib $xlibpth"
941 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
942 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
943
944 : Private path used by Configure to find libraries.  Its value
945 : is prepended to libpth. This variable takes care of special
946 : machines, like the mips.  Usually, it should be empty.
947 plibpth=''
948
949 : default library list
950 libswanted=''
951 : some systems want to use only the non-versioned libso:s
952 ignore_versioned_solibs=''
953 : full support for void wanted by default
954 defvoidused=15
955
956 : set useposix=false in your hint file to disable the POSIX extension.
957 useposix=true
958 : set useopcode=false in your hint file to disable the Opcode extension.
959 useopcode=true
960 : set usemultiplicity on the Configure command line to enable multiplicity.
961 : set usesocks on the Configure command line to enable socks.
962 : set usethreads on the Configure command line to enable threads.
963 : List of libraries we want.
964 : If anyone needs -lnet, put it in a hint file.
965 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
966 libswanted="$libswanted dld ld sun m rt c cposix posix"
967 libswanted="$libswanted ndir dir crypt sec"
968 libswanted="$libswanted ucb bsd BSD PW x"
969 : We probably want to search /usr/shlib before most other libraries.
970 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
971 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
972 glibpth="/usr/shlib $glibpth"
973 : Do not use vfork unless overridden by a hint file.
974 usevfork=false
975
976 : Find the basic shell for Bourne shell scripts
977 case "$sh" in
978 '')
979         case "$SYSTYPE" in
980         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
981         *) xxx='/bin/sh';;
982         esac
983         if test -f "$xxx"; then
984                 sh="$xxx"
985         else
986                 : Build up a list and do a single loop so we can 'break' out.
987                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
988                 for xxx in sh bash ksh pdksh ash; do
989                         for p in $pth; do
990                                 try="$try ${p}/${xxx}"
991                         done
992                 done
993                 for xxx in $try; do
994                         if test -f "$xxx"; then
995                                 sh="$xxx";
996                                 break
997                         elif test -f "$xxx.exe"; then
998                                 sh="$xxx";
999                                 break
1000                         fi
1001                 done
1002         fi
1003         ;;
1004 esac
1005
1006 case "$sh" in
1007 '')     cat <<EOM >&2
1008 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
1009
1010 Usually it's in /bin/sh.  How did you even get this far?
1011 Please contact me (Perl Maintainers) at perlbug@perl.com and 
1012 we'll try to straighten this all out.
1013 EOM
1014         exit 1
1015         ;;
1016 esac
1017
1018 : see if sh knows # comments
1019 if `$sh -c '#' >/dev/null 2>&1`; then
1020         shsharp=true
1021         spitshell=cat
1022         xcat=/bin/cat
1023         test -f $xcat || xcat=/usr/bin/cat
1024         echo "#!$xcat" >try
1025         $eunicefix try
1026         chmod +x try
1027         ./try > today
1028         if test -s today; then
1029                 sharpbang='#!'
1030         else
1031                 echo "#! $xcat" > try
1032                 $eunicefix try
1033                 chmod +x try
1034                 ./try > today
1035                 if test -s today; then
1036                         sharpbang='#! '
1037                 else
1038                         sharpbang=': use '
1039                 fi
1040         fi
1041 else
1042         echo " "
1043         echo "Your $sh doesn't grok # comments--I will strip them later on."
1044         shsharp=false
1045         cd ..
1046         echo "exec grep -v '^[  ]*#'" >spitshell
1047         chmod +x spitshell
1048         $eunicefix spitshell
1049         spitshell=`pwd`/spitshell
1050         cd UU
1051         echo "I presume that if # doesn't work, #! won't work either!"
1052         sharpbang=': use '
1053 fi
1054 rm -f try today
1055
1056 : figure out how to guarantee sh startup
1057 case "$startsh" in
1058 '') startsh=${sharpbang}${sh} ;;
1059 *)
1060 esac
1061 cat >try <<EOSS
1062 $startsh
1063 set abc
1064 test "$?abc" != 1
1065 EOSS
1066
1067 chmod +x try
1068 $eunicefix try
1069 if ./try; then
1070         : echo "Yup, it does."
1071 else
1072         echo "Hmm... '$startsh' does not guarantee sh startup..."
1073         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1074 fi
1075 rm -f try
1076
1077
1078 : Save command line options in file UU/cmdline.opt for later use in
1079 : generating config.sh.
1080 cat > cmdline.opt <<EOSH
1081 # Configure command line arguments.
1082 config_arg0='$0'
1083 config_args='$*'
1084 config_argc=$#
1085 EOSH
1086 argn=1
1087 for arg in "$@"; do
1088         cat >>cmdline.opt <<EOSH
1089 config_arg$argn='$arg'
1090 EOSH
1091         argn=`expr $argn + 1`
1092 done
1093
1094 : produce awk script to parse command line options
1095 cat >options.awk <<'EOF'
1096 BEGIN {
1097         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1098
1099         len = length(optstr);
1100         for (i = 1; i <= len; i++) {
1101                 c = substr(optstr, i, 1);
1102                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1103                 if (a == ":") {
1104                         arg[c] = 1;
1105                         i++;
1106                 }
1107                 opt[c] = 1;
1108         }
1109 }
1110 {
1111         expect = 0;
1112         str = $0;
1113         if (substr(str, 1, 1) != "-") {
1114                 printf("'%s'\n", str);
1115                 next;
1116         }
1117         len = length($0);
1118         for (i = 2; i <= len; i++) {
1119                 c = substr(str, i, 1);
1120                 if (!opt[c]) {
1121                         printf("-%s\n", substr(str, i));
1122                         next;
1123                 }
1124                 printf("-%s\n", c);
1125                 if (arg[c]) {
1126                         if (i < len)
1127                                 printf("'%s'\n", substr(str, i + 1));
1128                         else
1129                                 expect = 1;
1130                         next;
1131                 }
1132         }
1133 }
1134 END {
1135         if (expect)
1136                 print "?";
1137 }
1138 EOF
1139
1140 : process the command line options
1141 set X `for arg in "$@"; do echo "X$arg"; done |
1142         sed -e s/X// | awk -f options.awk`
1143 eval "set $*"
1144 shift
1145 rm -f options.awk
1146
1147 : set up default values
1148 fastread=''
1149 reuseval=false
1150 config_sh=''
1151 alldone=''
1152 error=''
1153 silent=''
1154 extractsh=''
1155 override=''
1156 knowitall=''
1157 rm -f optdef.sh
1158 cat >optdef.sh <<EOS
1159 $startsh
1160 EOS
1161
1162
1163 : option parsing
1164 while test $# -gt 0; do
1165         case "$1" in
1166         -d) shift; fastread=yes;;
1167         -e) shift; alldone=cont;;
1168         -f)
1169                 shift
1170                 cd ..
1171                 if test -r "$1"; then
1172                         config_sh="$1"
1173                 else
1174                         echo "$me: cannot read config file $1." >&2
1175                         error=true
1176                 fi
1177                 cd UU
1178                 shift;;
1179         -h) shift; error=true;;
1180         -r) shift; reuseval=true;;
1181         -s) shift; silent=true; realsilent=true;;
1182         -E) shift; alldone=exit;;
1183         -K) shift; knowitall=true;;
1184         -O) shift; override=true;;
1185         -S) shift; silent=true; extractsh=true;;
1186         -D)
1187                 shift
1188                 case "$1" in
1189                 *=)
1190                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1191                         echo "$me: ignoring -D $1" >&2
1192                         ;;
1193                 *=*) echo "$1" | \
1194                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1195                 *) echo "$1='define'" >> optdef.sh;;
1196                 esac
1197                 shift
1198                 ;;
1199         -U)
1200                 shift
1201                 case "$1" in
1202                 *=) echo "$1" >> optdef.sh;;
1203                 *=*)
1204                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1205                         echo "$me: ignoring -U $1" >&2
1206                         ;;
1207                 *) echo "$1='undef'" >> optdef.sh;;
1208                 esac
1209                 shift
1210                 ;;
1211         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1212                 exit 0;;
1213         --) break;;
1214         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1215         *) break;;
1216         esac
1217 done
1218
1219 case "$error" in
1220 true)
1221         cat >&2 <<EOM
1222 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1223                  [-U symbol] [-U symbol=]
1224   -d : use defaults for all answers.
1225   -e : go on without questioning past the production of config.sh.
1226   -f : specify an alternate default configuration file.
1227   -h : print this help message and exit (with an error status).
1228   -r : reuse C symbols value if possible (skips costly nm extraction).
1229   -s : silent mode, only echoes questions and essential information.
1230   -D : define symbol to have some value:
1231          -D symbol         symbol gets the value 'define'
1232          -D symbol=value   symbol gets the value 'value'
1233   -E : stop at the end of questions, after having produced config.sh.
1234   -K : do not use unless you know what you are doing.
1235   -O : let -D and -U override definitions from loaded configuration file.
1236   -S : perform variable substitutions on all .SH files (can mix with -f)
1237   -U : undefine symbol:
1238          -U symbol    symbol gets the value 'undef'
1239          -U symbol=   symbol gets completely empty
1240   -V : print version number and exit (with a zero status).
1241 EOM
1242         exit 1
1243         ;;
1244 esac
1245
1246 : Sanity checks
1247 case "$fastread$alldone" in
1248 yescont|yesexit) ;;
1249 *)
1250         if test ! -t 0; then
1251                 echo "Say 'sh Configure', not 'sh <Configure'"
1252                 exit 1
1253         fi
1254         ;;
1255 esac
1256
1257 exec 4>&1
1258 case "$silent" in
1259 true) exec 1>/dev/null;;
1260 esac
1261
1262 : run the defines and the undefines, if any, but leave the file out there...
1263 touch optdef.sh
1264 . ./optdef.sh
1265
1266 : set package name
1267 package=perl5
1268 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1269 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1270 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1271 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1272 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1273 esac
1274
1275 : Some greps do not return status, grrr.
1276 echo "grimblepritz" >grimble
1277 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1278         contains=contains
1279 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1280         contains=grep
1281 else
1282         contains=contains
1283 fi
1284 rm -f grimble
1285 : the following should work in any shell
1286 case "$contains" in
1287 contains*)
1288         echo " "
1289         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1290         cat >contains <<'EOSS'
1291 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1292 EOSS
1293 chmod +x contains
1294 esac
1295
1296 : Find the path to the source tree
1297 case "$src" in
1298 '') case "$0" in
1299     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1300     *)   src='.';;
1301     esac;;
1302 esac
1303 case "$src" in
1304 '')     src=/
1305         rsrc=/
1306         ;;
1307 /*) rsrc="$src";;
1308 *) rsrc="../$src";;
1309 esac
1310 if test -f $rsrc/Configure && \
1311         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1312 then
1313    : found it, so we are ok.
1314 else
1315         rsrc=''
1316         for src in . .. ../.. ../../.. ../../../..; do
1317                 if test -f ../$src/Configure && \
1318                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1319                 then
1320                         rsrc=../$src
1321                         break
1322                 fi
1323         done
1324 fi
1325 case "$rsrc" in
1326 '')
1327         cat <<EOM >&4
1328
1329 Sorry, I can't seem to locate the source dir for $package.  Please start
1330 Configure with an explicit path -- i.e. /some/path/Configure.
1331
1332 EOM
1333         exit 1
1334         ;;
1335 ../.)   rsrc='..';;
1336 *)
1337         echo " "
1338         echo "Sources for $package found in \"$src\"." >&4
1339         ;;
1340 esac
1341
1342 : script used to extract .SH files with variable substitutions
1343 cat >extract <<'EOS'
1344 CONFIGDOTSH=true
1345 echo "Doing variable substitutions on .SH files..."
1346 if test -f $src/MANIFEST; then
1347         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1348 else
1349         echo "(Looking for .SH files under the source directory.)"
1350         set x `(cd $src; find . -name "*.SH" -print)`
1351 fi
1352 shift
1353 case $# in
1354 0) set x `(cd $src; echo *.SH)`; shift;;
1355 esac
1356 if test ! -f $src/$1; then
1357         shift
1358 fi
1359 mkdir_p='
1360 name=$1;
1361 create="";
1362 while test $name; do
1363         if test ! -d "$name"; then
1364                 create="$name $create";
1365                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1366                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1367         else
1368                 name="";
1369         fi;
1370 done;
1371 for file in $create; do
1372         mkdir $file;
1373 done
1374 '
1375 for file in $*; do
1376         case "$src" in
1377         ".")
1378                 case "$file" in
1379                 */*)
1380                         dir=`expr X$file : 'X\(.*\)/'`
1381                         file=`expr X$file : 'X.*/\(.*\)'`
1382                         (cd $dir && . ./$file)
1383                         ;;
1384                 *)
1385                         . ./$file
1386                         ;;
1387                 esac
1388                 ;;
1389         *)
1390                 case "$file" in
1391                 */*)
1392                         dir=`expr X$file : 'X\(.*\)/'`
1393                         file=`expr X$file : 'X.*/\(.*\)'`
1394                         (set x $dir; shift; eval $mkdir_p)
1395                         sh <$src/$dir/$file
1396                         ;;
1397                 *)
1398                         sh <$src/$file
1399                         ;;
1400                 esac
1401                 ;;
1402         esac
1403 done
1404 if test -f $src/config_h.SH; then
1405         if test ! -f config.h; then
1406         : oops, they left it out of MANIFEST, probably, so do it anyway.
1407         . $src/config_h.SH
1408         fi
1409 fi
1410 EOS
1411
1412 : extract files and exit if asked to do so
1413 case "$extractsh" in
1414 true)
1415         case "$realsilent" in
1416         true) ;;
1417         *) exec 1>&4;;
1418         esac
1419         case "$config_sh" in
1420         '') config_sh='config.sh';;
1421         esac
1422         echo " "
1423         echo "Fetching answers from $config_sh..."
1424         cd ..
1425         . $config_sh
1426         test "$override" && . ./optdef.sh
1427         echo " "
1428         . UU/extract
1429         rm -rf UU
1430         echo "Done."
1431         exit 0
1432         ;;
1433 esac
1434
1435 : Eunice requires " " instead of "", can you believe it
1436 echo " "
1437 : Here we go...
1438 echo "Beginning of configuration questions for $package."
1439
1440 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1441
1442 : first determine how to suppress newline on echo command
1443 echo " "
1444 echo "Checking echo to see how to suppress newlines..."
1445 (echo "hi there\c" ; echo " ") >.echotmp
1446 if $contains c .echotmp >/dev/null 2>&1 ; then
1447         echo "...using -n."
1448         n='-n'
1449         c=''
1450 else
1451         cat <<'EOM'
1452 ...using \c
1453 EOM
1454         n=''
1455         c='\c'
1456 fi
1457 echo $n "The star should be here-->$c"
1458 echo '*'
1459 rm -f .echotmp
1460
1461 : Now test for existence of everything in MANIFEST
1462 echo " "
1463 if test -f $rsrc/MANIFEST; then
1464         echo "First let's make sure your kit is complete.  Checking..." >&4
1465         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1466         rm -f missing
1467         tmppwd=`pwd`
1468         for filelist in x??; do
1469                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1470         done
1471         if test -s missing; then
1472                 cat missing >&4
1473                 cat >&4 <<'EOM'
1474
1475 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1476
1477 You have the option of continuing the configuration process, despite the
1478 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1479 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1480 and contact the author (perlbug@perl.com).
1481
1482 EOM
1483                 echo $n "Continue? [n] $c" >&4
1484                 read ans
1485                 case "$ans" in
1486                 y*)
1487                         echo "Continuing..." >&4
1488                         rm -f missing
1489                         ;;
1490                 *)
1491                         echo "ABORTING..." >&4
1492                         kill $$
1493                         ;;
1494                 esac
1495         else
1496                 echo "Looks good..."
1497         fi
1498 else
1499         echo "There is no MANIFEST file.  I hope your kit is complete !"
1500 fi
1501 rm -f missing x??
1502
1503 echo " "
1504 : Find the appropriate value for a newline for tr
1505 if test -n "$DJGPP"; then
1506        trnl='\012'
1507 fi
1508 if test X"$trnl" = X; then
1509         case "`echo foo|tr '\n' x 2>/dev/null`" in
1510         foox) trnl='\n' ;;
1511         esac
1512 fi
1513 if test X"$trnl" = X; then
1514         case "`echo foo|tr '\012' x 2>/dev/null`" in
1515         foox) trnl='\012' ;;
1516         esac
1517 fi
1518 if test X"$trnl" = X; then
1519         cat <<EOM >&2
1520
1521 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1522
1523 EOM
1524         exit 1
1525 fi
1526
1527 : compute the number of columns on the terminal for proper question formatting
1528 case "$COLUMNS" in
1529 '') COLUMNS='80';;
1530 esac
1531
1532 : set up the echo used in my read
1533 myecho="case \"\$xxxm\" in
1534 '') echo $n \"\$rp $c\" >&4;;
1535 *) case \"\$rp\" in
1536         '') echo $n \"[\$xxxm] $c\";;
1537         *)
1538                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1539                         echo \"\$rp\" >&4
1540                         echo $n \"[\$xxxm] $c\" >&4
1541                 else
1542                         echo $n \"\$rp [\$xxxm] $c\" >&4
1543                 fi
1544                 ;;
1545         esac;;
1546 esac"
1547
1548 : now set up to do reads with possible shell escape and default assignment
1549 cat <<EOSC >myread
1550 $startsh
1551 xxxm=\$dflt
1552 $myecho
1553 ans='!'
1554 case "\$fastread" in
1555 yes) case "\$dflt" in
1556         '') ;;
1557         *) ans='';
1558                 case "\$silent-\$rp" in
1559                 true-) ;;
1560                 *) echo " " >&4;;
1561                 esac;;
1562         esac;;
1563 *) case "\$silent" in
1564         true) case "\$rp" in
1565                 '') ans='';;
1566                 esac;;
1567         esac;;
1568 esac
1569 while expr "X\$ans" : "X!" >/dev/null; do
1570         read answ
1571         set x \$xxxm
1572         shift
1573         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1574         case  "\$answ" in
1575         "!")
1576                 sh 1>&4
1577                 echo " "
1578                 $myecho
1579                 ;;
1580         !*)
1581                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1582                 shift
1583                 sh 1>&4 -c "\$*"
1584                 echo " "
1585                 $myecho
1586                 ;;
1587         "\$ans")
1588                 case "\$ans" in
1589                 \\&*)
1590                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1591                         shift
1592                         case "\$1" in
1593                         -d)
1594                                 fastread=yes
1595                                 echo "(OK, I'll run with -d after this question.)" >&4
1596                                 ;;
1597                         -*)
1598                                 echo "*** Sorry, \$1 not supported yet." >&4
1599                                 ;;
1600                         esac
1601                         $myecho
1602                         ans=!
1603                         ;;
1604                 esac;;
1605         *)
1606                 case "\$aok" in
1607                 y)
1608                         echo "*** Substitution done -- please confirm."
1609                         xxxm="\$ans"
1610                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1611                         xxxm="\$ans"
1612                         ans=!
1613                         ;;
1614                 *)
1615                         echo "*** Error -- try again."
1616                         ans=!
1617                         ;;
1618                 esac
1619                 $myecho
1620                 ;;
1621         esac
1622         case "\$ans\$xxxm\$nostick" in
1623         '')
1624                 ans=!
1625                 $myecho
1626                 ;;
1627         esac
1628 done
1629 case "\$ans" in
1630 '') ans="\$xxxm";;
1631 esac
1632 EOSC
1633
1634 : create .config dir to save info across Configure sessions
1635 test -d ../.config || mkdir ../.config
1636 cat >../.config/README <<EOF
1637 This directory created by Configure to save information that should
1638 persist across sessions for $package.
1639
1640 You may safely delete it if you wish.
1641 EOF
1642
1643 : general instructions
1644 needman=true
1645 firsttime=true
1646 user=`(logname) 2>/dev/null`
1647 case "$user" in
1648 '') user=`whoami 2>&1`;;
1649 esac
1650 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1651         firsttime=false
1652         echo " "
1653         rp='Would you like to see the instructions?'
1654         dflt=n
1655         . ./myread
1656         case "$ans" in
1657         [yY]*) ;;
1658         *) needman=false;;
1659         esac
1660 fi
1661 if $needman; then
1662         cat <<EOH
1663
1664 This installation shell script will examine your system and ask you questions
1665 to determine how the perl5 package should be installed. If you get
1666 stuck on a question, you may use a ! shell escape to start a subshell or
1667 execute a command.  Many of the questions will have default answers in square
1668 brackets; typing carriage return will give you the default.
1669
1670 On some of the questions which ask for file or directory names you are allowed
1671 to use the ~name construct to specify the login directory belonging to "name",
1672 even if you don't have a shell which knows about that.  Questions where this is
1673 allowed will be marked "(~name ok)".
1674
1675 EOH
1676         rp=''
1677         dflt='Type carriage return to continue'
1678         . ./myread
1679         cat <<'EOH'
1680
1681 The prompter used in this script allows you to use shell variables and
1682 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1683 in the default answer, as if the default line was a set of arguments given to a
1684 script shell.  This means you may also use $* to repeat the whole default line,
1685 so you do not have to re-type everything to add something to the default.
1686
1687 Everytime there is a substitution, you will have to confirm.  If there is an
1688 error (e.g. an unmatched backtick), the default answer will remain unchanged
1689 and you will be prompted again.
1690
1691 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1692 the questions and use the computed defaults (or the previous answers if there
1693 was already a config.sh file). Type 'Configure -h' for a list of options.
1694 You may also start interactively and then answer '& -d' at any prompt to turn
1695 on the non-interactive behaviour for the remainder of the execution.
1696
1697 EOH
1698         . ./myread
1699         cat <<EOH
1700
1701 Much effort has been expended to ensure that this shell script will run on any
1702 Unix system.  If despite that it blows up on yours, your best bet is to edit
1703 Configure and run it again.  If you can't run Configure for some reason,
1704 you'll have to generate a config.sh file by hand.  Whatever problems you
1705 have, let me (perlbug@perl.com) know how I blew it.
1706
1707 This installation script affects things in two ways:
1708
1709 1) it may do direct variable substitutions on some of the files included
1710    in this kit.
1711 2) it builds a config.h file for inclusion in C programs.  You may edit
1712    any of these files as the need arises after running this script.
1713
1714 If you make a mistake on a question, there is no easy way to back up to it
1715 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1716 files.  Configure will offer to let you do this before it runs the SH files.
1717
1718 EOH
1719         dflt='Type carriage return to continue'
1720         . ./myread
1721         case "$firsttime" in
1722         true) echo $user >>../.config/instruct;;
1723         esac
1724 fi
1725
1726 : find out where common programs are
1727 echo " "
1728 echo "Locating common programs..." >&4
1729 cat <<EOSC >loc
1730 $startsh
1731 case \$# in
1732 0) exit 1;;
1733 esac
1734 thing=\$1
1735 shift
1736 dflt=\$1
1737 shift
1738 for dir in \$*; do
1739         case "\$thing" in
1740         .)
1741         if test -d \$dir/\$thing; then
1742                 echo \$dir
1743                 exit 0
1744         fi
1745         ;;
1746         *)
1747         for thisthing in \$dir/\$thing; do
1748                 : just loop through to pick last item
1749         done
1750         if test -f \$thisthing; then
1751                 echo \$thisthing
1752                 exit 0
1753         elif test -f \$dir/\$thing.exe; then
1754                 if test -n "$DJGPP"; then
1755                         echo \$dir/\$thing.exe
1756                 else
1757                         : on Eunice apparently
1758                         echo \$dir/\$thing
1759                 fi
1760                 exit 0
1761         fi
1762         ;;
1763         esac
1764 done
1765 echo \$dflt
1766 exit 1
1767 EOSC
1768 chmod +x loc
1769 $eunicefix loc
1770 loclist="
1771 awk
1772 cat
1773 comm
1774 cp
1775 echo
1776 expr
1777 grep
1778 ls
1779 make
1780 mkdir
1781 rm
1782 sed
1783 sort
1784 touch
1785 tr
1786 uniq
1787 "
1788 trylist="
1789 Mcc
1790 ar
1791 byacc
1792 cpp
1793 csh
1794 date
1795 egrep
1796 gzip
1797 less
1798 ln
1799 more
1800 nm
1801 nroff
1802 pg
1803 test
1804 uname
1805 zip
1806 "
1807 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1808 pth="$pth /lib /usr/lib"
1809 for file in $loclist; do
1810         eval xxx=\$$file
1811         case "$xxx" in
1812         /*|?:[\\/]*)
1813                 if test -f "$xxx"; then
1814                         : ok
1815                 else
1816                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1817                         xxx=`./loc $file $file $pth`
1818                 fi
1819                 ;;
1820         '') xxx=`./loc $file $file $pth`;;
1821         *) xxx=`./loc $xxx $xxx $pth`;;
1822         esac
1823         eval $file=$xxx
1824         eval _$file=$xxx
1825         case "$xxx" in
1826         /*)
1827                 echo $file is in $xxx.
1828                 ;;
1829         ?:[\\/]*)
1830                 echo $file is in $xxx.
1831                 ;;
1832         *)
1833                 echo "I don't know where '$file' is, and my life depends on it." >&4
1834                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1835                 exit 1
1836                 ;;
1837         esac
1838 done
1839 echo " "
1840 echo "Don't worry if any of the following aren't found..."
1841 say=offhand
1842 for file in $trylist; do
1843         eval xxx=\$$file
1844         case "$xxx" in
1845         /*|?:[\\/]*)
1846                 if test -f "$xxx"; then
1847                         : ok
1848                 else
1849                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1850                         xxx=`./loc $file $file $pth`
1851                 fi
1852                 ;;
1853         '') xxx=`./loc $file $file $pth`;;
1854         *) xxx=`./loc $xxx $xxx $pth`;;
1855         esac
1856         eval $file=$xxx
1857         eval _$file=$xxx
1858         case "$xxx" in
1859         /*)
1860                 echo $file is in $xxx.
1861                 ;;
1862         ?:[\\/]*)
1863                 echo $file is in $xxx.
1864                 ;;
1865         *)
1866                 echo "I don't see $file out there, $say."
1867                 say=either
1868                 ;;
1869         esac
1870 done
1871 case "$egrep" in
1872 egrep)
1873         echo "Substituting grep for egrep."
1874         egrep=$grep
1875         ;;
1876 esac
1877 case "$ln" in
1878 ln)
1879         echo "Substituting cp for ln."
1880         ln=$cp
1881         ;;
1882 esac
1883 case "$test" in
1884 test)
1885         echo "Hopefully test is built into your sh."
1886         ;;
1887 *)
1888         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1889                 echo "Using the test built into your sh."
1890                 test=test
1891                 _test=test
1892         fi
1893         ;;
1894 esac
1895 case "$echo" in
1896 echo)
1897         echo "Hopefully echo is built into your sh."
1898         ;;
1899 '') ;;
1900 *)
1901         echo " "
1902 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1903         $echo $n "hi there$c" >foo1
1904         echo $n "hi there$c" >foo2
1905         if cmp foo1 foo2 >/dev/null 2>&1; then
1906                 echo "They are compatible.  In fact, they may be identical."
1907         else
1908                 case "$n" in
1909                 '-n') n='' c='\c';;
1910                 *) n='-n' c='';;
1911                 esac
1912                 cat <<FOO
1913 They are not compatible!  You are probably running ksh on a non-USG system.
1914 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1915 have echo built in and we may have to run some Bourne shell scripts.  That
1916 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1917
1918 FOO
1919                 $echo $n "The star should be here-->$c"
1920                 $echo "*"
1921         fi
1922         $rm -f foo1 foo2
1923         ;;
1924 esac
1925
1926 : determine whether symbolic links are supported
1927 echo " "
1928 $touch blurfl
1929 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1930         echo "Symbolic links are supported." >&4
1931         lns="$ln -s"
1932 else
1933         echo "Symbolic links are NOT supported." >&4
1934         lns="$ln"
1935 fi
1936 $rm -f blurfl sym
1937
1938 : see whether [:lower:] and [:upper:] are supported character classes
1939 echo " "
1940 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1941 ABYZ)
1942         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1943         up='[:upper:]'
1944         low='[:lower:]'
1945         ;;
1946 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1947         # (0xc9 and 0xd1), therefore that is a nice testing point.
1948         if test "X$up" = X -o "X$low" = X; then
1949             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1950             ij) up='[A-Z]'
1951                 low='[a-z]'
1952                 ;;
1953             esac
1954         fi
1955         if test "X$up" = X -o "X$low" = X; then
1956             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1957             ij) up='A-Z'
1958                 low='a-z'
1959                 ;;
1960             esac
1961         fi
1962         if test "X$up" = X -o "X$low" = X; then
1963             case "`echo IJ | od -x 2>/dev/null`" in
1964             *C9D1*|*c9d1*)
1965                 echo "Hey, this might be EBCDIC." >&4
1966                 if test "X$up" = X -o "X$low" = X; then
1967                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1968                     ij) up='[A-IJ-RS-Z]'
1969                         low='[a-ij-rs-z]'
1970                         ;;
1971                     esac
1972                 fi
1973                 if test "X$up" = X -o "X$low" = X; then
1974                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1975                     ij) up='A-IJ-RS-Z'
1976                         low='a-ij-rs-z'
1977                         ;;
1978                     esac
1979                 fi
1980                 ;;
1981             esac
1982         fi
1983 esac
1984 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1985 ij)
1986     echo "Using $up and $low to convert case." >&4
1987     ;;
1988 *)
1989     echo "I don't know how to translate letters from upper to lower case." >&4
1990     echo "Your tr is not acting any way I know of." >&4
1991     exit 1
1992     ;;
1993 esac
1994 : set up the translation script tr, must be called with ./tr of course
1995 cat >tr <<EOSC
1996 $startsh
1997 case "\$1\$2" in
1998 '[A-Z][a-z]') exec $tr '$up' '$low';;
1999 '[a-z][A-Z]') exec $tr '$low' '$up';;
2000 esac
2001 exec $tr "\$@"
2002 EOSC
2003 chmod +x tr
2004 $eunicefix tr
2005
2006 : Try to determine whether config.sh was made on this system
2007 case "$config_sh" in
2008 '')
2009 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
2010 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
2011 # because the A-Z/a-z are not consecutive.
2012 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
2013         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
2014 newmyuname="$myuname"
2015 dflt=n
2016 case "$knowitall" in
2017 '')
2018         if test -f ../config.sh; then
2019                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
2020                         eval "`grep myuname= ../config.sh`"
2021                 fi
2022                 if test "X$myuname" = "X$newmyuname"; then
2023                         dflt=y
2024                 fi
2025         fi
2026         ;;
2027 *) dflt=y;;
2028 esac
2029
2030 : Get old answers from old config file if Configure was run on the
2031 : same system, otherwise use the hints.
2032 hint=default
2033 cd ..
2034 if test -f config.sh; then
2035         echo " "
2036         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2037         . UU/myread
2038         case "$ans" in
2039         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2040         *)  echo "Fetching default answers from your old config.sh file..." >&4
2041                 tmp_n="$n"
2042                 tmp_c="$c"
2043                 tmp_sh="$sh"
2044                 . ./config.sh
2045                 cp config.sh UU
2046                 n="$tmp_n"
2047                 c="$tmp_c"
2048                 : Older versions did not always set $sh.  Catch re-use of such
2049                 : an old config.sh.
2050                 case "$sh" in
2051                 '') sh="$tmp_sh" ;;
2052                 esac
2053                 hint=previous
2054                 ;;
2055         esac
2056 fi
2057 if test ! -f config.sh; then
2058         $cat <<EOM
2059
2060 First time through, eh?  I have some defaults handy for some systems
2061 that need some extra help getting the Configure answers right:
2062
2063 EOM
2064         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2065         dflt=''
2066         : Half the following guesses are probably wrong... If you have better
2067         : tests or hints, please send them to perlbug@perl.com
2068         : The metaconfig authors would also appreciate a copy...
2069         $test -f /irix && osname=irix
2070         $test -f /xenix && osname=sco_xenix
2071         $test -f /dynix && osname=dynix
2072         $test -f /dnix && osname=dnix
2073         $test -f /lynx.os && osname=lynxos
2074         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2075         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2076         $test -f /bin/mips && /bin/mips && osname=mips
2077         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2078                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2079         $test -d /usr/apollo/bin && osname=apollo
2080         $test -f /etc/saf/_sactab && osname=svr4
2081         $test -d /usr/include/minix && osname=minix
2082         if $test -d /MachTen -o -d /MachTen_Folder; then
2083                 osname=machten
2084                 if $test -x /sbin/version; then
2085                         osvers=`/sbin/version | $awk '{print $2}' |
2086                         $sed -e 's/[A-Za-z]$//'`
2087                 elif $test -x /usr/etc/version; then
2088                         osvers=`/usr/etc/version | $awk '{print $2}' |
2089                         $sed -e 's/[A-Za-z]$//'`
2090                 else
2091                         osvers="$2.$3"
2092                 fi
2093         fi
2094        $test -f /sys/posix.dll &&
2095                $test -f /usr/bin/what &&
2096                set X `/usr/bin/what /sys/posix.dll` &&
2097                $test "$3" = UWIN &&
2098                osname=uwin &&
2099                osvers="$5"
2100         if $test -f $uname; then
2101                 set X $myuname
2102                 shift
2103
2104                 case "$5" in
2105                 fps*) osname=fps ;;
2106                 mips*)
2107                         case "$4" in
2108                         umips) osname=umips ;;
2109                         *) osname=mips ;;
2110                         esac;;
2111                 [23]100) osname=mips ;;
2112                 next*) osname=next ;;
2113                 i386*)
2114                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2115                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2116                                 osname='sco'
2117                                 osvers=$tmp
2118                         elif $test -f /etc/kconfig; then
2119                                 osname=isc
2120                                 if test "$lns" = "$ln -s"; then
2121                                         osvers=4
2122                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2123                                         osvers=3
2124                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2125                                         osvers=2
2126                                 fi
2127                         fi
2128                         tmp=''
2129                         ;;
2130                 pc*)
2131                         if test -n "$DJGPP"; then
2132                                 osname=dos
2133                                 osvers=djgpp
2134                         fi
2135                         ;;
2136                 esac
2137
2138                 case "$1" in
2139                 aix) osname=aix
2140                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2141                         case "$tmp" in
2142                         'not found') osvers="$4"."$3" ;;
2143                         '<3240'|'<>3240') osvers=3.2.0 ;;
2144                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2145                         '=3250'|'>3250') osvers=3.2.5 ;;
2146                         *) osvers=$tmp;;
2147                         esac
2148                         ;;
2149                 *dc.osx) osname=dcosx
2150                         osvers="$3"
2151                         ;;
2152                 dnix) osname=dnix
2153                         osvers="$3"
2154                         ;;
2155                 domainos) osname=apollo
2156                         osvers="$3"
2157                         ;;
2158                 dgux) osname=dgux 
2159                         osvers="$3"
2160                         ;;
2161                 dynixptx*) osname=dynixptx
2162                         osvers=`echo "$4"|sed 's/^v//'`
2163                         ;;
2164                 freebsd) osname=freebsd 
2165                         osvers="$3" ;;
2166                 genix) osname=genix ;;
2167                 hp*) osname=hpux 
2168                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2169                         ;;
2170                 irix*) osname=irix
2171                         case "$3" in
2172                         4*) osvers=4 ;;
2173                         5*) osvers=5 ;;
2174                         *)      osvers="$3" ;;
2175                         esac
2176                         ;;
2177                 linux) osname=linux
2178                         case "$3" in
2179                         *)      osvers="$3" ;;
2180                         esac
2181                         ;;
2182                 MiNT) osname=mint
2183                         ;;
2184                 netbsd*) osname=netbsd
2185                         osvers="$3"
2186                         ;;
2187                 news-os) osvers="$3"
2188                         case "$3" in
2189                         4*) osname=newsos4 ;;
2190                         *) osname=newsos ;;
2191                         esac
2192                         ;;
2193                 bsd386) osname=bsd386
2194                         osvers=`$uname -r`
2195                         ;;
2196                 POSIX-BC | posix-bc ) osname=posix-bc
2197                         osvers="$3"
2198                         ;;
2199                 powerux | power_ux | powermax_os | powermaxos | \
2200                 powerunix | power_unix) osname=powerux
2201                         osvers="$3"
2202                         ;;
2203                 next*) osname=next ;;
2204                 solaris) osname=solaris
2205                         case "$3" in
2206                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2207                         *)      osvers="$3" ;;
2208                         esac
2209                         ;;
2210                 sunos) osname=sunos
2211                         case "$3" in
2212                         5*) osname=solaris
2213                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2214                         *)      osvers="$3" ;;
2215                         esac
2216                         ;;
2217                 titanos) osname=titanos
2218                         case "$3" in
2219                         1*) osvers=1 ;;
2220                         2*) osvers=2 ;;
2221                         3*) osvers=3 ;;
2222                         4*) osvers=4 ;;
2223                         *)      osvers="$3" ;;
2224                         esac
2225                         ;;
2226                 ultrix) osname=ultrix
2227                         osvers="$3"
2228                         ;;
2229                 osf1|mls+)      case "$5" in
2230                                 alpha)
2231                                         osname=dec_osf
2232                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2233                                         ;;
2234                         hp*)    osname=hp_osf1  ;;
2235                         mips)   osname=mips_osf1 ;;
2236                         esac
2237                         ;;
2238                 uts) osname=uts 
2239                         osvers="$3"
2240                         ;;
2241                 qnx) osname=qnx
2242                         osvers="$4"
2243                         ;;
2244                 $2) case "$osname" in
2245                         *isc*) ;;
2246                         *freebsd*) ;;
2247                         svr*)
2248                                 : svr4.x or possibly later
2249                                 case "svr$3" in 
2250                                 ${osname}*)
2251                                         osname=svr$3
2252                                         osvers=$4
2253                                         ;;
2254                                 esac
2255                                 case "$osname" in
2256                                 svr4.0)
2257                                         : Check for ESIX
2258                                         if test -f /stand/boot ; then
2259                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2260                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2261                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2262                                                         if test -n "$isesix"; then
2263                                                                 osname=esix4
2264                                                         fi
2265                                                 fi
2266                                         fi
2267                                         ;;
2268                                 esac
2269                                 ;;
2270                         *)      if test -f /etc/systemid; then
2271                                         osname=sco
2272                                         set `echo $3 | $sed 's/\./ /g'` $4
2273                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2274                                                 osvers=$1.$2.$3
2275                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2276                                                 osvers=$1.$2
2277                                         elif $test -f $src/hints/sco_$1.sh; then
2278                                                 osvers=$1
2279                                         fi
2280                                 else
2281                                         case "$osname" in
2282                                         '') : Still unknown.  Probably a generic Sys V.
2283                                                 osname="sysv"
2284                                                 osvers="$3"
2285                                                 ;;
2286                                         esac
2287                                 fi
2288                                 ;;
2289                         esac
2290                         ;;
2291                 *)      case "$osname" in
2292                         '') : Still unknown.  Probably a generic BSD.
2293                                 osname="$1"
2294                                 osvers="$3"
2295                                 ;;
2296                         esac
2297                         ;;
2298                 esac
2299         else
2300                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2301                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2302                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2303                                 osname=news_os
2304                         fi
2305                         $rm -f UU/kernel.what
2306                 elif test -d c:/.; then
2307                         set X $myuname
2308                         osname=os2
2309                         osvers="$5"
2310                 fi
2311         fi
2312         
2313         : Now look for a hint file osname_osvers, unless one has been
2314         : specified already.
2315         case "$hintfile" in
2316         ''|' ')
2317                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2318                 : Also try without trailing minor version numbers.
2319                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2320                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2321                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2322                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2323                 case "$file" in
2324                 '') dflt=none ;;
2325                 *)  case "$osvers" in
2326                         '') dflt=$file
2327                                 ;;
2328                         *)  if $test -f $src/hints/$file.sh ; then
2329                                         dflt=$file
2330                                 elif $test -f $src/hints/$xfile.sh ; then
2331                                         dflt=$xfile
2332                                 elif $test -f $src/hints/$xxfile.sh ; then
2333                                         dflt=$xxfile
2334                                 elif $test -f $src/hints/$xxxfile.sh ; then
2335                                         dflt=$xxxfile
2336                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2337                                         dflt=$xxxxfile
2338                                 elif $test -f "$src/hints/${osname}.sh" ; then
2339                                         dflt="${osname}"
2340                                 else
2341                                         dflt=none
2342                                 fi
2343                                 ;;
2344                         esac
2345                         ;;
2346                 esac
2347                 if $test -f Policy.sh ; then
2348                         case "$dflt" in
2349                         *Policy*) ;;
2350                         none) dflt="Policy" ;;
2351                         *) dflt="Policy $dflt" ;;
2352                         esac
2353                 fi
2354                 ;;
2355         *)
2356                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2357                 ;;
2358         esac
2359
2360         if $test -f Policy.sh ; then
2361                 $cat <<EOM
2362
2363 There's also a Policy hint file available, which should make the
2364 site-specific (policy) questions easier to answer.
2365 EOM
2366
2367         fi
2368
2369         $cat <<EOM
2370
2371 You may give one or more space-separated answers, or "none" if appropriate.
2372 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2373 is a good thing.  DO NOT give a wrong version.
2374
2375 EOM
2376
2377         rp="Which of these apply, if any?"
2378         . UU/myread
2379         tans=$ans
2380         for file in $tans; do
2381                 if $test X$file = XPolicy -a -f Policy.sh; then
2382                         . Policy.sh
2383                         $cat Policy.sh >> UU/config.sh
2384                 elif $test -f $src/hints/$file.sh; then
2385                         . $src/hints/$file.sh
2386                         $cat $src/hints/$file.sh >> UU/config.sh
2387                 elif $test X$tans = X -o X$tans = Xnone ; then
2388                         : nothing
2389                 else
2390                         : Give one chance to correct a possible typo.
2391                         echo "$file.sh does not exist"
2392                         dflt=$file
2393                         rp="hint to use instead?"
2394                         . UU/myread
2395                         for file in $ans; do
2396                                 if $test -f "$src/hints/$file.sh"; then
2397                                         . $src/hints/$file.sh
2398                                         $cat $src/hints/$file.sh >> UU/config.sh
2399                                 elif $test X$ans = X -o X$ans = Xnone ; then
2400                                         : nothing
2401                                 else
2402                                         echo "$file.sh does not exist -- ignored."
2403                                 fi
2404                         done
2405                 fi
2406         done
2407
2408         hint=recommended
2409         : Remember our hint file for later.
2410         if $test -f "$src/hints/$file.sh" ; then
2411                 hintfile="$file"
2412         else
2413                 hintfile=''
2414         fi
2415 fi
2416 cd UU
2417 ;;
2418 *)
2419         echo " "
2420         echo "Fetching default answers from $config_sh..." >&4
2421         tmp_n="$n"
2422         tmp_c="$c"
2423         cd ..
2424         cp $config_sh config.sh 2>/dev/null
2425         chmod +w config.sh
2426         . ./config.sh
2427         cd UU
2428         cp ../config.sh .
2429         n="$tmp_n"
2430         c="$tmp_c"
2431         hint=previous
2432         ;;
2433 esac
2434 test "$override" && . ./optdef.sh
2435 myuname="$newmyuname"
2436
2437 : Restore computed paths
2438 for file in $loclist $trylist; do
2439         eval $file="\$_$file"
2440 done
2441
2442 cat << EOM
2443
2444 Configure uses the operating system name and version to set some defaults.
2445 The default value is probably right if the name rings a bell. Otherwise,
2446 since spelling matters for me, either accept the default or answer "none"
2447 to leave it blank.
2448
2449 EOM
2450 case "$osname" in
2451         ''|' ')
2452                 case "$hintfile" in
2453                 ''|' '|none) dflt=none ;;
2454                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2455                 esac
2456                 ;;
2457         *) dflt="$osname" ;;
2458 esac
2459 rp="Operating system name?"
2460 . ./myread
2461 case "$ans" in
2462 none)  osname='' ;;
2463 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2464 esac
2465 echo " "
2466 case "$osvers" in
2467         ''|' ')
2468                 case "$hintfile" in
2469                 ''|' '|none) dflt=none ;;
2470                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2471                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2472                         case "$dflt" in
2473                         ''|' ') dflt=none ;;
2474                         esac
2475                         ;;
2476                 esac
2477                 ;;
2478         *) dflt="$osvers" ;;
2479 esac
2480 rp="Operating system version?"
2481 . ./myread
2482 case "$ans" in
2483 none)  osvers='' ;;
2484 *) osvers="$ans" ;;
2485 esac
2486
2487 : who configured the system
2488 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2489 cf_by=`(logname) 2>/dev/null`
2490 case "$cf_by" in
2491 "")
2492         cf_by=`(whoami) 2>/dev/null`
2493         case "$cf_by" in
2494         "") cf_by=unknown ;;
2495         esac ;;
2496 esac
2497
2498 : set up the script used to warn in case of inconsistency
2499 cat <<EOS >whoa
2500 $startsh
2501 EOS
2502 cat <<'EOSC' >>whoa
2503 dflt=y
2504 echo " "
2505 echo "*** WHOA THERE!!! ***" >&4
2506 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2507 rp="    Keep the $hint value?"
2508 . ./myread
2509 case "$ans" in
2510 y) td=$was; tu=$was;;
2511 esac
2512 EOSC
2513
2514 : function used to set $1 to $val
2515 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2516 case "$val$was" in
2517 $define$undef) . ./whoa; eval "$var=\$td";;
2518 $undef$define) . ./whoa; eval "$var=\$tu";;
2519 *) eval "$var=$val";;
2520 esac'
2521
2522 cat <<EOM
2523
2524 Perl can be built to take advantage of threads, on some systems.
2525 To do so, Configure must be run with -Dusethreads.
2526
2527 Note that threading is a highly experimental feature, and
2528 some known race conditions still remain.  If you choose to try
2529 it, be very sure to not actually deploy it for production
2530 purposes.  README.threads has more details, and is required
2531 reading if you enable threads.
2532 EOM
2533 case "$usethreads" in
2534 $define|true|[yY]*)     dflt='y';;
2535 *) dflt='n';;
2536 esac
2537 rp='Build a threading Perl?'
2538 . ./myread
2539 case "$ans" in
2540 y|Y)    val="$define" ;;     
2541 *)      val="$undef" ;;
2542 esac
2543 set usethreads
2544 eval $setvar 
2545
2546 case "$d_oldpthreads" in
2547 '')     : Configure tests would be welcome here.  For now, assume undef.
2548         val="$undef" ;;
2549 *)      val="$d_oldpthreads" ;;
2550 esac
2551 set d_oldpthreads
2552 eval $setvar
2553
2554
2555 case "$usethreads" in
2556 "$define"|true|[yY]*)
2557 : Look for a hint-file generated 'call-back-unit'.  If the
2558 : user has specified that a threading perl is to be built,
2559 : we may need to set or change some other defaults.
2560         if $test -f usethreads.cbu; then
2561                 . ./usethreads.cbu
2562         fi
2563         case "$osname" in
2564         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2565                 # Known thread-capable platforms.
2566                 ;;
2567         *)
2568                 cat >&4 <<EOM
2569 $osname is not known to support threads.
2570 Please let perlbug@perl.com know how to do that.
2571
2572 Cannot continue, aborting.
2573 EOM
2574                 exit 1
2575         ;;
2576         esac # $osname
2577     ;;
2578 esac # $usethreads
2579
2580 cat <<EOM
2581
2582 Perl can be built so that multiple Perl interpreters can coexist
2583 within the same Perl executable.  To do so, Configure must be run with
2584 -Dusemultiplicity.
2585
2586 Normally you do not need this and you should answer no.
2587
2588 EOM
2589 case "$usemultiplicity" in
2590 $define|true|[yY]*)     dflt='y';;
2591 *) dflt='n';;
2592 esac
2593 rp='Build Perl for multiplicity?'
2594 . ./myread
2595 case "$ans" in
2596 y|Y)    val="$define" ;;     
2597 *)      val="$undef" ;;
2598 esac
2599 set usemultiplicity
2600 eval $setvar 
2601
2602 cat <<EOM
2603
2604 Perl can be built to take advantage of explicit 64-bit interfaces,
2605 on some systems.  To do so, Configure must be run with -Duse64bits.
2606
2607 If this doesn't make any sense to you, just accept the default 'n'.
2608 EOM
2609 case "$use64bits" in
2610 $define|true|[yY]*)     dflt='y';;
2611 *) dflt='n';;
2612 esac
2613 rp='Try to use explicit 64-bit interfaces, if available?'
2614 . ./myread
2615 case "$ans" in
2616 y|Y) 
2617         val="$define"
2618         ;;     
2619 *)      
2620         val="$undef"
2621         ;;
2622 esac
2623 set use64bits
2624 eval $setvar
2625
2626 case "$archname64" in
2627 '') archname64='' ;;    # not a typo
2628 esac
2629
2630 case "$use64bits" in
2631 "$define"|true|[yY]*)
2632 : Look for a hint-file generated 'call-back-unit'.  If the
2633 : user has specified that a 64 bit perl is to be built,
2634 : we may need to set or change some other defaults.
2635         if $test -f use64bits.cbu; then
2636                 . ./use64bits.cbu
2637         fi
2638         case "$osname" in
2639         aix|dec_osf|hpux|irix|solaris|unicos)
2640                 # Known 64-bit capable platforms.
2641                 ;;
2642         *)
2643                 cat >&4 <<EOM
2644 $osname is not known to support 64-bit interfaces.
2645 Please let perlbug@perl.com know how to do that.
2646
2647 Cannot continue, aborting.
2648 EOM
2649                 exit 1
2650                 ;;
2651         esac
2652         ;;
2653 esac
2654
2655 : determine the architecture name
2656 echo " "
2657 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2658         tarch=`arch`"-$osname"
2659 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2660         if uname -m > tmparch 2>&1 ; then
2661                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2662                         -e 's/$/'"-$osname/" tmparch`
2663         else
2664                 tarch="$osname"
2665         fi
2666         $rm -f tmparch
2667 else
2668         tarch="$osname"
2669 fi
2670 case "$myarchname" in
2671 ''|"$tarch") ;;
2672 *)
2673         echo "(Your architecture name used to be $myarchname.)"
2674         archname=''
2675         ;;
2676 esac
2677 myarchname="$tarch"
2678 case "$archname" in
2679 '') dflt="$tarch";;
2680 *) dflt="$archname";;
2681 esac
2682 rp='What is your architecture name'
2683 . ./myread
2684 archname="$ans"
2685 case "$usethreads" in
2686 $define)
2687         echo "Threads selected." >&4
2688         case "$archname" in
2689         *-thread*) echo "...and architecture name already has -thread." >&4
2690                 ;;
2691         *)      archname="$archname-thread"
2692                 echo "...setting architecture name to $archname." >&4
2693                 ;;
2694         esac
2695         ;;
2696 esac
2697 case "$usemultiplicity" in
2698 $define)
2699         echo "Multiplicity selected." >&4
2700         case "$archname" in
2701         *-multi*) echo "...and architecture name already has -multi." >&4
2702                 ;;
2703         *)      archname="$archname-multi"
2704                 echo "...setting architecture name to $archname." >&4
2705                 ;;
2706         esac
2707         ;;
2708 esac
2709 case "$use64bits" in
2710 $define)
2711         echo "Explicit 64-bitness selected." >&4
2712         case "$archname64" in
2713         '')
2714                 ;;
2715         *)
2716                 case "$archname" in
2717                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2718                         ;;
2719                 *)      archname="$archname-$archname64"
2720                         echo "...setting architecture name to $archname." >&4
2721                         ;;
2722                 esac
2723                 ;;
2724         esac
2725 esac
2726
2727 : decide how portable to be.  Allow command line overrides.
2728 case "$d_portable" in
2729 "$undef") ;;
2730 *)      d_portable="$define" ;;
2731 esac
2732
2733 : set up shell script to do ~ expansion
2734 cat >filexp <<EOSS
2735 $startsh
2736 : expand filename
2737 case "\$1" in
2738  ~/*|~)
2739         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2740         ;;
2741  ~*)
2742         if $test -f /bin/csh; then
2743                 /bin/csh -f -c "glob \$1"
2744                 failed=\$?
2745                 echo ""
2746                 exit \$failed
2747         else
2748                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2749                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2750                 if $test ! -d "\$dir"; then
2751                         me=\`basename \$0\`
2752                         echo "\$me: can't locate home directory for: \$name" >&2
2753                         exit 1
2754                 fi
2755                 case "\$1" in
2756                 */*)
2757                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2758                         ;;
2759                 *)
2760                         echo \$dir
2761                         ;;
2762                 esac
2763         fi
2764         ;;
2765 *)
2766         echo \$1
2767         ;;
2768 esac
2769 EOSS
2770 chmod +x filexp
2771 $eunicefix filexp
2772
2773 : now set up to get a file name
2774 cat <<EOS >getfile
2775 $startsh
2776 EOS
2777 cat <<'EOSC' >>getfile
2778 tilde=''
2779 fullpath=''
2780 already=''
2781 skip=''
2782 none_ok=''
2783 exp_file=''
2784 nopath_ok=''
2785 orig_rp="$rp"
2786 orig_dflt="$dflt"
2787
2788 case "$fn" in
2789 *\(*)
2790         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2791         fn=`echo $fn | sed 's/(.*)//'`
2792         ;;
2793 esac
2794
2795 case "$fn" in
2796 *:*)
2797         loc_file=`expr $fn : '.*:\(.*\)'`
2798         fn=`expr $fn : '\(.*\):.*'`
2799         ;;
2800 esac
2801
2802 case "$fn" in
2803 *~*) tilde=true;;
2804 esac
2805 case "$fn" in
2806 */*) fullpath=true;;
2807 esac
2808 case "$fn" in
2809 *+*) skip=true;;
2810 esac
2811 case "$fn" in
2812 *n*) none_ok=true;;
2813 esac
2814 case "$fn" in
2815 *e*) exp_file=true;;
2816 esac
2817 case "$fn" in
2818 *p*) nopath_ok=true;;
2819 esac
2820
2821 case "$fn" in
2822 *f*) type='File';;
2823 *d*) type='Directory';;
2824 *l*) type='Locate';;
2825 esac
2826
2827 what="$type"
2828 case "$what" in
2829 Locate) what='File';;
2830 esac
2831
2832 case "$exp_file" in
2833 '')
2834         case "$d_portable" in
2835         "$define") ;;
2836         *) exp_file=true;;
2837         esac
2838         ;;
2839 esac
2840
2841 cd ..
2842 while test "$type"; do
2843         redo=''
2844         rp="$orig_rp"
2845         dflt="$orig_dflt"
2846         case "$tilde" in
2847         true) rp="$rp (~name ok)";;
2848         esac
2849         . UU/myread
2850         if test -f UU/getfile.ok && \
2851                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2852         then
2853                 value="$ans"
2854                 ansexp="$ans"
2855                 break
2856         fi
2857         case "$ans" in
2858         none)
2859                 value=''
2860                 ansexp=''
2861                 case "$none_ok" in
2862                 true) type='';;
2863                 esac
2864                 ;;
2865         *)
2866                 case "$tilde" in
2867                 '') value="$ans"
2868                         ansexp="$ans";;
2869                 *)
2870                         value=`UU/filexp $ans`
2871                         case $? in
2872                         0)
2873                                 if test "$ans" != "$value"; then
2874                                         echo "(That expands to $value on this system.)"
2875                                 fi
2876                                 ;;
2877                         *) value="$ans";;
2878                         esac
2879                         ansexp="$value"
2880                         case "$exp_file" in
2881                         '') value="$ans";;
2882                         esac
2883                         ;;
2884                 esac
2885                 case "$fullpath" in
2886                 true)
2887                         case "$ansexp" in
2888                         /*) value="$ansexp" ;;
2889                         *)
2890                                 redo=true
2891                                 case "$already" in
2892                                 true)
2893                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2894                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2895                                         ;;
2896                                 *)
2897                                 echo "Please give a full path name, starting with slash." >&4
2898                                         case "$tilde" in
2899                                         true)
2900                                 echo "Note that using ~name is ok provided it expands well." >&4
2901                                                 already=true
2902                                                 ;;
2903                                         esac
2904                                 esac
2905                                 ;;
2906                         esac
2907                         ;;
2908                 esac
2909                 case "$redo" in
2910                 '')
2911                         case "$type" in
2912                         File)
2913                                 if test -f "$ansexp"; then
2914                                         type=''
2915                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2916                                 then
2917                                         echo "($value is not a plain file, but that's ok.)"
2918                                         type=''
2919                                 fi
2920                                 ;;
2921                         Directory)
2922                                 if test -d "$ansexp"; then
2923                                         type=''
2924                                 fi
2925                                 ;;
2926                         Locate)
2927                                 if test -d "$ansexp"; then
2928                                         echo "(Looking for $loc_file in directory $value.)"
2929                                         value="$value/$loc_file"
2930                                         ansexp="$ansexp/$loc_file"
2931                                 fi
2932                                 if test -f "$ansexp"; then
2933                                         type=''
2934                                 fi
2935                                 case "$nopath_ok" in
2936                                 true)   case "$value" in
2937                                         */*) ;;
2938                                         *)      echo "Assuming $value will be in people's path."
2939                                                 type=''
2940                                                 ;;
2941                                         esac
2942                                         ;;
2943                                 esac
2944                                 ;;
2945                         esac
2946
2947                         case "$skip" in
2948                         true) type='';
2949                         esac
2950
2951                         case "$type" in
2952                         '') ;;
2953                         *)
2954                                 if test "$fastread" = yes; then
2955                                         dflt=y
2956                                 else
2957                                         dflt=n
2958                                 fi
2959                                 rp="$what $value doesn't exist.  Use that name anyway?"
2960                                 . UU/myread
2961                                 dflt=''
2962                                 case "$ans" in
2963                                 y*) type='';;
2964                                 *) echo " ";;
2965                                 esac
2966                                 ;;
2967                         esac
2968                         ;;
2969                 esac
2970                 ;;
2971         esac
2972 done
2973 cd UU
2974 ans="$value"
2975 rp="$orig_rp"
2976 dflt="$orig_dflt"
2977 rm -f getfile.ok
2978 EOSC
2979
2980 : determine root of directory hierarchy where package will be installed.
2981 case "$prefix" in
2982 '')
2983         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2984         ;;
2985 *)
2986         dflt="$prefix"
2987         ;;
2988 esac
2989 $cat <<EOM
2990
2991 By default, $package will be installed in $dflt/bin, manual pages
2992 under $dflt/man, etc..., i.e. with $dflt as prefix for all
2993 installation directories. Typically this is something like /usr/local.
2994 If you wish to have binaries under /usr/bin but other parts of the
2995 installation under /usr/local, that's ok: you will be prompted
2996 separately for each of the installation directories, the prefix being
2997 only used to set the defaults.
2998
2999 EOM
3000 fn=d~
3001 rp='Installation prefix to use?'
3002 . ./getfile
3003 oldprefix=''
3004 case "$prefix" in
3005 '') ;;
3006 *)
3007         case "$ans" in
3008         "$prefix") ;;
3009         *) oldprefix="$prefix";;
3010         esac
3011         ;;
3012 esac
3013 prefix="$ans"
3014 prefixexp="$ansexp"
3015
3016 : is AFS running?
3017 echo " "
3018 case "$afs" in
3019 $define|true)   afs=true ;;
3020 $undef|false)   afs=false ;;
3021 *)      if test -d /afs; then
3022                 afs=true
3023         else
3024                 afs=false
3025         fi
3026         ;;
3027 esac
3028 if $afs; then
3029         echo "AFS may be running... I'll be extra cautious then..." >&4
3030 else
3031         echo "AFS does not seem to be running..." >&4
3032 fi
3033
3034 : determine installation prefix for where package is to be installed.
3035 if $afs; then 
3036 $cat <<EOM
3037
3038 Since you are running AFS, I need to distinguish the directory in which
3039 files will reside from the directory in which they are installed (and from
3040 which they are presumably copied to the former directory by occult means).
3041
3042 EOM
3043         case "$installprefix" in
3044         '') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
3045         *) dflt="$installprefix";;
3046         esac
3047 else
3048 $cat <<EOM
3049
3050 In some special cases, particularly when building $package for distribution,
3051 it is convenient to distinguish between the directory in which files should 
3052 be installed from the directory ($prefix) in which they 
3053 will eventually reside.  For most users, these two directories are the same.
3054
3055 EOM
3056         case "$installprefix" in
3057         '') dflt=$prefix ;;
3058         *) dflt=$installprefix;;
3059         esac
3060 fi
3061 fn=d~
3062 rp='What installation prefix should I use for installing files?'
3063 . ./getfile
3064 installprefix="$ans"
3065 installprefixexp="$ansexp"
3066
3067 : set the prefixit variable, to compute a suitable default value
3068 prefixit='case "$3" in
3069 ""|none)
3070         case "$oldprefix" in
3071         "") eval "$1=\"\$$2\"";;
3072         *)
3073                 case "$3" in
3074                 "") eval "$1=";;
3075                 none)
3076                         eval "tp=\"\$$2\"";
3077                         case "$tp" in
3078                         ""|" ") eval "$1=\"\$$2\"";;
3079                         *) eval "$1=";;
3080                         esac;;
3081                 esac;;
3082         esac;;
3083 *)
3084         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3085         case "$tp" in
3086         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3087         /*-$oldprefix/*|\~*-$oldprefix/*)
3088                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3089         *) eval "$1=\"\$$2\"";;
3090         esac;;
3091 esac'
3092
3093 : set the base revision
3094 baserev=5.0
3095
3096 : get the patchlevel
3097 echo " "
3098 echo "Getting the current patchlevel..." >&4
3099 if $test -r $rsrc/patchlevel.h;then
3100         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3101         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3102 else
3103         patchlevel=0
3104         subversion=0
3105 fi
3106 $echo $n "(You have $package" $c
3107 case "$package" in
3108 "*$baserev")    ;;
3109 *)              $echo $n " $baserev" $c ;;
3110 esac
3111 $echo $n " patchlevel $patchlevel" $c
3112 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3113 echo ".)"
3114
3115 if test 0 -eq "$subversion"; then
3116         version=`LC_ALL=C; export LC_ALL; \
3117                  echo $baserev $patchlevel | \
3118                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3119 else
3120         version=`LC_ALL=C; export LC_ALL; \
3121                  echo $baserev $patchlevel $subversion | \
3122                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3123 fi
3124 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3125 if test "$subversion" -lt 50; then
3126         apiversion=`LC_ALL=C; export LC_ALL; \
3127                  LANGUAGE=C; export LANGUAGE; \
3128                  echo $baserev $patchlevel | \
3129                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3130 else
3131         apiversion="$version"
3132 fi
3133
3134 : determine installation style
3135 : For now, try to deduce it from prefix unless it is already set.
3136 : Reproduce behavior of 5.005 and earlier, maybe drop that in 5.7.
3137 case "$installstyle" in
3138 '')     case "$prefix" in
3139                 *perl*) dflt='lib';;
3140                 *) dflt='lib/perl5' ;;
3141         esac
3142         ;;
3143 *)      dflt='lib/perl5' ;;
3144 esac
3145 : Probably not worth prompting for this since we prompt for all
3146 : the directories individually, and the prompt would be too long and
3147 : confusing anyway.
3148 installstyle=$dflt
3149
3150 : determine where private library files go
3151 : Usual default is /usr/local/lib/perl5/$version.
3152 : Also allow things like /opt/perl/lib/$version, since 
3153 : /opt/perl/lib/perl5... would be redundant.
3154 : The default "style" setting is made in installstyle.U
3155 case "$installstyle" in
3156 *lib/perl5*) set dflt privlib lib/$package/$version ;;
3157 *)       set dflt privlib lib/$version ;;
3158 esac
3159 eval $prefixit
3160 $cat <<EOM
3161
3162 There are some auxiliary files for $package that need to be put into a
3163 private library directory that is accessible by everyone.
3164
3165 EOM
3166 fn=d~+
3167 rp='Pathname where the private library files will reside?'
3168 . ./getfile
3169 privlib="$ans"
3170 privlibexp="$ansexp"
3171 : Change installation prefix, if necessary.
3172 if $test X"$prefix" != X"$installprefix"; then
3173         installprivlib=`echo $privlibexp | sed 's#^$prefix#$installprefix#'`
3174 else
3175         installprivlib="$privlibexp"
3176 fi
3177
3178 : set the prefixup variable, to restore leading tilda escape
3179 prefixup='case "$prefixexp" in
3180 "$prefix") ;;
3181 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3182 esac'
3183
3184 : determine where public architecture dependent libraries go
3185 set archlib archlib
3186 eval $prefixit
3187 : privlib default is /usr/local/lib/$package/$version
3188 : archlib default is /usr/local/lib/$package/$version/$archname
3189 : privlib may have an optional trailing /share.
3190 tdflt=`echo $privlib | $sed 's,/share$,,'`
3191 tdflt=$tdflt/$archname
3192 case "$archlib" in
3193 '')     dflt=$tdflt
3194         ;;
3195 *)      dflt="$archlib"
3196     ;;
3197 esac
3198 $cat <<EOM
3199
3200 $spackage contains architecture-dependent library files.  If you are
3201 sharing libraries in a heterogeneous environment, you might store
3202 these files in a separate location.  Otherwise, you can just include
3203 them with the rest of the public library files.
3204
3205 EOM
3206 fn=d+~
3207 rp='Where do you want to put the public architecture-dependent libraries?'
3208 . ./getfile
3209 archlib="$ans"
3210 archlibexp="$ansexp"
3211 if $test X"$archlib" = X"$privlib"; then
3212         d_archlib="$undef"
3213 else
3214         d_archlib="$define"
3215 fi
3216 : Change installation prefix, if necessary.
3217 if $test X"$prefix" != X"$installprefix"; then
3218         installarchlib=`echo $archlibexp | sed 's#^$prefix#$installprefix#'`
3219 else
3220         installarchlib="$archlibexp"
3221 fi
3222
3223 : make some quick guesses about what we are up against
3224 echo " "
3225 $echo $n "Hmm...  $c"
3226 echo exit 1 >bsd
3227 echo exit 1 >usg
3228 echo exit 1 >v7
3229 echo exit 1 >osf1
3230 echo exit 1 >eunice
3231 echo exit 1 >xenix
3232 echo exit 1 >venix
3233 echo exit 1 >os2
3234 d_bsd="$undef"
3235 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3236 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3237 then
3238         echo "Looks kind of like an OSF/1 system, but we'll see..."
3239         echo exit 0 >osf1
3240 elif test `echo abc | tr a-z A-Z` = Abc ; then
3241         xxx=`./loc addbib blurfl $pth`
3242         if $test -f $xxx; then
3243         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3244                 echo exit 0 >bsd
3245                 echo exit 0 >usg
3246         else
3247                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3248                         echo "Looks kind of like an extended USG system, but we'll see..."
3249                 else
3250                         echo "Looks kind of like a USG system, but we'll see..."
3251                 fi
3252                 echo exit 0 >usg
3253         fi
3254 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3255         echo "Looks kind of like a BSD system, but we'll see..."
3256         d_bsd="$define"
3257         echo exit 0 >bsd
3258 else
3259         echo "Looks kind of like a Version 7 system, but we'll see..."
3260         echo exit 0 >v7
3261 fi
3262 case "$eunicefix" in
3263 *unixtovms*)
3264         $cat <<'EOI'
3265 There is, however, a strange, musty smell in the air that reminds me of
3266 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3267 EOI
3268         echo exit 0 >eunice
3269         d_eunice="$define"
3270 : it so happens the Eunice I know will not run shell scripts in Unix format
3271         ;;
3272 *)
3273         echo " "
3274         echo "Congratulations.  You aren't running Eunice."
3275         d_eunice="$undef"
3276         ;;
3277 esac
3278 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3279 case "$p_" in
3280 :) ;;
3281 *)
3282         $cat <<'EOI'
3283 I have the feeling something is not exactly right, however...don't tell me...
3284 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3285 EOI
3286         echo exit 0 >os2
3287         ;;
3288 esac
3289 if test -f /xenix; then
3290         echo "Actually, this looks more like a XENIX system..."
3291         echo exit 0 >xenix
3292         d_xenix="$define"
3293 else
3294         echo " "
3295         echo "It's not Xenix..."
3296         d_xenix="$undef"
3297 fi
3298 chmod +x xenix
3299 $eunicefix xenix
3300 if test -f /venix; then
3301         echo "Actually, this looks more like a VENIX system..."
3302         echo exit 0 >venix
3303 else
3304         echo " "
3305         if ./xenix; then
3306                 : null
3307         else
3308                 echo "Nor is it Venix..."
3309         fi
3310 fi
3311 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3312 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3313 $rm -f foo
3314
3315 : see if setuid scripts can be secure
3316 $cat <<EOM
3317
3318 Some kernels have a bug that prevents setuid #! scripts from being
3319 secure.  Some sites have disabled setuid #! scripts because of this.
3320
3321 First let's decide if your kernel supports secure setuid #! scripts.
3322 (If setuid #! scripts would be secure but have been disabled anyway,
3323 don't say that they are secure if asked.)
3324
3325 EOM
3326
3327 val="$undef"
3328 if $test -d /dev/fd; then
3329         echo "#!$ls" >reflect
3330         chmod +x,u+s reflect
3331         ./reflect >flect 2>&1
3332         if $contains "/dev/fd" flect >/dev/null; then
3333                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3334                 val="$define"
3335         else
3336                 $cat <<EOM
3337 If you are not sure if they are secure, I can check but I'll need a
3338 username and password different from the one you are using right now.
3339 If you don't have such a username or don't want me to test, simply
3340 enter 'none'.
3341
3342 EOM
3343                 rp='Other username to test security of setuid scripts with?'
3344                 dflt='none'
3345                 . ./myread
3346                 case "$ans" in
3347                 n|none)
3348                         case "$d_suidsafe" in
3349                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3350                                 dflt=n;;
3351                         "$undef")
3352                                 echo "Well, the $hint value is *not* secure." >&4
3353                                 dflt=n;;
3354                         *)      echo "Well, the $hint value *is* secure." >&4
3355                                 dflt=y;;
3356                         esac
3357                         ;;
3358                 *)
3359                         $rm -f reflect flect
3360                         echo "#!$ls" >reflect
3361                         chmod +x,u+s reflect
3362                         echo >flect
3363                         chmod a+w flect
3364                         echo '"su" will (probably) prompt you for '"$ans's password."
3365                         su $ans -c './reflect >flect'
3366                         if $contains "/dev/fd" flect >/dev/null; then
3367                                 echo "Okay, it looks like setuid scripts are secure." >&4
3368                                 dflt=y
3369                         else
3370                                 echo "I don't think setuid scripts are secure." >&4
3371                                 dflt=n
3372                         fi
3373                         ;;
3374                 esac
3375                 rp='Does your kernel have *secure* setuid scripts?'
3376                 . ./myread
3377                 case "$ans" in
3378                 [yY]*)  val="$define";;
3379                 *)      val="$undef";;
3380                 esac
3381         fi
3382 else
3383         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3384         echo "(That's for file descriptors, not floppy disks.)"
3385         val="$undef"
3386 fi
3387 set d_suidsafe
3388 eval $setvar
3389
3390 $rm -f reflect flect
3391
3392 : now see if they want to do setuid emulation
3393 echo " "
3394 val="$undef"
3395 case "$d_suidsafe" in
3396 "$define")
3397         val="$undef"
3398         echo "No need to emulate SUID scripts since they are secure here." >& 4
3399         ;;
3400 *)
3401         $cat <<EOM
3402 Some systems have disabled setuid scripts, especially systems where
3403 setuid scripts cannot be secure.  On systems where setuid scripts have
3404 been disabled, the setuid/setgid bits on scripts are currently
3405 useless.  It is possible for $package to detect those bits and emulate
3406 setuid/setgid in a secure fashion.  This emulation will only work if
3407 setuid scripts have been disabled in your kernel.
3408
3409 EOM
3410         case "$d_dosuid" in
3411         "$define") dflt=y ;;
3412         *) dflt=n ;;
3413         esac
3414         rp="Do you want to do setuid/setgid emulation?"
3415         . ./myread
3416         case "$ans" in
3417         [yY]*)  val="$define";;
3418         *)      val="$undef";;
3419         esac
3420         ;;
3421 esac
3422 set d_dosuid
3423 eval $setvar
3424
3425 : determine where manual pages are on this system
3426 echo " "
3427 case "$sysman" in
3428 '') 
3429         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3430         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3431         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3432         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3433         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3434         sysman=`./loc . /usr/man/man1 $syspath`
3435         ;;
3436 esac
3437 if $test -d "$sysman"; then
3438         echo "System manual is in $sysman." >&4
3439 else
3440         echo "Could not find manual pages in source form." >&4
3441 fi
3442
3443 : see what memory models we can support
3444 case "$models" in
3445 '')
3446         $cat >pdp11.c <<'EOP'
3447 int main() {
3448 #ifdef pdp11
3449         exit(0);
3450 #else
3451         exit(1);
3452 #endif
3453 }
3454 EOP
3455         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3456         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3457                 dflt='unsplit split'
3458         else
3459                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3460                 case "$tans" in
3461                 X) dflt='none';;
3462                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3463                                 dflt='small'
3464                         else
3465                                 dflt=''
3466                         fi
3467                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3468                                 dflt="$dflt medium"
3469                         fi
3470                         if $test -d /lib/large || $test -d /usr/lib/large; then
3471                                 dflt="$dflt large"
3472                         fi
3473                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3474                                 dflt="$dflt huge"
3475                         fi
3476                 esac
3477         fi;;
3478 *) dflt="$models";;
3479 esac
3480 $cat <<EOM
3481  
3482 Some systems have different model sizes.  On most systems they are called
3483 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3484 split.  If your system doesn't support different memory models, say "none".
3485 If you wish to force everything to one memory model, say "none" here and
3486 put the appropriate flags later when it asks you for other cc and ld flags.
3487 Venix systems may wish to put "none" and let the compiler figure things out.
3488 (In the following question multiple model names should be space separated.)
3489
3490 The default for most systems is "none".
3491
3492 EOM
3493 rp="Which memory models are supported?"
3494 . ./myread
3495 models="$ans"
3496
3497 case "$models" in
3498 none)
3499         small=''
3500         medium=''
3501         large=''
3502         huge=''
3503         unsplit=''
3504         split=''
3505         ;;
3506 *split)
3507         case "$split" in
3508         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3509                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3510                         dflt='-i'
3511                 else
3512                         dflt='none'
3513                 fi;;
3514         *) dflt="$split";;
3515         esac
3516         rp="What flag indicates separate I and D space?"
3517         . ./myread
3518         tans="$ans"
3519         case "$tans" in
3520         none) tans='';;
3521         esac
3522         split="$tans"
3523         unsplit='';;
3524 *large*|*small*|*medium*|*huge*)
3525         case "$models" in
3526         *large*)
3527                 case "$large" in
3528                 '') dflt='-Ml';;
3529                 *) dflt="$large";;
3530                 esac
3531         rp="What flag indicates large model?"
3532         . ./myread
3533         tans="$ans"
3534         case "$tans" in
3535         none) tans='';
3536         esac
3537         large="$tans";;
3538         *) large='';;
3539         esac
3540         case "$models" in
3541         *huge*) case "$huge" in
3542                 '') dflt='-Mh';;
3543                 *) dflt="$huge";;
3544                 esac
3545                 rp="What flag indicates huge model?"
3546                 . ./myread
3547                 tans="$ans"
3548                 case "$tans" in
3549                 none) tans='';
3550                 esac
3551                 huge="$tans";;
3552         *) huge="$large";;
3553         esac
3554         case "$models" in
3555         *medium*) case "$medium" in
3556                 '') dflt='-Mm';;
3557                 *) dflt="$medium";;
3558                 esac
3559                 rp="What flag indicates medium model?"
3560                 . ./myread
3561                 tans="$ans"
3562                 case "$tans" in
3563                 none) tans='';
3564                 esac
3565                 medium="$tans";;
3566         *) medium="$large";;
3567         esac
3568         case "$models" in
3569         *small*) case "$small" in
3570                 '') dflt='none';;
3571                 *) dflt="$small";;
3572                 esac
3573                 rp="What flag indicates small model?"
3574                 . ./myread
3575                 tans="$ans"
3576                 case "$tans" in
3577                 none) tans='';
3578                 esac
3579                 small="$tans";;
3580         *) small='';;
3581         esac
3582         ;;
3583 *)
3584         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3585         ;;
3586 esac
3587 $rm -f pdp11.* pdp11
3588
3589 : see if we need a special compiler
3590 echo " "
3591 if ./usg; then
3592         case "$cc" in
3593         '') case "$Mcc" in
3594                 /*) dflt='Mcc';;
3595                 *) case "$large" in
3596                         -M*) dflt='cc';;
3597                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3598                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3599                                                 dflt='cc'
3600                                         else
3601                                                 dflt='cc -M'
3602                                         fi
3603                                 else
3604                                         dflt='cc'
3605                                 fi;;
3606                         esac;;
3607                 esac;;
3608         *)  dflt="$cc";;
3609         esac
3610         case "$dflt" in
3611         *M*)    $cat <<'EOM'
3612 On some older systems the default C compiler will not resolve multiple global
3613 references that happen to have the same name.  On some such systems the "Mcc"
3614 command may be used to force these to be resolved.  On other systems a "cc -M"
3615 command is required.  (Note that the -M flag on other systems indicates a
3616 memory model to use!) If you have the Gnu C compiler, you might wish to use
3617 that instead.
3618
3619 EOM
3620         ;;
3621         esac
3622         rp="Use which C compiler?"
3623         . ./myread
3624         cc="$ans"
3625 else
3626         case "$cc" in
3627         '') dflt=cc;;
3628         *) dflt="$cc";;
3629         esac
3630         rp="Use which C compiler?"
3631         . ./myread
3632         cc="$ans"
3633 fi
3634 : Look for a hint-file generated 'call-back-unit'.  Now that the
3635 : user has specified the compiler, we may need to set or change some
3636 : other defaults.
3637 if $test -f cc.cbu; then
3638     . ./cc.cbu
3639 fi
3640 echo " "
3641 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3642 $cat >gccvers.c <<EOM
3643 #include <stdio.h>
3644 int main() {
3645 #ifdef __GNUC__
3646 #ifdef __VERSION__
3647         printf("%s\n", __VERSION__);
3648 #else
3649         printf("%s\n", "1");
3650 #endif
3651 #endif
3652         exit(0);
3653 }
3654 EOM
3655 if $cc -o gccvers gccvers.c; then
3656         gccversion=`./gccvers`
3657         case "$gccversion" in
3658         '') echo "You are not using GNU cc." ;;
3659         *)  echo "You are using GNU cc $gccversion." ;;
3660         esac
3661 else
3662         echo " "
3663         echo "*** WHOA THERE!!! ***" >&4
3664         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3665         case "$knowitall" in
3666         '')
3667         echo "    You'd better start hunting for one and let me know about it." >&4
3668                 exit 1
3669                 ;;
3670         esac
3671 fi
3672 $rm -f gccvers*
3673 case "$gccversion" in
3674 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3675 esac
3676
3677 : What should the include directory be ?
3678 echo " "
3679 $echo $n "Hmm...  $c"
3680 dflt='/usr/include'
3681 incpath=''
3682 mips_type=''
3683 if $test -f /bin/mips && /bin/mips; then
3684         echo "Looks like a MIPS system..."
3685         $cat >usr.c <<'EOCP'
3686 #ifdef SYSTYPE_BSD43
3687 /bsd43
3688 #endif
3689 EOCP
3690         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3691                 dflt='/bsd43/usr/include'
3692                 incpath='/bsd43'
3693                 mips_type='BSD 4.3'
3694         else
3695                 mips_type='System V'
3696         fi
3697         $rm -f usr.c usr.out
3698         echo "and you're compiling with the $mips_type compiler and libraries."
3699         xxx_prompt=y
3700         echo "exit 0" >mips
3701 else
3702         echo "Doesn't look like a MIPS system."
3703         xxx_prompt=n
3704         echo "exit 1" >mips
3705 fi
3706 chmod +x mips
3707 $eunicefix mips
3708 case "$usrinc" in
3709 '') ;;
3710 *) dflt="$usrinc";;
3711 esac
3712 case "$xxx_prompt" in
3713 y)      fn=d/
3714         echo " "
3715         rp='Where are the include files you want to use?'
3716         . ./getfile
3717         usrinc="$ans"
3718         ;;
3719 *)      usrinc="$dflt"
3720         ;;
3721 esac
3722
3723 : see how we invoke the C preprocessor
3724 echo " "
3725 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3726 cat <<'EOT' >testcpp.c
3727 #define ABC abc
3728 #define XYZ xyz
3729 ABC.XYZ
3730 EOT
3731 cd ..
3732 if test ! -f cppstdin; then
3733         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3734 else
3735         echo "Keeping your $hint cppstdin wrapper."
3736 fi
3737 chmod 755 cppstdin
3738 wrapper=`pwd`/cppstdin
3739 ok='false'
3740 cd UU
3741
3742 if $test "X$cppstdin" != "X" && \
3743         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3744         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3745 then
3746         echo "You used to use $cppstdin $cppminus so we'll use that again."
3747         case "$cpprun" in
3748         '') echo "But let's see if we can live without a wrapper..." ;;
3749         *)
3750                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3751                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3752                 then
3753                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3754                         ok='true'
3755                 else
3756                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3757                 fi
3758                 ;;
3759         esac
3760 else
3761         case "$cppstdin" in
3762         '') ;;
3763         *)
3764                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3765                 ;;
3766         esac
3767 fi
3768
3769 if $ok; then
3770         : nothing
3771 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3772         $cc -E <testcpp.c >testcpp.out 2>&1; \
3773         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3774         echo "Yup, it does."
3775         x_cpp="$cc -E"
3776         x_minus='';
3777 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3778         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3779         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3780         echo "Yup, it does."
3781         x_cpp="$cc -E"
3782         x_minus='-';
3783 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3784         $cc -P <testcpp.c >testcpp.out 2>&1; \
3785         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3786         echo "Yipee, that works!"
3787         x_cpp="$cc -P"
3788         x_minus='';
3789 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3790         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3791         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3792         echo "At long last!"
3793         x_cpp="$cc -P"
3794         x_minus='-';
3795 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3796         $cpp <testcpp.c >testcpp.out 2>&1; \
3797         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3798         echo "It works!"
3799         x_cpp="$cpp"
3800         x_minus='';
3801 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3802         $cpp - <testcpp.c >testcpp.out 2>&1; \
3803         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3804         echo "Hooray, it works!  I was beginning to wonder."
3805         x_cpp="$cpp"
3806         x_minus='-';
3807 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3808         $wrapper <testcpp.c >testcpp.out 2>&1; \
3809         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3810         x_cpp="$wrapper"
3811         x_minus=''
3812         echo "Eureka!"
3813 else
3814         dflt=''
3815         rp="No dice.  I can't find a C preprocessor.  Name one:"
3816         . ./myread
3817         x_cpp="$ans"
3818         x_minus=''
3819         $x_cpp <testcpp.c >testcpp.out 2>&1
3820         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3821                 echo "OK, that will do." >&4
3822         else
3823 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3824                 exit 1
3825         fi
3826 fi
3827
3828 case "$ok" in
3829 false)
3830         cppstdin="$x_cpp"
3831         cppminus="$x_minus"
3832         cpprun="$x_cpp"
3833         cpplast="$x_minus"
3834         set X $x_cpp
3835         shift
3836         case "$1" in
3837         "$cpp")
3838                 echo "Perhaps can we force $cc -E using a wrapper..."
3839                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3840                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3841                 then
3842                         echo "Yup, we can."
3843                         cppstdin="$wrapper"
3844                         cppminus='';
3845                 else
3846                         echo "Nope, we'll have to live without it..."
3847                 fi
3848                 ;;
3849         esac
3850         case "$cpprun" in
3851         "$wrapper")
3852                 cpprun=''
3853                 cpplast=''
3854                 ;;
3855         esac
3856         ;;
3857 esac
3858
3859 case "$cppstdin" in
3860 "$wrapper"|'cppstdin') ;;
3861 *) $rm -f $wrapper;;
3862 esac
3863 $rm -f testcpp.c testcpp.out
3864
3865 : Set private lib path
3866 case "$plibpth" in
3867 '') if ./mips; then
3868                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3869         fi;;
3870 esac
3871 case "$libpth" in
3872 ' ') dlist='';;
3873 '') dlist="$loclibpth $plibpth $glibpth";;
3874 *) dlist="$libpth";;
3875 esac
3876
3877 : Now check and see which directories actually exist, avoiding duplicates
3878 libpth=''
3879 for xxx in $dlist
3880 do
3881     if $test -d $xxx; then
3882                 case " $libpth " in
3883                 *" $xxx "*) ;;
3884                 *) libpth="$libpth $xxx";;
3885                 esac
3886     fi
3887 done
3888 $cat <<'EOM'
3889
3890 Some systems have incompatible or broken versions of libraries.  Among
3891 the directories listed in the question below, please remove any you
3892 know not to be holding relevant libraries, and add any that are needed.
3893 Say "none" for none.
3894
3895 EOM
3896 case "$libpth" in
3897 '') dflt='none';;
3898 *)
3899         set X $libpth
3900         shift
3901         dflt=${1+"$@"}
3902         ;;
3903 esac
3904 rp="Directories to use for library searches?"
3905 . ./myread
3906 case "$ans" in
3907 none) libpth=' ';;
3908 *) libpth="$ans";;
3909 esac
3910
3911 : compute shared library extension
3912 case "$so" in
3913 '')
3914         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3915                 dflt='sl'
3916         else
3917                 dflt='so'
3918         fi
3919         ;;
3920 *) dflt="$so";;
3921 esac
3922 $cat <<EOM
3923
3924 On some systems, shared libraries may be available.  Answer 'none' if
3925 you want to suppress searching of shared libraries for the remaining
3926 of this configuration.
3927
3928 EOM
3929 rp='What is the file extension used for shared libraries?'
3930 . ./myread
3931 so="$ans"
3932
3933 : Define several unixisms.
3934 : Hints files or command line option can be used to override them.
3935 : The convoluted testing is in case hints files set either the old
3936 : or the new name.
3937 case "$_exe" in
3938 '')     case "$exe_ext" in
3939     '') ;;
3940         *)      _exe="$exe_ext" ;;
3941         esac
3942         ;;
3943 esac
3944 case "$_a" in
3945 '')     case "$lib_ext" in
3946     '') _a='.a';;
3947         *)      _a="$lib_ext" ;;
3948         esac
3949         ;;
3950 esac
3951 case "$_o" in
3952 '') case "$obj_ext" in
3953         '')     _o='.o';;
3954         *)      _o="$obj_ext";;
3955         esac
3956         ;;
3957 esac
3958 case "$p_" in
3959 '') case "$path_sep" in
3960         '')     p_=':';;
3961         *)      p_="$path_sep";;
3962         esac
3963         ;;
3964 esac
3965 exe_ext=$_exe
3966 lib_ext=$_a
3967 obj_ext=$_o
3968 path_sep=$p_
3969
3970 : Which makefile gets called first.  This is used by make depend.
3971 case "$firstmakefile" in
3972 '') firstmakefile='makefile';;
3973 esac
3974
3975 cat <<EOM
3976
3977 Perl can be built to use the SOCKS proxy protocol library.  To do so,
3978 Configure must be run with -Dusesocks.
3979
3980 Normally you do not need this and you should answer no.
3981
3982 EOM
3983 case "$usesocks" in
3984 $define|true|[yY]*)     dflt='y';;
3985 *) dflt='n';;
3986 esac
3987 rp='Build Perl for SOCKS?'
3988 . ./myread
3989 case "$ans" in
3990 y|Y)    val="$define" ;;     
3991 *)      val="$undef" ;;
3992 esac
3993 set usesocks
3994 eval $setvar
3995
3996 : Looking for optional libraries
3997 echo " "
3998 echo "Checking for optional libraries..." >&4
3999 case "$libs" in
4000 ' '|'') dflt='';;
4001 *) dflt="$libs";;
4002 esac
4003 case "$libswanted" in
4004 '') libswanted='c_s';;
4005 esac
4006 case "$usesocks" in
4007 $define)
4008         libswanted="$libswanted socks5 socks5_sh"
4009         ;;
4010 esac
4011 for thislib in $libswanted; do
4012         
4013         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
4014                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
4015                 echo "Found -l$thislib (shared)."
4016                 case " $dflt " in
4017                 *"-l$thislib "*);;
4018                 *) dflt="$dflt -l$thislib";;
4019                 esac
4020         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
4021                 echo "Found -l$thislib (shared)."
4022                 case " $dflt " in
4023                 *"-l$thislib "*);;
4024                 *) dflt="$dflt -l$thislib";;
4025                 esac
4026         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
4027                 echo "Found -l$thislib."
4028                 case " $dflt " in
4029                 *"-l$thislib "*);;
4030                 *) dflt="$dflt -l$thislib";;
4031                 esac
4032         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
4033                 echo "Found -l$thislib."
4034                 case " $dflt " in
4035                 *"-l$thislib "*);;
4036                 *) dflt="$dflt -l$thislib";;
4037                 esac
4038         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
4039                 echo "Found -l${thislib}_s."
4040                 case " $dflt " in
4041                 *"-l$thislib "*);;
4042                 *) dflt="$dflt -l${thislib}_s";;
4043                 esac
4044         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
4045                 echo "Found -l$thislib."
4046                 case " $dflt " in
4047                 *"-l$thislib "*);;
4048                 *) dflt="$dflt -l$thislib";;
4049                 esac
4050         else
4051                 echo "No -l$thislib."
4052         fi
4053 done
4054 set X $dflt
4055 shift
4056 dflt="$*"
4057 case "$libs" in
4058 '') dflt="$dflt";;
4059 *) dflt="$libs";;
4060 esac
4061 case "$dflt" in
4062 ' '|'') dflt='none';;
4063 esac
4064
4065 $cat <<EOM
4066
4067 In order to compile $package on your machine, a number of libraries
4068 are usually needed.  Include any other special libraries here as well.
4069 Say "none" for none.  The default list is almost always right.
4070 EOM
4071
4072 echo " "
4073 rp="What libraries to use?"
4074 . ./myread
4075 case "$ans" in
4076 none) libs=' ';;
4077 *) libs="$ans";;
4078 esac
4079
4080 : determine optimize, if desired, or use for debug flag also
4081 case "$optimize" in
4082 ' '|$undef) dflt='none';;
4083 '') dflt='-O';;
4084 *) dflt="$optimize";;
4085 esac
4086 $cat <<EOH
4087
4088 Some C compilers have problems with their optimizers.  By default, $package
4089 compiles with the -O flag to use the optimizer.  Alternately, you might want
4090 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4091 systems).  Either flag can be specified here.  To use neither flag, specify
4092 the word "none".
4093
4094 EOH
4095 rp="What optimizer/debugger flag should be used?"
4096 . ./myread
4097 optimize="$ans"
4098 case "$optimize" in
4099 'none') optimize=" ";;
4100 esac
4101
4102 dflt=''
4103 : We will not override a previous value, but we might want to
4104 : augment a hint file
4105 case "$hint" in
4106 none|recommended)
4107         case "$gccversion" in
4108         1*) dflt='-fpcc-struct-return' ;;
4109         esac
4110         case "$optimize" in
4111         *-g*) dflt="$dflt -DDEBUGGING";;
4112         esac
4113         case "$gccversion" in
4114         2*) if test -d /etc/conf/kconfig.d &&
4115                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4116                 then
4117                         dflt="$dflt -posix"
4118                 fi
4119                 ;;
4120         esac
4121         ;;
4122 esac
4123
4124 case "$mips_type" in
4125 *BSD*|'') inclwanted="$locincpth $usrinc";;
4126 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4127 esac
4128 for thisincl in $inclwanted; do
4129         if $test -d $thisincl; then
4130                 if $test x$thisincl != x$usrinc; then
4131                         case "$dflt" in
4132                         *$thisincl*);;
4133                         *) dflt="$dflt -I$thisincl";;
4134                         esac
4135                 fi
4136         fi
4137 done
4138
4139 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4140         xxx=true;
4141 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4142         xxx=true;
4143 else
4144         xxx=false;
4145 fi;
4146 if $xxx; then
4147         case "$dflt" in
4148         *$2*);;
4149         *) dflt="$dflt -D$2";;
4150         esac;
4151 fi'
4152
4153 set signal.h LANGUAGE_C; eval $inctest
4154
4155 case "$usesocks" in
4156 $define)
4157         ccflags="$ccflags -DSOCKS"
4158         ;;
4159 esac
4160
4161 case "$hint" in
4162 none|recommended) dflt="$ccflags $dflt" ;;
4163 *) dflt="$ccflags";;
4164 esac
4165
4166 case "$dflt" in
4167 ''|' ') dflt=none;;
4168 esac
4169 $cat <<EOH
4170
4171 Your C compiler may want other flags.  For this question you should include
4172 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4173 but you should NOT include libraries or ld flags like -lwhatever.  If you
4174 want $package to honor its debug switch, you should include -DDEBUGGING here.
4175 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4176
4177 To use no flags, specify the word "none".
4178
4179 EOH
4180 set X $dflt
4181 shift
4182 dflt=${1+"$@"}
4183 rp="Any additional cc flags?"
4184 . ./myread
4185 case "$ans" in
4186 none) ccflags='';;
4187 *) ccflags="$ans";;
4188 esac
4189
4190 : the following weeds options from ccflags that are of no interest to cpp
4191 cppflags="$ccflags"
4192 case "$gccversion" in
4193 1*) cppflags="$cppflags -D__GNUC__"
4194 esac
4195 case "$mips_type" in
4196 '');;
4197 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4198 esac
4199 case "$cppflags" in
4200 '');;
4201 *)
4202         echo " "
4203         echo "Let me guess what the preprocessor flags are..." >&4
4204         set X $cppflags
4205         shift
4206         cppflags=''
4207         $cat >cpp.c <<'EOM'
4208 #define BLURFL foo
4209
4210 BLURFL xx LFRULB
4211 EOM
4212         previous=''
4213         for flag in $*
4214         do
4215                 case "$flag" in
4216                 -*) ftry="$flag";;
4217                 *) ftry="$previous $flag";;
4218                 esac
4219                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4220                         >cpp1.out 2>/dev/null && \
4221                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4222                         >cpp2.out 2>/dev/null && \
4223                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4224                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4225                 then
4226                         cppflags="$cppflags $ftry"
4227                         previous=''
4228                 else
4229                         previous="$flag"
4230                 fi
4231         done
4232         set X $cppflags
4233         shift
4234         cppflags=${1+"$@"}
4235         case "$cppflags" in
4236         *-*)  echo "They appear to be: $cppflags";;
4237         esac
4238         $rm -f cpp.c cpp?.out
4239         ;;
4240 esac
4241
4242 : flags used in final linking phase
4243 case "$ldflags" in
4244 '') if ./venix; then
4245                 dflt='-i -z'
4246         else
4247                 dflt=''
4248         fi
4249         case "$ccflags" in
4250         *-posix*) dflt="$dflt -posix" ;;
4251         esac
4252         ;;
4253 *) dflt="$ldflags";;
4254 esac
4255
4256 : Try to guess additional flags to pick up local libraries.
4257 for thislibdir in $libpth; do
4258         case " $loclibpth " in
4259         *" $thislibdir "*)
4260                 case "$dflt " in 
4261                 *"-L$thislibdir "*) ;;
4262                 *)  dflt="$dflt -L$thislibdir" ;;
4263                 esac
4264                 ;;
4265         esac
4266 done
4267
4268 case "$dflt" in
4269 '') dflt='none' ;;
4270 esac
4271
4272 $cat <<EOH
4273
4274 Your C linker may need flags.  For this question you should
4275 include -L/whatever and any other flags used by the C linker, but you
4276 should NOT include libraries like -lwhatever.
4277
4278 Make sure you include the appropriate -L/path flags if your C linker
4279 does not normally search all of the directories you specified above,
4280 namely
4281         $libpth
4282 To use no flags, specify the word "none".
4283
4284 EOH
4285
4286 rp="Any additional ld flags (NOT including libraries)?"
4287 . ./myread
4288 case "$ans" in
4289 none) ldflags='';;
4290 *) ldflags="$ans";;
4291 esac
4292 rmlist="$rmlist pdp11"
4293
4294 : coherency check
4295 echo " "
4296 echo "Checking your choice of C compiler and flags for coherency..." >&4
4297 $cat > try.c <<'EOF'
4298 #include <stdio.h>
4299 int main() { printf("Ok\n"); exit(0); }
4300 EOF
4301 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4302 shift
4303 $cat >try.msg <<'EOM'
4304 I've tried to compile and run the following simple program:
4305
4306 EOM
4307 $cat try.c >> try.msg
4308
4309 $cat >> try.msg <<EOM
4310
4311 I used the command:
4312
4313         $*
4314         ./try
4315
4316 and I got the following output:
4317
4318 EOM
4319 dflt=y
4320 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4321         if sh -c './try' >>try.msg 2>&1; then
4322                 xxx=`./try`
4323                 case "$xxx" in
4324                 "Ok") dflt=n ;;
4325                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4326                         case " $libs " in
4327                         *" -lsfio "*)
4328                                 cat >> try.msg <<'EOQS'
4329 If $libs contains -lsfio, and sfio is mis-configured, then it
4330 sometimes (apparently) runs and exits with a 0 status, but with no
4331 output!  It may have to do with sfio's use of _exit vs. exit.
4332
4333 EOQS
4334                                 rp="You have a big problem.  Shall I abort Configure"
4335                                 dflt=y
4336                                 ;;
4337                         esac
4338                         ;;
4339                 esac
4340         else
4341                 echo "The program compiled OK, but exited with status $?." >>try.msg
4342                 rp="You have a problem.  Shall I abort Configure"
4343                 dflt=y
4344         fi
4345 else
4346         echo "I can't compile the test program." >>try.msg
4347         rp="You have a BIG problem.  Shall I abort Configure"
4348         dflt=y
4349 fi
4350 case "$dflt" in
4351 y)
4352         $cat try.msg >&4
4353         case "$knowitall" in
4354         '')
4355                 echo "(The supplied flags or libraries might be incorrect.)"
4356                 ;;
4357         *) dflt=n;;
4358         esac
4359         echo " "
4360         . ./myread
4361         case "$ans" in
4362         n*|N*) ;;
4363         *)      echo "Ok.  Stopping Configure." >&4
4364                 exit 1
4365                 ;;
4366         esac
4367         ;;
4368 n) echo "OK, that should do.";;
4369 esac
4370 $rm -f try try.* core
4371
4372 : determine filename position in cpp output
4373 echo " "
4374 echo "Computing filename position in cpp output for #include directives..." >&4
4375 echo '#include <stdio.h>' > foo.c
4376 $cat >fieldn <<EOF
4377 $startsh
4378 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4379 $grep '^[       ]*#.*stdio\.h' | \
4380 while read cline; do
4381         pos=1
4382         set \$cline
4383         while $test \$# -gt 0; do
4384                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4385                         echo "\$pos"
4386                         exit 0
4387                 fi
4388                 shift
4389                 pos=\`expr \$pos + 1\`
4390         done
4391 done
4392 EOF
4393 chmod +x fieldn
4394 fieldn=`./fieldn`
4395 $rm -f foo.c fieldn
4396 case $fieldn in
4397 '') pos='???';;
4398 1) pos=first;;
4399 2) pos=second;;
4400 3) pos=third;;
4401 *) pos="${fieldn}th";;
4402 esac
4403 echo "Your cpp writes the filename in the $pos field of the line."
4404
4405 : locate header file
4406 $cat >findhdr <<EOF
4407 $startsh
4408 wanted=\$1
4409 name=''
4410 for usrincdir in $usrinc
4411 do
4412         if test -f \$usrincdir/\$wanted; then
4413                 echo "\$usrincdir/\$wanted"
4414                 exit 0
4415         fi
4416 done
4417 awkprg='{ print \$$fieldn }'
4418 echo "#include <\$wanted>" > foo\$\$.c
4419 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4420 $grep "^[       ]*#.*\$wanted" | \
4421 while read cline; do
4422         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4423         case "\$name" in
4424         *[/\\\\]\$wanted) echo "\$name"; exit 1;;
4425         *[\\\\/]\$wanted) echo "\$name"; exit 1;;
4426         *) exit 2;;
4427         esac;
4428 done;
4429 #
4430 # status = 0: grep returned 0 lines, case statement not executed
4431 # status = 1: headerfile found
4432 # status = 2: while loop executed, no headerfile found
4433 #
4434 status=\$?
4435 $rm -f foo\$\$.c;
4436 if test \$status -eq 1; then
4437         exit 0;
4438 fi
4439 exit 1
4440 EOF
4441 chmod +x findhdr
4442
4443 : define an alternate in-header-list? function
4444 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4445 cont=true; xxf="echo \"<\$1> found.\" >&4";
4446 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4447 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4448 esac;
4449 case $# in 4) instead=instead;; *) instead="at last";; esac;
4450 while $test "$cont"; do
4451         xxx=`./findhdr $1`
4452         var=$2; eval "was=\$$2";
4453         if $test "$xxx" && $test -r "$xxx";
4454         then eval $xxf;
4455         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4456                 cont="";
4457         else eval $xxnf;
4458         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4459         set $yyy; shift; shift; yyy=$@;
4460         case $# in 0) cont="";;
4461         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4462                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4463         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4464                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4465         esac;
4466 done;
4467 while $test "$yyy";
4468 do set $yyy; var=$2; eval "was=\$$2";
4469         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4470         set $yyy; shift; shift; yyy=$@;
4471 done'
4472
4473 : see if this is a malloc.h system
4474 set malloc.h i_malloc
4475 eval $inhdr
4476
4477 : see if stdlib is available
4478 set stdlib.h i_stdlib
4479 eval $inhdr
4480
4481 : determine which malloc to compile in
4482 echo " "
4483 case "$usemymalloc" in
4484 ''|[yY]*|true|$define)  dflt='y' ;;
4485 *)      dflt='n' ;;
4486 esac
4487 rp="Do you wish to attempt to use the malloc that comes with $package?"
4488 . ./myread
4489 usemymalloc="$ans"
4490 case "$ans" in
4491 y*|true)
4492         usemymalloc='y'
4493         mallocsrc='malloc.c'
4494         mallocobj="malloc$_o"
4495         d_mymalloc="$define"
4496         case "$libs" in
4497         *-lmalloc*)
4498                 : Remove malloc from list of libraries to use
4499                 echo "Removing unneeded -lmalloc from library list" >&4
4500                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4501                 shift
4502                 libs="$*"
4503                 echo "libs = $libs" >&4
4504                 ;;
4505         esac
4506         ;;
4507 *)
4508         usemymalloc='n'
4509         mallocsrc=''
4510         mallocobj=''
4511         d_mymalloc="$undef"
4512         ;;
4513 esac
4514
4515 : compute the return types of malloc and free
4516 echo " "
4517 $cat >malloc.c <<END
4518 #$i_malloc I_MALLOC
4519 #$i_stdlib I_STDLIB
4520 #include <stdio.h>
4521 #include <sys/types.h>
4522 #ifdef I_MALLOC
4523 #include <malloc.h>
4524 #endif
4525 #ifdef I_STDLIB
4526 #include <stdlib.h>
4527 #endif
4528 #ifdef TRY_MALLOC
4529 void *malloc();
4530 #endif
4531 #ifdef TRY_FREE
4532 void free();
4533 #endif
4534 END
4535 case "$malloctype" in
4536 '')
4537         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4538                 malloctype='void *'
4539         else
4540                 malloctype='char *'
4541         fi
4542         ;;
4543 esac
4544 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4545
4546 case "$freetype" in
4547 '')
4548         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4549                 freetype='void'
4550         else
4551                 freetype='int'
4552         fi
4553         ;;
4554 esac
4555 echo "Your system uses $freetype free(), it would seem." >&4
4556 $rm -f malloc.[co]
4557 : Cruising for prototypes
4558 echo " "
4559 echo "Checking out function prototypes..." >&4
4560 $cat >prototype.c <<'EOCP'
4561 int main(int argc, char *argv[]) {
4562         exit(0);}
4563 EOCP
4564 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4565         echo "Your C compiler appears to support function prototypes."
4566         val="$define"
4567 else
4568         echo "Your C compiler doesn't seem to understand function prototypes."
4569         val="$undef"
4570 fi
4571 set prototype
4572 eval $setvar
4573 $rm -f prototype*
4574
4575 case "$prototype" in
4576 "$define") ;;
4577 *)      ansi2knr='ansi2knr'
4578         echo " "
4579         cat <<EOM >&4
4580
4581 $me:  FATAL ERROR:
4582 This version of $package can only be compiled by a compiler that 
4583 understands function prototypes.  Unfortunately, your C compiler 
4584         $cc $ccflags
4585 doesn't seem to understand them.  Sorry about that.
4586
4587 If GNU cc is available for your system, perhaps you could try that instead.  
4588
4589 Eventually, we hope to support building Perl with pre-ANSI compilers.
4590 If you would like to help in that effort, please contact <perlbug@perl.org>.
4591
4592 Aborting Configure now.
4593 EOM
4594         exit 2
4595         ;;
4596 esac
4597
4598 : determine where public executables go
4599 echo " "
4600 set dflt bin bin
4601 eval $prefixit
4602 fn=d~
4603 rp='Pathname where the public executables will reside?'
4604 . ./getfile
4605 if $test "X$ansexp" != "X$binexp"; then
4606         installbin=''
4607 fi
4608 bin="$ans"
4609 binexp="$ansexp"
4610 : Change installation prefix, if necessary.
4611 : XXX Bug? -- ignores Configure -Dinstallprefix setting.
4612 if $test X"$prefix" != X"$installprefix"; then
4613         installbin=`echo $binexp | sed 's#^$prefix#$installprefix#'`
4614 else
4615         installbin="$binexp"
4616 fi
4617
4618 : determine whether to install perl also as /usr/bin/perl
4619
4620 echo " "
4621 if $test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4622         $cat <<EOM
4623 Many scripts expect to perl to be installed as /usr/bin/perl.
4624 I can install the perl you are about to compile also as /usr/bin/perl
4625 (in addition to $installbin/perl).
4626 EOM
4627         case "$installusrbinperl" in
4628         "$undef"|[nN]*) dflt='n';;
4629         *)              dflt='y';;
4630         esac
4631         rp="Do you want to install perl as /usr/bin/perl?"
4632         . ./myread
4633         case "$ans" in
4634         [yY]*)  val="$define";;
4635         *)      val="$undef" ;;
4636         esac
4637 else
4638         val="$undef"
4639 fi
4640 set installusrbinperl
4641 eval $setvar
4642
4643 : define a shorthand compile call
4644 compile='
4645 mc_file=$1;
4646 shift;
4647 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4648 : define a shorthand compile call for compilations that should be ok.
4649 compile_ok='
4650 mc_file=$1;
4651 shift;
4652 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4653
4654 echo " "
4655 echo "Checking for GNU C Library..." >&4
4656 cat >gnulibc.c <<EOM
4657 #include <stdio.h>
4658 int main()
4659 {
4660 #ifdef __GLIBC__
4661     exit(0);
4662 #else
4663     exit(1);
4664 #endif
4665 }
4666 EOM
4667 set gnulibc
4668 if eval $compile_ok && ./gnulibc; then
4669         val="$define"
4670         echo "You are using the GNU C Library"
4671 else
4672         val="$undef"
4673         echo "You are not using the GNU C Library"
4674 fi
4675 $rm -f gnulibc*
4676 set d_gnulibc
4677 eval $setvar
4678
4679 : see if nm is to be used to determine whether a symbol is defined or not
4680 case "$usenm" in
4681 '')
4682         dflt=''
4683         case "$d_gnulibc" in
4684         "$define")
4685                 echo " "
4686                 echo "nm probably won't work on the GNU C Library." >&4
4687                 dflt=n
4688                 ;;
4689         esac
4690         case "$dflt" in
4691         '') 
4692                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4693                         echo " "
4694                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4695                         echo "'nm' won't be sufficient on this sytem." >&4
4696                         dflt=n
4697                 fi
4698                 ;;
4699         esac
4700         case "$dflt" in
4701         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4702                 if $test $dflt -gt 20; then
4703                         dflt=y
4704                 else
4705                         dflt=n
4706                 fi
4707                 ;;
4708         esac
4709         ;;
4710 *)
4711         case "$usenm" in
4712         true|$define) dflt=y;;
4713         *) dflt=n;;
4714         esac
4715         ;;
4716 esac
4717 $cat <<EOM
4718
4719 I can use $nm to extract the symbols from your C libraries. This
4720 is a time consuming task which may generate huge output on the disk (up
4721 to 3 megabytes) but that should make the symbols extraction faster. The
4722 alternative is to skip the 'nm' extraction part and to compile a small
4723 test program instead to determine whether each symbol is present. If
4724 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4725 this may be the best solution.
4726
4727 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4728
4729 EOM
4730 rp="Shall I use $nm to extract C symbols from the libraries?"
4731 . ./myread
4732 case "$ans" in
4733 [Nn]*) usenm=false;;
4734 *) usenm=true;;
4735 esac
4736
4737 runnm=$usenm
4738 case "$reuseval" in
4739 true) runnm=false;;
4740 esac
4741
4742 : nm options which may be necessary
4743 case "$nm_opt" in
4744 '') if $test -f /mach_boot; then
4745                 nm_opt=''       # Mach
4746         elif $test -d /usr/ccs/lib; then
4747                 nm_opt='-p'     # Solaris (and SunOS?)
4748         elif $test -f /dgux; then
4749                 nm_opt='-p'     # DG-UX
4750         elif $test -f /lib64/rld; then
4751                 nm_opt='-p'     # 64-bit Irix
4752         else
4753                 nm_opt=''
4754         fi;;
4755 esac
4756
4757 : nm options which may be necessary for shared libraries but illegal
4758 : for archive libraries.  Thank you, Linux.
4759 case "$nm_so_opt" in
4760 '')     case "$myuname" in
4761         *linux*)
4762                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4763                         nm_so_opt='--dynamic'
4764                 fi
4765                 ;;
4766         esac
4767         ;;
4768 esac
4769
4770 case "$runnm" in
4771 true)
4772 : get list of predefined functions in a handy place
4773 echo " "
4774 case "$libc" in
4775 '') libc=unknown
4776         case "$libs" in
4777         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4778         esac
4779         ;;
4780 esac
4781 libnames='';
4782 case "$libs" in
4783 '') ;;
4784 *)  for thislib in $libs; do
4785         case "$thislib" in
4786         -lc|-lc_s)
4787                 : Handle C library specially below.
4788                 ;;
4789         -l*)
4790                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4791                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4792                         :
4793                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4794                         :
4795                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4796                         :
4797                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4798                         :
4799                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4800                         :
4801                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4802                         :
4803                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4804                         :
4805                 else
4806                         try=''
4807                 fi
4808                 libnames="$libnames $try"
4809                 ;;
4810         *) libnames="$libnames $thislib" ;;
4811         esac
4812         done
4813         ;;
4814 esac
4815 xxx=normal
4816 case "$libc" in
4817 unknown)
4818         set /lib/libc.$so
4819         for xxx in $libpth; do
4820                 $test -r $1 || set $xxx/libc.$so
4821                 : The messy sed command sorts on library version numbers.
4822                 $test -r $1 || \
4823                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4824                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4825                                 h
4826                                 s/[0-9][0-9]*/0000&/g
4827                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4828                                 G
4829                                 s/\n/ /' | \
4830                          sort | $sed -e 's/^.* //'`
4831                 eval set \$$#
4832         done
4833         $test -r $1 || set /usr/ccs/lib/libc.$so
4834         $test -r $1 || set /lib/libsys_s$_a
4835         ;;
4836 *)
4837         set blurfl
4838         ;;
4839 esac
4840 if $test -r "$1"; then
4841         echo "Your (shared) C library seems to be in $1."
4842         libc="$1"
4843 elif $test -r /lib/libc && $test -r /lib/clib; then
4844         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4845         xxx=apollo
4846         libc='/lib/clib /lib/libc'
4847         if $test -r /lib/syslib; then
4848                 echo "(Your math library is in /lib/syslib.)"
4849                 libc="$libc /lib/syslib"
4850         fi
4851 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4852         echo "Your C library seems to be in $libc, as you said before."
4853 elif $test -r $incpath/usr/lib/libc$_a; then
4854         libc=$incpath/usr/lib/libc$_a;
4855         echo "Your C library seems to be in $libc.  That's fine."
4856 elif $test -r /lib/libc$_a; then
4857         libc=/lib/libc$_a;
4858         echo "Your C library seems to be in $libc.  You're normal."
4859 else
4860         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4861                 :
4862         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4863                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4864         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4865                 :
4866         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4867                 :
4868         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4869                 :
4870         else
4871                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4872         fi
4873         if $test -r "$tans"; then
4874                 echo "Your C library seems to be in $tans, of all places."
4875                 libc=$tans
4876         else
4877                 libc='blurfl'
4878         fi
4879 fi
4880 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4881         dflt="$libc"
4882         cat <<EOM
4883
4884 If the guess above is wrong (which it might be if you're using a strange
4885 compiler, or your machine supports multiple models), you can override it here.
4886
4887 EOM
4888 else
4889         dflt=''
4890         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4891         cat >&4 <<EOM
4892 I can't seem to find your C library.  I've looked in the following places:
4893
4894 EOM
4895         $sed 's/^/      /' libpath
4896         cat <<EOM
4897
4898 None of these seems to contain your C library. I need to get its name...
4899
4900 EOM
4901 fi
4902 fn=f
4903 rp='Where is your C library?'
4904 . ./getfile
4905 libc="$ans"
4906
4907 echo " "
4908 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4909 set X `cat libnames`
4910 shift
4911 xxx=files
4912 case $# in 1) xxx=file; esac
4913 echo "Extracting names from the following $xxx for later perusal:" >&4
4914 echo " "
4915 $sed 's/^/      /' libnames >&4
4916 echo " "
4917 $echo $n "This may take a while...$c" >&4
4918
4919 for file in $*; do
4920         case $file in
4921         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4922         *) $nm $nm_opt $file 2>/dev/null;;
4923         esac
4924 done >libc.tmp
4925
4926 $echo $n ".$c"
4927 $grep fprintf libc.tmp > libc.ptf
4928 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4929 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4930 xxx='[ADTSIW]'
4931 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4932         eval $xscan;\
4933         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4934                 eval $xrun
4935 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4936         eval $xscan;\
4937         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4938                 eval $xrun
4939 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4940         eval $xscan;\
4941         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4942                 eval $xrun
4943 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4944         eval $xscan;\
4945         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4946                 eval $xrun
4947 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4948         eval $xscan;\
4949         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4950                 eval $xrun
4951 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4952         eval $xscan;\
4953         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4954                 eval $xrun
4955 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4956                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4957         eval $xscan;\
4958         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4959                 eval $xrun
4960 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4961         eval $xscan;\
4962         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4963                 eval $xrun
4964 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4965         eval $xscan;\
4966         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4967                 eval $xrun
4968 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4969         eval $xscan;\
4970         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4971                 eval $xrun
4972 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4973         eval $xscan;\
4974         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4975                 eval $xrun
4976 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4977         eval $xscan;\
4978         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4979                 eval $xrun
4980 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4981         eval $xscan;\
4982         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4983                 eval $xrun
4984 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4985         eval $xscan;\
4986         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4987                 eval $xrun
4988 else
4989         $nm -p $* 2>/dev/null >libc.tmp
4990         $grep fprintf libc.tmp > libc.ptf
4991         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4992                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4993         then
4994                 nm_opt='-p'
4995                 eval $xrun
4996         else
4997                 echo " "
4998                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4999                 com=''
5000                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
5001                         for thisname in $libnames $libc; do
5002                                 $ar t $thisname >>libc.tmp
5003                         done
5004                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
5005                         echo "Ok." >&4
5006                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
5007                         # Repeat libc to extract forwarders to DLL entries too
5008                         for thisname in $libnames $libc; do
5009                                 $ar tv $thisname >>libc.tmp
5010                                 # Revision 50 of EMX has bug in $ar.
5011                                 # it will not extract forwarders to DLL entries
5012                                 # Use emximp which will extract exactly them.
5013                                 emximp -o tmp.imp $thisname \
5014                                     2>/dev/null && \
5015                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
5016                                     < tmp.imp >>libc.tmp
5017                                 $rm tmp.imp
5018                         done
5019                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
5020                         echo "Ok." >&4
5021                 else
5022                         echo "$ar didn't seem to work right." >&4
5023                         echo "Maybe this is a Cray...trying bld instead..." >&4
5024                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
5025                         then
5026                                 for thisname in $libnames; do
5027                                         bld t $libnames | \
5028                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
5029                                         $ar t $thisname >>libc.tmp
5030                                 done
5031                                 echo "Ok." >&4
5032                         else
5033                                 echo "That didn't work either.  Giving up." >&4
5034                                 exit 1
5035                         fi
5036                 fi
5037         fi
5038 fi
5039 nm_extract="$com"
5040 if $test -f /lib/syscalls.exp; then
5041         echo " "
5042         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
5043         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
5044 fi
5045 ;;
5046 esac
5047 $rm -f libnames libpath
5048
5049 : see if dld is available
5050 set dld.h i_dld
5051 eval $inhdr
5052
5053 : is a C symbol defined?
5054 csym='tlook=$1;
5055 case "$3" in
5056 -v) tf=libc.tmp; tc=""; tdc="";;
5057 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5058 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5059 esac;
5060 tx=yes;
5061 case "$reuseval-$4" in
5062 true-) ;;
5063 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5064 esac;
5065 case "$tx" in
5066 yes)
5067         case "$runnm" in
5068         true)
5069                 if $contains $tlook $tf >/dev/null 2>&1;
5070                 then tval=true;
5071                 else tval=false;
5072                 fi;;
5073         *)
5074                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5075                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5076                 then tval=true;
5077                 else tval=false;
5078                 fi;
5079                 $rm -f t t.c;;
5080         esac;;
5081 *)
5082         case "$tval" in
5083         $define) tval=true;;
5084         *) tval=false;;
5085         esac;;
5086 esac;
5087 eval "$2=$tval"'
5088
5089 : define an is-in-libc? function
5090 inlibc='echo " "; td=$define; tu=$undef;
5091 sym=$1; var=$2; eval "was=\$$2";
5092 tx=yes;
5093 case "$reuseval$was" in
5094 true) ;;
5095 true*) tx=no;;
5096 esac;
5097 case "$tx" in
5098 yes)
5099         set $sym tres -f;
5100         eval $csym;
5101         case "$tres" in
5102         true)
5103                 echo "$sym() found." >&4;
5104                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5105         *)
5106                 echo "$sym() NOT found." >&4;
5107                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5108         esac;;
5109 *)
5110         case "$was" in
5111         $define) echo "$sym() found." >&4;;
5112         *) echo "$sym() NOT found." >&4;;
5113         esac;;
5114 esac'
5115
5116 : see if dlopen exists
5117 xxx_runnm="$runnm"
5118 runnm=false
5119 set dlopen d_dlopen
5120 eval $inlibc
5121 runnm="$xxx_runnm"
5122
5123 : determine which dynamic loading, if any, to compile in
5124 echo " "
5125 dldir="ext/DynaLoader"
5126 case "$usedl" in
5127 $define|y|true)
5128         dflt='y'
5129         usedl="$define"
5130         ;;
5131 $undef|n|false)
5132         dflt='n'
5133         usedl="$undef"
5134         ;;
5135 *) 
5136         dflt='n'
5137         case "$d_dlopen" in
5138             $define) dflt='y' ;;
5139         esac
5140         case "$i_dld" in
5141             $define) dflt='y' ;;
5142         esac
5143         : Does a dl_xxx.xs file exist for this operating system
5144         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5145         ;;
5146 esac
5147 rp="Do you wish to use dynamic loading?"
5148 . ./myread
5149 usedl="$ans"
5150 case "$ans" in
5151 y*) usedl="$define"
5152         case "$dlsrc" in
5153         '')
5154                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5155                         dflt="$dldir/dl_${osname}.xs"
5156                 elif $test "$d_dlopen" = "$define" ; then
5157                         dflt="$dldir/dl_dlopen.xs"
5158                 elif $test "$i_dld" = "$define" ; then
5159                         dflt="$dldir/dl_dld.xs"
5160                 else
5161                         dflt=''
5162                 fi
5163                 ;;
5164         *)      dflt="$dldir/$dlsrc"
5165                 ;;
5166         esac
5167     echo "The following dynamic loading files are available:"
5168         : Can not go over to $dldir because getfile has path hard-coded in.
5169         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5170         rp="Source file to use for dynamic loading"
5171         fn="fne"
5172         # XXX This getfile call will fail the existence check if you try 
5173         # building away from $src (this is not supported yet).
5174         . ./getfile
5175         usedl="$define"
5176         : emulate basename
5177         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5178
5179         $cat << EOM
5180
5181 Some systems may require passing special flags to $cc -c to
5182 compile modules that will be used to create a shared library.
5183 To use no flags, say "none".
5184
5185 EOM
5186     case "$cccdlflags" in
5187     '') case "$gccversion" in
5188                 '') case "$osname" in
5189                         hpux)   dflt='+z' ;;
5190                         next)   dflt='none' ;;
5191                         irix*)  dflt='-KPIC' ;;
5192                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5193                         sunos)  dflt='-pic' ;;
5194                         *)      dflt='none' ;;
5195                     esac
5196                         ;;
5197                 *)  case "$osname" in
5198                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5199                         *)      dflt='-fpic' ;;
5200                     esac ;;
5201             esac ;;
5202         ' ') dflt='none' ;;
5203     *)  dflt="$cccdlflags" ;;
5204     esac
5205     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5206     . ./myread
5207     case "$ans" in
5208     none) cccdlflags=' ' ;;
5209     *) cccdlflags="$ans" ;;
5210     esac
5211
5212     cat << EOM
5213
5214 Some systems use ld to create libraries that can be dynamically loaded,
5215 while other systems (such as those using ELF) use $cc.
5216
5217 EOM
5218         case "$ld" in
5219         '')     $cat >try.c <<'EOM'
5220 /* Test for whether ELF binaries are produced */
5221 #include <fcntl.h>
5222 #include <stdlib.h>
5223 int main() {
5224         char b[4];
5225         int i = open("a.out",O_RDONLY);
5226         if(i == -1) 
5227                 exit(1); /* fail */
5228         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5229                 exit(0); /* succeed (yes, it's ELF) */
5230         else
5231                 exit(1); /* fail */
5232 }
5233 EOM
5234                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5235                         cat <<EOM
5236 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5237 EOM
5238                         dflt="$cc"
5239                 else
5240                         echo "I'll use ld to build dynamic libraries."
5241                         dflt='ld'
5242                 fi
5243                 rm -f try.c a.out
5244                 ;;
5245         *)      dflt="$ld"
5246                 ;;
5247         esac
5248
5249     rp="What command should be used to create dynamic libraries?"
5250     . ./myread
5251         ld="$ans"
5252
5253     cat << EOM
5254
5255 Some systems may require passing special flags to $ld to create a
5256 library that can be dynamically loaded.  If your ld flags include
5257 -L/other/path options to locate libraries outside your loader's normal
5258 search path, you may need to specify those -L options here as well.  To
5259 use no flags, say "none".
5260
5261 EOM
5262     case "$lddlflags" in
5263     '') case "$osname" in
5264                         beos) dflt='-nostart' ;;
5265                         hpux)  dflt='-b' ;;
5266                         linux|irix*)    dflt='-shared' ;;
5267                         next)  dflt='none' ;;
5268                         solaris) dflt='-G' ;;
5269                         sunos) dflt='-assert nodefinitions' ;;
5270                         svr4*|esix*) dflt="-G $ldflags" ;;
5271                 *)     dflt='none' ;;
5272                         esac
5273                         ;;
5274     *) dflt="$lddlflags" ;;
5275     esac
5276
5277         : Try to guess additional flags to pick up local libraries.
5278         : Be careful not to append to a plain 'none'
5279         case "$dflt" in
5280         none) dflt='' ;;
5281         esac
5282         for thisflag in $ldflags; do
5283                 case "$thisflag" in
5284                 -L*)
5285                         case " $dflt " in
5286                         *" $thisflag "*) ;;
5287                         *) dflt="$dflt $thisflag" ;;
5288                         esac
5289                         ;;
5290                 esac
5291         done
5292
5293         case "$dflt" in
5294         ''|' ') dflt='none' ;;
5295         esac
5296
5297     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5298     . ./myread
5299     case "$ans" in
5300     none) lddlflags=' ' ;;
5301     *) lddlflags="$ans" ;;
5302     esac
5303
5304         cat <<EOM
5305
5306 Some systems may require passing special flags to $cc to indicate that
5307 the resulting executable will use dynamic linking.  To use no flags,
5308 say "none".
5309
5310 EOM
5311     case "$ccdlflags" in
5312     '') case "$osname" in
5313                 hpux)   dflt='-Wl,-E' ;;
5314                 linux)  dflt='-rdynamic' ;;
5315                 next)   dflt='none' ;;
5316                 sunos)  dflt='none' ;;
5317                 *)      dflt='none' ;;
5318             esac ;;
5319     ' ')  dflt='none' ;;
5320     *)  dflt="$ccdlflags" ;;
5321     esac
5322     rp="Any special flags to pass to $cc to use dynamic loading?"
5323     . ./myread
5324     case "$ans" in
5325     none) ccdlflags=' ' ;;
5326     *) ccdlflags="$ans" ;;
5327     esac
5328     ;;
5329 *)  usedl="$undef"
5330         ld='ld'
5331     dlsrc='dl_none.xs'
5332     lddlflags=''
5333     ccdlflags=''
5334     ;;
5335 esac
5336
5337 also=''
5338 case "$usedl" in
5339 $undef)
5340         # No dynamic loading being used, so don't bother even to prompt.
5341         useshrplib='false'
5342         ;;
5343 *)      case "$useshrplib" in
5344         '')     case "$osname" in
5345                 svr4*|dgux|dynixptx|esix|powerux|beos)
5346                         dflt=y
5347                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5348                         ;;
5349                 next*)
5350                         case "$osvers" in
5351                         4*)     dflt=y
5352                                 also='Building a shared libperl is needed for MAB support.'
5353                                 ;;
5354                         *)      dflt=n
5355                                 ;;
5356                         esac
5357                         ;;
5358                 *)      dflt=n
5359                         ;;
5360                 esac
5361                 ;;
5362         $define|true|[Yy]*)
5363                 dflt=y
5364                 ;;
5365         *)      dflt=n
5366                 ;;
5367         esac
5368         $cat << EOM
5369
5370 The perl executable is normally obtained by linking perlmain.c with
5371 libperl${_a}, any static extensions (usually just DynaLoader), and
5372 any other libraries needed on this system (such as -lm, etc.).  Since
5373 your system supports dynamic loading, it is probably possible to build
5374 a shared libperl.$so.  If you will have more than one executable linked
5375 to libperl.$so, this will significantly reduce the size of each
5376 executable, but it may have a noticeable affect on performance.  The
5377 default is probably sensible for your system.
5378 $also
5379
5380 EOM
5381         rp="Build a shared libperl.$so (y/n)"
5382         . ./myread
5383         case "$ans" in
5384         true|$define|[Yy]*)
5385                 useshrplib='true'  ;;
5386         *)      useshrplib='false' ;;
5387         esac
5388         ;;
5389 esac
5390
5391 case "$useshrplib" in
5392 true)
5393         case "$libperl" in
5394         '')
5395                 # Figure out a good name for libperl.so.  Since it gets stored in
5396                 # a version-specific architecture-dependent library, the version
5397                 # number isn't really that important, except for making cc/ld happy.
5398                 #
5399                 # A name such as libperl.so.3.1
5400                 majmin="libperl.$so.$patchlevel.$subversion"
5401                 # A name such as libperl.so.301
5402                 majonly=`echo $patchlevel $subversion |
5403                         $awk '{printf "%d%02d", $1, $2}'`
5404                 majonly=libperl.$so.$majonly
5405                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5406                 # rely on figuring it out from the naming of libc.
5407                 case "${osname}${osvers}" in
5408                 next4*)
5409                         dflt=libperl.5.$so
5410                         # XXX How handle the --version stuff for MAB?
5411                         ;;
5412                 linux*)  # ld won't link with a bare -lperl otherwise.
5413                         dflt=libperl.$so
5414                         ;;
5415                 *)      # Try to guess based on whether libc has major.minor.
5416                         case "$libc" in
5417                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5418                         *libc.$so.[0-9]*) dflt=$majonly ;;
5419                         *)      dflt=libperl.$so ;;
5420                         esac
5421                         ;;
5422                 esac
5423                 ;;
5424         *)      dflt=$libperl
5425                 ;;
5426         esac
5427         cat << EOM
5428
5429 I need to select a good name for the shared libperl.  If your system uses
5430 library names with major and minor numbers, then you might want something
5431 like $majmin.  Alternatively, if your system uses a single version
5432 number for shared libraries, then you might want to use $majonly.
5433 Or, your system might be quite happy with a simple libperl.$so.
5434
5435 Since the shared libperl will get installed into a version-specific
5436 architecture-dependent directory, the version number of the shared perl
5437 library probably isn't important, so the default should be o.k.
5438
5439 EOM
5440         rp='What name do you want to give to the shared libperl?'
5441         . ./myread
5442         libperl=$ans
5443         echo "Ok, I'll use $libperl"
5444         ;;
5445 *)
5446         libperl="libperl${_a}"
5447         ;;
5448 esac
5449
5450 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5451 case "$shrpdir" in
5452 '') ;;
5453 *)      $cat >&4 <<EOM
5454 WARNING:  Use of the shrpdir variable for the installation location of
5455 the shared $libperl is not supported.  It was never documented and
5456 will not work in this version.  Let me (perlbug@perl.com)
5457 know of any problems this may cause.
5458
5459 EOM
5460         case "$shrpdir" in
5461         "$archlibexp/CORE")
5462                 $cat >&4 <<EOM
5463 But your current setting of $shrpdir is
5464 the default anyway, so it's harmless.
5465 EOM
5466                 ;;
5467         *)
5468                 $cat >&4 <<EOM
5469 Further, your current attempted setting of $shrpdir
5470 conflicts with the value of $archlibexp/CORE
5471 that installperl will use.
5472 EOM
5473                 ;;
5474         esac
5475         ;;
5476 esac
5477
5478 # How will the perl executable find the installed shared $libperl?
5479 # Add $xxx to ccdlflags.
5480 # If we can't figure out a command-line option, use $shrpenv to
5481 # set env LD_RUN_PATH.  The main perl makefile uses this.
5482 shrpdir=$archlibexp/CORE
5483 xxx=''
5484 tmp_shrpenv=''
5485 if "$useshrplib"; then
5486     case "$osname" in 
5487         aix)
5488                 # We'll set it in Makefile.SH...
5489                 ;;
5490         solaris|netbsd)
5491                 xxx="-R $shrpdir"
5492                 ;;
5493         freebsd)
5494                 xxx="-Wl,-R$shrpdir"
5495                 ;;
5496         linux|irix*|dec_osf)
5497                 xxx="-Wl,-rpath,$shrpdir"
5498                 ;;
5499         next)
5500                 # next doesn't like the default...
5501                 ;;
5502         beos)
5503                 # beos doesn't like the default, either.
5504                 ;;
5505         hpux*)
5506                 # hpux doesn't like the default, either.
5507                 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
5508                 ;;
5509         *)
5510                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5511                 ;;
5512         esac
5513         case "$xxx" in
5514         '') ;;
5515         *)      
5516                 # Only add $xxx if it isn't already in ccdlflags.
5517                 case " $ccdlflags " in
5518                 *" $xxx "*)     ;;
5519                 *)      ccdlflags="$ccdlflags $xxx"
5520                         cat <<EOM >&4
5521
5522 Adding $xxx to the flags
5523 passed to $ld so that the perl executable will find the 
5524 installed shared $libperl.
5525
5526 EOM
5527                         ;;
5528                 esac
5529                 ;;
5530         esac
5531 fi
5532 # Fix ccdlflags in AIX for building external extensions.
5533 # (For building Perl itself bare -bE:perl.exp is needed,
5534 #  Makefile.SH takes care of this.)
5535 case "$osname" in
5536 aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
5537 esac
5538 # Respect a hint or command-line value.
5539 case "$shrpenv" in
5540 '') shrpenv="$tmp_shrpenv" ;;
5541 esac
5542 case "$ldlibpthname" in
5543 '')     ldlibpthname=LD_LIBRARY_PATH ;;
5544 none)   ldlibpthname='' ;;
5545 esac
5546
5547 : determine where manual pages go
5548 set man1dir man1dir none
5549 eval $prefixit
5550 $cat <<EOM
5551
5552 $spackage has manual pages available in source form.
5553 EOM
5554 case "$nroff" in
5555 nroff)
5556         echo "However, you don't have nroff, so they're probably useless to you."
5557         case "$man1dir" in
5558         '') man1dir="none";;
5559         esac;;
5560 esac
5561 echo "If you don't want the manual sources installed, answer 'none'."
5562 case "$man1dir" in
5563 ' ') dflt=none
5564         ;;
5565 '')
5566         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5567         lookpath="$lookpath $prefixexp/man/p_man/man1"
5568         lookpath="$lookpath $prefixexp/man/u_man/man1"
5569         lookpath="$lookpath $prefixexp/man/man.1"
5570         case "$sysman" in
5571         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5572         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5573         esac
5574         set dflt
5575         eval $prefixup
5576         ;;
5577 *)  dflt="$man1dir"
5578         ;;
5579 esac
5580 echo " "
5581 fn=dn+~
5582 rp="Where do the main $spackage manual pages (source) go?"
5583 . ./getfile
5584 if $test "X$man1direxp" != "X$ansexp"; then
5585         installman1dir=''
5586 fi
5587 man1dir="$ans"
5588 man1direxp="$ansexp"
5589 case "$man1dir" in
5590 '')     man1dir=' '
5591         installman1dir='';;
5592 esac
5593
5594 : Change installation prefix, if necessary.
5595 if $test X"$prefix" != X"$installprefix"; then
5596         installman1dir=`echo $man1direxp | $sed 's#^$prefix#$installprefix#'`
5597 else
5598         installman1dir="$man1direxp"
5599 fi
5600
5601 : What suffix to use on installed man pages
5602
5603 case "$man1dir" in
5604 ' ')
5605         man1ext='0'
5606         ;;
5607 *)
5608         rp="What suffix should be used for the main $spackage man pages?"
5609         case "$man1ext" in
5610         '')     case "$man1dir" in
5611                 *1)  dflt=1 ;;
5612                 *1p) dflt=1p ;;
5613                 *1pm) dflt=1pm ;;
5614                 *l) dflt=l;;
5615                 *n) dflt=n;;
5616                 *o) dflt=o;;
5617                 *p) dflt=p;;
5618                 *C) dflt=C;;
5619                 *L) dflt=L;;
5620                 *L1) dflt=L1;;
5621                 *) dflt=1;;
5622                 esac
5623                 ;;
5624         *)      dflt="$man1ext";;
5625         esac
5626         . ./myread
5627         man1ext="$ans"
5628         ;;
5629 esac
5630
5631 : see if we can have long filenames
5632 echo " "
5633 rmlist="$rmlist /tmp/cf$$"
5634 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5635 first=123456789abcdef
5636 second=/tmp/cf$$/$first
5637 $rm -f $first $second
5638 if (echo hi >$first) 2>/dev/null; then
5639         if $test -f 123456789abcde; then
5640                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5641                 val="$undef"
5642         else
5643                 if (echo hi >$second) 2>/dev/null; then
5644                         if $test -f /tmp/cf$$/123456789abcde; then
5645                                 $cat <<'EOM'
5646 That's peculiar... You can have filenames longer than 14 characters, but only
5647 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5648 I shall consider your system cannot support long filenames at all.
5649 EOM
5650                                 val="$undef"
5651                         else
5652                                 echo 'You can have filenames longer than 14 characters.' >&4
5653                                 val="$define"
5654                         fi
5655                 else
5656                         $cat <<'EOM'
5657 How confusing! Some of your filesystems are sane enough to allow filenames
5658 longer than 14 characters but some others like /tmp can't even think about them.
5659 So, for now on, I shall assume your kernel does not allow them at all.
5660 EOM
5661                         val="$undef"
5662                 fi
5663         fi
5664 else
5665         $cat <<'EOM'
5666 You can't have filenames longer than 14 chars.  You can't even think about them!
5667 EOM
5668         val="$undef"
5669 fi 
5670 set d_flexfnam
5671 eval $setvar
5672 $rm -rf /tmp/cf$$ 123456789abcde*
5673
5674 : determine where library module manual pages go
5675 set man3dir man3dir none
5676 eval $prefixit
5677 $cat <<EOM
5678
5679 $spackage has manual pages for many of the library modules.
5680 EOM
5681
5682 case "$nroff" in
5683 nroff)
5684         $cat <<'EOM'
5685 However, you don't have nroff, so they're probably useless to you.
5686 EOM
5687         case "$man3dir" in
5688         '') man3dir="none";;
5689         esac;;
5690 esac
5691
5692 case "$d_flexfnam" in
5693 undef)
5694         $cat <<'EOM'
5695 However, your system can't handle the long file names like File::Basename.3. 
5696 EOM
5697         case "$man3dir" in
5698         '') man3dir="none";;
5699         esac;;
5700 esac
5701
5702 echo "If you don't want the manual sources installed, answer 'none'."
5703 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5704 case "$man3dir" in
5705 '')     dflt=`echo $man1dir | $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'`
5706         if $test -d "$privlib/man/man3"; then
5707                 cat <<EOM >&4
5708
5709 WARNING:  Previous versions of perl installed man3 pages into
5710 $privlib/man/man3.  This version will suggest a 
5711 new default of $dflt.  
5712 EOM
5713                 tdflt=$dflt
5714                 dflt='n'
5715                 rp='Do you wish to preserve the old behavior?(y/n)'
5716                 . ./myread
5717                 case "$ans" in
5718                 y*) dflt="$privlib/man/man3" ;;
5719                 *)  dflt=$tdflt ;;
5720                 esac
5721     fi
5722         ;;
5723 ' ') dflt=none;;
5724 *)      dflt="$man3dir" ;;
5725 esac
5726 echo " "
5727 fn=dn+~
5728 rp="Where do the $package library man pages (source) go?"
5729 . ./getfile
5730 man3dir="$ans"
5731 man3direxp="$ansexp"
5732 case "$man1dir" in
5733 '')     man3dir=' '
5734         installman3dir='';;
5735 esac
5736
5737 : Change installation prefix, if necessary.
5738 if $test X"$prefix" != X"$installprefix"; then
5739         installman3dir=`echo $man3direxp | $sed 's#^$prefix#$installprefix#'`
5740 else
5741         installman3dir="$man3direxp"
5742 fi
5743
5744 : What suffix to use on installed man pages
5745 case "$man3dir" in
5746 ' ')
5747         man3ext='0'
5748         ;;
5749 *)
5750         rp="What suffix should be used for the $package library man pages?"
5751         case "$man3ext" in
5752         '')     case "$man3dir" in
5753                 *3)  dflt=3 ;;
5754                 *3p) dflt=3p ;;
5755                 *3pm) dflt=3pm ;;
5756                 *l) dflt=l;;
5757                 *n) dflt=n;;
5758                 *o) dflt=o;;
5759                 *p) dflt=p;;
5760                 *C) dflt=C;;
5761                 *L) dflt=L;;
5762                 *L3) dflt=L3;;
5763                 *) dflt=3;;
5764                 esac
5765                 ;;
5766         *)      dflt="$man3ext";;
5767         esac
5768         . ./myread
5769         man3ext="$ans"
5770         ;;
5771 esac
5772
5773 : see if we have to deal with yellow pages, now NIS.
5774 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5775         if $test -f /usr/etc/nibindd; then
5776                 echo " "
5777                 echo "I'm fairly confident you're on a NeXT."
5778                 echo " "
5779                 rp='Do you get the hosts file via NetInfo?'
5780                 dflt=y
5781                 case "$hostcat" in
5782                 nidump*) ;;
5783                 '') ;;
5784                 *) dflt=n;;
5785                 esac
5786                 . ./myread
5787                 case "$ans" in
5788                 y*) hostcat='nidump hosts .';;
5789                 *)      case "$hostcat" in
5790                         nidump*) hostcat='';;
5791                         esac
5792                         ;;
5793                 esac
5794         fi
5795         case "$hostcat" in
5796         nidump*) ;;
5797         *)
5798                 case "$hostcat" in
5799                 *ypcat*) dflt=y;;
5800                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5801                                 dflt=y
5802                         else
5803                                 dflt=n
5804                         fi;;
5805                 *) dflt=n;;
5806                 esac
5807                 echo " "
5808                 rp='Are you getting the hosts file via yellow pages?'
5809                 . ./myread
5810                 case "$ans" in
5811                 y*) hostcat='ypcat hosts';;
5812                 *) hostcat='cat /etc/hosts';;
5813                 esac
5814                 ;;
5815         esac
5816 fi
5817 case "$hostcat" in
5818 '') hostcat='cat /etc/hosts';;
5819 esac
5820 case "$groupcat" in
5821 '') groupcat='cat /etc/group';;
5822 esac
5823 case "$passcat" in
5824 '') passcat='cat /etc/passwd';;
5825 esac
5826
5827 : now get the host name
5828 echo " "
5829 echo "Figuring out host name..." >&4
5830 case "$myhostname" in
5831 '') cont=true
5832         echo 'Maybe "hostname" will work...'
5833         if tans=`sh -c hostname 2>&1` ; then
5834                 myhostname=$tans
5835                 phostname=hostname
5836                 cont=''
5837         fi
5838         ;;
5839 *) cont='';;
5840 esac
5841 if $test "$cont"; then
5842         if ./xenix; then
5843                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5844                 if tans=`cat /etc/systemid 2>&1` ; then
5845                         myhostname=$tans
5846                         phostname='cat /etc/systemid'
5847                         echo "Whadyaknow.  Xenix always was a bit strange..."
5848                         cont=''
5849                 fi
5850         elif $test -r /etc/systemid; then
5851                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5852         fi
5853 fi
5854 if $test "$cont"; then
5855         echo 'No, maybe "uuname -l" will work...'
5856         if tans=`sh -c 'uuname -l' 2>&1` ; then
5857                 myhostname=$tans
5858                 phostname='uuname -l'
5859         else
5860                 echo 'Strange.  Maybe "uname -n" will work...'
5861                 if tans=`sh -c 'uname -n' 2>&1` ; then
5862                         myhostname=$tans
5863                         phostname='uname -n'
5864                 else
5865                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5866                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5867                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5868                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5869                         else
5870                                 case "$myhostname" in
5871                                 '') echo "Does this machine have an identity crisis or something?"
5872                                         phostname='';;
5873                                 *)
5874                                         echo "Well, you said $myhostname before..."
5875                                         phostname='echo $myhostname';;
5876                                 esac
5877                         fi
5878                 fi
5879         fi
5880 fi
5881 : you do not want to know about this
5882 set $myhostname
5883 myhostname=$1
5884
5885 : verify guess
5886 if $test "$myhostname" ; then
5887         dflt=y
5888         rp='Your host name appears to be "'$myhostname'".'" Right?"
5889         . ./myread
5890         case "$ans" in
5891         y*) ;;
5892         *) myhostname='';;
5893         esac
5894 fi
5895
5896 : bad guess or no guess
5897 while $test "X$myhostname" = X ; do
5898         dflt=''
5899         rp="Please type the (one word) name of your host:"
5900         . ./myread
5901         myhostname="$ans"
5902 done
5903
5904 : translate upper to lower if necessary
5905 case "$myhostname" in
5906 *[A-Z]*)
5907         echo "(Normalizing case in your host name)"
5908         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5909         ;;
5910 esac
5911
5912 case "$myhostname" in
5913 *.*)
5914         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5915         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5916         echo "(Trimming domain name from host name--host name is now $myhostname)"
5917         ;;
5918 *) case "$mydomain" in
5919         '')
5920                 {
5921                         test "X$hostcat" = "Xypcat hosts" &&
5922                         ypmatch "$myhostname" hosts 2>/dev/null |\
5923                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5924                         $test -s hosts
5925                 } || {
5926                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5927                                         /[       ]$myhostname[  . ]/p" > hosts
5928                 }
5929                 tmp_re="[       . ]"
5930                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5931                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5932                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5933                         hosts | $sort | $uniq | \
5934                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5935                 case `$echo X$dflt` in
5936                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5937                         dflt=.
5938                         ;;
5939                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5940                         ;;
5941                 esac
5942                 case "$dflt" in
5943                 .)
5944                         tans=`./loc resolv.conf X /etc /usr/etc`
5945                         if $test -f "$tans"; then
5946                                 echo "(Attempting domain name extraction from $tans)"
5947                                 dflt=.`$sed -n -e 's/   / /g' \
5948                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5949                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5950                                 case "$dflt" in
5951                                 .) dflt=.`$sed -n -e 's/        / /g' \
5952                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5953                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5954                                         ;;
5955                                 esac
5956                         fi
5957                         ;;
5958                 esac
5959                 case "$dflt" in
5960                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5961                         dflt=.`sh -c domainname 2>/dev/null`
5962                         case "$dflt" in
5963                         '') dflt='.';;
5964                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5965                         esac
5966                         ;;
5967                 esac
5968                 case "$dflt" in
5969                 .) echo "(Lost all hope -- silly guess then)"
5970                         dflt='.uucp'
5971                         ;;
5972                 esac
5973                 $rm -f hosts
5974                 ;;
5975         *) dflt="$mydomain";;
5976         esac;;
5977 esac
5978 echo " "
5979 rp="What is your domain name?"
5980 . ./myread
5981 tans="$ans"
5982 case "$ans" in
5983 '') ;;
5984 .*) ;;
5985 *) tans=".$tans";;
5986 esac
5987 mydomain="$tans"
5988
5989 : translate upper to lower if necessary
5990 case "$mydomain" in
5991 *[A-Z]*)
5992         echo "(Normalizing case in your domain name)"
5993         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5994         ;;
5995 esac
5996
5997 : a little sanity check here
5998 case "$phostname" in
5999 '') ;;
6000 *)
6001         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
6002         $myhostname$mydomain|$myhostname) ;;
6003         *)
6004                 case "$phostname" in
6005                 sed*)
6006                         echo "(That doesn't agree with your whoami.h file, by the way.)"
6007                         ;;
6008                 *)
6009                         echo "(That doesn't agree with your $phostname command, by the way.)"
6010                         ;;
6011                 esac
6012         ;;
6013         esac
6014         ;;
6015 esac
6016
6017 $cat <<EOM
6018
6019 I need to get your e-mail address in Internet format if possible, i.e.
6020 something like user@host.domain. Please answer accurately since I have
6021 no easy means to double check it. The default value provided below
6022 is most probably close to the reality but may not be valid from outside
6023 your organization...
6024
6025 EOM
6026 cont=x
6027 while test "$cont"; do
6028         case "$cf_email" in
6029         '') dflt="$cf_by@$myhostname$mydomain";;
6030         *) dflt="$cf_email";;
6031         esac
6032         rp='What is your e-mail address?'
6033         . ./myread
6034         cf_email="$ans"
6035         case "$cf_email" in
6036         *@*.*) cont='' ;;
6037         *)
6038                 rp='Address does not look like an Internet one.  Use it anyway?'
6039                 case "$fastread" in
6040                 yes) dflt=y ;;
6041                 *) dflt=n ;;
6042                 esac
6043                 . ./myread
6044                 case "$ans" in
6045                 y*) cont='' ;;
6046                 *) echo " " ;;
6047                 esac
6048                 ;;
6049         esac
6050 done
6051
6052 $cat <<EOM
6053
6054 If you or somebody else will be maintaining perl at your site, please
6055 fill in the correct e-mail address here so that they may be contacted
6056 if necessary. Currently, the "perlbug" program included with perl
6057 will send mail to this address in addition to perlbug@perl.com. You may
6058 enter "none" for no administrator.
6059
6060 EOM
6061 case "$perladmin" in
6062 '') dflt="$cf_email";;
6063 *) dflt="$perladmin";;
6064 esac
6065 rp='Perl administrator e-mail address'
6066 . ./myread
6067 perladmin="$ans"
6068
6069 : figure out how to guarantee perl startup
6070 case "$startperl" in
6071 '')
6072         case "$sharpbang" in
6073         *!)
6074                 $cat <<EOH
6075
6076 I can use the #! construct to start perl on your system. This will
6077 make startup of perl scripts faster, but may cause problems if you
6078 want to share those scripts and perl is not in a standard place
6079 ($binexp/perl) on all your platforms. The alternative is to force
6080 a shell by starting the script with a single ':' character.
6081
6082 EOH
6083                 dflt="$binexp/perl"
6084                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6085                 . ./myread
6086                 case "$ans" in
6087                 none)   startperl=": # use perl";;
6088                 *)      startperl="#!$ans"
6089                         if $test 30 -lt `echo "$ans" | wc -c`; then
6090                                 $cat >&4 <<EOM
6091
6092 WARNING:  Some systems limit the #! command to 32 characters.
6093 If you experience difficulty running Perl scripts with #!, try
6094 installing Perl in a directory with a shorter pathname.
6095
6096 EOM
6097                         fi ;;
6098                 esac
6099                 ;;
6100         *) startperl=": # use perl"
6101                 ;;
6102         esac
6103         ;;
6104 esac
6105 echo "I'll use $startperl to start perl scripts."
6106
6107 : figure best path for perl in scripts
6108 case "$perlpath" in
6109 '')
6110         perlpath="$binexp/perl"
6111         case "$startperl" in
6112         *!*) ;;
6113         *)
6114                 $cat <<EOH
6115
6116 I will use the "eval 'exec'" idiom to start Perl on your system.
6117 I can use the full path of your Perl binary for this purpose, but
6118 doing so may cause problems if you want to share those scripts and
6119 Perl is not always in a standard place ($binexp/perl).
6120
6121 EOH
6122                 dflt="$binexp/perl"
6123                 rp="What path shall I use in \"eval 'exec'\"?"
6124                 . ./myread
6125                 perlpath="$ans"
6126                 ;;
6127         esac
6128         ;;
6129 esac
6130 case "$startperl" in
6131 *!*)    ;;
6132 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6133 esac
6134
6135 : determine where public executable scripts go
6136 set scriptdir scriptdir
6137 eval $prefixit
6138 case "$scriptdir" in
6139 '')
6140         dflt="$bin"
6141         : guess some guesses
6142         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6143         $test -d /usr/share/bin     && dflt=/usr/share/bin
6144         $test -d /usr/local/script  && dflt=/usr/local/script
6145         $test -d /usr/local/scripts && dflt=/usr/local/scripts
6146         $test -d $prefixexp/script  && dflt=$prefixexp/script
6147         set dflt
6148         eval $prefixup
6149         ;;
6150 *)  dflt="$scriptdir"
6151         ;;
6152 esac
6153 $cat <<EOM
6154  
6155 Some installations have a separate directory just for executable scripts so
6156 that they can mount it across multiple architectures but keep the scripts in
6157 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6158 Or you might just lump your scripts in with all your other executables.
6159  
6160 EOM
6161 fn=d~
6162 rp='Where do you keep publicly executable scripts?'
6163 . ./getfile
6164 if $test "X$ansexp" != "X$scriptdirexp"; then
6165         installscript=''
6166 fi
6167 scriptdir="$ans"
6168 scriptdirexp="$ansexp"
6169 : Change installation prefix, if necessary.
6170 if $test X"$prefix" != X"$installprefix"; then
6171         installscript=`echo $scriptdirexp | sed 's#^$prefix#$installprefix#'`
6172 else
6173         installscript="$scriptdirexp"
6174 fi
6175
6176 $cat <<EOM
6177
6178 After $package is installed, you may wish to install various
6179 add-on modules and utilities.  Typically, these add-ons will
6180 be installed under $prefix with the rest
6181 of this package.  However, you may wish to install such add-ons
6182 elsewhere under a different prefix.
6183
6184 If you do not wish to put everything under a single prefix, that's
6185 ok.  You will be prompted for the individual locations; this siteprefix
6186 is only used to suggest the defaults.
6187
6188 The default should be fine for most people.
6189
6190 EOM
6191 fn=d~+
6192 rp='Installation prefix to use for add-on modules and utilities?'
6193 : XXX Here might be another good place for an installstyle setting.
6194 case "$siteprefix" in
6195 '') dflt=$prefix ;;
6196 *)  dflt=$siteprefix ;;
6197 esac
6198 . ./getfile
6199 oldsiteprefix=''
6200 case "$siteprefix" in
6201 '') ;;
6202 *)
6203         case "$ans" in
6204         "$prefix") ;;
6205         *) oldsiteprefix="$prefix";;
6206         esac
6207         ;;
6208 esac
6209 siteprefix="$ans"
6210 siteprefixexp="$ansexp"
6211
6212 : determine where site specific libraries go.
6213 : Usual default is /usr/local/lib/perl5/site_perl
6214 : The default "style" setting is made in installstyle.U
6215 : XXX No longer works with Prefixit stuff.
6216 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6217 case "$installstyle" in
6218 *lib/perl5*) dflt=$siteprefix/lib/site_$prog/ ;;
6219 *)       dflt=$siteprefix/lib/site_$prog ;;
6220 esac
6221 $cat <<EOM
6222
6223 The installation process will create a directory for
6224 site-specific extensions and modules.  Most users find it convenient
6225 to place all site-specific files in this directory rather than in the
6226 main distribution directory.
6227
6228 EOM
6229 fn=d~+
6230 rp='Pathname for the site-specific library files?'
6231 . ./getfile
6232 sitelib="$ans"
6233 sitelibexp="$ansexp"
6234 : Change installation prefix, if necessary.
6235 if $test X"$prefix" != X"$installprefix"; then
6236         installsitelib=`echo $sitelibexp | sed 's#^$prefix#$installprefix#'`
6237 else
6238         installsitelib="$sitelibexp"
6239 fi
6240
6241 : determine where site specific architecture-dependent libraries go.
6242 : sitelib  default is /usr/local/lib/perl5/site_perl/
6243 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6244 : sitelib may have an optional trailing /share.
6245 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6246 tdflt="$tdflt/$apiversion/$archname"
6247 set sitearch sitearch none
6248 eval $prefixit
6249 case "$sitearch" in
6250 '')     dflt="$tdflt" ;;
6251 *)      dflt="$sitearch" ;;
6252 esac
6253 $cat <<EOM
6254
6255 The installation process will also create a directory for
6256 architecture-dependent site-specific extensions and modules.
6257
6258 EOM
6259 fn=nd~+
6260 rp='Pathname for the site-specific architecture-dependent library files?'
6261 . ./getfile
6262 sitearch="$ans"
6263 sitearchexp="$ansexp"
6264 : Change installation prefix, if necessary.
6265 if $test X"$prefix" != X"$installprefix"; then
6266         installsitearch=`echo $sitearchexp | sed 's#^$prefix#$installprefix#'`
6267 else
6268         installsitearch="$sitearchexp"
6269 fi
6270
6271 cat <<EOM
6272
6273 Previous version of $package used the standard IO mechanisms as defined
6274 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6275 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6276 the default.  This abstraction layer can use AT&T's sfio (if you already
6277 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6278 problems with some extension modules.  Using PerlIO with stdio is safe,
6279 but it is slower than plain stdio and therefore is not the default.
6280
6281 If this doesn't make any sense to you, just accept the default 'n'.
6282 EOM
6283 case "$useperlio" in
6284 $define|true|[yY]*)     dflt='y';;
6285 *) dflt='n';;
6286 esac
6287 rp='Use the experimental PerlIO abstraction layer?'
6288 . ./myread
6289 case "$ans" in
6290 y|Y) 
6291         val="$define"
6292         ;;     
6293 *)      
6294         echo "Ok, doing things the stdio way"
6295         val="$undef"
6296         ;;
6297 esac
6298 set useperlio
6299 eval $setvar 
6300
6301 : Check how to convert floats to strings.
6302 if test "X$d_Gconvert" = X; then
6303         echo " "
6304         echo "Checking for an efficient way to convert floats to strings."
6305         $cat >try.c <<'EOP'
6306 #ifdef TRY_gconvert
6307 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6308 char *myname = "gconvert";
6309 #endif
6310 #ifdef TRY_gcvt
6311 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6312 char *myname = "gcvt";
6313 #endif
6314 #ifdef TRY_sprintf
6315 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6316 char *myname = "sprintf";
6317 #endif
6318
6319 #include <stdio.h>
6320
6321 int
6322 checkit(expect, got)
6323 char *expect;
6324 char *got;
6325 {
6326     if (strcmp(expect, got)) {
6327                 printf("%s oddity:  Expected %s, got %s\n",
6328                         myname, expect, got);
6329                 exit(1);
6330         }
6331 }
6332
6333 int main()
6334
6335         char buf[64]; 
6336         buf[63] = '\0';
6337
6338         /* This must be 1st test on (which?) platform */
6339         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6340         Gconvert(0.1, 8, 0, buf);
6341         checkit("0.1", buf);
6342
6343         Gconvert(1.0, 8, 0, buf); 
6344         checkit("1", buf);
6345
6346         Gconvert(0.0, 8, 0, buf); 
6347         checkit("0", buf);
6348
6349         Gconvert(-1.0, 8, 0, buf); 
6350         checkit("-1", buf);
6351
6352         /* Some Linux gcvt's give 1.e+5 here. */
6353         Gconvert(100000.0, 8, 0, buf); 
6354         checkit("100000", buf);
6355         
6356         /* Some Linux gcvt's give -1.e+5 here. */
6357         Gconvert(-100000.0, 8, 0, buf); 
6358         checkit("-100000", buf);
6359
6360         exit(0);
6361 }
6362 EOP
6363         case "$d_Gconvert" in
6364         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6365         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6366         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6367         *) xxx_list='gconvert gcvt sprintf' ;;
6368         esac
6369
6370         for xxx_convert in $xxx_list; do
6371                 echo "Trying $xxx_convert"
6372                 $rm -f try try$_o
6373                 set try -DTRY_$xxx_convert
6374                 if eval $compile; then
6375                         echo "$xxx_convert" found. >&4
6376                         if ./try; then
6377                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6378                                 break;
6379                         else
6380                                 echo "...But $xxx_convert didn't work as I expected."
6381                         fi
6382                 else
6383                         echo "$xxx_convert NOT found." >&4
6384                 fi
6385         done
6386                 
6387         case "$xxx_convert" in
6388         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6389         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6390         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6391         esac
6392 fi
6393
6394 : Initialize h_fcntl
6395 h_fcntl=false
6396
6397 : Initialize h_sysfile
6398 h_sysfile=false
6399
6400 : access call always available on UNIX
6401 set access d_access
6402 eval $inlibc
6403
6404 : locate the flags for 'access()'
6405 case "$d_access" in
6406 "$define")
6407         echo " "
6408         $cat >access.c <<'EOCP'
6409 #include <sys/types.h>
6410 #ifdef I_FCNTL
6411 #include <fcntl.h>
6412 #endif
6413 #ifdef I_SYS_FILE
6414 #include <sys/file.h>
6415 #endif
6416 #ifdef I_UNISTD
6417 #include <unistd.h>
6418 #endif
6419 int main() {
6420         exit(R_OK);
6421 }
6422 EOCP
6423         : check sys/file.h first, no particular reason here
6424         if $test `./findhdr sys/file.h` && \
6425                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6426                 h_sysfile=true;
6427                 echo "<sys/file.h> defines the *_OK access constants." >&4
6428         elif $test `./findhdr fcntl.h` && \
6429                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6430                 h_fcntl=true;
6431                 echo "<fcntl.h> defines the *_OK access constants." >&4
6432         elif $test `./findhdr unistd.h` && \
6433                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6434                 echo "<unistd.h> defines the *_OK access constants." >&4
6435         else
6436                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6437         fi
6438         ;;
6439 esac
6440 $rm -f access*
6441
6442 : see if accessx exists
6443 set accessx d_accessx
6444 eval $inlibc
6445
6446 : see if alarm exists
6447 set alarm d_alarm
6448 eval $inlibc
6449
6450 : Look for GNU-cc style attribute checking
6451 echo " "
6452 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6453 $cat >attrib.c <<'EOCP'
6454 #include <stdio.h>
6455 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6456 EOCP
6457 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6458         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6459                 echo "Your C compiler doesn't fully support __attribute__."
6460                 val="$undef"
6461         else
6462                 echo "Your C compiler supports __attribute__."
6463                 val="$define"
6464         fi
6465 else
6466         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6467         val="$undef"
6468 fi
6469 set d_attribut
6470 eval $setvar
6471 $rm -f attrib*
6472
6473 : see if bcmp exists
6474 set bcmp d_bcmp
6475 eval $inlibc
6476
6477 : see if bcopy exists
6478 set bcopy d_bcopy
6479 eval $inlibc
6480
6481 : see if this is a unistd.h system
6482 set unistd.h i_unistd
6483 eval $inhdr
6484
6485 : see if getpgrp exists
6486 set getpgrp d_getpgrp
6487 eval $inlibc
6488
6489 case "$d_getpgrp" in
6490 "$define")
6491         echo " "
6492         echo "Checking to see which flavor of getpgrp is in use..."
6493         $cat >set.c <<EOP
6494 #$i_unistd I_UNISTD
6495 #include <sys/types.h>
6496 #ifdef I_UNISTD
6497 #  include <unistd.h>
6498 #endif
6499 int main()
6500 {
6501         if (getuid() == 0) {
6502                 printf("(I see you are running Configure as super-user...)\n");
6503                 setuid(1);
6504         }
6505 #ifdef TRY_BSD_PGRP
6506         if (getpgrp(1) == 0)
6507                 exit(0);
6508 #else
6509         if (getpgrp() > 0)
6510                 exit(0);
6511 #endif
6512         exit(1);
6513 }
6514 EOP
6515         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6516                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6517                 val="$define"
6518         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6519                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6520                 val="$undef"
6521         else
6522                 echo "I can't seem to compile and run the test program."
6523                 if ./usg; then
6524                         xxx="a USG one, i.e. you use getpgrp()."
6525                 else
6526                         # SVR4 systems can appear rather BSD-ish.
6527                         case "$i_unistd" in
6528                         $undef)
6529                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6530                                 val="$define"
6531                                 ;;
6532                         $define)
6533                                 xxx="probably a USG one, i.e. you use getpgrp()."
6534                                 val="$undef"
6535                                 ;;
6536                         esac
6537                 fi
6538                 echo "Assuming your getpgrp is $xxx" >&4
6539         fi
6540         ;;
6541 *) val="$undef";;
6542 esac
6543 set d_bsdgetpgrp
6544 eval $setvar
6545 $rm -f set set.c
6546
6547 : see if setpgrp exists
6548 set setpgrp d_setpgrp
6549 eval $inlibc
6550
6551 case "$d_setpgrp" in
6552 "$define")
6553         echo " "
6554         echo "Checking to see which flavor of setpgrp is in use..."
6555         $cat >set.c <<EOP
6556 #$i_unistd I_UNISTD
6557 #include <sys/types.h>
6558 #ifdef I_UNISTD
6559 #  include <unistd.h>
6560 #endif
6561 int main()
6562 {
6563         if (getuid() == 0) {
6564                 printf("(I see you are running Configure as super-user...)\n");
6565                 setuid(1);
6566         }
6567 #ifdef TRY_BSD_PGRP
6568         if (-1 == setpgrp(1, 1))
6569                 exit(0);
6570 #else
6571         if (setpgrp() != -1)
6572                 exit(0);
6573 #endif
6574         exit(1);
6575 }
6576 EOP
6577         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6578                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6579                 val="$define"
6580         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6581                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6582                 val="$undef"
6583         else
6584                 echo "(I can't seem to compile and run the test program.)"
6585                 if ./usg; then
6586                         xxx="a USG one, i.e. you use setpgrp()."
6587                 else
6588                         # SVR4 systems can appear rather BSD-ish.
6589                         case "$i_unistd" in
6590                         $undef)
6591                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6592                                 val="$define"
6593                                 ;;
6594                         $define)
6595                                 xxx="probably a USG one, i.e. you use setpgrp()."
6596                                 val="$undef"
6597                                 ;;
6598                         esac
6599                 fi
6600                 echo "Assuming your setpgrp is $xxx" >&4
6601         fi
6602         ;;
6603 *) val="$undef";;
6604 esac
6605 set d_bsdsetpgrp
6606 eval $setvar
6607 $rm -f set set.c
6608 : see if bzero exists
6609 set bzero d_bzero
6610 eval $inlibc
6611
6612 : check for lengths of integral types
6613 echo " "
6614 case "$intsize" in
6615 '')
6616         echo "Checking to see how big your integers are..." >&4
6617         $cat >intsize.c <<'EOCP'
6618 #include <stdio.h>
6619 int main()
6620 {
6621         printf("intsize=%d;\n", sizeof(int));
6622         printf("longsize=%d;\n", sizeof(long));
6623         printf("shortsize=%d;\n", sizeof(short));
6624         exit(0);
6625 }
6626 EOCP
6627         set intsize
6628         if eval $compile_ok && ./intsize > /dev/null; then
6629                 eval `./intsize`
6630                 echo "Your integers are $intsize bytes long."
6631                 echo "Your long integers are $longsize bytes long."
6632                 echo "Your short integers are $shortsize bytes long."
6633         else
6634                 $cat >&4 <<EOM
6635 !
6636 Help! I can't compile and run the intsize test program: please enlighten me!
6637 (This is probably a misconfiguration in your system or libraries, and
6638 you really ought to fix it.  Still, I'll try anyway.)
6639 !
6640 EOM
6641                 dflt=4
6642                 rp="What is the size of an integer (in bytes)?"
6643                 . ./myread
6644                 intsize="$ans"
6645                 dflt=$intsize
6646                 rp="What is the size of a long integer (in bytes)?"
6647                 . ./myread
6648                 longsize="$ans"
6649                 dflt=2
6650                 rp="What is the size of a short integer (in bytes)?"
6651                 . ./myread
6652                 shortsize="$ans"
6653         fi
6654         ;;
6655 esac
6656 $rm -f intsize intsize.*
6657
6658 : see if signal is declared as pointer to function returning int or void
6659 echo " "
6660 xxx=`./findhdr signal.h`
6661 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6662 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6663         echo "You have int (*signal())() instead of void." >&4
6664         val="$undef"
6665 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6666         echo "You have void (*signal())()." >&4
6667         val="$define"
6668 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6669         echo "You have int (*signal())() instead of void." >&4
6670         val="$undef"
6671 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6672         echo "You have void (*signal())()." >&4
6673         val="$define"
6674 else
6675         case "$d_voidsig" in
6676         '')
6677         echo "I can't determine whether signal handler returns void or int..." >&4
6678                 dflt=void
6679                 rp="What type does your signal handler return?"
6680                 . ./myread
6681                 case "$ans" in
6682                 v*) val="$define";;
6683                 *) val="$undef";;
6684                 esac;;
6685         "$define")
6686                 echo "As you already told me, signal handler returns void." >&4
6687                 val="$define"
6688                 ;;
6689         *)      echo "As you already told me, signal handler returns int." >&4
6690                 val="$undef"
6691                 ;;
6692         esac
6693 fi
6694 set d_voidsig
6695 eval $setvar
6696 case "$d_voidsig" in
6697 "$define") signal_t="void";;
6698 *) signal_t="int";;
6699 esac
6700 $rm -f $$.tmp
6701
6702 : check for ability to cast large floats to 32-bit ints.
6703 echo " "
6704 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6705 if $test "$intsize" -ge 4; then
6706         xxx=int
6707 else
6708         xxx=long
6709 fi
6710 $cat >try.c <<EOCP
6711 #include <stdio.h>
6712 #include <sys/types.h>
6713 #include <signal.h>
6714 $signal_t blech(s) int s; { exit(3); }
6715 int main()
6716 {
6717         $xxx i32;
6718         double f, g;
6719         int result = 0;
6720         char str[16];
6721         signal(SIGFPE, blech);
6722
6723         /* Don't let compiler optimize the test away.  Store the number 
6724            in a writable string for gcc to pass to sscanf under HP/UX.
6725         */
6726         sprintf(str, "2147483647");
6727         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6728         g = 10 * f;
6729         i32  = ($xxx) g;
6730
6731         /* x86 processors will probably give 0x8000 0000, which is a
6732        sign change.  We don't want that.  We want to mimic SPARC
6733            behavior here, which is to preserve the sign and give
6734            back 0x7fff ffff.
6735         */
6736         if (i32 != ($xxx) f)
6737                 result |= 1;
6738         exit(result);
6739 }
6740 EOCP
6741 set try
6742 if eval $compile_ok; then
6743         ./try
6744         yyy=$?
6745 else
6746         echo "(I can't seem to compile the test program--assuming it can't)"
6747         yyy=1
6748 fi
6749 case "$yyy" in
6750 0)      val="$define"
6751         echo "Yup, it can."
6752         ;;
6753 *)      val="$undef"
6754         echo "Nope, it can't."
6755         ;;
6756 esac
6757 set d_casti32
6758 eval $setvar
6759 $rm -f try try.*
6760
6761 : check for ability to cast negative floats to unsigned
6762 echo " "
6763 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6764 $cat >try.c <<EOCP
6765 #include <stdio.h>
6766 #include <sys/types.h>
6767 #include <signal.h>
6768 $signal_t blech(s) int s; { exit(7); }
6769 $signal_t blech_in_list(s) int s; { exit(4); }
6770 unsigned long dummy_long(p) unsigned long p; { return p; }
6771 unsigned int dummy_int(p) unsigned int p; { return p; }
6772 unsigned short dummy_short(p) unsigned short p; { return p; }
6773 int main()
6774 {
6775         double f;
6776         unsigned long along;
6777         unsigned int aint;
6778         unsigned short ashort;
6779         int result = 0;
6780         char str[16];
6781         
6782         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6783            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6784            optimized the whole file away
6785         */
6786         /* Store the number in a writable string for gcc to pass to 
6787            sscanf under HP/UX.
6788         */
6789         sprintf(str, "-123");
6790         sscanf(str, "%lf", &f);  /* f = -123.; */
6791
6792         signal(SIGFPE, blech);
6793         along = (unsigned long)f;
6794         aint = (unsigned int)f;
6795         ashort = (unsigned short)f;
6796         if (along != (unsigned long)-123)
6797                 result |= 1;
6798         if (aint != (unsigned int)-123)
6799                 result |= 1;
6800         if (ashort != (unsigned short)-123)
6801                 result |= 1;
6802         sprintf(str, "1073741824.");
6803         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6804         f = f + f;
6805         along = 0;
6806         along = (unsigned long)f;
6807         if (along != 0x80000000)
6808                 result |= 2;
6809         f -= 1.;
6810         along = 0;
6811         along = (unsigned long)f;
6812         if (along != 0x7fffffff)
6813                 result |= 1;
6814         f += 2.;
6815         along = 0;
6816         along = (unsigned long)f;
6817         if (along != 0x80000001)
6818                 result |= 2;
6819         if (result)
6820                 exit(result);
6821         signal(SIGFPE, blech_in_list);
6822         sprintf(str, "123.");
6823         sscanf(str, "%lf", &f);  /* f = 123.; */
6824         along = dummy_long((unsigned long)f);
6825         aint = dummy_int((unsigned int)f);
6826         ashort = dummy_short((unsigned short)f);
6827         if (along != (unsigned long)123)
6828                 result |= 4;
6829         if (aint != (unsigned int)123)
6830                 result |= 4;
6831         if (ashort != (unsigned short)123)
6832                 result |= 4;
6833         exit(result);
6834
6835 }
6836 EOCP
6837 set try
6838 if eval $compile_ok; then
6839         ./try
6840         castflags=$?
6841 else
6842         echo "(I can't seem to compile the test program--assuming it can't)"
6843         castflags=7
6844 fi
6845 case "$castflags" in
6846 0)      val="$define"
6847         echo "Yup, it can."
6848         ;;
6849 *)      val="$undef"
6850         echo "Nope, it can't."
6851         ;;
6852 esac
6853 set d_castneg
6854 eval $setvar
6855 $rm -f try.*
6856
6857 : see if vprintf exists
6858 echo " "
6859 if set vprintf val -f d_vprintf; eval $csym; $val; then
6860         echo 'vprintf() found.' >&4
6861         val="$define"
6862         $cat >vprintf.c <<'EOF'
6863 #include <varargs.h>
6864
6865 int main() { xxx("foo"); }
6866
6867 xxx(va_alist)
6868 va_dcl
6869 {
6870         va_list args;
6871         char buf[10];
6872
6873         va_start(args);
6874         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6875 }
6876 EOF
6877         set vprintf
6878         if eval $compile && ./vprintf; then
6879                 echo "Your vsprintf() returns (int)." >&4
6880                 val2="$undef"
6881         else
6882                 echo "Your vsprintf() returns (char*)." >&4
6883                 val2="$define"
6884         fi
6885 else
6886         echo 'vprintf() NOT found.' >&4
6887                 val="$undef"
6888                 val2="$undef"
6889 fi
6890 set d_vprintf
6891 eval $setvar
6892 val=$val2
6893 set d_charvspr
6894 eval $setvar
6895
6896 : see if chown exists
6897 set chown d_chown
6898 eval $inlibc
6899
6900 : see if chroot exists
6901 set chroot d_chroot
6902 eval $inlibc
6903
6904 : see if chsize exists
6905 set chsize d_chsize
6906 eval $inlibc
6907
6908 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6909 while $test $# -ge 2; do
6910         case "$1" in
6911         $define) echo "#include <$2>";;
6912         esac ;
6913     shift 2;
6914 done > try.c;
6915 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6916 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6917         val="$define";
6918 else
6919         val="$undef";
6920 fi;
6921 set $varname;
6922 eval $setvar;
6923 $rm -f try.c try.o'
6924
6925 : see if this is a sys/uio.h system
6926 set sys/uio.h i_sysuio
6927 eval $inhdr
6928
6929 echo "Checking to see if your system supports struct iovec..." >&4
6930 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6931 eval $hasfield
6932 case "$d_iovec_s" in
6933 "$define")      echo "Yup, it does." >&4
6934                 ;;
6935 *)              echo "Nope, it doesn't." >&4
6936                 ;;
6937 esac
6938
6939 socketlib=''
6940 sockethdr=''
6941 : see whether socket exists
6942 echo " "
6943 $echo $n "Hmm... $c" >&4
6944 if set socket val -f d_socket; eval $csym; $val; then
6945         echo "Looks like you have Berkeley networking support." >&4
6946         d_socket="$define"
6947         if set setsockopt val -f; eval $csym; $val; then
6948                 d_oldsock="$undef"
6949         else
6950                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6951                 d_oldsock="$define"
6952         fi
6953 else
6954         if $contains socklib libc.list >/dev/null 2>&1; then
6955                 echo "Looks like you have Berkeley networking support." >&4
6956                 d_socket="$define"
6957                 : we will have to assume that it supports the 4.2 BSD interface
6958                 d_oldsock="$undef"
6959         else
6960                 echo "You don't have Berkeley networking in libc$_a..." >&4
6961                 if test "X$d_socket" = "X$define"; then
6962                    echo "...but you seem to believe that you have sockets." >&4
6963                 else
6964                         for net in net socket
6965                         do
6966                                 if test -f /usr/lib/lib$net$_a; then
6967                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6968                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6969                                         if $contains socket libc.list >/dev/null 2>&1; then
6970                                                 d_socket="$define"
6971                                                 socketlib="-l$net"
6972                                                 case "$net" in
6973                                                 net)
6974                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6975                                                         sockethdr="-I/usr/netinclude"
6976                                                         ;;
6977                                                 esac
6978                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6979                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6980                                                         d_oldsock="$undef"
6981                                                 else
6982                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6983                                                         d_oldsock="$define"
6984                                                 fi
6985                                                 break
6986                                         fi
6987                                 fi
6988                         done
6989                         if test "X$d_socket" != "X$define"; then
6990                            echo "or anywhere else I see." >&4
6991                            d_socket="$undef"
6992                            d_oldsock="$undef"
6993                         fi
6994                 fi
6995         fi
6996 fi
6997
6998 : see if socketpair exists
6999 set socketpair d_sockpair
7000 eval $inlibc
7001
7002
7003 echo " "
7004 echo "Checking the availability of certain socket constants..." >& 4
7005 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
7006         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
7007         $cat >try.c <<EOF
7008 #include <sys/types.h>
7009 #include <sys/socket.h>
7010 int main() {
7011     int i = $ENUM;
7012 }
7013 EOF
7014         val="$undef"
7015         set try; if eval $compile; then
7016                 val="$define"
7017         fi
7018         set d_${enum}; eval $setvar
7019         $rm -f try.c try
7020 done
7021
7022 set sendmsg d_sendmsg
7023 eval $inlibc
7024
7025 set recvmsg d_recvmsg
7026 eval $inlibc
7027
7028 echo " "
7029 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
7030 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7031 eval $hasfield
7032 case "$d_msghdr_s" in
7033 "$define")      echo "Yup, it does." >&4
7034                 ;;
7035 *)              echo "Nope, it doesn't." >&4
7036                 ;;
7037 esac
7038
7039 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7040 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7041 eval $hasfield
7042 case "$d_cmsghdr_s" in
7043 "$define")      echo "Yup, it does." >&4
7044                 ;;
7045 *)              echo "Nope, it doesn't." >&4
7046                 ;;
7047 esac
7048
7049 : check for const keyword
7050 echo " "
7051 echo 'Checking to see if your C compiler knows about "const"...' >&4
7052 $cat >const.c <<'EOCP'
7053 typedef struct spug { int drokk; } spug;
7054 int main()
7055 {
7056         const char *foo;
7057         const spug y;
7058 }
7059 EOCP
7060 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7061         val="$define"
7062         echo "Yup, it does."
7063 else
7064         val="$undef"
7065         echo "Nope, it doesn't."
7066 fi
7067 set d_const
7068 eval $setvar
7069
7070 : see if crypt exists
7071 echo " "
7072 if set crypt val -f d_crypt; eval $csym; $val; then
7073         echo 'crypt() found.' >&4
7074         val="$define"
7075         cryptlib=''
7076 else
7077         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7078         if $test -z "$cryptlib"; then
7079                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7080         else
7081                 cryptlib=-lcrypt
7082         fi
7083         if $test -z "$cryptlib"; then
7084                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7085         else
7086                 cryptlib=-lcrypt
7087         fi
7088         if $test -z "$cryptlib"; then
7089                 cryptlib=`./loc libcrypt$_a "" $libpth`
7090         else
7091                 cryptlib=-lcrypt
7092         fi
7093         if $test -z "$cryptlib"; then
7094                 echo 'crypt() NOT found.' >&4
7095                 val="$undef"
7096         else
7097                 val="$define"
7098         fi
7099 fi
7100 set d_crypt
7101 eval $setvar
7102
7103 : get csh whereabouts
7104 case "$csh" in
7105 'csh') val="$undef" ;;
7106 *) val="$define" ;;
7107 esac
7108 set d_csh
7109 eval $setvar
7110 : Respect a hint or command line value for full_csh.
7111 case "$full_csh" in
7112 '') full_csh=$csh ;;
7113 esac
7114
7115 : see if cuserid exists
7116 set cuserid d_cuserid
7117 eval $inlibc
7118
7119 : see if this is a limits.h system
7120 set limits.h i_limits
7121 eval $inhdr
7122
7123 : see if this is a float.h system
7124 set float.h i_float
7125 eval $inhdr
7126
7127 : See if number of significant digits in a double precision number is known
7128 echo " "
7129 $cat >dbl_dig.c <<EOM
7130 #$i_limits I_LIMITS
7131 #$i_float I_FLOAT
7132 #ifdef I_LIMITS
7133 #include <limits.h>
7134 #endif
7135 #ifdef I_FLOAT
7136 #include <float.h>
7137 #endif
7138 #ifdef DBL_DIG
7139 printf("Contains DBL_DIG");
7140 #endif
7141 EOM
7142 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7143 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7144         echo "DBL_DIG found." >&4
7145         val="$define"
7146 else
7147         echo "DBL_DIG NOT found." >&4
7148         val="$undef"
7149 fi
7150 $rm -f dbl_dig.?
7151 set d_dbl_dig
7152 eval $setvar
7153
7154
7155 if $test X"$use64bits" = X"$define"; then
7156         : see if dbminit64 exists
7157         set dbminit64 d_dbminit64
7158         eval $inlibc
7159
7160         : see if dbmclose64 exists
7161         set dbmclose64 d_dbmclose64
7162         eval $inlibc
7163
7164         : see if fetch64 exists
7165         set fetch64 d_fetch64
7166         eval $inlibc
7167
7168         : see if store64 exists
7169         set store64 d_store64
7170         eval $inlibc
7171
7172         : see if delete64 exists
7173         set delete64 d_delete64
7174         eval $inlibc
7175
7176         : see if firstkey64 exists
7177         set firstkey64 d_firstkey64
7178         eval $inlibc
7179
7180         : see if nextkey64 exists
7181         set nextkey64 d_nextkey64
7182         eval $inlibc
7183 else
7184         val="$undef"
7185         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7186         do
7187                 set $xxx
7188                 eval $setvar
7189         done
7190 fi
7191
7192 : see if difftime exists
7193 set difftime d_difftime
7194 eval $inlibc
7195
7196 : see if sys/stat.h is available
7197 set sys/stat.h i_sysstat
7198 eval $inhdr
7199
7200 : see if this is a dirent system
7201 echo " "
7202 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7203         val="$define"
7204         echo "<dirent.h> found." >&4
7205 else
7206         val="$undef"
7207         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7208                 echo "<sys/dir.h> found." >&4
7209                 echo " "
7210         else
7211                 xinc=`./findhdr sys/ndir.h`
7212         fi
7213         echo "<dirent.h> NOT found." >&4
7214 fi
7215 set i_dirent
7216 eval $setvar
7217
7218 : Look for type of directory structure.
7219 echo " "
7220 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7221
7222 case "$direntrytype" in
7223 ''|' ')
7224         case "$i_dirent" in
7225         $define) guess1='struct dirent' ;;
7226         *) guess1='struct direct'  ;;
7227         esac
7228         ;;
7229 *)      guess1="$direntrytype"
7230         ;;
7231 esac
7232
7233 case "$guess1" in
7234 'struct dirent') guess2='struct direct' ;;
7235 *) guess2='struct dirent' ;;
7236 esac
7237                 
7238 if $contains "$guess1" try.c >/dev/null 2>&1; then
7239         direntrytype="$guess1"
7240         echo "Your directory entries are $direntrytype." >&4
7241 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7242         direntrytype="$guess2"
7243         echo "Your directory entries seem to be $direntrytype." >&4
7244 else
7245         echo "I don't recognize your system's directory entries." >&4
7246         rp="What type is used for directory entries on this system?"
7247         dflt="$guess1"
7248         . ./myread
7249         direntrytype="$ans"
7250 fi
7251 $rm -f try.c
7252
7253
7254 : see if the directory entry stores field length
7255 echo " "
7256 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7257 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7258         echo "Good, your directory entry keeps length information in d_namlen." >&4
7259         val="$define"
7260 else
7261         echo "Your directory entry does not know about the d_namlen field." >&4
7262         val="$undef"
7263 fi
7264 set d_dirnamlen
7265 eval $setvar
7266 $rm -f try.c
7267
7268
7269 if $test X"$use64bits" = X"$define"; then
7270         : see if fstat64 exists
7271         set fstat64 d_fstat64
7272         eval $inlibc
7273
7274         : see if ftruncate64 exists
7275         set ftruncate64 d_ftruncate64
7276         eval $inlibc
7277
7278         : see if lockf64 exists
7279         set lockf64 d_lockf64
7280         eval $inlibc
7281
7282         : see if llseek exists
7283         set llseek d_llseek
7284         eval $inlibc
7285
7286         : see if lseek64 exists
7287         set lseek64 d_lseek64
7288         eval $inlibc
7289
7290         : see if lstat64 exists
7291         set lstat64 d_lstat64
7292         eval $inlibc
7293
7294         : see if open64 exists
7295         set open64 d_open64
7296         eval $inlibc
7297
7298         : see if opendir64 exists
7299         set opendir64 d_opendir64
7300         eval $inlibc
7301
7302         : see if readdir64 exists
7303         set readdir64 d_readdir64
7304         eval $inlibc
7305
7306         : see if seekdir64 exists
7307         set seekdir64 d_seekdir64
7308         eval $inlibc
7309
7310         : see if stat64 exists
7311         set stat64 d_stat64
7312         eval $inlibc
7313
7314         : see if telldir64 exists
7315         set telldir64 d_telldir64
7316         eval $inlibc
7317
7318         : see if truncate64 exists
7319         set truncate64 d_truncate64
7320         eval $inlibc
7321
7322         : check for off64_t
7323         echo " "
7324         echo $n "Checking to see if your system supports off64_t...$c" >&4
7325         $cat >try.c <<EOCP
7326 #include <sys/types.h>
7327 #include <unistd.h>
7328 off64_t foo() { off64_t x; x = 7; return x; }'
7329 EOCP
7330         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7331                 val="$define"
7332                 echo " Yup, it does." >&4
7333         else
7334                 val="$undef"
7335                 echo " Nope, it doesn't." >&4
7336         fi
7337         $rm -f try.*
7338         set d_off64_t
7339         eval $setvar
7340
7341         : check for offset_t
7342         echo " "
7343         echo $n "Checking to see if your system supports offset_t...$c" >&4
7344         $cat >try.c <<EOCP
7345 #include <sys/types.h>
7346 #include <unistd.h>
7347 offset_t foo() { offset_t x; x = 7; return x; }'
7348 EOCP
7349         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7350                 val="$define"
7351                 echo " Yup, it does." >&4
7352         else
7353                 val="$undef"
7354                 echo " Nope, it doesn't." >&4
7355         fi
7356         $rm -f try.*
7357         set d_offset_t
7358         eval $setvar
7359
7360         : check for ino64_t
7361         echo " "
7362         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7363         val="$undef"
7364         case "$i_sysstat" in
7365         "$define" )
7366                 $cat >try.c <<EOCP
7367 #include <sys/types.h>
7368 #include <sys/stat.h>
7369 ino64_t foo() { ino64_t x; x = 7; return x; }'
7370 EOCP
7371                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7372                         val="$define"
7373                 fi
7374                 $rm -f try.*
7375                 ;;
7376         esac
7377         if $test "X$val" = X"$define"; then
7378                 echo " Yup, it does." >&4
7379         else
7380                 echo " Nope, it doesn't." >&4
7381         fi
7382         set d_ino64_t
7383         eval $setvar
7384
7385         : check for struct flock64
7386         echo " "
7387         echo "Checking to see if your system supports struct flock64..." >&4
7388         if $h_fcntl; then
7389                 set d_flock64_s flock64 l_len define fcntl.h
7390                 eval $hasfield
7391         else
7392                 val="$undef"
7393                 set d_flock64_s
7394                 eval $setvar
7395         fi
7396         case "$d_flock64_s" in
7397         "$define")      echo "Yup, it does." >&4
7398                         ;;
7399         *)              echo "Nope, it doesn't." >&4
7400                         ;;
7401         esac
7402
7403         : check for struct dirent64
7404         echo " "
7405         echo "Checking to see if your system supports struct dirent64..." >&4
7406         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7407         eval $hasfield
7408         case "$d_dirent64_s" in
7409         "$define")      echo "Yup, it does." >&4
7410                         ;;
7411         *)              echo "Nope, it doesn't." >&4
7412                         ;;
7413         esac
7414
7415 else
7416         val="$undef"
7417         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
7418         do
7419                 set $xxx
7420                 eval $setvar
7421         done
7422 fi
7423
7424 : see if dlerror exists
7425 xxx_runnm="$runnm"
7426 runnm=false
7427 set dlerror d_dlerror
7428 eval $inlibc
7429 runnm="$xxx_runnm"
7430
7431 : see if dlfcn is available
7432 set dlfcn.h i_dlfcn
7433 eval $inhdr
7434
7435 case "$usedl" in
7436 $define|y|true)
7437         $cat << EOM
7438
7439 On a few systems, the dynamically loaded modules that perl generates and uses
7440 will need a different extension than shared libs. The default will probably
7441 be appropriate.
7442
7443 EOM
7444         case "$dlext" in
7445         '')     dflt="$so" ;;
7446         *)      dflt="$dlext" ;;
7447         esac
7448         rp='What is the extension of dynamically loaded modules'
7449         . ./myread
7450         dlext="$ans"
7451         ;;
7452 *)
7453         dlext="none"
7454         ;;
7455 esac
7456
7457 : Check if dlsym need a leading underscore
7458 echo " "
7459 val="$undef"
7460
7461 case "$dlsrc" in
7462 dl_dlopen.xs)
7463         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7464         $cat >dyna.c <<'EOM'
7465 fred () { }
7466 EOM
7467
7468 $cat >fred.c<<EOM
7469
7470 #include <stdio.h>
7471 #$i_dlfcn I_DLFCN
7472 #ifdef I_DLFCN
7473 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7474 #else
7475 #include <sys/types.h>
7476 #include <nlist.h>
7477 #include <link.h>
7478 #endif
7479
7480 extern int fred() ;
7481
7482 int main()
7483 {
7484     void * handle ;
7485     void * symbol ;
7486 #ifndef RTLD_LAZY
7487     int mode = 1 ;
7488 #else
7489     int mode = RTLD_LAZY ;
7490 #endif
7491     handle = dlopen("./dyna.$dlext", mode) ;
7492     if (handle == NULL) {
7493         printf ("1\n") ;
7494         fflush (stdout) ;
7495         exit(0);
7496     }
7497     symbol = dlsym(handle, "fred") ;
7498     if (symbol == NULL) {
7499         /* try putting a leading underscore */
7500         symbol = dlsym(handle, "_fred") ;
7501         if (symbol == NULL) {
7502             printf ("2\n") ;
7503             fflush (stdout) ;
7504             exit(0);
7505         }
7506         printf ("3\n") ;
7507     }
7508     else
7509         printf ("4\n") ;
7510     fflush (stdout) ;
7511     exit(0);
7512 }
7513 EOM
7514         : Call the object file tmp-dyna.o in case dlext=o.
7515         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7516                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7517                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7518                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7519                 xxx=`./fred`
7520                 case $xxx in
7521                 1)      echo "Test program failed using dlopen." >&4
7522                         echo "Perhaps you should not use dynamic loading." >&4;;
7523                 2)      echo "Test program failed using dlsym." >&4
7524                         echo "Perhaps you should not use dynamic loading." >&4;;
7525                 3)      echo "dlsym needs a leading underscore" >&4
7526                         val="$define" ;;
7527                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7528                 esac
7529         else
7530                 echo "I can't compile and run the test program." >&4
7531         fi
7532         ;;
7533 esac
7534                 
7535 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7536
7537 set d_dlsymun
7538 eval $setvar
7539
7540 hasproto='varname=$1; func=$2; shift; shift;
7541 while $test $# -ge 2; do
7542         case "$1" in
7543         $define) echo "#include <$2>";;
7544         esac ;
7545     shift 2;
7546 done > try.c;
7547 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7548 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7549         echo "$func() prototype found.";
7550         val="$define";
7551 else
7552         echo "$func() prototype NOT found.";
7553         val="$undef";
7554 fi;
7555 set $varname;
7556 eval $setvar;
7557 $rm -f try.c tryout.c'
7558
7559 : see if prototype for drand48 is available
7560 echo " "
7561 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7562 eval $hasproto
7563
7564 : see if dup2 exists
7565 set dup2 d_dup2
7566 eval $inlibc
7567
7568 : see if eaccess exists
7569 set eaccess d_eaccess
7570 eval $inlibc
7571
7572 : see if endgrent exists
7573 set endgrent d_endgrent
7574 eval $inlibc
7575
7576 : see if endhostent exists
7577 set endhostent d_endhent
7578 eval $inlibc
7579
7580 : see if endnetent exists
7581 set endnetent d_endnent
7582 eval $inlibc
7583
7584 : see if endprotoent exists
7585 set endprotoent d_endpent
7586 eval $inlibc
7587
7588 : see if endpwent exists
7589 set endpwent d_endpwent
7590 eval $inlibc
7591
7592 : see if endservent exists
7593 set endservent d_endsent
7594 eval $inlibc
7595
7596 : see if endspent exists
7597 set endspent d_endspent
7598 eval $inlibc
7599
7600 : Locate the flags for 'open()'
7601 echo " "
7602 $cat >open3.c <<'EOCP'
7603 #include <sys/types.h>
7604 #ifdef I_FCNTL
7605 #include <fcntl.h>
7606 #endif
7607 #ifdef I_SYS_FILE
7608 #include <sys/file.h>
7609 #endif
7610 int main() {
7611         if(O_RDONLY);
7612 #ifdef O_TRUNC
7613         exit(0);
7614 #else
7615         exit(1);
7616 #endif
7617 }
7618 EOCP
7619 : check sys/file.h first to get FREAD on Sun
7620 if $test `./findhdr sys/file.h` && \
7621                 set open3 -DI_SYS_FILE && eval $compile; then
7622         h_sysfile=true;
7623         echo "<sys/file.h> defines the O_* constants..." >&4
7624         if ./open3; then
7625                 echo "and you have the 3 argument form of open()." >&4
7626                 val="$define"
7627         else
7628                 echo "but not the 3 argument form of open().  Oh, well." >&4
7629                 val="$undef"
7630         fi
7631 elif $test `./findhdr fcntl.h` && \
7632                 set open3 -DI_FCNTL && eval $compile; then
7633         h_fcntl=true;
7634         echo "<fcntl.h> defines the O_* constants..." >&4
7635         if ./open3; then
7636                 echo "and you have the 3 argument form of open()." >&4
7637                 val="$define"
7638         else
7639                 echo "but not the 3 argument form of open().  Oh, well." >&4
7640                 val="$undef"
7641         fi
7642 else
7643         val="$undef"
7644         echo "I can't find the O_* constant definitions!  You got problems." >&4
7645 fi
7646 set d_open3
7647 eval $setvar
7648 $rm -f open3*
7649
7650 : check for non-blocking I/O stuff
7651 case "$h_sysfile" in
7652 true) echo "#include <sys/file.h>" > head.c;;
7653 *)
7654         case "$h_fcntl" in
7655         true) echo "#include <fcntl.h>" > head.c;;
7656         *) echo "#include <sys/fcntl.h>" > head.c;;
7657         esac
7658         ;;
7659 esac
7660 echo " "
7661 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7662 case "$o_nonblock" in
7663 '')
7664         $cat head.c > try.c
7665         $cat >>try.c <<'EOCP'
7666 int main() {
7667 #ifdef O_NONBLOCK
7668         printf("O_NONBLOCK\n");
7669         exit(0);
7670 #endif
7671 #ifdef O_NDELAY
7672         printf("O_NDELAY\n");
7673         exit(0);
7674 #endif
7675 #ifdef FNDELAY
7676         printf("FNDELAY\n");
7677         exit(0);
7678 #endif
7679         exit(0);
7680 }
7681 EOCP
7682         set try
7683         if eval $compile_ok; then
7684                 o_nonblock=`./try`
7685                 case "$o_nonblock" in
7686                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7687                 *) echo "Seems like we can use $o_nonblock.";;
7688                 esac
7689         else
7690                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7691         fi
7692         ;;
7693 *) echo "Using $hint value $o_nonblock.";;
7694 esac
7695 $rm -f try try.* .out core
7696
7697 echo " "
7698 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7699 case "$eagain" in
7700 '')
7701         $cat head.c > try.c
7702         $cat >>try.c <<EOCP
7703 #include <errno.h>
7704 #include <sys/types.h>
7705 #include <signal.h>
7706 #define MY_O_NONBLOCK $o_nonblock
7707 #ifndef errno  /* XXX need better Configure test */
7708 extern int errno;
7709 #endif
7710 $signal_t blech(x) int x; { exit(3); }
7711 EOCP
7712         $cat >> try.c <<'EOCP'
7713 int main()
7714 {
7715         int pd[2];
7716         int pu[2];
7717         char buf[1];
7718         char string[100];
7719
7720         pipe(pd);       /* Down: child -> parent */
7721         pipe(pu);       /* Up: parent -> child */
7722         if (0 != fork()) {
7723                 int ret;
7724                 close(pd[1]);   /* Parent reads from pd[0] */
7725                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7726                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7727                         exit(1);
7728                 signal(SIGALRM, blech);
7729                 alarm(5);
7730                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7731                         exit(2);
7732                 sprintf(string, "%d\n", ret);
7733                 write(2, string, strlen(string));
7734                 alarm(0);
7735 #ifdef EAGAIN
7736                 if (errno == EAGAIN) {
7737                         printf("EAGAIN\n");
7738                         goto ok;
7739                 }
7740 #endif
7741 #ifdef EWOULDBLOCK
7742                 if (errno == EWOULDBLOCK)
7743                         printf("EWOULDBLOCK\n");
7744 #endif
7745         ok:
7746                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7747                 sleep(2);                               /* Give it time to close our pipe */
7748                 alarm(5);
7749                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7750                 alarm(0);
7751                 sprintf(string, "%d\n", ret);
7752                 write(3, string, strlen(string));
7753                 exit(0);
7754         }
7755
7756         close(pd[0]);                   /* We write to pd[1] */
7757         close(pu[1]);                   /* We read from pu[0] */
7758         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7759         close(pd[1]);                   /* Pipe pd is now fully closed! */
7760         exit(0);                                /* Bye bye, thank you for playing! */
7761 }
7762 EOCP
7763         set try
7764         if eval $compile_ok; then
7765                 echo "$startsh" >mtry
7766                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7767                 chmod +x mtry
7768                 ./mtry >/dev/null 2>&1
7769                 case $? in
7770                 0) eagain=`$cat try.out`;;
7771                 1) echo "Could not perform non-blocking setting!";;
7772                 2) echo "I did a successful read() for something that was not there!";;
7773                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7774                 *) echo "Something terribly wrong happened during testing.";;
7775                 esac
7776                 rd_nodata=`$cat try.ret`
7777                 echo "A read() system call with no data present returns $rd_nodata."
7778                 case "$rd_nodata" in
7779                 0|-1) ;;
7780                 *)
7781                         echo "(That's peculiar, fixing that to be -1.)"
7782                         rd_nodata=-1
7783                         ;;
7784                 esac
7785                 case "$eagain" in
7786                 '')
7787                         echo "Forcing errno EAGAIN on read() with no data available."
7788                         eagain=EAGAIN
7789                         ;;
7790                 *)
7791                         echo "Your read() sets errno to $eagain when no data is available."
7792                         ;;
7793                 esac
7794                 status=`$cat try.err`
7795                 case "$status" in
7796                 0) echo "And it correctly returns 0 to signal EOF.";;
7797                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7798                 *) echo "However, your read() returns '$status' on EOF??";;
7799                 esac
7800                 val="$define"
7801                 if test "$status" = "$rd_nodata"; then
7802                         echo "WARNING: you can't distinguish between EOF and no data!"
7803                         val="$undef"
7804                 fi
7805         else
7806                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7807                 eagain=EAGAIN
7808         fi
7809         set d_eofnblk
7810         eval $setvar
7811         ;;
7812 *)
7813         echo "Using $hint value $eagain."
7814         echo "Your read() returns $rd_nodata when no data is present."
7815         case "$d_eofnblk" in
7816         "$define") echo "And you can see EOF because read() returns 0.";;
7817         "$undef") echo "But you can't see EOF status from read() returned value.";;
7818         *)
7819                 echo "(Assuming you can't see EOF status from read anyway.)"
7820                 d_eofnblk=$undef
7821                 ;;
7822         esac
7823         ;;
7824 esac
7825 $rm -f try try.* .out core head.c mtry
7826
7827 : see if fchmod exists
7828 set fchmod d_fchmod
7829 eval $inlibc
7830
7831 : see if fchown exists
7832 set fchown d_fchown
7833 eval $inlibc
7834
7835 : see if this is an fcntl system
7836 set fcntl d_fcntl
7837 eval $inlibc
7838
7839 : see if sys/select.h has to be included
7840 set sys/select.h i_sysselct
7841 eval $inhdr
7842
7843 : see if we should include time.h, sys/time.h, or both
7844 echo " "
7845 if test "X$timeincl" = X; then
7846         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7847         $echo $n "I'm now running the test program...$c"
7848         $cat >try.c <<'EOCP'
7849 #include <sys/types.h>
7850 #ifdef I_TIME
7851 #include <time.h>
7852 #endif
7853 #ifdef I_SYSTIME
7854 #ifdef SYSTIMEKERNEL
7855 #define KERNEL
7856 #endif
7857 #include <sys/time.h>
7858 #endif
7859 #ifdef I_SYSSELECT
7860 #include <sys/select.h>
7861 #endif
7862 int main()
7863 {
7864         struct tm foo;
7865 #ifdef S_TIMEVAL
7866         struct timeval bar;
7867 #endif
7868 #ifdef S_TIMEZONE
7869         struct timezone tzp;
7870 #endif
7871         if (foo.tm_sec == foo.tm_sec)
7872                 exit(0);
7873 #ifdef S_TIMEVAL
7874         if (bar.tv_sec == bar.tv_sec)
7875                 exit(0);
7876 #endif
7877         exit(1);
7878 }
7879 EOCP
7880         flags=''
7881         for s_timezone in '-DS_TIMEZONE' ''; do
7882         sysselect=''
7883         for s_timeval in '-DS_TIMEVAL' ''; do
7884         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7885         for i_time in '' '-DI_TIME'; do
7886         for i_systime in '-DI_SYSTIME' ''; do
7887                 case "$flags" in
7888                 '') $echo $n ".$c"
7889                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7890                         if eval $compile; then
7891                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7892                                 shift
7893                                 flags="$*"
7894                                 echo " "
7895                                 $echo $n "Succeeded with $flags$c"
7896                         fi
7897                         ;;
7898                 esac
7899         done
7900         done
7901         done
7902         done
7903         done
7904         timeincl=''
7905         echo " "
7906         case "$flags" in
7907         *SYSTIMEKERNEL*) i_systimek="$define"
7908                 timeincl=`./findhdr sys/time.h`
7909                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7910         *) i_systimek="$undef";;
7911         esac
7912         case "$flags" in
7913         *I_TIME*) i_time="$define"
7914                 timeincl=`./findhdr time.h`" $timeincl"
7915                 echo "We'll include <time.h>." >&4;;
7916         *) i_time="$undef";;
7917         esac
7918         case "$flags" in
7919         *I_SYSTIME*) i_systime="$define"
7920                 timeincl=`./findhdr sys/time.h`" $timeincl"
7921                 echo "We'll include <sys/time.h>." >&4;;
7922         *) i_systime="$undef";;
7923         esac
7924         $rm -f try.c try
7925 fi
7926
7927 : check for fd_set items
7928 $cat <<EOM
7929
7930 Checking to see how well your C compiler handles fd_set and friends ...
7931 EOM
7932 $cat >fd_set.c <<EOCP
7933 #$i_systime I_SYS_TIME
7934 #$i_sysselct I_SYS_SELECT
7935 #$d_socket HAS_SOCKET
7936 #include <sys/types.h>
7937 #ifdef HAS_SOCKET
7938 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7939 #endif
7940 #ifdef I_SYS_TIME
7941 #include <sys/time.h>
7942 #endif
7943 #ifdef I_SYS_SELECT
7944 #include <sys/select.h>
7945 #endif
7946 int main() {
7947         fd_set fds;
7948
7949 #ifdef TRYBITS
7950         if(fds.fds_bits);
7951 #endif
7952
7953 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7954         exit(0);
7955 #else
7956         exit(1);
7957 #endif
7958 }
7959 EOCP
7960 set fd_set -DTRYBITS
7961 if eval $compile; then
7962         d_fds_bits="$define"
7963         d_fd_set="$define"
7964         echo "Well, your system knows about the normal fd_set typedef..." >&4
7965         if ./fd_set; then
7966                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7967                 d_fd_macros="$define"
7968         else
7969                 $cat >&4 <<'EOM'
7970 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7971 EOM
7972                 d_fd_macros="$undef"
7973         fi
7974 else
7975         $cat <<'EOM'
7976 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7977 EOM
7978         set fd_set
7979         if eval $compile; then
7980                 d_fds_bits="$undef"
7981                 d_fd_set="$define"
7982                 echo "Well, your system has some sort of fd_set available..." >&4
7983                 if ./fd_set; then
7984                         echo "and you have the normal fd_set macros." >&4
7985                         d_fd_macros="$define"
7986                 else
7987                         $cat <<'EOM'
7988 but not the normal fd_set macros!  Gross!  More work for me...
7989 EOM
7990                         d_fd_macros="$undef"
7991                 fi
7992         else
7993         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7994                 d_fd_set="$undef"
7995                 d_fds_bits="$undef"
7996                 d_fd_macros="$undef"
7997         fi
7998 fi
7999 $rm -f fd_set*
8000
8001 : see if fgetpos exists
8002 set fgetpos d_fgetpos
8003 eval $inlibc
8004
8005
8006 if $test X"$use64bits" = X"$define"; then
8007         : see if fgetpos64 exists
8008         set fgetpos64 d_fgetpos64
8009         eval $inlibc
8010
8011         : see if fopen64 exists
8012         set freopen64 d_fopen64
8013         eval $inlibc
8014
8015         : see if freopen64 exists
8016         set freopen64 d_freopen64
8017         eval $inlibc
8018
8019         : see if fseek64 exists
8020         set fseek64 d_fseek64
8021         eval $inlibc
8022
8023         : see if fseeko64 exists
8024         set fseeko64 d_fseeko64
8025         eval $inlibc
8026
8027         : see if fsetpos64 exists
8028         set fsetpos64 d_fsetpos64
8029         eval $inlibc
8030
8031         : see if ftell64 exists
8032         set ftell64 d_ftell64
8033         eval $inlibc
8034
8035         : see if ftello64 exists
8036         set ftello64 d_ftello64
8037         eval $inlibc
8038
8039         : see if tmpfile64 exists
8040         set tmpfile64 d_tmpfile64
8041         eval $inlibc
8042 else
8043         val="$undef"
8044         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
8045         do
8046                 set $xxx
8047                 eval $setvar
8048         done
8049 fi
8050
8051 : see if flock exists
8052 set flock d_flock
8053 eval $inlibc
8054
8055 : see if fork exists
8056 set fork d_fork
8057 eval $inlibc
8058
8059 : see if pathconf exists
8060 set pathconf d_pathconf
8061 eval $inlibc
8062
8063 : see if fpathconf exists
8064 set fpathconf d_fpathconf
8065 eval $inlibc
8066
8067 : see if fseeko exists
8068 set fseeko d_fseeko
8069 eval $inlibc
8070
8071 : see if fsetpos exists
8072 set fsetpos d_fsetpos
8073 eval $inlibc
8074
8075 : see if this is a sys/param system
8076 set sys/param.h i_sysparam
8077 eval $inhdr
8078
8079 : see if this is a sys/mount.h system
8080 set sys/mount.h i_sysmount
8081 eval $inhdr
8082
8083
8084 : see if statfs exists
8085 set statfs d_statfs
8086 eval $inlibc
8087
8088 : see if fstatfs exists
8089 set fstatfs d_fstatfs
8090 eval $inlibc
8091
8092 : see if statfs knows about mount flags
8093 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8094 eval $hasfield
8095
8096
8097 : see if statvfs exists
8098 set statvfs d_statvfs
8099 eval $inlibc
8100
8101 : see if fstatvfs exists
8102 set fstatvfs d_fstatvfs
8103 eval $inlibc
8104
8105
8106 : see if ftello exists
8107 set ftello d_ftello
8108 eval $inlibc
8109
8110 : see if getgrent exists
8111 set getgrent d_getgrent
8112 eval $inlibc
8113
8114 : see if gethostbyaddr exists
8115 set gethostbyaddr d_gethbyaddr
8116 eval $inlibc
8117
8118 : see if gethostbyname exists
8119 set gethostbyname d_gethbyname
8120 eval $inlibc
8121
8122 : see if gethostent exists
8123 set gethostent d_gethent
8124 eval $inlibc
8125
8126 : see how we will look up host name
8127 echo " "
8128 call=''
8129 if set gethostname val -f d_gethname; eval $csym; $val; then
8130         echo 'gethostname() found.' >&4
8131         d_gethname="$define"
8132         call=gethostname
8133 fi
8134 if set uname val -f d_uname; eval $csym; $val; then
8135         if ./xenix; then
8136                 $cat <<'EOM'
8137 uname() was found, but you're running xenix, and older versions of xenix
8138 have a broken uname(). If you don't really know whether your xenix is old
8139 enough to have a broken system call, use the default answer.
8140
8141 EOM
8142                 dflt=y
8143                 case "$d_uname" in
8144                 "$define") dflt=n;;
8145                 esac
8146                 rp='Is your uname() broken?'
8147                 . ./myread
8148                 case "$ans" in
8149                 n*) d_uname="$define"; call=uname;;
8150                 esac
8151         else
8152                 echo 'uname() found.' >&4
8153                 d_uname="$define"
8154                 case "$call" in
8155                 '') call=uname ;;
8156                 esac
8157         fi
8158 fi
8159 case "$d_gethname" in
8160 '') d_gethname="$undef";;
8161 esac
8162 case "$d_uname" in
8163 '') d_uname="$undef";;
8164 esac
8165 case "$d_uname$d_gethname" in
8166 *define*)
8167         dflt=n
8168         cat <<EOM
8169  
8170 Every now and then someone has a $call() that lies about the hostname
8171 but can't be fixed for political or economic reasons.  If you wish, I can
8172 pretend $call() isn't there and maybe compute hostname at run-time
8173 thanks to the '$phostname' command.
8174
8175 EOM
8176         rp="Shall I ignore $call() from now on?"
8177         . ./myread
8178         case "$ans" in
8179         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8180         esac;;
8181 esac
8182 case "$phostname" in
8183 '') aphostname='';;
8184 *) case "$aphostname" in
8185         /*) ;;
8186         *) set X $phostname
8187                 shift
8188                 file=$1
8189                 shift
8190                 file=`./loc $file $file $pth`
8191                 aphostname=`echo $file $*`
8192                 ;;
8193         esac
8194         ;;
8195 esac
8196 case "$d_uname$d_gethname" in
8197 *define*) ;;
8198 *)
8199         case "$phostname" in
8200         '')
8201                 echo "There will be no way for $package to get your hostname." >&4;;
8202         *)
8203         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8204                 ;;
8205         esac;;
8206 esac
8207 case "$d_phostname" in
8208 '') d_phostname="$undef";;
8209 esac
8210
8211 : see if this is a netdb.h system
8212 set netdb.h i_netdb
8213 eval $inhdr
8214
8215 : see if prototypes for various gethostxxx netdb.h functions are available
8216 echo " "
8217 set d_gethostprotos gethostent $i_netdb netdb.h
8218 eval $hasproto
8219
8220 : see if getlogin exists
8221 set getlogin d_getlogin
8222 eval $inlibc
8223
8224 : see if getmntent exists
8225 set getmntent d_getmntent
8226 eval $inlibc
8227
8228 : see if getnetbyaddr exists
8229 set getnetbyaddr d_getnbyaddr
8230 eval $inlibc
8231
8232 : see if getnetbyname exists
8233 set getnetbyname d_getnbyname
8234 eval $inlibc
8235
8236 : see if getnetent exists
8237 set getnetent d_getnent
8238 eval $inlibc
8239
8240 : see if prototypes for various getnetxxx netdb.h functions are available
8241 echo " "
8242 set d_getnetprotos getnetent $i_netdb netdb.h
8243 eval $hasproto
8244
8245
8246 : see if getprotobyname exists
8247 set getprotobyname d_getpbyname
8248 eval $inlibc
8249
8250 : see if getprotobynumber exists
8251 set getprotobynumber d_getpbynumber
8252 eval $inlibc
8253
8254 : see if getprotoent exists
8255 set getprotoent d_getpent
8256 eval $inlibc
8257
8258 : see if getpgid exists
8259 set getpgid d_getpgid
8260 eval $inlibc
8261
8262 : see if getpgrp2 exists
8263 set getpgrp2 d_getpgrp2
8264 eval $inlibc
8265
8266 : see if getppid exists
8267 set getppid d_getppid
8268 eval $inlibc
8269
8270 : see if getpriority exists
8271 set getpriority d_getprior
8272 eval $inlibc
8273
8274 : see if prototypes for various getprotoxxx netdb.h functions are available
8275 echo " "
8276 set d_getprotoprotos getprotoent $i_netdb netdb.h
8277 eval $hasproto
8278
8279 : see if getpwent exists
8280 set getpwent d_getpwent
8281 eval $inlibc
8282
8283
8284 : see if getservbyname exists
8285 set getservbyname d_getsbyname
8286 eval $inlibc
8287
8288 : see if getservbyport exists
8289 set getservbyport d_getsbyport
8290 eval $inlibc
8291
8292 : see if getservent exists
8293 set getservent d_getsent
8294 eval $inlibc
8295
8296 : see if prototypes for various getservxxx netdb.h functions are available
8297 echo " "
8298 set d_getservprotos getservent $i_netdb netdb.h
8299 eval $hasproto
8300
8301 : see if getspent exists
8302 set getspent d_getspent
8303 eval $inlibc
8304
8305 : see if getspnam exists
8306 set getspnam d_getspnam
8307 eval $inlibc
8308
8309 : see if gettimeofday or ftime exists
8310 set gettimeofday d_gettimeod
8311 eval $inlibc
8312 case "$d_gettimeod" in
8313 "$undef")
8314         set ftime d_ftime 
8315         eval $inlibc
8316         ;;
8317 *)
8318         val="$undef"; set d_ftime; eval $setvar
8319         ;;
8320 esac
8321 case "$d_gettimeod$d_ftime" in
8322 "$undef$undef")
8323         echo " "
8324         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8325         ;;
8326 esac
8327
8328 : see if this is an grp system
8329 set grp.h i_grp
8330 eval $inhdr
8331
8332 case "$i_grp" in
8333 $define)
8334         xxx=`./findhdr grp.h`
8335         $cppstdin $cppflags $cppminus < $xxx >$$.h
8336
8337         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8338                 val="$define"
8339         else
8340                 val="$undef"
8341         fi
8342         set d_grpasswd
8343         eval $setvar
8344
8345         $rm -f $$.h
8346         ;;
8347 *)
8348         val="$undef";
8349         set d_grpasswd; eval $setvar
8350         ;;
8351 esac
8352
8353 : see if hasmntopt exists
8354 set hasmntopt d_hasmntopt
8355 eval $inlibc
8356
8357 : see if this is a netinet/in.h or sys/in.h system
8358 set netinet/in.h i_niin sys/in.h i_sysin
8359 eval $inhdr
8360
8361 : see if arpa/inet.h has to be included
8362 set arpa/inet.h i_arpainet
8363 eval $inhdr
8364
8365 : see if htonl --and friends-- exists
8366 val=''
8367 set htonl val
8368 eval $inlibc
8369
8370 : Maybe they are macros.
8371 case "$val" in
8372 $undef)
8373         $cat >htonl.c <<EOM
8374 #include <stdio.h>
8375 #include <sys/types.h>
8376 #$i_niin I_NETINET_IN
8377 #$i_sysin I_SYS_IN
8378 #$i_arpainet I_ARPA_INET
8379 #ifdef I_NETINET_IN
8380 #include <netinet/in.h>
8381 #endif
8382 #ifdef I_SYS_IN
8383 #include <sys/in.h>
8384 #endif
8385 #ifdef I_ARPA_INET
8386 #include <arpa/inet.h>
8387 #endif
8388 #ifdef htonl
8389 printf("Defined as a macro.");
8390 #endif
8391 EOM
8392         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8393         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8394                 val="$define"
8395                 echo "But it seems to be defined as a macro." >&4
8396         fi
8397         $rm -f htonl.?
8398         ;;
8399 esac
8400 set d_htonl
8401 eval $setvar
8402
8403 : see which of string.h or strings.h is needed
8404 echo " "
8405 strings=`./findhdr string.h`
8406 if $test "$strings" && $test -r "$strings"; then
8407         echo "Using <string.h> instead of <strings.h>." >&4
8408         val="$define"
8409 else
8410         val="$undef"
8411         strings=`./findhdr strings.h`
8412         if $test "$strings" && $test -r "$strings"; then
8413                 echo "Using <strings.h> instead of <string.h>." >&4
8414         else
8415                 echo "No string header found -- You'll surely have problems." >&4
8416         fi
8417 fi
8418 set i_string
8419 eval $setvar
8420 case "$i_string" in
8421 "$undef") strings=`./findhdr strings.h`;;
8422 *)        strings=`./findhdr string.h`;;
8423 esac
8424
8425 : index or strchr
8426 echo " "
8427 if set index val -f; eval $csym; $val; then
8428         if set strchr val -f d_strchr; eval $csym; $val; then
8429                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8430                         val="$define"
8431                         vali="$undef"
8432                         echo "strchr() found." >&4
8433                 else
8434                         val="$undef"
8435                         vali="$define"
8436                         echo "index() found." >&4
8437                 fi
8438         else
8439                 val="$undef"
8440                 vali="$define"
8441                 echo "index() found." >&4
8442         fi
8443 else
8444         if set strchr val -f d_strchr; eval $csym; $val; then
8445                 val="$define"
8446                 vali="$undef"
8447                 echo "strchr() found." >&4
8448         else
8449                 echo "No index() or strchr() found!" >&4
8450                 val="$undef"
8451                 vali="$undef"
8452         fi
8453 fi
8454 set d_strchr; eval $setvar
8455 val="$vali"
8456 set d_index; eval $setvar
8457
8458 : check whether inet_aton exists
8459 set inet_aton d_inetaton
8460 eval $inlibc
8461
8462 : see if inttypes.h is available
8463 : we want a real compile instead of Inhdr because some systems
8464 : have an inttypes.h which includes non-existent headers
8465 echo " "
8466 $cat >try.c <<EOCP
8467 #include <inttypes.h>
8468 int main() {
8469         static int32_t foo32 = 0x12345678;
8470 }
8471 EOCP
8472 set try
8473 if eval $compile; then
8474         echo "<inttypes.h> found." >&4
8475         val="$define"
8476 else
8477         echo "<inttypes.h> NOT found." >&4
8478         val="$undef"
8479 fi
8480 $rm -f try.c try
8481 set i_inttypes
8482 eval $setvar
8483
8484 : check for int64_t
8485 case "$use64bits" in
8486 "$define" )
8487         echo " "
8488         echo $n "Checking to see if your system supports int64_t...$c" >&4
8489         $cat >try.c <<EOCP
8490 #include <sys/types.h>
8491 #$i_inttypes I_INTTYPES
8492 #ifdef I_INTTYPES
8493 #include <inttypes.h>
8494 #endif
8495 int64_t foo() { int64_t x; x = 7; return x; }
8496 EOCP
8497         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8498                 val="$define"
8499                 echo " Yup, it does." >&4
8500         else
8501                 val="$undef"
8502                 echo " Nope, it doesn't." >&4
8503         fi
8504         $rm -f try.*
8505         ;;
8506 *)      val="$undef"
8507         ;;
8508 esac
8509 set d_int64t
8510 eval $setvar
8511
8512
8513 : Look for isascii
8514 echo " "
8515 $cat >isascii.c <<'EOCP'
8516 #include <stdio.h>
8517 #include <ctype.h>
8518 int main() {
8519         int c = 'A';
8520         if (isascii(c))
8521                 exit(0);
8522         else
8523                 exit(1);
8524 }
8525 EOCP
8526 set isascii
8527 if eval $compile; then
8528         echo "isascii() found." >&4
8529         val="$define"
8530 else
8531         echo "isascii() NOT found." >&4
8532         val="$undef"
8533 fi
8534 set d_isascii
8535 eval $setvar
8536 $rm -f isascii*
8537
8538 : see if killpg exists
8539 set killpg d_killpg
8540 eval $inlibc
8541
8542 : see if lchown exists
8543 echo " "
8544 $cat > try.c <<'EOCP'
8545 /* System header to define __stub macros and hopefully few prototypes,
8546     which can conflict with char lchown(); below.  */
8547 #include <assert.h>
8548 /* Override any gcc2 internal prototype to avoid an error.  */
8549 /* We use char because int might match the return type of a gcc2
8550    builtin and then its argument prototype would still apply.  */
8551 char lchown();
8552 int main() {
8553     /*  The GNU C library defines this for functions which it implements
8554         to always fail with ENOSYS.  Some functions are actually named
8555         something starting with __ and the normal name is an alias.  */
8556 #if defined (__stub_lchown) || defined (__stub___lchown)
8557 choke me
8558 #else
8559 lchown();
8560 #endif
8561 ; return 0; }
8562 EOCP
8563 set try
8564 if eval $compile; then
8565     $echo "lchown() found." >&4
8566     val="$define"
8567 else
8568     $echo "lchown() NOT found." >&4
8569     val="$undef"
8570 fi
8571 set d_lchown
8572 eval $setvar
8573
8574 : see if link exists
8575 set link d_link
8576 eval $inlibc
8577
8578 : see if localeconv exists
8579 set localeconv d_locconv
8580 eval $inlibc
8581
8582 : see if lockf exists
8583 set lockf d_lockf
8584 eval $inlibc
8585
8586 : check for length of double
8587 echo " "
8588 case "$doublesize" in
8589 '')
8590         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8591         $cat >try.c <<'EOCP'
8592 #include <stdio.h>
8593 int main()
8594 {
8595         printf("%d\n", sizeof(double));
8596 }
8597 EOCP
8598         set try
8599         if eval $compile_ok; then
8600                 doublesize=`./try`
8601                 $echo " $doublesize bytes." >&4
8602         else
8603                 dflt='8'
8604                 echo "(I can't seem to compile the test program.  Guessing...)"
8605                 rp="What is the size of a double precision number (in bytes)?"
8606                 . ./myread
8607                 doublesize="$ans"
8608         fi
8609         ;;
8610 esac
8611 $rm -f try.c try
8612
8613 : check for long doubles
8614 echo " "
8615 echo $n "Checking to see if your system supports long doubles...$c" >&4
8616 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8617 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8618         val="$define"
8619         echo " Yup, it does." >&4
8620 else
8621         val="$undef"
8622         echo " Nope, it doesn't." >&4
8623 fi
8624 $rm try.*
8625 set d_longdbl
8626 eval $setvar
8627
8628 : check for length of long double
8629 case "${d_longdbl}${longdblsize}" in
8630 $define)
8631         echo " "
8632         $echo $n "Checking to see how big your long doubles are...$c" >&4
8633         $cat >try.c <<'EOCP'
8634 #include <stdio.h>
8635 int main()
8636 {
8637         printf("%d\n", sizeof(long double));
8638 }
8639 EOCP
8640         set try
8641         if eval $compile; then
8642                 longdblsize=`./try`
8643                 $echo " $longdblsize bytes." >&4
8644         else
8645                 dflt='8'
8646                 echo " "
8647                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8648                 rp="What is the size of a long double (in bytes)?"
8649                 . ./myread
8650                 longdblsize="$ans"
8651         fi
8652         if $test "X$doublesize" = "X$longdblsize"; then
8653                 echo "(That isn't any different from an ordinary double.)"
8654         fi      
8655         ;;
8656 esac
8657 $rm -f try.c try
8658
8659 : check for long long
8660 echo " "
8661 echo $n "Checking to see if your system supports long long...$c" >&4
8662 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8663 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8664         val="$define"
8665         echo " Yup, it does." >&4
8666 else
8667         val="$undef"
8668         echo " Nope, it doesn't." >&4
8669 fi
8670 $rm try.*
8671 set d_longlong
8672 eval $setvar
8673
8674 : check for length of long long
8675 case "${d_longlong}${longlongsize}" in
8676 $define)
8677         echo " "
8678         $echo $n "Checking to see how big your long longs are...$c" >&4
8679         $cat >try.c <<'EOCP'
8680 #include <stdio.h>
8681 int main()
8682 {
8683         printf("%d\n", sizeof(long long));
8684 }
8685 EOCP
8686         set try
8687         if eval $compile_ok; then
8688                 longlongsize=`./try`
8689                 $echo " $longlongsize bytes." >&4
8690         else
8691                 dflt='8'
8692                 echo " "
8693                 echo "(I can't seem to compile the test program.  Guessing...)"
8694                 rp="What is the size of a long long (in bytes)?"
8695                 . ./myread
8696                 longlongsize="$ans"
8697         fi
8698         if $test "X$longsize" = "X$longlongsize"; then
8699                 echo "(That isn't any different from an ordinary long.)"
8700         fi      
8701         ;;
8702 esac
8703 $rm -f try.c try
8704
8705 : see if lstat exists
8706 set lstat d_lstat
8707 eval $inlibc
8708
8709 : see if madvise exists
8710 set madvise d_madvise
8711 eval $inlibc
8712
8713 : see if mblen exists
8714 set mblen d_mblen
8715 eval $inlibc
8716
8717 : see if mbstowcs exists
8718 set mbstowcs d_mbstowcs
8719 eval $inlibc
8720
8721 : see if mbtowc exists
8722 set mbtowc d_mbtowc
8723 eval $inlibc
8724
8725 : see if memchr exists
8726 set memchr d_memchr
8727 eval $inlibc
8728
8729 : see if memcmp exists
8730 set memcmp d_memcmp
8731 eval $inlibc
8732
8733 : see if memcpy exists
8734 set memcpy d_memcpy
8735 eval $inlibc
8736
8737 : see if memmove exists
8738 set memmove d_memmove
8739 eval $inlibc
8740
8741 : see if memset exists
8742 set memset d_memset
8743 eval $inlibc
8744
8745 : see if mkdir exists
8746 set mkdir d_mkdir
8747 eval $inlibc
8748
8749 : see if mkfifo exists
8750 set mkfifo d_mkfifo
8751 eval $inlibc
8752
8753 : see if mktime exists
8754 set mktime d_mktime
8755 eval $inlibc
8756
8757 : see if this is a sys/mman.h system
8758 set sys/mman.h i_sysmman
8759 eval $inhdr
8760
8761 : see if mmap exists
8762 set mmap d_mmap
8763 eval $inlibc
8764 : see what shmat returns
8765 : default to something harmless
8766 mmaptype='void *'
8767 case "$i_sysmman$d_mmap" in
8768 "$define$define")
8769         $cat >mmap.c <<'END'
8770 #include <sys/mman.h>
8771 void *mmap();
8772 END
8773         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8774                 mmaptype='void *'
8775         else
8776                 mmaptype='caddr_t'
8777         fi
8778         echo "and it returns ($mmaptype)." >&4
8779         ;;
8780 esac
8781
8782
8783
8784 : see if mprotect exists
8785 set mprotect d_mprotect
8786 eval $inlibc
8787
8788 : see if msgctl exists
8789 set msgctl d_msgctl
8790 eval $inlibc
8791
8792 : see if msgget exists
8793 set msgget d_msgget
8794 eval $inlibc
8795
8796 : see if msgsnd exists
8797 set msgsnd d_msgsnd
8798 eval $inlibc
8799
8800 : see if msgrcv exists
8801 set msgrcv d_msgrcv
8802 eval $inlibc
8803
8804 : see how much of the 'msg*(2)' library is present.
8805 h_msg=true
8806 echo " "
8807 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8808 *"$undef"*) h_msg=false;;
8809 esac
8810 case "$osname" in
8811 freebsd)
8812     case "`ipcs 2>&1`" in
8813     "SVID messages"*"not configured"*)
8814         echo "Your $osname does not have the msg*(2) configured." >&4
8815         h_msg=false
8816         val="$undef"
8817         set msgctl d_msgctl
8818         eval $setvar
8819         set msgget d_msgget
8820         eval $setvar
8821         set msgsnd d_msgsnd
8822         eval $setvar
8823         set msgrcv d_msgrcv
8824         eval $setvar
8825         ;;
8826     esac
8827     ;;
8828 esac
8829 : we could also check for sys/ipc.h ...
8830 if $h_msg && $test `./findhdr sys/msg.h`; then
8831         echo "You have the full msg*(2) library." >&4
8832         val="$define"
8833 else
8834         echo "You don't have the full msg*(2) library." >&4
8835         val="$undef"
8836 fi
8837 set d_msg
8838 eval $setvar
8839
8840 : see if msync exists
8841 set msync d_msync
8842 eval $inlibc
8843
8844 : see if munmap exists
8845 set munmap d_munmap
8846 eval $inlibc
8847
8848 : see if nice exists
8849 set nice d_nice
8850 eval $inlibc
8851
8852 : see if POSIX threads are available
8853 if test "X$usethreads" = "X$define"; then
8854         set pthread.h i_pthread
8855         eval $inhdr
8856 else
8857         i_pthread="$undef"
8858 fi
8859
8860
8861
8862 : how to create joinable pthreads
8863 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
8864         echo " "
8865         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8866         $cat >try.c <<'EOCP'
8867 #include <pthread.h>
8868 int main() {
8869     int detachstate = JOINABLE;
8870 }
8871 EOCP
8872         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8873         if eval $compile; then
8874                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8875                 val="$undef" # Yes, undef.
8876                 set d_old_pthread_create_joinable
8877                 eval $setvar
8878                 val=""
8879                 set old_pthread_create_joinable
8880                 eval $setvar
8881         else
8882                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8883                 if eval $compile; then
8884                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8885                         val="$define"
8886                         set d_old_pthread_create_joinable
8887                         eval $setvar
8888                         val=PTHREAD_CREATE_UNDETACHED
8889                         set old_pthread_create_joinable
8890                         eval $setvar
8891                 else            
8892                         set try -DJOINABLE=__UNDETACHED
8893                         if eval $compile; then
8894                                 echo "You seem to use __UNDETACHED." >&4
8895                                 val="$define"
8896                                 set d_old_pthread_create_joinable
8897                                 eval $setvar
8898                                 val=__UNDETACHED
8899                                 set old_pthread_create_joinable
8900                                 eval $setvar
8901                         else
8902                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8903                                 val="$define"
8904                                 set d_old_pthread_create_joinable
8905                                 eval $setvar
8906                                 val=0
8907                                 set old_pthread_create_joinable
8908                                 eval $setvar
8909                         fi
8910                 fi
8911         fi
8912         $rm -f try try.*
8913 else
8914     d_old_pthread_create_joinable="$undef"
8915     old_pthread_create_joinable=""
8916 fi
8917
8918 : see if pause exists
8919 set pause d_pause
8920 eval $inlibc
8921
8922 : see if pipe exists
8923 set pipe d_pipe
8924 eval $inlibc
8925
8926 : see if poll exists
8927 set poll d_poll
8928 eval $inlibc
8929
8930
8931 : see whether the various POSIXish _yields exist
8932 $cat >try.c <<EOP
8933 #include <pthread.h>
8934 #include <stdio.h>
8935 int main() {
8936 #ifdef SCHED_YIELD
8937         sched_yield();
8938 #else
8939 #ifdef PTHREAD_YIELD
8940         pthread_yield();
8941 #else
8942 #ifdef PTHREAD_YIELD_NULL
8943         pthread_yield(NULL);
8944 #endif
8945 #endif
8946 #endif
8947 }
8948 EOP
8949 : see if sched_yield exists
8950 set try -DSCHED_YIELD
8951 if eval $compile; then
8952     val="$define"
8953     sched_yield='sched_yield()'
8954 else
8955     val="$undef"
8956 fi
8957 case "$usethreads" in
8958 $define)
8959         case "$val" in
8960         $define) echo 'sched_yield() found.' >&4        ;;
8961         *)       echo 'sched_yield() NOT found.' >&4    ;;
8962         esac
8963 esac
8964 set d_sched_yield
8965 eval $setvar
8966
8967 : see if pthread_yield exists
8968 set try -DPTHREAD_YIELD
8969 if eval $compile; then
8970     val="$define"
8971     case "$sched_yield" in
8972     '') sched_yield='pthread_yield()' ;;
8973     esac
8974 else
8975     set try -DPTHREAD_YIELD_NULL
8976     if eval $compile; then
8977         val="$define"
8978         case "$sched_yield" in
8979         '') sched_yield='pthread_yield(NULL)' ;;
8980         esac
8981     else
8982         val="$undef"
8983     fi
8984 fi
8985 case "$usethreads" in
8986 $define)
8987         case "$val" in
8988         $define) echo 'pthread_yield() found.' >&4      ;;
8989         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8990         esac
8991         ;;
8992 esac
8993 set d_pthread_yield
8994 eval $setvar
8995
8996 case "$sched_yield" in
8997 '') sched_yield=undef ;;
8998 esac
8999
9000 $rm -f try try.*
9001
9002 : see if this is a pwd.h system
9003 set pwd.h i_pwd
9004 eval $inhdr
9005
9006 case "$i_pwd" in
9007 $define)
9008         xxx=`./findhdr pwd.h`
9009         $cppstdin $cppflags $cppminus < $xxx >$$.h
9010
9011         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
9012                 val="$define"
9013         else
9014                 val="$undef"
9015         fi
9016         set d_pwquota
9017         eval $setvar
9018
9019         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
9020                 val="$define"
9021         else
9022                 val="$undef"
9023         fi
9024         set d_pwage
9025         eval $setvar
9026
9027         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
9028                 val="$define"
9029         else
9030                 val="$undef"
9031         fi
9032         set d_pwchange
9033         eval $setvar
9034
9035         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
9036                 val="$define"
9037         else
9038                 val="$undef"
9039         fi
9040         set d_pwclass
9041         eval $setvar
9042
9043         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
9044                 val="$define"
9045         else
9046                 val="$undef"
9047         fi
9048         set d_pwexpire
9049         eval $setvar
9050
9051         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
9052                 val="$define"
9053         else
9054                 val="$undef"
9055         fi
9056         set d_pwcomment
9057         eval $setvar
9058
9059         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
9060                 val="$define"
9061         else
9062                 val="$undef"
9063         fi
9064         set d_pwgecos
9065         eval $setvar
9066
9067         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
9068                 val="$define"
9069         else
9070                 val="$undef"
9071         fi
9072         set d_pwpasswd
9073         eval $setvar
9074
9075         $rm -f $$.h
9076         ;;
9077 *)
9078         val="$undef"; 
9079         set d_pwquota; eval $setvar
9080         set d_pwage; eval $setvar
9081         set d_pwchange; eval $setvar
9082         set d_pwclass; eval $setvar
9083         set d_pwexpire; eval $setvar
9084         set d_pwcomment; eval $setvar
9085         set d_pwgecos; eval $setvar
9086         set d_pwpasswd; eval $setvar
9087         ;;
9088 esac
9089
9090 : see if readdir and friends exist
9091 set readdir d_readdir
9092 eval $inlibc
9093 set seekdir d_seekdir
9094 eval $inlibc
9095 set telldir d_telldir
9096 eval $inlibc
9097 set rewinddir d_rewinddir
9098 eval $inlibc
9099
9100 : see if readlink exists
9101 set readlink d_readlink
9102 eval $inlibc
9103
9104 : see if readv exists
9105 set readv d_readv
9106 eval $inlibc
9107
9108 : see if rename exists
9109 set rename d_rename
9110 eval $inlibc
9111
9112 : see if rmdir exists
9113 set rmdir d_rmdir
9114 eval $inlibc
9115
9116 : see if memory.h is available.
9117 val=''
9118 set memory.h val
9119 eval $inhdr
9120
9121 : See if it conflicts with string.h
9122 case "$val" in
9123 $define)
9124         case "$strings" in
9125         '') ;;
9126         *)
9127                 $cppstdin $cppflags $cppminus < $strings > mem.h
9128                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9129                         echo " "
9130                         echo "We won't be including <memory.h>."
9131                         val="$undef"
9132                 fi
9133                 $rm -f mem.h
9134                 ;;
9135         esac
9136 esac
9137 set i_memory
9138 eval $setvar
9139
9140 : can bcopy handle overlapping blocks?
9141 val="$undef"
9142 case "$d_bcopy" in
9143 "$define")
9144         echo " "
9145         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9146         $cat >try.c <<EOCP
9147 #$i_memory I_MEMORY
9148 #$i_stdlib I_STDLIB
9149 #$i_string I_STRING
9150 #$i_unistd I_UNISTD
9151 EOCP
9152         $cat >>try.c <<'EOCP'
9153 #include <stdio.h>
9154 #ifdef I_MEMORY
9155 #  include <memory.h>
9156 #endif
9157 #ifdef I_STDLIB
9158 #  include <stdlib.h>
9159 #endif
9160 #ifdef I_STRING
9161 #  include <string.h>
9162 #else
9163 #  include <strings.h>
9164 #endif
9165 #ifdef I_UNISTD
9166 #  include <unistd.h>  /* Needed for NetBSD */
9167 #endif
9168 int main()
9169 {
9170 char buf[128], abc[128];
9171 char *b;
9172 int len;
9173 int off;
9174 int align;
9175
9176 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9177
9178 for (align = 7; align >= 0; align--) {
9179         for (len = 36; len; len--) {
9180                 b = buf+align;
9181                 bcopy(abc, b, len);
9182                 for (off = 1; off <= len; off++) {
9183                         bcopy(b, b+off, len);
9184                         bcopy(b+off, b, len);
9185                         if (bcmp(b, abc, len))
9186                                 exit(1);
9187                 }
9188         }
9189 }
9190 exit(0);
9191 }
9192 EOCP
9193         set try
9194         if eval $compile_ok; then
9195                 if ./try 2>/dev/null; then
9196                         echo "Yes, it can."
9197                         val="$define"
9198                 else
9199                         echo "It can't, sorry."
9200                         case "$d_memmove" in
9201                         "$define") echo "But that's Ok since you have memmove()." ;;
9202                         esac
9203                 fi
9204         else
9205                 echo "(I can't compile the test program, so we'll assume not...)"
9206                 case "$d_memmove" in
9207                 "$define") echo "But that's Ok since you have memmove()." ;;
9208                 esac
9209         fi
9210         ;;
9211 esac
9212 $rm -f try.* try core
9213 set d_safebcpy
9214 eval $setvar
9215
9216 : can memcpy handle overlapping blocks?
9217 val="$undef"
9218 case "$d_memcpy" in
9219 "$define")
9220         echo " "
9221         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9222         $cat >try.c <<EOCP
9223 #$i_memory I_MEMORY
9224 #$i_stdlib I_STDLIB
9225 #$i_string I_STRING
9226 #$i_unistd I_UNISTD
9227 EOCP
9228         $cat >>try.c <<'EOCP'
9229 #include <stdio.h>
9230 #ifdef I_MEMORY
9231 #  include <memory.h>
9232 #endif
9233 #ifdef I_STDLIB
9234 #  include <stdlib.h>
9235 #endif
9236 #ifdef I_STRING
9237 #  include <string.h>
9238 #else
9239 #  include <strings.h>
9240 #endif
9241 #ifdef I_UNISTD
9242 #  include <unistd.h>  /* Needed for NetBSD */
9243 #endif
9244 int main()
9245 {
9246 char buf[128], abc[128];
9247 char *b;
9248 int len;
9249 int off;
9250 int align;
9251
9252 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9253    try to store the string in read-only memory. */
9254 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9255
9256 for (align = 7; align >= 0; align--) {
9257         for (len = 36; len; len--) {
9258                 b = buf+align;
9259                 memcpy(b, abc, len);
9260                 for (off = 1; off <= len; off++) {
9261                         memcpy(b+off, b, len);
9262                         memcpy(b, b+off, len);
9263                         if (memcmp(b, abc, len))
9264                                 exit(1);
9265                 }
9266         }
9267 }
9268 exit(0);
9269 }
9270 EOCP
9271         set try
9272         if eval $compile_ok; then
9273                 if ./try 2>/dev/null; then
9274                         echo "Yes, it can."
9275                         val="$define"
9276                 else
9277                         echo "It can't, sorry."
9278                         case "$d_memmove" in
9279                         "$define") echo "But that's Ok since you have memmove()." ;;
9280                         esac
9281                 fi
9282         else
9283                 echo "(I can't compile the test program, so we'll assume not...)"
9284                 case "$d_memmove" in
9285                 "$define") echo "But that's Ok since you have memmove()." ;;
9286                 esac
9287         fi
9288         ;;
9289 esac
9290 $rm -f try.* try core
9291 set d_safemcpy
9292 eval $setvar
9293
9294 : can memcmp be trusted to compare relative magnitude?
9295 val="$undef"
9296 case "$d_memcmp" in
9297 "$define")
9298         echo " "
9299         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9300         $cat >try.c <<EOCP
9301 #$i_memory I_MEMORY
9302 #$i_stdlib I_STDLIB
9303 #$i_string I_STRING
9304 #$i_unistd I_UNISTD
9305 EOCP
9306         $cat >>try.c <<'EOCP'
9307 #include <stdio.h>
9308 #ifdef I_MEMORY
9309 #  include <memory.h>
9310 #endif
9311 #ifdef I_STDLIB
9312 #  include <stdlib.h>
9313 #endif
9314 #ifdef I_STRING
9315 #  include <string.h>
9316 #else
9317 #  include <strings.h>
9318 #endif
9319 #ifdef I_UNISTD
9320 #  include <unistd.h>  /* Needed for NetBSD */
9321 #endif
9322 int main()
9323 {
9324 char a = -1;
9325 char b = 0;
9326 if ((a < b) && memcmp(&a, &b, 1) < 0)
9327         exit(1);
9328 exit(0);
9329 }
9330 EOCP
9331         set try
9332         if eval $compile_ok; then
9333                 if ./try 2>/dev/null; then
9334                         echo "Yes, it can."
9335                         val="$define"
9336                 else
9337                         echo "No, it can't (it uses signed chars)."
9338                 fi
9339         else
9340                 echo "(I can't compile the test program, so we'll assume not...)"
9341         fi
9342         ;;
9343 esac
9344 $rm -f try.* try core
9345 set d_sanemcmp
9346 eval $setvar
9347
9348 : see if select exists
9349 set select d_select
9350 eval $inlibc
9351
9352 : see if semctl exists
9353 set semctl d_semctl
9354 eval $inlibc
9355
9356 : see if semget exists
9357 set semget d_semget
9358 eval $inlibc
9359
9360 : see if semop exists
9361 set semop d_semop
9362 eval $inlibc
9363
9364 : see how much of the 'sem*(2)' library is present.
9365 h_sem=true
9366 echo " "
9367 case "$d_semctl$d_semget$d_semop" in
9368 *"$undef"*) h_sem=false;;
9369 esac
9370 case "$osname" in
9371 freebsd)
9372     case "`ipcs 2>&1`" in
9373     "SVID messages"*"not configured"*)
9374         echo "Your $osname does not have the sem*(2) configured." >&4
9375         h_sem=false
9376         val="$undef"
9377         set semctl d_semctl
9378         eval $setvar
9379         set semget d_semget
9380         eval $setvar
9381         set semop d_semop
9382         eval $setvar
9383         ;;
9384     esac
9385     ;;
9386 esac
9387 : we could also check for sys/ipc.h ...
9388 if $h_sem && $test `./findhdr sys/sem.h`; then
9389         echo "You have the full sem*(2) library." >&4
9390         val="$define"
9391 else
9392         echo "You don't have the full sem*(2) library." >&4
9393         val="$undef"
9394 fi
9395 set d_sem
9396 eval $setvar
9397
9398 : see whether sys/sem.h defines union semun
9399 echo " "
9400 $cat > try.c <<'END'
9401 #include <sys/types.h>
9402 #include <sys/ipc.h>
9403 #include <sys/sem.h>
9404 int main () { union semun semun; semun.buf = 0; }
9405 END
9406 set try
9407 if eval $compile; then
9408     echo "You have union semun in <sys/sem.h>." >&4
9409     val="$define"
9410 else
9411     echo "You do not have union semun in <sys/sem.h>." >&4
9412     val="$undef"
9413 fi
9414 $rm -f try try.c try.h
9415 set d_union_semun
9416 eval $setvar
9417
9418 : see how to do semctl IPC_STAT
9419 case "$d_sem" in
9420 $define)
9421     : see whether semctl IPC_STAT can use union semun
9422     echo " "
9423     $cat > try.h <<END
9424 #ifndef S_IRUSR
9425 #   ifdef S_IREAD
9426 #       define S_IRUSR S_IREAD
9427 #       define S_IWUSR S_IWRITE
9428 #       define S_IXUSR S_IEXEC
9429 #   else
9430 #       define S_IRUSR 0400
9431 #       define S_IWUSR 0200
9432 #       define S_IXUSR 0100
9433 #   endif
9434 #   define S_IRGRP (S_IRUSR>>3)
9435 #   define S_IWGRP (S_IWUSR>>3)
9436 #   define S_IXGRP (S_IXUSR>>3)
9437 #   define S_IROTH (S_IRUSR>>6)
9438 #   define S_IWOTH (S_IWUSR>>6)
9439 #   define S_IXOTH (S_IXUSR>>6)
9440 #endif
9441 #ifndef S_IRWXU
9442 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9443 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9444 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9445 #endif
9446 END
9447
9448     $cat > try.c <<END
9449 #include <sys/types.h>
9450 #include <sys/ipc.h>
9451 #include <sys/sem.h>
9452 #include <sys/stat.h>
9453 #include <stdio.h>
9454 #include <errno.h>
9455 #include "try.h"
9456 #ifndef errno
9457 extern int errno;
9458 #endif
9459 #$d_union_semun HAS_UNION_SEMUN
9460 int main() {
9461     union semun
9462 #ifndef HAS_UNION_SEMUN
9463     {
9464         int val;
9465         struct semid_ds *buf;
9466         unsigned short *array;
9467     }
9468 #endif
9469     arg;
9470     int sem, st;
9471
9472 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9473     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9474     if (sem > -1) {
9475         struct semid_ds argbuf;
9476         arg.buf = &argbuf;
9477 #       ifdef IPC_STAT
9478         st = semctl(sem, 0, IPC_STAT, arg);
9479         if (st == 0)
9480             printf("semun\n");
9481         else
9482 #       endif /* IPC_STAT */
9483             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9484 #       ifdef IPC_RMID
9485         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9486 #       endif /* IPC_RMID */
9487             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9488     } else
9489 #endif /* IPC_PRIVATE && ... */
9490         printf("semget failed: errno = %d\n", errno);
9491   return 0;
9492 }
9493 END
9494     val="$undef"
9495     set try
9496     if eval $compile; then
9497         xxx=`./try`
9498         case "$xxx" in
9499         semun) val="$define" ;;
9500         esac
9501     fi
9502     $rm -f try try.c
9503     set d_semctl_semun
9504     eval $setvar
9505     case "$d_semctl_semun" in
9506     $define)
9507         echo "You can use union semun for semctl IPC_STAT." >&4
9508         also='also'
9509         ;;
9510     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9511         also=''
9512         ;;
9513     esac
9514
9515     : see whether semctl IPC_STAT can use struct semid_ds pointer
9516     $cat > try.c <<'END'
9517 #include <sys/types.h>
9518 #include <sys/ipc.h>
9519 #include <sys/sem.h>
9520 #include <sys/stat.h>
9521 #include "try.h"
9522 #include <stdio.h>
9523 #include <errno.h>
9524 #ifndef errno
9525 extern int errno;
9526 #endif
9527 int main() {
9528     struct semid_ds arg;
9529     int sem, st;
9530
9531 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9532     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9533     if (sem > -1) {
9534 #       ifdef IPC_STAT
9535         st = semctl(sem, 0, IPC_STAT, &arg);
9536         if (st == 0)
9537             printf("semid_ds\n");
9538         else
9539 #       endif /* IPC_STAT */
9540             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9541 #       ifdef IPC_RMID
9542         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9543 #       endif /* IPC_RMID */
9544             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9545     } else
9546 #endif /* IPC_PRIVATE && ... */
9547         printf("semget failed: errno = %d\n", errno);
9548
9549     return 0;
9550 }
9551 END
9552     val="$undef"
9553     set try
9554     if eval $compile; then
9555         xxx=`./try`
9556         case "$xxx" in
9557         semid_ds) val="$define" ;;
9558         esac
9559     fi
9560     $rm -f try try.c
9561     set d_semctl_semid_ds
9562     eval $setvar
9563     case "$d_semctl_semid_ds" in
9564     $define)
9565         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9566         ;;
9567     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9568         ;;
9569     esac
9570     $rm -f try.h
9571     ;;
9572 *)  val="$undef"
9573
9574     # We do not have the full sem*(2) library, so assume we can not
9575     # use either.
9576
9577     set d_semctl_semun
9578     eval $setvar
9579
9580     set d_semctl_semid_ds
9581     eval $setvar
9582     ;;
9583 esac
9584
9585 : see if setegid exists
9586 set setegid d_setegid
9587 eval $inlibc
9588
9589 : see if seteuid exists
9590 set seteuid d_seteuid
9591 eval $inlibc
9592
9593 : see if setgrent exists
9594 set setgrent d_setgrent
9595 eval $inlibc
9596
9597 : see if sethostent exists
9598 set sethostent d_sethent
9599 eval $inlibc
9600
9601 : see if setlinebuf exists
9602 set setlinebuf d_setlinebuf
9603 eval $inlibc
9604
9605 : see if setlocale exists
9606 set setlocale d_setlocale
9607 eval $inlibc
9608
9609 : see if setnetent exists
9610 set setnetent d_setnent
9611 eval $inlibc
9612
9613 : see if setprotoent exists
9614 set setprotoent d_setpent
9615 eval $inlibc
9616
9617 : see if setpgid exists
9618 set setpgid d_setpgid
9619 eval $inlibc
9620
9621 : see if setpgrp2 exists
9622 set setpgrp2 d_setpgrp2
9623 eval $inlibc
9624
9625 : see if setpriority exists
9626 set setpriority d_setprior
9627 eval $inlibc
9628
9629 : see if setpwent exists
9630 set setpwent d_setpwent
9631 eval $inlibc
9632
9633 : see if setregid exists
9634 set setregid d_setregid
9635 eval $inlibc
9636 set setresgid d_setresgid
9637 eval $inlibc
9638
9639 : see if setreuid exists
9640 set setreuid d_setreuid
9641 eval $inlibc
9642 set setresuid d_setresuid
9643 eval $inlibc
9644
9645 : see if setrgid exists
9646 set setrgid d_setrgid
9647 eval $inlibc
9648
9649 : see if setruid exists
9650 set setruid d_setruid
9651 eval $inlibc
9652
9653 : see if setservent exists
9654 set setservent d_setsent
9655 eval $inlibc
9656
9657 : see if setsid exists
9658 set setsid d_setsid
9659 eval $inlibc
9660
9661 : see if setspent exists
9662 set setspent d_setspent
9663 eval $inlibc
9664
9665 : see if setvbuf exists
9666 set setvbuf d_setvbuf
9667 eval $inlibc
9668
9669 : see if sfio.h is available
9670 set sfio.h i_sfio
9671 eval $inhdr
9672
9673
9674 : see if sfio library is available
9675 case "$i_sfio" in
9676 $define)
9677         val=''
9678         set sfreserve val
9679         eval $inlibc
9680         ;;
9681 *)
9682         val="$undef"
9683         ;;
9684 esac
9685 : Ok, but do we want to use it.
9686 case "$val" in
9687 $define)
9688         case "$usesfio" in
9689         true|$define|[yY]*) dflt='y';;
9690         *) dflt='n';;
9691         esac
9692         echo "$package can use the sfio library, but it is experimental."
9693         rp="You seem to have sfio available, do you want to try using it?"
9694         . ./myread
9695         case "$ans" in
9696         y|Y) ;;
9697         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9698                 val="$undef"
9699                 : Remove sfio from list of libraries to use
9700                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9701                 shift
9702                 libs="$*"
9703                 echo "libs = $libs" >&4
9704                 ;;
9705         esac
9706         ;;
9707 *)      case "$usesfio" in
9708         true|$define|[yY]*)
9709                 echo "Sorry, cannot find sfio on this machine" >&4
9710                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9711                 ;;
9712         esac
9713         ;;
9714 esac
9715 set d_sfio
9716 eval $setvar
9717 case "$d_sfio" in
9718 $define) usesfio='true';;
9719 *) usesfio='false';;
9720 esac
9721
9722 : see if shmctl exists
9723 set shmctl d_shmctl
9724 eval $inlibc
9725
9726 : see if shmget exists
9727 set shmget d_shmget
9728 eval $inlibc
9729
9730 : see if shmat exists
9731 set shmat d_shmat
9732 eval $inlibc
9733 : see what shmat returns
9734 case "$d_shmat" in
9735 "$define")
9736         $cat >shmat.c <<'END'
9737 #include <sys/shm.h>
9738 void *shmat();
9739 END
9740         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9741                 shmattype='void *'
9742         else
9743                 shmattype='char *'
9744         fi
9745         echo "and it returns ($shmattype)." >&4
9746         : see if a prototype for shmat is available
9747         xxx=`./findhdr sys/shm.h`
9748         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9749         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9750                 val="$define"
9751         else
9752                 val="$undef"
9753         fi
9754         $rm -f shmat.[co]
9755         ;;
9756 *)
9757         val="$undef"
9758         ;;
9759 esac
9760 set d_shmatprototype
9761 eval $setvar
9762
9763 : see if shmdt exists
9764 set shmdt d_shmdt
9765 eval $inlibc
9766
9767 : see how much of the 'shm*(2)' library is present.
9768 h_shm=true
9769 echo " "
9770 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9771 *"$undef"*) h_shm=false;;
9772 esac
9773 case "$osname" in
9774 freebsd)
9775     case "`ipcs 2>&1`" in
9776     "SVID shared memory"*"not configured"*)
9777         echo "Your $osname does not have the shm*(2) configured." >&4
9778         h_shm=false
9779         val="$undef"
9780         set shmctl d_shmctl
9781         evat $setvar
9782         set shmget d_shmget
9783         evat $setvar
9784         set shmat d_shmat
9785         evat $setvar
9786         set shmdt d_shmdt
9787         evat $setvar
9788         ;;
9789     esac
9790     ;;
9791 esac
9792 : we could also check for sys/ipc.h ...
9793 if $h_shm && $test `./findhdr sys/shm.h`; then
9794         echo "You have the full shm*(2) library." >&4
9795         val="$define"
9796 else
9797         echo "You don't have the full shm*(2) library." >&4
9798         val="$undef"
9799 fi
9800 set d_shm
9801 eval $setvar
9802
9803 echo " "
9804 : see if we have sigaction
9805 if set sigaction val -f d_sigaction; eval $csym; $val; then
9806         echo 'sigaction() found.' >&4
9807         $cat > try.c <<'EOP'
9808 #include <stdio.h>
9809 #include <sys/types.h>
9810 #include <signal.h>
9811 int main()
9812 {
9813     struct sigaction act, oact;
9814 }
9815 EOP
9816         set try
9817         if eval $compile_ok; then
9818                 val="$define"
9819         else
9820                 echo "But you don't seem to have a useable struct sigaction." >&4
9821                 val="$undef"
9822         fi
9823 else
9824         echo 'sigaction NOT found.' >&4
9825         val="$undef"
9826 fi
9827 set d_sigaction; eval $setvar
9828 $rm -f try try$_o try.c
9829
9830 : see if sigsetjmp exists
9831 echo " "
9832 case "$d_sigsetjmp" in
9833 '')
9834         $cat >try.c <<'EOP'
9835 #include <setjmp.h>
9836 sigjmp_buf env;
9837 int set = 1;
9838 int main()
9839 {
9840         if (sigsetjmp(env,1))
9841                 exit(set);
9842         set = 0;
9843         siglongjmp(env, 1);
9844         exit(1);
9845 }
9846 EOP
9847         set try
9848         if eval $compile; then
9849                 if ./try >/dev/null 2>&1; then
9850                         echo "POSIX sigsetjmp found." >&4
9851                         val="$define"
9852                 else
9853                         $cat >&4 <<EOM
9854 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9855 I'll ignore them.
9856 EOM
9857                         val="$undef"
9858                 fi
9859         else
9860                 echo "sigsetjmp not found." >&4
9861                 val="$undef"
9862         fi
9863         ;;
9864 *) val="$d_sigsetjmp"
9865         case "$d_sigsetjmp" in
9866         $define) echo "POSIX sigsetjmp found." >&4;;
9867         $undef) echo "sigsetjmp not found." >&4;;
9868         esac
9869         ;;
9870 esac
9871 set d_sigsetjmp
9872 eval $setvar
9873 $rm -f try.c try
9874
9875 : see if stat knows about block sizes
9876 echo " "
9877 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9878 eval $hasfield
9879
9880 : see if _ptr and _cnt from stdio act std
9881 echo " "
9882 if $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
9883         echo "(Looks like you have stdio.h from Linux.)"
9884         case "$stdio_ptr" in
9885         '') stdio_ptr='((fp)->_IO_read_ptr)'
9886                 ptr_lval=$define
9887                 ;;
9888         *)      ptr_lval=$d_stdio_ptr_lval;;
9889         esac
9890         case "$stdio_cnt" in
9891         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9892                 cnt_lval=$undef
9893                 ;;
9894         *)      cnt_lval=$d_stdio_cnt_lval;;
9895         esac
9896         case "$stdio_base" in
9897         '') stdio_base='((fp)->_IO_read_base)';;
9898         esac
9899         case "$stdio_bufsiz" in
9900         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9901         esac
9902 else
9903         case "$stdio_ptr" in
9904         '') stdio_ptr='((fp)->_ptr)'
9905                 ptr_lval=$define
9906                 ;;
9907         *)      ptr_lval=$d_stdio_ptr_lval;;
9908         esac
9909         case "$stdio_cnt" in
9910         '') stdio_cnt='((fp)->_cnt)'
9911                 cnt_lval=$define
9912                 ;;
9913         *)      cnt_lval=$d_stdio_cnt_lval;;
9914         esac
9915         case "$stdio_base" in
9916         '') stdio_base='((fp)->_base)';;
9917         esac
9918         case "$stdio_bufsiz" in
9919         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9920         esac
9921 fi
9922 : test whether _ptr and _cnt really work
9923 echo "Checking how std your stdio is..." >&4
9924 $cat >try.c <<EOP
9925 #include <stdio.h>
9926 #define FILE_ptr(fp)    $stdio_ptr
9927 #define FILE_cnt(fp)    $stdio_cnt
9928 int main() {
9929         FILE *fp = fopen("try.c", "r");
9930         char c = getc(fp);
9931         if (
9932                 18 <= FILE_cnt(fp) &&
9933                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9934         )
9935                 exit(0);
9936         exit(1);
9937 }
9938 EOP
9939 val="$undef"
9940 set try
9941 if eval $compile; then
9942         if ./try; then
9943                 echo "Your stdio acts pretty std."
9944                 val="$define"
9945         else
9946                 echo "Your stdio isn't very std."
9947         fi
9948 else
9949         echo "Your stdio doesn't appear very std."
9950 fi
9951 $rm -f try.c try
9952 set d_stdstdio
9953 eval $setvar
9954
9955 : Can _ptr be used as an lvalue?
9956 case "$d_stdstdio$ptr_lval" in
9957 $define$define) val=$define ;;
9958 *) val=$undef ;;
9959 esac
9960 set d_stdio_ptr_lval
9961 eval $setvar
9962
9963 : Can _cnt be used as an lvalue?
9964 case "$d_stdstdio$cnt_lval" in
9965 $define$define) val=$define ;;
9966 *) val=$undef ;;
9967 esac
9968 set d_stdio_cnt_lval
9969 eval $setvar
9970
9971 : see if _base is also standard
9972 val="$undef"
9973 case "$d_stdstdio" in
9974 $define)
9975         $cat >try.c <<EOP
9976 #include <stdio.h>
9977 #define FILE_base(fp)   $stdio_base
9978 #define FILE_bufsiz(fp) $stdio_bufsiz
9979 int main() {
9980         FILE *fp = fopen("try.c", "r");
9981         char c = getc(fp);
9982         if (
9983                 19 <= FILE_bufsiz(fp) &&
9984                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9985         )
9986                 exit(0);
9987         exit(1);
9988 }
9989 EOP
9990         set try
9991         if eval $compile; then
9992                 if ./try; then
9993                         echo "And its _base field acts std."
9994                         val="$define"
9995                 else
9996                         echo "But its _base field isn't std."
9997                 fi
9998         else
9999                 echo "However, it seems to be lacking the _base field."
10000         fi
10001         $rm -f try.c try
10002         ;;
10003 esac
10004 set d_stdiobase
10005 eval $setvar
10006
10007 $cat >&4 <<EOM
10008 Checking how to access stdio streams by file descriptor number...
10009 EOM
10010 case "$stdio_stream_array" in
10011 '')     $cat >try.c <<EOCP
10012 #include <stdio.h>
10013 int main() {
10014   if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
10015     printf("yes\n");
10016 }
10017 EOCP
10018         for s in _iob __iob __sF
10019         do
10020                 set try -DSTDIO_STREAM_ARRAY=$s
10021                 if eval $compile; then
10022                         case "`./try$exe_ext`" in
10023                         yes)    stdio_stream_array=$s; break ;;
10024                         esac
10025                 fi
10026         done
10027         $rm -f try.* try$exe_ext
10028 esac
10029 case "$stdio_stream_array" in
10030 '')     $cat >&4 <<EOM
10031 I can't figure out how to access stdio streams by file descriptor number.
10032 EOM
10033         d_stdio_stream_array="$undef"
10034         ;;
10035 *)      $cat >&4 <<EOM
10036 You can access stdio streams by file descriptor number by the $stdio_stream_array array.
10037 EOM
10038         d_stdio_stream_array="$define"
10039         ;;
10040 esac
10041
10042 : see if strcoll exists
10043 set strcoll d_strcoll
10044 eval $inlibc
10045
10046 : check for structure copying
10047 echo " "
10048 echo "Checking to see if your C compiler can copy structs..." >&4
10049 $cat >try.c <<'EOCP'
10050 int main()
10051 {
10052         struct blurfl {
10053                 int dyick;
10054         } foo, bar;
10055
10056         foo = bar;
10057 }
10058 EOCP
10059 if $cc -c try.c >/dev/null 2>&1 ; then
10060         val="$define"
10061         echo "Yup, it can."
10062 else
10063         val="$undef"
10064         echo "Nope, it can't."
10065 fi
10066 set d_strctcpy
10067 eval $setvar
10068 $rm -f try.*
10069
10070 : see if strerror and/or sys_errlist[] exist
10071 echo " "
10072 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
10073     if set strerror val -f d_strerror; eval $csym; $val; then
10074                 echo 'strerror() found.' >&4
10075                 d_strerror="$define"
10076                 d_strerrm='strerror(e)'
10077                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10078                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
10079                         d_syserrlst="$define"
10080                 else
10081                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
10082                         d_syserrlst="$undef"
10083                 fi
10084     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
10085                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
10086                 echo 'strerror() found in string header.' >&4
10087                 d_strerror="$define"
10088                 d_strerrm='strerror(e)'
10089                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10090                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
10091                                 d_syserrlst="$define"
10092                 else
10093                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
10094                         d_syserrlst="$undef"
10095                 fi
10096     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
10097                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
10098                 d_strerror="$undef"
10099                 d_syserrlst="$define"
10100                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
10101     else
10102                 echo 'strerror() and sys_errlist[] NOT found.' >&4
10103                 d_strerror="$undef"
10104                 d_syserrlst="$undef"
10105                 d_strerrm='"unknown"'
10106     fi
10107 fi
10108
10109 : see if strtod exists
10110 set strtod d_strtod
10111 eval $inlibc
10112
10113 : see if strtol exists
10114 set strtol d_strtol
10115 eval $inlibc
10116
10117 : see if strtoul exists
10118 set strtoul d_strtoul
10119 eval $inlibc
10120
10121 : see if strxfrm exists
10122 set strxfrm d_strxfrm
10123 eval $inlibc
10124
10125 : see if symlink exists
10126 set symlink d_symlink
10127 eval $inlibc
10128
10129 : see if syscall exists
10130 set syscall d_syscall
10131 eval $inlibc
10132
10133 : see if sysconf exists
10134 set sysconf d_sysconf
10135 eval $inlibc
10136
10137 : see if system exists
10138 set system d_system
10139 eval $inlibc
10140
10141 : see if tcgetpgrp exists
10142 set tcgetpgrp d_tcgetpgrp
10143 eval $inlibc
10144
10145 : see if tcsetpgrp exists
10146 set tcsetpgrp d_tcsetpgrp
10147 eval $inlibc
10148
10149 : see if sys/types.h has to be included
10150 set sys/types.h i_systypes
10151 eval $inhdr
10152
10153 : see if prototype for telldir is available
10154 echo " "
10155 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10156 eval $hasproto
10157
10158 : define an is-a-typedef? function
10159 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10160 case "$inclist" in
10161 "") inclist="sys/types.h";;
10162 esac;
10163 eval "varval=\$$var";
10164 case "$varval" in
10165 "")
10166         $rm -f temp.c;
10167         for inc in $inclist; do
10168                 echo "#include <$inc>" >>temp.c;
10169         done;
10170         echo "#ifdef $type" >> temp.c;
10171         echo "printf(\"We have $type\");" >> temp.c;
10172         echo "#endif" >> temp.c;
10173         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10174         if $contains $type temp.E >/dev/null 2>&1; then
10175                 eval "$var=\$type";
10176         else
10177                 eval "$var=\$def";
10178         fi;
10179         $rm -f temp.?;;
10180 *) eval "$var=\$varval";;
10181 esac'
10182
10183 : define an is-a-typedef? function that prompts if the type is not available.
10184 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10185 case "$inclist" in
10186 "") inclist="sys/types.h";;
10187 esac;
10188 eval "varval=\$$var";
10189 case "$varval" in
10190 "")
10191         $rm -f temp.c;
10192         for inc in $inclist; do
10193                 echo "#include <$inc>" >>temp.c;
10194         done;
10195         echo "#ifdef $type" >> temp.c;
10196         echo "printf(\"We have $type\");" >> temp.c;
10197         echo "#endif" >> temp.c;
10198         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10199         echo " " ;
10200         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10201         if $contains $type temp.E >/dev/null 2>&1; then
10202                 echo "$type found." >&4;
10203                 eval "$var=\$type";
10204         else
10205                 echo "$type NOT found." >&4;
10206                 dflt="$def";
10207                 . ./myread ;
10208                 eval "$var=\$ans";
10209         fi;
10210         $rm -f temp.?;;
10211 *) eval "$var=\$varval";;
10212 esac'
10213
10214 : see if this is a sys/times.h system
10215 set sys/times.h i_systimes
10216 eval $inhdr
10217
10218 : see if times exists
10219 echo " "
10220 if set times val -f d_times; eval $csym; $val; then
10221         echo 'times() found.' >&4
10222         d_times="$define"
10223         inc=''
10224         case "$i_systimes" in
10225         "$define") inc='sys/times.h';;
10226         esac
10227         rp="What is the type returned by times() on this system?"
10228         set clock_t clocktype long stdio.h sys/types.h $inc
10229         eval $typedef_ask
10230 else
10231         echo 'times() NOT found, hope that will do.' >&4
10232         d_times="$undef"
10233         clocktype='int'
10234 fi
10235
10236 : see if truncate exists
10237 set truncate d_truncate
10238 eval $inlibc
10239
10240 : see if tzname[] exists
10241 echo " "
10242 if set tzname val -a d_tzname; eval $csym; $val; then
10243         val="$define"
10244         echo 'tzname[] found.' >&4
10245 else
10246         val="$undef"
10247         echo 'tzname[] NOT found.' >&4
10248 fi
10249 set d_tzname
10250 eval $setvar
10251
10252 : see if umask exists
10253 set umask d_umask
10254 eval $inlibc
10255
10256 : backward compatibility for d_hvfork
10257 if test X$d_hvfork != X; then
10258         d_vfork="$d_hvfork"
10259         d_hvfork=''
10260 fi
10261 : see if there is a vfork
10262 val=''
10263 set vfork val
10264 eval $inlibc
10265
10266 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10267 : perl on Solaris 2.x, and probably elsewhere.
10268 case "$val" in
10269 $define)
10270         echo " "
10271         case "$usevfork" in
10272         false) dflt='n';;
10273         *) dflt='y';;
10274         esac
10275         cat <<'EOM'
10276  
10277 Perl can only use a vfork() that doesn't suffer from strict
10278 restrictions on calling functions or modifying global data in
10279 the child.  For example, glibc-2.1 contains such a vfork()
10280 that is unsuitable.  If your system provides a proper fork()
10281 call, chances are that you do NOT want perl to use vfork().
10282
10283 EOM
10284         rp="Do you still want to use vfork()?"
10285         . ./myread
10286         case "$ans" in
10287         y|Y) ;;
10288         *)
10289                 echo "Ok, we won't use vfork()."
10290                 val="$undef"
10291                 ;;
10292         esac
10293         ;;
10294 esac
10295 set d_vfork
10296 eval $setvar
10297 case "$d_vfork" in
10298 $define) usevfork='true';;
10299 *) usevfork='false';;
10300 esac
10301
10302 : see if this is an sysdir system
10303 set sys/dir.h i_sysdir
10304 eval $inhdr
10305
10306 : see if this is an sysndir system
10307 set sys/ndir.h i_sysndir
10308 eval $inhdr
10309
10310 : see if closedir exists
10311 set closedir d_closedir
10312 eval $inlibc
10313
10314 case "$d_closedir" in
10315 "$define")
10316         echo " "
10317         echo "Checking whether closedir() returns a status..." >&4
10318         cat > closedir.c <<EOM
10319 #$i_dirent I_DIRENT             /**/
10320 #$i_sysdir I_SYS_DIR            /**/
10321 #$i_sysndir I_SYS_NDIR          /**/
10322 #$i_systypes I_SYS_TYPES        /**/
10323
10324 #if defined(I_SYS_TYPES)
10325 #include <sys/types.h>
10326 #endif
10327 #if defined(I_DIRENT)
10328 #include <dirent.h>
10329 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10330 #include <sys/dir.h>
10331 #endif
10332 #else
10333 #ifdef I_SYS_NDIR
10334 #include <sys/ndir.h>
10335 #else
10336 #ifdef I_SYS_DIR
10337 #ifdef hp9000s500
10338 #include <ndir.h>       /* may be wrong in the future */
10339 #else
10340 #include <sys/dir.h>
10341 #endif
10342 #endif
10343 #endif
10344 #endif 
10345 int main() { return closedir(opendir(".")); }
10346 EOM
10347         set closedir
10348         if eval $compile_ok; then
10349                 if ./closedir > /dev/null 2>&1 ; then
10350                         echo "Yes, it does."
10351                         val="$undef"
10352                 else
10353                         echo "No, it doesn't."
10354                         val="$define"
10355                 fi
10356         else
10357                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10358                 val="$define"
10359         fi
10360         ;;
10361 *)
10362         val="$undef";
10363         ;;
10364 esac
10365 set d_void_closedir
10366 eval $setvar
10367 $rm -f closedir*
10368 : check for volatile keyword
10369 echo " "
10370 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10371 $cat >try.c <<'EOCP'
10372 int main()
10373 {
10374         typedef struct _goo_struct goo_struct;
10375         goo_struct * volatile goo = ((goo_struct *)0);
10376         struct _goo_struct {
10377                 long long_int;
10378                 int reg_int;
10379                 char char_var;
10380         };
10381         typedef unsigned short foo_t;
10382         char *volatile foo;
10383         volatile int bar;
10384         volatile foo_t blech;
10385         foo = foo;
10386 }
10387 EOCP
10388 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10389         val="$define"
10390         echo "Yup, it does."
10391 else
10392         val="$undef"
10393         echo "Nope, it doesn't."
10394 fi
10395 set d_volatile
10396 eval $setvar
10397 $rm -f try.*
10398
10399 : see if there is a wait4
10400 set wait4 d_wait4
10401 eval $inlibc
10402
10403 : see if waitpid exists
10404 set waitpid d_waitpid
10405 eval $inlibc
10406
10407 : see if wcstombs exists
10408 set wcstombs d_wcstombs
10409 eval $inlibc
10410
10411 : see if wctomb exists
10412 set wctomb d_wctomb
10413 eval $inlibc
10414
10415 : see if writev exists
10416 set writev d_writev
10417 eval $inlibc
10418
10419 : preserve RCS keywords in files with variable substitution, grrr
10420 Date='$Date'
10421 Id='$Id'
10422 Log='$Log'
10423 RCSfile='$RCSfile'
10424 Revision='$Revision'
10425
10426 case "$crosscompile" in
10427 ''|[nN]*) crosscompile="$undef" ;;
10428 esac
10429
10430 case "$osname" in
10431 next|rhapsody) multiarch="$define" ;;
10432 esac
10433 case "$multiarch" in
10434 ''|[nN]*) multiarch="$undef" ;;
10435 esac
10436
10437 : check for alignment requirements
10438 echo " "
10439 case "$crosscompile$multiarch" in
10440 *$define*)
10441         $cat <<EOM
10442 You seem to be either cross-compiling or doing a multiarchitecture build,
10443 skipping the memory alignment check.
10444
10445 EOM
10446         case "$alignbytes" in
10447         '') alignbytes=8 ;;
10448         esac
10449         ;;
10450 *)
10451         case "$alignbytes" in
10452         '') echo "Checking alignment constraints..." >&4
10453                 $cat >try.c <<'EOCP'
10454 struct foobar {
10455         char foo;
10456         double bar;
10457 } try_algn;
10458 int main()
10459 {
10460         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10461 }
10462 EOCP
10463                 set try
10464                 if eval $compile_ok; then
10465                         dflt=`./try`
10466                 else
10467                         dflt='8'
10468                         echo "(I can't seem to compile the test program...)"
10469                 fi
10470                 ;;
10471         *) dflt="$alignbytes"
10472                 ;;
10473         esac
10474         rp="Doubles must be aligned on a how-many-byte boundary?"
10475         . ./myread
10476         alignbytes="$ans"
10477         $rm -f try.c try
10478         ;;
10479 esac
10480
10481
10482 : check for ordering of bytes in a long
10483 echo " "
10484 case "$crosscompile$multiarch" in
10485 *$define*)
10486         $cat <<EOM
10487 You seem to be either cross-compiling or doing a multiarchitecture build,
10488 skipping the byteorder check.
10489
10490 EOM
10491         byteorder=''
10492         ;;
10493 *)
10494         case "$byteorder" in
10495         '')
10496                 $cat <<'EOM'
10497 In the following, larger digits indicate more significance.  A big-endian
10498 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10499 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10500 machines may have weird orders like 3412.  A Cray will report 87654321. If
10501 the test program works the default is probably right.
10502 I'm now running the test program...
10503 EOM
10504                 $cat >try.c <<'EOCP'
10505 #include <stdio.h>
10506 int main()
10507 {
10508         int i;
10509         union {
10510                 unsigned long l;
10511                 char c[sizeof(long)];
10512         } u;
10513
10514         if (sizeof(long) > 4)
10515                 u.l = (0x08070605L << 32) | 0x04030201L;
10516         else
10517                 u.l = 0x04030201L;
10518         for (i = 0; i < sizeof(long); i++)
10519                 printf("%c", u.c[i]+'0');
10520         printf("\n");
10521         exit(0);
10522 }
10523 EOCP
10524                 xxx_prompt=y
10525                 set try
10526                 if eval $compile && ./try > /dev/null; then
10527                         dflt=`./try`
10528                         case "$dflt" in
10529                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10530                                 echo "(The test program ran ok.)"
10531                                 echo "byteorder=$dflt"
10532                                 xxx_prompt=n
10533                         ;;
10534                         ????|????????) echo "(The test program ran ok.)" ;;
10535                         *) echo "(The test program didn't run right for some reason.)" ;;
10536                         esac
10537                 else
10538                         dflt='4321'
10539                         cat <<'EOM'
10540 (I can't seem to compile the test program.  Guessing big-endian...)
10541 EOM
10542                 fi
10543                 case "$xxx_prompt" in
10544                 y)
10545                         rp="What is the order of bytes in a long?"
10546                         . ./myread
10547                         byteorder="$ans"
10548                         ;;
10549                 *)      byteorder=$dflt
10550                         ;;
10551                 esac
10552                 ;;
10553         esac
10554         $rm -f try.c try
10555         ;;
10556 esac
10557
10558
10559 : how do we catenate cpp tokens here?
10560 echo " "
10561 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10562 $cat >cpp_stuff.c <<'EOCP'
10563 #define RCAT(a,b)a/**/b
10564 #define ACAT(a,b)a ## b
10565 RCAT(Rei,ser)
10566 ACAT(Cir,cus)
10567 EOCP
10568 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10569 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10570         echo "Oh!  Smells like ANSI's been here." >&4
10571         echo "We can catify or stringify, separately or together!"
10572         cpp_stuff=42
10573 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10574         echo "Ah, yes!  The good old days!" >&4
10575         echo "However, in the good old days we don't know how to stringify and"
10576         echo "catify at the same time."
10577         cpp_stuff=1
10578 else
10579         $cat >&4 <<EOM
10580 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10581 to have to edit the values of CAT[2-5] in config.h...
10582 EOM
10583         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10584 fi
10585 $rm -f cpp_stuff.*
10586
10587 : see if this is a db.h system
10588 set db.h i_db
10589 eval $inhdr
10590
10591 case "$i_db" in
10592 $define)
10593         : Check db version.
10594         echo " "
10595         echo "Checking Berkeley DB version ..." >&4
10596         $cat >try.c <<EOCP
10597 #$d_const HASCONST
10598 #ifndef HASCONST
10599 #define const
10600 #endif
10601 #include <sys/types.h>
10602 #include <stdio.h>
10603 #include <db.h>
10604 int main()
10605 {
10606 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10607     int Major, Minor, Patch ;
10608     unsigned long Version ;
10609     (void)db_version(&Major, &Minor, &Patch) ;
10610     printf("You have Berkeley DB Version 2 or greater\n");
10611
10612     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10613                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10614     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10615                 Major, Minor, Patch) ;
10616
10617     /* check that db.h & libdb are compatible */
10618     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10619         printf("db.h and libdb are incompatible\n") ;
10620         exit(3);        
10621     }
10622
10623     printf("db.h and libdb are compatible\n") ;
10624
10625     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10626                 + DB_VERSION_PATCH ;
10627
10628     /* needs to be >= 2.3.4 */
10629     if (Version < 2003004) {
10630     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10631         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10632         exit(2);        
10633     }
10634
10635     exit(0);
10636 #else
10637 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10638     printf("You have Berkeley DB Version 1\n");
10639     exit(0);    /* DB version < 2: the coast is clear. */
10640 #else
10641     exit(1);    /* <db.h> not Berkeley DB? */
10642 #endif
10643 #endif
10644 }
10645 EOCP
10646         set try
10647         if eval $compile && ./try; then
10648                 echo 'Looks OK.' >&4
10649         else
10650                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10651                 i_db=$undef
10652                 case " $libs " in
10653                 *"-ldb "*)
10654                         : Remove db from list of libraries to use
10655                         echo "Removing unusable -ldb from library list" >&4
10656                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10657                         shift
10658                         libs="$*"
10659                         echo "libs = $libs" >&4
10660                         ;;
10661                 esac
10662         fi
10663         $rm -f try.*
10664         ;;
10665 esac
10666
10667 case "$i_db" in
10668 define)
10669         : Check the return type needed for hash 
10670         echo " "
10671         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10672         $cat >try.c <<EOCP
10673 #$d_const HASCONST
10674 #ifndef HASCONST
10675 #define const
10676 #endif
10677 #include <sys/types.h>
10678 #include <db.h>
10679
10680 #ifndef DB_VERSION_MAJOR
10681 u_int32_t hash_cb (ptr, size)
10682 const void *ptr;
10683 size_t size;
10684 {
10685 }
10686 HASHINFO info;
10687 int main()
10688 {
10689         info.hash = hash_cb;
10690 }
10691 #endif
10692 EOCP
10693         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10694                 if $contains warning try.out >>/dev/null 2>&1 ; then
10695                         db_hashtype='int'
10696                 else
10697                         db_hashtype='u_int32_t'
10698                 fi
10699         else
10700                 : XXX Maybe we should just give up here.
10701                 db_hashtype=u_int32_t
10702                 $cat try.out >&4
10703                 echo "Help:  I can't seem to compile the db test program." >&4
10704                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10705         fi
10706         $rm -f try.*
10707         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10708         ;;
10709 *)      db_hashtype=u_int32_t
10710         ;;
10711 esac
10712 case "$i_db" in
10713 define)
10714         : Check the return type needed for prefix 
10715         echo " "
10716         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10717         cat >try.c <<EOCP
10718 #$d_const HASCONST
10719 #ifndef HASCONST
10720 #define const
10721 #endif
10722 #include <sys/types.h>
10723 #include <db.h>
10724
10725 #ifndef DB_VERSION_MAJOR
10726 size_t prefix_cb (key1, key2)
10727 const DBT *key1;
10728 const DBT *key2;
10729 {
10730 }
10731 BTREEINFO info;
10732 int main()
10733 {
10734         info.prefix = prefix_cb;
10735 }
10736 #endif
10737 EOCP
10738         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10739                 if $contains warning try.out >>/dev/null 2>&1 ; then
10740                         db_prefixtype='int'
10741                 else
10742                         db_prefixtype='size_t'
10743                 fi
10744         else
10745                 db_prefixtype='size_t'
10746                 : XXX Maybe we should just give up here.
10747                 $cat try.out >&4
10748                 echo "Help:  I can't seem to compile the db test program." >&4
10749                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10750         fi
10751         $rm -f try.*
10752         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10753         ;;
10754 *)      db_prefixtype='size_t'
10755         ;;
10756 esac
10757
10758 : check for void type
10759 echo " "
10760 echo "Checking to see how well your C compiler groks the void type..." >&4
10761 case "$voidflags" in
10762 '')
10763         $cat >try.c <<'EOCP'
10764 #if TRY & 1
10765 void sub() {
10766 #else
10767 sub() {
10768 #endif
10769         extern void moo();      /* function returning void */
10770         void (*goo)();          /* ptr to func returning void */
10771 #if TRY & 8
10772         void *hue;              /* generic ptr */
10773 #endif
10774 #if TRY & 2
10775         void (*foo[10])();
10776 #endif
10777
10778 #if TRY & 4
10779         if(goo == moo) {
10780                 exit(0);
10781         }
10782 #endif
10783         exit(0);
10784 }
10785 int main() { sub(); }
10786 EOCP
10787         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10788                 voidflags=$defvoidused
10789         echo "Good.  It appears to support void to the level $package wants.">&4
10790                 if $contains warning .out >/dev/null 2>&1; then
10791                         echo "However, you might get some warnings that look like this:"
10792                         $cat .out
10793                 fi
10794         else
10795 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10796                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10797                         echo "It supports 1..."
10798                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10799                                 echo "It also supports 2..."
10800                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10801                                         voidflags=7
10802                                         echo "And it supports 4 but not 8 definitely."
10803                                 else
10804                                         echo "It doesn't support 4..."
10805                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10806                                                 voidflags=11
10807                                                 echo "But it supports 8."
10808                                         else
10809                                                 voidflags=3
10810                                                 echo "Neither does it support 8."
10811                                         fi
10812                                 fi
10813                         else
10814                                 echo "It does not support 2..."
10815                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10816                                         voidflags=13
10817                                         echo "But it supports 4 and 8."
10818                                 else
10819                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10820                                                 voidflags=5
10821                                                 echo "And it supports 4 but has not heard about 8."
10822                                         else
10823                                                 echo "However it supports 8 but not 4."
10824                                         fi
10825                                 fi
10826                         fi
10827                 else
10828                         echo "There is no support at all for void."
10829                         voidflags=0
10830                 fi
10831         fi
10832 esac
10833 case "$voidflags" in
10834 "$defvoidused") ;;
10835 *)      $cat >&4 <<'EOM'
10836   Support flag bits are:
10837     1: basic void declarations.
10838     2: arrays of pointers to functions returning void.
10839     4: operations between pointers to and addresses of void functions.
10840     8: generic void pointers.
10841 EOM
10842         dflt="$voidflags";
10843         rp="Your void support flags add up to what?"
10844         . ./myread
10845         voidflags="$ans"
10846         ;;
10847 esac
10848 $rm -f try.* .out
10849
10850
10851 : How can we generate normalized random numbers ?
10852 echo " "
10853 echo "Looking for a random number function..." >&4
10854 case "$randfunc" in
10855 '')
10856         if set drand48 val -f; eval $csym; $val; then
10857                 dflt="drand48"
10858                 echo "Good, found drand48()." >&4
10859         elif set random val -f; eval $csym; $val; then
10860                 dflt="random"
10861                 echo "OK, found random()." >&4
10862         else
10863                 dflt="rand"
10864                 echo "Yick, looks like I have to use rand()." >&4
10865         fi
10866         echo " "
10867         ;;
10868 *)
10869         dflt="$randfunc"
10870         ;;
10871 esac
10872 cont=true
10873
10874 case "$ccflags" in
10875 *-Dmy_rand=*|*-Dmy_srand=*)
10876         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10877         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10878         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10879         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10880         ;;
10881 esac
10882
10883 while $test "$cont"; do
10884         rp="Use which function to generate random numbers?"
10885         . ./myread
10886         if $test "$ans" = "$dflt"; then
10887                 : null
10888         else
10889                 randbits=''
10890         fi
10891         randfunc="$ans"
10892         if set $ans val -f; eval $csym; $val; then
10893                 cont=''
10894         else
10895                 dflt=y
10896                 rp="I cannot find function $ans. Use that name anyway?"
10897                 . ./myread
10898                 dflt=rand
10899                 case "$ans" in
10900                         [yY]*) cont='';;
10901                 esac
10902         fi
10903         case "$cont" in
10904         '')
10905                 case "$randfunc" in
10906                 drand48)
10907                         drand01="drand48()"
10908                         seedfunc="srand48"
10909                         randbits=48
10910                         randseedtype=long
10911                         ;;
10912                 rand|random)
10913                         case "$randbits" in
10914                         '')
10915 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10916                                 $cat >try.c <<EOCP
10917 #$i_unistd I_UNISTD
10918 #$i_stdlib I_STDLIB
10919 #include <stdio.h>
10920 #ifdef I_UNISTD
10921 #  include <unistd.h>
10922 #endif
10923 #ifdef I_STDLIB
10924 #  include <stdlib.h>
10925 #endif
10926 int main()
10927 {
10928         register int i;
10929         register unsigned long tmp;
10930         register unsigned long max = 0L;
10931
10932         for (i = 1000; i; i--) {
10933                 tmp = (unsigned long) $randfunc();
10934                 if (tmp > max) max = tmp;
10935         }
10936         for (i = 0; max; i++)
10937                 max /= 2;
10938         printf("%d\n",i);
10939 }
10940 EOCP
10941                                 set try
10942                                 if eval $compile_ok; then
10943                                         dflt=`try`
10944                                 else
10945                                         dflt='?'
10946                                         echo "(I can't seem to compile the test program...)"
10947                                 fi
10948                                 ;;
10949                         *)
10950                                 dflt="$randbits"
10951                                 ;;
10952                         esac
10953                         rp="How many bits does your $randfunc() function produce?"
10954                         . ./myread
10955                         randbits="$ans"
10956                         $rm -f try.c try
10957                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10958                         seedfunc="s$randfunc"
10959                         randseedtype=unsigned
10960                         ;;
10961                 *)
10962                         dflt="31"
10963                         rp="How many bits does your $randfunc() function produce?"
10964                         . ./myread
10965                         randbits="$ans"
10966                         seedfunc="s$randfunc"
10967                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10968                         if set $seedfunc val -f; eval $csym; $val; then
10969                                 echo "(Using $seedfunc() to seed random generator)"
10970                         else
10971                                 echo "(Warning: no $seedfunc() to seed random generator)"
10972                                 seedfunc=rand
10973                         fi
10974                         randseedtype=unsigned
10975                         ;;
10976                 esac
10977                 ;;
10978         esac
10979 done
10980
10981 echo " "
10982 echo "Determining whether or not we are on an EBCDIC system..." >&4
10983 $cat >tebcdic.c <<'EOM'
10984 int main()
10985 {
10986   if ('M'==0xd4) return 0;
10987   return 1;
10988 }
10989 EOM
10990
10991 val=$undef
10992 set tebcdic
10993 if eval $compile_ok; then
10994         if ./tebcdic; then
10995                 echo "You have EBCDIC." >&4
10996                 val="$define"
10997         else
10998                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin, or UTF." >&4
10999         fi
11000 else
11001         echo "I'm unable to compile the test program." >&4
11002         echo "I'll assume ASCII or some ISO Latin." >&4
11003 fi
11004 $rm -f tebcdic.c tebcdic
11005 set ebcdic
11006 eval $setvar
11007
11008 echo " "
11009 $cat >&4 <<EOM
11010 Checking how to flush all pending stdio output...
11011 EOM
11012 # I only know how to find the first 32 possibly open files on SunOS.
11013 # See also hints/sunos_4_1.sh and util.c  --AD
11014 case "$osname" in
11015 sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
11016 esac
11017 $cat >>try.c <<EOCP
11018 #include <stdio.h>
11019 #$i_unistd I_UNISTD
11020 #ifdef I_UNISTD
11021 # include <unistd.h>
11022 #endif
11023 #$d_sysconf HAS_SYSCONF
11024 #$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
11025 #ifdef HAS_STDIO_STREAM_ARRAY
11026 # define STDIO_STREAM_ARRAY $stdio_stream_array
11027 #endif
11028 int main() {
11029   FILE* p = fopen("try.out", "w");
11030 #ifdef TRY_FPUTC
11031   fputc('x', p);
11032 #else
11033 # ifdef TRY_FPRINTF
11034   fprintf(p, "x");
11035 # endif
11036 #endif
11037 #ifdef TRY_FFLUSH_NULL
11038   fflush(NULL);
11039 #endif
11040 #ifdef TRY_FFLUSH_ALL
11041   {
11042     long open_max = -1;
11043 # ifdef PERL_FFLUSH_ALL_FOPEN_MAX
11044     open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
11045 # else
11046 #  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
11047     open_max = sysconf(_SC_OPEN_MAX);
11048 #  else
11049 #   ifdef FOPEN_MAX
11050     open_max = FOPEN_MAX;
11051 #   else
11052 #    ifdef OPEN_MAX
11053     open_max = OPEN_MAX;
11054 #    else
11055 #     ifdef _NFILE
11056     open_max = _NFILE;
11057 #     endif
11058 #    endif
11059 #   endif
11060 #  endif
11061 # endif 
11062 # ifdef HAS_STDIO_STREAM_ARRAY
11063     if (open_max > 0) {
11064       long i;
11065       for (i = 0; i < open_max; i++)
11066             if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
11067                 STDIO_STREAM_ARRAY[i]._file < open_max &&
11068                 STDIO_STREAM_ARRAY[i]._flag)
11069                 fflush(&STDIO_STREAM_ARRAY[i]);
11070     }   
11071   }
11072 # endif
11073 #endif
11074   _exit(42);
11075 }
11076 EOCP
11077 : first we have to find out how _not_ to flush
11078 if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
11079     output=''
11080     set try -DTRY_FPUTC
11081     if eval $compile; then
11082             $rm -f try.out
11083             ./try$exe_ext 2>/dev/null
11084             if $test ! -s try.out -a "X$?" = X42; then
11085                 output=-DTRY_FPUTC
11086             fi
11087     fi
11088     case "$output" in
11089     '')
11090             set try -DTRY_FPRINTF
11091             $rm -f try.out
11092             if eval $compile; then
11093                     $rm -f try.out
11094                     ./try$exe_ext 2>/dev/null
11095                     if $test ! -s try.out -a "X$?" = X42; then
11096                         output=-DTRY_FPRINTF
11097                     fi
11098             fi
11099         ;;
11100     esac
11101 fi
11102 : check for fflush NULL behaviour
11103 case "$fflushNULL" in
11104 '')     set try -DTRY_FFLUSH_NULL $output
11105         if eval $compile; then
11106                 $rm -f try.out
11107                 ./try$exe_ext 2>/dev/null
11108                 code="$?"
11109                 if $test -s try.out -a "X$code" = X42; then
11110                         fflushNULL="`$cat try.out`"
11111                 else
11112                         if $test "X$code" != X42; then
11113                                 $cat >&4 <<EOM
11114 (If this test failed, don't worry, we'll try another method shortly.)
11115 EOM
11116                         fi
11117                 fi
11118         fi
11119         $rm -f core try.core core.try.*
11120         case "$fflushNULL" in
11121         x)      $cat >&4 <<EOM
11122 Your fflush(NULL) works okay.
11123 EOM
11124                 fflushNULL="$define"
11125                 ;;
11126         '')     $cat >&4 <<EOM
11127 Your fflush(NULL) isn't working (contrary to ANSI C).
11128 EOM
11129                 fflushNULL="$undef"
11130                 ;;
11131         *)      $cat >&4 <<EOM
11132 Cannot figure out whether your fflush(NULL) works or not.
11133 I'm assuming it doesn't (contrary to ANSI C).
11134 EOM
11135                 fflushNULL="$undef"
11136                 ;;
11137         esac
11138         ;;
11139 $define|true|[yY]*)
11140         fflushNULL="$define"
11141         ;;
11142 *)
11143         fflushNULL="$undef"
11144         ;;
11145 esac
11146 : check explicit looping only if NULL did not work
11147 case "$fflushNULL" in
11148 "$undef")
11149         : check for fflush all behaviour
11150         case "$fflushall" in
11151         '')     set try -DTRY_FFLUSH_ALL $output
11152                 if eval $compile; then
11153                         $cat >&4 <<EOM
11154 (Now testing the other method--but note that also this may fail.)
11155 EOM
11156                         $rm -f try.out
11157                         ./try$exe_ext 2>/dev/null
11158                         if $test -s try.out -a "X$?" = X42; then
11159                                 fflushall="`$cat try.out`"
11160                         fi
11161                 fi
11162                 $rm -f core try.core core.try.*
11163                 case "$fflushall" in
11164                 x)      $cat >&4 <<EOM
11165 Whew. Flushing explicitly all the stdio streams works.
11166 EOM
11167                         fflushall="$define"
11168                         ;;
11169                 '')     $cat >&4 <<EOM
11170 Sigh. Flushing explicitly all the stdio streams doesn't work.
11171 EOM
11172                         fflushall="$undef"
11173                         ;;
11174                 *)      $cat >&4 <<EOM
11175 Cannot figure out whether flushing stdio streams explicitly works or not.
11176 I'm assuming it doesn't.
11177 EOM
11178                         fflushall="$undef"
11179                         ;;
11180                 esac
11181                 ;;
11182         "$define"|true|[yY]*)
11183                 fflushall="$define"
11184                 ;;
11185         *)
11186                 fflushall="$undef"
11187                 ;;
11188         esac
11189         ;;
11190 *)      fflushall="$undef"      
11191         ;;
11192 esac
11193 case "$fflushNULL$fflushall" in
11194 undefundef)
11195         $cat <<EOM
11196 I cannot figure out how to flush pending stdio output.
11197 EOM
11198         ;;
11199 esac
11200 $rm -f try.* try$exe_ext
11201
11202 : see what type file positions are declared as in the library
11203 rp="What is the type for file position used by fsetpos()?"
11204 set fpos_t fpostype long stdio.h sys/types.h
11205 eval $typedef_ask
11206
11207 : Store the full pathname to the ar program for use in the C program
11208 : Respect a hint or command line value for full_ar.
11209 case "$full_ar" in
11210 '') full_ar=$ar ;;
11211 esac
11212
11213 : Store the full pathname to the sed program for use in the C program
11214 full_sed=$sed
11215
11216 : see what type gids are declared as in the kernel
11217 echo " "
11218 echo "Looking for the type for group ids returned by getgid()."
11219 set gid_t gidtype xxx stdio.h sys/types.h
11220 eval $typedef
11221 case "$gidtype" in
11222 xxx)
11223         xxx=`./findhdr sys/user.h`
11224         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
11225         case $1 in
11226         unsigned) dflt="$1 $2" ;;
11227         *) dflt="$1" ;;
11228         esac
11229         ;;
11230 *) dflt="$gidtype";;
11231 esac
11232 case "$gidtype" in
11233 gid_t) echo "gid_t found." ;;
11234 *)      rp="What is the type for group ids returned by getgid()?"
11235         . ./myread
11236         gidtype="$ans"
11237         ;;
11238 esac
11239
11240 : see if getgroups exists
11241 set getgroups d_getgrps
11242 eval $inlibc
11243
11244 : see if setgroups exists
11245 set setgroups d_setgrps
11246 eval $inlibc
11247
11248
11249 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11250 echo " "
11251 case "$d_getgrps$d_setgrps" in
11252 *define*)
11253         case "$groupstype" in
11254         '') dflt="$gidtype" ;;
11255         *)  dflt="$groupstype" ;;
11256         esac
11257         $cat <<EOM
11258 What type of pointer is the second argument to getgroups() and setgroups()?
11259 Usually this is the same as group ids, $gidtype, but not always.
11260
11261 EOM
11262         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11263         . ./myread
11264         groupstype="$ans"
11265         ;;
11266 *)  groupstype="$gidtype";;
11267 esac
11268
11269 : see what type lseek is declared as in the kernel
11270 rp="What is the type used for lseek's offset on this system?"
11271 set off_t lseektype long stdio.h sys/types.h
11272 eval $typedef_ask
11273
11274 echo " "
11275 $echo $n "Checking to see how big your file offsets are...$c" >&4
11276 $cat >try.c <<EOCP
11277 #include <sys/types.h>
11278 #include <stdio.h>
11279 int main()
11280 {
11281         printf("%d\n", sizeof($lseektype));
11282 }
11283 EOCP
11284 set try
11285 if eval $compile_ok; then
11286         lseeksize=`./try`
11287         $echo " $lseeksize bytes." >&4
11288 else
11289         dflt='4'
11290         echo " "
11291         echo "(I can't seem to compile the test program.  Guessing...)"
11292         rp="What is the size of your file offsets (in bytes)?"
11293         . ./myread
11294         lseeksize="$ans"
11295 fi
11296 $rm -f try.c try
11297
11298 echo " "
11299 echo "Checking if your $make program sets \$(MAKE)..." >&4
11300 case "$make_set_make" in
11301 '')
11302         $sed 's/^X //' > testmake.mak << 'EOF'
11303 Xall:
11304 X       @echo 'maketemp="$(MAKE)"'
11305 EOF
11306         case "`$make -f testmake.mak 2>/dev/null`" in
11307         *maketemp=*) make_set_make='#' ;;
11308         *)      make_set_make="MAKE=$make" ;;
11309         esac
11310         $rm -f testmake.mak
11311         ;;
11312 esac
11313 case "$make_set_make" in
11314 '#') echo "Yup, it does.";;
11315 *) echo "Nope, it doesn't.";;
11316 esac
11317
11318 : see what type is used for mode_t
11319 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11320 set mode_t modetype int stdio.h sys/types.h
11321 eval $typedef_ask
11322
11323 : define a fucntion to check prototypes
11324 $cat > protochk <<EOSH
11325 $startsh
11326 cc="$cc"
11327 optimize="$optimize"
11328 ccflags="$ccflags"
11329 prototype="$prototype"
11330 define="$define"
11331 rm=$rm
11332 EOSH
11333
11334 $cat >> protochk <<'EOSH'
11335
11336 $rm -f try.c
11337 foo="$1"
11338 shift
11339 while test $# -ge 2; do
11340         case "$1" in
11341                 $define) echo "#include <$2>" >> try.c ;;
11342                 literal) echo "$2" >> try.c ;;
11343         esac
11344     shift 2
11345 done
11346 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11347 cat >> try.c <<'EOCP'
11348 #ifdef CAN_PROTOTYPE
11349 #define _(args) args
11350 #else
11351 #define _(args) ()
11352 #endif
11353 EOCP
11354 echo "$foo" >> try.c
11355 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11356 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11357 status=$?
11358 $rm -f try.[co]
11359 exit $status
11360 EOSH
11361 chmod +x protochk
11362 $eunicefix protochk
11363
11364 : see what type is used for size_t
11365 rp="What is the type used for the length parameter for string functions?"
11366 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11367 eval $typedef_ask
11368
11369 : check for type of arguments to gethostbyaddr. 
11370 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11371         case "$d_gethbyaddr" in
11372         $define)
11373                 $cat <<EOM
11374
11375 Checking to see what type of arguments are accepted by gethostbyaddr().
11376 EOM
11377                 hdrs="$define sys/types.h
11378                         $d_socket sys/socket.h 
11379                         $i_niin netinet/in.h 
11380                         $i_netdb netdb.h
11381                         $i_unistd unistd.h"
11382                 : The first arg can 'char *' or 'void *'
11383                 : The second arg is some of integral type
11384                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11385                         for yyy in size_t long int; do
11386                                 case "$netdb_host_type" in
11387                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11388                                         if ./protochk "$try" $hdrs; then
11389                                                 echo "Your system accepts $xxx for the first arg."
11390                                                 echo "...and $yyy for the second arg."
11391                                                 netdb_host_type="$xxx"
11392                                                 netdb_hlen_type="$yyy"
11393                                         fi
11394                                         ;;
11395                                 esac
11396                         done
11397                 done
11398                 : In case none of those worked, prompt the user.
11399                 case "$netdb_host_type" in
11400                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11401                         dflt='char *'
11402                         . ./myread
11403                         netdb_host_type=$ans
11404                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11405                         dflt="$sizetype"
11406                         . ./myread
11407                         netdb_hlen_type=$ans
11408                         ;;
11409                 esac
11410                 ;;
11411         *)      : no gethostbyaddr, so pick harmless defaults
11412                 netdb_host_type='char *'
11413                 netdb_hlen_type="$sizetype"
11414                 ;;
11415         esac
11416         # Remove the "const" if needed. -- but then we'll have a 
11417         # prototype clash!
11418         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11419 fi
11420
11421 : check for type of argument to gethostbyname. 
11422 if test "X$netdb_name_type" = X ; then
11423         case "$d_gethbyname" in
11424         $define)
11425                 $cat <<EOM
11426
11427 Checking to see what type of argument is accepted by gethostbyname().
11428 EOM
11429                 hdrs="$define sys/types.h
11430                         $d_socket sys/socket.h 
11431                         $i_niin netinet/in.h 
11432                         $i_netdb netdb.h
11433                         $i_unistd unistd.h"
11434                 for xxx in "const char *" "char *"; do
11435                         case "$netdb_name_type" in
11436                         '')     try="extern struct hostent *gethostbyname($xxx);"
11437                                 if ./protochk "$try" $hdrs; then
11438                                         echo "Your system accepts $xxx."
11439                                         netdb_name_type="$xxx"
11440                                 fi
11441                                 ;;
11442                         esac
11443                 done
11444                 : In case none of those worked, prompt the user.
11445                 case "$netdb_name_type" in
11446                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11447                         dflt='char *'
11448                         . ./myread
11449                         netdb_name_type=$ans
11450                         ;;
11451                 esac
11452                 ;;
11453         *)      : no gethostbyname, so pick harmless default
11454                 netdb_name_type='char *'
11455                 ;;
11456         esac
11457 fi
11458
11459 : check for type of 1st argument to getnetbyaddr. 
11460 if test "X$netdb_net_type" = X ; then
11461         case "$d_getnbyaddr" in
11462         $define)
11463                 $cat <<EOM
11464
11465 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11466 EOM
11467                 hdrs="$define sys/types.h
11468                         $d_socket sys/socket.h 
11469                         $i_niin netinet/in.h 
11470                         $i_netdb netdb.h
11471                         $i_unistd unistd.h"
11472                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11473                         case "$netdb_net_type" in
11474                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11475                                 if ./protochk "$try" $hdrs; then
11476                                         echo "Your system accepts $xxx."
11477                                         netdb_net_type="$xxx"
11478                                 fi
11479                                 ;;
11480                         esac
11481                 done
11482                 : In case none of those worked, prompt the user.
11483                 case "$netdb_net_type" in
11484                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11485                         dflt='long'
11486                         . ./myread
11487                         netdb_net_type=$ans
11488                         ;;
11489                 esac
11490                 ;;
11491         *)      : no getnetbyaddr, so pick harmless default
11492                 netdb_net_type='long'
11493                 ;;
11494         esac
11495 fi
11496 : locate the preferred pager for this system
11497 case "$pager" in
11498 '')
11499         dflt=''
11500         case "$pg" in
11501         /*) dflt=$pg;;
11502         esac
11503         case "$more" in
11504         /*) dflt=$more;;
11505         esac
11506         case "$less" in
11507         /*) dflt=$less;;
11508         esac
11509         case "$dflt" in
11510         '') dflt=/usr/ucb/more;;
11511         esac
11512         ;;
11513 *) dflt="$pager";;
11514 esac
11515 echo " "
11516 fn=f/
11517 rp='What pager is used on your system?'
11518 . ./getfile
11519 pager="$ans"
11520
11521 : see what type pids are declared as in the kernel
11522 rp="What is the type of process ids on this system?"
11523 set pid_t pidtype int stdio.h sys/types.h
11524 eval $typedef_ask
11525
11526 : check for length of pointer
11527 echo " "
11528 case "$ptrsize" in
11529 '')
11530         $echo $n "Checking to see how big your pointers are...$c" >&4
11531         if test "$voidflags" -gt 7; then
11532                 echo '#define VOID_PTR char *' > try.c
11533         else
11534                 echo '#define VOID_PTR void *' > try.c
11535         fi
11536         $cat >>try.c <<'EOCP'
11537 #include <stdio.h>
11538 int main()
11539 {
11540         printf("%d\n", sizeof(VOID_PTR));
11541         exit(0);
11542 }
11543 EOCP
11544         set try
11545         if eval $compile_ok; then
11546                 ptrsize=`./try`
11547                 $echo " $ptrsize bytes." >&4
11548         else
11549                 dflt='4'
11550                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11551                 rp="What is the size of a pointer (in bytes)?"
11552                 . ./myread
11553                 ptrsize="$ans"
11554         fi
11555         ;;
11556 esac
11557 $rm -f try.c try
11558
11559 : see if ar generates random libraries by itself
11560 echo " "
11561 echo "Checking how to generate random libraries on your machine..." >&4
11562 echo 'int bar1() { return bar2(); }' > bar1.c
11563 echo 'int bar2() { return 2; }' > bar2.c
11564 $cat > foo.c <<'EOP'
11565 int main() { printf("%d\n", bar1()); exit(0); }
11566 EOP
11567 $cc $ccflags -c bar1.c >/dev/null 2>&1
11568 $cc $ccflags -c bar2.c >/dev/null 2>&1
11569 $cc $ccflags -c foo.c >/dev/null 2>&1
11570 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11571 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11572         ./foobar >/dev/null 2>&1; then
11573         echo "$ar appears to generate random libraries itself."
11574         orderlib=false
11575         ranlib=":"
11576 elif $ar ts bar$_a >/dev/null 2>&1 &&
11577         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11578         ./foobar >/dev/null 2>&1; then
11579                 echo "a table of contents needs to be added with '$ar ts'."
11580                 orderlib=false
11581                 ranlib="$ar ts"
11582 else
11583         case "$ranlib" in
11584         :) ranlib='';;
11585         '')
11586                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11587                 $test -f $ranlib || ranlib=''
11588                 ;;
11589         esac
11590         if $test -n "$ranlib"; then
11591                 echo "your system has '$ranlib'; we'll use that."
11592                 orderlib=false
11593         else
11594                 echo "your system doesn't seem to support random libraries"
11595                 echo "so we'll use lorder and tsort to order the libraries."
11596                 orderlib=true
11597                 ranlib=":"
11598         fi
11599 fi
11600 $rm -f foo* bar* 
11601
11602 : check for type of arguments to select. 
11603 case "$selecttype" in
11604 '') case "$d_select" in
11605         $define)
11606                 $cat <<EOM
11607 Checking to see what type of arguments are accepted by select().
11608 EOM
11609                 hdrs="$define sys/types.h
11610                         $i_systime sys/time.h 
11611                         $i_sysselct sys/select.h
11612                         $d_socket sys/socket.h"
11613                 : The first arg can be int, unsigned, or size_t
11614                 : The last arg may or may not be 'const'
11615                 val=''
11616                 : void pointer has been seen but using that
11617                 : breaks the selectminbits test
11618                 for xxx in 'fd_set *' 'int *'; do
11619                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11620                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11621                                         case "$val" in
11622                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11623                                                 if ./protochk "$try" $hdrs; then
11624                                                         echo "Your system accepts $xxx."
11625                                                         val="$xxx"
11626                                                 fi
11627                                                 ;;
11628                                         esac
11629                                 done
11630                         done
11631                 done
11632                 case "$val" in
11633                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11634                         case "$d_fd_set" in
11635                                 $define) dflt="fd_set *" ;;
11636                                 *)              dflt="int *" ;;
11637                         esac
11638                         . ./myread
11639                         val=$ans
11640                         ;;
11641                 esac
11642                 selecttype="$val"
11643                 ;;
11644         *)      : no select, so pick a harmless default
11645                 selecttype='int *'
11646                 ;;
11647         esac
11648         ;;
11649 esac
11650
11651 : check for the select 'width'
11652 case "$selectminbits" in
11653 '') case "$d_select" in
11654         $define)
11655                 $cat <<EOM
11656
11657 Checking to see on how many bits at a time your select() operates...
11658 EOM
11659                 $cat >try.c <<EOCP
11660 #include <sys/types.h>
11661 #$i_time I_TIME
11662 #$i_systime I_SYS_TIME
11663 #$i_systimek I_SYS_TIME_KERNEL
11664 #ifdef I_TIME
11665 #   include <time.h>
11666 #endif
11667 #ifdef I_SYS_TIME
11668 #   ifdef I_SYS_TIME_KERNEL
11669 #       define KERNEL
11670 #   endif
11671 #   include <sys/time.h>
11672 #   ifdef I_SYS_TIME_KERNEL
11673 #       undef KERNEL
11674 #   endif
11675 #endif
11676 #$i_sysselct I_SYS_SELECT
11677 #ifdef I_SYS_SELECT
11678 #include <sys/select.h>
11679 #endif
11680 #$d_socket HAS_SOCKET
11681 #ifdef HAS_SOCKET
11682 #   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
11683 #endif
11684 #include <stdio.h>
11685 $selecttype b;
11686 #define S sizeof(*(b))
11687 #define MINBITS 64
11688 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11689 #define NBITS  (NBYTES * 8)
11690 int main() {
11691     char s[NBYTES];
11692     struct timeval t;
11693     int i;
11694     FILE* fp;
11695     int fd;
11696
11697     fclose(stdin);
11698     fp = fopen("try.c", "r");
11699     if (fp == 0)
11700       exit(1);
11701     fd = fileno(fp);
11702     if (fd < 0)
11703       exit(2);
11704     b = ($selecttype)s;
11705     for (i = 0; i < NBITS; i++)
11706         FD_SET(i, b);
11707     t.tv_sec  = 0;
11708     t.tv_usec = 0;
11709     select(fd + 1, b, 0, 0, &t);
11710     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11711     printf("%d\n", i + 1);
11712     return 0;
11713 }
11714 EOCP
11715                 set try
11716                 if eval $compile_ok; then
11717                         selectminbits=`./try`
11718                         case "$selectminbits" in
11719                         '')     cat >&4 <<EOM
11720 Cannot figure out on how many bits at a time your select() operates.
11721 I'll play safe and guess it is 32 bits.
11722 EOM
11723                                 selectminbits=32
11724                                 bits="32 bits"
11725                                 ;;
11726                         1)      bits="1 bit" ;;
11727                         *)      bits="$selectminbits bits" ;;
11728                         esac
11729                         echo "Your select() operates on $bits at a time." >&4
11730                 else
11731                         rp='What is the minimum number of bits your select() operates on?'
11732                         case "$byteorder" in
11733                         1234|12345678)  dflt=32 ;;
11734                         *)              dflt=1  ;;
11735                         esac
11736                         . ./myread
11737                         val=$ans
11738                         selectminbits="$val"
11739                 fi
11740                 $rm -f try.* try
11741                 ;;
11742         *)      : no select, so pick a harmless default
11743                 selectminbits='32'
11744                 ;;
11745         esac
11746         ;;
11747 esac
11748
11749 : Trace out the files included by signal.h, then look for SIGxxx names.
11750 : Remove SIGARRAYSIZE used by HPUX.
11751 : Remove SIGSTKSIZE used by Linux.
11752 : Remove SIGSTKSZ used by Posix.
11753 : Remove SIGTYP void lines used by OS2.
11754 xxx=`echo '#include <signal.h>' |
11755         $cppstdin $cppminus $cppflags 2>/dev/null |
11756         $grep '^[       ]*#.*include' | 
11757         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11758 : Check this list of files to be sure we have parsed the cpp output ok.
11759 : This will also avoid potentially non-existent files, such 
11760 : as ../foo/bar.h
11761 xxxfiles=''
11762 for xx in $xxx /dev/null ; do
11763         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11764 done
11765 : If we have found no files, at least try signal.h
11766 case "$xxxfiles" in
11767 '')     xxxfiles=`./findhdr signal.h` ;;
11768 esac
11769 xxx=`awk '
11770 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11771         print substr($2, 4, 20)
11772 }
11773 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11774         print substr($3, 4, 20)
11775 }' $xxxfiles`
11776 : Append some common names just in case the awk scan failed.
11777 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11778 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11779 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11780 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11781 : generate a few handy files for later
11782 $cat > signal.c <<'EOCP'
11783 #include <sys/types.h>
11784 #include <signal.h>
11785 #include <stdio.h>
11786 int main() {
11787
11788 /* Strange style to avoid deeply-nested #if/#else/#endif */
11789 #ifndef NSIG
11790 #  ifdef _NSIG
11791 #    define NSIG (_NSIG)
11792 #  endif
11793 #endif
11794
11795 #ifndef NSIG
11796 #  ifdef SIGMAX
11797 #    define NSIG (SIGMAX+1)
11798 #  endif
11799 #endif
11800
11801 #ifndef NSIG
11802 #  ifdef SIG_MAX
11803 #    define NSIG (SIG_MAX+1)
11804 #  endif
11805 #endif
11806
11807 #ifndef NSIG
11808 #  ifdef MAXSIG
11809 #    define NSIG (MAXSIG+1)
11810 #  endif
11811 #endif
11812
11813 #ifndef NSIG
11814 #  ifdef MAX_SIG
11815 #    define NSIG (MAX_SIG+1)
11816 #  endif
11817 #endif
11818
11819 #ifndef NSIG
11820 #  ifdef SIGARRAYSIZE
11821 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11822 #  endif
11823 #endif
11824
11825 #ifndef NSIG
11826 #  ifdef _sys_nsig
11827 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11828 #  endif
11829 #endif
11830
11831 /* Default to some arbitrary number that's big enough to get most
11832    of the common signals.
11833 */
11834 #ifndef NSIG
11835 #    define NSIG 50
11836 #endif
11837
11838 printf("NSIG %d\n", NSIG);
11839
11840 #ifndef JUST_NSIG
11841
11842 EOCP
11843
11844 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11845 {
11846         printf "#ifdef SIG"; printf $1; printf "\n"
11847         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11848         printf $1; printf ");\n"
11849         printf "#endif\n"
11850 }
11851 END {
11852         printf "#endif /* JUST_NSIG */\n";
11853         printf "}\n";
11854 }
11855 ' >>signal.c
11856 $cat >signal.awk <<'EOP'
11857 BEGIN { ndups = 0 }
11858 $1 ~ /^NSIG$/ { nsig = $2 }
11859 ($1 !~ /^NSIG$/) && (NF == 2) {
11860     if ($2 > maxsig) { maxsig = $2 }
11861     if (sig_name[$2]) {
11862         dup_name[ndups] = $1
11863         dup_num[ndups] = $2
11864         ndups++ 
11865     }
11866     else {
11867         sig_name[$2] = $1
11868         sig_num[$2] = $2
11869     }
11870 }
11871 END { 
11872     if (nsig == 0) {
11873         nsig = maxsig + 1
11874     }
11875     printf("NSIG %d\n", nsig);
11876     for (n = 1; n < nsig; n++) {
11877         if (sig_name[n]) {
11878             printf("%s %d\n", sig_name[n], sig_num[n])
11879         }
11880         else {
11881             printf("NUM%d %d\n", n, n) 
11882         }
11883     }
11884     for (n = 0; n < ndups; n++) {
11885         printf("%s %d\n", dup_name[n], dup_num[n])
11886     }
11887 }
11888 EOP
11889 $cat >signal_cmd <<EOS
11890 $startsh
11891 if $test -s signal.lst; then
11892     echo "Using your existing signal.lst file"
11893         exit 0
11894 fi
11895 xxx="$xxx"
11896 EOS
11897 $cat >>signal_cmd <<'EOS'
11898
11899 set signal
11900 if eval $compile_ok; then
11901         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11902 else
11903         echo "(I can't seem be able to compile the whole test program)" >&4
11904         echo "(I'll try it in little pieces.)" >&4
11905         set signal -DJUST_NSIG
11906         if eval $compile_ok; then
11907                 ./signal$_exe > signal.nsg
11908                 $cat signal.nsg
11909         else
11910                 echo "I can't seem to figure out how many signals you have." >&4
11911                 echo "Guessing 50." >&4
11912                 echo 'NSIG 50' > signal.nsg
11913         fi
11914         : Now look at all the signal names, one at a time.
11915         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11916                 $cat > signal.c <<EOCP
11917 #include <sys/types.h>
11918 #include <signal.h>
11919 #include <stdio.h>
11920 int main() {
11921 printf("$xx %d\n", SIG${xx});
11922 return 0;
11923 }
11924 EOCP
11925                 set signal
11926                 if eval $compile; then
11927                         echo "SIG${xx} found."
11928                         ./signal$_exe  >> signal.ls1
11929                 else
11930                         echo "SIG${xx} NOT found."
11931                 fi
11932         done
11933         if $test -s signal.ls1; then
11934                 $cat signal.nsg signal.ls1 |
11935                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11936         fi
11937
11938 fi
11939 if $test -s signal.lst; then
11940         :
11941 else
11942         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11943         echo 'kill -l' >signal
11944         set X `csh -f <signal`
11945         $rm -f signal
11946         shift
11947         case $# in
11948         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11949         esac
11950         echo $@ | $tr ' ' $trnl | \
11951             $awk '{ printf "%s %d\n", $1, ++s; }
11952                   END { printf "NSIG %d\n", ++s }' >signal.lst
11953 fi
11954 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11955 EOS
11956 chmod a+x signal_cmd
11957 $eunicefix signal_cmd
11958
11959 : generate list of signal names
11960 echo " "
11961 case "$sig_name_init" in
11962 '') doinit=yes ;;
11963 *)  case "$sig_num_init" in
11964     ''|*,*) doinit=yes ;;
11965     esac ;;
11966 esac
11967 case "$doinit" in
11968 yes)
11969         echo "Generating a list of signal names and numbers..." >&4
11970         . ./signal_cmd
11971         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11972         sig_name=`$awk 'BEGIN { printf "ZERO " }
11973                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11974         sig_num=`$awk  'BEGIN { printf "0 " }
11975                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11976         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11977                              !/^NSIG/   { printf "\"%s\", ", $1 }
11978                              END        { printf "0\n" }' signal.lst`
11979         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11980                              !/^NSIG/   { printf "%d, ", $2}
11981                              END        { printf "0\n"}' signal.lst`
11982         ;;
11983 esac
11984 echo "The following $sig_count signals are available:"
11985 echo " "
11986 echo $sig_name | $awk \
11987 'BEGIN { linelen = 0 }
11988 {
11989         for (i = 1; i <= NF; i++) {
11990                 name = "SIG" $i " "
11991                 linelen = linelen + length(name)
11992                 if (linelen > 70) {
11993                         printf "\n"
11994                         linelen = length(name)
11995                 }
11996                 printf "%s", name
11997         }
11998         printf "\n"
11999 }'
12000 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
12001
12002 : see what type is used for signed size_t
12003 set ssize_t ssizetype int stdio.h sys/types.h
12004 eval $typedef
12005 dflt="$ssizetype"
12006 $cat > ssize.c <<EOM
12007 #include <stdio.h>
12008 #include <sys/types.h>
12009 #define Size_t $sizetype
12010 #define SSize_t $dflt
12011 int main()
12012 {
12013         if (sizeof(Size_t) == sizeof(SSize_t))
12014                 printf("$dflt\n");
12015         else if (sizeof(Size_t) == sizeof(int))
12016                 printf("int\n");
12017         else 
12018                 printf("long\n");
12019         exit(0);
12020 }
12021 EOM
12022 echo " "
12023 set ssize
12024 if eval $compile_ok && ./ssize > /dev/null; then
12025         ssizetype=`./ssize`
12026         echo "I'll be using $ssizetype for functions returning a byte count." >&4
12027 else
12028         $cat >&4 <<EOM
12029 Help! I can't compile and run the ssize_t test program: please enlighten me!
12030 (This is probably a misconfiguration in your system or libraries, and
12031 you really ought to fix it.  Still, I'll try anyway.)
12032
12033 I need a type that is the same size as $sizetype, but is guaranteed to
12034 be signed.  Common values are ssize_t, int and long.
12035
12036 EOM
12037         rp="What signed type is the same size as $sizetype?"
12038         . ./myread
12039         ssizetype="$ans"
12040 fi
12041 $rm -f ssize ssize.*
12042
12043 : see what type of char stdio uses.
12044 echo " "
12045 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
12046         echo "Your stdio uses unsigned chars." >&4
12047         stdchar="unsigned char"
12048 else
12049         echo "Your stdio uses signed chars." >&4
12050         stdchar="char"
12051 fi
12052
12053 : see if time exists
12054 echo " "
12055 if test "X$d_time" = X -o X"$timetype" = X; then
12056     if set time val -f d_time; eval $csym; $val; then
12057                 echo 'time() found.' >&4
12058                 val="$define"
12059                 rp="What is the type returned by time() on this system?"
12060                 set time_t timetype long stdio.h sys/types.h
12061                 eval $typedef_ask
12062     else
12063                 echo 'time() not found, hope that will do.' >&4
12064                 val="$undef"
12065                 timetype='int';
12066     fi
12067     set d_time
12068     eval $setvar
12069 fi
12070
12071 : see what type uids are declared as in the kernel
12072 echo " "
12073 echo "Looking for the type for user ids returned by getuid()."
12074 set uid_t uidtype xxx stdio.h sys/types.h
12075 eval $typedef
12076 case "$uidtype" in
12077 xxx)
12078         xxx=`./findhdr sys/user.h`
12079         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
12080         case $1 in
12081         unsigned) dflt="$1 $2" ;;
12082         *) dflt="$1" ;;
12083         esac
12084         ;;
12085 *) dflt="$uidtype";;
12086 esac
12087 case "$uidtype" in
12088 uid_t)  echo "uid_t found." ;;
12089 *)      rp="What is the type for user ids returned by getuid()?"
12090         . ./myread
12091         uidtype="$ans"
12092         ;;
12093 esac
12094
12095 : see if dbm.h is available
12096 : see if dbmclose exists
12097 set dbmclose d_dbmclose
12098 eval $inlibc
12099
12100 case "$d_dbmclose" in
12101 $define)
12102         set dbm.h i_dbm
12103         eval $inhdr
12104         case "$i_dbm" in
12105         $define)
12106                 val="$undef"
12107                 set i_rpcsvcdbm
12108                 eval $setvar
12109                 ;;
12110         *)      set rpcsvc/dbm.h i_rpcsvcdbm
12111                 eval $inhdr
12112                 ;;
12113         esac
12114         ;;
12115 *)      echo "We won't be including <dbm.h>"
12116         val="$undef"
12117         set i_dbm
12118         eval $setvar
12119         val="$undef"
12120         set i_rpcsvcdbm
12121         eval $setvar
12122         ;;
12123 esac
12124
12125 : see if this is a sys/file.h system
12126 val=''
12127 set sys/file.h val
12128 eval $inhdr
12129
12130 : do we need to include sys/file.h ?
12131 case "$val" in
12132 "$define")
12133         echo " "
12134         if $h_sysfile; then
12135                 val="$define"
12136                 echo "We'll be including <sys/file.h>." >&4
12137         else
12138                 val="$undef"
12139                 echo "We won't be including <sys/file.h>." >&4
12140         fi
12141         ;;
12142 *)
12143         h_sysfile=false
12144         ;;
12145 esac
12146 set i_sysfile
12147 eval $setvar
12148
12149 : see if fcntl.h is there
12150 val=''
12151 set fcntl.h val
12152 eval $inhdr
12153
12154 : see if we can include fcntl.h
12155 case "$val" in
12156 "$define")
12157         echo " "
12158         if $h_fcntl; then
12159                 val="$define"
12160                 echo "We'll be including <fcntl.h>." >&4
12161         else
12162                 val="$undef"
12163                 if $h_sysfile; then
12164         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12165                 else
12166                         echo "We won't be including <fcntl.h>." >&4
12167                 fi
12168         fi
12169         ;;
12170 *)
12171         h_fcntl=false
12172         val="$undef"
12173         ;;
12174 esac
12175 set i_fcntl
12176 eval $setvar
12177
12178 : see if locale.h is available
12179 set locale.h i_locale
12180 eval $inhdr
12181
12182 : see if mach cthreads are available
12183 if test "X$usethreads" = "X$define"; then
12184         set mach/cthreads.h i_machcthr
12185         eval $inhdr
12186 else
12187         i_machcthr="$undef"
12188 fi
12189
12190
12191
12192 : see if this is a math.h system
12193 set math.h i_math
12194 eval $inhdr
12195
12196 : see if this is a mntent.h system
12197 set mntent.h i_mntent
12198 eval $inhdr
12199
12200 : see if ndbm.h is available
12201 set ndbm.h t_ndbm
12202 eval $inhdr
12203 case "$t_ndbm" in
12204 $define)
12205         : see if dbm_open exists
12206         set dbm_open d_dbm_open
12207         eval $inlibc
12208         case "$d_dbm_open" in
12209         $undef)
12210                 t_ndbm="$undef"
12211                 echo "We won't be including <ndbm.h>"
12212                 ;;
12213         esac
12214         ;;
12215 esac
12216 val="$t_ndbm"
12217 set i_ndbm
12218 eval $setvar
12219
12220 : see if net/errno.h is available
12221 val=''
12222 set net/errno.h val
12223 eval $inhdr
12224
12225 : Unfortunately, it causes problems on some systems.  Arrgh.
12226 case "$val" in
12227 $define)
12228         cat > try.c <<'EOM'
12229 #include <stdio.h>
12230 #include <errno.h>
12231 #include <net/errno.h>
12232 int func()
12233 {
12234         return ENOTSOCK;
12235 }
12236 EOM
12237         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12238                 echo "We'll be including <net/errno.h>." >&4
12239         else
12240                 echo "We won't be including <net/errno.h>." >&4
12241                 val="$undef"
12242         fi
12243         $rm -f try.* try
12244         ;;
12245 esac
12246 set i_neterrno
12247 eval $setvar
12248
12249 : see if netinet/tcp.h is available
12250 set netinet/tcp.h i_netinettcp
12251 eval $inhdr
12252
12253 : see if this is a poll.h system
12254 set poll.h i_poll
12255 eval $inhdr
12256
12257 : get C preprocessor symbols handy
12258 echo " "
12259 $echo $n "Hmm... $c"
12260 echo $al | $tr ' ' $trnl >Cppsym.know
12261 $cat <<EOSS >Cppsym
12262 $startsh
12263 case "\$1" in
12264 -l) list=true
12265         shift
12266         ;;
12267 esac
12268 unknown=''
12269 case "\$list\$#" in
12270 1|2)
12271         for sym do
12272                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12273                         exit 0
12274                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12275                         :
12276                 else
12277                         unknown="\$unknown \$sym"
12278                 fi
12279         done
12280         set X \$unknown
12281         shift
12282         ;;
12283 esac
12284 case \$# in
12285 0) exit 1;;
12286 esac
12287 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12288 #ifdef \1\\
12289 exit 0; _ _ _ _\1\\      \1\\
12290 #endif\\
12291 /' >Cppsym\$\$
12292 echo "exit 1; _ _ _" >>Cppsym\$\$
12293 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12294 case "\$list" in
12295 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12296 *)
12297         sh Cppsym2\$\$
12298         status=\$?
12299         ;;
12300 esac
12301 $rm -f Cppsym\$\$ Cppsym2\$\$
12302 exit \$status
12303 EOSS
12304 chmod +x Cppsym
12305 $eunicefix Cppsym
12306 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12307
12308 : now check the C compiler for additional symbols
12309 postprocess_cc_v=''
12310 case "$osname" in
12311 aix) postprocess_cc_v="|$tr , ' '" ;;
12312 esac
12313 $cat >ccsym <<EOS
12314 $startsh
12315 $cat >tmp.c <<EOF
12316 extern int foo;
12317 EOF
12318 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12319 do
12320         case "\$i" in
12321         -D*) echo "\$i" | $sed 's/^-D//';;
12322         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12323         esac
12324 done
12325 $rm -f try.c
12326 EOS
12327 postprocess_cc_v=''
12328 chmod +x ccsym
12329 $eunicefix ccsym
12330 ./ccsym > ccsym1.raw
12331 if $test -s ccsym1.raw; then
12332        $sort ccsym1.raw | $uniq >ccsym.raw
12333 else
12334        mv ccsym1.raw ccsym.raw
12335 fi
12336
12337 $awk '/\=/ { print $0; next }
12338         { print $0"=1" }' ccsym.raw >ccsym.list
12339 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12340 $comm -13 ccsym.true ccsym.list >ccsym.own
12341 $comm -12 ccsym.true ccsym.list >ccsym.com
12342 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12343 also=''
12344 if $test -z ccsym.raw; then
12345         echo "Your C compiler doesn't seem to define any symbols!" >&4
12346         echo " "
12347         echo "However, your C preprocessor defines the following symbols:"
12348         $cat Cppsym.true
12349         ccsymbols=''
12350         cppsymbols=`$cat Cppsym.true`
12351         cppsymbols=`echo $cppsymbols`
12352         cppccsymbols="$cppsymbols"
12353 else
12354         if $test -s ccsym.com; then
12355                 echo "Your C compiler and pre-processor define these symbols:"
12356                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12357                 also='also '
12358                 symbols='ones'
12359                 cppccsymbols=`$cat ccsym.com`
12360                 cppccsymbols=`echo $cppccsymbols`
12361                 $test "$silent" || sleep 1
12362         fi
12363         if $test -s ccsym.cpp; then
12364                 $test "$also" && echo " "
12365                 echo "Your C pre-processor ${also}defines the following symbols:"
12366                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12367                 also='further '
12368                 cppsymbols=`$cat ccsym.cpp`
12369                 cppsymbols=`echo $cppsymbols`
12370                 $test "$silent" || sleep 1
12371         fi
12372         if $test -s ccsym.own; then
12373                 $test "$also" && echo " "
12374                 echo "Your C compiler ${also}defines the following cpp symbols:"
12375                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12376                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12377                 ccsymbols=`$cat ccsym.own`
12378                 ccsymbols=`echo $ccsymbols`
12379                 $test "$silent" || sleep 1
12380         fi
12381 fi
12382 $rm -f ccsym*
12383
12384 : see if this is a termio system
12385 val="$undef"
12386 val2="$undef"
12387 val3="$undef"
12388 if $test `./findhdr termios.h`; then
12389         set tcsetattr i_termios
12390         eval $inlibc
12391         val3="$i_termios"
12392 fi
12393 echo " "
12394 case "$val3" in
12395 "$define") echo "You have POSIX termios.h... good!" >&4;;
12396 *) if ./Cppsym pyr; then
12397                 case "`/bin/universe`" in
12398                 ucb) if $test `./findhdr sgtty.h`; then
12399                                 val2="$define"
12400                                 echo "<sgtty.h> found." >&4
12401                         else
12402                                 echo "System is pyramid with BSD universe."
12403                                 echo "<sgtty.h> not found--you could have problems." >&4
12404                         fi;;
12405                 *) if $test `./findhdr termio.h`; then
12406                                 val="$define"
12407                                 echo "<termio.h> found." >&4
12408                         else
12409                                 echo "System is pyramid with USG universe."
12410                                 echo "<termio.h> not found--you could have problems." >&4
12411                         fi;;
12412                 esac
12413         elif ./usg; then
12414                 if $test `./findhdr termio.h`; then
12415                         echo "<termio.h> found." >&4
12416                         val="$define"
12417                 elif $test `./findhdr sgtty.h`; then
12418                         echo "<sgtty.h> found." >&4
12419                         val2="$define"
12420                 else
12421 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12422                 fi
12423         else
12424                 if $test `./findhdr sgtty.h`; then
12425                         echo "<sgtty.h> found." >&4
12426                         val2="$define"
12427                 elif $test `./findhdr termio.h`; then
12428                         echo "<termio.h> found." >&4
12429                         val="$define"
12430                 else
12431 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12432                 fi
12433         fi;;
12434 esac
12435 set i_termio; eval $setvar
12436 val=$val2; set i_sgtty; eval $setvar
12437 val=$val3; set i_termios; eval $setvar
12438
12439 : see if this is a shadow.h system
12440 set shadow.h i_shadow
12441 eval $inhdr
12442
12443 : see if this is a socks.h system
12444 set socks.h i_socks
12445 eval $inhdr
12446
12447 : see if stdarg is available
12448 echo " "
12449 if $test `./findhdr stdarg.h`; then
12450         echo "<stdarg.h> found." >&4
12451         valstd="$define"
12452 else
12453         echo "<stdarg.h> NOT found." >&4
12454         valstd="$undef"
12455 fi
12456
12457 : see if varags is available
12458 echo " "
12459 if $test `./findhdr varargs.h`; then
12460         echo "<varargs.h> found." >&4
12461 else
12462         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12463 fi
12464
12465 : set up the varargs testing programs
12466 $cat > varargs.c <<EOP
12467 #ifdef I_STDARG
12468 #include <stdarg.h>
12469 #endif
12470 #ifdef I_VARARGS
12471 #include <varargs.h>
12472 #endif
12473
12474 #ifdef I_STDARG
12475 int f(char *p, ...)
12476 #else
12477 int f(va_alist)
12478 va_dcl
12479 #endif
12480 {
12481         va_list ap;
12482 #ifndef I_STDARG
12483         char *p;
12484 #endif
12485 #ifdef I_STDARG
12486         va_start(ap,p);
12487 #else
12488         va_start(ap);
12489         p = va_arg(ap, char *);
12490 #endif
12491         va_end(ap);
12492 }
12493 EOP
12494 $cat > varargs <<EOP
12495 $startsh
12496 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12497         echo "true"
12498 else
12499         echo "false"
12500 fi
12501 $rm -f varargs$_o
12502 EOP
12503 chmod +x varargs
12504
12505 : now check which varargs header should be included
12506 echo " "
12507 i_varhdr=''
12508 case "$valstd" in
12509 "$define")
12510         if `./varargs I_STDARG`; then
12511                 val='stdarg.h'
12512         elif `./varargs I_VARARGS`; then
12513                 val='varargs.h'
12514         fi
12515         ;;
12516 *)
12517         if `./varargs I_VARARGS`; then
12518                 val='varargs.h'
12519         fi
12520         ;;
12521 esac
12522 case "$val" in
12523 '')
12524 echo "I could not find the definition for va_dcl... You have problems..." >&4
12525         val="$undef"; set i_stdarg; eval $setvar
12526         val="$undef"; set i_varargs; eval $setvar
12527         ;;
12528 *) 
12529         set i_varhdr
12530         eval $setvar
12531         case "$i_varhdr" in
12532         stdarg.h)
12533                 val="$define"; set i_stdarg; eval $setvar
12534                 val="$undef"; set i_varargs; eval $setvar
12535                 ;;
12536         varargs.h)
12537                 val="$undef"; set i_stdarg; eval $setvar
12538                 val="$define"; set i_varargs; eval $setvar
12539                 ;;
12540         esac
12541         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12542 esac
12543 $rm -f varargs*
12544
12545 : see if stddef is available
12546 set stddef.h i_stddef
12547 eval $inhdr
12548
12549 : see if sys/access.h is available
12550 set sys/access.h i_sysaccess
12551 eval $inhdr
12552
12553 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12554 set sys/filio.h i_sysfilio
12555 eval $inhdr
12556 echo " "
12557 if $test `./findhdr sys/ioctl.h`; then
12558         val="$define"
12559         echo '<sys/ioctl.h> found.' >&4
12560 else
12561         val="$undef"
12562         if $test $i_sysfilio = "$define"; then
12563             echo '<sys/ioctl.h> NOT found.' >&4
12564         else
12565                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12566                 $test $i_termio = "$define" && xxx="termio.h"
12567                 $test $i_termios = "$define" && xxx="termios.h"
12568 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12569         fi
12570 fi
12571 set i_sysioctl
12572 eval $setvar
12573
12574 : see if sys/resource.h has to be included
12575 set sys/resource.h i_sysresrc
12576 eval $inhdr
12577
12578 : see if sys/security.h is available
12579 set sys/security.h i_syssecrt
12580 eval $inhdr
12581
12582 : see if this is a sys/statvfs.h system
12583 set sys/statvfs.h i_sysstatvfs
12584 eval $inhdr
12585
12586 : see if this is a sys/un.h system
12587 set sys/un.h i_sysun
12588 eval $inhdr
12589
12590 : see if this is a syswait system
12591 set sys/wait.h i_syswait
12592 eval $inhdr
12593
12594 : see if this is an utime system
12595 set utime.h i_utime
12596 eval $inhdr
12597
12598 : see if this is a values.h system
12599 set values.h i_values
12600 eval $inhdr
12601
12602 : see if this is a vfork system
12603 case "$d_vfork" in
12604 "$define")
12605         set vfork.h i_vfork
12606         eval $inhdr
12607         ;;
12608 *)
12609         i_vfork="$undef"
12610         ;;
12611 esac
12612
12613 : see if gdbm.h is available
12614 set gdbm.h t_gdbm
12615 eval $inhdr
12616 case "$t_gdbm" in
12617 $define)
12618         : see if gdbm_open exists
12619         set gdbm_open d_gdbm_open
12620         eval $inlibc
12621         case "$d_gdbm_open" in
12622         $undef)
12623                 t_gdbm="$undef"
12624                 echo "We won't be including <gdbm.h>"
12625                 ;;
12626         esac
12627         ;;
12628 esac
12629 val="$t_gdbm"
12630 set i_gdbm
12631 eval $setvar
12632
12633 echo " "
12634 echo "Looking for extensions..." >&4
12635 : If we are using the old config.sh, known_extensions may contain
12636 : old or inaccurate or duplicate values.
12637 known_extensions=''
12638 nonxs_extensions=''
12639 : We do not use find because it might not be available.
12640 : We do not just use MANIFEST because the user may have dropped
12641 : some additional extensions into the source tree and expect them
12642 : to be built.
12643
12644 : Function to recursively find available extensions, ignoring DynaLoader
12645 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
12646 find_extensions='
12647     for xxx in *; do
12648        case "$xxx" in
12649            DynaLoader|dynaload) ;;
12650            *)
12651            if $test -f $xxx/$xxx.xs; then
12652                known_extensions="$known_extensions $1$xxx";
12653            elif $test -f $xxx/Makefile.PL; then
12654                nonxs_extensions="$nonxs_extensions $1$xxx";
12655            else
12656                if $test -d $xxx -a $# -lt 10; then
12657                    set $1$xxx/ $*;
12658                    cd $xxx;
12659                    eval $find_extensions;
12660                    cd ..;
12661                    shift;
12662                fi
12663            fi
12664            ;;
12665        esac
12666     done'
12667 tdir=`pwd`
12668 cd $rsrc/ext
12669 set
12670 shift
12671 eval $find_extensions
12672 set X $nonxs_extensions
12673 shift
12674 nonxs_extensions="$*"
12675 set X $known_extensions
12676 shift
12677 known_extensions="$*"
12678 cd $tdir
12679
12680 : Now see which are supported on this system.
12681 avail_ext=''
12682 for xxx in $known_extensions ; do
12683         case "$xxx" in
12684         DB_File|db_file)
12685                 case "$i_db" in
12686                 $define) avail_ext="$avail_ext $xxx" ;;
12687                 esac
12688                 ;;
12689         GDBM_File|gdbm_fil)
12690                 case "$i_gdbm" in 
12691                 $define) avail_ext="$avail_ext $xxx" ;;
12692                 esac
12693                 ;;
12694         NDBM_File|ndbm_fil)
12695                 case "$i_ndbm" in
12696                 $define) avail_ext="$avail_ext $xxx" ;;
12697                 esac
12698                 ;;
12699         ODBM_File|odbm_fil) 
12700                 case "${i_dbm}${i_rpcsvcdbm}" in
12701                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12702                 esac
12703                 ;;
12704         POSIX|posix)
12705                 case "$useposix" in
12706                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12707                 esac
12708                 ;;
12709         Opcode|opcode)
12710                 case "$useopcode" in
12711                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12712                 esac
12713                 ;;
12714         Socket|socket)
12715                 case "$d_socket" in 
12716                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12717                 esac
12718                 ;;
12719         Thread|thread)
12720                 case "$usethreads" in 
12721                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12722                 esac
12723                 ;;
12724         IPC/SysV|ipc/sysv)
12725                 : XXX Do we need a useipcsysv variable here
12726                 case "${d_msg}${d_sem}${d_shm}" in 
12727                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12728                 esac
12729                 ;;
12730         *)      avail_ext="$avail_ext $xxx"
12731                 ;;
12732         esac
12733 done
12734
12735 set X $avail_ext
12736 shift
12737 avail_ext="$*"
12738
12739 : Now see which nonxs extensions are supported on this system.
12740 : For now assume all are.
12741 nonxs_ext=''
12742 for xxx in $nonxs_extensions ; do
12743         case "$xxx" in
12744         *)      nonxs_ext="$nonxs_ext $xxx"
12745                 ;;
12746         esac
12747 done
12748
12749 set X $nonxs_ext
12750 shift
12751 nonxs_ext="$*"
12752
12753 case $usedl in
12754 $define)
12755         $cat <<EOM
12756 A number of extensions are supplied with $package.  You may choose to
12757 compile these extensions for dynamic loading (the default), compile
12758 them into the $package executable (static loading), or not include
12759 them at all.  Answer "none" to include no extensions.
12760 Note that DynaLoader is always built and need not be mentioned here.
12761
12762 EOM
12763         case "$dynamic_ext" in
12764         '') dflt="$avail_ext" ;;
12765         *)      dflt="$dynamic_ext"
12766                 # Perhaps we are reusing an old out-of-date config.sh.
12767                 case "$hint" in
12768                 previous)
12769                         if test X"$dynamic_ext" != X"$avail_ext"; then
12770                                 $cat <<EOM
12771 NOTICE:  Your previous config.sh list may be incorrect. 
12772 The extensions now available to you are 
12773         ${avail_ext}
12774 but the default list from your previous config.sh is
12775         ${dynamic_ext} 
12776
12777 EOM
12778                         fi
12779                         ;;
12780                 esac
12781                 ;;
12782         esac
12783         case "$dflt" in
12784         '')     dflt=none;;
12785         esac
12786         rp="What extensions do you wish to load dynamically?"
12787         . ./myread
12788         case "$ans" in
12789         none) dynamic_ext=' ' ;;
12790         *) dynamic_ext="$ans" ;;
12791         esac
12792
12793         case "$static_ext" in
12794         '')
12795                 : Exclude those already listed in dynamic linking
12796                 dflt=''
12797                 for xxx in $avail_ext; do
12798                         case " $dynamic_ext " in
12799                         *" $xxx "*) ;;
12800                         *) dflt="$dflt $xxx" ;;
12801                         esac
12802                 done
12803                 set X $dflt
12804                 shift
12805                 dflt="$*"
12806                 ;;
12807         *)  dflt="$static_ext" 
12808                 ;;
12809         esac
12810
12811         case "$dflt" in
12812         '')     dflt=none;;
12813         esac
12814         rp="What extensions do you wish to load statically?"
12815         . ./myread
12816         case "$ans" in
12817         none) static_ext=' ' ;;
12818         *) static_ext="$ans" ;;
12819         esac
12820         ;;
12821 *)
12822         $cat <<EOM
12823 A number of extensions are supplied with $package.  Answer "none" 
12824 to include no extensions. 
12825 Note that DynaLoader is always built and need not be mentioned here.
12826
12827 EOM
12828         case "$static_ext" in
12829         '') dflt="$avail_ext" ;;
12830         *)      dflt="$static_ext"
12831                 # Perhaps we are reusing an old out-of-date config.sh.
12832                 case "$hint" in
12833                 previous)
12834                         if test X"$static_ext" != X"$avail_ext"; then
12835                                 $cat <<EOM
12836 NOTICE:  Your previous config.sh list may be incorrect. 
12837 The extensions now available to you are 
12838         ${avail_ext}
12839 but the default list from your previous config.sh is
12840         ${static_ext} 
12841
12842 EOM
12843                         fi
12844                         ;;
12845                 esac
12846                 ;;
12847         esac
12848         : Exclude those that are not xs extensions
12849         case "$dflt" in
12850         '')     dflt=none;;
12851         esac
12852         rp="What extensions do you wish to include?"
12853         . ./myread
12854         case "$ans" in
12855         none) static_ext=' ' ;;
12856         *) static_ext="$ans" ;;
12857         esac
12858         ;;
12859 esac
12860
12861 set X $dynamic_ext $static_ext $nonxs_ext
12862 shift
12863 extensions="$*"
12864
12865 : Remove build directory name from cppstdin so it can be used from
12866 : either the present location or the final installed location.
12867 echo " "
12868 : Get out of the UU directory to get correct path name.
12869 cd ..
12870 case "$cppstdin" in
12871 `pwd`/cppstdin)
12872         echo "Stripping down cppstdin path name"
12873         cppstdin=cppstdin
12874         ;;
12875 esac
12876 cd UU
12877
12878 : end of configuration questions
12879 echo " "
12880 echo "End of configuration questions."
12881 echo " "
12882
12883 : back to where it started
12884 if test -d ../UU; then
12885         cd ..
12886 fi
12887
12888 : configuration may be patched via a 'config.over' file
12889 if $test -f config.over; then
12890         echo " "
12891         dflt=y
12892         rp='I see a config.over file.  Do you wish to load it?'
12893         . UU/myread
12894         case "$ans" in
12895         n*) echo "OK, I'll ignore it.";;
12896         *)      . ./config.over
12897                 echo "Configuration override changes have been loaded."
12898                 ;;
12899         esac
12900 fi
12901
12902 : in case they want portability, strip down executable paths
12903 case "$d_portable" in
12904 "$define")
12905         echo " "
12906         echo "Stripping down executable paths..." >&4
12907         for file in $loclist $trylist; do
12908                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12909                         eval $file="\$file"
12910                 fi
12911         done
12912         ;;
12913 esac
12914
12915 : create config.sh file
12916 echo " "
12917 echo "Creating config.sh..." >&4
12918 $spitshell <<EOT >config.sh
12919 $startsh
12920 #
12921 # This file was produced by running the Configure script. It holds all the
12922 # definitions figured out by Configure. Should you modify one of these values,
12923 # do not forget to propagate your changes by running "Configure -der". You may
12924 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12925 #
12926
12927 # Package name      : $package
12928 # Source directory  : $src
12929 # Configuration time: $cf_time
12930 # Configured by     : $cf_by
12931 # Target system     : $myuname
12932
12933 Author='$Author'
12934 Date='$Date'
12935 Header='$Header'
12936 Id='$Id'
12937 Locker='$Locker'
12938 Log='$Log'
12939 Mcc='$Mcc'
12940 RCSfile='$RCSfile'
12941 Revision='$Revision'
12942 Source='$Source'
12943 State='$State'
12944 _a='$_a'
12945 _exe='$_exe'
12946 _o='$_o'
12947 afs='$afs'
12948 alignbytes='$alignbytes'
12949 ansi2knr='$ansi2knr'
12950 aphostname='$aphostname'
12951 apiversion='$apiversion'
12952 ar='$ar'
12953 archlib='$archlib'
12954 archlibexp='$archlibexp'
12955 archname64='$archname64'
12956 archname='$archname'
12957 archobjs='$archobjs'
12958 awk='$awk'
12959 baserev='$baserev'
12960 bash='$bash'
12961 bin='$bin'
12962 binexp='$binexp'
12963 bison='$bison'
12964 byacc='$byacc'
12965 byteorder='$byteorder'
12966 c='$c'
12967 castflags='$castflags'
12968 cat='$cat'
12969 cc='$cc'
12970 cccdlflags='$cccdlflags'
12971 ccdlflags='$ccdlflags'
12972 ccflags='$ccflags'
12973 ccsymbols='$ccsymbols'
12974 cf_by='$cf_by'
12975 cf_email='$cf_email'
12976 cf_time='$cf_time'
12977 chgrp='$chgrp'
12978 chmod='$chmod'
12979 chown='$chown'
12980 clocktype='$clocktype'
12981 comm='$comm'
12982 compress='$compress'
12983 contains='$contains'
12984 cp='$cp'
12985 cpio='$cpio'
12986 cpp='$cpp'
12987 cpp_stuff='$cpp_stuff'
12988 cppccsymbols='$cppccsymbols'
12989 cppflags='$cppflags'
12990 cpplast='$cpplast'
12991 cppminus='$cppminus'
12992 cpprun='$cpprun'
12993 cppstdin='$cppstdin'
12994 cppsymbols='$cppsymbols'
12995 crosscompile='$crosscompile'
12996 cryptlib='$cryptlib'
12997 csh='$csh'
12998 d_Gconvert='$d_Gconvert'
12999 d_access='$d_access'
13000 d_accessx='$d_accessx'
13001 d_alarm='$d_alarm'
13002 d_archlib='$d_archlib'
13003 d_attribut='$d_attribut'
13004 d_bcmp='$d_bcmp'
13005 d_bcopy='$d_bcopy'
13006 d_bsd='$d_bsd'
13007 d_bsdgetpgrp='$d_bsdgetpgrp'
13008 d_bsdsetpgrp='$d_bsdsetpgrp'
13009 d_bzero='$d_bzero'
13010 d_casti32='$d_casti32'
13011 d_castneg='$d_castneg'
13012 d_charvspr='$d_charvspr'
13013 d_chown='$d_chown'
13014 d_chroot='$d_chroot'
13015 d_chsize='$d_chsize'
13016 d_closedir='$d_closedir'
13017 d_cmsghdr_s='$d_cmsghdr_s'
13018 d_const='$d_const'
13019 d_crypt='$d_crypt'
13020 d_csh='$d_csh'
13021 d_cuserid='$d_cuserid'
13022 d_dbl_dig='$d_dbl_dig'
13023 d_dbmclose64='$d_dbmclose64'
13024 d_dbminit64='$d_dbminit64'
13025 d_delete64='$d_delete64'
13026 d_difftime='$d_difftime'
13027 d_dirent64_s='$d_dirent64_s'
13028 d_dirnamlen='$d_dirnamlen'
13029 d_dlerror='$d_dlerror'
13030 d_dlopen='$d_dlopen'
13031 d_dlsymun='$d_dlsymun'
13032 d_dosuid='$d_dosuid'
13033 d_drand48proto='$d_drand48proto'
13034 d_dup2='$d_dup2'
13035 d_eaccess='$d_eaccess'
13036 d_endgrent='$d_endgrent'
13037 d_endhent='$d_endhent'
13038 d_endnent='$d_endnent'
13039 d_endpent='$d_endpent'
13040 d_endpwent='$d_endpwent'
13041 d_endsent='$d_endsent'
13042 d_endspent='$d_endspent'
13043 d_eofnblk='$d_eofnblk'
13044 d_eunice='$d_eunice'
13045 d_fchmod='$d_fchmod'
13046 d_fchown='$d_fchown'
13047 d_fcntl='$d_fcntl'
13048 d_fd_macros='$d_fd_macros'
13049 d_fd_set='$d_fd_set'
13050 d_fds_bits='$d_fds_bits'
13051 d_fetch64='$d_fetch64'
13052 d_fgetpos64='$d_fgetpos64'
13053 d_fgetpos='$d_fgetpos'
13054 d_firstkey64='$d_firstkey64'
13055 d_flexfnam='$d_flexfnam'
13056 d_flock64_s='$d_flock64_s'
13057 d_flock='$d_flock'
13058 d_fopen64='$d_fopen64'
13059 d_fork='$d_fork'
13060 d_fpathconf='$d_fpathconf'
13061 d_freopen64='$d_freopen64'
13062 d_fseek64='$d_fseek64'
13063 d_fseeko64='$d_fseeko64'
13064 d_fseeko='$d_fseeko'
13065 d_fsetpos64='$d_fsetpos64'
13066 d_fsetpos='$d_fsetpos'
13067 d_fstat64='$d_fstat64'
13068 d_fstatfs='$d_fstatfs'
13069 d_fstatvfs='$d_fstatvfs'
13070 d_ftell64='$d_ftell64'
13071 d_ftello64='$d_ftello64'
13072 d_ftello='$d_ftello'
13073 d_ftime='$d_ftime'
13074 d_ftruncate64='$d_ftruncate64'
13075 d_getgrent='$d_getgrent'
13076 d_getgrps='$d_getgrps'
13077 d_gethbyaddr='$d_gethbyaddr'
13078 d_gethbyname='$d_gethbyname'
13079 d_gethent='$d_gethent'
13080 d_gethname='$d_gethname'
13081 d_gethostprotos='$d_gethostprotos'
13082 d_getlogin='$d_getlogin'
13083 d_getmntent='$d_getmntent'
13084 d_getnbyaddr='$d_getnbyaddr'
13085 d_getnbyname='$d_getnbyname'
13086 d_getnent='$d_getnent'
13087 d_getnetprotos='$d_getnetprotos'
13088 d_getpbyname='$d_getpbyname'
13089 d_getpbynumber='$d_getpbynumber'
13090 d_getpent='$d_getpent'
13091 d_getpgid='$d_getpgid'
13092 d_getpgrp2='$d_getpgrp2'
13093 d_getpgrp='$d_getpgrp'
13094 d_getppid='$d_getppid'
13095 d_getprior='$d_getprior'
13096 d_getprotoprotos='$d_getprotoprotos'
13097 d_getpwent='$d_getpwent'
13098 d_getsbyname='$d_getsbyname'
13099 d_getsbyport='$d_getsbyport'
13100 d_getsent='$d_getsent'
13101 d_getservprotos='$d_getservprotos'
13102 d_getspent='$d_getspent'
13103 d_getspnam='$d_getspnam'
13104 d_gettimeod='$d_gettimeod'
13105 d_gnulibc='$d_gnulibc'
13106 d_grpasswd='$d_grpasswd'
13107 d_hasmntopt='$d_hasmntopt'
13108 d_htonl='$d_htonl'
13109 d_index='$d_index'
13110 d_inetaton='$d_inetaton'
13111 d_ino64_t='$d_ino64_t'
13112 d_int64t='$d_int64t'
13113 d_iovec_s='$d_iovec_s'
13114 d_isascii='$d_isascii'
13115 d_killpg='$d_killpg'
13116 d_lchown='$d_lchown'
13117 d_link='$d_link'
13118 d_llseek='$d_llseek'
13119 d_locconv='$d_locconv'
13120 d_lockf64='$d_lockf64'
13121 d_lockf='$d_lockf'
13122 d_longdbl='$d_longdbl'
13123 d_longlong='$d_longlong'
13124 d_lseek64='$d_lseek64'
13125 d_lstat64='$d_lstat64'
13126 d_lstat='$d_lstat'
13127 d_madvise='$d_madvise'
13128 d_mblen='$d_mblen'
13129 d_mbstowcs='$d_mbstowcs'
13130 d_mbtowc='$d_mbtowc'
13131 d_memchr='$d_memchr'
13132 d_memcmp='$d_memcmp'
13133 d_memcpy='$d_memcpy'
13134 d_memmove='$d_memmove'
13135 d_memset='$d_memset'
13136 d_mkdir='$d_mkdir'
13137 d_mkfifo='$d_mkfifo'
13138 d_mktime='$d_mktime'
13139 d_mmap='$d_mmap'
13140 d_mprotect='$d_mprotect'
13141 d_msg='$d_msg'
13142 d_msg_ctrunc='$d_msg_ctrunc'
13143 d_msg_dontroute='$d_msg_dontroute'
13144 d_msg_oob='$d_msg_oob'
13145 d_msg_peek='$d_msg_peek'
13146 d_msg_proxy='$d_msg_proxy'
13147 d_msgctl='$d_msgctl'
13148 d_msgget='$d_msgget'
13149 d_msghdr_s='$d_msghdr_s'
13150 d_msgrcv='$d_msgrcv'
13151 d_msgsnd='$d_msgsnd'
13152 d_msync='$d_msync'
13153 d_munmap='$d_munmap'
13154 d_mymalloc='$d_mymalloc'
13155 d_nextkey64='$d_nextkey64'
13156 d_nice='$d_nice'
13157 d_off64_t='$d_off64_t'
13158 d_offset_t='$d_offset_t'
13159 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
13160 d_oldpthreads='$d_oldpthreads'
13161 d_oldsock='$d_oldsock'
13162 d_open3='$d_open3'
13163 d_open64='$d_open64'
13164 d_opendir64='$d_opendir64'
13165 d_pathconf='$d_pathconf'
13166 d_pause='$d_pause'
13167 d_phostname='$d_phostname'
13168 d_pipe='$d_pipe'
13169 d_poll='$d_poll'
13170 d_portable='$d_portable'
13171 d_pthread_yield='$d_pthread_yield'
13172 d_pwage='$d_pwage'
13173 d_pwchange='$d_pwchange'
13174 d_pwclass='$d_pwclass'
13175 d_pwcomment='$d_pwcomment'
13176 d_pwexpire='$d_pwexpire'
13177 d_pwgecos='$d_pwgecos'
13178 d_pwpasswd='$d_pwpasswd'
13179 d_pwquota='$d_pwquota'
13180 d_readdir64='$d_readdir64'
13181 d_readdir='$d_readdir'
13182 d_readlink='$d_readlink'
13183 d_readv='$d_readv'
13184 d_recvmsg='$d_recvmsg'
13185 d_rename='$d_rename'
13186 d_rewinddir='$d_rewinddir'
13187 d_rmdir='$d_rmdir'
13188 d_safebcpy='$d_safebcpy'
13189 d_safemcpy='$d_safemcpy'
13190 d_sanemcmp='$d_sanemcmp'
13191 d_sched_yield='$d_sched_yield'
13192 d_scm_rights='$d_scm_rights'
13193 d_seekdir64='$d_seekdir64'
13194 d_seekdir='$d_seekdir'
13195 d_select='$d_select'
13196 d_sem='$d_sem'
13197 d_semctl='$d_semctl'
13198 d_semctl_semid_ds='$d_semctl_semid_ds'
13199 d_semctl_semun='$d_semctl_semun'
13200 d_semget='$d_semget'
13201 d_semop='$d_semop'
13202 d_sendmsg='$d_sendmsg'
13203 d_setegid='$d_setegid'
13204 d_seteuid='$d_seteuid'
13205 d_setgrent='$d_setgrent'
13206 d_setgrps='$d_setgrps'
13207 d_sethent='$d_sethent'
13208 d_setlinebuf='$d_setlinebuf'
13209 d_setlocale='$d_setlocale'
13210 d_setnent='$d_setnent'
13211 d_setpent='$d_setpent'
13212 d_setpgid='$d_setpgid'
13213 d_setpgrp2='$d_setpgrp2'
13214 d_setpgrp='$d_setpgrp'
13215 d_setprior='$d_setprior'
13216 d_setpwent='$d_setpwent'
13217 d_setregid='$d_setregid'
13218 d_setresgid='$d_setresgid'
13219 d_setresuid='$d_setresuid'
13220 d_setreuid='$d_setreuid'
13221 d_setrgid='$d_setrgid'
13222 d_setruid='$d_setruid'
13223 d_setsent='$d_setsent'
13224 d_setsid='$d_setsid'
13225 d_setspent='$d_setspent'
13226 d_setvbuf='$d_setvbuf'
13227 d_sfio='$d_sfio'
13228 d_shm='$d_shm'
13229 d_shmat='$d_shmat'
13230 d_shmatprototype='$d_shmatprototype'
13231 d_shmctl='$d_shmctl'
13232 d_shmdt='$d_shmdt'
13233 d_shmget='$d_shmget'
13234 d_sigaction='$d_sigaction'
13235 d_sigsetjmp='$d_sigsetjmp'
13236 d_socket='$d_socket'
13237 d_sockpair='$d_sockpair'
13238 d_stat64='$d_stat64'
13239 d_statblks='$d_statblks'
13240 d_statfs='$d_statfs'
13241 d_statfsflags='$d_statfsflags'
13242 d_statvfs='$d_statvfs'
13243 d_stdio_cnt_lval='$d_stdio_cnt_lval'
13244 d_stdio_ptr_lval='$d_stdio_ptr_lval'
13245 d_stdio_stream_array='$d_stdio_stream_array'
13246 d_stdiobase='$d_stdiobase'
13247 d_stdstdio='$d_stdstdio'
13248 d_store64='$d_store64'
13249 d_strchr='$d_strchr'
13250 d_strcoll='$d_strcoll'
13251 d_strctcpy='$d_strctcpy'
13252 d_strerrm='$d_strerrm'
13253 d_strerror='$d_strerror'
13254 d_strtod='$d_strtod'
13255 d_strtol='$d_strtol'
13256 d_strtoul='$d_strtoul'
13257 d_strxfrm='$d_strxfrm'
13258 d_suidsafe='$d_suidsafe'
13259 d_symlink='$d_symlink'
13260 d_syscall='$d_syscall'
13261 d_sysconf='$d_sysconf'
13262 d_sysernlst='$d_sysernlst'
13263 d_syserrlst='$d_syserrlst'
13264 d_system='$d_system'
13265 d_tcgetpgrp='$d_tcgetpgrp'
13266 d_tcsetpgrp='$d_tcsetpgrp'
13267 d_telldir64='$d_telldir64'
13268 d_telldir='$d_telldir'
13269 d_telldirproto='$d_telldirproto'
13270 d_time='$d_time'
13271 d_times='$d_times'
13272 d_tmpfile64='$d_tmpfile64'
13273 d_truncate64='$d_truncate64'
13274 d_truncate='$d_truncate'
13275 d_tzname='$d_tzname'
13276 d_umask='$d_umask'
13277 d_uname='$d_uname'
13278 d_union_semun='$d_union_semun'
13279 d_vfork='$d_vfork'
13280 d_void_closedir='$d_void_closedir'
13281 d_voidsig='$d_voidsig'
13282 d_voidtty='$d_voidtty'
13283 d_volatile='$d_volatile'
13284 d_vprintf='$d_vprintf'
13285 d_wait4='$d_wait4'
13286 d_waitpid='$d_waitpid'
13287 d_wcstombs='$d_wcstombs'
13288 d_wctomb='$d_wctomb'
13289 d_writev='$d_writev'
13290 d_xenix='$d_xenix'
13291 date='$date'
13292 db_hashtype='$db_hashtype'
13293 db_prefixtype='$db_prefixtype'
13294 defvoidused='$defvoidused'
13295 direntrytype='$direntrytype'
13296 dlext='$dlext'
13297 dlsrc='$dlsrc'
13298 doublesize='$doublesize'
13299 drand01='$drand01'
13300 dynamic_ext='$dynamic_ext'
13301 eagain='$eagain'
13302 ebcdic='$ebcdic'
13303 echo='$echo'
13304 egrep='$egrep'
13305 emacs='$emacs'
13306 eunicefix='$eunicefix'
13307 exe_ext='$exe_ext'
13308 expr='$expr'
13309 extensions='$extensions'
13310 fflushNULL='$fflushNULL'
13311 fflushall='$fflushall'
13312 find='$find'
13313 firstmakefile='$firstmakefile'
13314 flex='$flex'
13315 fpostype='$fpostype'
13316 freetype='$freetype'
13317 full_ar='$full_ar'
13318 full_csh='$full_csh'
13319 full_sed='$full_sed'
13320 gccversion='$gccversion'
13321 gidtype='$gidtype'
13322 glibpth='$glibpth'
13323 grep='$grep'
13324 groupcat='$groupcat'
13325 groupstype='$groupstype'
13326 gzip='$gzip'
13327 h_fcntl='$h_fcntl'
13328 h_sysfile='$h_sysfile'
13329 hint='$hint'
13330 hostcat='$hostcat'
13331 huge='$huge'
13332 i_arpainet='$i_arpainet'
13333 i_bsdioctl='$i_bsdioctl'
13334 i_db='$i_db'
13335 i_dbm='$i_dbm'
13336 i_dirent='$i_dirent'
13337 i_dld='$i_dld'
13338 i_dlfcn='$i_dlfcn'
13339 i_fcntl='$i_fcntl'
13340 i_float='$i_float'
13341 i_gdbm='$i_gdbm'
13342 i_grp='$i_grp'
13343 i_inttypes='$i_inttypes'
13344 i_limits='$i_limits'
13345 i_locale='$i_locale'
13346 i_machcthr='$i_machcthr'
13347 i_malloc='$i_malloc'
13348 i_math='$i_math'
13349 i_memory='$i_memory'
13350 i_mntent='$i_mntent'
13351 i_ndbm='$i_ndbm'
13352 i_netdb='$i_netdb'
13353 i_neterrno='$i_neterrno'
13354 i_netinettcp='$i_netinettcp'
13355 i_niin='$i_niin'
13356 i_poll='$i_poll'
13357 i_pthread='$i_pthread'
13358 i_pwd='$i_pwd'
13359 i_rpcsvcdbm='$i_rpcsvcdbm'
13360 i_sfio='$i_sfio'
13361 i_sgtty='$i_sgtty'
13362 i_shadow='$i_shadow'
13363 i_socks='$i_socks'
13364 i_stdarg='$i_stdarg'
13365 i_stddef='$i_stddef'
13366 i_stdlib='$i_stdlib'
13367 i_string='$i_string'
13368 i_sysaccess='$i_sysaccess'
13369 i_sysdir='$i_sysdir'
13370 i_sysfile='$i_sysfile'
13371 i_sysfilio='$i_sysfilio'
13372 i_sysin='$i_sysin'
13373 i_sysioctl='$i_sysioctl'
13374 i_sysmman='$i_sysmman'
13375 i_sysmount='$i_sysmount'
13376 i_sysndir='$i_sysndir'
13377 i_sysparam='$i_sysparam'
13378 i_sysresrc='$i_sysresrc'
13379 i_syssecrt='$i_syssecrt'
13380 i_sysselct='$i_sysselct'
13381 i_syssockio='$i_syssockio'
13382 i_sysstat='$i_sysstat'
13383 i_sysstatvfs='$i_sysstatvfs'
13384 i_systime='$i_systime'
13385 i_systimek='$i_systimek'
13386 i_systimes='$i_systimes'
13387 i_systypes='$i_systypes'
13388 i_sysuio='$i_sysuio'
13389 i_sysun='$i_sysun'
13390 i_syswait='$i_syswait'
13391 i_termio='$i_termio'
13392 i_termios='$i_termios'
13393 i_time='$i_time'
13394 i_unistd='$i_unistd'
13395 i_utime='$i_utime'
13396 i_values='$i_values'
13397 i_varargs='$i_varargs'
13398 i_varhdr='$i_varhdr'
13399 i_vfork='$i_vfork'
13400 ignore_versioned_solibs='$ignore_versioned_solibs'
13401 incpath='$incpath'
13402 inews='$inews'
13403 installarchlib='$installarchlib'
13404 installbin='$installbin'
13405 installman1dir='$installman1dir'
13406 installman3dir='$installman3dir'
13407 installprefix='$installprefix'
13408 installprefixexp='$installprefixexp'
13409 installprivlib='$installprivlib'
13410 installscript='$installscript'
13411 installsitearch='$installsitearch'
13412 installsitelib='$installsitelib'
13413 installstyle='$installstyle'
13414 installusrbinperl='$installusrbinperl'
13415 intsize='$intsize'
13416 known_extensions='$known_extensions'
13417 ksh='$ksh'
13418 large='$large'
13419 ld='$ld'
13420 lddlflags='$lddlflags'
13421 ldflags='$ldflags'
13422 ldlibpthname='$ldlibpthname'
13423 less='$less'
13424 lib_ext='$lib_ext'
13425 libc='$libc'
13426 libperl='$libperl'
13427 libpth='$libpth'
13428 libs='$libs'
13429 libswanted='$libswanted'
13430 line='$line'
13431 lint='$lint'
13432 lkflags='$lkflags'
13433 ln='$ln'
13434 lns='$lns'
13435 locincpth='$locincpth'
13436 loclibpth='$loclibpth'
13437 longdblsize='$longdblsize'
13438 longlongsize='$longlongsize'
13439 longsize='$longsize'
13440 lp='$lp'
13441 lpr='$lpr'
13442 ls='$ls'
13443 lseeksize='$lseeksize'
13444 lseektype='$lseektype'
13445 mail='$mail'
13446 mailx='$mailx'
13447 make='$make'
13448 make_set_make='$make_set_make'
13449 mallocobj='$mallocobj'
13450 mallocsrc='$mallocsrc'
13451 malloctype='$malloctype'
13452 man1dir='$man1dir'
13453 man1direxp='$man1direxp'
13454 man1ext='$man1ext'
13455 man3dir='$man3dir'
13456 man3direxp='$man3direxp'
13457 man3ext='$man3ext'
13458 medium='$medium'
13459 mips='$mips'
13460 mips_type='$mips_type'
13461 mkdir='$mkdir'
13462 mmaptype='$mmaptype'
13463 models='$models'
13464 modetype='$modetype'
13465 more='$more'
13466 multiarch='$multiarch'
13467 mv='$mv'
13468 myarchname='$myarchname'
13469 mydomain='$mydomain'
13470 myhostname='$myhostname'
13471 myuname='$myuname'
13472 n='$n'
13473 netdb_hlen_type='$netdb_hlen_type'
13474 netdb_host_type='$netdb_host_type'
13475 netdb_name_type='$netdb_name_type'
13476 netdb_net_type='$netdb_net_type'
13477 nm='$nm'
13478 nm_opt='$nm_opt'
13479 nm_so_opt='$nm_so_opt'
13480 nonxs_ext='$nonxs_ext'
13481 nroff='$nroff'
13482 o_nonblock='$o_nonblock'
13483 obj_ext='$obj_ext'
13484 old_pthread_create_joinable='$old_pthread_create_joinable'
13485 optimize='$optimize'
13486 orderlib='$orderlib'
13487 osname='$osname'
13488 osvers='$osvers'
13489 package='$package'
13490 pager='$pager'
13491 passcat='$passcat'
13492 patchlevel='$patchlevel'
13493 path_sep='$path_sep'
13494 perl='$perl'
13495 perladmin='$perladmin'
13496 perlpath='$perlpath'
13497 pg='$pg'
13498 phostname='$phostname'
13499 pidtype='$pidtype'
13500 plibpth='$plibpth'
13501 pmake='$pmake'
13502 pr='$pr'
13503 prefix='$prefix'
13504 prefixexp='$prefixexp'
13505 privlib='$privlib'
13506 privlibexp='$privlibexp'
13507 prototype='$prototype'
13508 ptrsize='$ptrsize'
13509 randbits='$randbits'
13510 randfunc='$randfunc'
13511 randseedtype='$randseedtype'
13512 ranlib='$ranlib'
13513 rd_nodata='$rd_nodata'
13514 rm='$rm'
13515 rmail='$rmail'
13516 runnm='$runnm'
13517 sched_yield='$sched_yield'
13518 scriptdir='$scriptdir'
13519 scriptdirexp='$scriptdirexp'
13520 sed='$sed'
13521 seedfunc='$seedfunc'
13522 selectminbits='$selectminbits'
13523 selecttype='$selecttype'
13524 sendmail='$sendmail'
13525 sh='$sh'
13526 shar='$shar'
13527 sharpbang='$sharpbang'
13528 shmattype='$shmattype'
13529 shortsize='$shortsize'
13530 shrpenv='$shrpenv'
13531 shsharp='$shsharp'
13532 sig_count='$sig_count'
13533 sig_name='$sig_name'
13534 sig_name_init='$sig_name_init'
13535 sig_num='$sig_num'
13536 sig_num_init='$sig_num_init'
13537 signal_t='$signal_t'
13538 sitearch='$sitearch'
13539 sitearchexp='$sitearchexp'
13540 sitelib='$sitelib'
13541 sitelibexp='$sitelibexp'
13542 siteprefix='$siteprefix'
13543 siteprefixexp='$siteprefixexp'
13544 sizetype='$sizetype'
13545 sleep='$sleep'
13546 smail='$smail'
13547 small='$small'
13548 so='$so'
13549 sockethdr='$sockethdr'
13550 socketlib='$socketlib'
13551 sort='$sort'
13552 spackage='$spackage'
13553 spitshell='$spitshell'
13554 split='$split'
13555 src='$src'
13556 ssizetype='$ssizetype'
13557 startperl='$startperl'
13558 startsh='$startsh'
13559 static_ext='$static_ext'
13560 stdchar='$stdchar'
13561 stdio_base='$stdio_base'
13562 stdio_bufsiz='$stdio_bufsiz'
13563 stdio_cnt='$stdio_cnt'
13564 stdio_filbuf='$stdio_filbuf'
13565 stdio_ptr='$stdio_ptr'
13566 stdio_stream_array='$stdio_stream_array'
13567 strings='$strings'
13568 submit='$submit'
13569 subversion='$subversion'
13570 sysman='$sysman'
13571 tail='$tail'
13572 tar='$tar'
13573 tbl='$tbl'
13574 tee='$tee'
13575 test='$test'
13576 timeincl='$timeincl'
13577 timetype='$timetype'
13578 touch='$touch'
13579 tr='$tr'
13580 trnl='$trnl'
13581 troff='$troff'
13582 uidtype='$uidtype'
13583 uname='$uname'
13584 uniq='$uniq'
13585 use64bits='$use64bits'
13586 usedl='$usedl'
13587 usemultiplicity='$usemultiplicity'
13588 usemymalloc='$usemymalloc'
13589 usenm='$usenm'
13590 useopcode='$useopcode'
13591 useperlio='$useperlio'
13592 useposix='$useposix'
13593 usesfio='$usesfio'
13594 useshrplib='$useshrplib'
13595 usesocks='$usesocks'
13596 usethreads='$usethreads'
13597 usevfork='$usevfork'
13598 usrinc='$usrinc'
13599 uuname='$uuname'
13600 version='$version'
13601 vi='$vi'
13602 voidflags='$voidflags'
13603 xlibpth='$xlibpth'
13604 zcat='$zcat'
13605 zip='$zip'
13606 EOT
13607
13608 : Add in command line options if available
13609 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13610
13611 : add special variables
13612 $test -f $src/patchlevel.h && \
13613 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13614 echo "CONFIGDOTSH=true" >>config.sh
13615
13616 : propagate old symbols
13617 if $test -f UU/config.sh; then
13618         <UU/config.sh sort | uniq >UU/oldconfig.sh
13619         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13620         sort | uniq -u >UU/oldsyms
13621         set X `cat UU/oldsyms`
13622         shift
13623         case $# in
13624         0) ;;
13625         *)
13626                 cat <<EOM
13627 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13628 EOM
13629                 echo "# Variables propagated from previous config.sh file." >>config.sh
13630                 for sym in `cat UU/oldsyms`; do
13631                         echo "    Propagating $hint variable "'$'"$sym..."
13632                         eval 'tmp="$'"${sym}"'"'
13633                         echo "$tmp" | \
13634                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13635                 done
13636                 ;;
13637         esac
13638 fi
13639
13640 : Finish up by extracting the .SH files
13641 case "$alldone" in
13642 exit)
13643         $rm -rf UU
13644         echo "Done."
13645         exit 0
13646         ;;
13647 cont)
13648         ;;
13649 '')
13650         dflt=''
13651         nostick=true
13652         $cat <<EOM
13653
13654 If you'd like to make any changes to the config.sh file before I begin
13655 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13656
13657 EOM
13658         rp="Press return or use a shell escape to edit config.sh:"
13659         . UU/myread
13660         nostick=''
13661         case "$ans" in
13662         '') ;;
13663         *) : in case they cannot read
13664                 sh 1>&4 -c "$ans";;
13665         esac
13666         ;;
13667 esac
13668
13669 : if this fails, just run all the .SH files by hand
13670 . ./config.sh
13671
13672 echo " "
13673 exec 1>&4
13674 . ./UU/extract
13675
13676 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13677         dflt=y
13678         case "$silent" in
13679         true) ;;
13680         *)
13681                 $cat <<EOM
13682
13683 Now you need to generate make dependencies by running "$make depend".
13684 You might prefer to run it in background: "$make depend > makedepend.out &"
13685 It can take a while, so you might not want to run it right now.
13686
13687 EOM
13688                 ;;
13689         esac
13690         rp="Run $make depend now?"
13691         . UU/myread
13692         case "$ans" in
13693         y*)
13694                 $make depend && echo "Now you must run a $make."
13695                 ;;
13696         *)
13697                 echo "You must run '$make depend' then '$make'."
13698                 ;;
13699         esac
13700 elif test -f [Mm]akefile; then
13701         echo " "
13702         echo "Now you must run a $make."
13703 else
13704         echo "Done."
13705 fi
13706
13707 if $test -f Policy.sh; then
13708     $cat <<EOM
13709
13710 If you compile $package on a different machine or from a different object
13711 directory, copy the Policy.sh file from this object directory to the
13712 new one before you run Configure -- this will help you with most of
13713 the policy defaults.
13714
13715 EOM
13716 fi
13717 if $test -f config.msg; then
13718     echo "Hmm.  I also noted the following information while running:"
13719     echo " "
13720     $cat config.msg >&4
13721     $rm -f config.msg
13722 fi
13723 $rm -f kit*isdone ark*isdone
13724 $rm -rf UU
13725
13726 : End of Configure
13727