Introduce $Config{ldlibpthname} which contains
[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 Fri Jul 23 13:08:17 EET DST 1999 [metaconfig 3.0 PL70]
24 # (with additional metaconfig patches by perlbug@perl.com)
25
26 cat >/tmp/c1$$ <<EOF
27 ARGGGHHHH!!!!!
28
29 SCO csh still thinks true is false.  Write to SCO today and tell them that next
30 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
31
32 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
33 we'd have to do is go in and swap the && and || tokens, wherever they are.)
34
35 [End of diatribe. We now return you to your regularly scheduled programming...]
36 EOF
37 cat >/tmp/c2$$ <<EOF
38
39 OOPS!  You naughty creature!  You didn't run Configure with sh!
40 I will attempt to remedy the situation by running sh for you...
41 EOF
42
43 true || cat /tmp/c1$$ /tmp/c2$$
44 true || exec sh $0 $argv:q
45
46 (exit $?0) || cat /tmp/c2$$
47 (exit $?0) || exec sh $0 $argv:q
48 rm -f /tmp/c1$$ /tmp/c2$$
49
50 : compute my invocation name
51 me=$0
52 case "$0" in
53 */*)
54         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55         test "$me" || me=$0
56         ;;
57 esac
58
59 : Proper separator for the PATH environment variable
60 p_=:
61 : On OS/2 this directory should exist if this is not floppy only system :-]
62 if test -d c:/. ; then
63     if test -n "$OS2_SHELL"; then
64                 p_=\;
65                 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
66                 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
67         elif test -n "$DJGPP"; then
68                 p_=\;
69         fi
70 fi
71
72 : Proper PATH setting
73 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
74 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
75 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
76 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
77 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80 paths="$paths /sbin /usr/sbin /usr/libexec"
81
82 for p in $paths
83 do
84         case "$p_$PATH$p_" in
85         *$p_$p$p_*) ;;
86         *) test -d $p && PATH=$PATH$p_$p ;;
87         esac
88 done
89
90 PATH=.$p_$PATH
91 export PATH
92
93 : shall we be using ksh?
94 inksh=''
95 needksh=''
96 avoidksh=''
97 newsh=/bin/ksh
98 changesh=''
99 if (PATH=.; alias -x) >/dev/null 2>&1; then
100                 inksh=true
101 fi
102 if test -f /hp-ux -a -f /bin/ksh; then
103         needksh='to avoid sh bug in "here document" expansion'
104 fi
105 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
106         if test X`/usr/bin/uname -v` = X4; then
107                 avoidksh="to avoid AIX 4's /bin/sh"
108                 newsh=/usr/bin/bsh
109         fi
110 fi
111 if test -f /osf_boot -a -f /usr/sbin/setld; then
112         if test X`/usr/bin/uname -s` = XOSF1; then
113                 avoidksh="to avoid Digital UNIX' ksh"
114                 newsh=/bin/sh
115                 unset BIN_SH # if this is 'xpg4' sh will start up ksh
116         fi
117 fi
118 case "$inksh/$needksh" in
119 /[a-z]*)
120                 ENV=''
121                 changesh=true
122                 reason="$needksh"
123         ;;
124 esac
125 case "$inksh/$avoidksh" in
126 true/[a-z]*)
127         changesh=true
128         reason="$avoidksh"
129         ;;
130 esac
131 case "$inksh/$needksh-$avoidksh-" in
132 true/--)
133                 cat <<EOM
134 (I see you are using the Korn shell.  Some ksh's blow up on $me,
135 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
136 EOM
137         ;;
138 esac
139 case "$changesh" in
140 true)
141         echo "(Feeding myself to $newsh $reason.)"
142         case "$0" in
143         Configure|*/Configure) exec $newsh $0 "$@";;
144         *) exec $newsh Configure "$@";;
145         esac
146         ;;
147 esac
148
149 : if needed set CDPATH to a harmless value that is not chatty
150 : avoid bash 2.02 problems with empty CDPATH.
151 case "$CDPATH" in
152 '')     ;;
153 *)      case "$SHELL" in
154         *bash*) CDPATH='.' ;;
155         *)              CDPATH='' ;;
156         esac
157         ;;
158 esac
159 : Configure runs within the UU subdirectory
160 test -d UU || mkdir UU
161 cd UU && rm -f ./*
162
163 ccsymbols=''
164 cppccsymbols=''
165 cppsymbols=''
166 dynamic_ext=''
167 extensions=''
168 known_extensions=''
169 nonxs_ext=''
170 static_ext=''
171 useopcode=''
172 useposix=''
173 d_bsd=''
174 d_eunice=''
175 d_xenix=''
176 eunicefix=''
177 Mcc=''
178 ar=''
179 awk=''
180 bash=''
181 bison=''
182 byacc=''
183 cat=''
184 chgrp=''
185 chmod=''
186 chown=''
187 comm=''
188 compress=''
189 cp=''
190 cpio=''
191 cpp=''
192 csh=''
193 date=''
194 echo=''
195 egrep=''
196 emacs=''
197 expr=''
198 find=''
199 flex=''
200 grep=''
201 gzip=''
202 inews=''
203 ksh=''
204 less=''
205 line=''
206 lint=''
207 ln=''
208 lp=''
209 lpr=''
210 ls=''
211 mail=''
212 mailx=''
213 make=''
214 mkdir=''
215 more=''
216 mv=''
217 nm=''
218 nroff=''
219 perl=''
220 pg=''
221 pmake=''
222 pr=''
223 rm=''
224 rmail=''
225 sed=''
226 sendmail=''
227 shar=''
228 sleep=''
229 smail=''
230 sort=''
231 submit=''
232 tail=''
233 tar=''
234 tbl=''
235 tee=''
236 test=''
237 touch=''
238 tr=''
239 troff=''
240 uname=''
241 uniq=''
242 uuname=''
243 vi=''
244 zcat=''
245 zip=''
246 full_ar=''
247 full_sed=''
248 libswanted=''
249 hint=''
250 myuname=''
251 osname=''
252 osvers=''
253 Author=''
254 Date=''
255 Header=''
256 Id=''
257 Locker=''
258 Log=''
259 RCSfile=''
260 Revision=''
261 Source=''
262 State=''
263 _a=''
264 _exe=''
265 _o=''
266 archobjs=''
267 exe_ext=''
268 firstmakefile=''
269 lib_ext=''
270 obj_ext=''
271 path_sep=''
272 afs=''
273 alignbytes=''
274 ansi2knr=''
275 archlib=''
276 archlibexp=''
277 d_archlib=''
278 installarchlib=''
279 archname=''
280 myarchname=''
281 baserev=''
282 bin=''
283 binexp=''
284 installbin=''
285 byteorder=''
286 cc=''
287 gccversion=''
288 ccflags=''
289 cppflags=''
290 ldflags=''
291 lkflags=''
292 locincpth=''
293 optimize=''
294 cf_email=''
295 cf_by=''
296 cf_time=''
297 contains=''
298 cpp_stuff=''
299 cpplast=''
300 cppminus=''
301 cpprun=''
302 cppstdin=''
303 crosscompile=''
304 d_access=''
305 d_accessx=''
306 d_alarm=''
307 d_attribut=''
308 d_bcmp=''
309 d_bcopy=''
310 d_bzero=''
311 d_casti32=''
312 castflags=''
313 d_castneg=''
314 d_chown=''
315 d_chroot=''
316 d_chsize=''
317 d_closedir=''
318 d_void_closedir=''
319 d_const=''
320 cryptlib=''
321 d_crypt=''
322 d_csh=''
323 full_csh=''
324 d_cuserid=''
325 d_dbl_dig=''
326 d_difftime=''
327 d_dlerror=''
328 d_dlopen=''
329 d_dlsymun=''
330 d_dosuid=''
331 d_suidsafe=''
332 d_drand48proto=''
333 d_dup2=''
334 d_eaccess=''
335 d_endgrent=''
336 d_endhent=''
337 d_endnent=''
338 d_endpent=''
339 d_endpwent=''
340 d_endsent=''
341 d_endspent=''
342 d_fchmod=''
343 d_fchown=''
344 d_fcntl=''
345 d_fd_macros=''
346 d_fd_set=''
347 d_fds_bits=''
348 d_fgetpos=''
349 d_flexfnam=''
350 d_flock=''
351 d_fork=''
352 d_fseeko=''
353 d_fsetpos=''
354 d_ftello=''
355 d_ftime=''
356 d_gettimeod=''
357 d_Gconvert=''
358 d_getgrent=''
359 d_getgrps=''
360 d_gethbyaddr=''
361 d_gethbyname=''
362 d_gethent=''
363 aphostname=''
364 d_gethname=''
365 d_phostname=''
366 d_uname=''
367 d_gethostprotos=''
368 d_getlogin=''
369 d_getmntent=''
370 d_getnbyaddr=''
371 d_getnbyname=''
372 d_getnent=''
373 d_getnetprotos=''
374 d_getpent=''
375 d_getpgid=''
376 d_getpgrp2=''
377 d_bsdgetpgrp=''
378 d_getpgrp=''
379 d_getppid=''
380 d_getprior=''
381 d_getpbyname=''
382 d_getpbynumber=''
383 d_getprotoprotos=''
384 d_getpwent=''
385 d_getsent=''
386 d_getservprotos=''
387 d_getspent=''
388 d_getspnam=''
389 d_getsbyname=''
390 d_getsbyport=''
391 d_gnulibc=''
392 d_hasmntopt=''
393 d_htonl=''
394 d_inetaton=''
395 d_isascii=''
396 d_killpg=''
397 d_lchown=''
398 d_link=''
399 d_locconv=''
400 d_lockf=''
401 d_longdbl=''
402 longdblsize=''
403 d_longlong=''
404 longlongsize=''
405 d_lstat=''
406 d_madvise=''
407 d_mblen=''
408 d_mbstowcs=''
409 d_mbtowc=''
410 d_memchr=''
411 d_memcmp=''
412 d_memcpy=''
413 d_memmove=''
414 d_memset=''
415 d_mkdir=''
416 d_mkfifo=''
417 d_mktime=''
418 d_mmap=''
419 mmaptype=''
420 d_mprotect=''
421 d_msg=''
422 d_msgctl=''
423 d_msgget=''
424 d_msgrcv=''
425 d_msgsnd=''
426 d_msync=''
427 d_munmap=''
428 d_nice=''
429 d_open3=''
430 d_fpathconf=''
431 d_pathconf=''
432 d_pause=''
433 d_pipe=''
434 d_poll=''
435 d_portable=''
436 d_old_pthread_create_joinable=''
437 old_pthread_create_joinable=''
438 d_pthread_yield=''
439 d_sched_yield=''
440 sched_yield=''
441 d_readdir=''
442 d_rewinddir=''
443 d_seekdir=''
444 d_telldir=''
445 d_readlink=''
446 d_readv=''
447 d_rename=''
448 d_rmdir=''
449 d_safebcpy=''
450 d_safemcpy=''
451 d_sanemcmp=''
452 d_select=''
453 d_sem=''
454 d_semctl=''
455 d_semget=''
456 d_semop=''
457 d_setegid=''
458 d_seteuid=''
459 d_setgrent=''
460 d_setgrps=''
461 d_sethent=''
462 d_setlinebuf=''
463 d_setlocale=''
464 d_setnent=''
465 d_setpent=''
466 d_setpgid=''
467 d_setpgrp2=''
468 d_bsdsetpgrp=''
469 d_setpgrp=''
470 d_setprior=''
471 d_setpwent=''
472 d_setregid=''
473 d_setresgid=''
474 d_setresuid=''
475 d_setreuid=''
476 d_setrgid=''
477 d_setruid=''
478 d_setsent=''
479 d_setsid=''
480 d_setspent=''
481 d_setvbuf=''
482 d_sfio=''
483 usesfio=''
484 d_shm=''
485 d_shmat=''
486 d_shmatprototype=''
487 shmattype=''
488 d_shmctl=''
489 d_shmdt=''
490 d_shmget=''
491 d_sigaction=''
492 d_sigsetjmp=''
493 d_cmsghdr_s=''
494 d_msg_ctrunc=''
495 d_msg_dontroute=''
496 d_msg_oob=''
497 d_msg_peek=''
498 d_msg_proxy=''
499 d_msghdr_s=''
500 d_oldsock=''
501 d_recvmsg=''
502 d_scm_rights=''
503 d_sendmsg=''
504 d_socket=''
505 d_sockpair=''
506 sockethdr=''
507 socketlib=''
508 d_statblks=''
509 d_fstatfs=''
510 d_statfs=''
511 d_statfsflags=''
512 d_fstatvfs=''
513 d_statvfs=''
514 d_stdio_cnt_lval=''
515 d_stdio_ptr_lval=''
516 d_stdiobase=''
517 d_stdstdio=''
518 stdio_base=''
519 stdio_bufsiz=''
520 stdio_cnt=''
521 stdio_filbuf=''
522 stdio_ptr=''
523 d_index=''
524 d_strchr=''
525 d_strcoll=''
526 d_strctcpy=''
527 d_strerrm=''
528 d_strerror=''
529 d_sysernlst=''
530 d_syserrlst=''
531 d_strtod=''
532 d_strtol=''
533 d_strtoul=''
534 d_strxfrm=''
535 d_symlink=''
536 d_syscall=''
537 d_sysconf=''
538 d_system=''
539 d_tcgetpgrp=''
540 d_tcsetpgrp=''
541 d_telldirproto=''
542 d_time=''
543 timetype=''
544 clocktype=''
545 d_times=''
546 d_truncate=''
547 d_tzname=''
548 d_umask=''
549 d_semctl_semid_ds=''
550 d_semctl_semun=''
551 d_union_semun=''
552 d_vfork=''
553 usevfork=''
554 d_voidsig=''
555 signal_t=''
556 d_volatile=''
557 d_charvspr=''
558 d_vprintf=''
559 d_wait4=''
560 d_waitpid=''
561 d_wcstombs=''
562 d_wctomb=''
563 d_writev=''
564 d_dbmclose64=''
565 d_dbminit64=''
566 d_delete64=''
567 d_fetch64=''
568 d_firstkey64=''
569 d_nextkey64=''
570 d_store64=''
571 dlext=''
572 cccdlflags=''
573 ccdlflags=''
574 dlsrc=''
575 ld=''
576 lddlflags=''
577 usedl=''
578 doublesize=''
579 ebcdic=''
580 fflushNULL=''
581 fflushall=''
582 fpostype=''
583 gidtype=''
584 groupstype=''
585 h_fcntl=''
586 h_sysfile=''
587 i_arpainet=''
588 db_hashtype=''
589 db_prefixtype=''
590 i_db=''
591 i_dbm=''
592 i_rpcsvcdbm=''
593 d_dirnamlen=''
594 direntrytype=''
595 i_dirent=''
596 i_dld=''
597 i_dlfcn=''
598 i_fcntl=''
599 i_float=''
600 i_gdbm=''
601 d_grpasswd=''
602 i_grp=''
603 d_int64t=''
604 i_inttypes=''
605 i_limits=''
606 i_locale=''
607 i_machcthr=''
608 i_malloc=''
609 i_math=''
610 i_memory=''
611 i_mntent=''
612 i_ndbm=''
613 i_netdb=''
614 i_neterrno=''
615 i_netinettcp=''
616 i_niin=''
617 i_sysin=''
618 i_poll=''
619 i_pthread=''
620 d_pwage=''
621 d_pwchange=''
622 d_pwclass=''
623 d_pwcomment=''
624 d_pwexpire=''
625 d_pwgecos=''
626 d_pwpasswd=''
627 d_pwquota=''
628 i_pwd=''
629 i_sfio=''
630 i_shadow=''
631 i_socks=''
632 i_stddef=''
633 i_stdlib=''
634 i_string=''
635 strings=''
636 i_sysaccess=''
637 i_sysdir=''
638 i_sysfile=''
639 d_voidtty=''
640 i_bsdioctl=''
641 i_sysfilio=''
642 i_sysioctl=''
643 i_syssockio=''
644 i_sysmman=''
645 i_sysmount=''
646 i_sysndir=''
647 i_sysparam=''
648 i_sysresrc=''
649 i_syssecrt=''
650 i_sysselct=''
651 i_sysstat=''
652 i_sysstatvfs=''
653 i_systimes=''
654 i_systypes=''
655 d_iovec_s=''
656 i_sysuio=''
657 i_sysun=''
658 i_syswait=''
659 i_sgtty=''
660 i_termio=''
661 i_termios=''
662 i_systime=''
663 i_systimek=''
664 i_time=''
665 timeincl=''
666 i_unistd=''
667 i_utime=''
668 i_values=''
669 i_stdarg=''
670 i_varargs=''
671 i_varhdr=''
672 i_vfork=''
673 installusrbinperl=''
674 intsize=''
675 longsize=''
676 shortsize=''
677 d_dirent64_s=''
678 d_flock64_s=''
679 d_fstat64=''
680 d_ftruncate64=''
681 d_ino64_t=''
682 d_llseek=''
683 d_lockf64=''
684 d_lseek64=''
685 d_lstat64=''
686 d_off64_t=''
687 d_offset_t=''
688 d_open64=''
689 d_opendir64=''
690 d_readdir64=''
691 d_seekdir64=''
692 d_stat64=''
693 d_telldir64=''
694 d_truncate64=''
695 libc=''
696 ldlibpthname=''
697 libperl=''
698 shrpenv=''
699 useshrplib=''
700 glibpth=''
701 libpth=''
702 loclibpth=''
703 plibpth=''
704 xlibpth=''
705 ignore_versioned_solibs=''
706 libs=''
707 lns=''
708 lseeksize=''
709 lseektype=''
710 make_set_make=''
711 d_mymalloc=''
712 freetype=''
713 mallocobj=''
714 mallocsrc=''
715 malloctype=''
716 usemymalloc=''
717 installman1dir=''
718 man1dir=''
719 man1direxp=''
720 man1ext=''
721 installman3dir=''
722 man3dir=''
723 man3direxp=''
724 man3ext=''
725 huge=''
726 large=''
727 medium=''
728 models=''
729 small=''
730 split=''
731 modetype=''
732 multiarch=''
733 mydomain=''
734 myhostname=''
735 phostname=''
736 c=''
737 n=''
738 d_eofnblk=''
739 eagain=''
740 o_nonblock=''
741 rd_nodata=''
742 netdb_hlen_type=''
743 netdb_host_type=''
744 netdb_name_type=''
745 netdb_net_type=''
746 groupcat=''
747 hostcat=''
748 passcat=''
749 orderlib=''
750 ranlib=''
751 package=''
752 spackage=''
753 pager=''
754 apiversion=''
755 patchlevel=''
756 subversion=''
757 version=''
758 perladmin=''
759 perlpath=''
760 pidtype=''
761 prefix=''
762 prefixexp=''
763 installprivlib=''
764 privlib=''
765 privlibexp=''
766 prototype=''
767 ptrsize=''
768 drand01=''
769 randbits=''
770 randfunc=''
771 randseedtype=''
772 seedfunc=''
773 installscript=''
774 scriptdir=''
775 scriptdirexp=''
776 selectminbits=''
777 selecttype=''
778 sh=''
779 sig_count=''
780 sig_name=''
781 sig_name_init=''
782 sig_num=''
783 sig_num_init=''
784 installsitearch=''
785 sitearch=''
786 sitearchexp=''
787 installsitelib=''
788 sitelib=''
789 sitelibexp=''
790 sizetype=''
791 so=''
792 sharpbang=''
793 shsharp=''
794 spitshell=''
795 src=''
796 ssizetype=''
797 startperl=''
798 startsh=''
799 stdchar=''
800 d_fgetpos64=''
801 d_fopen64=''
802 d_freopen64=''
803 d_fseek64=''
804 d_fseeko64=''
805 d_fsetpos64=''
806 d_ftell64=''
807 d_ftello64=''
808 d_tmpfile64=''
809 d_stdio_stream_array=''
810 stdio_stream_array=''
811 sysman=''
812 trnl=''
813 uidtype=''
814 archname64=''
815 use64bits=''
816 usemultiplicity=''
817 nm_opt=''
818 nm_so_opt=''
819 runnm=''
820 usenm=''
821 useperlio=''
822 usesocks=''
823 d_oldpthreads=''
824 usethreads=''
825 incpath=''
826 mips=''
827 mips_type=''
828 usrinc=''
829 defvoidused=''
830 voidflags=''
831 CONFIG=''
832
833 define='define'
834 undef='undef'
835 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
836 rmlist=''
837
838 : We must find out about Eunice early
839 eunicefix=':'
840 if test -f /etc/unixtovms; then
841         eunicefix=/etc/unixtovms
842 fi
843 if test -f /etc/unixtovms.exe; then
844         eunicefix=/etc/unixtovms.exe
845 fi
846
847 i_whoami=''
848 : Possible local include directories to search.
849 : Set locincpth to "" in a hint file to defeat local include searches.
850 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
851 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
852 :
853 : no include file wanted by default
854 inclwanted=''
855
856 : list of known cpp symbols, sorted alphabetically
857 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
858 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
859 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
860 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
861 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
862 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
863 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
864 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
865 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
866 al="$al VMS Xenix286"
867 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
868 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
869 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
870 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
871 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
872 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
873 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
874 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
875 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
876 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
877 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
878 al="$al __SVR4_2__ __UMAXV__"
879 al="$al ____386BSD____ __alpha __alpha__ __amiga"
880 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
881 al="$al __host_mips__"
882 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
883 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
884 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
885 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
886 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
887 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
888 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
889 al="$al __mc88100 __mc88100__ __mips __mips__"
890 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
891 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
892 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
893 al="$al _host_mips _mips _unix"
894 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
895 al="$al apollo ardent att386 att3b"
896 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
897 al="$al cadmus clipper concurrent convex cray ctix"
898 al="$al dmert encore gcos gcx gimpel gould"
899 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
900 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
901 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
902 al="$al i186 i286 i386 i486 i8086"
903 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
904 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
905 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
906 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
907 al="$al mc88000 mc88100 merlin mert mips mvs n16"
908 al="$al ncl_el ncl_mr"
909 al="$al news1500 news1700 news1800 news1900 news3700"
910 al="$al news700 news800 news900 ns16000 ns32000"
911 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
912 al="$al parisc pc532 pdp11 plexus posix pyr"
913 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
914 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
915 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
916 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
917 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
918 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
919 al="$al xenix z8000"
920
921 : Trailing extension.  Override this in a hint file, if needed.
922 _exe=''
923 : Extra object files, if any, needed on this platform.
924 archobjs=''
925 groupstype=''
926 : change the next line if compiling for Xenix/286 on Xenix/386
927 xlibpth='/usr/lib/386 /lib/386'
928
929 : Possible local library directories to search.
930 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
931 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
932
933 : general looking path for locating libraries
934 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
935 glibpth="$glibpth /lib /usr/lib $xlibpth"
936 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
937 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
938
939 : Private path used by Configure to find libraries.  Its value
940 : is prepended to libpth. This variable takes care of special
941 : machines, like the mips.  Usually, it should be empty.
942 plibpth=''
943
944 : default library list
945 libswanted=''
946 : some systems want to use only the non-versioned libso:s
947 ignore_versioned_solibs=''
948 : full support for void wanted by default
949 defvoidused=15
950
951 : set useposix=false in your hint file to disable the POSIX extension.
952 useposix=true
953 : set useopcode=false in your hint file to disable the Opcode extension.
954 useopcode=true
955 : set usemultiplicity on the Configure command line to enable multiplicity.
956 : set usesocks on the Configure command line to enable socks.
957 : set usethreads on the Configure command line to enable threads.
958 : List of libraries we want.
959 : If anyone needs -lnet, put it in a hint file.
960 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
961 libswanted="$libswanted dld ld sun m rt c cposix posix"
962 libswanted="$libswanted ndir dir crypt sec"
963 libswanted="$libswanted ucb bsd BSD PW x"
964 : We probably want to search /usr/shlib before most other libraries.
965 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
966 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
967 glibpth="/usr/shlib $glibpth"
968 : Do not use vfork unless overridden by a hint file.
969 usevfork=false
970
971 : Find the basic shell for Bourne shell scripts
972 case "$sh" in
973 '')
974         case "$SYSTYPE" in
975         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
976         *) xxx='/bin/sh';;
977         esac
978         if test -f "$xxx"; then
979                 sh="$xxx"
980         else
981                 : Build up a list and do a single loop so we can 'break' out.
982                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
983                 for xxx in sh bash ksh pdksh ash; do
984                         for p in $pth; do
985                                 try="$try ${p}/${xxx}"
986                         done
987                 done
988                 for xxx in $try; do
989                         if test -f "$xxx"; then
990                                 sh="$xxx";
991                                 break
992                         elif test -f "$xxx.exe"; then
993                                 sh="$xxx";
994                                 break
995                         fi
996                 done
997         fi
998         ;;
999 esac
1000
1001 case "$sh" in
1002 '')     cat <<EOM >&2
1003 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
1004
1005 Usually it's in /bin/sh.  How did you even get this far?
1006 Please contact me (Perl Maintainers) at perlbug@perl.com and 
1007 we'll try to straighten this all out.
1008 EOM
1009         exit 1
1010         ;;
1011 esac
1012
1013 : see if sh knows # comments
1014 if `$sh -c '#' >/dev/null 2>&1`; then
1015         shsharp=true
1016         spitshell=cat
1017         xcat=/bin/cat
1018         test -f $xcat || xcat=/usr/bin/cat
1019         echo "#!$xcat" >try
1020         $eunicefix try
1021         chmod +x try
1022         ./try > today
1023         if test -s today; then
1024                 sharpbang='#!'
1025         else
1026                 echo "#! $xcat" > try
1027                 $eunicefix try
1028                 chmod +x try
1029                 ./try > today
1030                 if test -s today; then
1031                         sharpbang='#! '
1032                 else
1033                         sharpbang=': use '
1034                 fi
1035         fi
1036 else
1037         echo " "
1038         echo "Your $sh doesn't grok # comments--I will strip them later on."
1039         shsharp=false
1040         cd ..
1041         echo "exec grep -v '^[  ]*#'" >spitshell
1042         chmod +x spitshell
1043         $eunicefix spitshell
1044         spitshell=`pwd`/spitshell
1045         cd UU
1046         echo "I presume that if # doesn't work, #! won't work either!"
1047         sharpbang=': use '
1048 fi
1049 rm -f try today
1050
1051 : figure out how to guarantee sh startup
1052 case "$startsh" in
1053 '') startsh=${sharpbang}${sh} ;;
1054 *)
1055 esac
1056 cat >try <<EOSS
1057 $startsh
1058 set abc
1059 test "$?abc" != 1
1060 EOSS
1061
1062 chmod +x try
1063 $eunicefix try
1064 if ./try; then
1065         : echo "Yup, it does."
1066 else
1067         echo "Hmm... '$startsh' does not guarantee sh startup..."
1068         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1069 fi
1070 rm -f try
1071
1072
1073 : Save command line options in file UU/cmdline.opt for later use in
1074 : generating config.sh.
1075 cat > cmdline.opt <<EOSH
1076 # Configure command line arguments.
1077 config_arg0='$0'
1078 config_args='$*'
1079 config_argc=$#
1080 EOSH
1081 argn=1
1082 for arg in "$@"; do
1083         cat >>cmdline.opt <<EOSH
1084 config_arg$argn='$arg'
1085 EOSH
1086         argn=`expr $argn + 1`
1087 done
1088
1089 : produce awk script to parse command line options
1090 cat >options.awk <<'EOF'
1091 BEGIN {
1092         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1093
1094         len = length(optstr);
1095         for (i = 1; i <= len; i++) {
1096                 c = substr(optstr, i, 1);
1097                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1098                 if (a == ":") {
1099                         arg[c] = 1;
1100                         i++;
1101                 }
1102                 opt[c] = 1;
1103         }
1104 }
1105 {
1106         expect = 0;
1107         str = $0;
1108         if (substr(str, 1, 1) != "-") {
1109                 printf("'%s'\n", str);
1110                 next;
1111         }
1112         len = length($0);
1113         for (i = 2; i <= len; i++) {
1114                 c = substr(str, i, 1);
1115                 if (!opt[c]) {
1116                         printf("-%s\n", substr(str, i));
1117                         next;
1118                 }
1119                 printf("-%s\n", c);
1120                 if (arg[c]) {
1121                         if (i < len)
1122                                 printf("'%s'\n", substr(str, i + 1));
1123                         else
1124                                 expect = 1;
1125                         next;
1126                 }
1127         }
1128 }
1129 END {
1130         if (expect)
1131                 print "?";
1132 }
1133 EOF
1134
1135 : process the command line options
1136 set X `for arg in "$@"; do echo "X$arg"; done |
1137         sed -e s/X// | awk -f options.awk`
1138 eval "set $*"
1139 shift
1140 rm -f options.awk
1141
1142 : set up default values
1143 fastread=''
1144 reuseval=false
1145 config_sh=''
1146 alldone=''
1147 error=''
1148 silent=''
1149 extractsh=''
1150 override=''
1151 knowitall=''
1152 rm -f optdef.sh
1153 cat >optdef.sh <<EOS
1154 $startsh
1155 EOS
1156
1157
1158 : option parsing
1159 while test $# -gt 0; do
1160         case "$1" in
1161         -d) shift; fastread=yes;;
1162         -e) shift; alldone=cont;;
1163         -f)
1164                 shift
1165                 cd ..
1166                 if test -r "$1"; then
1167                         config_sh="$1"
1168                 else
1169                         echo "$me: cannot read config file $1." >&2
1170                         error=true
1171                 fi
1172                 cd UU
1173                 shift;;
1174         -h) shift; error=true;;
1175         -r) shift; reuseval=true;;
1176         -s) shift; silent=true; realsilent=true;;
1177         -E) shift; alldone=exit;;
1178         -K) shift; knowitall=true;;
1179         -O) shift; override=true;;
1180         -S) shift; silent=true; extractsh=true;;
1181         -D)
1182                 shift
1183                 case "$1" in
1184                 *=)
1185                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1186                         echo "$me: ignoring -D $1" >&2
1187                         ;;
1188                 *=*) echo "$1" | \
1189                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1190                 *) echo "$1='define'" >> optdef.sh;;
1191                 esac
1192                 shift
1193                 ;;
1194         -U)
1195                 shift
1196                 case "$1" in
1197                 *=) echo "$1" >> optdef.sh;;
1198                 *=*)
1199                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1200                         echo "$me: ignoring -U $1" >&2
1201                         ;;
1202                 *) echo "$1='undef'" >> optdef.sh;;
1203                 esac
1204                 shift
1205                 ;;
1206         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1207                 exit 0;;
1208         --) break;;
1209         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1210         *) break;;
1211         esac
1212 done
1213
1214 case "$error" in
1215 true)
1216         cat >&2 <<EOM
1217 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1218                  [-U symbol] [-U symbol=]
1219   -d : use defaults for all answers.
1220   -e : go on without questioning past the production of config.sh.
1221   -f : specify an alternate default configuration file.
1222   -h : print this help message and exit (with an error status).
1223   -r : reuse C symbols value if possible (skips costly nm extraction).
1224   -s : silent mode, only echoes questions and essential information.
1225   -D : define symbol to have some value:
1226          -D symbol         symbol gets the value 'define'
1227          -D symbol=value   symbol gets the value 'value'
1228   -E : stop at the end of questions, after having produced config.sh.
1229   -K : do not use unless you know what you are doing.
1230   -O : let -D and -U override definitions from loaded configuration file.
1231   -S : perform variable substitutions on all .SH files (can mix with -f)
1232   -U : undefine symbol:
1233          -U symbol    symbol gets the value 'undef'
1234          -U symbol=   symbol gets completely empty
1235   -V : print version number and exit (with a zero status).
1236 EOM
1237         exit 1
1238         ;;
1239 esac
1240
1241 : Sanity checks
1242 case "$fastread$alldone" in
1243 yescont|yesexit) ;;
1244 *)
1245         if test ! -t 0; then
1246                 echo "Say 'sh Configure', not 'sh <Configure'"
1247                 exit 1
1248         fi
1249         ;;
1250 esac
1251
1252 exec 4>&1
1253 case "$silent" in
1254 true) exec 1>/dev/null;;
1255 esac
1256
1257 : run the defines and the undefines, if any, but leave the file out there...
1258 touch optdef.sh
1259 . ./optdef.sh
1260
1261 : set package name
1262 package=perl5
1263 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1264 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1265 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1266 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1267 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1268 esac
1269
1270 : Some greps do not return status, grrr.
1271 echo "grimblepritz" >grimble
1272 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1273         contains=contains
1274 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1275         contains=grep
1276 else
1277         contains=contains
1278 fi
1279 rm -f grimble
1280 : the following should work in any shell
1281 case "$contains" in
1282 contains*)
1283         echo " "
1284         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1285         cat >contains <<'EOSS'
1286 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1287 EOSS
1288 chmod +x contains
1289 esac
1290
1291 : Find the path to the source tree
1292 case "$src" in
1293 '') case "$0" in
1294     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1295     *)   src='.';;
1296     esac;;
1297 esac
1298 case "$src" in
1299 '')     src=/
1300         rsrc=/
1301         ;;
1302 /*) rsrc="$src";;
1303 *) rsrc="../$src";;
1304 esac
1305 if test -f $rsrc/Configure && \
1306         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1307 then
1308    : found it, so we are ok.
1309 else
1310         rsrc=''
1311         for src in . .. ../.. ../../.. ../../../..; do
1312                 if test -f ../$src/Configure && \
1313                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1314                 then
1315                         rsrc=../$src
1316                         break
1317                 fi
1318         done
1319 fi
1320 case "$rsrc" in
1321 '')
1322         cat <<EOM >&4
1323
1324 Sorry, I can't seem to locate the source dir for $package.  Please start
1325 Configure with an explicit path -- i.e. /some/path/Configure.
1326
1327 EOM
1328         exit 1
1329         ;;
1330 ../.)   rsrc='..';;
1331 *)
1332         echo " "
1333         echo "Sources for $package found in \"$src\"." >&4
1334         ;;
1335 esac
1336
1337 : script used to extract .SH files with variable substitutions
1338 cat >extract <<'EOS'
1339 CONFIGDOTSH=true
1340 echo "Doing variable substitutions on .SH files..."
1341 if test -f $src/MANIFEST; then
1342         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1343 else
1344         echo "(Looking for .SH files under the source directory.)"
1345         set x `(cd $src; find . -name "*.SH" -print)`
1346 fi
1347 shift
1348 case $# in
1349 0) set x `(cd $src; echo *.SH)`; shift;;
1350 esac
1351 if test ! -f $src/$1; then
1352         shift
1353 fi
1354 mkdir_p='
1355 name=$1;
1356 create="";
1357 while test $name; do
1358         if test ! -d "$name"; then
1359                 create="$name $create";
1360                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1361                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1362         else
1363                 name="";
1364         fi;
1365 done;
1366 for file in $create; do
1367         mkdir $file;
1368 done
1369 '
1370 for file in $*; do
1371         case "$src" in
1372         ".")
1373                 case "$file" in
1374                 */*)
1375                         dir=`expr X$file : 'X\(.*\)/'`
1376                         file=`expr X$file : 'X.*/\(.*\)'`
1377                         (cd $dir && . ./$file)
1378                         ;;
1379                 *)
1380                         . ./$file
1381                         ;;
1382                 esac
1383                 ;;
1384         *)
1385                 case "$file" in
1386                 */*)
1387                         dir=`expr X$file : 'X\(.*\)/'`
1388                         file=`expr X$file : 'X.*/\(.*\)'`
1389                         (set x $dir; shift; eval $mkdir_p)
1390                         sh <$src/$dir/$file
1391                         ;;
1392                 *)
1393                         sh <$src/$file
1394                         ;;
1395                 esac
1396                 ;;
1397         esac
1398 done
1399 if test -f $src/config_h.SH; then
1400         if test ! -f config.h; then
1401         : oops, they left it out of MANIFEST, probably, so do it anyway.
1402         . $src/config_h.SH
1403         fi
1404 fi
1405 EOS
1406
1407 : extract files and exit if asked to do so
1408 case "$extractsh" in
1409 true)
1410         case "$realsilent" in
1411         true) ;;
1412         *) exec 1>&4;;
1413         esac
1414         case "$config_sh" in
1415         '') config_sh='config.sh';;
1416         esac
1417         echo " "
1418         echo "Fetching answers from $config_sh..."
1419         cd ..
1420         . $config_sh
1421         test "$override" && . ./optdef.sh
1422         echo " "
1423         . UU/extract
1424         rm -rf UU
1425         echo "Done."
1426         exit 0
1427         ;;
1428 esac
1429
1430 : Eunice requires " " instead of "", can you believe it
1431 echo " "
1432 : Here we go...
1433 echo "Beginning of configuration questions for $package."
1434
1435 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1436
1437 : first determine how to suppress newline on echo command
1438 echo " "
1439 echo "Checking echo to see how to suppress newlines..."
1440 (echo "hi there\c" ; echo " ") >.echotmp
1441 if $contains c .echotmp >/dev/null 2>&1 ; then
1442         echo "...using -n."
1443         n='-n'
1444         c=''
1445 else
1446         cat <<'EOM'
1447 ...using \c
1448 EOM
1449         n=''
1450         c='\c'
1451 fi
1452 echo $n "The star should be here-->$c"
1453 echo '*'
1454 rm -f .echotmp
1455
1456 : Now test for existence of everything in MANIFEST
1457 echo " "
1458 if test -f $rsrc/MANIFEST; then
1459         echo "First let's make sure your kit is complete.  Checking..." >&4
1460         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1461         rm -f missing
1462         tmppwd=`pwd`
1463         for filelist in x??; do
1464                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1465         done
1466         if test -s missing; then
1467                 cat missing >&4
1468                 cat >&4 <<'EOM'
1469
1470 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1471
1472 You have the option of continuing the configuration process, despite the
1473 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1474 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1475 and contact the author (perlbug@perl.com).
1476
1477 EOM
1478                 echo $n "Continue? [n] $c" >&4
1479                 read ans
1480                 case "$ans" in
1481                 y*)
1482                         echo "Continuing..." >&4
1483                         rm -f missing
1484                         ;;
1485                 *)
1486                         echo "ABORTING..." >&4
1487                         kill $$
1488                         ;;
1489                 esac
1490         else
1491                 echo "Looks good..."
1492         fi
1493 else
1494         echo "There is no MANIFEST file.  I hope your kit is complete !"
1495 fi
1496 rm -f missing x??
1497
1498 echo " "
1499 : Find the appropriate value for a newline for tr
1500 if test -n "$DJGPP"; then
1501        trnl='\012'
1502 fi
1503 if test X"$trnl" = X; then
1504         case "`echo foo|tr '\n' x 2>/dev/null`" in
1505         foox) trnl='\n' ;;
1506         esac
1507 fi
1508 if test X"$trnl" = X; then
1509         case "`echo foo|tr '\012' x 2>/dev/null`" in
1510         foox) trnl='\012' ;;
1511         esac
1512 fi
1513 if test X"$trnl" = X; then
1514         cat <<EOM >&2
1515
1516 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1517
1518 EOM
1519         exit 1
1520 fi
1521
1522 : compute the number of columns on the terminal for proper question formatting
1523 case "$COLUMNS" in
1524 '') COLUMNS='80';;
1525 esac
1526
1527 : set up the echo used in my read
1528 myecho="case \"\$xxxm\" in
1529 '') echo $n \"\$rp $c\" >&4;;
1530 *) case \"\$rp\" in
1531         '') echo $n \"[\$xxxm] $c\";;
1532         *)
1533                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1534                         echo \"\$rp\" >&4
1535                         echo $n \"[\$xxxm] $c\" >&4
1536                 else
1537                         echo $n \"\$rp [\$xxxm] $c\" >&4
1538                 fi
1539                 ;;
1540         esac;;
1541 esac"
1542
1543 : now set up to do reads with possible shell escape and default assignment
1544 cat <<EOSC >myread
1545 $startsh
1546 xxxm=\$dflt
1547 $myecho
1548 ans='!'
1549 case "\$fastread" in
1550 yes) case "\$dflt" in
1551         '') ;;
1552         *) ans='';
1553                 case "\$silent-\$rp" in
1554                 true-) ;;
1555                 *) echo " " >&4;;
1556                 esac;;
1557         esac;;
1558 *) case "\$silent" in
1559         true) case "\$rp" in
1560                 '') ans='';;
1561                 esac;;
1562         esac;;
1563 esac
1564 while expr "X\$ans" : "X!" >/dev/null; do
1565         read answ
1566         set x \$xxxm
1567         shift
1568         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1569         case  "\$answ" in
1570         "!")
1571                 sh 1>&4
1572                 echo " "
1573                 $myecho
1574                 ;;
1575         !*)
1576                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1577                 shift
1578                 sh 1>&4 -c "\$*"
1579                 echo " "
1580                 $myecho
1581                 ;;
1582         "\$ans")
1583                 case "\$ans" in
1584                 \\&*)
1585                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1586                         shift
1587                         case "\$1" in
1588                         -d)
1589                                 fastread=yes
1590                                 echo "(OK, I'll run with -d after this question.)" >&4
1591                                 ;;
1592                         -*)
1593                                 echo "*** Sorry, \$1 not supported yet." >&4
1594                                 ;;
1595                         esac
1596                         $myecho
1597                         ans=!
1598                         ;;
1599                 esac;;
1600         *)
1601                 case "\$aok" in
1602                 y)
1603                         echo "*** Substitution done -- please confirm."
1604                         xxxm="\$ans"
1605                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1606                         xxxm="\$ans"
1607                         ans=!
1608                         ;;
1609                 *)
1610                         echo "*** Error -- try again."
1611                         ans=!
1612                         ;;
1613                 esac
1614                 $myecho
1615                 ;;
1616         esac
1617         case "\$ans\$xxxm\$nostick" in
1618         '')
1619                 ans=!
1620                 $myecho
1621                 ;;
1622         esac
1623 done
1624 case "\$ans" in
1625 '') ans="\$xxxm";;
1626 esac
1627 EOSC
1628
1629 : create .config dir to save info across Configure sessions
1630 test -d ../.config || mkdir ../.config
1631 cat >../.config/README <<EOF
1632 This directory created by Configure to save information that should
1633 persist across sessions for $package.
1634
1635 You may safely delete it if you wish.
1636 EOF
1637
1638 : general instructions
1639 needman=true
1640 firsttime=true
1641 user=`(logname) 2>/dev/null`
1642 case "$user" in
1643 '') user=`whoami 2>&1`;;
1644 esac
1645 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1646         firsttime=false
1647         echo " "
1648         rp='Would you like to see the instructions?'
1649         dflt=n
1650         . ./myread
1651         case "$ans" in
1652         [yY]*) ;;
1653         *) needman=false;;
1654         esac
1655 fi
1656 if $needman; then
1657         cat <<EOH
1658
1659 This installation shell script will examine your system and ask you questions
1660 to determine how the perl5 package should be installed. If you get
1661 stuck on a question, you may use a ! shell escape to start a subshell or
1662 execute a command.  Many of the questions will have default answers in square
1663 brackets; typing carriage return will give you the default.
1664
1665 On some of the questions which ask for file or directory names you are allowed
1666 to use the ~name construct to specify the login directory belonging to "name",
1667 even if you don't have a shell which knows about that.  Questions where this is
1668 allowed will be marked "(~name ok)".
1669
1670 EOH
1671         rp=''
1672         dflt='Type carriage return to continue'
1673         . ./myread
1674         cat <<'EOH'
1675
1676 The prompter used in this script allows you to use shell variables and
1677 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1678 in the default answer, as if the default line was a set of arguments given to a
1679 script shell.  This means you may also use $* to repeat the whole default line,
1680 so you do not have to re-type everything to add something to the default.
1681
1682 Everytime there is a substitution, you will have to confirm.  If there is an
1683 error (e.g. an unmatched backtick), the default answer will remain unchanged
1684 and you will be prompted again.
1685
1686 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1687 the questions and use the computed defaults (or the previous answers if there
1688 was already a config.sh file). Type 'Configure -h' for a list of options.
1689 You may also start interactively and then answer '& -d' at any prompt to turn
1690 on the non-interactive behaviour for the remainder of the execution.
1691
1692 EOH
1693         . ./myread
1694         cat <<EOH
1695
1696 Much effort has been expended to ensure that this shell script will run on any
1697 Unix system.  If despite that it blows up on yours, your best bet is to edit
1698 Configure and run it again.  If you can't run Configure for some reason,
1699 you'll have to generate a config.sh file by hand.  Whatever problems you
1700 have, let me (perlbug@perl.com) know how I blew it.
1701
1702 This installation script affects things in two ways:
1703
1704 1) it may do direct variable substitutions on some of the files included
1705    in this kit.
1706 2) it builds a config.h file for inclusion in C programs.  You may edit
1707    any of these files as the need arises after running this script.
1708
1709 If you make a mistake on a question, there is no easy way to back up to it
1710 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1711 files.  Configure will offer to let you do this before it runs the SH files.
1712
1713 EOH
1714         dflt='Type carriage return to continue'
1715         . ./myread
1716         case "$firsttime" in
1717         true) echo $user >>../.config/instruct;;
1718         esac
1719 fi
1720
1721 : find out where common programs are
1722 echo " "
1723 echo "Locating common programs..." >&4
1724 cat <<EOSC >loc
1725 $startsh
1726 case \$# in
1727 0) exit 1;;
1728 esac
1729 thing=\$1
1730 shift
1731 dflt=\$1
1732 shift
1733 for dir in \$*; do
1734         case "\$thing" in
1735         .)
1736         if test -d \$dir/\$thing; then
1737                 echo \$dir
1738                 exit 0
1739         fi
1740         ;;
1741         *)
1742         for thisthing in \$dir/\$thing; do
1743                 : just loop through to pick last item
1744         done
1745         if test -f \$thisthing; then
1746                 echo \$thisthing
1747                 exit 0
1748         elif test -f \$dir/\$thing.exe; then
1749                 if test -n "$DJGPP"; then
1750                         echo \$dir/\$thing.exe
1751                 else
1752                         : on Eunice apparently
1753                         echo \$dir/\$thing
1754                 fi
1755                 exit 0
1756         fi
1757         ;;
1758         esac
1759 done
1760 echo \$dflt
1761 exit 1
1762 EOSC
1763 chmod +x loc
1764 $eunicefix loc
1765 loclist="
1766 awk
1767 cat
1768 comm
1769 cp
1770 echo
1771 expr
1772 grep
1773 ls
1774 make
1775 mkdir
1776 rm
1777 sed
1778 sort
1779 touch
1780 tr
1781 uniq
1782 "
1783 trylist="
1784 Mcc
1785 ar
1786 byacc
1787 cpp
1788 csh
1789 date
1790 egrep
1791 gzip
1792 less
1793 ln
1794 more
1795 nm
1796 nroff
1797 pg
1798 test
1799 uname
1800 zip
1801 "
1802 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1803 pth="$pth /lib /usr/lib"
1804 for file in $loclist; do
1805         eval xxx=\$$file
1806         case "$xxx" in
1807         /*|?:[\\/]*)
1808                 if test -f "$xxx"; then
1809                         : ok
1810                 else
1811                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1812                         xxx=`./loc $file $file $pth`
1813                 fi
1814                 ;;
1815         '') xxx=`./loc $file $file $pth`;;
1816         *) xxx=`./loc $xxx $xxx $pth`;;
1817         esac
1818         eval $file=$xxx
1819         eval _$file=$xxx
1820         case "$xxx" in
1821         /*)
1822                 echo $file is in $xxx.
1823                 ;;
1824         ?:[\\/]*)
1825                 echo $file is in $xxx.
1826                 ;;
1827         *)
1828                 echo "I don't know where '$file' is, and my life depends on it." >&4
1829                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1830                 exit 1
1831                 ;;
1832         esac
1833 done
1834 echo " "
1835 echo "Don't worry if any of the following aren't found..."
1836 say=offhand
1837 for file in $trylist; do
1838         eval xxx=\$$file
1839         case "$xxx" in
1840         /*|?:[\\/]*)
1841                 if test -f "$xxx"; then
1842                         : ok
1843                 else
1844                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1845                         xxx=`./loc $file $file $pth`
1846                 fi
1847                 ;;
1848         '') xxx=`./loc $file $file $pth`;;
1849         *) xxx=`./loc $xxx $xxx $pth`;;
1850         esac
1851         eval $file=$xxx
1852         eval _$file=$xxx
1853         case "$xxx" in
1854         /*)
1855                 echo $file is in $xxx.
1856                 ;;
1857         ?:[\\/]*)
1858                 echo $file is in $xxx.
1859                 ;;
1860         *)
1861                 echo "I don't see $file out there, $say."
1862                 say=either
1863                 ;;
1864         esac
1865 done
1866 case "$egrep" in
1867 egrep)
1868         echo "Substituting grep for egrep."
1869         egrep=$grep
1870         ;;
1871 esac
1872 case "$ln" in
1873 ln)
1874         echo "Substituting cp for ln."
1875         ln=$cp
1876         ;;
1877 esac
1878 case "$test" in
1879 test)
1880         echo "Hopefully test is built into your sh."
1881         ;;
1882 *)
1883         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1884                 echo "Using the test built into your sh."
1885                 test=test
1886                 _test=test
1887         fi
1888         ;;
1889 esac
1890 case "$echo" in
1891 echo)
1892         echo "Hopefully echo is built into your sh."
1893         ;;
1894 '') ;;
1895 *)
1896         echo " "
1897 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1898         $echo $n "hi there$c" >foo1
1899         echo $n "hi there$c" >foo2
1900         if cmp foo1 foo2 >/dev/null 2>&1; then
1901                 echo "They are compatible.  In fact, they may be identical."
1902         else
1903                 case "$n" in
1904                 '-n') n='' c='\c';;
1905                 *) n='-n' c='';;
1906                 esac
1907                 cat <<FOO
1908 They are not compatible!  You are probably running ksh on a non-USG system.
1909 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1910 have echo built in and we may have to run some Bourne shell scripts.  That
1911 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1912
1913 FOO
1914                 $echo $n "The star should be here-->$c"
1915                 $echo "*"
1916         fi
1917         $rm -f foo1 foo2
1918         ;;
1919 esac
1920
1921 : determine whether symbolic links are supported
1922 echo " "
1923 $touch blurfl
1924 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1925         echo "Symbolic links are supported." >&4
1926         lns="$ln -s"
1927 else
1928         echo "Symbolic links are NOT supported." >&4
1929         lns="$ln"
1930 fi
1931 $rm -f blurfl sym
1932
1933 : see whether [:lower:] and [:upper:] are supported character classes
1934 echo " "
1935 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1936 ABYZ)
1937         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1938         up='[:upper:]'
1939         low='[:lower:]'
1940         ;;
1941 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1942         # (0xc9 and 0xd1), therefore that is a nice testing point.
1943         if test "X$up" = X -o "X$low" = X; then
1944             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1945             ij) up='[A-Z]'
1946                 low='[a-z]'
1947                 ;;
1948             esac
1949         fi
1950         if test "X$up" = X -o "X$low" = X; then
1951             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1952             ij) up='A-Z'
1953                 low='a-z'
1954                 ;;
1955             esac
1956         fi
1957         if test "X$up" = X -o "X$low" = X; then
1958             case "`echo IJ | od -x 2>/dev/null`" in
1959             *C9D1*|*c9d1*)
1960                 echo "Hey, this might be EBCDIC." >&4
1961                 if test "X$up" = X -o "X$low" = X; then
1962                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1963                     ij) up='[A-IJ-RS-Z]'
1964                         low='[a-ij-rs-z]'
1965                         ;;
1966                     esac
1967                 fi
1968                 if test "X$up" = X -o "X$low" = X; then
1969                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1970                     ij) up='A-IJ-RS-Z'
1971                         low='a-ij-rs-z'
1972                         ;;
1973                     esac
1974                 fi
1975                 ;;
1976             esac
1977         fi
1978 esac
1979 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1980 ij)
1981     echo "Using $up and $low to convert case." >&4
1982     ;;
1983 *)
1984     echo "I don't know how to translate letters from upper to lower case." >&4
1985     echo "Your tr is not acting any way I know of." >&4
1986     exit 1
1987     ;;
1988 esac
1989 : set up the translation script tr, must be called with ./tr of course
1990 cat >tr <<EOSC
1991 $startsh
1992 case "\$1\$2" in
1993 '[A-Z][a-z]') exec $tr '$up' '$low';;
1994 '[a-z][A-Z]') exec $tr '$low' '$up';;
1995 esac
1996 exec $tr "\$@"
1997 EOSC
1998 chmod +x tr
1999 $eunicefix tr
2000
2001 : Try to determine whether config.sh was made on this system
2002 case "$config_sh" in
2003 '')
2004 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
2005 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
2006 # because the A-Z/a-z are not consecutive.
2007 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
2008         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
2009 newmyuname="$myuname"
2010 dflt=n
2011 case "$knowitall" in
2012 '')
2013         if test -f ../config.sh; then
2014                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
2015                         eval "`grep myuname= ../config.sh`"
2016                 fi
2017                 if test "X$myuname" = "X$newmyuname"; then
2018                         dflt=y
2019                 fi
2020         fi
2021         ;;
2022 *) dflt=y;;
2023 esac
2024
2025 : Get old answers from old config file if Configure was run on the
2026 : same system, otherwise use the hints.
2027 hint=default
2028 cd ..
2029 if test -f config.sh; then
2030         echo " "
2031         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2032         . UU/myread
2033         case "$ans" in
2034         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2035         *)  echo "Fetching default answers from your old config.sh file..." >&4
2036                 tmp_n="$n"
2037                 tmp_c="$c"
2038                 tmp_sh="$sh"
2039                 . ./config.sh
2040                 cp config.sh UU
2041                 n="$tmp_n"
2042                 c="$tmp_c"
2043                 : Older versions did not always set $sh.  Catch re-use of such
2044                 : an old config.sh.
2045                 case "$sh" in
2046                 '') sh="$tmp_sh" ;;
2047                 esac
2048                 hint=previous
2049                 ;;
2050         esac
2051 fi
2052 if test ! -f config.sh; then
2053         $cat <<EOM
2054
2055 First time through, eh?  I have some defaults handy for some systems
2056 that need some extra help getting the Configure answers right:
2057
2058 EOM
2059         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2060         dflt=''
2061         : Half the following guesses are probably wrong... If you have better
2062         : tests or hints, please send them to perlbug@perl.com
2063         : The metaconfig authors would also appreciate a copy...
2064         $test -f /irix && osname=irix
2065         $test -f /xenix && osname=sco_xenix
2066         $test -f /dynix && osname=dynix
2067         $test -f /dnix && osname=dnix
2068         $test -f /lynx.os && osname=lynxos
2069         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2070         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2071         $test -f /bin/mips && /bin/mips && osname=mips
2072         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2073                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2074         $test -d /usr/apollo/bin && osname=apollo
2075         $test -f /etc/saf/_sactab && osname=svr4
2076         $test -d /usr/include/minix && osname=minix
2077         if $test -d /MachTen -o -d /MachTen_Folder; then
2078                 osname=machten
2079                 if $test -x /sbin/version; then
2080                         osvers=`/sbin/version | $awk '{print $2}' |
2081                         $sed -e 's/[A-Za-z]$//'`
2082                 elif $test -x /usr/etc/version; then
2083                         osvers=`/usr/etc/version | $awk '{print $2}' |
2084                         $sed -e 's/[A-Za-z]$//'`
2085                 else
2086                         osvers="$2.$3"
2087                 fi
2088         fi
2089        $test -f /sys/posix.dll &&
2090                $test -f /usr/bin/what &&
2091                set X `/usr/bin/what /sys/posix.dll` &&
2092                $test "$3" = UWIN &&
2093                osname=uwin &&
2094                osvers="$5"
2095         if $test -f $uname; then
2096                 set X $myuname
2097                 shift
2098
2099                 case "$5" in
2100                 fps*) osname=fps ;;
2101                 mips*)
2102                         case "$4" in
2103                         umips) osname=umips ;;
2104                         *) osname=mips ;;
2105                         esac;;
2106                 [23]100) osname=mips ;;
2107                 next*) osname=next ;;
2108                 i386*)
2109                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2110                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2111                                 osname='sco'
2112                                 osvers=$tmp
2113                         elif $test -f /etc/kconfig; then
2114                                 osname=isc
2115                                 if test "$lns" = "$ln -s"; then
2116                                         osvers=4
2117                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2118                                         osvers=3
2119                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2120                                         osvers=2
2121                                 fi
2122                         fi
2123                         tmp=''
2124                         ;;
2125                 pc*)
2126                         if test -n "$DJGPP"; then
2127                                 osname=dos
2128                                 osvers=djgpp
2129                         fi
2130                         ;;
2131                 esac
2132
2133                 case "$1" in
2134                 aix) osname=aix
2135                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2136                         case "$tmp" in
2137                         'not found') osvers="$4"."$3" ;;
2138                         '<3240'|'<>3240') osvers=3.2.0 ;;
2139                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2140                         '=3250'|'>3250') osvers=3.2.5 ;;
2141                         *) osvers=$tmp;;
2142                         esac
2143                         ;;
2144                 *dc.osx) osname=dcosx
2145                         osvers="$3"
2146                         ;;
2147                 dnix) osname=dnix
2148                         osvers="$3"
2149                         ;;
2150                 domainos) osname=apollo
2151                         osvers="$3"
2152                         ;;
2153                 dgux) osname=dgux 
2154                         osvers="$3"
2155                         ;;
2156                 dynixptx*) osname=dynixptx
2157                         osvers=`echo "$4"|sed 's/^v//'`
2158                         ;;
2159                 freebsd) osname=freebsd 
2160                         osvers="$3" ;;
2161                 genix) osname=genix ;;
2162                 hp*) osname=hpux 
2163                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2164                         ;;
2165                 irix*) osname=irix
2166                         case "$3" in
2167                         4*) osvers=4 ;;
2168                         5*) osvers=5 ;;
2169                         *)      osvers="$3" ;;
2170                         esac
2171                         ;;
2172                 linux) osname=linux
2173                         case "$3" in
2174                         *)      osvers="$3" ;;
2175                         esac
2176                         ;;
2177                 MiNT) osname=mint
2178                         ;;
2179                 netbsd*) osname=netbsd
2180                         osvers="$3"
2181                         ;;
2182                 news-os) osvers="$3"
2183                         case "$3" in
2184                         4*) osname=newsos4 ;;
2185                         *) osname=newsos ;;
2186                         esac
2187                         ;;
2188                 bsd386) osname=bsd386
2189                         osvers=`$uname -r`
2190                         ;;
2191                 POSIX-BC | posix-bc ) osname=posix-bc
2192                         osvers="$3"
2193                         ;;
2194                 powerux | power_ux | powermax_os | powermaxos | \
2195                 powerunix | power_unix) osname=powerux
2196                         osvers="$3"
2197                         ;;
2198                 next*) osname=next ;;
2199                 solaris) osname=solaris
2200                         case "$3" in
2201                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2202                         *)      osvers="$3" ;;
2203                         esac
2204                         ;;
2205                 sunos) osname=sunos
2206                         case "$3" in
2207                         5*) osname=solaris
2208                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2209                         *)      osvers="$3" ;;
2210                         esac
2211                         ;;
2212                 titanos) osname=titanos
2213                         case "$3" in
2214                         1*) osvers=1 ;;
2215                         2*) osvers=2 ;;
2216                         3*) osvers=3 ;;
2217                         4*) osvers=4 ;;
2218                         *)      osvers="$3" ;;
2219                         esac
2220                         ;;
2221                 ultrix) osname=ultrix
2222                         osvers="$3"
2223                         ;;
2224                 osf1|mls+)      case "$5" in
2225                                 alpha)
2226                                         osname=dec_osf
2227                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2228                                         ;;
2229                         hp*)    osname=hp_osf1  ;;
2230                         mips)   osname=mips_osf1 ;;
2231                         esac
2232                         ;;
2233                 uts) osname=uts 
2234                         osvers="$3"
2235                         ;;
2236                 qnx) osname=qnx
2237                         osvers="$4"
2238                         ;;
2239                 $2) case "$osname" in
2240                         *isc*) ;;
2241                         *freebsd*) ;;
2242                         svr*)
2243                                 : svr4.x or possibly later
2244                                 case "svr$3" in 
2245                                 ${osname}*)
2246                                         osname=svr$3
2247                                         osvers=$4
2248                                         ;;
2249                                 esac
2250                                 case "$osname" in
2251                                 svr4.0)
2252                                         : Check for ESIX
2253                                         if test -f /stand/boot ; then
2254                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2255                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2256                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2257                                                         if test -n "$isesix"; then
2258                                                                 osname=esix4
2259                                                         fi
2260                                                 fi
2261                                         fi
2262                                         ;;
2263                                 esac
2264                                 ;;
2265                         *)      if test -f /etc/systemid; then
2266                                         osname=sco
2267                                         set `echo $3 | $sed 's/\./ /g'` $4
2268                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2269                                                 osvers=$1.$2.$3
2270                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2271                                                 osvers=$1.$2
2272                                         elif $test -f $src/hints/sco_$1.sh; then
2273                                                 osvers=$1
2274                                         fi
2275                                 else
2276                                         case "$osname" in
2277                                         '') : Still unknown.  Probably a generic Sys V.
2278                                                 osname="sysv"
2279                                                 osvers="$3"
2280                                                 ;;
2281                                         esac
2282                                 fi
2283                                 ;;
2284                         esac
2285                         ;;
2286                 *)      case "$osname" in
2287                         '') : Still unknown.  Probably a generic BSD.
2288                                 osname="$1"
2289                                 osvers="$3"
2290                                 ;;
2291                         esac
2292                         ;;
2293                 esac
2294         else
2295                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2296                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2297                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2298                                 osname=news_os
2299                         fi
2300                         $rm -f UU/kernel.what
2301                 elif test -d c:/.; then
2302                         set X $myuname
2303                         osname=os2
2304                         osvers="$5"
2305                 fi
2306         fi
2307         
2308         : Now look for a hint file osname_osvers, unless one has been
2309         : specified already.
2310         case "$hintfile" in
2311         ''|' ')
2312                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2313                 : Also try without trailing minor version numbers.
2314                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2315                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2316                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2317                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2318                 case "$file" in
2319                 '') dflt=none ;;
2320                 *)  case "$osvers" in
2321                         '') dflt=$file
2322                                 ;;
2323                         *)  if $test -f $src/hints/$file.sh ; then
2324                                         dflt=$file
2325                                 elif $test -f $src/hints/$xfile.sh ; then
2326                                         dflt=$xfile
2327                                 elif $test -f $src/hints/$xxfile.sh ; then
2328                                         dflt=$xxfile
2329                                 elif $test -f $src/hints/$xxxfile.sh ; then
2330                                         dflt=$xxxfile
2331                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2332                                         dflt=$xxxxfile
2333                                 elif $test -f "$src/hints/${osname}.sh" ; then
2334                                         dflt="${osname}"
2335                                 else
2336                                         dflt=none
2337                                 fi
2338                                 ;;
2339                         esac
2340                         ;;
2341                 esac
2342                 if $test -f Policy.sh ; then
2343                         case "$dflt" in
2344                         *Policy*) ;;
2345                         none) dflt="Policy" ;;
2346                         *) dflt="Policy $dflt" ;;
2347                         esac
2348                 fi
2349                 ;;
2350         *)
2351                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2352                 ;;
2353         esac
2354
2355         if $test -f Policy.sh ; then
2356                 $cat <<EOM
2357
2358 There's also a Policy hint file available, which should make the
2359 site-specific (policy) questions easier to answer.
2360 EOM
2361
2362         fi
2363
2364         $cat <<EOM
2365
2366 You may give one or more space-separated answers, or "none" if appropriate.
2367 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2368 is a good thing.  DO NOT give a wrong version.
2369
2370 EOM
2371
2372         rp="Which of these apply, if any?"
2373         . UU/myread
2374         tans=$ans
2375         for file in $tans; do
2376                 if $test X$file = XPolicy -a -f Policy.sh; then
2377                         . Policy.sh
2378                         $cat Policy.sh >> UU/config.sh
2379                 elif $test -f $src/hints/$file.sh; then
2380                         . $src/hints/$file.sh
2381                         $cat $src/hints/$file.sh >> UU/config.sh
2382                 elif $test X$tans = X -o X$tans = Xnone ; then
2383                         : nothing
2384                 else
2385                         : Give one chance to correct a possible typo.
2386                         echo "$file.sh does not exist"
2387                         dflt=$file
2388                         rp="hint to use instead?"
2389                         . UU/myread
2390                         for file in $ans; do
2391                                 if $test -f "$src/hints/$file.sh"; then
2392                                         . $src/hints/$file.sh
2393                                         $cat $src/hints/$file.sh >> UU/config.sh
2394                                 elif $test X$ans = X -o X$ans = Xnone ; then
2395                                         : nothing
2396                                 else
2397                                         echo "$file.sh does not exist -- ignored."
2398                                 fi
2399                         done
2400                 fi
2401         done
2402
2403         hint=recommended
2404         : Remember our hint file for later.
2405         if $test -f "$src/hints/$file.sh" ; then
2406                 hintfile="$file"
2407         else
2408                 hintfile=''
2409         fi
2410 fi
2411 cd UU
2412 ;;
2413 *)
2414         echo " "
2415         echo "Fetching default answers from $config_sh..." >&4
2416         tmp_n="$n"
2417         tmp_c="$c"
2418         cd ..
2419         cp $config_sh config.sh 2>/dev/null
2420         chmod +w config.sh
2421         . ./config.sh
2422         cd UU
2423         cp ../config.sh .
2424         n="$tmp_n"
2425         c="$tmp_c"
2426         hint=previous
2427         ;;
2428 esac
2429 test "$override" && . ./optdef.sh
2430 myuname="$newmyuname"
2431
2432 : Restore computed paths
2433 for file in $loclist $trylist; do
2434         eval $file="\$_$file"
2435 done
2436
2437 cat << EOM
2438
2439 Configure uses the operating system name and version to set some defaults.
2440 The default value is probably right if the name rings a bell. Otherwise,
2441 since spelling matters for me, either accept the default or answer "none"
2442 to leave it blank.
2443
2444 EOM
2445 case "$osname" in
2446         ''|' ')
2447                 case "$hintfile" in
2448                 ''|' '|none) dflt=none ;;
2449                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2450                 esac
2451                 ;;
2452         *) dflt="$osname" ;;
2453 esac
2454 rp="Operating system name?"
2455 . ./myread
2456 case "$ans" in
2457 none)  osname='' ;;
2458 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2459 esac
2460 echo " "
2461 case "$osvers" in
2462         ''|' ')
2463                 case "$hintfile" in
2464                 ''|' '|none) dflt=none ;;
2465                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2466                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2467                         case "$dflt" in
2468                         ''|' ') dflt=none ;;
2469                         esac
2470                         ;;
2471                 esac
2472                 ;;
2473         *) dflt="$osvers" ;;
2474 esac
2475 rp="Operating system version?"
2476 . ./myread
2477 case "$ans" in
2478 none)  osvers='' ;;
2479 *) osvers="$ans" ;;
2480 esac
2481
2482 : who configured the system
2483 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2484 cf_by=`(logname) 2>/dev/null`
2485 case "$cf_by" in
2486 "")
2487         cf_by=`(whoami) 2>/dev/null`
2488         case "$cf_by" in
2489         "") cf_by=unknown ;;
2490         esac ;;
2491 esac
2492
2493 : set up the script used to warn in case of inconsistency
2494 cat <<EOS >whoa
2495 $startsh
2496 EOS
2497 cat <<'EOSC' >>whoa
2498 dflt=y
2499 echo " "
2500 echo "*** WHOA THERE!!! ***" >&4
2501 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2502 rp="    Keep the $hint value?"
2503 . ./myread
2504 case "$ans" in
2505 y) td=$was; tu=$was;;
2506 esac
2507 EOSC
2508
2509 : function used to set $1 to $val
2510 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2511 case "$val$was" in
2512 $define$undef) . ./whoa; eval "$var=\$td";;
2513 $undef$define) . ./whoa; eval "$var=\$tu";;
2514 *) eval "$var=$val";;
2515 esac'
2516
2517 cat <<EOM
2518
2519 Perl can be built to take advantage of threads, on some systems.
2520 To do so, Configure must be run with -Dusethreads.
2521
2522 Note that threading is a highly experimental feature, and
2523 some known race conditions still remain.  If you choose to try
2524 it, be very sure to not actually deploy it for production
2525 purposes.  README.threads has more details, and is required
2526 reading if you enable threads.
2527 EOM
2528 case "$usethreads" in
2529 $define|true|[yY]*)     dflt='y';;
2530 *) dflt='n';;
2531 esac
2532 rp='Build a threading Perl?'
2533 . ./myread
2534 case "$ans" in
2535 y|Y)    val="$define" ;;     
2536 *)      val="$undef" ;;
2537 esac
2538 set usethreads
2539 eval $setvar 
2540
2541 case "$d_oldpthreads" in
2542 '')     : Configure tests would be welcome here.  For now, assume undef.
2543         val="$undef" ;;
2544 *)      val="$d_oldpthreads" ;;
2545 esac
2546 set d_oldpthreads
2547 eval $setvar
2548
2549
2550 case "$usethreads" in
2551 "$define"|true|[yY]*)
2552 : Look for a hint-file generated 'call-back-unit'.  If the
2553 : user has specified that a threading perl is to be built,
2554 : we may need to set or change some other defaults.
2555         if $test -f usethreads.cbu; then
2556                 . ./usethreads.cbu
2557         fi
2558         case "$osname" in
2559         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2560                 # Known thread-capable platforms.
2561                 ;;
2562         *)
2563                 cat >&4 <<EOM
2564 $osname is not known to support threads.
2565 Please let perlbug@perl.com know how to do that.
2566
2567 Cannot continue, aborting.
2568 EOM
2569                 exit 1
2570         ;;
2571         esac # $osname
2572     ;;
2573 esac # $usethreads
2574
2575 cat <<EOM
2576
2577 Perl can be built so that multiple Perl interpreters can coexist
2578 within the same Perl executable.  To do so, Configure must be run with
2579 -Dusemultiplicity.
2580
2581 Normally you do not need this and you should answer no.
2582
2583 EOM
2584 case "$usemultiplicity" in
2585 $define|true|[yY]*)     dflt='y';;
2586 *) dflt='n';;
2587 esac
2588 rp='Build Perl for multiplicity?'
2589 . ./myread
2590 case "$ans" in
2591 y|Y)    val="$define" ;;     
2592 *)      val="$undef" ;;
2593 esac
2594 set usemultiplicity
2595 eval $setvar 
2596
2597 cat <<EOM
2598
2599 Perl can be built to take advantage of explicit 64-bit interfaces,
2600 on some systems.  To do so, Configure must be run with -Duse64bits.
2601
2602 If this doesn't make any sense to you, just accept the default 'n'.
2603 EOM
2604 case "$use64bits" in
2605 $define|true|[yY]*)     dflt='y';;
2606 *) dflt='n';;
2607 esac
2608 rp='Try to use explicit 64-bit interfaces, if available?'
2609 . ./myread
2610 case "$ans" in
2611 y|Y) 
2612         val="$define"
2613         ;;     
2614 *)      
2615         val="$undef"
2616         ;;
2617 esac
2618 set use64bits
2619 eval $setvar
2620
2621 case "$archname64" in
2622 '') archname64='' ;;    # not a typo
2623 esac
2624
2625 case "$use64bits" in
2626 "$define"|true|[yY]*)
2627 : Look for a hint-file generated 'call-back-unit'.  If the
2628 : user has specified that a threading perl is to be built,
2629 : we may need to set or change some other defaults.
2630         if $test -f use64bits.cbu; then
2631                 . ./use64bits.cbu
2632         fi
2633         case "$osname" in
2634         aix|dec_osf|hpux|irix|solaris|unicos)
2635                 # Known 64-bit capable platforms.
2636                 ;;
2637         *)
2638                 cat >&4 <<EOM
2639 $osname is not known to support 64-bit interfaces.
2640 Please let perlbug@perl.com know how to do that.
2641
2642 Cannot continue, aborting.
2643 EOM
2644                 exit 1
2645                 ;;
2646         esac
2647         ;;
2648 esac
2649
2650 : determine the architecture name
2651 echo " "
2652 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2653         tarch=`arch`"-$osname"
2654 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2655         if uname -m > tmparch 2>&1 ; then
2656                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2657                         -e 's/$/'"-$osname/" tmparch`
2658         else
2659                 tarch="$osname"
2660         fi
2661         $rm -f tmparch
2662 else
2663         tarch="$osname"
2664 fi
2665 case "$myarchname" in
2666 ''|"$tarch") ;;
2667 *)
2668         echo "(Your architecture name used to be $myarchname.)"
2669         archname=''
2670         ;;
2671 esac
2672 myarchname="$tarch"
2673 case "$archname" in
2674 '') dflt="$tarch";;
2675 *) dflt="$archname";;
2676 esac
2677 rp='What is your architecture name'
2678 . ./myread
2679 archname="$ans"
2680 case "$usethreads" in
2681 $define)
2682         echo "Threads selected." >&4
2683         case "$archname" in
2684         *-thread*) echo "...and architecture name already has -thread." >&4
2685                 ;;
2686         *)      archname="$archname-thread"
2687                 echo "...setting architecture name to $archname." >&4
2688                 ;;
2689         esac
2690         ;;
2691 esac
2692 case "$usemultiplicity" in
2693 $define)
2694         echo "Multiplicity selected." >&4
2695         case "$archname" in
2696         *-multi*) echo "...and architecture name already has -multi." >&4
2697                 ;;
2698         *)      archname="$archname-multi"
2699                 echo "...setting architecture name to $archname." >&4
2700                 ;;
2701         esac
2702         ;;
2703 esac
2704 case "$use64bits" in
2705 $define)
2706         echo "Explicit 64-bitness selected." >&4
2707         case "$archname64" in
2708         '')
2709                 ;;
2710         *)
2711                 case "$archname" in
2712                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2713                         ;;
2714                 *)      archname="$archname-$archname64"
2715                         echo "...setting architecture name to $archname." >&4
2716                         ;;
2717                 esac
2718                 ;;
2719         esac
2720 esac
2721
2722 : is AFS running?
2723 echo " "
2724 case "$afs" in
2725 $define|true)   afs=true ;;
2726 $undef|false)   afs=false ;;
2727 *)      if test -d /afs; then
2728                 afs=true
2729         else
2730                 afs=false
2731         fi
2732         ;;
2733 esac
2734 if $afs; then
2735         echo "AFS may be running... I'll be extra cautious then..." >&4
2736 else
2737         echo "AFS does not seem to be running..." >&4
2738 fi
2739
2740 : decide how portable to be.  Allow command line overrides.
2741 case "$d_portable" in
2742 "$undef") ;;
2743 *)      d_portable="$define" ;;
2744 esac
2745
2746 : set up shell script to do ~ expansion
2747 cat >filexp <<EOSS
2748 $startsh
2749 : expand filename
2750 case "\$1" in
2751  ~/*|~)
2752         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2753         ;;
2754  ~*)
2755         if $test -f /bin/csh; then
2756                 /bin/csh -f -c "glob \$1"
2757                 failed=\$?
2758                 echo ""
2759                 exit \$failed
2760         else
2761                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2762                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2763                 if $test ! -d "\$dir"; then
2764                         me=\`basename \$0\`
2765                         echo "\$me: can't locate home directory for: \$name" >&2
2766                         exit 1
2767                 fi
2768                 case "\$1" in
2769                 */*)
2770                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2771                         ;;
2772                 *)
2773                         echo \$dir
2774                         ;;
2775                 esac
2776         fi
2777         ;;
2778 *)
2779         echo \$1
2780         ;;
2781 esac
2782 EOSS
2783 chmod +x filexp
2784 $eunicefix filexp
2785
2786 : now set up to get a file name
2787 cat <<EOS >getfile
2788 $startsh
2789 EOS
2790 cat <<'EOSC' >>getfile
2791 tilde=''
2792 fullpath=''
2793 already=''
2794 skip=''
2795 none_ok=''
2796 exp_file=''
2797 nopath_ok=''
2798 orig_rp="$rp"
2799 orig_dflt="$dflt"
2800
2801 case "$fn" in
2802 *\(*)
2803         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2804         fn=`echo $fn | sed 's/(.*)//'`
2805         ;;
2806 esac
2807
2808 case "$fn" in
2809 *:*)
2810         loc_file=`expr $fn : '.*:\(.*\)'`
2811         fn=`expr $fn : '\(.*\):.*'`
2812         ;;
2813 esac
2814
2815 case "$fn" in
2816 *~*) tilde=true;;
2817 esac
2818 case "$fn" in
2819 */*) fullpath=true;;
2820 esac
2821 case "$fn" in
2822 *+*) skip=true;;
2823 esac
2824 case "$fn" in
2825 *n*) none_ok=true;;
2826 esac
2827 case "$fn" in
2828 *e*) exp_file=true;;
2829 esac
2830 case "$fn" in
2831 *p*) nopath_ok=true;;
2832 esac
2833
2834 case "$fn" in
2835 *f*) type='File';;
2836 *d*) type='Directory';;
2837 *l*) type='Locate';;
2838 esac
2839
2840 what="$type"
2841 case "$what" in
2842 Locate) what='File';;
2843 esac
2844
2845 case "$exp_file" in
2846 '')
2847         case "$d_portable" in
2848         "$define") ;;
2849         *) exp_file=true;;
2850         esac
2851         ;;
2852 esac
2853
2854 cd ..
2855 while test "$type"; do
2856         redo=''
2857         rp="$orig_rp"
2858         dflt="$orig_dflt"
2859         case "$tilde" in
2860         true) rp="$rp (~name ok)";;
2861         esac
2862         . UU/myread
2863         if test -f UU/getfile.ok && \
2864                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2865         then
2866                 value="$ans"
2867                 ansexp="$ans"
2868                 break
2869         fi
2870         case "$ans" in
2871         none)
2872                 value=''
2873                 ansexp=''
2874                 case "$none_ok" in
2875                 true) type='';;
2876                 esac
2877                 ;;
2878         *)
2879                 case "$tilde" in
2880                 '') value="$ans"
2881                         ansexp="$ans";;
2882                 *)
2883                         value=`UU/filexp $ans`
2884                         case $? in
2885                         0)
2886                                 if test "$ans" != "$value"; then
2887                                         echo "(That expands to $value on this system.)"
2888                                 fi
2889                                 ;;
2890                         *) value="$ans";;
2891                         esac
2892                         ansexp="$value"
2893                         case "$exp_file" in
2894                         '') value="$ans";;
2895                         esac
2896                         ;;
2897                 esac
2898                 case "$fullpath" in
2899                 true)
2900                         case "$ansexp" in
2901                         /*) value="$ansexp" ;;
2902                         *)
2903                                 redo=true
2904                                 case "$already" in
2905                                 true)
2906                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2907                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2908                                         ;;
2909                                 *)
2910                                 echo "Please give a full path name, starting with slash." >&4
2911                                         case "$tilde" in
2912                                         true)
2913                                 echo "Note that using ~name is ok provided it expands well." >&4
2914                                                 already=true
2915                                                 ;;
2916                                         esac
2917                                 esac
2918                                 ;;
2919                         esac
2920                         ;;
2921                 esac
2922                 case "$redo" in
2923                 '')
2924                         case "$type" in
2925                         File)
2926                                 if test -f "$ansexp"; then
2927                                         type=''
2928                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2929                                 then
2930                                         echo "($value is not a plain file, but that's ok.)"
2931                                         type=''
2932                                 fi
2933                                 ;;
2934                         Directory)
2935                                 if test -d "$ansexp"; then
2936                                         type=''
2937                                 fi
2938                                 ;;
2939                         Locate)
2940                                 if test -d "$ansexp"; then
2941                                         echo "(Looking for $loc_file in directory $value.)"
2942                                         value="$value/$loc_file"
2943                                         ansexp="$ansexp/$loc_file"
2944                                 fi
2945                                 if test -f "$ansexp"; then
2946                                         type=''
2947                                 fi
2948                                 case "$nopath_ok" in
2949                                 true)   case "$value" in
2950                                         */*) ;;
2951                                         *)      echo "Assuming $value will be in people's path."
2952                                                 type=''
2953                                                 ;;
2954                                         esac
2955                                         ;;
2956                                 esac
2957                                 ;;
2958                         esac
2959
2960                         case "$skip" in
2961                         true) type='';
2962                         esac
2963
2964                         case "$type" in
2965                         '') ;;
2966                         *)
2967                                 if test "$fastread" = yes; then
2968                                         dflt=y
2969                                 else
2970                                         dflt=n
2971                                 fi
2972                                 rp="$what $value doesn't exist.  Use that name anyway?"
2973                                 . UU/myread
2974                                 dflt=''
2975                                 case "$ans" in
2976                                 y*) type='';;
2977                                 *) echo " ";;
2978                                 esac
2979                                 ;;
2980                         esac
2981                         ;;
2982                 esac
2983                 ;;
2984         esac
2985 done
2986 cd UU
2987 ans="$value"
2988 rp="$orig_rp"
2989 dflt="$orig_dflt"
2990 rm -f getfile.ok
2991 EOSC
2992
2993 : determine root of directory hierarchy where package will be installed.
2994 case "$prefix" in
2995 '')
2996         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2997         ;;
2998 *)
2999         dflt="$prefix"
3000         ;;
3001 esac
3002 $cat <<EOM
3003
3004 By default, $package will be installed in $dflt/bin, manual
3005 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
3006 all installation directories. Typically set to /usr/local, but you
3007 may choose /usr if you wish to install $package among your system
3008 binaries. If you wish to have binaries under /bin but manual pages
3009 under /usr/local/man, that's ok: you will be prompted separately
3010 for each of the installation directories, the prefix being only used
3011 to set the defaults.
3012
3013 EOM
3014 fn=d~
3015 rp='Installation prefix to use?'
3016 . ./getfile
3017 oldprefix=''
3018 case "$prefix" in
3019 '') ;;
3020 *)
3021         case "$ans" in
3022         "$prefix") ;;
3023         *) oldprefix="$prefix";;
3024         esac
3025         ;;
3026 esac
3027 prefix="$ans"
3028 prefixexp="$ansexp"
3029
3030 : set the prefixit variable, to compute a suitable default value
3031 prefixit='case "$3" in
3032 ""|none)
3033         case "$oldprefix" in
3034         "") eval "$1=\"\$$2\"";;
3035         *)
3036                 case "$3" in
3037                 "") eval "$1=";;
3038                 none)
3039                         eval "tp=\"\$$2\"";
3040                         case "$tp" in
3041                         ""|" ") eval "$1=\"\$$2\"";;
3042                         *) eval "$1=";;
3043                         esac;;
3044                 esac;;
3045         esac;;
3046 *)
3047         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3048         case "$tp" in
3049         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3050         /*-$oldprefix/*|\~*-$oldprefix/*)
3051                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3052         *) eval "$1=\"\$$2\"";;
3053         esac;;
3054 esac'
3055
3056 : set the base revision
3057 baserev=5.0
3058
3059 : get the patchlevel
3060 echo " "
3061 echo "Getting the current patchlevel..." >&4
3062 if $test -r $rsrc/patchlevel.h;then
3063         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3064         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3065 else
3066         patchlevel=0
3067         subversion=0
3068 fi
3069 $echo $n "(You have $package" $c
3070 case "$package" in
3071 "*$baserev")    ;;
3072 *)              $echo $n " $baserev" $c ;;
3073 esac
3074 $echo $n " patchlevel $patchlevel" $c
3075 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3076 echo ".)"
3077
3078 if test 0 -eq "$subversion"; then
3079         version=`LC_ALL=C; export LC_ALL; \
3080                  echo $baserev $patchlevel | \
3081                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3082 else
3083         version=`LC_ALL=C; export LC_ALL; \
3084                  echo $baserev $patchlevel $subversion | \
3085                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3086 fi
3087 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3088 if test "$subversion" -lt 50; then
3089         apiversion=`LC_ALL=C; export LC_ALL; \
3090                  LANGUAGE=C; export LANGUAGE; \
3091                  echo $baserev $patchlevel | \
3092                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3093 else
3094         apiversion="$version"
3095 fi
3096
3097 : determine where private library files go
3098 : Usual default is /usr/local/lib/perl5/$version.
3099 : Also allow things like /opt/perl/lib/$version, since 
3100 : /opt/perl/lib/perl5... would be redundant.
3101 case "$prefix" in
3102 *perl*) set dflt privlib lib/$version ;;
3103 *)       set dflt privlib lib/$package/$version ;;
3104 esac
3105 eval $prefixit
3106 $cat <<EOM
3107
3108 There are some auxiliary files for $package that need to be put into a
3109 private library directory that is accessible by everyone.
3110
3111 EOM
3112 fn=d~+
3113 rp='Pathname where the private library files will reside?'
3114 . ./getfile
3115 if $test "X$privlibexp" != "X$ansexp"; then
3116         installprivlib=''
3117 fi
3118 privlib="$ans"
3119 privlibexp="$ansexp"
3120 if $afs; then
3121         $cat <<EOM
3122
3123 Since you are running AFS, I need to distinguish the directory in which
3124 private files reside from the directory in which they are installed (and from
3125 which they are presumably copied to the former directory by occult means).
3126
3127 EOM
3128         case "$installprivlib" in
3129         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3130         *) dflt="$installprivlib";;
3131         esac
3132         fn=de~
3133         rp='Where will private files be installed?'
3134         . ./getfile
3135         installprivlib="$ans"
3136 else
3137         installprivlib="$privlibexp"
3138 fi
3139
3140 : set the prefixup variable, to restore leading tilda escape
3141 prefixup='case "$prefixexp" in
3142 "$prefix") ;;
3143 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3144 esac'
3145
3146 : determine where public architecture dependent libraries go
3147 set archlib archlib
3148 eval $prefixit
3149 : privlib default is /usr/local/lib/$package/$version
3150 : archlib default is /usr/local/lib/$package/$version/$archname
3151 : privlib may have an optional trailing /share.
3152 tdflt=`echo $privlib | $sed 's,/share$,,'`
3153 tdflt=$tdflt/$archname
3154 case "$archlib" in
3155 '')     dflt=$tdflt
3156         ;;
3157 *)      dflt="$archlib"
3158     ;;
3159 esac
3160 cat <<EOM
3161
3162 $spackage contains architecture-dependent library files.  If you are
3163 sharing libraries in a heterogeneous environment, you might store
3164 these files in a separate location.  Otherwise, you can just include
3165 them with the rest of the public library files.
3166
3167 EOM
3168 fn=d+~
3169 rp='Where do you want to put the public architecture-dependent libraries?'
3170 . ./getfile
3171 archlib="$ans"
3172 archlibexp="$ansexp"
3173
3174 if $afs; then
3175         $cat <<EOM
3176
3177 Since you are running AFS, I need to distinguish the directory in
3178 which architecture-dependent library files reside from the directory
3179 in which they are installed (and from which they are presumably copied
3180 to the former directory by occult means).
3181
3182 EOM
3183         case "$installarchlib" in
3184         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3185         *) dflt="$installarchlib";;
3186         esac
3187         fn=de~
3188         rp='Where will architecture-dependent library files be installed?'
3189         . ./getfile
3190         installarchlib="$ans"
3191 else
3192         installarchlib="$archlibexp"
3193 fi
3194 if $test X"$archlib" = X"$privlib"; then
3195         d_archlib="$undef"
3196 else
3197         d_archlib="$define"
3198 fi
3199
3200 : make some quick guesses about what we are up against
3201 echo " "
3202 $echo $n "Hmm...  $c"
3203 echo exit 1 >bsd
3204 echo exit 1 >usg
3205 echo exit 1 >v7
3206 echo exit 1 >osf1
3207 echo exit 1 >eunice
3208 echo exit 1 >xenix
3209 echo exit 1 >venix
3210 echo exit 1 >os2
3211 d_bsd="$undef"
3212 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3213 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3214 then
3215         echo "Looks kind of like an OSF/1 system, but we'll see..."
3216         echo exit 0 >osf1
3217 elif test `echo abc | tr a-z A-Z` = Abc ; then
3218         xxx=`./loc addbib blurfl $pth`
3219         if $test -f $xxx; then
3220         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3221                 echo exit 0 >bsd
3222                 echo exit 0 >usg
3223         else
3224                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3225                         echo "Looks kind of like an extended USG system, but we'll see..."
3226                 else
3227                         echo "Looks kind of like a USG system, but we'll see..."
3228                 fi
3229                 echo exit 0 >usg
3230         fi
3231 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3232         echo "Looks kind of like a BSD system, but we'll see..."
3233         d_bsd="$define"
3234         echo exit 0 >bsd
3235 else
3236         echo "Looks kind of like a Version 7 system, but we'll see..."
3237         echo exit 0 >v7
3238 fi
3239 case "$eunicefix" in
3240 *unixtovms*)
3241         $cat <<'EOI'
3242 There is, however, a strange, musty smell in the air that reminds me of
3243 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3244 EOI
3245         echo exit 0 >eunice
3246         d_eunice="$define"
3247 : it so happens the Eunice I know will not run shell scripts in Unix format
3248         ;;
3249 *)
3250         echo " "
3251         echo "Congratulations.  You aren't running Eunice."
3252         d_eunice="$undef"
3253         ;;
3254 esac
3255 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3256 case "$p_" in
3257 :) ;;
3258 *)
3259         $cat <<'EOI'
3260 I have the feeling something is not exactly right, however...don't tell me...
3261 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3262 EOI
3263         echo exit 0 >os2
3264         ;;
3265 esac
3266 if test -f /xenix; then
3267         echo "Actually, this looks more like a XENIX system..."
3268         echo exit 0 >xenix
3269         d_xenix="$define"
3270 else
3271         echo " "
3272         echo "It's not Xenix..."
3273         d_xenix="$undef"
3274 fi
3275 chmod +x xenix
3276 $eunicefix xenix
3277 if test -f /venix; then
3278         echo "Actually, this looks more like a VENIX system..."
3279         echo exit 0 >venix
3280 else
3281         echo " "
3282         if ./xenix; then
3283                 : null
3284         else
3285                 echo "Nor is it Venix..."
3286         fi
3287 fi
3288 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3289 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3290 $rm -f foo
3291
3292 : see if setuid scripts can be secure
3293 $cat <<EOM
3294
3295 Some kernels have a bug that prevents setuid #! scripts from being
3296 secure.  Some sites have disabled setuid #! scripts because of this.
3297
3298 First let's decide if your kernel supports secure setuid #! scripts.
3299 (If setuid #! scripts would be secure but have been disabled anyway,
3300 don't say that they are secure if asked.)
3301
3302 EOM
3303
3304 val="$undef"
3305 if $test -d /dev/fd; then
3306         echo "#!$ls" >reflect
3307         chmod +x,u+s reflect
3308         ./reflect >flect 2>&1
3309         if $contains "/dev/fd" flect >/dev/null; then
3310                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3311                 val="$define"
3312         else
3313                 $cat <<EOM
3314 If you are not sure if they are secure, I can check but I'll need a
3315 username and password different from the one you are using right now.
3316 If you don't have such a username or don't want me to test, simply
3317 enter 'none'.
3318
3319 EOM
3320                 rp='Other username to test security of setuid scripts with?'
3321                 dflt='none'
3322                 . ./myread
3323                 case "$ans" in
3324                 n|none)
3325                         case "$d_suidsafe" in
3326                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3327                                 dflt=n;;
3328                         "$undef")
3329                                 echo "Well, the $hint value is *not* secure." >&4
3330                                 dflt=n;;
3331                         *)      echo "Well, the $hint value *is* secure." >&4
3332                                 dflt=y;;
3333                         esac
3334                         ;;
3335                 *)
3336                         $rm -f reflect flect
3337                         echo "#!$ls" >reflect
3338                         chmod +x,u+s reflect
3339                         echo >flect
3340                         chmod a+w flect
3341                         echo '"su" will (probably) prompt you for '"$ans's password."
3342                         su $ans -c './reflect >flect'
3343                         if $contains "/dev/fd" flect >/dev/null; then
3344                                 echo "Okay, it looks like setuid scripts are secure." >&4
3345                                 dflt=y
3346                         else
3347                                 echo "I don't think setuid scripts are secure." >&4
3348                                 dflt=n
3349                         fi
3350                         ;;
3351                 esac
3352                 rp='Does your kernel have *secure* setuid scripts?'
3353                 . ./myread
3354                 case "$ans" in
3355                 [yY]*)  val="$define";;
3356                 *)      val="$undef";;
3357                 esac
3358         fi
3359 else
3360         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3361         echo "(That's for file descriptors, not floppy disks.)"
3362         val="$undef"
3363 fi
3364 set d_suidsafe
3365 eval $setvar
3366
3367 $rm -f reflect flect
3368
3369 : now see if they want to do setuid emulation
3370 echo " "
3371 val="$undef"
3372 case "$d_suidsafe" in
3373 "$define")
3374         val="$undef"
3375         echo "No need to emulate SUID scripts since they are secure here." >& 4
3376         ;;
3377 *)
3378         $cat <<EOM
3379 Some systems have disabled setuid scripts, especially systems where
3380 setuid scripts cannot be secure.  On systems where setuid scripts have
3381 been disabled, the setuid/setgid bits on scripts are currently
3382 useless.  It is possible for $package to detect those bits and emulate
3383 setuid/setgid in a secure fashion.  This emulation will only work if
3384 setuid scripts have been disabled in your kernel.
3385
3386 EOM
3387         case "$d_dosuid" in
3388         "$define") dflt=y ;;
3389         *) dflt=n ;;
3390         esac
3391         rp="Do you want to do setuid/setgid emulation?"
3392         . ./myread
3393         case "$ans" in
3394         [yY]*)  val="$define";;
3395         *)      val="$undef";;
3396         esac
3397         ;;
3398 esac
3399 set d_dosuid
3400 eval $setvar
3401
3402 : determine where manual pages are on this system
3403 echo " "
3404 case "$sysman" in
3405 '') 
3406         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3407         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3408         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3409         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3410         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3411         sysman=`./loc . /usr/man/man1 $syspath`
3412         ;;
3413 esac
3414 if $test -d "$sysman"; then
3415         echo "System manual is in $sysman." >&4
3416 else
3417         echo "Could not find manual pages in source form." >&4
3418 fi
3419
3420 : see what memory models we can support
3421 case "$models" in
3422 '')
3423         $cat >pdp11.c <<'EOP'
3424 int main() {
3425 #ifdef pdp11
3426         exit(0);
3427 #else
3428         exit(1);
3429 #endif
3430 }
3431 EOP
3432         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3433         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3434                 dflt='unsplit split'
3435         else
3436                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3437                 case "$tans" in
3438                 X) dflt='none';;
3439                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3440                                 dflt='small'
3441                         else
3442                                 dflt=''
3443                         fi
3444                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3445                                 dflt="$dflt medium"
3446                         fi
3447                         if $test -d /lib/large || $test -d /usr/lib/large; then
3448                                 dflt="$dflt large"
3449                         fi
3450                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3451                                 dflt="$dflt huge"
3452                         fi
3453                 esac
3454         fi;;
3455 *) dflt="$models";;
3456 esac
3457 $cat <<EOM
3458  
3459 Some systems have different model sizes.  On most systems they are called
3460 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3461 split.  If your system doesn't support different memory models, say "none".
3462 If you wish to force everything to one memory model, say "none" here and
3463 put the appropriate flags later when it asks you for other cc and ld flags.
3464 Venix systems may wish to put "none" and let the compiler figure things out.
3465 (In the following question multiple model names should be space separated.)
3466
3467 The default for most systems is "none".
3468
3469 EOM
3470 rp="Which memory models are supported?"
3471 . ./myread
3472 models="$ans"
3473
3474 case "$models" in
3475 none)
3476         small=''
3477         medium=''
3478         large=''
3479         huge=''
3480         unsplit=''
3481         split=''
3482         ;;
3483 *split)
3484         case "$split" in
3485         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3486                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3487                         dflt='-i'
3488                 else
3489                         dflt='none'
3490                 fi;;
3491         *) dflt="$split";;
3492         esac
3493         rp="What flag indicates separate I and D space?"
3494         . ./myread
3495         tans="$ans"
3496         case "$tans" in
3497         none) tans='';;
3498         esac
3499         split="$tans"
3500         unsplit='';;
3501 *large*|*small*|*medium*|*huge*)
3502         case "$models" in
3503         *large*)
3504                 case "$large" in
3505                 '') dflt='-Ml';;
3506                 *) dflt="$large";;
3507                 esac
3508         rp="What flag indicates large model?"
3509         . ./myread
3510         tans="$ans"
3511         case "$tans" in
3512         none) tans='';
3513         esac
3514         large="$tans";;
3515         *) large='';;
3516         esac
3517         case "$models" in
3518         *huge*) case "$huge" in
3519                 '') dflt='-Mh';;
3520                 *) dflt="$huge";;
3521                 esac
3522                 rp="What flag indicates huge model?"
3523                 . ./myread
3524                 tans="$ans"
3525                 case "$tans" in
3526                 none) tans='';
3527                 esac
3528                 huge="$tans";;
3529         *) huge="$large";;
3530         esac
3531         case "$models" in
3532         *medium*) case "$medium" in
3533                 '') dflt='-Mm';;
3534                 *) dflt="$medium";;
3535                 esac
3536                 rp="What flag indicates medium model?"
3537                 . ./myread
3538                 tans="$ans"
3539                 case "$tans" in
3540                 none) tans='';
3541                 esac
3542                 medium="$tans";;
3543         *) medium="$large";;
3544         esac
3545         case "$models" in
3546         *small*) case "$small" in
3547                 '') dflt='none';;
3548                 *) dflt="$small";;
3549                 esac
3550                 rp="What flag indicates small model?"
3551                 . ./myread
3552                 tans="$ans"
3553                 case "$tans" in
3554                 none) tans='';
3555                 esac
3556                 small="$tans";;
3557         *) small='';;
3558         esac
3559         ;;
3560 *)
3561         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3562         ;;
3563 esac
3564 $rm -f pdp11.* pdp11
3565
3566 : see if we need a special compiler
3567 echo " "
3568 if ./usg; then
3569         case "$cc" in
3570         '') case "$Mcc" in
3571                 /*) dflt='Mcc';;
3572                 *) case "$large" in
3573                         -M*) dflt='cc';;
3574                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3575                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3576                                                 dflt='cc'
3577                                         else
3578                                                 dflt='cc -M'
3579                                         fi
3580                                 else
3581                                         dflt='cc'
3582                                 fi;;
3583                         esac;;
3584                 esac;;
3585         *)  dflt="$cc";;
3586         esac
3587         case "$dflt" in
3588         *M*)    $cat <<'EOM'
3589 On some older systems the default C compiler will not resolve multiple global
3590 references that happen to have the same name.  On some such systems the "Mcc"
3591 command may be used to force these to be resolved.  On other systems a "cc -M"
3592 command is required.  (Note that the -M flag on other systems indicates a
3593 memory model to use!) If you have the Gnu C compiler, you might wish to use
3594 that instead.
3595
3596 EOM
3597         ;;
3598         esac
3599         rp="Use which C compiler?"
3600         . ./myread
3601         cc="$ans"
3602 else
3603         case "$cc" in
3604         '') dflt=cc;;
3605         *) dflt="$cc";;
3606         esac
3607         rp="Use which C compiler?"
3608         . ./myread
3609         cc="$ans"
3610 fi
3611 : Look for a hint-file generated 'call-back-unit'.  Now that the
3612 : user has specified the compiler, we may need to set or change some
3613 : other defaults.
3614 if $test -f cc.cbu; then
3615     . ./cc.cbu
3616 fi
3617 echo " "
3618 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3619 $cat >gccvers.c <<EOM
3620 #include <stdio.h>
3621 int main() {
3622 #ifdef __GNUC__
3623 #ifdef __VERSION__
3624         printf("%s\n", __VERSION__);
3625 #else
3626         printf("%s\n", "1");
3627 #endif
3628 #endif
3629         exit(0);
3630 }
3631 EOM
3632 if $cc -o gccvers gccvers.c; then
3633         gccversion=`./gccvers`
3634         case "$gccversion" in
3635         '') echo "You are not using GNU cc." ;;
3636         *)  echo "You are using GNU cc $gccversion." ;;
3637         esac
3638 else
3639         echo " "
3640         echo "*** WHOA THERE!!! ***" >&4
3641         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3642         case "$knowitall" in
3643         '')
3644         echo "    You'd better start hunting for one and let me know about it." >&4
3645                 exit 1
3646                 ;;
3647         esac
3648 fi
3649 $rm -f gccvers*
3650 case "$gccversion" in
3651 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3652 esac
3653
3654 : What should the include directory be ?
3655 echo " "
3656 $echo $n "Hmm...  $c"
3657 dflt='/usr/include'
3658 incpath=''
3659 mips_type=''
3660 if $test -f /bin/mips && /bin/mips; then
3661         echo "Looks like a MIPS system..."
3662         $cat >usr.c <<'EOCP'
3663 #ifdef SYSTYPE_BSD43
3664 /bsd43
3665 #endif
3666 EOCP
3667         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3668                 dflt='/bsd43/usr/include'
3669                 incpath='/bsd43'
3670                 mips_type='BSD 4.3'
3671         else
3672                 mips_type='System V'
3673         fi
3674         $rm -f usr.c usr.out
3675         echo "and you're compiling with the $mips_type compiler and libraries."
3676         xxx_prompt=y
3677         echo "exit 0" >mips
3678 else
3679         echo "Doesn't look like a MIPS system."
3680         xxx_prompt=n
3681         echo "exit 1" >mips
3682 fi
3683 chmod +x mips
3684 $eunicefix mips
3685 case "$usrinc" in
3686 '') ;;
3687 *) dflt="$usrinc";;
3688 esac
3689 case "$xxx_prompt" in
3690 y)      fn=d/
3691         echo " "
3692         rp='Where are the include files you want to use?'
3693         . ./getfile
3694         usrinc="$ans"
3695         ;;
3696 *)      usrinc="$dflt"
3697         ;;
3698 esac
3699
3700 : see how we invoke the C preprocessor
3701 echo " "
3702 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3703 cat <<'EOT' >testcpp.c
3704 #define ABC abc
3705 #define XYZ xyz
3706 ABC.XYZ
3707 EOT
3708 cd ..
3709 if test ! -f cppstdin; then
3710         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3711 else
3712         echo "Keeping your $hint cppstdin wrapper."
3713 fi
3714 chmod 755 cppstdin
3715 wrapper=`pwd`/cppstdin
3716 ok='false'
3717 cd UU
3718
3719 if $test "X$cppstdin" != "X" && \
3720         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3721         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3722 then
3723         echo "You used to use $cppstdin $cppminus so we'll use that again."
3724         case "$cpprun" in
3725         '') echo "But let's see if we can live without a wrapper..." ;;
3726         *)
3727                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3728                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3729                 then
3730                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3731                         ok='true'
3732                 else
3733                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3734                 fi
3735                 ;;
3736         esac
3737 else
3738         case "$cppstdin" in
3739         '') ;;
3740         *)
3741                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3742                 ;;
3743         esac
3744 fi
3745
3746 if $ok; then
3747         : nothing
3748 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3749         $cc -E <testcpp.c >testcpp.out 2>&1; \
3750         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3751         echo "Yup, it does."
3752         x_cpp="$cc -E"
3753         x_minus='';
3754 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3755         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3756         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3757         echo "Yup, it does."
3758         x_cpp="$cc -E"
3759         x_minus='-';
3760 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3761         $cc -P <testcpp.c >testcpp.out 2>&1; \
3762         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3763         echo "Yipee, that works!"
3764         x_cpp="$cc -P"
3765         x_minus='';
3766 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3767         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3768         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3769         echo "At long last!"
3770         x_cpp="$cc -P"
3771         x_minus='-';
3772 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3773         $cpp <testcpp.c >testcpp.out 2>&1; \
3774         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3775         echo "It works!"
3776         x_cpp="$cpp"
3777         x_minus='';
3778 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3779         $cpp - <testcpp.c >testcpp.out 2>&1; \
3780         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3781         echo "Hooray, it works!  I was beginning to wonder."
3782         x_cpp="$cpp"
3783         x_minus='-';
3784 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3785         $wrapper <testcpp.c >testcpp.out 2>&1; \
3786         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3787         x_cpp="$wrapper"
3788         x_minus=''
3789         echo "Eureka!"
3790 else
3791         dflt=''
3792         rp="No dice.  I can't find a C preprocessor.  Name one:"
3793         . ./myread
3794         x_cpp="$ans"
3795         x_minus=''
3796         $x_cpp <testcpp.c >testcpp.out 2>&1
3797         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3798                 echo "OK, that will do." >&4
3799         else
3800 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3801                 exit 1
3802         fi
3803 fi
3804
3805 case "$ok" in
3806 false)
3807         cppstdin="$x_cpp"
3808         cppminus="$x_minus"
3809         cpprun="$x_cpp"
3810         cpplast="$x_minus"
3811         set X $x_cpp
3812         shift
3813         case "$1" in
3814         "$cpp")
3815                 echo "Perhaps can we force $cc -E using a wrapper..."
3816                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3817                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3818                 then
3819                         echo "Yup, we can."
3820                         cppstdin="$wrapper"
3821                         cppminus='';
3822                 else
3823                         echo "Nope, we'll have to live without it..."
3824                 fi
3825                 ;;
3826         esac
3827         case "$cpprun" in
3828         "$wrapper")
3829                 cpprun=''
3830                 cpplast=''
3831                 ;;
3832         esac
3833         ;;
3834 esac
3835
3836 case "$cppstdin" in
3837 "$wrapper"|'cppstdin') ;;
3838 *) $rm -f $wrapper;;
3839 esac
3840 $rm -f testcpp.c testcpp.out
3841
3842 : Set private lib path
3843 case "$plibpth" in
3844 '') if ./mips; then
3845                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3846         fi;;
3847 esac
3848 case "$libpth" in
3849 ' ') dlist='';;
3850 '') dlist="$loclibpth $plibpth $glibpth";;
3851 *) dlist="$libpth";;
3852 esac
3853
3854 : Now check and see which directories actually exist, avoiding duplicates
3855 libpth=''
3856 for xxx in $dlist
3857 do
3858     if $test -d $xxx; then
3859                 case " $libpth " in
3860                 *" $xxx "*) ;;
3861                 *) libpth="$libpth $xxx";;
3862                 esac
3863     fi
3864 done
3865 $cat <<'EOM'
3866
3867 Some systems have incompatible or broken versions of libraries.  Among
3868 the directories listed in the question below, please remove any you
3869 know not to be holding relevant libraries, and add any that are needed.
3870 Say "none" for none.
3871
3872 EOM
3873 case "$libpth" in
3874 '') dflt='none';;
3875 *)
3876         set X $libpth
3877         shift
3878         dflt=${1+"$@"}
3879         ;;
3880 esac
3881 rp="Directories to use for library searches?"
3882 . ./myread
3883 case "$ans" in
3884 none) libpth=' ';;
3885 *) libpth="$ans";;
3886 esac
3887
3888 : compute shared library extension
3889 case "$so" in
3890 '')
3891         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3892                 dflt='sl'
3893         else
3894                 dflt='so'
3895         fi
3896         ;;
3897 *) dflt="$so";;
3898 esac
3899 $cat <<EOM
3900
3901 On some systems, shared libraries may be available.  Answer 'none' if
3902 you want to suppress searching of shared libraries for the remaining
3903 of this configuration.
3904
3905 EOM
3906 rp='What is the file extension used for shared libraries?'
3907 . ./myread
3908 so="$ans"
3909
3910 : Define several unixisms.
3911 : Hints files or command line option can be used to override them.
3912 : The convoluted testing is in case hints files set either the old
3913 : or the new name.
3914 case "$_exe" in
3915 '')     case "$exe_ext" in
3916     '') ;;
3917         *)      _exe="$exe_ext" ;;
3918         esac
3919         ;;
3920 esac
3921 case "$_a" in
3922 '')     case "$lib_ext" in
3923     '') _a='.a';;
3924         *)      _a="$lib_ext" ;;
3925         esac
3926         ;;
3927 esac
3928 case "$_o" in
3929 '') case "$obj_ext" in
3930         '')     _o='.o';;
3931         *)      _o="$obj_ext";;
3932         esac
3933         ;;
3934 esac
3935 case "$p_" in
3936 '') case "$path_sep" in
3937         '')     p_=':';;
3938         *)      p_="$path_sep";;
3939         esac
3940         ;;
3941 esac
3942 exe_ext=$_exe
3943 lib_ext=$_a
3944 obj_ext=$_o
3945 path_sep=$p_
3946
3947 : Which makefile gets called first.  This is used by make depend.
3948 case "$firstmakefile" in
3949 '') firstmakefile='makefile';;
3950 esac
3951
3952 cat <<EOM
3953
3954 Perl can be built to use the SOCKS proxy protocol library.  To do so,
3955 Configure must be run with -Dusesocks.
3956
3957 Normally you do not need this and you should answer no.
3958
3959 EOM
3960 case "$usesocks" in
3961 $define|true|[yY]*)     dflt='y';;
3962 *) dflt='n';;
3963 esac
3964 rp='Build Perl for SOCKS?'
3965 . ./myread
3966 case "$ans" in
3967 y|Y)    val="$define" ;;     
3968 *)      val="$undef" ;;
3969 esac
3970 set usesocks
3971 eval $setvar
3972
3973 : Looking for optional libraries
3974 echo " "
3975 echo "Checking for optional libraries..." >&4
3976 case "$libs" in
3977 ' '|'') dflt='';;
3978 *) dflt="$libs";;
3979 esac
3980 case "$libswanted" in
3981 '') libswanted='c_s';;
3982 esac
3983 case "$usesocks" in
3984 $define)
3985         libswanted="$libswanted socks5 socks5_sh"
3986         ;;
3987 esac
3988 for thislib in $libswanted; do
3989         
3990         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3991                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3992                 echo "Found -l$thislib (shared)."
3993                 case " $dflt " in
3994                 *"-l$thislib "*);;
3995                 *) dflt="$dflt -l$thislib";;
3996                 esac
3997         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3998                 echo "Found -l$thislib (shared)."
3999                 case " $dflt " in
4000                 *"-l$thislib "*);;
4001                 *) dflt="$dflt -l$thislib";;
4002                 esac
4003         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
4004                 echo "Found -l$thislib."
4005                 case " $dflt " in
4006                 *"-l$thislib "*);;
4007                 *) dflt="$dflt -l$thislib";;
4008                 esac
4009         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
4010                 echo "Found -l$thislib."
4011                 case " $dflt " in
4012                 *"-l$thislib "*);;
4013                 *) dflt="$dflt -l$thislib";;
4014                 esac
4015         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
4016                 echo "Found -l${thislib}_s."
4017                 case " $dflt " in
4018                 *"-l$thislib "*);;
4019                 *) dflt="$dflt -l${thislib}_s";;
4020                 esac
4021         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
4022                 echo "Found -l$thislib."
4023                 case " $dflt " in
4024                 *"-l$thislib "*);;
4025                 *) dflt="$dflt -l$thislib";;
4026                 esac
4027         else
4028                 echo "No -l$thislib."
4029         fi
4030 done
4031 set X $dflt
4032 shift
4033 dflt="$*"
4034 case "$libs" in
4035 '') dflt="$dflt";;
4036 *) dflt="$libs";;
4037 esac
4038 case "$dflt" in
4039 ' '|'') dflt='none';;
4040 esac
4041
4042 $cat <<EOM
4043
4044 In order to compile $package on your machine, a number of libraries
4045 are usually needed.  Include any other special libraries here as well.
4046 Say "none" for none.  The default list is almost always right.
4047 EOM
4048
4049 echo " "
4050 rp="What libraries to use?"
4051 . ./myread
4052 case "$ans" in
4053 none) libs=' ';;
4054 *) libs="$ans";;
4055 esac
4056
4057 : determine optimize, if desired, or use for debug flag also
4058 case "$optimize" in
4059 ' '|$undef) dflt='none';;
4060 '') dflt='-O';;
4061 *) dflt="$optimize";;
4062 esac
4063 $cat <<EOH
4064
4065 Some C compilers have problems with their optimizers.  By default, $package
4066 compiles with the -O flag to use the optimizer.  Alternately, you might want
4067 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4068 systems).  Either flag can be specified here.  To use neither flag, specify
4069 the word "none".
4070
4071 EOH
4072 rp="What optimizer/debugger flag should be used?"
4073 . ./myread
4074 optimize="$ans"
4075 case "$optimize" in
4076 'none') optimize=" ";;
4077 esac
4078
4079 dflt=''
4080 : We will not override a previous value, but we might want to
4081 : augment a hint file
4082 case "$hint" in
4083 none|recommended)
4084         case "$gccversion" in
4085         1*) dflt='-fpcc-struct-return' ;;
4086         esac
4087         case "$optimize" in
4088         *-g*) dflt="$dflt -DDEBUGGING";;
4089         esac
4090         case "$gccversion" in
4091         2*) if test -d /etc/conf/kconfig.d &&
4092                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4093                 then
4094                         dflt="$dflt -posix"
4095                 fi
4096                 ;;
4097         esac
4098         ;;
4099 esac
4100
4101 case "$mips_type" in
4102 *BSD*|'') inclwanted="$locincpth $usrinc";;
4103 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4104 esac
4105 for thisincl in $inclwanted; do
4106         if $test -d $thisincl; then
4107                 if $test x$thisincl != x$usrinc; then
4108                         case "$dflt" in
4109                         *$thisincl*);;
4110                         *) dflt="$dflt -I$thisincl";;
4111                         esac
4112                 fi
4113         fi
4114 done
4115
4116 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4117         xxx=true;
4118 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4119         xxx=true;
4120 else
4121         xxx=false;
4122 fi;
4123 if $xxx; then
4124         case "$dflt" in
4125         *$2*);;
4126         *) dflt="$dflt -D$2";;
4127         esac;
4128 fi'
4129
4130 set signal.h LANGUAGE_C; eval $inctest
4131
4132 case "$usesocks" in
4133 $define)
4134         ccflags="$ccflags -DSOCKS"
4135         ;;
4136 esac
4137
4138 case "$hint" in
4139 none|recommended) dflt="$ccflags $dflt" ;;
4140 *) dflt="$ccflags";;
4141 esac
4142
4143 case "$dflt" in
4144 ''|' ') dflt=none;;
4145 esac
4146 $cat <<EOH
4147
4148 Your C compiler may want other flags.  For this question you should include
4149 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4150 but you should NOT include libraries or ld flags like -lwhatever.  If you
4151 want $package to honor its debug switch, you should include -DDEBUGGING here.
4152 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4153
4154 To use no flags, specify the word "none".
4155
4156 EOH
4157 set X $dflt
4158 shift
4159 dflt=${1+"$@"}
4160 rp="Any additional cc flags?"
4161 . ./myread
4162 case "$ans" in
4163 none) ccflags='';;
4164 *) ccflags="$ans";;
4165 esac
4166
4167 : the following weeds options from ccflags that are of no interest to cpp
4168 cppflags="$ccflags"
4169 case "$gccversion" in
4170 1*) cppflags="$cppflags -D__GNUC__"
4171 esac
4172 case "$mips_type" in
4173 '');;
4174 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4175 esac
4176 case "$cppflags" in
4177 '');;
4178 *)
4179         echo " "
4180         echo "Let me guess what the preprocessor flags are..." >&4
4181         set X $cppflags
4182         shift
4183         cppflags=''
4184         $cat >cpp.c <<'EOM'
4185 #define BLURFL foo
4186
4187 BLURFL xx LFRULB
4188 EOM
4189         previous=''
4190         for flag in $*
4191         do
4192                 case "$flag" in
4193                 -*) ftry="$flag";;
4194                 *) ftry="$previous $flag";;
4195                 esac
4196                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4197                         >cpp1.out 2>/dev/null && \
4198                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4199                         >cpp2.out 2>/dev/null && \
4200                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4201                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4202                 then
4203                         cppflags="$cppflags $ftry"
4204                         previous=''
4205                 else
4206                         previous="$flag"
4207                 fi
4208         done
4209         set X $cppflags
4210         shift
4211         cppflags=${1+"$@"}
4212         case "$cppflags" in
4213         *-*)  echo "They appear to be: $cppflags";;
4214         esac
4215         $rm -f cpp.c cpp?.out
4216         ;;
4217 esac
4218
4219 : flags used in final linking phase
4220 case "$ldflags" in
4221 '') if ./venix; then
4222                 dflt='-i -z'
4223         else
4224                 dflt=''
4225         fi
4226         case "$ccflags" in
4227         *-posix*) dflt="$dflt -posix" ;;
4228         esac
4229         ;;
4230 *) dflt="$ldflags";;
4231 esac
4232
4233 : Try to guess additional flags to pick up local libraries.
4234 for thislibdir in $libpth; do
4235         case " $loclibpth " in
4236         *" $thislibdir "*)
4237                 case "$dflt " in 
4238                 *"-L$thislibdir "*) ;;
4239                 *)  dflt="$dflt -L$thislibdir" ;;
4240                 esac
4241                 ;;
4242         esac
4243 done
4244
4245 case "$dflt" in
4246 '') dflt='none' ;;
4247 esac
4248
4249 $cat <<EOH
4250
4251 Your C linker may need flags.  For this question you should
4252 include -L/whatever and any other flags used by the C linker, but you
4253 should NOT include libraries like -lwhatever.
4254
4255 Make sure you include the appropriate -L/path flags if your C linker
4256 does not normally search all of the directories you specified above,
4257 namely
4258         $libpth
4259 To use no flags, specify the word "none".
4260
4261 EOH
4262
4263 rp="Any additional ld flags (NOT including libraries)?"
4264 . ./myread
4265 case "$ans" in
4266 none) ldflags='';;
4267 *) ldflags="$ans";;
4268 esac
4269 rmlist="$rmlist pdp11"
4270
4271 : coherency check
4272 echo " "
4273 echo "Checking your choice of C compiler and flags for coherency..." >&4
4274 $cat > try.c <<'EOF'
4275 #include <stdio.h>
4276 int main() { printf("Ok\n"); exit(0); }
4277 EOF
4278 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4279 shift
4280 $cat >try.msg <<'EOM'
4281 I've tried to compile and run the following simple program:
4282
4283 EOM
4284 $cat try.c >> try.msg
4285
4286 $cat >> try.msg <<EOM
4287
4288 I used the command:
4289
4290         $*
4291         ./try
4292
4293 and I got the following output:
4294
4295 EOM
4296 dflt=y
4297 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4298         if sh -c './try' >>try.msg 2>&1; then
4299                 xxx=`./try`
4300                 case "$xxx" in
4301                 "Ok") dflt=n ;;
4302                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4303                         case " $libs " in
4304                         *" -lsfio "*)
4305                                 cat >> try.msg <<'EOQS'
4306 If $libs contains -lsfio, and sfio is mis-configured, then it
4307 sometimes (apparently) runs and exits with a 0 status, but with no
4308 output!  It may have to do with sfio's use of _exit vs. exit.
4309
4310 EOQS
4311                                 rp="You have a big problem.  Shall I abort Configure"
4312                                 dflt=y
4313                                 ;;
4314                         esac
4315                         ;;
4316                 esac
4317         else
4318                 echo "The program compiled OK, but exited with status $?." >>try.msg
4319                 rp="You have a problem.  Shall I abort Configure"
4320                 dflt=y
4321         fi
4322 else
4323         echo "I can't compile the test program." >>try.msg
4324         rp="You have a BIG problem.  Shall I abort Configure"
4325         dflt=y
4326 fi
4327 case "$dflt" in
4328 y)
4329         $cat try.msg >&4
4330         case "$knowitall" in
4331         '')
4332                 echo "(The supplied flags or libraries might be incorrect.)"
4333                 ;;
4334         *) dflt=n;;
4335         esac
4336         echo " "
4337         . ./myread
4338         case "$ans" in
4339         n*|N*) ;;
4340         *)      echo "Ok.  Stopping Configure." >&4
4341                 exit 1
4342                 ;;
4343         esac
4344         ;;
4345 n) echo "OK, that should do.";;
4346 esac
4347 $rm -f try try.* core
4348
4349 : determine filename position in cpp output
4350 echo " "
4351 echo "Computing filename position in cpp output for #include directives..." >&4
4352 echo '#include <stdio.h>' > foo.c
4353 $cat >fieldn <<EOF
4354 $startsh
4355 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4356 $grep '^[       ]*#.*stdio\.h' | \
4357 while read cline; do
4358         pos=1
4359         set \$cline
4360         while $test \$# -gt 0; do
4361                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4362                         echo "\$pos"
4363                         exit 0
4364                 fi
4365                 shift
4366                 pos=\`expr \$pos + 1\`
4367         done
4368 done
4369 EOF
4370 chmod +x fieldn
4371 fieldn=`./fieldn`
4372 $rm -f foo.c fieldn
4373 case $fieldn in
4374 '') pos='???';;
4375 1) pos=first;;
4376 2) pos=second;;
4377 3) pos=third;;
4378 *) pos="${fieldn}th";;
4379 esac
4380 echo "Your cpp writes the filename in the $pos field of the line."
4381
4382 : locate header file
4383 $cat >findhdr <<EOF
4384 $startsh
4385 wanted=\$1
4386 name=''
4387 for usrincdir in $usrinc
4388 do
4389         if test -f \$usrincdir/\$wanted; then
4390                 echo "\$usrincdir/\$wanted"
4391                 exit 0
4392         fi
4393 done
4394 awkprg='{ print \$$fieldn }'
4395 echo "#include <\$wanted>" > foo\$\$.c
4396 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4397 $grep "^[       ]*#.*\$wanted" | \
4398 while read cline; do
4399         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4400         case "\$name" in
4401         *[/\\\\]\$wanted) echo "\$name"; exit 1;;
4402         *[\\\\/]\$wanted) echo "\$name"; exit 1;;
4403         *) exit 2;;
4404         esac;
4405 done;
4406 #
4407 # status = 0: grep returned 0 lines, case statement not executed
4408 # status = 1: headerfile found
4409 # status = 2: while loop executed, no headerfile found
4410 #
4411 status=\$?
4412 $rm -f foo\$\$.c;
4413 if test \$status -eq 1; then
4414         exit 0;
4415 fi
4416 exit 1
4417 EOF
4418 chmod +x findhdr
4419
4420 : define an alternate in-header-list? function
4421 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4422 cont=true; xxf="echo \"<\$1> found.\" >&4";
4423 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4424 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4425 esac;
4426 case $# in 4) instead=instead;; *) instead="at last";; esac;
4427 while $test "$cont"; do
4428         xxx=`./findhdr $1`
4429         var=$2; eval "was=\$$2";
4430         if $test "$xxx" && $test -r "$xxx";
4431         then eval $xxf;
4432         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4433                 cont="";
4434         else eval $xxnf;
4435         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4436         set $yyy; shift; shift; yyy=$@;
4437         case $# in 0) cont="";;
4438         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4439                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4440         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4441                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4442         esac;
4443 done;
4444 while $test "$yyy";
4445 do set $yyy; var=$2; eval "was=\$$2";
4446         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4447         set $yyy; shift; shift; yyy=$@;
4448 done'
4449
4450 : see if this is a malloc.h system
4451 set malloc.h i_malloc
4452 eval $inhdr
4453
4454 : see if stdlib is available
4455 set stdlib.h i_stdlib
4456 eval $inhdr
4457
4458 : determine which malloc to compile in
4459 echo " "
4460 case "$usemymalloc" in
4461 ''|[yY]*|true|$define)  dflt='y' ;;
4462 *)      dflt='n' ;;
4463 esac
4464 rp="Do you wish to attempt to use the malloc that comes with $package?"
4465 . ./myread
4466 usemymalloc="$ans"
4467 case "$ans" in
4468 y*|true)
4469         usemymalloc='y'
4470         mallocsrc='malloc.c'
4471         mallocobj="malloc$_o"
4472         d_mymalloc="$define"
4473         case "$libs" in
4474         *-lmalloc*)
4475                 : Remove malloc from list of libraries to use
4476                 echo "Removing unneeded -lmalloc from library list" >&4
4477                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4478                 shift
4479                 libs="$*"
4480                 echo "libs = $libs" >&4
4481                 ;;
4482         esac
4483         ;;
4484 *)
4485         usemymalloc='n'
4486         mallocsrc=''
4487         mallocobj=''
4488         d_mymalloc="$undef"
4489         ;;
4490 esac
4491
4492 : compute the return types of malloc and free
4493 echo " "
4494 $cat >malloc.c <<END
4495 #$i_malloc I_MALLOC
4496 #$i_stdlib I_STDLIB
4497 #include <stdio.h>
4498 #include <sys/types.h>
4499 #ifdef I_MALLOC
4500 #include <malloc.h>
4501 #endif
4502 #ifdef I_STDLIB
4503 #include <stdlib.h>
4504 #endif
4505 #ifdef TRY_MALLOC
4506 void *malloc();
4507 #endif
4508 #ifdef TRY_FREE
4509 void free();
4510 #endif
4511 END
4512 case "$malloctype" in
4513 '')
4514         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4515                 malloctype='void *'
4516         else
4517                 malloctype='char *'
4518         fi
4519         ;;
4520 esac
4521 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4522
4523 case "$freetype" in
4524 '')
4525         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4526                 freetype='void'
4527         else
4528                 freetype='int'
4529         fi
4530         ;;
4531 esac
4532 echo "Your system uses $freetype free(), it would seem." >&4
4533 $rm -f malloc.[co]
4534 : Cruising for prototypes
4535 echo " "
4536 echo "Checking out function prototypes..." >&4
4537 $cat >prototype.c <<'EOCP'
4538 int main(int argc, char *argv[]) {
4539         exit(0);}
4540 EOCP
4541 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4542         echo "Your C compiler appears to support function prototypes."
4543         val="$define"
4544 else
4545         echo "Your C compiler doesn't seem to understand function prototypes."
4546         val="$undef"
4547 fi
4548 set prototype
4549 eval $setvar
4550 $rm -f prototype*
4551
4552 case "$prototype" in
4553 "$define") ;;
4554 *)      ansi2knr='ansi2knr'
4555         echo " "
4556         cat <<EOM >&4
4557
4558 $me:  FATAL ERROR:
4559 This version of $package can only be compiled by a compiler that 
4560 understands function prototypes.  Unfortunately, your C compiler 
4561         $cc $ccflags
4562 doesn't seem to understand them.  Sorry about that.
4563
4564 If GNU cc is available for your system, perhaps you could try that instead.  
4565
4566 Eventually, we hope to support building Perl with pre-ANSI compilers.
4567 If you would like to help in that effort, please contact <perlbug@perl.org>.
4568
4569 Aborting Configure now.
4570 EOM
4571         exit 2
4572         ;;
4573 esac
4574
4575 : determine where public executables go
4576 echo " "
4577 set dflt bin bin
4578 eval $prefixit
4579 fn=d~
4580 rp='Pathname where the public executables will reside?'
4581 . ./getfile
4582 if $test "X$ansexp" != "X$binexp"; then
4583         installbin=''
4584 fi
4585 bin="$ans"
4586 binexp="$ansexp"
4587 if $afs; then
4588         $cat <<EOM
4589
4590 Since you are running AFS, I need to distinguish the directory in which
4591 executables reside from the directory in which they are installed (and from
4592 which they are presumably copied to the former directory by occult means).
4593
4594 EOM
4595         case "$installbin" in
4596         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4597         *) dflt="$installbin";;
4598         esac
4599         fn=de~
4600         rp='Where will public executables be installed?'
4601         . ./getfile
4602         installbin="$ans"
4603 else
4604         installbin="$binexp"
4605 fi
4606
4607 : determine whether to install perl also as /usr/bin/perl
4608
4609 echo " "
4610 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4611         $cat <<EOM
4612 Many scripts expect to perl to be installed as /usr/bin/perl.
4613 I can install the perl you are about to compile also as /usr/bin/perl
4614 (in addition to $installbin/perl).
4615 EOM
4616         case "$installusrbinperl" in
4617         "$undef"|[nN]*) dflt='n';;
4618         *)              dflt='y';;
4619         esac
4620         rp="Do you want to install perl as /usr/bin/perl?"
4621         . ./myread
4622         case "$ans" in
4623         [yY]*)  val="$define";;
4624         *)      val="$undef" ;;
4625         esac
4626 else
4627         val="$undef"
4628 fi
4629 set installusrbinperl
4630 eval $setvar
4631
4632 : define a shorthand compile call
4633 compile='
4634 mc_file=$1;
4635 shift;
4636 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4637 : define a shorthand compile call for compilations that should be ok.
4638 compile_ok='
4639 mc_file=$1;
4640 shift;
4641 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4642
4643 echo " "
4644 echo "Checking for GNU C Library..." >&4
4645 cat >gnulibc.c <<EOM
4646 #include <stdio.h>
4647 int main()
4648 {
4649 #ifdef __GLIBC__
4650     exit(0);
4651 #else
4652     exit(1);
4653 #endif
4654 }
4655 EOM
4656 set gnulibc
4657 if eval $compile_ok && ./gnulibc; then
4658         val="$define"
4659         echo "You are using the GNU C Library"
4660 else
4661         val="$undef"
4662         echo "You are not using the GNU C Library"
4663 fi
4664 $rm -f gnulibc*
4665 set d_gnulibc
4666 eval $setvar
4667
4668 : see if nm is to be used to determine whether a symbol is defined or not
4669 case "$usenm" in
4670 '')
4671         dflt=''
4672         case "$d_gnulibc" in
4673         "$define")
4674                 echo " "
4675                 echo "nm probably won't work on the GNU C Library." >&4
4676                 dflt=n
4677                 ;;
4678         esac
4679         case "$dflt" in
4680         '') 
4681                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4682                         echo " "
4683                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4684                         echo "'nm' won't be sufficient on this sytem." >&4
4685                         dflt=n
4686                 fi
4687                 ;;
4688         esac
4689         case "$dflt" in
4690         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4691                 if $test $dflt -gt 20; then
4692                         dflt=y
4693                 else
4694                         dflt=n
4695                 fi
4696                 ;;
4697         esac
4698         ;;
4699 *)
4700         case "$usenm" in
4701         true|$define) dflt=y;;
4702         *) dflt=n;;
4703         esac
4704         ;;
4705 esac
4706 $cat <<EOM
4707
4708 I can use $nm to extract the symbols from your C libraries. This
4709 is a time consuming task which may generate huge output on the disk (up
4710 to 3 megabytes) but that should make the symbols extraction faster. The
4711 alternative is to skip the 'nm' extraction part and to compile a small
4712 test program instead to determine whether each symbol is present. If
4713 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4714 this may be the best solution.
4715
4716 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4717
4718 EOM
4719 rp="Shall I use $nm to extract C symbols from the libraries?"
4720 . ./myread
4721 case "$ans" in
4722 [Nn]*) usenm=false;;
4723 *) usenm=true;;
4724 esac
4725
4726 runnm=$usenm
4727 case "$reuseval" in
4728 true) runnm=false;;
4729 esac
4730
4731 : nm options which may be necessary
4732 case "$nm_opt" in
4733 '') if $test -f /mach_boot; then
4734                 nm_opt=''       # Mach
4735         elif $test -d /usr/ccs/lib; then
4736                 nm_opt='-p'     # Solaris (and SunOS?)
4737         elif $test -f /dgux; then
4738                 nm_opt='-p'     # DG-UX
4739         elif $test -f /lib64/rld; then
4740                 nm_opt='-p'     # 64-bit Irix
4741         else
4742                 nm_opt=''
4743         fi;;
4744 esac
4745
4746 : nm options which may be necessary for shared libraries but illegal
4747 : for archive libraries.  Thank you, Linux.
4748 case "$nm_so_opt" in
4749 '')     case "$myuname" in
4750         *linux*)
4751                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4752                         nm_so_opt='--dynamic'
4753                 fi
4754                 ;;
4755         esac
4756         ;;
4757 esac
4758
4759 case "$runnm" in
4760 true)
4761 : get list of predefined functions in a handy place
4762 echo " "
4763 case "$libc" in
4764 '') libc=unknown
4765         case "$libs" in
4766         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4767         esac
4768         ;;
4769 esac
4770 libnames='';
4771 case "$libs" in
4772 '') ;;
4773 *)  for thislib in $libs; do
4774         case "$thislib" in
4775         -lc|-lc_s)
4776                 : Handle C library specially below.
4777                 ;;
4778         -l*)
4779                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4780                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4781                         :
4782                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4783                         :
4784                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4785                         :
4786                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4787                         :
4788                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4789                         :
4790                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4791                         :
4792                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4793                         :
4794                 else
4795                         try=''
4796                 fi
4797                 libnames="$libnames $try"
4798                 ;;
4799         *) libnames="$libnames $thislib" ;;
4800         esac
4801         done
4802         ;;
4803 esac
4804 xxx=normal
4805 case "$libc" in
4806 unknown)
4807         set /lib/libc.$so
4808         for xxx in $libpth; do
4809                 $test -r $1 || set $xxx/libc.$so
4810                 : The messy sed command sorts on library version numbers.
4811                 $test -r $1 || \
4812                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4813                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4814                                 h
4815                                 s/[0-9][0-9]*/0000&/g
4816                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4817                                 G
4818                                 s/\n/ /' | \
4819                          sort | $sed -e 's/^.* //'`
4820                 eval set \$$#
4821         done
4822         $test -r $1 || set /usr/ccs/lib/libc.$so
4823         $test -r $1 || set /lib/libsys_s$_a
4824         ;;
4825 *)
4826         set blurfl
4827         ;;
4828 esac
4829 if $test -r "$1"; then
4830         echo "Your (shared) C library seems to be in $1."
4831         libc="$1"
4832 elif $test -r /lib/libc && $test -r /lib/clib; then
4833         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4834         xxx=apollo
4835         libc='/lib/clib /lib/libc'
4836         if $test -r /lib/syslib; then
4837                 echo "(Your math library is in /lib/syslib.)"
4838                 libc="$libc /lib/syslib"
4839         fi
4840 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4841         echo "Your C library seems to be in $libc, as you said before."
4842 elif $test -r $incpath/usr/lib/libc$_a; then
4843         libc=$incpath/usr/lib/libc$_a;
4844         echo "Your C library seems to be in $libc.  That's fine."
4845 elif $test -r /lib/libc$_a; then
4846         libc=/lib/libc$_a;
4847         echo "Your C library seems to be in $libc.  You're normal."
4848 else
4849         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4850                 :
4851         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4852                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4853         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4854                 :
4855         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4856                 :
4857         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4858                 :
4859         else
4860                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4861         fi
4862         if $test -r "$tans"; then
4863                 echo "Your C library seems to be in $tans, of all places."
4864                 libc=$tans
4865         else
4866                 libc='blurfl'
4867         fi
4868 fi
4869 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4870         dflt="$libc"
4871         cat <<EOM
4872
4873 If the guess above is wrong (which it might be if you're using a strange
4874 compiler, or your machine supports multiple models), you can override it here.
4875
4876 EOM
4877 else
4878         dflt=''
4879         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4880         cat >&4 <<EOM
4881 I can't seem to find your C library.  I've looked in the following places:
4882
4883 EOM
4884         $sed 's/^/      /' libpath
4885         cat <<EOM
4886
4887 None of these seems to contain your C library. I need to get its name...
4888
4889 EOM
4890 fi
4891 fn=f
4892 rp='Where is your C library?'
4893 . ./getfile
4894 libc="$ans"
4895
4896 echo " "
4897 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4898 set X `cat libnames`
4899 shift
4900 xxx=files
4901 case $# in 1) xxx=file; esac
4902 echo "Extracting names from the following $xxx for later perusal:" >&4
4903 echo " "
4904 $sed 's/^/      /' libnames >&4
4905 echo " "
4906 $echo $n "This may take a while...$c" >&4
4907
4908 for file in $*; do
4909         case $file in
4910         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4911         *) $nm $nm_opt $file 2>/dev/null;;
4912         esac
4913 done >libc.tmp
4914
4915 $echo $n ".$c"
4916 $grep fprintf libc.tmp > libc.ptf
4917 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4918 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4919 xxx='[ADTSIW]'
4920 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4921         eval $xscan;\
4922         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4923                 eval $xrun
4924 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4925         eval $xscan;\
4926         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4927                 eval $xrun
4928 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4929         eval $xscan;\
4930         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4931                 eval $xrun
4932 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4933         eval $xscan;\
4934         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4935                 eval $xrun
4936 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4937         eval $xscan;\
4938         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4939                 eval $xrun
4940 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4941         eval $xscan;\
4942         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4943                 eval $xrun
4944 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4945                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4946         eval $xscan;\
4947         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4948                 eval $xrun
4949 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4950         eval $xscan;\
4951         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4952                 eval $xrun
4953 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4954         eval $xscan;\
4955         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4956                 eval $xrun
4957 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4958         eval $xscan;\
4959         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4960                 eval $xrun
4961 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4962         eval $xscan;\
4963         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4964                 eval $xrun
4965 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4966         eval $xscan;\
4967         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4968                 eval $xrun
4969 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4970         eval $xscan;\
4971         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4972                 eval $xrun
4973 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4974         eval $xscan;\
4975         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4976                 eval $xrun
4977 else
4978         $nm -p $* 2>/dev/null >libc.tmp
4979         $grep fprintf libc.tmp > libc.ptf
4980         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4981                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4982         then
4983                 nm_opt='-p'
4984                 eval $xrun
4985         else
4986                 echo " "
4987                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4988                 com=''
4989                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4990                         for thisname in $libnames $libc; do
4991                                 $ar t $thisname >>libc.tmp
4992                         done
4993                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4994                         echo "Ok." >&4
4995                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4996                         # Repeat libc to extract forwarders to DLL entries too
4997                         for thisname in $libnames $libc; do
4998                                 $ar tv $thisname >>libc.tmp
4999                                 # Revision 50 of EMX has bug in $ar.
5000                                 # it will not extract forwarders to DLL entries
5001                                 # Use emximp which will extract exactly them.
5002                                 emximp -o tmp.imp $thisname \
5003                                     2>/dev/null && \
5004                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
5005                                     < tmp.imp >>libc.tmp
5006                                 $rm tmp.imp
5007                         done
5008                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
5009                         echo "Ok." >&4
5010                 else
5011                         echo "$ar didn't seem to work right." >&4
5012                         echo "Maybe this is a Cray...trying bld instead..." >&4
5013                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
5014                         then
5015                                 for thisname in $libnames; do
5016                                         bld t $libnames | \
5017                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
5018                                         $ar t $thisname >>libc.tmp
5019                                 done
5020                                 echo "Ok." >&4
5021                         else
5022                                 echo "That didn't work either.  Giving up." >&4
5023                                 exit 1
5024                         fi
5025                 fi
5026         fi
5027 fi
5028 nm_extract="$com"
5029 if $test -f /lib/syscalls.exp; then
5030         echo " "
5031         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
5032         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
5033 fi
5034 ;;
5035 esac
5036 $rm -f libnames libpath
5037
5038 : see if dld is available
5039 set dld.h i_dld
5040 eval $inhdr
5041
5042 : is a C symbol defined?
5043 csym='tlook=$1;
5044 case "$3" in
5045 -v) tf=libc.tmp; tc=""; tdc="";;
5046 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5047 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5048 esac;
5049 tx=yes;
5050 case "$reuseval-$4" in
5051 true-) ;;
5052 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5053 esac;
5054 case "$tx" in
5055 yes)
5056         case "$runnm" in
5057         true)
5058                 if $contains $tlook $tf >/dev/null 2>&1;
5059                 then tval=true;
5060                 else tval=false;
5061                 fi;;
5062         *)
5063                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5064                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5065                 then tval=true;
5066                 else tval=false;
5067                 fi;
5068                 $rm -f t t.c;;
5069         esac;;
5070 *)
5071         case "$tval" in
5072         $define) tval=true;;
5073         *) tval=false;;
5074         esac;;
5075 esac;
5076 eval "$2=$tval"'
5077
5078 : define an is-in-libc? function
5079 inlibc='echo " "; td=$define; tu=$undef;
5080 sym=$1; var=$2; eval "was=\$$2";
5081 tx=yes;
5082 case "$reuseval$was" in
5083 true) ;;
5084 true*) tx=no;;
5085 esac;
5086 case "$tx" in
5087 yes)
5088         set $sym tres -f;
5089         eval $csym;
5090         case "$tres" in
5091         true)
5092                 echo "$sym() found." >&4;
5093                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5094         *)
5095                 echo "$sym() NOT found." >&4;
5096                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5097         esac;;
5098 *)
5099         case "$was" in
5100         $define) echo "$sym() found." >&4;;
5101         *) echo "$sym() NOT found." >&4;;
5102         esac;;
5103 esac'
5104
5105 : see if dlopen exists
5106 xxx_runnm="$runnm"
5107 runnm=false
5108 set dlopen d_dlopen
5109 eval $inlibc
5110 runnm="$xxx_runnm"
5111
5112 : determine which dynamic loading, if any, to compile in
5113 echo " "
5114 dldir="ext/DynaLoader"
5115 case "$usedl" in
5116 $define|y|true)
5117         dflt='y'
5118         usedl="$define"
5119         ;;
5120 $undef|n|false)
5121         dflt='n'
5122         usedl="$undef"
5123         ;;
5124 *) 
5125         dflt='n'
5126         case "$d_dlopen" in
5127             $define) dflt='y' ;;
5128         esac
5129         case "$i_dld" in
5130             $define) dflt='y' ;;
5131         esac
5132         : Does a dl_xxx.xs file exist for this operating system
5133         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5134         ;;
5135 esac
5136 rp="Do you wish to use dynamic loading?"
5137 . ./myread
5138 usedl="$ans"
5139 case "$ans" in
5140 y*) usedl="$define"
5141         case "$dlsrc" in
5142         '')
5143                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5144                         dflt="$dldir/dl_${osname}.xs"
5145                 elif $test "$d_dlopen" = "$define" ; then
5146                         dflt="$dldir/dl_dlopen.xs"
5147                 elif $test "$i_dld" = "$define" ; then
5148                         dflt="$dldir/dl_dld.xs"
5149                 else
5150                         dflt=''
5151                 fi
5152                 ;;
5153         *)      dflt="$dldir/$dlsrc"
5154                 ;;
5155         esac
5156     echo "The following dynamic loading files are available:"
5157         : Can not go over to $dldir because getfile has path hard-coded in.
5158         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5159         rp="Source file to use for dynamic loading"
5160         fn="fne"
5161         # XXX This getfile call will fail the existence check if you try 
5162         # building away from $src (this is not supported yet).
5163         . ./getfile
5164         usedl="$define"
5165         : emulate basename
5166         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5167
5168         $cat << EOM
5169
5170 Some systems may require passing special flags to $cc -c to
5171 compile modules that will be used to create a shared library.
5172 To use no flags, say "none".
5173
5174 EOM
5175     case "$cccdlflags" in
5176     '') case "$gccversion" in
5177                 '') case "$osname" in
5178                         hpux)   dflt='+z' ;;
5179                         next)   dflt='none' ;;
5180                         irix*)  dflt='-KPIC' ;;
5181                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5182                         sunos)  dflt='-pic' ;;
5183                         *)      dflt='none' ;;
5184                     esac
5185                         ;;
5186                 *)  case "$osname" in
5187                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5188                         *)      dflt='-fpic' ;;
5189                     esac ;;
5190             esac ;;
5191         ' ') dflt='none' ;;
5192     *)  dflt="$cccdlflags" ;;
5193     esac
5194     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5195     . ./myread
5196     case "$ans" in
5197     none) cccdlflags=' ' ;;
5198     *) cccdlflags="$ans" ;;
5199     esac
5200
5201     cat << EOM
5202
5203 Some systems use ld to create libraries that can be dynamically loaded,
5204 while other systems (such as those using ELF) use $cc.
5205
5206 EOM
5207         case "$ld" in
5208         '')     $cat >try.c <<'EOM'
5209 /* Test for whether ELF binaries are produced */
5210 #include <fcntl.h>
5211 #include <stdlib.h>
5212 int main() {
5213         char b[4];
5214         int i = open("a.out",O_RDONLY);
5215         if(i == -1) 
5216                 exit(1); /* fail */
5217         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5218                 exit(0); /* succeed (yes, it's ELF) */
5219         else
5220                 exit(1); /* fail */
5221 }
5222 EOM
5223                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5224                         cat <<EOM
5225 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5226 EOM
5227                         dflt="$cc"
5228                 else
5229                         echo "I'll use ld to build dynamic libraries."
5230                         dflt='ld'
5231                 fi
5232                 rm -f try.c a.out
5233                 ;;
5234         *)      dflt="$ld"
5235                 ;;
5236         esac
5237
5238     rp="What command should be used to create dynamic libraries?"
5239     . ./myread
5240         ld="$ans"
5241
5242     cat << EOM
5243
5244 Some systems may require passing special flags to $ld to create a
5245 library that can be dynamically loaded.  If your ld flags include
5246 -L/other/path options to locate libraries outside your loader's normal
5247 search path, you may need to specify those -L options here as well.  To
5248 use no flags, say "none".
5249
5250 EOM
5251     case "$lddlflags" in
5252     '') case "$osname" in
5253                         beos) dflt='-nostart' ;;
5254                         hpux)  dflt='-b' ;;
5255                         linux|irix*)    dflt='-shared' ;;
5256                         next)  dflt='none' ;;
5257                         solaris) dflt='-G' ;;
5258                         sunos) dflt='-assert nodefinitions' ;;
5259                         svr4*|esix*) dflt="-G $ldflags" ;;
5260                 *)     dflt='none' ;;
5261                         esac
5262                         ;;
5263     *) dflt="$lddlflags" ;;
5264     esac
5265
5266         : Try to guess additional flags to pick up local libraries.
5267         : Be careful not to append to a plain 'none'
5268         case "$dflt" in
5269         none) dflt='' ;;
5270         esac
5271         for thisflag in $ldflags; do
5272                 case "$thisflag" in
5273                 -L*)
5274                         case " $dflt " in
5275                         *" $thisflag "*) ;;
5276                         *) dflt="$dflt $thisflag" ;;
5277                         esac
5278                         ;;
5279                 esac
5280         done
5281
5282         case "$dflt" in
5283         ''|' ') dflt='none' ;;
5284         esac
5285
5286     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5287     . ./myread
5288     case "$ans" in
5289     none) lddlflags=' ' ;;
5290     *) lddlflags="$ans" ;;
5291     esac
5292
5293         cat <<EOM
5294
5295 Some systems may require passing special flags to $cc to indicate that
5296 the resulting executable will use dynamic linking.  To use no flags,
5297 say "none".
5298
5299 EOM
5300     case "$ccdlflags" in
5301     '') case "$osname" in
5302                 hpux)   dflt='-Wl,-E' ;;
5303                 linux)  dflt='-rdynamic' ;;
5304                 next)   dflt='none' ;;
5305                 sunos)  dflt='none' ;;
5306                 *)      dflt='none' ;;
5307             esac ;;
5308     ' ')  dflt='none' ;;
5309     *)  dflt="$ccdlflags" ;;
5310     esac
5311     rp="Any special flags to pass to $cc to use dynamic loading?"
5312     . ./myread
5313     case "$ans" in
5314     none) ccdlflags=' ' ;;
5315     *) ccdlflags="$ans" ;;
5316     esac
5317     ;;
5318 *)  usedl="$undef"
5319         ld='ld'
5320     dlsrc='dl_none.xs'
5321     lddlflags=''
5322     ccdlflags=''
5323     ;;
5324 esac
5325
5326 also=''
5327 case "$usedl" in
5328 $undef)
5329         # No dynamic loading being used, so don't bother even to prompt.
5330         useshrplib='false'
5331         ;;
5332 *)      case "$useshrplib" in
5333         '')     case "$osname" in
5334                 svr4*|dgux|dynixptx|esix|powerux|beos)
5335                         dflt=y
5336                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5337                         ;;
5338                 next*)
5339                         case "$osvers" in
5340                         4*)     dflt=y
5341                                 also='Building a shared libperl is needed for MAB support.'
5342                                 ;;
5343                         *)      dflt=n
5344                                 ;;
5345                         esac
5346                         ;;
5347                 *)      dflt=n
5348                         ;;
5349                 esac
5350                 ;;
5351         $define|true|[Yy]*)
5352                 dflt=y
5353                 ;;
5354         *)      dflt=n
5355                 ;;
5356         esac
5357         $cat << EOM
5358
5359 The perl executable is normally obtained by linking perlmain.c with
5360 libperl${_a}, any static extensions (usually just DynaLoader), and
5361 any other libraries needed on this system (such as -lm, etc.).  Since
5362 your system supports dynamic loading, it is probably possible to build
5363 a shared libperl.$so.  If you will have more than one executable linked
5364 to libperl.$so, this will significantly reduce the size of each
5365 executable, but it may have a noticeable affect on performance.  The
5366 default is probably sensible for your system.
5367 $also
5368
5369 EOM
5370         rp="Build a shared libperl.$so (y/n)"
5371         . ./myread
5372         case "$ans" in
5373         true|$define|[Yy]*)
5374                 useshrplib='true'  ;;
5375         *)      useshrplib='false' ;;
5376         esac
5377         ;;
5378 esac
5379
5380 case "$useshrplib" in
5381 true)
5382         case "$libperl" in
5383         '')
5384                 # Figure out a good name for libperl.so.  Since it gets stored in
5385                 # a version-specific architecture-dependent library, the version
5386                 # number isn't really that important, except for making cc/ld happy.
5387                 #
5388                 # A name such as libperl.so.3.1
5389                 majmin="libperl.$so.$patchlevel.$subversion"
5390                 # A name such as libperl.so.301
5391                 majonly=`echo $patchlevel $subversion |
5392                         $awk '{printf "%d%02d", $1, $2}'`
5393                 majonly=libperl.$so.$majonly
5394                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5395                 # rely on figuring it out from the naming of libc.
5396                 case "${osname}${osvers}" in
5397                 next4*)
5398                         dflt=libperl.5.$so
5399                         # XXX How handle the --version stuff for MAB?
5400                         ;;
5401                 linux*)  # ld won't link with a bare -lperl otherwise.
5402                         dflt=libperl.$so
5403                         ;;
5404                 *)      # Try to guess based on whether libc has major.minor.
5405                         case "$libc" in
5406                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5407                         *libc.$so.[0-9]*) dflt=$majonly ;;
5408                         *)      dflt=libperl.$so ;;
5409                         esac
5410                         ;;
5411                 esac
5412                 ;;
5413         *)      dflt=$libperl
5414                 ;;
5415         esac
5416         cat << EOM
5417
5418 I need to select a good name for the shared libperl.  If your system uses
5419 library names with major and minor numbers, then you might want something
5420 like $majmin.  Alternatively, if your system uses a single version
5421 number for shared libraries, then you might want to use $majonly.
5422 Or, your system might be quite happy with a simple libperl.$so.
5423
5424 Since the shared libperl will get installed into a version-specific
5425 architecture-dependent directory, the version number of the shared perl
5426 library probably isn't important, so the default should be o.k.
5427
5428 EOM
5429         rp='What name do you want to give to the shared libperl?'
5430         . ./myread
5431         libperl=$ans
5432         echo "Ok, I'll use $libperl"
5433         ;;
5434 *)
5435         libperl="libperl${_a}"
5436         ;;
5437 esac
5438
5439 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5440 case "$shrpdir" in
5441 '') ;;
5442 *)      $cat >&4 <<EOM
5443 WARNING:  Use of the shrpdir variable for the installation location of
5444 the shared $libperl is not supported.  It was never documented and
5445 will not work in this version.  Let me (perlbug@perl.com)
5446 know of any problems this may cause.
5447
5448 EOM
5449         case "$shrpdir" in
5450         "$archlibexp/CORE")
5451                 $cat >&4 <<EOM
5452 But your current setting of $shrpdir is
5453 the default anyway, so it's harmless.
5454 EOM
5455                 ;;
5456         *)
5457                 $cat >&4 <<EOM
5458 Further, your current attempted setting of $shrpdir
5459 conflicts with the value of $archlibexp/CORE
5460 that installperl will use.
5461 EOM
5462                 ;;
5463         esac
5464         ;;
5465 esac
5466
5467 # How will the perl executable find the installed shared $libperl?
5468 # Add $xxx to ccdlflags.
5469 # If we can't figure out a command-line option, use $shrpenv to
5470 # set env LD_RUN_PATH.  The main perl makefile uses this.
5471 shrpdir=$archlibexp/CORE
5472 xxx=''
5473 tmp_shrpenv=''
5474 if "$useshrplib"; then
5475     case "$osname" in 
5476         aix)
5477                 # We'll set it in Makefile.SH...
5478                 ;;
5479         solaris|netbsd)
5480                 xxx="-R $shrpdir"
5481                 ;;
5482         freebsd)
5483                 xxx="-Wl,-R$shrpdir"
5484                 ;;
5485         linux|irix*|dec_osf)
5486                 xxx="-Wl,-rpath,$shrpdir"
5487                 ;;
5488         next)
5489                 # next doesn't like the default...
5490                 ;;
5491         beos)
5492                 # beos doesn't like the default, either.
5493                 ;;
5494         hpux*)
5495                 # hpux doesn't like the default, either.
5496                 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
5497                 ;;
5498         *)
5499                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5500                 ;;
5501         esac
5502         case "$xxx" in
5503         '') ;;
5504         *)      
5505                 # Only add $xxx if it isn't already in ccdlflags.
5506                 case " $ccdlflags " in
5507                 *" $xxx "*)     ;;
5508                 *)      ccdlflags="$ccdlflags $xxx"
5509                         cat <<EOM >&4
5510
5511 Adding $xxx to the flags
5512 passed to $ld so that the perl executable will find the 
5513 installed shared $libperl.
5514
5515 EOM
5516                         ;;
5517                 esac
5518                 ;;
5519         esac
5520 fi
5521 # Fix ccdlflags in AIX for building external extensions.
5522 # (For building Perl itself bare -bE:perl.exp is needed,
5523 #  Makefile.SH takes care of this.)
5524 case "$osname" in
5525 aix) ccdlflags="$ccdlflags -bE:$installarchlib/CORE/perl.exp" ;;
5526 esac
5527 # Respect a hint or command-line value.
5528 case "$shrpenv" in
5529 '') shrpenv="$tmp_shrpenv" ;;
5530 esac
5531 case "$ldlibpthname" in
5532 '')     ldlibpthname=LD_LIBRARY_PATH ;;
5533 none)   ldlibpthname='' ;;
5534 esac
5535
5536 : determine where manual pages go
5537 set man1dir man1dir none
5538 eval $prefixit
5539 $cat <<EOM
5540
5541 $spackage has manual pages available in source form.
5542 EOM
5543 case "$nroff" in
5544 nroff)
5545         echo "However, you don't have nroff, so they're probably useless to you."
5546         case "$man1dir" in
5547         '') man1dir="none";;
5548         esac;;
5549 esac
5550 echo "If you don't want the manual sources installed, answer 'none'."
5551 case "$man1dir" in
5552 ' ') dflt=none
5553         ;;
5554 '')
5555         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5556         lookpath="$lookpath $prefixexp/man/p_man/man1"
5557         lookpath="$lookpath $prefixexp/man/u_man/man1"
5558         lookpath="$lookpath $prefixexp/man/man.1"
5559         case "$sysman" in
5560         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5561         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5562         esac
5563         set dflt
5564         eval $prefixup
5565         ;;
5566 *)  dflt="$man1dir"
5567         ;;
5568 esac
5569 echo " "
5570 fn=dn+~
5571 rp="Where do the main $spackage manual pages (source) go?"
5572 . ./getfile
5573 if $test "X$man1direxp" != "X$ansexp"; then
5574         installman1dir=''
5575 fi
5576 man1dir="$ans"
5577 man1direxp="$ansexp"
5578 case "$man1dir" in
5579 '') man1dir=' '
5580         installman1dir='';;
5581 esac
5582 if $afs; then
5583         $cat <<EOM
5584
5585 Since you are running AFS, I need to distinguish the directory in which
5586 manual pages reside from the directory in which they are installed (and from
5587 which they are presumably copied to the former directory by occult means).
5588
5589 EOM
5590         case "$installman1dir" in
5591         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5592         *) dflt="$installman1dir";;
5593         esac
5594         fn=de~
5595         rp='Where will man pages be installed?'
5596         . ./getfile
5597         installman1dir="$ans"
5598 else
5599         installman1dir="$man1direxp"
5600 fi
5601
5602 : What suffix to use on installed man pages
5603
5604 case "$man1dir" in
5605 ' ')
5606         man1ext='0'
5607         ;;
5608 *)
5609         rp="What suffix should be used for the main $spackage man pages?"
5610         case "$man1ext" in
5611         '')     case "$man1dir" in
5612                 *1)  dflt=1 ;;
5613                 *1p) dflt=1p ;;
5614                 *1pm) dflt=1pm ;;
5615                 *l) dflt=l;;
5616                 *n) dflt=n;;
5617                 *o) dflt=o;;
5618                 *p) dflt=p;;
5619                 *C) dflt=C;;
5620                 *L) dflt=L;;
5621                 *L1) dflt=L1;;
5622                 *) dflt=1;;
5623                 esac
5624                 ;;
5625         *)      dflt="$man1ext";;
5626         esac
5627         . ./myread
5628         man1ext="$ans"
5629         ;;
5630 esac
5631
5632 : see if we can have long filenames
5633 echo " "
5634 rmlist="$rmlist /tmp/cf$$"
5635 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5636 first=123456789abcdef
5637 second=/tmp/cf$$/$first
5638 $rm -f $first $second
5639 if (echo hi >$first) 2>/dev/null; then
5640         if $test -f 123456789abcde; then
5641                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5642                 val="$undef"
5643         else
5644                 if (echo hi >$second) 2>/dev/null; then
5645                         if $test -f /tmp/cf$$/123456789abcde; then
5646                                 $cat <<'EOM'
5647 That's peculiar... You can have filenames longer than 14 characters, but only
5648 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5649 I shall consider your system cannot support long filenames at all.
5650 EOM
5651                                 val="$undef"
5652                         else
5653                                 echo 'You can have filenames longer than 14 characters.' >&4
5654                                 val="$define"
5655                         fi
5656                 else
5657                         $cat <<'EOM'
5658 How confusing! Some of your filesystems are sane enough to allow filenames
5659 longer than 14 characters but some others like /tmp can't even think about them.
5660 So, for now on, I shall assume your kernel does not allow them at all.
5661 EOM
5662                         val="$undef"
5663                 fi
5664         fi
5665 else
5666         $cat <<'EOM'
5667 You can't have filenames longer than 14 chars.  You can't even think about them!
5668 EOM
5669         val="$undef"
5670 fi 
5671 set d_flexfnam
5672 eval $setvar
5673 $rm -rf /tmp/cf$$ 123456789abcde*
5674
5675 : determine where library module manual pages go
5676 set man3dir man3dir none
5677 eval $prefixit
5678 $cat <<EOM
5679
5680 $spackage has manual pages for many of the library modules.
5681 EOM
5682
5683 case "$nroff" in
5684 nroff)
5685         $cat <<'EOM'
5686 However, you don't have nroff, so they're probably useless to you.
5687 EOM
5688         case "$man3dir" in
5689         '') man3dir="none";;
5690         esac;;
5691 esac
5692
5693 case "$d_flexfnam" in
5694 undef)
5695         $cat <<'EOM'
5696 However, your system can't handle the long file names like File::Basename.3. 
5697 EOM
5698         case "$man3dir" in
5699         '') man3dir="none";;
5700         esac;;
5701 esac
5702
5703 echo "If you don't want the manual sources installed, answer 'none'."
5704 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5705 case "$man3dir" in
5706 '')     case "$prefix" in 
5707         *$prog*) dflt=`echo $man1dir | 
5708                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5709         *)      dflt="$privlib/man/man3" ;;
5710         esac
5711         ;;
5712 ' ') dflt=none;;
5713 *)      dflt="$man3dir" ;;
5714 esac
5715 echo " "
5716
5717 fn=dn+~
5718 rp="Where do the $package library man pages (source) go?"
5719 . ./getfile
5720 if test "X$man3direxp" != "X$ansexp"; then
5721         installman3dir=''
5722 fi
5723
5724 man3dir="$ans"
5725 man3direxp="$ansexp"
5726 case "$man3dir" in
5727 '') man3dir=' '
5728         installman3dir='';;
5729 esac
5730 if $afs; then
5731         $cat <<EOM
5732
5733 Since you are running AFS, I need to distinguish the directory in which
5734 manual pages reside from the directory in which they are installed (and from
5735 which they are presumably copied to the former directory by occult means).
5736
5737 EOM
5738         case "$installman3dir" in
5739         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5740         *) dflt="$installman3dir";;
5741         esac
5742         fn=de~
5743         rp='Where will man pages be installed?'
5744         . ./getfile
5745         installman3dir="$ans"
5746 else
5747         installman3dir="$man3direxp"
5748 fi
5749
5750 : What suffix to use on installed man pages
5751
5752 case "$man3dir" in
5753 ' ')
5754         man3ext='0'
5755         ;;
5756 *)
5757         rp="What suffix should be used for the $package library man pages?"
5758         case "$man3ext" in
5759         '')     case "$man3dir" in
5760                 *3)  dflt=3 ;;
5761                 *3p) dflt=3p ;;
5762                 *3pm) dflt=3pm ;;
5763                 *l) dflt=l;;
5764                 *n) dflt=n;;
5765                 *o) dflt=o;;
5766                 *p) dflt=p;;
5767                 *C) dflt=C;;
5768                 *L) dflt=L;;
5769                 *L3) dflt=L3;;
5770                 *) dflt=3;;
5771                 esac
5772                 ;;
5773         *)      dflt="$man3ext";;
5774         esac
5775         . ./myread
5776         man3ext="$ans"
5777         ;;
5778 esac
5779
5780 : see if we have to deal with yellow pages, now NIS.
5781 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5782         if $test -f /usr/etc/nibindd; then
5783                 echo " "
5784                 echo "I'm fairly confident you're on a NeXT."
5785                 echo " "
5786                 rp='Do you get the hosts file via NetInfo?'
5787                 dflt=y
5788                 case "$hostcat" in
5789                 nidump*) ;;
5790                 '') ;;
5791                 *) dflt=n;;
5792                 esac
5793                 . ./myread
5794                 case "$ans" in
5795                 y*) hostcat='nidump hosts .';;
5796                 *)      case "$hostcat" in
5797                         nidump*) hostcat='';;
5798                         esac
5799                         ;;
5800                 esac
5801         fi
5802         case "$hostcat" in
5803         nidump*) ;;
5804         *)
5805                 case "$hostcat" in
5806                 *ypcat*) dflt=y;;
5807                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5808                                 dflt=y
5809                         else
5810                                 dflt=n
5811                         fi;;
5812                 *) dflt=n;;
5813                 esac
5814                 echo " "
5815                 rp='Are you getting the hosts file via yellow pages?'
5816                 . ./myread
5817                 case "$ans" in
5818                 y*) hostcat='ypcat hosts';;
5819                 *) hostcat='cat /etc/hosts';;
5820                 esac
5821                 ;;
5822         esac
5823 fi
5824 case "$hostcat" in
5825 '') hostcat='cat /etc/hosts';;
5826 esac
5827 case "$groupcat" in
5828 '') groupcat='cat /etc/group';;
5829 esac
5830 case "$passcat" in
5831 '') passcat='cat /etc/passwd';;
5832 esac
5833
5834 : now get the host name
5835 echo " "
5836 echo "Figuring out host name..." >&4
5837 case "$myhostname" in
5838 '') cont=true
5839         echo 'Maybe "hostname" will work...'
5840         if tans=`sh -c hostname 2>&1` ; then
5841                 myhostname=$tans
5842                 phostname=hostname
5843                 cont=''
5844         fi
5845         ;;
5846 *) cont='';;
5847 esac
5848 if $test "$cont"; then
5849         if ./xenix; then
5850                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5851                 if tans=`cat /etc/systemid 2>&1` ; then
5852                         myhostname=$tans
5853                         phostname='cat /etc/systemid'
5854                         echo "Whadyaknow.  Xenix always was a bit strange..."
5855                         cont=''
5856                 fi
5857         elif $test -r /etc/systemid; then
5858                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5859         fi
5860 fi
5861 if $test "$cont"; then
5862         echo 'No, maybe "uuname -l" will work...'
5863         if tans=`sh -c 'uuname -l' 2>&1` ; then
5864                 myhostname=$tans
5865                 phostname='uuname -l'
5866         else
5867                 echo 'Strange.  Maybe "uname -n" will work...'
5868                 if tans=`sh -c 'uname -n' 2>&1` ; then
5869                         myhostname=$tans
5870                         phostname='uname -n'
5871                 else
5872                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5873                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5874                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5875                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5876                         else
5877                                 case "$myhostname" in
5878                                 '') echo "Does this machine have an identity crisis or something?"
5879                                         phostname='';;
5880                                 *)
5881                                         echo "Well, you said $myhostname before..."
5882                                         phostname='echo $myhostname';;
5883                                 esac
5884                         fi
5885                 fi
5886         fi
5887 fi
5888 : you do not want to know about this
5889 set $myhostname
5890 myhostname=$1
5891
5892 : verify guess
5893 if $test "$myhostname" ; then
5894         dflt=y
5895         rp='Your host name appears to be "'$myhostname'".'" Right?"
5896         . ./myread
5897         case "$ans" in
5898         y*) ;;
5899         *) myhostname='';;
5900         esac
5901 fi
5902
5903 : bad guess or no guess
5904 while $test "X$myhostname" = X ; do
5905         dflt=''
5906         rp="Please type the (one word) name of your host:"
5907         . ./myread
5908         myhostname="$ans"
5909 done
5910
5911 : translate upper to lower if necessary
5912 case "$myhostname" in
5913 *[A-Z]*)
5914         echo "(Normalizing case in your host name)"
5915         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5916         ;;
5917 esac
5918
5919 case "$myhostname" in
5920 *.*)
5921         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5922         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5923         echo "(Trimming domain name from host name--host name is now $myhostname)"
5924         ;;
5925 *) case "$mydomain" in
5926         '')
5927                 {
5928                         test "X$hostcat" = "Xypcat hosts" &&
5929                         ypmatch "$myhostname" hosts 2>/dev/null |\
5930                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5931                         $test -s hosts
5932                 } || {
5933                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5934                                         /[       ]$myhostname[  . ]/p" > hosts
5935                 }
5936                 tmp_re="[       . ]"
5937                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5938                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5939                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5940                         hosts | $sort | $uniq | \
5941                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5942                 case `$echo X$dflt` in
5943                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5944                         dflt=.
5945                         ;;
5946                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5947                         ;;
5948                 esac
5949                 case "$dflt" in
5950                 .)
5951                         tans=`./loc resolv.conf X /etc /usr/etc`
5952                         if $test -f "$tans"; then
5953                                 echo "(Attempting domain name extraction from $tans)"
5954                                 dflt=.`$sed -n -e 's/   / /g' \
5955                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5956                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5957                                 case "$dflt" in
5958                                 .) dflt=.`$sed -n -e 's/        / /g' \
5959                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5960                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5961                                         ;;
5962                                 esac
5963                         fi
5964                         ;;
5965                 esac
5966                 case "$dflt" in
5967                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5968                         dflt=.`sh -c domainname 2>/dev/null`
5969                         case "$dflt" in
5970                         '') dflt='.';;
5971                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5972                         esac
5973                         ;;
5974                 esac
5975                 case "$dflt" in
5976                 .) echo "(Lost all hope -- silly guess then)"
5977                         dflt='.uucp'
5978                         ;;
5979                 esac
5980                 $rm -f hosts
5981                 ;;
5982         *) dflt="$mydomain";;
5983         esac;;
5984 esac
5985 echo " "
5986 rp="What is your domain name?"
5987 . ./myread
5988 tans="$ans"
5989 case "$ans" in
5990 '') ;;
5991 .*) ;;
5992 *) tans=".$tans";;
5993 esac
5994 mydomain="$tans"
5995
5996 : translate upper to lower if necessary
5997 case "$mydomain" in
5998 *[A-Z]*)
5999         echo "(Normalizing case in your domain name)"
6000         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
6001         ;;
6002 esac
6003
6004 : a little sanity check here
6005 case "$phostname" in
6006 '') ;;
6007 *)
6008         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
6009         $myhostname$mydomain|$myhostname) ;;
6010         *)
6011                 case "$phostname" in
6012                 sed*)
6013                         echo "(That doesn't agree with your whoami.h file, by the way.)"
6014                         ;;
6015                 *)
6016                         echo "(That doesn't agree with your $phostname command, by the way.)"
6017                         ;;
6018                 esac
6019         ;;
6020         esac
6021         ;;
6022 esac
6023
6024 $cat <<EOM
6025
6026 I need to get your e-mail address in Internet format if possible, i.e.
6027 something like user@host.domain. Please answer accurately since I have
6028 no easy means to double check it. The default value provided below
6029 is most probably close to the reality but may not be valid from outside
6030 your organization...
6031
6032 EOM
6033 cont=x
6034 while test "$cont"; do
6035         case "$cf_email" in
6036         '') dflt="$cf_by@$myhostname$mydomain";;
6037         *) dflt="$cf_email";;
6038         esac
6039         rp='What is your e-mail address?'
6040         . ./myread
6041         cf_email="$ans"
6042         case "$cf_email" in
6043         *@*.*) cont='' ;;
6044         *)
6045                 rp='Address does not look like an Internet one.  Use it anyway?'
6046                 case "$fastread" in
6047                 yes) dflt=y ;;
6048                 *) dflt=n ;;
6049                 esac
6050                 . ./myread
6051                 case "$ans" in
6052                 y*) cont='' ;;
6053                 *) echo " " ;;
6054                 esac
6055                 ;;
6056         esac
6057 done
6058
6059 $cat <<EOM
6060
6061 If you or somebody else will be maintaining perl at your site, please
6062 fill in the correct e-mail address here so that they may be contacted
6063 if necessary. Currently, the "perlbug" program included with perl
6064 will send mail to this address in addition to perlbug@perl.com. You may
6065 enter "none" for no administrator.
6066
6067 EOM
6068 case "$perladmin" in
6069 '') dflt="$cf_email";;
6070 *) dflt="$perladmin";;
6071 esac
6072 rp='Perl administrator e-mail address'
6073 . ./myread
6074 perladmin="$ans"
6075
6076 : figure out how to guarantee perl startup
6077 case "$startperl" in
6078 '')
6079         case "$sharpbang" in
6080         *!)
6081                 $cat <<EOH
6082
6083 I can use the #! construct to start perl on your system. This will
6084 make startup of perl scripts faster, but may cause problems if you
6085 want to share those scripts and perl is not in a standard place
6086 ($binexp/perl) on all your platforms. The alternative is to force
6087 a shell by starting the script with a single ':' character.
6088
6089 EOH
6090                 dflt="$binexp/perl"
6091                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6092                 . ./myread
6093                 case "$ans" in
6094                 none)   startperl=": # use perl";;
6095                 *)      startperl="#!$ans"
6096                         if $test 30 -lt `echo "$ans" | wc -c`; then
6097                                 $cat >&4 <<EOM
6098
6099 WARNING:  Some systems limit the #! command to 32 characters.
6100 If you experience difficulty running Perl scripts with #!, try
6101 installing Perl in a directory with a shorter pathname.
6102
6103 EOM
6104                         fi ;;
6105                 esac
6106                 ;;
6107         *) startperl=": # use perl"
6108                 ;;
6109         esac
6110         ;;
6111 esac
6112 echo "I'll use $startperl to start perl scripts."
6113
6114 : figure best path for perl in scripts
6115 case "$perlpath" in
6116 '')
6117         perlpath="$binexp/perl"
6118         case "$startperl" in
6119         *!*) ;;
6120         *)
6121                 $cat <<EOH
6122
6123 I will use the "eval 'exec'" idiom to start Perl on your system.
6124 I can use the full path of your Perl binary for this purpose, but
6125 doing so may cause problems if you want to share those scripts and
6126 Perl is not always in a standard place ($binexp/perl).
6127
6128 EOH
6129                 dflt="$binexp/perl"
6130                 rp="What path shall I use in \"eval 'exec'\"?"
6131                 . ./myread
6132                 perlpath="$ans"
6133                 ;;
6134         esac
6135         ;;
6136 esac
6137 case "$startperl" in
6138 *!*)    ;;
6139 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6140 esac
6141
6142 : determine where public executable scripts go
6143 set scriptdir scriptdir
6144 eval $prefixit
6145 case "$scriptdir" in
6146 '')
6147         dflt="$bin"
6148         : guess some guesses
6149         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6150         $test -d /usr/share/bin && dflt=/usr/share/bin
6151         $test -d /usr/local/script && dflt=/usr/local/script
6152         $test -d $prefixexp/script && dflt=$prefixexp/script
6153         set dflt
6154         eval $prefixup
6155         ;;
6156 *)  dflt="$scriptdir"
6157         ;;
6158 esac
6159 $cat <<EOM
6160  
6161 Some installations have a separate directory just for executable scripts so
6162 that they can mount it across multiple architectures but keep the scripts in
6163 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6164 Or you might just lump your scripts in with all your other executables.
6165  
6166 EOM
6167 fn=d~
6168 rp='Where do you keep publicly executable scripts?'
6169 . ./getfile
6170 if $test "X$ansexp" != "X$scriptdirexp"; then
6171         installscript=''
6172 fi
6173 scriptdir="$ans"
6174 scriptdirexp="$ansexp"
6175 if $afs; then
6176         $cat <<EOM
6177
6178 Since you are running AFS, I need to distinguish the directory in which
6179 scripts reside from the directory in which they are installed (and from
6180 which they are presumably copied to the former directory by occult means).
6181
6182 EOM
6183         case "$installscript" in
6184         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6185         *) dflt="$installscript";;
6186         esac
6187         fn=de~
6188         rp='Where will public scripts be installed?'
6189         . ./getfile
6190         installscript="$ans"
6191 else
6192         installscript="$scriptdirexp"
6193 fi
6194
6195 : determine where site specific libraries go.
6196 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6197 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6198 case "$prefix" in
6199 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6200 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6201 esac
6202 eval $prefixit
6203 $cat <<EOM
6204
6205 The installation process will also create a directory for
6206 site-specific extensions and modules.  Some users find it convenient
6207 to place all site-specific files in this directory rather than in the
6208 main distribution directory.
6209
6210 EOM
6211 fn=d~+
6212 rp='Pathname for the site-specific library files?'
6213 . ./getfile
6214 if $test "X$sitelibexp" != "X$ansexp"; then
6215         installsitelib=''
6216 fi
6217 sitelib="$ans"
6218 sitelibexp="$ansexp"
6219 if $afs; then
6220         $cat <<EOM
6221
6222 Since you are running AFS, I need to distinguish the directory in
6223 which site-specific files reside from the directory in which they are
6224 installed (and from which they are presumably copied to the former
6225 directory by occult means).
6226
6227 EOM
6228         case "$installsitelib" in
6229         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6230         *) dflt="$installsitelib";;
6231         esac
6232         fn=de~
6233         rp='Where will site-specific files be installed?'
6234         . ./getfile
6235         installsitelib="$ans"
6236 else
6237         installsitelib="$sitelibexp"
6238 fi
6239
6240 : determine where site specific architecture-dependent libraries go.
6241 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6242 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6243 : sitelib may have an optional trailing /share.
6244 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6245 tdflt="$tdflt/$archname"
6246 set sitearch sitearch none
6247 eval $prefixit
6248 case "$sitearch" in
6249 '')     dflt="$tdflt" ;;
6250 *)      dflt="$sitearch" ;;
6251 esac
6252 $cat <<EOM
6253
6254 The installation process will also create a directory for
6255 architecture-dependent site-specific extensions and modules.
6256
6257 EOM
6258 fn=nd~+
6259 rp='Pathname for the site-specific architecture-dependent library files?'
6260 . ./getfile
6261 if $test "X$sitearchexp" != "X$ansexp"; then
6262         installsitearch=''
6263 fi
6264 sitearch="$ans"
6265 sitearchexp="$ansexp"
6266 if $afs; then
6267         $cat <<EOM
6268
6269 Since you are running AFS, I need to distinguish the directory in
6270 which site-specific architecture-dependent library files reside from
6271 the directory in which they are installed (and from which they are
6272 presumably copied to the former directory by occult means).
6273
6274 EOM
6275         case "$installsitearch" in
6276         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6277         *) dflt="$installsitearch";;
6278         esac
6279         fn=de~
6280         rp='Where will site-specific architecture-dependent files be installed?'
6281         . ./getfile
6282         installsitearch="$ans"
6283 else
6284         installsitearch="$sitearchexp"
6285 fi
6286
6287 cat <<EOM
6288
6289 Previous version of $package used the standard IO mechanisms as defined
6290 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6291 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6292 the default.  This abstraction layer can use AT&T's sfio (if you already
6293 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6294 problems with some extension modules.  Using PerlIO with stdio is safe,
6295 but it is slower than plain stdio and therefore is not the default.
6296
6297 If this doesn't make any sense to you, just accept the default 'n'.
6298 EOM
6299 case "$useperlio" in
6300 $define|true|[yY]*)     dflt='y';;
6301 *) dflt='n';;
6302 esac
6303 rp='Use the experimental PerlIO abstraction layer?'
6304 . ./myread
6305 case "$ans" in
6306 y|Y) 
6307         val="$define"
6308         ;;     
6309 *)      
6310         echo "Ok, doing things the stdio way"
6311         val="$undef"
6312         ;;
6313 esac
6314 set useperlio
6315 eval $setvar 
6316
6317 : Check how to convert floats to strings.
6318 if test "X$d_Gconvert" = X; then
6319         echo " "
6320         echo "Checking for an efficient way to convert floats to strings."
6321         $cat >try.c <<'EOP'
6322 #ifdef TRY_gconvert
6323 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6324 char *myname = "gconvert";
6325 #endif
6326 #ifdef TRY_gcvt
6327 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6328 char *myname = "gcvt";
6329 #endif
6330 #ifdef TRY_sprintf
6331 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6332 char *myname = "sprintf";
6333 #endif
6334
6335 #include <stdio.h>
6336
6337 int
6338 checkit(expect, got)
6339 char *expect;
6340 char *got;
6341 {
6342     if (strcmp(expect, got)) {
6343                 printf("%s oddity:  Expected %s, got %s\n",
6344                         myname, expect, got);
6345                 exit(1);
6346         }
6347 }
6348
6349 int main()
6350
6351         char buf[64]; 
6352         buf[63] = '\0';
6353
6354         /* This must be 1st test on (which?) platform */
6355         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6356         Gconvert(0.1, 8, 0, buf);
6357         checkit("0.1", buf);
6358
6359         Gconvert(1.0, 8, 0, buf); 
6360         checkit("1", buf);
6361
6362         Gconvert(0.0, 8, 0, buf); 
6363         checkit("0", buf);
6364
6365         Gconvert(-1.0, 8, 0, buf); 
6366         checkit("-1", buf);
6367
6368         /* Some Linux gcvt's give 1.e+5 here. */
6369         Gconvert(100000.0, 8, 0, buf); 
6370         checkit("100000", buf);
6371         
6372         /* Some Linux gcvt's give -1.e+5 here. */
6373         Gconvert(-100000.0, 8, 0, buf); 
6374         checkit("-100000", buf);
6375
6376         exit(0);
6377 }
6378 EOP
6379         case "$d_Gconvert" in
6380         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6381         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6382         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6383         *) xxx_list='gconvert gcvt sprintf' ;;
6384         esac
6385
6386         for xxx_convert in $xxx_list; do
6387                 echo "Trying $xxx_convert"
6388                 $rm -f try try$_o
6389                 set try -DTRY_$xxx_convert
6390                 if eval $compile; then
6391                         echo "$xxx_convert" found. >&4
6392                         if ./try; then
6393                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6394                                 break;
6395                         else
6396                                 echo "...But $xxx_convert didn't work as I expected."
6397                         fi
6398                 else
6399                         echo "$xxx_convert NOT found." >&4
6400                 fi
6401         done
6402                 
6403         case "$xxx_convert" in
6404         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6405         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6406         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6407         esac
6408 fi
6409
6410 : Initialize h_fcntl
6411 h_fcntl=false
6412
6413 : Initialize h_sysfile
6414 h_sysfile=false
6415
6416 : access call always available on UNIX
6417 set access d_access
6418 eval $inlibc
6419
6420 : locate the flags for 'access()'
6421 case "$d_access" in
6422 "$define")
6423         echo " "
6424         $cat >access.c <<'EOCP'
6425 #include <sys/types.h>
6426 #ifdef I_FCNTL
6427 #include <fcntl.h>
6428 #endif
6429 #ifdef I_SYS_FILE
6430 #include <sys/file.h>
6431 #endif
6432 #ifdef I_UNISTD
6433 #include <unistd.h>
6434 #endif
6435 int main() {
6436         exit(R_OK);
6437 }
6438 EOCP
6439         : check sys/file.h first, no particular reason here
6440         if $test `./findhdr sys/file.h` && \
6441                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6442                 h_sysfile=true;
6443                 echo "<sys/file.h> defines the *_OK access constants." >&4
6444         elif $test `./findhdr fcntl.h` && \
6445                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6446                 h_fcntl=true;
6447                 echo "<fcntl.h> defines the *_OK access constants." >&4
6448         elif $test `./findhdr unistd.h` && \
6449                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6450                 echo "<unistd.h> defines the *_OK access constants." >&4
6451         else
6452                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6453         fi
6454         ;;
6455 esac
6456 $rm -f access*
6457
6458 : see if accessx exists
6459 set accessx d_accessx
6460 eval $inlibc
6461
6462 : see if alarm exists
6463 set alarm d_alarm
6464 eval $inlibc
6465
6466 : Look for GNU-cc style attribute checking
6467 echo " "
6468 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6469 $cat >attrib.c <<'EOCP'
6470 #include <stdio.h>
6471 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6472 EOCP
6473 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6474         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6475                 echo "Your C compiler doesn't fully support __attribute__."
6476                 val="$undef"
6477         else
6478                 echo "Your C compiler supports __attribute__."
6479                 val="$define"
6480         fi
6481 else
6482         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6483         val="$undef"
6484 fi
6485 set d_attribut
6486 eval $setvar
6487 $rm -f attrib*
6488
6489 : see if bcmp exists
6490 set bcmp d_bcmp
6491 eval $inlibc
6492
6493 : see if bcopy exists
6494 set bcopy d_bcopy
6495 eval $inlibc
6496
6497 : see if this is a unistd.h system
6498 set unistd.h i_unistd
6499 eval $inhdr
6500
6501 : see if getpgrp exists
6502 set getpgrp d_getpgrp
6503 eval $inlibc
6504
6505 case "$d_getpgrp" in
6506 "$define")
6507         echo " "
6508         echo "Checking to see which flavor of getpgrp is in use..."
6509         $cat >set.c <<EOP
6510 #$i_unistd I_UNISTD
6511 #include <sys/types.h>
6512 #ifdef I_UNISTD
6513 #  include <unistd.h>
6514 #endif
6515 int main()
6516 {
6517         if (getuid() == 0) {
6518                 printf("(I see you are running Configure as super-user...)\n");
6519                 setuid(1);
6520         }
6521 #ifdef TRY_BSD_PGRP
6522         if (getpgrp(1) == 0)
6523                 exit(0);
6524 #else
6525         if (getpgrp() > 0)
6526                 exit(0);
6527 #endif
6528         exit(1);
6529 }
6530 EOP
6531         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6532                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6533                 val="$define"
6534         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6535                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6536                 val="$undef"
6537         else
6538                 echo "I can't seem to compile and run the test program."
6539                 if ./usg; then
6540                         xxx="a USG one, i.e. you use getpgrp()."
6541                 else
6542                         # SVR4 systems can appear rather BSD-ish.
6543                         case "$i_unistd" in
6544                         $undef)
6545                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6546                                 val="$define"
6547                                 ;;
6548                         $define)
6549                                 xxx="probably a USG one, i.e. you use getpgrp()."
6550                                 val="$undef"
6551                                 ;;
6552                         esac
6553                 fi
6554                 echo "Assuming your getpgrp is $xxx" >&4
6555         fi
6556         ;;
6557 *) val="$undef";;
6558 esac
6559 set d_bsdgetpgrp
6560 eval $setvar
6561 $rm -f set set.c
6562
6563 : see if setpgrp exists
6564 set setpgrp d_setpgrp
6565 eval $inlibc
6566
6567 case "$d_setpgrp" in
6568 "$define")
6569         echo " "
6570         echo "Checking to see which flavor of setpgrp is in use..."
6571         $cat >set.c <<EOP
6572 #$i_unistd I_UNISTD
6573 #include <sys/types.h>
6574 #ifdef I_UNISTD
6575 #  include <unistd.h>
6576 #endif
6577 int main()
6578 {
6579         if (getuid() == 0) {
6580                 printf("(I see you are running Configure as super-user...)\n");
6581                 setuid(1);
6582         }
6583 #ifdef TRY_BSD_PGRP
6584         if (-1 == setpgrp(1, 1))
6585                 exit(0);
6586 #else
6587         if (setpgrp() != -1)
6588                 exit(0);
6589 #endif
6590         exit(1);
6591 }
6592 EOP
6593         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6594                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6595                 val="$define"
6596         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6597                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6598                 val="$undef"
6599         else
6600                 echo "(I can't seem to compile and run the test program.)"
6601                 if ./usg; then
6602                         xxx="a USG one, i.e. you use setpgrp()."
6603                 else
6604                         # SVR4 systems can appear rather BSD-ish.
6605                         case "$i_unistd" in
6606                         $undef)
6607                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6608                                 val="$define"
6609                                 ;;
6610                         $define)
6611                                 xxx="probably a USG one, i.e. you use setpgrp()."
6612                                 val="$undef"
6613                                 ;;
6614                         esac
6615                 fi
6616                 echo "Assuming your setpgrp is $xxx" >&4
6617         fi
6618         ;;
6619 *) val="$undef";;
6620 esac
6621 set d_bsdsetpgrp
6622 eval $setvar
6623 $rm -f set set.c
6624 : see if bzero exists
6625 set bzero d_bzero
6626 eval $inlibc
6627
6628 : check for lengths of integral types
6629 echo " "
6630 case "$intsize" in
6631 '')
6632         echo "Checking to see how big your integers are..." >&4
6633         $cat >intsize.c <<'EOCP'
6634 #include <stdio.h>
6635 int main()
6636 {
6637         printf("intsize=%d;\n", sizeof(int));
6638         printf("longsize=%d;\n", sizeof(long));
6639         printf("shortsize=%d;\n", sizeof(short));
6640         exit(0);
6641 }
6642 EOCP
6643         set intsize
6644         if eval $compile_ok && ./intsize > /dev/null; then
6645                 eval `./intsize`
6646                 echo "Your integers are $intsize bytes long."
6647                 echo "Your long integers are $longsize bytes long."
6648                 echo "Your short integers are $shortsize bytes long."
6649         else
6650                 $cat >&4 <<EOM
6651 !
6652 Help! I can't compile and run the intsize test program: please enlighten me!
6653 (This is probably a misconfiguration in your system or libraries, and
6654 you really ought to fix it.  Still, I'll try anyway.)
6655 !
6656 EOM
6657                 dflt=4
6658                 rp="What is the size of an integer (in bytes)?"
6659                 . ./myread
6660                 intsize="$ans"
6661                 dflt=$intsize
6662                 rp="What is the size of a long integer (in bytes)?"
6663                 . ./myread
6664                 longsize="$ans"
6665                 dflt=2
6666                 rp="What is the size of a short integer (in bytes)?"
6667                 . ./myread
6668                 shortsize="$ans"
6669         fi
6670         ;;
6671 esac
6672 $rm -f intsize intsize.*
6673
6674 : see if signal is declared as pointer to function returning int or void
6675 echo " "
6676 xxx=`./findhdr signal.h`
6677 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6678 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6679         echo "You have int (*signal())() instead of void." >&4
6680         val="$undef"
6681 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6682         echo "You have void (*signal())()." >&4
6683         val="$define"
6684 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6685         echo "You have int (*signal())() instead of void." >&4
6686         val="$undef"
6687 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6688         echo "You have void (*signal())()." >&4
6689         val="$define"
6690 else
6691         case "$d_voidsig" in
6692         '')
6693         echo "I can't determine whether signal handler returns void or int..." >&4
6694                 dflt=void
6695                 rp="What type does your signal handler return?"
6696                 . ./myread
6697                 case "$ans" in
6698                 v*) val="$define";;
6699                 *) val="$undef";;
6700                 esac;;
6701         "$define")
6702                 echo "As you already told me, signal handler returns void." >&4
6703                 val="$define"
6704                 ;;
6705         *)      echo "As you already told me, signal handler returns int." >&4
6706                 val="$undef"
6707                 ;;
6708         esac
6709 fi
6710 set d_voidsig
6711 eval $setvar
6712 case "$d_voidsig" in
6713 "$define") signal_t="void";;
6714 *) signal_t="int";;
6715 esac
6716 $rm -f $$.tmp
6717
6718 : check for ability to cast large floats to 32-bit ints.
6719 echo " "
6720 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6721 if $test "$intsize" -ge 4; then
6722         xxx=int
6723 else
6724         xxx=long
6725 fi
6726 $cat >try.c <<EOCP
6727 #include <stdio.h>
6728 #include <sys/types.h>
6729 #include <signal.h>
6730 $signal_t blech(s) int s; { exit(3); }
6731 int main()
6732 {
6733         $xxx i32;
6734         double f, g;
6735         int result = 0;
6736         char str[16];
6737         signal(SIGFPE, blech);
6738
6739         /* Don't let compiler optimize the test away.  Store the number 
6740            in a writable string for gcc to pass to sscanf under HP/UX.
6741         */
6742         sprintf(str, "2147483647");
6743         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6744         g = 10 * f;
6745         i32  = ($xxx) g;
6746
6747         /* x86 processors will probably give 0x8000 0000, which is a
6748        sign change.  We don't want that.  We want to mimic SPARC
6749            behavior here, which is to preserve the sign and give
6750            back 0x7fff ffff.
6751         */
6752         if (i32 != ($xxx) f)
6753                 result |= 1;
6754         exit(result);
6755 }
6756 EOCP
6757 set try
6758 if eval $compile_ok; then
6759         ./try
6760         yyy=$?
6761 else
6762         echo "(I can't seem to compile the test program--assuming it can't)"
6763         yyy=1
6764 fi
6765 case "$yyy" in
6766 0)      val="$define"
6767         echo "Yup, it can."
6768         ;;
6769 *)      val="$undef"
6770         echo "Nope, it can't."
6771         ;;
6772 esac
6773 set d_casti32
6774 eval $setvar
6775 $rm -f try try.*
6776
6777 : check for ability to cast negative floats to unsigned
6778 echo " "
6779 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6780 $cat >try.c <<EOCP
6781 #include <stdio.h>
6782 #include <sys/types.h>
6783 #include <signal.h>
6784 $signal_t blech(s) int s; { exit(7); }
6785 $signal_t blech_in_list(s) int s; { exit(4); }
6786 unsigned long dummy_long(p) unsigned long p; { return p; }
6787 unsigned int dummy_int(p) unsigned int p; { return p; }
6788 unsigned short dummy_short(p) unsigned short p; { return p; }
6789 int main()
6790 {
6791         double f;
6792         unsigned long along;
6793         unsigned int aint;
6794         unsigned short ashort;
6795         int result = 0;
6796         char str[16];
6797         
6798         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6799            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6800            optimized the whole file away
6801         */
6802         /* Store the number in a writable string for gcc to pass to 
6803            sscanf under HP/UX.
6804         */
6805         sprintf(str, "-123");
6806         sscanf(str, "%lf", &f);  /* f = -123.; */
6807
6808         signal(SIGFPE, blech);
6809         along = (unsigned long)f;
6810         aint = (unsigned int)f;
6811         ashort = (unsigned short)f;
6812         if (along != (unsigned long)-123)
6813                 result |= 1;
6814         if (aint != (unsigned int)-123)
6815                 result |= 1;
6816         if (ashort != (unsigned short)-123)
6817                 result |= 1;
6818         sprintf(str, "1073741824.");
6819         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6820         f = f + f;
6821         along = 0;
6822         along = (unsigned long)f;
6823         if (along != 0x80000000)
6824                 result |= 2;
6825         f -= 1.;
6826         along = 0;
6827         along = (unsigned long)f;
6828         if (along != 0x7fffffff)
6829                 result |= 1;
6830         f += 2.;
6831         along = 0;
6832         along = (unsigned long)f;
6833         if (along != 0x80000001)
6834                 result |= 2;
6835         if (result)
6836                 exit(result);
6837         signal(SIGFPE, blech_in_list);
6838         sprintf(str, "123.");
6839         sscanf(str, "%lf", &f);  /* f = 123.; */
6840         along = dummy_long((unsigned long)f);
6841         aint = dummy_int((unsigned int)f);
6842         ashort = dummy_short((unsigned short)f);
6843         if (along != (unsigned long)123)
6844                 result |= 4;
6845         if (aint != (unsigned int)123)
6846                 result |= 4;
6847         if (ashort != (unsigned short)123)
6848                 result |= 4;
6849         exit(result);
6850
6851 }
6852 EOCP
6853 set try
6854 if eval $compile_ok; then
6855         ./try
6856         castflags=$?
6857 else
6858         echo "(I can't seem to compile the test program--assuming it can't)"
6859         castflags=7
6860 fi
6861 case "$castflags" in
6862 0)      val="$define"
6863         echo "Yup, it can."
6864         ;;
6865 *)      val="$undef"
6866         echo "Nope, it can't."
6867         ;;
6868 esac
6869 set d_castneg
6870 eval $setvar
6871 $rm -f try.*
6872
6873 : see if vprintf exists
6874 echo " "
6875 if set vprintf val -f d_vprintf; eval $csym; $val; then
6876         echo 'vprintf() found.' >&4
6877         val="$define"
6878         $cat >vprintf.c <<'EOF'
6879 #include <varargs.h>
6880
6881 int main() { xxx("foo"); }
6882
6883 xxx(va_alist)
6884 va_dcl
6885 {
6886         va_list args;
6887         char buf[10];
6888
6889         va_start(args);
6890         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6891 }
6892 EOF
6893         set vprintf
6894         if eval $compile && ./vprintf; then
6895                 echo "Your vsprintf() returns (int)." >&4
6896                 val2="$undef"
6897         else
6898                 echo "Your vsprintf() returns (char*)." >&4
6899                 val2="$define"
6900         fi
6901 else
6902         echo 'vprintf() NOT found.' >&4
6903                 val="$undef"
6904                 val2="$undef"
6905 fi
6906 set d_vprintf
6907 eval $setvar
6908 val=$val2
6909 set d_charvspr
6910 eval $setvar
6911
6912 : see if chown exists
6913 set chown d_chown
6914 eval $inlibc
6915
6916 : see if chroot exists
6917 set chroot d_chroot
6918 eval $inlibc
6919
6920 : see if chsize exists
6921 set chsize d_chsize
6922 eval $inlibc
6923
6924 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6925 while $test $# -ge 2; do
6926         case "$1" in
6927         $define) echo "#include <$2>";;
6928         esac ;
6929     shift 2;
6930 done > try.c;
6931 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6932 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6933         val="$define";
6934 else
6935         val="$undef";
6936 fi;
6937 set $varname;
6938 eval $setvar;
6939 $rm -f try.c try.o'
6940
6941 : see if this is a sys/uio.h system
6942 set sys/uio.h i_sysuio
6943 eval $inhdr
6944
6945 echo "Checking to see if your system supports struct iovec..." >&4
6946 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6947 eval $hasfield
6948 case "$d_iovec_s" in
6949 "$define")      echo "Yup, it does." >&4
6950                 ;;
6951 *)              echo "Nope, it doesn't." >&4
6952                 ;;
6953 esac
6954
6955 socketlib=''
6956 sockethdr=''
6957 : see whether socket exists
6958 echo " "
6959 $echo $n "Hmm... $c" >&4
6960 if set socket val -f d_socket; eval $csym; $val; then
6961         echo "Looks like you have Berkeley networking support." >&4
6962         d_socket="$define"
6963         if set setsockopt val -f; eval $csym; $val; then
6964                 d_oldsock="$undef"
6965         else
6966                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6967                 d_oldsock="$define"
6968         fi
6969 else
6970         if $contains socklib libc.list >/dev/null 2>&1; then
6971                 echo "Looks like you have Berkeley networking support." >&4
6972                 d_socket="$define"
6973                 : we will have to assume that it supports the 4.2 BSD interface
6974                 d_oldsock="$undef"
6975         else
6976                 echo "You don't have Berkeley networking in libc$_a..." >&4
6977                 if test "X$d_socket" = "X$define"; then
6978                    echo "...but you seem to believe that you have sockets." >&4
6979                 else
6980                         for net in net socket
6981                         do
6982                                 if test -f /usr/lib/lib$net$_a; then
6983                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6984                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6985                                         if $contains socket libc.list >/dev/null 2>&1; then
6986                                                 d_socket="$define"
6987                                                 socketlib="-l$net"
6988                                                 case "$net" in
6989                                                 net)
6990                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6991                                                         sockethdr="-I/usr/netinclude"
6992                                                         ;;
6993                                                 esac
6994                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6995                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6996                                                         d_oldsock="$undef"
6997                                                 else
6998                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6999                                                         d_oldsock="$define"
7000                                                 fi
7001                                                 break
7002                                         fi
7003                                 fi
7004                         done
7005                         if test "X$d_socket" != "X$define"; then
7006                            echo "or anywhere else I see." >&4
7007                            d_socket="$undef"
7008                            d_oldsock="$undef"
7009                         fi
7010                 fi
7011         fi
7012 fi
7013
7014 : see if socketpair exists
7015 set socketpair d_sockpair
7016 eval $inlibc
7017
7018
7019 echo " "
7020 echo "Checking the availability of certain socket constants..." >& 4
7021 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
7022         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
7023         $cat >try.c <<EOF
7024 #include <sys/types.h>
7025 #include <sys/socket.h>
7026 int main() {
7027     int i = $ENUM;
7028 }
7029 EOF
7030         val="$undef"
7031         set try; if eval $compile; then
7032                 val="$define"
7033         fi
7034         set d_${enum}; eval $setvar
7035         $rm -f try.c try
7036 done
7037
7038 set sendmsg d_sendmsg
7039 eval $inlibc
7040
7041 set recvmsg d_recvmsg
7042 eval $inlibc
7043
7044 echo " "
7045 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
7046 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7047 eval $hasfield
7048 case "$d_msghdr_s" in
7049 "$define")      echo "Yup, it does." >&4
7050                 ;;
7051 *)              echo "Nope, it doesn't." >&4
7052                 ;;
7053 esac
7054
7055 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7056 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7057 eval $hasfield
7058 case "$d_cmsghdr_s" in
7059 "$define")      echo "Yup, it does." >&4
7060                 ;;
7061 *)              echo "Nope, it doesn't." >&4
7062                 ;;
7063 esac
7064
7065 : check for const keyword
7066 echo " "
7067 echo 'Checking to see if your C compiler knows about "const"...' >&4
7068 $cat >const.c <<'EOCP'
7069 typedef struct spug { int drokk; } spug;
7070 int main()
7071 {
7072         const char *foo;
7073         const spug y;
7074 }
7075 EOCP
7076 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7077         val="$define"
7078         echo "Yup, it does."
7079 else
7080         val="$undef"
7081         echo "Nope, it doesn't."
7082 fi
7083 set d_const
7084 eval $setvar
7085
7086 : see if crypt exists
7087 echo " "
7088 if set crypt val -f d_crypt; eval $csym; $val; then
7089         echo 'crypt() found.' >&4
7090         val="$define"
7091         cryptlib=''
7092 else
7093         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7094         if $test -z "$cryptlib"; then
7095                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7096         else
7097                 cryptlib=-lcrypt
7098         fi
7099         if $test -z "$cryptlib"; then
7100                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7101         else
7102                 cryptlib=-lcrypt
7103         fi
7104         if $test -z "$cryptlib"; then
7105                 cryptlib=`./loc libcrypt$_a "" $libpth`
7106         else
7107                 cryptlib=-lcrypt
7108         fi
7109         if $test -z "$cryptlib"; then
7110                 echo 'crypt() NOT found.' >&4
7111                 val="$undef"
7112         else
7113                 val="$define"
7114         fi
7115 fi
7116 set d_crypt
7117 eval $setvar
7118
7119 : get csh whereabouts
7120 case "$csh" in
7121 'csh') val="$undef" ;;
7122 *) val="$define" ;;
7123 esac
7124 set d_csh
7125 eval $setvar
7126 : Respect a hint or command line value for full_csh.
7127 case "$full_csh" in
7128 '') full_csh=$csh ;;
7129 esac
7130
7131 : see if cuserid exists
7132 set cuserid d_cuserid
7133 eval $inlibc
7134
7135 : see if this is a limits.h system
7136 set limits.h i_limits
7137 eval $inhdr
7138
7139 : see if this is a float.h system
7140 set float.h i_float
7141 eval $inhdr
7142
7143 : See if number of significant digits in a double precision number is known
7144 echo " "
7145 $cat >dbl_dig.c <<EOM
7146 #$i_limits I_LIMITS
7147 #$i_float I_FLOAT
7148 #ifdef I_LIMITS
7149 #include <limits.h>
7150 #endif
7151 #ifdef I_FLOAT
7152 #include <float.h>
7153 #endif
7154 #ifdef DBL_DIG
7155 printf("Contains DBL_DIG");
7156 #endif
7157 EOM
7158 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7159 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7160         echo "DBL_DIG found." >&4
7161         val="$define"
7162 else
7163         echo "DBL_DIG NOT found." >&4
7164         val="$undef"
7165 fi
7166 $rm -f dbl_dig.?
7167 set d_dbl_dig
7168 eval $setvar
7169
7170
7171 if $test X"$use64bits" = X"$define"; then
7172         : see if dbminit64 exists
7173         set dbminit64 d_dbminit64
7174         eval $inlibc
7175
7176         : see if dbmclose64 exists
7177         set dbmclose64 d_dbmclose64
7178         eval $inlibc
7179
7180         : see if fetch64 exists
7181         set fetch64 d_fetch64
7182         eval $inlibc
7183
7184         : see if store64 exists
7185         set store64 d_store64
7186         eval $inlibc
7187
7188         : see if delete64 exists
7189         set delete64 d_delete64
7190         eval $inlibc
7191
7192         : see if firstkey64 exists
7193         set firstkey64 d_firstkey64
7194         eval $inlibc
7195
7196         : see if nextkey64 exists
7197         set nextkey64 d_nextkey64
7198         eval $inlibc
7199 else
7200         val="$undef"
7201         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7202         do
7203                 set $xxx
7204                 eval $setvar
7205         done
7206 fi
7207
7208 : see if difftime exists
7209 set difftime d_difftime
7210 eval $inlibc
7211
7212 : see if sys/stat.h is available
7213 set sys/stat.h i_sysstat
7214 eval $inhdr
7215
7216 : see if this is a dirent system
7217 echo " "
7218 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7219         val="$define"
7220         echo "<dirent.h> found." >&4
7221 else
7222         val="$undef"
7223         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7224                 echo "<sys/dir.h> found." >&4
7225                 echo " "
7226         else
7227                 xinc=`./findhdr sys/ndir.h`
7228         fi
7229         echo "<dirent.h> NOT found." >&4
7230 fi
7231 set i_dirent
7232 eval $setvar
7233
7234 : Look for type of directory structure.
7235 echo " "
7236 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7237
7238 case "$direntrytype" in
7239 ''|' ')
7240         case "$i_dirent" in
7241         $define) guess1='struct dirent' ;;
7242         *) guess1='struct direct'  ;;
7243         esac
7244         ;;
7245 *)      guess1="$direntrytype"
7246         ;;
7247 esac
7248
7249 case "$guess1" in
7250 'struct dirent') guess2='struct direct' ;;
7251 *) guess2='struct dirent' ;;
7252 esac
7253                 
7254 if $contains "$guess1" try.c >/dev/null 2>&1; then
7255         direntrytype="$guess1"
7256         echo "Your directory entries are $direntrytype." >&4
7257 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7258         direntrytype="$guess2"
7259         echo "Your directory entries seem to be $direntrytype." >&4
7260 else
7261         echo "I don't recognize your system's directory entries." >&4
7262         rp="What type is used for directory entries on this system?"
7263         dflt="$guess1"
7264         . ./myread
7265         direntrytype="$ans"
7266 fi
7267 $rm -f try.c
7268
7269
7270 : see if the directory entry stores field length
7271 echo " "
7272 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7273 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7274         echo "Good, your directory entry keeps length information in d_namlen." >&4
7275         val="$define"
7276 else
7277         echo "Your directory entry does not know about the d_namlen field." >&4
7278         val="$undef"
7279 fi
7280 set d_dirnamlen
7281 eval $setvar
7282 $rm -f try.c
7283
7284
7285 if $test X"$use64bits" = X"$define"; then
7286         : see if fstat64 exists
7287         set fstat64 d_fstat64
7288         eval $inlibc
7289
7290         : see if ftruncate64 exists
7291         set ftruncate64 d_ftruncate64
7292         eval $inlibc
7293
7294         : see if lockf64 exists
7295         set lockf64 d_lockf64
7296         eval $inlibc
7297
7298         : see if llseek exists
7299         set llseek d_llseek
7300         eval $inlibc
7301
7302         : see if lseek64 exists
7303         set lseek64 d_lseek64
7304         eval $inlibc
7305
7306         : see if lstat64 exists
7307         set lstat64 d_lstat64
7308         eval $inlibc
7309
7310         : see if open64 exists
7311         set open64 d_open64
7312         eval $inlibc
7313
7314         : see if opendir64 exists
7315         set opendir64 d_opendir64
7316         eval $inlibc
7317
7318         : see if readdir64 exists
7319         set readdir64 d_readdir64
7320         eval $inlibc
7321
7322         : see if seekdir64 exists
7323         set seekdir64 d_seekdir64
7324         eval $inlibc
7325
7326         : see if stat64 exists
7327         set stat64 d_stat64
7328         eval $inlibc
7329
7330         : see if telldir64 exists
7331         set telldir64 d_telldir64
7332         eval $inlibc
7333
7334         : see if truncate64 exists
7335         set truncate64 d_truncate64
7336         eval $inlibc
7337
7338         : check for off64_t
7339         echo " "
7340         echo $n "Checking to see if your system supports off64_t...$c" >&4
7341         $cat >try.c <<EOCP
7342 #include <sys/types.h>
7343 #include <unistd.h>
7344 off64_t foo() { off64_t x; x = 7; return x; }'
7345 EOCP
7346         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7347                 val="$define"
7348                 echo " Yup, it does." >&4
7349         else
7350                 val="$undef"
7351                 echo " Nope, it doesn't." >&4
7352         fi
7353         $rm -f try.*
7354         set d_off64_t
7355         eval $setvar
7356
7357         : check for offset_t
7358         echo " "
7359         echo $n "Checking to see if your system supports offset_t...$c" >&4
7360         $cat >try.c <<EOCP
7361 #include <sys/types.h>
7362 #include <unistd.h>
7363 offset_t foo() { offset_t x; x = 7; return x; }'
7364 EOCP
7365         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7366                 val="$define"
7367                 echo " Yup, it does." >&4
7368         else
7369                 val="$undef"
7370                 echo " Nope, it doesn't." >&4
7371         fi
7372         $rm -f try.*
7373         set d_offset_t
7374         eval $setvar
7375
7376         : check for ino64_t
7377         echo " "
7378         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7379         val="$undef"
7380         case "$i_sysstat" in
7381         "$define" )
7382                 $cat >try.c <<EOCP
7383 #include <sys/types.h>
7384 #include <sys/stat.h>
7385 ino64_t foo() { ino64_t x; x = 7; return x; }'
7386 EOCP
7387                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7388                         val="$define"
7389                 fi
7390                 $rm -f try.*
7391                 ;;
7392         esac
7393         if $test "X$val" = X"$define"; then
7394                 echo " Yup, it does." >&4
7395         else
7396                 echo " Nope, it doesn't." >&4
7397         fi
7398         set d_ino64_t
7399         eval $setvar
7400
7401         : check for struct flock64
7402         echo " "
7403         echo "Checking to see if your system supports struct flock64..." >&4
7404         if $h_fcntl; then
7405                 set d_flock64_s flock64 l_len define fcntl.h
7406                 eval $hasfield
7407         else
7408                 val="$undef"
7409                 set d_flock64_s
7410                 eval $setvar
7411         fi
7412         case "$d_flock64_s" in
7413         "$define")      echo "Yup, it does." >&4
7414                         ;;
7415         *)              echo "Nope, it doesn't." >&4
7416                         ;;
7417         esac
7418
7419         : check for struct dirent64
7420         echo " "
7421         echo "Checking to see if your system supports struct dirent64..." >&4
7422         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7423         eval $hasfield
7424         case "$d_dirent64_s" in
7425         "$define")      echo "Yup, it does." >&4
7426                         ;;
7427         *)              echo "Nope, it doesn't." >&4
7428                         ;;
7429         esac
7430
7431 else
7432         val="$undef"
7433         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
7434         do
7435                 set $xxx
7436                 eval $setvar
7437         done
7438 fi
7439
7440 : see if dlerror exists
7441 xxx_runnm="$runnm"
7442 runnm=false
7443 set dlerror d_dlerror
7444 eval $inlibc
7445 runnm="$xxx_runnm"
7446
7447 : see if dlfcn is available
7448 set dlfcn.h i_dlfcn
7449 eval $inhdr
7450
7451 case "$usedl" in
7452 $define|y|true)
7453         $cat << EOM
7454
7455 On a few systems, the dynamically loaded modules that perl generates and uses
7456 will need a different extension than shared libs. The default will probably
7457 be appropriate.
7458
7459 EOM
7460         case "$dlext" in
7461         '')     dflt="$so" ;;
7462         *)      dflt="$dlext" ;;
7463         esac
7464         rp='What is the extension of dynamically loaded modules'
7465         . ./myread
7466         dlext="$ans"
7467         ;;
7468 *)
7469         dlext="none"
7470         ;;
7471 esac
7472
7473 : Check if dlsym need a leading underscore
7474 echo " "
7475 val="$undef"
7476
7477 case "$dlsrc" in
7478 dl_dlopen.xs)
7479         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7480         $cat >dyna.c <<'EOM'
7481 fred () { }
7482 EOM
7483
7484 $cat >fred.c<<EOM
7485
7486 #include <stdio.h>
7487 #$i_dlfcn I_DLFCN
7488 #ifdef I_DLFCN
7489 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7490 #else
7491 #include <sys/types.h>
7492 #include <nlist.h>
7493 #include <link.h>
7494 #endif
7495
7496 extern int fred() ;
7497
7498 int main()
7499 {
7500     void * handle ;
7501     void * symbol ;
7502 #ifndef RTLD_LAZY
7503     int mode = 1 ;
7504 #else
7505     int mode = RTLD_LAZY ;
7506 #endif
7507     handle = dlopen("./dyna.$dlext", mode) ;
7508     if (handle == NULL) {
7509         printf ("1\n") ;
7510         fflush (stdout) ;
7511         exit(0);
7512     }
7513     symbol = dlsym(handle, "fred") ;
7514     if (symbol == NULL) {
7515         /* try putting a leading underscore */
7516         symbol = dlsym(handle, "_fred") ;
7517         if (symbol == NULL) {
7518             printf ("2\n") ;
7519             fflush (stdout) ;
7520             exit(0);
7521         }
7522         printf ("3\n") ;
7523     }
7524     else
7525         printf ("4\n") ;
7526     fflush (stdout) ;
7527     exit(0);
7528 }
7529 EOM
7530         : Call the object file tmp-dyna.o in case dlext=o.
7531         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7532                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7533                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7534                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7535                 xxx=`./fred`
7536                 case $xxx in
7537                 1)      echo "Test program failed using dlopen." >&4
7538                         echo "Perhaps you should not use dynamic loading." >&4;;
7539                 2)      echo "Test program failed using dlsym." >&4
7540                         echo "Perhaps you should not use dynamic loading." >&4;;
7541                 3)      echo "dlsym needs a leading underscore" >&4
7542                         val="$define" ;;
7543                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7544                 esac
7545         else
7546                 echo "I can't compile and run the test program." >&4
7547         fi
7548         ;;
7549 esac
7550                 
7551 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7552
7553 set d_dlsymun
7554 eval $setvar
7555
7556 hasproto='varname=$1; func=$2; shift; shift;
7557 while $test $# -ge 2; do
7558         case "$1" in
7559         $define) echo "#include <$2>";;
7560         esac ;
7561     shift 2;
7562 done > try.c;
7563 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7564 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7565         echo "$func() prototype found.";
7566         val="$define";
7567 else
7568         echo "$func() prototype NOT found.";
7569         val="$undef";
7570 fi;
7571 set $varname;
7572 eval $setvar;
7573 $rm -f try.c tryout.c'
7574
7575 : see if prototype for drand48 is available
7576 echo " "
7577 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7578 eval $hasproto
7579
7580 : see if dup2 exists
7581 set dup2 d_dup2
7582 eval $inlibc
7583
7584 : see if eaccess exists
7585 set eaccess d_eaccess
7586 eval $inlibc
7587
7588 : see if endgrent exists
7589 set endgrent d_endgrent
7590 eval $inlibc
7591
7592 : see if endhostent exists
7593 set endhostent d_endhent
7594 eval $inlibc
7595
7596 : see if endnetent exists
7597 set endnetent d_endnent
7598 eval $inlibc
7599
7600 : see if endprotoent exists
7601 set endprotoent d_endpent
7602 eval $inlibc
7603
7604 : see if endpwent exists
7605 set endpwent d_endpwent
7606 eval $inlibc
7607
7608 : see if endservent exists
7609 set endservent d_endsent
7610 eval $inlibc
7611
7612 : see if endspent exists
7613 set endspent d_endspent
7614 eval $inlibc
7615
7616 : Locate the flags for 'open()'
7617 echo " "
7618 $cat >open3.c <<'EOCP'
7619 #include <sys/types.h>
7620 #ifdef I_FCNTL
7621 #include <fcntl.h>
7622 #endif
7623 #ifdef I_SYS_FILE
7624 #include <sys/file.h>
7625 #endif
7626 int main() {
7627         if(O_RDONLY);
7628 #ifdef O_TRUNC
7629         exit(0);
7630 #else
7631         exit(1);
7632 #endif
7633 }
7634 EOCP
7635 : check sys/file.h first to get FREAD on Sun
7636 if $test `./findhdr sys/file.h` && \
7637                 set open3 -DI_SYS_FILE && eval $compile; then
7638         h_sysfile=true;
7639         echo "<sys/file.h> defines the O_* constants..." >&4
7640         if ./open3; then
7641                 echo "and you have the 3 argument form of open()." >&4
7642                 val="$define"
7643         else
7644                 echo "but not the 3 argument form of open().  Oh, well." >&4
7645                 val="$undef"
7646         fi
7647 elif $test `./findhdr fcntl.h` && \
7648                 set open3 -DI_FCNTL && eval $compile; then
7649         h_fcntl=true;
7650         echo "<fcntl.h> defines the O_* constants..." >&4
7651         if ./open3; then
7652                 echo "and you have the 3 argument form of open()." >&4
7653                 val="$define"
7654         else
7655                 echo "but not the 3 argument form of open().  Oh, well." >&4
7656                 val="$undef"
7657         fi
7658 else
7659         val="$undef"
7660         echo "I can't find the O_* constant definitions!  You got problems." >&4
7661 fi
7662 set d_open3
7663 eval $setvar
7664 $rm -f open3*
7665
7666 : check for non-blocking I/O stuff
7667 case "$h_sysfile" in
7668 true) echo "#include <sys/file.h>" > head.c;;
7669 *)
7670         case "$h_fcntl" in
7671         true) echo "#include <fcntl.h>" > head.c;;
7672         *) echo "#include <sys/fcntl.h>" > head.c;;
7673         esac
7674         ;;
7675 esac
7676 echo " "
7677 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7678 case "$o_nonblock" in
7679 '')
7680         $cat head.c > try.c
7681         $cat >>try.c <<'EOCP'
7682 int main() {
7683 #ifdef O_NONBLOCK
7684         printf("O_NONBLOCK\n");
7685         exit(0);
7686 #endif
7687 #ifdef O_NDELAY
7688         printf("O_NDELAY\n");
7689         exit(0);
7690 #endif
7691 #ifdef FNDELAY
7692         printf("FNDELAY\n");
7693         exit(0);
7694 #endif
7695         exit(0);
7696 }
7697 EOCP
7698         set try
7699         if eval $compile_ok; then
7700                 o_nonblock=`./try`
7701                 case "$o_nonblock" in
7702                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7703                 *) echo "Seems like we can use $o_nonblock.";;
7704                 esac
7705         else
7706                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7707         fi
7708         ;;
7709 *) echo "Using $hint value $o_nonblock.";;
7710 esac
7711 $rm -f try try.* .out core
7712
7713 echo " "
7714 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7715 case "$eagain" in
7716 '')
7717         $cat head.c > try.c
7718         $cat >>try.c <<EOCP
7719 #include <errno.h>
7720 #include <sys/types.h>
7721 #include <signal.h>
7722 #define MY_O_NONBLOCK $o_nonblock
7723 #ifndef errno  /* XXX need better Configure test */
7724 extern int errno;
7725 #endif
7726 $signal_t blech(x) int x; { exit(3); }
7727 EOCP
7728         $cat >> try.c <<'EOCP'
7729 int main()
7730 {
7731         int pd[2];
7732         int pu[2];
7733         char buf[1];
7734         char string[100];
7735
7736         pipe(pd);       /* Down: child -> parent */
7737         pipe(pu);       /* Up: parent -> child */
7738         if (0 != fork()) {
7739                 int ret;
7740                 close(pd[1]);   /* Parent reads from pd[0] */
7741                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7742                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7743                         exit(1);
7744                 signal(SIGALRM, blech);
7745                 alarm(5);
7746                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7747                         exit(2);
7748                 sprintf(string, "%d\n", ret);
7749                 write(2, string, strlen(string));
7750                 alarm(0);
7751 #ifdef EAGAIN
7752                 if (errno == EAGAIN) {
7753                         printf("EAGAIN\n");
7754                         goto ok;
7755                 }
7756 #endif
7757 #ifdef EWOULDBLOCK
7758                 if (errno == EWOULDBLOCK)
7759                         printf("EWOULDBLOCK\n");
7760 #endif
7761         ok:
7762                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7763                 sleep(2);                               /* Give it time to close our pipe */
7764                 alarm(5);
7765                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7766                 alarm(0);
7767                 sprintf(string, "%d\n", ret);
7768                 write(3, string, strlen(string));
7769                 exit(0);
7770         }
7771
7772         close(pd[0]);                   /* We write to pd[1] */
7773         close(pu[1]);                   /* We read from pu[0] */
7774         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7775         close(pd[1]);                   /* Pipe pd is now fully closed! */
7776         exit(0);                                /* Bye bye, thank you for playing! */
7777 }
7778 EOCP
7779         set try
7780         if eval $compile_ok; then
7781                 echo "$startsh" >mtry
7782                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7783                 chmod +x mtry
7784                 ./mtry >/dev/null 2>&1
7785                 case $? in
7786                 0) eagain=`$cat try.out`;;
7787                 1) echo "Could not perform non-blocking setting!";;
7788                 2) echo "I did a successful read() for something that was not there!";;
7789                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7790                 *) echo "Something terribly wrong happened during testing.";;
7791                 esac
7792                 rd_nodata=`$cat try.ret`
7793                 echo "A read() system call with no data present returns $rd_nodata."
7794                 case "$rd_nodata" in
7795                 0|-1) ;;
7796                 *)
7797                         echo "(That's peculiar, fixing that to be -1.)"
7798                         rd_nodata=-1
7799                         ;;
7800                 esac
7801                 case "$eagain" in
7802                 '')
7803                         echo "Forcing errno EAGAIN on read() with no data available."
7804                         eagain=EAGAIN
7805                         ;;
7806                 *)
7807                         echo "Your read() sets errno to $eagain when no data is available."
7808                         ;;
7809                 esac
7810                 status=`$cat try.err`
7811                 case "$status" in
7812                 0) echo "And it correctly returns 0 to signal EOF.";;
7813                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7814                 *) echo "However, your read() returns '$status' on EOF??";;
7815                 esac
7816                 val="$define"
7817                 if test "$status" = "$rd_nodata"; then
7818                         echo "WARNING: you can't distinguish between EOF and no data!"
7819                         val="$undef"
7820                 fi
7821         else
7822                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7823                 eagain=EAGAIN
7824         fi
7825         set d_eofnblk
7826         eval $setvar
7827         ;;
7828 *)
7829         echo "Using $hint value $eagain."
7830         echo "Your read() returns $rd_nodata when no data is present."
7831         case "$d_eofnblk" in
7832         "$define") echo "And you can see EOF because read() returns 0.";;
7833         "$undef") echo "But you can't see EOF status from read() returned value.";;
7834         *)
7835                 echo "(Assuming you can't see EOF status from read anyway.)"
7836                 d_eofnblk=$undef
7837                 ;;
7838         esac
7839         ;;
7840 esac
7841 $rm -f try try.* .out core head.c mtry
7842
7843 : see if fchmod exists
7844 set fchmod d_fchmod
7845 eval $inlibc
7846
7847 : see if fchown exists
7848 set fchown d_fchown
7849 eval $inlibc
7850
7851 : see if this is an fcntl system
7852 set fcntl d_fcntl
7853 eval $inlibc
7854
7855 : see if sys/select.h has to be included
7856 set sys/select.h i_sysselct
7857 eval $inhdr
7858
7859 : see if we should include time.h, sys/time.h, or both
7860 echo " "
7861 if test "X$timeincl" = X; then
7862         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7863         $echo $n "I'm now running the test program...$c"
7864         $cat >try.c <<'EOCP'
7865 #include <sys/types.h>
7866 #ifdef I_TIME
7867 #include <time.h>
7868 #endif
7869 #ifdef I_SYSTIME
7870 #ifdef SYSTIMEKERNEL
7871 #define KERNEL
7872 #endif
7873 #include <sys/time.h>
7874 #endif
7875 #ifdef I_SYSSELECT
7876 #include <sys/select.h>
7877 #endif
7878 int main()
7879 {
7880         struct tm foo;
7881 #ifdef S_TIMEVAL
7882         struct timeval bar;
7883 #endif
7884 #ifdef S_TIMEZONE
7885         struct timezone tzp;
7886 #endif
7887         if (foo.tm_sec == foo.tm_sec)
7888                 exit(0);
7889 #ifdef S_TIMEVAL
7890         if (bar.tv_sec == bar.tv_sec)
7891                 exit(0);
7892 #endif
7893         exit(1);
7894 }
7895 EOCP
7896         flags=''
7897         for s_timezone in '-DS_TIMEZONE' ''; do
7898         sysselect=''
7899         for s_timeval in '-DS_TIMEVAL' ''; do
7900         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7901         for i_time in '' '-DI_TIME'; do
7902         for i_systime in '-DI_SYSTIME' ''; do
7903                 case "$flags" in
7904                 '') $echo $n ".$c"
7905                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7906                         if eval $compile; then
7907                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7908                                 shift
7909                                 flags="$*"
7910                                 echo " "
7911                                 $echo $n "Succeeded with $flags$c"
7912                         fi
7913                         ;;
7914                 esac
7915         done
7916         done
7917         done
7918         done
7919         done
7920         timeincl=''
7921         echo " "
7922         case "$flags" in
7923         *SYSTIMEKERNEL*) i_systimek="$define"
7924                 timeincl=`./findhdr sys/time.h`
7925                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7926         *) i_systimek="$undef";;
7927         esac
7928         case "$flags" in
7929         *I_TIME*) i_time="$define"
7930                 timeincl=`./findhdr time.h`" $timeincl"
7931                 echo "We'll include <time.h>." >&4;;
7932         *) i_time="$undef";;
7933         esac
7934         case "$flags" in
7935         *I_SYSTIME*) i_systime="$define"
7936                 timeincl=`./findhdr sys/time.h`" $timeincl"
7937                 echo "We'll include <sys/time.h>." >&4;;
7938         *) i_systime="$undef";;
7939         esac
7940         $rm -f try.c try
7941 fi
7942
7943 : check for fd_set items
7944 $cat <<EOM
7945
7946 Checking to see how well your C compiler handles fd_set and friends ...
7947 EOM
7948 $cat >fd_set.c <<EOCP
7949 #$i_systime I_SYS_TIME
7950 #$i_sysselct I_SYS_SELECT
7951 #$d_socket HAS_SOCKET
7952 #include <sys/types.h>
7953 #ifdef HAS_SOCKET
7954 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7955 #endif
7956 #ifdef I_SYS_TIME
7957 #include <sys/time.h>
7958 #endif
7959 #ifdef I_SYS_SELECT
7960 #include <sys/select.h>
7961 #endif
7962 int main() {
7963         fd_set fds;
7964
7965 #ifdef TRYBITS
7966         if(fds.fds_bits);
7967 #endif
7968
7969 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7970         exit(0);
7971 #else
7972         exit(1);
7973 #endif
7974 }
7975 EOCP
7976 set fd_set -DTRYBITS
7977 if eval $compile; then
7978         d_fds_bits="$define"
7979         d_fd_set="$define"
7980         echo "Well, your system knows about the normal fd_set typedef..." >&4
7981         if ./fd_set; then
7982                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7983                 d_fd_macros="$define"
7984         else
7985                 $cat >&4 <<'EOM'
7986 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7987 EOM
7988                 d_fd_macros="$undef"
7989         fi
7990 else
7991         $cat <<'EOM'
7992 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7993 EOM
7994         set fd_set
7995         if eval $compile; then
7996                 d_fds_bits="$undef"
7997                 d_fd_set="$define"
7998                 echo "Well, your system has some sort of fd_set available..." >&4
7999                 if ./fd_set; then
8000                         echo "and you have the normal fd_set macros." >&4
8001                         d_fd_macros="$define"
8002                 else
8003                         $cat <<'EOM'
8004 but not the normal fd_set macros!  Gross!  More work for me...
8005 EOM
8006                         d_fd_macros="$undef"
8007                 fi
8008         else
8009         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
8010                 d_fd_set="$undef"
8011                 d_fds_bits="$undef"
8012                 d_fd_macros="$undef"
8013         fi
8014 fi
8015 $rm -f fd_set*
8016
8017 : see if fgetpos exists
8018 set fgetpos d_fgetpos
8019 eval $inlibc
8020
8021
8022 if $test X"$use64bits" = X"$define"; then
8023         : see if fgetpos64 exists
8024         set fgetpos64 d_fgetpos64
8025         eval $inlibc
8026
8027         : see if fopen64 exists
8028         set freopen64 d_fopen64
8029         eval $inlibc
8030
8031         : see if freopen64 exists
8032         set freopen64 d_freopen64
8033         eval $inlibc
8034
8035         : see if fseek64 exists
8036         set fseek64 d_fseek64
8037         eval $inlibc
8038
8039         : see if fseeko64 exists
8040         set fseeko64 d_fseeko64
8041         eval $inlibc
8042
8043         : see if fsetpos64 exists
8044         set fsetpos64 d_fsetpos64
8045         eval $inlibc
8046
8047         : see if ftell64 exists
8048         set ftell64 d_ftell64
8049         eval $inlibc
8050
8051         : see if ftello64 exists
8052         set ftello64 d_ftello64
8053         eval $inlibc
8054
8055         : see if tmpfile64 exists
8056         set tmpfile64 d_tmpfile64
8057         eval $inlibc
8058 else
8059         val="$undef"
8060         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
8061         do
8062                 set $xxx
8063                 eval $setvar
8064         done
8065 fi
8066
8067 : see if flock exists
8068 set flock d_flock
8069 eval $inlibc
8070
8071 : see if fork exists
8072 set fork d_fork
8073 eval $inlibc
8074
8075 : see if pathconf exists
8076 set pathconf d_pathconf
8077 eval $inlibc
8078
8079 : see if fpathconf exists
8080 set fpathconf d_fpathconf
8081 eval $inlibc
8082
8083 : see if fseeko exists
8084 set fseeko d_fseeko
8085 eval $inlibc
8086
8087 : see if fsetpos exists
8088 set fsetpos d_fsetpos
8089 eval $inlibc
8090
8091 : see if this is a sys/param system
8092 set sys/param.h i_sysparam
8093 eval $inhdr
8094
8095 : see if this is a sys/mount.h system
8096 set sys/mount.h i_sysmount
8097 eval $inhdr
8098
8099
8100 : see if statfs exists
8101 set statfs d_statfs
8102 eval $inlibc
8103
8104 : see if fstatfs exists
8105 set fstatfs d_fstatfs
8106 eval $inlibc
8107
8108 : see if statfs knows about mount flags
8109 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8110 eval $hasfield
8111
8112
8113 : see if statvfs exists
8114 set statvfs d_statvfs
8115 eval $inlibc
8116
8117 : see if fstatvfs exists
8118 set fstatvfs d_fstatvfs
8119 eval $inlibc
8120
8121
8122 : see if ftello exists
8123 set ftello d_ftello
8124 eval $inlibc
8125
8126 : see if getgrent exists
8127 set getgrent d_getgrent
8128 eval $inlibc
8129
8130 : see if gethostbyaddr exists
8131 set gethostbyaddr d_gethbyaddr
8132 eval $inlibc
8133
8134 : see if gethostbyname exists
8135 set gethostbyname d_gethbyname
8136 eval $inlibc
8137
8138 : see if gethostent exists
8139 set gethostent d_gethent
8140 eval $inlibc
8141
8142 : see how we will look up host name
8143 echo " "
8144 call=''
8145 if set gethostname val -f d_gethname; eval $csym; $val; then
8146         echo 'gethostname() found.' >&4
8147         d_gethname="$define"
8148         call=gethostname
8149 fi
8150 if set uname val -f d_uname; eval $csym; $val; then
8151         if ./xenix; then
8152                 $cat <<'EOM'
8153 uname() was found, but you're running xenix, and older versions of xenix
8154 have a broken uname(). If you don't really know whether your xenix is old
8155 enough to have a broken system call, use the default answer.
8156
8157 EOM
8158                 dflt=y
8159                 case "$d_uname" in
8160                 "$define") dflt=n;;
8161                 esac
8162                 rp='Is your uname() broken?'
8163                 . ./myread
8164                 case "$ans" in
8165                 n*) d_uname="$define"; call=uname;;
8166                 esac
8167         else
8168                 echo 'uname() found.' >&4
8169                 d_uname="$define"
8170                 case "$call" in
8171                 '') call=uname ;;
8172                 esac
8173         fi
8174 fi
8175 case "$d_gethname" in
8176 '') d_gethname="$undef";;
8177 esac
8178 case "$d_uname" in
8179 '') d_uname="$undef";;
8180 esac
8181 case "$d_uname$d_gethname" in
8182 *define*)
8183         dflt=n
8184         cat <<EOM
8185  
8186 Every now and then someone has a $call() that lies about the hostname
8187 but can't be fixed for political or economic reasons.  If you wish, I can
8188 pretend $call() isn't there and maybe compute hostname at run-time
8189 thanks to the '$phostname' command.
8190
8191 EOM
8192         rp="Shall I ignore $call() from now on?"
8193         . ./myread
8194         case "$ans" in
8195         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8196         esac;;
8197 esac
8198 case "$phostname" in
8199 '') aphostname='';;
8200 *) case "$aphostname" in
8201         /*) ;;
8202         *) set X $phostname
8203                 shift
8204                 file=$1
8205                 shift
8206                 file=`./loc $file $file $pth`
8207                 aphostname=`echo $file $*`
8208                 ;;
8209         esac
8210         ;;
8211 esac
8212 case "$d_uname$d_gethname" in
8213 *define*) ;;
8214 *)
8215         case "$phostname" in
8216         '')
8217                 echo "There will be no way for $package to get your hostname." >&4;;
8218         *)
8219         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8220                 ;;
8221         esac;;
8222 esac
8223 case "$d_phostname" in
8224 '') d_phostname="$undef";;
8225 esac
8226
8227 : see if this is a netdb.h system
8228 set netdb.h i_netdb
8229 eval $inhdr
8230
8231 : see if prototypes for various gethostxxx netdb.h functions are available
8232 echo " "
8233 set d_gethostprotos gethostent $i_netdb netdb.h
8234 eval $hasproto
8235
8236 : see if getlogin exists
8237 set getlogin d_getlogin
8238 eval $inlibc
8239
8240 : see if getmntent exists
8241 set getmntent d_getmntent
8242 eval $inlibc
8243
8244 : see if getnetbyaddr exists
8245 set getnetbyaddr d_getnbyaddr
8246 eval $inlibc
8247
8248 : see if getnetbyname exists
8249 set getnetbyname d_getnbyname
8250 eval $inlibc
8251
8252 : see if getnetent exists
8253 set getnetent d_getnent
8254 eval $inlibc
8255
8256 : see if prototypes for various getnetxxx netdb.h functions are available
8257 echo " "
8258 set d_getnetprotos getnetent $i_netdb netdb.h
8259 eval $hasproto
8260
8261
8262 : see if getprotobyname exists
8263 set getprotobyname d_getpbyname
8264 eval $inlibc
8265
8266 : see if getprotobynumber exists
8267 set getprotobynumber d_getpbynumber
8268 eval $inlibc
8269
8270 : see if getprotoent exists
8271 set getprotoent d_getpent
8272 eval $inlibc
8273
8274 : see if getpgid exists
8275 set getpgid d_getpgid
8276 eval $inlibc
8277
8278 : see if getpgrp2 exists
8279 set getpgrp2 d_getpgrp2
8280 eval $inlibc
8281
8282 : see if getppid exists
8283 set getppid d_getppid
8284 eval $inlibc
8285
8286 : see if getpriority exists
8287 set getpriority d_getprior
8288 eval $inlibc
8289
8290 : see if prototypes for various getprotoxxx netdb.h functions are available
8291 echo " "
8292 set d_getprotoprotos getprotoent $i_netdb netdb.h
8293 eval $hasproto
8294
8295 : see if getpwent exists
8296 set getpwent d_getpwent
8297 eval $inlibc
8298
8299
8300 : see if getservbyname exists
8301 set getservbyname d_getsbyname
8302 eval $inlibc
8303
8304 : see if getservbyport exists
8305 set getservbyport d_getsbyport
8306 eval $inlibc
8307
8308 : see if getservent exists
8309 set getservent d_getsent
8310 eval $inlibc
8311
8312 : see if prototypes for various getservxxx netdb.h functions are available
8313 echo " "
8314 set d_getservprotos getservent $i_netdb netdb.h
8315 eval $hasproto
8316
8317 : see if getspent exists
8318 set getspent d_getspent
8319 eval $inlibc
8320
8321 : see if getspnam exists
8322 set getspnam d_getspnam
8323 eval $inlibc
8324
8325 : see if gettimeofday or ftime exists
8326 set gettimeofday d_gettimeod
8327 eval $inlibc
8328 case "$d_gettimeod" in
8329 "$undef")
8330         set ftime d_ftime 
8331         eval $inlibc
8332         ;;
8333 *)
8334         val="$undef"; set d_ftime; eval $setvar
8335         ;;
8336 esac
8337 case "$d_gettimeod$d_ftime" in
8338 "$undef$undef")
8339         echo " "
8340         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8341         ;;
8342 esac
8343
8344 : see if this is an grp system
8345 set grp.h i_grp
8346 eval $inhdr
8347
8348 case "$i_grp" in
8349 $define)
8350         xxx=`./findhdr grp.h`
8351         $cppstdin $cppflags $cppminus < $xxx >$$.h
8352
8353         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8354                 val="$define"
8355         else
8356                 val="$undef"
8357         fi
8358         set d_grpasswd
8359         eval $setvar
8360
8361         $rm -f $$.h
8362         ;;
8363 *)
8364         val="$undef";
8365         set d_grpasswd; eval $setvar
8366         ;;
8367 esac
8368
8369 : see if hasmntopt exists
8370 set hasmntopt d_hasmntopt
8371 eval $inlibc
8372
8373 : see if this is a netinet/in.h or sys/in.h system
8374 set netinet/in.h i_niin sys/in.h i_sysin
8375 eval $inhdr
8376
8377 : see if arpa/inet.h has to be included
8378 set arpa/inet.h i_arpainet
8379 eval $inhdr
8380
8381 : see if htonl --and friends-- exists
8382 val=''
8383 set htonl val
8384 eval $inlibc
8385
8386 : Maybe they are macros.
8387 case "$val" in
8388 $undef)
8389         $cat >htonl.c <<EOM
8390 #include <stdio.h>
8391 #include <sys/types.h>
8392 #$i_niin I_NETINET_IN
8393 #$i_sysin I_SYS_IN
8394 #$i_arpainet I_ARPA_INET
8395 #ifdef I_NETINET_IN
8396 #include <netinet/in.h>
8397 #endif
8398 #ifdef I_SYS_IN
8399 #include <sys/in.h>
8400 #endif
8401 #ifdef I_ARPA_INET
8402 #include <arpa/inet.h>
8403 #endif
8404 #ifdef htonl
8405 printf("Defined as a macro.");
8406 #endif
8407 EOM
8408         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8409         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8410                 val="$define"
8411                 echo "But it seems to be defined as a macro." >&4
8412         fi
8413         $rm -f htonl.?
8414         ;;
8415 esac
8416 set d_htonl
8417 eval $setvar
8418
8419 : see which of string.h or strings.h is needed
8420 echo " "
8421 strings=`./findhdr string.h`
8422 if $test "$strings" && $test -r "$strings"; then
8423         echo "Using <string.h> instead of <strings.h>." >&4
8424         val="$define"
8425 else
8426         val="$undef"
8427         strings=`./findhdr strings.h`
8428         if $test "$strings" && $test -r "$strings"; then
8429                 echo "Using <strings.h> instead of <string.h>." >&4
8430         else
8431                 echo "No string header found -- You'll surely have problems." >&4
8432         fi
8433 fi
8434 set i_string
8435 eval $setvar
8436 case "$i_string" in
8437 "$undef") strings=`./findhdr strings.h`;;
8438 *)        strings=`./findhdr string.h`;;
8439 esac
8440
8441 : index or strchr
8442 echo " "
8443 if set index val -f; eval $csym; $val; then
8444         if set strchr val -f d_strchr; eval $csym; $val; then
8445                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8446                         val="$define"
8447                         vali="$undef"
8448                         echo "strchr() found." >&4
8449                 else
8450                         val="$undef"
8451                         vali="$define"
8452                         echo "index() found." >&4
8453                 fi
8454         else
8455                 val="$undef"
8456                 vali="$define"
8457                 echo "index() found." >&4
8458         fi
8459 else
8460         if set strchr val -f d_strchr; eval $csym; $val; then
8461                 val="$define"
8462                 vali="$undef"
8463                 echo "strchr() found." >&4
8464         else
8465                 echo "No index() or strchr() found!" >&4
8466                 val="$undef"
8467                 vali="$undef"
8468         fi
8469 fi
8470 set d_strchr; eval $setvar
8471 val="$vali"
8472 set d_index; eval $setvar
8473
8474 : check whether inet_aton exists
8475 set inet_aton d_inetaton
8476 eval $inlibc
8477
8478 : see if inttypes.h is available
8479 : we want a real compile instead of Inhdr because some systems
8480 : have an inttypes.h which includes non-existent headers
8481 echo " "
8482 $cat >try.c <<EOCP
8483 #include <inttypes.h>
8484 int main() {
8485         static int32_t foo32 = 0x12345678;
8486 }
8487 EOCP
8488 set try
8489 if eval $compile; then
8490         echo "<inttypes.h> found." >&4
8491         val="$define"
8492 else
8493         echo "<inttypes.h> NOT found." >&4
8494         val="$undef"
8495 fi
8496 $rm -f try.c try
8497 set i_inttypes
8498 eval $setvar
8499
8500 : check for int64_t
8501 case "$use64bits" in
8502 "$define" )
8503         echo " "
8504         echo $n "Checking to see if your system supports int64_t...$c" >&4
8505         $cat >try.c <<EOCP
8506 #include <sys/types.h>
8507 #$i_inttypes I_INTTYPES
8508 #ifdef I_INTTYPES
8509 #include <inttypes.h>
8510 #endif
8511 int64_t foo() { int64_t x; x = 7; return x; }
8512 EOCP
8513         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8514                 val="$define"
8515                 echo " Yup, it does." >&4
8516         else
8517                 val="$undef"
8518                 echo " Nope, it doesn't." >&4
8519         fi
8520         $rm -f try.*
8521         ;;
8522 *)      val="$undef"
8523         ;;
8524 esac
8525 set d_int64t
8526 eval $setvar
8527
8528
8529 : Look for isascii
8530 echo " "
8531 $cat >isascii.c <<'EOCP'
8532 #include <stdio.h>
8533 #include <ctype.h>
8534 int main() {
8535         int c = 'A';
8536         if (isascii(c))
8537                 exit(0);
8538         else
8539                 exit(1);
8540 }
8541 EOCP
8542 set isascii
8543 if eval $compile; then
8544         echo "isascii() found." >&4
8545         val="$define"
8546 else
8547         echo "isascii() NOT found." >&4
8548         val="$undef"
8549 fi
8550 set d_isascii
8551 eval $setvar
8552 $rm -f isascii*
8553
8554 : see if killpg exists
8555 set killpg d_killpg
8556 eval $inlibc
8557
8558 : see if lchown exists
8559 echo " "
8560 $cat > try.c <<'EOCP'
8561 /* System header to define __stub macros and hopefully few prototypes,
8562     which can conflict with char lchown(); below.  */
8563 #include <assert.h>
8564 /* Override any gcc2 internal prototype to avoid an error.  */
8565 /* We use char because int might match the return type of a gcc2
8566    builtin and then its argument prototype would still apply.  */
8567 char lchown();
8568 int main() {
8569     /*  The GNU C library defines this for functions which it implements
8570         to always fail with ENOSYS.  Some functions are actually named
8571         something starting with __ and the normal name is an alias.  */
8572 #if defined (__stub_lchown) || defined (__stub___lchown)
8573 choke me
8574 #else
8575 lchown();
8576 #endif
8577 ; return 0; }
8578 EOCP
8579 set try
8580 if eval $compile; then
8581     $echo "lchown() found." >&4
8582     val="$define"
8583 else
8584     $echo "lchown() NOT found." >&4
8585     val="$undef"
8586 fi
8587 set d_lchown
8588 eval $setvar
8589
8590 : see if link exists
8591 set link d_link
8592 eval $inlibc
8593
8594 : see if localeconv exists
8595 set localeconv d_locconv
8596 eval $inlibc
8597
8598 : see if lockf exists
8599 set lockf d_lockf
8600 eval $inlibc
8601
8602 : check for length of double
8603 echo " "
8604 case "$doublesize" in
8605 '')
8606         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8607         $cat >try.c <<'EOCP'
8608 #include <stdio.h>
8609 int main()
8610 {
8611         printf("%d\n", sizeof(double));
8612 }
8613 EOCP
8614         set try
8615         if eval $compile_ok; then
8616                 doublesize=`./try`
8617                 $echo " $doublesize bytes." >&4
8618         else
8619                 dflt='8'
8620                 echo "(I can't seem to compile the test program.  Guessing...)"
8621                 rp="What is the size of a double precision number (in bytes)?"
8622                 . ./myread
8623                 doublesize="$ans"
8624         fi
8625         ;;
8626 esac
8627 $rm -f try.c try
8628
8629 : check for long doubles
8630 echo " "
8631 echo $n "Checking to see if your system supports long doubles...$c" >&4
8632 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8633 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8634         val="$define"
8635         echo " Yup, it does." >&4
8636 else
8637         val="$undef"
8638         echo " Nope, it doesn't." >&4
8639 fi
8640 $rm try.*
8641 set d_longdbl
8642 eval $setvar
8643
8644 : check for length of long double
8645 case "${d_longdbl}${longdblsize}" in
8646 $define)
8647         echo " "
8648         $echo $n "Checking to see how big your long doubles are...$c" >&4
8649         $cat >try.c <<'EOCP'
8650 #include <stdio.h>
8651 int main()
8652 {
8653         printf("%d\n", sizeof(long double));
8654 }
8655 EOCP
8656         set try
8657         if eval $compile; then
8658                 longdblsize=`./try`
8659                 $echo " $longdblsize bytes." >&4
8660         else
8661                 dflt='8'
8662                 echo " "
8663                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8664                 rp="What is the size of a long double (in bytes)?"
8665                 . ./myread
8666                 longdblsize="$ans"
8667         fi
8668         if $test "X$doublesize" = "X$longdblsize"; then
8669                 echo "(That isn't any different from an ordinary double.)"
8670         fi      
8671         ;;
8672 esac
8673 $rm -f try.c try
8674
8675 : check for long long
8676 echo " "
8677 echo $n "Checking to see if your system supports long long...$c" >&4
8678 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8679 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8680         val="$define"
8681         echo " Yup, it does." >&4
8682 else
8683         val="$undef"
8684         echo " Nope, it doesn't." >&4
8685 fi
8686 $rm try.*
8687 set d_longlong
8688 eval $setvar
8689
8690 : check for length of long long
8691 case "${d_longlong}${longlongsize}" in
8692 $define)
8693         echo " "
8694         $echo $n "Checking to see how big your long longs are...$c" >&4
8695         $cat >try.c <<'EOCP'
8696 #include <stdio.h>
8697 int main()
8698 {
8699         printf("%d\n", sizeof(long long));
8700 }
8701 EOCP
8702         set try
8703         if eval $compile_ok; then
8704                 longlongsize=`./try`
8705                 $echo " $longlongsize bytes." >&4
8706         else
8707                 dflt='8'
8708                 echo " "
8709                 echo "(I can't seem to compile the test program.  Guessing...)"
8710                 rp="What is the size of a long long (in bytes)?"
8711                 . ./myread
8712                 longlongsize="$ans"
8713         fi
8714         if $test "X$longsize" = "X$longlongsize"; then
8715                 echo "(That isn't any different from an ordinary long.)"
8716         fi      
8717         ;;
8718 esac
8719 $rm -f try.c try
8720
8721 : see if lstat exists
8722 set lstat d_lstat
8723 eval $inlibc
8724
8725 : see if madvise exists
8726 set madvise d_madvise
8727 eval $inlibc
8728
8729 : see if mblen exists
8730 set mblen d_mblen
8731 eval $inlibc
8732
8733 : see if mbstowcs exists
8734 set mbstowcs d_mbstowcs
8735 eval $inlibc
8736
8737 : see if mbtowc exists
8738 set mbtowc d_mbtowc
8739 eval $inlibc
8740
8741 : see if memchr exists
8742 set memchr d_memchr
8743 eval $inlibc
8744
8745 : see if memcmp exists
8746 set memcmp d_memcmp
8747 eval $inlibc
8748
8749 : see if memcpy exists
8750 set memcpy d_memcpy
8751 eval $inlibc
8752
8753 : see if memmove exists
8754 set memmove d_memmove
8755 eval $inlibc
8756
8757 : see if memset exists
8758 set memset d_memset
8759 eval $inlibc
8760
8761 : see if mkdir exists
8762 set mkdir d_mkdir
8763 eval $inlibc
8764
8765 : see if mkfifo exists
8766 set mkfifo d_mkfifo
8767 eval $inlibc
8768
8769 : see if mktime exists
8770 set mktime d_mktime
8771 eval $inlibc
8772
8773 : see if this is a sys/mman.h system
8774 set sys/mman.h i_sysmman
8775 eval $inhdr
8776
8777 : see if mmap exists
8778 set mmap d_mmap
8779 eval $inlibc
8780 : see what shmat returns
8781 : default to something harmless
8782 mmaptype='void *'
8783 case "$i_sysmman$d_mmap" in
8784 "$define$define")
8785         $cat >mmap.c <<'END'
8786 #include <sys/mman.h>
8787 void *mmap();
8788 END
8789         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8790                 mmaptype='void *'
8791         else
8792                 mmaptype='caddr_t'
8793         fi
8794         echo "and it returns ($mmaptype)." >&4
8795         ;;
8796 esac
8797
8798
8799
8800 : see if mprotect exists
8801 set mprotect d_mprotect
8802 eval $inlibc
8803
8804 : see if msgctl exists
8805 set msgctl d_msgctl
8806 eval $inlibc
8807
8808 : see if msgget exists
8809 set msgget d_msgget
8810 eval $inlibc
8811
8812 : see if msgsnd exists
8813 set msgsnd d_msgsnd
8814 eval $inlibc
8815
8816 : see if msgrcv exists
8817 set msgrcv d_msgrcv
8818 eval $inlibc
8819
8820 : see how much of the 'msg*(2)' library is present.
8821 h_msg=true
8822 echo " "
8823 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8824 *"$undef"*) h_msg=false;;
8825 esac
8826 case "$osname" in
8827 freebsd)
8828     case "`ipcs 2>&1`" in
8829     "SVID messages"*"not configured"*)
8830         echo "Your $osname does not have the msg*(2) configured." >&4
8831         h_msg=false
8832         val="$undef"
8833         set msgctl d_msgctl
8834         eval $setvar
8835         set msgget d_msgget
8836         eval $setvar
8837         set msgsnd d_msgsnd
8838         eval $setvar
8839         set msgrcv d_msgrcv
8840         eval $setvar
8841         ;;
8842     esac
8843     ;;
8844 esac
8845 : we could also check for sys/ipc.h ...
8846 if $h_msg && $test `./findhdr sys/msg.h`; then
8847         echo "You have the full msg*(2) library." >&4
8848         val="$define"
8849 else
8850         echo "You don't have the full msg*(2) library." >&4
8851         val="$undef"
8852 fi
8853 set d_msg
8854 eval $setvar
8855
8856 : see if msync exists
8857 set msync d_msync
8858 eval $inlibc
8859
8860 : see if munmap exists
8861 set munmap d_munmap
8862 eval $inlibc
8863
8864 : see if nice exists
8865 set nice d_nice
8866 eval $inlibc
8867
8868 : see if POSIX threads are available
8869 if test "X$usethreads" = "X$define"; then
8870         set pthread.h i_pthread
8871         eval $inhdr
8872 else
8873         i_pthread="$undef"
8874 fi
8875
8876
8877
8878 : how to create joinable pthreads
8879 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
8880         echo " "
8881         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8882         $cat >try.c <<'EOCP'
8883 #include <pthread.h>
8884 int main() {
8885     int detachstate = JOINABLE;
8886 }
8887 EOCP
8888         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8889         if eval $compile; then
8890                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8891                 val="$undef" # Yes, undef.
8892                 set d_old_pthread_create_joinable
8893                 eval $setvar
8894                 val=""
8895                 set old_pthread_create_joinable
8896                 eval $setvar
8897         else
8898                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8899                 if eval $compile; then
8900                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8901                         val="$define"
8902                         set d_old_pthread_create_joinable
8903                         eval $setvar
8904                         val=PTHREAD_CREATE_UNDETACHED
8905                         set old_pthread_create_joinable
8906                         eval $setvar
8907                 else            
8908                         set try -DJOINABLE=__UNDETACHED
8909                         if eval $compile; then
8910                                 echo "You seem to use __UNDETACHED." >&4
8911                                 val="$define"
8912                                 set d_old_pthread_create_joinable
8913                                 eval $setvar
8914                                 val=__UNDETACHED
8915                                 set old_pthread_create_joinable
8916                                 eval $setvar
8917                         else
8918                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8919                                 val="$define"
8920                                 set d_old_pthread_create_joinable
8921                                 eval $setvar
8922                                 val=0
8923                                 set old_pthread_create_joinable
8924                                 eval $setvar
8925                         fi
8926                 fi
8927         fi
8928         $rm -f try try.*
8929 else
8930     d_old_pthread_create_joinable="$undef"
8931     old_pthread_create_joinable=""
8932 fi
8933
8934 : see if pause exists
8935 set pause d_pause
8936 eval $inlibc
8937
8938 : see if pipe exists
8939 set pipe d_pipe
8940 eval $inlibc
8941
8942 : see if poll exists
8943 set poll d_poll
8944 eval $inlibc
8945
8946
8947 : see whether the various POSIXish _yields exist
8948 $cat >try.c <<EOP
8949 #include <pthread.h>
8950 #include <stdio.h>
8951 int main() {
8952 #ifdef SCHED_YIELD
8953         sched_yield();
8954 #else
8955 #ifdef PTHREAD_YIELD
8956         pthread_yield();
8957 #else
8958 #ifdef PTHREAD_YIELD_NULL
8959         pthread_yield(NULL);
8960 #endif
8961 #endif
8962 #endif
8963 }
8964 EOP
8965 : see if sched_yield exists
8966 set try -DSCHED_YIELD
8967 if eval $compile; then
8968     val="$define"
8969     sched_yield='sched_yield()'
8970 else
8971     val="$undef"
8972 fi
8973 case "$usethreads" in
8974 $define)
8975         case "$val" in
8976         $define) echo 'sched_yield() found.' >&4        ;;
8977         *)       echo 'sched_yield() NOT found.' >&4    ;;
8978         esac
8979 esac
8980 set d_sched_yield
8981 eval $setvar
8982
8983 : see if pthread_yield exists
8984 set try -DPTHREAD_YIELD
8985 if eval $compile; then
8986     val="$define"
8987     case "$sched_yield" in
8988     '') sched_yield='pthread_yield()' ;;
8989     esac
8990 else
8991     set try -DPTHREAD_YIELD_NULL
8992     if eval $compile; then
8993         val="$define"
8994         case "$sched_yield" in
8995         '') sched_yield='pthread_yield(NULL)' ;;
8996         esac
8997     else
8998         val="$undef"
8999     fi
9000 fi
9001 case "$usethreads" in
9002 $define)
9003         case "$val" in
9004         $define) echo 'pthread_yield() found.' >&4      ;;
9005         *)       echo 'pthread_yield() NOT found.' >&4  ;;
9006         esac
9007         ;;
9008 esac
9009 set d_pthread_yield
9010 eval $setvar
9011
9012 case "$sched_yield" in
9013 '') sched_yield=undef ;;
9014 esac
9015
9016 $rm -f try try.*
9017
9018 : see if this is a pwd.h system
9019 set pwd.h i_pwd
9020 eval $inhdr
9021
9022 case "$i_pwd" in
9023 $define)
9024         xxx=`./findhdr pwd.h`
9025         $cppstdin $cppflags $cppminus < $xxx >$$.h
9026
9027         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
9028                 val="$define"
9029         else
9030                 val="$undef"
9031         fi
9032         set d_pwquota
9033         eval $setvar
9034
9035         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
9036                 val="$define"
9037         else
9038                 val="$undef"
9039         fi
9040         set d_pwage
9041         eval $setvar
9042
9043         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
9044                 val="$define"
9045         else
9046                 val="$undef"
9047         fi
9048         set d_pwchange
9049         eval $setvar
9050
9051         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
9052                 val="$define"
9053         else
9054                 val="$undef"
9055         fi
9056         set d_pwclass
9057         eval $setvar
9058
9059         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
9060                 val="$define"
9061         else
9062                 val="$undef"
9063         fi
9064         set d_pwexpire
9065         eval $setvar
9066
9067         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
9068                 val="$define"
9069         else
9070                 val="$undef"
9071         fi
9072         set d_pwcomment
9073         eval $setvar
9074
9075         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
9076                 val="$define"
9077         else
9078                 val="$undef"
9079         fi
9080         set d_pwgecos
9081         eval $setvar
9082
9083         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
9084                 val="$define"
9085         else
9086                 val="$undef"
9087         fi
9088         set d_pwpasswd
9089         eval $setvar
9090
9091         $rm -f $$.h
9092         ;;
9093 *)
9094         val="$undef"; 
9095         set d_pwquota; eval $setvar
9096         set d_pwage; eval $setvar
9097         set d_pwchange; eval $setvar
9098         set d_pwclass; eval $setvar
9099         set d_pwexpire; eval $setvar
9100         set d_pwcomment; eval $setvar
9101         set d_pwgecos; eval $setvar
9102         set d_pwpasswd; eval $setvar
9103         ;;
9104 esac
9105
9106 : see if readdir and friends exist
9107 set readdir d_readdir
9108 eval $inlibc
9109 set seekdir d_seekdir
9110 eval $inlibc
9111 set telldir d_telldir
9112 eval $inlibc
9113 set rewinddir d_rewinddir
9114 eval $inlibc
9115
9116 : see if readlink exists
9117 set readlink d_readlink
9118 eval $inlibc
9119
9120 : see if readv exists
9121 set readv d_readv
9122 eval $inlibc
9123
9124 : see if rename exists
9125 set rename d_rename
9126 eval $inlibc
9127
9128 : see if rmdir exists
9129 set rmdir d_rmdir
9130 eval $inlibc
9131
9132 : see if memory.h is available.
9133 val=''
9134 set memory.h val
9135 eval $inhdr
9136
9137 : See if it conflicts with string.h
9138 case "$val" in
9139 $define)
9140         case "$strings" in
9141         '') ;;
9142         *)
9143                 $cppstdin $cppflags $cppminus < $strings > mem.h
9144                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9145                         echo " "
9146                         echo "We won't be including <memory.h>."
9147                         val="$undef"
9148                 fi
9149                 $rm -f mem.h
9150                 ;;
9151         esac
9152 esac
9153 set i_memory
9154 eval $setvar
9155
9156 : can bcopy handle overlapping blocks?
9157 val="$undef"
9158 case "$d_bcopy" in
9159 "$define")
9160         echo " "
9161         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9162         $cat >try.c <<EOCP
9163 #$i_memory I_MEMORY
9164 #$i_stdlib I_STDLIB
9165 #$i_string I_STRING
9166 #$i_unistd I_UNISTD
9167 EOCP
9168         $cat >>try.c <<'EOCP'
9169 #include <stdio.h>
9170 #ifdef I_MEMORY
9171 #  include <memory.h>
9172 #endif
9173 #ifdef I_STDLIB
9174 #  include <stdlib.h>
9175 #endif
9176 #ifdef I_STRING
9177 #  include <string.h>
9178 #else
9179 #  include <strings.h>
9180 #endif
9181 #ifdef I_UNISTD
9182 #  include <unistd.h>  /* Needed for NetBSD */
9183 #endif
9184 int main()
9185 {
9186 char buf[128], abc[128];
9187 char *b;
9188 int len;
9189 int off;
9190 int align;
9191
9192 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9193
9194 for (align = 7; align >= 0; align--) {
9195         for (len = 36; len; len--) {
9196                 b = buf+align;
9197                 bcopy(abc, b, len);
9198                 for (off = 1; off <= len; off++) {
9199                         bcopy(b, b+off, len);
9200                         bcopy(b+off, b, len);
9201                         if (bcmp(b, abc, len))
9202                                 exit(1);
9203                 }
9204         }
9205 }
9206 exit(0);
9207 }
9208 EOCP
9209         set try
9210         if eval $compile_ok; then
9211                 if ./try 2>/dev/null; then
9212                         echo "Yes, it can."
9213                         val="$define"
9214                 else
9215                         echo "It can't, sorry."
9216                         case "$d_memmove" in
9217                         "$define") echo "But that's Ok since you have memmove()." ;;
9218                         esac
9219                 fi
9220         else
9221                 echo "(I can't compile the test program, so we'll assume not...)"
9222                 case "$d_memmove" in
9223                 "$define") echo "But that's Ok since you have memmove()." ;;
9224                 esac
9225         fi
9226         ;;
9227 esac
9228 $rm -f try.* try core
9229 set d_safebcpy
9230 eval $setvar
9231
9232 : can memcpy handle overlapping blocks?
9233 val="$undef"
9234 case "$d_memcpy" in
9235 "$define")
9236         echo " "
9237         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9238         $cat >try.c <<EOCP
9239 #$i_memory I_MEMORY
9240 #$i_stdlib I_STDLIB
9241 #$i_string I_STRING
9242 #$i_unistd I_UNISTD
9243 EOCP
9244         $cat >>try.c <<'EOCP'
9245 #include <stdio.h>
9246 #ifdef I_MEMORY
9247 #  include <memory.h>
9248 #endif
9249 #ifdef I_STDLIB
9250 #  include <stdlib.h>
9251 #endif
9252 #ifdef I_STRING
9253 #  include <string.h>
9254 #else
9255 #  include <strings.h>
9256 #endif
9257 #ifdef I_UNISTD
9258 #  include <unistd.h>  /* Needed for NetBSD */
9259 #endif
9260 int main()
9261 {
9262 char buf[128], abc[128];
9263 char *b;
9264 int len;
9265 int off;
9266 int align;
9267
9268 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9269    try to store the string in read-only memory. */
9270 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9271
9272 for (align = 7; align >= 0; align--) {
9273         for (len = 36; len; len--) {
9274                 b = buf+align;
9275                 memcpy(b, abc, len);
9276                 for (off = 1; off <= len; off++) {
9277                         memcpy(b+off, b, len);
9278                         memcpy(b, b+off, len);
9279                         if (memcmp(b, abc, len))
9280                                 exit(1);
9281                 }
9282         }
9283 }
9284 exit(0);
9285 }
9286 EOCP
9287         set try
9288         if eval $compile_ok; then
9289                 if ./try 2>/dev/null; then
9290                         echo "Yes, it can."
9291                         val="$define"
9292                 else
9293                         echo "It can't, sorry."
9294                         case "$d_memmove" in
9295                         "$define") echo "But that's Ok since you have memmove()." ;;
9296                         esac
9297                 fi
9298         else
9299                 echo "(I can't compile the test program, so we'll assume not...)"
9300                 case "$d_memmove" in
9301                 "$define") echo "But that's Ok since you have memmove()." ;;
9302                 esac
9303         fi
9304         ;;
9305 esac
9306 $rm -f try.* try core
9307 set d_safemcpy
9308 eval $setvar
9309
9310 : can memcmp be trusted to compare relative magnitude?
9311 val="$undef"
9312 case "$d_memcmp" in
9313 "$define")
9314         echo " "
9315         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9316         $cat >try.c <<EOCP
9317 #$i_memory I_MEMORY
9318 #$i_stdlib I_STDLIB
9319 #$i_string I_STRING
9320 #$i_unistd I_UNISTD
9321 EOCP
9322         $cat >>try.c <<'EOCP'
9323 #include <stdio.h>
9324 #ifdef I_MEMORY
9325 #  include <memory.h>
9326 #endif
9327 #ifdef I_STDLIB
9328 #  include <stdlib.h>
9329 #endif
9330 #ifdef I_STRING
9331 #  include <string.h>
9332 #else
9333 #  include <strings.h>
9334 #endif
9335 #ifdef I_UNISTD
9336 #  include <unistd.h>  /* Needed for NetBSD */
9337 #endif
9338 int main()
9339 {
9340 char a = -1;
9341 char b = 0;
9342 if ((a < b) && memcmp(&a, &b, 1) < 0)
9343         exit(1);
9344 exit(0);
9345 }
9346 EOCP
9347         set try
9348         if eval $compile_ok; then
9349                 if ./try 2>/dev/null; then
9350                         echo "Yes, it can."
9351                         val="$define"
9352                 else
9353                         echo "No, it can't (it uses signed chars)."
9354                 fi
9355         else
9356                 echo "(I can't compile the test program, so we'll assume not...)"
9357         fi
9358         ;;
9359 esac
9360 $rm -f try.* try core
9361 set d_sanemcmp
9362 eval $setvar
9363
9364 : see if select exists
9365 set select d_select
9366 eval $inlibc
9367
9368 : see if semctl exists
9369 set semctl d_semctl
9370 eval $inlibc
9371
9372 : see if semget exists
9373 set semget d_semget
9374 eval $inlibc
9375
9376 : see if semop exists
9377 set semop d_semop
9378 eval $inlibc
9379
9380 : see how much of the 'sem*(2)' library is present.
9381 h_sem=true
9382 echo " "
9383 case "$d_semctl$d_semget$d_semop" in
9384 *"$undef"*) h_sem=false;;
9385 esac
9386 case "$osname" in
9387 freebsd)
9388     case "`ipcs 2>&1`" in
9389     "SVID messages"*"not configured"*)
9390         echo "Your $osname does not have the sem*(2) configured." >&4
9391         h_sem=false
9392         val="$undef"
9393         set semctl d_semctl
9394         eval $setvar
9395         set semget d_semget
9396         eval $setvar
9397         set semop d_semop
9398         eval $setvar
9399         ;;
9400     esac
9401     ;;
9402 esac
9403 : we could also check for sys/ipc.h ...
9404 if $h_sem && $test `./findhdr sys/sem.h`; then
9405         echo "You have the full sem*(2) library." >&4
9406         val="$define"
9407 else
9408         echo "You don't have the full sem*(2) library." >&4
9409         val="$undef"
9410 fi
9411 set d_sem
9412 eval $setvar
9413
9414 : see whether sys/sem.h defines union semun
9415 echo " "
9416 $cat > try.c <<'END'
9417 #include <sys/types.h>
9418 #include <sys/ipc.h>
9419 #include <sys/sem.h>
9420 int main () { union semun semun; semun.buf = 0; }
9421 END
9422 set try
9423 if eval $compile; then
9424     echo "You have union semun in <sys/sem.h>." >&4
9425     val="$define"
9426 else
9427     echo "You do not have union semun in <sys/sem.h>." >&4
9428     val="$undef"
9429 fi
9430 $rm -f try try.c try.h
9431 set d_union_semun
9432 eval $setvar
9433
9434 : see how to do semctl IPC_STAT
9435 case "$d_sem" in
9436 $define)
9437     : see whether semctl IPC_STAT can use union semun
9438     echo " "
9439     $cat > try.h <<END
9440 #ifndef S_IRUSR
9441 #   ifdef S_IREAD
9442 #       define S_IRUSR S_IREAD
9443 #       define S_IWUSR S_IWRITE
9444 #       define S_IXUSR S_IEXEC
9445 #   else
9446 #       define S_IRUSR 0400
9447 #       define S_IWUSR 0200
9448 #       define S_IXUSR 0100
9449 #   endif
9450 #   define S_IRGRP (S_IRUSR>>3)
9451 #   define S_IWGRP (S_IWUSR>>3)
9452 #   define S_IXGRP (S_IXUSR>>3)
9453 #   define S_IROTH (S_IRUSR>>6)
9454 #   define S_IWOTH (S_IWUSR>>6)
9455 #   define S_IXOTH (S_IXUSR>>6)
9456 #endif
9457 #ifndef S_IRWXU
9458 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9459 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9460 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9461 #endif
9462 END
9463
9464     $cat > try.c <<END
9465 #include <sys/types.h>
9466 #include <sys/ipc.h>
9467 #include <sys/sem.h>
9468 #include <sys/stat.h>
9469 #include <stdio.h>
9470 #include <errno.h>
9471 #include "try.h"
9472 #ifndef errno
9473 extern int errno;
9474 #endif
9475 #$d_union_semun HAS_UNION_SEMUN
9476 int main() {
9477     union semun
9478 #ifndef HAS_UNION_SEMUN
9479     {
9480         int val;
9481         struct semid_ds *buf;
9482         unsigned short *array;
9483     }
9484 #endif
9485     arg;
9486     int sem, st;
9487
9488 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9489     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9490     if (sem > -1) {
9491         struct semid_ds argbuf;
9492         arg.buf = &argbuf;
9493 #       ifdef IPC_STAT
9494         st = semctl(sem, 0, IPC_STAT, arg);
9495         if (st == 0)
9496             printf("semun\n");
9497         else
9498 #       endif /* IPC_STAT */
9499             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9500 #       ifdef IPC_RMID
9501         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9502 #       endif /* IPC_RMID */
9503             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9504     } else
9505 #endif /* IPC_PRIVATE && ... */
9506         printf("semget failed: errno = %d\n", errno);
9507   return 0;
9508 }
9509 END
9510     val="$undef"
9511     set try
9512     if eval $compile; then
9513         xxx=`./try`
9514         case "$xxx" in
9515         semun) val="$define" ;;
9516         esac
9517     fi
9518     $rm -f try try.c
9519     set d_semctl_semun
9520     eval $setvar
9521     case "$d_semctl_semun" in
9522     $define)
9523         echo "You can use union semun for semctl IPC_STAT." >&4
9524         also='also'
9525         ;;
9526     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9527         also=''
9528         ;;
9529     esac
9530
9531     : see whether semctl IPC_STAT can use struct semid_ds pointer
9532     $cat > try.c <<'END'
9533 #include <sys/types.h>
9534 #include <sys/ipc.h>
9535 #include <sys/sem.h>
9536 #include <sys/stat.h>
9537 #include "try.h"
9538 #include <stdio.h>
9539 #include <errno.h>
9540 #ifndef errno
9541 extern int errno;
9542 #endif
9543 int main() {
9544     struct semid_ds arg;
9545     int sem, st;
9546
9547 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9548     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9549     if (sem > -1) {
9550 #       ifdef IPC_STAT
9551         st = semctl(sem, 0, IPC_STAT, &arg);
9552         if (st == 0)
9553             printf("semid_ds\n");
9554         else
9555 #       endif /* IPC_STAT */
9556             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9557 #       ifdef IPC_RMID
9558         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9559 #       endif /* IPC_RMID */
9560             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9561     } else
9562 #endif /* IPC_PRIVATE && ... */
9563         printf("semget failed: errno = %d\n", errno);
9564
9565     return 0;
9566 }
9567 END
9568     val="$undef"
9569     set try
9570     if eval $compile; then
9571         xxx=`./try`
9572         case "$xxx" in
9573         semid_ds) val="$define" ;;
9574         esac
9575     fi
9576     $rm -f try try.c
9577     set d_semctl_semid_ds
9578     eval $setvar
9579     case "$d_semctl_semid_ds" in
9580     $define)
9581         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9582         ;;
9583     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9584         ;;
9585     esac
9586     $rm -f try.h
9587     ;;
9588 *)  val="$undef"
9589
9590     # We do not have the full sem*(2) library, so assume we can not
9591     # use either.
9592
9593     set d_semctl_semun
9594     eval $setvar
9595
9596     set d_semctl_semid_ds
9597     eval $setvar
9598     ;;
9599 esac
9600
9601 : see if setegid exists
9602 set setegid d_setegid
9603 eval $inlibc
9604
9605 : see if seteuid exists
9606 set seteuid d_seteuid
9607 eval $inlibc
9608
9609 : see if setgrent exists
9610 set setgrent d_setgrent
9611 eval $inlibc
9612
9613 : see if sethostent exists
9614 set sethostent d_sethent
9615 eval $inlibc
9616
9617 : see if setlinebuf exists
9618 set setlinebuf d_setlinebuf
9619 eval $inlibc
9620
9621 : see if setlocale exists
9622 set setlocale d_setlocale
9623 eval $inlibc
9624
9625 : see if setnetent exists
9626 set setnetent d_setnent
9627 eval $inlibc
9628
9629 : see if setprotoent exists
9630 set setprotoent d_setpent
9631 eval $inlibc
9632
9633 : see if setpgid exists
9634 set setpgid d_setpgid
9635 eval $inlibc
9636
9637 : see if setpgrp2 exists
9638 set setpgrp2 d_setpgrp2
9639 eval $inlibc
9640
9641 : see if setpriority exists
9642 set setpriority d_setprior
9643 eval $inlibc
9644
9645 : see if setpwent exists
9646 set setpwent d_setpwent
9647 eval $inlibc
9648
9649 : see if setregid exists
9650 set setregid d_setregid
9651 eval $inlibc
9652 set setresgid d_setresgid
9653 eval $inlibc
9654
9655 : see if setreuid exists
9656 set setreuid d_setreuid
9657 eval $inlibc
9658 set setresuid d_setresuid
9659 eval $inlibc
9660
9661 : see if setrgid exists
9662 set setrgid d_setrgid
9663 eval $inlibc
9664
9665 : see if setruid exists
9666 set setruid d_setruid
9667 eval $inlibc
9668
9669 : see if setservent exists
9670 set setservent d_setsent
9671 eval $inlibc
9672
9673 : see if setsid exists
9674 set setsid d_setsid
9675 eval $inlibc
9676
9677 : see if setspent exists
9678 set setspent d_setspent
9679 eval $inlibc
9680
9681 : see if setvbuf exists
9682 set setvbuf d_setvbuf
9683 eval $inlibc
9684
9685 : see if sfio.h is available
9686 set sfio.h i_sfio
9687 eval $inhdr
9688
9689
9690 : see if sfio library is available
9691 case "$i_sfio" in
9692 $define)
9693         val=''
9694         set sfreserve val
9695         eval $inlibc
9696         ;;
9697 *)
9698         val="$undef"
9699         ;;
9700 esac
9701 : Ok, but do we want to use it.
9702 case "$val" in
9703 $define)
9704         case "$usesfio" in
9705         true|$define|[yY]*) dflt='y';;
9706         *) dflt='n';;
9707         esac
9708         echo "$package can use the sfio library, but it is experimental."
9709         rp="You seem to have sfio available, do you want to try using it?"
9710         . ./myread
9711         case "$ans" in
9712         y|Y) ;;
9713         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9714                 val="$undef"
9715                 : Remove sfio from list of libraries to use
9716                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9717                 shift
9718                 libs="$*"
9719                 echo "libs = $libs" >&4
9720                 ;;
9721         esac
9722         ;;
9723 *)      case "$usesfio" in
9724         true|$define|[yY]*)
9725                 echo "Sorry, cannot find sfio on this machine" >&4
9726                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9727                 ;;
9728         esac
9729         ;;
9730 esac
9731 set d_sfio
9732 eval $setvar
9733 case "$d_sfio" in
9734 $define) usesfio='true';;
9735 *) usesfio='false';;
9736 esac
9737
9738 : see if shmctl exists
9739 set shmctl d_shmctl
9740 eval $inlibc
9741
9742 : see if shmget exists
9743 set shmget d_shmget
9744 eval $inlibc
9745
9746 : see if shmat exists
9747 set shmat d_shmat
9748 eval $inlibc
9749 : see what shmat returns
9750 case "$d_shmat" in
9751 "$define")
9752         $cat >shmat.c <<'END'
9753 #include <sys/shm.h>
9754 void *shmat();
9755 END
9756         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9757                 shmattype='void *'
9758         else
9759                 shmattype='char *'
9760         fi
9761         echo "and it returns ($shmattype)." >&4
9762         : see if a prototype for shmat is available
9763         xxx=`./findhdr sys/shm.h`
9764         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9765         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9766                 val="$define"
9767         else
9768                 val="$undef"
9769         fi
9770         $rm -f shmat.[co]
9771         ;;
9772 *)
9773         val="$undef"
9774         ;;
9775 esac
9776 set d_shmatprototype
9777 eval $setvar
9778
9779 : see if shmdt exists
9780 set shmdt d_shmdt
9781 eval $inlibc
9782
9783 : see how much of the 'shm*(2)' library is present.
9784 h_shm=true
9785 echo " "
9786 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9787 *"$undef"*) h_shm=false;;
9788 esac
9789 case "$osname" in
9790 freebsd)
9791     case "`ipcs 2>&1`" in
9792     "SVID shared memory"*"not configured"*)
9793         echo "Your $osname does not have the shm*(2) configured." >&4
9794         h_shm=false
9795         val="$undef"
9796         set shmctl d_shmctl
9797         evat $setvar
9798         set shmget d_shmget
9799         evat $setvar
9800         set shmat d_shmat
9801         evat $setvar
9802         set shmdt d_shmdt
9803         evat $setvar
9804         ;;
9805     esac
9806     ;;
9807 esac
9808 : we could also check for sys/ipc.h ...
9809 if $h_shm && $test `./findhdr sys/shm.h`; then
9810         echo "You have the full shm*(2) library." >&4
9811         val="$define"
9812 else
9813         echo "You don't have the full shm*(2) library." >&4
9814         val="$undef"
9815 fi
9816 set d_shm
9817 eval $setvar
9818
9819 echo " "
9820 : see if we have sigaction
9821 if set sigaction val -f d_sigaction; eval $csym; $val; then
9822         echo 'sigaction() found.' >&4
9823         $cat > try.c <<'EOP'
9824 #include <stdio.h>
9825 #include <sys/types.h>
9826 #include <signal.h>
9827 int main()
9828 {
9829     struct sigaction act, oact;
9830 }
9831 EOP
9832         set try
9833         if eval $compile_ok; then
9834                 val="$define"
9835         else
9836                 echo "But you don't seem to have a useable struct sigaction." >&4
9837                 val="$undef"
9838         fi
9839 else
9840         echo 'sigaction NOT found.' >&4
9841         val="$undef"
9842 fi
9843 set d_sigaction; eval $setvar
9844 $rm -f try try$_o try.c
9845
9846 : see if sigsetjmp exists
9847 echo " "
9848 case "$d_sigsetjmp" in
9849 '')
9850         $cat >try.c <<'EOP'
9851 #include <setjmp.h>
9852 sigjmp_buf env;
9853 int set = 1;
9854 int main()
9855 {
9856         if (sigsetjmp(env,1))
9857                 exit(set);
9858         set = 0;
9859         siglongjmp(env, 1);
9860         exit(1);
9861 }
9862 EOP
9863         set try
9864         if eval $compile; then
9865                 if ./try >/dev/null 2>&1; then
9866                         echo "POSIX sigsetjmp found." >&4
9867                         val="$define"
9868                 else
9869                         $cat >&4 <<EOM
9870 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9871 I'll ignore them.
9872 EOM
9873                         val="$undef"
9874                 fi
9875         else
9876                 echo "sigsetjmp not found." >&4
9877                 val="$undef"
9878         fi
9879         ;;
9880 *) val="$d_sigsetjmp"
9881         case "$d_sigsetjmp" in
9882         $define) echo "POSIX sigsetjmp found." >&4;;
9883         $undef) echo "sigsetjmp not found." >&4;;
9884         esac
9885         ;;
9886 esac
9887 set d_sigsetjmp
9888 eval $setvar
9889 $rm -f try.c try
9890
9891 : see if stat knows about block sizes
9892 echo " "
9893 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9894 eval $hasfield
9895
9896 : see if _ptr and _cnt from stdio act std
9897 echo " "
9898 if $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
9899         echo "(Looks like you have stdio.h from Linux.)"
9900         case "$stdio_ptr" in
9901         '') stdio_ptr='((fp)->_IO_read_ptr)'
9902                 ptr_lval=$define
9903                 ;;
9904         *)      ptr_lval=$d_stdio_ptr_lval;;
9905         esac
9906         case "$stdio_cnt" in
9907         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9908                 cnt_lval=$undef
9909                 ;;
9910         *)      cnt_lval=$d_stdio_cnt_lval;;
9911         esac
9912         case "$stdio_base" in
9913         '') stdio_base='((fp)->_IO_read_base)';;
9914         esac
9915         case "$stdio_bufsiz" in
9916         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9917         esac
9918 else
9919         case "$stdio_ptr" in
9920         '') stdio_ptr='((fp)->_ptr)'
9921                 ptr_lval=$define
9922                 ;;
9923         *)      ptr_lval=$d_stdio_ptr_lval;;
9924         esac
9925         case "$stdio_cnt" in
9926         '') stdio_cnt='((fp)->_cnt)'
9927                 cnt_lval=$define
9928                 ;;
9929         *)      cnt_lval=$d_stdio_cnt_lval;;
9930         esac
9931         case "$stdio_base" in
9932         '') stdio_base='((fp)->_base)';;
9933         esac
9934         case "$stdio_bufsiz" in
9935         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9936         esac
9937 fi
9938 : test whether _ptr and _cnt really work
9939 echo "Checking how std your stdio is..." >&4
9940 $cat >try.c <<EOP
9941 #include <stdio.h>
9942 #define FILE_ptr(fp)    $stdio_ptr
9943 #define FILE_cnt(fp)    $stdio_cnt
9944 int main() {
9945         FILE *fp = fopen("try.c", "r");
9946         char c = getc(fp);
9947         if (
9948                 18 <= FILE_cnt(fp) &&
9949                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9950         )
9951                 exit(0);
9952         exit(1);
9953 }
9954 EOP
9955 val="$undef"
9956 set try
9957 if eval $compile; then
9958         if ./try; then
9959                 echo "Your stdio acts pretty std."
9960                 val="$define"
9961         else
9962                 echo "Your stdio isn't very std."
9963         fi
9964 else
9965         echo "Your stdio doesn't appear very std."
9966 fi
9967 $rm -f try.c try
9968 set d_stdstdio
9969 eval $setvar
9970
9971 : Can _ptr be used as an lvalue?
9972 case "$d_stdstdio$ptr_lval" in
9973 $define$define) val=$define ;;
9974 *) val=$undef ;;
9975 esac
9976 set d_stdio_ptr_lval
9977 eval $setvar
9978
9979 : Can _cnt be used as an lvalue?
9980 case "$d_stdstdio$cnt_lval" in
9981 $define$define) val=$define ;;
9982 *) val=$undef ;;
9983 esac
9984 set d_stdio_cnt_lval
9985 eval $setvar
9986
9987 : see if _base is also standard
9988 val="$undef"
9989 case "$d_stdstdio" in
9990 $define)
9991         $cat >try.c <<EOP
9992 #include <stdio.h>
9993 #define FILE_base(fp)   $stdio_base
9994 #define FILE_bufsiz(fp) $stdio_bufsiz
9995 int main() {
9996         FILE *fp = fopen("try.c", "r");
9997         char c = getc(fp);
9998         if (
9999                 19 <= FILE_bufsiz(fp) &&
10000                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
10001         )
10002                 exit(0);
10003         exit(1);
10004 }
10005 EOP
10006         set try
10007         if eval $compile; then
10008                 if ./try; then
10009                         echo "And its _base field acts std."
10010                         val="$define"
10011                 else
10012                         echo "But its _base field isn't std."
10013                 fi
10014         else
10015                 echo "However, it seems to be lacking the _base field."
10016         fi
10017         $rm -f try.c try
10018         ;;
10019 esac
10020 set d_stdiobase
10021 eval $setvar
10022
10023 $cat >&4 <<EOM
10024 Checking how to access stdio streams by file descriptor number...
10025 EOM
10026 case "$stdio_stream_array" in
10027 '')     $cat >try.c <<EOCP
10028 #include <stdio.h>
10029 int main() {
10030   if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
10031     printf("yes\n");
10032 }
10033 EOCP
10034         for s in _iob __iob __sF
10035         do
10036                 set try -DSTDIO_STREAM_ARRAY=$s
10037                 if eval $compile; then
10038                         case "`./try$exe_ext`" in
10039                         yes)    stdio_stream_array=$s; break ;;
10040                         esac
10041                 fi
10042         done
10043         $rm -f try.* try$exe_ext
10044 esac
10045 case "$stdio_stream_array" in
10046 '')     $cat >&4 <<EOM
10047 I can't figure out how to access stdio streams by file descriptor number.
10048 EOM
10049         d_stdio_stream_array="$undef"
10050         ;;
10051 *)      $cat >&4 <<EOM
10052 You can access stdio streams by file descriptor number by the $stdio_stream_array array.
10053 EOM
10054         d_stdio_stream_array="$define"
10055         ;;
10056 esac
10057
10058 : see if strcoll exists
10059 set strcoll d_strcoll
10060 eval $inlibc
10061
10062 : check for structure copying
10063 echo " "
10064 echo "Checking to see if your C compiler can copy structs..." >&4
10065 $cat >try.c <<'EOCP'
10066 int main()
10067 {
10068         struct blurfl {
10069                 int dyick;
10070         } foo, bar;
10071
10072         foo = bar;
10073 }
10074 EOCP
10075 if $cc -c try.c >/dev/null 2>&1 ; then
10076         val="$define"
10077         echo "Yup, it can."
10078 else
10079         val="$undef"
10080         echo "Nope, it can't."
10081 fi
10082 set d_strctcpy
10083 eval $setvar
10084 $rm -f try.*
10085
10086 : see if strerror and/or sys_errlist[] exist
10087 echo " "
10088 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
10089     if set strerror val -f d_strerror; eval $csym; $val; then
10090                 echo 'strerror() found.' >&4
10091                 d_strerror="$define"
10092                 d_strerrm='strerror(e)'
10093                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10094                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
10095                         d_syserrlst="$define"
10096                 else
10097                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
10098                         d_syserrlst="$undef"
10099                 fi
10100     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
10101                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
10102                 echo 'strerror() found in string header.' >&4
10103                 d_strerror="$define"
10104                 d_strerrm='strerror(e)'
10105                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10106                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
10107                                 d_syserrlst="$define"
10108                 else
10109                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
10110                         d_syserrlst="$undef"
10111                 fi
10112     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
10113                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
10114                 d_strerror="$undef"
10115                 d_syserrlst="$define"
10116                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
10117     else
10118                 echo 'strerror() and sys_errlist[] NOT found.' >&4
10119                 d_strerror="$undef"
10120                 d_syserrlst="$undef"
10121                 d_strerrm='"unknown"'
10122     fi
10123 fi
10124
10125 : see if strtod exists
10126 set strtod d_strtod
10127 eval $inlibc
10128
10129 : see if strtol exists
10130 set strtol d_strtol
10131 eval $inlibc
10132
10133 : see if strtoul exists
10134 set strtoul d_strtoul
10135 eval $inlibc
10136
10137 : see if strxfrm exists
10138 set strxfrm d_strxfrm
10139 eval $inlibc
10140
10141 : see if symlink exists
10142 set symlink d_symlink
10143 eval $inlibc
10144
10145 : see if syscall exists
10146 set syscall d_syscall
10147 eval $inlibc
10148
10149 : see if sysconf exists
10150 set sysconf d_sysconf
10151 eval $inlibc
10152
10153 : see if system exists
10154 set system d_system
10155 eval $inlibc
10156
10157 : see if tcgetpgrp exists
10158 set tcgetpgrp d_tcgetpgrp
10159 eval $inlibc
10160
10161 : see if tcsetpgrp exists
10162 set tcsetpgrp d_tcsetpgrp
10163 eval $inlibc
10164
10165 : see if sys/types.h has to be included
10166 set sys/types.h i_systypes
10167 eval $inhdr
10168
10169 : see if prototype for telldir is available
10170 echo " "
10171 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10172 eval $hasproto
10173
10174 : define an is-a-typedef? function
10175 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10176 case "$inclist" in
10177 "") inclist="sys/types.h";;
10178 esac;
10179 eval "varval=\$$var";
10180 case "$varval" in
10181 "")
10182         $rm -f temp.c;
10183         for inc in $inclist; do
10184                 echo "#include <$inc>" >>temp.c;
10185         done;
10186         echo "#ifdef $type" >> temp.c;
10187         echo "printf(\"We have $type\");" >> temp.c;
10188         echo "#endif" >> temp.c;
10189         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10190         if $contains $type temp.E >/dev/null 2>&1; then
10191                 eval "$var=\$type";
10192         else
10193                 eval "$var=\$def";
10194         fi;
10195         $rm -f temp.?;;
10196 *) eval "$var=\$varval";;
10197 esac'
10198
10199 : define an is-a-typedef? function that prompts if the type is not available.
10200 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10201 case "$inclist" in
10202 "") inclist="sys/types.h";;
10203 esac;
10204 eval "varval=\$$var";
10205 case "$varval" in
10206 "")
10207         $rm -f temp.c;
10208         for inc in $inclist; do
10209                 echo "#include <$inc>" >>temp.c;
10210         done;
10211         echo "#ifdef $type" >> temp.c;
10212         echo "printf(\"We have $type\");" >> temp.c;
10213         echo "#endif" >> temp.c;
10214         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10215         echo " " ;
10216         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10217         if $contains $type temp.E >/dev/null 2>&1; then
10218                 echo "$type found." >&4;
10219                 eval "$var=\$type";
10220         else
10221                 echo "$type NOT found." >&4;
10222                 dflt="$def";
10223                 . ./myread ;
10224                 eval "$var=\$ans";
10225         fi;
10226         $rm -f temp.?;;
10227 *) eval "$var=\$varval";;
10228 esac'
10229
10230 : see if this is a sys/times.h system
10231 set sys/times.h i_systimes
10232 eval $inhdr
10233
10234 : see if times exists
10235 echo " "
10236 if set times val -f d_times; eval $csym; $val; then
10237         echo 'times() found.' >&4
10238         d_times="$define"
10239         inc=''
10240         case "$i_systimes" in
10241         "$define") inc='sys/times.h';;
10242         esac
10243         rp="What is the type returned by times() on this system?"
10244         set clock_t clocktype long stdio.h sys/types.h $inc
10245         eval $typedef_ask
10246 else
10247         echo 'times() NOT found, hope that will do.' >&4
10248         d_times="$undef"
10249         clocktype='int'
10250 fi
10251
10252 : see if truncate exists
10253 set truncate d_truncate
10254 eval $inlibc
10255
10256 : see if tzname[] exists
10257 echo " "
10258 if set tzname val -a d_tzname; eval $csym; $val; then
10259         val="$define"
10260         echo 'tzname[] found.' >&4
10261 else
10262         val="$undef"
10263         echo 'tzname[] NOT found.' >&4
10264 fi
10265 set d_tzname
10266 eval $setvar
10267
10268 : see if umask exists
10269 set umask d_umask
10270 eval $inlibc
10271
10272 : backward compatibility for d_hvfork
10273 if test X$d_hvfork != X; then
10274         d_vfork="$d_hvfork"
10275         d_hvfork=''
10276 fi
10277 : see if there is a vfork
10278 val=''
10279 set vfork val
10280 eval $inlibc
10281
10282 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10283 : perl on Solaris 2.x, and probably elsewhere.
10284 case "$val" in
10285 $define)
10286         echo " "
10287         case "$usevfork" in
10288         false) dflt='n';;
10289         *) dflt='y';;
10290         esac
10291         cat <<'EOM'
10292  
10293 Perl can only use a vfork() that doesn't suffer from strict
10294 restrictions on calling functions or modifying global data in
10295 the child.  For example, glibc-2.1 contains such a vfork()
10296 that is unsuitable.  If your system provides a proper fork()
10297 call, chances are that you do NOT want perl to use vfork().
10298
10299 EOM
10300         rp="Do you still want to use vfork()?"
10301         . ./myread
10302         case "$ans" in
10303         y|Y) ;;
10304         *)
10305                 echo "Ok, we won't use vfork()."
10306                 val="$undef"
10307                 ;;
10308         esac
10309         ;;
10310 esac
10311 set d_vfork
10312 eval $setvar
10313 case "$d_vfork" in
10314 $define) usevfork='true';;
10315 *) usevfork='false';;
10316 esac
10317
10318 : see if this is an sysdir system
10319 set sys/dir.h i_sysdir
10320 eval $inhdr
10321
10322 : see if this is an sysndir system
10323 set sys/ndir.h i_sysndir
10324 eval $inhdr
10325
10326 : see if closedir exists
10327 set closedir d_closedir
10328 eval $inlibc
10329
10330 case "$d_closedir" in
10331 "$define")
10332         echo " "
10333         echo "Checking whether closedir() returns a status..." >&4
10334         cat > closedir.c <<EOM
10335 #$i_dirent I_DIRENT             /**/
10336 #$i_sysdir I_SYS_DIR            /**/
10337 #$i_sysndir I_SYS_NDIR          /**/
10338 #$i_systypes I_SYS_TYPES        /**/
10339
10340 #if defined(I_SYS_TYPES)
10341 #include <sys/types.h>
10342 #endif
10343 #if defined(I_DIRENT)
10344 #include <dirent.h>
10345 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10346 #include <sys/dir.h>
10347 #endif
10348 #else
10349 #ifdef I_SYS_NDIR
10350 #include <sys/ndir.h>
10351 #else
10352 #ifdef I_SYS_DIR
10353 #ifdef hp9000s500
10354 #include <ndir.h>       /* may be wrong in the future */
10355 #else
10356 #include <sys/dir.h>
10357 #endif
10358 #endif
10359 #endif
10360 #endif 
10361 int main() { return closedir(opendir(".")); }
10362 EOM
10363         set closedir
10364         if eval $compile_ok; then
10365                 if ./closedir > /dev/null 2>&1 ; then
10366                         echo "Yes, it does."
10367                         val="$undef"
10368                 else
10369                         echo "No, it doesn't."
10370                         val="$define"
10371                 fi
10372         else
10373                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10374                 val="$define"
10375         fi
10376         ;;
10377 *)
10378         val="$undef";
10379         ;;
10380 esac
10381 set d_void_closedir
10382 eval $setvar
10383 $rm -f closedir*
10384 : check for volatile keyword
10385 echo " "
10386 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10387 $cat >try.c <<'EOCP'
10388 int main()
10389 {
10390         typedef struct _goo_struct goo_struct;
10391         goo_struct * volatile goo = ((goo_struct *)0);
10392         struct _goo_struct {
10393                 long long_int;
10394                 int reg_int;
10395                 char char_var;
10396         };
10397         typedef unsigned short foo_t;
10398         char *volatile foo;
10399         volatile int bar;
10400         volatile foo_t blech;
10401         foo = foo;
10402 }
10403 EOCP
10404 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10405         val="$define"
10406         echo "Yup, it does."
10407 else
10408         val="$undef"
10409         echo "Nope, it doesn't."
10410 fi
10411 set d_volatile
10412 eval $setvar
10413 $rm -f try.*
10414
10415 : see if there is a wait4
10416 set wait4 d_wait4
10417 eval $inlibc
10418
10419 : see if waitpid exists
10420 set waitpid d_waitpid
10421 eval $inlibc
10422
10423 : see if wcstombs exists
10424 set wcstombs d_wcstombs
10425 eval $inlibc
10426
10427 : see if wctomb exists
10428 set wctomb d_wctomb
10429 eval $inlibc
10430
10431 : see if writev exists
10432 set writev d_writev
10433 eval $inlibc
10434
10435 : preserve RCS keywords in files with variable substitution, grrr
10436 Date='$Date'
10437 Id='$Id'
10438 Log='$Log'
10439 RCSfile='$RCSfile'
10440 Revision='$Revision'
10441
10442 case "$crosscompile" in
10443 ''|[nN]*) crosscompile="$undef" ;;
10444 esac
10445
10446 case "$osname" in
10447 next|rhapsody) multiarch="$define" ;;
10448 esac
10449 case "$multiarch" in
10450 ''|[nN]*) multiarch="$undef" ;;
10451 esac
10452
10453 : check for alignment requirements
10454 echo " "
10455 case "$crosscompile$multiarch" in
10456 *$define*)
10457         $cat <<EOM
10458 You seem to be either cross-compiling or doing a multiarchitecture build,
10459 skipping the memory alignment check.
10460
10461 EOM
10462         case "$alignbytes" in
10463         '') alignbytes=8 ;;
10464         esac
10465         ;;
10466 *)
10467         case "$alignbytes" in
10468         '') echo "Checking alignment constraints..." >&4
10469                 $cat >try.c <<'EOCP'
10470 struct foobar {
10471         char foo;
10472         double bar;
10473 } try_algn;
10474 int main()
10475 {
10476         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10477 }
10478 EOCP
10479                 set try
10480                 if eval $compile_ok; then
10481                         dflt=`./try`
10482                 else
10483                         dflt='8'
10484                         echo "(I can't seem to compile the test program...)"
10485                 fi
10486                 ;;
10487         *) dflt="$alignbytes"
10488                 ;;
10489         esac
10490         rp="Doubles must be aligned on a how-many-byte boundary?"
10491         . ./myread
10492         alignbytes="$ans"
10493         $rm -f try.c try
10494         ;;
10495 esac
10496
10497
10498 : check for ordering of bytes in a long
10499 echo " "
10500 case "$crosscompile$multiarch" in
10501 *$define*)
10502         $cat <<EOM
10503 You seem to be either cross-compiling or doing a multiarchitecture build,
10504 skipping the byteorder check.
10505
10506 EOM
10507         byteorder=''
10508         ;;
10509 *)
10510         case "$byteorder" in
10511         '')
10512                 $cat <<'EOM'
10513 In the following, larger digits indicate more significance.  A big-endian
10514 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10515 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10516 machines may have weird orders like 3412.  A Cray will report 87654321. If
10517 the test program works the default is probably right.
10518 I'm now running the test program...
10519 EOM
10520                 $cat >try.c <<'EOCP'
10521 #include <stdio.h>
10522 int main()
10523 {
10524         int i;
10525         union {
10526                 unsigned long l;
10527                 char c[sizeof(long)];
10528         } u;
10529
10530         if (sizeof(long) > 4)
10531                 u.l = (0x08070605L << 32) | 0x04030201L;
10532         else
10533                 u.l = 0x04030201L;
10534         for (i = 0; i < sizeof(long); i++)
10535                 printf("%c", u.c[i]+'0');
10536         printf("\n");
10537         exit(0);
10538 }
10539 EOCP
10540                 xxx_prompt=y
10541                 set try
10542                 if eval $compile && ./try > /dev/null; then
10543                         dflt=`./try`
10544                         case "$dflt" in
10545                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10546                                 echo "(The test program ran ok.)"
10547                                 echo "byteorder=$dflt"
10548                                 xxx_prompt=n
10549                         ;;
10550                         ????|????????) echo "(The test program ran ok.)" ;;
10551                         *) echo "(The test program didn't run right for some reason.)" ;;
10552                         esac
10553                 else
10554                         dflt='4321'
10555                         cat <<'EOM'
10556 (I can't seem to compile the test program.  Guessing big-endian...)
10557 EOM
10558                 fi
10559                 case "$xxx_prompt" in
10560                 y)
10561                         rp="What is the order of bytes in a long?"
10562                         . ./myread
10563                         byteorder="$ans"
10564                         ;;
10565                 *)      byteorder=$dflt
10566                         ;;
10567                 esac
10568                 ;;
10569         esac
10570         $rm -f try.c try
10571         ;;
10572 esac
10573
10574
10575 : how do we catenate cpp tokens here?
10576 echo " "
10577 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10578 $cat >cpp_stuff.c <<'EOCP'
10579 #define RCAT(a,b)a/**/b
10580 #define ACAT(a,b)a ## b
10581 RCAT(Rei,ser)
10582 ACAT(Cir,cus)
10583 EOCP
10584 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10585 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10586         echo "Oh!  Smells like ANSI's been here." >&4
10587         echo "We can catify or stringify, separately or together!"
10588         cpp_stuff=42
10589 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10590         echo "Ah, yes!  The good old days!" >&4
10591         echo "However, in the good old days we don't know how to stringify and"
10592         echo "catify at the same time."
10593         cpp_stuff=1
10594 else
10595         $cat >&4 <<EOM
10596 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10597 to have to edit the values of CAT[2-5] in config.h...
10598 EOM
10599         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10600 fi
10601 $rm -f cpp_stuff.*
10602
10603 : see if this is a db.h system
10604 set db.h i_db
10605 eval $inhdr
10606
10607 case "$i_db" in
10608 $define)
10609         : Check db version.
10610         echo " "
10611         echo "Checking Berkeley DB version ..." >&4
10612         $cat >try.c <<EOCP
10613 #$d_const HASCONST
10614 #ifndef HASCONST
10615 #define const
10616 #endif
10617 #include <sys/types.h>
10618 #include <stdio.h>
10619 #include <db.h>
10620 int main()
10621 {
10622 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10623     int Major, Minor, Patch ;
10624     unsigned long Version ;
10625     (void)db_version(&Major, &Minor, &Patch) ;
10626     printf("You have Berkeley DB Version 2 or greater\n");
10627
10628     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10629                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10630     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10631                 Major, Minor, Patch) ;
10632
10633     /* check that db.h & libdb are compatible */
10634     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10635         printf("db.h and libdb are incompatible\n") ;
10636         exit(3);        
10637     }
10638
10639     printf("db.h and libdb are compatible\n") ;
10640
10641     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10642                 + DB_VERSION_PATCH ;
10643
10644     /* needs to be >= 2.3.4 */
10645     if (Version < 2003004) {
10646     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10647         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10648         exit(2);        
10649     }
10650
10651     exit(0);
10652 #else
10653 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10654     printf("You have Berkeley DB Version 1\n");
10655     exit(0);    /* DB version < 2: the coast is clear. */
10656 #else
10657     exit(1);    /* <db.h> not Berkeley DB? */
10658 #endif
10659 #endif
10660 }
10661 EOCP
10662         set try
10663         if eval $compile && ./try; then
10664                 echo 'Looks OK.' >&4
10665         else
10666                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10667                 i_db=$undef
10668                 case " $libs " in
10669                 *"-ldb "*)
10670                         : Remove db from list of libraries to use
10671                         echo "Removing unusable -ldb from library list" >&4
10672                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10673                         shift
10674                         libs="$*"
10675                         echo "libs = $libs" >&4
10676                         ;;
10677                 esac
10678         fi
10679         $rm -f try.*
10680         ;;
10681 esac
10682
10683 case "$i_db" in
10684 define)
10685         : Check the return type needed for hash 
10686         echo " "
10687         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10688         $cat >try.c <<EOCP
10689 #$d_const HASCONST
10690 #ifndef HASCONST
10691 #define const
10692 #endif
10693 #include <sys/types.h>
10694 #include <db.h>
10695
10696 #ifndef DB_VERSION_MAJOR
10697 u_int32_t hash_cb (ptr, size)
10698 const void *ptr;
10699 size_t size;
10700 {
10701 }
10702 HASHINFO info;
10703 int main()
10704 {
10705         info.hash = hash_cb;
10706 }
10707 #endif
10708 EOCP
10709         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10710                 if $contains warning try.out >>/dev/null 2>&1 ; then
10711                         db_hashtype='int'
10712                 else
10713                         db_hashtype='u_int32_t'
10714                 fi
10715         else
10716                 : XXX Maybe we should just give up here.
10717                 db_hashtype=u_int32_t
10718                 $cat try.out >&4
10719                 echo "Help:  I can't seem to compile the db test program." >&4
10720                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10721         fi
10722         $rm -f try.*
10723         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10724         ;;
10725 *)      db_hashtype=u_int32_t
10726         ;;
10727 esac
10728 case "$i_db" in
10729 define)
10730         : Check the return type needed for prefix 
10731         echo " "
10732         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10733         cat >try.c <<EOCP
10734 #$d_const HASCONST
10735 #ifndef HASCONST
10736 #define const
10737 #endif
10738 #include <sys/types.h>
10739 #include <db.h>
10740
10741 #ifndef DB_VERSION_MAJOR
10742 size_t prefix_cb (key1, key2)
10743 const DBT *key1;
10744 const DBT *key2;
10745 {
10746 }
10747 BTREEINFO info;
10748 int main()
10749 {
10750         info.prefix = prefix_cb;
10751 }
10752 #endif
10753 EOCP
10754         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10755                 if $contains warning try.out >>/dev/null 2>&1 ; then
10756                         db_prefixtype='int'
10757                 else
10758                         db_prefixtype='size_t'
10759                 fi
10760         else
10761                 db_prefixtype='size_t'
10762                 : XXX Maybe we should just give up here.
10763                 $cat try.out >&4
10764                 echo "Help:  I can't seem to compile the db test program." >&4
10765                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10766         fi
10767         $rm -f try.*
10768         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10769         ;;
10770 *)      db_prefixtype='size_t'
10771         ;;
10772 esac
10773
10774 : check for void type
10775 echo " "
10776 echo "Checking to see how well your C compiler groks the void type..." >&4
10777 case "$voidflags" in
10778 '')
10779         $cat >try.c <<'EOCP'
10780 #if TRY & 1
10781 void sub() {
10782 #else
10783 sub() {
10784 #endif
10785         extern void moo();      /* function returning void */
10786         void (*goo)();          /* ptr to func returning void */
10787 #if TRY & 8
10788         void *hue;              /* generic ptr */
10789 #endif
10790 #if TRY & 2
10791         void (*foo[10])();
10792 #endif
10793
10794 #if TRY & 4
10795         if(goo == moo) {
10796                 exit(0);
10797         }
10798 #endif
10799         exit(0);
10800 }
10801 int main() { sub(); }
10802 EOCP
10803         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10804                 voidflags=$defvoidused
10805         echo "Good.  It appears to support void to the level $package wants.">&4
10806                 if $contains warning .out >/dev/null 2>&1; then
10807                         echo "However, you might get some warnings that look like this:"
10808                         $cat .out
10809                 fi
10810         else
10811 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10812                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10813                         echo "It supports 1..."
10814                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10815                                 echo "It also supports 2..."
10816                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10817                                         voidflags=7
10818                                         echo "And it supports 4 but not 8 definitely."
10819                                 else
10820                                         echo "It doesn't support 4..."
10821                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10822                                                 voidflags=11
10823                                                 echo "But it supports 8."
10824                                         else
10825                                                 voidflags=3
10826                                                 echo "Neither does it support 8."
10827                                         fi
10828                                 fi
10829                         else
10830                                 echo "It does not support 2..."
10831                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10832                                         voidflags=13
10833                                         echo "But it supports 4 and 8."
10834                                 else
10835                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10836                                                 voidflags=5
10837                                                 echo "And it supports 4 but has not heard about 8."
10838                                         else
10839                                                 echo "However it supports 8 but not 4."
10840                                         fi
10841                                 fi
10842                         fi
10843                 else
10844                         echo "There is no support at all for void."
10845                         voidflags=0
10846                 fi
10847         fi
10848 esac
10849 case "$voidflags" in
10850 "$defvoidused") ;;
10851 *)      $cat >&4 <<'EOM'
10852   Support flag bits are:
10853     1: basic void declarations.
10854     2: arrays of pointers to functions returning void.
10855     4: operations between pointers to and addresses of void functions.
10856     8: generic void pointers.
10857 EOM
10858         dflt="$voidflags";
10859         rp="Your void support flags add up to what?"
10860         . ./myread
10861         voidflags="$ans"
10862         ;;
10863 esac
10864 $rm -f try.* .out
10865
10866
10867 : How can we generate normalized random numbers ?
10868 echo " "
10869 echo "Looking for a random number function..." >&4
10870 case "$randfunc" in
10871 '')
10872         if set drand48 val -f; eval $csym; $val; then
10873                 dflt="drand48"
10874                 echo "Good, found drand48()." >&4
10875         elif set random val -f; eval $csym; $val; then
10876                 dflt="random"
10877                 echo "OK, found random()." >&4
10878         else
10879                 dflt="rand"
10880                 echo "Yick, looks like I have to use rand()." >&4
10881         fi
10882         echo " "
10883         ;;
10884 *)
10885         dflt="$randfunc"
10886         ;;
10887 esac
10888 cont=true
10889
10890 case "$ccflags" in
10891 *-Dmy_rand=*|*-Dmy_srand=*)
10892         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10893         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10894         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10895         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10896         ;;
10897 esac
10898
10899 while $test "$cont"; do
10900         rp="Use which function to generate random numbers?"
10901         . ./myread
10902         if $test "$ans" = "$dflt"; then
10903                 : null
10904         else
10905                 randbits=''
10906         fi
10907         randfunc="$ans"
10908         if set $ans val -f; eval $csym; $val; then
10909                 cont=''
10910         else
10911                 dflt=y
10912                 rp="I cannot find function $ans. Use that name anyway?"
10913                 . ./myread
10914                 dflt=rand
10915                 case "$ans" in
10916                         [yY]*) cont='';;
10917                 esac
10918         fi
10919         case "$cont" in
10920         '')
10921                 case "$randfunc" in
10922                 drand48)
10923                         drand01="drand48()"
10924                         seedfunc="srand48"
10925                         randbits=48
10926                         randseedtype=long
10927                         ;;
10928                 rand|random)
10929                         case "$randbits" in
10930                         '')
10931 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10932                                 $cat >try.c <<EOCP
10933 #$i_unistd I_UNISTD
10934 #$i_stdlib I_STDLIB
10935 #include <stdio.h>
10936 #ifdef I_UNISTD
10937 #  include <unistd.h>
10938 #endif
10939 #ifdef I_STDLIB
10940 #  include <stdlib.h>
10941 #endif
10942 int main()
10943 {
10944         register int i;
10945         register unsigned long tmp;
10946         register unsigned long max = 0L;
10947
10948         for (i = 1000; i; i--) {
10949                 tmp = (unsigned long) $randfunc();
10950                 if (tmp > max) max = tmp;
10951         }
10952         for (i = 0; max; i++)
10953                 max /= 2;
10954         printf("%d\n",i);
10955 }
10956 EOCP
10957                                 set try
10958                                 if eval $compile_ok; then
10959                                         dflt=`try`
10960                                 else
10961                                         dflt='?'
10962                                         echo "(I can't seem to compile the test program...)"
10963                                 fi
10964                                 ;;
10965                         *)
10966                                 dflt="$randbits"
10967                                 ;;
10968                         esac
10969                         rp="How many bits does your $randfunc() function produce?"
10970                         . ./myread
10971                         randbits="$ans"
10972                         $rm -f try.c try
10973                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10974                         seedfunc="s$randfunc"
10975                         randseedtype=unsigned
10976                         ;;
10977                 *)
10978                         dflt="31"
10979                         rp="How many bits does your $randfunc() function produce?"
10980                         . ./myread
10981                         randbits="$ans"
10982                         seedfunc="s$randfunc"
10983                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10984                         if set $seedfunc val -f; eval $csym; $val; then
10985                                 echo "(Using $seedfunc() to seed random generator)"
10986                         else
10987                                 echo "(Warning: no $seedfunc() to seed random generator)"
10988                                 seedfunc=rand
10989                         fi
10990                         randseedtype=unsigned
10991                         ;;
10992                 esac
10993                 ;;
10994         esac
10995 done
10996
10997 echo " "
10998 echo "Determining whether or not we are on an EBCDIC system..." >&4
10999 $cat >tebcdic.c <<'EOM'
11000 int main()
11001 {
11002   if ('M'==0xd4) return 0;
11003   return 1;
11004 }
11005 EOM
11006
11007 val=$undef
11008 set tebcdic
11009 if eval $compile_ok; then
11010         if ./tebcdic; then
11011                 echo "You have EBCDIC." >&4
11012                 val="$define"
11013         else
11014                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin, or UTF." >&4
11015         fi
11016 else
11017         echo "I'm unable to compile the test program." >&4
11018         echo "I'll assume ASCII or some ISO Latin." >&4
11019 fi
11020 $rm -f tebcdic.c tebcdic
11021 set ebcdic
11022 eval $setvar
11023
11024 echo " "
11025 $cat >&4 <<EOM
11026 Checking how to flush all pending stdio output...
11027 EOM
11028 # I only know how to find the first 32 possibly open files on SunOS.
11029 # See also hints/sunos_4_1.sh and util.c  --AD
11030 case "$osname" in
11031 sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
11032 esac
11033 $cat >>try.c <<EOCP
11034 #include <stdio.h>
11035 #$i_unistd I_UNISTD
11036 #ifdef I_UNISTD
11037 # include <unistd.h>
11038 #endif
11039 #$d_sysconf HAS_SYSCONF
11040 #$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
11041 #ifdef HAS_STDIO_STREAM_ARRAY
11042 # define STDIO_STREAM_ARRAY $stdio_stream_array
11043 #endif
11044 int main() {
11045   FILE* p = fopen("try.out", "w");
11046 #ifdef TRY_FPUTC
11047   fputc('x', p);
11048 #else
11049 # ifdef TRY_FPRINTF
11050   fprintf(p, "x");
11051 # endif
11052 #endif
11053 #ifdef TRY_FFLUSH_NULL
11054   fflush(NULL);
11055 #endif
11056 #ifdef TRY_FFLUSH_ALL
11057   {
11058     long open_max = -1;
11059 # ifdef PERL_FFLUSH_ALL_FOPEN_MAX
11060     open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
11061 # else
11062 #  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
11063     open_max = sysconf(_SC_OPEN_MAX);
11064 #  else
11065 #   ifdef FOPEN_MAX
11066     open_max = FOPEN_MAX;
11067 #   else
11068 #    ifdef OPEN_MAX
11069     open_max = OPEN_MAX;
11070 #    else
11071 #     ifdef _NFILE
11072     open_max = _NFILE;
11073 #     endif
11074 #    endif
11075 #   endif
11076 #  endif
11077 # endif 
11078 # ifdef HAS_STDIO_STREAM_ARRAY
11079     if (open_max > 0) {
11080       long i;
11081       for (i = 0; i < open_max; i++)
11082             if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
11083                 STDIO_STREAM_ARRAY[i]._file < open_max &&
11084                 STDIO_STREAM_ARRAY[i]._flag)
11085                 fflush(&STDIO_STREAM_ARRAY[i]);
11086     }   
11087   }
11088 # endif
11089 #endif
11090   _exit(42);
11091 }
11092 EOCP
11093 : first we have to find out how _not_ to flush
11094 if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
11095     output=''
11096     set try -DTRY_FPUTC
11097     if eval $compile; then
11098             $rm -f try.out
11099             ./try$exe_ext 2>/dev/null
11100             if $test ! -s try.out -a "X$?" = X42; then
11101                 output=-DTRY_FPUTC
11102             fi
11103     fi
11104     case "$output" in
11105     '')
11106             set try -DTRY_FPRINTF
11107             $rm -f try.out
11108             if eval $compile; then
11109                     $rm -f try.out
11110                     ./try$exe_ext 2>/dev/null
11111                     if $test ! -s try.out -a "X$?" = X42; then
11112                         output=-DTRY_FPRINTF
11113                     fi
11114             fi
11115         ;;
11116     esac
11117 fi
11118 : check for fflush NULL behaviour
11119 case "$fflushNULL" in
11120 '')     set try -DTRY_FFLUSH_NULL $output
11121         if eval $compile; then
11122                 $rm -f try.out
11123                 ./try$exe_ext 2>/dev/null
11124                 code="$?"
11125                 if $test -s try.out -a "X$code" = X42; then
11126                         fflushNULL="`$cat try.out`"
11127                 else
11128                         if $test "X$code" != X42; then
11129                                 $cat >&4 <<EOM
11130 (If this test failed, don't worry, we'll try another method shortly.)
11131 EOM
11132                         fi
11133                 fi
11134         fi
11135         $rm -f core try.core core.try.*
11136         case "$fflushNULL" in
11137         x)      $cat >&4 <<EOM
11138 Your fflush(NULL) works okay.
11139 EOM
11140                 fflushNULL="$define"
11141                 ;;
11142         '')     $cat >&4 <<EOM
11143 Your fflush(NULL) isn't working (contrary to ANSI C).
11144 EOM
11145                 fflushNULL="$undef"
11146                 ;;
11147         *)      $cat >&4 <<EOM
11148 Cannot figure out whether your fflush(NULL) works or not.
11149 I'm assuming it doesn't (contrary to ANSI C).
11150 EOM
11151                 fflushNULL="$undef"
11152                 ;;
11153         esac
11154         ;;
11155 $define|true|[yY]*)
11156         fflushNULL="$define"
11157         ;;
11158 *)
11159         fflushNULL="$undef"
11160         ;;
11161 esac
11162 : check explicit looping only if NULL did not work
11163 case "$fflushNULL" in
11164 "$undef")
11165         : check for fflush all behaviour
11166         case "$fflushall" in
11167         '')     set try -DTRY_FFLUSH_ALL $output
11168                 if eval $compile; then
11169                         $cat >&4 <<EOM
11170 (Now testing the other method--but note that also this may fail.)
11171 EOM
11172                         $rm -f try.out
11173                         ./try$exe_ext 2>/dev/null
11174                         if $test -s try.out -a "X$?" = X42; then
11175                                 fflushall="`$cat try.out`"
11176                         fi
11177                 fi
11178                 $rm -f core try.core core.try.*
11179                 case "$fflushall" in
11180                 x)      $cat >&4 <<EOM
11181 Whew. Flushing explicitly all the stdio streams works.
11182 EOM
11183                         fflushall="$define"
11184                         ;;
11185                 '')     $cat >&4 <<EOM
11186 Sigh. Flushing explicitly all the stdio streams doesn't work.
11187 EOM
11188                         fflushall="$undef"
11189                         ;;
11190                 *)      $cat >&4 <<EOM
11191 Cannot figure out whether flushing stdio streams explicitly works or not.
11192 I'm assuming it doesn't.
11193 EOM
11194                         fflushall="$undef"
11195                         ;;
11196                 esac
11197                 ;;
11198         "$define"|true|[yY]*)
11199                 fflushall="$define"
11200                 ;;
11201         *)
11202                 fflushall="$undef"
11203                 ;;
11204         esac
11205         ;;
11206 *)      fflushall="$undef"      
11207         ;;
11208 esac
11209 case "$fflushNULL$fflushall" in
11210 undefundef)
11211         $cat <<EOM
11212 I cannot figure out how to flush pending stdio output.
11213 EOM
11214         ;;
11215 esac
11216 $rm -f try.* try$exe_ext
11217
11218 : see what type file positions are declared as in the library
11219 rp="What is the type for file position used by fsetpos()?"
11220 set fpos_t fpostype long stdio.h sys/types.h
11221 eval $typedef_ask
11222
11223 : Store the full pathname to the ar program for use in the C program
11224 : Respect a hint or command line value for full_ar.
11225 case "$full_ar" in
11226 '') full_ar=$ar ;;
11227 esac
11228
11229 : Store the full pathname to the sed program for use in the C program
11230 full_sed=$sed
11231
11232 : see what type gids are declared as in the kernel
11233 echo " "
11234 echo "Looking for the type for group ids returned by getgid()."
11235 set gid_t gidtype xxx stdio.h sys/types.h
11236 eval $typedef
11237 case "$gidtype" in
11238 xxx)
11239         xxx=`./findhdr sys/user.h`
11240         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
11241         case $1 in
11242         unsigned) dflt="$1 $2" ;;
11243         *) dflt="$1" ;;
11244         esac
11245         ;;
11246 *) dflt="$gidtype";;
11247 esac
11248 case "$gidtype" in
11249 gid_t) echo "gid_t found." ;;
11250 *)      rp="What is the type for group ids returned by getgid()?"
11251         . ./myread
11252         gidtype="$ans"
11253         ;;
11254 esac
11255
11256 : see if getgroups exists
11257 set getgroups d_getgrps
11258 eval $inlibc
11259
11260 : see if setgroups exists
11261 set setgroups d_setgrps
11262 eval $inlibc
11263
11264
11265 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11266 echo " "
11267 case "$d_getgrps$d_setgrps" in
11268 *define*)
11269         case "$groupstype" in
11270         '') dflt="$gidtype" ;;
11271         *)  dflt="$groupstype" ;;
11272         esac
11273         $cat <<EOM
11274 What type of pointer is the second argument to getgroups() and setgroups()?
11275 Usually this is the same as group ids, $gidtype, but not always.
11276
11277 EOM
11278         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11279         . ./myread
11280         groupstype="$ans"
11281         ;;
11282 *)  groupstype="$gidtype";;
11283 esac
11284
11285 : see what type lseek is declared as in the kernel
11286 rp="What is the type used for lseek's offset on this system?"
11287 set off_t lseektype long stdio.h sys/types.h
11288 eval $typedef_ask
11289
11290 echo " "
11291 $echo $n "Checking to see how big your file offsets are...$c" >&4
11292 $cat >try.c <<EOCP
11293 #include <sys/types.h>
11294 #include <stdio.h>
11295 int main()
11296 {
11297         printf("%d\n", sizeof($lseektype));
11298 }
11299 EOCP
11300 set try
11301 if eval $compile_ok; then
11302         lseeksize=`./try`
11303         $echo " $lseeksize bytes." >&4
11304 else
11305         dflt='4'
11306         echo " "
11307         echo "(I can't seem to compile the test program.  Guessing...)"
11308         rp="What is the size of your file offsets (in bytes)?"
11309         . ./myread
11310         lseeksize="$ans"
11311 fi
11312 $rm -f try.c try
11313
11314 echo " "
11315 echo "Checking if your $make program sets \$(MAKE)..." >&4
11316 case "$make_set_make" in
11317 '')
11318         $sed 's/^X //' > testmake.mak << 'EOF'
11319 Xall:
11320 X       @echo 'maketemp="$(MAKE)"'
11321 EOF
11322         case "`$make -f testmake.mak 2>/dev/null`" in
11323         *maketemp=*) make_set_make='#' ;;
11324         *)      make_set_make="MAKE=$make" ;;
11325         esac
11326         $rm -f testmake.mak
11327         ;;
11328 esac
11329 case "$make_set_make" in
11330 '#') echo "Yup, it does.";;
11331 *) echo "Nope, it doesn't.";;
11332 esac
11333
11334 : see what type is used for mode_t
11335 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11336 set mode_t modetype int stdio.h sys/types.h
11337 eval $typedef_ask
11338
11339 : define a fucntion to check prototypes
11340 $cat > protochk <<EOSH
11341 $startsh
11342 cc="$cc"
11343 optimize="$optimize"
11344 ccflags="$ccflags"
11345 prototype="$prototype"
11346 define="$define"
11347 rm=$rm
11348 EOSH
11349
11350 $cat >> protochk <<'EOSH'
11351
11352 $rm -f try.c
11353 foo="$1"
11354 shift
11355 while test $# -ge 2; do
11356         case "$1" in
11357                 $define) echo "#include <$2>" >> try.c ;;
11358                 literal) echo "$2" >> try.c ;;
11359         esac
11360     shift 2
11361 done
11362 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11363 cat >> try.c <<'EOCP'
11364 #ifdef CAN_PROTOTYPE
11365 #define _(args) args
11366 #else
11367 #define _(args) ()
11368 #endif
11369 EOCP
11370 echo "$foo" >> try.c
11371 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11372 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11373 status=$?
11374 $rm -f try.[co]
11375 exit $status
11376 EOSH
11377 chmod +x protochk
11378 $eunicefix protochk
11379
11380 : see what type is used for size_t
11381 rp="What is the type used for the length parameter for string functions?"
11382 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11383 eval $typedef_ask
11384
11385 : check for type of arguments to gethostbyaddr. 
11386 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11387         case "$d_gethbyaddr" in
11388         $define)
11389                 $cat <<EOM
11390
11391 Checking to see what type of arguments are accepted by gethostbyaddr().
11392 EOM
11393                 hdrs="$define sys/types.h
11394                         $d_socket sys/socket.h 
11395                         $i_niin netinet/in.h 
11396                         $i_netdb netdb.h
11397                         $i_unistd unistd.h"
11398                 : The first arg can 'char *' or 'void *'
11399                 : The second arg is some of integral type
11400                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11401                         for yyy in size_t long int; do
11402                                 case "$netdb_host_type" in
11403                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11404                                         if ./protochk "$try" $hdrs; then
11405                                                 echo "Your system accepts $xxx for the first arg."
11406                                                 echo "...and $yyy for the second arg."
11407                                                 netdb_host_type="$xxx"
11408                                                 netdb_hlen_type="$yyy"
11409                                         fi
11410                                         ;;
11411                                 esac
11412                         done
11413                 done
11414                 : In case none of those worked, prompt the user.
11415                 case "$netdb_host_type" in
11416                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11417                         dflt='char *'
11418                         . ./myread
11419                         netdb_host_type=$ans
11420                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11421                         dflt="$sizetype"
11422                         . ./myread
11423                         netdb_hlen_type=$ans
11424                         ;;
11425                 esac
11426                 ;;
11427         *)      : no gethostbyaddr, so pick harmless defaults
11428                 netdb_host_type='char *'
11429                 netdb_hlen_type="$sizetype"
11430                 ;;
11431         esac
11432         # Remove the "const" if needed. -- but then we'll have a 
11433         # prototype clash!
11434         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11435 fi
11436
11437 : check for type of argument to gethostbyname. 
11438 if test "X$netdb_name_type" = X ; then
11439         case "$d_gethbyname" in
11440         $define)
11441                 $cat <<EOM
11442
11443 Checking to see what type of argument is accepted by gethostbyname().
11444 EOM
11445                 hdrs="$define sys/types.h
11446                         $d_socket sys/socket.h 
11447                         $i_niin netinet/in.h 
11448                         $i_netdb netdb.h
11449                         $i_unistd unistd.h"
11450                 for xxx in "const char *" "char *"; do
11451                         case "$netdb_name_type" in
11452                         '')     try="extern struct hostent *gethostbyname($xxx);"
11453                                 if ./protochk "$try" $hdrs; then
11454                                         echo "Your system accepts $xxx."
11455                                         netdb_name_type="$xxx"
11456                                 fi
11457                                 ;;
11458                         esac
11459                 done
11460                 : In case none of those worked, prompt the user.
11461                 case "$netdb_name_type" in
11462                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11463                         dflt='char *'
11464                         . ./myread
11465                         netdb_name_type=$ans
11466                         ;;
11467                 esac
11468                 ;;
11469         *)      : no gethostbyname, so pick harmless default
11470                 netdb_name_type='char *'
11471                 ;;
11472         esac
11473 fi
11474
11475 : check for type of 1st argument to getnetbyaddr. 
11476 if test "X$netdb_net_type" = X ; then
11477         case "$d_getnbyaddr" in
11478         $define)
11479                 $cat <<EOM
11480
11481 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11482 EOM
11483                 hdrs="$define sys/types.h
11484                         $d_socket sys/socket.h 
11485                         $i_niin netinet/in.h 
11486                         $i_netdb netdb.h
11487                         $i_unistd unistd.h"
11488                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11489                         case "$netdb_net_type" in
11490                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11491                                 if ./protochk "$try" $hdrs; then
11492                                         echo "Your system accepts $xxx."
11493                                         netdb_net_type="$xxx"
11494                                 fi
11495                                 ;;
11496                         esac
11497                 done
11498                 : In case none of those worked, prompt the user.
11499                 case "$netdb_net_type" in
11500                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11501                         dflt='long'
11502                         . ./myread
11503                         netdb_net_type=$ans
11504                         ;;
11505                 esac
11506                 ;;
11507         *)      : no getnetbyaddr, so pick harmless default
11508                 netdb_net_type='long'
11509                 ;;
11510         esac
11511 fi
11512 : locate the preferred pager for this system
11513 case "$pager" in
11514 '')
11515         dflt=''
11516         case "$pg" in
11517         /*) dflt=$pg;;
11518         esac
11519         case "$more" in
11520         /*) dflt=$more;;
11521         esac
11522         case "$less" in
11523         /*) dflt=$less;;
11524         esac
11525         case "$dflt" in
11526         '') dflt=/usr/ucb/more;;
11527         esac
11528         ;;
11529 *) dflt="$pager";;
11530 esac
11531 echo " "
11532 fn=f/
11533 rp='What pager is used on your system?'
11534 . ./getfile
11535 pager="$ans"
11536
11537 : see what type pids are declared as in the kernel
11538 rp="What is the type of process ids on this system?"
11539 set pid_t pidtype int stdio.h sys/types.h
11540 eval $typedef_ask
11541
11542 : check for length of pointer
11543 echo " "
11544 case "$ptrsize" in
11545 '')
11546         $echo $n "Checking to see how big your pointers are...$c" >&4
11547         if test "$voidflags" -gt 7; then
11548                 echo '#define VOID_PTR char *' > try.c
11549         else
11550                 echo '#define VOID_PTR void *' > try.c
11551         fi
11552         $cat >>try.c <<'EOCP'
11553 #include <stdio.h>
11554 int main()
11555 {
11556         printf("%d\n", sizeof(VOID_PTR));
11557         exit(0);
11558 }
11559 EOCP
11560         set try
11561         if eval $compile_ok; then
11562                 ptrsize=`./try`
11563                 $echo " $ptrsize bytes." >&4
11564         else
11565                 dflt='4'
11566                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11567                 rp="What is the size of a pointer (in bytes)?"
11568                 . ./myread
11569                 ptrsize="$ans"
11570         fi
11571         ;;
11572 esac
11573 $rm -f try.c try
11574
11575 : see if ar generates random libraries by itself
11576 echo " "
11577 echo "Checking how to generate random libraries on your machine..." >&4
11578 echo 'int bar1() { return bar2(); }' > bar1.c
11579 echo 'int bar2() { return 2; }' > bar2.c
11580 $cat > foo.c <<'EOP'
11581 int main() { printf("%d\n", bar1()); exit(0); }
11582 EOP
11583 $cc $ccflags -c bar1.c >/dev/null 2>&1
11584 $cc $ccflags -c bar2.c >/dev/null 2>&1
11585 $cc $ccflags -c foo.c >/dev/null 2>&1
11586 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11587 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11588         ./foobar >/dev/null 2>&1; then
11589         echo "$ar appears to generate random libraries itself."
11590         orderlib=false
11591         ranlib=":"
11592 elif $ar ts bar$_a >/dev/null 2>&1 &&
11593         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11594         ./foobar >/dev/null 2>&1; then
11595                 echo "a table of contents needs to be added with '$ar ts'."
11596                 orderlib=false
11597                 ranlib="$ar ts"
11598 else
11599         case "$ranlib" in
11600         :) ranlib='';;
11601         '')
11602                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11603                 $test -f $ranlib || ranlib=''
11604                 ;;
11605         esac
11606         if $test -n "$ranlib"; then
11607                 echo "your system has '$ranlib'; we'll use that."
11608                 orderlib=false
11609         else
11610                 echo "your system doesn't seem to support random libraries"
11611                 echo "so we'll use lorder and tsort to order the libraries."
11612                 orderlib=true
11613                 ranlib=":"
11614         fi
11615 fi
11616 $rm -f foo* bar* 
11617
11618 : check for type of arguments to select. 
11619 case "$selecttype" in
11620 '') case "$d_select" in
11621         $define)
11622                 $cat <<EOM
11623 Checking to see what type of arguments are accepted by select().
11624 EOM
11625                 hdrs="$define sys/types.h
11626                         $i_systime sys/time.h 
11627                         $i_sysselct sys/select.h
11628                         $d_socket sys/socket.h"
11629                 : The first arg can be int, unsigned, or size_t
11630                 : The last arg may or may not be 'const'
11631                 val=''
11632                 : void pointer has been seen but using that
11633                 : breaks the selectminbits test
11634                 for xxx in 'fd_set *' 'int *'; do
11635                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11636                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11637                                         case "$val" in
11638                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11639                                                 if ./protochk "$try" $hdrs; then
11640                                                         echo "Your system accepts $xxx."
11641                                                         val="$xxx"
11642                                                 fi
11643                                                 ;;
11644                                         esac
11645                                 done
11646                         done
11647                 done
11648                 case "$val" in
11649                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11650                         case "$d_fd_set" in
11651                                 $define) dflt="fd_set *" ;;
11652                                 *)              dflt="int *" ;;
11653                         esac
11654                         . ./myread
11655                         val=$ans
11656                         ;;
11657                 esac
11658                 selecttype="$val"
11659                 ;;
11660         *)      : no select, so pick a harmless default
11661                 selecttype='int *'
11662                 ;;
11663         esac
11664         ;;
11665 esac
11666
11667 : check for the select 'width'
11668 case "$selectminbits" in
11669 '') case "$d_select" in
11670         $define)
11671                 $cat <<EOM
11672
11673 Checking to see on how many bits at a time your select() operates...
11674 EOM
11675                 $cat >try.c <<EOCP
11676 #include <sys/types.h>
11677 #$i_time I_TIME
11678 #$i_systime I_SYS_TIME
11679 #$i_systimek I_SYS_TIME_KERNEL
11680 #ifdef I_TIME
11681 #   include <time.h>
11682 #endif
11683 #ifdef I_SYS_TIME
11684 #   ifdef I_SYS_TIME_KERNEL
11685 #       define KERNEL
11686 #   endif
11687 #   include <sys/time.h>
11688 #   ifdef I_SYS_TIME_KERNEL
11689 #       undef KERNEL
11690 #   endif
11691 #endif
11692 #$i_sysselct I_SYS_SELECT
11693 #ifdef I_SYS_SELECT
11694 #include <sys/select.h>
11695 #endif
11696 #$d_socket HAS_SOCKET
11697 #ifdef HAS_SOCKET
11698 #   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
11699 #endif
11700 #include <stdio.h>
11701 $selecttype b;
11702 #define S sizeof(*(b))
11703 #define MINBITS 64
11704 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11705 #define NBITS  (NBYTES * 8)
11706 int main() {
11707     char s[NBYTES];
11708     struct timeval t;
11709     int i;
11710     FILE* fp;
11711     int fd;
11712
11713     fclose(stdin);
11714     fp = fopen("try.c", "r");
11715     if (fp == 0)
11716       exit(1);
11717     fd = fileno(fp);
11718     if (fd < 0)
11719       exit(2);
11720     b = ($selecttype)s;
11721     for (i = 0; i < NBITS; i++)
11722         FD_SET(i, b);
11723     t.tv_sec  = 0;
11724     t.tv_usec = 0;
11725     select(fd + 1, b, 0, 0, &t);
11726     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11727     printf("%d\n", i + 1);
11728     return 0;
11729 }
11730 EOCP
11731                 set try
11732                 if eval $compile_ok; then
11733                         selectminbits=`./try`
11734                         case "$selectminbits" in
11735                         '')     cat >&4 <<EOM
11736 Cannot figure out on how many bits at a time your select() operates.
11737 I'll play safe and guess it is 32 bits.
11738 EOM
11739                                 selectminbits=32
11740                                 bits="32 bits"
11741                                 ;;
11742                         1)      bits="1 bit" ;;
11743                         *)      bits="$selectminbits bits" ;;
11744                         esac
11745                         echo "Your select() operates on $bits at a time." >&4
11746                 else
11747                         rp='What is the minimum number of bits your select() operates on?'
11748                         case "$byteorder" in
11749                         1234|12345678)  dflt=32 ;;
11750                         *)              dflt=1  ;;
11751                         esac
11752                         . ./myread
11753                         val=$ans
11754                         selectminbits="$val"
11755                 fi
11756                 $rm -f try.* try
11757                 ;;
11758         *)      : no select, so pick a harmless default
11759                 selectminbits='32'
11760                 ;;
11761         esac
11762         ;;
11763 esac
11764
11765 : Trace out the files included by signal.h, then look for SIGxxx names.
11766 : Remove SIGARRAYSIZE used by HPUX.
11767 : Remove SIGSTKSIZE used by Linux.
11768 : Remove SIGSTKSZ used by Posix.
11769 : Remove SIGTYP void lines used by OS2.
11770 xxx=`echo '#include <signal.h>' |
11771         $cppstdin $cppminus $cppflags 2>/dev/null |
11772         $grep '^[       ]*#.*include' | 
11773         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11774 : Check this list of files to be sure we have parsed the cpp output ok.
11775 : This will also avoid potentially non-existent files, such 
11776 : as ../foo/bar.h
11777 xxxfiles=''
11778 for xx in $xxx /dev/null ; do
11779         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11780 done
11781 : If we have found no files, at least try signal.h
11782 case "$xxxfiles" in
11783 '')     xxxfiles=`./findhdr signal.h` ;;
11784 esac
11785 xxx=`awk '
11786 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11787         print substr($2, 4, 20)
11788 }
11789 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11790         print substr($3, 4, 20)
11791 }' $xxxfiles`
11792 : Append some common names just in case the awk scan failed.
11793 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11794 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11795 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11796 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11797 : generate a few handy files for later
11798 $cat > signal.c <<'EOCP'
11799 #include <sys/types.h>
11800 #include <signal.h>
11801 #include <stdio.h>
11802 int main() {
11803
11804 /* Strange style to avoid deeply-nested #if/#else/#endif */
11805 #ifndef NSIG
11806 #  ifdef _NSIG
11807 #    define NSIG (_NSIG)
11808 #  endif
11809 #endif
11810
11811 #ifndef NSIG
11812 #  ifdef SIGMAX
11813 #    define NSIG (SIGMAX+1)
11814 #  endif
11815 #endif
11816
11817 #ifndef NSIG
11818 #  ifdef SIG_MAX
11819 #    define NSIG (SIG_MAX+1)
11820 #  endif
11821 #endif
11822
11823 #ifndef NSIG
11824 #  ifdef MAXSIG
11825 #    define NSIG (MAXSIG+1)
11826 #  endif
11827 #endif
11828
11829 #ifndef NSIG
11830 #  ifdef MAX_SIG
11831 #    define NSIG (MAX_SIG+1)
11832 #  endif
11833 #endif
11834
11835 #ifndef NSIG
11836 #  ifdef SIGARRAYSIZE
11837 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11838 #  endif
11839 #endif
11840
11841 #ifndef NSIG
11842 #  ifdef _sys_nsig
11843 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11844 #  endif
11845 #endif
11846
11847 /* Default to some arbitrary number that's big enough to get most
11848    of the common signals.
11849 */
11850 #ifndef NSIG
11851 #    define NSIG 50
11852 #endif
11853
11854 printf("NSIG %d\n", NSIG);
11855
11856 #ifndef JUST_NSIG
11857
11858 EOCP
11859
11860 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11861 {
11862         printf "#ifdef SIG"; printf $1; printf "\n"
11863         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11864         printf $1; printf ");\n"
11865         printf "#endif\n"
11866 }
11867 END {
11868         printf "#endif /* JUST_NSIG */\n";
11869         printf "}\n";
11870 }
11871 ' >>signal.c
11872 $cat >signal.awk <<'EOP'
11873 BEGIN { ndups = 0 }
11874 $1 ~ /^NSIG$/ { nsig = $2 }
11875 ($1 !~ /^NSIG$/) && (NF == 2) {
11876     if ($2 > maxsig) { maxsig = $2 }
11877     if (sig_name[$2]) {
11878         dup_name[ndups] = $1
11879         dup_num[ndups] = $2
11880         ndups++ 
11881     }
11882     else {
11883         sig_name[$2] = $1
11884         sig_num[$2] = $2
11885     }
11886 }
11887 END { 
11888     if (nsig == 0) {
11889         nsig = maxsig + 1
11890     }
11891     printf("NSIG %d\n", nsig);
11892     for (n = 1; n < nsig; n++) {
11893         if (sig_name[n]) {
11894             printf("%s %d\n", sig_name[n], sig_num[n])
11895         }
11896         else {
11897             printf("NUM%d %d\n", n, n) 
11898         }
11899     }
11900     for (n = 0; n < ndups; n++) {
11901         printf("%s %d\n", dup_name[n], dup_num[n])
11902     }
11903 }
11904 EOP
11905 $cat >signal_cmd <<EOS
11906 $startsh
11907 if $test -s signal.lst; then
11908     echo "Using your existing signal.lst file"
11909         exit 0
11910 fi
11911 xxx="$xxx"
11912 EOS
11913 $cat >>signal_cmd <<'EOS'
11914
11915 set signal
11916 if eval $compile_ok; then
11917         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11918 else
11919         echo "(I can't seem be able to compile the whole test program)" >&4
11920         echo "(I'll try it in little pieces.)" >&4
11921         set signal -DJUST_NSIG
11922         if eval $compile_ok; then
11923                 ./signal$_exe > signal.nsg
11924                 $cat signal.nsg
11925         else
11926                 echo "I can't seem to figure out how many signals you have." >&4
11927                 echo "Guessing 50." >&4
11928                 echo 'NSIG 50' > signal.nsg
11929         fi
11930         : Now look at all the signal names, one at a time.
11931         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11932                 $cat > signal.c <<EOCP
11933 #include <sys/types.h>
11934 #include <signal.h>
11935 #include <stdio.h>
11936 int main() {
11937 printf("$xx %d\n", SIG${xx});
11938 return 0;
11939 }
11940 EOCP
11941                 set signal
11942                 if eval $compile; then
11943                         echo "SIG${xx} found."
11944                         ./signal$_exe  >> signal.ls1
11945                 else
11946                         echo "SIG${xx} NOT found."
11947                 fi
11948         done
11949         if $test -s signal.ls1; then
11950                 $cat signal.nsg signal.ls1 |
11951                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11952         fi
11953
11954 fi
11955 if $test -s signal.lst; then
11956         :
11957 else
11958         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11959         echo 'kill -l' >signal
11960         set X `csh -f <signal`
11961         $rm -f signal
11962         shift
11963         case $# in
11964         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11965         esac
11966         echo $@ | $tr ' ' $trnl | \
11967             $awk '{ printf "%s %d\n", $1, ++s; }
11968                   END { printf "NSIG %d\n", ++s }' >signal.lst
11969 fi
11970 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11971 EOS
11972 chmod a+x signal_cmd
11973 $eunicefix signal_cmd
11974
11975 : generate list of signal names
11976 echo " "
11977 case "$sig_name_init" in
11978 '') doinit=yes ;;
11979 *)  case "$sig_num_init" in
11980     ''|*,*) doinit=yes ;;
11981     esac ;;
11982 esac
11983 case "$doinit" in
11984 yes)
11985         echo "Generating a list of signal names and numbers..." >&4
11986         . ./signal_cmd
11987         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11988         sig_name=`$awk 'BEGIN { printf "ZERO " }
11989                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11990         sig_num=`$awk  'BEGIN { printf "0 " }
11991                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11992         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11993                              !/^NSIG/   { printf "\"%s\", ", $1 }
11994                              END        { printf "0\n" }' signal.lst`
11995         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11996                              !/^NSIG/   { printf "%d, ", $2}
11997                              END        { printf "0\n"}' signal.lst`
11998         ;;
11999 esac
12000 echo "The following $sig_count signals are available:"
12001 echo " "
12002 echo $sig_name | $awk \
12003 'BEGIN { linelen = 0 }
12004 {
12005         for (i = 1; i <= NF; i++) {
12006                 name = "SIG" $i " "
12007                 linelen = linelen + length(name)
12008                 if (linelen > 70) {
12009                         printf "\n"
12010                         linelen = length(name)
12011                 }
12012                 printf "%s", name
12013         }
12014         printf "\n"
12015 }'
12016 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
12017
12018 : see what type is used for signed size_t
12019 set ssize_t ssizetype int stdio.h sys/types.h
12020 eval $typedef
12021 dflt="$ssizetype"
12022 $cat > ssize.c <<EOM
12023 #include <stdio.h>
12024 #include <sys/types.h>
12025 #define Size_t $sizetype
12026 #define SSize_t $dflt
12027 int main()
12028 {
12029         if (sizeof(Size_t) == sizeof(SSize_t))
12030                 printf("$dflt\n");
12031         else if (sizeof(Size_t) == sizeof(int))
12032                 printf("int\n");
12033         else 
12034                 printf("long\n");
12035         exit(0);
12036 }
12037 EOM
12038 echo " "
12039 set ssize
12040 if eval $compile_ok && ./ssize > /dev/null; then
12041         ssizetype=`./ssize`
12042         echo "I'll be using $ssizetype for functions returning a byte count." >&4
12043 else
12044         $cat >&4 <<EOM
12045 Help! I can't compile and run the ssize_t test program: please enlighten me!
12046 (This is probably a misconfiguration in your system or libraries, and
12047 you really ought to fix it.  Still, I'll try anyway.)
12048
12049 I need a type that is the same size as $sizetype, but is guaranteed to
12050 be signed.  Common values are ssize_t, int and long.
12051
12052 EOM
12053         rp="What signed type is the same size as $sizetype?"
12054         . ./myread
12055         ssizetype="$ans"
12056 fi
12057 $rm -f ssize ssize.*
12058
12059 : see what type of char stdio uses.
12060 echo " "
12061 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
12062         echo "Your stdio uses unsigned chars." >&4
12063         stdchar="unsigned char"
12064 else
12065         echo "Your stdio uses signed chars." >&4
12066         stdchar="char"
12067 fi
12068
12069 : see if time exists
12070 echo " "
12071 if test "X$d_time" = X -o X"$timetype" = X; then
12072     if set time val -f d_time; eval $csym; $val; then
12073                 echo 'time() found.' >&4
12074                 val="$define"
12075                 rp="What is the type returned by time() on this system?"
12076                 set time_t timetype long stdio.h sys/types.h
12077                 eval $typedef_ask
12078     else
12079                 echo 'time() not found, hope that will do.' >&4
12080                 val="$undef"
12081                 timetype='int';
12082     fi
12083     set d_time
12084     eval $setvar
12085 fi
12086
12087 : see what type uids are declared as in the kernel
12088 echo " "
12089 echo "Looking for the type for user ids returned by getuid()."
12090 set uid_t uidtype xxx stdio.h sys/types.h
12091 eval $typedef
12092 case "$uidtype" in
12093 xxx)
12094         xxx=`./findhdr sys/user.h`
12095         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
12096         case $1 in
12097         unsigned) dflt="$1 $2" ;;
12098         *) dflt="$1" ;;
12099         esac
12100         ;;
12101 *) dflt="$uidtype";;
12102 esac
12103 case "$uidtype" in
12104 uid_t)  echo "uid_t found." ;;
12105 *)      rp="What is the type for user ids returned by getuid()?"
12106         . ./myread
12107         uidtype="$ans"
12108         ;;
12109 esac
12110
12111 : see if dbm.h is available
12112 : see if dbmclose exists
12113 set dbmclose d_dbmclose
12114 eval $inlibc
12115
12116 case "$d_dbmclose" in
12117 $define)
12118         set dbm.h i_dbm
12119         eval $inhdr
12120         case "$i_dbm" in
12121         $define)
12122                 val="$undef"
12123                 set i_rpcsvcdbm
12124                 eval $setvar
12125                 ;;
12126         *)      set rpcsvc/dbm.h i_rpcsvcdbm
12127                 eval $inhdr
12128                 ;;
12129         esac
12130         ;;
12131 *)      echo "We won't be including <dbm.h>"
12132         val="$undef"
12133         set i_dbm
12134         eval $setvar
12135         val="$undef"
12136         set i_rpcsvcdbm
12137         eval $setvar
12138         ;;
12139 esac
12140
12141 : see if this is a sys/file.h system
12142 val=''
12143 set sys/file.h val
12144 eval $inhdr
12145
12146 : do we need to include sys/file.h ?
12147 case "$val" in
12148 "$define")
12149         echo " "
12150         if $h_sysfile; then
12151                 val="$define"
12152                 echo "We'll be including <sys/file.h>." >&4
12153         else
12154                 val="$undef"
12155                 echo "We won't be including <sys/file.h>." >&4
12156         fi
12157         ;;
12158 *)
12159         h_sysfile=false
12160         ;;
12161 esac
12162 set i_sysfile
12163 eval $setvar
12164
12165 : see if fcntl.h is there
12166 val=''
12167 set fcntl.h val
12168 eval $inhdr
12169
12170 : see if we can include fcntl.h
12171 case "$val" in
12172 "$define")
12173         echo " "
12174         if $h_fcntl; then
12175                 val="$define"
12176                 echo "We'll be including <fcntl.h>." >&4
12177         else
12178                 val="$undef"
12179                 if $h_sysfile; then
12180         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12181                 else
12182                         echo "We won't be including <fcntl.h>." >&4
12183                 fi
12184         fi
12185         ;;
12186 *)
12187         h_fcntl=false
12188         val="$undef"
12189         ;;
12190 esac
12191 set i_fcntl
12192 eval $setvar
12193
12194 : see if locale.h is available
12195 set locale.h i_locale
12196 eval $inhdr
12197
12198 : see if mach cthreads are available
12199 if test "X$usethreads" = "X$define"; then
12200         set mach/cthreads.h i_machcthr
12201         eval $inhdr
12202 else
12203         i_machcthr="$undef"
12204 fi
12205
12206
12207
12208 : see if this is a math.h system
12209 set math.h i_math
12210 eval $inhdr
12211
12212 : see if this is a mntent.h system
12213 set mntent.h i_mntent
12214 eval $inhdr
12215
12216 : see if ndbm.h is available
12217 set ndbm.h t_ndbm
12218 eval $inhdr
12219 case "$t_ndbm" in
12220 $define)
12221         : see if dbm_open exists
12222         set dbm_open d_dbm_open
12223         eval $inlibc
12224         case "$d_dbm_open" in
12225         $undef)
12226                 t_ndbm="$undef"
12227                 echo "We won't be including <ndbm.h>"
12228                 ;;
12229         esac
12230         ;;
12231 esac
12232 val="$t_ndbm"
12233 set i_ndbm
12234 eval $setvar
12235
12236 : see if net/errno.h is available
12237 val=''
12238 set net/errno.h val
12239 eval $inhdr
12240
12241 : Unfortunately, it causes problems on some systems.  Arrgh.
12242 case "$val" in
12243 $define)
12244         cat > try.c <<'EOM'
12245 #include <stdio.h>
12246 #include <errno.h>
12247 #include <net/errno.h>
12248 int func()
12249 {
12250         return ENOTSOCK;
12251 }
12252 EOM
12253         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12254                 echo "We'll be including <net/errno.h>." >&4
12255         else
12256                 echo "We won't be including <net/errno.h>." >&4
12257                 val="$undef"
12258         fi
12259         $rm -f try.* try
12260         ;;
12261 esac
12262 set i_neterrno
12263 eval $setvar
12264
12265 : see if netinet/tcp.h is available
12266 set netinet/tcp.h i_netinettcp
12267 eval $inhdr
12268
12269 : see if this is a poll.h system
12270 set poll.h i_poll
12271 eval $inhdr
12272
12273 : get C preprocessor symbols handy
12274 echo " "
12275 $echo $n "Hmm... $c"
12276 echo $al | $tr ' ' $trnl >Cppsym.know
12277 $cat <<EOSS >Cppsym
12278 $startsh
12279 case "\$1" in
12280 -l) list=true
12281         shift
12282         ;;
12283 esac
12284 unknown=''
12285 case "\$list\$#" in
12286 1|2)
12287         for sym do
12288                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12289                         exit 0
12290                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12291                         :
12292                 else
12293                         unknown="\$unknown \$sym"
12294                 fi
12295         done
12296         set X \$unknown
12297         shift
12298         ;;
12299 esac
12300 case \$# in
12301 0) exit 1;;
12302 esac
12303 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12304 #ifdef \1\\
12305 exit 0; _ _ _ _\1\\      \1\\
12306 #endif\\
12307 /' >Cppsym\$\$
12308 echo "exit 1; _ _ _" >>Cppsym\$\$
12309 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12310 case "\$list" in
12311 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12312 *)
12313         sh Cppsym2\$\$
12314         status=\$?
12315         ;;
12316 esac
12317 $rm -f Cppsym\$\$ Cppsym2\$\$
12318 exit \$status
12319 EOSS
12320 chmod +x Cppsym
12321 $eunicefix Cppsym
12322 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12323
12324 : now check the C compiler for additional symbols
12325 postprocess_cc_v=''
12326 case "$osname" in
12327 aix) postprocess_cc_v="|$tr , ' '" ;;
12328 esac
12329 $cat >ccsym <<EOS
12330 $startsh
12331 $cat >tmp.c <<EOF
12332 extern int foo;
12333 EOF
12334 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12335 do
12336         case "\$i" in
12337         -D*) echo "\$i" | $sed 's/^-D//';;
12338         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12339         esac
12340 done
12341 $rm -f try.c
12342 EOS
12343 postprocess_cc_v=''
12344 chmod +x ccsym
12345 $eunicefix ccsym
12346 ./ccsym > ccsym1.raw
12347 if $test -s ccsym1.raw; then
12348        $sort ccsym1.raw | $uniq >ccsym.raw
12349 else
12350        mv ccsym1.raw ccsym.raw
12351 fi
12352
12353 $awk '/\=/ { print $0; next }
12354         { print $0"=1" }' ccsym.raw >ccsym.list
12355 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12356 $comm -13 ccsym.true ccsym.list >ccsym.own
12357 $comm -12 ccsym.true ccsym.list >ccsym.com
12358 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12359 also=''
12360 if $test -z ccsym.raw; then
12361         echo "Your C compiler doesn't seem to define any symbols!" >&4
12362         echo " "
12363         echo "However, your C preprocessor defines the following symbols:"
12364         $cat Cppsym.true
12365         ccsymbols=''
12366         cppsymbols=`$cat Cppsym.true`
12367         cppsymbols=`echo $cppsymbols`
12368         cppccsymbols="$cppsymbols"
12369 else
12370         if $test -s ccsym.com; then
12371                 echo "Your C compiler and pre-processor define these symbols:"
12372                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12373                 also='also '
12374                 symbols='ones'
12375                 cppccsymbols=`$cat ccsym.com`
12376                 cppccsymbols=`echo $cppccsymbols`
12377                 $test "$silent" || sleep 1
12378         fi
12379         if $test -s ccsym.cpp; then
12380                 $test "$also" && echo " "
12381                 echo "Your C pre-processor ${also}defines the following symbols:"
12382                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12383                 also='further '
12384                 cppsymbols=`$cat ccsym.cpp`
12385                 cppsymbols=`echo $cppsymbols`
12386                 $test "$silent" || sleep 1
12387         fi
12388         if $test -s ccsym.own; then
12389                 $test "$also" && echo " "
12390                 echo "Your C compiler ${also}defines the following cpp symbols:"
12391                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12392                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12393                 ccsymbols=`$cat ccsym.own`
12394                 ccsymbols=`echo $ccsymbols`
12395                 $test "$silent" || sleep 1
12396         fi
12397 fi
12398 $rm -f ccsym*
12399
12400 : see if this is a termio system
12401 val="$undef"
12402 val2="$undef"
12403 val3="$undef"
12404 if $test `./findhdr termios.h`; then
12405         set tcsetattr i_termios
12406         eval $inlibc
12407         val3="$i_termios"
12408 fi
12409 echo " "
12410 case "$val3" in
12411 "$define") echo "You have POSIX termios.h... good!" >&4;;
12412 *) if ./Cppsym pyr; then
12413                 case "`/bin/universe`" in
12414                 ucb) if $test `./findhdr sgtty.h`; then
12415                                 val2="$define"
12416                                 echo "<sgtty.h> found." >&4
12417                         else
12418                                 echo "System is pyramid with BSD universe."
12419                                 echo "<sgtty.h> not found--you could have problems." >&4
12420                         fi;;
12421                 *) if $test `./findhdr termio.h`; then
12422                                 val="$define"
12423                                 echo "<termio.h> found." >&4
12424                         else
12425                                 echo "System is pyramid with USG universe."
12426                                 echo "<termio.h> not found--you could have problems." >&4
12427                         fi;;
12428                 esac
12429         elif ./usg; then
12430                 if $test `./findhdr termio.h`; then
12431                         echo "<termio.h> found." >&4
12432                         val="$define"
12433                 elif $test `./findhdr sgtty.h`; then
12434                         echo "<sgtty.h> found." >&4
12435                         val2="$define"
12436                 else
12437 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12438                 fi
12439         else
12440                 if $test `./findhdr sgtty.h`; then
12441                         echo "<sgtty.h> found." >&4
12442                         val2="$define"
12443                 elif $test `./findhdr termio.h`; then
12444                         echo "<termio.h> found." >&4
12445                         val="$define"
12446                 else
12447 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12448                 fi
12449         fi;;
12450 esac
12451 set i_termio; eval $setvar
12452 val=$val2; set i_sgtty; eval $setvar
12453 val=$val3; set i_termios; eval $setvar
12454
12455 : see if this is a shadow.h system
12456 set shadow.h i_shadow
12457 eval $inhdr
12458
12459 : see if this is a socks.h system
12460 set socks.h i_socks
12461 eval $inhdr
12462
12463 : see if stdarg is available
12464 echo " "
12465 if $test `./findhdr stdarg.h`; then
12466         echo "<stdarg.h> found." >&4
12467         valstd="$define"
12468 else
12469         echo "<stdarg.h> NOT found." >&4
12470         valstd="$undef"
12471 fi
12472
12473 : see if varags is available
12474 echo " "
12475 if $test `./findhdr varargs.h`; then
12476         echo "<varargs.h> found." >&4
12477 else
12478         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12479 fi
12480
12481 : set up the varargs testing programs
12482 $cat > varargs.c <<EOP
12483 #ifdef I_STDARG
12484 #include <stdarg.h>
12485 #endif
12486 #ifdef I_VARARGS
12487 #include <varargs.h>
12488 #endif
12489
12490 #ifdef I_STDARG
12491 int f(char *p, ...)
12492 #else
12493 int f(va_alist)
12494 va_dcl
12495 #endif
12496 {
12497         va_list ap;
12498 #ifndef I_STDARG
12499         char *p;
12500 #endif
12501 #ifdef I_STDARG
12502         va_start(ap,p);
12503 #else
12504         va_start(ap);
12505         p = va_arg(ap, char *);
12506 #endif
12507         va_end(ap);
12508 }
12509 EOP
12510 $cat > varargs <<EOP
12511 $startsh
12512 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12513         echo "true"
12514 else
12515         echo "false"
12516 fi
12517 $rm -f varargs$_o
12518 EOP
12519 chmod +x varargs
12520
12521 : now check which varargs header should be included
12522 echo " "
12523 i_varhdr=''
12524 case "$valstd" in
12525 "$define")
12526         if `./varargs I_STDARG`; then
12527                 val='stdarg.h'
12528         elif `./varargs I_VARARGS`; then
12529                 val='varargs.h'
12530         fi
12531         ;;
12532 *)
12533         if `./varargs I_VARARGS`; then
12534                 val='varargs.h'
12535         fi
12536         ;;
12537 esac
12538 case "$val" in
12539 '')
12540 echo "I could not find the definition for va_dcl... You have problems..." >&4
12541         val="$undef"; set i_stdarg; eval $setvar
12542         val="$undef"; set i_varargs; eval $setvar
12543         ;;
12544 *) 
12545         set i_varhdr
12546         eval $setvar
12547         case "$i_varhdr" in
12548         stdarg.h)
12549                 val="$define"; set i_stdarg; eval $setvar
12550                 val="$undef"; set i_varargs; eval $setvar
12551                 ;;
12552         varargs.h)
12553                 val="$undef"; set i_stdarg; eval $setvar
12554                 val="$define"; set i_varargs; eval $setvar
12555                 ;;
12556         esac
12557         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12558 esac
12559 $rm -f varargs*
12560
12561 : see if stddef is available
12562 set stddef.h i_stddef
12563 eval $inhdr
12564
12565 : see if sys/access.h is available
12566 set sys/access.h i_sysaccess
12567 eval $inhdr
12568
12569 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12570 set sys/filio.h i_sysfilio
12571 eval $inhdr
12572 echo " "
12573 if $test `./findhdr sys/ioctl.h`; then
12574         val="$define"
12575         echo '<sys/ioctl.h> found.' >&4
12576 else
12577         val="$undef"
12578         if $test $i_sysfilio = "$define"; then
12579             echo '<sys/ioctl.h> NOT found.' >&4
12580         else
12581                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12582                 $test $i_termio = "$define" && xxx="termio.h"
12583                 $test $i_termios = "$define" && xxx="termios.h"
12584 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12585         fi
12586 fi
12587 set i_sysioctl
12588 eval $setvar
12589
12590 : see if sys/resource.h has to be included
12591 set sys/resource.h i_sysresrc
12592 eval $inhdr
12593
12594 : see if sys/security.h is available
12595 set sys/security.h i_syssecrt
12596 eval $inhdr
12597
12598 : see if this is a sys/statvfs.h system
12599 set sys/statvfs.h i_sysstatvfs
12600 eval $inhdr
12601
12602 : see if this is a sys/un.h system
12603 set sys/un.h i_sysun
12604 eval $inhdr
12605
12606 : see if this is a syswait system
12607 set sys/wait.h i_syswait
12608 eval $inhdr
12609
12610 : see if this is an utime system
12611 set utime.h i_utime
12612 eval $inhdr
12613
12614 : see if this is a values.h system
12615 set values.h i_values
12616 eval $inhdr
12617
12618 : see if this is a vfork system
12619 case "$d_vfork" in
12620 "$define")
12621         set vfork.h i_vfork
12622         eval $inhdr
12623         ;;
12624 *)
12625         i_vfork="$undef"
12626         ;;
12627 esac
12628
12629 : see if gdbm.h is available
12630 set gdbm.h t_gdbm
12631 eval $inhdr
12632 case "$t_gdbm" in
12633 $define)
12634         : see if gdbm_open exists
12635         set gdbm_open d_gdbm_open
12636         eval $inlibc
12637         case "$d_gdbm_open" in
12638         $undef)
12639                 t_gdbm="$undef"
12640                 echo "We won't be including <gdbm.h>"
12641                 ;;
12642         esac
12643         ;;
12644 esac
12645 val="$t_gdbm"
12646 set i_gdbm
12647 eval $setvar
12648
12649 echo " "
12650 echo "Looking for extensions..." >&4
12651 : If we are using the old config.sh, known_extensions may contain
12652 : old or inaccurate or duplicate values.
12653 known_extensions=''
12654 nonxs_extensions=''
12655 : We do not use find because it might not be available.
12656 : We do not just use MANIFEST because the user may have dropped
12657 : some additional extensions into the source tree and expect them
12658 : to be built.
12659
12660 : Function to recursively find available extensions, ignoring DynaLoader
12661 : NOTE: recursion limit of 10 to prevent runaway in case of symlink madness
12662 find_extensions='
12663     for xxx in *; do
12664        case "$xxx" in
12665            DynaLoader|dynaload) ;;
12666            *)
12667            if $test -f $xxx/$xxx.xs; then
12668                known_extensions="$known_extensions $1$xxx";
12669            elif $test -f $xxx/Makefile.PL; then
12670                nonxs_extensions="$nonxs_extensions $1$xxx";
12671            else
12672                if $test -d $xxx -a $# -lt 10; then
12673                    set $1$xxx/ $*;
12674                    cd $xxx;
12675                    eval $find_extensions;
12676                    cd ..;
12677                    shift;
12678                fi
12679            fi
12680            ;;
12681        esac
12682     done'
12683 tdir=`pwd`
12684 cd $rsrc/ext
12685 set
12686 shift
12687 eval $find_extensions
12688 set X $nonxs_extensions
12689 shift
12690 nonxs_extensions="$*"
12691 set X $known_extensions
12692 shift
12693 known_extensions="$*"
12694 cd $tdir
12695
12696 : Now see which are supported on this system.
12697 avail_ext=''
12698 for xxx in $known_extensions ; do
12699         case "$xxx" in
12700         DB_File|db_file)
12701                 case "$i_db" in
12702                 $define) avail_ext="$avail_ext $xxx" ;;
12703                 esac
12704                 ;;
12705         GDBM_File|gdbm_fil)
12706                 case "$i_gdbm" in 
12707                 $define) avail_ext="$avail_ext $xxx" ;;
12708                 esac
12709                 ;;
12710         NDBM_File|ndbm_fil)
12711                 case "$i_ndbm" in
12712                 $define) avail_ext="$avail_ext $xxx" ;;
12713                 esac
12714                 ;;
12715         ODBM_File|odbm_fil) 
12716                 case "${i_dbm}${i_rpcsvcdbm}" in
12717                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12718                 esac
12719                 ;;
12720         POSIX|posix)
12721                 case "$useposix" in
12722                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12723                 esac
12724                 ;;
12725         Opcode|opcode)
12726                 case "$useopcode" in
12727                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12728                 esac
12729                 ;;
12730         Socket|socket)
12731                 case "$d_socket" in 
12732                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12733                 esac
12734                 ;;
12735         Thread|thread)
12736                 case "$usethreads" in 
12737                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12738                 esac
12739                 ;;
12740         IPC/SysV|ipc/sysv)
12741                 : XXX Do we need a useipcsysv variable here
12742                 case "${d_msg}${d_sem}${d_shm}" in 
12743                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12744                 esac
12745                 ;;
12746         *)      avail_ext="$avail_ext $xxx"
12747                 ;;
12748         esac
12749 done
12750
12751 set X $avail_ext
12752 shift
12753 avail_ext="$*"
12754
12755 : Now see which nonxs extensions are supported on this system.
12756 : For now assume all are.
12757 nonxs_ext=''
12758 for xxx in $nonxs_extensions ; do
12759         case "$xxx" in
12760         *)      nonxs_ext="$nonxs_ext $xxx"
12761                 ;;
12762         esac
12763 done
12764
12765 set X $nonxs_ext
12766 shift
12767 nonxs_ext="$*"
12768
12769 case $usedl in
12770 $define)
12771         $cat <<EOM
12772 A number of extensions are supplied with $package.  You may choose to
12773 compile these extensions for dynamic loading (the default), compile
12774 them into the $package executable (static loading), or not include
12775 them at all.  Answer "none" to include no extensions.
12776 Note that DynaLoader is always built and need not be mentioned here.
12777
12778 EOM
12779         case "$dynamic_ext" in
12780         '') dflt="$avail_ext" ;;
12781         *)      dflt="$dynamic_ext"
12782                 # Perhaps we are reusing an old out-of-date config.sh.
12783                 case "$hint" in
12784                 previous)
12785                         if test X"$dynamic_ext" != X"$avail_ext"; then
12786                                 $cat <<EOM
12787 NOTICE:  Your previous config.sh list may be incorrect. 
12788 The extensions now available to you are 
12789         ${avail_ext}
12790 but the default list from your previous config.sh is
12791         ${dynamic_ext} 
12792
12793 EOM
12794                         fi
12795                         ;;
12796                 esac
12797                 ;;
12798         esac
12799         case "$dflt" in
12800         '')     dflt=none;;
12801         esac
12802         rp="What extensions do you wish to load dynamically?"
12803         . ./myread
12804         case "$ans" in
12805         none) dynamic_ext=' ' ;;
12806         *) dynamic_ext="$ans" ;;
12807         esac
12808
12809         case "$static_ext" in
12810         '')
12811                 : Exclude those already listed in dynamic linking
12812                 dflt=''
12813                 for xxx in $avail_ext; do
12814                         case " $dynamic_ext " in
12815                         *" $xxx "*) ;;
12816                         *) dflt="$dflt $xxx" ;;
12817                         esac
12818                 done
12819                 set X $dflt
12820                 shift
12821                 dflt="$*"
12822                 ;;
12823         *)  dflt="$static_ext" 
12824                 ;;
12825         esac
12826
12827         case "$dflt" in
12828         '')     dflt=none;;
12829         esac
12830         rp="What extensions do you wish to load statically?"
12831         . ./myread
12832         case "$ans" in
12833         none) static_ext=' ' ;;
12834         *) static_ext="$ans" ;;
12835         esac
12836         ;;
12837 *)
12838         $cat <<EOM
12839 A number of extensions are supplied with $package.  Answer "none" 
12840 to include no extensions. 
12841 Note that DynaLoader is always built and need not be mentioned here.
12842
12843 EOM
12844         case "$static_ext" in
12845         '') dflt="$avail_ext" ;;
12846         *)      dflt="$static_ext"
12847                 # Perhaps we are reusing an old out-of-date config.sh.
12848                 case "$hint" in
12849                 previous)
12850                         if test X"$static_ext" != X"$avail_ext"; then
12851                                 $cat <<EOM
12852 NOTICE:  Your previous config.sh list may be incorrect. 
12853 The extensions now available to you are 
12854         ${avail_ext}
12855 but the default list from your previous config.sh is
12856         ${static_ext} 
12857
12858 EOM
12859                         fi
12860                         ;;
12861                 esac
12862                 ;;
12863         esac
12864         : Exclude those that are not xs extensions
12865         case "$dflt" in
12866         '')     dflt=none;;
12867         esac
12868         rp="What extensions do you wish to include?"
12869         . ./myread
12870         case "$ans" in
12871         none) static_ext=' ' ;;
12872         *) static_ext="$ans" ;;
12873         esac
12874         ;;
12875 esac
12876
12877 set X $dynamic_ext $static_ext $nonxs_ext
12878 shift
12879 extensions="$*"
12880
12881 : Remove build directory name from cppstdin so it can be used from
12882 : either the present location or the final installed location.
12883 echo " "
12884 : Get out of the UU directory to get correct path name.
12885 cd ..
12886 case "$cppstdin" in
12887 `pwd`/cppstdin)
12888         echo "Stripping down cppstdin path name"
12889         cppstdin=cppstdin
12890         ;;
12891 esac
12892 cd UU
12893
12894 : end of configuration questions
12895 echo " "
12896 echo "End of configuration questions."
12897 echo " "
12898
12899 : back to where it started
12900 if test -d ../UU; then
12901         cd ..
12902 fi
12903
12904 : configuration may be patched via a 'config.over' file
12905 if $test -f config.over; then
12906         echo " "
12907         dflt=y
12908         rp='I see a config.over file.  Do you wish to load it?'
12909         . UU/myread
12910         case "$ans" in
12911         n*) echo "OK, I'll ignore it.";;
12912         *)      . ./config.over
12913                 echo "Configuration override changes have been loaded."
12914                 ;;
12915         esac
12916 fi
12917
12918 : in case they want portability, strip down executable paths
12919 case "$d_portable" in
12920 "$define")
12921         echo " "
12922         echo "Stripping down executable paths..." >&4
12923         for file in $loclist $trylist; do
12924                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12925                         eval $file="\$file"
12926                 fi
12927         done
12928         ;;
12929 esac
12930
12931 : create config.sh file
12932 echo " "
12933 echo "Creating config.sh..." >&4
12934 $spitshell <<EOT >config.sh
12935 $startsh
12936 #
12937 # This file was produced by running the Configure script. It holds all the
12938 # definitions figured out by Configure. Should you modify one of these values,
12939 # do not forget to propagate your changes by running "Configure -der". You may
12940 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12941 #
12942
12943 # Package name      : $package
12944 # Source directory  : $src
12945 # Configuration time: $cf_time
12946 # Configured by     : $cf_by
12947 # Target system     : $myuname
12948
12949 Author='$Author'
12950 Date='$Date'
12951 Header='$Header'
12952 Id='$Id'
12953 Locker='$Locker'
12954 Log='$Log'
12955 Mcc='$Mcc'
12956 RCSfile='$RCSfile'
12957 Revision='$Revision'
12958 Source='$Source'
12959 State='$State'
12960 _a='$_a'
12961 _exe='$_exe'
12962 _o='$_o'
12963 afs='$afs'
12964 alignbytes='$alignbytes'
12965 ansi2knr='$ansi2knr'
12966 aphostname='$aphostname'
12967 apiversion='$apiversion'
12968 ar='$ar'
12969 archlib='$archlib'
12970 archlibexp='$archlibexp'
12971 archname64='$archname64'
12972 archname='$archname'
12973 archobjs='$archobjs'
12974 awk='$awk'
12975 baserev='$baserev'
12976 bash='$bash'
12977 bin='$bin'
12978 binexp='$binexp'
12979 bison='$bison'
12980 byacc='$byacc'
12981 byteorder='$byteorder'
12982 c='$c'
12983 castflags='$castflags'
12984 cat='$cat'
12985 cc='$cc'
12986 cccdlflags='$cccdlflags'
12987 ccdlflags='$ccdlflags'
12988 ccflags='$ccflags'
12989 ccsymbols='$ccsymbols'
12990 cf_by='$cf_by'
12991 cf_email='$cf_email'
12992 cf_time='$cf_time'
12993 chgrp='$chgrp'
12994 chmod='$chmod'
12995 chown='$chown'
12996 clocktype='$clocktype'
12997 comm='$comm'
12998 compress='$compress'
12999 contains='$contains'
13000 cp='$cp'
13001 cpio='$cpio'
13002 cpp='$cpp'
13003 cpp_stuff='$cpp_stuff'
13004 cppccsymbols='$cppccsymbols'
13005 cppflags='$cppflags'
13006 cpplast='$cpplast'
13007 cppminus='$cppminus'
13008 cpprun='$cpprun'
13009 cppstdin='$cppstdin'
13010 cppsymbols='$cppsymbols'
13011 crosscompile='$crosscompile'
13012 cryptlib='$cryptlib'
13013 csh='$csh'
13014 d_Gconvert='$d_Gconvert'
13015 d_access='$d_access'
13016 d_accessx='$d_accessx'
13017 d_alarm='$d_alarm'
13018 d_archlib='$d_archlib'
13019 d_attribut='$d_attribut'
13020 d_bcmp='$d_bcmp'
13021 d_bcopy='$d_bcopy'
13022 d_bsd='$d_bsd'
13023 d_bsdgetpgrp='$d_bsdgetpgrp'
13024 d_bsdsetpgrp='$d_bsdsetpgrp'
13025 d_bzero='$d_bzero'
13026 d_casti32='$d_casti32'
13027 d_castneg='$d_castneg'
13028 d_charvspr='$d_charvspr'
13029 d_chown='$d_chown'
13030 d_chroot='$d_chroot'
13031 d_chsize='$d_chsize'
13032 d_closedir='$d_closedir'
13033 d_cmsghdr_s='$d_cmsghdr_s'
13034 d_const='$d_const'
13035 d_crypt='$d_crypt'
13036 d_csh='$d_csh'
13037 d_cuserid='$d_cuserid'
13038 d_dbl_dig='$d_dbl_dig'
13039 d_dbmclose64='$d_dbmclose64'
13040 d_dbminit64='$d_dbminit64'
13041 d_delete64='$d_delete64'
13042 d_difftime='$d_difftime'
13043 d_dirent64_s='$d_dirent64_s'
13044 d_dirnamlen='$d_dirnamlen'
13045 d_dlerror='$d_dlerror'
13046 d_dlopen='$d_dlopen'
13047 d_dlsymun='$d_dlsymun'
13048 d_dosuid='$d_dosuid'
13049 d_drand48proto='$d_drand48proto'
13050 d_dup2='$d_dup2'
13051 d_eaccess='$d_eaccess'
13052 d_endgrent='$d_endgrent'
13053 d_endhent='$d_endhent'
13054 d_endnent='$d_endnent'
13055 d_endpent='$d_endpent'
13056 d_endpwent='$d_endpwent'
13057 d_endsent='$d_endsent'
13058 d_endspent='$d_endspent'
13059 d_eofnblk='$d_eofnblk'
13060 d_eunice='$d_eunice'
13061 d_fchmod='$d_fchmod'
13062 d_fchown='$d_fchown'
13063 d_fcntl='$d_fcntl'
13064 d_fd_macros='$d_fd_macros'
13065 d_fd_set='$d_fd_set'
13066 d_fds_bits='$d_fds_bits'
13067 d_fetch64='$d_fetch64'
13068 d_fgetpos64='$d_fgetpos64'
13069 d_fgetpos='$d_fgetpos'
13070 d_firstkey64='$d_firstkey64'
13071 d_flexfnam='$d_flexfnam'
13072 d_flock64_s='$d_flock64_s'
13073 d_flock='$d_flock'
13074 d_fopen64='$d_fopen64'
13075 d_fork='$d_fork'
13076 d_fpathconf='$d_fpathconf'
13077 d_freopen64='$d_freopen64'
13078 d_fseek64='$d_fseek64'
13079 d_fseeko64='$d_fseeko64'
13080 d_fseeko='$d_fseeko'
13081 d_fsetpos64='$d_fsetpos64'
13082 d_fsetpos='$d_fsetpos'
13083 d_fstat64='$d_fstat64'
13084 d_fstatfs='$d_fstatfs'
13085 d_fstatvfs='$d_fstatvfs'
13086 d_ftell64='$d_ftell64'
13087 d_ftello64='$d_ftello64'
13088 d_ftello='$d_ftello'
13089 d_ftime='$d_ftime'
13090 d_ftruncate64='$d_ftruncate64'
13091 d_getgrent='$d_getgrent'
13092 d_getgrps='$d_getgrps'
13093 d_gethbyaddr='$d_gethbyaddr'
13094 d_gethbyname='$d_gethbyname'
13095 d_gethent='$d_gethent'
13096 d_gethname='$d_gethname'
13097 d_gethostprotos='$d_gethostprotos'
13098 d_getlogin='$d_getlogin'
13099 d_getmntent='$d_getmntent'
13100 d_getnbyaddr='$d_getnbyaddr'
13101 d_getnbyname='$d_getnbyname'
13102 d_getnent='$d_getnent'
13103 d_getnetprotos='$d_getnetprotos'
13104 d_getpbyname='$d_getpbyname'
13105 d_getpbynumber='$d_getpbynumber'
13106 d_getpent='$d_getpent'
13107 d_getpgid='$d_getpgid'
13108 d_getpgrp2='$d_getpgrp2'
13109 d_getpgrp='$d_getpgrp'
13110 d_getppid='$d_getppid'
13111 d_getprior='$d_getprior'
13112 d_getprotoprotos='$d_getprotoprotos'
13113 d_getpwent='$d_getpwent'
13114 d_getsbyname='$d_getsbyname'
13115 d_getsbyport='$d_getsbyport'
13116 d_getsent='$d_getsent'
13117 d_getservprotos='$d_getservprotos'
13118 d_getspent='$d_getspent'
13119 d_getspnam='$d_getspnam'
13120 d_gettimeod='$d_gettimeod'
13121 d_gnulibc='$d_gnulibc'
13122 d_grpasswd='$d_grpasswd'
13123 d_hasmntopt='$d_hasmntopt'
13124 d_htonl='$d_htonl'
13125 d_index='$d_index'
13126 d_inetaton='$d_inetaton'
13127 d_ino64_t='$d_ino64_t'
13128 d_int64t='$d_int64t'
13129 d_iovec_s='$d_iovec_s'
13130 d_isascii='$d_isascii'
13131 d_killpg='$d_killpg'
13132 d_lchown='$d_lchown'
13133 d_link='$d_link'
13134 d_llseek='$d_llseek'
13135 d_locconv='$d_locconv'
13136 d_lockf64='$d_lockf64'
13137 d_lockf='$d_lockf'
13138 d_longdbl='$d_longdbl'
13139 d_longlong='$d_longlong'
13140 d_lseek64='$d_lseek64'
13141 d_lstat64='$d_lstat64'
13142 d_lstat='$d_lstat'
13143 d_madvise='$d_madvise'
13144 d_mblen='$d_mblen'
13145 d_mbstowcs='$d_mbstowcs'
13146 d_mbtowc='$d_mbtowc'
13147 d_memchr='$d_memchr'
13148 d_memcmp='$d_memcmp'
13149 d_memcpy='$d_memcpy'
13150 d_memmove='$d_memmove'
13151 d_memset='$d_memset'
13152 d_mkdir='$d_mkdir'
13153 d_mkfifo='$d_mkfifo'
13154 d_mktime='$d_mktime'
13155 d_mmap='$d_mmap'
13156 d_mprotect='$d_mprotect'
13157 d_msg='$d_msg'
13158 d_msg_ctrunc='$d_msg_ctrunc'
13159 d_msg_dontroute='$d_msg_dontroute'
13160 d_msg_oob='$d_msg_oob'
13161 d_msg_peek='$d_msg_peek'
13162 d_msg_proxy='$d_msg_proxy'
13163 d_msgctl='$d_msgctl'
13164 d_msgget='$d_msgget'
13165 d_msghdr_s='$d_msghdr_s'
13166 d_msgrcv='$d_msgrcv'
13167 d_msgsnd='$d_msgsnd'
13168 d_msync='$d_msync'
13169 d_munmap='$d_munmap'
13170 d_mymalloc='$d_mymalloc'
13171 d_nextkey64='$d_nextkey64'
13172 d_nice='$d_nice'
13173 d_off64_t='$d_off64_t'
13174 d_offset_t='$d_offset_t'
13175 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
13176 d_oldpthreads='$d_oldpthreads'
13177 d_oldsock='$d_oldsock'
13178 d_open3='$d_open3'
13179 d_open64='$d_open64'
13180 d_opendir64='$d_opendir64'
13181 d_pathconf='$d_pathconf'
13182 d_pause='$d_pause'
13183 d_phostname='$d_phostname'
13184 d_pipe='$d_pipe'
13185 d_poll='$d_poll'
13186 d_portable='$d_portable'
13187 d_pthread_yield='$d_pthread_yield'
13188 d_pwage='$d_pwage'
13189 d_pwchange='$d_pwchange'
13190 d_pwclass='$d_pwclass'
13191 d_pwcomment='$d_pwcomment'
13192 d_pwexpire='$d_pwexpire'
13193 d_pwgecos='$d_pwgecos'
13194 d_pwpasswd='$d_pwpasswd'
13195 d_pwquota='$d_pwquota'
13196 d_readdir64='$d_readdir64'
13197 d_readdir='$d_readdir'
13198 d_readlink='$d_readlink'
13199 d_readv='$d_readv'
13200 d_recvmsg='$d_recvmsg'
13201 d_rename='$d_rename'
13202 d_rewinddir='$d_rewinddir'
13203 d_rmdir='$d_rmdir'
13204 d_safebcpy='$d_safebcpy'
13205 d_safemcpy='$d_safemcpy'
13206 d_sanemcmp='$d_sanemcmp'
13207 d_sched_yield='$d_sched_yield'
13208 d_scm_rights='$d_scm_rights'
13209 d_seekdir64='$d_seekdir64'
13210 d_seekdir='$d_seekdir'
13211 d_select='$d_select'
13212 d_sem='$d_sem'
13213 d_semctl='$d_semctl'
13214 d_semctl_semid_ds='$d_semctl_semid_ds'
13215 d_semctl_semun='$d_semctl_semun'
13216 d_semget='$d_semget'
13217 d_semop='$d_semop'
13218 d_sendmsg='$d_sendmsg'
13219 d_setegid='$d_setegid'
13220 d_seteuid='$d_seteuid'
13221 d_setgrent='$d_setgrent'
13222 d_setgrps='$d_setgrps'
13223 d_sethent='$d_sethent'
13224 d_setlinebuf='$d_setlinebuf'
13225 d_setlocale='$d_setlocale'
13226 d_setnent='$d_setnent'
13227 d_setpent='$d_setpent'
13228 d_setpgid='$d_setpgid'
13229 d_setpgrp2='$d_setpgrp2'
13230 d_setpgrp='$d_setpgrp'
13231 d_setprior='$d_setprior'
13232 d_setpwent='$d_setpwent'
13233 d_setregid='$d_setregid'
13234 d_setresgid='$d_setresgid'
13235 d_setresuid='$d_setresuid'
13236 d_setreuid='$d_setreuid'
13237 d_setrgid='$d_setrgid'
13238 d_setruid='$d_setruid'
13239 d_setsent='$d_setsent'
13240 d_setsid='$d_setsid'
13241 d_setspent='$d_setspent'
13242 d_setvbuf='$d_setvbuf'
13243 d_sfio='$d_sfio'
13244 d_shm='$d_shm'
13245 d_shmat='$d_shmat'
13246 d_shmatprototype='$d_shmatprototype'
13247 d_shmctl='$d_shmctl'
13248 d_shmdt='$d_shmdt'
13249 d_shmget='$d_shmget'
13250 d_sigaction='$d_sigaction'
13251 d_sigsetjmp='$d_sigsetjmp'
13252 d_socket='$d_socket'
13253 d_sockpair='$d_sockpair'
13254 d_stat64='$d_stat64'
13255 d_statblks='$d_statblks'
13256 d_statfs='$d_statfs'
13257 d_statfsflags='$d_statfsflags'
13258 d_statvfs='$d_statvfs'
13259 d_stdio_cnt_lval='$d_stdio_cnt_lval'
13260 d_stdio_ptr_lval='$d_stdio_ptr_lval'
13261 d_stdio_stream_array='$d_stdio_stream_array'
13262 d_stdiobase='$d_stdiobase'
13263 d_stdstdio='$d_stdstdio'
13264 d_store64='$d_store64'
13265 d_strchr='$d_strchr'
13266 d_strcoll='$d_strcoll'
13267 d_strctcpy='$d_strctcpy'
13268 d_strerrm='$d_strerrm'
13269 d_strerror='$d_strerror'
13270 d_strtod='$d_strtod'
13271 d_strtol='$d_strtol'
13272 d_strtoul='$d_strtoul'
13273 d_strxfrm='$d_strxfrm'
13274 d_suidsafe='$d_suidsafe'
13275 d_symlink='$d_symlink'
13276 d_syscall='$d_syscall'
13277 d_sysconf='$d_sysconf'
13278 d_sysernlst='$d_sysernlst'
13279 d_syserrlst='$d_syserrlst'
13280 d_system='$d_system'
13281 d_tcgetpgrp='$d_tcgetpgrp'
13282 d_tcsetpgrp='$d_tcsetpgrp'
13283 d_telldir64='$d_telldir64'
13284 d_telldir='$d_telldir'
13285 d_telldirproto='$d_telldirproto'
13286 d_time='$d_time'
13287 d_times='$d_times'
13288 d_tmpfile64='$d_tmpfile64'
13289 d_truncate64='$d_truncate64'
13290 d_truncate='$d_truncate'
13291 d_tzname='$d_tzname'
13292 d_umask='$d_umask'
13293 d_uname='$d_uname'
13294 d_union_semun='$d_union_semun'
13295 d_vfork='$d_vfork'
13296 d_void_closedir='$d_void_closedir'
13297 d_voidsig='$d_voidsig'
13298 d_voidtty='$d_voidtty'
13299 d_volatile='$d_volatile'
13300 d_vprintf='$d_vprintf'
13301 d_wait4='$d_wait4'
13302 d_waitpid='$d_waitpid'
13303 d_wcstombs='$d_wcstombs'
13304 d_wctomb='$d_wctomb'
13305 d_writev='$d_writev'
13306 d_xenix='$d_xenix'
13307 date='$date'
13308 db_hashtype='$db_hashtype'
13309 db_prefixtype='$db_prefixtype'
13310 defvoidused='$defvoidused'
13311 direntrytype='$direntrytype'
13312 dlext='$dlext'
13313 dlsrc='$dlsrc'
13314 doublesize='$doublesize'
13315 drand01='$drand01'
13316 dynamic_ext='$dynamic_ext'
13317 eagain='$eagain'
13318 ebcdic='$ebcdic'
13319 echo='$echo'
13320 egrep='$egrep'
13321 emacs='$emacs'
13322 eunicefix='$eunicefix'
13323 exe_ext='$exe_ext'
13324 expr='$expr'
13325 extensions='$extensions'
13326 fflushNULL='$fflushNULL'
13327 fflushall='$fflushall'
13328 find='$find'
13329 firstmakefile='$firstmakefile'
13330 flex='$flex'
13331 fpostype='$fpostype'
13332 freetype='$freetype'
13333 full_ar='$full_ar'
13334 full_csh='$full_csh'
13335 full_sed='$full_sed'
13336 gccversion='$gccversion'
13337 gidtype='$gidtype'
13338 glibpth='$glibpth'
13339 grep='$grep'
13340 groupcat='$groupcat'
13341 groupstype='$groupstype'
13342 gzip='$gzip'
13343 h_fcntl='$h_fcntl'
13344 h_sysfile='$h_sysfile'
13345 hint='$hint'
13346 hostcat='$hostcat'
13347 huge='$huge'
13348 i_arpainet='$i_arpainet'
13349 i_bsdioctl='$i_bsdioctl'
13350 i_db='$i_db'
13351 i_dbm='$i_dbm'
13352 i_dirent='$i_dirent'
13353 i_dld='$i_dld'
13354 i_dlfcn='$i_dlfcn'
13355 i_fcntl='$i_fcntl'
13356 i_float='$i_float'
13357 i_gdbm='$i_gdbm'
13358 i_grp='$i_grp'
13359 i_inttypes='$i_inttypes'
13360 i_limits='$i_limits'
13361 i_locale='$i_locale'
13362 i_machcthr='$i_machcthr'
13363 i_malloc='$i_malloc'
13364 i_math='$i_math'
13365 i_memory='$i_memory'
13366 i_mntent='$i_mntent'
13367 i_ndbm='$i_ndbm'
13368 i_netdb='$i_netdb'
13369 i_neterrno='$i_neterrno'
13370 i_netinettcp='$i_netinettcp'
13371 i_niin='$i_niin'
13372 i_poll='$i_poll'
13373 i_pthread='$i_pthread'
13374 i_pwd='$i_pwd'
13375 i_rpcsvcdbm='$i_rpcsvcdbm'
13376 i_sfio='$i_sfio'
13377 i_sgtty='$i_sgtty'
13378 i_shadow='$i_shadow'
13379 i_socks='$i_socks'
13380 i_stdarg='$i_stdarg'
13381 i_stddef='$i_stddef'
13382 i_stdlib='$i_stdlib'
13383 i_string='$i_string'
13384 i_sysaccess='$i_sysaccess'
13385 i_sysdir='$i_sysdir'
13386 i_sysfile='$i_sysfile'
13387 i_sysfilio='$i_sysfilio'
13388 i_sysin='$i_sysin'
13389 i_sysioctl='$i_sysioctl'
13390 i_sysmman='$i_sysmman'
13391 i_sysmount='$i_sysmount'
13392 i_sysndir='$i_sysndir'
13393 i_sysparam='$i_sysparam'
13394 i_sysresrc='$i_sysresrc'
13395 i_syssecrt='$i_syssecrt'
13396 i_sysselct='$i_sysselct'
13397 i_syssockio='$i_syssockio'
13398 i_sysstat='$i_sysstat'
13399 i_sysstatvfs='$i_sysstatvfs'
13400 i_systime='$i_systime'
13401 i_systimek='$i_systimek'
13402 i_systimes='$i_systimes'
13403 i_systypes='$i_systypes'
13404 i_sysuio='$i_sysuio'
13405 i_sysun='$i_sysun'
13406 i_syswait='$i_syswait'
13407 i_termio='$i_termio'
13408 i_termios='$i_termios'
13409 i_time='$i_time'
13410 i_unistd='$i_unistd'
13411 i_utime='$i_utime'
13412 i_values='$i_values'
13413 i_varargs='$i_varargs'
13414 i_varhdr='$i_varhdr'
13415 i_vfork='$i_vfork'
13416 ignore_versioned_solibs='$ignore_versioned_solibs'
13417 incpath='$incpath'
13418 inews='$inews'
13419 installarchlib='$installarchlib'
13420 installbin='$installbin'
13421 installman1dir='$installman1dir'
13422 installman3dir='$installman3dir'
13423 installprivlib='$installprivlib'
13424 installscript='$installscript'
13425 installsitearch='$installsitearch'
13426 installsitelib='$installsitelib'
13427 installusrbinperl='$installusrbinperl'
13428 intsize='$intsize'
13429 known_extensions='$known_extensions'
13430 ksh='$ksh'
13431 large='$large'
13432 ld='$ld'
13433 lddlflags='$lddlflags'
13434 ldflags='$ldflags'
13435 ldlibpthname='$ldlibpthname'
13436 less='$less'
13437 lib_ext='$lib_ext'
13438 libc='$libc'
13439 libperl='$libperl'
13440 libpth='$libpth'
13441 libs='$libs'
13442 libswanted='$libswanted'
13443 line='$line'
13444 lint='$lint'
13445 lkflags='$lkflags'
13446 ln='$ln'
13447 lns='$lns'
13448 locincpth='$locincpth'
13449 loclibpth='$loclibpth'
13450 longdblsize='$longdblsize'
13451 longlongsize='$longlongsize'
13452 longsize='$longsize'
13453 lp='$lp'
13454 lpr='$lpr'
13455 ls='$ls'
13456 lseeksize='$lseeksize'
13457 lseektype='$lseektype'
13458 mail='$mail'
13459 mailx='$mailx'
13460 make='$make'
13461 make_set_make='$make_set_make'
13462 mallocobj='$mallocobj'
13463 mallocsrc='$mallocsrc'
13464 malloctype='$malloctype'
13465 man1dir='$man1dir'
13466 man1direxp='$man1direxp'
13467 man1ext='$man1ext'
13468 man3dir='$man3dir'
13469 man3direxp='$man3direxp'
13470 man3ext='$man3ext'
13471 medium='$medium'
13472 mips='$mips'
13473 mips_type='$mips_type'
13474 mkdir='$mkdir'
13475 mmaptype='$mmaptype'
13476 models='$models'
13477 modetype='$modetype'
13478 more='$more'
13479 multiarch='$multiarch'
13480 mv='$mv'
13481 myarchname='$myarchname'
13482 mydomain='$mydomain'
13483 myhostname='$myhostname'
13484 myuname='$myuname'
13485 n='$n'
13486 netdb_hlen_type='$netdb_hlen_type'
13487 netdb_host_type='$netdb_host_type'
13488 netdb_name_type='$netdb_name_type'
13489 netdb_net_type='$netdb_net_type'
13490 nm='$nm'
13491 nm_opt='$nm_opt'
13492 nm_so_opt='$nm_so_opt'
13493 nonxs_ext='$nonxs_ext'
13494 nroff='$nroff'
13495 o_nonblock='$o_nonblock'
13496 obj_ext='$obj_ext'
13497 old_pthread_create_joinable='$old_pthread_create_joinable'
13498 optimize='$optimize'
13499 orderlib='$orderlib'
13500 osname='$osname'
13501 osvers='$osvers'
13502 package='$package'
13503 pager='$pager'
13504 passcat='$passcat'
13505 patchlevel='$patchlevel'
13506 path_sep='$path_sep'
13507 perl='$perl'
13508 perladmin='$perladmin'
13509 perlpath='$perlpath'
13510 pg='$pg'
13511 phostname='$phostname'
13512 pidtype='$pidtype'
13513 plibpth='$plibpth'
13514 pmake='$pmake'
13515 pr='$pr'
13516 prefix='$prefix'
13517 prefixexp='$prefixexp'
13518 privlib='$privlib'
13519 privlibexp='$privlibexp'
13520 prototype='$prototype'
13521 ptrsize='$ptrsize'
13522 randbits='$randbits'
13523 randfunc='$randfunc'
13524 randseedtype='$randseedtype'
13525 ranlib='$ranlib'
13526 rd_nodata='$rd_nodata'
13527 rm='$rm'
13528 rmail='$rmail'
13529 runnm='$runnm'
13530 sched_yield='$sched_yield'
13531 scriptdir='$scriptdir'
13532 scriptdirexp='$scriptdirexp'
13533 sed='$sed'
13534 seedfunc='$seedfunc'
13535 selectminbits='$selectminbits'
13536 selecttype='$selecttype'
13537 sendmail='$sendmail'
13538 sh='$sh'
13539 shar='$shar'
13540 sharpbang='$sharpbang'
13541 shmattype='$shmattype'
13542 shortsize='$shortsize'
13543 shrpenv='$shrpenv'
13544 shsharp='$shsharp'
13545 sig_count='$sig_count'
13546 sig_name='$sig_name'
13547 sig_name_init='$sig_name_init'
13548 sig_num='$sig_num'
13549 sig_num_init='$sig_num_init'
13550 signal_t='$signal_t'
13551 sitearch='$sitearch'
13552 sitearchexp='$sitearchexp'
13553 sitelib='$sitelib'
13554 sitelibexp='$sitelibexp'
13555 sizetype='$sizetype'
13556 sleep='$sleep'
13557 smail='$smail'
13558 small='$small'
13559 so='$so'
13560 sockethdr='$sockethdr'
13561 socketlib='$socketlib'
13562 sort='$sort'
13563 spackage='$spackage'
13564 spitshell='$spitshell'
13565 split='$split'
13566 src='$src'
13567 ssizetype='$ssizetype'
13568 startperl='$startperl'
13569 startsh='$startsh'
13570 static_ext='$static_ext'
13571 stdchar='$stdchar'
13572 stdio_base='$stdio_base'
13573 stdio_bufsiz='$stdio_bufsiz'
13574 stdio_cnt='$stdio_cnt'
13575 stdio_filbuf='$stdio_filbuf'
13576 stdio_ptr='$stdio_ptr'
13577 stdio_stream_array='$stdio_stream_array'
13578 strings='$strings'
13579 submit='$submit'
13580 subversion='$subversion'
13581 sysman='$sysman'
13582 tail='$tail'
13583 tar='$tar'
13584 tbl='$tbl'
13585 tee='$tee'
13586 test='$test'
13587 timeincl='$timeincl'
13588 timetype='$timetype'
13589 touch='$touch'
13590 tr='$tr'
13591 trnl='$trnl'
13592 troff='$troff'
13593 uidtype='$uidtype'
13594 uname='$uname'
13595 uniq='$uniq'
13596 use64bits='$use64bits'
13597 usedl='$usedl'
13598 usemultiplicity='$usemultiplicity'
13599 usemymalloc='$usemymalloc'
13600 usenm='$usenm'
13601 useopcode='$useopcode'
13602 useperlio='$useperlio'
13603 useposix='$useposix'
13604 usesfio='$usesfio'
13605 useshrplib='$useshrplib'
13606 usesocks='$usesocks'
13607 usethreads='$usethreads'
13608 usevfork='$usevfork'
13609 usrinc='$usrinc'
13610 uuname='$uuname'
13611 version='$version'
13612 vi='$vi'
13613 voidflags='$voidflags'
13614 xlibpth='$xlibpth'
13615 zcat='$zcat'
13616 zip='$zip'
13617 EOT
13618
13619 : Add in command line options if available
13620 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13621
13622 : add special variables
13623 $test -f $src/patchlevel.h && \
13624 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13625 echo "CONFIGDOTSH=true" >>config.sh
13626
13627 : propagate old symbols
13628 if $test -f UU/config.sh; then
13629         <UU/config.sh sort | uniq >UU/oldconfig.sh
13630         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13631         sort | uniq -u >UU/oldsyms
13632         set X `cat UU/oldsyms`
13633         shift
13634         case $# in
13635         0) ;;
13636         *)
13637                 cat <<EOM
13638 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13639 EOM
13640                 echo "# Variables propagated from previous config.sh file." >>config.sh
13641                 for sym in `cat UU/oldsyms`; do
13642                         echo "    Propagating $hint variable "'$'"$sym..."
13643                         eval 'tmp="$'"${sym}"'"'
13644                         echo "$tmp" | \
13645                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13646                 done
13647                 ;;
13648         esac
13649 fi
13650
13651 : Finish up by extracting the .SH files
13652 case "$alldone" in
13653 exit)
13654         $rm -rf UU
13655         echo "Done."
13656         exit 0
13657         ;;
13658 cont)
13659         ;;
13660 '')
13661         dflt=''
13662         nostick=true
13663         $cat <<EOM
13664
13665 If you'd like to make any changes to the config.sh file before I begin
13666 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13667
13668 EOM
13669         rp="Press return or use a shell escape to edit config.sh:"
13670         . UU/myread
13671         nostick=''
13672         case "$ans" in
13673         '') ;;
13674         *) : in case they cannot read
13675                 sh 1>&4 -c "$ans";;
13676         esac
13677         ;;
13678 esac
13679
13680 : if this fails, just run all the .SH files by hand
13681 . ./config.sh
13682
13683 echo " "
13684 exec 1>&4
13685 . ./UU/extract
13686
13687 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13688         dflt=y
13689         case "$silent" in
13690         true) ;;
13691         *)
13692                 $cat <<EOM
13693
13694 Now you need to generate make dependencies by running "$make depend".
13695 You might prefer to run it in background: "$make depend > makedepend.out &"
13696 It can take a while, so you might not want to run it right now.
13697
13698 EOM
13699                 ;;
13700         esac
13701         rp="Run $make depend now?"
13702         . UU/myread
13703         case "$ans" in
13704         y*)
13705                 $make depend && echo "Now you must run a $make."
13706                 ;;
13707         *)
13708                 echo "You must run '$make depend' then '$make'."
13709                 ;;
13710         esac
13711 elif test -f [Mm]akefile; then
13712         echo " "
13713         echo "Now you must run a $make."
13714 else
13715         echo "Done."
13716 fi
13717
13718 if $test -f Policy.sh; then
13719     $cat <<EOM
13720
13721 If you compile $package on a different machine or from a different object
13722 directory, copy the Policy.sh file from this object directory to the
13723 new one before you run Configure -- this will help you with most of
13724 the policy defaults.
13725
13726 EOM
13727 fi
13728 if $test -f config.msg; then
13729     echo "Hmm.  I also noted the following information while running:"
13730     echo " "
13731     $cat config.msg >&4
13732     $rm -f config.msg
13733 fi
13734 $rm -f kit*isdone ark*isdone
13735 $rm -rf UU
13736
13737 : End of Configure
13738