a3ba9b2bd98fa3c5a4c7fe08a4ed998ff10d009f
[p5sagit/p5-mst-13.2.git] / Configure
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc and is available on CPAN under authors/id/RAM so
18 # you may fetch it yourself from your nearest archive site.)
19 #
20
21 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
22 #
23 # Generated on Mon Jul  5 22:55:23 EET DST 1999 [metaconfig 3.0 PL70]
24 # (with additional metaconfig patches by perlbug@perl.com)
25
26 cat >/tmp/c1$$ <<EOF
27 ARGGGHHHH!!!!!
28
29 SCO csh still thinks true is false.  Write to SCO today and tell them that next
30 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
31
32 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
33 we'd have to do is go in and swap the && and || tokens, wherever they are.)
34
35 [End of diatribe. We now return you to your regularly scheduled programming...]
36 EOF
37 cat >/tmp/c2$$ <<EOF
38
39 OOPS!  You naughty creature!  You didn't run Configure with sh!
40 I will attempt to remedy the situation by running sh for you...
41 EOF
42
43 true || cat /tmp/c1$$ /tmp/c2$$
44 true || exec sh $0 $argv:q
45
46 (exit $?0) || cat /tmp/c2$$
47 (exit $?0) || exec sh $0 $argv:q
48 rm -f /tmp/c1$$ /tmp/c2$$
49
50 : compute my invocation name
51 me=$0
52 case "$0" in
53 */*)
54         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55         test "$me" || me=$0
56         ;;
57 esac
58
59 : Proper separator for the PATH environment variable
60 p_=:
61 : On OS/2 this directory should exist if this is not floppy only system :-]
62 if test -d c:/. ; then
63     if test -n "$OS2_SHELL"; then
64                 p_=\;
65                 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
66                 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
67         elif test -n "$DJGPP"; then
68                 p_=\;
69         fi
70 fi
71
72 : Proper PATH setting
73 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
74 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
75 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
76 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
77 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80 paths="$paths /sbin /usr/sbin /usr/libexec"
81
82 for p in $paths
83 do
84         case "$p_$PATH$p_" in
85         *$p_$p$p_*) ;;
86         *) test -d $p && PATH=$PATH$p_$p ;;
87         esac
88 done
89
90 PATH=.$p_$PATH
91 export PATH
92
93 : shall we be using ksh?
94 inksh=''
95 needksh=''
96 avoidksh=''
97 newsh=/bin/ksh
98 changesh=''
99 if (PATH=.; alias -x) >/dev/null 2>&1; then
100                 inksh=true
101 fi
102 if test -f /hp-ux -a -f /bin/ksh; then
103         needksh='to avoid sh bug in "here document" expansion'
104 fi
105 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
106         if test X`/usr/bin/uname -v` = X4; then
107                 avoidksh="to avoid AIX 4's /bin/sh"
108                 newsh=/usr/bin/bsh
109         fi
110 fi
111 if test -f /osf_boot -a -f /usr/sbin/setld; then
112         if test X`/usr/bin/uname -s` = XOSF1; then
113                 avoidksh="to avoid Digital UNIX' ksh"
114                 newsh=/bin/sh
115                 unset BIN_SH # if this is 'xpg4' sh will start up ksh
116         fi
117 fi
118 case "$inksh/$needksh" in
119 /[a-z]*)
120                 ENV=''
121                 changesh=true
122                 reason="$needksh"
123         ;;
124 esac
125 case "$inksh/$avoidksh" in
126 true/[a-z]*)
127         changesh=true
128         reason="$avoidksh"
129         ;;
130 esac
131 case "$inksh/$needksh-$avoidksh-" in
132 true/--)
133                 cat <<EOM
134 (I see you are using the Korn shell.  Some ksh's blow up on $me,
135 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
136 EOM
137         ;;
138 esac
139 case "$changesh" in
140 true)
141         echo "(Feeding myself to $newsh $reason.)"
142         case "$0" in
143         Configure|*/Configure) exec $newsh $0 "$@";;
144         *) exec $newsh Configure "$@";;
145         esac
146         ;;
147 esac
148
149 : if needed set CDPATH to a harmless value that is not chatty
150 : avoid bash 2.02 problems with empty CDPATH.
151 case "$CDPATH" in
152 '')     ;;
153 *)      case "$SHELL" in
154         *bash*) CDPATH='.' ;;
155         *)              CDPATH='' ;;
156         esac
157         ;;
158 esac
159 : Configure runs within the UU subdirectory
160 test -d UU || mkdir UU
161 cd UU && rm -f ./*
162
163 ccsymbols=''
164 cppccsymbols=''
165 cppsymbols=''
166 dynamic_ext=''
167 extensions=''
168 known_extensions=''
169 nonxs_ext=''
170 static_ext=''
171 useopcode=''
172 useposix=''
173 d_bsd=''
174 d_eunice=''
175 d_xenix=''
176 eunicefix=''
177 Mcc=''
178 ar=''
179 awk=''
180 bash=''
181 bison=''
182 byacc=''
183 cat=''
184 chgrp=''
185 chmod=''
186 chown=''
187 comm=''
188 compress=''
189 cp=''
190 cpio=''
191 cpp=''
192 csh=''
193 date=''
194 echo=''
195 egrep=''
196 emacs=''
197 expr=''
198 find=''
199 flex=''
200 grep=''
201 gzip=''
202 inews=''
203 ksh=''
204 less=''
205 line=''
206 lint=''
207 ln=''
208 lp=''
209 lpr=''
210 ls=''
211 mail=''
212 mailx=''
213 make=''
214 mkdir=''
215 more=''
216 mv=''
217 nm=''
218 nroff=''
219 perl=''
220 pg=''
221 pmake=''
222 pr=''
223 rm=''
224 rmail=''
225 sed=''
226 sendmail=''
227 shar=''
228 sleep=''
229 smail=''
230 sort=''
231 submit=''
232 tail=''
233 tar=''
234 tbl=''
235 tee=''
236 test=''
237 touch=''
238 tr=''
239 troff=''
240 uname=''
241 uniq=''
242 uuname=''
243 vi=''
244 zcat=''
245 zip=''
246 full_ar=''
247 full_sed=''
248 libswanted=''
249 hint=''
250 myuname=''
251 osname=''
252 osvers=''
253 Author=''
254 Date=''
255 Header=''
256 Id=''
257 Locker=''
258 Log=''
259 RCSfile=''
260 Revision=''
261 Source=''
262 State=''
263 _a=''
264 _exe=''
265 _o=''
266 archobjs=''
267 exe_ext=''
268 firstmakefile=''
269 lib_ext=''
270 obj_ext=''
271 path_sep=''
272 afs=''
273 alignbytes=''
274 ansi2knr=''
275 archlib=''
276 archlibexp=''
277 d_archlib=''
278 installarchlib=''
279 archname=''
280 myarchname=''
281 baserev=''
282 bin=''
283 binexp=''
284 installbin=''
285 byteorder=''
286 cc=''
287 gccversion=''
288 ccflags=''
289 cppflags=''
290 ldflags=''
291 lkflags=''
292 locincpth=''
293 optimize=''
294 cf_email=''
295 cf_by=''
296 cf_time=''
297 contains=''
298 cpp_stuff=''
299 cpplast=''
300 cppminus=''
301 cpprun=''
302 cppstdin=''
303 crosscompile=''
304 d_access=''
305 d_accessx=''
306 d_alarm=''
307 d_attribut=''
308 d_bcmp=''
309 d_bcopy=''
310 d_bzero=''
311 d_casti32=''
312 castflags=''
313 d_castneg=''
314 d_chown=''
315 d_chroot=''
316 d_chsize=''
317 d_closedir=''
318 d_void_closedir=''
319 d_const=''
320 cryptlib=''
321 d_crypt=''
322 d_csh=''
323 full_csh=''
324 d_cuserid=''
325 d_dbl_dig=''
326 d_difftime=''
327 d_dlerror=''
328 d_dlopen=''
329 d_dlsymun=''
330 d_dosuid=''
331 d_suidsafe=''
332 d_drand48proto=''
333 d_dup2=''
334 d_eaccess=''
335 d_endgrent=''
336 d_endhent=''
337 d_endnent=''
338 d_endpent=''
339 d_endpwent=''
340 d_endsent=''
341 d_endspent=''
342 d_fchmod=''
343 d_fchown=''
344 d_fcntl=''
345 d_fd_macros=''
346 d_fd_set=''
347 d_fds_bits=''
348 d_fgetpos=''
349 d_flexfnam=''
350 d_flock=''
351 d_fork=''
352 d_fseeko=''
353 d_fsetpos=''
354 d_ftello=''
355 d_ftime=''
356 d_gettimeod=''
357 d_Gconvert=''
358 d_getgrent=''
359 d_getgrps=''
360 d_gethbyaddr=''
361 d_gethbyname=''
362 d_gethent=''
363 aphostname=''
364 d_gethname=''
365 d_phostname=''
366 d_uname=''
367 d_gethostprotos=''
368 d_getlogin=''
369 d_getmntent=''
370 d_getnbyaddr=''
371 d_getnbyname=''
372 d_getnent=''
373 d_getnetprotos=''
374 d_getpent=''
375 d_getpgid=''
376 d_getpgrp2=''
377 d_bsdgetpgrp=''
378 d_getpgrp=''
379 d_getppid=''
380 d_getprior=''
381 d_getpbyname=''
382 d_getpbynumber=''
383 d_getprotoprotos=''
384 d_getpwent=''
385 d_getsent=''
386 d_getservprotos=''
387 d_getspent=''
388 d_getspnam=''
389 d_getsbyname=''
390 d_getsbyport=''
391 d_gnulibc=''
392 d_hasmntopt=''
393 d_htonl=''
394 d_inetaton=''
395 d_isascii=''
396 d_killpg=''
397 d_lchown=''
398 d_link=''
399 d_locconv=''
400 d_lockf=''
401 d_longdbl=''
402 longdblsize=''
403 d_longlong=''
404 longlongsize=''
405 d_lstat=''
406 d_madvise=''
407 d_mblen=''
408 d_mbstowcs=''
409 d_mbtowc=''
410 d_memchr=''
411 d_memcmp=''
412 d_memcpy=''
413 d_memmove=''
414 d_memset=''
415 d_mkdir=''
416 d_mkfifo=''
417 d_mktime=''
418 d_mmap=''
419 mmaptype=''
420 d_mprotect=''
421 d_msg=''
422 d_msgctl=''
423 d_msgget=''
424 d_msgrcv=''
425 d_msgsnd=''
426 d_msync=''
427 d_munmap=''
428 d_nice=''
429 d_open3=''
430 d_fpathconf=''
431 d_pathconf=''
432 d_pause=''
433 d_pipe=''
434 d_poll=''
435 d_portable=''
436 d_old_pthread_create_joinable=''
437 old_pthread_create_joinable=''
438 d_pthread_yield=''
439 d_sched_yield=''
440 sched_yield=''
441 d_readdir=''
442 d_rewinddir=''
443 d_seekdir=''
444 d_telldir=''
445 d_readlink=''
446 d_readv=''
447 d_rename=''
448 d_rmdir=''
449 d_safebcpy=''
450 d_safemcpy=''
451 d_sanemcmp=''
452 d_select=''
453 d_sem=''
454 d_semctl=''
455 d_semget=''
456 d_semop=''
457 d_setegid=''
458 d_seteuid=''
459 d_setgrent=''
460 d_setgrps=''
461 d_sethent=''
462 d_setlinebuf=''
463 d_setlocale=''
464 d_setnent=''
465 d_setpent=''
466 d_setpgid=''
467 d_setpgrp2=''
468 d_bsdsetpgrp=''
469 d_setpgrp=''
470 d_setprior=''
471 d_setpwent=''
472 d_setregid=''
473 d_setresgid=''
474 d_setresuid=''
475 d_setreuid=''
476 d_setrgid=''
477 d_setruid=''
478 d_setsent=''
479 d_setsid=''
480 d_setspent=''
481 d_setvbuf=''
482 d_sfio=''
483 usesfio=''
484 d_shm=''
485 d_shmat=''
486 d_shmatprototype=''
487 shmattype=''
488 d_shmctl=''
489 d_shmdt=''
490 d_shmget=''
491 d_sigaction=''
492 d_sigsetjmp=''
493 d_cmsghdr_s=''
494 d_msg_ctrunc=''
495 d_msg_dontroute=''
496 d_msg_oob=''
497 d_msg_peek=''
498 d_msg_proxy=''
499 d_msghdr_s=''
500 d_oldsock=''
501 d_recvmsg=''
502 d_scm_rights=''
503 d_sendmsg=''
504 d_socket=''
505 d_sockpair=''
506 sockethdr=''
507 socketlib=''
508 d_statblks=''
509 d_fstatfs=''
510 d_statfs=''
511 d_statfsflags=''
512 d_fstatvfs=''
513 d_statvfs=''
514 d_stdio_cnt_lval=''
515 d_stdio_ptr_lval=''
516 d_stdiobase=''
517 d_stdstdio=''
518 stdio_base=''
519 stdio_bufsiz=''
520 stdio_cnt=''
521 stdio_filbuf=''
522 stdio_ptr=''
523 d_index=''
524 d_strchr=''
525 d_strcoll=''
526 d_strctcpy=''
527 d_strerrm=''
528 d_strerror=''
529 d_sysernlst=''
530 d_syserrlst=''
531 d_strtod=''
532 d_strtol=''
533 d_strtoul=''
534 d_strxfrm=''
535 d_symlink=''
536 d_syscall=''
537 d_sysconf=''
538 d_system=''
539 d_tcgetpgrp=''
540 d_tcsetpgrp=''
541 d_telldirproto=''
542 d_time=''
543 timetype=''
544 clocktype=''
545 d_times=''
546 d_truncate=''
547 d_tzname=''
548 d_umask=''
549 d_semctl_semid_ds=''
550 d_semctl_semun=''
551 d_union_semun=''
552 d_vfork=''
553 usevfork=''
554 d_voidsig=''
555 signal_t=''
556 d_volatile=''
557 d_charvspr=''
558 d_vprintf=''
559 d_wait4=''
560 d_waitpid=''
561 d_wcstombs=''
562 d_wctomb=''
563 d_writev=''
564 d_dbmclose64=''
565 d_dbminit64=''
566 d_delete64=''
567 d_fetch64=''
568 d_firstkey64=''
569 d_nextkey64=''
570 d_store64=''
571 dlext=''
572 cccdlflags=''
573 ccdlflags=''
574 dlsrc=''
575 ld=''
576 lddlflags=''
577 usedl=''
578 doublesize=''
579 ebcdic=''
580 fflushNULL=''
581 fflushall=''
582 fpostype=''
583 gidtype=''
584 groupstype=''
585 h_fcntl=''
586 h_sysfile=''
587 i_arpainet=''
588 db_hashtype=''
589 db_prefixtype=''
590 i_db=''
591 i_dbm=''
592 i_rpcsvcdbm=''
593 d_dirnamlen=''
594 direntrytype=''
595 i_dirent=''
596 i_dld=''
597 i_dlfcn=''
598 i_fcntl=''
599 i_float=''
600 i_gdbm=''
601 d_grpasswd=''
602 i_grp=''
603 d_int64t=''
604 i_inttypes=''
605 i_limits=''
606 i_locale=''
607 i_machcthr=''
608 i_malloc=''
609 i_math=''
610 i_memory=''
611 i_mntent=''
612 i_ndbm=''
613 i_netdb=''
614 i_neterrno=''
615 i_netinettcp=''
616 i_niin=''
617 i_sysin=''
618 i_poll=''
619 i_pthread=''
620 d_pwage=''
621 d_pwchange=''
622 d_pwclass=''
623 d_pwcomment=''
624 d_pwexpire=''
625 d_pwgecos=''
626 d_pwpasswd=''
627 d_pwquota=''
628 i_pwd=''
629 i_sfio=''
630 i_shadow=''
631 i_socks=''
632 i_stddef=''
633 i_stdlib=''
634 i_string=''
635 strings=''
636 i_sysaccess=''
637 i_sysdir=''
638 i_sysfile=''
639 d_voidtty=''
640 i_bsdioctl=''
641 i_sysfilio=''
642 i_sysioctl=''
643 i_syssockio=''
644 i_sysmman=''
645 i_sysmount=''
646 i_sysndir=''
647 i_sysparam=''
648 i_sysresrc=''
649 i_syssecrt=''
650 i_sysselct=''
651 i_sysstat=''
652 i_sysstatvfs=''
653 i_systimes=''
654 i_systypes=''
655 d_iovec_s=''
656 i_sysuio=''
657 i_sysun=''
658 i_syswait=''
659 i_sgtty=''
660 i_termio=''
661 i_termios=''
662 i_systime=''
663 i_systimek=''
664 i_time=''
665 timeincl=''
666 i_unistd=''
667 i_utime=''
668 i_values=''
669 i_stdarg=''
670 i_varargs=''
671 i_varhdr=''
672 i_vfork=''
673 installusrbinperl=''
674 intsize=''
675 longsize=''
676 shortsize=''
677 d_dirent64_s=''
678 d_flock64_s=''
679 d_fstat64=''
680 d_ftruncate64=''
681 d_ino64_t=''
682 d_llseek=''
683 d_lockf64=''
684 d_lseek64=''
685 d_lstat64=''
686 d_off64_t=''
687 d_offset_t=''
688 d_open64=''
689 d_opendir64=''
690 d_readdir64=''
691 d_seekdir64=''
692 d_stat64=''
693 d_telldir64=''
694 d_truncate64=''
695 libc=''
696 libperl=''
697 shrpenv=''
698 useshrplib=''
699 glibpth=''
700 libpth=''
701 loclibpth=''
702 plibpth=''
703 xlibpth=''
704 ignore_versioned_solibs=''
705 libs=''
706 lns=''
707 lseeksize=''
708 lseektype=''
709 make_set_make=''
710 d_mymalloc=''
711 freetype=''
712 mallocobj=''
713 mallocsrc=''
714 malloctype=''
715 usemymalloc=''
716 installman1dir=''
717 man1dir=''
718 man1direxp=''
719 man1ext=''
720 installman3dir=''
721 man3dir=''
722 man3direxp=''
723 man3ext=''
724 huge=''
725 large=''
726 medium=''
727 models=''
728 small=''
729 split=''
730 modetype=''
731 multiarch=''
732 mydomain=''
733 myhostname=''
734 phostname=''
735 c=''
736 n=''
737 d_eofnblk=''
738 eagain=''
739 o_nonblock=''
740 rd_nodata=''
741 netdb_hlen_type=''
742 netdb_host_type=''
743 netdb_name_type=''
744 netdb_net_type=''
745 groupcat=''
746 hostcat=''
747 passcat=''
748 orderlib=''
749 ranlib=''
750 package=''
751 spackage=''
752 pager=''
753 apiversion=''
754 patchlevel=''
755 subversion=''
756 version=''
757 perladmin=''
758 perlpath=''
759 pidtype=''
760 prefix=''
761 prefixexp=''
762 installprivlib=''
763 privlib=''
764 privlibexp=''
765 prototype=''
766 ptrsize=''
767 drand01=''
768 randbits=''
769 randfunc=''
770 randseedtype=''
771 seedfunc=''
772 installscript=''
773 scriptdir=''
774 scriptdirexp=''
775 selectminbits=''
776 selecttype=''
777 sh=''
778 sig_count=''
779 sig_name=''
780 sig_name_init=''
781 sig_num=''
782 sig_num_init=''
783 installsitearch=''
784 sitearch=''
785 sitearchexp=''
786 installsitelib=''
787 sitelib=''
788 sitelibexp=''
789 sizetype=''
790 so=''
791 sharpbang=''
792 shsharp=''
793 spitshell=''
794 src=''
795 ssizetype=''
796 startperl=''
797 startsh=''
798 stdchar=''
799 d_fgetpos64=''
800 d_fopen64=''
801 d_freopen64=''
802 d_fseek64=''
803 d_fseeko64=''
804 d_fsetpos64=''
805 d_ftell64=''
806 d_ftello64=''
807 d_tmpfile64=''
808 d_stdio_stream_array=''
809 stdio_stream_array=''
810 sysman=''
811 trnl=''
812 uidtype=''
813 archname64=''
814 use64bits=''
815 usemultiplicity=''
816 nm_opt=''
817 nm_so_opt=''
818 runnm=''
819 usenm=''
820 useperlio=''
821 usesocks=''
822 d_oldpthreads=''
823 usethreads=''
824 incpath=''
825 mips=''
826 mips_type=''
827 usrinc=''
828 defvoidused=''
829 voidflags=''
830 CONFIG=''
831
832 define='define'
833 undef='undef'
834 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
835 rmlist=''
836
837 : We must find out about Eunice early
838 eunicefix=':'
839 if test -f /etc/unixtovms; then
840         eunicefix=/etc/unixtovms
841 fi
842 if test -f /etc/unixtovms.exe; then
843         eunicefix=/etc/unixtovms.exe
844 fi
845
846 i_whoami=''
847 : Possible local include directories to search.
848 : Set locincpth to "" in a hint file to defeat local include searches.
849 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
850 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
851 :
852 : no include file wanted by default
853 inclwanted=''
854
855 : list of known cpp symbols, sorted alphabetically
856 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
857 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
858 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
859 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
860 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
861 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
862 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
863 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
864 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
865 al="$al VMS Xenix286"
866 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
867 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
868 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
869 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
870 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
871 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
872 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
873 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
874 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
875 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
876 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
877 al="$al __SVR4_2__ __UMAXV__"
878 al="$al ____386BSD____ __alpha __alpha__ __amiga"
879 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
880 al="$al __host_mips__"
881 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
882 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
883 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
884 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
885 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
886 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
887 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
888 al="$al __mc88100 __mc88100__ __mips __mips__"
889 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
890 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
891 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
892 al="$al _host_mips _mips _unix"
893 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
894 al="$al apollo ardent att386 att3b"
895 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
896 al="$al cadmus clipper concurrent convex cray ctix"
897 al="$al dmert encore gcos gcx gimpel gould"
898 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
899 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
900 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
901 al="$al i186 i286 i386 i486 i8086"
902 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
903 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
904 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
905 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
906 al="$al mc88000 mc88100 merlin mert mips mvs n16"
907 al="$al ncl_el ncl_mr"
908 al="$al news1500 news1700 news1800 news1900 news3700"
909 al="$al news700 news800 news900 ns16000 ns32000"
910 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
911 al="$al parisc pc532 pdp11 plexus posix pyr"
912 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
913 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
914 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
915 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
916 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
917 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
918 al="$al xenix z8000"
919
920 : Trailing extension.  Override this in a hint file, if needed.
921 _exe=''
922 : Extra object files, if any, needed on this platform.
923 archobjs=''
924 groupstype=''
925 : change the next line if compiling for Xenix/286 on Xenix/386
926 xlibpth='/usr/lib/386 /lib/386'
927
928 : Possible local library directories to search.
929 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
930 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
931
932 : general looking path for locating libraries
933 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
934 glibpth="$glibpth /lib /usr/lib $xlibpth"
935 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
936 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
937
938 : Private path used by Configure to find libraries.  Its value
939 : is prepended to libpth. This variable takes care of special
940 : machines, like the mips.  Usually, it should be empty.
941 plibpth=''
942
943 : default library list
944 libswanted=''
945 : some systems want to use only the non-versioned libso:s
946 ignore_versioned_solibs=''
947 : full support for void wanted by default
948 defvoidused=15
949
950 : set useposix=false in your hint file to disable the POSIX extension.
951 useposix=true
952 : set useopcode=false in your hint file to disable the Opcode extension.
953 useopcode=true
954 : set usemultiplicity on the Configure command line to enable multiplicity.
955 : set usesocks on the Configure command line to enable socks.
956 : set usethreads on the Configure command line to enable threads.
957 : List of libraries we want.
958 : If anyone needs -lnet, put it in a hint file.
959 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
960 libswanted="$libswanted dld ld sun m rt c cposix posix"
961 libswanted="$libswanted ndir dir crypt sec"
962 libswanted="$libswanted ucb bsd BSD PW x"
963 : We probably want to search /usr/shlib before most other libraries.
964 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
965 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
966 glibpth="/usr/shlib $glibpth"
967 : Do not use vfork unless overridden by a hint file.
968 usevfork=false
969
970 : Find the basic shell for Bourne shell scripts
971 case "$sh" in
972 '')
973         case "$SYSTYPE" in
974         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
975         *) xxx='/bin/sh';;
976         esac
977         if test -f "$xxx"; then
978                 sh="$xxx"
979         else
980                 : Build up a list and do a single loop so we can 'break' out.
981                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
982                 for xxx in sh bash ksh pdksh ash; do
983                         for p in $pth; do
984                                 try="$try ${p}/${xxx}"
985                         done
986                 done
987                 for xxx in $try; do
988                         if test -f "$xxx"; then
989                                 sh="$xxx";
990                                 break
991                         elif test -f "$xxx.exe"; then
992                                 sh="$xxx";
993                                 break
994                         fi
995                 done
996         fi
997         ;;
998 esac
999
1000 case "$sh" in
1001 '')     cat <<EOM >&2
1002 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
1003
1004 Usually it's in /bin/sh.  How did you even get this far?
1005 Please contact me (Perl Maintainers) at perlbug@perl.com and 
1006 we'll try to straighten this all out.
1007 EOM
1008         exit 1
1009         ;;
1010 esac
1011
1012 : see if sh knows # comments
1013 if `$sh -c '#' >/dev/null 2>&1`; then
1014         shsharp=true
1015         spitshell=cat
1016         xcat=/bin/cat
1017         test -f $xcat || xcat=/usr/bin/cat
1018         echo "#!$xcat" >try
1019         $eunicefix try
1020         chmod +x try
1021         ./try > today
1022         if test -s today; then
1023                 sharpbang='#!'
1024         else
1025                 echo "#! $xcat" > try
1026                 $eunicefix try
1027                 chmod +x try
1028                 ./try > today
1029                 if test -s today; then
1030                         sharpbang='#! '
1031                 else
1032                         sharpbang=': use '
1033                 fi
1034         fi
1035 else
1036         echo " "
1037         echo "Your $sh doesn't grok # comments--I will strip them later on."
1038         shsharp=false
1039         cd ..
1040         echo "exec grep -v '^[  ]*#'" >spitshell
1041         chmod +x spitshell
1042         $eunicefix spitshell
1043         spitshell=`pwd`/spitshell
1044         cd UU
1045         echo "I presume that if # doesn't work, #! won't work either!"
1046         sharpbang=': use '
1047 fi
1048 rm -f try today
1049
1050 : figure out how to guarantee sh startup
1051 case "$startsh" in
1052 '') startsh=${sharpbang}${sh} ;;
1053 *)
1054 esac
1055 cat >try <<EOSS
1056 $startsh
1057 set abc
1058 test "$?abc" != 1
1059 EOSS
1060
1061 chmod +x try
1062 $eunicefix try
1063 if ./try; then
1064         : echo "Yup, it does."
1065 else
1066         echo "Hmm... '$startsh' does not guarantee sh startup..."
1067         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1068 fi
1069 rm -f try
1070
1071
1072 : Save command line options in file UU/cmdline.opt for later use in
1073 : generating config.sh.
1074 cat > cmdline.opt <<EOSH
1075 # Configure command line arguments.
1076 config_arg0='$0'
1077 config_args='$*'
1078 config_argc=$#
1079 EOSH
1080 argn=1
1081 for arg in "$@"; do
1082         cat >>cmdline.opt <<EOSH
1083 config_arg$argn='$arg'
1084 EOSH
1085         argn=`expr $argn + 1`
1086 done
1087
1088 : produce awk script to parse command line options
1089 cat >options.awk <<'EOF'
1090 BEGIN {
1091         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1092
1093         len = length(optstr);
1094         for (i = 1; i <= len; i++) {
1095                 c = substr(optstr, i, 1);
1096                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1097                 if (a == ":") {
1098                         arg[c] = 1;
1099                         i++;
1100                 }
1101                 opt[c] = 1;
1102         }
1103 }
1104 {
1105         expect = 0;
1106         str = $0;
1107         if (substr(str, 1, 1) != "-") {
1108                 printf("'%s'\n", str);
1109                 next;
1110         }
1111         len = length($0);
1112         for (i = 2; i <= len; i++) {
1113                 c = substr(str, i, 1);
1114                 if (!opt[c]) {
1115                         printf("-%s\n", substr(str, i));
1116                         next;
1117                 }
1118                 printf("-%s\n", c);
1119                 if (arg[c]) {
1120                         if (i < len)
1121                                 printf("'%s'\n", substr(str, i + 1));
1122                         else
1123                                 expect = 1;
1124                         next;
1125                 }
1126         }
1127 }
1128 END {
1129         if (expect)
1130                 print "?";
1131 }
1132 EOF
1133
1134 : process the command line options
1135 set X `for arg in "$@"; do echo "X$arg"; done |
1136         sed -e s/X// | awk -f options.awk`
1137 eval "set $*"
1138 shift
1139 rm -f options.awk
1140
1141 : set up default values
1142 fastread=''
1143 reuseval=false
1144 config_sh=''
1145 alldone=''
1146 error=''
1147 silent=''
1148 extractsh=''
1149 override=''
1150 knowitall=''
1151 rm -f optdef.sh
1152 cat >optdef.sh <<EOS
1153 $startsh
1154 EOS
1155
1156
1157 : option parsing
1158 while test $# -gt 0; do
1159         case "$1" in
1160         -d) shift; fastread=yes;;
1161         -e) shift; alldone=cont;;
1162         -f)
1163                 shift
1164                 cd ..
1165                 if test -r "$1"; then
1166                         config_sh="$1"
1167                 else
1168                         echo "$me: cannot read config file $1." >&2
1169                         error=true
1170                 fi
1171                 cd UU
1172                 shift;;
1173         -h) shift; error=true;;
1174         -r) shift; reuseval=true;;
1175         -s) shift; silent=true; realsilent=true;;
1176         -E) shift; alldone=exit;;
1177         -K) shift; knowitall=true;;
1178         -O) shift; override=true;;
1179         -S) shift; silent=true; extractsh=true;;
1180         -D)
1181                 shift
1182                 case "$1" in
1183                 *=)
1184                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1185                         echo "$me: ignoring -D $1" >&2
1186                         ;;
1187                 *=*) echo "$1" | \
1188                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1189                 *) echo "$1='define'" >> optdef.sh;;
1190                 esac
1191                 shift
1192                 ;;
1193         -U)
1194                 shift
1195                 case "$1" in
1196                 *=) echo "$1" >> optdef.sh;;
1197                 *=*)
1198                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1199                         echo "$me: ignoring -U $1" >&2
1200                         ;;
1201                 *) echo "$1='undef'" >> optdef.sh;;
1202                 esac
1203                 shift
1204                 ;;
1205         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1206                 exit 0;;
1207         --) break;;
1208         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1209         *) break;;
1210         esac
1211 done
1212
1213 case "$error" in
1214 true)
1215         cat >&2 <<EOM
1216 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1217                  [-U symbol] [-U symbol=]
1218   -d : use defaults for all answers.
1219   -e : go on without questioning past the production of config.sh.
1220   -f : specify an alternate default configuration file.
1221   -h : print this help message and exit (with an error status).
1222   -r : reuse C symbols value if possible (skips costly nm extraction).
1223   -s : silent mode, only echoes questions and essential information.
1224   -D : define symbol to have some value:
1225          -D symbol         symbol gets the value 'define'
1226          -D symbol=value   symbol gets the value 'value'
1227   -E : stop at the end of questions, after having produced config.sh.
1228   -K : do not use unless you know what you are doing.
1229   -O : let -D and -U override definitions from loaded configuration file.
1230   -S : perform variable substitutions on all .SH files (can mix with -f)
1231   -U : undefine symbol:
1232          -U symbol    symbol gets the value 'undef'
1233          -U symbol=   symbol gets completely empty
1234   -V : print version number and exit (with a zero status).
1235 EOM
1236         exit 1
1237         ;;
1238 esac
1239
1240 : Sanity checks
1241 case "$fastread$alldone" in
1242 yescont|yesexit) ;;
1243 *)
1244         if test ! -t 0; then
1245                 echo "Say 'sh Configure', not 'sh <Configure'"
1246                 exit 1
1247         fi
1248         ;;
1249 esac
1250
1251 exec 4>&1
1252 case "$silent" in
1253 true) exec 1>/dev/null;;
1254 esac
1255
1256 : run the defines and the undefines, if any, but leave the file out there...
1257 touch optdef.sh
1258 . ./optdef.sh
1259
1260 : set package name
1261 package=perl5
1262 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1263 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1264 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1265 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1266 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1267 esac
1268
1269 : Some greps do not return status, grrr.
1270 echo "grimblepritz" >grimble
1271 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1272         contains=contains
1273 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1274         contains=grep
1275 else
1276         contains=contains
1277 fi
1278 rm -f grimble
1279 : the following should work in any shell
1280 case "$contains" in
1281 contains*)
1282         echo " "
1283         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1284         cat >contains <<'EOSS'
1285 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1286 EOSS
1287 chmod +x contains
1288 esac
1289
1290 : Find the path to the source tree
1291 case "$src" in
1292 '') case "$0" in
1293     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1294     *)   src='.';;
1295     esac;;
1296 esac
1297 case "$src" in
1298 '')     src=/
1299         rsrc=/
1300         ;;
1301 /*) rsrc="$src";;
1302 *) rsrc="../$src";;
1303 esac
1304 if test -f $rsrc/Configure && \
1305         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1306 then
1307    : found it, so we are ok.
1308 else
1309         rsrc=''
1310         for src in . .. ../.. ../../.. ../../../..; do
1311                 if test -f ../$src/Configure && \
1312                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1313                 then
1314                         rsrc=../$src
1315                         break
1316                 fi
1317         done
1318 fi
1319 case "$rsrc" in
1320 '')
1321         cat <<EOM >&4
1322
1323 Sorry, I can't seem to locate the source dir for $package.  Please start
1324 Configure with an explicit path -- i.e. /some/path/Configure.
1325
1326 EOM
1327         exit 1
1328         ;;
1329 ../.)   rsrc='..';;
1330 *)
1331         echo " "
1332         echo "Sources for $package found in \"$src\"." >&4
1333         ;;
1334 esac
1335
1336 : script used to extract .SH files with variable substitutions
1337 cat >extract <<'EOS'
1338 CONFIGDOTSH=true
1339 echo "Doing variable substitutions on .SH files..."
1340 if test -f $src/MANIFEST; then
1341         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1342 else
1343         echo "(Looking for .SH files under the source directory.)"
1344         set x `(cd $src; find . -name "*.SH" -print)`
1345 fi
1346 shift
1347 case $# in
1348 0) set x `(cd $src; echo *.SH)`; shift;;
1349 esac
1350 if test ! -f $src/$1; then
1351         shift
1352 fi
1353 mkdir_p='
1354 name=$1;
1355 create="";
1356 while test $name; do
1357         if test ! -d "$name"; then
1358                 create="$name $create";
1359                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1360                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1361         else
1362                 name="";
1363         fi;
1364 done;
1365 for file in $create; do
1366         mkdir $file;
1367 done
1368 '
1369 for file in $*; do
1370         case "$src" in
1371         ".")
1372                 case "$file" in
1373                 */*)
1374                         dir=`expr X$file : 'X\(.*\)/'`
1375                         file=`expr X$file : 'X.*/\(.*\)'`
1376                         (cd $dir && . ./$file)
1377                         ;;
1378                 *)
1379                         . ./$file
1380                         ;;
1381                 esac
1382                 ;;
1383         *)
1384                 case "$file" in
1385                 */*)
1386                         dir=`expr X$file : 'X\(.*\)/'`
1387                         file=`expr X$file : 'X.*/\(.*\)'`
1388                         (set x $dir; shift; eval $mkdir_p)
1389                         sh <$src/$dir/$file
1390                         ;;
1391                 *)
1392                         sh <$src/$file
1393                         ;;
1394                 esac
1395                 ;;
1396         esac
1397 done
1398 if test -f $src/config_h.SH; then
1399         if test ! -f config.h; then
1400         : oops, they left it out of MANIFEST, probably, so do it anyway.
1401         . $src/config_h.SH
1402         fi
1403 fi
1404 EOS
1405
1406 : extract files and exit if asked to do so
1407 case "$extractsh" in
1408 true)
1409         case "$realsilent" in
1410         true) ;;
1411         *) exec 1>&4;;
1412         esac
1413         case "$config_sh" in
1414         '') config_sh='config.sh';;
1415         esac
1416         echo " "
1417         echo "Fetching answers from $config_sh..."
1418         cd ..
1419         . $config_sh
1420         test "$override" && . ./optdef.sh
1421         echo " "
1422         . UU/extract
1423         rm -rf UU
1424         echo "Done."
1425         exit 0
1426         ;;
1427 esac
1428
1429 : Eunice requires " " instead of "", can you believe it
1430 echo " "
1431 : Here we go...
1432 echo "Beginning of configuration questions for $package."
1433
1434 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1435
1436 : first determine how to suppress newline on echo command
1437 echo " "
1438 echo "Checking echo to see how to suppress newlines..."
1439 (echo "hi there\c" ; echo " ") >.echotmp
1440 if $contains c .echotmp >/dev/null 2>&1 ; then
1441         echo "...using -n."
1442         n='-n'
1443         c=''
1444 else
1445         cat <<'EOM'
1446 ...using \c
1447 EOM
1448         n=''
1449         c='\c'
1450 fi
1451 echo $n "The star should be here-->$c"
1452 echo '*'
1453 rm -f .echotmp
1454
1455 : Now test for existence of everything in MANIFEST
1456 echo " "
1457 if test -f $rsrc/MANIFEST; then
1458         echo "First let's make sure your kit is complete.  Checking..." >&4
1459         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1460         rm -f missing
1461         tmppwd=`pwd`
1462         for filelist in x??; do
1463                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1464         done
1465         if test -s missing; then
1466                 cat missing >&4
1467                 cat >&4 <<'EOM'
1468
1469 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1470
1471 You have the option of continuing the configuration process, despite the
1472 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1473 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1474 and contact the author (perlbug@perl.com).
1475
1476 EOM
1477                 echo $n "Continue? [n] $c" >&4
1478                 read ans
1479                 case "$ans" in
1480                 y*)
1481                         echo "Continuing..." >&4
1482                         rm -f missing
1483                         ;;
1484                 *)
1485                         echo "ABORTING..." >&4
1486                         kill $$
1487                         ;;
1488                 esac
1489         else
1490                 echo "Looks good..."
1491         fi
1492 else
1493         echo "There is no MANIFEST file.  I hope your kit is complete !"
1494 fi
1495 rm -f missing x??
1496
1497 echo " "
1498 : Find the appropriate value for a newline for tr
1499 if test -n "$DJGPP"; then
1500        trnl='\012'
1501 fi
1502 if test X"$trnl" = X; then
1503         case "`echo foo|tr '\n' x 2>/dev/null`" in
1504         foox) trnl='\n' ;;
1505         esac
1506 fi
1507 if test X"$trnl" = X; then
1508         case "`echo foo|tr '\012' x 2>/dev/null`" in
1509         foox) trnl='\012' ;;
1510         esac
1511 fi
1512 if test X"$trnl" = X; then
1513         cat <<EOM >&2
1514
1515 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1516
1517 EOM
1518         exit 1
1519 fi
1520
1521 : compute the number of columns on the terminal for proper question formatting
1522 case "$COLUMNS" in
1523 '') COLUMNS='80';;
1524 esac
1525
1526 : set up the echo used in my read
1527 myecho="case \"\$xxxm\" in
1528 '') echo $n \"\$rp $c\" >&4;;
1529 *) case \"\$rp\" in
1530         '') echo $n \"[\$xxxm] $c\";;
1531         *)
1532                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1533                         echo \"\$rp\" >&4
1534                         echo $n \"[\$xxxm] $c\" >&4
1535                 else
1536                         echo $n \"\$rp [\$xxxm] $c\" >&4
1537                 fi
1538                 ;;
1539         esac;;
1540 esac"
1541
1542 : now set up to do reads with possible shell escape and default assignment
1543 cat <<EOSC >myread
1544 $startsh
1545 xxxm=\$dflt
1546 $myecho
1547 ans='!'
1548 case "\$fastread" in
1549 yes) case "\$dflt" in
1550         '') ;;
1551         *) ans='';
1552                 case "\$silent-\$rp" in
1553                 true-) ;;
1554                 *) echo " " >&4;;
1555                 esac;;
1556         esac;;
1557 *) case "\$silent" in
1558         true) case "\$rp" in
1559                 '') ans='';;
1560                 esac;;
1561         esac;;
1562 esac
1563 while expr "X\$ans" : "X!" >/dev/null; do
1564         read answ
1565         set x \$xxxm
1566         shift
1567         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1568         case  "\$answ" in
1569         "!")
1570                 sh 1>&4
1571                 echo " "
1572                 $myecho
1573                 ;;
1574         !*)
1575                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1576                 shift
1577                 sh 1>&4 -c "\$*"
1578                 echo " "
1579                 $myecho
1580                 ;;
1581         "\$ans")
1582                 case "\$ans" in
1583                 \\&*)
1584                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1585                         shift
1586                         case "\$1" in
1587                         -d)
1588                                 fastread=yes
1589                                 echo "(OK, I'll run with -d after this question.)" >&4
1590                                 ;;
1591                         -*)
1592                                 echo "*** Sorry, \$1 not supported yet." >&4
1593                                 ;;
1594                         esac
1595                         $myecho
1596                         ans=!
1597                         ;;
1598                 esac;;
1599         *)
1600                 case "\$aok" in
1601                 y)
1602                         echo "*** Substitution done -- please confirm."
1603                         xxxm="\$ans"
1604                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1605                         xxxm="\$ans"
1606                         ans=!
1607                         ;;
1608                 *)
1609                         echo "*** Error -- try again."
1610                         ans=!
1611                         ;;
1612                 esac
1613                 $myecho
1614                 ;;
1615         esac
1616         case "\$ans\$xxxm\$nostick" in
1617         '')
1618                 ans=!
1619                 $myecho
1620                 ;;
1621         esac
1622 done
1623 case "\$ans" in
1624 '') ans="\$xxxm";;
1625 esac
1626 EOSC
1627
1628 : create .config dir to save info across Configure sessions
1629 test -d ../.config || mkdir ../.config
1630 cat >../.config/README <<EOF
1631 This directory created by Configure to save information that should
1632 persist across sessions for $package.
1633
1634 You may safely delete it if you wish.
1635 EOF
1636
1637 : general instructions
1638 needman=true
1639 firsttime=true
1640 user=`(logname) 2>/dev/null`
1641 case "$user" in
1642 '') user=`whoami 2>&1`;;
1643 esac
1644 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1645         firsttime=false
1646         echo " "
1647         rp='Would you like to see the instructions?'
1648         dflt=n
1649         . ./myread
1650         case "$ans" in
1651         [yY]*) ;;
1652         *) needman=false;;
1653         esac
1654 fi
1655 if $needman; then
1656         cat <<EOH
1657
1658 This installation shell script will examine your system and ask you questions
1659 to determine how the perl5 package should be installed. If you get
1660 stuck on a question, you may use a ! shell escape to start a subshell or
1661 execute a command.  Many of the questions will have default answers in square
1662 brackets; typing carriage return will give you the default.
1663
1664 On some of the questions which ask for file or directory names you are allowed
1665 to use the ~name construct to specify the login directory belonging to "name",
1666 even if you don't have a shell which knows about that.  Questions where this is
1667 allowed will be marked "(~name ok)".
1668
1669 EOH
1670         rp=''
1671         dflt='Type carriage return to continue'
1672         . ./myread
1673         cat <<'EOH'
1674
1675 The prompter used in this script allows you to use shell variables and
1676 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1677 in the default answer, as if the default line was a set of arguments given to a
1678 script shell.  This means you may also use $* to repeat the whole default line,
1679 so you do not have to re-type everything to add something to the default.
1680
1681 Everytime there is a substitution, you will have to confirm.  If there is an
1682 error (e.g. an unmatched backtick), the default answer will remain unchanged
1683 and you will be prompted again.
1684
1685 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1686 the questions and use the computed defaults (or the previous answers if there
1687 was already a config.sh file). Type 'Configure -h' for a list of options.
1688 You may also start interactively and then answer '& -d' at any prompt to turn
1689 on the non-interactive behaviour for the remainder of the execution.
1690
1691 EOH
1692         . ./myread
1693         cat <<EOH
1694
1695 Much effort has been expended to ensure that this shell script will run on any
1696 Unix system.  If despite that it blows up on yours, your best bet is to edit
1697 Configure and run it again.  If you can't run Configure for some reason,
1698 you'll have to generate a config.sh file by hand.  Whatever problems you
1699 have, let me (perlbug@perl.com) know how I blew it.
1700
1701 This installation script affects things in two ways:
1702
1703 1) it may do direct variable substitutions on some of the files included
1704    in this kit.
1705 2) it builds a config.h file for inclusion in C programs.  You may edit
1706    any of these files as the need arises after running this script.
1707
1708 If you make a mistake on a question, there is no easy way to back up to it
1709 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1710 files.  Configure will offer to let you do this before it runs the SH files.
1711
1712 EOH
1713         dflt='Type carriage return to continue'
1714         . ./myread
1715         case "$firsttime" in
1716         true) echo $user >>../.config/instruct;;
1717         esac
1718 fi
1719
1720 : find out where common programs are
1721 echo " "
1722 echo "Locating common programs..." >&4
1723 cat <<EOSC >loc
1724 $startsh
1725 case \$# in
1726 0) exit 1;;
1727 esac
1728 thing=\$1
1729 shift
1730 dflt=\$1
1731 shift
1732 for dir in \$*; do
1733         case "\$thing" in
1734         .)
1735         if test -d \$dir/\$thing; then
1736                 echo \$dir
1737                 exit 0
1738         fi
1739         ;;
1740         *)
1741         for thisthing in \$dir/\$thing; do
1742                 : just loop through to pick last item
1743         done
1744         if test -f \$thisthing; then
1745                 echo \$thisthing
1746                 exit 0
1747         elif test -f \$dir/\$thing.exe; then
1748                 if test -n "$DJGPP"; then
1749                         echo \$dir/\$thing.exe
1750                 else
1751                         : on Eunice apparently
1752                         echo \$dir/\$thing
1753                 fi
1754                 exit 0
1755         fi
1756         ;;
1757         esac
1758 done
1759 echo \$dflt
1760 exit 1
1761 EOSC
1762 chmod +x loc
1763 $eunicefix loc
1764 loclist="
1765 awk
1766 cat
1767 comm
1768 cp
1769 echo
1770 expr
1771 grep
1772 ls
1773 make
1774 mkdir
1775 rm
1776 sed
1777 sort
1778 touch
1779 tr
1780 uniq
1781 "
1782 trylist="
1783 Mcc
1784 ar
1785 byacc
1786 cpp
1787 csh
1788 date
1789 egrep
1790 gzip
1791 less
1792 ln
1793 more
1794 nm
1795 nroff
1796 pg
1797 test
1798 uname
1799 zip
1800 "
1801 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1802 pth="$pth /lib /usr/lib"
1803 for file in $loclist; do
1804         eval xxx=\$$file
1805         case "$xxx" in
1806         /*|?:[\\/]*)
1807                 if test -f "$xxx"; then
1808                         : ok
1809                 else
1810                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1811                         xxx=`./loc $file $file $pth`
1812                 fi
1813                 ;;
1814         '') xxx=`./loc $file $file $pth`;;
1815         *) xxx=`./loc $xxx $xxx $pth`;;
1816         esac
1817         eval $file=$xxx
1818         eval _$file=$xxx
1819         case "$xxx" in
1820         /*)
1821                 echo $file is in $xxx.
1822                 ;;
1823         ?:[\\/]*)
1824                 echo $file is in $xxx.
1825                 ;;
1826         *)
1827                 echo "I don't know where '$file' is, and my life depends on it." >&4
1828                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1829                 exit 1
1830                 ;;
1831         esac
1832 done
1833 echo " "
1834 echo "Don't worry if any of the following aren't found..."
1835 say=offhand
1836 for file in $trylist; do
1837         eval xxx=\$$file
1838         case "$xxx" in
1839         /*|?:[\\/]*)
1840                 if test -f "$xxx"; then
1841                         : ok
1842                 else
1843                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1844                         xxx=`./loc $file $file $pth`
1845                 fi
1846                 ;;
1847         '') xxx=`./loc $file $file $pth`;;
1848         *) xxx=`./loc $xxx $xxx $pth`;;
1849         esac
1850         eval $file=$xxx
1851         eval _$file=$xxx
1852         case "$xxx" in
1853         /*)
1854                 echo $file is in $xxx.
1855                 ;;
1856         ?:[\\/]*)
1857                 echo $file is in $xxx.
1858                 ;;
1859         *)
1860                 echo "I don't see $file out there, $say."
1861                 say=either
1862                 ;;
1863         esac
1864 done
1865 case "$egrep" in
1866 egrep)
1867         echo "Substituting grep for egrep."
1868         egrep=$grep
1869         ;;
1870 esac
1871 case "$ln" in
1872 ln)
1873         echo "Substituting cp for ln."
1874         ln=$cp
1875         ;;
1876 esac
1877 case "$test" in
1878 test)
1879         echo "Hopefully test is built into your sh."
1880         ;;
1881 *)
1882         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1883                 echo "Using the test built into your sh."
1884                 test=test
1885                 _test=test
1886         fi
1887         ;;
1888 esac
1889 case "$echo" in
1890 echo)
1891         echo "Hopefully echo is built into your sh."
1892         ;;
1893 '') ;;
1894 *)
1895         echo " "
1896 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1897         $echo $n "hi there$c" >foo1
1898         echo $n "hi there$c" >foo2
1899         if cmp foo1 foo2 >/dev/null 2>&1; then
1900                 echo "They are compatible.  In fact, they may be identical."
1901         else
1902                 case "$n" in
1903                 '-n') n='' c='\c';;
1904                 *) n='-n' c='';;
1905                 esac
1906                 cat <<FOO
1907 They are not compatible!  You are probably running ksh on a non-USG system.
1908 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1909 have echo built in and we may have to run some Bourne shell scripts.  That
1910 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1911
1912 FOO
1913                 $echo $n "The star should be here-->$c"
1914                 $echo "*"
1915         fi
1916         $rm -f foo1 foo2
1917         ;;
1918 esac
1919
1920 : determine whether symbolic links are supported
1921 echo " "
1922 $touch blurfl
1923 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1924         echo "Symbolic links are supported." >&4
1925         lns="$ln -s"
1926 else
1927         echo "Symbolic links are NOT supported." >&4
1928         lns="$ln"
1929 fi
1930 $rm -f blurfl sym
1931
1932 : see whether [:lower:] and [:upper:] are supported character classes
1933 echo " "
1934 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1935 ABYZ)
1936         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1937         up='[:upper:]'
1938         low='[:lower:]'
1939         ;;
1940 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1941         # (0xc9 and 0xd1), therefore that is a nice testing point.
1942         if test "X$up" = X -o "X$low" = X; then
1943             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1944             ij) up='[A-Z]'
1945                 low='[a-z]'
1946                 ;;
1947             esac
1948         fi
1949         if test "X$up" = X -o "X$low" = X; then
1950             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1951             ij) up='A-Z'
1952                 low='a-z'
1953                 ;;
1954             esac
1955         fi
1956         if test "X$up" = X -o "X$low" = X; then
1957             case "`echo IJ | od -x 2>/dev/null`" in
1958             *C9D1*|*c9d1*)
1959                 echo "Hey, this might be EBCDIC." >&4
1960                 if test "X$up" = X -o "X$low" = X; then
1961                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1962                     ij) up='[A-IJ-RS-Z]'
1963                         low='[a-ij-rs-z]'
1964                         ;;
1965                     esac
1966                 fi
1967                 if test "X$up" = X -o "X$low" = X; then
1968                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1969                     ij) up='A-IJ-RS-Z'
1970                         low='a-ij-rs-z'
1971                         ;;
1972                     esac
1973                 fi
1974                 ;;
1975             esac
1976         fi
1977 esac
1978 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1979 ij)
1980     echo "Using $up and $low to convert case." >&4
1981     ;;
1982 *)
1983     echo "I don't know how to translate letters from upper to lower case." >&4
1984     echo "Your tr is not acting any way I know of." >&4
1985     exit 1
1986     ;;
1987 esac
1988 : set up the translation script tr, must be called with ./tr of course
1989 cat >tr <<EOSC
1990 $startsh
1991 case "\$1\$2" in
1992 '[A-Z][a-z]') exec $tr '$up' '$low';;
1993 '[a-z][A-Z]') exec $tr '$low' '$up';;
1994 esac
1995 exec $tr "\$@"
1996 EOSC
1997 chmod +x tr
1998 $eunicefix tr
1999
2000 : Try to determine whether config.sh was made on this system
2001 case "$config_sh" in
2002 '')
2003 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
2004 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
2005 # because the A-Z/a-z are not consecutive.
2006 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
2007         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
2008 newmyuname="$myuname"
2009 dflt=n
2010 case "$knowitall" in
2011 '')
2012         if test -f ../config.sh; then
2013                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
2014                         eval "`grep myuname= ../config.sh`"
2015                 fi
2016                 if test "X$myuname" = "X$newmyuname"; then
2017                         dflt=y
2018                 fi
2019         fi
2020         ;;
2021 *) dflt=y;;
2022 esac
2023
2024 : Get old answers from old config file if Configure was run on the
2025 : same system, otherwise use the hints.
2026 hint=default
2027 cd ..
2028 if test -f config.sh; then
2029         echo " "
2030         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2031         . UU/myread
2032         case "$ans" in
2033         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2034         *)  echo "Fetching default answers from your old config.sh file..." >&4
2035                 tmp_n="$n"
2036                 tmp_c="$c"
2037                 tmp_sh="$sh"
2038                 . ./config.sh
2039                 cp config.sh UU
2040                 n="$tmp_n"
2041                 c="$tmp_c"
2042                 : Older versions did not always set $sh.  Catch re-use of such
2043                 : an old config.sh.
2044                 case "$sh" in
2045                 '') sh="$tmp_sh" ;;
2046                 esac
2047                 hint=previous
2048                 ;;
2049         esac
2050 fi
2051 if test ! -f config.sh; then
2052         $cat <<EOM
2053
2054 First time through, eh?  I have some defaults handy for some systems
2055 that need some extra help getting the Configure answers right:
2056
2057 EOM
2058         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2059         dflt=''
2060         : Half the following guesses are probably wrong... If you have better
2061         : tests or hints, please send them to perlbug@perl.com
2062         : The metaconfig authors would also appreciate a copy...
2063         $test -f /irix && osname=irix
2064         $test -f /xenix && osname=sco_xenix
2065         $test -f /dynix && osname=dynix
2066         $test -f /dnix && osname=dnix
2067         $test -f /lynx.os && osname=lynxos
2068         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2069         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2070         $test -f /bin/mips && /bin/mips && osname=mips
2071         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2072                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2073         $test -d /usr/apollo/bin && osname=apollo
2074         $test -f /etc/saf/_sactab && osname=svr4
2075         $test -d /usr/include/minix && osname=minix
2076         if $test -d /MachTen -o -d /MachTen_Folder; then
2077                 osname=machten
2078                 if $test -x /sbin/version; then
2079                         osvers=`/sbin/version | $awk '{print $2}' |
2080                         $sed -e 's/[A-Za-z]$//'`
2081                 elif $test -x /usr/etc/version; then
2082                         osvers=`/usr/etc/version | $awk '{print $2}' |
2083                         $sed -e 's/[A-Za-z]$//'`
2084                 else
2085                         osvers="$2.$3"
2086                 fi
2087         fi
2088        $test -f /sys/posix.dll &&
2089                $test -f /usr/bin/what &&
2090                set X `/usr/bin/what /sys/posix.dll` &&
2091                $test "$3" = UWIN &&
2092                osname=uwin &&
2093                osvers="$5"
2094         if $test -f $uname; then
2095                 set X $myuname
2096                 shift
2097
2098                 case "$5" in
2099                 fps*) osname=fps ;;
2100                 mips*)
2101                         case "$4" in
2102                         umips) osname=umips ;;
2103                         *) osname=mips ;;
2104                         esac;;
2105                 [23]100) osname=mips ;;
2106                 next*) osname=next ;;
2107                 i386*)
2108                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2109                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2110                                 osname='sco'
2111                                 osvers=$tmp
2112                         elif $test -f /etc/kconfig; then
2113                                 osname=isc
2114                                 if test "$lns" = "$ln -s"; then
2115                                         osvers=4
2116                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2117                                         osvers=3
2118                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2119                                         osvers=2
2120                                 fi
2121                         fi
2122                         tmp=''
2123                         ;;
2124                 pc*)
2125                         if test -n "$DJGPP"; then
2126                                 osname=dos
2127                                 osvers=djgpp
2128                         fi
2129                         ;;
2130                 esac
2131
2132                 case "$1" in
2133                 aix) osname=aix
2134                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2135                         case "$tmp" in
2136                         'not found') osvers="$4"."$3" ;;
2137                         '<3240'|'<>3240') osvers=3.2.0 ;;
2138                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2139                         '=3250'|'>3250') osvers=3.2.5 ;;
2140                         *) osvers=$tmp;;
2141                         esac
2142                         ;;
2143                 *dc.osx) osname=dcosx
2144                         osvers="$3"
2145                         ;;
2146                 dnix) osname=dnix
2147                         osvers="$3"
2148                         ;;
2149                 domainos) osname=apollo
2150                         osvers="$3"
2151                         ;;
2152                 dgux) osname=dgux 
2153                         osvers="$3"
2154                         ;;
2155                 dynixptx*) osname=dynixptx
2156                         osvers=`echo "$4"|sed 's/^v//'`
2157                         ;;
2158                 freebsd) osname=freebsd 
2159                         osvers="$3" ;;
2160                 genix) osname=genix ;;
2161                 hp*) osname=hpux 
2162                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2163                         ;;
2164                 irix*) osname=irix
2165                         case "$3" in
2166                         4*) osvers=4 ;;
2167                         5*) osvers=5 ;;
2168                         *)      osvers="$3" ;;
2169                         esac
2170                         ;;
2171                 linux) osname=linux
2172                         case "$3" in
2173                         *)      osvers="$3" ;;
2174                         esac
2175                         ;;
2176                 MiNT) osname=mint
2177                         ;;
2178                 netbsd*) osname=netbsd
2179                         osvers="$3"
2180                         ;;
2181                 news-os) osvers="$3"
2182                         case "$3" in
2183                         4*) osname=newsos4 ;;
2184                         *) osname=newsos ;;
2185                         esac
2186                         ;;
2187                 bsd386) osname=bsd386
2188                         osvers=`$uname -r`
2189                         ;;
2190                 POSIX-BC | posix-bc ) osname=posix-bc
2191                         osvers="$3"
2192                         ;;
2193                 powerux | power_ux | powermax_os | powermaxos | \
2194                 powerunix | power_unix) osname=powerux
2195                         osvers="$3"
2196                         ;;
2197                 next*) osname=next ;;
2198                 solaris) osname=solaris
2199                         case "$3" in
2200                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2201                         *)      osvers="$3" ;;
2202                         esac
2203                         ;;
2204                 sunos) osname=sunos
2205                         case "$3" in
2206                         5*) osname=solaris
2207                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2208                         *)      osvers="$3" ;;
2209                         esac
2210                         ;;
2211                 titanos) osname=titanos
2212                         case "$3" in
2213                         1*) osvers=1 ;;
2214                         2*) osvers=2 ;;
2215                         3*) osvers=3 ;;
2216                         4*) osvers=4 ;;
2217                         *)      osvers="$3" ;;
2218                         esac
2219                         ;;
2220                 ultrix) osname=ultrix
2221                         osvers="$3"
2222                         ;;
2223                 osf1|mls+)      case "$5" in
2224                                 alpha)
2225                                         osname=dec_osf
2226                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2227                                         ;;
2228                         hp*)    osname=hp_osf1  ;;
2229                         mips)   osname=mips_osf1 ;;
2230                         esac
2231                         ;;
2232                 uts) osname=uts 
2233                         osvers="$3"
2234                         ;;
2235                 qnx) osname=qnx
2236                         osvers="$4"
2237                         ;;
2238                 $2) case "$osname" in
2239                         *isc*) ;;
2240                         *freebsd*) ;;
2241                         svr*)
2242                                 : svr4.x or possibly later
2243                                 case "svr$3" in 
2244                                 ${osname}*)
2245                                         osname=svr$3
2246                                         osvers=$4
2247                                         ;;
2248                                 esac
2249                                 case "$osname" in
2250                                 svr4.0)
2251                                         : Check for ESIX
2252                                         if test -f /stand/boot ; then
2253                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2254                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2255                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2256                                                         if test -n "$isesix"; then
2257                                                                 osname=esix4
2258                                                         fi
2259                                                 fi
2260                                         fi
2261                                         ;;
2262                                 esac
2263                                 ;;
2264                         *)      if test -f /etc/systemid; then
2265                                         osname=sco
2266                                         set `echo $3 | $sed 's/\./ /g'` $4
2267                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2268                                                 osvers=$1.$2.$3
2269                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2270                                                 osvers=$1.$2
2271                                         elif $test -f $src/hints/sco_$1.sh; then
2272                                                 osvers=$1
2273                                         fi
2274                                 else
2275                                         case "$osname" in
2276                                         '') : Still unknown.  Probably a generic Sys V.
2277                                                 osname="sysv"
2278                                                 osvers="$3"
2279                                                 ;;
2280                                         esac
2281                                 fi
2282                                 ;;
2283                         esac
2284                         ;;
2285                 *)      case "$osname" in
2286                         '') : Still unknown.  Probably a generic BSD.
2287                                 osname="$1"
2288                                 osvers="$3"
2289                                 ;;
2290                         esac
2291                         ;;
2292                 esac
2293         else
2294                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2295                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2296                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2297                                 osname=news_os
2298                         fi
2299                         $rm -f UU/kernel.what
2300                 elif test -d c:/.; then
2301                         set X $myuname
2302                         osname=os2
2303                         osvers="$5"
2304                 fi
2305         fi
2306         
2307         : Now look for a hint file osname_osvers, unless one has been
2308         : specified already.
2309         case "$hintfile" in
2310         ''|' ')
2311                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2312                 : Also try without trailing minor version numbers.
2313                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2314                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2315                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2316                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2317                 case "$file" in
2318                 '') dflt=none ;;
2319                 *)  case "$osvers" in
2320                         '') dflt=$file
2321                                 ;;
2322                         *)  if $test -f $src/hints/$file.sh ; then
2323                                         dflt=$file
2324                                 elif $test -f $src/hints/$xfile.sh ; then
2325                                         dflt=$xfile
2326                                 elif $test -f $src/hints/$xxfile.sh ; then
2327                                         dflt=$xxfile
2328                                 elif $test -f $src/hints/$xxxfile.sh ; then
2329                                         dflt=$xxxfile
2330                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2331                                         dflt=$xxxxfile
2332                                 elif $test -f "$src/hints/${osname}.sh" ; then
2333                                         dflt="${osname}"
2334                                 else
2335                                         dflt=none
2336                                 fi
2337                                 ;;
2338                         esac
2339                         ;;
2340                 esac
2341                 if $test -f Policy.sh ; then
2342                         case "$dflt" in
2343                         *Policy*) ;;
2344                         none) dflt="Policy" ;;
2345                         *) dflt="Policy $dflt" ;;
2346                         esac
2347                 fi
2348                 ;;
2349         *)
2350                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2351                 ;;
2352         esac
2353
2354         if $test -f Policy.sh ; then
2355                 $cat <<EOM
2356
2357 There's also a Policy hint file available, which should make the
2358 site-specific (policy) questions easier to answer.
2359 EOM
2360
2361         fi
2362
2363         $cat <<EOM
2364
2365 You may give one or more space-separated answers, or "none" if appropriate.
2366 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2367 is a good thing.  DO NOT give a wrong version.
2368
2369 EOM
2370
2371         rp="Which of these apply, if any?"
2372         . UU/myread
2373         tans=$ans
2374         for file in $tans; do
2375                 if $test X$file = XPolicy -a -f Policy.sh; then
2376                         . Policy.sh
2377                         $cat Policy.sh >> UU/config.sh
2378                 elif $test -f $src/hints/$file.sh; then
2379                         . $src/hints/$file.sh
2380                         $cat $src/hints/$file.sh >> UU/config.sh
2381                 elif $test X$tans = X -o X$tans = Xnone ; then
2382                         : nothing
2383                 else
2384                         : Give one chance to correct a possible typo.
2385                         echo "$file.sh does not exist"
2386                         dflt=$file
2387                         rp="hint to use instead?"
2388                         . UU/myread
2389                         for file in $ans; do
2390                                 if $test -f "$src/hints/$file.sh"; then
2391                                         . $src/hints/$file.sh
2392                                         $cat $src/hints/$file.sh >> UU/config.sh
2393                                 elif $test X$ans = X -o X$ans = Xnone ; then
2394                                         : nothing
2395                                 else
2396                                         echo "$file.sh does not exist -- ignored."
2397                                 fi
2398                         done
2399                 fi
2400         done
2401
2402         hint=recommended
2403         : Remember our hint file for later.
2404         if $test -f "$src/hints/$file.sh" ; then
2405                 hintfile="$file"
2406         else
2407                 hintfile=''
2408         fi
2409 fi
2410 cd UU
2411 ;;
2412 *)
2413         echo " "
2414         echo "Fetching default answers from $config_sh..." >&4
2415         tmp_n="$n"
2416         tmp_c="$c"
2417         cd ..
2418         cp $config_sh config.sh 2>/dev/null
2419         chmod +w config.sh
2420         . ./config.sh
2421         cd UU
2422         cp ../config.sh .
2423         n="$tmp_n"
2424         c="$tmp_c"
2425         hint=previous
2426         ;;
2427 esac
2428 test "$override" && . ./optdef.sh
2429 myuname="$newmyuname"
2430
2431 : Restore computed paths
2432 for file in $loclist $trylist; do
2433         eval $file="\$_$file"
2434 done
2435
2436 cat << EOM
2437
2438 Configure uses the operating system name and version to set some defaults.
2439 The default value is probably right if the name rings a bell. Otherwise,
2440 since spelling matters for me, either accept the default or answer "none"
2441 to leave it blank.
2442
2443 EOM
2444 case "$osname" in
2445         ''|' ')
2446                 case "$hintfile" in
2447                 ''|' '|none) dflt=none ;;
2448                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2449                 esac
2450                 ;;
2451         *) dflt="$osname" ;;
2452 esac
2453 rp="Operating system name?"
2454 . ./myread
2455 case "$ans" in
2456 none)  osname='' ;;
2457 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2458 esac
2459 echo " "
2460 case "$osvers" in
2461         ''|' ')
2462                 case "$hintfile" in
2463                 ''|' '|none) dflt=none ;;
2464                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2465                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2466                         case "$dflt" in
2467                         ''|' ') dflt=none ;;
2468                         esac
2469                         ;;
2470                 esac
2471                 ;;
2472         *) dflt="$osvers" ;;
2473 esac
2474 rp="Operating system version?"
2475 . ./myread
2476 case "$ans" in
2477 none)  osvers='' ;;
2478 *) osvers="$ans" ;;
2479 esac
2480
2481 : who configured the system
2482 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2483 cf_by=`(logname) 2>/dev/null`
2484 case "$cf_by" in
2485 "")
2486         cf_by=`(whoami) 2>/dev/null`
2487         case "$cf_by" in
2488         "") cf_by=unknown ;;
2489         esac ;;
2490 esac
2491
2492 : set up the script used to warn in case of inconsistency
2493 cat <<EOS >whoa
2494 $startsh
2495 EOS
2496 cat <<'EOSC' >>whoa
2497 dflt=y
2498 echo " "
2499 echo "*** WHOA THERE!!! ***" >&4
2500 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2501 rp="    Keep the $hint value?"
2502 . ./myread
2503 case "$ans" in
2504 y) td=$was; tu=$was;;
2505 esac
2506 EOSC
2507
2508 : function used to set $1 to $val
2509 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2510 case "$val$was" in
2511 $define$undef) . ./whoa; eval "$var=\$td";;
2512 $undef$define) . ./whoa; eval "$var=\$tu";;
2513 *) eval "$var=$val";;
2514 esac'
2515
2516 cat <<EOM
2517
2518 Perl can be built to take advantage of threads, on some systems.
2519 To do so, Configure must be run with -Dusethreads.
2520
2521 Note that threading is a highly experimental feature, and
2522 some known race conditions still remain.  If you choose to try
2523 it, be very sure to not actually deploy it for production
2524 purposes.  README.threads has more details, and is required
2525 reading if you enable threads.
2526 EOM
2527 case "$usethreads" in
2528 $define|true|[yY]*)     dflt='y';;
2529 *) dflt='n';;
2530 esac
2531 rp='Build a threading Perl?'
2532 . ./myread
2533 case "$ans" in
2534 y|Y)    val="$define" ;;     
2535 *)      val="$undef" ;;
2536 esac
2537 set usethreads
2538 eval $setvar 
2539
2540 case "$d_oldpthreads" in
2541 '')     : Configure tests would be welcome here.  For now, assume undef.
2542         val="$undef" ;;
2543 *)      val="$d_oldpthreads" ;;
2544 esac
2545 set d_oldpthreads
2546 eval $setvar
2547
2548
2549 case "$usethreads" in
2550 "$define"|true|[yY]*)
2551 : Look for a hint-file generated 'call-back-unit'.  If the
2552 : user has specified that a threading perl is to be built,
2553 : we may need to set or change some other defaults.
2554         if $test -f usethreads.cbu; then
2555                 . ./usethreads.cbu
2556         fi
2557         case "$osname" in
2558         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2559                 # Known thread-capable platforms.
2560                 ;;
2561         *)
2562                 cat >&4 <<EOM
2563 $osname is not known to support threads.
2564 Please let perlbug@perl.com know how to do that.
2565
2566 Cannot continue, aborting.
2567 EOM
2568                 exit 1
2569         ;;
2570         esac # $osname
2571     ;;
2572 esac # $usethreads
2573
2574 cat <<EOM
2575
2576 Perl can be built so that multiple Perl interpreters can coexist
2577 within the same Perl executable.  To do so, Configure must be run with
2578 -Dusemultiplicity.
2579
2580 Normally you do not need this and you should answer no.
2581
2582 EOM
2583 case "$usemultiplicity" in
2584 $define|true|[yY]*)     dflt='y';;
2585 *) dflt='n';;
2586 esac
2587 rp='Build Perl for multiplicity?'
2588 . ./myread
2589 case "$ans" in
2590 y|Y)    val="$define" ;;     
2591 *)      val="$undef" ;;
2592 esac
2593 set usemultiplicity
2594 eval $setvar 
2595
2596 cat <<EOM
2597
2598 Perl can be built to take advantage of explicit 64-bit interfaces,
2599 on some systems.  To do so, Configure must be run with -Duse64bits.
2600
2601 If this doesn't make any sense to you, just accept the default 'n'.
2602 EOM
2603 case "$use64bits" in
2604 $define|true|[yY]*)     dflt='y';;
2605 *) dflt='n';;
2606 esac
2607 rp='Try to use explicit 64-bit interfaces, if available?'
2608 . ./myread
2609 case "$ans" in
2610 y|Y) 
2611         val="$define"
2612         ;;     
2613 *)      
2614         val="$undef"
2615         ;;
2616 esac
2617 set use64bits
2618 eval $setvar
2619
2620 case "$archname64" in
2621 '') archname64='' ;;    # not a typo
2622 esac
2623
2624 case "$use64bits" in
2625 "$define"|true|[yY]*)
2626 : Look for a hint-file generated 'call-back-unit'.  If the
2627 : user has specified that a threading perl is to be built,
2628 : we may need to set or change some other defaults.
2629         if $test -f use64bits.cbu; then
2630                 . ./use64bits.cbu
2631         fi
2632         case "$osname" in
2633         aix|dec_osf|hpux|irix|solaris|unicos)
2634                 # Known 64-bit capable platforms.
2635                 ;;
2636         *)
2637                 cat >&4 <<EOM
2638 $osname is not known to support 64-bit interfaces.
2639 Please let perlbug@perl.com know how to do that.
2640
2641 Cannot continue, aborting.
2642 EOM
2643                 exit 1
2644                 ;;
2645         esac
2646         ;;
2647 esac
2648
2649 : determine the architecture name
2650 echo " "
2651 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2652         tarch=`arch`"-$osname"
2653 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2654         if uname -m > tmparch 2>&1 ; then
2655                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2656                         -e 's/$/'"-$osname/" tmparch`
2657         else
2658                 tarch="$osname"
2659         fi
2660         $rm -f tmparch
2661 else
2662         tarch="$osname"
2663 fi
2664 case "$myarchname" in
2665 ''|"$tarch") ;;
2666 *)
2667         echo "(Your architecture name used to be $myarchname.)"
2668         archname=''
2669         ;;
2670 esac
2671 myarchname="$tarch"
2672 case "$archname" in
2673 '') dflt="$tarch";;
2674 *) dflt="$archname";;
2675 esac
2676 rp='What is your architecture name'
2677 . ./myread
2678 archname="$ans"
2679 case "$usethreads" in
2680 $define)
2681         echo "Threads selected." >&4
2682         case "$archname" in
2683         *-thread*) echo "...and architecture name already has -thread." >&4
2684                 ;;
2685         *)      archname="$archname-thread"
2686                 echo "...setting architecture name to $archname." >&4
2687                 ;;
2688         esac
2689         ;;
2690 esac
2691 case "$usemultiplicity" in
2692 $define)
2693         echo "Multiplicity selected." >&4
2694         case "$archname" in
2695         *-multi*) echo "...and architecture name already has -multi." >&4
2696                 ;;
2697         *)      archname="$archname-multi"
2698                 echo "...setting architecture name to $archname." >&4
2699                 ;;
2700         esac
2701         ;;
2702 esac
2703 case "$use64bits" in
2704 $define)
2705         echo "Explicit 64-bitness selected." >&4
2706         case "$archname64" in
2707         '')
2708                 ;;
2709         *)
2710                 case "$archname" in
2711                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2712                         ;;
2713                 *)      archname="$archname-$archname64"
2714                         echo "...setting architecture name to $archname." >&4
2715                         ;;
2716                 esac
2717                 ;;
2718         esac
2719 esac
2720
2721 : is AFS running?
2722 echo " "
2723 case "$afs" in
2724 $define|true)   afs=true ;;
2725 $undef|false)   afs=false ;;
2726 *)      if test -d /afs; then
2727                 afs=true
2728         else
2729                 afs=false
2730         fi
2731         ;;
2732 esac
2733 if $afs; then
2734         echo "AFS may be running... I'll be extra cautious then..." >&4
2735 else
2736         echo "AFS does not seem to be running..." >&4
2737 fi
2738
2739 : decide how portable to be.  Allow command line overrides.
2740 case "$d_portable" in
2741 "$undef") ;;
2742 *)      d_portable="$define" ;;
2743 esac
2744
2745 : set up shell script to do ~ expansion
2746 cat >filexp <<EOSS
2747 $startsh
2748 : expand filename
2749 case "\$1" in
2750  ~/*|~)
2751         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2752         ;;
2753  ~*)
2754         if $test -f /bin/csh; then
2755                 /bin/csh -f -c "glob \$1"
2756                 failed=\$?
2757                 echo ""
2758                 exit \$failed
2759         else
2760                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2761                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2762                 if $test ! -d "\$dir"; then
2763                         me=\`basename \$0\`
2764                         echo "\$me: can't locate home directory for: \$name" >&2
2765                         exit 1
2766                 fi
2767                 case "\$1" in
2768                 */*)
2769                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2770                         ;;
2771                 *)
2772                         echo \$dir
2773                         ;;
2774                 esac
2775         fi
2776         ;;
2777 *)
2778         echo \$1
2779         ;;
2780 esac
2781 EOSS
2782 chmod +x filexp
2783 $eunicefix filexp
2784
2785 : now set up to get a file name
2786 cat <<EOS >getfile
2787 $startsh
2788 EOS
2789 cat <<'EOSC' >>getfile
2790 tilde=''
2791 fullpath=''
2792 already=''
2793 skip=''
2794 none_ok=''
2795 exp_file=''
2796 nopath_ok=''
2797 orig_rp="$rp"
2798 orig_dflt="$dflt"
2799
2800 case "$fn" in
2801 *\(*)
2802         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2803         fn=`echo $fn | sed 's/(.*)//'`
2804         ;;
2805 esac
2806
2807 case "$fn" in
2808 *:*)
2809         loc_file=`expr $fn : '.*:\(.*\)'`
2810         fn=`expr $fn : '\(.*\):.*'`
2811         ;;
2812 esac
2813
2814 case "$fn" in
2815 *~*) tilde=true;;
2816 esac
2817 case "$fn" in
2818 */*) fullpath=true;;
2819 esac
2820 case "$fn" in
2821 *+*) skip=true;;
2822 esac
2823 case "$fn" in
2824 *n*) none_ok=true;;
2825 esac
2826 case "$fn" in
2827 *e*) exp_file=true;;
2828 esac
2829 case "$fn" in
2830 *p*) nopath_ok=true;;
2831 esac
2832
2833 case "$fn" in
2834 *f*) type='File';;
2835 *d*) type='Directory';;
2836 *l*) type='Locate';;
2837 esac
2838
2839 what="$type"
2840 case "$what" in
2841 Locate) what='File';;
2842 esac
2843
2844 case "$exp_file" in
2845 '')
2846         case "$d_portable" in
2847         "$define") ;;
2848         *) exp_file=true;;
2849         esac
2850         ;;
2851 esac
2852
2853 cd ..
2854 while test "$type"; do
2855         redo=''
2856         rp="$orig_rp"
2857         dflt="$orig_dflt"
2858         case "$tilde" in
2859         true) rp="$rp (~name ok)";;
2860         esac
2861         . UU/myread
2862         if test -f UU/getfile.ok && \
2863                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2864         then
2865                 value="$ans"
2866                 ansexp="$ans"
2867                 break
2868         fi
2869         case "$ans" in
2870         none)
2871                 value=''
2872                 ansexp=''
2873                 case "$none_ok" in
2874                 true) type='';;
2875                 esac
2876                 ;;
2877         *)
2878                 case "$tilde" in
2879                 '') value="$ans"
2880                         ansexp="$ans";;
2881                 *)
2882                         value=`UU/filexp $ans`
2883                         case $? in
2884                         0)
2885                                 if test "$ans" != "$value"; then
2886                                         echo "(That expands to $value on this system.)"
2887                                 fi
2888                                 ;;
2889                         *) value="$ans";;
2890                         esac
2891                         ansexp="$value"
2892                         case "$exp_file" in
2893                         '') value="$ans";;
2894                         esac
2895                         ;;
2896                 esac
2897                 case "$fullpath" in
2898                 true)
2899                         case "$ansexp" in
2900                         /*) value="$ansexp" ;;
2901                         *)
2902                                 redo=true
2903                                 case "$already" in
2904                                 true)
2905                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2906                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2907                                         ;;
2908                                 *)
2909                                 echo "Please give a full path name, starting with slash." >&4
2910                                         case "$tilde" in
2911                                         true)
2912                                 echo "Note that using ~name is ok provided it expands well." >&4
2913                                                 already=true
2914                                                 ;;
2915                                         esac
2916                                 esac
2917                                 ;;
2918                         esac
2919                         ;;
2920                 esac
2921                 case "$redo" in
2922                 '')
2923                         case "$type" in
2924                         File)
2925                                 if test -f "$ansexp"; then
2926                                         type=''
2927                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2928                                 then
2929                                         echo "($value is not a plain file, but that's ok.)"
2930                                         type=''
2931                                 fi
2932                                 ;;
2933                         Directory)
2934                                 if test -d "$ansexp"; then
2935                                         type=''
2936                                 fi
2937                                 ;;
2938                         Locate)
2939                                 if test -d "$ansexp"; then
2940                                         echo "(Looking for $loc_file in directory $value.)"
2941                                         value="$value/$loc_file"
2942                                         ansexp="$ansexp/$loc_file"
2943                                 fi
2944                                 if test -f "$ansexp"; then
2945                                         type=''
2946                                 fi
2947                                 case "$nopath_ok" in
2948                                 true)   case "$value" in
2949                                         */*) ;;
2950                                         *)      echo "Assuming $value will be in people's path."
2951                                                 type=''
2952                                                 ;;
2953                                         esac
2954                                         ;;
2955                                 esac
2956                                 ;;
2957                         esac
2958
2959                         case "$skip" in
2960                         true) type='';
2961                         esac
2962
2963                         case "$type" in
2964                         '') ;;
2965                         *)
2966                                 if test "$fastread" = yes; then
2967                                         dflt=y
2968                                 else
2969                                         dflt=n
2970                                 fi
2971                                 rp="$what $value doesn't exist.  Use that name anyway?"
2972                                 . UU/myread
2973                                 dflt=''
2974                                 case "$ans" in
2975                                 y*) type='';;
2976                                 *) echo " ";;
2977                                 esac
2978                                 ;;
2979                         esac
2980                         ;;
2981                 esac
2982                 ;;
2983         esac
2984 done
2985 cd UU
2986 ans="$value"
2987 rp="$orig_rp"
2988 dflt="$orig_dflt"
2989 rm -f getfile.ok
2990 EOSC
2991
2992 : determine root of directory hierarchy where package will be installed.
2993 case "$prefix" in
2994 '')
2995         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2996         ;;
2997 *)
2998         dflt="$prefix"
2999         ;;
3000 esac
3001 $cat <<EOM
3002
3003 By default, $package will be installed in $dflt/bin, manual
3004 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
3005 all installation directories. Typically set to /usr/local, but you
3006 may choose /usr if you wish to install $package among your system
3007 binaries. If you wish to have binaries under /bin but manual pages
3008 under /usr/local/man, that's ok: you will be prompted separately
3009 for each of the installation directories, the prefix being only used
3010 to set the defaults.
3011
3012 EOM
3013 fn=d~
3014 rp='Installation prefix to use?'
3015 . ./getfile
3016 oldprefix=''
3017 case "$prefix" in
3018 '') ;;
3019 *)
3020         case "$ans" in
3021         "$prefix") ;;
3022         *) oldprefix="$prefix";;
3023         esac
3024         ;;
3025 esac
3026 prefix="$ans"
3027 prefixexp="$ansexp"
3028
3029 : set the prefixit variable, to compute a suitable default value
3030 prefixit='case "$3" in
3031 ""|none)
3032         case "$oldprefix" in
3033         "") eval "$1=\"\$$2\"";;
3034         *)
3035                 case "$3" in
3036                 "") eval "$1=";;
3037                 none)
3038                         eval "tp=\"\$$2\"";
3039                         case "$tp" in
3040                         ""|" ") eval "$1=\"\$$2\"";;
3041                         *) eval "$1=";;
3042                         esac;;
3043                 esac;;
3044         esac;;
3045 *)
3046         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3047         case "$tp" in
3048         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3049         /*-$oldprefix/*|\~*-$oldprefix/*)
3050                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3051         *) eval "$1=\"\$$2\"";;
3052         esac;;
3053 esac'
3054
3055 : set the base revision
3056 baserev=5.0
3057
3058 : get the patchlevel
3059 echo " "
3060 echo "Getting the current patchlevel..." >&4
3061 if $test -r $rsrc/patchlevel.h;then
3062         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3063         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3064 else
3065         patchlevel=0
3066         subversion=0
3067 fi
3068 $echo $n "(You have $package" $c
3069 case "$package" in
3070 "*$baserev")    ;;
3071 *)              $echo $n " $baserev" $c ;;
3072 esac
3073 $echo $n " patchlevel $patchlevel" $c
3074 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3075 echo ".)"
3076
3077 if test 0 -eq "$subversion"; then
3078         version=`LC_ALL=C; export LC_ALL; \
3079                  echo $baserev $patchlevel | \
3080                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3081 else
3082         version=`LC_ALL=C; export LC_ALL; \
3083                  echo $baserev $patchlevel $subversion | \
3084                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3085 fi
3086 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3087 if test "$subversion" -lt 50; then
3088         apiversion=`LC_ALL=C; export LC_ALL; \
3089                  LANGUAGE=C; export LANGUAGE; \
3090                  echo $baserev $patchlevel | \
3091                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3092 else
3093         apiversion="$version"
3094 fi
3095
3096 : determine where private library files go
3097 : Usual default is /usr/local/lib/perl5/$version.
3098 : Also allow things like /opt/perl/lib/$version, since 
3099 : /opt/perl/lib/perl5... would be redundant.
3100 case "$prefix" in
3101 *perl*) set dflt privlib lib/$version ;;
3102 *)       set dflt privlib lib/$package/$version ;;
3103 esac
3104 eval $prefixit
3105 $cat <<EOM
3106
3107 There are some auxiliary files for $package that need to be put into a
3108 private library directory that is accessible by everyone.
3109
3110 EOM
3111 fn=d~+
3112 rp='Pathname where the private library files will reside?'
3113 . ./getfile
3114 if $test "X$privlibexp" != "X$ansexp"; then
3115         installprivlib=''
3116 fi
3117 privlib="$ans"
3118 privlibexp="$ansexp"
3119 if $afs; then
3120         $cat <<EOM
3121
3122 Since you are running AFS, I need to distinguish the directory in which
3123 private files reside from the directory in which they are installed (and from
3124 which they are presumably copied to the former directory by occult means).
3125
3126 EOM
3127         case "$installprivlib" in
3128         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3129         *) dflt="$installprivlib";;
3130         esac
3131         fn=de~
3132         rp='Where will private files be installed?'
3133         . ./getfile
3134         installprivlib="$ans"
3135 else
3136         installprivlib="$privlibexp"
3137 fi
3138
3139 : set the prefixup variable, to restore leading tilda escape
3140 prefixup='case "$prefixexp" in
3141 "$prefix") ;;
3142 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3143 esac'
3144
3145 : determine where public architecture dependent libraries go
3146 set archlib archlib
3147 eval $prefixit
3148 : privlib default is /usr/local/lib/$package/$version
3149 : archlib default is /usr/local/lib/$package/$version/$archname
3150 : privlib may have an optional trailing /share.
3151 tdflt=`echo $privlib | $sed 's,/share$,,'`
3152 tdflt=$tdflt/$archname
3153 case "$archlib" in
3154 '')     dflt=$tdflt
3155         ;;
3156 *)      dflt="$archlib"
3157     ;;
3158 esac
3159 cat <<EOM
3160
3161 $spackage contains architecture-dependent library files.  If you are
3162 sharing libraries in a heterogeneous environment, you might store
3163 these files in a separate location.  Otherwise, you can just include
3164 them with the rest of the public library files.
3165
3166 EOM
3167 fn=d+~
3168 rp='Where do you want to put the public architecture-dependent libraries?'
3169 . ./getfile
3170 archlib="$ans"
3171 archlibexp="$ansexp"
3172
3173 if $afs; then
3174         $cat <<EOM
3175
3176 Since you are running AFS, I need to distinguish the directory in
3177 which architecture-dependent library files reside from the directory
3178 in which they are installed (and from which they are presumably copied
3179 to the former directory by occult means).
3180
3181 EOM
3182         case "$installarchlib" in
3183         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3184         *) dflt="$installarchlib";;
3185         esac
3186         fn=de~
3187         rp='Where will architecture-dependent library files be installed?'
3188         . ./getfile
3189         installarchlib="$ans"
3190 else
3191         installarchlib="$archlibexp"
3192 fi
3193 if $test X"$archlib" = X"$privlib"; then
3194         d_archlib="$undef"
3195 else
3196         d_archlib="$define"
3197 fi
3198
3199 : make some quick guesses about what we are up against
3200 echo " "
3201 $echo $n "Hmm...  $c"
3202 echo exit 1 >bsd
3203 echo exit 1 >usg
3204 echo exit 1 >v7
3205 echo exit 1 >osf1
3206 echo exit 1 >eunice
3207 echo exit 1 >xenix
3208 echo exit 1 >venix
3209 echo exit 1 >os2
3210 d_bsd="$undef"
3211 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3212 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3213 then
3214         echo "Looks kind of like an OSF/1 system, but we'll see..."
3215         echo exit 0 >osf1
3216 elif test `echo abc | tr a-z A-Z` = Abc ; then
3217         xxx=`./loc addbib blurfl $pth`
3218         if $test -f $xxx; then
3219         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3220                 echo exit 0 >bsd
3221                 echo exit 0 >usg
3222         else
3223                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3224                         echo "Looks kind of like an extended USG system, but we'll see..."
3225                 else
3226                         echo "Looks kind of like a USG system, but we'll see..."
3227                 fi
3228                 echo exit 0 >usg
3229         fi
3230 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3231         echo "Looks kind of like a BSD system, but we'll see..."
3232         d_bsd="$define"
3233         echo exit 0 >bsd
3234 else
3235         echo "Looks kind of like a Version 7 system, but we'll see..."
3236         echo exit 0 >v7
3237 fi
3238 case "$eunicefix" in
3239 *unixtovms*)
3240         $cat <<'EOI'
3241 There is, however, a strange, musty smell in the air that reminds me of
3242 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3243 EOI
3244         echo exit 0 >eunice
3245         d_eunice="$define"
3246 : it so happens the Eunice I know will not run shell scripts in Unix format
3247         ;;
3248 *)
3249         echo " "
3250         echo "Congratulations.  You aren't running Eunice."
3251         d_eunice="$undef"
3252         ;;
3253 esac
3254 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3255 case "$p_" in
3256 :) ;;
3257 *)
3258         $cat <<'EOI'
3259 I have the feeling something is not exactly right, however...don't tell me...
3260 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3261 EOI
3262         echo exit 0 >os2
3263         ;;
3264 esac
3265 if test -f /xenix; then
3266         echo "Actually, this looks more like a XENIX system..."
3267         echo exit 0 >xenix
3268         d_xenix="$define"
3269 else
3270         echo " "
3271         echo "It's not Xenix..."
3272         d_xenix="$undef"
3273 fi
3274 chmod +x xenix
3275 $eunicefix xenix
3276 if test -f /venix; then
3277         echo "Actually, this looks more like a VENIX system..."
3278         echo exit 0 >venix
3279 else
3280         echo " "
3281         if ./xenix; then
3282                 : null
3283         else
3284                 echo "Nor is it Venix..."
3285         fi
3286 fi
3287 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3288 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3289 $rm -f foo
3290
3291 : see if setuid scripts can be secure
3292 $cat <<EOM
3293
3294 Some kernels have a bug that prevents setuid #! scripts from being
3295 secure.  Some sites have disabled setuid #! scripts because of this.
3296
3297 First let's decide if your kernel supports secure setuid #! scripts.
3298 (If setuid #! scripts would be secure but have been disabled anyway,
3299 don't say that they are secure if asked.)
3300
3301 EOM
3302
3303 val="$undef"
3304 if $test -d /dev/fd; then
3305         echo "#!$ls" >reflect
3306         chmod +x,u+s reflect
3307         ./reflect >flect 2>&1
3308         if $contains "/dev/fd" flect >/dev/null; then
3309                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3310                 val="$define"
3311         else
3312                 $cat <<EOM
3313 If you are not sure if they are secure, I can check but I'll need a
3314 username and password different from the one you are using right now.
3315 If you don't have such a username or don't want me to test, simply
3316 enter 'none'.
3317
3318 EOM
3319                 rp='Other username to test security of setuid scripts with?'
3320                 dflt='none'
3321                 . ./myread
3322                 case "$ans" in
3323                 n|none)
3324                         case "$d_suidsafe" in
3325                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3326                                 dflt=n;;
3327                         "$undef")
3328                                 echo "Well, the $hint value is *not* secure." >&4
3329                                 dflt=n;;
3330                         *)      echo "Well, the $hint value *is* secure." >&4
3331                                 dflt=y;;
3332                         esac
3333                         ;;
3334                 *)
3335                         $rm -f reflect flect
3336                         echo "#!$ls" >reflect
3337                         chmod +x,u+s reflect
3338                         echo >flect
3339                         chmod a+w flect
3340                         echo '"su" will (probably) prompt you for '"$ans's password."
3341                         su $ans -c './reflect >flect'
3342                         if $contains "/dev/fd" flect >/dev/null; then
3343                                 echo "Okay, it looks like setuid scripts are secure." >&4
3344                                 dflt=y
3345                         else
3346                                 echo "I don't think setuid scripts are secure." >&4
3347                                 dflt=n
3348                         fi
3349                         ;;
3350                 esac
3351                 rp='Does your kernel have *secure* setuid scripts?'
3352                 . ./myread
3353                 case "$ans" in
3354                 [yY]*)  val="$define";;
3355                 *)      val="$undef";;
3356                 esac
3357         fi
3358 else
3359         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3360         echo "(That's for file descriptors, not floppy disks.)"
3361         val="$undef"
3362 fi
3363 set d_suidsafe
3364 eval $setvar
3365
3366 $rm -f reflect flect
3367
3368 : now see if they want to do setuid emulation
3369 echo " "
3370 val="$undef"
3371 case "$d_suidsafe" in
3372 "$define")
3373         val="$undef"
3374         echo "No need to emulate SUID scripts since they are secure here." >& 4
3375         ;;
3376 *)
3377         $cat <<EOM
3378 Some systems have disabled setuid scripts, especially systems where
3379 setuid scripts cannot be secure.  On systems where setuid scripts have
3380 been disabled, the setuid/setgid bits on scripts are currently
3381 useless.  It is possible for $package to detect those bits and emulate
3382 setuid/setgid in a secure fashion.  This emulation will only work if
3383 setuid scripts have been disabled in your kernel.
3384
3385 EOM
3386         case "$d_dosuid" in
3387         "$define") dflt=y ;;
3388         *) dflt=n ;;
3389         esac
3390         rp="Do you want to do setuid/setgid emulation?"
3391         . ./myread
3392         case "$ans" in
3393         [yY]*)  val="$define";;
3394         *)      val="$undef";;
3395         esac
3396         ;;
3397 esac
3398 set d_dosuid
3399 eval $setvar
3400
3401 : determine where manual pages are on this system
3402 echo " "
3403 case "$sysman" in
3404 '') 
3405         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3406         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3407         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3408         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3409         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3410         sysman=`./loc . /usr/man/man1 $syspath`
3411         ;;
3412 esac
3413 if $test -d "$sysman"; then
3414         echo "System manual is in $sysman." >&4
3415 else
3416         echo "Could not find manual pages in source form." >&4
3417 fi
3418
3419 : see what memory models we can support
3420 case "$models" in
3421 '')
3422         $cat >pdp11.c <<'EOP'
3423 int main() {
3424 #ifdef pdp11
3425         exit(0);
3426 #else
3427         exit(1);
3428 #endif
3429 }
3430 EOP
3431         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3432         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3433                 dflt='unsplit split'
3434         else
3435                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3436                 case "$tans" in
3437                 X) dflt='none';;
3438                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3439                                 dflt='small'
3440                         else
3441                                 dflt=''
3442                         fi
3443                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3444                                 dflt="$dflt medium"
3445                         fi
3446                         if $test -d /lib/large || $test -d /usr/lib/large; then
3447                                 dflt="$dflt large"
3448                         fi
3449                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3450                                 dflt="$dflt huge"
3451                         fi
3452                 esac
3453         fi;;
3454 *) dflt="$models";;
3455 esac
3456 $cat <<EOM
3457  
3458 Some systems have different model sizes.  On most systems they are called
3459 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3460 split.  If your system doesn't support different memory models, say "none".
3461 If you wish to force everything to one memory model, say "none" here and
3462 put the appropriate flags later when it asks you for other cc and ld flags.
3463 Venix systems may wish to put "none" and let the compiler figure things out.
3464 (In the following question multiple model names should be space separated.)
3465
3466 The default for most systems is "none".
3467
3468 EOM
3469 rp="Which memory models are supported?"
3470 . ./myread
3471 models="$ans"
3472
3473 case "$models" in
3474 none)
3475         small=''
3476         medium=''
3477         large=''
3478         huge=''
3479         unsplit=''
3480         split=''
3481         ;;
3482 *split)
3483         case "$split" in
3484         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3485                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3486                         dflt='-i'
3487                 else
3488                         dflt='none'
3489                 fi;;
3490         *) dflt="$split";;
3491         esac
3492         rp="What flag indicates separate I and D space?"
3493         . ./myread
3494         tans="$ans"
3495         case "$tans" in
3496         none) tans='';;
3497         esac
3498         split="$tans"
3499         unsplit='';;
3500 *large*|*small*|*medium*|*huge*)
3501         case "$models" in
3502         *large*)
3503                 case "$large" in
3504                 '') dflt='-Ml';;
3505                 *) dflt="$large";;
3506                 esac
3507         rp="What flag indicates large model?"
3508         . ./myread
3509         tans="$ans"
3510         case "$tans" in
3511         none) tans='';
3512         esac
3513         large="$tans";;
3514         *) large='';;
3515         esac
3516         case "$models" in
3517         *huge*) case "$huge" in
3518                 '') dflt='-Mh';;
3519                 *) dflt="$huge";;
3520                 esac
3521                 rp="What flag indicates huge model?"
3522                 . ./myread
3523                 tans="$ans"
3524                 case "$tans" in
3525                 none) tans='';
3526                 esac
3527                 huge="$tans";;
3528         *) huge="$large";;
3529         esac
3530         case "$models" in
3531         *medium*) case "$medium" in
3532                 '') dflt='-Mm';;
3533                 *) dflt="$medium";;
3534                 esac
3535                 rp="What flag indicates medium model?"
3536                 . ./myread
3537                 tans="$ans"
3538                 case "$tans" in
3539                 none) tans='';
3540                 esac
3541                 medium="$tans";;
3542         *) medium="$large";;
3543         esac
3544         case "$models" in
3545         *small*) case "$small" in
3546                 '') dflt='none';;
3547                 *) dflt="$small";;
3548                 esac
3549                 rp="What flag indicates small model?"
3550                 . ./myread
3551                 tans="$ans"
3552                 case "$tans" in
3553                 none) tans='';
3554                 esac
3555                 small="$tans";;
3556         *) small='';;
3557         esac
3558         ;;
3559 *)
3560         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3561         ;;
3562 esac
3563 $rm -f pdp11.* pdp11
3564
3565 : see if we need a special compiler
3566 echo " "
3567 if ./usg; then
3568         case "$cc" in
3569         '') case "$Mcc" in
3570                 /*) dflt='Mcc';;
3571                 *) case "$large" in
3572                         -M*) dflt='cc';;
3573                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3574                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3575                                                 dflt='cc'
3576                                         else
3577                                                 dflt='cc -M'
3578                                         fi
3579                                 else
3580                                         dflt='cc'
3581                                 fi;;
3582                         esac;;
3583                 esac;;
3584         *)  dflt="$cc";;
3585         esac
3586         case "$dflt" in
3587         *M*)    $cat <<'EOM'
3588 On some older systems the default C compiler will not resolve multiple global
3589 references that happen to have the same name.  On some such systems the "Mcc"
3590 command may be used to force these to be resolved.  On other systems a "cc -M"
3591 command is required.  (Note that the -M flag on other systems indicates a
3592 memory model to use!) If you have the Gnu C compiler, you might wish to use
3593 that instead.
3594
3595 EOM
3596         ;;
3597         esac
3598         rp="Use which C compiler?"
3599         . ./myread
3600         cc="$ans"
3601 else
3602         case "$cc" in
3603         '') dflt=cc;;
3604         *) dflt="$cc";;
3605         esac
3606         rp="Use which C compiler?"
3607         . ./myread
3608         cc="$ans"
3609 fi
3610 : Look for a hint-file generated 'call-back-unit'.  Now that the
3611 : user has specified the compiler, we may need to set or change some
3612 : other defaults.
3613 if $test -f cc.cbu; then
3614     . ./cc.cbu
3615 fi
3616 echo " "
3617 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3618 $cat >gccvers.c <<EOM
3619 #include <stdio.h>
3620 int main() {
3621 #ifdef __GNUC__
3622 #ifdef __VERSION__
3623         printf("%s\n", __VERSION__);
3624 #else
3625         printf("%s\n", "1");
3626 #endif
3627 #endif
3628         exit(0);
3629 }
3630 EOM
3631 if $cc -o gccvers gccvers.c; then
3632         gccversion=`./gccvers`
3633         case "$gccversion" in
3634         '') echo "You are not using GNU cc." ;;
3635         *)  echo "You are using GNU cc $gccversion." ;;
3636         esac
3637 else
3638         echo " "
3639         echo "*** WHOA THERE!!! ***" >&4
3640         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3641         case "$knowitall" in
3642         '')
3643         echo "    You'd better start hunting for one and let me know about it." >&4
3644                 exit 1
3645                 ;;
3646         esac
3647 fi
3648 $rm -f gccvers*
3649 case "$gccversion" in
3650 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3651 esac
3652
3653 : What should the include directory be ?
3654 echo " "
3655 $echo $n "Hmm...  $c"
3656 dflt='/usr/include'
3657 incpath=''
3658 mips_type=''
3659 if $test -f /bin/mips && /bin/mips; then
3660         echo "Looks like a MIPS system..."
3661         $cat >usr.c <<'EOCP'
3662 #ifdef SYSTYPE_BSD43
3663 /bsd43
3664 #endif
3665 EOCP
3666         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3667                 dflt='/bsd43/usr/include'
3668                 incpath='/bsd43'
3669                 mips_type='BSD 4.3'
3670         else
3671                 mips_type='System V'
3672         fi
3673         $rm -f usr.c usr.out
3674         echo "and you're compiling with the $mips_type compiler and libraries."
3675         xxx_prompt=y
3676         echo "exit 0" >mips
3677 else
3678         echo "Doesn't look like a MIPS system."
3679         xxx_prompt=n
3680         echo "exit 1" >mips
3681 fi
3682 chmod +x mips
3683 $eunicefix mips
3684 case "$usrinc" in
3685 '') ;;
3686 *) dflt="$usrinc";;
3687 esac
3688 case "$xxx_prompt" in
3689 y)      fn=d/
3690         echo " "
3691         rp='Where are the include files you want to use?'
3692         . ./getfile
3693         usrinc="$ans"
3694         ;;
3695 *)      usrinc="$dflt"
3696         ;;
3697 esac
3698
3699 : see how we invoke the C preprocessor
3700 echo " "
3701 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3702 cat <<'EOT' >testcpp.c
3703 #define ABC abc
3704 #define XYZ xyz
3705 ABC.XYZ
3706 EOT
3707 cd ..
3708 if test ! -f cppstdin; then
3709         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3710 else
3711         echo "Keeping your $hint cppstdin wrapper."
3712 fi
3713 chmod 755 cppstdin
3714 wrapper=`pwd`/cppstdin
3715 ok='false'
3716 cd UU
3717
3718 if $test "X$cppstdin" != "X" && \
3719         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3720         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3721 then
3722         echo "You used to use $cppstdin $cppminus so we'll use that again."
3723         case "$cpprun" in
3724         '') echo "But let's see if we can live without a wrapper..." ;;
3725         *)
3726                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3727                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3728                 then
3729                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3730                         ok='true'
3731                 else
3732                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3733                 fi
3734                 ;;
3735         esac
3736 else
3737         case "$cppstdin" in
3738         '') ;;
3739         *)
3740                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3741                 ;;
3742         esac
3743 fi
3744
3745 if $ok; then
3746         : nothing
3747 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3748         $cc -E <testcpp.c >testcpp.out 2>&1; \
3749         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3750         echo "Yup, it does."
3751         x_cpp="$cc -E"
3752         x_minus='';
3753 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3754         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3755         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3756         echo "Yup, it does."
3757         x_cpp="$cc -E"
3758         x_minus='-';
3759 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3760         $cc -P <testcpp.c >testcpp.out 2>&1; \
3761         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3762         echo "Yipee, that works!"
3763         x_cpp="$cc -P"
3764         x_minus='';
3765 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3766         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3767         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3768         echo "At long last!"
3769         x_cpp="$cc -P"
3770         x_minus='-';
3771 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3772         $cpp <testcpp.c >testcpp.out 2>&1; \
3773         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3774         echo "It works!"
3775         x_cpp="$cpp"
3776         x_minus='';
3777 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3778         $cpp - <testcpp.c >testcpp.out 2>&1; \
3779         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3780         echo "Hooray, it works!  I was beginning to wonder."
3781         x_cpp="$cpp"
3782         x_minus='-';
3783 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3784         $wrapper <testcpp.c >testcpp.out 2>&1; \
3785         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3786         x_cpp="$wrapper"
3787         x_minus=''
3788         echo "Eureka!"
3789 else
3790         dflt=''
3791         rp="No dice.  I can't find a C preprocessor.  Name one:"
3792         . ./myread
3793         x_cpp="$ans"
3794         x_minus=''
3795         $x_cpp <testcpp.c >testcpp.out 2>&1
3796         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3797                 echo "OK, that will do." >&4
3798         else
3799 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3800                 exit 1
3801         fi
3802 fi
3803
3804 case "$ok" in
3805 false)
3806         cppstdin="$x_cpp"
3807         cppminus="$x_minus"
3808         cpprun="$x_cpp"
3809         cpplast="$x_minus"
3810         set X $x_cpp
3811         shift
3812         case "$1" in
3813         "$cpp")
3814                 echo "Perhaps can we force $cc -E using a wrapper..."
3815                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3816                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3817                 then
3818                         echo "Yup, we can."
3819                         cppstdin="$wrapper"
3820                         cppminus='';
3821                 else
3822                         echo "Nope, we'll have to live without it..."
3823                 fi
3824                 ;;
3825         esac
3826         case "$cpprun" in
3827         "$wrapper")
3828                 cpprun=''
3829                 cpplast=''
3830                 ;;
3831         esac
3832         ;;
3833 esac
3834
3835 case "$cppstdin" in
3836 "$wrapper"|'cppstdin') ;;
3837 *) $rm -f $wrapper;;
3838 esac
3839 $rm -f testcpp.c testcpp.out
3840
3841 : Set private lib path
3842 case "$plibpth" in
3843 '') if ./mips; then
3844                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3845         fi;;
3846 esac
3847 case "$libpth" in
3848 ' ') dlist='';;
3849 '') dlist="$loclibpth $plibpth $glibpth";;
3850 *) dlist="$libpth";;
3851 esac
3852
3853 : Now check and see which directories actually exist, avoiding duplicates
3854 libpth=''
3855 for xxx in $dlist
3856 do
3857     if $test -d $xxx; then
3858                 case " $libpth " in
3859                 *" $xxx "*) ;;
3860                 *) libpth="$libpth $xxx";;
3861                 esac
3862     fi
3863 done
3864 $cat <<'EOM'
3865
3866 Some systems have incompatible or broken versions of libraries.  Among
3867 the directories listed in the question below, please remove any you
3868 know not to be holding relevant libraries, and add any that are needed.
3869 Say "none" for none.
3870
3871 EOM
3872 case "$libpth" in
3873 '') dflt='none';;
3874 *)
3875         set X $libpth
3876         shift
3877         dflt=${1+"$@"}
3878         ;;
3879 esac
3880 rp="Directories to use for library searches?"
3881 . ./myread
3882 case "$ans" in
3883 none) libpth=' ';;
3884 *) libpth="$ans";;
3885 esac
3886
3887 : compute shared library extension
3888 case "$so" in
3889 '')
3890         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3891                 dflt='sl'
3892         else
3893                 dflt='so'
3894         fi
3895         ;;
3896 *) dflt="$so";;
3897 esac
3898 $cat <<EOM
3899
3900 On some systems, shared libraries may be available.  Answer 'none' if
3901 you want to suppress searching of shared libraries for the remaining
3902 of this configuration.
3903
3904 EOM
3905 rp='What is the file extension used for shared libraries?'
3906 . ./myread
3907 so="$ans"
3908
3909 : Define several unixisms.
3910 : Hints files or command line option can be used to override them.
3911 : The convoluted testing is in case hints files set either the old
3912 : or the new name.
3913 case "$_exe" in
3914 '')     case "$exe_ext" in
3915     '') ;;
3916         *)      _exe="$exe_ext" ;;
3917         esac
3918         ;;
3919 esac
3920 case "$_a" in
3921 '')     case "$lib_ext" in
3922     '') _a='.a';;
3923         *)      _a="$lib_ext" ;;
3924         esac
3925         ;;
3926 esac
3927 case "$_o" in
3928 '') case "$obj_ext" in
3929         '')     _o='.o';;
3930         *)      _o="$obj_ext";;
3931         esac
3932         ;;
3933 esac
3934 case "$p_" in
3935 '') case "$path_sep" in
3936         '')     p_=':';;
3937         *)      p_="$path_sep";;
3938         esac
3939         ;;
3940 esac
3941 exe_ext=$_exe
3942 lib_ext=$_a
3943 obj_ext=$_o
3944 path_sep=$p_
3945
3946 : Which makefile gets called first.  This is used by make depend.
3947 case "$firstmakefile" in
3948 '') firstmakefile='makefile';;
3949 esac
3950
3951 cat <<EOM
3952
3953 Perl can be built to use the SOCKS proxy protocol library.  To do so,
3954 Configure must be run with -Dusesocks.
3955
3956 Normally you do not need this and you should answer no.
3957
3958 EOM
3959 case "$usesocks" in
3960 $define|true|[yY]*)     dflt='y';;
3961 *) dflt='n';;
3962 esac
3963 rp='Build Perl for SOCKS?'
3964 . ./myread
3965 case "$ans" in
3966 y|Y)    val="$define" ;;     
3967 *)      val="$undef" ;;
3968 esac
3969 set usesocks
3970 eval $setvar
3971
3972 : Looking for optional libraries
3973 echo " "
3974 echo "Checking for optional libraries..." >&4
3975 case "$libs" in
3976 ' '|'') dflt='';;
3977 *) dflt="$libs";;
3978 esac
3979 case "$libswanted" in
3980 '') libswanted='c_s';;
3981 esac
3982 case "$usesocks" in
3983 $define)
3984         libswanted="$libswanted socks5 socks5_sh"
3985         ;;
3986 esac
3987 for thislib in $libswanted; do
3988         
3989         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3990                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3991                 echo "Found -l$thislib (shared)."
3992                 case " $dflt " in
3993                 *"-l$thislib "*);;
3994                 *) dflt="$dflt -l$thislib";;
3995                 esac
3996         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3997                 echo "Found -l$thislib (shared)."
3998                 case " $dflt " in
3999                 *"-l$thislib "*);;
4000                 *) dflt="$dflt -l$thislib";;
4001                 esac
4002         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
4003                 echo "Found -l$thislib."
4004                 case " $dflt " in
4005                 *"-l$thislib "*);;
4006                 *) dflt="$dflt -l$thislib";;
4007                 esac
4008         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
4009                 echo "Found -l$thislib."
4010                 case " $dflt " in
4011                 *"-l$thislib "*);;
4012                 *) dflt="$dflt -l$thislib";;
4013                 esac
4014         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
4015                 echo "Found -l${thislib}_s."
4016                 case " $dflt " in
4017                 *"-l$thislib "*);;
4018                 *) dflt="$dflt -l${thislib}_s";;
4019                 esac
4020         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
4021                 echo "Found -l$thislib."
4022                 case " $dflt " in
4023                 *"-l$thislib "*);;
4024                 *) dflt="$dflt -l$thislib";;
4025                 esac
4026         else
4027                 echo "No -l$thislib."
4028         fi
4029 done
4030 set X $dflt
4031 shift
4032 dflt="$*"
4033 case "$libs" in
4034 '') dflt="$dflt";;
4035 *) dflt="$libs";;
4036 esac
4037 case "$dflt" in
4038 ' '|'') dflt='none';;
4039 esac
4040
4041 $cat <<EOM
4042
4043 In order to compile $package on your machine, a number of libraries
4044 are usually needed.  Include any other special libraries here as well.
4045 Say "none" for none.  The default list is almost always right.
4046 EOM
4047
4048 echo " "
4049 rp="What libraries to use?"
4050 . ./myread
4051 case "$ans" in
4052 none) libs=' ';;
4053 *) libs="$ans";;
4054 esac
4055
4056 : determine optimize, if desired, or use for debug flag also
4057 case "$optimize" in
4058 ' '|$undef) dflt='none';;
4059 '') dflt='-O';;
4060 *) dflt="$optimize";;
4061 esac
4062 $cat <<EOH
4063
4064 Some C compilers have problems with their optimizers.  By default, $package
4065 compiles with the -O flag to use the optimizer.  Alternately, you might want
4066 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4067 systems).  Either flag can be specified here.  To use neither flag, specify
4068 the word "none".
4069
4070 EOH
4071 rp="What optimizer/debugger flag should be used?"
4072 . ./myread
4073 optimize="$ans"
4074 case "$optimize" in
4075 'none') optimize=" ";;
4076 esac
4077
4078 dflt=''
4079 : We will not override a previous value, but we might want to
4080 : augment a hint file
4081 case "$hint" in
4082 none|recommended)
4083         case "$gccversion" in
4084         1*) dflt='-fpcc-struct-return' ;;
4085         esac
4086         case "$optimize" in
4087         *-g*) dflt="$dflt -DDEBUGGING";;
4088         esac
4089         case "$gccversion" in
4090         2*) if test -d /etc/conf/kconfig.d &&
4091                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4092                 then
4093                         dflt="$dflt -posix"
4094                 fi
4095                 ;;
4096         esac
4097         ;;
4098 esac
4099
4100 case "$mips_type" in
4101 *BSD*|'') inclwanted="$locincpth $usrinc";;
4102 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4103 esac
4104 for thisincl in $inclwanted; do
4105         if $test -d $thisincl; then
4106                 if $test x$thisincl != x$usrinc; then
4107                         case "$dflt" in
4108                         *$thisincl*);;
4109                         *) dflt="$dflt -I$thisincl";;
4110                         esac
4111                 fi
4112         fi
4113 done
4114
4115 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4116         xxx=true;
4117 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4118         xxx=true;
4119 else
4120         xxx=false;
4121 fi;
4122 if $xxx; then
4123         case "$dflt" in
4124         *$2*);;
4125         *) dflt="$dflt -D$2";;
4126         esac;
4127 fi'
4128
4129 set signal.h LANGUAGE_C; eval $inctest
4130
4131 case "$usesocks" in
4132 $define)
4133         ccflags="$ccflags -DSOCKS"
4134         ;;
4135 esac
4136
4137 case "$hint" in
4138 none|recommended) dflt="$ccflags $dflt" ;;
4139 *) dflt="$ccflags";;
4140 esac
4141
4142 case "$dflt" in
4143 ''|' ') dflt=none;;
4144 esac
4145 $cat <<EOH
4146
4147 Your C compiler may want other flags.  For this question you should include
4148 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4149 but you should NOT include libraries or ld flags like -lwhatever.  If you
4150 want $package to honor its debug switch, you should include -DDEBUGGING here.
4151 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4152
4153 To use no flags, specify the word "none".
4154
4155 EOH
4156 set X $dflt
4157 shift
4158 dflt=${1+"$@"}
4159 rp="Any additional cc flags?"
4160 . ./myread
4161 case "$ans" in
4162 none) ccflags='';;
4163 *) ccflags="$ans";;
4164 esac
4165
4166 : the following weeds options from ccflags that are of no interest to cpp
4167 cppflags="$ccflags"
4168 case "$gccversion" in
4169 1*) cppflags="$cppflags -D__GNUC__"
4170 esac
4171 case "$mips_type" in
4172 '');;
4173 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4174 esac
4175 case "$cppflags" in
4176 '');;
4177 *)
4178         echo " "
4179         echo "Let me guess what the preprocessor flags are..." >&4
4180         set X $cppflags
4181         shift
4182         cppflags=''
4183         $cat >cpp.c <<'EOM'
4184 #define BLURFL foo
4185
4186 BLURFL xx LFRULB
4187 EOM
4188         previous=''
4189         for flag in $*
4190         do
4191                 case "$flag" in
4192                 -*) ftry="$flag";;
4193                 *) ftry="$previous $flag";;
4194                 esac
4195                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4196                         >cpp1.out 2>/dev/null && \
4197                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4198                         >cpp2.out 2>/dev/null && \
4199                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4200                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4201                 then
4202                         cppflags="$cppflags $ftry"
4203                         previous=''
4204                 else
4205                         previous="$flag"
4206                 fi
4207         done
4208         set X $cppflags
4209         shift
4210         cppflags=${1+"$@"}
4211         case "$cppflags" in
4212         *-*)  echo "They appear to be: $cppflags";;
4213         esac
4214         $rm -f cpp.c cpp?.out
4215         ;;
4216 esac
4217
4218 : flags used in final linking phase
4219 case "$ldflags" in
4220 '') if ./venix; then
4221                 dflt='-i -z'
4222         else
4223                 dflt=''
4224         fi
4225         case "$ccflags" in
4226         *-posix*) dflt="$dflt -posix" ;;
4227         esac
4228         ;;
4229 *) dflt="$ldflags";;
4230 esac
4231
4232 : Try to guess additional flags to pick up local libraries.
4233 for thislibdir in $libpth; do
4234         case " $loclibpth " in
4235         *" $thislibdir "*)
4236                 case "$dflt " in 
4237                 *"-L$thislibdir "*) ;;
4238                 *)  dflt="$dflt -L$thislibdir" ;;
4239                 esac
4240                 ;;
4241         esac
4242 done
4243
4244 case "$dflt" in
4245 '') dflt='none' ;;
4246 esac
4247
4248 $cat <<EOH
4249
4250 Your C linker may need flags.  For this question you should
4251 include -L/whatever and any other flags used by the C linker, but you
4252 should NOT include libraries like -lwhatever.
4253
4254 Make sure you include the appropriate -L/path flags if your C linker
4255 does not normally search all of the directories you specified above,
4256 namely
4257         $libpth
4258 To use no flags, specify the word "none".
4259
4260 EOH
4261
4262 rp="Any additional ld flags (NOT including libraries)?"
4263 . ./myread
4264 case "$ans" in
4265 none) ldflags='';;
4266 *) ldflags="$ans";;
4267 esac
4268 rmlist="$rmlist pdp11"
4269
4270 : coherency check
4271 echo " "
4272 echo "Checking your choice of C compiler and flags for coherency..." >&4
4273 $cat > try.c <<'EOF'
4274 #include <stdio.h>
4275 int main() { printf("Ok\n"); exit(0); }
4276 EOF
4277 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4278 shift
4279 $cat >try.msg <<'EOM'
4280 I've tried to compile and run the following simple program:
4281
4282 EOM
4283 $cat try.c >> try.msg
4284
4285 $cat >> try.msg <<EOM
4286
4287 I used the command:
4288
4289         $*
4290         ./try
4291
4292 and I got the following output:
4293
4294 EOM
4295 dflt=y
4296 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4297         if sh -c './try' >>try.msg 2>&1; then
4298                 xxx=`./try`
4299                 case "$xxx" in
4300                 "Ok") dflt=n ;;
4301                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4302                         case " $libs " in
4303                         *" -lsfio "*)
4304                                 cat >> try.msg <<'EOQS'
4305 If $libs contains -lsfio, and sfio is mis-configured, then it
4306 sometimes (apparently) runs and exits with a 0 status, but with no
4307 output!  It may have to do with sfio's use of _exit vs. exit.
4308
4309 EOQS
4310                                 rp="You have a big problem.  Shall I abort Configure"
4311                                 dflt=y
4312                                 ;;
4313                         esac
4314                         ;;
4315                 esac
4316         else
4317                 echo "The program compiled OK, but exited with status $?." >>try.msg
4318                 rp="You have a problem.  Shall I abort Configure"
4319                 dflt=y
4320         fi
4321 else
4322         echo "I can't compile the test program." >>try.msg
4323         rp="You have a BIG problem.  Shall I abort Configure"
4324         dflt=y
4325 fi
4326 case "$dflt" in
4327 y)
4328         $cat try.msg >&4
4329         case "$knowitall" in
4330         '')
4331                 echo "(The supplied flags or libraries might be incorrect.)"
4332                 ;;
4333         *) dflt=n;;
4334         esac
4335         echo " "
4336         . ./myread
4337         case "$ans" in
4338         n*|N*) ;;
4339         *)      echo "Ok.  Stopping Configure." >&4
4340                 exit 1
4341                 ;;
4342         esac
4343         ;;
4344 n) echo "OK, that should do.";;
4345 esac
4346 $rm -f try try.* core
4347
4348 : determine filename position in cpp output
4349 echo " "
4350 echo "Computing filename position in cpp output for #include directives..." >&4
4351 echo '#include <stdio.h>' > foo.c
4352 $cat >fieldn <<EOF
4353 $startsh
4354 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4355 $grep '^[       ]*#.*stdio\.h' | \
4356 while read cline; do
4357         pos=1
4358         set \$cline
4359         while $test \$# -gt 0; do
4360                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4361                         echo "\$pos"
4362                         exit 0
4363                 fi
4364                 shift
4365                 pos=\`expr \$pos + 1\`
4366         done
4367 done
4368 EOF
4369 chmod +x fieldn
4370 fieldn=`./fieldn`
4371 $rm -f foo.c fieldn
4372 case $fieldn in
4373 '') pos='???';;
4374 1) pos=first;;
4375 2) pos=second;;
4376 3) pos=third;;
4377 *) pos="${fieldn}th";;
4378 esac
4379 echo "Your cpp writes the filename in the $pos field of the line."
4380
4381 : locate header file
4382 $cat >findhdr <<EOF
4383 $startsh
4384 wanted=\$1
4385 name=''
4386 for usrincdir in $usrinc
4387 do
4388         if test -f \$usrincdir/\$wanted; then
4389                 echo "\$usrincdir/\$wanted"
4390                 exit 0
4391         fi
4392 done
4393 awkprg='{ print \$$fieldn }'
4394 echo "#include <\$wanted>" > foo\$\$.c
4395 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4396 $grep "^[       ]*#.*\$wanted" | \
4397 while read cline; do
4398         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4399         case "\$name" in
4400         *[/\\\\]\$wanted) echo "\$name"; exit 0;;
4401         *[\\\\/]\$wanted) echo "\$name"; exit 0;;
4402         *) name='';;
4403         esac;
4404 done;
4405 $rm -f foo\$\$.c;
4406 case "\$name" in
4407 '') exit 1;;
4408 esac
4409 EOF
4410 chmod +x findhdr
4411
4412 : define an alternate in-header-list? function
4413 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4414 cont=true; xxf="echo \"<\$1> found.\" >&4";
4415 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4416 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4417 esac;
4418 case $# in 4) instead=instead;; *) instead="at last";; esac;
4419 while $test "$cont"; do
4420         xxx=`./findhdr $1`
4421         var=$2; eval "was=\$$2";
4422         if $test "$xxx" && $test -r "$xxx";
4423         then eval $xxf;
4424         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4425                 cont="";
4426         else eval $xxnf;
4427         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4428         set $yyy; shift; shift; yyy=$@;
4429         case $# in 0) cont="";;
4430         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4431                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4432         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4433                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4434         esac;
4435 done;
4436 while $test "$yyy";
4437 do set $yyy; var=$2; eval "was=\$$2";
4438         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4439         set $yyy; shift; shift; yyy=$@;
4440 done'
4441
4442 : see if this is a malloc.h system
4443 set malloc.h i_malloc
4444 eval $inhdr
4445
4446 : see if stdlib is available
4447 set stdlib.h i_stdlib
4448 eval $inhdr
4449
4450 : determine which malloc to compile in
4451 echo " "
4452 case "$usemymalloc" in
4453 ''|[yY]*|true|$define)  dflt='y' ;;
4454 *)      dflt='n' ;;
4455 esac
4456 rp="Do you wish to attempt to use the malloc that comes with $package?"
4457 . ./myread
4458 usemymalloc="$ans"
4459 case "$ans" in
4460 y*|true)
4461         usemymalloc='y'
4462         mallocsrc='malloc.c'
4463         mallocobj="malloc$_o"
4464         d_mymalloc="$define"
4465         case "$libs" in
4466         *-lmalloc*)
4467                 : Remove malloc from list of libraries to use
4468                 echo "Removing unneeded -lmalloc from library list" >&4
4469                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4470                 shift
4471                 libs="$*"
4472                 echo "libs = $libs" >&4
4473                 ;;
4474         esac
4475         ;;
4476 *)
4477         usemymalloc='n'
4478         mallocsrc=''
4479         mallocobj=''
4480         d_mymalloc="$undef"
4481         ;;
4482 esac
4483
4484 : compute the return types of malloc and free
4485 echo " "
4486 $cat >malloc.c <<END
4487 #$i_malloc I_MALLOC
4488 #$i_stdlib I_STDLIB
4489 #include <stdio.h>
4490 #include <sys/types.h>
4491 #ifdef I_MALLOC
4492 #include <malloc.h>
4493 #endif
4494 #ifdef I_STDLIB
4495 #include <stdlib.h>
4496 #endif
4497 #ifdef TRY_MALLOC
4498 void *malloc();
4499 #endif
4500 #ifdef TRY_FREE
4501 void free();
4502 #endif
4503 END
4504 case "$malloctype" in
4505 '')
4506         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4507                 malloctype='void *'
4508         else
4509                 malloctype='char *'
4510         fi
4511         ;;
4512 esac
4513 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4514
4515 case "$freetype" in
4516 '')
4517         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4518                 freetype='void'
4519         else
4520                 freetype='int'
4521         fi
4522         ;;
4523 esac
4524 echo "Your system uses $freetype free(), it would seem." >&4
4525 $rm -f malloc.[co]
4526 : Cruising for prototypes
4527 echo " "
4528 echo "Checking out function prototypes..." >&4
4529 $cat >prototype.c <<'EOCP'
4530 int main(int argc, char *argv[]) {
4531         exit(0);}
4532 EOCP
4533 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4534         echo "Your C compiler appears to support function prototypes."
4535         val="$define"
4536 else
4537         echo "Your C compiler doesn't seem to understand function prototypes."
4538         val="$undef"
4539 fi
4540 set prototype
4541 eval $setvar
4542 $rm -f prototype*
4543
4544 case "$prototype" in
4545 "$define") ;;
4546 *)      ansi2knr='ansi2knr'
4547         echo " "
4548         cat <<EOM >&4
4549
4550 $me:  FATAL ERROR:
4551 This version of $package can only be compiled by a compiler that 
4552 understands function prototypes.  Unfortunately, your C compiler 
4553         $cc $ccflags
4554 doesn't seem to understand them.  Sorry about that.
4555
4556 If GNU cc is available for your system, perhaps you could try that instead.  
4557
4558 Eventually, we hope to support building Perl with pre-ANSI compilers.
4559 If you would like to help in that effort, please contact <perlbug@perl.org>.
4560
4561 Aborting Configure now.
4562 EOM
4563         exit 2
4564         ;;
4565 esac
4566
4567 : determine where public executables go
4568 echo " "
4569 set dflt bin bin
4570 eval $prefixit
4571 fn=d~
4572 rp='Pathname where the public executables will reside?'
4573 . ./getfile
4574 if $test "X$ansexp" != "X$binexp"; then
4575         installbin=''
4576 fi
4577 bin="$ans"
4578 binexp="$ansexp"
4579 if $afs; then
4580         $cat <<EOM
4581
4582 Since you are running AFS, I need to distinguish the directory in which
4583 executables reside from the directory in which they are installed (and from
4584 which they are presumably copied to the former directory by occult means).
4585
4586 EOM
4587         case "$installbin" in
4588         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4589         *) dflt="$installbin";;
4590         esac
4591         fn=de~
4592         rp='Where will public executables be installed?'
4593         . ./getfile
4594         installbin="$ans"
4595 else
4596         installbin="$binexp"
4597 fi
4598
4599 : determine whether to install perl also as /usr/bin/perl
4600
4601 echo " "
4602 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4603         $cat <<EOM
4604 Many scripts expect to perl to be installed as /usr/bin/perl.
4605 I can install the perl you are about to compile also as /usr/bin/perl
4606 (in addition to $installbin/perl).
4607 EOM
4608         case "$installusrbinperl" in
4609         "$undef"|[nN]*) dflt='n';;
4610         *)              dflt='y';;
4611         esac
4612         rp="Do you want to install perl as /usr/bin/perl?"
4613         . ./myread
4614         case "$ans" in
4615         [yY]*)  val="$define";;
4616         *)      val="$undef" ;;
4617         esac
4618 else
4619         val="$undef"
4620 fi
4621 set installusrbinperl
4622 eval $setvar
4623
4624 : define a shorthand compile call
4625 compile='
4626 mc_file=$1;
4627 shift;
4628 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4629 : define a shorthand compile call for compilations that should be ok.
4630 compile_ok='
4631 mc_file=$1;
4632 shift;
4633 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4634
4635 echo " "
4636 echo "Checking for GNU C Library..." >&4
4637 cat >gnulibc.c <<EOM
4638 #include <stdio.h>
4639 int main()
4640 {
4641 #ifdef __GLIBC__
4642     exit(0);
4643 #else
4644     exit(1);
4645 #endif
4646 }
4647 EOM
4648 set gnulibc
4649 if eval $compile_ok && ./gnulibc; then
4650         val="$define"
4651         echo "You are using the GNU C Library"
4652 else
4653         val="$undef"
4654         echo "You are not using the GNU C Library"
4655 fi
4656 $rm -f gnulibc*
4657 set d_gnulibc
4658 eval $setvar
4659
4660 : see if nm is to be used to determine whether a symbol is defined or not
4661 case "$usenm" in
4662 '')
4663         dflt=''
4664         case "$d_gnulibc" in
4665         "$define")
4666                 echo " "
4667                 echo "nm probably won't work on the GNU C Library." >&4
4668                 dflt=n
4669                 ;;
4670         esac
4671         case "$dflt" in
4672         '') 
4673                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4674                         echo " "
4675                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4676                         echo "'nm' won't be sufficient on this sytem." >&4
4677                         dflt=n
4678                 fi
4679                 ;;
4680         esac
4681         case "$dflt" in
4682         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4683                 if $test $dflt -gt 20; then
4684                         dflt=y
4685                 else
4686                         dflt=n
4687                 fi
4688                 ;;
4689         esac
4690         ;;
4691 *)
4692         case "$usenm" in
4693         true|$define) dflt=y;;
4694         *) dflt=n;;
4695         esac
4696         ;;
4697 esac
4698 $cat <<EOM
4699
4700 I can use $nm to extract the symbols from your C libraries. This
4701 is a time consuming task which may generate huge output on the disk (up
4702 to 3 megabytes) but that should make the symbols extraction faster. The
4703 alternative is to skip the 'nm' extraction part and to compile a small
4704 test program instead to determine whether each symbol is present. If
4705 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4706 this may be the best solution.
4707
4708 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4709
4710 EOM
4711 rp="Shall I use $nm to extract C symbols from the libraries?"
4712 . ./myread
4713 case "$ans" in
4714 [Nn]*) usenm=false;;
4715 *) usenm=true;;
4716 esac
4717
4718 runnm=$usenm
4719 case "$reuseval" in
4720 true) runnm=false;;
4721 esac
4722
4723 : nm options which may be necessary
4724 case "$nm_opt" in
4725 '') if $test -f /mach_boot; then
4726                 nm_opt=''       # Mach
4727         elif $test -d /usr/ccs/lib; then
4728                 nm_opt='-p'     # Solaris (and SunOS?)
4729         elif $test -f /dgux; then
4730                 nm_opt='-p'     # DG-UX
4731         elif $test -f /lib64/rld; then
4732                 nm_opt='-p'     # 64-bit Irix
4733         else
4734                 nm_opt=''
4735         fi;;
4736 esac
4737
4738 : nm options which may be necessary for shared libraries but illegal
4739 : for archive libraries.  Thank you, Linux.
4740 case "$nm_so_opt" in
4741 '')     case "$myuname" in
4742         *linux*)
4743                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4744                         nm_so_opt='--dynamic'
4745                 fi
4746                 ;;
4747         esac
4748         ;;
4749 esac
4750
4751 case "$runnm" in
4752 true)
4753 : get list of predefined functions in a handy place
4754 echo " "
4755 case "$libc" in
4756 '') libc=unknown
4757         case "$libs" in
4758         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4759         esac
4760         ;;
4761 esac
4762 libnames='';
4763 case "$libs" in
4764 '') ;;
4765 *)  for thislib in $libs; do
4766         case "$thislib" in
4767         -lc|-lc_s)
4768                 : Handle C library specially below.
4769                 ;;
4770         -l*)
4771                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4772                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4773                         :
4774                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4775                         :
4776                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4777                         :
4778                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4779                         :
4780                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4781                         :
4782                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4783                         :
4784                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4785                         :
4786                 else
4787                         try=''
4788                 fi
4789                 libnames="$libnames $try"
4790                 ;;
4791         *) libnames="$libnames $thislib" ;;
4792         esac
4793         done
4794         ;;
4795 esac
4796 xxx=normal
4797 case "$libc" in
4798 unknown)
4799         set /lib/libc.$so
4800         for xxx in $libpth; do
4801                 $test -r $1 || set $xxx/libc.$so
4802                 : The messy sed command sorts on library version numbers.
4803                 $test -r $1 || \
4804                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4805                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4806                                 h
4807                                 s/[0-9][0-9]*/0000&/g
4808                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4809                                 G
4810                                 s/\n/ /' | \
4811                          sort | $sed -e 's/^.* //'`
4812                 eval set \$$#
4813         done
4814         $test -r $1 || set /usr/ccs/lib/libc.$so
4815         $test -r $1 || set /lib/libsys_s$_a
4816         ;;
4817 *)
4818         set blurfl
4819         ;;
4820 esac
4821 if $test -r "$1"; then
4822         echo "Your (shared) C library seems to be in $1."
4823         libc="$1"
4824 elif $test -r /lib/libc && $test -r /lib/clib; then
4825         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4826         xxx=apollo
4827         libc='/lib/clib /lib/libc'
4828         if $test -r /lib/syslib; then
4829                 echo "(Your math library is in /lib/syslib.)"
4830                 libc="$libc /lib/syslib"
4831         fi
4832 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4833         echo "Your C library seems to be in $libc, as you said before."
4834 elif $test -r $incpath/usr/lib/libc$_a; then
4835         libc=$incpath/usr/lib/libc$_a;
4836         echo "Your C library seems to be in $libc.  That's fine."
4837 elif $test -r /lib/libc$_a; then
4838         libc=/lib/libc$_a;
4839         echo "Your C library seems to be in $libc.  You're normal."
4840 else
4841         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4842                 :
4843         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4844                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4845         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4846                 :
4847         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4848                 :
4849         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4850                 :
4851         else
4852                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4853         fi
4854         if $test -r "$tans"; then
4855                 echo "Your C library seems to be in $tans, of all places."
4856                 libc=$tans
4857         else
4858                 libc='blurfl'
4859         fi
4860 fi
4861 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4862         dflt="$libc"
4863         cat <<EOM
4864
4865 If the guess above is wrong (which it might be if you're using a strange
4866 compiler, or your machine supports multiple models), you can override it here.
4867
4868 EOM
4869 else
4870         dflt=''
4871         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4872         cat >&4 <<EOM
4873 I can't seem to find your C library.  I've looked in the following places:
4874
4875 EOM
4876         $sed 's/^/      /' libpath
4877         cat <<EOM
4878
4879 None of these seems to contain your C library. I need to get its name...
4880
4881 EOM
4882 fi
4883 fn=f
4884 rp='Where is your C library?'
4885 . ./getfile
4886 libc="$ans"
4887
4888 echo " "
4889 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4890 set X `cat libnames`
4891 shift
4892 xxx=files
4893 case $# in 1) xxx=file; esac
4894 echo "Extracting names from the following $xxx for later perusal:" >&4
4895 echo " "
4896 $sed 's/^/      /' libnames >&4
4897 echo " "
4898 $echo $n "This may take a while...$c" >&4
4899
4900 for file in $*; do
4901         case $file in
4902         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4903         *) $nm $nm_opt $file 2>/dev/null;;
4904         esac
4905 done >libc.tmp
4906
4907 $echo $n ".$c"
4908 $grep fprintf libc.tmp > libc.ptf
4909 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4910 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4911 xxx='[ADTSIW]'
4912 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4913         eval $xscan;\
4914         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4915                 eval $xrun
4916 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4917         eval $xscan;\
4918         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4919                 eval $xrun
4920 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4921         eval $xscan;\
4922         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4923                 eval $xrun
4924 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4925         eval $xscan;\
4926         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4927                 eval $xrun
4928 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4929         eval $xscan;\
4930         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4931                 eval $xrun
4932 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4933         eval $xscan;\
4934         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4935                 eval $xrun
4936 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4937                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4938         eval $xscan;\
4939         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4940                 eval $xrun
4941 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4942         eval $xscan;\
4943         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4944                 eval $xrun
4945 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4946         eval $xscan;\
4947         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4948                 eval $xrun
4949 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4950         eval $xscan;\
4951         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4952                 eval $xrun
4953 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4954         eval $xscan;\
4955         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4956                 eval $xrun
4957 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4958         eval $xscan;\
4959         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4960                 eval $xrun
4961 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4962         eval $xscan;\
4963         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4964                 eval $xrun
4965 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4966         eval $xscan;\
4967         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4968                 eval $xrun
4969 else
4970         $nm -p $* 2>/dev/null >libc.tmp
4971         $grep fprintf libc.tmp > libc.ptf
4972         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4973                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4974         then
4975                 nm_opt='-p'
4976                 eval $xrun
4977         else
4978                 echo " "
4979                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4980                 com=''
4981                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4982                         for thisname in $libnames $libc; do
4983                                 $ar t $thisname >>libc.tmp
4984                         done
4985                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4986                         echo "Ok." >&4
4987                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4988                         # Repeat libc to extract forwarders to DLL entries too
4989                         for thisname in $libnames $libc; do
4990                                 $ar tv $thisname >>libc.tmp
4991                                 # Revision 50 of EMX has bug in $ar.
4992                                 # it will not extract forwarders to DLL entries
4993                                 # Use emximp which will extract exactly them.
4994                                 emximp -o tmp.imp $thisname \
4995                                     2>/dev/null && \
4996                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4997                                     < tmp.imp >>libc.tmp
4998                                 $rm tmp.imp
4999                         done
5000                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
5001                         echo "Ok." >&4
5002                 else
5003                         echo "$ar didn't seem to work right." >&4
5004                         echo "Maybe this is a Cray...trying bld instead..." >&4
5005                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
5006                         then
5007                                 for thisname in $libnames; do
5008                                         bld t $libnames | \
5009                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
5010                                         $ar t $thisname >>libc.tmp
5011                                 done
5012                                 echo "Ok." >&4
5013                         else
5014                                 echo "That didn't work either.  Giving up." >&4
5015                                 exit 1
5016                         fi
5017                 fi
5018         fi
5019 fi
5020 nm_extract="$com"
5021 if $test -f /lib/syscalls.exp; then
5022         echo " "
5023         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
5024         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
5025 fi
5026 ;;
5027 esac
5028 $rm -f libnames libpath
5029
5030 : see if dld is available
5031 set dld.h i_dld
5032 eval $inhdr
5033
5034 : is a C symbol defined?
5035 csym='tlook=$1;
5036 case "$3" in
5037 -v) tf=libc.tmp; tc=""; tdc="";;
5038 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5039 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5040 esac;
5041 tx=yes;
5042 case "$reuseval-$4" in
5043 true-) ;;
5044 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5045 esac;
5046 case "$tx" in
5047 yes)
5048         case "$runnm" in
5049         true)
5050                 if $contains $tlook $tf >/dev/null 2>&1;
5051                 then tval=true;
5052                 else tval=false;
5053                 fi;;
5054         *)
5055                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5056                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5057                 then tval=true;
5058                 else tval=false;
5059                 fi;
5060                 $rm -f t t.c;;
5061         esac;;
5062 *)
5063         case "$tval" in
5064         $define) tval=true;;
5065         *) tval=false;;
5066         esac;;
5067 esac;
5068 eval "$2=$tval"'
5069
5070 : define an is-in-libc? function
5071 inlibc='echo " "; td=$define; tu=$undef;
5072 sym=$1; var=$2; eval "was=\$$2";
5073 tx=yes;
5074 case "$reuseval$was" in
5075 true) ;;
5076 true*) tx=no;;
5077 esac;
5078 case "$tx" in
5079 yes)
5080         set $sym tres -f;
5081         eval $csym;
5082         case "$tres" in
5083         true)
5084                 echo "$sym() found." >&4;
5085                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5086         *)
5087                 echo "$sym() NOT found." >&4;
5088                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5089         esac;;
5090 *)
5091         case "$was" in
5092         $define) echo "$sym() found." >&4;;
5093         *) echo "$sym() NOT found." >&4;;
5094         esac;;
5095 esac'
5096
5097 : see if dlopen exists
5098 xxx_runnm="$runnm"
5099 runnm=false
5100 set dlopen d_dlopen
5101 eval $inlibc
5102 runnm="$xxx_runnm"
5103
5104 : determine which dynamic loading, if any, to compile in
5105 echo " "
5106 dldir="ext/DynaLoader"
5107 case "$usedl" in
5108 $define|y|true)
5109         dflt='y'
5110         usedl="$define"
5111         ;;
5112 $undef|n|false)
5113         dflt='n'
5114         usedl="$undef"
5115         ;;
5116 *) 
5117         dflt='n'
5118         case "$d_dlopen" in
5119             $define) dflt='y' ;;
5120         esac
5121         case "$i_dld" in
5122             $define) dflt='y' ;;
5123         esac
5124         : Does a dl_xxx.xs file exist for this operating system
5125         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5126         ;;
5127 esac
5128 rp="Do you wish to use dynamic loading?"
5129 . ./myread
5130 usedl="$ans"
5131 case "$ans" in
5132 y*) usedl="$define"
5133         case "$dlsrc" in
5134         '')
5135                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5136                         dflt="$dldir/dl_${osname}.xs"
5137                 elif $test "$d_dlopen" = "$define" ; then
5138                         dflt="$dldir/dl_dlopen.xs"
5139                 elif $test "$i_dld" = "$define" ; then
5140                         dflt="$dldir/dl_dld.xs"
5141                 else
5142                         dflt=''
5143                 fi
5144                 ;;
5145         *)      dflt="$dldir/$dlsrc"
5146                 ;;
5147         esac
5148     echo "The following dynamic loading files are available:"
5149         : Can not go over to $dldir because getfile has path hard-coded in.
5150         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5151         rp="Source file to use for dynamic loading"
5152         fn="fne"
5153         # XXX This getfile call will fail the existence check if you try 
5154         # building away from $src (this is not supported yet).
5155         . ./getfile
5156         usedl="$define"
5157         : emulate basename
5158         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5159
5160         $cat << EOM
5161
5162 Some systems may require passing special flags to $cc -c to
5163 compile modules that will be used to create a shared library.
5164 To use no flags, say "none".
5165
5166 EOM
5167     case "$cccdlflags" in
5168     '') case "$gccversion" in
5169                 '') case "$osname" in
5170                         hpux)   dflt='+z' ;;
5171                         next)   dflt='none' ;;
5172                         irix*)  dflt='-KPIC' ;;
5173                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5174                         sunos)  dflt='-pic' ;;
5175                         *)      dflt='none' ;;
5176                     esac
5177                         ;;
5178                 *)  case "$osname" in
5179                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5180                         *)      dflt='-fpic' ;;
5181                     esac ;;
5182             esac ;;
5183         ' ') dflt='none' ;;
5184     *)  dflt="$cccdlflags" ;;
5185     esac
5186     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5187     . ./myread
5188     case "$ans" in
5189     none) cccdlflags=' ' ;;
5190     *) cccdlflags="$ans" ;;
5191     esac
5192
5193     cat << EOM
5194
5195 Some systems use ld to create libraries that can be dynamically loaded,
5196 while other systems (such as those using ELF) use $cc.
5197
5198 EOM
5199         case "$ld" in
5200         '')     $cat >try.c <<'EOM'
5201 /* Test for whether ELF binaries are produced */
5202 #include <fcntl.h>
5203 #include <stdlib.h>
5204 int main() {
5205         char b[4];
5206         int i = open("a.out",O_RDONLY);
5207         if(i == -1) 
5208                 exit(1); /* fail */
5209         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5210                 exit(0); /* succeed (yes, it's ELF) */
5211         else
5212                 exit(1); /* fail */
5213 }
5214 EOM
5215                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5216                         cat <<EOM
5217 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5218 EOM
5219                         dflt="$cc"
5220                 else
5221                         echo "I'll use ld to build dynamic libraries."
5222                         dflt='ld'
5223                 fi
5224                 rm -f try.c a.out
5225                 ;;
5226         *)      dflt="$ld"
5227                 ;;
5228         esac
5229
5230     rp="What command should be used to create dynamic libraries?"
5231     . ./myread
5232         ld="$ans"
5233
5234     cat << EOM
5235
5236 Some systems may require passing special flags to $ld to create a
5237 library that can be dynamically loaded.  If your ld flags include
5238 -L/other/path options to locate libraries outside your loader's normal
5239 search path, you may need to specify those -L options here as well.  To
5240 use no flags, say "none".
5241
5242 EOM
5243     case "$lddlflags" in
5244     '') case "$osname" in
5245                         beos) dflt='-nostart' ;;
5246                         hpux)  dflt='-b' ;;
5247                         linux|irix*)    dflt='-shared' ;;
5248                         next)  dflt='none' ;;
5249                         solaris) dflt='-G' ;;
5250                         sunos) dflt='-assert nodefinitions' ;;
5251                         svr4*|esix*) dflt="-G $ldflags" ;;
5252                 *)     dflt='none' ;;
5253                         esac
5254                         ;;
5255     *) dflt="$lddlflags" ;;
5256     esac
5257
5258         : Try to guess additional flags to pick up local libraries.
5259         : Be careful not to append to a plain 'none'
5260         case "$dflt" in
5261         none) dflt='' ;;
5262         esac
5263         for thisflag in $ldflags; do
5264                 case "$thisflag" in
5265                 -L*)
5266                         case " $dflt " in
5267                         *" $thisflag "*) ;;
5268                         *) dflt="$dflt $thisflag" ;;
5269                         esac
5270                         ;;
5271                 esac
5272         done
5273
5274         case "$dflt" in
5275         ''|' ') dflt='none' ;;
5276         esac
5277
5278     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5279     . ./myread
5280     case "$ans" in
5281     none) lddlflags=' ' ;;
5282     *) lddlflags="$ans" ;;
5283     esac
5284
5285         cat <<EOM
5286
5287 Some systems may require passing special flags to $cc to indicate that
5288 the resulting executable will use dynamic linking.  To use no flags,
5289 say "none".
5290
5291 EOM
5292     case "$ccdlflags" in
5293     '') case "$osname" in
5294                 hpux)   dflt='-Wl,-E' ;;
5295                 linux)  dflt='-rdynamic' ;;
5296                 next)   dflt='none' ;;
5297                 sunos)  dflt='none' ;;
5298                 *)      dflt='none' ;;
5299             esac ;;
5300     ' ')  dflt='none' ;;
5301     *)  dflt="$ccdlflags" ;;
5302     esac
5303     rp="Any special flags to pass to $cc to use dynamic loading?"
5304     . ./myread
5305     case "$ans" in
5306     none) ccdlflags=' ' ;;
5307     *) ccdlflags="$ans" ;;
5308     esac
5309     ;;
5310 *)  usedl="$undef"
5311         ld='ld'
5312     dlsrc='dl_none.xs'
5313     lddlflags=''
5314     ccdlflags=''
5315     ;;
5316 esac
5317
5318 also=''
5319 case "$usedl" in
5320 $undef)
5321         # No dynamic loading being used, so don't bother even to prompt.
5322         useshrplib='false'
5323         ;;
5324 *)      case "$useshrplib" in
5325         '')     case "$osname" in
5326                 svr4*|dgux|dynixptx|esix|powerux|beos)
5327                         dflt=y
5328                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5329                         ;;
5330                 next*)
5331                         case "$osvers" in
5332                         4*)     dflt=y
5333                                 also='Building a shared libperl is needed for MAB support.'
5334                                 ;;
5335                         *)      dflt=n
5336                                 ;;
5337                         esac
5338                         ;;
5339                 *)      dflt=n
5340                         ;;
5341                 esac
5342                 ;;
5343         $define|true|[Yy]*)
5344                 dflt=y
5345                 ;;
5346         *)      dflt=n
5347                 ;;
5348         esac
5349         $cat << EOM
5350
5351 The perl executable is normally obtained by linking perlmain.c with
5352 libperl${_a}, any static extensions (usually just DynaLoader), and
5353 any other libraries needed on this system (such as -lm, etc.).  Since
5354 your system supports dynamic loading, it is probably possible to build
5355 a shared libperl.$so.  If you will have more than one executable linked
5356 to libperl.$so, this will significantly reduce the size of each
5357 executable, but it may have a noticeable affect on performance.  The
5358 default is probably sensible for your system.
5359 $also
5360
5361 EOM
5362         rp="Build a shared libperl.$so (y/n)"
5363         . ./myread
5364         case "$ans" in
5365         true|$define|[Yy]*)
5366                 useshrplib='true'
5367                 # Why does next4 have to be so different?
5368                 case "${osname}${osvers}" in
5369                 next4*|rhapsody*)
5370                         xxx='DYLD_LIBRARY_PATH' ;;
5371                 os2*)   xxx='' ;; # Nothing special needed.
5372                 beos*)  xxx='' ;;
5373                 *)              xxx='LD_LIBRARY_PATH' ;;
5374                 esac
5375                 ;;
5376         *)      useshrplib='false' ;;
5377         esac
5378         ;;
5379 esac
5380
5381 case "$useshrplib" in
5382 true)
5383         case "$libperl" in
5384         '')
5385                 # Figure out a good name for libperl.so.  Since it gets stored in
5386                 # a version-specific architecture-dependent library, the version
5387                 # number isn't really that important, except for making cc/ld happy.
5388                 #
5389                 # A name such as libperl.so.3.1
5390                 majmin="libperl.$so.$patchlevel.$subversion"
5391                 # A name such as libperl.so.301
5392                 majonly=`echo $patchlevel $subversion |
5393                         $awk '{printf "%d%02d", $1, $2}'`
5394                 majonly=libperl.$so.$majonly
5395                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5396                 # rely on figuring it out from the naming of libc.
5397                 case "${osname}${osvers}" in
5398                 next4*)
5399                         dflt=libperl.5.$so
5400                         # XXX How handle the --version stuff for MAB?
5401                         ;;
5402                 linux*)  # ld won't link with a bare -lperl otherwise.
5403                         dflt=libperl.$so
5404                         ;;
5405                 *)      # Try to guess based on whether libc has major.minor.
5406                         case "$libc" in
5407                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5408                         *libc.$so.[0-9]*) dflt=$majonly ;;
5409                         *)      dflt=libperl.$so ;;
5410                         esac
5411                         ;;
5412                 esac
5413                 ;;
5414         *)      dflt=$libperl
5415                 ;;
5416         esac
5417         cat << EOM
5418
5419 I need to select a good name for the shared libperl.  If your system uses
5420 library names with major and minor numbers, then you might want something
5421 like $majmin.  Alternatively, if your system uses a single version
5422 number for shared libraries, then you might want to use $majonly.
5423 Or, your system might be quite happy with a simple libperl.$so.
5424
5425 Since the shared libperl will get installed into a version-specific
5426 architecture-dependent directory, the version number of the shared perl
5427 library probably isn't important, so the default should be o.k.
5428
5429 EOM
5430         rp='What name do you want to give to the shared libperl?'
5431         . ./myread
5432         libperl=$ans
5433         echo "Ok, I'll use $libperl"
5434         ;;
5435 *)
5436         libperl="libperl${_a}"
5437         ;;
5438 esac
5439
5440 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5441 case "$shrpdir" in
5442 '') ;;
5443 *)      $cat >&4 <<EOM
5444 WARNING:  Use of the shrpdir variable for the installation location of
5445 the shared $libperl is not supported.  It was never documented and
5446 will not work in this version.  Let me (perlbug@perl.com)
5447 know of any problems this may cause.
5448
5449 EOM
5450         case "$shrpdir" in
5451         "$archlibexp/CORE")
5452                 $cat >&4 <<EOM
5453 But your current setting of $shrpdir is
5454 the default anyway, so it's harmless.
5455 EOM
5456                 ;;
5457         *)
5458                 $cat >&4 <<EOM
5459 Further, your current attempted setting of $shrpdir
5460 conflicts with the value of $archlibexp/CORE
5461 that installperl will use.
5462 EOM
5463                 ;;
5464         esac
5465         ;;
5466 esac
5467
5468 # How will the perl executable find the installed shared $libperl?
5469 # Add $xxx to ccdlflags.
5470 # If we can't figure out a command-line option, use $shrpenv to
5471 # set env LD_RUN_PATH.  The main perl makefile uses this.
5472 shrpdir=$archlibexp/CORE
5473 xxx=''
5474 tmp_shrpenv=''
5475 if "$useshrplib"; then
5476     case "$osname" in 
5477         aix)
5478                 # We'll set it in Makefile.SH...
5479                 ;;
5480         solaris|netbsd)
5481                 xxx="-R $shrpdir"
5482                 ;;
5483         freebsd)
5484                 xxx="-Wl,-R$shrpdir"
5485                 ;;
5486         linux|irix*|dec_osf)
5487                 xxx="-Wl,-rpath,$shrpdir"
5488                 ;;
5489         next)
5490                 # next doesn't like the default...
5491                 ;;
5492         beos)
5493                 # beos doesn't like the default, either.
5494                 ;;
5495         hpux*)
5496                 # hpux doesn't like the default, either.
5497                 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
5498                 ;;
5499         *)
5500                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5501                 ;;
5502         esac
5503         case "$xxx" in
5504         '') ;;
5505         *)      
5506                 # Only add $xxx if it isn't already in ccdlflags.
5507                 case " $ccdlflags " in
5508                 *" $xxx "*)     ;;
5509                 *)      ccdlflags="$ccdlflags $xxx"
5510                         cat <<EOM >&4
5511
5512 Adding $xxx to the flags
5513 passed to $ld so that the perl executable will find the 
5514 installed shared $libperl.
5515
5516 EOM
5517                         ;;
5518                 esac
5519                 ;;
5520         esac
5521 fi
5522 # Respect a hint or command-line value.
5523 case "$shrpenv" in
5524 '') shrpenv="$tmp_shrpenv" ;;
5525 esac
5526
5527 : determine where manual pages go
5528 set man1dir man1dir none
5529 eval $prefixit
5530 $cat <<EOM
5531
5532 $spackage has manual pages available in source form.
5533 EOM
5534 case "$nroff" in
5535 nroff)
5536         echo "However, you don't have nroff, so they're probably useless to you."
5537         case "$man1dir" in
5538         '') man1dir="none";;
5539         esac;;
5540 esac
5541 echo "If you don't want the manual sources installed, answer 'none'."
5542 case "$man1dir" in
5543 ' ') dflt=none
5544         ;;
5545 '')
5546         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5547         lookpath="$lookpath $prefixexp/man/p_man/man1"
5548         lookpath="$lookpath $prefixexp/man/u_man/man1"
5549         lookpath="$lookpath $prefixexp/man/man.1"
5550         case "$sysman" in
5551         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5552         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5553         esac
5554         set dflt
5555         eval $prefixup
5556         ;;
5557 *)  dflt="$man1dir"
5558         ;;
5559 esac
5560 echo " "
5561 fn=dn+~
5562 rp="Where do the main $spackage manual pages (source) go?"
5563 . ./getfile
5564 if $test "X$man1direxp" != "X$ansexp"; then
5565         installman1dir=''
5566 fi
5567 man1dir="$ans"
5568 man1direxp="$ansexp"
5569 case "$man1dir" in
5570 '') man1dir=' '
5571         installman1dir='';;
5572 esac
5573 if $afs; then
5574         $cat <<EOM
5575
5576 Since you are running AFS, I need to distinguish the directory in which
5577 manual pages reside from the directory in which they are installed (and from
5578 which they are presumably copied to the former directory by occult means).
5579
5580 EOM
5581         case "$installman1dir" in
5582         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5583         *) dflt="$installman1dir";;
5584         esac
5585         fn=de~
5586         rp='Where will man pages be installed?'
5587         . ./getfile
5588         installman1dir="$ans"
5589 else
5590         installman1dir="$man1direxp"
5591 fi
5592
5593 : What suffix to use on installed man pages
5594
5595 case "$man1dir" in
5596 ' ')
5597         man1ext='0'
5598         ;;
5599 *)
5600         rp="What suffix should be used for the main $spackage man pages?"
5601         case "$man1ext" in
5602         '')     case "$man1dir" in
5603                 *1)  dflt=1 ;;
5604                 *1p) dflt=1p ;;
5605                 *1pm) dflt=1pm ;;
5606                 *l) dflt=l;;
5607                 *n) dflt=n;;
5608                 *o) dflt=o;;
5609                 *p) dflt=p;;
5610                 *C) dflt=C;;
5611                 *L) dflt=L;;
5612                 *L1) dflt=L1;;
5613                 *) dflt=1;;
5614                 esac
5615                 ;;
5616         *)      dflt="$man1ext";;
5617         esac
5618         . ./myread
5619         man1ext="$ans"
5620         ;;
5621 esac
5622
5623 : see if we can have long filenames
5624 echo " "
5625 rmlist="$rmlist /tmp/cf$$"
5626 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5627 first=123456789abcdef
5628 second=/tmp/cf$$/$first
5629 $rm -f $first $second
5630 if (echo hi >$first) 2>/dev/null; then
5631         if $test -f 123456789abcde; then
5632                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5633                 val="$undef"
5634         else
5635                 if (echo hi >$second) 2>/dev/null; then
5636                         if $test -f /tmp/cf$$/123456789abcde; then
5637                                 $cat <<'EOM'
5638 That's peculiar... You can have filenames longer than 14 characters, but only
5639 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5640 I shall consider your system cannot support long filenames at all.
5641 EOM
5642                                 val="$undef"
5643                         else
5644                                 echo 'You can have filenames longer than 14 characters.' >&4
5645                                 val="$define"
5646                         fi
5647                 else
5648                         $cat <<'EOM'
5649 How confusing! Some of your filesystems are sane enough to allow filenames
5650 longer than 14 characters but some others like /tmp can't even think about them.
5651 So, for now on, I shall assume your kernel does not allow them at all.
5652 EOM
5653                         val="$undef"
5654                 fi
5655         fi
5656 else
5657         $cat <<'EOM'
5658 You can't have filenames longer than 14 chars.  You can't even think about them!
5659 EOM
5660         val="$undef"
5661 fi 
5662 set d_flexfnam
5663 eval $setvar
5664 $rm -rf /tmp/cf$$ 123456789abcde*
5665
5666 : determine where library module manual pages go
5667 set man3dir man3dir none
5668 eval $prefixit
5669 $cat <<EOM
5670
5671 $spackage has manual pages for many of the library modules.
5672 EOM
5673
5674 case "$nroff" in
5675 nroff)
5676         $cat <<'EOM'
5677 However, you don't have nroff, so they're probably useless to you.
5678 EOM
5679         case "$man3dir" in
5680         '') man3dir="none";;
5681         esac;;
5682 esac
5683
5684 case "$d_flexfnam" in
5685 undef)
5686         $cat <<'EOM'
5687 However, your system can't handle the long file names like File::Basename.3. 
5688 EOM
5689         case "$man3dir" in
5690         '') man3dir="none";;
5691         esac;;
5692 esac
5693
5694 echo "If you don't want the manual sources installed, answer 'none'."
5695 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5696 case "$man3dir" in
5697 '')     case "$prefix" in 
5698         *$prog*) dflt=`echo $man1dir | 
5699                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5700         *)      dflt="$privlib/man/man3" ;;
5701         esac
5702         ;;
5703 ' ') dflt=none;;
5704 *)      dflt="$man3dir" ;;
5705 esac
5706 echo " "
5707
5708 fn=dn+~
5709 rp="Where do the $package library man pages (source) go?"
5710 . ./getfile
5711 if test "X$man3direxp" != "X$ansexp"; then
5712         installman3dir=''
5713 fi
5714
5715 man3dir="$ans"
5716 man3direxp="$ansexp"
5717 case "$man3dir" in
5718 '') man3dir=' '
5719         installman3dir='';;
5720 esac
5721 if $afs; then
5722         $cat <<EOM
5723
5724 Since you are running AFS, I need to distinguish the directory in which
5725 manual pages reside from the directory in which they are installed (and from
5726 which they are presumably copied to the former directory by occult means).
5727
5728 EOM
5729         case "$installman3dir" in
5730         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5731         *) dflt="$installman3dir";;
5732         esac
5733         fn=de~
5734         rp='Where will man pages be installed?'
5735         . ./getfile
5736         installman3dir="$ans"
5737 else
5738         installman3dir="$man3direxp"
5739 fi
5740
5741 : What suffix to use on installed man pages
5742
5743 case "$man3dir" in
5744 ' ')
5745         man3ext='0'
5746         ;;
5747 *)
5748         rp="What suffix should be used for the $package library man pages?"
5749         case "$man3ext" in
5750         '')     case "$man3dir" in
5751                 *3)  dflt=3 ;;
5752                 *3p) dflt=3p ;;
5753                 *3pm) dflt=3pm ;;
5754                 *l) dflt=l;;
5755                 *n) dflt=n;;
5756                 *o) dflt=o;;
5757                 *p) dflt=p;;
5758                 *C) dflt=C;;
5759                 *L) dflt=L;;
5760                 *L3) dflt=L3;;
5761                 *) dflt=3;;
5762                 esac
5763                 ;;
5764         *)      dflt="$man3ext";;
5765         esac
5766         . ./myread
5767         man3ext="$ans"
5768         ;;
5769 esac
5770
5771 : see if we have to deal with yellow pages, now NIS.
5772 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5773         if $test -f /usr/etc/nibindd; then
5774                 echo " "
5775                 echo "I'm fairly confident you're on a NeXT."
5776                 echo " "
5777                 rp='Do you get the hosts file via NetInfo?'
5778                 dflt=y
5779                 case "$hostcat" in
5780                 nidump*) ;;
5781                 '') ;;
5782                 *) dflt=n;;
5783                 esac
5784                 . ./myread
5785                 case "$ans" in
5786                 y*) hostcat='nidump hosts .';;
5787                 *)      case "$hostcat" in
5788                         nidump*) hostcat='';;
5789                         esac
5790                         ;;
5791                 esac
5792         fi
5793         case "$hostcat" in
5794         nidump*) ;;
5795         *)
5796                 case "$hostcat" in
5797                 *ypcat*) dflt=y;;
5798                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5799                                 dflt=y
5800                         else
5801                                 dflt=n
5802                         fi;;
5803                 *) dflt=n;;
5804                 esac
5805                 echo " "
5806                 rp='Are you getting the hosts file via yellow pages?'
5807                 . ./myread
5808                 case "$ans" in
5809                 y*) hostcat='ypcat hosts';;
5810                 *) hostcat='cat /etc/hosts';;
5811                 esac
5812                 ;;
5813         esac
5814 fi
5815 case "$hostcat" in
5816 '') hostcat='cat /etc/hosts';;
5817 esac
5818 case "$groupcat" in
5819 '') groupcat='cat /etc/group';;
5820 esac
5821 case "$passcat" in
5822 '') passcat='cat /etc/passwd';;
5823 esac
5824
5825 : now get the host name
5826 echo " "
5827 echo "Figuring out host name..." >&4
5828 case "$myhostname" in
5829 '') cont=true
5830         echo 'Maybe "hostname" will work...'
5831         if tans=`sh -c hostname 2>&1` ; then
5832                 myhostname=$tans
5833                 phostname=hostname
5834                 cont=''
5835         fi
5836         ;;
5837 *) cont='';;
5838 esac
5839 if $test "$cont"; then
5840         if ./xenix; then
5841                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5842                 if tans=`cat /etc/systemid 2>&1` ; then
5843                         myhostname=$tans
5844                         phostname='cat /etc/systemid'
5845                         echo "Whadyaknow.  Xenix always was a bit strange..."
5846                         cont=''
5847                 fi
5848         elif $test -r /etc/systemid; then
5849                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5850         fi
5851 fi
5852 if $test "$cont"; then
5853         echo 'No, maybe "uuname -l" will work...'
5854         if tans=`sh -c 'uuname -l' 2>&1` ; then
5855                 myhostname=$tans
5856                 phostname='uuname -l'
5857         else
5858                 echo 'Strange.  Maybe "uname -n" will work...'
5859                 if tans=`sh -c 'uname -n' 2>&1` ; then
5860                         myhostname=$tans
5861                         phostname='uname -n'
5862                 else
5863                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5864                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5865                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5866                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5867                         else
5868                                 case "$myhostname" in
5869                                 '') echo "Does this machine have an identity crisis or something?"
5870                                         phostname='';;
5871                                 *)
5872                                         echo "Well, you said $myhostname before..."
5873                                         phostname='echo $myhostname';;
5874                                 esac
5875                         fi
5876                 fi
5877         fi
5878 fi
5879 : you do not want to know about this
5880 set $myhostname
5881 myhostname=$1
5882
5883 : verify guess
5884 if $test "$myhostname" ; then
5885         dflt=y
5886         rp='Your host name appears to be "'$myhostname'".'" Right?"
5887         . ./myread
5888         case "$ans" in
5889         y*) ;;
5890         *) myhostname='';;
5891         esac
5892 fi
5893
5894 : bad guess or no guess
5895 while $test "X$myhostname" = X ; do
5896         dflt=''
5897         rp="Please type the (one word) name of your host:"
5898         . ./myread
5899         myhostname="$ans"
5900 done
5901
5902 : translate upper to lower if necessary
5903 case "$myhostname" in
5904 *[A-Z]*)
5905         echo "(Normalizing case in your host name)"
5906         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5907         ;;
5908 esac
5909
5910 case "$myhostname" in
5911 *.*)
5912         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5913         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5914         echo "(Trimming domain name from host name--host name is now $myhostname)"
5915         ;;
5916 *) case "$mydomain" in
5917         '')
5918                 {
5919                         test "X$hostcat" = "Xypcat hosts" &&
5920                         ypmatch "$myhostname" hosts 2>/dev/null |\
5921                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5922                         $test -s hosts
5923                 } || {
5924                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5925                                         /[       ]$myhostname[  . ]/p" > hosts
5926                 }
5927                 tmp_re="[       . ]"
5928                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5929                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5930                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5931                         hosts | $sort | $uniq | \
5932                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5933                 case `$echo X$dflt` in
5934                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5935                         dflt=.
5936                         ;;
5937                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5938                         ;;
5939                 esac
5940                 case "$dflt" in
5941                 .)
5942                         tans=`./loc resolv.conf X /etc /usr/etc`
5943                         if $test -f "$tans"; then
5944                                 echo "(Attempting domain name extraction from $tans)"
5945                                 dflt=.`$sed -n -e 's/   / /g' \
5946                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5947                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5948                                 case "$dflt" in
5949                                 .) dflt=.`$sed -n -e 's/        / /g' \
5950                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5951                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5952                                         ;;
5953                                 esac
5954                         fi
5955                         ;;
5956                 esac
5957                 case "$dflt" in
5958                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5959                         dflt=.`sh -c domainname 2>/dev/null`
5960                         case "$dflt" in
5961                         '') dflt='.';;
5962                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5963                         esac
5964                         ;;
5965                 esac
5966                 case "$dflt" in
5967                 .) echo "(Lost all hope -- silly guess then)"
5968                         dflt='.uucp'
5969                         ;;
5970                 esac
5971                 $rm -f hosts
5972                 ;;
5973         *) dflt="$mydomain";;
5974         esac;;
5975 esac
5976 echo " "
5977 rp="What is your domain name?"
5978 . ./myread
5979 tans="$ans"
5980 case "$ans" in
5981 '') ;;
5982 .*) ;;
5983 *) tans=".$tans";;
5984 esac
5985 mydomain="$tans"
5986
5987 : translate upper to lower if necessary
5988 case "$mydomain" in
5989 *[A-Z]*)
5990         echo "(Normalizing case in your domain name)"
5991         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5992         ;;
5993 esac
5994
5995 : a little sanity check here
5996 case "$phostname" in
5997 '') ;;
5998 *)
5999         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
6000         $myhostname$mydomain|$myhostname) ;;
6001         *)
6002                 case "$phostname" in
6003                 sed*)
6004                         echo "(That doesn't agree with your whoami.h file, by the way.)"
6005                         ;;
6006                 *)
6007                         echo "(That doesn't agree with your $phostname command, by the way.)"
6008                         ;;
6009                 esac
6010         ;;
6011         esac
6012         ;;
6013 esac
6014
6015 $cat <<EOM
6016
6017 I need to get your e-mail address in Internet format if possible, i.e.
6018 something like user@host.domain. Please answer accurately since I have
6019 no easy means to double check it. The default value provided below
6020 is most probably close to the reality but may not be valid from outside
6021 your organization...
6022
6023 EOM
6024 cont=x
6025 while test "$cont"; do
6026         case "$cf_email" in
6027         '') dflt="$cf_by@$myhostname$mydomain";;
6028         *) dflt="$cf_email";;
6029         esac
6030         rp='What is your e-mail address?'
6031         . ./myread
6032         cf_email="$ans"
6033         case "$cf_email" in
6034         *@*.*) cont='' ;;
6035         *)
6036                 rp='Address does not look like an Internet one.  Use it anyway?'
6037                 case "$fastread" in
6038                 yes) dflt=y ;;
6039                 *) dflt=n ;;
6040                 esac
6041                 . ./myread
6042                 case "$ans" in
6043                 y*) cont='' ;;
6044                 *) echo " " ;;
6045                 esac
6046                 ;;
6047         esac
6048 done
6049
6050 $cat <<EOM
6051
6052 If you or somebody else will be maintaining perl at your site, please
6053 fill in the correct e-mail address here so that they may be contacted
6054 if necessary. Currently, the "perlbug" program included with perl
6055 will send mail to this address in addition to perlbug@perl.com. You may
6056 enter "none" for no administrator.
6057
6058 EOM
6059 case "$perladmin" in
6060 '') dflt="$cf_email";;
6061 *) dflt="$perladmin";;
6062 esac
6063 rp='Perl administrator e-mail address'
6064 . ./myread
6065 perladmin="$ans"
6066
6067 : figure out how to guarantee perl startup
6068 case "$startperl" in
6069 '')
6070         case "$sharpbang" in
6071         *!)
6072                 $cat <<EOH
6073
6074 I can use the #! construct to start perl on your system. This will
6075 make startup of perl scripts faster, but may cause problems if you
6076 want to share those scripts and perl is not in a standard place
6077 ($binexp/perl) on all your platforms. The alternative is to force
6078 a shell by starting the script with a single ':' character.
6079
6080 EOH
6081                 dflt="$binexp/perl"
6082                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6083                 . ./myread
6084                 case "$ans" in
6085                 none)   startperl=": # use perl";;
6086                 *)      startperl="#!$ans"
6087                         if $test 30 -lt `echo "$ans" | wc -c`; then
6088                                 $cat >&4 <<EOM
6089
6090 WARNING:  Some systems limit the #! command to 32 characters.
6091 If you experience difficulty running Perl scripts with #!, try
6092 installing Perl in a directory with a shorter pathname.
6093
6094 EOM
6095                         fi ;;
6096                 esac
6097                 ;;
6098         *) startperl=": # use perl"
6099                 ;;
6100         esac
6101         ;;
6102 esac
6103 echo "I'll use $startperl to start perl scripts."
6104
6105 : figure best path for perl in scripts
6106 case "$perlpath" in
6107 '')
6108         perlpath="$binexp/perl"
6109         case "$startperl" in
6110         *!*) ;;
6111         *)
6112                 $cat <<EOH
6113
6114 I will use the "eval 'exec'" idiom to start Perl on your system.
6115 I can use the full path of your Perl binary for this purpose, but
6116 doing so may cause problems if you want to share those scripts and
6117 Perl is not always in a standard place ($binexp/perl).
6118
6119 EOH
6120                 dflt="$binexp/perl"
6121                 rp="What path shall I use in \"eval 'exec'\"?"
6122                 . ./myread
6123                 perlpath="$ans"
6124                 ;;
6125         esac
6126         ;;
6127 esac
6128 case "$startperl" in
6129 *!*)    ;;
6130 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6131 esac
6132
6133 : determine where public executable scripts go
6134 set scriptdir scriptdir
6135 eval $prefixit
6136 case "$scriptdir" in
6137 '')
6138         dflt="$bin"
6139         : guess some guesses
6140         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6141         $test -d /usr/share/bin && dflt=/usr/share/bin
6142         $test -d /usr/local/script && dflt=/usr/local/script
6143         $test -d $prefixexp/script && dflt=$prefixexp/script
6144         set dflt
6145         eval $prefixup
6146         ;;
6147 *)  dflt="$scriptdir"
6148         ;;
6149 esac
6150 $cat <<EOM
6151  
6152 Some installations have a separate directory just for executable scripts so
6153 that they can mount it across multiple architectures but keep the scripts in
6154 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6155 Or you might just lump your scripts in with all your other executables.
6156  
6157 EOM
6158 fn=d~
6159 rp='Where do you keep publicly executable scripts?'
6160 . ./getfile
6161 if $test "X$ansexp" != "X$scriptdirexp"; then
6162         installscript=''
6163 fi
6164 scriptdir="$ans"
6165 scriptdirexp="$ansexp"
6166 if $afs; then
6167         $cat <<EOM
6168
6169 Since you are running AFS, I need to distinguish the directory in which
6170 scripts reside from the directory in which they are installed (and from
6171 which they are presumably copied to the former directory by occult means).
6172
6173 EOM
6174         case "$installscript" in
6175         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6176         *) dflt="$installscript";;
6177         esac
6178         fn=de~
6179         rp='Where will public scripts be installed?'
6180         . ./getfile
6181         installscript="$ans"
6182 else
6183         installscript="$scriptdirexp"
6184 fi
6185
6186 : determine where site specific libraries go.
6187 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6188 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6189 case "$prefix" in
6190 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6191 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6192 esac
6193 eval $prefixit
6194 $cat <<EOM
6195
6196 The installation process will also create a directory for
6197 site-specific extensions and modules.  Some users find it convenient
6198 to place all site-specific files in this directory rather than in the
6199 main distribution directory.
6200
6201 EOM
6202 fn=d~+
6203 rp='Pathname for the site-specific library files?'
6204 . ./getfile
6205 if $test "X$sitelibexp" != "X$ansexp"; then
6206         installsitelib=''
6207 fi
6208 sitelib="$ans"
6209 sitelibexp="$ansexp"
6210 if $afs; then
6211         $cat <<EOM
6212
6213 Since you are running AFS, I need to distinguish the directory in
6214 which site-specific files reside from the directory in which they are
6215 installed (and from which they are presumably copied to the former
6216 directory by occult means).
6217
6218 EOM
6219         case "$installsitelib" in
6220         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6221         *) dflt="$installsitelib";;
6222         esac
6223         fn=de~
6224         rp='Where will site-specific files be installed?'
6225         . ./getfile
6226         installsitelib="$ans"
6227 else
6228         installsitelib="$sitelibexp"
6229 fi
6230
6231 : determine where site specific architecture-dependent libraries go.
6232 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6233 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6234 : sitelib may have an optional trailing /share.
6235 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6236 tdflt="$tdflt/$archname"
6237 set sitearch sitearch none
6238 eval $prefixit
6239 case "$sitearch" in
6240 '')     dflt="$tdflt" ;;
6241 *)      dflt="$sitearch" ;;
6242 esac
6243 $cat <<EOM
6244
6245 The installation process will also create a directory for
6246 architecture-dependent site-specific extensions and modules.
6247
6248 EOM
6249 fn=nd~+
6250 rp='Pathname for the site-specific architecture-dependent library files?'
6251 . ./getfile
6252 if $test "X$sitearchexp" != "X$ansexp"; then
6253         installsitearch=''
6254 fi
6255 sitearch="$ans"
6256 sitearchexp="$ansexp"
6257 if $afs; then
6258         $cat <<EOM
6259
6260 Since you are running AFS, I need to distinguish the directory in
6261 which site-specific architecture-dependent library files reside from
6262 the directory in which they are installed (and from which they are
6263 presumably copied to the former directory by occult means).
6264
6265 EOM
6266         case "$installsitearch" in
6267         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6268         *) dflt="$installsitearch";;
6269         esac
6270         fn=de~
6271         rp='Where will site-specific architecture-dependent files be installed?'
6272         . ./getfile
6273         installsitearch="$ans"
6274 else
6275         installsitearch="$sitearchexp"
6276 fi
6277
6278 cat <<EOM
6279
6280 Previous version of $package used the standard IO mechanisms as defined
6281 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6282 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6283 the default.  This abstraction layer can use AT&T's sfio (if you already
6284 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6285 problems with some extension modules.  Using PerlIO with stdio is safe,
6286 but it is slower than plain stdio and therefore is not the default.
6287
6288 If this doesn't make any sense to you, just accept the default 'n'.
6289 EOM
6290 case "$useperlio" in
6291 $define|true|[yY]*)     dflt='y';;
6292 *) dflt='n';;
6293 esac
6294 rp='Use the experimental PerlIO abstraction layer?'
6295 . ./myread
6296 case "$ans" in
6297 y|Y) 
6298         val="$define"
6299         ;;     
6300 *)      
6301         echo "Ok, doing things the stdio way"
6302         val="$undef"
6303         ;;
6304 esac
6305 set useperlio
6306 eval $setvar 
6307
6308 : Check how to convert floats to strings.
6309 if test "X$d_Gconvert" = X; then
6310         echo " "
6311         echo "Checking for an efficient way to convert floats to strings."
6312         $cat >try.c <<'EOP'
6313 #ifdef TRY_gconvert
6314 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6315 char *myname = "gconvert";
6316 #endif
6317 #ifdef TRY_gcvt
6318 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6319 char *myname = "gcvt";
6320 #endif
6321 #ifdef TRY_sprintf
6322 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6323 char *myname = "sprintf";
6324 #endif
6325
6326 #include <stdio.h>
6327
6328 int
6329 checkit(expect, got)
6330 char *expect;
6331 char *got;
6332 {
6333     if (strcmp(expect, got)) {
6334                 printf("%s oddity:  Expected %s, got %s\n",
6335                         myname, expect, got);
6336                 exit(1);
6337         }
6338 }
6339
6340 int main()
6341
6342         char buf[64]; 
6343         buf[63] = '\0';
6344
6345         /* This must be 1st test on (which?) platform */
6346         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6347         Gconvert(0.1, 8, 0, buf);
6348         checkit("0.1", buf);
6349
6350         Gconvert(1.0, 8, 0, buf); 
6351         checkit("1", buf);
6352
6353         Gconvert(0.0, 8, 0, buf); 
6354         checkit("0", buf);
6355
6356         Gconvert(-1.0, 8, 0, buf); 
6357         checkit("-1", buf);
6358
6359         /* Some Linux gcvt's give 1.e+5 here. */
6360         Gconvert(100000.0, 8, 0, buf); 
6361         checkit("100000", buf);
6362         
6363         /* Some Linux gcvt's give -1.e+5 here. */
6364         Gconvert(-100000.0, 8, 0, buf); 
6365         checkit("-100000", buf);
6366
6367         exit(0);
6368 }
6369 EOP
6370         case "$d_Gconvert" in
6371         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6372         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6373         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6374         *) xxx_list='gconvert gcvt sprintf' ;;
6375         esac
6376
6377         for xxx_convert in $xxx_list; do
6378                 echo "Trying $xxx_convert"
6379                 $rm -f try try$_o
6380                 set try -DTRY_$xxx_convert
6381                 if eval $compile; then
6382                         echo "$xxx_convert" found. >&4
6383                         if ./try; then
6384                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6385                                 break;
6386                         else
6387                                 echo "...But $xxx_convert didn't work as I expected."
6388                         fi
6389                 else
6390                         echo "$xxx_convert NOT found." >&4
6391                 fi
6392         done
6393                 
6394         case "$xxx_convert" in
6395         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6396         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6397         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6398         esac
6399 fi
6400
6401 : Initialize h_fcntl
6402 h_fcntl=false
6403
6404 : Initialize h_sysfile
6405 h_sysfile=false
6406
6407 : access call always available on UNIX
6408 set access d_access
6409 eval $inlibc
6410
6411 : locate the flags for 'access()'
6412 case "$d_access" in
6413 "$define")
6414         echo " "
6415         $cat >access.c <<'EOCP'
6416 #include <sys/types.h>
6417 #ifdef I_FCNTL
6418 #include <fcntl.h>
6419 #endif
6420 #ifdef I_SYS_FILE
6421 #include <sys/file.h>
6422 #endif
6423 #ifdef I_UNISTD
6424 #include <unistd.h>
6425 #endif
6426 int main() {
6427         exit(R_OK);
6428 }
6429 EOCP
6430         : check sys/file.h first, no particular reason here
6431         if $test `./findhdr sys/file.h` && \
6432                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6433                 h_sysfile=true;
6434                 echo "<sys/file.h> defines the *_OK access constants." >&4
6435         elif $test `./findhdr fcntl.h` && \
6436                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6437                 h_fcntl=true;
6438                 echo "<fcntl.h> defines the *_OK access constants." >&4
6439         elif $test `./findhdr unistd.h` && \
6440                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6441                 echo "<unistd.h> defines the *_OK access constants." >&4
6442         else
6443                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6444         fi
6445         ;;
6446 esac
6447 $rm -f access*
6448
6449 : see if accessx exists
6450 set accessx d_accessx
6451 eval $inlibc
6452
6453 : see if alarm exists
6454 set alarm d_alarm
6455 eval $inlibc
6456
6457 : Look for GNU-cc style attribute checking
6458 echo " "
6459 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6460 $cat >attrib.c <<'EOCP'
6461 #include <stdio.h>
6462 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6463 EOCP
6464 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6465         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6466                 echo "Your C compiler doesn't fully support __attribute__."
6467                 val="$undef"
6468         else
6469                 echo "Your C compiler supports __attribute__."
6470                 val="$define"
6471         fi
6472 else
6473         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6474         val="$undef"
6475 fi
6476 set d_attribut
6477 eval $setvar
6478 $rm -f attrib*
6479
6480 : see if bcmp exists
6481 set bcmp d_bcmp
6482 eval $inlibc
6483
6484 : see if bcopy exists
6485 set bcopy d_bcopy
6486 eval $inlibc
6487
6488 : see if this is a unistd.h system
6489 set unistd.h i_unistd
6490 eval $inhdr
6491
6492 : see if getpgrp exists
6493 set getpgrp d_getpgrp
6494 eval $inlibc
6495
6496 case "$d_getpgrp" in
6497 "$define")
6498         echo " "
6499         echo "Checking to see which flavor of getpgrp is in use..."
6500         $cat >set.c <<EOP
6501 #$i_unistd I_UNISTD
6502 #include <sys/types.h>
6503 #ifdef I_UNISTD
6504 #  include <unistd.h>
6505 #endif
6506 int main()
6507 {
6508         if (getuid() == 0) {
6509                 printf("(I see you are running Configure as super-user...)\n");
6510                 setuid(1);
6511         }
6512 #ifdef TRY_BSD_PGRP
6513         if (getpgrp(1) == 0)
6514                 exit(0);
6515 #else
6516         if (getpgrp() > 0)
6517                 exit(0);
6518 #endif
6519         exit(1);
6520 }
6521 EOP
6522         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6523                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6524                 val="$define"
6525         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6526                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6527                 val="$undef"
6528         else
6529                 echo "I can't seem to compile and run the test program."
6530                 if ./usg; then
6531                         xxx="a USG one, i.e. you use getpgrp()."
6532                 else
6533                         # SVR4 systems can appear rather BSD-ish.
6534                         case "$i_unistd" in
6535                         $undef)
6536                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6537                                 val="$define"
6538                                 ;;
6539                         $define)
6540                                 xxx="probably a USG one, i.e. you use getpgrp()."
6541                                 val="$undef"
6542                                 ;;
6543                         esac
6544                 fi
6545                 echo "Assuming your getpgrp is $xxx" >&4
6546         fi
6547         ;;
6548 *) val="$undef";;
6549 esac
6550 set d_bsdgetpgrp
6551 eval $setvar
6552 $rm -f set set.c
6553
6554 : see if setpgrp exists
6555 set setpgrp d_setpgrp
6556 eval $inlibc
6557
6558 case "$d_setpgrp" in
6559 "$define")
6560         echo " "
6561         echo "Checking to see which flavor of setpgrp is in use..."
6562         $cat >set.c <<EOP
6563 #$i_unistd I_UNISTD
6564 #include <sys/types.h>
6565 #ifdef I_UNISTD
6566 #  include <unistd.h>
6567 #endif
6568 int main()
6569 {
6570         if (getuid() == 0) {
6571                 printf("(I see you are running Configure as super-user...)\n");
6572                 setuid(1);
6573         }
6574 #ifdef TRY_BSD_PGRP
6575         if (-1 == setpgrp(1, 1))
6576                 exit(0);
6577 #else
6578         if (setpgrp() != -1)
6579                 exit(0);
6580 #endif
6581         exit(1);
6582 }
6583 EOP
6584         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6585                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6586                 val="$define"
6587         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6588                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6589                 val="$undef"
6590         else
6591                 echo "(I can't seem to compile and run the test program.)"
6592                 if ./usg; then
6593                         xxx="a USG one, i.e. you use setpgrp()."
6594                 else
6595                         # SVR4 systems can appear rather BSD-ish.
6596                         case "$i_unistd" in
6597                         $undef)
6598                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6599                                 val="$define"
6600                                 ;;
6601                         $define)
6602                                 xxx="probably a USG one, i.e. you use setpgrp()."
6603                                 val="$undef"
6604                                 ;;
6605                         esac
6606                 fi
6607                 echo "Assuming your setpgrp is $xxx" >&4
6608         fi
6609         ;;
6610 *) val="$undef";;
6611 esac
6612 set d_bsdsetpgrp
6613 eval $setvar
6614 $rm -f set set.c
6615 : see if bzero exists
6616 set bzero d_bzero
6617 eval $inlibc
6618
6619 : check for lengths of integral types
6620 echo " "
6621 case "$intsize" in
6622 '')
6623         echo "Checking to see how big your integers are..." >&4
6624         $cat >intsize.c <<'EOCP'
6625 #include <stdio.h>
6626 int main()
6627 {
6628         printf("intsize=%d;\n", sizeof(int));
6629         printf("longsize=%d;\n", sizeof(long));
6630         printf("shortsize=%d;\n", sizeof(short));
6631         exit(0);
6632 }
6633 EOCP
6634         set intsize
6635         if eval $compile_ok && ./intsize > /dev/null; then
6636                 eval `./intsize`
6637                 echo "Your integers are $intsize bytes long."
6638                 echo "Your long integers are $longsize bytes long."
6639                 echo "Your short integers are $shortsize bytes long."
6640         else
6641                 $cat >&4 <<EOM
6642 !
6643 Help! I can't compile and run the intsize test program: please enlighten me!
6644 (This is probably a misconfiguration in your system or libraries, and
6645 you really ought to fix it.  Still, I'll try anyway.)
6646 !
6647 EOM
6648                 dflt=4
6649                 rp="What is the size of an integer (in bytes)?"
6650                 . ./myread
6651                 intsize="$ans"
6652                 dflt=$intsize
6653                 rp="What is the size of a long integer (in bytes)?"
6654                 . ./myread
6655                 longsize="$ans"
6656                 dflt=2
6657                 rp="What is the size of a short integer (in bytes)?"
6658                 . ./myread
6659                 shortsize="$ans"
6660         fi
6661         ;;
6662 esac
6663 $rm -f intsize intsize.*
6664
6665 : see if signal is declared as pointer to function returning int or void
6666 echo " "
6667 xxx=`./findhdr signal.h`
6668 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6669 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6670         echo "You have int (*signal())() instead of void." >&4
6671         val="$undef"
6672 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6673         echo "You have void (*signal())()." >&4
6674         val="$define"
6675 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6676         echo "You have int (*signal())() instead of void." >&4
6677         val="$undef"
6678 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6679         echo "You have void (*signal())()." >&4
6680         val="$define"
6681 else
6682         case "$d_voidsig" in
6683         '')
6684         echo "I can't determine whether signal handler returns void or int..." >&4
6685                 dflt=void
6686                 rp="What type does your signal handler return?"
6687                 . ./myread
6688                 case "$ans" in
6689                 v*) val="$define";;
6690                 *) val="$undef";;
6691                 esac;;
6692         "$define")
6693                 echo "As you already told me, signal handler returns void." >&4
6694                 val="$define"
6695                 ;;
6696         *)      echo "As you already told me, signal handler returns int." >&4
6697                 val="$undef"
6698                 ;;
6699         esac
6700 fi
6701 set d_voidsig
6702 eval $setvar
6703 case "$d_voidsig" in
6704 "$define") signal_t="void";;
6705 *) signal_t="int";;
6706 esac
6707 $rm -f $$.tmp
6708
6709 : check for ability to cast large floats to 32-bit ints.
6710 echo " "
6711 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6712 if $test "$intsize" -ge 4; then
6713         xxx=int
6714 else
6715         xxx=long
6716 fi
6717 $cat >try.c <<EOCP
6718 #include <stdio.h>
6719 #include <sys/types.h>
6720 #include <signal.h>
6721 $signal_t blech(s) int s; { exit(3); }
6722 int main()
6723 {
6724         $xxx i32;
6725         double f, g;
6726         int result = 0;
6727         char str[16];
6728         signal(SIGFPE, blech);
6729
6730         /* Don't let compiler optimize the test away.  Store the number 
6731            in a writable string for gcc to pass to sscanf under HP/UX.
6732         */
6733         sprintf(str, "2147483647");
6734         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6735         g = 10 * f;
6736         i32  = ($xxx) g;
6737
6738         /* x86 processors will probably give 0x8000 0000, which is a
6739        sign change.  We don't want that.  We want to mimic SPARC
6740            behavior here, which is to preserve the sign and give
6741            back 0x7fff ffff.
6742         */
6743         if (i32 != ($xxx) f)
6744                 result |= 1;
6745         exit(result);
6746 }
6747 EOCP
6748 set try
6749 if eval $compile_ok; then
6750         ./try
6751         yyy=$?
6752 else
6753         echo "(I can't seem to compile the test program--assuming it can't)"
6754         yyy=1
6755 fi
6756 case "$yyy" in
6757 0)      val="$define"
6758         echo "Yup, it can."
6759         ;;
6760 *)      val="$undef"
6761         echo "Nope, it can't."
6762         ;;
6763 esac
6764 set d_casti32
6765 eval $setvar
6766 $rm -f try try.*
6767
6768 : check for ability to cast negative floats to unsigned
6769 echo " "
6770 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6771 $cat >try.c <<EOCP
6772 #include <stdio.h>
6773 #include <sys/types.h>
6774 #include <signal.h>
6775 $signal_t blech(s) int s; { exit(7); }
6776 $signal_t blech_in_list(s) int s; { exit(4); }
6777 unsigned long dummy_long(p) unsigned long p; { return p; }
6778 unsigned int dummy_int(p) unsigned int p; { return p; }
6779 unsigned short dummy_short(p) unsigned short p; { return p; }
6780 int main()
6781 {
6782         double f;
6783         unsigned long along;
6784         unsigned int aint;
6785         unsigned short ashort;
6786         int result = 0;
6787         char str[16];
6788         
6789         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6790            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6791            optimized the whole file away
6792         */
6793         /* Store the number in a writable string for gcc to pass to 
6794            sscanf under HP/UX.
6795         */
6796         sprintf(str, "-123");
6797         sscanf(str, "%lf", &f);  /* f = -123.; */
6798
6799         signal(SIGFPE, blech);
6800         along = (unsigned long)f;
6801         aint = (unsigned int)f;
6802         ashort = (unsigned short)f;
6803         if (along != (unsigned long)-123)
6804                 result |= 1;
6805         if (aint != (unsigned int)-123)
6806                 result |= 1;
6807         if (ashort != (unsigned short)-123)
6808                 result |= 1;
6809         sprintf(str, "1073741824.");
6810         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6811         f = f + f;
6812         along = 0;
6813         along = (unsigned long)f;
6814         if (along != 0x80000000)
6815                 result |= 2;
6816         f -= 1.;
6817         along = 0;
6818         along = (unsigned long)f;
6819         if (along != 0x7fffffff)
6820                 result |= 1;
6821         f += 2.;
6822         along = 0;
6823         along = (unsigned long)f;
6824         if (along != 0x80000001)
6825                 result |= 2;
6826         if (result)
6827                 exit(result);
6828         signal(SIGFPE, blech_in_list);
6829         sprintf(str, "123.");
6830         sscanf(str, "%lf", &f);  /* f = 123.; */
6831         along = dummy_long((unsigned long)f);
6832         aint = dummy_int((unsigned int)f);
6833         ashort = dummy_short((unsigned short)f);
6834         if (along != (unsigned long)123)
6835                 result |= 4;
6836         if (aint != (unsigned int)123)
6837                 result |= 4;
6838         if (ashort != (unsigned short)123)
6839                 result |= 4;
6840         exit(result);
6841
6842 }
6843 EOCP
6844 set try
6845 if eval $compile_ok; then
6846         ./try
6847         castflags=$?
6848 else
6849         echo "(I can't seem to compile the test program--assuming it can't)"
6850         castflags=7
6851 fi
6852 case "$castflags" in
6853 0)      val="$define"
6854         echo "Yup, it can."
6855         ;;
6856 *)      val="$undef"
6857         echo "Nope, it can't."
6858         ;;
6859 esac
6860 set d_castneg
6861 eval $setvar
6862 $rm -f try.*
6863
6864 : see if vprintf exists
6865 echo " "
6866 if set vprintf val -f d_vprintf; eval $csym; $val; then
6867         echo 'vprintf() found.' >&4
6868         val="$define"
6869         $cat >vprintf.c <<'EOF'
6870 #include <varargs.h>
6871
6872 int main() { xxx("foo"); }
6873
6874 xxx(va_alist)
6875 va_dcl
6876 {
6877         va_list args;
6878         char buf[10];
6879
6880         va_start(args);
6881         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6882 }
6883 EOF
6884         set vprintf
6885         if eval $compile && ./vprintf; then
6886                 echo "Your vsprintf() returns (int)." >&4
6887                 val2="$undef"
6888         else
6889                 echo "Your vsprintf() returns (char*)." >&4
6890                 val2="$define"
6891         fi
6892 else
6893         echo 'vprintf() NOT found.' >&4
6894                 val="$undef"
6895                 val2="$undef"
6896 fi
6897 set d_vprintf
6898 eval $setvar
6899 val=$val2
6900 set d_charvspr
6901 eval $setvar
6902
6903 : see if chown exists
6904 set chown d_chown
6905 eval $inlibc
6906
6907 : see if chroot exists
6908 set chroot d_chroot
6909 eval $inlibc
6910
6911 : see if chsize exists
6912 set chsize d_chsize
6913 eval $inlibc
6914
6915 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6916 while $test $# -ge 2; do
6917         case "$1" in
6918         $define) echo "#include <$2>";;
6919         esac ;
6920     shift 2;
6921 done > try.c;
6922 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6923 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6924         val="$define";
6925 else
6926         val="$undef";
6927 fi;
6928 set $varname;
6929 eval $setvar;
6930 $rm -f try.c try.o'
6931
6932 : see if this is a sys/uio.h system
6933 set sys/uio.h i_sysuio
6934 eval $inhdr
6935
6936 echo "Checking to see if your system supports struct iovec..." >&4
6937 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6938 eval $hasfield
6939 case "$d_iovec_s" in
6940 "$define")      echo "Yup, it does." >&4
6941                 ;;
6942 *)              echo "Nope, it doesn't." >&4
6943                 ;;
6944 esac
6945
6946 socketlib=''
6947 sockethdr=''
6948 : see whether socket exists
6949 echo " "
6950 $echo $n "Hmm... $c" >&4
6951 if set socket val -f d_socket; eval $csym; $val; then
6952         echo "Looks like you have Berkeley networking support." >&4
6953         d_socket="$define"
6954         if set setsockopt val -f; eval $csym; $val; then
6955                 d_oldsock="$undef"
6956         else
6957                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6958                 d_oldsock="$define"
6959         fi
6960 else
6961         if $contains socklib libc.list >/dev/null 2>&1; then
6962                 echo "Looks like you have Berkeley networking support." >&4
6963                 d_socket="$define"
6964                 : we will have to assume that it supports the 4.2 BSD interface
6965                 d_oldsock="$undef"
6966         else
6967                 echo "You don't have Berkeley networking in libc$_a..." >&4
6968                 if test "X$d_socket" = "X$define"; then
6969                    echo "...but you seem to believe that you have sockets." >&4
6970                 else
6971                         for net in net socket
6972                         do
6973                                 if test -f /usr/lib/lib$net$_a; then
6974                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6975                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6976                                         if $contains socket libc.list >/dev/null 2>&1; then
6977                                                 d_socket="$define"
6978                                                 socketlib="-l$net"
6979                                                 case "$net" in
6980                                                 net)
6981                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6982                                                         sockethdr="-I/usr/netinclude"
6983                                                         ;;
6984                                                 esac
6985                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6986                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6987                                                         d_oldsock="$undef"
6988                                                 else
6989                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6990                                                         d_oldsock="$define"
6991                                                 fi
6992                                                 break
6993                                         fi
6994                                 fi
6995                         done
6996                         if test "X$d_socket" != "X$define"; then
6997                            echo "or anywhere else I see." >&4
6998                            d_socket="$undef"
6999                            d_oldsock="$undef"
7000                         fi
7001                 fi
7002         fi
7003 fi
7004
7005 : see if socketpair exists
7006 set socketpair d_sockpair
7007 eval $inlibc
7008
7009
7010 echo " "
7011 echo "Checking the availability of certain socket constants..." >& 4
7012 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
7013         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
7014         $cat >try.c <<EOF
7015 #include <sys/types.h>
7016 #include <sys/socket.h>
7017 int main() {
7018     int i = $ENUM;
7019 }
7020 EOF
7021         val="$undef"
7022         set try; if eval $compile; then
7023                 val="$define"
7024         fi
7025         set d_${enum}; eval $setvar
7026         $rm -f try.c try
7027 done
7028
7029 set sendmsg d_sendmsg
7030 eval $inlibc
7031
7032 set recvmsg d_recvmsg
7033 eval $inlibc
7034
7035 echo " "
7036 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
7037 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7038 eval $hasfield
7039 case "$d_msghdr_s" in
7040 "$define")      echo "Yup, it does." >&4
7041                 ;;
7042 *)              echo "Nope, it doesn't." >&4
7043                 ;;
7044 esac
7045
7046 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7047 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7048 eval $hasfield
7049 case "$d_cmsghdr_s" in
7050 "$define")      echo "Yup, it does." >&4
7051                 ;;
7052 *)              echo "Nope, it doesn't." >&4
7053                 ;;
7054 esac
7055
7056 : check for const keyword
7057 echo " "
7058 echo 'Checking to see if your C compiler knows about "const"...' >&4
7059 $cat >const.c <<'EOCP'
7060 typedef struct spug { int drokk; } spug;
7061 int main()
7062 {
7063         const char *foo;
7064         const spug y;
7065 }
7066 EOCP
7067 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7068         val="$define"
7069         echo "Yup, it does."
7070 else
7071         val="$undef"
7072         echo "Nope, it doesn't."
7073 fi
7074 set d_const
7075 eval $setvar
7076
7077 : see if crypt exists
7078 echo " "
7079 if set crypt val -f d_crypt; eval $csym; $val; then
7080         echo 'crypt() found.' >&4
7081         val="$define"
7082         cryptlib=''
7083 else
7084         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7085         if $test -z "$cryptlib"; then
7086                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7087         else
7088                 cryptlib=-lcrypt
7089         fi
7090         if $test -z "$cryptlib"; then
7091                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7092         else
7093                 cryptlib=-lcrypt
7094         fi
7095         if $test -z "$cryptlib"; then
7096                 cryptlib=`./loc libcrypt$_a "" $libpth`
7097         else
7098                 cryptlib=-lcrypt
7099         fi
7100         if $test -z "$cryptlib"; then
7101                 echo 'crypt() NOT found.' >&4
7102                 val="$undef"
7103         else
7104                 val="$define"
7105         fi
7106 fi
7107 set d_crypt
7108 eval $setvar
7109
7110 : get csh whereabouts
7111 case "$csh" in
7112 'csh') val="$undef" ;;
7113 *) val="$define" ;;
7114 esac
7115 set d_csh
7116 eval $setvar
7117 : Respect a hint or command line value for full_csh.
7118 case "$full_csh" in
7119 '') full_csh=$csh ;;
7120 esac
7121
7122 : see if cuserid exists
7123 set cuserid d_cuserid
7124 eval $inlibc
7125
7126 : see if this is a limits.h system
7127 set limits.h i_limits
7128 eval $inhdr
7129
7130 : see if this is a float.h system
7131 set float.h i_float
7132 eval $inhdr
7133
7134 : See if number of significant digits in a double precision number is known
7135 echo " "
7136 $cat >dbl_dig.c <<EOM
7137 #$i_limits I_LIMITS
7138 #$i_float I_FLOAT
7139 #ifdef I_LIMITS
7140 #include <limits.h>
7141 #endif
7142 #ifdef I_FLOAT
7143 #include <float.h>
7144 #endif
7145 #ifdef DBL_DIG
7146 printf("Contains DBL_DIG");
7147 #endif
7148 EOM
7149 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7150 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7151         echo "DBL_DIG found." >&4
7152         val="$define"
7153 else
7154         echo "DBL_DIG NOT found." >&4
7155         val="$undef"
7156 fi
7157 $rm -f dbl_dig.?
7158 set d_dbl_dig
7159 eval $setvar
7160
7161
7162 if $test X"$use64bits" = X"$define"; then
7163         : see if dbminit64 exists
7164         set dbminit64 d_dbminit64
7165         eval $inlibc
7166
7167         : see if dbmclose64 exists
7168         set dbmclose64 d_dbmclose64
7169         eval $inlibc
7170
7171         : see if fetch64 exists
7172         set fetch64 d_fetch64
7173         eval $inlibc
7174
7175         : see if store64 exists
7176         set store64 d_store64
7177         eval $inlibc
7178
7179         : see if delete64 exists
7180         set delete64 d_delete64
7181         eval $inlibc
7182
7183         : see if firstkey64 exists
7184         set firstkey64 d_firstkey64
7185         eval $inlibc
7186
7187         : see if nextkey64 exists
7188         set nextkey64 d_nextkey64
7189         eval $inlibc
7190 else
7191         val="$undef"
7192         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7193         do
7194                 set $xxx
7195                 eval $setvar
7196         done
7197 fi
7198
7199 : see if difftime exists
7200 set difftime d_difftime
7201 eval $inlibc
7202
7203 : see if sys/stat.h is available
7204 set sys/stat.h i_sysstat
7205 eval $inhdr
7206
7207 : see if this is a dirent system
7208 echo " "
7209 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7210         val="$define"
7211         echo "<dirent.h> found." >&4
7212 else
7213         val="$undef"
7214         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7215                 echo "<sys/dir.h> found." >&4
7216                 echo " "
7217         else
7218                 xinc=`./findhdr sys/ndir.h`
7219         fi
7220         echo "<dirent.h> NOT found." >&4
7221 fi
7222 set i_dirent
7223 eval $setvar
7224
7225 : Look for type of directory structure.
7226 echo " "
7227 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7228
7229 case "$direntrytype" in
7230 ''|' ')
7231         case "$i_dirent" in
7232         $define) guess1='struct dirent' ;;
7233         *) guess1='struct direct'  ;;
7234         esac
7235         ;;
7236 *)      guess1="$direntrytype"
7237         ;;
7238 esac
7239
7240 case "$guess1" in
7241 'struct dirent') guess2='struct direct' ;;
7242 *) guess2='struct dirent' ;;
7243 esac
7244                 
7245 if $contains "$guess1" try.c >/dev/null 2>&1; then
7246         direntrytype="$guess1"
7247         echo "Your directory entries are $direntrytype." >&4
7248 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7249         direntrytype="$guess2"
7250         echo "Your directory entries seem to be $direntrytype." >&4
7251 else
7252         echo "I don't recognize your system's directory entries." >&4
7253         rp="What type is used for directory entries on this system?"
7254         dflt="$guess1"
7255         . ./myread
7256         direntrytype="$ans"
7257 fi
7258 $rm -f try.c
7259
7260
7261 : see if the directory entry stores field length
7262 echo " "
7263 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7264 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7265         echo "Good, your directory entry keeps length information in d_namlen." >&4
7266         val="$define"
7267 else
7268         echo "Your directory entry does not know about the d_namlen field." >&4
7269         val="$undef"
7270 fi
7271 set d_dirnamlen
7272 eval $setvar
7273 $rm -f try.c
7274
7275
7276 if $test X"$use64bits" = X"$define"; then
7277         : see if fstat64 exists
7278         set fstat64 d_fstat64
7279         eval $inlibc
7280
7281         : see if ftruncate64 exists
7282         set ftruncate64 d_ftruncate64
7283         eval $inlibc
7284
7285         : see if lockf64 exists
7286         set lockf64 d_lockf64
7287         eval $inlibc
7288
7289         : see if llseek exists
7290         set llseek d_llseek
7291         eval $inlibc
7292
7293         : see if lseek64 exists
7294         set lseek64 d_lseek64
7295         eval $inlibc
7296
7297         : see if lstat64 exists
7298         set lstat64 d_lstat64
7299         eval $inlibc
7300
7301         : see if open64 exists
7302         set open64 d_open64
7303         eval $inlibc
7304
7305         : see if opendir64 exists
7306         set opendir64 d_opendir64
7307         eval $inlibc
7308
7309         : see if readdir64 exists
7310         set readdir64 d_readdir64
7311         eval $inlibc
7312
7313         : see if seekdir64 exists
7314         set seekdir64 d_seekdir64
7315         eval $inlibc
7316
7317         : see if stat64 exists
7318         set stat64 d_stat64
7319         eval $inlibc
7320
7321         : see if telldir64 exists
7322         set telldir64 d_telldir64
7323         eval $inlibc
7324
7325         : see if truncate64 exists
7326         set truncate64 d_truncate64
7327         eval $inlibc
7328
7329         : check for off64_t
7330         echo " "
7331         echo $n "Checking to see if your system supports off64_t...$c" >&4
7332         $cat >try.c <<EOCP
7333 #include <sys/types.h>
7334 #include <unistd.h>
7335 off64_t foo() { off64_t x; x = 7; return x; }'
7336 EOCP
7337         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7338                 val="$define"
7339                 echo " Yup, it does." >&4
7340         else
7341                 val="$undef"
7342                 echo " Nope, it doesn't." >&4
7343         fi
7344         $rm -f try.*
7345         set d_off64_t
7346         eval $setvar
7347
7348         : check for offset_t
7349         echo " "
7350         echo $n "Checking to see if your system supports offset_t...$c" >&4
7351         $cat >try.c <<EOCP
7352 #include <sys/types.h>
7353 #include <unistd.h>
7354 offset_t foo() { offset_t x; x = 7; return x; }'
7355 EOCP
7356         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7357                 val="$define"
7358                 echo " Yup, it does." >&4
7359         else
7360                 val="$undef"
7361                 echo " Nope, it doesn't." >&4
7362         fi
7363         $rm -f try.*
7364         set d_offset_t
7365         eval $setvar
7366
7367         : check for ino64_t
7368         echo " "
7369         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7370         val="$undef"
7371         case "$i_sysstat" in
7372         "$define" )
7373                 $cat >try.c <<EOCP
7374 #include <sys/types.h>
7375 #include <sys/stat.h>
7376 ino64_t foo() { ino64_t x; x = 7; return x; }'
7377 EOCP
7378                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7379                         val="$define"
7380                 fi
7381                 $rm -f try.*
7382                 ;;
7383         esac
7384         if $test "X$val" = X"$define"; then
7385                 echo " Yup, it does." >&4
7386         else
7387                 echo " Nope, it doesn't." >&4
7388         fi
7389         set d_ino64_t
7390         eval $setvar
7391
7392         : check for struct flock64
7393         echo " "
7394         echo "Checking to see if your system supports struct flock64..." >&4
7395         if $h_fcntl; then
7396                 set d_flock64_s flock64 l_len define fcntl.h
7397                 eval $hasfield
7398         else
7399                 val="$undef"
7400                 set d_flock64_s
7401                 eval $setvar
7402         fi
7403         case "$d_flock64_s" in
7404         "$define")      echo "Yup, it does." >&4
7405                         ;;
7406         *)              echo "Nope, it doesn't." >&4
7407                         ;;
7408         esac
7409
7410         : check for struct dirent64
7411         echo " "
7412         echo "Checking to see if your system supports struct dirent64..." >&4
7413         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7414         eval $hasfield
7415         case "$d_dirent64_s" in
7416         "$define")      echo "Yup, it does." >&4
7417                         ;;
7418         *)              echo "Nope, it doesn't." >&4
7419                         ;;
7420         esac
7421
7422 else
7423         val="$undef"
7424         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
7425         do
7426                 set $xxx
7427                 eval $setvar
7428         done
7429 fi
7430
7431 : see if dlerror exists
7432 xxx_runnm="$runnm"
7433 runnm=false
7434 set dlerror d_dlerror
7435 eval $inlibc
7436 runnm="$xxx_runnm"
7437
7438 : see if dlfcn is available
7439 set dlfcn.h i_dlfcn
7440 eval $inhdr
7441
7442 case "$usedl" in
7443 $define|y|true)
7444         $cat << EOM
7445
7446 On a few systems, the dynamically loaded modules that perl generates and uses
7447 will need a different extension than shared libs. The default will probably
7448 be appropriate.
7449
7450 EOM
7451         case "$dlext" in
7452         '')     dflt="$so" ;;
7453         *)      dflt="$dlext" ;;
7454         esac
7455         rp='What is the extension of dynamically loaded modules'
7456         . ./myread
7457         dlext="$ans"
7458         ;;
7459 *)
7460         dlext="none"
7461         ;;
7462 esac
7463
7464 : Check if dlsym need a leading underscore
7465 echo " "
7466 val="$undef"
7467
7468 case "$dlsrc" in
7469 dl_dlopen.xs)
7470         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7471         $cat >dyna.c <<'EOM'
7472 fred () { }
7473 EOM
7474
7475 $cat >fred.c<<EOM
7476
7477 #include <stdio.h>
7478 #$i_dlfcn I_DLFCN
7479 #ifdef I_DLFCN
7480 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7481 #else
7482 #include <sys/types.h>
7483 #include <nlist.h>
7484 #include <link.h>
7485 #endif
7486
7487 extern int fred() ;
7488
7489 int main()
7490 {
7491     void * handle ;
7492     void * symbol ;
7493 #ifndef RTLD_LAZY
7494     int mode = 1 ;
7495 #else
7496     int mode = RTLD_LAZY ;
7497 #endif
7498     handle = dlopen("./dyna.$dlext", mode) ;
7499     if (handle == NULL) {
7500         printf ("1\n") ;
7501         fflush (stdout) ;
7502         exit(0);
7503     }
7504     symbol = dlsym(handle, "fred") ;
7505     if (symbol == NULL) {
7506         /* try putting a leading underscore */
7507         symbol = dlsym(handle, "_fred") ;
7508         if (symbol == NULL) {
7509             printf ("2\n") ;
7510             fflush (stdout) ;
7511             exit(0);
7512         }
7513         printf ("3\n") ;
7514     }
7515     else
7516         printf ("4\n") ;
7517     fflush (stdout) ;
7518     exit(0);
7519 }
7520 EOM
7521         : Call the object file tmp-dyna.o in case dlext=o.
7522         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7523                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7524                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7525                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7526                 xxx=`./fred`
7527                 case $xxx in
7528                 1)      echo "Test program failed using dlopen." >&4
7529                         echo "Perhaps you should not use dynamic loading." >&4;;
7530                 2)      echo "Test program failed using dlsym." >&4
7531                         echo "Perhaps you should not use dynamic loading." >&4;;
7532                 3)      echo "dlsym needs a leading underscore" >&4
7533                         val="$define" ;;
7534                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7535                 esac
7536         else
7537                 echo "I can't compile and run the test program." >&4
7538         fi
7539         ;;
7540 esac
7541                 
7542 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7543
7544 set d_dlsymun
7545 eval $setvar
7546
7547 hasproto='varname=$1; func=$2; shift; shift;
7548 while $test $# -ge 2; do
7549         case "$1" in
7550         $define) echo "#include <$2>";;
7551         esac ;
7552     shift 2;
7553 done > try.c;
7554 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7555 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7556         echo "$func() prototype found.";
7557         val="$define";
7558 else
7559         echo "$func() prototype NOT found.";
7560         val="$undef";
7561 fi;
7562 set $varname;
7563 eval $setvar;
7564 $rm -f try.c tryout.c'
7565
7566 : see if prototype for drand48 is available
7567 echo " "
7568 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7569 eval $hasproto
7570
7571 : see if dup2 exists
7572 set dup2 d_dup2
7573 eval $inlibc
7574
7575 : see if eaccess exists
7576 set eaccess d_eaccess
7577 eval $inlibc
7578
7579 : see if endgrent exists
7580 set endgrent d_endgrent
7581 eval $inlibc
7582
7583 : see if endhostent exists
7584 set endhostent d_endhent
7585 eval $inlibc
7586
7587 : see if endnetent exists
7588 set endnetent d_endnent
7589 eval $inlibc
7590
7591 : see if endprotoent exists
7592 set endprotoent d_endpent
7593 eval $inlibc
7594
7595 : see if endpwent exists
7596 set endpwent d_endpwent
7597 eval $inlibc
7598
7599 : see if endservent exists
7600 set endservent d_endsent
7601 eval $inlibc
7602
7603 : see if endspent exists
7604 set endspent d_endspent
7605 eval $inlibc
7606
7607 : Locate the flags for 'open()'
7608 echo " "
7609 $cat >open3.c <<'EOCP'
7610 #include <sys/types.h>
7611 #ifdef I_FCNTL
7612 #include <fcntl.h>
7613 #endif
7614 #ifdef I_SYS_FILE
7615 #include <sys/file.h>
7616 #endif
7617 int main() {
7618         if(O_RDONLY);
7619 #ifdef O_TRUNC
7620         exit(0);
7621 #else
7622         exit(1);
7623 #endif
7624 }
7625 EOCP
7626 : check sys/file.h first to get FREAD on Sun
7627 if $test `./findhdr sys/file.h` && \
7628                 set open3 -DI_SYS_FILE && eval $compile; then
7629         h_sysfile=true;
7630         echo "<sys/file.h> defines the O_* constants..." >&4
7631         if ./open3; then
7632                 echo "and you have the 3 argument form of open()." >&4
7633                 val="$define"
7634         else
7635                 echo "but not the 3 argument form of open().  Oh, well." >&4
7636                 val="$undef"
7637         fi
7638 elif $test `./findhdr fcntl.h` && \
7639                 set open3 -DI_FCNTL && eval $compile; then
7640         h_fcntl=true;
7641         echo "<fcntl.h> defines the O_* constants..." >&4
7642         if ./open3; then
7643                 echo "and you have the 3 argument form of open()." >&4
7644                 val="$define"
7645         else
7646                 echo "but not the 3 argument form of open().  Oh, well." >&4
7647                 val="$undef"
7648         fi
7649 else
7650         val="$undef"
7651         echo "I can't find the O_* constant definitions!  You got problems." >&4
7652 fi
7653 set d_open3
7654 eval $setvar
7655 $rm -f open3*
7656
7657 : check for non-blocking I/O stuff
7658 case "$h_sysfile" in
7659 true) echo "#include <sys/file.h>" > head.c;;
7660 *)
7661         case "$h_fcntl" in
7662         true) echo "#include <fcntl.h>" > head.c;;
7663         *) echo "#include <sys/fcntl.h>" > head.c;;
7664         esac
7665         ;;
7666 esac
7667 echo " "
7668 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7669 case "$o_nonblock" in
7670 '')
7671         $cat head.c > try.c
7672         $cat >>try.c <<'EOCP'
7673 int main() {
7674 #ifdef O_NONBLOCK
7675         printf("O_NONBLOCK\n");
7676         exit(0);
7677 #endif
7678 #ifdef O_NDELAY
7679         printf("O_NDELAY\n");
7680         exit(0);
7681 #endif
7682 #ifdef FNDELAY
7683         printf("FNDELAY\n");
7684         exit(0);
7685 #endif
7686         exit(0);
7687 }
7688 EOCP
7689         set try
7690         if eval $compile_ok; then
7691                 o_nonblock=`./try`
7692                 case "$o_nonblock" in
7693                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7694                 *) echo "Seems like we can use $o_nonblock.";;
7695                 esac
7696         else
7697                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7698         fi
7699         ;;
7700 *) echo "Using $hint value $o_nonblock.";;
7701 esac
7702 $rm -f try try.* .out core
7703
7704 echo " "
7705 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7706 case "$eagain" in
7707 '')
7708         $cat head.c > try.c
7709         $cat >>try.c <<EOCP
7710 #include <errno.h>
7711 #include <sys/types.h>
7712 #include <signal.h>
7713 #define MY_O_NONBLOCK $o_nonblock
7714 #ifndef errno  /* XXX need better Configure test */
7715 extern int errno;
7716 #endif
7717 $signal_t blech(x) int x; { exit(3); }
7718 EOCP
7719         $cat >> try.c <<'EOCP'
7720 int main()
7721 {
7722         int pd[2];
7723         int pu[2];
7724         char buf[1];
7725         char string[100];
7726
7727         pipe(pd);       /* Down: child -> parent */
7728         pipe(pu);       /* Up: parent -> child */
7729         if (0 != fork()) {
7730                 int ret;
7731                 close(pd[1]);   /* Parent reads from pd[0] */
7732                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7733                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7734                         exit(1);
7735                 signal(SIGALRM, blech);
7736                 alarm(5);
7737                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7738                         exit(2);
7739                 sprintf(string, "%d\n", ret);
7740                 write(2, string, strlen(string));
7741                 alarm(0);
7742 #ifdef EAGAIN
7743                 if (errno == EAGAIN) {
7744                         printf("EAGAIN\n");
7745                         goto ok;
7746                 }
7747 #endif
7748 #ifdef EWOULDBLOCK
7749                 if (errno == EWOULDBLOCK)
7750                         printf("EWOULDBLOCK\n");
7751 #endif
7752         ok:
7753                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7754                 sleep(2);                               /* Give it time to close our pipe */
7755                 alarm(5);
7756                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7757                 alarm(0);
7758                 sprintf(string, "%d\n", ret);
7759                 write(3, string, strlen(string));
7760                 exit(0);
7761         }
7762
7763         close(pd[0]);                   /* We write to pd[1] */
7764         close(pu[1]);                   /* We read from pu[0] */
7765         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7766         close(pd[1]);                   /* Pipe pd is now fully closed! */
7767         exit(0);                                /* Bye bye, thank you for playing! */
7768 }
7769 EOCP
7770         set try
7771         if eval $compile_ok; then
7772                 echo "$startsh" >mtry
7773                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7774                 chmod +x mtry
7775                 ./mtry >/dev/null 2>&1
7776                 case $? in
7777                 0) eagain=`$cat try.out`;;
7778                 1) echo "Could not perform non-blocking setting!";;
7779                 2) echo "I did a successful read() for something that was not there!";;
7780                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7781                 *) echo "Something terribly wrong happened during testing.";;
7782                 esac
7783                 rd_nodata=`$cat try.ret`
7784                 echo "A read() system call with no data present returns $rd_nodata."
7785                 case "$rd_nodata" in
7786                 0|-1) ;;
7787                 *)
7788                         echo "(That's peculiar, fixing that to be -1.)"
7789                         rd_nodata=-1
7790                         ;;
7791                 esac
7792                 case "$eagain" in
7793                 '')
7794                         echo "Forcing errno EAGAIN on read() with no data available."
7795                         eagain=EAGAIN
7796                         ;;
7797                 *)
7798                         echo "Your read() sets errno to $eagain when no data is available."
7799                         ;;
7800                 esac
7801                 status=`$cat try.err`
7802                 case "$status" in
7803                 0) echo "And it correctly returns 0 to signal EOF.";;
7804                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7805                 *) echo "However, your read() returns '$status' on EOF??";;
7806                 esac
7807                 val="$define"
7808                 if test "$status" = "$rd_nodata"; then
7809                         echo "WARNING: you can't distinguish between EOF and no data!"
7810                         val="$undef"
7811                 fi
7812         else
7813                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7814                 eagain=EAGAIN
7815         fi
7816         set d_eofnblk
7817         eval $setvar
7818         ;;
7819 *)
7820         echo "Using $hint value $eagain."
7821         echo "Your read() returns $rd_nodata when no data is present."
7822         case "$d_eofnblk" in
7823         "$define") echo "And you can see EOF because read() returns 0.";;
7824         "$undef") echo "But you can't see EOF status from read() returned value.";;
7825         *)
7826                 echo "(Assuming you can't see EOF status from read anyway.)"
7827                 d_eofnblk=$undef
7828                 ;;
7829         esac
7830         ;;
7831 esac
7832 $rm -f try try.* .out core head.c mtry
7833
7834 : see if fchmod exists
7835 set fchmod d_fchmod
7836 eval $inlibc
7837
7838 : see if fchown exists
7839 set fchown d_fchown
7840 eval $inlibc
7841
7842 : see if this is an fcntl system
7843 set fcntl d_fcntl
7844 eval $inlibc
7845
7846 : see if sys/select.h has to be included
7847 set sys/select.h i_sysselct
7848 eval $inhdr
7849
7850 : see if we should include time.h, sys/time.h, or both
7851 echo " "
7852 if test "X$timeincl" = X; then
7853         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7854         $echo $n "I'm now running the test program...$c"
7855         $cat >try.c <<'EOCP'
7856 #include <sys/types.h>
7857 #ifdef I_TIME
7858 #include <time.h>
7859 #endif
7860 #ifdef I_SYSTIME
7861 #ifdef SYSTIMEKERNEL
7862 #define KERNEL
7863 #endif
7864 #include <sys/time.h>
7865 #endif
7866 #ifdef I_SYSSELECT
7867 #include <sys/select.h>
7868 #endif
7869 int main()
7870 {
7871         struct tm foo;
7872 #ifdef S_TIMEVAL
7873         struct timeval bar;
7874 #endif
7875 #ifdef S_TIMEZONE
7876         struct timezone tzp;
7877 #endif
7878         if (foo.tm_sec == foo.tm_sec)
7879                 exit(0);
7880 #ifdef S_TIMEVAL
7881         if (bar.tv_sec == bar.tv_sec)
7882                 exit(0);
7883 #endif
7884         exit(1);
7885 }
7886 EOCP
7887         flags=''
7888         for s_timezone in '-DS_TIMEZONE' ''; do
7889         sysselect=''
7890         for s_timeval in '-DS_TIMEVAL' ''; do
7891         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7892         for i_time in '' '-DI_TIME'; do
7893         for i_systime in '-DI_SYSTIME' ''; do
7894                 case "$flags" in
7895                 '') $echo $n ".$c"
7896                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7897                         if eval $compile; then
7898                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7899                                 shift
7900                                 flags="$*"
7901                                 echo " "
7902                                 $echo $n "Succeeded with $flags$c"
7903                         fi
7904                         ;;
7905                 esac
7906         done
7907         done
7908         done
7909         done
7910         done
7911         timeincl=''
7912         echo " "
7913         case "$flags" in
7914         *SYSTIMEKERNEL*) i_systimek="$define"
7915                 timeincl=`./findhdr sys/time.h`
7916                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7917         *) i_systimek="$undef";;
7918         esac
7919         case "$flags" in
7920         *I_TIME*) i_time="$define"
7921                 timeincl=`./findhdr time.h`" $timeincl"
7922                 echo "We'll include <time.h>." >&4;;
7923         *) i_time="$undef";;
7924         esac
7925         case "$flags" in
7926         *I_SYSTIME*) i_systime="$define"
7927                 timeincl=`./findhdr sys/time.h`" $timeincl"
7928                 echo "We'll include <sys/time.h>." >&4;;
7929         *) i_systime="$undef";;
7930         esac
7931         $rm -f try.c try
7932 fi
7933
7934 : check for fd_set items
7935 $cat <<EOM
7936
7937 Checking to see how well your C compiler handles fd_set and friends ...
7938 EOM
7939 $cat >fd_set.c <<EOCP
7940 #$i_systime I_SYS_TIME
7941 #$i_sysselct I_SYS_SELECT
7942 #$d_socket HAS_SOCKET
7943 #include <sys/types.h>
7944 #ifdef HAS_SOCKET
7945 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7946 #endif
7947 #ifdef I_SYS_TIME
7948 #include <sys/time.h>
7949 #endif
7950 #ifdef I_SYS_SELECT
7951 #include <sys/select.h>
7952 #endif
7953 int main() {
7954         fd_set fds;
7955
7956 #ifdef TRYBITS
7957         if(fds.fds_bits);
7958 #endif
7959
7960 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7961         exit(0);
7962 #else
7963         exit(1);
7964 #endif
7965 }
7966 EOCP
7967 set fd_set -DTRYBITS
7968 if eval $compile; then
7969         d_fds_bits="$define"
7970         d_fd_set="$define"
7971         echo "Well, your system knows about the normal fd_set typedef..." >&4
7972         if ./fd_set; then
7973                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7974                 d_fd_macros="$define"
7975         else
7976                 $cat >&4 <<'EOM'
7977 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7978 EOM
7979                 d_fd_macros="$undef"
7980         fi
7981 else
7982         $cat <<'EOM'
7983 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7984 EOM
7985         set fd_set
7986         if eval $compile; then
7987                 d_fds_bits="$undef"
7988                 d_fd_set="$define"
7989                 echo "Well, your system has some sort of fd_set available..." >&4
7990                 if ./fd_set; then
7991                         echo "and you have the normal fd_set macros." >&4
7992                         d_fd_macros="$define"
7993                 else
7994                         $cat <<'EOM'
7995 but not the normal fd_set macros!  Gross!  More work for me...
7996 EOM
7997                         d_fd_macros="$undef"
7998                 fi
7999         else
8000         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
8001                 d_fd_set="$undef"
8002                 d_fds_bits="$undef"
8003                 d_fd_macros="$undef"
8004         fi
8005 fi
8006 $rm -f fd_set*
8007
8008 : see if fgetpos exists
8009 set fgetpos d_fgetpos
8010 eval $inlibc
8011
8012
8013 if $test X"$use64bits" = X"$define"; then
8014         : see if fgetpos64 exists
8015         set fgetpos64 d_fgetpos64
8016         eval $inlibc
8017
8018         : see if fopen64 exists
8019         set freopen64 d_fopen64
8020         eval $inlibc
8021
8022         : see if freopen64 exists
8023         set freopen64 d_freopen64
8024         eval $inlibc
8025
8026         : see if fseek64 exists
8027         set fseek64 d_fseek64
8028         eval $inlibc
8029
8030         : see if fseeko64 exists
8031         set fseeko64 d_fseeko64
8032         eval $inlibc
8033
8034         : see if fsetpos64 exists
8035         set fsetpos64 d_fsetpos64
8036         eval $inlibc
8037
8038         : see if ftell64 exists
8039         set ftell64 d_ftell64
8040         eval $inlibc
8041
8042         : see if ftello64 exists
8043         set ftello64 d_ftello64
8044         eval $inlibc
8045
8046         : see if tmpfile64 exists
8047         set tmpfile64 d_tmpfile64
8048         eval $inlibc
8049 else
8050         val="$undef"
8051         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
8052         do
8053                 set $xxx
8054                 eval $setvar
8055         done
8056 fi
8057
8058 : see if flock exists
8059 set flock d_flock
8060 eval $inlibc
8061
8062 : see if fork exists
8063 set fork d_fork
8064 eval $inlibc
8065
8066 : see if pathconf exists
8067 set pathconf d_pathconf
8068 eval $inlibc
8069
8070 : see if fpathconf exists
8071 set fpathconf d_fpathconf
8072 eval $inlibc
8073
8074 : see if fseeko exists
8075 set fseeko d_fseeko
8076 eval $inlibc
8077
8078 : see if fsetpos exists
8079 set fsetpos d_fsetpos
8080 eval $inlibc
8081
8082 : see if this is a sys/param system
8083 set sys/param.h i_sysparam
8084 eval $inhdr
8085
8086 : see if this is a sys/mount.h system
8087 set sys/mount.h i_sysmount
8088 eval $inhdr
8089
8090
8091 : see if statfs exists
8092 set statfs d_statfs
8093 eval $inlibc
8094
8095 : see if fstatfs exists
8096 set fstatfs d_fstatfs
8097 eval $inlibc
8098
8099 : see if statfs knows about mount flags
8100 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8101 eval $hasfield
8102
8103
8104 : see if statvfs exists
8105 set statvfs d_statvfs
8106 eval $inlibc
8107
8108 : see if fstatvfs exists
8109 set fstatvfs d_fstatvfs
8110 eval $inlibc
8111
8112
8113 : see if ftello exists
8114 set ftello d_ftello
8115 eval $inlibc
8116
8117 : see if getgrent exists
8118 set getgrent d_getgrent
8119 eval $inlibc
8120
8121 : see if gethostbyaddr exists
8122 set gethostbyaddr d_gethbyaddr
8123 eval $inlibc
8124
8125 : see if gethostbyname exists
8126 set gethostbyname d_gethbyname
8127 eval $inlibc
8128
8129 : see if gethostent exists
8130 set gethostent d_gethent
8131 eval $inlibc
8132
8133 : see how we will look up host name
8134 echo " "
8135 call=''
8136 if set gethostname val -f d_gethname; eval $csym; $val; then
8137         echo 'gethostname() found.' >&4
8138         d_gethname="$define"
8139         call=gethostname
8140 fi
8141 if set uname val -f d_uname; eval $csym; $val; then
8142         if ./xenix; then
8143                 $cat <<'EOM'
8144 uname() was found, but you're running xenix, and older versions of xenix
8145 have a broken uname(). If you don't really know whether your xenix is old
8146 enough to have a broken system call, use the default answer.
8147
8148 EOM
8149                 dflt=y
8150                 case "$d_uname" in
8151                 "$define") dflt=n;;
8152                 esac
8153                 rp='Is your uname() broken?'
8154                 . ./myread
8155                 case "$ans" in
8156                 n*) d_uname="$define"; call=uname;;
8157                 esac
8158         else
8159                 echo 'uname() found.' >&4
8160                 d_uname="$define"
8161                 case "$call" in
8162                 '') call=uname ;;
8163                 esac
8164         fi
8165 fi
8166 case "$d_gethname" in
8167 '') d_gethname="$undef";;
8168 esac
8169 case "$d_uname" in
8170 '') d_uname="$undef";;
8171 esac
8172 case "$d_uname$d_gethname" in
8173 *define*)
8174         dflt=n
8175         cat <<EOM
8176  
8177 Every now and then someone has a $call() that lies about the hostname
8178 but can't be fixed for political or economic reasons.  If you wish, I can
8179 pretend $call() isn't there and maybe compute hostname at run-time
8180 thanks to the '$phostname' command.
8181
8182 EOM
8183         rp="Shall I ignore $call() from now on?"
8184         . ./myread
8185         case "$ans" in
8186         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8187         esac;;
8188 esac
8189 case "$phostname" in
8190 '') aphostname='';;
8191 *) case "$aphostname" in
8192         /*) ;;
8193         *) set X $phostname
8194                 shift
8195                 file=$1
8196                 shift
8197                 file=`./loc $file $file $pth`
8198                 aphostname=`echo $file $*`
8199                 ;;
8200         esac
8201         ;;
8202 esac
8203 case "$d_uname$d_gethname" in
8204 *define*) ;;
8205 *)
8206         case "$phostname" in
8207         '')
8208                 echo "There will be no way for $package to get your hostname." >&4;;
8209         *)
8210         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8211                 ;;
8212         esac;;
8213 esac
8214 case "$d_phostname" in
8215 '') d_phostname="$undef";;
8216 esac
8217
8218 : see if this is a netdb.h system
8219 set netdb.h i_netdb
8220 eval $inhdr
8221
8222 : see if prototypes for various gethostxxx netdb.h functions are available
8223 echo " "
8224 set d_gethostprotos gethostent $i_netdb netdb.h
8225 eval $hasproto
8226
8227 : see if getlogin exists
8228 set getlogin d_getlogin
8229 eval $inlibc
8230
8231 : see if getmntent exists
8232 set getmntent d_getmntent
8233 eval $inlibc
8234
8235 : see if getnetbyaddr exists
8236 set getnetbyaddr d_getnbyaddr
8237 eval $inlibc
8238
8239 : see if getnetbyname exists
8240 set getnetbyname d_getnbyname
8241 eval $inlibc
8242
8243 : see if getnetent exists
8244 set getnetent d_getnent
8245 eval $inlibc
8246
8247 : see if prototypes for various getnetxxx netdb.h functions are available
8248 echo " "
8249 set d_getnetprotos getnetent $i_netdb netdb.h
8250 eval $hasproto
8251
8252
8253 : see if getprotobyname exists
8254 set getprotobyname d_getpbyname
8255 eval $inlibc
8256
8257 : see if getprotobynumber exists
8258 set getprotobynumber d_getpbynumber
8259 eval $inlibc
8260
8261 : see if getprotoent exists
8262 set getprotoent d_getpent
8263 eval $inlibc
8264
8265 : see if getpgid exists
8266 set getpgid d_getpgid
8267 eval $inlibc
8268
8269 : see if getpgrp2 exists
8270 set getpgrp2 d_getpgrp2
8271 eval $inlibc
8272
8273 : see if getppid exists
8274 set getppid d_getppid
8275 eval $inlibc
8276
8277 : see if getpriority exists
8278 set getpriority d_getprior
8279 eval $inlibc
8280
8281 : see if prototypes for various getprotoxxx netdb.h functions are available
8282 echo " "
8283 set d_getprotoprotos getprotoent $i_netdb netdb.h
8284 eval $hasproto
8285
8286 : see if getpwent exists
8287 set getpwent d_getpwent
8288 eval $inlibc
8289
8290
8291 : see if getservbyname exists
8292 set getservbyname d_getsbyname
8293 eval $inlibc
8294
8295 : see if getservbyport exists
8296 set getservbyport d_getsbyport
8297 eval $inlibc
8298
8299 : see if getservent exists
8300 set getservent d_getsent
8301 eval $inlibc
8302
8303 : see if prototypes for various getservxxx netdb.h functions are available
8304 echo " "
8305 set d_getservprotos getservent $i_netdb netdb.h
8306 eval $hasproto
8307
8308 : see if getspent exists
8309 set getspent d_getspent
8310 eval $inlibc
8311
8312 : see if getspnam exists
8313 set getspnam d_getspnam
8314 eval $inlibc
8315
8316 : see if gettimeofday or ftime exists
8317 set gettimeofday d_gettimeod
8318 eval $inlibc
8319 case "$d_gettimeod" in
8320 "$undef")
8321         set ftime d_ftime 
8322         eval $inlibc
8323         ;;
8324 *)
8325         val="$undef"; set d_ftime; eval $setvar
8326         ;;
8327 esac
8328 case "$d_gettimeod$d_ftime" in
8329 "$undef$undef")
8330         echo " "
8331         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8332         ;;
8333 esac
8334
8335 : see if this is an grp system
8336 set grp.h i_grp
8337 eval $inhdr
8338
8339 case "$i_grp" in
8340 $define)
8341         xxx=`./findhdr grp.h`
8342         $cppstdin $cppflags $cppminus < $xxx >$$.h
8343
8344         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8345                 val="$define"
8346         else
8347                 val="$undef"
8348         fi
8349         set d_grpasswd
8350         eval $setvar
8351
8352         $rm -f $$.h
8353         ;;
8354 *)
8355         val="$undef";
8356         set d_grpasswd; eval $setvar
8357         ;;
8358 esac
8359
8360 : see if hasmntopt exists
8361 set hasmntopt d_hasmntopt
8362 eval $inlibc
8363
8364 : see if this is a netinet/in.h or sys/in.h system
8365 set netinet/in.h i_niin sys/in.h i_sysin
8366 eval $inhdr
8367
8368 : see if arpa/inet.h has to be included
8369 set arpa/inet.h i_arpainet
8370 eval $inhdr
8371
8372 : see if htonl --and friends-- exists
8373 val=''
8374 set htonl val
8375 eval $inlibc
8376
8377 : Maybe they are macros.
8378 case "$val" in
8379 $undef)
8380         $cat >htonl.c <<EOM
8381 #include <stdio.h>
8382 #include <sys/types.h>
8383 #$i_niin I_NETINET_IN
8384 #$i_sysin I_SYS_IN
8385 #$i_arpainet I_ARPA_INET
8386 #ifdef I_NETINET_IN
8387 #include <netinet/in.h>
8388 #endif
8389 #ifdef I_SYS_IN
8390 #include <sys/in.h>
8391 #endif
8392 #ifdef I_ARPA_INET
8393 #include <arpa/inet.h>
8394 #endif
8395 #ifdef htonl
8396 printf("Defined as a macro.");
8397 #endif
8398 EOM
8399         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8400         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8401                 val="$define"
8402                 echo "But it seems to be defined as a macro." >&4
8403         fi
8404         $rm -f htonl.?
8405         ;;
8406 esac
8407 set d_htonl
8408 eval $setvar
8409
8410 : see which of string.h or strings.h is needed
8411 echo " "
8412 strings=`./findhdr string.h`
8413 if $test "$strings" && $test -r "$strings"; then
8414         echo "Using <string.h> instead of <strings.h>." >&4
8415         val="$define"
8416 else
8417         val="$undef"
8418         strings=`./findhdr strings.h`
8419         if $test "$strings" && $test -r "$strings"; then
8420                 echo "Using <strings.h> instead of <string.h>." >&4
8421         else
8422                 echo "No string header found -- You'll surely have problems." >&4
8423         fi
8424 fi
8425 set i_string
8426 eval $setvar
8427 case "$i_string" in
8428 "$undef") strings=`./findhdr strings.h`;;
8429 *)        strings=`./findhdr string.h`;;
8430 esac
8431
8432 : index or strchr
8433 echo " "
8434 if set index val -f; eval $csym; $val; then
8435         if set strchr val -f d_strchr; eval $csym; $val; then
8436                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8437                         val="$define"
8438                         vali="$undef"
8439                         echo "strchr() found." >&4
8440                 else
8441                         val="$undef"
8442                         vali="$define"
8443                         echo "index() found." >&4
8444                 fi
8445         else
8446                 val="$undef"
8447                 vali="$define"
8448                 echo "index() found." >&4
8449         fi
8450 else
8451         if set strchr val -f d_strchr; eval $csym; $val; then
8452                 val="$define"
8453                 vali="$undef"
8454                 echo "strchr() found." >&4
8455         else
8456                 echo "No index() or strchr() found!" >&4
8457                 val="$undef"
8458                 vali="$undef"
8459         fi
8460 fi
8461 set d_strchr; eval $setvar
8462 val="$vali"
8463 set d_index; eval $setvar
8464
8465 : check whether inet_aton exists
8466 set inet_aton d_inetaton
8467 eval $inlibc
8468
8469 : see if inttypes.h is available
8470 : we want a real compile instead of Inhdr because some systems
8471 : have an inttypes.h which includes non-existent headers
8472 echo " "
8473 $cat >try.c <<EOCP
8474 #include <inttypes.h>
8475 int main() {
8476         static int32_t foo32 = 0x12345678;
8477 }
8478 EOCP
8479 set try
8480 if eval $compile; then
8481         echo "<inttypes.h> found." >&4
8482         val="$define"
8483 else
8484         echo "<inttypes.h> NOT found." >&4
8485         val="$undef"
8486 fi
8487 $rm -f try.c try
8488 set i_inttypes
8489 eval $setvar
8490
8491 : check for int64_t
8492 case "$use64bits" in
8493 "$define" )
8494         echo " "
8495         echo $n "Checking to see if your system supports int64_t...$c" >&4
8496         $cat >try.c <<EOCP
8497 #include <sys/types.h>
8498 #$i_inttypes I_INTTYPES
8499 #ifdef I_INTTYPES
8500 #include <inttypes.h>
8501 #endif
8502 int64_t foo() { int64_t x; x = 7; return x; }
8503 EOCP
8504         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8505                 val="$define"
8506                 echo " Yup, it does." >&4
8507         else
8508                 val="$undef"
8509                 echo " Nope, it doesn't." >&4
8510         fi
8511         $rm -f try.*
8512         ;;
8513 *)      val="$undef"
8514         ;;
8515 esac
8516 set d_int64t
8517 eval $setvar
8518
8519
8520 : Look for isascii
8521 echo " "
8522 $cat >isascii.c <<'EOCP'
8523 #include <stdio.h>
8524 #include <ctype.h>
8525 int main() {
8526         int c = 'A';
8527         if (isascii(c))
8528                 exit(0);
8529         else
8530                 exit(1);
8531 }
8532 EOCP
8533 set isascii
8534 if eval $compile; then
8535         echo "isascii() found." >&4
8536         val="$define"
8537 else
8538         echo "isascii() NOT found." >&4
8539         val="$undef"
8540 fi
8541 set d_isascii
8542 eval $setvar
8543 $rm -f isascii*
8544
8545 : see if killpg exists
8546 set killpg d_killpg
8547 eval $inlibc
8548
8549 : see if lchown exists
8550 echo " "
8551 $cat > try.c <<'EOCP'
8552 /* System header to define __stub macros and hopefully few prototypes,
8553     which can conflict with char lchown(); below.  */
8554 #include <assert.h>
8555 /* Override any gcc2 internal prototype to avoid an error.  */
8556 /* We use char because int might match the return type of a gcc2
8557    builtin and then its argument prototype would still apply.  */
8558 char lchown();
8559 int main() {
8560     /*  The GNU C library defines this for functions which it implements
8561         to always fail with ENOSYS.  Some functions are actually named
8562         something starting with __ and the normal name is an alias.  */
8563 #if defined (__stub_lchown) || defined (__stub___lchown)
8564 choke me
8565 #else
8566 lchown();
8567 #endif
8568 ; return 0; }
8569 EOCP
8570 set try
8571 if eval $compile; then
8572     $echo "lchown() found." >&4
8573     val="$define"
8574 else
8575     $echo "lchown() NOT found." >&4
8576     val="$undef"
8577 fi
8578 set d_lchown
8579 eval $setvar
8580
8581 : see if link exists
8582 set link d_link
8583 eval $inlibc
8584
8585 : see if localeconv exists
8586 set localeconv d_locconv
8587 eval $inlibc
8588
8589 : see if lockf exists
8590 set lockf d_lockf
8591 eval $inlibc
8592
8593 : check for length of double
8594 echo " "
8595 case "$doublesize" in
8596 '')
8597         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8598         $cat >try.c <<'EOCP'
8599 #include <stdio.h>
8600 int main()
8601 {
8602         printf("%d\n", sizeof(double));
8603 }
8604 EOCP
8605         set try
8606         if eval $compile_ok; then
8607                 doublesize=`./try`
8608                 $echo " $doublesize bytes." >&4
8609         else
8610                 dflt='8'
8611                 echo "(I can't seem to compile the test program.  Guessing...)"
8612                 rp="What is the size of a double precision number (in bytes)?"
8613                 . ./myread
8614                 doublesize="$ans"
8615         fi
8616         ;;
8617 esac
8618 $rm -f try.c try
8619
8620 : check for long doubles
8621 echo " "
8622 echo $n "Checking to see if your system supports long doubles...$c" >&4
8623 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8624 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8625         val="$define"
8626         echo " Yup, it does." >&4
8627 else
8628         val="$undef"
8629         echo " Nope, it doesn't." >&4
8630 fi
8631 $rm try.*
8632 set d_longdbl
8633 eval $setvar
8634
8635 : check for length of long double
8636 case "${d_longdbl}${longdblsize}" in
8637 $define)
8638         echo " "
8639         $echo $n "Checking to see how big your long doubles are...$c" >&4
8640         $cat >try.c <<'EOCP'
8641 #include <stdio.h>
8642 int main()
8643 {
8644         printf("%d\n", sizeof(long double));
8645 }
8646 EOCP
8647         set try
8648         if eval $compile; then
8649                 longdblsize=`./try`
8650                 $echo " $longdblsize bytes." >&4
8651         else
8652                 dflt='8'
8653                 echo " "
8654                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8655                 rp="What is the size of a long double (in bytes)?"
8656                 . ./myread
8657                 longdblsize="$ans"
8658         fi
8659         if $test "X$doublesize" = "X$longdblsize"; then
8660                 echo "(That isn't any different from an ordinary double.)"
8661         fi      
8662         ;;
8663 esac
8664 $rm -f try.c try
8665
8666 : check for long long
8667 echo " "
8668 echo $n "Checking to see if your system supports long long...$c" >&4
8669 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8670 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8671         val="$define"
8672         echo " Yup, it does." >&4
8673 else
8674         val="$undef"
8675         echo " Nope, it doesn't." >&4
8676 fi
8677 $rm try.*
8678 set d_longlong
8679 eval $setvar
8680
8681 : check for length of long long
8682 case "${d_longlong}${longlongsize}" in
8683 $define)
8684         echo " "
8685         $echo $n "Checking to see how big your long longs are...$c" >&4
8686         $cat >try.c <<'EOCP'
8687 #include <stdio.h>
8688 int main()
8689 {
8690         printf("%d\n", sizeof(long long));
8691 }
8692 EOCP
8693         set try
8694         if eval $compile_ok; then
8695                 longlongsize=`./try`
8696                 $echo " $longlongsize bytes." >&4
8697         else
8698                 dflt='8'
8699                 echo " "
8700                 echo "(I can't seem to compile the test program.  Guessing...)"
8701                 rp="What is the size of a long long (in bytes)?"
8702                 . ./myread
8703                 longlongsize="$ans"
8704         fi
8705         if $test "X$longsize" = "X$longlongsize"; then
8706                 echo "(That isn't any different from an ordinary long.)"
8707         fi      
8708         ;;
8709 esac
8710 $rm -f try.c try
8711
8712 : see if lstat exists
8713 set lstat d_lstat
8714 eval $inlibc
8715
8716 : see if madvise exists
8717 set madvise d_madvise
8718 eval $inlibc
8719
8720 : see if mblen exists
8721 set mblen d_mblen
8722 eval $inlibc
8723
8724 : see if mbstowcs exists
8725 set mbstowcs d_mbstowcs
8726 eval $inlibc
8727
8728 : see if mbtowc exists
8729 set mbtowc d_mbtowc
8730 eval $inlibc
8731
8732 : see if memchr exists
8733 set memchr d_memchr
8734 eval $inlibc
8735
8736 : see if memcmp exists
8737 set memcmp d_memcmp
8738 eval $inlibc
8739
8740 : see if memcpy exists
8741 set memcpy d_memcpy
8742 eval $inlibc
8743
8744 : see if memmove exists
8745 set memmove d_memmove
8746 eval $inlibc
8747
8748 : see if memset exists
8749 set memset d_memset
8750 eval $inlibc
8751
8752 : see if mkdir exists
8753 set mkdir d_mkdir
8754 eval $inlibc
8755
8756 : see if mkfifo exists
8757 set mkfifo d_mkfifo
8758 eval $inlibc
8759
8760 : see if mktime exists
8761 set mktime d_mktime
8762 eval $inlibc
8763
8764 : see if this is a sys/mman.h system
8765 set sys/mman.h i_sysmman
8766 eval $inhdr
8767
8768 : see if mmap exists
8769 set mmap d_mmap
8770 eval $inlibc
8771 : see what shmat returns
8772 : default to something harmless
8773 mmaptype='void *'
8774 case "$i_sysmman$d_mmap" in
8775 "$define$define")
8776         $cat >mmap.c <<'END'
8777 #include <sys/mman.h>
8778 void *mmap();
8779 END
8780         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8781                 mmaptype='void *'
8782         else
8783                 mmaptype='caddr_t'
8784         fi
8785         echo "and it returns ($mmaptype)." >&4
8786         ;;
8787 esac
8788
8789
8790
8791 : see if mprotect exists
8792 set mprotect d_mprotect
8793 eval $inlibc
8794
8795 : see if msgctl exists
8796 set msgctl d_msgctl
8797 eval $inlibc
8798
8799 : see if msgget exists
8800 set msgget d_msgget
8801 eval $inlibc
8802
8803 : see if msgsnd exists
8804 set msgsnd d_msgsnd
8805 eval $inlibc
8806
8807 : see if msgrcv exists
8808 set msgrcv d_msgrcv
8809 eval $inlibc
8810
8811 : see how much of the 'msg*(2)' library is present.
8812 h_msg=true
8813 echo " "
8814 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8815 *"$undef"*) h_msg=false;;
8816 esac
8817 case "$osname" in
8818 freebsd)
8819     case "`ipcs 2>&1`" in
8820     "SVID messages"*"not configured"*)
8821         echo "Your $osname does not have the msg*(2) configured." >&4
8822         h_msg=false
8823         val="$undef"
8824         set msgctl d_msgctl
8825         eval $setvar
8826         set msgget d_msgget
8827         eval $setvar
8828         set msgsnd d_msgsnd
8829         eval $setvar
8830         set msgrcv d_msgrcv
8831         eval $setvar
8832         ;;
8833     esac
8834     ;;
8835 esac
8836 : we could also check for sys/ipc.h ...
8837 if $h_msg && $test `./findhdr sys/msg.h`; then
8838         echo "You have the full msg*(2) library." >&4
8839         val="$define"
8840 else
8841         echo "You don't have the full msg*(2) library." >&4
8842         val="$undef"
8843 fi
8844 set d_msg
8845 eval $setvar
8846
8847 : see if msync exists
8848 set msync d_msync
8849 eval $inlibc
8850
8851 : see if munmap exists
8852 set munmap d_munmap
8853 eval $inlibc
8854
8855 : see if nice exists
8856 set nice d_nice
8857 eval $inlibc
8858
8859 : see if POSIX threads are available
8860 if test "X$usethreads" = "X$define"; then
8861         set pthread.h i_pthread
8862         eval $inhdr
8863 else
8864         i_pthread="$undef"
8865 fi
8866
8867
8868
8869 : how to create joinable pthreads
8870 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
8871         echo " "
8872         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8873         $cat >try.c <<'EOCP'
8874 #include <pthread.h>
8875 int main() {
8876     int detachstate = JOINABLE;
8877 }
8878 EOCP
8879         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8880         if eval $compile; then
8881                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8882                 val="$undef" # Yes, undef.
8883                 set d_old_pthread_create_joinable
8884                 eval $setvar
8885                 val=""
8886                 set old_pthread_create_joinable
8887                 eval $setvar
8888         else
8889                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8890                 if eval $compile; then
8891                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8892                         val="$define"
8893                         set d_old_pthread_create_joinable
8894                         eval $setvar
8895                         val=PTHREAD_CREATE_UNDETACHED
8896                         set old_pthread_create_joinable
8897                         eval $setvar
8898                 else            
8899                         set try -DJOINABLE=__UNDETACHED
8900                         if eval $compile; then
8901                                 echo "You seem to use __UNDETACHED." >&4
8902                                 val="$define"
8903                                 set d_old_pthread_create_joinable
8904                                 eval $setvar
8905                                 val=__UNDETACHED
8906                                 set old_pthread_create_joinable
8907                                 eval $setvar
8908                         else
8909                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8910                                 val="$define"
8911                                 set d_old_pthread_create_joinable
8912                                 eval $setvar
8913                                 val=0
8914                                 set old_pthread_create_joinable
8915                                 eval $setvar
8916                         fi
8917                 fi
8918         fi
8919         $rm -f try try.*
8920 else
8921     d_old_pthread_create_joinable="$undef"
8922     old_pthread_create_joinable=""
8923 fi
8924
8925 : see if pause exists
8926 set pause d_pause
8927 eval $inlibc
8928
8929 : see if pipe exists
8930 set pipe d_pipe
8931 eval $inlibc
8932
8933 : see if poll exists
8934 set poll d_poll
8935 eval $inlibc
8936
8937
8938 : see whether the various POSIXish _yields exist
8939 $cat >try.c <<EOP
8940 #include <pthread.h>
8941 #include <stdio.h>
8942 int main() {
8943 #ifdef SCHED_YIELD
8944         sched_yield();
8945 #else
8946 #ifdef PTHREAD_YIELD
8947         pthread_yield();
8948 #else
8949 #ifdef PTHREAD_YIELD_NULL
8950         pthread_yield(NULL);
8951 #endif
8952 #endif
8953 #endif
8954 }
8955 EOP
8956 : see if sched_yield exists
8957 set try -DSCHED_YIELD
8958 if eval $compile; then
8959     val="$define"
8960     sched_yield='sched_yield()'
8961 else
8962     val="$undef"
8963 fi
8964 case "$usethreads" in
8965 $define)
8966         case "$val" in
8967         $define) echo 'sched_yield() found.' >&4        ;;
8968         *)       echo 'sched_yield() NOT found.' >&4    ;;
8969         esac
8970 esac
8971 set d_sched_yield
8972 eval $setvar
8973
8974 : see if pthread_yield exists
8975 set try -DPTHREAD_YIELD
8976 if eval $compile; then
8977     val="$define"
8978     case "$sched_yield" in
8979     '') sched_yield='pthread_yield()' ;;
8980     esac
8981 else
8982     set try -DPTHREAD_YIELD_NULL
8983     if eval $compile; then
8984         val="$define"
8985         case "$sched_yield" in
8986         '') sched_yield='pthread_yield(NULL)' ;;
8987         esac
8988     else
8989         val="$undef"
8990     fi
8991 fi
8992 case "$usethreads" in
8993 $define)
8994         case "$val" in
8995         $define) echo 'pthread_yield() found.' >&4      ;;
8996         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8997         esac
8998         ;;
8999 esac
9000 set d_pthread_yield
9001 eval $setvar
9002
9003 case "$sched_yield" in
9004 '') sched_yield=undef ;;
9005 esac
9006
9007 $rm -f try try.*
9008
9009 : see if this is a pwd.h system
9010 set pwd.h i_pwd
9011 eval $inhdr
9012
9013 case "$i_pwd" in
9014 $define)
9015         xxx=`./findhdr pwd.h`
9016         $cppstdin $cppflags $cppminus < $xxx >$$.h
9017
9018         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
9019                 val="$define"
9020         else
9021                 val="$undef"
9022         fi
9023         set d_pwquota
9024         eval $setvar
9025
9026         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
9027                 val="$define"
9028         else
9029                 val="$undef"
9030         fi
9031         set d_pwage
9032         eval $setvar
9033
9034         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
9035                 val="$define"
9036         else
9037                 val="$undef"
9038         fi
9039         set d_pwchange
9040         eval $setvar
9041
9042         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
9043                 val="$define"
9044         else
9045                 val="$undef"
9046         fi
9047         set d_pwclass
9048         eval $setvar
9049
9050         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
9051                 val="$define"
9052         else
9053                 val="$undef"
9054         fi
9055         set d_pwexpire
9056         eval $setvar
9057
9058         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
9059                 val="$define"
9060         else
9061                 val="$undef"
9062         fi
9063         set d_pwcomment
9064         eval $setvar
9065
9066         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
9067                 val="$define"
9068         else
9069                 val="$undef"
9070         fi
9071         set d_pwgecos
9072         eval $setvar
9073
9074         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
9075                 val="$define"
9076         else
9077                 val="$undef"
9078         fi
9079         set d_pwpasswd
9080         eval $setvar
9081
9082         $rm -f $$.h
9083         ;;
9084 *)
9085         val="$undef"; 
9086         set d_pwquota; eval $setvar
9087         set d_pwage; eval $setvar
9088         set d_pwchange; eval $setvar
9089         set d_pwclass; eval $setvar
9090         set d_pwexpire; eval $setvar
9091         set d_pwcomment; eval $setvar
9092         set d_pwgecos; eval $setvar
9093         set d_pwpasswd; eval $setvar
9094         ;;
9095 esac
9096
9097 : see if readdir and friends exist
9098 set readdir d_readdir
9099 eval $inlibc
9100 set seekdir d_seekdir
9101 eval $inlibc
9102 set telldir d_telldir
9103 eval $inlibc
9104 set rewinddir d_rewinddir
9105 eval $inlibc
9106
9107 : see if readlink exists
9108 set readlink d_readlink
9109 eval $inlibc
9110
9111 : see if readv exists
9112 set readv d_readv
9113 eval $inlibc
9114
9115 : see if rename exists
9116 set rename d_rename
9117 eval $inlibc
9118
9119 : see if rmdir exists
9120 set rmdir d_rmdir
9121 eval $inlibc
9122
9123 : see if memory.h is available.
9124 val=''
9125 set memory.h val
9126 eval $inhdr
9127
9128 : See if it conflicts with string.h
9129 case "$val" in
9130 $define)
9131         case "$strings" in
9132         '') ;;
9133         *)
9134                 $cppstdin $cppflags $cppminus < $strings > mem.h
9135                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9136                         echo " "
9137                         echo "We won't be including <memory.h>."
9138                         val="$undef"
9139                 fi
9140                 $rm -f mem.h
9141                 ;;
9142         esac
9143 esac
9144 set i_memory
9145 eval $setvar
9146
9147 : can bcopy handle overlapping blocks?
9148 val="$undef"
9149 case "$d_bcopy" in
9150 "$define")
9151         echo " "
9152         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9153         $cat >try.c <<EOCP
9154 #$i_memory I_MEMORY
9155 #$i_stdlib I_STDLIB
9156 #$i_string I_STRING
9157 #$i_unistd I_UNISTD
9158 EOCP
9159         $cat >>try.c <<'EOCP'
9160 #include <stdio.h>
9161 #ifdef I_MEMORY
9162 #  include <memory.h>
9163 #endif
9164 #ifdef I_STDLIB
9165 #  include <stdlib.h>
9166 #endif
9167 #ifdef I_STRING
9168 #  include <string.h>
9169 #else
9170 #  include <strings.h>
9171 #endif
9172 #ifdef I_UNISTD
9173 #  include <unistd.h>  /* Needed for NetBSD */
9174 #endif
9175 int main()
9176 {
9177 char buf[128], abc[128];
9178 char *b;
9179 int len;
9180 int off;
9181 int align;
9182
9183 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9184
9185 for (align = 7; align >= 0; align--) {
9186         for (len = 36; len; len--) {
9187                 b = buf+align;
9188                 bcopy(abc, b, len);
9189                 for (off = 1; off <= len; off++) {
9190                         bcopy(b, b+off, len);
9191                         bcopy(b+off, b, len);
9192                         if (bcmp(b, abc, len))
9193                                 exit(1);
9194                 }
9195         }
9196 }
9197 exit(0);
9198 }
9199 EOCP
9200         set try
9201         if eval $compile_ok; then
9202                 if ./try 2>/dev/null; then
9203                         echo "Yes, it can."
9204                         val="$define"
9205                 else
9206                         echo "It can't, sorry."
9207                         case "$d_memmove" in
9208                         "$define") echo "But that's Ok since you have memmove()." ;;
9209                         esac
9210                 fi
9211         else
9212                 echo "(I can't compile the test program, so we'll assume not...)"
9213                 case "$d_memmove" in
9214                 "$define") echo "But that's Ok since you have memmove()." ;;
9215                 esac
9216         fi
9217         ;;
9218 esac
9219 $rm -f try.* try core
9220 set d_safebcpy
9221 eval $setvar
9222
9223 : can memcpy handle overlapping blocks?
9224 val="$undef"
9225 case "$d_memcpy" in
9226 "$define")
9227         echo " "
9228         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9229         $cat >try.c <<EOCP
9230 #$i_memory I_MEMORY
9231 #$i_stdlib I_STDLIB
9232 #$i_string I_STRING
9233 #$i_unistd I_UNISTD
9234 EOCP
9235         $cat >>try.c <<'EOCP'
9236 #include <stdio.h>
9237 #ifdef I_MEMORY
9238 #  include <memory.h>
9239 #endif
9240 #ifdef I_STDLIB
9241 #  include <stdlib.h>
9242 #endif
9243 #ifdef I_STRING
9244 #  include <string.h>
9245 #else
9246 #  include <strings.h>
9247 #endif
9248 #ifdef I_UNISTD
9249 #  include <unistd.h>  /* Needed for NetBSD */
9250 #endif
9251 int main()
9252 {
9253 char buf[128], abc[128];
9254 char *b;
9255 int len;
9256 int off;
9257 int align;
9258
9259 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9260    try to store the string in read-only memory. */
9261 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9262
9263 for (align = 7; align >= 0; align--) {
9264         for (len = 36; len; len--) {
9265                 b = buf+align;
9266                 memcpy(b, abc, len);
9267                 for (off = 1; off <= len; off++) {
9268                         memcpy(b+off, b, len);
9269                         memcpy(b, b+off, len);
9270                         if (memcmp(b, abc, len))
9271                                 exit(1);
9272                 }
9273         }
9274 }
9275 exit(0);
9276 }
9277 EOCP
9278         set try
9279         if eval $compile_ok; then
9280                 if ./try 2>/dev/null; then
9281                         echo "Yes, it can."
9282                         val="$define"
9283                 else
9284                         echo "It can't, sorry."
9285                         case "$d_memmove" in
9286                         "$define") echo "But that's Ok since you have memmove()." ;;
9287                         esac
9288                 fi
9289         else
9290                 echo "(I can't compile the test program, so we'll assume not...)"
9291                 case "$d_memmove" in
9292                 "$define") echo "But that's Ok since you have memmove()." ;;
9293                 esac
9294         fi
9295         ;;
9296 esac
9297 $rm -f try.* try core
9298 set d_safemcpy
9299 eval $setvar
9300
9301 : can memcmp be trusted to compare relative magnitude?
9302 val="$undef"
9303 case "$d_memcmp" in
9304 "$define")
9305         echo " "
9306         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9307         $cat >try.c <<EOCP
9308 #$i_memory I_MEMORY
9309 #$i_stdlib I_STDLIB
9310 #$i_string I_STRING
9311 #$i_unistd I_UNISTD
9312 EOCP
9313         $cat >>try.c <<'EOCP'
9314 #include <stdio.h>
9315 #ifdef I_MEMORY
9316 #  include <memory.h>
9317 #endif
9318 #ifdef I_STDLIB
9319 #  include <stdlib.h>
9320 #endif
9321 #ifdef I_STRING
9322 #  include <string.h>
9323 #else
9324 #  include <strings.h>
9325 #endif
9326 #ifdef I_UNISTD
9327 #  include <unistd.h>  /* Needed for NetBSD */
9328 #endif
9329 int main()
9330 {
9331 char a = -1;
9332 char b = 0;
9333 if ((a < b) && memcmp(&a, &b, 1) < 0)
9334         exit(1);
9335 exit(0);
9336 }
9337 EOCP
9338         set try
9339         if eval $compile_ok; then
9340                 if ./try 2>/dev/null; then
9341                         echo "Yes, it can."
9342                         val="$define"
9343                 else
9344                         echo "No, it can't (it uses signed chars)."
9345                 fi
9346         else
9347                 echo "(I can't compile the test program, so we'll assume not...)"
9348         fi
9349         ;;
9350 esac
9351 $rm -f try.* try core
9352 set d_sanemcmp
9353 eval $setvar
9354
9355 : see if select exists
9356 set select d_select
9357 eval $inlibc
9358
9359 : see if semctl exists
9360 set semctl d_semctl
9361 eval $inlibc
9362
9363 : see if semget exists
9364 set semget d_semget
9365 eval $inlibc
9366
9367 : see if semop exists
9368 set semop d_semop
9369 eval $inlibc
9370
9371 : see how much of the 'sem*(2)' library is present.
9372 h_sem=true
9373 echo " "
9374 case "$d_semctl$d_semget$d_semop" in
9375 *"$undef"*) h_sem=false;;
9376 esac
9377 case "$osname" in
9378 freebsd)
9379     case "`ipcs 2>&1`" in
9380     "SVID messages"*"not configured"*)
9381         echo "Your $osname does not have the sem*(2) configured." >&4
9382         h_sem=false
9383         val="$undef"
9384         set semctl d_semctl
9385         eval $setvar
9386         set semget d_semget
9387         eval $setvar
9388         set semop d_semop
9389         eval $setvar
9390         ;;
9391     esac
9392     ;;
9393 esac
9394 : we could also check for sys/ipc.h ...
9395 if $h_sem && $test `./findhdr sys/sem.h`; then
9396         echo "You have the full sem*(2) library." >&4
9397         val="$define"
9398 else
9399         echo "You don't have the full sem*(2) library." >&4
9400         val="$undef"
9401 fi
9402 set d_sem
9403 eval $setvar
9404
9405 : see whether sys/sem.h defines union semun
9406 echo " "
9407 $cat > try.c <<'END'
9408 #include <sys/types.h>
9409 #include <sys/ipc.h>
9410 #include <sys/sem.h>
9411 int main () { union semun semun; semun.buf = 0; }
9412 END
9413 set try
9414 if eval $compile; then
9415     echo "You have union semun in <sys/sem.h>." >&4
9416     val="$define"
9417 else
9418     echo "You do not have union semun in <sys/sem.h>." >&4
9419     val="$undef"
9420 fi
9421 $rm -f try try.c try.h
9422 set d_union_semun
9423 eval $setvar
9424
9425 : see how to do semctl IPC_STAT
9426 case "$d_sem" in
9427 $define)
9428     : see whether semctl IPC_STAT can use union semun
9429     echo " "
9430     $cat > try.h <<END
9431 #ifndef S_IRUSR
9432 #   ifdef S_IREAD
9433 #       define S_IRUSR S_IREAD
9434 #       define S_IWUSR S_IWRITE
9435 #       define S_IXUSR S_IEXEC
9436 #   else
9437 #       define S_IRUSR 0400
9438 #       define S_IWUSR 0200
9439 #       define S_IXUSR 0100
9440 #   endif
9441 #   define S_IRGRP (S_IRUSR>>3)
9442 #   define S_IWGRP (S_IWUSR>>3)
9443 #   define S_IXGRP (S_IXUSR>>3)
9444 #   define S_IROTH (S_IRUSR>>6)
9445 #   define S_IWOTH (S_IWUSR>>6)
9446 #   define S_IXOTH (S_IXUSR>>6)
9447 #endif
9448 #ifndef S_IRWXU
9449 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9450 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9451 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9452 #endif
9453 END
9454
9455     $cat > try.c <<END
9456 #include <sys/types.h>
9457 #include <sys/ipc.h>
9458 #include <sys/sem.h>
9459 #include <sys/stat.h>
9460 #include <stdio.h>
9461 #include <errno.h>
9462 #include "try.h"
9463 #ifndef errno
9464 extern int errno;
9465 #endif
9466 #$d_union_semun HAS_UNION_SEMUN
9467 int main() {
9468     union semun
9469 #ifndef HAS_UNION_SEMUN
9470     {
9471         int val;
9472         struct semid_ds *buf;
9473         unsigned short *array;
9474     }
9475 #endif
9476     arg;
9477     int sem, st;
9478
9479 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9480     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9481     if (sem > -1) {
9482         struct semid_ds argbuf;
9483         arg.buf = &argbuf;
9484 #       ifdef IPC_STAT
9485         st = semctl(sem, 0, IPC_STAT, arg);
9486         if (st == 0)
9487             printf("semun\n");
9488         else
9489 #       endif /* IPC_STAT */
9490             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9491 #       ifdef IPC_RMID
9492         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9493 #       endif /* IPC_RMID */
9494             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9495     } else
9496 #endif /* IPC_PRIVATE && ... */
9497         printf("semget failed: errno = %d\n", errno);
9498   return 0;
9499 }
9500 END
9501     val="$undef"
9502     set try
9503     if eval $compile; then
9504         xxx=`./try`
9505         case "$xxx" in
9506         semun) val="$define" ;;
9507         esac
9508     fi
9509     $rm -f try try.c
9510     set d_semctl_semun
9511     eval $setvar
9512     case "$d_semctl_semun" in
9513     $define)
9514         echo "You can use union semun for semctl IPC_STAT." >&4
9515         also='also'
9516         ;;
9517     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9518         also=''
9519         ;;
9520     esac
9521
9522     : see whether semctl IPC_STAT can use struct semid_ds pointer
9523     $cat > try.c <<'END'
9524 #include <sys/types.h>
9525 #include <sys/ipc.h>
9526 #include <sys/sem.h>
9527 #include <sys/stat.h>
9528 #include "try.h"
9529 #include <stdio.h>
9530 #include <errno.h>
9531 #ifndef errno
9532 extern int errno;
9533 #endif
9534 int main() {
9535     struct semid_ds arg;
9536     int sem, st;
9537
9538 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9539     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9540     if (sem > -1) {
9541 #       ifdef IPC_STAT
9542         st = semctl(sem, 0, IPC_STAT, &arg);
9543         if (st == 0)
9544             printf("semid_ds\n");
9545         else
9546 #       endif /* IPC_STAT */
9547             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9548 #       ifdef IPC_RMID
9549         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9550 #       endif /* IPC_RMID */
9551             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9552     } else
9553 #endif /* IPC_PRIVATE && ... */
9554         printf("semget failed: errno = %d\n", errno);
9555
9556     return 0;
9557 }
9558 END
9559     val="$undef"
9560     set try
9561     if eval $compile; then
9562         xxx=`./try`
9563         case "$xxx" in
9564         semid_ds) val="$define" ;;
9565         esac
9566     fi
9567     $rm -f try try.c
9568     set d_semctl_semid_ds
9569     eval $setvar
9570     case "$d_semctl_semid_ds" in
9571     $define)
9572         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9573         ;;
9574     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9575         ;;
9576     esac
9577     $rm -f try.h
9578     ;;
9579 *)  val="$undef"
9580
9581     # We do not have the full sem*(2) library, so assume we can not
9582     # use either.
9583
9584     set d_semctl_semun
9585     eval $setvar
9586
9587     set d_semctl_semid_ds
9588     eval $setvar
9589     ;;
9590 esac
9591
9592 : see if setegid exists
9593 set setegid d_setegid
9594 eval $inlibc
9595
9596 : see if seteuid exists
9597 set seteuid d_seteuid
9598 eval $inlibc
9599
9600 : see if setgrent exists
9601 set setgrent d_setgrent
9602 eval $inlibc
9603
9604 : see if sethostent exists
9605 set sethostent d_sethent
9606 eval $inlibc
9607
9608 : see if setlinebuf exists
9609 set setlinebuf d_setlinebuf
9610 eval $inlibc
9611
9612 : see if setlocale exists
9613 set setlocale d_setlocale
9614 eval $inlibc
9615
9616 : see if setnetent exists
9617 set setnetent d_setnent
9618 eval $inlibc
9619
9620 : see if setprotoent exists
9621 set setprotoent d_setpent
9622 eval $inlibc
9623
9624 : see if setpgid exists
9625 set setpgid d_setpgid
9626 eval $inlibc
9627
9628 : see if setpgrp2 exists
9629 set setpgrp2 d_setpgrp2
9630 eval $inlibc
9631
9632 : see if setpriority exists
9633 set setpriority d_setprior
9634 eval $inlibc
9635
9636 : see if setpwent exists
9637 set setpwent d_setpwent
9638 eval $inlibc
9639
9640 : see if setregid exists
9641 set setregid d_setregid
9642 eval $inlibc
9643 set setresgid d_setresgid
9644 eval $inlibc
9645
9646 : see if setreuid exists
9647 set setreuid d_setreuid
9648 eval $inlibc
9649 set setresuid d_setresuid
9650 eval $inlibc
9651
9652 : see if setrgid exists
9653 set setrgid d_setrgid
9654 eval $inlibc
9655
9656 : see if setruid exists
9657 set setruid d_setruid
9658 eval $inlibc
9659
9660 : see if setservent exists
9661 set setservent d_setsent
9662 eval $inlibc
9663
9664 : see if setsid exists
9665 set setsid d_setsid
9666 eval $inlibc
9667
9668 : see if setspent exists
9669 set setspent d_setspent
9670 eval $inlibc
9671
9672 : see if setvbuf exists
9673 set setvbuf d_setvbuf
9674 eval $inlibc
9675
9676 : see if sfio.h is available
9677 set sfio.h i_sfio
9678 eval $inhdr
9679
9680
9681 : see if sfio library is available
9682 case "$i_sfio" in
9683 $define)
9684         val=''
9685         set sfreserve val
9686         eval $inlibc
9687         ;;
9688 *)
9689         val="$undef"
9690         ;;
9691 esac
9692 : Ok, but do we want to use it.
9693 case "$val" in
9694 $define)
9695         case "$usesfio" in
9696         true|$define|[yY]*) dflt='y';;
9697         *) dflt='n';;
9698         esac
9699         echo "$package can use the sfio library, but it is experimental."
9700         rp="You seem to have sfio available, do you want to try using it?"
9701         . ./myread
9702         case "$ans" in
9703         y|Y) ;;
9704         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9705                 val="$undef"
9706                 : Remove sfio from list of libraries to use
9707                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9708                 shift
9709                 libs="$*"
9710                 echo "libs = $libs" >&4
9711                 ;;
9712         esac
9713         ;;
9714 *)      case "$usesfio" in
9715         true|$define|[yY]*)
9716                 echo "Sorry, cannot find sfio on this machine" >&4
9717                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9718                 ;;
9719         esac
9720         ;;
9721 esac
9722 set d_sfio
9723 eval $setvar
9724 case "$d_sfio" in
9725 $define) usesfio='true';;
9726 *) usesfio='false';;
9727 esac
9728
9729 : see if shmctl exists
9730 set shmctl d_shmctl
9731 eval $inlibc
9732
9733 : see if shmget exists
9734 set shmget d_shmget
9735 eval $inlibc
9736
9737 : see if shmat exists
9738 set shmat d_shmat
9739 eval $inlibc
9740 : see what shmat returns
9741 case "$d_shmat" in
9742 "$define")
9743         $cat >shmat.c <<'END'
9744 #include <sys/shm.h>
9745 void *shmat();
9746 END
9747         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9748                 shmattype='void *'
9749         else
9750                 shmattype='char *'
9751         fi
9752         echo "and it returns ($shmattype)." >&4
9753         : see if a prototype for shmat is available
9754         xxx=`./findhdr sys/shm.h`
9755         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9756         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9757                 val="$define"
9758         else
9759                 val="$undef"
9760         fi
9761         $rm -f shmat.[co]
9762         ;;
9763 *)
9764         val="$undef"
9765         ;;
9766 esac
9767 set d_shmatprototype
9768 eval $setvar
9769
9770 : see if shmdt exists
9771 set shmdt d_shmdt
9772 eval $inlibc
9773
9774 : see how much of the 'shm*(2)' library is present.
9775 h_shm=true
9776 echo " "
9777 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9778 *"$undef"*) h_shm=false;;
9779 esac
9780 case "$osname" in
9781 freebsd)
9782     case "`ipcs 2>&1`" in
9783     "SVID shared memory"*"not configured"*)
9784         echo "Your $osname does not have the shm*(2) configured." >&4
9785         h_shm=false
9786         val="$undef"
9787         set shmctl d_shmctl
9788         evat $setvar
9789         set shmget d_shmget
9790         evat $setvar
9791         set shmat d_shmat
9792         evat $setvar
9793         set shmdt d_shmdt
9794         evat $setvar
9795         ;;
9796     esac
9797     ;;
9798 esac
9799 : we could also check for sys/ipc.h ...
9800 if $h_shm && $test `./findhdr sys/shm.h`; then
9801         echo "You have the full shm*(2) library." >&4
9802         val="$define"
9803 else
9804         echo "You don't have the full shm*(2) library." >&4
9805         val="$undef"
9806 fi
9807 set d_shm
9808 eval $setvar
9809
9810 echo " "
9811 : see if we have sigaction
9812 if set sigaction val -f d_sigaction; eval $csym; $val; then
9813         echo 'sigaction() found.' >&4
9814         $cat > try.c <<'EOP'
9815 #include <stdio.h>
9816 #include <sys/types.h>
9817 #include <signal.h>
9818 int main()
9819 {
9820     struct sigaction act, oact;
9821 }
9822 EOP
9823         set try
9824         if eval $compile_ok; then
9825                 val="$define"
9826         else
9827                 echo "But you don't seem to have a useable struct sigaction." >&4
9828                 val="$undef"
9829         fi
9830 else
9831         echo 'sigaction NOT found.' >&4
9832         val="$undef"
9833 fi
9834 set d_sigaction; eval $setvar
9835 $rm -f try try$_o try.c
9836
9837 : see if sigsetjmp exists
9838 echo " "
9839 case "$d_sigsetjmp" in
9840 '')
9841         $cat >try.c <<'EOP'
9842 #include <setjmp.h>
9843 sigjmp_buf env;
9844 int set = 1;
9845 int main()
9846 {
9847         if (sigsetjmp(env,1))
9848                 exit(set);
9849         set = 0;
9850         siglongjmp(env, 1);
9851         exit(1);
9852 }
9853 EOP
9854         set try
9855         if eval $compile; then
9856                 if ./try >/dev/null 2>&1; then
9857                         echo "POSIX sigsetjmp found." >&4
9858                         val="$define"
9859                 else
9860                         $cat >&4 <<EOM
9861 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9862 I'll ignore them.
9863 EOM
9864                         val="$undef"
9865                 fi
9866         else
9867                 echo "sigsetjmp not found." >&4
9868                 val="$undef"
9869         fi
9870         ;;
9871 *) val="$d_sigsetjmp"
9872         case "$d_sigsetjmp" in
9873         $define) echo "POSIX sigsetjmp found." >&4;;
9874         $undef) echo "sigsetjmp not found." >&4;;
9875         esac
9876         ;;
9877 esac
9878 set d_sigsetjmp
9879 eval $setvar
9880 $rm -f try.c try
9881
9882 : see if stat knows about block sizes
9883 echo " "
9884 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9885 eval $hasfield
9886
9887 : see if _ptr and _cnt from stdio act std
9888 echo " "
9889 if $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
9890         echo "(Looks like you have stdio.h from Linux.)"
9891         case "$stdio_ptr" in
9892         '') stdio_ptr='((fp)->_IO_read_ptr)'
9893                 ptr_lval=$define
9894                 ;;
9895         *)      ptr_lval=$d_stdio_ptr_lval;;
9896         esac
9897         case "$stdio_cnt" in
9898         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9899                 cnt_lval=$undef
9900                 ;;
9901         *)      cnt_lval=$d_stdio_cnt_lval;;
9902         esac
9903         case "$stdio_base" in
9904         '') stdio_base='((fp)->_IO_read_base)';;
9905         esac
9906         case "$stdio_bufsiz" in
9907         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9908         esac
9909 else
9910         case "$stdio_ptr" in
9911         '') stdio_ptr='((fp)->_ptr)'
9912                 ptr_lval=$define
9913                 ;;
9914         *)      ptr_lval=$d_stdio_ptr_lval;;
9915         esac
9916         case "$stdio_cnt" in
9917         '') stdio_cnt='((fp)->_cnt)'
9918                 cnt_lval=$define
9919                 ;;
9920         *)      cnt_lval=$d_stdio_cnt_lval;;
9921         esac
9922         case "$stdio_base" in
9923         '') stdio_base='((fp)->_base)';;
9924         esac
9925         case "$stdio_bufsiz" in
9926         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9927         esac
9928 fi
9929 : test whether _ptr and _cnt really work
9930 echo "Checking how std your stdio is..." >&4
9931 $cat >try.c <<EOP
9932 #include <stdio.h>
9933 #define FILE_ptr(fp)    $stdio_ptr
9934 #define FILE_cnt(fp)    $stdio_cnt
9935 int main() {
9936         FILE *fp = fopen("try.c", "r");
9937         char c = getc(fp);
9938         if (
9939                 18 <= FILE_cnt(fp) &&
9940                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9941         )
9942                 exit(0);
9943         exit(1);
9944 }
9945 EOP
9946 val="$undef"
9947 set try
9948 if eval $compile; then
9949         if ./try; then
9950                 echo "Your stdio acts pretty std."
9951                 val="$define"
9952         else
9953                 echo "Your stdio isn't very std."
9954         fi
9955 else
9956         echo "Your stdio doesn't appear very std."
9957 fi
9958 $rm -f try.c try
9959 set d_stdstdio
9960 eval $setvar
9961
9962 : Can _ptr be used as an lvalue?
9963 case "$d_stdstdio$ptr_lval" in
9964 $define$define) val=$define ;;
9965 *) val=$undef ;;
9966 esac
9967 set d_stdio_ptr_lval
9968 eval $setvar
9969
9970 : Can _cnt be used as an lvalue?
9971 case "$d_stdstdio$cnt_lval" in
9972 $define$define) val=$define ;;
9973 *) val=$undef ;;
9974 esac
9975 set d_stdio_cnt_lval
9976 eval $setvar
9977
9978 : see if _base is also standard
9979 val="$undef"
9980 case "$d_stdstdio" in
9981 $define)
9982         $cat >try.c <<EOP
9983 #include <stdio.h>
9984 #define FILE_base(fp)   $stdio_base
9985 #define FILE_bufsiz(fp) $stdio_bufsiz
9986 int main() {
9987         FILE *fp = fopen("try.c", "r");
9988         char c = getc(fp);
9989         if (
9990                 19 <= FILE_bufsiz(fp) &&
9991                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9992         )
9993                 exit(0);
9994         exit(1);
9995 }
9996 EOP
9997         set try
9998         if eval $compile; then
9999                 if ./try; then
10000                         echo "And its _base field acts std."
10001                         val="$define"
10002                 else
10003                         echo "But its _base field isn't std."
10004                 fi
10005         else
10006                 echo "However, it seems to be lacking the _base field."
10007         fi
10008         $rm -f try.c try
10009         ;;
10010 esac
10011 set d_stdiobase
10012 eval $setvar
10013
10014 $cat >&4 <<EOM
10015 Checking how to access stdio streams by file descriptor number...
10016 EOM
10017 case "$stdio_stream_array" in
10018 '')     $cat >try.c <<EOCP
10019 #include <stdio.h>
10020 int main() {
10021   if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
10022     printf("yes\n");
10023 }
10024 EOCP
10025         for s in _iob __iob __sF
10026         do
10027                 set try -DSTDIO_STREAM_ARRAY=$s
10028                 if eval $compile; then
10029                         case "`./try$exe_ext`" in
10030                         yes)    stdio_stream_array=$s; break ;;
10031                         esac
10032                 fi
10033         done
10034         $rm -f try.* try$exe_ext
10035 esac
10036 case "$stdio_stream_array" in
10037 '')     $cat >&4 <<EOM
10038 I can't figure out how to access stdio streams by file descriptor number.
10039 EOM
10040         d_stdio_stream_array="$undef"
10041         ;;
10042 *)      $cat >&4 <<EOM
10043 You can access stdio streams by file descriptor number by the $stdio_stream_array array.
10044 EOM
10045         d_stdio_stream_array="$define"
10046         ;;
10047 esac
10048
10049 : see if strcoll exists
10050 set strcoll d_strcoll
10051 eval $inlibc
10052
10053 : check for structure copying
10054 echo " "
10055 echo "Checking to see if your C compiler can copy structs..." >&4
10056 $cat >try.c <<'EOCP'
10057 int main()
10058 {
10059         struct blurfl {
10060                 int dyick;
10061         } foo, bar;
10062
10063         foo = bar;
10064 }
10065 EOCP
10066 if $cc -c try.c >/dev/null 2>&1 ; then
10067         val="$define"
10068         echo "Yup, it can."
10069 else
10070         val="$undef"
10071         echo "Nope, it can't."
10072 fi
10073 set d_strctcpy
10074 eval $setvar
10075 $rm -f try.*
10076
10077 : see if strerror and/or sys_errlist[] exist
10078 echo " "
10079 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
10080     if set strerror val -f d_strerror; eval $csym; $val; then
10081                 echo 'strerror() found.' >&4
10082                 d_strerror="$define"
10083                 d_strerrm='strerror(e)'
10084                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10085                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
10086                         d_syserrlst="$define"
10087                 else
10088                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
10089                         d_syserrlst="$undef"
10090                 fi
10091     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
10092                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
10093                 echo 'strerror() found in string header.' >&4
10094                 d_strerror="$define"
10095                 d_strerrm='strerror(e)'
10096                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10097                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
10098                                 d_syserrlst="$define"
10099                 else
10100                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
10101                         d_syserrlst="$undef"
10102                 fi
10103     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
10104                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
10105                 d_strerror="$undef"
10106                 d_syserrlst="$define"
10107                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
10108     else
10109                 echo 'strerror() and sys_errlist[] NOT found.' >&4
10110                 d_strerror="$undef"
10111                 d_syserrlst="$undef"
10112                 d_strerrm='"unknown"'
10113     fi
10114 fi
10115
10116 : see if strtod exists
10117 set strtod d_strtod
10118 eval $inlibc
10119
10120 : see if strtol exists
10121 set strtol d_strtol
10122 eval $inlibc
10123
10124 : see if strtoul exists
10125 set strtoul d_strtoul
10126 eval $inlibc
10127
10128 : see if strxfrm exists
10129 set strxfrm d_strxfrm
10130 eval $inlibc
10131
10132 : see if symlink exists
10133 set symlink d_symlink
10134 eval $inlibc
10135
10136 : see if syscall exists
10137 set syscall d_syscall
10138 eval $inlibc
10139
10140 : see if sysconf exists
10141 set sysconf d_sysconf
10142 eval $inlibc
10143
10144 : see if system exists
10145 set system d_system
10146 eval $inlibc
10147
10148 : see if tcgetpgrp exists
10149 set tcgetpgrp d_tcgetpgrp
10150 eval $inlibc
10151
10152 : see if tcsetpgrp exists
10153 set tcsetpgrp d_tcsetpgrp
10154 eval $inlibc
10155
10156 : see if sys/types.h has to be included
10157 set sys/types.h i_systypes
10158 eval $inhdr
10159
10160 : see if prototype for telldir is available
10161 echo " "
10162 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10163 eval $hasproto
10164
10165 : define an is-a-typedef? function
10166 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10167 case "$inclist" in
10168 "") inclist="sys/types.h";;
10169 esac;
10170 eval "varval=\$$var";
10171 case "$varval" in
10172 "")
10173         $rm -f temp.c;
10174         for inc in $inclist; do
10175                 echo "#include <$inc>" >>temp.c;
10176         done;
10177         echo "#ifdef $type" >> temp.c;
10178         echo "printf(\"We have $type\");" >> temp.c;
10179         echo "#endif" >> temp.c;
10180         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10181         if $contains $type temp.E >/dev/null 2>&1; then
10182                 eval "$var=\$type";
10183         else
10184                 eval "$var=\$def";
10185         fi;
10186         $rm -f temp.?;;
10187 *) eval "$var=\$varval";;
10188 esac'
10189
10190 : define an is-a-typedef? function that prompts if the type is not available.
10191 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10192 case "$inclist" in
10193 "") inclist="sys/types.h";;
10194 esac;
10195 eval "varval=\$$var";
10196 case "$varval" in
10197 "")
10198         $rm -f temp.c;
10199         for inc in $inclist; do
10200                 echo "#include <$inc>" >>temp.c;
10201         done;
10202         echo "#ifdef $type" >> temp.c;
10203         echo "printf(\"We have $type\");" >> temp.c;
10204         echo "#endif" >> temp.c;
10205         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10206         echo " " ;
10207         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10208         if $contains $type temp.E >/dev/null 2>&1; then
10209                 echo "$type found." >&4;
10210                 eval "$var=\$type";
10211         else
10212                 echo "$type NOT found." >&4;
10213                 dflt="$def";
10214                 . ./myread ;
10215                 eval "$var=\$ans";
10216         fi;
10217         $rm -f temp.?;;
10218 *) eval "$var=\$varval";;
10219 esac'
10220
10221 : see if this is a sys/times.h system
10222 set sys/times.h i_systimes
10223 eval $inhdr
10224
10225 : see if times exists
10226 echo " "
10227 if set times val -f d_times; eval $csym; $val; then
10228         echo 'times() found.' >&4
10229         d_times="$define"
10230         inc=''
10231         case "$i_systimes" in
10232         "$define") inc='sys/times.h';;
10233         esac
10234         rp="What is the type returned by times() on this system?"
10235         set clock_t clocktype long stdio.h sys/types.h $inc
10236         eval $typedef_ask
10237 else
10238         echo 'times() NOT found, hope that will do.' >&4
10239         d_times="$undef"
10240         clocktype='int'
10241 fi
10242
10243 : see if truncate exists
10244 set truncate d_truncate
10245 eval $inlibc
10246
10247 : see if tzname[] exists
10248 echo " "
10249 if set tzname val -a d_tzname; eval $csym; $val; then
10250         val="$define"
10251         echo 'tzname[] found.' >&4
10252 else
10253         val="$undef"
10254         echo 'tzname[] NOT found.' >&4
10255 fi
10256 set d_tzname
10257 eval $setvar
10258
10259 : see if umask exists
10260 set umask d_umask
10261 eval $inlibc
10262
10263 : backward compatibility for d_hvfork
10264 if test X$d_hvfork != X; then
10265         d_vfork="$d_hvfork"
10266         d_hvfork=''
10267 fi
10268 : see if there is a vfork
10269 val=''
10270 set vfork val
10271 eval $inlibc
10272
10273 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10274 : perl on Solaris 2.x, and probably elsewhere.
10275 case "$val" in
10276 $define)
10277         echo " "
10278         case "$usevfork" in
10279         false) dflt='n';;
10280         *) dflt='y';;
10281         esac
10282         cat <<'EOM'
10283  
10284 Perl can only use a vfork() that doesn't suffer from strict
10285 restrictions on calling functions or modifying global data in
10286 the child.  For example, glibc-2.1 contains such a vfork()
10287 that is unsuitable.  If your system provides a proper fork()
10288 call, chances are that you do NOT want perl to use vfork().
10289
10290 EOM
10291         rp="Do you still want to use vfork()?"
10292         . ./myread
10293         case "$ans" in
10294         y|Y) ;;
10295         *)
10296                 echo "Ok, we won't use vfork()."
10297                 val="$undef"
10298                 ;;
10299         esac
10300         ;;
10301 esac
10302 set d_vfork
10303 eval $setvar
10304 case "$d_vfork" in
10305 $define) usevfork='true';;
10306 *) usevfork='false';;
10307 esac
10308
10309 : see if this is an sysdir system
10310 set sys/dir.h i_sysdir
10311 eval $inhdr
10312
10313 : see if this is an sysndir system
10314 set sys/ndir.h i_sysndir
10315 eval $inhdr
10316
10317 : see if closedir exists
10318 set closedir d_closedir
10319 eval $inlibc
10320
10321 case "$d_closedir" in
10322 "$define")
10323         echo " "
10324         echo "Checking whether closedir() returns a status..." >&4
10325         cat > closedir.c <<EOM
10326 #$i_dirent I_DIRENT             /**/
10327 #$i_sysdir I_SYS_DIR            /**/
10328 #$i_sysndir I_SYS_NDIR          /**/
10329 #$i_systypes I_SYS_TYPES        /**/
10330
10331 #if defined(I_SYS_TYPES)
10332 #include <sys/types.h>
10333 #endif
10334 #if defined(I_DIRENT)
10335 #include <dirent.h>
10336 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10337 #include <sys/dir.h>
10338 #endif
10339 #else
10340 #ifdef I_SYS_NDIR
10341 #include <sys/ndir.h>
10342 #else
10343 #ifdef I_SYS_DIR
10344 #ifdef hp9000s500
10345 #include <ndir.h>       /* may be wrong in the future */
10346 #else
10347 #include <sys/dir.h>
10348 #endif
10349 #endif
10350 #endif
10351 #endif 
10352 int main() { return closedir(opendir(".")); }
10353 EOM
10354         set closedir
10355         if eval $compile_ok; then
10356                 if ./closedir > /dev/null 2>&1 ; then
10357                         echo "Yes, it does."
10358                         val="$undef"
10359                 else
10360                         echo "No, it doesn't."
10361                         val="$define"
10362                 fi
10363         else
10364                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10365                 val="$define"
10366         fi
10367         ;;
10368 *)
10369         val="$undef";
10370         ;;
10371 esac
10372 set d_void_closedir
10373 eval $setvar
10374 $rm -f closedir*
10375 : check for volatile keyword
10376 echo " "
10377 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10378 $cat >try.c <<'EOCP'
10379 int main()
10380 {
10381         typedef struct _goo_struct goo_struct;
10382         goo_struct * volatile goo = ((goo_struct *)0);
10383         struct _goo_struct {
10384                 long long_int;
10385                 int reg_int;
10386                 char char_var;
10387         };
10388         typedef unsigned short foo_t;
10389         char *volatile foo;
10390         volatile int bar;
10391         volatile foo_t blech;
10392         foo = foo;
10393 }
10394 EOCP
10395 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10396         val="$define"
10397         echo "Yup, it does."
10398 else
10399         val="$undef"
10400         echo "Nope, it doesn't."
10401 fi
10402 set d_volatile
10403 eval $setvar
10404 $rm -f try.*
10405
10406 : see if there is a wait4
10407 set wait4 d_wait4
10408 eval $inlibc
10409
10410 : see if waitpid exists
10411 set waitpid d_waitpid
10412 eval $inlibc
10413
10414 : see if wcstombs exists
10415 set wcstombs d_wcstombs
10416 eval $inlibc
10417
10418 : see if wctomb exists
10419 set wctomb d_wctomb
10420 eval $inlibc
10421
10422 : see if writev exists
10423 set writev d_writev
10424 eval $inlibc
10425
10426 : preserve RCS keywords in files with variable substitution, grrr
10427 Date='$Date'
10428 Id='$Id'
10429 Log='$Log'
10430 RCSfile='$RCSfile'
10431 Revision='$Revision'
10432
10433 case "$crosscompile" in
10434 ''|[nN]*) crosscompile="$undef" ;;
10435 esac
10436
10437 case "$osname" in
10438 next|rhapsody) multiarch="$define" ;;
10439 esac
10440 case "$multiarch" in
10441 ''|[nN]*) multiarch="$undef" ;;
10442 esac
10443
10444 : check for alignment requirements
10445 echo " "
10446 case "$crosscompile$multiarch" in
10447 *$define*)
10448         $cat <<EOM
10449 You seem to be either cross-compiling or doing a multiarchitecture build,
10450 skipping the memory alignment check.
10451
10452 EOM
10453         case "$alignbytes" in
10454         '') alignbytes=8 ;;
10455         esac
10456         ;;
10457 *)
10458         case "$alignbytes" in
10459         '') echo "Checking alignment constraints..." >&4
10460                 $cat >try.c <<'EOCP'
10461 struct foobar {
10462         char foo;
10463         double bar;
10464 } try_algn;
10465 int main()
10466 {
10467         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10468 }
10469 EOCP
10470                 set try
10471                 if eval $compile_ok; then
10472                         dflt=`./try`
10473                 else
10474                         dflt='8'
10475                         echo "(I can't seem to compile the test program...)"
10476                 fi
10477                 ;;
10478         *) dflt="$alignbytes"
10479                 ;;
10480         esac
10481         rp="Doubles must be aligned on a how-many-byte boundary?"
10482         . ./myread
10483         alignbytes="$ans"
10484         $rm -f try.c try
10485         ;;
10486 esac
10487
10488
10489 : check for ordering of bytes in a long
10490 echo " "
10491 case "$crosscompile$multiarch" in
10492 *$define*)
10493         $cat <<EOM
10494 You seem to be either cross-compiling or doing a multiarchitecture build,
10495 skipping the byteorder check.
10496
10497 EOM
10498         byteorder=''
10499         ;;
10500 *)
10501         case "$byteorder" in
10502         '')
10503                 $cat <<'EOM'
10504 In the following, larger digits indicate more significance.  A big-endian
10505 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10506 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10507 machines may have weird orders like 3412.  A Cray will report 87654321. If
10508 the test program works the default is probably right.
10509 I'm now running the test program...
10510 EOM
10511                 $cat >try.c <<'EOCP'
10512 #include <stdio.h>
10513 int main()
10514 {
10515         int i;
10516         union {
10517                 unsigned long l;
10518                 char c[sizeof(long)];
10519         } u;
10520
10521         if (sizeof(long) > 4)
10522                 u.l = (0x08070605L << 32) | 0x04030201L;
10523         else
10524                 u.l = 0x04030201L;
10525         for (i = 0; i < sizeof(long); i++)
10526                 printf("%c", u.c[i]+'0');
10527         printf("\n");
10528         exit(0);
10529 }
10530 EOCP
10531                 xxx_prompt=y
10532                 set try
10533                 if eval $compile && ./try > /dev/null; then
10534                         dflt=`./try`
10535                         case "$dflt" in
10536                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10537                                 echo "(The test program ran ok.)"
10538                                 echo "byteorder=$dflt"
10539                                 xxx_prompt=n
10540                         ;;
10541                         ????|????????) echo "(The test program ran ok.)" ;;
10542                         *) echo "(The test program didn't run right for some reason.)" ;;
10543                         esac
10544                 else
10545                         dflt='4321'
10546                         cat <<'EOM'
10547 (I can't seem to compile the test program.  Guessing big-endian...)
10548 EOM
10549                 fi
10550                 case "$xxx_prompt" in
10551                 y)
10552                         rp="What is the order of bytes in a long?"
10553                         . ./myread
10554                         byteorder="$ans"
10555                         ;;
10556                 *)      byteorder=$dflt
10557                         ;;
10558                 esac
10559                 ;;
10560         esac
10561         $rm -f try.c try
10562         ;;
10563 esac
10564
10565
10566 : how do we catenate cpp tokens here?
10567 echo " "
10568 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10569 $cat >cpp_stuff.c <<'EOCP'
10570 #define RCAT(a,b)a/**/b
10571 #define ACAT(a,b)a ## b
10572 RCAT(Rei,ser)
10573 ACAT(Cir,cus)
10574 EOCP
10575 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10576 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10577         echo "Oh!  Smells like ANSI's been here." >&4
10578         echo "We can catify or stringify, separately or together!"
10579         cpp_stuff=42
10580 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10581         echo "Ah, yes!  The good old days!" >&4
10582         echo "However, in the good old days we don't know how to stringify and"
10583         echo "catify at the same time."
10584         cpp_stuff=1
10585 else
10586         $cat >&4 <<EOM
10587 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10588 to have to edit the values of CAT[2-5] in config.h...
10589 EOM
10590         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10591 fi
10592 $rm -f cpp_stuff.*
10593
10594 : see if this is a db.h system
10595 set db.h i_db
10596 eval $inhdr
10597
10598 case "$i_db" in
10599 $define)
10600         : Check db version.
10601         echo " "
10602         echo "Checking Berkeley DB version ..." >&4
10603         $cat >try.c <<EOCP
10604 #$d_const HASCONST
10605 #ifndef HASCONST
10606 #define const
10607 #endif
10608 #include <sys/types.h>
10609 #include <stdio.h>
10610 #include <db.h>
10611 int main()
10612 {
10613 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10614     int Major, Minor, Patch ;
10615     unsigned long Version ;
10616     (void)db_version(&Major, &Minor, &Patch) ;
10617     printf("You have Berkeley DB Version 2 or greater\n");
10618
10619     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10620                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10621     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10622                 Major, Minor, Patch) ;
10623
10624     /* check that db.h & libdb are compatible */
10625     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10626         printf("db.h and libdb are incompatible\n") ;
10627         exit(3);        
10628     }
10629
10630     printf("db.h and libdb are compatible\n") ;
10631
10632     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10633                 + DB_VERSION_PATCH ;
10634
10635     /* needs to be >= 2.3.4 */
10636     if (Version < 2003004) {
10637     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10638         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10639         exit(2);        
10640     }
10641
10642     exit(0);
10643 #else
10644 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10645     printf("You have Berkeley DB Version 1\n");
10646     exit(0);    /* DB version < 2: the coast is clear. */
10647 #else
10648     exit(1);    /* <db.h> not Berkeley DB? */
10649 #endif
10650 #endif
10651 }
10652 EOCP
10653         set try
10654         if eval $compile && ./try; then
10655                 echo 'Looks OK.' >&4
10656         else
10657                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10658                 i_db=$undef
10659                 case " $libs " in
10660                 *"-ldb "*)
10661                         : Remove db from list of libraries to use
10662                         echo "Removing unusable -ldb from library list" >&4
10663                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10664                         shift
10665                         libs="$*"
10666                         echo "libs = $libs" >&4
10667                         ;;
10668                 esac
10669         fi
10670         $rm -f try.*
10671         ;;
10672 esac
10673
10674 case "$i_db" in
10675 define)
10676         : Check the return type needed for hash 
10677         echo " "
10678         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10679         $cat >try.c <<EOCP
10680 #$d_const HASCONST
10681 #ifndef HASCONST
10682 #define const
10683 #endif
10684 #include <sys/types.h>
10685 #include <db.h>
10686
10687 #ifndef DB_VERSION_MAJOR
10688 u_int32_t hash_cb (ptr, size)
10689 const void *ptr;
10690 size_t size;
10691 {
10692 }
10693 HASHINFO info;
10694 int main()
10695 {
10696         info.hash = hash_cb;
10697 }
10698 #endif
10699 EOCP
10700         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10701                 if $contains warning try.out >>/dev/null 2>&1 ; then
10702                         db_hashtype='int'
10703                 else
10704                         db_hashtype='u_int32_t'
10705                 fi
10706         else
10707                 : XXX Maybe we should just give up here.
10708                 db_hashtype=u_int32_t
10709                 $cat try.out >&4
10710                 echo "Help:  I can't seem to compile the db test program." >&4
10711                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10712         fi
10713         $rm -f try.*
10714         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10715         ;;
10716 *)      db_hashtype=u_int32_t
10717         ;;
10718 esac
10719 case "$i_db" in
10720 define)
10721         : Check the return type needed for prefix 
10722         echo " "
10723         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10724         cat >try.c <<EOCP
10725 #$d_const HASCONST
10726 #ifndef HASCONST
10727 #define const
10728 #endif
10729 #include <sys/types.h>
10730 #include <db.h>
10731
10732 #ifndef DB_VERSION_MAJOR
10733 size_t prefix_cb (key1, key2)
10734 const DBT *key1;
10735 const DBT *key2;
10736 {
10737 }
10738 BTREEINFO info;
10739 int main()
10740 {
10741         info.prefix = prefix_cb;
10742 }
10743 #endif
10744 EOCP
10745         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10746                 if $contains warning try.out >>/dev/null 2>&1 ; then
10747                         db_prefixtype='int'
10748                 else
10749                         db_prefixtype='size_t'
10750                 fi
10751         else
10752                 db_prefixtype='size_t'
10753                 : XXX Maybe we should just give up here.
10754                 $cat try.out >&4
10755                 echo "Help:  I can't seem to compile the db test program." >&4
10756                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10757         fi
10758         $rm -f try.*
10759         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10760         ;;
10761 *)      db_prefixtype='size_t'
10762         ;;
10763 esac
10764
10765 : check for void type
10766 echo " "
10767 echo "Checking to see how well your C compiler groks the void type..." >&4
10768 case "$voidflags" in
10769 '')
10770         $cat >try.c <<'EOCP'
10771 #if TRY & 1
10772 void sub() {
10773 #else
10774 sub() {
10775 #endif
10776         extern void moo();      /* function returning void */
10777         void (*goo)();          /* ptr to func returning void */
10778 #if TRY & 8
10779         void *hue;              /* generic ptr */
10780 #endif
10781 #if TRY & 2
10782         void (*foo[10])();
10783 #endif
10784
10785 #if TRY & 4
10786         if(goo == moo) {
10787                 exit(0);
10788         }
10789 #endif
10790         exit(0);
10791 }
10792 int main() { sub(); }
10793 EOCP
10794         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10795                 voidflags=$defvoidused
10796         echo "Good.  It appears to support void to the level $package wants.">&4
10797                 if $contains warning .out >/dev/null 2>&1; then
10798                         echo "However, you might get some warnings that look like this:"
10799                         $cat .out
10800                 fi
10801         else
10802 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10803                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10804                         echo "It supports 1..."
10805                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10806                                 echo "It also supports 2..."
10807                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10808                                         voidflags=7
10809                                         echo "And it supports 4 but not 8 definitely."
10810                                 else
10811                                         echo "It doesn't support 4..."
10812                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10813                                                 voidflags=11
10814                                                 echo "But it supports 8."
10815                                         else
10816                                                 voidflags=3
10817                                                 echo "Neither does it support 8."
10818                                         fi
10819                                 fi
10820                         else
10821                                 echo "It does not support 2..."
10822                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10823                                         voidflags=13
10824                                         echo "But it supports 4 and 8."
10825                                 else
10826                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10827                                                 voidflags=5
10828                                                 echo "And it supports 4 but has not heard about 8."
10829                                         else
10830                                                 echo "However it supports 8 but not 4."
10831                                         fi
10832                                 fi
10833                         fi
10834                 else
10835                         echo "There is no support at all for void."
10836                         voidflags=0
10837                 fi
10838         fi
10839 esac
10840 case "$voidflags" in
10841 "$defvoidused") ;;
10842 *)      $cat >&4 <<'EOM'
10843   Support flag bits are:
10844     1: basic void declarations.
10845     2: arrays of pointers to functions returning void.
10846     4: operations between pointers to and addresses of void functions.
10847     8: generic void pointers.
10848 EOM
10849         dflt="$voidflags";
10850         rp="Your void support flags add up to what?"
10851         . ./myread
10852         voidflags="$ans"
10853         ;;
10854 esac
10855 $rm -f try.* .out
10856
10857
10858 : How can we generate normalized random numbers ?
10859 echo " "
10860 echo "Looking for a random number function..." >&4
10861 case "$randfunc" in
10862 '')
10863         if set drand48 val -f; eval $csym; $val; then
10864                 dflt="drand48"
10865                 echo "Good, found drand48()." >&4
10866         elif set random val -f; eval $csym; $val; then
10867                 dflt="random"
10868                 echo "OK, found random()." >&4
10869         else
10870                 dflt="rand"
10871                 echo "Yick, looks like I have to use rand()." >&4
10872         fi
10873         echo " "
10874         ;;
10875 *)
10876         dflt="$randfunc"
10877         ;;
10878 esac
10879 cont=true
10880
10881 case "$ccflags" in
10882 *-Dmy_rand=*|*-Dmy_srand=*)
10883         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10884         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10885         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10886         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10887         ;;
10888 esac
10889
10890 while $test "$cont"; do
10891         rp="Use which function to generate random numbers?"
10892         . ./myread
10893         if $test "$ans" = "$dflt"; then
10894                 : null
10895         else
10896                 randbits=''
10897         fi
10898         randfunc="$ans"
10899         if set $ans val -f; eval $csym; $val; then
10900                 cont=''
10901         else
10902                 dflt=y
10903                 rp="I cannot find function $ans. Use that name anyway?"
10904                 . ./myread
10905                 dflt=rand
10906                 case "$ans" in
10907                         [yY]*) cont='';;
10908                 esac
10909         fi
10910         case "$cont" in
10911         '')
10912                 case "$randfunc" in
10913                 drand48)
10914                         drand01="drand48()"
10915                         seedfunc="srand48"
10916                         randbits=48
10917                         randseedtype=long
10918                         ;;
10919                 rand|random)
10920                         case "$randbits" in
10921                         '')
10922 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10923                                 $cat >try.c <<EOCP
10924 #$i_unistd I_UNISTD
10925 #$i_stdlib I_STDLIB
10926 #include <stdio.h>
10927 #ifdef I_UNISTD
10928 #  include <unistd.h>
10929 #endif
10930 #ifdef I_STDLIB
10931 #  include <stdlib.h>
10932 #endif
10933 int main()
10934 {
10935         register int i;
10936         register unsigned long tmp;
10937         register unsigned long max = 0L;
10938
10939         for (i = 1000; i; i--) {
10940                 tmp = (unsigned long) $randfunc();
10941                 if (tmp > max) max = tmp;
10942         }
10943         for (i = 0; max; i++)
10944                 max /= 2;
10945         printf("%d\n",i);
10946 }
10947 EOCP
10948                                 set try
10949                                 if eval $compile_ok; then
10950                                         dflt=`try`
10951                                 else
10952                                         dflt='?'
10953                                         echo "(I can't seem to compile the test program...)"
10954                                 fi
10955                                 ;;
10956                         *)
10957                                 dflt="$randbits"
10958                                 ;;
10959                         esac
10960                         rp="How many bits does your $randfunc() function produce?"
10961                         . ./myread
10962                         randbits="$ans"
10963                         $rm -f try.c try
10964                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10965                         seedfunc="s$randfunc"
10966                         randseedtype=unsigned
10967                         ;;
10968                 *)
10969                         dflt="31"
10970                         rp="How many bits does your $randfunc() function produce?"
10971                         . ./myread
10972                         randbits="$ans"
10973                         seedfunc="s$randfunc"
10974                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10975                         if set $seedfunc val -f; eval $csym; $val; then
10976                                 echo "(Using $seedfunc() to seed random generator)"
10977                         else
10978                                 echo "(Warning: no $seedfunc() to seed random generator)"
10979                                 seedfunc=rand
10980                         fi
10981                         randseedtype=unsigned
10982                         ;;
10983                 esac
10984                 ;;
10985         esac
10986 done
10987
10988 echo " "
10989 echo "Determining whether or not we are on an EBCDIC system..." >&4
10990 $cat >tebcdic.c <<'EOM'
10991 int main()
10992 {
10993   if ('M'==0xd4) return 0;
10994   return 1;
10995 }
10996 EOM
10997
10998 val=$undef
10999 set tebcdic
11000 if eval $compile_ok; then
11001         if ./tebcdic; then
11002                 echo "You have EBCDIC." >&4
11003                 val="$define"
11004         else
11005                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
11006         fi
11007 else
11008         echo "I'm unable to compile the test program." >&4
11009         echo "I'll assume ASCII or some ISO Latin." >&4
11010 fi
11011 $rm -f tebcdic.c tebcdic
11012 set ebcdic
11013 eval $setvar
11014
11015 echo " "
11016 $cat >&4 <<EOM
11017 Checking how to flush all pending stdio output...
11018 EOM
11019 # I only know how to find the first 32 possibly open files on SunOS.
11020 # See also hints/sunos_4_1.sh and util.c  --AD
11021 case "$osname" in
11022 sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
11023 esac
11024 $cat >>try.c <<EOCP
11025 #include <stdio.h>
11026 #$i_unistd I_UNISTD
11027 #ifdef I_UNISTD
11028 # include <unistd.h>
11029 #endif
11030 #$d_sysconf HAS_SYSCONF
11031 #$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
11032 #ifdef HAS_STDIO_STREAM_ARRAY
11033 # define STDIO_STREAM_ARRAY $stdio_stream_array
11034 #endif
11035 int main() {
11036   FILE* p = fopen("try.out", "w");
11037 #ifdef TRY_FPUTC
11038   fputc('x', p);
11039 #else
11040 # ifdef TRY_FPRINTF
11041   fprintf(p, "x");
11042 # endif
11043 #endif
11044 #ifdef TRY_FFLUSH_NULL
11045   fflush(NULL);
11046 #endif
11047 #ifdef TRY_FFLUSH_ALL
11048   {
11049     long open_max = -1;
11050 # ifdef PERL_FFLUSH_ALL_FOPEN_MAX
11051     open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
11052 # else
11053 #  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
11054     open_max = sysconf(_SC_OPEN_MAX);
11055 #  else
11056 #   ifdef FOPEN_MAX
11057     open_max = FOPEN_MAX;
11058 #   else
11059 #    ifdef OPEN_MAX
11060     open_max = OPEN_MAX;
11061 #    else
11062 #     ifdef _NFILE
11063     open_max = _NFILE;
11064 #     endif
11065 #    endif
11066 #   endif
11067 #  endif
11068 # endif 
11069 # ifdef HAS_STDIO_STREAM_ARRAY
11070     if (open_max > 0) {
11071       long i;
11072       for (i = 0; i < open_max; i++)
11073             if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
11074                 STDIO_STREAM_ARRAY[i]._file < open_max &&
11075                 STDIO_STREAM_ARRAY[i]._flag)
11076                 fflush(&STDIO_STREAM_ARRAY[i]);
11077     }   
11078   }
11079 # endif
11080 #endif
11081   _exit(42);
11082 }
11083 EOCP
11084 : first we have to find out how _not_ to flush
11085 if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
11086     output=''
11087     set try -DTRY_FPUTC
11088     if eval $compile; then
11089             $rm -f try.out
11090             ./try$exe_ext 2>/dev/null
11091             if $test ! -s try.out -a "X$?" = X42; then
11092                 output=-DTRY_FPUTC
11093             fi
11094     fi
11095     case "$output" in
11096     '')
11097             set try -DTRY_FPRINTF
11098             $rm -f try.out
11099             if eval $compile; then
11100                     $rm -f try.out
11101                     ./try$exe_ext 2>/dev/null
11102                     if $test ! -s try.out -a "X$?" = X42; then
11103                         output=-DTRY_FPRINTF
11104                     fi
11105             fi
11106         ;;
11107     esac
11108 fi
11109 : check for fflush NULL behaviour
11110 case "$fflushNULL" in
11111 '')     set try -DTRY_FFLUSH_NULL $output
11112         if eval $compile; then
11113                 $rm -f try.out
11114                 ./try$exe_ext 2>/dev/null
11115                 code="$?"
11116                 if $test -s try.out -a "X$code" = X42; then
11117                         fflushNULL="`$cat try.out`"
11118                 else
11119                         if $test "X$code" != X42; then
11120                                 $cat >&4 <<EOM
11121 (If this test failed, don't worry, we'll try another method shortly.)
11122 EOM
11123                         fi
11124                 fi
11125         fi
11126         $rm -f core try.core core.try.*
11127         case "$fflushNULL" in
11128         x)      $cat >&4 <<EOM
11129 Your fflush(NULL) works okay.
11130 EOM
11131                 fflushNULL="$define"
11132                 ;;
11133         '')     $cat >&4 <<EOM
11134 Your fflush(NULL) isn't working (contrary to ANSI C).
11135 EOM
11136                 fflushNULL="$undef"
11137                 ;;
11138         *)      $cat >&4 <<EOM
11139 Cannot figure out whether your fflush(NULL) works or not.
11140 I'm assuming it doesn't (contrary to ANSI C).
11141 EOM
11142                 fflushNULL="$undef"
11143                 ;;
11144         esac
11145         ;;
11146 $define|true|[yY]*)
11147         fflushNULL="$define"
11148         ;;
11149 *)
11150         fflushNULL="$undef"
11151         ;;
11152 esac
11153 : check explicit looping only if NULL did not work
11154 case "$fflushNULL" in
11155 "$undef")
11156         : check for fflush all behaviour
11157         case "$fflushall" in
11158         '')     set try -DTRY_FFLUSH_ALL $output
11159                 if eval $compile; then
11160                         $cat >&4 <<EOM
11161 (Now testing the other method--but note that also this may fail.)
11162 EOM
11163                         $rm -f try.out
11164                         ./try$exe_ext 2>/dev/null
11165                         if $test -s try.out -a "X$?" = X42; then
11166                                 fflushall="`$cat try.out`"
11167                         fi
11168                 fi
11169                 $rm -f core try.core core.try.*
11170                 case "$fflushall" in
11171                 x)      $cat >&4 <<EOM
11172 Whew. Flushing explicitly all the stdio streams works.
11173 EOM
11174                         fflushall="$define"
11175                         ;;
11176                 '')     $cat >&4 <<EOM
11177 Sigh. Flushing explicitly all the stdio streams doesn't work.
11178 EOM
11179                         fflushall="$undef"
11180                         ;;
11181                 *)      $cat >&4 <<EOM
11182 Cannot figure out whether flushing stdio streams explicitly works or not.
11183 I'm assuming it doesn't.
11184 EOM
11185                         fflushall="$undef"
11186                         ;;
11187                 esac
11188                 ;;
11189         "$define"|true|[yY]*)
11190                 fflushall="$define"
11191                 ;;
11192         *)
11193                 fflushall="$undef"
11194                 ;;
11195         esac
11196         ;;
11197 *)      fflushall="$undef"      
11198         ;;
11199 esac
11200 case "$fflushNULL$fflushall" in
11201 undefundef)
11202         $cat <<EOM
11203 I cannot figure out how to flush pending stdio output.
11204 EOM
11205         ;;
11206 esac
11207 $rm -f try.* try$exe_ext
11208
11209 : see what type file positions are declared as in the library
11210 rp="What is the type for file position used by fsetpos()?"
11211 set fpos_t fpostype long stdio.h sys/types.h
11212 eval $typedef_ask
11213
11214 : Store the full pathname to the ar program for use in the C program
11215 : Respect a hint or command line value for full_ar.
11216 case "$full_ar" in
11217 '') full_ar=$ar ;;
11218 esac
11219
11220 : Store the full pathname to the sed program for use in the C program
11221 full_sed=$sed
11222
11223 : see what type gids are declared as in the kernel
11224 echo " "
11225 echo "Looking for the type for group ids returned by getgid()."
11226 set gid_t gidtype xxx stdio.h sys/types.h
11227 eval $typedef
11228 case "$gidtype" in
11229 xxx)
11230         xxx=`./findhdr sys/user.h`
11231         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
11232         case $1 in
11233         unsigned) dflt="$1 $2" ;;
11234         *) dflt="$1" ;;
11235         esac
11236         ;;
11237 *) dflt="$gidtype";;
11238 esac
11239 case "$gidtype" in
11240 gid_t) echo "gid_t found." ;;
11241 *)      rp="What is the type for group ids returned by getgid()?"
11242         . ./myread
11243         gidtype="$ans"
11244         ;;
11245 esac
11246
11247 : see if getgroups exists
11248 set getgroups d_getgrps
11249 eval $inlibc
11250
11251 : see if setgroups exists
11252 set setgroups d_setgrps
11253 eval $inlibc
11254
11255
11256 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11257 echo " "
11258 case "$d_getgrps$d_setgrps" in
11259 *define*)
11260         case "$groupstype" in
11261         '') dflt="$gidtype" ;;
11262         *)  dflt="$groupstype" ;;
11263         esac
11264         $cat <<EOM
11265 What type of pointer is the second argument to getgroups() and setgroups()?
11266 Usually this is the same as group ids, $gidtype, but not always.
11267
11268 EOM
11269         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11270         . ./myread
11271         groupstype="$ans"
11272         ;;
11273 *)  groupstype="$gidtype";;
11274 esac
11275
11276 : see what type lseek is declared as in the kernel
11277 rp="What is the type used for lseek's offset on this system?"
11278 set off_t lseektype long stdio.h sys/types.h
11279 eval $typedef_ask
11280
11281 echo " "
11282 $echo $n "Checking to see how big your file offsets are...$c" >&4
11283 $cat >try.c <<EOCP
11284 #include <sys/types.h>
11285 #include <stdio.h>
11286 int main()
11287 {
11288         printf("%d\n", sizeof($lseektype));
11289 }
11290 EOCP
11291 set try
11292 if eval $compile_ok; then
11293         lseeksize=`./try`
11294         $echo " $lseeksize bytes." >&4
11295 else
11296         dflt='4'
11297         echo " "
11298         echo "(I can't seem to compile the test program.  Guessing...)"
11299         rp="What is the size of your file offsets (in bytes)?"
11300         . ./myread
11301         lseeksize="$ans"
11302 fi
11303 $rm -f try.c try
11304
11305 echo " "
11306 echo "Checking if your $make program sets \$(MAKE)..." >&4
11307 case "$make_set_make" in
11308 '')
11309         $sed 's/^X //' > testmake.mak << 'EOF'
11310 Xall:
11311 X       @echo 'maketemp="$(MAKE)"'
11312 EOF
11313         case "`$make -f testmake.mak 2>/dev/null`" in
11314         *maketemp=*) make_set_make='#' ;;
11315         *)      make_set_make="MAKE=$make" ;;
11316         esac
11317         $rm -f testmake.mak
11318         ;;
11319 esac
11320 case "$make_set_make" in
11321 '#') echo "Yup, it does.";;
11322 *) echo "Nope, it doesn't.";;
11323 esac
11324
11325 : see what type is used for mode_t
11326 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11327 set mode_t modetype int stdio.h sys/types.h
11328 eval $typedef_ask
11329
11330 : define a fucntion to check prototypes
11331 $cat > protochk <<EOSH
11332 $startsh
11333 cc="$cc"
11334 optimize="$optimize"
11335 ccflags="$ccflags"
11336 prototype="$prototype"
11337 define="$define"
11338 rm=$rm
11339 EOSH
11340
11341 $cat >> protochk <<'EOSH'
11342
11343 $rm -f try.c
11344 foo="$1"
11345 shift
11346 while test $# -ge 2; do
11347         case "$1" in
11348                 $define) echo "#include <$2>" >> try.c ;;
11349                 literal) echo "$2" >> try.c ;;
11350         esac
11351     shift 2
11352 done
11353 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11354 cat >> try.c <<'EOCP'
11355 #ifdef CAN_PROTOTYPE
11356 #define _(args) args
11357 #else
11358 #define _(args) ()
11359 #endif
11360 EOCP
11361 echo "$foo" >> try.c
11362 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11363 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11364 status=$?
11365 $rm -f try.[co]
11366 exit $status
11367 EOSH
11368 chmod +x protochk
11369 $eunicefix protochk
11370
11371 : see what type is used for size_t
11372 rp="What is the type used for the length parameter for string functions?"
11373 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11374 eval $typedef_ask
11375
11376 : check for type of arguments to gethostbyaddr. 
11377 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11378         case "$d_gethbyaddr" in
11379         $define)
11380                 $cat <<EOM
11381
11382 Checking to see what type of arguments are accepted by gethostbyaddr().
11383 EOM
11384                 hdrs="$define sys/types.h
11385                         $d_socket sys/socket.h 
11386                         $i_niin netinet/in.h 
11387                         $i_netdb netdb.h
11388                         $i_unistd unistd.h"
11389                 : The first arg can 'char *' or 'void *'
11390                 : The second arg is some of integral type
11391                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11392                         for yyy in size_t long int; do
11393                                 case "$netdb_host_type" in
11394                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11395                                         if ./protochk "$try" $hdrs; then
11396                                                 echo "Your system accepts $xxx for the first arg."
11397                                                 echo "...and $yyy for the second arg."
11398                                                 netdb_host_type="$xxx"
11399                                                 netdb_hlen_type="$yyy"
11400                                         fi
11401                                         ;;
11402                                 esac
11403                         done
11404                 done
11405                 : In case none of those worked, prompt the user.
11406                 case "$netdb_host_type" in
11407                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11408                         dflt='char *'
11409                         . ./myread
11410                         netdb_host_type=$ans
11411                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11412                         dflt="$sizetype"
11413                         . ./myread
11414                         netdb_hlen_type=$ans
11415                         ;;
11416                 esac
11417                 ;;
11418         *)      : no gethostbyaddr, so pick harmless defaults
11419                 netdb_host_type='char *'
11420                 netdb_hlen_type="$sizetype"
11421                 ;;
11422         esac
11423         # Remove the "const" if needed. -- but then we'll have a 
11424         # prototype clash!
11425         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11426 fi
11427
11428 : check for type of argument to gethostbyname. 
11429 if test "X$netdb_name_type" = X ; then
11430         case "$d_gethbyname" in
11431         $define)
11432                 $cat <<EOM
11433
11434 Checking to see what type of argument is accepted by gethostbyname().
11435 EOM
11436                 hdrs="$define sys/types.h
11437                         $d_socket sys/socket.h 
11438                         $i_niin netinet/in.h 
11439                         $i_netdb netdb.h
11440                         $i_unistd unistd.h"
11441                 for xxx in "const char *" "char *"; do
11442                         case "$netdb_name_type" in
11443                         '')     try="extern struct hostent *gethostbyname($xxx);"
11444                                 if ./protochk "$try" $hdrs; then
11445                                         echo "Your system accepts $xxx."
11446                                         netdb_name_type="$xxx"
11447                                 fi
11448                                 ;;
11449                         esac
11450                 done
11451                 : In case none of those worked, prompt the user.
11452                 case "$netdb_name_type" in
11453                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11454                         dflt='char *'
11455                         . ./myread
11456                         netdb_name_type=$ans
11457                         ;;
11458                 esac
11459                 ;;
11460         *)      : no gethostbyname, so pick harmless default
11461                 netdb_name_type='char *'
11462                 ;;
11463         esac
11464 fi
11465
11466 : check for type of 1st argument to getnetbyaddr. 
11467 if test "X$netdb_net_type" = X ; then
11468         case "$d_getnbyaddr" in
11469         $define)
11470                 $cat <<EOM
11471
11472 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11473 EOM
11474                 hdrs="$define sys/types.h
11475                         $d_socket sys/socket.h 
11476                         $i_niin netinet/in.h 
11477                         $i_netdb netdb.h
11478                         $i_unistd unistd.h"
11479                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11480                         case "$netdb_net_type" in
11481                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11482                                 if ./protochk "$try" $hdrs; then
11483                                         echo "Your system accepts $xxx."
11484                                         netdb_net_type="$xxx"
11485                                 fi
11486                                 ;;
11487                         esac
11488                 done
11489                 : In case none of those worked, prompt the user.
11490                 case "$netdb_net_type" in
11491                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11492                         dflt='long'
11493                         . ./myread
11494                         netdb_net_type=$ans
11495                         ;;
11496                 esac
11497                 ;;
11498         *)      : no getnetbyaddr, so pick harmless default
11499                 netdb_net_type='long'
11500                 ;;
11501         esac
11502 fi
11503 : locate the preferred pager for this system
11504 case "$pager" in
11505 '')
11506         dflt=''
11507         case "$pg" in
11508         /*) dflt=$pg;;
11509         esac
11510         case "$more" in
11511         /*) dflt=$more;;
11512         esac
11513         case "$less" in
11514         /*) dflt=$less;;
11515         esac
11516         case "$dflt" in
11517         '') dflt=/usr/ucb/more;;
11518         esac
11519         ;;
11520 *) dflt="$pager";;
11521 esac
11522 echo " "
11523 fn=f/
11524 rp='What pager is used on your system?'
11525 . ./getfile
11526 pager="$ans"
11527
11528 : see what type pids are declared as in the kernel
11529 rp="What is the type of process ids on this system?"
11530 set pid_t pidtype int stdio.h sys/types.h
11531 eval $typedef_ask
11532
11533 : check for length of pointer
11534 echo " "
11535 case "$ptrsize" in
11536 '')
11537         $echo $n "Checking to see how big your pointers are...$c" >&4
11538         if test "$voidflags" -gt 7; then
11539                 echo '#define VOID_PTR char *' > try.c
11540         else
11541                 echo '#define VOID_PTR void *' > try.c
11542         fi
11543         $cat >>try.c <<'EOCP'
11544 #include <stdio.h>
11545 int main()
11546 {
11547         printf("%d\n", sizeof(VOID_PTR));
11548         exit(0);
11549 }
11550 EOCP
11551         set try
11552         if eval $compile_ok; then
11553                 ptrsize=`./try`
11554                 $echo " $ptrsize bytes." >&4
11555         else
11556                 dflt='4'
11557                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11558                 rp="What is the size of a pointer (in bytes)?"
11559                 . ./myread
11560                 ptrsize="$ans"
11561         fi
11562         ;;
11563 esac
11564 $rm -f try.c try
11565
11566 : see if ar generates random libraries by itself
11567 echo " "
11568 echo "Checking how to generate random libraries on your machine..." >&4
11569 echo 'int bar1() { return bar2(); }' > bar1.c
11570 echo 'int bar2() { return 2; }' > bar2.c
11571 $cat > foo.c <<'EOP'
11572 int main() { printf("%d\n", bar1()); exit(0); }
11573 EOP
11574 $cc $ccflags -c bar1.c >/dev/null 2>&1
11575 $cc $ccflags -c bar2.c >/dev/null 2>&1
11576 $cc $ccflags -c foo.c >/dev/null 2>&1
11577 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11578 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11579         ./foobar >/dev/null 2>&1; then
11580         echo "$ar appears to generate random libraries itself."
11581         orderlib=false
11582         ranlib=":"
11583 elif $ar ts bar$_a >/dev/null 2>&1 &&
11584         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11585         ./foobar >/dev/null 2>&1; then
11586                 echo "a table of contents needs to be added with '$ar ts'."
11587                 orderlib=false
11588                 ranlib="$ar ts"
11589 else
11590         case "$ranlib" in
11591         :) ranlib='';;
11592         '')
11593                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11594                 $test -f $ranlib || ranlib=''
11595                 ;;
11596         esac
11597         if $test -n "$ranlib"; then
11598                 echo "your system has '$ranlib'; we'll use that."
11599                 orderlib=false
11600         else
11601                 echo "your system doesn't seem to support random libraries"
11602                 echo "so we'll use lorder and tsort to order the libraries."
11603                 orderlib=true
11604                 ranlib=":"
11605         fi
11606 fi
11607 $rm -f foo* bar* 
11608
11609 : check for type of arguments to select. 
11610 case "$selecttype" in
11611 '') case "$d_select" in
11612         $define)
11613                 $cat <<EOM
11614 Checking to see what type of arguments are accepted by select().
11615 EOM
11616                 hdrs="$define sys/types.h
11617                         $i_systime sys/time.h 
11618                         $i_sysselct sys/select.h
11619                         $d_socket sys/socket.h"
11620                 : The first arg can be int, unsigned, or size_t
11621                 : The last arg may or may not be 'const'
11622                 val=''
11623                 : void pointer has been seen but using that
11624                 : breaks the selectminbits test
11625                 for xxx in 'fd_set *' 'int *'; do
11626                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11627                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11628                                         case "$val" in
11629                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11630                                                 if ./protochk "$try" $hdrs; then
11631                                                         echo "Your system accepts $xxx."
11632                                                         val="$xxx"
11633                                                 fi
11634                                                 ;;
11635                                         esac
11636                                 done
11637                         done
11638                 done
11639                 case "$val" in
11640                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11641                         case "$d_fd_set" in
11642                                 $define) dflt="fd_set *" ;;
11643                                 *)              dflt="int *" ;;
11644                         esac
11645                         . ./myread
11646                         val=$ans
11647                         ;;
11648                 esac
11649                 selecttype="$val"
11650                 ;;
11651         *)      : no select, so pick a harmless default
11652                 selecttype='int *'
11653                 ;;
11654         esac
11655         ;;
11656 esac
11657
11658 : check for the select 'width'
11659 case "$selectminbits" in
11660 '') case "$d_select" in
11661         $define)
11662                 $cat <<EOM
11663
11664 Checking to see on how many bits at a time your select() operates...
11665 EOM
11666                 $cat >try.c <<EOCP
11667 #include <sys/types.h>
11668 #$i_time I_TIME
11669 #$i_systime I_SYS_TIME
11670 #$i_systimek I_SYS_TIME_KERNEL
11671 #ifdef I_TIME
11672 #   include <time.h>
11673 #endif
11674 #ifdef I_SYS_TIME
11675 #   ifdef I_SYS_TIME_KERNEL
11676 #       define KERNEL
11677 #   endif
11678 #   include <sys/time.h>
11679 #   ifdef I_SYS_TIME_KERNEL
11680 #       undef KERNEL
11681 #   endif
11682 #endif
11683 #$i_sysselct I_SYS_SELECT
11684 #ifdef I_SYS_SELECT
11685 #include <sys/select.h>
11686 #endif
11687 #$d_socket HAS_SOCKET
11688 #ifdef HAS_SOCKET
11689 #   include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
11690 #endif
11691 #include <stdio.h>
11692 $selecttype b;
11693 #define S sizeof(*(b))
11694 #define MINBITS 64
11695 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11696 #define NBITS  (NBYTES * 8)
11697 int main() {
11698     char s[NBYTES];
11699     struct timeval t;
11700     int i;
11701     FILE* fp;
11702     int fd;
11703
11704     fclose(stdin);
11705     fp = fopen("try.c", "r");
11706     if (fp == 0)
11707       exit(1);
11708     fd = fileno(fp);
11709     if (fd < 0)
11710       exit(2);
11711     b = ($selecttype)s;
11712     for (i = 0; i < NBITS; i++)
11713         FD_SET(i, b);
11714     t.tv_sec  = 0;
11715     t.tv_usec = 0;
11716     select(fd + 1, b, 0, 0, &t);
11717     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11718     printf("%d\n", i + 1);
11719     return 0;
11720 }
11721 EOCP
11722                 set try
11723                 if eval $compile_ok; then
11724                         selectminbits=`./try`
11725                         case "$selectminbits" in
11726                         '')     cat >&4 <<EOM
11727 Cannot figure out on how many bits at a time your select() operates.
11728 I'll play safe and guess it is 32 bits.
11729 EOM
11730                                 selectminbits=32
11731                                 bits="32 bits"
11732                                 ;;
11733                         1)      bits="1 bit" ;;
11734                         *)      bits="$selectminbits bits" ;;
11735                         esac
11736                         echo "Your select() operates on $bits at a time." >&4
11737                 else
11738                         rp='What is the minimum number of bits your select() operates on?'
11739                         case "$byteorder" in
11740                         1234|12345678)  dflt=32 ;;
11741                         *)              dflt=1  ;;
11742                         esac
11743                         . ./myread
11744                         val=$ans
11745                         selectminbits="$val"
11746                 fi
11747                 $rm -f try.* try
11748                 ;;
11749         *)      : no select, so pick a harmless default
11750                 selectminbits='32'
11751                 ;;
11752         esac
11753         ;;
11754 esac
11755
11756 : Trace out the files included by signal.h, then look for SIGxxx names.
11757 : Remove SIGARRAYSIZE used by HPUX.
11758 : Remove SIGSTKSIZE used by Linux.
11759 : Remove SIGSTKSZ used by Posix.
11760 : Remove SIGTYP void lines used by OS2.
11761 xxx=`echo '#include <signal.h>' |
11762         $cppstdin $cppminus $cppflags 2>/dev/null |
11763         $grep '^[       ]*#.*include' | 
11764         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11765 : Check this list of files to be sure we have parsed the cpp output ok.
11766 : This will also avoid potentially non-existent files, such 
11767 : as ../foo/bar.h
11768 xxxfiles=''
11769 for xx in $xxx /dev/null ; do
11770         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11771 done
11772 : If we have found no files, at least try signal.h
11773 case "$xxxfiles" in
11774 '')     xxxfiles=`./findhdr signal.h` ;;
11775 esac
11776 xxx=`awk '
11777 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11778         print substr($2, 4, 20)
11779 }
11780 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11781         print substr($3, 4, 20)
11782 }' $xxxfiles`
11783 : Append some common names just in case the awk scan failed.
11784 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11785 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11786 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11787 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11788 : generate a few handy files for later
11789 $cat > signal.c <<'EOCP'
11790 #include <sys/types.h>
11791 #include <signal.h>
11792 #include <stdio.h>
11793 int main() {
11794
11795 /* Strange style to avoid deeply-nested #if/#else/#endif */
11796 #ifndef NSIG
11797 #  ifdef _NSIG
11798 #    define NSIG (_NSIG)
11799 #  endif
11800 #endif
11801
11802 #ifndef NSIG
11803 #  ifdef SIGMAX
11804 #    define NSIG (SIGMAX+1)
11805 #  endif
11806 #endif
11807
11808 #ifndef NSIG
11809 #  ifdef SIG_MAX
11810 #    define NSIG (SIG_MAX+1)
11811 #  endif
11812 #endif
11813
11814 #ifndef NSIG
11815 #  ifdef MAXSIG
11816 #    define NSIG (MAXSIG+1)
11817 #  endif
11818 #endif
11819
11820 #ifndef NSIG
11821 #  ifdef MAX_SIG
11822 #    define NSIG (MAX_SIG+1)
11823 #  endif
11824 #endif
11825
11826 #ifndef NSIG
11827 #  ifdef SIGARRAYSIZE
11828 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11829 #  endif
11830 #endif
11831
11832 #ifndef NSIG
11833 #  ifdef _sys_nsig
11834 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11835 #  endif
11836 #endif
11837
11838 /* Default to some arbitrary number that's big enough to get most
11839    of the common signals.
11840 */
11841 #ifndef NSIG
11842 #    define NSIG 50
11843 #endif
11844
11845 printf("NSIG %d\n", NSIG);
11846
11847 #ifndef JUST_NSIG
11848
11849 EOCP
11850
11851 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11852 {
11853         printf "#ifdef SIG"; printf $1; printf "\n"
11854         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11855         printf $1; printf ");\n"
11856         printf "#endif\n"
11857 }
11858 END {
11859         printf "#endif /* JUST_NSIG */\n";
11860         printf "}\n";
11861 }
11862 ' >>signal.c
11863 $cat >signal.awk <<'EOP'
11864 BEGIN { ndups = 0 }
11865 $1 ~ /^NSIG$/ { nsig = $2 }
11866 ($1 !~ /^NSIG$/) && (NF == 2) {
11867     if ($2 > maxsig) { maxsig = $2 }
11868     if (sig_name[$2]) {
11869         dup_name[ndups] = $1
11870         dup_num[ndups] = $2
11871         ndups++ 
11872     }
11873     else {
11874         sig_name[$2] = $1
11875         sig_num[$2] = $2
11876     }
11877 }
11878 END { 
11879     if (nsig == 0) {
11880         nsig = maxsig + 1
11881     }
11882     printf("NSIG %d\n", nsig);
11883     for (n = 1; n < nsig; n++) {
11884         if (sig_name[n]) {
11885             printf("%s %d\n", sig_name[n], sig_num[n])
11886         }
11887         else {
11888             printf("NUM%d %d\n", n, n) 
11889         }
11890     }
11891     for (n = 0; n < ndups; n++) {
11892         printf("%s %d\n", dup_name[n], dup_num[n])
11893     }
11894 }
11895 EOP
11896 $cat >signal_cmd <<EOS
11897 $startsh
11898 if $test -s signal.lst; then
11899     echo "Using your existing signal.lst file"
11900         exit 0
11901 fi
11902 xxx="$xxx"
11903 EOS
11904 $cat >>signal_cmd <<'EOS'
11905
11906 set signal
11907 if eval $compile_ok; then
11908         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11909 else
11910         echo "(I can't seem be able to compile the whole test program)" >&4
11911         echo "(I'll try it in little pieces.)" >&4
11912         set signal -DJUST_NSIG
11913         if eval $compile_ok; then
11914                 ./signal$_exe > signal.nsg
11915                 $cat signal.nsg
11916         else
11917                 echo "I can't seem to figure out how many signals you have." >&4
11918                 echo "Guessing 50." >&4
11919                 echo 'NSIG 50' > signal.nsg
11920         fi
11921         : Now look at all the signal names, one at a time.
11922         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11923                 $cat > signal.c <<EOCP
11924 #include <sys/types.h>
11925 #include <signal.h>
11926 #include <stdio.h>
11927 int main() {
11928 printf("$xx %d\n", SIG${xx});
11929 return 0;
11930 }
11931 EOCP
11932                 set signal
11933                 if eval $compile; then
11934                         echo "SIG${xx} found."
11935                         ./signal$_exe  >> signal.ls1
11936                 else
11937                         echo "SIG${xx} NOT found."
11938                 fi
11939         done
11940         if $test -s signal.ls1; then
11941                 $cat signal.nsg signal.ls1 |
11942                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11943         fi
11944
11945 fi
11946 if $test -s signal.lst; then
11947         :
11948 else
11949         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11950         echo 'kill -l' >signal
11951         set X `csh -f <signal`
11952         $rm -f signal
11953         shift
11954         case $# in
11955         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11956         esac
11957         echo $@ | $tr ' ' $trnl | \
11958             $awk '{ printf "%s %d\n", $1, ++s; }
11959                   END { printf "NSIG %d\n", ++s }' >signal.lst
11960 fi
11961 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11962 EOS
11963 chmod a+x signal_cmd
11964 $eunicefix signal_cmd
11965
11966 : generate list of signal names
11967 echo " "
11968 case "$sig_name_init" in
11969 '') doinit=yes ;;
11970 *)  case "$sig_num_init" in
11971     ''|*,*) doinit=yes ;;
11972     esac ;;
11973 esac
11974 case "$doinit" in
11975 yes)
11976         echo "Generating a list of signal names and numbers..." >&4
11977         . ./signal_cmd
11978         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11979         sig_name=`$awk 'BEGIN { printf "ZERO " }
11980                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11981         sig_num=`$awk  'BEGIN { printf "0 " }
11982                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11983         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11984                              !/^NSIG/   { printf "\"%s\", ", $1 }
11985                              END        { printf "0\n" }' signal.lst`
11986         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11987                              !/^NSIG/   { printf "%d, ", $2}
11988                              END        { printf "0\n"}' signal.lst`
11989         ;;
11990 esac
11991 echo "The following $sig_count signals are available:"
11992 echo " "
11993 echo $sig_name | $awk \
11994 'BEGIN { linelen = 0 }
11995 {
11996         for (i = 1; i <= NF; i++) {
11997                 name = "SIG" $i " "
11998                 linelen = linelen + length(name)
11999                 if (linelen > 70) {
12000                         printf "\n"
12001                         linelen = length(name)
12002                 }
12003                 printf "%s", name
12004         }
12005         printf "\n"
12006 }'
12007 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
12008
12009 : see what type is used for signed size_t
12010 set ssize_t ssizetype int stdio.h sys/types.h
12011 eval $typedef
12012 dflt="$ssizetype"
12013 $cat > ssize.c <<EOM
12014 #include <stdio.h>
12015 #include <sys/types.h>
12016 #define Size_t $sizetype
12017 #define SSize_t $dflt
12018 int main()
12019 {
12020         if (sizeof(Size_t) == sizeof(SSize_t))
12021                 printf("$dflt\n");
12022         else if (sizeof(Size_t) == sizeof(int))
12023                 printf("int\n");
12024         else 
12025                 printf("long\n");
12026         exit(0);
12027 }
12028 EOM
12029 echo " "
12030 set ssize
12031 if eval $compile_ok && ./ssize > /dev/null; then
12032         ssizetype=`./ssize`
12033         echo "I'll be using $ssizetype for functions returning a byte count." >&4
12034 else
12035         $cat >&4 <<EOM
12036 Help! I can't compile and run the ssize_t test program: please enlighten me!
12037 (This is probably a misconfiguration in your system or libraries, and
12038 you really ought to fix it.  Still, I'll try anyway.)
12039
12040 I need a type that is the same size as $sizetype, but is guaranteed to
12041 be signed.  Common values are ssize_t, int and long.
12042
12043 EOM
12044         rp="What signed type is the same size as $sizetype?"
12045         . ./myread
12046         ssizetype="$ans"
12047 fi
12048 $rm -f ssize ssize.*
12049
12050 : see what type of char stdio uses.
12051 echo " "
12052 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
12053         echo "Your stdio uses unsigned chars." >&4
12054         stdchar="unsigned char"
12055 else
12056         echo "Your stdio uses signed chars." >&4
12057         stdchar="char"
12058 fi
12059
12060 : see if time exists
12061 echo " "
12062 if test "X$d_time" = X -o X"$timetype" = X; then
12063     if set time val -f d_time; eval $csym; $val; then
12064                 echo 'time() found.' >&4
12065                 val="$define"
12066                 rp="What is the type returned by time() on this system?"
12067                 set time_t timetype long stdio.h sys/types.h
12068                 eval $typedef_ask
12069     else
12070                 echo 'time() not found, hope that will do.' >&4
12071                 val="$undef"
12072                 timetype='int';
12073     fi
12074     set d_time
12075     eval $setvar
12076 fi
12077
12078 : see what type uids are declared as in the kernel
12079 echo " "
12080 echo "Looking for the type for user ids returned by getuid()."
12081 set uid_t uidtype xxx stdio.h sys/types.h
12082 eval $typedef
12083 case "$uidtype" in
12084 xxx)
12085         xxx=`./findhdr sys/user.h`
12086         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
12087         case $1 in
12088         unsigned) dflt="$1 $2" ;;
12089         *) dflt="$1" ;;
12090         esac
12091         ;;
12092 *) dflt="$uidtype";;
12093 esac
12094 case "$uidtype" in
12095 uid_t)  echo "uid_t found." ;;
12096 *)      rp="What is the type for user ids returned by getuid()?"
12097         . ./myread
12098         uidtype="$ans"
12099         ;;
12100 esac
12101
12102 : see if dbm.h is available
12103 : see if dbmclose exists
12104 set dbmclose d_dbmclose
12105 eval $inlibc
12106
12107 case "$d_dbmclose" in
12108 $define)
12109         set dbm.h i_dbm
12110         eval $inhdr
12111         case "$i_dbm" in
12112         $define)
12113                 val="$undef"
12114                 set i_rpcsvcdbm
12115                 eval $setvar
12116                 ;;
12117         *)      set rpcsvc/dbm.h i_rpcsvcdbm
12118                 eval $inhdr
12119                 ;;
12120         esac
12121         ;;
12122 *)      echo "We won't be including <dbm.h>"
12123         val="$undef"
12124         set i_dbm
12125         eval $setvar
12126         val="$undef"
12127         set i_rpcsvcdbm
12128         eval $setvar
12129         ;;
12130 esac
12131
12132 : see if this is a sys/file.h system
12133 val=''
12134 set sys/file.h val
12135 eval $inhdr
12136
12137 : do we need to include sys/file.h ?
12138 case "$val" in
12139 "$define")
12140         echo " "
12141         if $h_sysfile; then
12142                 val="$define"
12143                 echo "We'll be including <sys/file.h>." >&4
12144         else
12145                 val="$undef"
12146                 echo "We won't be including <sys/file.h>." >&4
12147         fi
12148         ;;
12149 *)
12150         h_sysfile=false
12151         ;;
12152 esac
12153 set i_sysfile
12154 eval $setvar
12155
12156 : see if fcntl.h is there
12157 val=''
12158 set fcntl.h val
12159 eval $inhdr
12160
12161 : see if we can include fcntl.h
12162 case "$val" in
12163 "$define")
12164         echo " "
12165         if $h_fcntl; then
12166                 val="$define"
12167                 echo "We'll be including <fcntl.h>." >&4
12168         else
12169                 val="$undef"
12170                 if $h_sysfile; then
12171         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12172                 else
12173                         echo "We won't be including <fcntl.h>." >&4
12174                 fi
12175         fi
12176         ;;
12177 *)
12178         h_fcntl=false
12179         val="$undef"
12180         ;;
12181 esac
12182 set i_fcntl
12183 eval $setvar
12184
12185 : see if locale.h is available
12186 set locale.h i_locale
12187 eval $inhdr
12188
12189 : see if mach cthreads are available
12190 if test "X$usethreads" = "X$define"; then
12191         set mach/cthreads.h i_machcthr
12192         eval $inhdr
12193 else
12194         i_machcthr="$undef"
12195 fi
12196
12197
12198
12199 : see if this is a math.h system
12200 set math.h i_math
12201 eval $inhdr
12202
12203 : see if this is a mntent.h system
12204 set mntent.h i_mntent
12205 eval $inhdr
12206
12207 : see if ndbm.h is available
12208 set ndbm.h t_ndbm
12209 eval $inhdr
12210 case "$t_ndbm" in
12211 $define)
12212         : see if dbm_open exists
12213         set dbm_open d_dbm_open
12214         eval $inlibc
12215         case "$d_dbm_open" in
12216         $undef)
12217                 t_ndbm="$undef"
12218                 echo "We won't be including <ndbm.h>"
12219                 ;;
12220         esac
12221         ;;
12222 esac
12223 val="$t_ndbm"
12224 set i_ndbm
12225 eval $setvar
12226
12227 : see if net/errno.h is available
12228 val=''
12229 set net/errno.h val
12230 eval $inhdr
12231
12232 : Unfortunately, it causes problems on some systems.  Arrgh.
12233 case "$val" in
12234 $define)
12235         cat > try.c <<'EOM'
12236 #include <stdio.h>
12237 #include <errno.h>
12238 #include <net/errno.h>
12239 int func()
12240 {
12241         return ENOTSOCK;
12242 }
12243 EOM
12244         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12245                 echo "We'll be including <net/errno.h>." >&4
12246         else
12247                 echo "We won't be including <net/errno.h>." >&4
12248                 val="$undef"
12249         fi
12250         $rm -f try.* try
12251         ;;
12252 esac
12253 set i_neterrno
12254 eval $setvar
12255
12256 : see if netinet/tcp.h is available
12257 set netinet/tcp.h i_netinettcp
12258 eval $inhdr
12259
12260 : see if this is a poll.h system
12261 set poll.h i_poll
12262 eval $inhdr
12263
12264 : get C preprocessor symbols handy
12265 echo " "
12266 $echo $n "Hmm... $c"
12267 echo $al | $tr ' ' $trnl >Cppsym.know
12268 $cat <<EOSS >Cppsym
12269 $startsh
12270 case "\$1" in
12271 -l) list=true
12272         shift
12273         ;;
12274 esac
12275 unknown=''
12276 case "\$list\$#" in
12277 1|2)
12278         for sym do
12279                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12280                         exit 0
12281                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12282                         :
12283                 else
12284                         unknown="\$unknown \$sym"
12285                 fi
12286         done
12287         set X \$unknown
12288         shift
12289         ;;
12290 esac
12291 case \$# in
12292 0) exit 1;;
12293 esac
12294 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12295 #ifdef \1\\
12296 exit 0; _ _ _ _\1\\      \1\\
12297 #endif\\
12298 /' >Cppsym\$\$
12299 echo "exit 1; _ _ _" >>Cppsym\$\$
12300 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12301 case "\$list" in
12302 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12303 *)
12304         sh Cppsym2\$\$
12305         status=\$?
12306         ;;
12307 esac
12308 $rm -f Cppsym\$\$ Cppsym2\$\$
12309 exit \$status
12310 EOSS
12311 chmod +x Cppsym
12312 $eunicefix Cppsym
12313 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12314
12315 : now check the C compiler for additional symbols
12316 postprocess_cc_v=''
12317 case "$osname" in
12318 aix) postprocess_cc_v="|$tr , ' '" ;;
12319 esac
12320 $cat >ccsym <<EOS
12321 $startsh
12322 $cat >tmp.c <<EOF
12323 extern int foo;
12324 EOF
12325 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12326 do
12327         case "\$i" in
12328         -D*) echo "\$i" | $sed 's/^-D//';;
12329         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12330         esac
12331 done
12332 $rm -f try.c
12333 EOS
12334 postprocess_cc_v=''
12335 chmod +x ccsym
12336 $eunicefix ccsym
12337 ./ccsym > ccsym1.raw
12338 if $test -s ccsym1.raw; then
12339        $sort ccsym1.raw | $uniq >ccsym.raw
12340 else
12341        mv ccsym1.raw ccsym.raw
12342 fi
12343
12344 $awk '/\=/ { print $0; next }
12345         { print $0"=1" }' ccsym.raw >ccsym.list
12346 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12347 $comm -13 ccsym.true ccsym.list >ccsym.own
12348 $comm -12 ccsym.true ccsym.list >ccsym.com
12349 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12350 also=''
12351 if $test -z ccsym.raw; then
12352         echo "Your C compiler doesn't seem to define any symbols!" >&4
12353         echo " "
12354         echo "However, your C preprocessor defines the following symbols:"
12355         $cat Cppsym.true
12356         ccsymbols=''
12357         cppsymbols=`$cat Cppsym.true`
12358         cppsymbols=`echo $cppsymbols`
12359         cppccsymbols="$cppsymbols"
12360 else
12361         if $test -s ccsym.com; then
12362                 echo "Your C compiler and pre-processor define these symbols:"
12363                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12364                 also='also '
12365                 symbols='ones'
12366                 cppccsymbols=`$cat ccsym.com`
12367                 cppccsymbols=`echo $cppccsymbols`
12368                 $test "$silent" || sleep 1
12369         fi
12370         if $test -s ccsym.cpp; then
12371                 $test "$also" && echo " "
12372                 echo "Your C pre-processor ${also}defines the following symbols:"
12373                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12374                 also='further '
12375                 cppsymbols=`$cat ccsym.cpp`
12376                 cppsymbols=`echo $cppsymbols`
12377                 $test "$silent" || sleep 1
12378         fi
12379         if $test -s ccsym.own; then
12380                 $test "$also" && echo " "
12381                 echo "Your C compiler ${also}defines the following cpp symbols:"
12382                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12383                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12384                 ccsymbols=`$cat ccsym.own`
12385                 ccsymbols=`echo $ccsymbols`
12386                 $test "$silent" || sleep 1
12387         fi
12388 fi
12389 $rm -f ccsym*
12390
12391 : see if this is a termio system
12392 val="$undef"
12393 val2="$undef"
12394 val3="$undef"
12395 if $test `./findhdr termios.h`; then
12396         set tcsetattr i_termios
12397         eval $inlibc
12398         val3="$i_termios"
12399 fi
12400 echo " "
12401 case "$val3" in
12402 "$define") echo "You have POSIX termios.h... good!" >&4;;
12403 *) if ./Cppsym pyr; then
12404                 case "`/bin/universe`" in
12405                 ucb) if $test `./findhdr sgtty.h`; then
12406                                 val2="$define"
12407                                 echo "<sgtty.h> found." >&4
12408                         else
12409                                 echo "System is pyramid with BSD universe."
12410                                 echo "<sgtty.h> not found--you could have problems." >&4
12411                         fi;;
12412                 *) if $test `./findhdr termio.h`; then
12413                                 val="$define"
12414                                 echo "<termio.h> found." >&4
12415                         else
12416                                 echo "System is pyramid with USG universe."
12417                                 echo "<termio.h> not found--you could have problems." >&4
12418                         fi;;
12419                 esac
12420         elif ./usg; then
12421                 if $test `./findhdr termio.h`; then
12422                         echo "<termio.h> found." >&4
12423                         val="$define"
12424                 elif $test `./findhdr sgtty.h`; then
12425                         echo "<sgtty.h> found." >&4
12426                         val2="$define"
12427                 else
12428 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12429                 fi
12430         else
12431                 if $test `./findhdr sgtty.h`; then
12432                         echo "<sgtty.h> found." >&4
12433                         val2="$define"
12434                 elif $test `./findhdr termio.h`; then
12435                         echo "<termio.h> found." >&4
12436                         val="$define"
12437                 else
12438 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12439                 fi
12440         fi;;
12441 esac
12442 set i_termio; eval $setvar
12443 val=$val2; set i_sgtty; eval $setvar
12444 val=$val3; set i_termios; eval $setvar
12445
12446 : see if this is a shadow.h system
12447 set shadow.h i_shadow
12448 eval $inhdr
12449
12450 : see if this is a socks.h system
12451 set socks.h i_socks
12452 eval $inhdr
12453
12454 : see if stdarg is available
12455 echo " "
12456 if $test `./findhdr stdarg.h`; then
12457         echo "<stdarg.h> found." >&4
12458         valstd="$define"
12459 else
12460         echo "<stdarg.h> NOT found." >&4
12461         valstd="$undef"
12462 fi
12463
12464 : see if varags is available
12465 echo " "
12466 if $test `./findhdr varargs.h`; then
12467         echo "<varargs.h> found." >&4
12468 else
12469         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12470 fi
12471
12472 : set up the varargs testing programs
12473 $cat > varargs.c <<EOP
12474 #ifdef I_STDARG
12475 #include <stdarg.h>
12476 #endif
12477 #ifdef I_VARARGS
12478 #include <varargs.h>
12479 #endif
12480
12481 #ifdef I_STDARG
12482 int f(char *p, ...)
12483 #else
12484 int f(va_alist)
12485 va_dcl
12486 #endif
12487 {
12488         va_list ap;
12489 #ifndef I_STDARG
12490         char *p;
12491 #endif
12492 #ifdef I_STDARG
12493         va_start(ap,p);
12494 #else
12495         va_start(ap);
12496         p = va_arg(ap, char *);
12497 #endif
12498         va_end(ap);
12499 }
12500 EOP
12501 $cat > varargs <<EOP
12502 $startsh
12503 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12504         echo "true"
12505 else
12506         echo "false"
12507 fi
12508 $rm -f varargs$_o
12509 EOP
12510 chmod +x varargs
12511
12512 : now check which varargs header should be included
12513 echo " "
12514 i_varhdr=''
12515 case "$valstd" in
12516 "$define")
12517         if `./varargs I_STDARG`; then
12518                 val='stdarg.h'
12519         elif `./varargs I_VARARGS`; then
12520                 val='varargs.h'
12521         fi
12522         ;;
12523 *)
12524         if `./varargs I_VARARGS`; then
12525                 val='varargs.h'
12526         fi
12527         ;;
12528 esac
12529 case "$val" in
12530 '')
12531 echo "I could not find the definition for va_dcl... You have problems..." >&4
12532         val="$undef"; set i_stdarg; eval $setvar
12533         val="$undef"; set i_varargs; eval $setvar
12534         ;;
12535 *) 
12536         set i_varhdr
12537         eval $setvar
12538         case "$i_varhdr" in
12539         stdarg.h)
12540                 val="$define"; set i_stdarg; eval $setvar
12541                 val="$undef"; set i_varargs; eval $setvar
12542                 ;;
12543         varargs.h)
12544                 val="$undef"; set i_stdarg; eval $setvar
12545                 val="$define"; set i_varargs; eval $setvar
12546                 ;;
12547         esac
12548         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12549 esac
12550 $rm -f varargs*
12551
12552 : see if stddef is available
12553 set stddef.h i_stddef
12554 eval $inhdr
12555
12556 : see if sys/access.h is available
12557 set sys/access.h i_sysaccess
12558 eval $inhdr
12559
12560 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12561 set sys/filio.h i_sysfilio
12562 eval $inhdr
12563 echo " "
12564 if $test `./findhdr sys/ioctl.h`; then
12565         val="$define"
12566         echo '<sys/ioctl.h> found.' >&4
12567 else
12568         val="$undef"
12569         if $test $i_sysfilio = "$define"; then
12570             echo '<sys/ioctl.h> NOT found.' >&4
12571         else
12572                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12573                 $test $i_termio = "$define" && xxx="termio.h"
12574                 $test $i_termios = "$define" && xxx="termios.h"
12575 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12576         fi
12577 fi
12578 set i_sysioctl
12579 eval $setvar
12580
12581 : see if sys/resource.h has to be included
12582 set sys/resource.h i_sysresrc
12583 eval $inhdr
12584
12585 : see if sys/security.h is available
12586 set sys/security.h i_syssecrt
12587 eval $inhdr
12588
12589 : see if this is a sys/statvfs.h system
12590 set sys/statvfs.h i_sysstatvfs
12591 eval $inhdr
12592
12593 : see if this is a sys/un.h system
12594 set sys/un.h i_sysun
12595 eval $inhdr
12596
12597 : see if this is a syswait system
12598 set sys/wait.h i_syswait
12599 eval $inhdr
12600
12601 : see if this is an utime system
12602 set utime.h i_utime
12603 eval $inhdr
12604
12605 : see if this is a values.h system
12606 set values.h i_values
12607 eval $inhdr
12608
12609 : see if this is a vfork system
12610 case "$d_vfork" in
12611 "$define")
12612         set vfork.h i_vfork
12613         eval $inhdr
12614         ;;
12615 *)
12616         i_vfork="$undef"
12617         ;;
12618 esac
12619
12620 : see if gdbm.h is available
12621 set gdbm.h t_gdbm
12622 eval $inhdr
12623 case "$t_gdbm" in
12624 $define)
12625         : see if gdbm_open exists
12626         set gdbm_open d_gdbm_open
12627         eval $inlibc
12628         case "$d_gdbm_open" in
12629         $undef)
12630                 t_gdbm="$undef"
12631                 echo "We won't be including <gdbm.h>"
12632                 ;;
12633         esac
12634         ;;
12635 esac
12636 val="$t_gdbm"
12637 set i_gdbm
12638 eval $setvar
12639
12640 echo " "
12641 echo "Looking for extensions..." >&4
12642 tdir=`pwd`
12643 cd $rsrc/ext
12644 : If we are using the old config.sh, known_extensions may contain
12645 : old or inaccurate or duplicate values.
12646 known_extensions=''
12647 nonxs_extensions=''
12648 : We do not use find because it might not be available.
12649 : We do not just use MANIFEST because the user may have dropped
12650 : some additional extensions into the source tree and expect them
12651 : to be built.
12652 for xxx in * ; do
12653         case "$xxx" in
12654         DynaLoader|dynaload) ;;
12655         *)      if $test -f $xxx/$xxx.xs; then
12656                         known_extensions="$known_extensions $xxx"
12657                 elif $test -f $xxx/Makefile.PL; then
12658                         nonxs_extensions="$nonxs_extensions $xxx"
12659                 else
12660                         if $test -d $xxx; then
12661                                 # Look for nested extensions, eg. Devel/Dprof.
12662                                 cd $xxx
12663                                 for yyy in * ; do
12664                                 if $test -f $yyy/$yyy.xs; then
12665                                         known_extensions="$known_extensions $xxx/$yyy"
12666                                 elif $test -f $yyy/Makefile.PL; then
12667                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12668                                 fi
12669                                 done
12670                                 cd ..
12671                         fi
12672                 fi 
12673                 ;;
12674         esac
12675 done
12676 set X $nonxs_extensions
12677 shift
12678 nonxs_extensions="$*"
12679 set X $known_extensions
12680 shift
12681 known_extensions="$*"
12682 cd $tdir
12683
12684 : Now see which are supported on this system.
12685 avail_ext=''
12686 for xxx in $known_extensions ; do
12687         case "$xxx" in
12688         DB_File|db_file)
12689                 case "$i_db" in
12690                 $define) avail_ext="$avail_ext $xxx" ;;
12691                 esac
12692                 ;;
12693         GDBM_File|gdbm_fil)
12694                 case "$i_gdbm" in 
12695                 $define) avail_ext="$avail_ext $xxx" ;;
12696                 esac
12697                 ;;
12698         NDBM_File|ndbm_fil)
12699                 case "$i_ndbm" in
12700                 $define) avail_ext="$avail_ext $xxx" ;;
12701                 esac
12702                 ;;
12703         ODBM_File|odbm_fil) 
12704                 case "${i_dbm}${i_rpcsvcdbm}" in
12705                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12706                 esac
12707                 ;;
12708         POSIX|posix)
12709                 case "$useposix" in
12710                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12711                 esac
12712                 ;;
12713         Opcode|opcode)
12714                 case "$useopcode" in
12715                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12716                 esac
12717                 ;;
12718         Socket|socket)
12719                 case "$d_socket" in 
12720                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12721                 esac
12722                 ;;
12723         Thread|thread)
12724                 case "$usethreads" in 
12725                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12726                 esac
12727                 ;;
12728         IPC/SysV|ipc/sysv)
12729                 : XXX Do we need a useipcsysv variable here
12730                 case "${d_msg}${d_sem}${d_shm}" in 
12731                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12732                 esac
12733                 ;;
12734         *)      avail_ext="$avail_ext $xxx"
12735                 ;;
12736         esac
12737 done
12738
12739 set X $avail_ext
12740 shift
12741 avail_ext="$*"
12742
12743 : Now see which nonxs extensions are supported on this system.
12744 : For now assume all are.
12745 nonxs_ext=''
12746 for xxx in $nonxs_extensions ; do
12747         case "$xxx" in
12748         *)      nonxs_ext="$nonxs_ext $xxx"
12749                 ;;
12750         esac
12751 done
12752
12753 set X $nonxs_ext
12754 shift
12755 nonxs_ext="$*"
12756
12757 case $usedl in
12758 $define)
12759         $cat <<EOM
12760 A number of extensions are supplied with $package.  You may choose to
12761 compile these extensions for dynamic loading (the default), compile
12762 them into the $package executable (static loading), or not include
12763 them at all.  Answer "none" to include no extensions.
12764 Note that DynaLoader is always built and need not be mentioned here.
12765
12766 EOM
12767         case "$dynamic_ext" in
12768         '') dflt="$avail_ext" ;;
12769         *)      dflt="$dynamic_ext"
12770                 # Perhaps we are reusing an old out-of-date config.sh.
12771                 case "$hint" in
12772                 previous)
12773                         if test X"$dynamic_ext" != X"$avail_ext"; then
12774                                 $cat <<EOM
12775 NOTICE:  Your previous config.sh list may be incorrect. 
12776 The extensions now available to you are 
12777         ${avail_ext}
12778 but the default list from your previous config.sh is
12779         ${dynamic_ext} 
12780
12781 EOM
12782                         fi
12783                         ;;
12784                 esac
12785                 ;;
12786         esac
12787         case "$dflt" in
12788         '')     dflt=none;;
12789         esac
12790         rp="What extensions do you wish to load dynamically?"
12791         . ./myread
12792         case "$ans" in
12793         none) dynamic_ext=' ' ;;
12794         *) dynamic_ext="$ans" ;;
12795         esac
12796
12797         case "$static_ext" in
12798         '')
12799                 : Exclude those already listed in dynamic linking
12800                 dflt=''
12801                 for xxx in $avail_ext; do
12802                         case " $dynamic_ext " in
12803                         *" $xxx "*) ;;
12804                         *) dflt="$dflt $xxx" ;;
12805                         esac
12806                 done
12807                 set X $dflt
12808                 shift
12809                 dflt="$*"
12810                 ;;
12811         *)  dflt="$static_ext" 
12812                 ;;
12813         esac
12814
12815         case "$dflt" in
12816         '')     dflt=none;;
12817         esac
12818         rp="What extensions do you wish to load statically?"
12819         . ./myread
12820         case "$ans" in
12821         none) static_ext=' ' ;;
12822         *) static_ext="$ans" ;;
12823         esac
12824         ;;
12825 *)
12826         $cat <<EOM
12827 A number of extensions are supplied with $package.  Answer "none" 
12828 to include no extensions. 
12829 Note that DynaLoader is always built and need not be mentioned here.
12830
12831 EOM
12832         case "$static_ext" in
12833         '') dflt="$avail_ext" ;;
12834         *)      dflt="$static_ext"
12835                 # Perhaps we are reusing an old out-of-date config.sh.
12836                 case "$hint" in
12837                 previous)
12838                         if test X"$static_ext" != X"$avail_ext"; then
12839                                 $cat <<EOM
12840 NOTICE:  Your previous config.sh list may be incorrect. 
12841 The extensions now available to you are 
12842         ${avail_ext}
12843 but the default list from your previous config.sh is
12844         ${static_ext} 
12845
12846 EOM
12847                         fi
12848                         ;;
12849                 esac
12850                 ;;
12851         esac
12852         : Exclude those that are not xs extensions
12853         case "$dflt" in
12854         '')     dflt=none;;
12855         esac
12856         rp="What extensions do you wish to include?"
12857         . ./myread
12858         case "$ans" in
12859         none) static_ext=' ' ;;
12860         *) static_ext="$ans" ;;
12861         esac
12862         ;;
12863 esac
12864
12865 set X $dynamic_ext $static_ext $nonxs_ext
12866 shift
12867 extensions="$*"
12868
12869 : Remove build directory name from cppstdin so it can be used from
12870 : either the present location or the final installed location.
12871 echo " "
12872 : Get out of the UU directory to get correct path name.
12873 cd ..
12874 case "$cppstdin" in
12875 `pwd`/cppstdin)
12876         echo "Stripping down cppstdin path name"
12877         cppstdin=cppstdin
12878         ;;
12879 esac
12880 cd UU
12881
12882 : end of configuration questions
12883 echo " "
12884 echo "End of configuration questions."
12885 echo " "
12886
12887 : back to where it started
12888 if test -d ../UU; then
12889         cd ..
12890 fi
12891
12892 : configuration may be patched via a 'config.over' file
12893 if $test -f config.over; then
12894         echo " "
12895         dflt=y
12896         rp='I see a config.over file.  Do you wish to load it?'
12897         . UU/myread
12898         case "$ans" in
12899         n*) echo "OK, I'll ignore it.";;
12900         *)      . ./config.over
12901                 echo "Configuration override changes have been loaded."
12902                 ;;
12903         esac
12904 fi
12905
12906 : in case they want portability, strip down executable paths
12907 case "$d_portable" in
12908 "$define")
12909         echo " "
12910         echo "Stripping down executable paths..." >&4
12911         for file in $loclist $trylist; do
12912                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12913                         eval $file="\$file"
12914                 fi
12915         done
12916         ;;
12917 esac
12918
12919 : create config.sh file
12920 echo " "
12921 echo "Creating config.sh..." >&4
12922 $spitshell <<EOT >config.sh
12923 $startsh
12924 #
12925 # This file was produced by running the Configure script. It holds all the
12926 # definitions figured out by Configure. Should you modify one of these values,
12927 # do not forget to propagate your changes by running "Configure -der". You may
12928 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12929 #
12930
12931 # Package name      : $package
12932 # Source directory  : $src
12933 # Configuration time: $cf_time
12934 # Configured by     : $cf_by
12935 # Target system     : $myuname
12936
12937 Author='$Author'
12938 Date='$Date'
12939 Header='$Header'
12940 Id='$Id'
12941 Locker='$Locker'
12942 Log='$Log'
12943 Mcc='$Mcc'
12944 RCSfile='$RCSfile'
12945 Revision='$Revision'
12946 Source='$Source'
12947 State='$State'
12948 _a='$_a'
12949 _exe='$_exe'
12950 _o='$_o'
12951 afs='$afs'
12952 alignbytes='$alignbytes'
12953 ansi2knr='$ansi2knr'
12954 aphostname='$aphostname'
12955 apiversion='$apiversion'
12956 ar='$ar'
12957 archlib='$archlib'
12958 archlibexp='$archlibexp'
12959 archname64='$archname64'
12960 archname='$archname'
12961 archobjs='$archobjs'
12962 awk='$awk'
12963 baserev='$baserev'
12964 bash='$bash'
12965 bin='$bin'
12966 binexp='$binexp'
12967 bison='$bison'
12968 byacc='$byacc'
12969 byteorder='$byteorder'
12970 c='$c'
12971 castflags='$castflags'
12972 cat='$cat'
12973 cc='$cc'
12974 cccdlflags='$cccdlflags'
12975 ccdlflags='$ccdlflags'
12976 ccflags='$ccflags'
12977 ccsymbols='$ccsymbols'
12978 cf_by='$cf_by'
12979 cf_email='$cf_email'
12980 cf_time='$cf_time'
12981 chgrp='$chgrp'
12982 chmod='$chmod'
12983 chown='$chown'
12984 clocktype='$clocktype'
12985 comm='$comm'
12986 compress='$compress'
12987 contains='$contains'
12988 cp='$cp'
12989 cpio='$cpio'
12990 cpp='$cpp'
12991 cpp_stuff='$cpp_stuff'
12992 cppccsymbols='$cppccsymbols'
12993 cppflags='$cppflags'
12994 cpplast='$cpplast'
12995 cppminus='$cppminus'
12996 cpprun='$cpprun'
12997 cppstdin='$cppstdin'
12998 cppsymbols='$cppsymbols'
12999 crosscompile='$crosscompile'
13000 cryptlib='$cryptlib'
13001 csh='$csh'
13002 d_Gconvert='$d_Gconvert'
13003 d_access='$d_access'
13004 d_accessx='$d_accessx'
13005 d_alarm='$d_alarm'
13006 d_archlib='$d_archlib'
13007 d_attribut='$d_attribut'
13008 d_bcmp='$d_bcmp'
13009 d_bcopy='$d_bcopy'
13010 d_bsd='$d_bsd'
13011 d_bsdgetpgrp='$d_bsdgetpgrp'
13012 d_bsdsetpgrp='$d_bsdsetpgrp'
13013 d_bzero='$d_bzero'
13014 d_casti32='$d_casti32'
13015 d_castneg='$d_castneg'
13016 d_charvspr='$d_charvspr'
13017 d_chown='$d_chown'
13018 d_chroot='$d_chroot'
13019 d_chsize='$d_chsize'
13020 d_closedir='$d_closedir'
13021 d_cmsghdr_s='$d_cmsghdr_s'
13022 d_const='$d_const'
13023 d_crypt='$d_crypt'
13024 d_csh='$d_csh'
13025 d_cuserid='$d_cuserid'
13026 d_dbl_dig='$d_dbl_dig'
13027 d_dbmclose64='$d_dbmclose64'
13028 d_dbminit64='$d_dbminit64'
13029 d_delete64='$d_delete64'
13030 d_difftime='$d_difftime'
13031 d_dirent64_s='$d_dirent64_s'
13032 d_dirnamlen='$d_dirnamlen'
13033 d_dlerror='$d_dlerror'
13034 d_dlopen='$d_dlopen'
13035 d_dlsymun='$d_dlsymun'
13036 d_dosuid='$d_dosuid'
13037 d_drand48proto='$d_drand48proto'
13038 d_dup2='$d_dup2'
13039 d_eaccess='$d_eaccess'
13040 d_endgrent='$d_endgrent'
13041 d_endhent='$d_endhent'
13042 d_endnent='$d_endnent'
13043 d_endpent='$d_endpent'
13044 d_endpwent='$d_endpwent'
13045 d_endsent='$d_endsent'
13046 d_endspent='$d_endspent'
13047 d_eofnblk='$d_eofnblk'
13048 d_eunice='$d_eunice'
13049 d_fchmod='$d_fchmod'
13050 d_fchown='$d_fchown'
13051 d_fcntl='$d_fcntl'
13052 d_fd_macros='$d_fd_macros'
13053 d_fd_set='$d_fd_set'
13054 d_fds_bits='$d_fds_bits'
13055 d_fetch64='$d_fetch64'
13056 d_fgetpos64='$d_fgetpos64'
13057 d_fgetpos='$d_fgetpos'
13058 d_firstkey64='$d_firstkey64'
13059 d_flexfnam='$d_flexfnam'
13060 d_flock64_s='$d_flock64_s'
13061 d_flock='$d_flock'
13062 d_fopen64='$d_fopen64'
13063 d_fork='$d_fork'
13064 d_fpathconf='$d_fpathconf'
13065 d_freopen64='$d_freopen64'
13066 d_fseek64='$d_fseek64'
13067 d_fseeko64='$d_fseeko64'
13068 d_fseeko='$d_fseeko'
13069 d_fsetpos64='$d_fsetpos64'
13070 d_fsetpos='$d_fsetpos'
13071 d_fstat64='$d_fstat64'
13072 d_fstatfs='$d_fstatfs'
13073 d_fstatvfs='$d_fstatvfs'
13074 d_ftell64='$d_ftell64'
13075 d_ftello64='$d_ftello64'
13076 d_ftello='$d_ftello'
13077 d_ftime='$d_ftime'
13078 d_ftruncate64='$d_ftruncate64'
13079 d_getgrent='$d_getgrent'
13080 d_getgrps='$d_getgrps'
13081 d_gethbyaddr='$d_gethbyaddr'
13082 d_gethbyname='$d_gethbyname'
13083 d_gethent='$d_gethent'
13084 d_gethname='$d_gethname'
13085 d_gethostprotos='$d_gethostprotos'
13086 d_getlogin='$d_getlogin'
13087 d_getmntent='$d_getmntent'
13088 d_getnbyaddr='$d_getnbyaddr'
13089 d_getnbyname='$d_getnbyname'
13090 d_getnent='$d_getnent'
13091 d_getnetprotos='$d_getnetprotos'
13092 d_getpbyname='$d_getpbyname'
13093 d_getpbynumber='$d_getpbynumber'
13094 d_getpent='$d_getpent'
13095 d_getpgid='$d_getpgid'
13096 d_getpgrp2='$d_getpgrp2'
13097 d_getpgrp='$d_getpgrp'
13098 d_getppid='$d_getppid'
13099 d_getprior='$d_getprior'
13100 d_getprotoprotos='$d_getprotoprotos'
13101 d_getpwent='$d_getpwent'
13102 d_getsbyname='$d_getsbyname'
13103 d_getsbyport='$d_getsbyport'
13104 d_getsent='$d_getsent'
13105 d_getservprotos='$d_getservprotos'
13106 d_getspent='$d_getspent'
13107 d_getspnam='$d_getspnam'
13108 d_gettimeod='$d_gettimeod'
13109 d_gnulibc='$d_gnulibc'
13110 d_grpasswd='$d_grpasswd'
13111 d_hasmntopt='$d_hasmntopt'
13112 d_htonl='$d_htonl'
13113 d_index='$d_index'
13114 d_inetaton='$d_inetaton'
13115 d_ino64_t='$d_ino64_t'
13116 d_int64t='$d_int64t'
13117 d_iovec_s='$d_iovec_s'
13118 d_isascii='$d_isascii'
13119 d_killpg='$d_killpg'
13120 d_lchown='$d_lchown'
13121 d_link='$d_link'
13122 d_llseek='$d_llseek'
13123 d_locconv='$d_locconv'
13124 d_lockf64='$d_lockf64'
13125 d_lockf='$d_lockf'
13126 d_longdbl='$d_longdbl'
13127 d_longlong='$d_longlong'
13128 d_lseek64='$d_lseek64'
13129 d_lstat64='$d_lstat64'
13130 d_lstat='$d_lstat'
13131 d_madvise='$d_madvise'
13132 d_mblen='$d_mblen'
13133 d_mbstowcs='$d_mbstowcs'
13134 d_mbtowc='$d_mbtowc'
13135 d_memchr='$d_memchr'
13136 d_memcmp='$d_memcmp'
13137 d_memcpy='$d_memcpy'
13138 d_memmove='$d_memmove'
13139 d_memset='$d_memset'
13140 d_mkdir='$d_mkdir'
13141 d_mkfifo='$d_mkfifo'
13142 d_mktime='$d_mktime'
13143 d_mmap='$d_mmap'
13144 d_mprotect='$d_mprotect'
13145 d_msg='$d_msg'
13146 d_msg_ctrunc='$d_msg_ctrunc'
13147 d_msg_dontroute='$d_msg_dontroute'
13148 d_msg_oob='$d_msg_oob'
13149 d_msg_peek='$d_msg_peek'
13150 d_msg_proxy='$d_msg_proxy'
13151 d_msgctl='$d_msgctl'
13152 d_msgget='$d_msgget'
13153 d_msghdr_s='$d_msghdr_s'
13154 d_msgrcv='$d_msgrcv'
13155 d_msgsnd='$d_msgsnd'
13156 d_msync='$d_msync'
13157 d_munmap='$d_munmap'
13158 d_mymalloc='$d_mymalloc'
13159 d_nextkey64='$d_nextkey64'
13160 d_nice='$d_nice'
13161 d_off64_t='$d_off64_t'
13162 d_offset_t='$d_offset_t'
13163 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
13164 d_oldpthreads='$d_oldpthreads'
13165 d_oldsock='$d_oldsock'
13166 d_open3='$d_open3'
13167 d_open64='$d_open64'
13168 d_opendir64='$d_opendir64'
13169 d_pathconf='$d_pathconf'
13170 d_pause='$d_pause'
13171 d_phostname='$d_phostname'
13172 d_pipe='$d_pipe'
13173 d_poll='$d_poll'
13174 d_portable='$d_portable'
13175 d_pthread_yield='$d_pthread_yield'
13176 d_pwage='$d_pwage'
13177 d_pwchange='$d_pwchange'
13178 d_pwclass='$d_pwclass'
13179 d_pwcomment='$d_pwcomment'
13180 d_pwexpire='$d_pwexpire'
13181 d_pwgecos='$d_pwgecos'
13182 d_pwpasswd='$d_pwpasswd'
13183 d_pwquota='$d_pwquota'
13184 d_readdir64='$d_readdir64'
13185 d_readdir='$d_readdir'
13186 d_readlink='$d_readlink'
13187 d_readv='$d_readv'
13188 d_recvmsg='$d_recvmsg'
13189 d_rename='$d_rename'
13190 d_rewinddir='$d_rewinddir'
13191 d_rmdir='$d_rmdir'
13192 d_safebcpy='$d_safebcpy'
13193 d_safemcpy='$d_safemcpy'
13194 d_sanemcmp='$d_sanemcmp'
13195 d_sched_yield='$d_sched_yield'
13196 d_scm_rights='$d_scm_rights'
13197 d_seekdir64='$d_seekdir64'
13198 d_seekdir='$d_seekdir'
13199 d_select='$d_select'
13200 d_sem='$d_sem'
13201 d_semctl='$d_semctl'
13202 d_semctl_semid_ds='$d_semctl_semid_ds'
13203 d_semctl_semun='$d_semctl_semun'
13204 d_semget='$d_semget'
13205 d_semop='$d_semop'
13206 d_sendmsg='$d_sendmsg'
13207 d_setegid='$d_setegid'
13208 d_seteuid='$d_seteuid'
13209 d_setgrent='$d_setgrent'
13210 d_setgrps='$d_setgrps'
13211 d_sethent='$d_sethent'
13212 d_setlinebuf='$d_setlinebuf'
13213 d_setlocale='$d_setlocale'
13214 d_setnent='$d_setnent'
13215 d_setpent='$d_setpent'
13216 d_setpgid='$d_setpgid'
13217 d_setpgrp2='$d_setpgrp2'
13218 d_setpgrp='$d_setpgrp'
13219 d_setprior='$d_setprior'
13220 d_setpwent='$d_setpwent'
13221 d_setregid='$d_setregid'
13222 d_setresgid='$d_setresgid'
13223 d_setresuid='$d_setresuid'
13224 d_setreuid='$d_setreuid'
13225 d_setrgid='$d_setrgid'
13226 d_setruid='$d_setruid'
13227 d_setsent='$d_setsent'
13228 d_setsid='$d_setsid'
13229 d_setspent='$d_setspent'
13230 d_setvbuf='$d_setvbuf'
13231 d_sfio='$d_sfio'
13232 d_shm='$d_shm'
13233 d_shmat='$d_shmat'
13234 d_shmatprototype='$d_shmatprototype'
13235 d_shmctl='$d_shmctl'
13236 d_shmdt='$d_shmdt'
13237 d_shmget='$d_shmget'
13238 d_sigaction='$d_sigaction'
13239 d_sigsetjmp='$d_sigsetjmp'
13240 d_socket='$d_socket'
13241 d_sockpair='$d_sockpair'
13242 d_stat64='$d_stat64'
13243 d_statblks='$d_statblks'
13244 d_statfs='$d_statfs'
13245 d_statfsflags='$d_statfsflags'
13246 d_statvfs='$d_statvfs'
13247 d_stdio_cnt_lval='$d_stdio_cnt_lval'
13248 d_stdio_ptr_lval='$d_stdio_ptr_lval'
13249 d_stdio_stream_array='$d_stdio_stream_array'
13250 d_stdiobase='$d_stdiobase'
13251 d_stdstdio='$d_stdstdio'
13252 d_store64='$d_store64'
13253 d_strchr='$d_strchr'
13254 d_strcoll='$d_strcoll'
13255 d_strctcpy='$d_strctcpy'
13256 d_strerrm='$d_strerrm'
13257 d_strerror='$d_strerror'
13258 d_strtod='$d_strtod'
13259 d_strtol='$d_strtol'
13260 d_strtoul='$d_strtoul'
13261 d_strxfrm='$d_strxfrm'
13262 d_suidsafe='$d_suidsafe'
13263 d_symlink='$d_symlink'
13264 d_syscall='$d_syscall'
13265 d_sysconf='$d_sysconf'
13266 d_sysernlst='$d_sysernlst'
13267 d_syserrlst='$d_syserrlst'
13268 d_system='$d_system'
13269 d_tcgetpgrp='$d_tcgetpgrp'
13270 d_tcsetpgrp='$d_tcsetpgrp'
13271 d_telldir64='$d_telldir64'
13272 d_telldir='$d_telldir'
13273 d_telldirproto='$d_telldirproto'
13274 d_time='$d_time'
13275 d_times='$d_times'
13276 d_tmpfile64='$d_tmpfile64'
13277 d_truncate64='$d_truncate64'
13278 d_truncate='$d_truncate'
13279 d_tzname='$d_tzname'
13280 d_umask='$d_umask'
13281 d_uname='$d_uname'
13282 d_union_semun='$d_union_semun'
13283 d_vfork='$d_vfork'
13284 d_void_closedir='$d_void_closedir'
13285 d_voidsig='$d_voidsig'
13286 d_voidtty='$d_voidtty'
13287 d_volatile='$d_volatile'
13288 d_vprintf='$d_vprintf'
13289 d_wait4='$d_wait4'
13290 d_waitpid='$d_waitpid'
13291 d_wcstombs='$d_wcstombs'
13292 d_wctomb='$d_wctomb'
13293 d_writev='$d_writev'
13294 d_xenix='$d_xenix'
13295 date='$date'
13296 db_hashtype='$db_hashtype'
13297 db_prefixtype='$db_prefixtype'
13298 defvoidused='$defvoidused'
13299 direntrytype='$direntrytype'
13300 dlext='$dlext'
13301 dlsrc='$dlsrc'
13302 doublesize='$doublesize'
13303 drand01='$drand01'
13304 dynamic_ext='$dynamic_ext'
13305 eagain='$eagain'
13306 ebcdic='$ebcdic'
13307 echo='$echo'
13308 egrep='$egrep'
13309 emacs='$emacs'
13310 eunicefix='$eunicefix'
13311 exe_ext='$exe_ext'
13312 expr='$expr'
13313 extensions='$extensions'
13314 fflushNULL='$fflushNULL'
13315 fflushall='$fflushall'
13316 find='$find'
13317 firstmakefile='$firstmakefile'
13318 flex='$flex'
13319 fpostype='$fpostype'
13320 freetype='$freetype'
13321 full_ar='$full_ar'
13322 full_csh='$full_csh'
13323 full_sed='$full_sed'
13324 gccversion='$gccversion'
13325 gidtype='$gidtype'
13326 glibpth='$glibpth'
13327 grep='$grep'
13328 groupcat='$groupcat'
13329 groupstype='$groupstype'
13330 gzip='$gzip'
13331 h_fcntl='$h_fcntl'
13332 h_sysfile='$h_sysfile'
13333 hint='$hint'
13334 hostcat='$hostcat'
13335 huge='$huge'
13336 i_arpainet='$i_arpainet'
13337 i_bsdioctl='$i_bsdioctl'
13338 i_db='$i_db'
13339 i_dbm='$i_dbm'
13340 i_dirent='$i_dirent'
13341 i_dld='$i_dld'
13342 i_dlfcn='$i_dlfcn'
13343 i_fcntl='$i_fcntl'
13344 i_float='$i_float'
13345 i_gdbm='$i_gdbm'
13346 i_grp='$i_grp'
13347 i_inttypes='$i_inttypes'
13348 i_limits='$i_limits'
13349 i_locale='$i_locale'
13350 i_machcthr='$i_machcthr'
13351 i_malloc='$i_malloc'
13352 i_math='$i_math'
13353 i_memory='$i_memory'
13354 i_mntent='$i_mntent'
13355 i_ndbm='$i_ndbm'
13356 i_netdb='$i_netdb'
13357 i_neterrno='$i_neterrno'
13358 i_netinettcp='$i_netinettcp'
13359 i_niin='$i_niin'
13360 i_poll='$i_poll'
13361 i_pthread='$i_pthread'
13362 i_pwd='$i_pwd'
13363 i_rpcsvcdbm='$i_rpcsvcdbm'
13364 i_sfio='$i_sfio'
13365 i_sgtty='$i_sgtty'
13366 i_shadow='$i_shadow'
13367 i_socks='$i_socks'
13368 i_stdarg='$i_stdarg'
13369 i_stddef='$i_stddef'
13370 i_stdlib='$i_stdlib'
13371 i_string='$i_string'
13372 i_sysaccess='$i_sysaccess'
13373 i_sysdir='$i_sysdir'
13374 i_sysfile='$i_sysfile'
13375 i_sysfilio='$i_sysfilio'
13376 i_sysin='$i_sysin'
13377 i_sysioctl='$i_sysioctl'
13378 i_sysmman='$i_sysmman'
13379 i_sysmount='$i_sysmount'
13380 i_sysndir='$i_sysndir'
13381 i_sysparam='$i_sysparam'
13382 i_sysresrc='$i_sysresrc'
13383 i_syssecrt='$i_syssecrt'
13384 i_sysselct='$i_sysselct'
13385 i_syssockio='$i_syssockio'
13386 i_sysstat='$i_sysstat'
13387 i_sysstatvfs='$i_sysstatvfs'
13388 i_systime='$i_systime'
13389 i_systimek='$i_systimek'
13390 i_systimes='$i_systimes'
13391 i_systypes='$i_systypes'
13392 i_sysuio='$i_sysuio'
13393 i_sysun='$i_sysun'
13394 i_syswait='$i_syswait'
13395 i_termio='$i_termio'
13396 i_termios='$i_termios'
13397 i_time='$i_time'
13398 i_unistd='$i_unistd'
13399 i_utime='$i_utime'
13400 i_values='$i_values'
13401 i_varargs='$i_varargs'
13402 i_varhdr='$i_varhdr'
13403 i_vfork='$i_vfork'
13404 ignore_versioned_solibs='$ignore_versioned_solibs'
13405 incpath='$incpath'
13406 inews='$inews'
13407 installarchlib='$installarchlib'
13408 installbin='$installbin'
13409 installman1dir='$installman1dir'
13410 installman3dir='$installman3dir'
13411 installprivlib='$installprivlib'
13412 installscript='$installscript'
13413 installsitearch='$installsitearch'
13414 installsitelib='$installsitelib'
13415 installusrbinperl='$installusrbinperl'
13416 intsize='$intsize'
13417 known_extensions='$known_extensions'
13418 ksh='$ksh'
13419 large='$large'
13420 ld='$ld'
13421 lddlflags='$lddlflags'
13422 ldflags='$ldflags'
13423 less='$less'
13424 lib_ext='$lib_ext'
13425 libc='$libc'
13426 libperl='$libperl'
13427 libpth='$libpth'
13428 libs='$libs'
13429 libswanted='$libswanted'
13430 line='$line'
13431 lint='$lint'
13432 lkflags='$lkflags'
13433 ln='$ln'
13434 lns='$lns'
13435 locincpth='$locincpth'
13436 loclibpth='$loclibpth'
13437 longdblsize='$longdblsize'
13438 longlongsize='$longlongsize'
13439 longsize='$longsize'
13440 lp='$lp'
13441 lpr='$lpr'
13442 ls='$ls'
13443 lseeksize='$lseeksize'
13444 lseektype='$lseektype'
13445 mail='$mail'
13446 mailx='$mailx'
13447 make='$make'
13448 make_set_make='$make_set_make'
13449 mallocobj='$mallocobj'
13450 mallocsrc='$mallocsrc'
13451 malloctype='$malloctype'
13452 man1dir='$man1dir'
13453 man1direxp='$man1direxp'
13454 man1ext='$man1ext'
13455 man3dir='$man3dir'
13456 man3direxp='$man3direxp'
13457 man3ext='$man3ext'
13458 medium='$medium'
13459 mips='$mips'
13460 mips_type='$mips_type'
13461 mkdir='$mkdir'
13462 mmaptype='$mmaptype'
13463 models='$models'
13464 modetype='$modetype'
13465 more='$more'
13466 multiarch='$multiarch'
13467 mv='$mv'
13468 myarchname='$myarchname'
13469 mydomain='$mydomain'
13470 myhostname='$myhostname'
13471 myuname='$myuname'
13472 n='$n'
13473 netdb_hlen_type='$netdb_hlen_type'
13474 netdb_host_type='$netdb_host_type'
13475 netdb_name_type='$netdb_name_type'
13476 netdb_net_type='$netdb_net_type'
13477 nm='$nm'
13478 nm_opt='$nm_opt'
13479 nm_so_opt='$nm_so_opt'
13480 nonxs_ext='$nonxs_ext'
13481 nroff='$nroff'
13482 o_nonblock='$o_nonblock'
13483 obj_ext='$obj_ext'
13484 old_pthread_create_joinable='$old_pthread_create_joinable'
13485 optimize='$optimize'
13486 orderlib='$orderlib'
13487 osname='$osname'
13488 osvers='$osvers'
13489 package='$package'
13490 pager='$pager'
13491 passcat='$passcat'
13492 patchlevel='$patchlevel'
13493 path_sep='$path_sep'
13494 perl='$perl'
13495 perladmin='$perladmin'
13496 perlpath='$perlpath'
13497 pg='$pg'
13498 phostname='$phostname'
13499 pidtype='$pidtype'
13500 plibpth='$plibpth'
13501 pmake='$pmake'
13502 pr='$pr'
13503 prefix='$prefix'
13504 prefixexp='$prefixexp'
13505 privlib='$privlib'
13506 privlibexp='$privlibexp'
13507 prototype='$prototype'
13508 ptrsize='$ptrsize'
13509 randbits='$randbits'
13510 randfunc='$randfunc'
13511 randseedtype='$randseedtype'
13512 ranlib='$ranlib'
13513 rd_nodata='$rd_nodata'
13514 rm='$rm'
13515 rmail='$rmail'
13516 runnm='$runnm'
13517 sched_yield='$sched_yield'
13518 scriptdir='$scriptdir'
13519 scriptdirexp='$scriptdirexp'
13520 sed='$sed'
13521 seedfunc='$seedfunc'
13522 selectminbits='$selectminbits'
13523 selecttype='$selecttype'
13524 sendmail='$sendmail'
13525 sh='$sh'
13526 shar='$shar'
13527 sharpbang='$sharpbang'
13528 shmattype='$shmattype'
13529 shortsize='$shortsize'
13530 shrpenv='$shrpenv'
13531 shsharp='$shsharp'
13532 sig_count='$sig_count'
13533 sig_name='$sig_name'
13534 sig_name_init='$sig_name_init'
13535 sig_num='$sig_num'
13536 sig_num_init='$sig_num_init'
13537 signal_t='$signal_t'
13538 sitearch='$sitearch'
13539 sitearchexp='$sitearchexp'
13540 sitelib='$sitelib'
13541 sitelibexp='$sitelibexp'
13542 sizetype='$sizetype'
13543 sleep='$sleep'
13544 smail='$smail'
13545 small='$small'
13546 so='$so'
13547 sockethdr='$sockethdr'
13548 socketlib='$socketlib'
13549 sort='$sort'
13550 spackage='$spackage'
13551 spitshell='$spitshell'
13552 split='$split'
13553 src='$src'
13554 ssizetype='$ssizetype'
13555 startperl='$startperl'
13556 startsh='$startsh'
13557 static_ext='$static_ext'
13558 stdchar='$stdchar'
13559 stdio_base='$stdio_base'
13560 stdio_bufsiz='$stdio_bufsiz'
13561 stdio_cnt='$stdio_cnt'
13562 stdio_filbuf='$stdio_filbuf'
13563 stdio_ptr='$stdio_ptr'
13564 stdio_stream_array='$stdio_stream_array'
13565 strings='$strings'
13566 submit='$submit'
13567 subversion='$subversion'
13568 sysman='$sysman'
13569 tail='$tail'
13570 tar='$tar'
13571 tbl='$tbl'
13572 tee='$tee'
13573 test='$test'
13574 timeincl='$timeincl'
13575 timetype='$timetype'
13576 touch='$touch'
13577 tr='$tr'
13578 trnl='$trnl'
13579 troff='$troff'
13580 uidtype='$uidtype'
13581 uname='$uname'
13582 uniq='$uniq'
13583 use64bits='$use64bits'
13584 usedl='$usedl'
13585 usemultiplicity='$usemultiplicity'
13586 usemymalloc='$usemymalloc'
13587 usenm='$usenm'
13588 useopcode='$useopcode'
13589 useperlio='$useperlio'
13590 useposix='$useposix'
13591 usesfio='$usesfio'
13592 useshrplib='$useshrplib'
13593 usesocks='$usesocks'
13594 usethreads='$usethreads'
13595 usevfork='$usevfork'
13596 usrinc='$usrinc'
13597 uuname='$uuname'
13598 version='$version'
13599 vi='$vi'
13600 voidflags='$voidflags'
13601 xlibpth='$xlibpth'
13602 zcat='$zcat'
13603 zip='$zip'
13604 EOT
13605
13606 : Add in command line options if available
13607 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13608
13609 : add special variables
13610 $test -f $src/patchlevel.h && \
13611 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13612 echo "CONFIGDOTSH=true" >>config.sh
13613
13614 : propagate old symbols
13615 if $test -f UU/config.sh; then
13616         <UU/config.sh sort | uniq >UU/oldconfig.sh
13617         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13618         sort | uniq -u >UU/oldsyms
13619         set X `cat UU/oldsyms`
13620         shift
13621         case $# in
13622         0) ;;
13623         *)
13624                 cat <<EOM
13625 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13626 EOM
13627                 echo "# Variables propagated from previous config.sh file." >>config.sh
13628                 for sym in `cat UU/oldsyms`; do
13629                         echo "    Propagating $hint variable "'$'"$sym..."
13630                         eval 'tmp="$'"${sym}"'"'
13631                         echo "$tmp" | \
13632                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13633                 done
13634                 ;;
13635         esac
13636 fi
13637
13638 : Finish up by extracting the .SH files
13639 case "$alldone" in
13640 exit)
13641         $rm -rf UU
13642         echo "Done."
13643         exit 0
13644         ;;
13645 cont)
13646         ;;
13647 '')
13648         dflt=''
13649         nostick=true
13650         $cat <<EOM
13651
13652 If you'd like to make any changes to the config.sh file before I begin
13653 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13654
13655 EOM
13656         rp="Press return or use a shell escape to edit config.sh:"
13657         . UU/myread
13658         nostick=''
13659         case "$ans" in
13660         '') ;;
13661         *) : in case they cannot read
13662                 sh 1>&4 -c "$ans";;
13663         esac
13664         ;;
13665 esac
13666
13667 : if this fails, just run all the .SH files by hand
13668 . ./config.sh
13669
13670 echo " "
13671 exec 1>&4
13672 . ./UU/extract
13673
13674 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13675         dflt=y
13676         case "$silent" in
13677         true) ;;
13678         *)
13679                 $cat <<EOM
13680
13681 Now you need to generate make dependencies by running "$make depend".
13682 You might prefer to run it in background: "$make depend > makedepend.out &"
13683 It can take a while, so you might not want to run it right now.
13684
13685 EOM
13686                 ;;
13687         esac
13688         rp="Run $make depend now?"
13689         . UU/myread
13690         case "$ans" in
13691         y*)
13692                 $make depend && echo "Now you must run a $make."
13693                 ;;
13694         *)
13695                 echo "You must run '$make depend' then '$make'."
13696                 ;;
13697         esac
13698 elif test -f [Mm]akefile; then
13699         echo " "
13700         echo "Now you must run a $make."
13701 else
13702         echo "Done."
13703 fi
13704
13705 if $test -f Policy.sh; then
13706     $cat <<EOM
13707
13708 If you compile $package on a different machine or from a different object
13709 directory, copy the Policy.sh file from this object directory to the
13710 new one before you run Configure -- this will help you with most of
13711 the policy defaults.
13712
13713 EOM
13714 fi
13715 if $test -f config.msg; then
13716     echo "Hmm.  I also noted the following information while running:"
13717     echo " "
13718     $cat config.msg >&4
13719     $rm -f config.msg
13720 fi
13721 $rm -f kit*isdone ark*isdone
13722 $rm -rf UU
13723
13724 : End of Configure
13725