2cc2bf4aa2523196f5862482b1a1c222e6fb2245
[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 Thu May 27 19:42:20 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_fchmod=''
342 d_fchown=''
343 d_fcntl=''
344 d_fd_macros=''
345 d_fd_set=''
346 d_fds_bits=''
347 d_fgetpos=''
348 d_flexfnam=''
349 d_flock=''
350 d_fork=''
351 d_fseeko=''
352 d_fsetpos=''
353 d_ftello=''
354 d_ftime=''
355 d_gettimeod=''
356 d_Gconvert=''
357 d_getgrent=''
358 d_getgrps=''
359 d_gethbyaddr=''
360 d_gethbyname=''
361 d_gethent=''
362 aphostname=''
363 d_gethname=''
364 d_phostname=''
365 d_uname=''
366 d_gethostprotos=''
367 d_getlogin=''
368 d_getmntent=''
369 d_getnbyaddr=''
370 d_getnbyname=''
371 d_getnent=''
372 d_getnetprotos=''
373 d_getpent=''
374 d_getpgid=''
375 d_getpgrp2=''
376 d_bsdgetpgrp=''
377 d_getpgrp=''
378 d_getppid=''
379 d_getprior=''
380 d_getpbyname=''
381 d_getpbynumber=''
382 d_getprotoprotos=''
383 d_getpwent=''
384 d_getsent=''
385 d_getservprotos=''
386 d_getsbyname=''
387 d_getsbyport=''
388 d_gnulibc=''
389 d_hasmntopt=''
390 d_htonl=''
391 d_inetaton=''
392 d_isascii=''
393 d_killpg=''
394 d_lchown=''
395 d_link=''
396 d_locconv=''
397 d_lockf=''
398 d_longdbl=''
399 longdblsize=''
400 d_longlong=''
401 longlongsize=''
402 d_lstat=''
403 d_madvise=''
404 d_mblen=''
405 d_mbstowcs=''
406 d_mbtowc=''
407 d_memchr=''
408 d_memcmp=''
409 d_memcpy=''
410 d_memmove=''
411 d_memset=''
412 d_mkdir=''
413 d_mkfifo=''
414 d_mktime=''
415 d_mmap=''
416 mmaptype=''
417 d_mprotect=''
418 d_msg=''
419 d_msgctl=''
420 d_msgget=''
421 d_msgrcv=''
422 d_msgsnd=''
423 d_msync=''
424 d_munmap=''
425 d_nice=''
426 d_open3=''
427 d_fpathconf=''
428 d_pathconf=''
429 d_pause=''
430 d_pipe=''
431 d_poll=''
432 d_portable=''
433 d_old_pthread_create_joinable=''
434 old_pthread_create_joinable=''
435 d_pthread_yield=''
436 d_sched_yield=''
437 sched_yield=''
438 d_readdir=''
439 d_rewinddir=''
440 d_seekdir=''
441 d_telldir=''
442 d_readlink=''
443 d_readv=''
444 d_rename=''
445 d_rmdir=''
446 d_safebcpy=''
447 d_safemcpy=''
448 d_sanemcmp=''
449 d_select=''
450 d_sem=''
451 d_semctl=''
452 d_semget=''
453 d_semop=''
454 d_setegid=''
455 d_seteuid=''
456 d_setgrent=''
457 d_setgrps=''
458 d_sethent=''
459 d_setlinebuf=''
460 d_setlocale=''
461 d_setnent=''
462 d_setpent=''
463 d_setpgid=''
464 d_setpgrp2=''
465 d_bsdsetpgrp=''
466 d_setpgrp=''
467 d_setprior=''
468 d_setpwent=''
469 d_setregid=''
470 d_setresgid=''
471 d_setresuid=''
472 d_setreuid=''
473 d_setrgid=''
474 d_setruid=''
475 d_setsent=''
476 d_setsid=''
477 d_setvbuf=''
478 d_sfio=''
479 usesfio=''
480 d_shm=''
481 d_shmat=''
482 d_shmatprototype=''
483 shmattype=''
484 d_shmctl=''
485 d_shmdt=''
486 d_shmget=''
487 d_sigaction=''
488 d_sigsetjmp=''
489 d_cmsghdr_s=''
490 d_msg_ctrunc=''
491 d_msg_dontroute=''
492 d_msg_oob=''
493 d_msg_peek=''
494 d_msg_proxy=''
495 d_msghdr_s=''
496 d_oldsock=''
497 d_recvmsg=''
498 d_scm_rights=''
499 d_sendmsg=''
500 d_socket=''
501 d_sockpair=''
502 sockethdr=''
503 socketlib=''
504 d_statblks=''
505 d_fstatfs=''
506 d_statfs=''
507 d_statfsflags=''
508 d_fstatvfs=''
509 d_statvfs=''
510 d_stdio_cnt_lval=''
511 d_stdio_ptr_lval=''
512 d_stdiobase=''
513 d_stdstdio=''
514 stdio_base=''
515 stdio_bufsiz=''
516 stdio_cnt=''
517 stdio_filbuf=''
518 stdio_ptr=''
519 d_index=''
520 d_strchr=''
521 d_strcoll=''
522 d_strctcpy=''
523 d_strerrm=''
524 d_strerror=''
525 d_sysernlst=''
526 d_syserrlst=''
527 d_strtod=''
528 d_strtol=''
529 d_strtoul=''
530 d_strxfrm=''
531 d_symlink=''
532 d_syscall=''
533 d_sysconf=''
534 d_system=''
535 d_tcgetpgrp=''
536 d_tcsetpgrp=''
537 d_telldirproto=''
538 d_time=''
539 timetype=''
540 clocktype=''
541 d_times=''
542 d_truncate=''
543 d_tzname=''
544 d_umask=''
545 d_semctl_semid_ds=''
546 d_semctl_semun=''
547 d_union_semun=''
548 d_vfork=''
549 usevfork=''
550 d_voidsig=''
551 signal_t=''
552 d_volatile=''
553 d_charvspr=''
554 d_vprintf=''
555 d_wait4=''
556 d_waitpid=''
557 d_wcstombs=''
558 d_wctomb=''
559 d_writev=''
560 d_dbmclose64=''
561 d_dbminit64=''
562 d_delete64=''
563 d_fetch64=''
564 d_firstkey64=''
565 d_nextkey64=''
566 d_store64=''
567 dlext=''
568 cccdlflags=''
569 ccdlflags=''
570 dlsrc=''
571 ld=''
572 lddlflags=''
573 usedl=''
574 doublesize=''
575 ebcdic=''
576 fflushNULL=''
577 fflushall=''
578 fpostype=''
579 gidtype=''
580 groupstype=''
581 h_fcntl=''
582 h_sysfile=''
583 i_arpainet=''
584 db_hashtype=''
585 db_prefixtype=''
586 i_db=''
587 i_dbm=''
588 i_rpcsvcdbm=''
589 d_dirnamlen=''
590 direntrytype=''
591 i_dirent=''
592 i_dld=''
593 i_dlfcn=''
594 i_fcntl=''
595 i_float=''
596 i_gdbm=''
597 d_grpasswd=''
598 i_grp=''
599 d_int64t=''
600 i_inttypes=''
601 i_limits=''
602 i_locale=''
603 i_machcthr=''
604 i_malloc=''
605 i_math=''
606 i_memory=''
607 i_mntent=''
608 i_ndbm=''
609 i_netdb=''
610 i_neterrno=''
611 i_netinettcp=''
612 i_niin=''
613 i_sysin=''
614 i_poll=''
615 i_pthread=''
616 d_pwage=''
617 d_pwchange=''
618 d_pwclass=''
619 d_pwcomment=''
620 d_pwexpire=''
621 d_pwgecos=''
622 d_pwpasswd=''
623 d_pwquota=''
624 i_pwd=''
625 i_sfio=''
626 i_stddef=''
627 i_stdlib=''
628 i_string=''
629 strings=''
630 i_sysaccess=''
631 i_sysdir=''
632 i_sysfile=''
633 d_voidtty=''
634 i_bsdioctl=''
635 i_sysfilio=''
636 i_sysioctl=''
637 i_syssockio=''
638 i_sysmman=''
639 i_sysmount=''
640 i_sysndir=''
641 i_sysparam=''
642 i_sysresrc=''
643 i_syssecrt=''
644 i_sysselct=''
645 i_sysstat=''
646 i_sysstatvfs=''
647 i_systimes=''
648 i_systypes=''
649 d_iovec_s=''
650 i_sysuio=''
651 i_sysun=''
652 i_syswait=''
653 i_sgtty=''
654 i_termio=''
655 i_termios=''
656 i_systime=''
657 i_systimek=''
658 i_time=''
659 timeincl=''
660 i_unistd=''
661 i_utime=''
662 i_values=''
663 i_stdarg=''
664 i_varargs=''
665 i_varhdr=''
666 i_vfork=''
667 installusrbinperl=''
668 intsize=''
669 longsize=''
670 shortsize=''
671 d_dirent64_s=''
672 d_flock64_s=''
673 d_fstat64=''
674 d_ftruncate64=''
675 d_ino64_t=''
676 d_llseek=''
677 d_lockf64=''
678 d_lseek64=''
679 d_lstat64=''
680 d_off64_t=''
681 d_offset_t=''
682 d_open64=''
683 d_opendir64=''
684 d_readdir64=''
685 d_seekdir64=''
686 d_stat64=''
687 d_telldir64=''
688 d_truncate64=''
689 libc=''
690 libperl=''
691 shrpenv=''
692 useshrplib=''
693 glibpth=''
694 libpth=''
695 loclibpth=''
696 plibpth=''
697 xlibpth=''
698 ignore_versioned_solibs=''
699 libs=''
700 lns=''
701 lseeksize=''
702 lseektype=''
703 make_set_make=''
704 d_mymalloc=''
705 freetype=''
706 mallocobj=''
707 mallocsrc=''
708 malloctype=''
709 usemymalloc=''
710 installman1dir=''
711 man1dir=''
712 man1direxp=''
713 man1ext=''
714 installman3dir=''
715 man3dir=''
716 man3direxp=''
717 man3ext=''
718 huge=''
719 large=''
720 medium=''
721 models=''
722 small=''
723 split=''
724 modetype=''
725 multiarch=''
726 mydomain=''
727 myhostname=''
728 phostname=''
729 c=''
730 n=''
731 d_eofnblk=''
732 eagain=''
733 o_nonblock=''
734 rd_nodata=''
735 netdb_hlen_type=''
736 netdb_host_type=''
737 netdb_name_type=''
738 netdb_net_type=''
739 groupcat=''
740 hostcat=''
741 passcat=''
742 orderlib=''
743 ranlib=''
744 package=''
745 spackage=''
746 pager=''
747 apiversion=''
748 patchlevel=''
749 subversion=''
750 version=''
751 perladmin=''
752 perlpath=''
753 pidtype=''
754 prefix=''
755 prefixexp=''
756 installprivlib=''
757 privlib=''
758 privlibexp=''
759 prototype=''
760 ptrsize=''
761 drand01=''
762 randbits=''
763 randfunc=''
764 randseedtype=''
765 seedfunc=''
766 installscript=''
767 scriptdir=''
768 scriptdirexp=''
769 selectminbits=''
770 selecttype=''
771 sh=''
772 sig_count=''
773 sig_name=''
774 sig_name_init=''
775 sig_num=''
776 sig_num_init=''
777 installsitearch=''
778 sitearch=''
779 sitearchexp=''
780 installsitelib=''
781 sitelib=''
782 sitelibexp=''
783 sizetype=''
784 so=''
785 sharpbang=''
786 shsharp=''
787 spitshell=''
788 src=''
789 ssizetype=''
790 startperl=''
791 startsh=''
792 stdchar=''
793 d_fgetpos64=''
794 d_fopen64=''
795 d_freopen64=''
796 d_fseek64=''
797 d_fseeko64=''
798 d_fsetpos64=''
799 d_ftell64=''
800 d_ftello64=''
801 d_tmpfile64=''
802 d_stdio_stream_array=''
803 stdio_stream_array=''
804 sysman=''
805 trnl=''
806 uidtype=''
807 archname64=''
808 use64bits=''
809 usemultiplicity=''
810 nm_opt=''
811 nm_so_opt=''
812 runnm=''
813 usenm=''
814 useperlio=''
815 d_oldpthreads=''
816 usethreads=''
817 incpath=''
818 mips=''
819 mips_type=''
820 usrinc=''
821 defvoidused=''
822 voidflags=''
823 CONFIG=''
824
825 define='define'
826 undef='undef'
827 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
828 rmlist=''
829
830 : We must find out about Eunice early
831 eunicefix=':'
832 if test -f /etc/unixtovms; then
833         eunicefix=/etc/unixtovms
834 fi
835 if test -f /etc/unixtovms.exe; then
836         eunicefix=/etc/unixtovms.exe
837 fi
838
839 i_whoami=''
840 : Possible local include directories to search.
841 : Set locincpth to "" in a hint file to defeat local include searches.
842 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
843 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
844 :
845 : no include file wanted by default
846 inclwanted=''
847
848 : list of known cpp symbols, sorted alphabetically
849 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
850 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
851 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
852 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
853 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
854 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
855 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
856 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
857 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
858 al="$al VMS Xenix286"
859 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
860 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
861 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
862 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
863 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
864 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
865 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
866 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
867 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
868 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
869 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
870 al="$al __SVR4_2__ __UMAXV__"
871 al="$al ____386BSD____ __alpha __alpha__ __amiga"
872 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
873 al="$al __host_mips__"
874 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
875 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
876 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
877 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
878 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
879 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
880 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
881 al="$al __mc88100 __mc88100__ __mips __mips__"
882 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
883 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
884 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
885 al="$al _host_mips _mips _unix"
886 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
887 al="$al apollo ardent att386 att3b"
888 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
889 al="$al cadmus clipper concurrent convex cray ctix"
890 al="$al dmert encore gcos gcx gimpel gould"
891 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
892 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
893 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
894 al="$al i186 i286 i386 i486 i8086"
895 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
896 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
897 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
898 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
899 al="$al mc88000 mc88100 merlin mert mips mvs n16"
900 al="$al ncl_el ncl_mr"
901 al="$al news1500 news1700 news1800 news1900 news3700"
902 al="$al news700 news800 news900 ns16000 ns32000"
903 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
904 al="$al parisc pc532 pdp11 plexus posix pyr"
905 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
906 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
907 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
908 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
909 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
910 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
911 al="$al xenix z8000"
912
913 : Trailing extension.  Override this in a hint file, if needed.
914 _exe=''
915 : Extra object files, if any, needed on this platform.
916 archobjs=''
917 groupstype=''
918 : change the next line if compiling for Xenix/286 on Xenix/386
919 xlibpth='/usr/lib/386 /lib/386'
920
921 : Possible local library directories to search.
922 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
923 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
924
925 : general looking path for locating libraries
926 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
927 glibpth="$glibpth /lib /usr/lib $xlibpth"
928 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
929 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
930
931 : Private path used by Configure to find libraries.  Its value
932 : is prepended to libpth. This variable takes care of special
933 : machines, like the mips.  Usually, it should be empty.
934 plibpth=''
935
936 : default library list
937 libswanted=''
938 : some systems want to use only the non-versioned libso:s
939 ignore_versioned_solibs=''
940 : full support for void wanted by default
941 defvoidused=15
942
943 : set useposix=false in your hint file to disable the POSIX extension.
944 useposix=true
945 : set useopcode=false in your hint file to disable the Opcode extension.
946 useopcode=true
947 : set usemultiplicity on the Configure command line to enable multiplicity.
948 : set usethreads on the Configure command line to enable threads.
949 : List of libraries we want.
950 : If anyone needs -lnet, put it in a hint file.
951 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
952 libswanted="$libswanted dld ld sun m rt c cposix posix"
953 libswanted="$libswanted ndir dir crypt"
954 libswanted="$libswanted ucb bsd BSD PW x"
955 : We probably want to search /usr/shlib before most other libraries.
956 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
957 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
958 glibpth="/usr/shlib $glibpth"
959 : Do not use vfork unless overridden by a hint file.
960 usevfork=false
961
962 : Find the basic shell for Bourne shell scripts
963 case "$sh" in
964 '')
965         case "$SYSTYPE" in
966         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
967         *) xxx='/bin/sh';;
968         esac
969         if test -f "$xxx"; then
970                 sh="$xxx"
971         else
972                 : Build up a list and do a single loop so we can 'break' out.
973                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
974                 for xxx in sh bash ksh pdksh ash; do
975                         for p in $pth; do
976                                 try="$try ${p}/${xxx}"
977                         done
978                 done
979                 for xxx in $try; do
980                         if test -f "$xxx"; then
981                                 sh="$xxx";
982                                 break
983                         elif test -f "$xxx.exe"; then
984                                 sh="$xxx";
985                                 break
986                         fi
987                 done
988         fi
989         ;;
990 esac
991
992 case "$sh" in
993 '')     cat <<EOM >&2
994 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
995
996 Usually it's in /bin/sh.  How did you even get this far?
997 Please contact me (Perl Maintainers) at perlbug@perl.com and 
998 we'll try to straighten this all out.
999 EOM
1000         exit 1
1001         ;;
1002 esac
1003
1004 : see if sh knows # comments
1005 if `$sh -c '#' >/dev/null 2>&1`; then
1006         shsharp=true
1007         spitshell=cat
1008         xcat=/bin/cat
1009         test -f $xcat || xcat=/usr/bin/cat
1010         echo "#!$xcat" >try
1011         $eunicefix try
1012         chmod +x try
1013         ./try > today
1014         if test -s today; then
1015                 sharpbang='#!'
1016         else
1017                 echo "#! $xcat" > try
1018                 $eunicefix try
1019                 chmod +x try
1020                 ./try > today
1021                 if test -s today; then
1022                         sharpbang='#! '
1023                 else
1024                         sharpbang=': use '
1025                 fi
1026         fi
1027 else
1028         echo " "
1029         echo "Your $sh doesn't grok # comments--I will strip them later on."
1030         shsharp=false
1031         cd ..
1032         echo "exec grep -v '^[  ]*#'" >spitshell
1033         chmod +x spitshell
1034         $eunicefix spitshell
1035         spitshell=`pwd`/spitshell
1036         cd UU
1037         echo "I presume that if # doesn't work, #! won't work either!"
1038         sharpbang=': use '
1039 fi
1040 rm -f try today
1041
1042 : figure out how to guarantee sh startup
1043 case "$startsh" in
1044 '') startsh=${sharpbang}${sh} ;;
1045 *)
1046 esac
1047 cat >try <<EOSS
1048 $startsh
1049 set abc
1050 test "$?abc" != 1
1051 EOSS
1052
1053 chmod +x try
1054 $eunicefix try
1055 if ./try; then
1056         : echo "Yup, it does."
1057 else
1058         echo "Hmm... '$startsh' does not guarantee sh startup..."
1059         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1060 fi
1061 rm -f try
1062
1063
1064 : Save command line options in file UU/cmdline.opt for later use in
1065 : generating config.sh.
1066 cat > cmdline.opt <<EOSH
1067 # Configure command line arguments.
1068 config_arg0='$0'
1069 config_args='$*'
1070 config_argc=$#
1071 EOSH
1072 argn=1
1073 for arg in "$@"; do
1074         cat >>cmdline.opt <<EOSH
1075 config_arg$argn='$arg'
1076 EOSH
1077         argn=`expr $argn + 1`
1078 done
1079
1080 : produce awk script to parse command line options
1081 cat >options.awk <<'EOF'
1082 BEGIN {
1083         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1084
1085         len = length(optstr);
1086         for (i = 1; i <= len; i++) {
1087                 c = substr(optstr, i, 1);
1088                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1089                 if (a == ":") {
1090                         arg[c] = 1;
1091                         i++;
1092                 }
1093                 opt[c] = 1;
1094         }
1095 }
1096 {
1097         expect = 0;
1098         str = $0;
1099         if (substr(str, 1, 1) != "-") {
1100                 printf("'%s'\n", str);
1101                 next;
1102         }
1103         len = length($0);
1104         for (i = 2; i <= len; i++) {
1105                 c = substr(str, i, 1);
1106                 if (!opt[c]) {
1107                         printf("-%s\n", substr(str, i));
1108                         next;
1109                 }
1110                 printf("-%s\n", c);
1111                 if (arg[c]) {
1112                         if (i < len)
1113                                 printf("'%s'\n", substr(str, i + 1));
1114                         else
1115                                 expect = 1;
1116                         next;
1117                 }
1118         }
1119 }
1120 END {
1121         if (expect)
1122                 print "?";
1123 }
1124 EOF
1125
1126 : process the command line options
1127 set X `for arg in "$@"; do echo "X$arg"; done |
1128         sed -e s/X// | awk -f options.awk`
1129 eval "set $*"
1130 shift
1131 rm -f options.awk
1132
1133 : set up default values
1134 fastread=''
1135 reuseval=false
1136 config_sh=''
1137 alldone=''
1138 error=''
1139 silent=''
1140 extractsh=''
1141 override=''
1142 knowitall=''
1143 rm -f optdef.sh
1144 cat >optdef.sh <<EOS
1145 $startsh
1146 EOS
1147
1148
1149 : option parsing
1150 while test $# -gt 0; do
1151         case "$1" in
1152         -d) shift; fastread=yes;;
1153         -e) shift; alldone=cont;;
1154         -f)
1155                 shift
1156                 cd ..
1157                 if test -r "$1"; then
1158                         config_sh="$1"
1159                 else
1160                         echo "$me: cannot read config file $1." >&2
1161                         error=true
1162                 fi
1163                 cd UU
1164                 shift;;
1165         -h) shift; error=true;;
1166         -r) shift; reuseval=true;;
1167         -s) shift; silent=true; realsilent=true;;
1168         -E) shift; alldone=exit;;
1169         -K) shift; knowitall=true;;
1170         -O) shift; override=true;;
1171         -S) shift; silent=true; extractsh=true;;
1172         -D)
1173                 shift
1174                 case "$1" in
1175                 *=)
1176                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1177                         echo "$me: ignoring -D $1" >&2
1178                         ;;
1179                 *=*) echo "$1" | \
1180                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1181                 *) echo "$1='define'" >> optdef.sh;;
1182                 esac
1183                 shift
1184                 ;;
1185         -U)
1186                 shift
1187                 case "$1" in
1188                 *=) echo "$1" >> optdef.sh;;
1189                 *=*)
1190                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1191                         echo "$me: ignoring -U $1" >&2
1192                         ;;
1193                 *) echo "$1='undef'" >> optdef.sh;;
1194                 esac
1195                 shift
1196                 ;;
1197         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1198                 exit 0;;
1199         --) break;;
1200         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1201         *) break;;
1202         esac
1203 done
1204
1205 case "$error" in
1206 true)
1207         cat >&2 <<EOM
1208 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1209                  [-U symbol] [-U symbol=]
1210   -d : use defaults for all answers.
1211   -e : go on without questioning past the production of config.sh.
1212   -f : specify an alternate default configuration file.
1213   -h : print this help message and exit (with an error status).
1214   -r : reuse C symbols value if possible (skips costly nm extraction).
1215   -s : silent mode, only echoes questions and essential information.
1216   -D : define symbol to have some value:
1217          -D symbol         symbol gets the value 'define'
1218          -D symbol=value   symbol gets the value 'value'
1219   -E : stop at the end of questions, after having produced config.sh.
1220   -K : do not use unless you know what you are doing.
1221   -O : let -D and -U override definitions from loaded configuration file.
1222   -S : perform variable substitutions on all .SH files (can mix with -f)
1223   -U : undefine symbol:
1224          -U symbol    symbol gets the value 'undef'
1225          -U symbol=   symbol gets completely empty
1226   -V : print version number and exit (with a zero status).
1227 EOM
1228         exit 1
1229         ;;
1230 esac
1231
1232 : Sanity checks
1233 case "$fastread$alldone" in
1234 yescont|yesexit) ;;
1235 *)
1236         if test ! -t 0; then
1237                 echo "Say 'sh Configure', not 'sh <Configure'"
1238                 exit 1
1239         fi
1240         ;;
1241 esac
1242
1243 exec 4>&1
1244 case "$silent" in
1245 true) exec 1>/dev/null;;
1246 esac
1247
1248 : run the defines and the undefines, if any, but leave the file out there...
1249 touch optdef.sh
1250 . ./optdef.sh
1251
1252 : set package name
1253 package=perl5
1254 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1255 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1256 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1257 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1258 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1259 esac
1260
1261 : Some greps do not return status, grrr.
1262 echo "grimblepritz" >grimble
1263 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1264         contains=contains
1265 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1266         contains=grep
1267 else
1268         contains=contains
1269 fi
1270 rm -f grimble
1271 : the following should work in any shell
1272 case "$contains" in
1273 contains*)
1274         echo " "
1275         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1276         cat >contains <<'EOSS'
1277 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1278 EOSS
1279 chmod +x contains
1280 esac
1281
1282 : Find the path to the source tree
1283 case "$src" in
1284 '') case "$0" in
1285     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1286     *)   src='.';;
1287     esac;;
1288 esac
1289 case "$src" in
1290 '')     src=/
1291         rsrc=/
1292         ;;
1293 /*) rsrc="$src";;
1294 *) rsrc="../$src";;
1295 esac
1296 if test -f $rsrc/Configure && \
1297         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1298 then
1299    : found it, so we are ok.
1300 else
1301         rsrc=''
1302         for src in . .. ../.. ../../.. ../../../..; do
1303                 if test -f ../$src/Configure && \
1304                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1305                 then
1306                         rsrc=../$src
1307                         break
1308                 fi
1309         done
1310 fi
1311 case "$rsrc" in
1312 '')
1313         cat <<EOM >&4
1314
1315 Sorry, I can't seem to locate the source dir for $package.  Please start
1316 Configure with an explicit path -- i.e. /some/path/Configure.
1317
1318 EOM
1319         exit 1
1320         ;;
1321 ../.)   rsrc='..';;
1322 *)
1323         echo " "
1324         echo "Sources for $package found in \"$src\"." >&4
1325         ;;
1326 esac
1327
1328 : script used to extract .SH files with variable substitutions
1329 cat >extract <<'EOS'
1330 CONFIGDOTSH=true
1331 echo "Doing variable substitutions on .SH files..."
1332 if test -f $src/MANIFEST; then
1333         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1334 else
1335         echo "(Looking for .SH files under the source directory.)"
1336         set x `(cd $src; find . -name "*.SH" -print)`
1337 fi
1338 shift
1339 case $# in
1340 0) set x `(cd $src; echo *.SH)`; shift;;
1341 esac
1342 if test ! -f $src/$1; then
1343         shift
1344 fi
1345 mkdir_p='
1346 name=$1;
1347 create="";
1348 while test $name; do
1349         if test ! -d "$name"; then
1350                 create="$name $create";
1351                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1352                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1353         else
1354                 name="";
1355         fi;
1356 done;
1357 for file in $create; do
1358         mkdir $file;
1359 done
1360 '
1361 for file in $*; do
1362         case "$src" in
1363         ".")
1364                 case "$file" in
1365                 */*)
1366                         dir=`expr X$file : 'X\(.*\)/'`
1367                         file=`expr X$file : 'X.*/\(.*\)'`
1368                         (cd $dir && . ./$file)
1369                         ;;
1370                 *)
1371                         . ./$file
1372                         ;;
1373                 esac
1374                 ;;
1375         *)
1376                 case "$file" in
1377                 */*)
1378                         dir=`expr X$file : 'X\(.*\)/'`
1379                         file=`expr X$file : 'X.*/\(.*\)'`
1380                         (set x $dir; shift; eval $mkdir_p)
1381                         sh <$src/$dir/$file
1382                         ;;
1383                 *)
1384                         sh <$src/$file
1385                         ;;
1386                 esac
1387                 ;;
1388         esac
1389 done
1390 if test -f $src/config_h.SH; then
1391         if test ! -f config.h; then
1392         : oops, they left it out of MANIFEST, probably, so do it anyway.
1393         . $src/config_h.SH
1394         fi
1395 fi
1396 EOS
1397
1398 : extract files and exit if asked to do so
1399 case "$extractsh" in
1400 true)
1401         case "$realsilent" in
1402         true) ;;
1403         *) exec 1>&4;;
1404         esac
1405         case "$config_sh" in
1406         '') config_sh='config.sh';;
1407         esac
1408         echo " "
1409         echo "Fetching answers from $config_sh..."
1410         cd ..
1411         . $config_sh
1412         test "$override" && . ./optdef.sh
1413         echo " "
1414         . UU/extract
1415         rm -rf UU
1416         echo "Done."
1417         exit 0
1418         ;;
1419 esac
1420
1421 : Eunice requires " " instead of "", can you believe it
1422 echo " "
1423 : Here we go...
1424 echo "Beginning of configuration questions for $package."
1425
1426 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1427
1428 : first determine how to suppress newline on echo command
1429 echo " "
1430 echo "Checking echo to see how to suppress newlines..."
1431 (echo "hi there\c" ; echo " ") >.echotmp
1432 if $contains c .echotmp >/dev/null 2>&1 ; then
1433         echo "...using -n."
1434         n='-n'
1435         c=''
1436 else
1437         cat <<'EOM'
1438 ...using \c
1439 EOM
1440         n=''
1441         c='\c'
1442 fi
1443 echo $n "The star should be here-->$c"
1444 echo '*'
1445 rm -f .echotmp
1446
1447 : Now test for existence of everything in MANIFEST
1448 echo " "
1449 if test -f $rsrc/MANIFEST; then
1450         echo "First let's make sure your kit is complete.  Checking..." >&4
1451         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1452         rm -f missing
1453         tmppwd=`pwd`
1454         for filelist in x??; do
1455                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1456         done
1457         if test -s missing; then
1458                 cat missing >&4
1459                 cat >&4 <<'EOM'
1460
1461 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1462
1463 You have the option of continuing the configuration process, despite the
1464 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1465 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1466 and contact the author (perlbug@perl.com).
1467
1468 EOM
1469                 echo $n "Continue? [n] $c" >&4
1470                 read ans
1471                 case "$ans" in
1472                 y*)
1473                         echo "Continuing..." >&4
1474                         rm -f missing
1475                         ;;
1476                 *)
1477                         echo "ABORTING..." >&4
1478                         kill $$
1479                         ;;
1480                 esac
1481         else
1482                 echo "Looks good..."
1483         fi
1484 else
1485         echo "There is no MANIFEST file.  I hope your kit is complete !"
1486 fi
1487 rm -f missing x??
1488
1489 echo " "
1490 : Find the appropriate value for a newline for tr
1491 if test -n "$DJGPP"; then
1492        trnl='\012'
1493 fi
1494 if test X"$trnl" = X; then
1495         case "`echo foo|tr '\n' x 2>/dev/null`" in
1496         foox) trnl='\n' ;;
1497         esac
1498 fi
1499 if test X"$trnl" = X; then
1500         case "`echo foo|tr '\012' x 2>/dev/null`" in
1501         foox) trnl='\012' ;;
1502         esac
1503 fi
1504 if test X"$trnl" = X; then
1505         cat <<EOM >&2
1506
1507 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1508
1509 EOM
1510         exit 1
1511 fi
1512
1513 : compute the number of columns on the terminal for proper question formatting
1514 case "$COLUMNS" in
1515 '') COLUMNS='80';;
1516 esac
1517
1518 : set up the echo used in my read
1519 myecho="case \"\$xxxm\" in
1520 '') echo $n \"\$rp $c\" >&4;;
1521 *) case \"\$rp\" in
1522         '') echo $n \"[\$xxxm] $c\";;
1523         *)
1524                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1525                         echo \"\$rp\" >&4
1526                         echo $n \"[\$xxxm] $c\" >&4
1527                 else
1528                         echo $n \"\$rp [\$xxxm] $c\" >&4
1529                 fi
1530                 ;;
1531         esac;;
1532 esac"
1533
1534 : now set up to do reads with possible shell escape and default assignment
1535 cat <<EOSC >myread
1536 $startsh
1537 xxxm=\$dflt
1538 $myecho
1539 ans='!'
1540 case "\$fastread" in
1541 yes) case "\$dflt" in
1542         '') ;;
1543         *) ans='';
1544                 case "\$silent-\$rp" in
1545                 true-) ;;
1546                 *) echo " " >&4;;
1547                 esac;;
1548         esac;;
1549 *) case "\$silent" in
1550         true) case "\$rp" in
1551                 '') ans='';;
1552                 esac;;
1553         esac;;
1554 esac
1555 while expr "X\$ans" : "X!" >/dev/null; do
1556         read answ
1557         set x \$xxxm
1558         shift
1559         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1560         case  "\$answ" in
1561         "!")
1562                 sh 1>&4
1563                 echo " "
1564                 $myecho
1565                 ;;
1566         !*)
1567                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1568                 shift
1569                 sh 1>&4 -c "\$*"
1570                 echo " "
1571                 $myecho
1572                 ;;
1573         "\$ans")
1574                 case "\$ans" in
1575                 \\&*)
1576                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1577                         shift
1578                         case "\$1" in
1579                         -d)
1580                                 fastread=yes
1581                                 echo "(OK, I'll run with -d after this question.)" >&4
1582                                 ;;
1583                         -*)
1584                                 echo "*** Sorry, \$1 not supported yet." >&4
1585                                 ;;
1586                         esac
1587                         $myecho
1588                         ans=!
1589                         ;;
1590                 esac;;
1591         *)
1592                 case "\$aok" in
1593                 y)
1594                         echo "*** Substitution done -- please confirm."
1595                         xxxm="\$ans"
1596                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1597                         xxxm="\$ans"
1598                         ans=!
1599                         ;;
1600                 *)
1601                         echo "*** Error -- try again."
1602                         ans=!
1603                         ;;
1604                 esac
1605                 $myecho
1606                 ;;
1607         esac
1608         case "\$ans\$xxxm\$nostick" in
1609         '')
1610                 ans=!
1611                 $myecho
1612                 ;;
1613         esac
1614 done
1615 case "\$ans" in
1616 '') ans="\$xxxm";;
1617 esac
1618 EOSC
1619
1620 : create .config dir to save info across Configure sessions
1621 test -d ../.config || mkdir ../.config
1622 cat >../.config/README <<EOF
1623 This directory created by Configure to save information that should
1624 persist across sessions for $package.
1625
1626 You may safely delete it if you wish.
1627 EOF
1628
1629 : general instructions
1630 needman=true
1631 firsttime=true
1632 user=`(logname) 2>/dev/null`
1633 case "$user" in
1634 '') user=`whoami 2>&1`;;
1635 esac
1636 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1637         firsttime=false
1638         echo " "
1639         rp='Would you like to see the instructions?'
1640         dflt=n
1641         . ./myread
1642         case "$ans" in
1643         [yY]*) ;;
1644         *) needman=false;;
1645         esac
1646 fi
1647 if $needman; then
1648         cat <<EOH
1649
1650 This installation shell script will examine your system and ask you questions
1651 to determine how the perl5 package should be installed. If you get
1652 stuck on a question, you may use a ! shell escape to start a subshell or
1653 execute a command.  Many of the questions will have default answers in square
1654 brackets; typing carriage return will give you the default.
1655
1656 On some of the questions which ask for file or directory names you are allowed
1657 to use the ~name construct to specify the login directory belonging to "name",
1658 even if you don't have a shell which knows about that.  Questions where this is
1659 allowed will be marked "(~name ok)".
1660
1661 EOH
1662         rp=''
1663         dflt='Type carriage return to continue'
1664         . ./myread
1665         cat <<'EOH'
1666
1667 The prompter used in this script allows you to use shell variables and
1668 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1669 in the default answer, as if the default line was a set of arguments given to a
1670 script shell.  This means you may also use $* to repeat the whole default line,
1671 so you do not have to re-type everything to add something to the default.
1672
1673 Everytime there is a substitution, you will have to confirm.  If there is an
1674 error (e.g. an unmatched backtick), the default answer will remain unchanged
1675 and you will be prompted again.
1676
1677 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1678 the questions and use the computed defaults (or the previous answers if there
1679 was already a config.sh file). Type 'Configure -h' for a list of options.
1680 You may also start interactively and then answer '& -d' at any prompt to turn
1681 on the non-interactive behaviour for the remainder of the execution.
1682
1683 EOH
1684         . ./myread
1685         cat <<EOH
1686
1687 Much effort has been expended to ensure that this shell script will run on any
1688 Unix system.  If despite that it blows up on yours, your best bet is to edit
1689 Configure and run it again.  If you can't run Configure for some reason,
1690 you'll have to generate a config.sh file by hand.  Whatever problems you
1691 have, let me (perlbug@perl.com) know how I blew it.
1692
1693 This installation script affects things in two ways:
1694
1695 1) it may do direct variable substitutions on some of the files included
1696    in this kit.
1697 2) it builds a config.h file for inclusion in C programs.  You may edit
1698    any of these files as the need arises after running this script.
1699
1700 If you make a mistake on a question, there is no easy way to back up to it
1701 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1702 files.  Configure will offer to let you do this before it runs the SH files.
1703
1704 EOH
1705         dflt='Type carriage return to continue'
1706         . ./myread
1707         case "$firsttime" in
1708         true) echo $user >>../.config/instruct;;
1709         esac
1710 fi
1711
1712 : find out where common programs are
1713 echo " "
1714 echo "Locating common programs..." >&4
1715 cat <<EOSC >loc
1716 $startsh
1717 case \$# in
1718 0) exit 1;;
1719 esac
1720 thing=\$1
1721 shift
1722 dflt=\$1
1723 shift
1724 for dir in \$*; do
1725         case "\$thing" in
1726         .)
1727         if test -d \$dir/\$thing; then
1728                 echo \$dir
1729                 exit 0
1730         fi
1731         ;;
1732         *)
1733         for thisthing in \$dir/\$thing; do
1734                 : just loop through to pick last item
1735         done
1736         if test -f \$thisthing; then
1737                 echo \$thisthing
1738                 exit 0
1739         elif test -f \$dir/\$thing.exe; then
1740                 if test -n "$DJGPP"; then
1741                         echo \$dir/\$thing.exe
1742                 else
1743                         : on Eunice apparently
1744                         echo \$dir/\$thing
1745                 fi
1746                 exit 0
1747         fi
1748         ;;
1749         esac
1750 done
1751 echo \$dflt
1752 exit 1
1753 EOSC
1754 chmod +x loc
1755 $eunicefix loc
1756 loclist="
1757 awk
1758 cat
1759 comm
1760 cp
1761 echo
1762 expr
1763 grep
1764 ls
1765 make
1766 mkdir
1767 rm
1768 sed
1769 sort
1770 touch
1771 tr
1772 uniq
1773 "
1774 trylist="
1775 Mcc
1776 ar
1777 byacc
1778 cpp
1779 csh
1780 date
1781 egrep
1782 gzip
1783 less
1784 ln
1785 more
1786 nm
1787 nroff
1788 pg
1789 test
1790 uname
1791 zip
1792 "
1793 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1794 pth="$pth /lib /usr/lib"
1795 for file in $loclist; do
1796         eval xxx=\$$file
1797         case "$xxx" in
1798         /*|?:[\\/]*)
1799                 if test -f "$xxx"; then
1800                         : ok
1801                 else
1802                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1803                         xxx=`./loc $file $file $pth`
1804                 fi
1805                 ;;
1806         '') xxx=`./loc $file $file $pth`;;
1807         *) xxx=`./loc $xxx $xxx $pth`;;
1808         esac
1809         eval $file=$xxx
1810         eval _$file=$xxx
1811         case "$xxx" in
1812         /*)
1813                 echo $file is in $xxx.
1814                 ;;
1815         ?:[\\/]*)
1816                 echo $file is in $xxx.
1817                 ;;
1818         *)
1819                 echo "I don't know where '$file' is, and my life depends on it." >&4
1820                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1821                 exit 1
1822                 ;;
1823         esac
1824 done
1825 echo " "
1826 echo "Don't worry if any of the following aren't found..."
1827 say=offhand
1828 for file in $trylist; do
1829         eval xxx=\$$file
1830         case "$xxx" in
1831         /*|?:[\\/]*)
1832                 if test -f "$xxx"; then
1833                         : ok
1834                 else
1835                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1836                         xxx=`./loc $file $file $pth`
1837                 fi
1838                 ;;
1839         '') xxx=`./loc $file $file $pth`;;
1840         *) xxx=`./loc $xxx $xxx $pth`;;
1841         esac
1842         eval $file=$xxx
1843         eval _$file=$xxx
1844         case "$xxx" in
1845         /*)
1846                 echo $file is in $xxx.
1847                 ;;
1848         ?:[\\/]*)
1849                 echo $file is in $xxx.
1850                 ;;
1851         *)
1852                 echo "I don't see $file out there, $say."
1853                 say=either
1854                 ;;
1855         esac
1856 done
1857 case "$egrep" in
1858 egrep)
1859         echo "Substituting grep for egrep."
1860         egrep=$grep
1861         ;;
1862 esac
1863 case "$ln" in
1864 ln)
1865         echo "Substituting cp for ln."
1866         ln=$cp
1867         ;;
1868 esac
1869 case "$test" in
1870 test)
1871         echo "Hopefully test is built into your sh."
1872         ;;
1873 *)
1874         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1875                 echo "Using the test built into your sh."
1876                 test=test
1877                 _test=test
1878         fi
1879         ;;
1880 esac
1881 case "$echo" in
1882 echo)
1883         echo "Hopefully echo is built into your sh."
1884         ;;
1885 '') ;;
1886 *)
1887         echo " "
1888 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1889         $echo $n "hi there$c" >foo1
1890         echo $n "hi there$c" >foo2
1891         if cmp foo1 foo2 >/dev/null 2>&1; then
1892                 echo "They are compatible.  In fact, they may be identical."
1893         else
1894                 case "$n" in
1895                 '-n') n='' c='\c';;
1896                 *) n='-n' c='';;
1897                 esac
1898                 cat <<FOO
1899 They are not compatible!  You are probably running ksh on a non-USG system.
1900 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1901 have echo built in and we may have to run some Bourne shell scripts.  That
1902 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1903
1904 FOO
1905                 $echo $n "The star should be here-->$c"
1906                 $echo "*"
1907         fi
1908         $rm -f foo1 foo2
1909         ;;
1910 esac
1911
1912 : determine whether symbolic links are supported
1913 echo " "
1914 $touch blurfl
1915 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1916         echo "Symbolic links are supported." >&4
1917         lns="$ln -s"
1918 else
1919         echo "Symbolic links are NOT supported." >&4
1920         lns="$ln"
1921 fi
1922 $rm -f blurfl sym
1923
1924 : see whether [:lower:] and [:upper:] are supported character classes
1925 echo " "
1926 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1927 ABYZ)
1928         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1929         up='[:upper:]'
1930         low='[:lower:]'
1931         ;;
1932 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1933         # (0xc9 and 0xd1), therefore that is a nice testing point.
1934         if test "X$up" = X -o "X$low" = X; then
1935             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1936             ij) up='[A-Z]'
1937                 low='[a-z]'
1938                 ;;
1939             esac
1940         fi
1941         if test "X$up" = X -o "X$low" = X; then
1942             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1943             ij) up='A-Z'
1944                 low='a-z'
1945                 ;;
1946             esac
1947         fi
1948         if test "X$up" = X -o "X$low" = X; then
1949             case "`echo IJ | od -x 2>/dev/null`" in
1950             *C9D1*|*c9d1*)
1951                 echo "Hey, this might be EBCDIC." >&4
1952                 if test "X$up" = X -o "X$low" = X; then
1953                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1954                     ij) up='[A-IJ-RS-Z]'
1955                         low='[a-ij-rs-z]'
1956                         ;;
1957                     esac
1958                 fi
1959                 if test "X$up" = X -o "X$low" = X; then
1960                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1961                     ij) up='A-IJ-RS-Z'
1962                         low='a-ij-rs-z'
1963                         ;;
1964                     esac
1965                 fi
1966                 ;;
1967             esac
1968         fi
1969 esac
1970 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1971 ij)
1972     echo "Using $up and $low to convert case." >&4
1973     ;;
1974 *)
1975     echo "I don't know how to translate letters from upper to lower case." >&4
1976     echo "Your tr is not acting any way I know of." >&4
1977     exit 1
1978     ;;
1979 esac
1980 : set up the translation script tr, must be called with ./tr of course
1981 cat >tr <<EOSC
1982 $startsh
1983 case "\$1\$2" in
1984 '[A-Z][a-z]') exec $tr '$up' '$low';;
1985 '[a-z][A-Z]') exec $tr '$low' '$up';;
1986 esac
1987 exec $tr "\$@"
1988 EOSC
1989 chmod +x tr
1990 $eunicefix tr
1991
1992 : Try to determine whether config.sh was made on this system
1993 case "$config_sh" in
1994 '')
1995 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1996 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
1997 # because the A-Z/a-z are not consecutive.
1998 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
1999         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
2000 newmyuname="$myuname"
2001 dflt=n
2002 case "$knowitall" in
2003 '')
2004         if test -f ../config.sh; then
2005                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
2006                         eval "`grep myuname= ../config.sh`"
2007                 fi
2008                 if test "X$myuname" = "X$newmyuname"; then
2009                         dflt=y
2010                 fi
2011         fi
2012         ;;
2013 *) dflt=y;;
2014 esac
2015
2016 : Get old answers from old config file if Configure was run on the
2017 : same system, otherwise use the hints.
2018 hint=default
2019 cd ..
2020 if test -f config.sh; then
2021         echo " "
2022         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2023         . UU/myread
2024         case "$ans" in
2025         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2026         *)  echo "Fetching default answers from your old config.sh file..." >&4
2027                 tmp_n="$n"
2028                 tmp_c="$c"
2029                 tmp_sh="$sh"
2030                 . ./config.sh
2031                 cp config.sh UU
2032                 n="$tmp_n"
2033                 c="$tmp_c"
2034                 : Older versions did not always set $sh.  Catch re-use of such
2035                 : an old config.sh.
2036                 case "$sh" in
2037                 '') sh="$tmp_sh" ;;
2038                 esac
2039                 hint=previous
2040                 ;;
2041         esac
2042 fi
2043 if test ! -f config.sh; then
2044         $cat <<EOM
2045
2046 First time through, eh?  I have some defaults handy for some systems
2047 that need some extra help getting the Configure answers right:
2048
2049 EOM
2050         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2051         dflt=''
2052         : Half the following guesses are probably wrong... If you have better
2053         : tests or hints, please send them to perlbug@perl.com
2054         : The metaconfig authors would also appreciate a copy...
2055         $test -f /irix && osname=irix
2056         $test -f /xenix && osname=sco_xenix
2057         $test -f /dynix && osname=dynix
2058         $test -f /dnix && osname=dnix
2059         $test -f /lynx.os && osname=lynxos
2060         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2061         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2062         $test -f /bin/mips && /bin/mips && osname=mips
2063         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2064                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2065         $test -d /usr/apollo/bin && osname=apollo
2066         $test -f /etc/saf/_sactab && osname=svr4
2067         $test -d /usr/include/minix && osname=minix
2068         if $test -d /MachTen -o -d /MachTen_Folder; then
2069                 osname=machten
2070                 if $test -x /sbin/version; then
2071                         osvers=`/sbin/version | $awk '{print $2}' |
2072                         $sed -e 's/[A-Za-z]$//'`
2073                 elif $test -x /usr/etc/version; then
2074                         osvers=`/usr/etc/version | $awk '{print $2}' |
2075                         $sed -e 's/[A-Za-z]$//'`
2076                 else
2077                         osvers="$2.$3"
2078                 fi
2079         fi
2080        $test -f /sys/posix.dll &&
2081                $test -f /usr/bin/what &&
2082                set X `/usr/bin/what /sys/posix.dll` &&
2083                $test "$3" = UWIN &&
2084                osname=uwin &&
2085                osvers="$5"
2086         if $test -f $uname; then
2087                 set X $myuname
2088                 shift
2089
2090                 case "$5" in
2091                 fps*) osname=fps ;;
2092                 mips*)
2093                         case "$4" in
2094                         umips) osname=umips ;;
2095                         *) osname=mips ;;
2096                         esac;;
2097                 [23]100) osname=mips ;;
2098                 next*) osname=next ;;
2099                 i386*)
2100                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2101                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2102                                 osname='sco'
2103                                 osvers=$tmp
2104                         elif $test -f /etc/kconfig; then
2105                                 osname=isc
2106                                 if test "$lns" = "ln -s"; then
2107                                         osvers=4
2108                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2109                                         osvers=3
2110                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2111                                         osvers=2
2112                                 fi
2113                         fi
2114                         tmp=''
2115                         ;;
2116                 pc*)
2117                         if test -n "$DJGPP"; then
2118                                 osname=dos
2119                                 osvers=djgpp
2120                         fi
2121                         ;;
2122                 esac
2123
2124                 case "$1" in
2125                 aix) osname=aix
2126                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2127                         case "$tmp" in
2128                         'not found') osvers="$4"."$3" ;;
2129                         '<3240'|'<>3240') osvers=3.2.0 ;;
2130                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2131                         '=3250'|'>3250') osvers=3.2.5 ;;
2132                         *) osvers=$tmp;;
2133                         esac
2134                         ;;
2135                 *dc.osx) osname=dcosx
2136                         osvers="$3"
2137                         ;;
2138                 dnix) osname=dnix
2139                         osvers="$3"
2140                         ;;
2141                 domainos) osname=apollo
2142                         osvers="$3"
2143                         ;;
2144                 dgux) osname=dgux 
2145                         osvers="$3"
2146                         ;;
2147                 dynixptx*) osname=dynixptx
2148                         osvers=`echo "$4"|sed 's/^v//'`
2149                         ;;
2150                 freebsd) osname=freebsd 
2151                         osvers="$3" ;;
2152                 genix) osname=genix ;;
2153                 hp*) osname=hpux 
2154                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2155                         ;;
2156                 irix*) osname=irix
2157                         case "$3" in
2158                         4*) osvers=4 ;;
2159                         5*) osvers=5 ;;
2160                         *)      osvers="$3" ;;
2161                         esac
2162                         ;;
2163                 linux) osname=linux
2164                         case "$3" in
2165                         *)      osvers="$3" ;;
2166                         esac
2167                         ;;
2168                 MiNT) osname=mint
2169                         ;;
2170                 netbsd*) osname=netbsd
2171                         osvers="$3"
2172                         ;;
2173                 news-os) osvers="$3"
2174                         case "$3" in
2175                         4*) osname=newsos4 ;;
2176                         *) osname=newsos ;;
2177                         esac
2178                         ;;
2179                 bsd386) osname=bsd386
2180                         osvers=`$uname -r`
2181                         ;;
2182                 POSIX-BC | posix-bc ) osname=posix-bc
2183                         osvers="$3"
2184                         ;;
2185                 powerux | power_ux | powermax_os | powermaxos | \
2186                 powerunix | power_unix) osname=powerux
2187                         osvers="$3"
2188                         ;;
2189                 next*) osname=next ;;
2190                 solaris) osname=solaris
2191                         case "$3" in
2192                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2193                         *)      osvers="$3" ;;
2194                         esac
2195                         ;;
2196                 sunos) osname=sunos
2197                         case "$3" in
2198                         5*) osname=solaris
2199                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2200                         *)      osvers="$3" ;;
2201                         esac
2202                         ;;
2203                 titanos) osname=titanos
2204                         case "$3" in
2205                         1*) osvers=1 ;;
2206                         2*) osvers=2 ;;
2207                         3*) osvers=3 ;;
2208                         4*) osvers=4 ;;
2209                         *)      osvers="$3" ;;
2210                         esac
2211                         ;;
2212                 ultrix) osname=ultrix
2213                         osvers="$3"
2214                         ;;
2215                 osf1|mls+)      case "$5" in
2216                                 alpha)
2217                                         osname=dec_osf
2218                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2219                                         ;;
2220                         hp*)    osname=hp_osf1  ;;
2221                         mips)   osname=mips_osf1 ;;
2222                         esac
2223                         ;;
2224                 uts) osname=uts 
2225                         osvers="$3"
2226                         ;;
2227                 qnx) osname=qnx
2228                         osvers="$4"
2229                         ;;
2230                 $2) case "$osname" in
2231                         *isc*) ;;
2232                         *freebsd*) ;;
2233                         svr*)
2234                                 : svr4.x or possibly later
2235                                 case "svr$3" in 
2236                                 ${osname}*)
2237                                         osname=svr$3
2238                                         osvers=$4
2239                                         ;;
2240                                 esac
2241                                 case "$osname" in
2242                                 svr4.0)
2243                                         : Check for ESIX
2244                                         if test -f /stand/boot ; then
2245                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2246                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2247                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2248                                                         if test -n "$isesix"; then
2249                                                                 osname=esix4
2250                                                         fi
2251                                                 fi
2252                                         fi
2253                                         ;;
2254                                 esac
2255                                 ;;
2256                         *)      if test -f /etc/systemid; then
2257                                         osname=sco
2258                                         set `echo $3 | $sed 's/\./ /g'` $4
2259                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2260                                                 osvers=$1.$2.$3
2261                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2262                                                 osvers=$1.$2
2263                                         elif $test -f $src/hints/sco_$1.sh; then
2264                                                 osvers=$1
2265                                         fi
2266                                 else
2267                                         case "$osname" in
2268                                         '') : Still unknown.  Probably a generic Sys V.
2269                                                 osname="sysv"
2270                                                 osvers="$3"
2271                                                 ;;
2272                                         esac
2273                                 fi
2274                                 ;;
2275                         esac
2276                         ;;
2277                 *)      case "$osname" in
2278                         '') : Still unknown.  Probably a generic BSD.
2279                                 osname="$1"
2280                                 osvers="$3"
2281                                 ;;
2282                         esac
2283                         ;;
2284                 esac
2285         else
2286                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2287                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2288                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2289                                 osname=news_os
2290                         fi
2291                         $rm -f UU/kernel.what
2292                 elif test -d c:/.; then
2293                         set X $myuname
2294                         osname=os2
2295                         osvers="$5"
2296                 fi
2297         fi
2298         
2299         : Now look for a hint file osname_osvers, unless one has been
2300         : specified already.
2301         case "$hintfile" in
2302         ''|' ')
2303                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2304                 : Also try without trailing minor version numbers.
2305                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2306                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2307                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2308                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2309                 case "$file" in
2310                 '') dflt=none ;;
2311                 *)  case "$osvers" in
2312                         '') dflt=$file
2313                                 ;;
2314                         *)  if $test -f $src/hints/$file.sh ; then
2315                                         dflt=$file
2316                                 elif $test -f $src/hints/$xfile.sh ; then
2317                                         dflt=$xfile
2318                                 elif $test -f $src/hints/$xxfile.sh ; then
2319                                         dflt=$xxfile
2320                                 elif $test -f $src/hints/$xxxfile.sh ; then
2321                                         dflt=$xxxfile
2322                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2323                                         dflt=$xxxxfile
2324                                 elif $test -f "$src/hints/${osname}.sh" ; then
2325                                         dflt="${osname}"
2326                                 else
2327                                         dflt=none
2328                                 fi
2329                                 ;;
2330                         esac
2331                         ;;
2332                 esac
2333                 if $test -f Policy.sh ; then
2334                         case "$dflt" in
2335                         *Policy*) ;;
2336                         none) dflt="Policy" ;;
2337                         *) dflt="Policy $dflt" ;;
2338                         esac
2339                 fi
2340                 ;;
2341         *)
2342                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2343                 ;;
2344         esac
2345
2346         if $test -f Policy.sh ; then
2347                 $cat <<EOM
2348
2349 There's also a Policy hint file available, which should make the
2350 site-specific (policy) questions easier to answer.
2351 EOM
2352
2353         fi
2354
2355         $cat <<EOM
2356
2357 You may give one or more space-separated answers, or "none" if appropriate.
2358 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2359 is a good thing.  DO NOT give a wrong version.
2360
2361 EOM
2362
2363         rp="Which of these apply, if any?"
2364         . UU/myread
2365         tans=$ans
2366         for file in $tans; do
2367                 if $test X$file = XPolicy -a -f Policy.sh; then
2368                         . Policy.sh
2369                         $cat Policy.sh >> UU/config.sh
2370                 elif $test -f $src/hints/$file.sh; then
2371                         . $src/hints/$file.sh
2372                         $cat $src/hints/$file.sh >> UU/config.sh
2373                 elif $test X$tans = X -o X$tans = Xnone ; then
2374                         : nothing
2375                 else
2376                         : Give one chance to correct a possible typo.
2377                         echo "$file.sh does not exist"
2378                         dflt=$file
2379                         rp="hint to use instead?"
2380                         . UU/myread
2381                         for file in $ans; do
2382                                 if $test -f "$src/hints/$file.sh"; then
2383                                         . $src/hints/$file.sh
2384                                         $cat $src/hints/$file.sh >> UU/config.sh
2385                                 elif $test X$ans = X -o X$ans = Xnone ; then
2386                                         : nothing
2387                                 else
2388                                         echo "$file.sh does not exist -- ignored."
2389                                 fi
2390                         done
2391                 fi
2392         done
2393
2394         hint=recommended
2395         : Remember our hint file for later.
2396         if $test -f "$src/hints/$file.sh" ; then
2397                 hintfile="$file"
2398         else
2399                 hintfile=''
2400         fi
2401 fi
2402 cd UU
2403 ;;
2404 *)
2405         echo " "
2406         echo "Fetching default answers from $config_sh..." >&4
2407         tmp_n="$n"
2408         tmp_c="$c"
2409         cd ..
2410         cp $config_sh config.sh 2>/dev/null
2411         chmod +w config.sh
2412         . ./config.sh
2413         cd UU
2414         cp ../config.sh .
2415         n="$tmp_n"
2416         c="$tmp_c"
2417         hint=previous
2418         ;;
2419 esac
2420 test "$override" && . ./optdef.sh
2421 myuname="$newmyuname"
2422
2423 : Restore computed paths
2424 for file in $loclist $trylist; do
2425         eval $file="\$_$file"
2426 done
2427
2428 cat << EOM
2429
2430 Configure uses the operating system name and version to set some defaults.
2431 The default value is probably right if the name rings a bell. Otherwise,
2432 since spelling matters for me, either accept the default or answer "none"
2433 to leave it blank.
2434
2435 EOM
2436 case "$osname" in
2437         ''|' ')
2438                 case "$hintfile" in
2439                 ''|' '|none) dflt=none ;;
2440                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2441                 esac
2442                 ;;
2443         *) dflt="$osname" ;;
2444 esac
2445 rp="Operating system name?"
2446 . ./myread
2447 case "$ans" in
2448 none)  osname='' ;;
2449 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2450 esac
2451 echo " "
2452 case "$osvers" in
2453         ''|' ')
2454                 case "$hintfile" in
2455                 ''|' '|none) dflt=none ;;
2456                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2457                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2458                         case "$dflt" in
2459                         ''|' ') dflt=none ;;
2460                         esac
2461                         ;;
2462                 esac
2463                 ;;
2464         *) dflt="$osvers" ;;
2465 esac
2466 rp="Operating system version?"
2467 . ./myread
2468 case "$ans" in
2469 none)  osvers='' ;;
2470 *) osvers="$ans" ;;
2471 esac
2472
2473 : who configured the system
2474 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2475 cf_by=`(logname) 2>/dev/null`
2476 case "$cf_by" in
2477 "")
2478         cf_by=`(whoami) 2>/dev/null`
2479         case "$cf_by" in
2480         "") cf_by=unknown ;;
2481         esac ;;
2482 esac
2483
2484 : set up the script used to warn in case of inconsistency
2485 cat <<EOS >whoa
2486 $startsh
2487 EOS
2488 cat <<'EOSC' >>whoa
2489 dflt=y
2490 echo " "
2491 echo "*** WHOA THERE!!! ***" >&4
2492 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2493 rp="    Keep the $hint value?"
2494 . ./myread
2495 case "$ans" in
2496 y) td=$was; tu=$was;;
2497 esac
2498 EOSC
2499
2500 : function used to set $1 to $val
2501 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2502 case "$val$was" in
2503 $define$undef) . ./whoa; eval "$var=\$td";;
2504 $undef$define) . ./whoa; eval "$var=\$tu";;
2505 *) eval "$var=$val";;
2506 esac'
2507
2508 cat <<EOM
2509
2510 Perl can be built to take advantage of threads, on some systems.
2511 To do so, Configure must be run with -Dusethreads.
2512
2513 Note that threading is a highly experimental feature, and
2514 some known race conditions still remain.  If you choose to try
2515 it, be very sure to not actually deploy it for production
2516 purposes.  README.threads has more details, and is required
2517 reading if you enable threads.
2518 EOM
2519 case "$usethreads" in
2520 $define|true|[yY]*)     dflt='y';;
2521 *) dflt='n';;
2522 esac
2523 rp='Build a threading Perl?'
2524 . ./myread
2525 case "$ans" in
2526 y|Y)    val="$define" ;;     
2527 *)      val="$undef" ;;
2528 esac
2529 set usethreads
2530 eval $setvar 
2531
2532 case "$d_oldpthreads" in
2533 '')     : Configure tests would be welcome here.  For now, assume undef.
2534         val="$undef" ;;
2535 *)      val="$d_oldpthreads" ;;
2536 esac
2537 set d_oldpthreads
2538 eval $setvar
2539
2540
2541 case "$usethreads" in
2542 "$define"|true|[yY]*)
2543 : Look for a hint-file generated 'call-back-unit'.  If the
2544 : user has specified that a threading perl is to be built,
2545 : we may need to set or change some other defaults.
2546         if $test -f usethreads.cbu; then
2547                 . ./usethreads.cbu
2548         fi
2549         case "$osname" in
2550         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2551                 # Known thread-capable platforms.
2552                 ;;
2553         *)
2554                 cat >&4 <<EOM
2555 $osname is not known to support threads.
2556 Please let perlbug@perl.com know how to do that.
2557
2558 Cannot continue, aborting.
2559 EOM
2560                 exit 1
2561         ;;
2562         esac # $osname
2563     ;;
2564 esac # $usethreads
2565
2566 cat <<EOM
2567
2568 Perl can be built so that multiple Perl interpreters can coexist
2569 within the same Perl executable.  To do so, Configure must be run with
2570 -Dusemultiplicity.
2571
2572 Normally you do not need this and you should answer no.
2573
2574 EOM
2575 case "$usemultiplicity" in
2576 $define|true|[yY]*)     dflt='y';;
2577 *) dflt='n';;
2578 esac
2579 rp='Build Perl for multiplicity?'
2580 . ./myread
2581 case "$ans" in
2582 y|Y)    val="$define" ;;     
2583 *)      val="$undef" ;;
2584 esac
2585 set usemultiplicity
2586 eval $setvar 
2587
2588 cat <<EOM
2589
2590 Perl can be built to take advantage of explicit 64-bit interfaces,
2591 on some systems.  To do so, Configure must be run with -Duse64bits.
2592
2593 If this doesn't make any sense to you, just accept the default 'n'.
2594 EOM
2595 case "$use64bits" in
2596 $define|true|[yY]*)     dflt='y';;
2597 *) dflt='n';;
2598 esac
2599 rp='Try to use explicit 64-bit interfaces, if available?'
2600 . ./myread
2601 case "$ans" in
2602 y|Y) 
2603         val="$define"
2604         ;;     
2605 *)      
2606         val="$undef"
2607         ;;
2608 esac
2609 set use64bits
2610 eval $setvar
2611
2612 case "$archname64" in
2613 '') archname64='' ;;    # not a typo
2614 esac
2615
2616 case "$use64bits" in
2617 "$define"|true|[yY]*)
2618 : Look for a hint-file generated 'call-back-unit'.  If the
2619 : user has specified that a threading perl is to be built,
2620 : we may need to set or change some other defaults.
2621         if $test -f use64bits.cbu; then
2622                 . ./use64bits.cbu
2623         fi
2624         case "$osname" in
2625         dec_osf|hpux|irix|solaris|unicos)
2626                 # Known 64-bit capable platforms.
2627                 ;;
2628         *)
2629                 cat >&4 <<EOM
2630 $osname is not known to support 64-bit interfaces.
2631 Please let perlbug@perl.com know how to do that.
2632
2633 Cannot continue, aborting.
2634 EOM
2635                 exit 1
2636                 ;;
2637         esac
2638         ;;
2639 esac
2640
2641 : determine the architecture name
2642 echo " "
2643 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2644         tarch=`arch`"-$osname"
2645 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2646         if uname -m > tmparch 2>&1 ; then
2647                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2648                         -e 's/$/'"-$osname/" tmparch`
2649         else
2650                 tarch="$osname"
2651         fi
2652         $rm -f tmparch
2653 else
2654         tarch="$osname"
2655 fi
2656 case "$myarchname" in
2657 ''|"$tarch") ;;
2658 *)
2659         echo "(Your architecture name used to be $myarchname.)"
2660         archname=''
2661         ;;
2662 esac
2663 myarchname="$tarch"
2664 case "$archname" in
2665 '') dflt="$tarch";;
2666 *) dflt="$archname";;
2667 esac
2668 rp='What is your architecture name'
2669 . ./myread
2670 archname="$ans"
2671 case "$usethreads" in
2672 $define)
2673         echo "Threads selected." >&4
2674         case "$archname" in
2675         *-thread*) echo "...and architecture name already has -thread." >&4
2676                 ;;
2677         *)      archname="$archname-thread"
2678                 echo "...setting architecture name to $archname." >&4
2679                 ;;
2680         esac
2681         ;;
2682 esac
2683 case "$usemultiplicity" in
2684 $define)
2685         echo "Multiplicity selected." >&4
2686         case "$archname" in
2687         *-multi*) echo "...and architecture name already has -multi." >&4
2688                 ;;
2689         *)      archname="$archname-multi"
2690                 echo "...setting architecture name to $archname." >&4
2691                 ;;
2692         esac
2693         ;;
2694 esac
2695 case "$use64bits" in
2696 $define)
2697         echo "Explicit 64-bitness selected." >&4
2698         case "$archname64" in
2699         '')
2700                 ;;
2701         *)
2702                 case "$archname" in
2703                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2704                         ;;
2705                 *)      archname="$archname-$archname64"
2706                         echo "...setting architecture name to $archname." >&4
2707                         ;;
2708                 esac
2709                 ;;
2710         esac
2711 esac
2712
2713 : is AFS running?
2714 echo " "
2715 case "$afs" in
2716 $define|true)   afs=true ;;
2717 $undef|false)   afs=false ;;
2718 *)      if test -d /afs; then
2719                 afs=true
2720         else
2721                 afs=false
2722         fi
2723         ;;
2724 esac
2725 if $afs; then
2726         echo "AFS may be running... I'll be extra cautious then..." >&4
2727 else
2728         echo "AFS does not seem to be running..." >&4
2729 fi
2730
2731 : decide how portable to be.  Allow command line overrides.
2732 case "$d_portable" in
2733 "$undef") ;;
2734 *)      d_portable="$define" ;;
2735 esac
2736
2737 : set up shell script to do ~ expansion
2738 cat >filexp <<EOSS
2739 $startsh
2740 : expand filename
2741 case "\$1" in
2742  ~/*|~)
2743         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2744         ;;
2745  ~*)
2746         if $test -f /bin/csh; then
2747                 /bin/csh -f -c "glob \$1"
2748                 failed=\$?
2749                 echo ""
2750                 exit \$failed
2751         else
2752                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2753                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2754                 if $test ! -d "\$dir"; then
2755                         me=\`basename \$0\`
2756                         echo "\$me: can't locate home directory for: \$name" >&2
2757                         exit 1
2758                 fi
2759                 case "\$1" in
2760                 */*)
2761                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2762                         ;;
2763                 *)
2764                         echo \$dir
2765                         ;;
2766                 esac
2767         fi
2768         ;;
2769 *)
2770         echo \$1
2771         ;;
2772 esac
2773 EOSS
2774 chmod +x filexp
2775 $eunicefix filexp
2776
2777 : now set up to get a file name
2778 cat <<EOS >getfile
2779 $startsh
2780 EOS
2781 cat <<'EOSC' >>getfile
2782 tilde=''
2783 fullpath=''
2784 already=''
2785 skip=''
2786 none_ok=''
2787 exp_file=''
2788 nopath_ok=''
2789 orig_rp="$rp"
2790 orig_dflt="$dflt"
2791
2792 case "$fn" in
2793 *\(*)
2794         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2795         fn=`echo $fn | sed 's/(.*)//'`
2796         ;;
2797 esac
2798
2799 case "$fn" in
2800 *:*)
2801         loc_file=`expr $fn : '.*:\(.*\)'`
2802         fn=`expr $fn : '\(.*\):.*'`
2803         ;;
2804 esac
2805
2806 case "$fn" in
2807 *~*) tilde=true;;
2808 esac
2809 case "$fn" in
2810 */*) fullpath=true;;
2811 esac
2812 case "$fn" in
2813 *+*) skip=true;;
2814 esac
2815 case "$fn" in
2816 *n*) none_ok=true;;
2817 esac
2818 case "$fn" in
2819 *e*) exp_file=true;;
2820 esac
2821 case "$fn" in
2822 *p*) nopath_ok=true;;
2823 esac
2824
2825 case "$fn" in
2826 *f*) type='File';;
2827 *d*) type='Directory';;
2828 *l*) type='Locate';;
2829 esac
2830
2831 what="$type"
2832 case "$what" in
2833 Locate) what='File';;
2834 esac
2835
2836 case "$exp_file" in
2837 '')
2838         case "$d_portable" in
2839         "$define") ;;
2840         *) exp_file=true;;
2841         esac
2842         ;;
2843 esac
2844
2845 cd ..
2846 while test "$type"; do
2847         redo=''
2848         rp="$orig_rp"
2849         dflt="$orig_dflt"
2850         case "$tilde" in
2851         true) rp="$rp (~name ok)";;
2852         esac
2853         . UU/myread
2854         if test -f UU/getfile.ok && \
2855                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2856         then
2857                 value="$ans"
2858                 ansexp="$ans"
2859                 break
2860         fi
2861         case "$ans" in
2862         none)
2863                 value=''
2864                 ansexp=''
2865                 case "$none_ok" in
2866                 true) type='';;
2867                 esac
2868                 ;;
2869         *)
2870                 case "$tilde" in
2871                 '') value="$ans"
2872                         ansexp="$ans";;
2873                 *)
2874                         value=`UU/filexp $ans`
2875                         case $? in
2876                         0)
2877                                 if test "$ans" != "$value"; then
2878                                         echo "(That expands to $value on this system.)"
2879                                 fi
2880                                 ;;
2881                         *) value="$ans";;
2882                         esac
2883                         ansexp="$value"
2884                         case "$exp_file" in
2885                         '') value="$ans";;
2886                         esac
2887                         ;;
2888                 esac
2889                 case "$fullpath" in
2890                 true)
2891                         case "$ansexp" in
2892                         /*) value="$ansexp" ;;
2893                         *)
2894                                 redo=true
2895                                 case "$already" in
2896                                 true)
2897                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2898                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2899                                         ;;
2900                                 *)
2901                                 echo "Please give a full path name, starting with slash." >&4
2902                                         case "$tilde" in
2903                                         true)
2904                                 echo "Note that using ~name is ok provided it expands well." >&4
2905                                                 already=true
2906                                                 ;;
2907                                         esac
2908                                 esac
2909                                 ;;
2910                         esac
2911                         ;;
2912                 esac
2913                 case "$redo" in
2914                 '')
2915                         case "$type" in
2916                         File)
2917                                 if test -f "$ansexp"; then
2918                                         type=''
2919                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2920                                 then
2921                                         echo "($value is not a plain file, but that's ok.)"
2922                                         type=''
2923                                 fi
2924                                 ;;
2925                         Directory)
2926                                 if test -d "$ansexp"; then
2927                                         type=''
2928                                 fi
2929                                 ;;
2930                         Locate)
2931                                 if test -d "$ansexp"; then
2932                                         echo "(Looking for $loc_file in directory $value.)"
2933                                         value="$value/$loc_file"
2934                                         ansexp="$ansexp/$loc_file"
2935                                 fi
2936                                 if test -f "$ansexp"; then
2937                                         type=''
2938                                 fi
2939                                 case "$nopath_ok" in
2940                                 true)   case "$value" in
2941                                         */*) ;;
2942                                         *)      echo "Assuming $value will be in people's path."
2943                                                 type=''
2944                                                 ;;
2945                                         esac
2946                                         ;;
2947                                 esac
2948                                 ;;
2949                         esac
2950
2951                         case "$skip" in
2952                         true) type='';
2953                         esac
2954
2955                         case "$type" in
2956                         '') ;;
2957                         *)
2958                                 if test "$fastread" = yes; then
2959                                         dflt=y
2960                                 else
2961                                         dflt=n
2962                                 fi
2963                                 rp="$what $value doesn't exist.  Use that name anyway?"
2964                                 . UU/myread
2965                                 dflt=''
2966                                 case "$ans" in
2967                                 y*) type='';;
2968                                 *) echo " ";;
2969                                 esac
2970                                 ;;
2971                         esac
2972                         ;;
2973                 esac
2974                 ;;
2975         esac
2976 done
2977 cd UU
2978 ans="$value"
2979 rp="$orig_rp"
2980 dflt="$orig_dflt"
2981 rm -f getfile.ok
2982 EOSC
2983
2984 : determine root of directory hierarchy where package will be installed.
2985 case "$prefix" in
2986 '')
2987         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2988         ;;
2989 *)
2990         dflt="$prefix"
2991         ;;
2992 esac
2993 $cat <<EOM
2994
2995 By default, $package will be installed in $dflt/bin, manual
2996 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
2997 all installation directories. Typically set to /usr/local, but you
2998 may choose /usr if you wish to install $package among your system
2999 binaries. If you wish to have binaries under /bin but manual pages
3000 under /usr/local/man, that's ok: you will be prompted separately
3001 for each of the installation directories, the prefix being only used
3002 to set the defaults.
3003
3004 EOM
3005 fn=d~
3006 rp='Installation prefix to use?'
3007 . ./getfile
3008 oldprefix=''
3009 case "$prefix" in
3010 '') ;;
3011 *)
3012         case "$ans" in
3013         "$prefix") ;;
3014         *) oldprefix="$prefix";;
3015         esac
3016         ;;
3017 esac
3018 prefix="$ans"
3019 prefixexp="$ansexp"
3020
3021 : set the prefixit variable, to compute a suitable default value
3022 prefixit='case "$3" in
3023 ""|none)
3024         case "$oldprefix" in
3025         "") eval "$1=\"\$$2\"";;
3026         *)
3027                 case "$3" in
3028                 "") eval "$1=";;
3029                 none)
3030                         eval "tp=\"\$$2\"";
3031                         case "$tp" in
3032                         ""|" ") eval "$1=\"\$$2\"";;
3033                         *) eval "$1=";;
3034                         esac;;
3035                 esac;;
3036         esac;;
3037 *)
3038         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3039         case "$tp" in
3040         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3041         /*-$oldprefix/*|\~*-$oldprefix/*)
3042                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3043         *) eval "$1=\"\$$2\"";;
3044         esac;;
3045 esac'
3046
3047 : set the base revision
3048 baserev=5.0
3049
3050 : get the patchlevel
3051 echo " "
3052 echo "Getting the current patchlevel..." >&4
3053 if $test -r $rsrc/patchlevel.h;then
3054         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3055         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3056 else
3057         patchlevel=0
3058         subversion=0
3059 fi
3060 $echo $n "(You have $package" $c
3061 case "$package" in
3062 "*$baserev")    ;;
3063 *)              $echo $n " $baserev" $c ;;
3064 esac
3065 $echo $n " patchlevel $patchlevel" $c
3066 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3067 echo ".)"
3068
3069 if test 0 -eq "$subversion"; then
3070         version=`LC_ALL=C; export LC_ALL; \
3071                  echo $baserev $patchlevel | \
3072                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3073 else
3074         version=`LC_ALL=C; export LC_ALL; \
3075                  echo $baserev $patchlevel $subversion | \
3076                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3077 fi
3078 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3079 if test "$subversion" -lt 50; then
3080         apiversion=`LC_ALL=C; export LC_ALL; \
3081                  LANGUAGE=C; export LANGUAGE; \
3082                  echo $baserev $patchlevel | \
3083                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3084 else
3085         apiversion="$version"
3086 fi
3087
3088 : determine where private library files go
3089 : Usual default is /usr/local/lib/perl5/$version.
3090 : Also allow things like /opt/perl/lib/$version, since 
3091 : /opt/perl/lib/perl5... would be redundant.
3092 case "$prefix" in
3093 *perl*) set dflt privlib lib/$version ;;
3094 *)       set dflt privlib lib/$package/$version ;;
3095 esac
3096 eval $prefixit
3097 $cat <<EOM
3098
3099 There are some auxiliary files for $package that need to be put into a
3100 private library directory that is accessible by everyone.
3101
3102 EOM
3103 fn=d~+
3104 rp='Pathname where the private library files will reside?'
3105 . ./getfile
3106 if $test "X$privlibexp" != "X$ansexp"; then
3107         installprivlib=''
3108 fi
3109 privlib="$ans"
3110 privlibexp="$ansexp"
3111 if $afs; then
3112         $cat <<EOM
3113
3114 Since you are running AFS, I need to distinguish the directory in which
3115 private files reside from the directory in which they are installed (and from
3116 which they are presumably copied to the former directory by occult means).
3117
3118 EOM
3119         case "$installprivlib" in
3120         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3121         *) dflt="$installprivlib";;
3122         esac
3123         fn=de~
3124         rp='Where will private files be installed?'
3125         . ./getfile
3126         installprivlib="$ans"
3127 else
3128         installprivlib="$privlibexp"
3129 fi
3130
3131 : set the prefixup variable, to restore leading tilda escape
3132 prefixup='case "$prefixexp" in
3133 "$prefix") ;;
3134 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3135 esac'
3136
3137 : determine where public architecture dependent libraries go
3138 set archlib archlib
3139 eval $prefixit
3140 : privlib default is /usr/local/lib/$package/$version
3141 : archlib default is /usr/local/lib/$package/$version/$archname
3142 : privlib may have an optional trailing /share.
3143 tdflt=`echo $privlib | $sed 's,/share$,,'`
3144 tdflt=$tdflt/$archname
3145 case "$archlib" in
3146 '')     dflt=$tdflt
3147         ;;
3148 *)      dflt="$archlib"
3149     ;;
3150 esac
3151 cat <<EOM
3152
3153 $spackage contains architecture-dependent library files.  If you are
3154 sharing libraries in a heterogeneous environment, you might store
3155 these files in a separate location.  Otherwise, you can just include
3156 them with the rest of the public library files.
3157
3158 EOM
3159 fn=d+~
3160 rp='Where do you want to put the public architecture-dependent libraries?'
3161 . ./getfile
3162 archlib="$ans"
3163 archlibexp="$ansexp"
3164
3165 if $afs; then
3166         $cat <<EOM
3167
3168 Since you are running AFS, I need to distinguish the directory in
3169 which architecture-dependent library files reside from the directory
3170 in which they are installed (and from which they are presumably copied
3171 to the former directory by occult means).
3172
3173 EOM
3174         case "$installarchlib" in
3175         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3176         *) dflt="$installarchlib";;
3177         esac
3178         fn=de~
3179         rp='Where will architecture-dependent library files be installed?'
3180         . ./getfile
3181         installarchlib="$ans"
3182 else
3183         installarchlib="$archlibexp"
3184 fi
3185 if $test X"$archlib" = X"$privlib"; then
3186         d_archlib="$undef"
3187 else
3188         d_archlib="$define"
3189 fi
3190
3191 : make some quick guesses about what we are up against
3192 echo " "
3193 $echo $n "Hmm...  $c"
3194 echo exit 1 >bsd
3195 echo exit 1 >usg
3196 echo exit 1 >v7
3197 echo exit 1 >osf1
3198 echo exit 1 >eunice
3199 echo exit 1 >xenix
3200 echo exit 1 >venix
3201 echo exit 1 >os2
3202 d_bsd="$undef"
3203 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3204 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3205 then
3206         echo "Looks kind of like an OSF/1 system, but we'll see..."
3207         echo exit 0 >osf1
3208 elif test `echo abc | tr a-z A-Z` = Abc ; then
3209         xxx=`./loc addbib blurfl $pth`
3210         if $test -f $xxx; then
3211         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3212                 echo exit 0 >bsd
3213                 echo exit 0 >usg
3214         else
3215                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3216                         echo "Looks kind of like an extended USG system, but we'll see..."
3217                 else
3218                         echo "Looks kind of like a USG system, but we'll see..."
3219                 fi
3220                 echo exit 0 >usg
3221         fi
3222 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3223         echo "Looks kind of like a BSD system, but we'll see..."
3224         d_bsd="$define"
3225         echo exit 0 >bsd
3226 else
3227         echo "Looks kind of like a Version 7 system, but we'll see..."
3228         echo exit 0 >v7
3229 fi
3230 case "$eunicefix" in
3231 *unixtovms*)
3232         $cat <<'EOI'
3233 There is, however, a strange, musty smell in the air that reminds me of
3234 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3235 EOI
3236         echo exit 0 >eunice
3237         d_eunice="$define"
3238 : it so happens the Eunice I know will not run shell scripts in Unix format
3239         ;;
3240 *)
3241         echo " "
3242         echo "Congratulations.  You aren't running Eunice."
3243         d_eunice="$undef"
3244         ;;
3245 esac
3246 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3247 case "$p_" in
3248 :) ;;
3249 *)
3250         $cat <<'EOI'
3251 I have the feeling something is not exactly right, however...don't tell me...
3252 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3253 EOI
3254         echo exit 0 >os2
3255         ;;
3256 esac
3257 if test -f /xenix; then
3258         echo "Actually, this looks more like a XENIX system..."
3259         echo exit 0 >xenix
3260         d_xenix="$define"
3261 else
3262         echo " "
3263         echo "It's not Xenix..."
3264         d_xenix="$undef"
3265 fi
3266 chmod +x xenix
3267 $eunicefix xenix
3268 if test -f /venix; then
3269         echo "Actually, this looks more like a VENIX system..."
3270         echo exit 0 >venix
3271 else
3272         echo " "
3273         if ./xenix; then
3274                 : null
3275         else
3276                 echo "Nor is it Venix..."
3277         fi
3278 fi
3279 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3280 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3281 $rm -f foo
3282
3283 : see if setuid scripts can be secure
3284 $cat <<EOM
3285
3286 Some kernels have a bug that prevents setuid #! scripts from being
3287 secure.  Some sites have disabled setuid #! scripts because of this.
3288
3289 First let's decide if your kernel supports secure setuid #! scripts.
3290 (If setuid #! scripts would be secure but have been disabled anyway,
3291 don't say that they are secure if asked.)
3292
3293 EOM
3294
3295 val="$undef"
3296 if $test -d /dev/fd; then
3297         echo "#!$ls" >reflect
3298         chmod +x,u+s reflect
3299         ./reflect >flect 2>&1
3300         if $contains "/dev/fd" flect >/dev/null; then
3301                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3302                 val="$define"
3303         else
3304                 $cat <<EOM
3305 If you are not sure if they are secure, I can check but I'll need a
3306 username and password different from the one you are using right now.
3307 If you don't have such a username or don't want me to test, simply
3308 enter 'none'.
3309
3310 EOM
3311                 rp='Other username to test security of setuid scripts with?'
3312                 dflt='none'
3313                 . ./myread
3314                 case "$ans" in
3315                 n|none)
3316                         case "$d_suidsafe" in
3317                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3318                                 dflt=n;;
3319                         "$undef")
3320                                 echo "Well, the $hint value is *not* secure." >&4
3321                                 dflt=n;;
3322                         *)      echo "Well, the $hint value *is* secure." >&4
3323                                 dflt=y;;
3324                         esac
3325                         ;;
3326                 *)
3327                         $rm -f reflect flect
3328                         echo "#!$ls" >reflect
3329                         chmod +x,u+s reflect
3330                         echo >flect
3331                         chmod a+w flect
3332                         echo '"su" will (probably) prompt you for '"$ans's password."
3333                         su $ans -c './reflect >flect'
3334                         if $contains "/dev/fd" flect >/dev/null; then
3335                                 echo "Okay, it looks like setuid scripts are secure." >&4
3336                                 dflt=y
3337                         else
3338                                 echo "I don't think setuid scripts are secure." >&4
3339                                 dflt=n
3340                         fi
3341                         ;;
3342                 esac
3343                 rp='Does your kernel have *secure* setuid scripts?'
3344                 . ./myread
3345                 case "$ans" in
3346                 [yY]*)  val="$define";;
3347                 *)      val="$undef";;
3348                 esac
3349         fi
3350 else
3351         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3352         echo "(That's for file descriptors, not floppy disks.)"
3353         val="$undef"
3354 fi
3355 set d_suidsafe
3356 eval $setvar
3357
3358 $rm -f reflect flect
3359
3360 : now see if they want to do setuid emulation
3361 echo " "
3362 val="$undef"
3363 case "$d_suidsafe" in
3364 "$define")
3365         val="$undef"
3366         echo "No need to emulate SUID scripts since they are secure here." >& 4
3367         ;;
3368 *)
3369         $cat <<EOM
3370 Some systems have disabled setuid scripts, especially systems where
3371 setuid scripts cannot be secure.  On systems where setuid scripts have
3372 been disabled, the setuid/setgid bits on scripts are currently
3373 useless.  It is possible for $package to detect those bits and emulate
3374 setuid/setgid in a secure fashion.  This emulation will only work if
3375 setuid scripts have been disabled in your kernel.
3376
3377 EOM
3378         case "$d_dosuid" in
3379         "$define") dflt=y ;;
3380         *) dflt=n ;;
3381         esac
3382         rp="Do you want to do setuid/setgid emulation?"
3383         . ./myread
3384         case "$ans" in
3385         [yY]*)  val="$define";;
3386         *)      val="$undef";;
3387         esac
3388         ;;
3389 esac
3390 set d_dosuid
3391 eval $setvar
3392
3393 : determine where manual pages are on this system
3394 echo " "
3395 case "$sysman" in
3396 '') 
3397         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3398         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3399         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3400         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3401         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3402         sysman=`./loc . /usr/man/man1 $syspath`
3403         ;;
3404 esac
3405 if $test -d "$sysman"; then
3406         echo "System manual is in $sysman." >&4
3407 else
3408         echo "Could not find manual pages in source form." >&4
3409 fi
3410
3411 : see what memory models we can support
3412 case "$models" in
3413 '')
3414         $cat >pdp11.c <<'EOP'
3415 int main() {
3416 #ifdef pdp11
3417         exit(0);
3418 #else
3419         exit(1);
3420 #endif
3421 }
3422 EOP
3423         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3424         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3425                 dflt='unsplit split'
3426         else
3427                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3428                 case "$tans" in
3429                 X) dflt='none';;
3430                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3431                                 dflt='small'
3432                         else
3433                                 dflt=''
3434                         fi
3435                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3436                                 dflt="$dflt medium"
3437                         fi
3438                         if $test -d /lib/large || $test -d /usr/lib/large; then
3439                                 dflt="$dflt large"
3440                         fi
3441                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3442                                 dflt="$dflt huge"
3443                         fi
3444                 esac
3445         fi;;
3446 *) dflt="$models";;
3447 esac
3448 $cat <<EOM
3449  
3450 Some systems have different model sizes.  On most systems they are called
3451 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3452 split.  If your system doesn't support different memory models, say "none".
3453 If you wish to force everything to one memory model, say "none" here and
3454 put the appropriate flags later when it asks you for other cc and ld flags.
3455 Venix systems may wish to put "none" and let the compiler figure things out.
3456 (In the following question multiple model names should be space separated.)
3457
3458 The default for most systems is "none".
3459
3460 EOM
3461 rp="Which memory models are supported?"
3462 . ./myread
3463 models="$ans"
3464
3465 case "$models" in
3466 none)
3467         small=''
3468         medium=''
3469         large=''
3470         huge=''
3471         unsplit=''
3472         split=''
3473         ;;
3474 *split)
3475         case "$split" in
3476         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3477                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3478                         dflt='-i'
3479                 else
3480                         dflt='none'
3481                 fi;;
3482         *) dflt="$split";;
3483         esac
3484         rp="What flag indicates separate I and D space?"
3485         . ./myread
3486         tans="$ans"
3487         case "$tans" in
3488         none) tans='';;
3489         esac
3490         split="$tans"
3491         unsplit='';;
3492 *large*|*small*|*medium*|*huge*)
3493         case "$models" in
3494         *large*)
3495                 case "$large" in
3496                 '') dflt='-Ml';;
3497                 *) dflt="$large";;
3498                 esac
3499         rp="What flag indicates large model?"
3500         . ./myread
3501         tans="$ans"
3502         case "$tans" in
3503         none) tans='';
3504         esac
3505         large="$tans";;
3506         *) large='';;
3507         esac
3508         case "$models" in
3509         *huge*) case "$huge" in
3510                 '') dflt='-Mh';;
3511                 *) dflt="$huge";;
3512                 esac
3513                 rp="What flag indicates huge model?"
3514                 . ./myread
3515                 tans="$ans"
3516                 case "$tans" in
3517                 none) tans='';
3518                 esac
3519                 huge="$tans";;
3520         *) huge="$large";;
3521         esac
3522         case "$models" in
3523         *medium*) case "$medium" in
3524                 '') dflt='-Mm';;
3525                 *) dflt="$medium";;
3526                 esac
3527                 rp="What flag indicates medium model?"
3528                 . ./myread
3529                 tans="$ans"
3530                 case "$tans" in
3531                 none) tans='';
3532                 esac
3533                 medium="$tans";;
3534         *) medium="$large";;
3535         esac
3536         case "$models" in
3537         *small*) case "$small" in
3538                 '') dflt='none';;
3539                 *) dflt="$small";;
3540                 esac
3541                 rp="What flag indicates small model?"
3542                 . ./myread
3543                 tans="$ans"
3544                 case "$tans" in
3545                 none) tans='';
3546                 esac
3547                 small="$tans";;
3548         *) small='';;
3549         esac
3550         ;;
3551 *)
3552         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3553         ;;
3554 esac
3555 $rm -f pdp11.* pdp11
3556
3557 : see if we need a special compiler
3558 echo " "
3559 if ./usg; then
3560         case "$cc" in
3561         '') case "$Mcc" in
3562                 /*) dflt='Mcc';;
3563                 *) case "$large" in
3564                         -M*) dflt='cc';;
3565                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3566                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3567                                                 dflt='cc'
3568                                         else
3569                                                 dflt='cc -M'
3570                                         fi
3571                                 else
3572                                         dflt='cc'
3573                                 fi;;
3574                         esac;;
3575                 esac;;
3576         *)  dflt="$cc";;
3577         esac
3578         case "$dflt" in
3579         *M*)    $cat <<'EOM'
3580 On some older systems the default C compiler will not resolve multiple global
3581 references that happen to have the same name.  On some such systems the "Mcc"
3582 command may be used to force these to be resolved.  On other systems a "cc -M"
3583 command is required.  (Note that the -M flag on other systems indicates a
3584 memory model to use!) If you have the Gnu C compiler, you might wish to use
3585 that instead.
3586
3587 EOM
3588         ;;
3589         esac
3590         rp="Use which C compiler?"
3591         . ./myread
3592         cc="$ans"
3593 else
3594         case "$cc" in
3595         '') dflt=cc;;
3596         *) dflt="$cc";;
3597         esac
3598         rp="Use which C compiler?"
3599         . ./myread
3600         cc="$ans"
3601 fi
3602 : Look for a hint-file generated 'call-back-unit'.  Now that the
3603 : user has specified the compiler, we may need to set or change some
3604 : other defaults.
3605 if $test -f cc.cbu; then
3606     . ./cc.cbu
3607 fi
3608 echo " "
3609 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3610 $cat >gccvers.c <<EOM
3611 #include <stdio.h>
3612 int main() {
3613 #ifdef __GNUC__
3614 #ifdef __VERSION__
3615         printf("%s\n", __VERSION__);
3616 #else
3617         printf("%s\n", "1");
3618 #endif
3619 #endif
3620         exit(0);
3621 }
3622 EOM
3623 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
3624         gccversion=`./gccvers`
3625         case "$gccversion" in
3626         '') echo "You are not using GNU cc." ;;
3627         *)  echo "You are using GNU cc $gccversion." ;;
3628         esac
3629 else
3630         echo " "
3631         echo "*** WHOA THERE!!! ***" >&4
3632         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3633         case "$knowitall" in
3634         '')
3635         echo "    You'd better start hunting for one and let me know about it." >&4
3636                 exit 1
3637                 ;;
3638         esac
3639 fi
3640 $rm -f gccvers*
3641 case "$gccversion" in
3642 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3643 esac
3644
3645 : What should the include directory be ?
3646 echo " "
3647 $echo $n "Hmm...  $c"
3648 dflt='/usr/include'
3649 incpath=''
3650 mips_type=''
3651 if $test -f /bin/mips && /bin/mips; then
3652         echo "Looks like a MIPS system..."
3653         $cat >usr.c <<'EOCP'
3654 #ifdef SYSTYPE_BSD43
3655 /bsd43
3656 #endif
3657 EOCP
3658         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3659                 dflt='/bsd43/usr/include'
3660                 incpath='/bsd43'
3661                 mips_type='BSD 4.3'
3662         else
3663                 mips_type='System V'
3664         fi
3665         $rm -f usr.c usr.out
3666         echo "and you're compiling with the $mips_type compiler and libraries."
3667         xxx_prompt=y
3668         echo "exit 0" >mips
3669 else
3670         echo "Doesn't look like a MIPS system."
3671         xxx_prompt=n
3672         echo "exit 1" >mips
3673 fi
3674 chmod +x mips
3675 $eunicefix mips
3676 case "$usrinc" in
3677 '') ;;
3678 *) dflt="$usrinc";;
3679 esac
3680 case "$xxx_prompt" in
3681 y)      fn=d/
3682         echo " "
3683         rp='Where are the include files you want to use?'
3684         . ./getfile
3685         usrinc="$ans"
3686         ;;
3687 *)      usrinc="$dflt"
3688         ;;
3689 esac
3690
3691 : see how we invoke the C preprocessor
3692 echo " "
3693 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3694 cat <<'EOT' >testcpp.c
3695 #define ABC abc
3696 #define XYZ xyz
3697 ABC.XYZ
3698 EOT
3699 cd ..
3700 if test ! -f cppstdin; then
3701         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3702 else
3703         echo "Keeping your $hint cppstdin wrapper."
3704 fi
3705 chmod 755 cppstdin
3706 wrapper=`pwd`/cppstdin
3707 ok='false'
3708 cd UU
3709
3710 if $test "X$cppstdin" != "X" && \
3711         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3712         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3713 then
3714         echo "You used to use $cppstdin $cppminus so we'll use that again."
3715         case "$cpprun" in
3716         '') echo "But let's see if we can live without a wrapper..." ;;
3717         *)
3718                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3719                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3720                 then
3721                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3722                         ok='true'
3723                 else
3724                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3725                 fi
3726                 ;;
3727         esac
3728 else
3729         case "$cppstdin" in
3730         '') ;;
3731         *)
3732                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3733                 ;;
3734         esac
3735 fi
3736
3737 if $ok; then
3738         : nothing
3739 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3740         $cc -E <testcpp.c >testcpp.out 2>&1; \
3741         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3742         echo "Yup, it does."
3743         x_cpp="$cc -E"
3744         x_minus='';
3745 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3746         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3747         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3748         echo "Yup, it does."
3749         x_cpp="$cc -E"
3750         x_minus='-';
3751 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3752         $cc -P <testcpp.c >testcpp.out 2>&1; \
3753         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3754         echo "Yipee, that works!"
3755         x_cpp="$cc -P"
3756         x_minus='';
3757 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3758         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3759         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3760         echo "At long last!"
3761         x_cpp="$cc -P"
3762         x_minus='-';
3763 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3764         $cpp <testcpp.c >testcpp.out 2>&1; \
3765         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3766         echo "It works!"
3767         x_cpp="$cpp"
3768         x_minus='';
3769 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3770         $cpp - <testcpp.c >testcpp.out 2>&1; \
3771         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3772         echo "Hooray, it works!  I was beginning to wonder."
3773         x_cpp="$cpp"
3774         x_minus='-';
3775 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3776         $wrapper <testcpp.c >testcpp.out 2>&1; \
3777         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3778         x_cpp="$wrapper"
3779         x_minus=''
3780         echo "Eureka!"
3781 else
3782         dflt=''
3783         rp="No dice.  I can't find a C preprocessor.  Name one:"
3784         . ./myread
3785         x_cpp="$ans"
3786         x_minus=''
3787         $x_cpp <testcpp.c >testcpp.out 2>&1
3788         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3789                 echo "OK, that will do." >&4
3790         else
3791 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3792                 exit 1
3793         fi
3794 fi
3795
3796 case "$ok" in
3797 false)
3798         cppstdin="$x_cpp"
3799         cppminus="$x_minus"
3800         cpprun="$x_cpp"
3801         cpplast="$x_minus"
3802         set X $x_cpp
3803         shift
3804         case "$1" in
3805         "$cpp")
3806                 echo "Perhaps can we force $cc -E using a wrapper..."
3807                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3808                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3809                 then
3810                         echo "Yup, we can."
3811                         cppstdin="$wrapper"
3812                         cppminus='';
3813                 else
3814                         echo "Nope, we'll have to live without it..."
3815                 fi
3816                 ;;
3817         esac
3818         case "$cpprun" in
3819         "$wrapper")
3820                 cpprun=''
3821                 cpplast=''
3822                 ;;
3823         esac
3824         ;;
3825 esac
3826
3827 case "$cppstdin" in
3828 "$wrapper"|'cppstdin') ;;
3829 *) $rm -f $wrapper;;
3830 esac
3831 $rm -f testcpp.c testcpp.out
3832
3833 : Set private lib path
3834 case "$plibpth" in
3835 '') if ./mips; then
3836                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3837         fi;;
3838 esac
3839 case "$libpth" in
3840 ' ') dlist='';;
3841 '') dlist="$loclibpth $plibpth $glibpth";;
3842 *) dlist="$libpth";;
3843 esac
3844
3845 : Now check and see which directories actually exist, avoiding duplicates
3846 libpth=''
3847 for xxx in $dlist
3848 do
3849     if $test -d $xxx; then
3850                 case " $libpth " in
3851                 *" $xxx "*) ;;
3852                 *) libpth="$libpth $xxx";;
3853                 esac
3854     fi
3855 done
3856 $cat <<'EOM'
3857
3858 Some systems have incompatible or broken versions of libraries.  Among
3859 the directories listed in the question below, please remove any you
3860 know not to be holding relevant libraries, and add any that are needed.
3861 Say "none" for none.
3862
3863 EOM
3864 case "$libpth" in
3865 '') dflt='none';;
3866 *)
3867         set X $libpth
3868         shift
3869         dflt=${1+"$@"}
3870         ;;
3871 esac
3872 rp="Directories to use for library searches?"
3873 . ./myread
3874 case "$ans" in
3875 none) libpth=' ';;
3876 *) libpth="$ans";;
3877 esac
3878
3879 : compute shared library extension
3880 case "$so" in
3881 '')
3882         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3883                 dflt='sl'
3884         else
3885                 dflt='so'
3886         fi
3887         ;;
3888 *) dflt="$so";;
3889 esac
3890 $cat <<EOM
3891
3892 On some systems, shared libraries may be available.  Answer 'none' if
3893 you want to suppress searching of shared libraries for the remaining
3894 of this configuration.
3895
3896 EOM
3897 rp='What is the file extension used for shared libraries?'
3898 . ./myread
3899 so="$ans"
3900
3901 : Define several unixisms.
3902 : Hints files or command line option can be used to override them.
3903 : The convoluted testing is in case hints files set either the old
3904 : or the new name.
3905 case "$_exe" in
3906 '')     case "$exe_ext" in
3907     '') ;;
3908         *)      _exe="$exe_ext" ;;
3909         esac
3910         ;;
3911 esac
3912 case "$_a" in
3913 '')     case "$lib_ext" in
3914     '') _a='.a';;
3915         *)      _a="$lib_ext" ;;
3916         esac
3917         ;;
3918 esac
3919 case "$_o" in
3920 '') case "$obj_ext" in
3921         '')     _o='.o';;
3922         *)      _o="$obj_ext";;
3923         esac
3924         ;;
3925 esac
3926 case "$p_" in
3927 '') case "$path_sep" in
3928         '')     p_=':';;
3929         *)      p_="$path_sep";;
3930         esac
3931         ;;
3932 esac
3933 exe_ext=$_exe
3934 lib_ext=$_a
3935 obj_ext=$_o
3936 path_sep=$p_
3937
3938 : Which makefile gets called first.  This is used by make depend.
3939 case "$firstmakefile" in
3940 '') firstmakefile='makefile';;
3941 esac
3942
3943 : Looking for optional libraries
3944 echo " "
3945 echo "Checking for optional libraries..." >&4
3946 case "$libs" in
3947 ' '|'') dflt='';;
3948 *) dflt="$libs";;
3949 esac
3950 case "$libswanted" in
3951 '') libswanted='c_s';;
3952 esac
3953 for thislib in $libswanted; do
3954         
3955         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3956                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3957                 echo "Found -l$thislib (shared)."
3958                 case " $dflt " in
3959                 *"-l$thislib "*);;
3960                 *) dflt="$dflt -l$thislib";;
3961                 esac
3962         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3963                 echo "Found -l$thislib (shared)."
3964                 case " $dflt " in
3965                 *"-l$thislib "*);;
3966                 *) dflt="$dflt -l$thislib";;
3967                 esac
3968         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
3969                 echo "Found -l$thislib."
3970                 case " $dflt " in
3971                 *"-l$thislib "*);;
3972                 *) dflt="$dflt -l$thislib";;
3973                 esac
3974         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
3975                 echo "Found -l$thislib."
3976                 case " $dflt " in
3977                 *"-l$thislib "*);;
3978                 *) dflt="$dflt -l$thislib";;
3979                 esac
3980         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
3981                 echo "Found -l${thislib}_s."
3982                 case " $dflt " in
3983                 *"-l$thislib "*);;
3984                 *) dflt="$dflt -l${thislib}_s";;
3985                 esac
3986         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
3987                 echo "Found -l$thislib."
3988                 case " $dflt " in
3989                 *"-l$thislib "*);;
3990                 *) dflt="$dflt -l$thislib";;
3991                 esac
3992         else
3993                 echo "No -l$thislib."
3994         fi
3995 done
3996 set X $dflt
3997 shift
3998 dflt="$*"
3999 case "$libs" in
4000 '') dflt="$dflt";;
4001 *) dflt="$libs";;
4002 esac
4003 case "$dflt" in
4004 ' '|'') dflt='none';;
4005 esac
4006
4007 $cat <<EOM
4008  
4009 Some versions of Unix support shared libraries, which make executables smaller
4010 but make load time slightly longer.
4011
4012 On some systems, mostly System V Release 3's, the shared library is included
4013 by putting the option "-lc_s" as the last thing on the cc command line when
4014 linking.  Other systems use shared libraries by default.  There may be other
4015 libraries needed to compile $package on your machine as well.  If your system
4016 needs the "-lc_s" option, include it here.  Include any other special libraries
4017 here as well.  Say "none" for none.
4018 EOM
4019
4020 echo " "
4021 rp="Any additional libraries?"
4022 . ./myread
4023 case "$ans" in
4024 none) libs=' ';;
4025 *) libs="$ans";;
4026 esac
4027
4028 : determine optimize, if desired, or use for debug flag also
4029 case "$optimize" in
4030 ' '|$undef) dflt='none';;
4031 '') dflt='-O';;
4032 *) dflt="$optimize";;
4033 esac
4034 $cat <<EOH
4035
4036 Some C compilers have problems with their optimizers.  By default, $package
4037 compiles with the -O flag to use the optimizer.  Alternately, you might want
4038 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4039 systems).  Either flag can be specified here.  To use neither flag, specify
4040 the word "none".
4041
4042 EOH
4043 rp="What optimizer/debugger flag should be used?"
4044 . ./myread
4045 optimize="$ans"
4046 case "$optimize" in
4047 'none') optimize=" ";;
4048 esac
4049
4050 dflt=''
4051 : We will not override a previous value, but we might want to
4052 : augment a hint file
4053 case "$hint" in
4054 none|recommended)
4055         case "$gccversion" in
4056         1*) dflt='-fpcc-struct-return' ;;
4057         esac
4058         case "$optimize" in
4059         *-g*) dflt="$dflt -DDEBUGGING";;
4060         esac
4061         case "$gccversion" in
4062         2*) if test -d /etc/conf/kconfig.d &&
4063                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4064                 then
4065                         dflt="$dflt -posix"
4066                 fi
4067                 ;;
4068         esac
4069         ;;
4070 esac
4071
4072 case "$mips_type" in
4073 *BSD*|'') inclwanted="$locincpth $usrinc";;
4074 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4075 esac
4076 for thisincl in $inclwanted; do
4077         if $test -d $thisincl; then
4078                 if $test x$thisincl != x$usrinc; then
4079                         case "$dflt" in
4080                         *$thisincl*);;
4081                         *) dflt="$dflt -I$thisincl";;
4082                         esac
4083                 fi
4084         fi
4085 done
4086
4087 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4088         xxx=true;
4089 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4090         xxx=true;
4091 else
4092         xxx=false;
4093 fi;
4094 if $xxx; then
4095         case "$dflt" in
4096         *$2*);;
4097         *) dflt="$dflt -D$2";;
4098         esac;
4099 fi'
4100
4101 set signal.h LANGUAGE_C; eval $inctest
4102
4103 case "$hint" in
4104 none|recommended) dflt="$ccflags $dflt" ;;
4105 *) dflt="$ccflags";;
4106 esac
4107
4108 case "$dflt" in
4109 ''|' ') dflt=none;;
4110 esac
4111 $cat <<EOH
4112
4113 Your C compiler may want other flags.  For this question you should include
4114 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4115 but you should NOT include libraries or ld flags like -lwhatever.  If you
4116 want $package to honor its debug switch, you should include -DDEBUGGING here.
4117 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4118
4119 To use no flags, specify the word "none".
4120
4121 EOH
4122 set X $dflt
4123 shift
4124 dflt=${1+"$@"}
4125 rp="Any additional cc flags?"
4126 . ./myread
4127 case "$ans" in
4128 none) ccflags='';;
4129 *) ccflags="$ans";;
4130 esac
4131
4132 : the following weeds options from ccflags that are of no interest to cpp
4133 cppflags="$ccflags"
4134 case "$gccversion" in
4135 1*) cppflags="$cppflags -D__GNUC__"
4136 esac
4137 case "$mips_type" in
4138 '');;
4139 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4140 esac
4141 case "$cppflags" in
4142 '');;
4143 *)
4144         echo " "
4145         echo "Let me guess what the preprocessor flags are..." >&4
4146         set X $cppflags
4147         shift
4148         cppflags=''
4149         $cat >cpp.c <<'EOM'
4150 #define BLURFL foo
4151
4152 BLURFL xx LFRULB
4153 EOM
4154         previous=''
4155         for flag in $*
4156         do
4157                 case "$flag" in
4158                 -*) ftry="$flag";;
4159                 *) ftry="$previous $flag";;
4160                 esac
4161                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4162                         >cpp1.out 2>/dev/null && \
4163                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4164                         >cpp2.out 2>/dev/null && \
4165                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4166                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4167                 then
4168                         cppflags="$cppflags $ftry"
4169                         previous=''
4170                 else
4171                         previous="$flag"
4172                 fi
4173         done
4174         set X $cppflags
4175         shift
4176         cppflags=${1+"$@"}
4177         case "$cppflags" in
4178         *-*)  echo "They appear to be: $cppflags";;
4179         esac
4180         $rm -f cpp.c cpp?.out
4181         ;;
4182 esac
4183
4184 : flags used in final linking phase
4185 case "$ldflags" in
4186 '') if ./venix; then
4187                 dflt='-i -z'
4188         else
4189                 dflt=''
4190         fi
4191         case "$ccflags" in
4192         *-posix*) dflt="$dflt -posix" ;;
4193         esac
4194         ;;
4195 *) dflt="$ldflags";;
4196 esac
4197
4198 : Try to guess additional flags to pick up local libraries.
4199 for thislibdir in $libpth; do
4200         case " $loclibpth " in
4201         *" $thislibdir "*)
4202                 case "$dflt " in 
4203                 *"-L$thislibdir "*) ;;
4204                 *)  dflt="$dflt -L$thislibdir" ;;
4205                 esac
4206                 ;;
4207         esac
4208 done
4209
4210 case "$dflt" in
4211 '') dflt='none' ;;
4212 esac
4213
4214 $cat <<EOH
4215
4216 Your C linker may need flags.  For this question you should
4217 include -L/whatever and any other flags used by the C linker, but you
4218 should NOT include libraries like -lwhatever.
4219
4220 Make sure you include the appropriate -L/path flags if your C linker
4221 does not normally search all of the directories you specified above,
4222 namely
4223         $libpth
4224 To use no flags, specify the word "none".
4225
4226 EOH
4227
4228 rp="Any additional ld flags (NOT including libraries)?"
4229 . ./myread
4230 case "$ans" in
4231 none) ldflags='';;
4232 *) ldflags="$ans";;
4233 esac
4234 rmlist="$rmlist pdp11"
4235
4236 : coherency check
4237 echo " "
4238 echo "Checking your choice of C compiler and flags for coherency..." >&4
4239 $cat > try.c <<'EOF'
4240 #include <stdio.h>
4241 int main() { printf("Ok\n"); exit(0); }
4242 EOF
4243 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4244 shift
4245 $cat >try.msg <<'EOM'
4246 I've tried to compile and run the following simple program:
4247
4248 EOM
4249 $cat try.c >> try.msg
4250
4251 $cat >> try.msg <<EOM
4252
4253 I used the command:
4254
4255         $*
4256         ./try
4257
4258 and I got the following output:
4259
4260 EOM
4261 dflt=y
4262 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4263         if sh -c './try' >>try.msg 2>&1; then
4264                 xxx=`./try`
4265                 case "$xxx" in
4266                 "Ok") dflt=n ;;
4267                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4268                         case " $libs " in
4269                         *" -lsfio "*)
4270                                 cat >> try.msg <<'EOQS'
4271 If $libs contains -lsfio, and sfio is mis-configured, then it
4272 sometimes (apparently) runs and exits with a 0 status, but with no
4273 output!  It may have to do with sfio's use of _exit vs. exit.
4274
4275 EOQS
4276                                 rp="You have a big problem.  Shall I abort Configure"
4277                                 dflt=y
4278                                 ;;
4279                         esac
4280                         ;;
4281                 esac
4282         else
4283                 echo "The program compiled OK, but exited with status $?." >>try.msg
4284                 rp="You have a problem.  Shall I abort Configure"
4285                 dflt=y
4286         fi
4287 else
4288         echo "I can't compile the test program." >>try.msg
4289         rp="You have a BIG problem.  Shall I abort Configure"
4290         dflt=y
4291 fi
4292 case "$dflt" in
4293 y)
4294         $cat try.msg >&4
4295         case "$knowitall" in
4296         '')
4297                 echo "(The supplied flags or libraries might be incorrect.)"
4298                 ;;
4299         *) dflt=n;;
4300         esac
4301         echo " "
4302         . ./myread
4303         case "$ans" in
4304         n*|N*) ;;
4305         *)      echo "Ok.  Stopping Configure." >&4
4306                 exit 1
4307                 ;;
4308         esac
4309         ;;
4310 n) echo "OK, that should do.";;
4311 esac
4312 $rm -f try try.* core
4313
4314 : determine filename position in cpp output
4315 echo " "
4316 echo "Computing filename position in cpp output for #include directives..." >&4
4317 echo '#include <stdio.h>' > foo.c
4318 $cat >fieldn <<EOF
4319 $startsh
4320 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4321 $grep '^[       ]*#.*stdio\.h' | \
4322 while read cline; do
4323         pos=1
4324         set \$cline
4325         while $test \$# -gt 0; do
4326                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4327                         echo "\$pos"
4328                         exit 0
4329                 fi
4330                 shift
4331                 pos=\`expr \$pos + 1\`
4332         done
4333 done
4334 EOF
4335 chmod +x fieldn
4336 fieldn=`./fieldn`
4337 $rm -f foo.c fieldn
4338 case $fieldn in
4339 '') pos='???';;
4340 1) pos=first;;
4341 2) pos=second;;
4342 3) pos=third;;
4343 *) pos="${fieldn}th";;
4344 esac
4345 echo "Your cpp writes the filename in the $pos field of the line."
4346
4347 : locate header file
4348 $cat >findhdr <<EOF
4349 $startsh
4350 wanted=\$1
4351 name=''
4352 for usrincdir in $usrinc
4353 do
4354         if test -f \$usrincdir/\$wanted; then
4355                 echo "\$usrincdir/\$wanted"
4356                 exit 0
4357         fi
4358 done
4359 awkprg='{ print \$$fieldn }'
4360 echo "#include <\$wanted>" > foo\$\$.c
4361 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4362 $grep "^[       ]*#.*\$wanted" | \
4363 while read cline; do
4364         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4365         case "\$name" in
4366         *[/\\\\]\$wanted) echo "\$name"; exit 0;;
4367         *[\\\\/]\$wanted) echo "\$name"; exit 0;;
4368         *) name='';;
4369         esac;
4370 done;
4371 $rm -f foo\$\$.c;
4372 case "\$name" in
4373 '') exit 1;;
4374 esac
4375 EOF
4376 chmod +x findhdr
4377
4378 : define an alternate in-header-list? function
4379 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4380 cont=true; xxf="echo \"<\$1> found.\" >&4";
4381 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4382 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4383 esac;
4384 case $# in 4) instead=instead;; *) instead="at last";; esac;
4385 while $test "$cont"; do
4386         xxx=`./findhdr $1`
4387         var=$2; eval "was=\$$2";
4388         if $test "$xxx" && $test -r "$xxx";
4389         then eval $xxf;
4390         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4391                 cont="";
4392         else eval $xxnf;
4393         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4394         set $yyy; shift; shift; yyy=$@;
4395         case $# in 0) cont="";;
4396         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4397                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4398         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4399                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4400         esac;
4401 done;
4402 while $test "$yyy";
4403 do set $yyy; var=$2; eval "was=\$$2";
4404         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4405         set $yyy; shift; shift; yyy=$@;
4406 done'
4407
4408 : see if this is a malloc.h system
4409 set malloc.h i_malloc
4410 eval $inhdr
4411
4412 : see if stdlib is available
4413 set stdlib.h i_stdlib
4414 eval $inhdr
4415
4416 : determine which malloc to compile in
4417 echo " "
4418 case "$usemymalloc" in
4419 ''|[yY]*|true|$define)  dflt='y' ;;
4420 *)      dflt='n' ;;
4421 esac
4422 rp="Do you wish to attempt to use the malloc that comes with $package?"
4423 . ./myread
4424 usemymalloc="$ans"
4425 case "$ans" in
4426 y*|true)
4427         usemymalloc='y'
4428         mallocsrc='malloc.c'
4429         mallocobj="malloc$_o"
4430         d_mymalloc="$define"
4431         case "$libs" in
4432         *-lmalloc*)
4433                 : Remove malloc from list of libraries to use
4434                 echo "Removing unneeded -lmalloc from library list" >&4
4435                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4436                 shift
4437                 libs="$*"
4438                 echo "libs = $libs" >&4
4439                 ;;
4440         esac
4441         ;;
4442 *)
4443         usemymalloc='n'
4444         mallocsrc=''
4445         mallocobj=''
4446         d_mymalloc="$undef"
4447         ;;
4448 esac
4449
4450 : compute the return types of malloc and free
4451 echo " "
4452 $cat >malloc.c <<END
4453 #$i_malloc I_MALLOC
4454 #$i_stdlib I_STDLIB
4455 #include <stdio.h>
4456 #include <sys/types.h>
4457 #ifdef I_MALLOC
4458 #include <malloc.h>
4459 #endif
4460 #ifdef I_STDLIB
4461 #include <stdlib.h>
4462 #endif
4463 #ifdef TRY_MALLOC
4464 void *malloc();
4465 #endif
4466 #ifdef TRY_FREE
4467 void free();
4468 #endif
4469 END
4470 case "$malloctype" in
4471 '')
4472         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4473                 malloctype='void *'
4474         else
4475                 malloctype='char *'
4476         fi
4477         ;;
4478 esac
4479 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4480
4481 case "$freetype" in
4482 '')
4483         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4484                 freetype='void'
4485         else
4486                 freetype='int'
4487         fi
4488         ;;
4489 esac
4490 echo "Your system uses $freetype free(), it would seem." >&4
4491 $rm -f malloc.[co]
4492 : Cruising for prototypes
4493 echo " "
4494 echo "Checking out function prototypes..." >&4
4495 $cat >prototype.c <<'EOCP'
4496 int main(int argc, char *argv[]) {
4497         exit(0);}
4498 EOCP
4499 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4500         echo "Your C compiler appears to support function prototypes."
4501         val="$define"
4502 else
4503         echo "Your C compiler doesn't seem to understand function prototypes."
4504         val="$undef"
4505 fi
4506 set prototype
4507 eval $setvar
4508 $rm -f prototype*
4509
4510 case "$prototype" in
4511 "$define") ;;
4512 *)      ansi2knr='ansi2knr'
4513         echo " "
4514         cat <<EOM >&4
4515
4516 $me:  FATAL ERROR:
4517 This version of $package can only be compiled by a compiler that 
4518 understands function prototypes.  Unfortunately, your C compiler 
4519         $cc $ccflags
4520 doesn't seem to understand them.  Sorry about that.
4521
4522 If GNU cc is available for your system, perhaps you could try that instead.  
4523
4524 Eventually, we hope to support building Perl with pre-ANSI compilers.
4525 If you would like to help in that effort, please contact <perlbug@perl.org>.
4526
4527 Aborting Configure now.
4528 EOM
4529         exit 2
4530         ;;
4531 esac
4532
4533 : determine where public executables go
4534 echo " "
4535 set dflt bin bin
4536 eval $prefixit
4537 fn=d~
4538 rp='Pathname where the public executables will reside?'
4539 . ./getfile
4540 if $test "X$ansexp" != "X$binexp"; then
4541         installbin=''
4542 fi
4543 bin="$ans"
4544 binexp="$ansexp"
4545 if $afs; then
4546         $cat <<EOM
4547
4548 Since you are running AFS, I need to distinguish the directory in which
4549 executables reside from the directory in which they are installed (and from
4550 which they are presumably copied to the former directory by occult means).
4551
4552 EOM
4553         case "$installbin" in
4554         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4555         *) dflt="$installbin";;
4556         esac
4557         fn=de~
4558         rp='Where will public executables be installed?'
4559         . ./getfile
4560         installbin="$ans"
4561 else
4562         installbin="$binexp"
4563 fi
4564
4565 : determine whether to install perl also as /usr/bin/perl
4566
4567 echo " "
4568 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4569         $cat <<EOM
4570 Many scripts expect to perl to be installed as /usr/bin/perl.
4571 I can install the perl you are about to compile also as /usr/bin/perl
4572 (in addition to $installbin/perl).
4573 EOM
4574         case "$installusrbinperl" in
4575         "$undef"|[nN]*) dflt='n';;
4576         *)              dflt='y';;
4577         esac
4578         rp="Do you want to install perl as /usr/bin/perl?"
4579         . ./myread
4580         case "$ans" in
4581         [yY]*)  val="$define";;
4582         *)      val="$undef" ;;
4583         esac
4584 else
4585         val="$undef"
4586 fi
4587 set installusrbinperl
4588 eval $setvar
4589
4590 : define a shorthand compile call
4591 compile='
4592 mc_file=$1;
4593 shift;
4594 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4595 : define a shorthand compile call for compilations that should be ok.
4596 compile_ok='
4597 mc_file=$1;
4598 shift;
4599 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4600
4601 echo " "
4602 echo "Checking for GNU C Library..." >&4
4603 cat >gnulibc.c <<EOM
4604 #include <stdio.h>
4605 int main()
4606 {
4607 #ifdef __GLIBC__
4608     exit(0);
4609 #else
4610     exit(1);
4611 #endif
4612 }
4613 EOM
4614 set gnulibc
4615 if eval $compile_ok && ./gnulibc; then
4616         val="$define"
4617         echo "You are using the GNU C Library"
4618 else
4619         val="$undef"
4620         echo "You are not using the GNU C Library"
4621 fi
4622 $rm -f gnulibc*
4623 set d_gnulibc
4624 eval $setvar
4625
4626 : see if nm is to be used to determine whether a symbol is defined or not
4627 case "$usenm" in
4628 '')
4629         dflt=''
4630         case "$d_gnulibc" in
4631         "$define")
4632                 echo " "
4633                 echo "nm probably won't work on the GNU C Library." >&4
4634                 dflt=n
4635                 ;;
4636         esac
4637         case "$dflt" in
4638         '') 
4639                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4640                         echo " "
4641                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4642                         echo "'nm' won't be sufficient on this sytem." >&4
4643                         dflt=n
4644                 fi
4645                 ;;
4646         esac
4647         case "$dflt" in
4648         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4649                 if $test $dflt -gt 20; then
4650                         dflt=y
4651                 else
4652                         dflt=n
4653                 fi
4654                 ;;
4655         esac
4656         ;;
4657 *)
4658         case "$usenm" in
4659         true|$define) dflt=y;;
4660         *) dflt=n;;
4661         esac
4662         ;;
4663 esac
4664 $cat <<EOM
4665
4666 I can use $nm to extract the symbols from your C libraries. This
4667 is a time consuming task which may generate huge output on the disk (up
4668 to 3 megabytes) but that should make the symbols extraction faster. The
4669 alternative is to skip the 'nm' extraction part and to compile a small
4670 test program instead to determine whether each symbol is present. If
4671 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4672 this may be the best solution.
4673
4674 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4675
4676 EOM
4677 rp="Shall I use $nm to extract C symbols from the libraries?"
4678 . ./myread
4679 case "$ans" in
4680 [Nn]*) usenm=false;;
4681 *) usenm=true;;
4682 esac
4683
4684 runnm=$usenm
4685 case "$reuseval" in
4686 true) runnm=false;;
4687 esac
4688
4689 : nm options which may be necessary
4690 case "$nm_opt" in
4691 '') if $test -f /mach_boot; then
4692                 nm_opt=''       # Mach
4693         elif $test -d /usr/ccs/lib; then
4694                 nm_opt='-p'     # Solaris (and SunOS?)
4695         elif $test -f /dgux; then
4696                 nm_opt='-p'     # DG-UX
4697         elif $test -f /lib64/rld; then
4698                 nm_opt='-p'     # 64-bit Irix
4699         else
4700                 nm_opt=''
4701         fi;;
4702 esac
4703
4704 : nm options which may be necessary for shared libraries but illegal
4705 : for archive libraries.  Thank you, Linux.
4706 case "$nm_so_opt" in
4707 '')     case "$myuname" in
4708         *linux*)
4709                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4710                         nm_so_opt='--dynamic'
4711                 fi
4712                 ;;
4713         esac
4714         ;;
4715 esac
4716
4717 case "$runnm" in
4718 true)
4719 : get list of predefined functions in a handy place
4720 echo " "
4721 case "$libc" in
4722 '') libc=unknown
4723         case "$libs" in
4724         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4725         esac
4726         ;;
4727 esac
4728 libnames='';
4729 case "$libs" in
4730 '') ;;
4731 *)  for thislib in $libs; do
4732         case "$thislib" in
4733         -lc|-lc_s)
4734                 : Handle C library specially below.
4735                 ;;
4736         -l*)
4737                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4738                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4739                         :
4740                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4741                         :
4742                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4743                         :
4744                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4745                         :
4746                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4747                         :
4748                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4749                         :
4750                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4751                         :
4752                 else
4753                         try=''
4754                 fi
4755                 libnames="$libnames $try"
4756                 ;;
4757         *) libnames="$libnames $thislib" ;;
4758         esac
4759         done
4760         ;;
4761 esac
4762 xxx=normal
4763 case "$libc" in
4764 unknown)
4765         set /lib/libc.$so
4766         for xxx in $libpth; do
4767                 $test -r $1 || set $xxx/libc.$so
4768                 : The messy sed command sorts on library version numbers.
4769                 $test -r $1 || \
4770                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4771                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4772                                 h
4773                                 s/[0-9][0-9]*/0000&/g
4774                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4775                                 G
4776                                 s/\n/ /' | \
4777                          sort | $sed -e 's/^.* //'`
4778                 eval set \$$#
4779         done
4780         $test -r $1 || set /usr/ccs/lib/libc.$so
4781         $test -r $1 || set /lib/libsys_s$_a
4782         ;;
4783 *)
4784         set blurfl
4785         ;;
4786 esac
4787 if $test -r "$1"; then
4788         echo "Your (shared) C library seems to be in $1."
4789         libc="$1"
4790 elif $test -r /lib/libc && $test -r /lib/clib; then
4791         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4792         xxx=apollo
4793         libc='/lib/clib /lib/libc'
4794         if $test -r /lib/syslib; then
4795                 echo "(Your math library is in /lib/syslib.)"
4796                 libc="$libc /lib/syslib"
4797         fi
4798 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4799         echo "Your C library seems to be in $libc, as you said before."
4800 elif $test -r $incpath/usr/lib/libc$_a; then
4801         libc=$incpath/usr/lib/libc$_a;
4802         echo "Your C library seems to be in $libc.  That's fine."
4803 elif $test -r /lib/libc$_a; then
4804         libc=/lib/libc$_a;
4805         echo "Your C library seems to be in $libc.  You're normal."
4806 else
4807         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4808                 :
4809         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4810                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4811         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4812                 :
4813         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4814                 :
4815         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4816                 :
4817         else
4818                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4819         fi
4820         if $test -r "$tans"; then
4821                 echo "Your C library seems to be in $tans, of all places."
4822                 libc=$tans
4823         else
4824                 libc='blurfl'
4825         fi
4826 fi
4827 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4828         dflt="$libc"
4829         cat <<EOM
4830
4831 If the guess above is wrong (which it might be if you're using a strange
4832 compiler, or your machine supports multiple models), you can override it here.
4833
4834 EOM
4835 else
4836         dflt=''
4837         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4838         cat >&4 <<EOM
4839 I can't seem to find your C library.  I've looked in the following places:
4840
4841 EOM
4842         $sed 's/^/      /' libpath
4843         cat <<EOM
4844
4845 None of these seems to contain your C library. I need to get its name...
4846
4847 EOM
4848 fi
4849 fn=f
4850 rp='Where is your C library?'
4851 . ./getfile
4852 libc="$ans"
4853
4854 echo " "
4855 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4856 set X `cat libnames`
4857 shift
4858 xxx=files
4859 case $# in 1) xxx=file; esac
4860 echo "Extracting names from the following $xxx for later perusal:" >&4
4861 echo " "
4862 $sed 's/^/      /' libnames >&4
4863 echo " "
4864 $echo $n "This may take a while...$c" >&4
4865
4866 for file in $*; do
4867         case $file in
4868         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4869         *) $nm $nm_opt $file 2>/dev/null;;
4870         esac
4871 done >libc.tmp
4872
4873 $echo $n ".$c"
4874 $grep fprintf libc.tmp > libc.ptf
4875 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4876 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4877 xxx='[ADTSIW]'
4878 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4879         eval $xscan;\
4880         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4881                 eval $xrun
4882 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4883         eval $xscan;\
4884         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4885                 eval $xrun
4886 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4887         eval $xscan;\
4888         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4889                 eval $xrun
4890 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4891         eval $xscan;\
4892         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4893                 eval $xrun
4894 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4895         eval $xscan;\
4896         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4897                 eval $xrun
4898 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4899         eval $xscan;\
4900         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4901                 eval $xrun
4902 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4903                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4904         eval $xscan;\
4905         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4906                 eval $xrun
4907 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4908         eval $xscan;\
4909         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4910                 eval $xrun
4911 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4912         eval $xscan;\
4913         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4914                 eval $xrun
4915 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4916         eval $xscan;\
4917         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4918                 eval $xrun
4919 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4920         eval $xscan;\
4921         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4922                 eval $xrun
4923 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4924         eval $xscan;\
4925         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4926                 eval $xrun
4927 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4928         eval $xscan;\
4929         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4930                 eval $xrun
4931 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4932         eval $xscan;\
4933         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4934                 eval $xrun
4935 else
4936         $nm -p $* 2>/dev/null >libc.tmp
4937         $grep fprintf libc.tmp > libc.ptf
4938         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4939                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4940         then
4941                 nm_opt='-p'
4942                 eval $xrun
4943         else
4944                 echo " "
4945                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4946                 com=''
4947                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4948                         for thisname in $libnames $libc; do
4949                                 $ar t $thisname >>libc.tmp
4950                         done
4951                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4952                         echo "Ok." >&4
4953                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4954                         # Repeat libc to extract forwarders to DLL entries too
4955                         for thisname in $libnames $libc; do
4956                                 $ar tv $thisname >>libc.tmp
4957                                 # Revision 50 of EMX has bug in $ar.
4958                                 # it will not extract forwarders to DLL entries
4959                                 # Use emximp which will extract exactly them.
4960                                 emximp -o tmp.imp $thisname \
4961                                     2>/dev/null && \
4962                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4963                                     < tmp.imp >>libc.tmp
4964                                 $rm tmp.imp
4965                         done
4966                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
4967                         echo "Ok." >&4
4968                 else
4969                         echo "$ar didn't seem to work right." >&4
4970                         echo "Maybe this is a Cray...trying bld instead..." >&4
4971                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
4972                         then
4973                                 for thisname in $libnames; do
4974                                         bld t $libnames | \
4975                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
4976                                         $ar t $thisname >>libc.tmp
4977                                 done
4978                                 echo "Ok." >&4
4979                         else
4980                                 echo "That didn't work either.  Giving up." >&4
4981                                 exit 1
4982                         fi
4983                 fi
4984         fi
4985 fi
4986 nm_extract="$com"
4987 if $test -f /lib/syscalls.exp; then
4988         echo " "
4989         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
4990         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
4991 fi
4992 ;;
4993 esac
4994 $rm -f libnames libpath
4995
4996 : see if dld is available
4997 set dld.h i_dld
4998 eval $inhdr
4999
5000 : is a C symbol defined?
5001 csym='tlook=$1;
5002 case "$3" in
5003 -v) tf=libc.tmp; tc=""; tdc="";;
5004 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5005 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5006 esac;
5007 tx=yes;
5008 case "$reuseval-$4" in
5009 true-) ;;
5010 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5011 esac;
5012 case "$tx" in
5013 yes)
5014         case "$runnm" in
5015         true)
5016                 if $contains $tlook $tf >/dev/null 2>&1;
5017                 then tval=true;
5018                 else tval=false;
5019                 fi;;
5020         *)
5021                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5022                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5023                 then tval=true;
5024                 else tval=false;
5025                 fi;
5026                 $rm -f t t.c;;
5027         esac;;
5028 *)
5029         case "$tval" in
5030         $define) tval=true;;
5031         *) tval=false;;
5032         esac;;
5033 esac;
5034 eval "$2=$tval"'
5035
5036 : define an is-in-libc? function
5037 inlibc='echo " "; td=$define; tu=$undef;
5038 sym=$1; var=$2; eval "was=\$$2";
5039 tx=yes;
5040 case "$reuseval$was" in
5041 true) ;;
5042 true*) tx=no;;
5043 esac;
5044 case "$tx" in
5045 yes)
5046         set $sym tres -f;
5047         eval $csym;
5048         case "$tres" in
5049         true)
5050                 echo "$sym() found." >&4;
5051                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5052         *)
5053                 echo "$sym() NOT found." >&4;
5054                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5055         esac;;
5056 *)
5057         case "$was" in
5058         $define) echo "$sym() found." >&4;;
5059         *) echo "$sym() NOT found." >&4;;
5060         esac;;
5061 esac'
5062
5063 : see if dlopen exists
5064 xxx_runnm="$runnm"
5065 runnm=false
5066 set dlopen d_dlopen
5067 eval $inlibc
5068 runnm="$xxx_runnm"
5069
5070 : determine which dynamic loading, if any, to compile in
5071 echo " "
5072 dldir="ext/DynaLoader"
5073 case "$usedl" in
5074 $define|y|true)
5075         dflt='y'
5076         usedl="$define"
5077         ;;
5078 $undef|n|false)
5079         dflt='n'
5080         usedl="$undef"
5081         ;;
5082 *) 
5083         dflt='n'
5084         case "$d_dlopen" in
5085             $define) dflt='y' ;;
5086         esac
5087         case "$i_dld" in
5088             $define) dflt='y' ;;
5089         esac
5090         : Does a dl_xxx.xs file exist for this operating system
5091         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5092         ;;
5093 esac
5094 rp="Do you wish to use dynamic loading?"
5095 . ./myread
5096 usedl="$ans"
5097 case "$ans" in
5098 y*) usedl="$define"
5099         case "$dlsrc" in
5100         '')
5101                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5102                         dflt="$dldir/dl_${osname}.xs"
5103                 elif $test "$d_dlopen" = "$define" ; then
5104                         dflt="$dldir/dl_dlopen.xs"
5105                 elif $test "$i_dld" = "$define" ; then
5106                         dflt="$dldir/dl_dld.xs"
5107                 else
5108                         dflt=''
5109                 fi
5110                 ;;
5111         *)      dflt="$dldir/$dlsrc"
5112                 ;;
5113         esac
5114     echo "The following dynamic loading files are available:"
5115         : Can not go over to $dldir because getfile has path hard-coded in.
5116         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5117         rp="Source file to use for dynamic loading"
5118         fn="fne"
5119         # XXX This getfile call will fail the existence check if you try 
5120         # building away from $src (this is not supported yet).
5121         . ./getfile
5122         usedl="$define"
5123         : emulate basename
5124         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5125
5126         $cat << EOM
5127
5128 Some systems may require passing special flags to $cc -c to
5129 compile modules that will be used to create a shared library.
5130 To use no flags, say "none".
5131
5132 EOM
5133     case "$cccdlflags" in
5134     '') case "$gccversion" in
5135                 '') case "$osname" in
5136                         hpux)   dflt='+z' ;;
5137                         next)   dflt='none' ;;
5138                         irix*)  dflt='-KPIC' ;;
5139                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5140                         sunos)  dflt='-pic' ;;
5141                         *)      dflt='none' ;;
5142                     esac
5143                         ;;
5144                 *)  case "$osname" in
5145                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5146                         *)      dflt='-fpic' ;;
5147                     esac ;;
5148             esac ;;
5149         ' ') dflt='none' ;;
5150     *)  dflt="$cccdlflags" ;;
5151     esac
5152     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5153     . ./myread
5154     case "$ans" in
5155     none) cccdlflags=' ' ;;
5156     *) cccdlflags="$ans" ;;
5157     esac
5158
5159     cat << EOM
5160
5161 Some systems use ld to create libraries that can be dynamically loaded,
5162 while other systems (such as those using ELF) use $cc.
5163
5164 EOM
5165         case "$ld" in
5166         '')     $cat >try.c <<'EOM'
5167 /* Test for whether ELF binaries are produced */
5168 #include <fcntl.h>
5169 #include <stdlib.h>
5170 int main() {
5171         char b[4];
5172         int i = open("a.out",O_RDONLY);
5173         if(i == -1) 
5174                 exit(1); /* fail */
5175         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5176                 exit(0); /* succeed (yes, it's ELF) */
5177         else
5178                 exit(1); /* fail */
5179 }
5180 EOM
5181                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5182                         cat <<EOM
5183 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5184 EOM
5185                         dflt="$cc"
5186                 else
5187                         echo "I'll use ld to build dynamic libraries."
5188                         dflt='ld'
5189                 fi
5190                 rm -f try.c a.out
5191                 ;;
5192         *)      dflt="$ld"
5193                 ;;
5194         esac
5195
5196     rp="What command should be used to create dynamic libraries?"
5197     . ./myread
5198         ld="$ans"
5199
5200     cat << EOM
5201
5202 Some systems may require passing special flags to $ld to create a
5203 library that can be dynamically loaded.  If your ld flags include
5204 -L/other/path options to locate libraries outside your loader's normal
5205 search path, you may need to specify those -L options here as well.  To
5206 use no flags, say "none".
5207
5208 EOM
5209     case "$lddlflags" in
5210     '') case "$osname" in
5211                         beos) dflt='-nostart' ;;
5212                         hpux)  dflt='-b' ;;
5213                         linux|irix*)    dflt='-shared' ;;
5214                         next)  dflt='none' ;;
5215                         solaris) dflt='-G' ;;
5216                         sunos) dflt='-assert nodefinitions' ;;
5217                         svr4*|esix*) dflt="-G $ldflags" ;;
5218                 *)     dflt='none' ;;
5219                         esac
5220                         ;;
5221     *) dflt="$lddlflags" ;;
5222     esac
5223
5224         : Try to guess additional flags to pick up local libraries.
5225         : Be careful not to append to a plain 'none'
5226         case "$dflt" in
5227         none) dflt='' ;;
5228         esac
5229         for thisflag in $ldflags; do
5230                 case "$thisflag" in
5231                 -L*)
5232                         case " $dflt " in
5233                         *" $thisflag "*) ;;
5234                         *) dflt="$dflt $thisflag" ;;
5235                         esac
5236                         ;;
5237                 esac
5238         done
5239
5240         case "$dflt" in
5241         ''|' ') dflt='none' ;;
5242         esac
5243
5244     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5245     . ./myread
5246     case "$ans" in
5247     none) lddlflags=' ' ;;
5248     *) lddlflags="$ans" ;;
5249     esac
5250
5251         cat <<EOM
5252
5253 Some systems may require passing special flags to $cc to indicate that
5254 the resulting executable will use dynamic linking.  To use no flags,
5255 say "none".
5256
5257 EOM
5258     case "$ccdlflags" in
5259     '') case "$osname" in
5260                 hpux)   dflt='-Wl,-E' ;;
5261                 linux)  dflt='-rdynamic' ;;
5262                 next)   dflt='none' ;;
5263                 sunos)  dflt='none' ;;
5264                 *)      dflt='none' ;;
5265             esac ;;
5266     ' ')  dflt='none' ;;
5267     *)  dflt="$ccdlflags" ;;
5268     esac
5269     rp="Any special flags to pass to $cc to use dynamic loading?"
5270     . ./myread
5271     case "$ans" in
5272     none) ccdlflags=' ' ;;
5273     *) ccdlflags="$ans" ;;
5274     esac
5275     ;;
5276 *)  usedl="$undef"
5277         ld='ld'
5278     dlsrc='dl_none.xs'
5279     lddlflags=''
5280     ccdlflags=''
5281     ;;
5282 esac
5283
5284 also=''
5285 case "$usedl" in
5286 $undef)
5287         # No dynamic loading being used, so don't bother even to prompt.
5288         useshrplib='false'
5289         ;;
5290 *)      case "$useshrplib" in
5291         '')     case "$osname" in
5292                 svr4*|dgux|dynixptx|esix|powerux|beos)
5293                         dflt=y
5294                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5295                         ;;
5296                 next*)
5297                         case "$osvers" in
5298                         4*)     dflt=y
5299                                 also='Building a shared libperl is needed for MAB support.'
5300                                 ;;
5301                         *)      dflt=n
5302                                 ;;
5303                         esac
5304                         ;;
5305                 *)      dflt=n
5306                         ;;
5307                 esac
5308                 ;;
5309         $define|true|[Yy]*)
5310                 dflt=y
5311                 ;;
5312         *)      dflt=n
5313                 ;;
5314         esac
5315         $cat << EOM
5316
5317 The perl executable is normally obtained by linking perlmain.c with
5318 libperl${_a}, any static extensions (usually just DynaLoader), and
5319 any other libraries needed on this system (such as -lm, etc.).  Since
5320 your system supports dynamic loading, it is probably possible to build
5321 a shared libperl.$so.  If you will have more than one executable linked
5322 to libperl.$so, this will significantly reduce the size of each
5323 executable, but it may have a noticeable affect on performance.  The
5324 default is probably sensible for your system.
5325 $also
5326
5327 EOM
5328         rp="Build a shared libperl.$so (y/n)"
5329         . ./myread
5330         case "$ans" in
5331         true|$define|[Yy]*)
5332                 useshrplib='true'
5333                 # Why does next4 have to be so different?
5334                 case "${osname}${osvers}" in
5335                 next4*|rhapsody*)
5336                         xxx='DYLD_LIBRARY_PATH' ;;
5337                 os2*)   xxx='' ;; # Nothing special needed.
5338                 beos*)  xxx='' ;;
5339                 *)              xxx='LD_LIBRARY_PATH' ;;
5340                 esac
5341                 ;;
5342         *)      useshrplib='false' ;;
5343         esac
5344         ;;
5345 esac
5346
5347 case "$useshrplib" in
5348 true)
5349         case "$libperl" in
5350         '')
5351                 # Figure out a good name for libperl.so.  Since it gets stored in
5352                 # a version-specific architecture-dependent library, the version
5353                 # number isn't really that important, except for making cc/ld happy.
5354                 #
5355                 # A name such as libperl.so.3.1
5356                 majmin="libperl.$so.$patchlevel.$subversion"
5357                 # A name such as libperl.so.301
5358                 majonly=`echo $patchlevel $subversion |
5359                         $awk '{printf "%d%02d", $1, $2}'`
5360                 majonly=libperl.$so.$majonly
5361                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5362                 # rely on figuring it out from the naming of libc.
5363                 case "${osname}${osvers}" in
5364                 next4*)
5365                         dflt=libperl.5.$so
5366                         # XXX How handle the --version stuff for MAB?
5367                         ;;
5368                 linux*)  # ld won't link with a bare -lperl otherwise.
5369                         dflt=libperl.$so
5370                         ;;
5371                 *)      # Try to guess based on whether libc has major.minor.
5372                         case "$libc" in
5373                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5374                         *libc.$so.[0-9]*) dflt=$majonly ;;
5375                         *)      dflt=libperl.$so ;;
5376                         esac
5377                         ;;
5378                 esac
5379                 ;;
5380         *)      dflt=$libperl
5381                 ;;
5382         esac
5383         cat << EOM
5384
5385 I need to select a good name for the shared libperl.  If your system uses
5386 library names with major and minor numbers, then you might want something
5387 like $majmin.  Alternatively, if your system uses a single version
5388 number for shared libraries, then you might want to use $majonly.
5389 Or, your system might be quite happy with a simple libperl.$so.
5390
5391 Since the shared libperl will get installed into a version-specific
5392 architecture-dependent directory, the version number of the shared perl
5393 library probably isn't important, so the default should be o.k.
5394
5395 EOM
5396         rp='What name do you want to give to the shared libperl?'
5397         . ./myread
5398         libperl=$ans
5399         echo "Ok, I'll use $libperl"
5400         ;;
5401 *)
5402         libperl="libperl${_a}"
5403         ;;
5404 esac
5405
5406 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5407 case "$shrpdir" in
5408 '') ;;
5409 *)      $cat >&4 <<EOM
5410 WARNING:  Use of the shrpdir variable for the installation location of
5411 the shared $libperl is not supported.  It was never documented and
5412 will not work in this version.  Let me (perlbug@perl.com)
5413 know of any problems this may cause.
5414
5415 EOM
5416         case "$shrpdir" in
5417         "$archlibexp/CORE")
5418                 $cat >&4 <<EOM
5419 But your current setting of $shrpdir is
5420 the default anyway, so it's harmless.
5421 EOM
5422                 ;;
5423         *)
5424                 $cat >&4 <<EOM
5425 Further, your current attempted setting of $shrpdir
5426 conflicts with the value of $archlibexp/CORE
5427 that installperl will use.
5428 EOM
5429                 ;;
5430         esac
5431         ;;
5432 esac
5433
5434 # How will the perl executable find the installed shared $libperl?
5435 # Add $xxx to ccdlflags.
5436 # If we can't figure out a command-line option, use $shrpenv to
5437 # set env LD_RUN_PATH.  The main perl makefile uses this.
5438 shrpdir=$archlibexp/CORE
5439 xxx=''
5440 tmp_shrpenv=''
5441 if "$useshrplib"; then
5442     case "$osname" in 
5443         aix)
5444                 # We'll set it in Makefile.SH...
5445                 ;;
5446         solaris|netbsd)
5447                 xxx="-R $shrpdir"
5448                 ;;
5449         freebsd)
5450                 xxx="-Wl,-R$shrpdir"
5451                 ;;
5452         linux|irix*|dec_osf)
5453                 xxx="-Wl,-rpath,$shrpdir"
5454                 ;;
5455         next)
5456                 # next doesn't like the default...
5457                 ;;
5458         beos)
5459                 # beos doesn't like the default, either.
5460                 ;;
5461         hpux*)
5462                 # hpux doesn't like the default, either.
5463                 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
5464                 ;;
5465         *)
5466                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5467                 ;;
5468         esac
5469         case "$xxx" in
5470         '') ;;
5471         *)      
5472                 # Only add $xxx if it isn't already in ccdlflags.
5473                 case " $ccdlflags " in
5474                 *" $xxx "*)     ;;
5475                 *)      ccdlflags="$ccdlflags $xxx"
5476                         cat <<EOM >&4
5477
5478 Adding $xxx to the flags
5479 passed to $ld so that the perl executable will find the 
5480 installed shared $libperl.
5481
5482 EOM
5483                         ;;
5484                 esac
5485                 ;;
5486         esac
5487 fi
5488 # Respect a hint or command-line value.
5489 case "$shrpenv" in
5490 '') shrpenv="$tmp_shrpenv" ;;
5491 esac
5492
5493 : determine where manual pages go
5494 set man1dir man1dir none
5495 eval $prefixit
5496 $cat <<EOM
5497
5498 $spackage has manual pages available in source form.
5499 EOM
5500 case "$nroff" in
5501 nroff)
5502         echo "However, you don't have nroff, so they're probably useless to you."
5503         case "$man1dir" in
5504         '') man1dir="none";;
5505         esac;;
5506 esac
5507 echo "If you don't want the manual sources installed, answer 'none'."
5508 case "$man1dir" in
5509 ' ') dflt=none
5510         ;;
5511 '')
5512         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5513         lookpath="$lookpath $prefixexp/man/p_man/man1"
5514         lookpath="$lookpath $prefixexp/man/u_man/man1"
5515         lookpath="$lookpath $prefixexp/man/man.1"
5516         case "$sysman" in
5517         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5518         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5519         esac
5520         set dflt
5521         eval $prefixup
5522         ;;
5523 *)  dflt="$man1dir"
5524         ;;
5525 esac
5526 echo " "
5527 fn=dn+~
5528 rp="Where do the main $spackage manual pages (source) go?"
5529 . ./getfile
5530 if $test "X$man1direxp" != "X$ansexp"; then
5531         installman1dir=''
5532 fi
5533 man1dir="$ans"
5534 man1direxp="$ansexp"
5535 case "$man1dir" in
5536 '') man1dir=' '
5537         installman1dir='';;
5538 esac
5539 if $afs; then
5540         $cat <<EOM
5541
5542 Since you are running AFS, I need to distinguish the directory in which
5543 manual pages reside from the directory in which they are installed (and from
5544 which they are presumably copied to the former directory by occult means).
5545
5546 EOM
5547         case "$installman1dir" in
5548         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5549         *) dflt="$installman1dir";;
5550         esac
5551         fn=de~
5552         rp='Where will man pages be installed?'
5553         . ./getfile
5554         installman1dir="$ans"
5555 else
5556         installman1dir="$man1direxp"
5557 fi
5558
5559 : What suffix to use on installed man pages
5560
5561 case "$man1dir" in
5562 ' ')
5563         man1ext='0'
5564         ;;
5565 *)
5566         rp="What suffix should be used for the main $spackage man pages?"
5567         case "$man1ext" in
5568         '')     case "$man1dir" in
5569                 *1)  dflt=1 ;;
5570                 *1p) dflt=1p ;;
5571                 *1pm) dflt=1pm ;;
5572                 *l) dflt=l;;
5573                 *n) dflt=n;;
5574                 *o) dflt=o;;
5575                 *p) dflt=p;;
5576                 *C) dflt=C;;
5577                 *L) dflt=L;;
5578                 *L1) dflt=L1;;
5579                 *) dflt=1;;
5580                 esac
5581                 ;;
5582         *)      dflt="$man1ext";;
5583         esac
5584         . ./myread
5585         man1ext="$ans"
5586         ;;
5587 esac
5588
5589 : see if we can have long filenames
5590 echo " "
5591 rmlist="$rmlist /tmp/cf$$"
5592 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5593 first=123456789abcdef
5594 second=/tmp/cf$$/$first
5595 $rm -f $first $second
5596 if (echo hi >$first) 2>/dev/null; then
5597         if $test -f 123456789abcde; then
5598                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5599                 val="$undef"
5600         else
5601                 if (echo hi >$second) 2>/dev/null; then
5602                         if $test -f /tmp/cf$$/123456789abcde; then
5603                                 $cat <<'EOM'
5604 That's peculiar... You can have filenames longer than 14 characters, but only
5605 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5606 I shall consider your system cannot support long filenames at all.
5607 EOM
5608                                 val="$undef"
5609                         else
5610                                 echo 'You can have filenames longer than 14 characters.' >&4
5611                                 val="$define"
5612                         fi
5613                 else
5614                         $cat <<'EOM'
5615 How confusing! Some of your filesystems are sane enough to allow filenames
5616 longer than 14 characters but some others like /tmp can't even think about them.
5617 So, for now on, I shall assume your kernel does not allow them at all.
5618 EOM
5619                         val="$undef"
5620                 fi
5621         fi
5622 else
5623         $cat <<'EOM'
5624 You can't have filenames longer than 14 chars.  You can't even think about them!
5625 EOM
5626         val="$undef"
5627 fi 
5628 set d_flexfnam
5629 eval $setvar
5630 $rm -rf /tmp/cf$$ 123456789abcde*
5631
5632 : determine where library module manual pages go
5633 set man3dir man3dir none
5634 eval $prefixit
5635 $cat <<EOM
5636
5637 $spackage has manual pages for many of the library modules.
5638 EOM
5639
5640 case "$nroff" in
5641 nroff)
5642         $cat <<'EOM'
5643 However, you don't have nroff, so they're probably useless to you.
5644 EOM
5645         case "$man3dir" in
5646         '') man3dir="none";;
5647         esac;;
5648 esac
5649
5650 case "$d_flexfnam" in
5651 undef)
5652         $cat <<'EOM'
5653 However, your system can't handle the long file names like File::Basename.3. 
5654 EOM
5655         case "$man3dir" in
5656         '') man3dir="none";;
5657         esac;;
5658 esac
5659
5660 echo "If you don't want the manual sources installed, answer 'none'."
5661 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5662 case "$man3dir" in
5663 '')     case "$prefix" in 
5664         *$prog*) dflt=`echo $man1dir | 
5665                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5666         *)      dflt="$privlib/man/man3" ;;
5667         esac
5668         ;;
5669 ' ') dflt=none;;
5670 *)      dflt="$man3dir" ;;
5671 esac
5672 echo " "
5673
5674 fn=dn+~
5675 rp="Where do the $package library man pages (source) go?"
5676 . ./getfile
5677 if test "X$man3direxp" != "X$ansexp"; then
5678         installman3dir=''
5679 fi
5680
5681 man3dir="$ans"
5682 man3direxp="$ansexp"
5683 case "$man3dir" in
5684 '') man3dir=' '
5685         installman3dir='';;
5686 esac
5687 if $afs; then
5688         $cat <<EOM
5689
5690 Since you are running AFS, I need to distinguish the directory in which
5691 manual pages reside from the directory in which they are installed (and from
5692 which they are presumably copied to the former directory by occult means).
5693
5694 EOM
5695         case "$installman3dir" in
5696         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5697         *) dflt="$installman3dir";;
5698         esac
5699         fn=de~
5700         rp='Where will man pages be installed?'
5701         . ./getfile
5702         installman3dir="$ans"
5703 else
5704         installman3dir="$man3direxp"
5705 fi
5706
5707 : What suffix to use on installed man pages
5708
5709 case "$man3dir" in
5710 ' ')
5711         man3ext='0'
5712         ;;
5713 *)
5714         rp="What suffix should be used for the $package library man pages?"
5715         case "$man3ext" in
5716         '')     case "$man3dir" in
5717                 *3)  dflt=3 ;;
5718                 *3p) dflt=3p ;;
5719                 *3pm) dflt=3pm ;;
5720                 *l) dflt=l;;
5721                 *n) dflt=n;;
5722                 *o) dflt=o;;
5723                 *p) dflt=p;;
5724                 *C) dflt=C;;
5725                 *L) dflt=L;;
5726                 *L3) dflt=L3;;
5727                 *) dflt=3;;
5728                 esac
5729                 ;;
5730         *)      dflt="$man3ext";;
5731         esac
5732         . ./myread
5733         man3ext="$ans"
5734         ;;
5735 esac
5736
5737 : see if we have to deal with yellow pages, now NIS.
5738 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5739         if $test -f /usr/etc/nibindd; then
5740                 echo " "
5741                 echo "I'm fairly confident you're on a NeXT."
5742                 echo " "
5743                 rp='Do you get the hosts file via NetInfo?'
5744                 dflt=y
5745                 case "$hostcat" in
5746                 nidump*) ;;
5747                 '') ;;
5748                 *) dflt=n;;
5749                 esac
5750                 . ./myread
5751                 case "$ans" in
5752                 y*) hostcat='nidump hosts .';;
5753                 *)      case "$hostcat" in
5754                         nidump*) hostcat='';;
5755                         esac
5756                         ;;
5757                 esac
5758         fi
5759         case "$hostcat" in
5760         nidump*) ;;
5761         *)
5762                 case "$hostcat" in
5763                 *ypcat*) dflt=y;;
5764                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5765                                 dflt=y
5766                         else
5767                                 dflt=n
5768                         fi;;
5769                 *) dflt=n;;
5770                 esac
5771                 echo " "
5772                 rp='Are you getting the hosts file via yellow pages?'
5773                 . ./myread
5774                 case "$ans" in
5775                 y*) hostcat='ypcat hosts';;
5776                 *) hostcat='cat /etc/hosts';;
5777                 esac
5778                 ;;
5779         esac
5780 fi
5781 case "$hostcat" in
5782 '') hostcat='cat /etc/hosts';;
5783 esac
5784 case "$groupcat" in
5785 '') groupcat='cat /etc/group';;
5786 esac
5787 case "$passcat" in
5788 '') passcat='cat /etc/passwd';;
5789 esac
5790
5791 : now get the host name
5792 echo " "
5793 echo "Figuring out host name..." >&4
5794 case "$myhostname" in
5795 '') cont=true
5796         echo 'Maybe "hostname" will work...'
5797         if tans=`sh -c hostname 2>&1` ; then
5798                 myhostname=$tans
5799                 phostname=hostname
5800                 cont=''
5801         fi
5802         ;;
5803 *) cont='';;
5804 esac
5805 if $test "$cont"; then
5806         if ./xenix; then
5807                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5808                 if tans=`cat /etc/systemid 2>&1` ; then
5809                         myhostname=$tans
5810                         phostname='cat /etc/systemid'
5811                         echo "Whadyaknow.  Xenix always was a bit strange..."
5812                         cont=''
5813                 fi
5814         elif $test -r /etc/systemid; then
5815                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5816         fi
5817 fi
5818 if $test "$cont"; then
5819         echo 'No, maybe "uuname -l" will work...'
5820         if tans=`sh -c 'uuname -l' 2>&1` ; then
5821                 myhostname=$tans
5822                 phostname='uuname -l'
5823         else
5824                 echo 'Strange.  Maybe "uname -n" will work...'
5825                 if tans=`sh -c 'uname -n' 2>&1` ; then
5826                         myhostname=$tans
5827                         phostname='uname -n'
5828                 else
5829                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5830                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5831                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5832                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5833                         else
5834                                 case "$myhostname" in
5835                                 '') echo "Does this machine have an identity crisis or something?"
5836                                         phostname='';;
5837                                 *)
5838                                         echo "Well, you said $myhostname before..."
5839                                         phostname='echo $myhostname';;
5840                                 esac
5841                         fi
5842                 fi
5843         fi
5844 fi
5845 : you do not want to know about this
5846 set $myhostname
5847 myhostname=$1
5848
5849 : verify guess
5850 if $test "$myhostname" ; then
5851         dflt=y
5852         rp='Your host name appears to be "'$myhostname'".'" Right?"
5853         . ./myread
5854         case "$ans" in
5855         y*) ;;
5856         *) myhostname='';;
5857         esac
5858 fi
5859
5860 : bad guess or no guess
5861 while $test "X$myhostname" = X ; do
5862         dflt=''
5863         rp="Please type the (one word) name of your host:"
5864         . ./myread
5865         myhostname="$ans"
5866 done
5867
5868 : translate upper to lower if necessary
5869 case "$myhostname" in
5870 *[A-Z]*)
5871         echo "(Normalizing case in your host name)"
5872         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5873         ;;
5874 esac
5875
5876 case "$myhostname" in
5877 *.*)
5878         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5879         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5880         echo "(Trimming domain name from host name--host name is now $myhostname)"
5881         ;;
5882 *) case "$mydomain" in
5883         '')
5884                 {
5885                         test "X$hostcat" = "Xypcat hosts" &&
5886                         ypmatch "$myhostname" hosts 2>/dev/null |\
5887                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5888                         $test -s hosts
5889                 } || {
5890                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5891                                         /[       ]$myhostname[  . ]/p" > hosts
5892                 }
5893                 tmp_re="[       . ]"
5894                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5895                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5896                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5897                         hosts | $sort | $uniq | \
5898                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5899                 case `$echo X$dflt` in
5900                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5901                         dflt=.
5902                         ;;
5903                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5904                         ;;
5905                 esac
5906                 case "$dflt" in
5907                 .)
5908                         tans=`./loc resolv.conf X /etc /usr/etc`
5909                         if $test -f "$tans"; then
5910                                 echo "(Attempting domain name extraction from $tans)"
5911                                 dflt=.`$sed -n -e 's/   / /g' \
5912                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5913                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5914                                 case "$dflt" in
5915                                 .) dflt=.`$sed -n -e 's/        / /g' \
5916                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5917                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5918                                         ;;
5919                                 esac
5920                         fi
5921                         ;;
5922                 esac
5923                 case "$dflt" in
5924                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5925                         dflt=.`sh -c domainname 2>/dev/null`
5926                         case "$dflt" in
5927                         '') dflt='.';;
5928                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5929                         esac
5930                         ;;
5931                 esac
5932                 case "$dflt" in
5933                 .) echo "(Lost all hope -- silly guess then)"
5934                         dflt='.uucp'
5935                         ;;
5936                 esac
5937                 $rm -f hosts
5938                 ;;
5939         *) dflt="$mydomain";;
5940         esac;;
5941 esac
5942 echo " "
5943 rp="What is your domain name?"
5944 . ./myread
5945 tans="$ans"
5946 case "$ans" in
5947 '') ;;
5948 .*) ;;
5949 *) tans=".$tans";;
5950 esac
5951 mydomain="$tans"
5952
5953 : translate upper to lower if necessary
5954 case "$mydomain" in
5955 *[A-Z]*)
5956         echo "(Normalizing case in your domain name)"
5957         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5958         ;;
5959 esac
5960
5961 : a little sanity check here
5962 case "$phostname" in
5963 '') ;;
5964 *)
5965         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
5966         $myhostname$mydomain|$myhostname) ;;
5967         *)
5968                 case "$phostname" in
5969                 sed*)
5970                         echo "(That doesn't agree with your whoami.h file, by the way.)"
5971                         ;;
5972                 *)
5973                         echo "(That doesn't agree with your $phostname command, by the way.)"
5974                         ;;
5975                 esac
5976         ;;
5977         esac
5978         ;;
5979 esac
5980
5981 $cat <<EOM
5982
5983 I need to get your e-mail address in Internet format if possible, i.e.
5984 something like user@host.domain. Please answer accurately since I have
5985 no easy means to double check it. The default value provided below
5986 is most probably close to the reality but may not be valid from outside
5987 your organization...
5988
5989 EOM
5990 cont=x
5991 while test "$cont"; do
5992         case "$cf_email" in
5993         '') dflt="$cf_by@$myhostname$mydomain";;
5994         *) dflt="$cf_email";;
5995         esac
5996         rp='What is your e-mail address?'
5997         . ./myread
5998         cf_email="$ans"
5999         case "$cf_email" in
6000         *@*.*) cont='' ;;
6001         *)
6002                 rp='Address does not look like an Internet one.  Use it anyway?'
6003                 case "$fastread" in
6004                 yes) dflt=y ;;
6005                 *) dflt=n ;;
6006                 esac
6007                 . ./myread
6008                 case "$ans" in
6009                 y*) cont='' ;;
6010                 *) echo " " ;;
6011                 esac
6012                 ;;
6013         esac
6014 done
6015
6016 $cat <<EOM
6017
6018 If you or somebody else will be maintaining perl at your site, please
6019 fill in the correct e-mail address here so that they may be contacted
6020 if necessary. Currently, the "perlbug" program included with perl
6021 will send mail to this address in addition to perlbug@perl.com. You may
6022 enter "none" for no administrator.
6023
6024 EOM
6025 case "$perladmin" in
6026 '') dflt="$cf_email";;
6027 *) dflt="$perladmin";;
6028 esac
6029 rp='Perl administrator e-mail address'
6030 . ./myread
6031 perladmin="$ans"
6032
6033 : figure out how to guarantee perl startup
6034 case "$startperl" in
6035 '')
6036         case "$sharpbang" in
6037         *!)
6038                 $cat <<EOH
6039
6040 I can use the #! construct to start perl on your system. This will
6041 make startup of perl scripts faster, but may cause problems if you
6042 want to share those scripts and perl is not in a standard place
6043 ($binexp/perl) on all your platforms. The alternative is to force
6044 a shell by starting the script with a single ':' character.
6045
6046 EOH
6047                 dflt="$binexp/perl"
6048                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6049                 . ./myread
6050                 case "$ans" in
6051                 none)   startperl=": # use perl";;
6052                 *)      startperl="#!$ans"
6053                         if $test 30 -lt `echo "$ans" | wc -c`; then
6054                                 $cat >&4 <<EOM
6055
6056 WARNING:  Some systems limit the #! command to 32 characters.
6057 If you experience difficulty running Perl scripts with #!, try
6058 installing Perl in a directory with a shorter pathname.
6059
6060 EOM
6061                         fi ;;
6062                 esac
6063                 ;;
6064         *) startperl=": # use perl"
6065                 ;;
6066         esac
6067         ;;
6068 esac
6069 echo "I'll use $startperl to start perl scripts."
6070
6071 : figure best path for perl in scripts
6072 case "$perlpath" in
6073 '')
6074         perlpath="$binexp/perl"
6075         case "$startperl" in
6076         *!*) ;;
6077         *)
6078                 $cat <<EOH
6079
6080 I will use the "eval 'exec'" idiom to start Perl on your system.
6081 I can use the full path of your Perl binary for this purpose, but
6082 doing so may cause problems if you want to share those scripts and
6083 Perl is not always in a standard place ($binexp/perl).
6084
6085 EOH
6086                 dflt="$binexp/perl"
6087                 rp="What path shall I use in \"eval 'exec'\"?"
6088                 . ./myread
6089                 perlpath="$ans"
6090                 ;;
6091         esac
6092         ;;
6093 esac
6094 case "$startperl" in
6095 *!*)    ;;
6096 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6097 esac
6098
6099 : determine where public executable scripts go
6100 set scriptdir scriptdir
6101 eval $prefixit
6102 case "$scriptdir" in
6103 '')
6104         dflt="$bin"
6105         : guess some guesses
6106         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6107         $test -d /usr/share/bin && dflt=/usr/share/bin
6108         $test -d /usr/local/script && dflt=/usr/local/script
6109         $test -d $prefixexp/script && dflt=$prefixexp/script
6110         set dflt
6111         eval $prefixup
6112         ;;
6113 *)  dflt="$scriptdir"
6114         ;;
6115 esac
6116 $cat <<EOM
6117  
6118 Some installations have a separate directory just for executable scripts so
6119 that they can mount it across multiple architectures but keep the scripts in
6120 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6121 Or you might just lump your scripts in with all your other executables.
6122  
6123 EOM
6124 fn=d~
6125 rp='Where do you keep publicly executable scripts?'
6126 . ./getfile
6127 if $test "X$ansexp" != "X$scriptdirexp"; then
6128         installscript=''
6129 fi
6130 scriptdir="$ans"
6131 scriptdirexp="$ansexp"
6132 if $afs; then
6133         $cat <<EOM
6134
6135 Since you are running AFS, I need to distinguish the directory in which
6136 scripts reside from the directory in which they are installed (and from
6137 which they are presumably copied to the former directory by occult means).
6138
6139 EOM
6140         case "$installscript" in
6141         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6142         *) dflt="$installscript";;
6143         esac
6144         fn=de~
6145         rp='Where will public scripts be installed?'
6146         . ./getfile
6147         installscript="$ans"
6148 else
6149         installscript="$scriptdirexp"
6150 fi
6151
6152 : determine where site specific libraries go.
6153 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6154 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6155 case "$prefix" in
6156 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6157 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6158 esac
6159 eval $prefixit
6160 $cat <<EOM
6161
6162 The installation process will also create a directory for
6163 site-specific extensions and modules.  Some users find it convenient
6164 to place all site-specific files in this directory rather than in the
6165 main distribution directory.
6166
6167 EOM
6168 fn=d~+
6169 rp='Pathname for the site-specific library files?'
6170 . ./getfile
6171 if $test "X$sitelibexp" != "X$ansexp"; then
6172         installsitelib=''
6173 fi
6174 sitelib="$ans"
6175 sitelibexp="$ansexp"
6176 if $afs; then
6177         $cat <<EOM
6178
6179 Since you are running AFS, I need to distinguish the directory in
6180 which site-specific files reside from the directory in which they are
6181 installed (and from which they are presumably copied to the former
6182 directory by occult means).
6183
6184 EOM
6185         case "$installsitelib" in
6186         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6187         *) dflt="$installsitelib";;
6188         esac
6189         fn=de~
6190         rp='Where will site-specific files be installed?'
6191         . ./getfile
6192         installsitelib="$ans"
6193 else
6194         installsitelib="$sitelibexp"
6195 fi
6196
6197 : determine where site specific architecture-dependent libraries go.
6198 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6199 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6200 : sitelib may have an optional trailing /share.
6201 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6202 tdflt="$tdflt/$archname"
6203 set sitearch sitearch none
6204 eval $prefixit
6205 case "$sitearch" in
6206 '')     dflt="$tdflt" ;;
6207 *)      dflt="$sitearch" ;;
6208 esac
6209 $cat <<EOM
6210
6211 The installation process will also create a directory for
6212 architecture-dependent site-specific extensions and modules.
6213
6214 EOM
6215 fn=nd~+
6216 rp='Pathname for the site-specific architecture-dependent library files?'
6217 . ./getfile
6218 if $test "X$sitearchexp" != "X$ansexp"; then
6219         installsitearch=''
6220 fi
6221 sitearch="$ans"
6222 sitearchexp="$ansexp"
6223 if $afs; then
6224         $cat <<EOM
6225
6226 Since you are running AFS, I need to distinguish the directory in
6227 which site-specific architecture-dependent library files reside from
6228 the directory in which they are installed (and from which they are
6229 presumably copied to the former directory by occult means).
6230
6231 EOM
6232         case "$installsitearch" in
6233         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6234         *) dflt="$installsitearch";;
6235         esac
6236         fn=de~
6237         rp='Where will site-specific architecture-dependent files be installed?'
6238         . ./getfile
6239         installsitearch="$ans"
6240 else
6241         installsitearch="$sitearchexp"
6242 fi
6243
6244 cat <<EOM
6245
6246 Previous version of $package used the standard IO mechanisms as defined
6247 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6248 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6249 the default.  This abstraction layer can use AT&T's sfio (if you already
6250 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6251 problems with some extension modules.  Using PerlIO with stdio is safe,
6252 but it is slower than plain stdio and therefore is not the default.
6253
6254 If this doesn't make any sense to you, just accept the default 'n'.
6255 EOM
6256 case "$useperlio" in
6257 $define|true|[yY]*)     dflt='y';;
6258 *) dflt='n';;
6259 esac
6260 rp='Use the experimental PerlIO abstraction layer?'
6261 . ./myread
6262 case "$ans" in
6263 y|Y) 
6264         val="$define"
6265         ;;     
6266 *)      
6267         echo "Ok, doing things the stdio way"
6268         val="$undef"
6269         ;;
6270 esac
6271 set useperlio
6272 eval $setvar 
6273
6274 : Check how to convert floats to strings.
6275 if test "X$d_Gconvert" = X; then
6276         echo " "
6277         echo "Checking for an efficient way to convert floats to strings."
6278         $cat >try.c <<'EOP'
6279 #ifdef TRY_gconvert
6280 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6281 char *myname = "gconvert";
6282 #endif
6283 #ifdef TRY_gcvt
6284 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6285 char *myname = "gcvt";
6286 #endif
6287 #ifdef TRY_sprintf
6288 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6289 char *myname = "sprintf";
6290 #endif
6291
6292 #include <stdio.h>
6293
6294 int
6295 checkit(expect, got)
6296 char *expect;
6297 char *got;
6298 {
6299     if (strcmp(expect, got)) {
6300                 printf("%s oddity:  Expected %s, got %s\n",
6301                         myname, expect, got);
6302                 exit(1);
6303         }
6304 }
6305
6306 int main()
6307
6308         char buf[64]; 
6309         buf[63] = '\0';
6310
6311         /* This must be 1st test on (which?) platform */
6312         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6313         Gconvert(0.1, 8, 0, buf);
6314         checkit("0.1", buf);
6315
6316         Gconvert(1.0, 8, 0, buf); 
6317         checkit("1", buf);
6318
6319         Gconvert(0.0, 8, 0, buf); 
6320         checkit("0", buf);
6321
6322         Gconvert(-1.0, 8, 0, buf); 
6323         checkit("-1", buf);
6324
6325         /* Some Linux gcvt's give 1.e+5 here. */
6326         Gconvert(100000.0, 8, 0, buf); 
6327         checkit("100000", buf);
6328         
6329         /* Some Linux gcvt's give -1.e+5 here. */
6330         Gconvert(-100000.0, 8, 0, buf); 
6331         checkit("-100000", buf);
6332
6333         exit(0);
6334 }
6335 EOP
6336         case "$d_Gconvert" in
6337         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6338         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6339         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6340         *) xxx_list='gconvert gcvt sprintf' ;;
6341         esac
6342
6343         for xxx_convert in $xxx_list; do
6344                 echo "Trying $xxx_convert"
6345                 $rm -f try try$_o
6346                 set try -DTRY_$xxx_convert
6347                 if eval $compile; then
6348                         echo "$xxx_convert" found. >&4
6349                         if ./try; then
6350                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6351                                 break;
6352                         else
6353                                 echo "...But $xxx_convert didn't work as I expected."
6354                         fi
6355                 else
6356                         echo "$xxx_convert NOT found." >&4
6357                 fi
6358         done
6359                 
6360         case "$xxx_convert" in
6361         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6362         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6363         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6364         esac
6365 fi
6366
6367 : Initialize h_fcntl
6368 h_fcntl=false
6369
6370 : Initialize h_sysfile
6371 h_sysfile=false
6372
6373 : access call always available on UNIX
6374 set access d_access
6375 eval $inlibc
6376
6377 : locate the flags for 'access()'
6378 case "$d_access" in
6379 "$define")
6380         echo " "
6381         $cat >access.c <<'EOCP'
6382 #include <sys/types.h>
6383 #ifdef I_FCNTL
6384 #include <fcntl.h>
6385 #endif
6386 #ifdef I_SYS_FILE
6387 #include <sys/file.h>
6388 #endif
6389 #ifdef I_UNISTD
6390 #include <unistd.h>
6391 #endif
6392 int main() {
6393         exit(R_OK);
6394 }
6395 EOCP
6396         : check sys/file.h first, no particular reason here
6397         if $test `./findhdr sys/file.h` && \
6398                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6399                 h_sysfile=true;
6400                 echo "<sys/file.h> defines the *_OK access constants." >&4
6401         elif $test `./findhdr fcntl.h` && \
6402                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6403                 h_fcntl=true;
6404                 echo "<fcntl.h> defines the *_OK access constants." >&4
6405         elif $test `./findhdr unistd.h` && \
6406                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6407                 echo "<unistd.h> defines the *_OK access constants." >&4
6408         else
6409                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6410         fi
6411         ;;
6412 esac
6413 $rm -f access*
6414
6415 : see if accessx exists
6416 set accessx d_accessx
6417 eval $inlibc
6418
6419 : see if alarm exists
6420 set alarm d_alarm
6421 eval $inlibc
6422
6423 : Look for GNU-cc style attribute checking
6424 echo " "
6425 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6426 $cat >attrib.c <<'EOCP'
6427 #include <stdio.h>
6428 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6429 EOCP
6430 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6431         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6432                 echo "Your C compiler doesn't fully support __attribute__."
6433                 val="$undef"
6434         else
6435                 echo "Your C compiler supports __attribute__."
6436                 val="$define"
6437         fi
6438 else
6439         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6440         val="$undef"
6441 fi
6442 set d_attribut
6443 eval $setvar
6444 $rm -f attrib*
6445
6446 : see if bcmp exists
6447 set bcmp d_bcmp
6448 eval $inlibc
6449
6450 : see if bcopy exists
6451 set bcopy d_bcopy
6452 eval $inlibc
6453
6454 : see if this is a unistd.h system
6455 set unistd.h i_unistd
6456 eval $inhdr
6457
6458 : see if getpgrp exists
6459 set getpgrp d_getpgrp
6460 eval $inlibc
6461
6462 case "$d_getpgrp" in
6463 "$define")
6464         echo " "
6465         echo "Checking to see which flavor of getpgrp is in use..."
6466         $cat >set.c <<EOP
6467 #$i_unistd I_UNISTD
6468 #include <sys/types.h>
6469 #ifdef I_UNISTD
6470 #  include <unistd.h>
6471 #endif
6472 int main()
6473 {
6474         if (getuid() == 0) {
6475                 printf("(I see you are running Configure as super-user...)\n");
6476                 setuid(1);
6477         }
6478 #ifdef TRY_BSD_PGRP
6479         if (getpgrp(1) == 0)
6480                 exit(0);
6481 #else
6482         if (getpgrp() > 0)
6483                 exit(0);
6484 #endif
6485         exit(1);
6486 }
6487 EOP
6488         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6489                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6490                 val="$define"
6491         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6492                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6493                 val="$undef"
6494         else
6495                 echo "I can't seem to compile and run the test program."
6496                 if ./usg; then
6497                         xxx="a USG one, i.e. you use getpgrp()."
6498                 else
6499                         # SVR4 systems can appear rather BSD-ish.
6500                         case "$i_unistd" in
6501                         $undef)
6502                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6503                                 val="$define"
6504                                 ;;
6505                         $define)
6506                                 xxx="probably a USG one, i.e. you use getpgrp()."
6507                                 val="$undef"
6508                                 ;;
6509                         esac
6510                 fi
6511                 echo "Assuming your getpgrp is $xxx" >&4
6512         fi
6513         ;;
6514 *) val="$undef";;
6515 esac
6516 set d_bsdgetpgrp
6517 eval $setvar
6518 $rm -f set set.c
6519
6520 : see if setpgrp exists
6521 set setpgrp d_setpgrp
6522 eval $inlibc
6523
6524 case "$d_setpgrp" in
6525 "$define")
6526         echo " "
6527         echo "Checking to see which flavor of setpgrp is in use..."
6528         $cat >set.c <<EOP
6529 #$i_unistd I_UNISTD
6530 #include <sys/types.h>
6531 #ifdef I_UNISTD
6532 #  include <unistd.h>
6533 #endif
6534 int main()
6535 {
6536         if (getuid() == 0) {
6537                 printf("(I see you are running Configure as super-user...)\n");
6538                 setuid(1);
6539         }
6540 #ifdef TRY_BSD_PGRP
6541         if (-1 == setpgrp(1, 1))
6542                 exit(0);
6543 #else
6544         if (setpgrp() != -1)
6545                 exit(0);
6546 #endif
6547         exit(1);
6548 }
6549 EOP
6550         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6551                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6552                 val="$define"
6553         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6554                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6555                 val="$undef"
6556         else
6557                 echo "(I can't seem to compile and run the test program.)"
6558                 if ./usg; then
6559                         xxx="a USG one, i.e. you use setpgrp()."
6560                 else
6561                         # SVR4 systems can appear rather BSD-ish.
6562                         case "$i_unistd" in
6563                         $undef)
6564                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6565                                 val="$define"
6566                                 ;;
6567                         $define)
6568                                 xxx="probably a USG one, i.e. you use setpgrp()."
6569                                 val="$undef"
6570                                 ;;
6571                         esac
6572                 fi
6573                 echo "Assuming your setpgrp is $xxx" >&4
6574         fi
6575         ;;
6576 *) val="$undef";;
6577 esac
6578 set d_bsdsetpgrp
6579 eval $setvar
6580 $rm -f set set.c
6581 : see if bzero exists
6582 set bzero d_bzero
6583 eval $inlibc
6584
6585 : check for lengths of integral types
6586 echo " "
6587 case "$intsize" in
6588 '')
6589         echo "Checking to see how big your integers are..." >&4
6590         $cat >intsize.c <<'EOCP'
6591 #include <stdio.h>
6592 int main()
6593 {
6594         printf("intsize=%d;\n", sizeof(int));
6595         printf("longsize=%d;\n", sizeof(long));
6596         printf("shortsize=%d;\n", sizeof(short));
6597         exit(0);
6598 }
6599 EOCP
6600         set intsize
6601         if eval $compile_ok && ./intsize > /dev/null; then
6602                 eval `./intsize`
6603                 echo "Your integers are $intsize bytes long."
6604                 echo "Your long integers are $longsize bytes long."
6605                 echo "Your short integers are $shortsize bytes long."
6606         else
6607                 $cat >&4 <<EOM
6608 !
6609 Help! I can't compile and run the intsize test program: please enlighten me!
6610 (This is probably a misconfiguration in your system or libraries, and
6611 you really ought to fix it.  Still, I'll try anyway.)
6612 !
6613 EOM
6614                 dflt=4
6615                 rp="What is the size of an integer (in bytes)?"
6616                 . ./myread
6617                 intsize="$ans"
6618                 dflt=$intsize
6619                 rp="What is the size of a long integer (in bytes)?"
6620                 . ./myread
6621                 longsize="$ans"
6622                 dflt=2
6623                 rp="What is the size of a short integer (in bytes)?"
6624                 . ./myread
6625                 shortsize="$ans"
6626         fi
6627         ;;
6628 esac
6629 $rm -f intsize intsize.*
6630
6631 : see if signal is declared as pointer to function returning int or void
6632 echo " "
6633 xxx=`./findhdr signal.h`
6634 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6635 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6636         echo "You have int (*signal())() instead of void." >&4
6637         val="$undef"
6638 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6639         echo "You have void (*signal())()." >&4
6640         val="$define"
6641 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6642         echo "You have int (*signal())() instead of void." >&4
6643         val="$undef"
6644 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6645         echo "You have void (*signal())()." >&4
6646         val="$define"
6647 else
6648         case "$d_voidsig" in
6649         '')
6650         echo "I can't determine whether signal handler returns void or int..." >&4
6651                 dflt=void
6652                 rp="What type does your signal handler return?"
6653                 . ./myread
6654                 case "$ans" in
6655                 v*) val="$define";;
6656                 *) val="$undef";;
6657                 esac;;
6658         "$define")
6659                 echo "As you already told me, signal handler returns void." >&4
6660                 val="$define"
6661                 ;;
6662         *)      echo "As you already told me, signal handler returns int." >&4
6663                 val="$undef"
6664                 ;;
6665         esac
6666 fi
6667 set d_voidsig
6668 eval $setvar
6669 case "$d_voidsig" in
6670 "$define") signal_t="void";;
6671 *) signal_t="int";;
6672 esac
6673 $rm -f $$.tmp
6674
6675 : check for ability to cast large floats to 32-bit ints.
6676 echo " "
6677 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6678 if $test "$intsize" -ge 4; then
6679         xxx=int
6680 else
6681         xxx=long
6682 fi
6683 $cat >try.c <<EOCP
6684 #include <stdio.h>
6685 #include <sys/types.h>
6686 #include <signal.h>
6687 $signal_t blech(s) int s; { exit(3); }
6688 int main()
6689 {
6690         $xxx i32;
6691         double f, g;
6692         int result = 0;
6693         char str[16];
6694         signal(SIGFPE, blech);
6695
6696         /* Don't let compiler optimize the test away.  Store the number 
6697            in a writable string for gcc to pass to sscanf under HP/UX.
6698         */
6699         sprintf(str, "2147483647");
6700         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6701         g = 10 * f;
6702         i32  = ($xxx) g;
6703
6704         /* x86 processors will probably give 0x8000 0000, which is a
6705        sign change.  We don't want that.  We want to mimic SPARC
6706            behavior here, which is to preserve the sign and give
6707            back 0x7fff ffff.
6708         */
6709         if (i32 != ($xxx) f)
6710                 result |= 1;
6711         exit(result);
6712 }
6713 EOCP
6714 set try
6715 if eval $compile_ok; then
6716         ./try
6717         yyy=$?
6718 else
6719         echo "(I can't seem to compile the test program--assuming it can't)"
6720         yyy=1
6721 fi
6722 case "$yyy" in
6723 0)      val="$define"
6724         echo "Yup, it can."
6725         ;;
6726 *)      val="$undef"
6727         echo "Nope, it can't."
6728         ;;
6729 esac
6730 set d_casti32
6731 eval $setvar
6732 $rm -f try try.*
6733
6734 : check for ability to cast negative floats to unsigned
6735 echo " "
6736 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6737 $cat >try.c <<EOCP
6738 #include <stdio.h>
6739 #include <sys/types.h>
6740 #include <signal.h>
6741 $signal_t blech(s) int s; { exit(7); }
6742 $signal_t blech_in_list(s) int s; { exit(4); }
6743 unsigned long dummy_long(p) unsigned long p; { return p; }
6744 unsigned int dummy_int(p) unsigned int p; { return p; }
6745 unsigned short dummy_short(p) unsigned short p; { return p; }
6746 int main()
6747 {
6748         double f;
6749         unsigned long along;
6750         unsigned int aint;
6751         unsigned short ashort;
6752         int result = 0;
6753         char str[16];
6754         
6755         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6756            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6757            optimized the whole file away
6758         */
6759         /* Store the number in a writable string for gcc to pass to 
6760            sscanf under HP/UX.
6761         */
6762         sprintf(str, "-123");
6763         sscanf(str, "%lf", &f);  /* f = -123.; */
6764
6765         signal(SIGFPE, blech);
6766         along = (unsigned long)f;
6767         aint = (unsigned int)f;
6768         ashort = (unsigned short)f;
6769         if (along != (unsigned long)-123)
6770                 result |= 1;
6771         if (aint != (unsigned int)-123)
6772                 result |= 1;
6773         if (ashort != (unsigned short)-123)
6774                 result |= 1;
6775         sprintf(str, "1073741824.");
6776         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6777         f = f + f;
6778         along = 0;
6779         along = (unsigned long)f;
6780         if (along != 0x80000000)
6781                 result |= 2;
6782         f -= 1.;
6783         along = 0;
6784         along = (unsigned long)f;
6785         if (along != 0x7fffffff)
6786                 result |= 1;
6787         f += 2.;
6788         along = 0;
6789         along = (unsigned long)f;
6790         if (along != 0x80000001)
6791                 result |= 2;
6792         if (result)
6793                 exit(result);
6794         signal(SIGFPE, blech_in_list);
6795         sprintf(str, "123.");
6796         sscanf(str, "%lf", &f);  /* f = 123.; */
6797         along = dummy_long((unsigned long)f);
6798         aint = dummy_int((unsigned int)f);
6799         ashort = dummy_short((unsigned short)f);
6800         if (along != (unsigned long)123)
6801                 result |= 4;
6802         if (aint != (unsigned int)123)
6803                 result |= 4;
6804         if (ashort != (unsigned short)123)
6805                 result |= 4;
6806         exit(result);
6807
6808 }
6809 EOCP
6810 set try
6811 if eval $compile_ok; then
6812         ./try
6813         castflags=$?
6814 else
6815         echo "(I can't seem to compile the test program--assuming it can't)"
6816         castflags=7
6817 fi
6818 case "$castflags" in
6819 0)      val="$define"
6820         echo "Yup, it can."
6821         ;;
6822 *)      val="$undef"
6823         echo "Nope, it can't."
6824         ;;
6825 esac
6826 set d_castneg
6827 eval $setvar
6828 $rm -f try.*
6829
6830 : see if vprintf exists
6831 echo " "
6832 if set vprintf val -f d_vprintf; eval $csym; $val; then
6833         echo 'vprintf() found.' >&4
6834         val="$define"
6835         $cat >vprintf.c <<'EOF'
6836 #include <varargs.h>
6837
6838 int main() { xxx("foo"); }
6839
6840 xxx(va_alist)
6841 va_dcl
6842 {
6843         va_list args;
6844         char buf[10];
6845
6846         va_start(args);
6847         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6848 }
6849 EOF
6850         set vprintf
6851         if eval $compile && ./vprintf; then
6852                 echo "Your vsprintf() returns (int)." >&4
6853                 val2="$undef"
6854         else
6855                 echo "Your vsprintf() returns (char*)." >&4
6856                 val2="$define"
6857         fi
6858 else
6859         echo 'vprintf() NOT found.' >&4
6860                 val="$undef"
6861                 val2="$undef"
6862 fi
6863 set d_vprintf
6864 eval $setvar
6865 val=$val2
6866 set d_charvspr
6867 eval $setvar
6868
6869 : see if chown exists
6870 set chown d_chown
6871 eval $inlibc
6872
6873 : see if chroot exists
6874 set chroot d_chroot
6875 eval $inlibc
6876
6877 : see if chsize exists
6878 set chsize d_chsize
6879 eval $inlibc
6880
6881 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6882 while $test $# -ge 2; do
6883         case "$1" in
6884         $define) echo "#include <$2>";;
6885         esac ;
6886     shift 2;
6887 done > try.c;
6888 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6889 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6890         val="$define";
6891 else
6892         val="$undef";
6893 fi;
6894 set $varname;
6895 eval $setvar;
6896 $rm -f try.c try.o'
6897
6898 : see if this is a sys/uio.h system
6899 set sys/uio.h i_sysuio
6900 eval $inhdr
6901
6902 echo "Checking to see if your system supports struct iovec..." >&4
6903 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6904 eval $hasfield
6905 case "$d_iovec_s" in
6906 "$define")      echo "Yup, it does." >&4
6907                 ;;
6908 *)              echo "Nope, it doesn't." >&4
6909                 ;;
6910 esac
6911
6912 socketlib=''
6913 sockethdr=''
6914 : see whether socket exists
6915 echo " "
6916 $echo $n "Hmm... $c" >&4
6917 if set socket val -f d_socket; eval $csym; $val; then
6918         echo "Looks like you have Berkeley networking support." >&4
6919         d_socket="$define"
6920         if set setsockopt val -f; eval $csym; $val; then
6921                 d_oldsock="$undef"
6922         else
6923                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6924                 d_oldsock="$define"
6925         fi
6926 else
6927         if $contains socklib libc.list >/dev/null 2>&1; then
6928                 echo "Looks like you have Berkeley networking support." >&4
6929                 d_socket="$define"
6930                 : we will have to assume that it supports the 4.2 BSD interface
6931                 d_oldsock="$undef"
6932         else
6933                 echo "You don't have Berkeley networking in libc$_a..." >&4
6934                 if test "X$d_socket" = "X$define"; then
6935                    echo "...but you seem to believe that you have sockets." >&4
6936                 else
6937                         for net in net socket
6938                         do
6939                                 if test -f /usr/lib/lib$net$_a; then
6940                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6941                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6942                                         if $contains socket libc.list >/dev/null 2>&1; then
6943                                                 d_socket="$define"
6944                                                 socketlib="-l$net"
6945                                                 case "$net" in
6946                                                 net)
6947                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6948                                                         sockethdr="-I/usr/netinclude"
6949                                                         ;;
6950                                                 esac
6951                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6952                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6953                                                         d_oldsock="$undef"
6954                                                 else
6955                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6956                                                         d_oldsock="$define"
6957                                                 fi
6958                                                 break
6959                                         fi
6960                                 fi
6961                         done
6962                         if test "X$d_socket" != "X$define"; then
6963                            echo "or anywhere else I see." >&4
6964                            d_socket="$undef"
6965                            d_oldsock="$undef"
6966                         fi
6967                 fi
6968         fi
6969 fi
6970
6971 : see if socketpair exists
6972 set socketpair d_sockpair
6973 eval $inlibc
6974
6975
6976 echo " "
6977 echo "Checking the availability of certain socket constants..." >& 4
6978 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
6979         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
6980         $cat >try.c <<EOF
6981 #include <sys/types.h>
6982 #include <sys/socket.h>
6983 int main() {
6984     int i = $ENUM;
6985 }
6986 EOF
6987         val="$undef"
6988         set try; if eval $compile; then
6989                 val="$define"
6990         fi
6991         set d_${enum}; eval $setvar
6992         $rm -f try.c try
6993 done
6994
6995 set sendmsg d_sendmsg
6996 eval $inlibc
6997
6998 set recvmsg d_recvmsg
6999 eval $inlibc
7000
7001 echo " "
7002 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
7003 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7004 eval $hasfield
7005 case "$d_msghdr_s" in
7006 "$define")      echo "Yup, it does." >&4
7007                 ;;
7008 *)              echo "Nope, it doesn't." >&4
7009                 ;;
7010 esac
7011
7012 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7013 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7014 eval $hasfield
7015 case "$d_cmsghdr_s" in
7016 "$define")      echo "Yup, it does." >&4
7017                 ;;
7018 *)              echo "Nope, it doesn't." >&4
7019                 ;;
7020 esac
7021
7022 : check for const keyword
7023 echo " "
7024 echo 'Checking to see if your C compiler knows about "const"...' >&4
7025 $cat >const.c <<'EOCP'
7026 typedef struct spug { int drokk; } spug;
7027 int main()
7028 {
7029         const char *foo;
7030         const spug y;
7031 }
7032 EOCP
7033 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7034         val="$define"
7035         echo "Yup, it does."
7036 else
7037         val="$undef"
7038         echo "Nope, it doesn't."
7039 fi
7040 set d_const
7041 eval $setvar
7042
7043 : see if crypt exists
7044 echo " "
7045 if set crypt val -f d_crypt; eval $csym; $val; then
7046         echo 'crypt() found.' >&4
7047         val="$define"
7048         cryptlib=''
7049 else
7050         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7051         if $test -z "$cryptlib"; then
7052                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7053         else
7054                 cryptlib=-lcrypt
7055         fi
7056         if $test -z "$cryptlib"; then
7057                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7058         else
7059                 cryptlib=-lcrypt
7060         fi
7061         if $test -z "$cryptlib"; then
7062                 cryptlib=`./loc libcrypt$_a "" $libpth`
7063         else
7064                 cryptlib=-lcrypt
7065         fi
7066         if $test -z "$cryptlib"; then
7067                 echo 'crypt() NOT found.' >&4
7068                 val="$undef"
7069         else
7070                 val="$define"
7071         fi
7072 fi
7073 set d_crypt
7074 eval $setvar
7075
7076 : get csh whereabouts
7077 case "$csh" in
7078 'csh') val="$undef" ;;
7079 *) val="$define" ;;
7080 esac
7081 set d_csh
7082 eval $setvar
7083 : Respect a hint or command line value for full_csh.
7084 case "$full_csh" in
7085 '') full_csh=$csh ;;
7086 esac
7087
7088 : see if cuserid exists
7089 set cuserid d_cuserid
7090 eval $inlibc
7091
7092 : see if this is a limits.h system
7093 set limits.h i_limits
7094 eval $inhdr
7095
7096 : see if this is a float.h system
7097 set float.h i_float
7098 eval $inhdr
7099
7100 : See if number of significant digits in a double precision number is known
7101 echo " "
7102 $cat >dbl_dig.c <<EOM
7103 #$i_limits I_LIMITS
7104 #$i_float I_FLOAT
7105 #ifdef I_LIMITS
7106 #include <limits.h>
7107 #endif
7108 #ifdef I_FLOAT
7109 #include <float.h>
7110 #endif
7111 #ifdef DBL_DIG
7112 printf("Contains DBL_DIG");
7113 #endif
7114 EOM
7115 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7116 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7117         echo "DBL_DIG found." >&4
7118         val="$define"
7119 else
7120         echo "DBL_DIG NOT found." >&4
7121         val="$undef"
7122 fi
7123 $rm -f dbl_dig.?
7124 set d_dbl_dig
7125 eval $setvar
7126
7127
7128 if $test X"$use64bits" = X"$define"; then
7129         : see if dbminit64 exists
7130         set dbminit64 d_dbminit64
7131         eval $inlibc
7132
7133         : see if dbmclose64 exists
7134         set dbmclose64 d_dbmclose64
7135         eval $inlibc
7136
7137         : see if fetch64 exists
7138         set fetch64 d_fetch64
7139         eval $inlibc
7140
7141         : see if store64 exists
7142         set store64 d_store64
7143         eval $inlibc
7144
7145         : see if delete64 exists
7146         set delete64 d_delete64
7147         eval $inlibc
7148
7149         : see if firstkey64 exists
7150         set firstkey64 d_firstkey64
7151         eval $inlibc
7152
7153         : see if nextkey64 exists
7154         set nextkey64 d_nextkey64
7155         eval $inlibc
7156 else
7157         val="$undef"
7158         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7159         do
7160                 set $xxx
7161                 eval $setvar
7162         done
7163 fi
7164
7165 : see if difftime exists
7166 set difftime d_difftime
7167 eval $inlibc
7168
7169 : see if sys/stat.h is available
7170 set sys/stat.h i_sysstat
7171 eval $inhdr
7172
7173 : see if this is a dirent system
7174 echo " "
7175 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7176         val="$define"
7177         echo "<dirent.h> found." >&4
7178 else
7179         val="$undef"
7180         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7181                 echo "<sys/dir.h> found." >&4
7182                 echo " "
7183         else
7184                 xinc=`./findhdr sys/ndir.h`
7185         fi
7186         echo "<dirent.h> NOT found." >&4
7187 fi
7188 set i_dirent
7189 eval $setvar
7190
7191 : Look for type of directory structure.
7192 echo " "
7193 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7194
7195 case "$direntrytype" in
7196 ''|' ')
7197         case "$i_dirent" in
7198         $define) guess1='struct dirent' ;;
7199         *) guess1='struct direct'  ;;
7200         esac
7201         ;;
7202 *)      guess1="$direntrytype"
7203         ;;
7204 esac
7205
7206 case "$guess1" in
7207 'struct dirent') guess2='struct direct' ;;
7208 *) guess2='struct dirent' ;;
7209 esac
7210                 
7211 if $contains "$guess1" try.c >/dev/null 2>&1; then
7212         direntrytype="$guess1"
7213         echo "Your directory entries are $direntrytype." >&4
7214 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7215         direntrytype="$guess2"
7216         echo "Your directory entries seem to be $direntrytype." >&4
7217 else
7218         echo "I don't recognize your system's directory entries." >&4
7219         rp="What type is used for directory entries on this system?"
7220         dflt="$guess1"
7221         . ./myread
7222         direntrytype="$ans"
7223 fi
7224 $rm -f try.c
7225
7226
7227 : see if the directory entry stores field length
7228 echo " "
7229 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7230 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7231         echo "Good, your directory entry keeps length information in d_namlen." >&4
7232         val="$define"
7233 else
7234         echo "Your directory entry does not know about the d_namlen field." >&4
7235         val="$undef"
7236 fi
7237 set d_dirnamlen
7238 eval $setvar
7239 $rm -f try.c
7240
7241
7242 if $test X"$use64bits" = X"$define"; then
7243         : see if fstat64 exists
7244         set fstat64 d_fstat64
7245         eval $inlibc
7246
7247         : see if ftruncate64 exists
7248         set ftruncate64 d_ftruncate64
7249         eval $inlibc
7250
7251         : see if lockf64 exists
7252         set lockf64 d_lockf64
7253         eval $inlibc
7254
7255         : see if llseek exists
7256         set llseek d_llseek
7257         eval $inlibc
7258
7259         : see if lseek64 exists
7260         set lseek64 d_lseek64
7261         eval $inlibc
7262
7263         : see if lstat64 exists
7264         set lstat64 d_lstat64
7265         eval $inlibc
7266
7267         : see if open64 exists
7268         set open64 d_open64
7269         eval $inlibc
7270
7271         : see if opendir64 exists
7272         set opendir64 d_opendir64
7273         eval $inlibc
7274
7275         : see if readdir64 exists
7276         set readdir64 d_readdir64
7277         eval $inlibc
7278
7279         : see if seekdir64 exists
7280         set seekdir64 d_seekdir64
7281         eval $inlibc
7282
7283         : see if stat64 exists
7284         set stat64 d_stat64
7285         eval $inlibc
7286
7287         : see if telldir64 exists
7288         set telldir64 d_telldir64
7289         eval $inlibc
7290
7291         : see if truncate64 exists
7292         set truncate64 d_truncate64
7293         eval $inlibc
7294
7295         : check for off64_t
7296         echo " "
7297         echo $n "Checking to see if your system supports off64_t...$c" >&4
7298         $cat >try.c <<EOCP
7299 #include <sys/types.h>
7300 #include <unistd.h>
7301 off64_t foo() { off64_t x; x = 7; return x; }'
7302 EOCP
7303         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7304                 val="$define"
7305                 echo " Yup, it does." >&4
7306         else
7307                 val="$undef"
7308                 echo " Nope, it doesn't." >&4
7309         fi
7310         $rm -f try.*
7311         set d_off64_t
7312         eval $setvar
7313
7314         : check for offset_t
7315         echo " "
7316         echo $n "Checking to see if your system supports offset_t...$c" >&4
7317         $cat >try.c <<EOCP
7318 #include <sys/types.h>
7319 #include <unistd.h>
7320 offset_t foo() { offset_t x; x = 7; return x; }'
7321 EOCP
7322         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7323                 val="$define"
7324                 echo " Yup, it does." >&4
7325         else
7326                 val="$undef"
7327                 echo " Nope, it doesn't." >&4
7328         fi
7329         $rm -f try.*
7330         set d_offset_t
7331         eval $setvar
7332
7333         : check for ino64_t
7334         echo " "
7335         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7336         val="$undef"
7337         case "$i_sysstat" in
7338         "$define" )
7339                 $cat >try.c <<EOCP
7340 #include <sys/types.h>
7341 #include <sys/stat.h>
7342 ino64_t foo() { ino64_t x; x = 7; return x; }'
7343 EOCP
7344                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7345                         val="$define"
7346                 fi
7347                 $rm -f try.*
7348                 ;;
7349         esac
7350         if $test "X$val" = X"$define"; then
7351                 echo " Yup, it does." >&4
7352         else
7353                 echo " Nope, it doesn't." >&4
7354         fi
7355         set d_ino64_t
7356         eval $setvar
7357
7358         : check for struct flock64
7359         echo " "
7360         echo "Checking to see if your system supports struct flock64..." >&4
7361         if $h_fcntl; then
7362                 set d_flock64_s flock64 l_len define fcntl.h
7363                 eval $hasfield
7364         else
7365                 val="$undef"
7366                 set d_flock64_s
7367                 eval $setvar
7368         fi
7369         case "$d_flock64_s" in
7370         "$define")      echo "Yup, it does." >&4
7371                         ;;
7372         *)              echo "Nope, it doesn't." >&4
7373                         ;;
7374         esac
7375
7376         : check for struct dirent64
7377         echo " "
7378         echo "Checking to see if your system supports struct dirent64..." >&4
7379         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7380         eval $hasfield
7381         case "$d_dirent64_s" in
7382         "$define")      echo "Yup, it does." >&4
7383                         ;;
7384         *)              echo "Nope, it doesn't." >&4
7385                         ;;
7386         esac
7387
7388 else
7389         val="$undef"
7390         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
7391         do
7392                 set $xxx
7393                 eval $setvar
7394         done
7395 fi
7396
7397 : see if dlerror exists
7398 xxx_runnm="$runnm"
7399 runnm=false
7400 set dlerror d_dlerror
7401 eval $inlibc
7402 runnm="$xxx_runnm"
7403
7404 : see if dlfcn is available
7405 set dlfcn.h i_dlfcn
7406 eval $inhdr
7407
7408 case "$usedl" in
7409 $define|y|true)
7410         $cat << EOM
7411
7412 On a few systems, the dynamically loaded modules that perl generates and uses
7413 will need a different extension than shared libs. The default will probably
7414 be appropriate.
7415
7416 EOM
7417         case "$dlext" in
7418         '')     dflt="$so" ;;
7419         *)      dflt="$dlext" ;;
7420         esac
7421         rp='What is the extension of dynamically loaded modules'
7422         . ./myread
7423         dlext="$ans"
7424         ;;
7425 *)
7426         dlext="none"
7427         ;;
7428 esac
7429
7430 : Check if dlsym need a leading underscore
7431 echo " "
7432 val="$undef"
7433
7434 case "$dlsrc" in
7435 dl_dlopen.xs)
7436         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7437         $cat >dyna.c <<'EOM'
7438 fred () { }
7439 EOM
7440
7441 $cat >fred.c<<EOM
7442
7443 #include <stdio.h>
7444 #$i_dlfcn I_DLFCN
7445 #ifdef I_DLFCN
7446 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7447 #else
7448 #include <sys/types.h>
7449 #include <nlist.h>
7450 #include <link.h>
7451 #endif
7452
7453 extern int fred() ;
7454
7455 int main()
7456 {
7457     void * handle ;
7458     void * symbol ;
7459 #ifndef RTLD_LAZY
7460     int mode = 1 ;
7461 #else
7462     int mode = RTLD_LAZY ;
7463 #endif
7464     handle = dlopen("./dyna.$dlext", mode) ;
7465     if (handle == NULL) {
7466         printf ("1\n") ;
7467         fflush (stdout) ;
7468         exit(0);
7469     }
7470     symbol = dlsym(handle, "fred") ;
7471     if (symbol == NULL) {
7472         /* try putting a leading underscore */
7473         symbol = dlsym(handle, "_fred") ;
7474         if (symbol == NULL) {
7475             printf ("2\n") ;
7476             fflush (stdout) ;
7477             exit(0);
7478         }
7479         printf ("3\n") ;
7480     }
7481     else
7482         printf ("4\n") ;
7483     fflush (stdout) ;
7484     exit(0);
7485 }
7486 EOM
7487         : Call the object file tmp-dyna.o in case dlext=o.
7488         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7489                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7490                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7491                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7492                 xxx=`./fred`
7493                 case $xxx in
7494                 1)      echo "Test program failed using dlopen." >&4
7495                         echo "Perhaps you should not use dynamic loading." >&4;;
7496                 2)      echo "Test program failed using dlsym." >&4
7497                         echo "Perhaps you should not use dynamic loading." >&4;;
7498                 3)      echo "dlsym needs a leading underscore" >&4
7499                         val="$define" ;;
7500                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7501                 esac
7502         else
7503                 echo "I can't compile and run the test program." >&4
7504         fi
7505         ;;
7506 esac
7507                 
7508 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7509
7510 set d_dlsymun
7511 eval $setvar
7512
7513 hasproto='varname=$1; func=$2; shift; shift;
7514 while $test $# -ge 2; do
7515         case "$1" in
7516         $define) echo "#include <$2>";;
7517         esac ;
7518     shift 2;
7519 done > try.c;
7520 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7521 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7522         echo "$func() prototype found.";
7523         val="$define";
7524 else
7525         echo "$func() prototype NOT found.";
7526         val="$undef";
7527 fi;
7528 set $varname;
7529 eval $setvar;
7530 $rm -f try.c tryout.c'
7531
7532 : see if prototype for drand48 is available
7533 echo " "
7534 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7535 eval $hasproto
7536
7537 : see if dup2 exists
7538 set dup2 d_dup2
7539 eval $inlibc
7540
7541 : see if eaccess exists
7542 set eaccess d_eaccess
7543 eval $inlibc
7544
7545 : see if endgrent exists
7546 set endgrent d_endgrent
7547 eval $inlibc
7548
7549 : see if endhostent exists
7550 set endhostent d_endhent
7551 eval $inlibc
7552
7553 : see if endnetent exists
7554 set endnetent d_endnent
7555 eval $inlibc
7556
7557 : see if endprotoent exists
7558 set endprotoent d_endpent
7559 eval $inlibc
7560
7561 : see if endpwent exists
7562 set endpwent d_endpwent
7563 eval $inlibc
7564
7565 : see if endservent exists
7566 set endservent d_endsent
7567 eval $inlibc
7568
7569 : Locate the flags for 'open()'
7570 echo " "
7571 $cat >open3.c <<'EOCP'
7572 #include <sys/types.h>
7573 #ifdef I_FCNTL
7574 #include <fcntl.h>
7575 #endif
7576 #ifdef I_SYS_FILE
7577 #include <sys/file.h>
7578 #endif
7579 int main() {
7580         if(O_RDONLY);
7581 #ifdef O_TRUNC
7582         exit(0);
7583 #else
7584         exit(1);
7585 #endif
7586 }
7587 EOCP
7588 : check sys/file.h first to get FREAD on Sun
7589 if $test `./findhdr sys/file.h` && \
7590                 set open3 -DI_SYS_FILE && eval $compile; then
7591         h_sysfile=true;
7592         echo "<sys/file.h> defines the O_* constants..." >&4
7593         if ./open3; then
7594                 echo "and you have the 3 argument form of open()." >&4
7595                 val="$define"
7596         else
7597                 echo "but not the 3 argument form of open().  Oh, well." >&4
7598                 val="$undef"
7599         fi
7600 elif $test `./findhdr fcntl.h` && \
7601                 set open3 -DI_FCNTL && eval $compile; then
7602         h_fcntl=true;
7603         echo "<fcntl.h> defines the O_* constants..." >&4
7604         if ./open3; then
7605                 echo "and you have the 3 argument form of open()." >&4
7606                 val="$define"
7607         else
7608                 echo "but not the 3 argument form of open().  Oh, well." >&4
7609                 val="$undef"
7610         fi
7611 else
7612         val="$undef"
7613         echo "I can't find the O_* constant definitions!  You got problems." >&4
7614 fi
7615 set d_open3
7616 eval $setvar
7617 $rm -f open3*
7618
7619 : check for non-blocking I/O stuff
7620 case "$h_sysfile" in
7621 true) echo "#include <sys/file.h>" > head.c;;
7622 *)
7623         case "$h_fcntl" in
7624         true) echo "#include <fcntl.h>" > head.c;;
7625         *) echo "#include <sys/fcntl.h>" > head.c;;
7626         esac
7627         ;;
7628 esac
7629 echo " "
7630 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7631 case "$o_nonblock" in
7632 '')
7633         $cat head.c > try.c
7634         $cat >>try.c <<'EOCP'
7635 int main() {
7636 #ifdef O_NONBLOCK
7637         printf("O_NONBLOCK\n");
7638         exit(0);
7639 #endif
7640 #ifdef O_NDELAY
7641         printf("O_NDELAY\n");
7642         exit(0);
7643 #endif
7644 #ifdef FNDELAY
7645         printf("FNDELAY\n");
7646         exit(0);
7647 #endif
7648         exit(0);
7649 }
7650 EOCP
7651         set try
7652         if eval $compile_ok; then
7653                 o_nonblock=`./try`
7654                 case "$o_nonblock" in
7655                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7656                 *) echo "Seems like we can use $o_nonblock.";;
7657                 esac
7658         else
7659                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7660         fi
7661         ;;
7662 *) echo "Using $hint value $o_nonblock.";;
7663 esac
7664 $rm -f try try.* .out core
7665
7666 echo " "
7667 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7668 case "$eagain" in
7669 '')
7670         $cat head.c > try.c
7671         $cat >>try.c <<EOCP
7672 #include <errno.h>
7673 #include <sys/types.h>
7674 #include <signal.h>
7675 #define MY_O_NONBLOCK $o_nonblock
7676 #ifndef errno  /* XXX need better Configure test */
7677 extern int errno;
7678 #endif
7679 $signal_t blech(x) int x; { exit(3); }
7680 EOCP
7681         $cat >> try.c <<'EOCP'
7682 int main()
7683 {
7684         int pd[2];
7685         int pu[2];
7686         char buf[1];
7687         char string[100];
7688
7689         pipe(pd);       /* Down: child -> parent */
7690         pipe(pu);       /* Up: parent -> child */
7691         if (0 != fork()) {
7692                 int ret;
7693                 close(pd[1]);   /* Parent reads from pd[0] */
7694                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7695                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7696                         exit(1);
7697                 signal(SIGALRM, blech);
7698                 alarm(5);
7699                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7700                         exit(2);
7701                 sprintf(string, "%d\n", ret);
7702                 write(2, string, strlen(string));
7703                 alarm(0);
7704 #ifdef EAGAIN
7705                 if (errno == EAGAIN) {
7706                         printf("EAGAIN\n");
7707                         goto ok;
7708                 }
7709 #endif
7710 #ifdef EWOULDBLOCK
7711                 if (errno == EWOULDBLOCK)
7712                         printf("EWOULDBLOCK\n");
7713 #endif
7714         ok:
7715                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7716                 sleep(2);                               /* Give it time to close our pipe */
7717                 alarm(5);
7718                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7719                 alarm(0);
7720                 sprintf(string, "%d\n", ret);
7721                 write(3, string, strlen(string));
7722                 exit(0);
7723         }
7724
7725         close(pd[0]);                   /* We write to pd[1] */
7726         close(pu[1]);                   /* We read from pu[0] */
7727         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7728         close(pd[1]);                   /* Pipe pd is now fully closed! */
7729         exit(0);                                /* Bye bye, thank you for playing! */
7730 }
7731 EOCP
7732         set try
7733         if eval $compile_ok; then
7734                 echo "$startsh" >mtry
7735                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7736                 chmod +x mtry
7737                 ./mtry >/dev/null 2>&1
7738                 case $? in
7739                 0) eagain=`$cat try.out`;;
7740                 1) echo "Could not perform non-blocking setting!";;
7741                 2) echo "I did a successful read() for something that was not there!";;
7742                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7743                 *) echo "Something terribly wrong happened during testing.";;
7744                 esac
7745                 rd_nodata=`$cat try.ret`
7746                 echo "A read() system call with no data present returns $rd_nodata."
7747                 case "$rd_nodata" in
7748                 0|-1) ;;
7749                 *)
7750                         echo "(That's peculiar, fixing that to be -1.)"
7751                         rd_nodata=-1
7752                         ;;
7753                 esac
7754                 case "$eagain" in
7755                 '')
7756                         echo "Forcing errno EAGAIN on read() with no data available."
7757                         eagain=EAGAIN
7758                         ;;
7759                 *)
7760                         echo "Your read() sets errno to $eagain when no data is available."
7761                         ;;
7762                 esac
7763                 status=`$cat try.err`
7764                 case "$status" in
7765                 0) echo "And it correctly returns 0 to signal EOF.";;
7766                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7767                 *) echo "However, your read() returns '$status' on EOF??";;
7768                 esac
7769                 val="$define"
7770                 if test "$status" = "$rd_nodata"; then
7771                         echo "WARNING: you can't distinguish between EOF and no data!"
7772                         val="$undef"
7773                 fi
7774         else
7775                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7776                 eagain=EAGAIN
7777         fi
7778         set d_eofnblk
7779         eval $setvar
7780         ;;
7781 *)
7782         echo "Using $hint value $eagain."
7783         echo "Your read() returns $rd_nodata when no data is present."
7784         case "$d_eofnblk" in
7785         "$define") echo "And you can see EOF because read() returns 0.";;
7786         "$undef") echo "But you can't see EOF status from read() returned value.";;
7787         *)
7788                 echo "(Assuming you can't see EOF status from read anyway.)"
7789                 d_eofnblk=$undef
7790                 ;;
7791         esac
7792         ;;
7793 esac
7794 $rm -f try try.* .out core head.c mtry
7795
7796 : see if fchmod exists
7797 set fchmod d_fchmod
7798 eval $inlibc
7799
7800 : see if fchown exists
7801 set fchown d_fchown
7802 eval $inlibc
7803
7804 : see if this is an fcntl system
7805 set fcntl d_fcntl
7806 eval $inlibc
7807
7808 : see if sys/select.h has to be included
7809 set sys/select.h i_sysselct
7810 eval $inhdr
7811
7812 : see if we should include time.h, sys/time.h, or both
7813 echo " "
7814 if test "X$timeincl" = X; then
7815         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7816         $echo $n "I'm now running the test program...$c"
7817         $cat >try.c <<'EOCP'
7818 #include <sys/types.h>
7819 #ifdef I_TIME
7820 #include <time.h>
7821 #endif
7822 #ifdef I_SYSTIME
7823 #ifdef SYSTIMEKERNEL
7824 #define KERNEL
7825 #endif
7826 #include <sys/time.h>
7827 #endif
7828 #ifdef I_SYSSELECT
7829 #include <sys/select.h>
7830 #endif
7831 int main()
7832 {
7833         struct tm foo;
7834 #ifdef S_TIMEVAL
7835         struct timeval bar;
7836 #endif
7837 #ifdef S_TIMEZONE
7838         struct timezone tzp;
7839 #endif
7840         if (foo.tm_sec == foo.tm_sec)
7841                 exit(0);
7842 #ifdef S_TIMEVAL
7843         if (bar.tv_sec == bar.tv_sec)
7844                 exit(0);
7845 #endif
7846         exit(1);
7847 }
7848 EOCP
7849         flags=''
7850         for s_timezone in '-DS_TIMEZONE' ''; do
7851         sysselect=''
7852         for s_timeval in '-DS_TIMEVAL' ''; do
7853         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7854         for i_time in '' '-DI_TIME'; do
7855         for i_systime in '-DI_SYSTIME' ''; do
7856                 case "$flags" in
7857                 '') $echo $n ".$c"
7858                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7859                         if eval $compile; then
7860                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7861                                 shift
7862                                 flags="$*"
7863                                 echo " "
7864                                 $echo $n "Succeeded with $flags$c"
7865                         fi
7866                         ;;
7867                 esac
7868         done
7869         done
7870         done
7871         done
7872         done
7873         timeincl=''
7874         echo " "
7875         case "$flags" in
7876         *SYSTIMEKERNEL*) i_systimek="$define"
7877                 timeincl=`./findhdr sys/time.h`
7878                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7879         *) i_systimek="$undef";;
7880         esac
7881         case "$flags" in
7882         *I_TIME*) i_time="$define"
7883                 timeincl=`./findhdr time.h`" $timeincl"
7884                 echo "We'll include <time.h>." >&4;;
7885         *) i_time="$undef";;
7886         esac
7887         case "$flags" in
7888         *I_SYSTIME*) i_systime="$define"
7889                 timeincl=`./findhdr sys/time.h`" $timeincl"
7890                 echo "We'll include <sys/time.h>." >&4;;
7891         *) i_systime="$undef";;
7892         esac
7893         $rm -f try.c try
7894 fi
7895
7896 : check for fd_set items
7897 $cat <<EOM
7898
7899 Checking to see how well your C compiler handles fd_set and friends ...
7900 EOM
7901 $cat >fd_set.c <<EOCP
7902 #$i_systime I_SYS_TIME
7903 #$i_sysselct I_SYS_SELECT
7904 #$d_socket HAS_SOCKET
7905 #include <sys/types.h>
7906 #ifdef HAS_SOCKET
7907 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7908 #endif
7909 #ifdef I_SYS_TIME
7910 #include <sys/time.h>
7911 #endif
7912 #ifdef I_SYS_SELECT
7913 #include <sys/select.h>
7914 #endif
7915 int main() {
7916         fd_set fds;
7917
7918 #ifdef TRYBITS
7919         if(fds.fds_bits);
7920 #endif
7921
7922 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7923         exit(0);
7924 #else
7925         exit(1);
7926 #endif
7927 }
7928 EOCP
7929 set fd_set -DTRYBITS
7930 if eval $compile; then
7931         d_fds_bits="$define"
7932         d_fd_set="$define"
7933         echo "Well, your system knows about the normal fd_set typedef..." >&4
7934         if ./fd_set; then
7935                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7936                 d_fd_macros="$define"
7937         else
7938                 $cat >&4 <<'EOM'
7939 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7940 EOM
7941                 d_fd_macros="$undef"
7942         fi
7943 else
7944         $cat <<'EOM'
7945 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7946 EOM
7947         set fd_set
7948         if eval $compile; then
7949                 d_fds_bits="$undef"
7950                 d_fd_set="$define"
7951                 echo "Well, your system has some sort of fd_set available..." >&4
7952                 if ./fd_set; then
7953                         echo "and you have the normal fd_set macros." >&4
7954                         d_fd_macros="$define"
7955                 else
7956                         $cat <<'EOM'
7957 but not the normal fd_set macros!  Gross!  More work for me...
7958 EOM
7959                         d_fd_macros="$undef"
7960                 fi
7961         else
7962         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7963                 d_fd_set="$undef"
7964                 d_fds_bits="$undef"
7965                 d_fd_macros="$undef"
7966         fi
7967 fi
7968 $rm -f fd_set*
7969
7970 : see if fgetpos exists
7971 set fgetpos d_fgetpos
7972 eval $inlibc
7973
7974
7975 if $test X"$use64bits" = X"$define"; then
7976         : see if fgetpos64 exists
7977         set fgetpos64 d_fgetpos64
7978         eval $inlibc
7979
7980         : see if fopen64 exists
7981         set freopen64 d_fopen64
7982         eval $inlibc
7983
7984         : see if freopen64 exists
7985         set freopen64 d_freopen64
7986         eval $inlibc
7987
7988         : see if fseek64 exists
7989         set fseek64 d_fseek64
7990         eval $inlibc
7991
7992         : see if fseeko64 exists
7993         set fseeko64 d_fseeko64
7994         eval $inlibc
7995
7996         : see if fsetpos64 exists
7997         set fsetpos64 d_fsetpos64
7998         eval $inlibc
7999
8000         : see if ftell64 exists
8001         set ftell64 d_ftell64
8002         eval $inlibc
8003
8004         : see if ftello64 exists
8005         set ftello64 d_ftello64
8006         eval $inlibc
8007
8008         : see if tmpfile64 exists
8009         set tmpfile64 d_tmpfile64
8010         eval $inlibc
8011 else
8012         val="$undef"
8013         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
8014         do
8015                 set $xxx
8016                 eval $setvar
8017         done
8018 fi
8019
8020 : see if flock exists
8021 set flock d_flock
8022 eval $inlibc
8023
8024 : see if fork exists
8025 set fork d_fork
8026 eval $inlibc
8027
8028 : see if pathconf exists
8029 set pathconf d_pathconf
8030 eval $inlibc
8031
8032 : see if fpathconf exists
8033 set fpathconf d_fpathconf
8034 eval $inlibc
8035
8036 : see if fseeko exists
8037 set fseeko d_fseeko
8038 eval $inlibc
8039
8040 : see if fsetpos exists
8041 set fsetpos d_fsetpos
8042 eval $inlibc
8043
8044 : see if this is a sys/param system
8045 set sys/param.h i_sysparam
8046 eval $inhdr
8047
8048 : see if this is a sys/mount.h system
8049 set sys/mount.h i_sysmount
8050 eval $inhdr
8051
8052
8053 : see if statfs exists
8054 set statfs d_statfs
8055 eval $inlibc
8056
8057 : see if fstatfs exists
8058 set fstatfs d_fstatfs
8059 eval $inlibc
8060
8061 : see if statfs knows about mount flags
8062 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8063 eval $hasfield
8064
8065
8066 : see if statvfs exists
8067 set statvfs d_statvfs
8068 eval $inlibc
8069
8070 : see if fstatvfs exists
8071 set fstatvfs d_fstatvfs
8072 eval $inlibc
8073
8074
8075 : see if ftello exists
8076 set ftello d_ftello
8077 eval $inlibc
8078
8079 : see if getgrent exists
8080 set getgrent d_getgrent
8081 eval $inlibc
8082
8083 : see if gethostbyaddr exists
8084 set gethostbyaddr d_gethbyaddr
8085 eval $inlibc
8086
8087 : see if gethostbyname exists
8088 set gethostbyname d_gethbyname
8089 eval $inlibc
8090
8091 : see if gethostent exists
8092 set gethostent d_gethent
8093 eval $inlibc
8094
8095 : see how we will look up host name
8096 echo " "
8097 call=''
8098 if set gethostname val -f d_gethname; eval $csym; $val; then
8099         echo 'gethostname() found.' >&4
8100         d_gethname="$define"
8101         call=gethostname
8102 fi
8103 if set uname val -f d_uname; eval $csym; $val; then
8104         if ./xenix; then
8105                 $cat <<'EOM'
8106 uname() was found, but you're running xenix, and older versions of xenix
8107 have a broken uname(). If you don't really know whether your xenix is old
8108 enough to have a broken system call, use the default answer.
8109
8110 EOM
8111                 dflt=y
8112                 case "$d_uname" in
8113                 "$define") dflt=n;;
8114                 esac
8115                 rp='Is your uname() broken?'
8116                 . ./myread
8117                 case "$ans" in
8118                 n*) d_uname="$define"; call=uname;;
8119                 esac
8120         else
8121                 echo 'uname() found.' >&4
8122                 d_uname="$define"
8123                 case "$call" in
8124                 '') call=uname ;;
8125                 esac
8126         fi
8127 fi
8128 case "$d_gethname" in
8129 '') d_gethname="$undef";;
8130 esac
8131 case "$d_uname" in
8132 '') d_uname="$undef";;
8133 esac
8134 case "$d_uname$d_gethname" in
8135 *define*)
8136         dflt=n
8137         cat <<EOM
8138  
8139 Every now and then someone has a $call() that lies about the hostname
8140 but can't be fixed for political or economic reasons.  If you wish, I can
8141 pretend $call() isn't there and maybe compute hostname at run-time
8142 thanks to the '$phostname' command.
8143
8144 EOM
8145         rp="Shall I ignore $call() from now on?"
8146         . ./myread
8147         case "$ans" in
8148         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8149         esac;;
8150 esac
8151 case "$phostname" in
8152 '') aphostname='';;
8153 *) case "$aphostname" in
8154         /*) ;;
8155         *) set X $phostname
8156                 shift
8157                 file=$1
8158                 shift
8159                 file=`./loc $file $file $pth`
8160                 aphostname=`echo $file $*`
8161                 ;;
8162         esac
8163         ;;
8164 esac
8165 case "$d_uname$d_gethname" in
8166 *define*) ;;
8167 *)
8168         case "$phostname" in
8169         '')
8170                 echo "There will be no way for $package to get your hostname." >&4;;
8171         *)
8172         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8173                 ;;
8174         esac;;
8175 esac
8176 case "$d_phostname" in
8177 '') d_phostname="$undef";;
8178 esac
8179
8180 : see if this is a netdb.h system
8181 set netdb.h i_netdb
8182 eval $inhdr
8183
8184 : see if prototypes for various gethostxxx netdb.h functions are available
8185 echo " "
8186 set d_gethostprotos gethostent $i_netdb netdb.h
8187 eval $hasproto
8188
8189 : see if getlogin exists
8190 set getlogin d_getlogin
8191 eval $inlibc
8192
8193 : see if getmntent exists
8194 set getmntent d_getmntent
8195 eval $inlibc
8196
8197 : see if getnetbyaddr exists
8198 set getnetbyaddr d_getnbyaddr
8199 eval $inlibc
8200
8201 : see if getnetbyname exists
8202 set getnetbyname d_getnbyname
8203 eval $inlibc
8204
8205 : see if getnetent exists
8206 set getnetent d_getnent
8207 eval $inlibc
8208
8209 : see if prototypes for various getnetxxx netdb.h functions are available
8210 echo " "
8211 set d_getnetprotos getnetent $i_netdb netdb.h
8212 eval $hasproto
8213
8214
8215 : see if getprotobyname exists
8216 set getprotobyname d_getpbyname
8217 eval $inlibc
8218
8219 : see if getprotobynumber exists
8220 set getprotobynumber d_getpbynumber
8221 eval $inlibc
8222
8223 : see if getprotoent exists
8224 set getprotoent d_getpent
8225 eval $inlibc
8226
8227 : see if getpgid exists
8228 set getpgid d_getpgid
8229 eval $inlibc
8230
8231 : see if getpgrp2 exists
8232 set getpgrp2 d_getpgrp2
8233 eval $inlibc
8234
8235 : see if getppid exists
8236 set getppid d_getppid
8237 eval $inlibc
8238
8239 : see if getpriority exists
8240 set getpriority d_getprior
8241 eval $inlibc
8242
8243 : see if prototypes for various getprotoxxx netdb.h functions are available
8244 echo " "
8245 set d_getprotoprotos getprotoent $i_netdb netdb.h
8246 eval $hasproto
8247
8248 : see if getpwent exists
8249 set getpwent d_getpwent
8250 eval $inlibc
8251
8252
8253 : see if getservbyname exists
8254 set getservbyname d_getsbyname
8255 eval $inlibc
8256
8257 : see if getservbyport exists
8258 set getservbyport d_getsbyport
8259 eval $inlibc
8260
8261 : see if getservent exists
8262 set getservent d_getsent
8263 eval $inlibc
8264
8265 : see if prototypes for various getservxxx netdb.h functions are available
8266 echo " "
8267 set d_getservprotos getservent $i_netdb netdb.h
8268 eval $hasproto
8269
8270 : see if gettimeofday or ftime exists
8271 set gettimeofday d_gettimeod
8272 eval $inlibc
8273 case "$d_gettimeod" in
8274 "$undef")
8275         set ftime d_ftime 
8276         eval $inlibc
8277         ;;
8278 *)
8279         val="$undef"; set d_ftime; eval $setvar
8280         ;;
8281 esac
8282 case "$d_gettimeod$d_ftime" in
8283 "$undef$undef")
8284         echo " "
8285         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8286         ;;
8287 esac
8288
8289 : see if this is an grp system
8290 set grp.h i_grp
8291 eval $inhdr
8292
8293 case "$i_grp" in
8294 $define)
8295         xxx=`./findhdr grp.h`
8296         $cppstdin $cppflags $cppminus < $xxx >$$.h
8297
8298         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8299                 val="$define"
8300         else
8301                 val="$undef"
8302         fi
8303         set d_grpasswd
8304         eval $setvar
8305
8306         $rm -f $$.h
8307         ;;
8308 *)
8309         val="$undef";
8310         set d_grpasswd; eval $setvar
8311         ;;
8312 esac
8313
8314 : see if hasmntopt exists
8315 set hasmntopt d_hasmntopt
8316 eval $inlibc
8317
8318 : see if this is a netinet/in.h or sys/in.h system
8319 set netinet/in.h i_niin sys/in.h i_sysin
8320 eval $inhdr
8321
8322 : see if arpa/inet.h has to be included
8323 set arpa/inet.h i_arpainet
8324 eval $inhdr
8325
8326 : see if htonl --and friends-- exists
8327 val=''
8328 set htonl val
8329 eval $inlibc
8330
8331 : Maybe they are macros.
8332 case "$val" in
8333 $undef)
8334         $cat >htonl.c <<EOM
8335 #include <stdio.h>
8336 #include <sys/types.h>
8337 #$i_niin I_NETINET_IN
8338 #$i_sysin I_SYS_IN
8339 #$i_arpainet I_ARPA_INET
8340 #ifdef I_NETINET_IN
8341 #include <netinet/in.h>
8342 #endif
8343 #ifdef I_SYS_IN
8344 #include <sys/in.h>
8345 #endif
8346 #ifdef I_ARPA_INET
8347 #include <arpa/inet.h>
8348 #endif
8349 #ifdef htonl
8350 printf("Defined as a macro.");
8351 #endif
8352 EOM
8353         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8354         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8355                 val="$define"
8356                 echo "But it seems to be defined as a macro." >&4
8357         fi
8358         $rm -f htonl.?
8359         ;;
8360 esac
8361 set d_htonl
8362 eval $setvar
8363
8364 : see which of string.h or strings.h is needed
8365 echo " "
8366 strings=`./findhdr string.h`
8367 if $test "$strings" && $test -r "$strings"; then
8368         echo "Using <string.h> instead of <strings.h>." >&4
8369         val="$define"
8370 else
8371         val="$undef"
8372         strings=`./findhdr strings.h`
8373         if $test "$strings" && $test -r "$strings"; then
8374                 echo "Using <strings.h> instead of <string.h>." >&4
8375         else
8376                 echo "No string header found -- You'll surely have problems." >&4
8377         fi
8378 fi
8379 set i_string
8380 eval $setvar
8381 case "$i_string" in
8382 "$undef") strings=`./findhdr strings.h`;;
8383 *)        strings=`./findhdr string.h`;;
8384 esac
8385
8386 : index or strchr
8387 echo " "
8388 if set index val -f; eval $csym; $val; then
8389         if set strchr val -f d_strchr; eval $csym; $val; then
8390                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8391                         val="$define"
8392                         vali="$undef"
8393                         echo "strchr() found." >&4
8394                 else
8395                         val="$undef"
8396                         vali="$define"
8397                         echo "index() found." >&4
8398                 fi
8399         else
8400                 val="$undef"
8401                 vali="$define"
8402                 echo "index() found." >&4
8403         fi
8404 else
8405         if set strchr val -f d_strchr; eval $csym; $val; then
8406                 val="$define"
8407                 vali="$undef"
8408                 echo "strchr() found." >&4
8409         else
8410                 echo "No index() or strchr() found!" >&4
8411                 val="$undef"
8412                 vali="$undef"
8413         fi
8414 fi
8415 set d_strchr; eval $setvar
8416 val="$vali"
8417 set d_index; eval $setvar
8418
8419 : check whether inet_aton exists
8420 set inet_aton d_inetaton
8421 eval $inlibc
8422
8423 : see if inttypes.h is available
8424 : we want a real compile instead of Inhdr because some systems
8425 : have an inttypes.h which includes non-existent headers
8426 echo " "
8427 $cat >try.c <<EOCP
8428 #include <inttypes.h>
8429 int main() {
8430         static int32_t foo32 = 0x12345678;
8431 }
8432 EOCP
8433 set try
8434 if eval $compile; then
8435         echo "<inttypes.h> found." >&4
8436         val="$define"
8437 else
8438         echo "<inttypes.h> NOT found." >&4
8439         val="$undef"
8440 fi
8441 $rm -f try.c try
8442 set i_inttypes
8443 eval $setvar
8444
8445 : check for int64_t
8446 case "$use64bits" in
8447 "$define" )
8448         echo " "
8449         echo $n "Checking to see if your system supports int64_t...$c" >&4
8450         $cat >try.c <<EOCP
8451 #include <sys/types.h>
8452 #$i_inttypes I_INTTYPES
8453 #ifdef I_INTTYPES
8454 #include <inttypes.h>
8455 #endif
8456 int64_t foo() { int64_t x; x = 7; return x; }
8457 EOCP
8458         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8459                 val="$define"
8460                 echo " Yup, it does." >&4
8461         else
8462                 val="$undef"
8463                 echo " Nope, it doesn't." >&4
8464         fi
8465         $rm -f try.*
8466         ;;
8467 *)      val="$undef"
8468         ;;
8469 esac
8470 set d_int64t
8471 eval $setvar
8472
8473
8474 : Look for isascii
8475 echo " "
8476 $cat >isascii.c <<'EOCP'
8477 #include <stdio.h>
8478 #include <ctype.h>
8479 int main() {
8480         int c = 'A';
8481         if (isascii(c))
8482                 exit(0);
8483         else
8484                 exit(1);
8485 }
8486 EOCP
8487 set isascii
8488 if eval $compile; then
8489         echo "isascii() found." >&4
8490         val="$define"
8491 else
8492         echo "isascii() NOT found." >&4
8493         val="$undef"
8494 fi
8495 set d_isascii
8496 eval $setvar
8497 $rm -f isascii*
8498
8499 : see if killpg exists
8500 set killpg d_killpg
8501 eval $inlibc
8502
8503 : see if lchown exists
8504 echo " "
8505 $cat > try.c <<'EOCP'
8506 /* System header to define __stub macros and hopefully few prototypes,
8507     which can conflict with char lchown(); below.  */
8508 #include <assert.h>
8509 /* Override any gcc2 internal prototype to avoid an error.  */
8510 /* We use char because int might match the return type of a gcc2
8511    builtin and then its argument prototype would still apply.  */
8512 char lchown();
8513 int main() {
8514     /*  The GNU C library defines this for functions which it implements
8515         to always fail with ENOSYS.  Some functions are actually named
8516         something starting with __ and the normal name is an alias.  */
8517 #if defined (__stub_lchown) || defined (__stub___lchown)
8518 choke me
8519 #else
8520 lchown();
8521 #endif
8522 ; return 0; }
8523 EOCP
8524 set try
8525 if eval $compile; then
8526     $echo "lchown() found." >&4
8527     val="$define"
8528 else
8529     $echo "lchown() NOT found." >&4
8530     val="$undef"
8531 fi
8532 set d_lchown
8533 eval $setvar
8534
8535 : see if link exists
8536 set link d_link
8537 eval $inlibc
8538
8539 : see if localeconv exists
8540 set localeconv d_locconv
8541 eval $inlibc
8542
8543 : see if lockf exists
8544 set lockf d_lockf
8545 eval $inlibc
8546
8547 : check for length of double
8548 echo " "
8549 case "$doublesize" in
8550 '')
8551         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8552         $cat >try.c <<'EOCP'
8553 #include <stdio.h>
8554 int main()
8555 {
8556         printf("%d\n", sizeof(double));
8557 }
8558 EOCP
8559         set try
8560         if eval $compile_ok; then
8561                 doublesize=`./try`
8562                 $echo " $doublesize bytes." >&4
8563         else
8564                 dflt='8'
8565                 echo "(I can't seem to compile the test program.  Guessing...)"
8566                 rp="What is the size of a double precision number (in bytes)?"
8567                 . ./myread
8568                 doublesize="$ans"
8569         fi
8570         ;;
8571 esac
8572 $rm -f try.c try
8573
8574 : check for long doubles
8575 echo " "
8576 echo $n "Checking to see if your system supports long doubles...$c" >&4
8577 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8578 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8579         val="$define"
8580         echo " Yup, it does." >&4
8581 else
8582         val="$undef"
8583         echo " Nope, it doesn't." >&4
8584 fi
8585 $rm try.*
8586 set d_longdbl
8587 eval $setvar
8588
8589 : check for length of long double
8590 case "${d_longdbl}${longdblsize}" in
8591 $define)
8592         echo " "
8593         $echo $n "Checking to see how big your long doubles are...$c" >&4
8594         $cat >try.c <<'EOCP'
8595 #include <stdio.h>
8596 int main()
8597 {
8598         printf("%d\n", sizeof(long double));
8599 }
8600 EOCP
8601         set try
8602         if eval $compile; then
8603                 longdblsize=`./try`
8604                 $echo " $longdblsize bytes." >&4
8605         else
8606                 dflt='8'
8607                 echo " "
8608                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8609                 rp="What is the size of a long double (in bytes)?"
8610                 . ./myread
8611                 longdblsize="$ans"
8612         fi
8613         if $test "X$doublesize" = "X$longdblsize"; then
8614                 echo "(That isn't any different from an ordinary double.)"
8615         fi      
8616         ;;
8617 esac
8618 $rm -f try.c try
8619
8620 : check for long long
8621 echo " "
8622 echo $n "Checking to see if your system supports long long...$c" >&4
8623 echo 'long long foo() { long long x; x = 7; 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_longlong
8633 eval $setvar
8634
8635 : check for length of long long
8636 case "${d_longlong}${longlongsize}" in
8637 $define)
8638         echo " "
8639         $echo $n "Checking to see how big your long longs are...$c" >&4
8640         $cat >try.c <<'EOCP'
8641 #include <stdio.h>
8642 int main()
8643 {
8644         printf("%d\n", sizeof(long long));
8645 }
8646 EOCP
8647         set try
8648         if eval $compile_ok; then
8649                 longlongsize=`./try`
8650                 $echo " $longlongsize bytes." >&4
8651         else
8652                 dflt='8'
8653                 echo " "
8654                 echo "(I can't seem to compile the test program.  Guessing...)"
8655                 rp="What is the size of a long long (in bytes)?"
8656                 . ./myread
8657                 longlongsize="$ans"
8658         fi
8659         if $test "X$longsize" = "X$longlongsize"; then
8660                 echo "(That isn't any different from an ordinary long.)"
8661         fi      
8662         ;;
8663 esac
8664 $rm -f try.c try
8665
8666 : see if lstat exists
8667 set lstat d_lstat
8668 eval $inlibc
8669
8670 : see if madvise exists
8671 set madvise d_madvise
8672 eval $inlibc
8673
8674 : see if mblen exists
8675 set mblen d_mblen
8676 eval $inlibc
8677
8678 : see if mbstowcs exists
8679 set mbstowcs d_mbstowcs
8680 eval $inlibc
8681
8682 : see if mbtowc exists
8683 set mbtowc d_mbtowc
8684 eval $inlibc
8685
8686 : see if memchr exists
8687 set memchr d_memchr
8688 eval $inlibc
8689
8690 : see if memcmp exists
8691 set memcmp d_memcmp
8692 eval $inlibc
8693
8694 : see if memcpy exists
8695 set memcpy d_memcpy
8696 eval $inlibc
8697
8698 : see if memmove exists
8699 set memmove d_memmove
8700 eval $inlibc
8701
8702 : see if memset exists
8703 set memset d_memset
8704 eval $inlibc
8705
8706 : see if mkdir exists
8707 set mkdir d_mkdir
8708 eval $inlibc
8709
8710 : see if mkfifo exists
8711 set mkfifo d_mkfifo
8712 eval $inlibc
8713
8714 : see if mktime exists
8715 set mktime d_mktime
8716 eval $inlibc
8717
8718 : see if this is a sys/mman.h system
8719 set sys/mman.h i_sysmman
8720 eval $inhdr
8721
8722 : see if mmap exists
8723 set mmap d_mmap
8724 eval $inlibc
8725 : see what shmat returns
8726 : default to something harmless
8727 mmaptype='void *'
8728 case "$i_sysmman$d_mmap" in
8729 "$define$define")
8730         $cat >mmap.c <<'END'
8731 #include <sys/mman.h>
8732 void *mmap();
8733 END
8734         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8735                 mmaptype='void *'
8736         else
8737                 mmaptype='caddr_t'
8738         fi
8739         echo "and it returns ($mmaptype)." >&4
8740         ;;
8741 esac
8742
8743
8744
8745 : see if mprotect exists
8746 set mprotect d_mprotect
8747 eval $inlibc
8748
8749 : see if msgctl exists
8750 set msgctl d_msgctl
8751 eval $inlibc
8752
8753 : see if msgget exists
8754 set msgget d_msgget
8755 eval $inlibc
8756
8757 : see if msgsnd exists
8758 set msgsnd d_msgsnd
8759 eval $inlibc
8760
8761 : see if msgrcv exists
8762 set msgrcv d_msgrcv
8763 eval $inlibc
8764
8765 : see how much of the 'msg*(2)' library is present.
8766 h_msg=true
8767 echo " "
8768 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8769 *"$undef"*) h_msg=false;;
8770 esac
8771 case "$osname" in
8772 freebsd)
8773     case "`ipcs 2>&1`" in
8774     "SVID messages"*"not configured"*)
8775         echo "Your $osname does not have the msg*(2) configured." >&4
8776         h_msg=false
8777         val="$undef"
8778         set msgctl d_msgctl
8779         eval $setvar
8780         set msgget d_msgget
8781         eval $setvar
8782         set msgsnd d_msgsnd
8783         eval $setvar
8784         set msgrcv d_msgrcv
8785         eval $setvar
8786         ;;
8787     esac
8788     ;;
8789 esac
8790 : we could also check for sys/ipc.h ...
8791 if $h_msg && $test `./findhdr sys/msg.h`; then
8792         echo "You have the full msg*(2) library." >&4
8793         val="$define"
8794 else
8795         echo "You don't have the full msg*(2) library." >&4
8796         val="$undef"
8797 fi
8798 set d_msg
8799 eval $setvar
8800
8801 : see if msync exists
8802 set msync d_msync
8803 eval $inlibc
8804
8805 : see if munmap exists
8806 set munmap d_munmap
8807 eval $inlibc
8808
8809 : see if nice exists
8810 set nice d_nice
8811 eval $inlibc
8812
8813 : see if POSIX threads are available
8814 if test "X$usethreads" = "X$define"; then
8815         set pthread.h i_pthread
8816         eval $inhdr
8817 else
8818         i_pthread="$undef"
8819 fi
8820
8821
8822
8823 : how to create joinable pthreads
8824 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
8825         echo " "
8826         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8827         $cat >try.c <<'EOCP'
8828 #include <pthread.h>
8829 int main() {
8830     int detachstate = JOINABLE;
8831 }
8832 EOCP
8833         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8834         if eval $compile; then
8835                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8836                 val="$undef" # Yes, undef.
8837                 set d_old_pthread_create_joinable
8838                 eval $setvar
8839                 val=""
8840                 set old_pthread_create_joinable
8841                 eval $setvar
8842         else
8843                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8844                 if eval $compile; then
8845                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8846                         val="$define"
8847                         set d_old_pthread_create_joinable
8848                         eval $setvar
8849                         val=PTHREAD_CREATE_UNDETACHED
8850                         set old_pthread_create_joinable
8851                         eval $setvar
8852                 else            
8853                         set try -DJOINABLE=__UNDETACHED
8854                         if eval $compile; then
8855                                 echo "You seem to use __UNDETACHED." >&4
8856                                 val="$define"
8857                                 set d_old_pthread_create_joinable
8858                                 eval $setvar
8859                                 val=__UNDETACHED
8860                                 set old_pthread_create_joinable
8861                                 eval $setvar
8862                         else
8863                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8864                                 val="$define"
8865                                 set d_old_pthread_create_joinable
8866                                 eval $setvar
8867                                 val=0
8868                                 set old_pthread_create_joinable
8869                                 eval $setvar
8870                         fi
8871                 fi
8872         fi
8873         $rm -f try try.*
8874 else
8875     d_old_pthread_create_joinable="$undef"
8876     old_pthread_create_joinable=""
8877 fi
8878
8879 : see if pause exists
8880 set pause d_pause
8881 eval $inlibc
8882
8883 : see if pipe exists
8884 set pipe d_pipe
8885 eval $inlibc
8886
8887 : see if poll exists
8888 set poll d_poll
8889 eval $inlibc
8890
8891
8892 : see whether the various POSIXish _yields exist
8893 $cat >try.c <<EOP
8894 #include <pthread.h>
8895 #include <stdio.h>
8896 int main() {
8897 #ifdef SCHED_YIELD
8898         sched_yield();
8899 #else
8900 #ifdef PTHREAD_YIELD
8901         pthread_yield();
8902 #else
8903 #ifdef PTHREAD_YIELD_NULL
8904         pthread_yield(NULL);
8905 #endif
8906 #endif
8907 #endif
8908 }
8909 EOP
8910 : see if sched_yield exists
8911 set try -DSCHED_YIELD
8912 if eval $compile; then
8913     val="$define"
8914     sched_yield='sched_yield()'
8915 else
8916     val="$undef"
8917 fi
8918 case "$usethreads" in
8919 $define)
8920         case "$val" in
8921         $define) echo 'sched_yield() found.' >&4        ;;
8922         *)       echo 'sched_yield() NOT found.' >&4    ;;
8923         esac
8924 esac
8925 set d_sched_yield
8926 eval $setvar
8927
8928 : see if pthread_yield exists
8929 set try -DPTHREAD_YIELD
8930 if eval $compile; then
8931     val="$define"
8932     case "$sched_yield" in
8933     '') sched_yield='pthread_yield()' ;;
8934     esac
8935 else
8936     set try -DPTHREAD_YIELD_NULL
8937     if eval $compile; then
8938         val="$define"
8939         case "$sched_yield" in
8940         '') sched_yield='pthread_yield(NULL)' ;;
8941         esac
8942     else
8943         val="$undef"
8944     fi
8945 fi
8946 case "$usethreads" in
8947 $define)
8948         case "$val" in
8949         $define) echo 'pthread_yield() found.' >&4      ;;
8950         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8951         esac
8952         ;;
8953 esac
8954 set d_pthread_yield
8955 eval $setvar
8956
8957 case "$sched_yield" in
8958 '') sched_yield=undef ;;
8959 esac
8960
8961 $rm -f try try.*
8962
8963 : see if this is a pwd.h system
8964 set pwd.h i_pwd
8965 eval $inhdr
8966
8967 case "$i_pwd" in
8968 $define)
8969         xxx=`./findhdr pwd.h`
8970         $cppstdin $cppflags $cppminus < $xxx >$$.h
8971
8972         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8973                 val="$define"
8974         else
8975                 val="$undef"
8976         fi
8977         set d_pwquota
8978         eval $setvar
8979
8980         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
8981                 val="$define"
8982         else
8983                 val="$undef"
8984         fi
8985         set d_pwage
8986         eval $setvar
8987
8988         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
8989                 val="$define"
8990         else
8991                 val="$undef"
8992         fi
8993         set d_pwchange
8994         eval $setvar
8995
8996         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
8997                 val="$define"
8998         else
8999                 val="$undef"
9000         fi
9001         set d_pwclass
9002         eval $setvar
9003
9004         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
9005                 val="$define"
9006         else
9007                 val="$undef"
9008         fi
9009         set d_pwexpire
9010         eval $setvar
9011
9012         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
9013                 val="$define"
9014         else
9015                 val="$undef"
9016         fi
9017         set d_pwcomment
9018         eval $setvar
9019
9020         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
9021                 val="$define"
9022         else
9023                 val="$undef"
9024         fi
9025         set d_pwgecos
9026         eval $setvar
9027
9028         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
9029                 val="$define"
9030         else
9031                 val="$undef"
9032         fi
9033         set d_pwpasswd
9034         eval $setvar
9035
9036         $rm -f $$.h
9037         ;;
9038 *)
9039         val="$undef"; 
9040         set d_pwquota; eval $setvar
9041         set d_pwage; eval $setvar
9042         set d_pwchange; eval $setvar
9043         set d_pwclass; eval $setvar
9044         set d_pwexpire; eval $setvar
9045         set d_pwcomment; eval $setvar
9046         set d_pwgecos; eval $setvar
9047         set d_pwpasswd; eval $setvar
9048         ;;
9049 esac
9050
9051 : see if readdir and friends exist
9052 set readdir d_readdir
9053 eval $inlibc
9054 set seekdir d_seekdir
9055 eval $inlibc
9056 set telldir d_telldir
9057 eval $inlibc
9058 set rewinddir d_rewinddir
9059 eval $inlibc
9060
9061 : see if readlink exists
9062 set readlink d_readlink
9063 eval $inlibc
9064
9065 : see if readv exists
9066 set readv d_readv
9067 eval $inlibc
9068
9069 : see if rename exists
9070 set rename d_rename
9071 eval $inlibc
9072
9073 : see if rmdir exists
9074 set rmdir d_rmdir
9075 eval $inlibc
9076
9077 : see if memory.h is available.
9078 val=''
9079 set memory.h val
9080 eval $inhdr
9081
9082 : See if it conflicts with string.h
9083 case "$val" in
9084 $define)
9085         case "$strings" in
9086         '') ;;
9087         *)
9088                 $cppstdin $cppflags $cppminus < $strings > mem.h
9089                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9090                         echo " "
9091                         echo "We won't be including <memory.h>."
9092                         val="$undef"
9093                 fi
9094                 $rm -f mem.h
9095                 ;;
9096         esac
9097 esac
9098 set i_memory
9099 eval $setvar
9100
9101 : can bcopy handle overlapping blocks?
9102 val="$undef"
9103 case "$d_bcopy" in
9104 "$define")
9105         echo " "
9106         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9107         $cat >try.c <<EOCP
9108 #$i_memory I_MEMORY
9109 #$i_stdlib I_STDLIB
9110 #$i_string I_STRING
9111 #$i_unistd I_UNISTD
9112 EOCP
9113         $cat >>try.c <<'EOCP'
9114 #include <stdio.h>
9115 #ifdef I_MEMORY
9116 #  include <memory.h>
9117 #endif
9118 #ifdef I_STDLIB
9119 #  include <stdlib.h>
9120 #endif
9121 #ifdef I_STRING
9122 #  include <string.h>
9123 #else
9124 #  include <strings.h>
9125 #endif
9126 #ifdef I_UNISTD
9127 #  include <unistd.h>  /* Needed for NetBSD */
9128 #endif
9129 int main()
9130 {
9131 char buf[128], abc[128];
9132 char *b;
9133 int len;
9134 int off;
9135 int align;
9136
9137 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9138
9139 for (align = 7; align >= 0; align--) {
9140         for (len = 36; len; len--) {
9141                 b = buf+align;
9142                 bcopy(abc, b, len);
9143                 for (off = 1; off <= len; off++) {
9144                         bcopy(b, b+off, len);
9145                         bcopy(b+off, b, len);
9146                         if (bcmp(b, abc, len))
9147                                 exit(1);
9148                 }
9149         }
9150 }
9151 exit(0);
9152 }
9153 EOCP
9154         set try
9155         if eval $compile_ok; then
9156                 if ./try 2>/dev/null; then
9157                         echo "Yes, it can."
9158                         val="$define"
9159                 else
9160                         echo "It can't, sorry."
9161                         case "$d_memmove" in
9162                         "$define") echo "But that's Ok since you have memmove()." ;;
9163                         esac
9164                 fi
9165         else
9166                 echo "(I can't compile the test program, so we'll assume not...)"
9167                 case "$d_memmove" in
9168                 "$define") echo "But that's Ok since you have memmove()." ;;
9169                 esac
9170         fi
9171         ;;
9172 esac
9173 $rm -f try.* try core
9174 set d_safebcpy
9175 eval $setvar
9176
9177 : can memcpy handle overlapping blocks?
9178 val="$undef"
9179 case "$d_memcpy" in
9180 "$define")
9181         echo " "
9182         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9183         $cat >try.c <<EOCP
9184 #$i_memory I_MEMORY
9185 #$i_stdlib I_STDLIB
9186 #$i_string I_STRING
9187 #$i_unistd I_UNISTD
9188 EOCP
9189         $cat >>try.c <<'EOCP'
9190 #include <stdio.h>
9191 #ifdef I_MEMORY
9192 #  include <memory.h>
9193 #endif
9194 #ifdef I_STDLIB
9195 #  include <stdlib.h>
9196 #endif
9197 #ifdef I_STRING
9198 #  include <string.h>
9199 #else
9200 #  include <strings.h>
9201 #endif
9202 #ifdef I_UNISTD
9203 #  include <unistd.h>  /* Needed for NetBSD */
9204 #endif
9205 int main()
9206 {
9207 char buf[128], abc[128];
9208 char *b;
9209 int len;
9210 int off;
9211 int align;
9212
9213 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9214    try to store the string in read-only memory. */
9215 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9216
9217 for (align = 7; align >= 0; align--) {
9218         for (len = 36; len; len--) {
9219                 b = buf+align;
9220                 memcpy(b, abc, len);
9221                 for (off = 1; off <= len; off++) {
9222                         memcpy(b+off, b, len);
9223                         memcpy(b, b+off, len);
9224                         if (memcmp(b, abc, len))
9225                                 exit(1);
9226                 }
9227         }
9228 }
9229 exit(0);
9230 }
9231 EOCP
9232         set try
9233         if eval $compile_ok; then
9234                 if ./try 2>/dev/null; then
9235                         echo "Yes, it can."
9236                         val="$define"
9237                 else
9238                         echo "It can't, sorry."
9239                         case "$d_memmove" in
9240                         "$define") echo "But that's Ok since you have memmove()." ;;
9241                         esac
9242                 fi
9243         else
9244                 echo "(I can't compile the test program, so we'll assume not...)"
9245                 case "$d_memmove" in
9246                 "$define") echo "But that's Ok since you have memmove()." ;;
9247                 esac
9248         fi
9249         ;;
9250 esac
9251 $rm -f try.* try core
9252 set d_safemcpy
9253 eval $setvar
9254
9255 : can memcmp be trusted to compare relative magnitude?
9256 val="$undef"
9257 case "$d_memcmp" in
9258 "$define")
9259         echo " "
9260         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9261         $cat >try.c <<EOCP
9262 #$i_memory I_MEMORY
9263 #$i_stdlib I_STDLIB
9264 #$i_string I_STRING
9265 #$i_unistd I_UNISTD
9266 EOCP
9267         $cat >>try.c <<'EOCP'
9268 #include <stdio.h>
9269 #ifdef I_MEMORY
9270 #  include <memory.h>
9271 #endif
9272 #ifdef I_STDLIB
9273 #  include <stdlib.h>
9274 #endif
9275 #ifdef I_STRING
9276 #  include <string.h>
9277 #else
9278 #  include <strings.h>
9279 #endif
9280 #ifdef I_UNISTD
9281 #  include <unistd.h>  /* Needed for NetBSD */
9282 #endif
9283 int main()
9284 {
9285 char a = -1;
9286 char b = 0;
9287 if ((a < b) && memcmp(&a, &b, 1) < 0)
9288         exit(1);
9289 exit(0);
9290 }
9291 EOCP
9292         set try
9293         if eval $compile_ok; then
9294                 if ./try 2>/dev/null; then
9295                         echo "Yes, it can."
9296                         val="$define"
9297                 else
9298                         echo "No, it can't (it uses signed chars)."
9299                 fi
9300         else
9301                 echo "(I can't compile the test program, so we'll assume not...)"
9302         fi
9303         ;;
9304 esac
9305 $rm -f try.* try core
9306 set d_sanemcmp
9307 eval $setvar
9308
9309 : see if select exists
9310 set select d_select
9311 eval $inlibc
9312
9313 : see if semctl exists
9314 set semctl d_semctl
9315 eval $inlibc
9316
9317 : see if semget exists
9318 set semget d_semget
9319 eval $inlibc
9320
9321 : see if semop exists
9322 set semop d_semop
9323 eval $inlibc
9324
9325 : see how much of the 'sem*(2)' library is present.
9326 h_sem=true
9327 echo " "
9328 case "$d_semctl$d_semget$d_semop" in
9329 *"$undef"*) h_sem=false;;
9330 esac
9331 case "$osname" in
9332 freebsd)
9333     case "`ipcs 2>&1`" in
9334     "SVID messages"*"not configured"*)
9335         echo "Your $osname does not have the sem*(2) configured." >&4
9336         h_sem=false
9337         val="$undef"
9338         set semctl d_semctl
9339         eval $setvar
9340         set semget d_semget
9341         eval $setvar
9342         set semop d_semop
9343         eval $setvar
9344         ;;
9345     esac
9346     ;;
9347 esac
9348 : we could also check for sys/ipc.h ...
9349 if $h_sem && $test `./findhdr sys/sem.h`; then
9350         echo "You have the full sem*(2) library." >&4
9351         val="$define"
9352 else
9353         echo "You don't have the full sem*(2) library." >&4
9354         val="$undef"
9355 fi
9356 set d_sem
9357 eval $setvar
9358
9359 : see whether sys/sem.h defines union semun
9360 echo " "
9361 $cat > try.c <<'END'
9362 #include <sys/types.h>
9363 #include <sys/ipc.h>
9364 #include <sys/sem.h>
9365 int main () { union semun semun; semun.buf = 0; }
9366 END
9367 set try
9368 if eval $compile; then
9369     echo "You have union semun in <sys/sem.h>." >&4
9370     val="$define"
9371 else
9372     echo "You do not have union semun in <sys/sem.h>." >&4
9373     val="$undef"
9374 fi
9375 $rm -f try try.c try.h
9376 set d_union_semun
9377 eval $setvar
9378
9379 : see how to do semctl IPC_STAT
9380 case "$d_sem" in
9381 $define)
9382     : see whether semctl IPC_STAT can use union semun
9383     echo " "
9384     $cat > try.h <<END
9385 #ifndef S_IRUSR
9386 #   ifdef S_IREAD
9387 #       define S_IRUSR S_IREAD
9388 #       define S_IWUSR S_IWRITE
9389 #       define S_IXUSR S_IEXEC
9390 #   else
9391 #       define S_IRUSR 0400
9392 #       define S_IWUSR 0200
9393 #       define S_IXUSR 0100
9394 #   endif
9395 #   define S_IRGRP (S_IRUSR>>3)
9396 #   define S_IWGRP (S_IWUSR>>3)
9397 #   define S_IXGRP (S_IXUSR>>3)
9398 #   define S_IROTH (S_IRUSR>>6)
9399 #   define S_IWOTH (S_IWUSR>>6)
9400 #   define S_IXOTH (S_IXUSR>>6)
9401 #endif
9402 #ifndef S_IRWXU
9403 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9404 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9405 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9406 #endif
9407 END
9408
9409     $cat > try.c <<END
9410 #include <sys/types.h>
9411 #include <sys/ipc.h>
9412 #include <sys/sem.h>
9413 #include <sys/stat.h>
9414 #include <stdio.h>
9415 #include <errno.h>
9416 #include "try.h"
9417 #ifndef errno
9418 extern int errno;
9419 #endif
9420 #$d_union_semun HAS_UNION_SEMUN
9421 int main() {
9422     union semun
9423 #ifndef HAS_UNION_SEMUN
9424     {
9425         int val;
9426         struct semid_ds *buf;
9427         unsigned short *array;
9428     }
9429 #endif
9430     arg;
9431     int sem, st;
9432
9433 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9434     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9435     if (sem > -1) {
9436         struct semid_ds argbuf;
9437         arg.buf = &argbuf;
9438 #       ifdef IPC_STAT
9439         st = semctl(sem, 0, IPC_STAT, arg);
9440         if (st == 0)
9441             printf("semun\n");
9442         else
9443 #       endif /* IPC_STAT */
9444             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9445 #       ifdef IPC_RMID
9446         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9447 #       endif /* IPC_RMID */
9448             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9449     } else
9450 #endif /* IPC_PRIVATE && ... */
9451         printf("semget failed: errno = %d\n", errno);
9452   return 0;
9453 }
9454 END
9455     val="$undef"
9456     set try
9457     if eval $compile; then
9458         xxx=`./try`
9459         case "$xxx" in
9460         semun) val="$define" ;;
9461         esac
9462     fi
9463     $rm -f try try.c
9464     set d_semctl_semun
9465     eval $setvar
9466     case "$d_semctl_semun" in
9467     $define)
9468         echo "You can use union semun for semctl IPC_STAT." >&4
9469         also='also'
9470         ;;
9471     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9472         also=''
9473         ;;
9474     esac
9475
9476     : see whether semctl IPC_STAT can use struct semid_ds pointer
9477     $cat > try.c <<'END'
9478 #include <sys/types.h>
9479 #include <sys/ipc.h>
9480 #include <sys/sem.h>
9481 #include <sys/stat.h>
9482 #include "try.h"
9483 #include <stdio.h>
9484 #include <errno.h>
9485 #ifndef errno
9486 extern int errno;
9487 #endif
9488 int main() {
9489     struct semid_ds arg;
9490     int sem, st;
9491
9492 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9493     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9494     if (sem > -1) {
9495 #       ifdef IPC_STAT
9496         st = semctl(sem, 0, IPC_STAT, &arg);
9497         if (st == 0)
9498             printf("semid_ds\n");
9499         else
9500 #       endif /* IPC_STAT */
9501             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9502 #       ifdef IPC_RMID
9503         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9504 #       endif /* IPC_RMID */
9505             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9506     } else
9507 #endif /* IPC_PRIVATE && ... */
9508         printf("semget failed: errno = %d\n", errno);
9509
9510     return 0;
9511 }
9512 END
9513     val="$undef"
9514     set try
9515     if eval $compile; then
9516         xxx=`./try`
9517         case "$xxx" in
9518         semid_ds) val="$define" ;;
9519         esac
9520     fi
9521     $rm -f try try.c
9522     set d_semctl_semid_ds
9523     eval $setvar
9524     case "$d_semctl_semid_ds" in
9525     $define)
9526         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9527         ;;
9528     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9529         ;;
9530     esac
9531     $rm -f try.h
9532     ;;
9533 *)  val="$undef"
9534
9535     # We do not have the full sem*(2) library, so assume we can not
9536     # use either.
9537
9538     set d_semctl_semun
9539     eval $setvar
9540
9541     set d_semctl_semid_ds
9542     eval $setvar
9543     ;;
9544 esac
9545
9546 : see if setegid exists
9547 set setegid d_setegid
9548 eval $inlibc
9549
9550 : see if seteuid exists
9551 set seteuid d_seteuid
9552 eval $inlibc
9553
9554 : see if setgrent exists
9555 set setgrent d_setgrent
9556 eval $inlibc
9557
9558 : see if sethostent exists
9559 set sethostent d_sethent
9560 eval $inlibc
9561
9562 : see if setlinebuf exists
9563 set setlinebuf d_setlinebuf
9564 eval $inlibc
9565
9566 : see if setlocale exists
9567 set setlocale d_setlocale
9568 eval $inlibc
9569
9570 : see if setnetent exists
9571 set setnetent d_setnent
9572 eval $inlibc
9573
9574 : see if setprotoent exists
9575 set setprotoent d_setpent
9576 eval $inlibc
9577
9578 : see if setpgid exists
9579 set setpgid d_setpgid
9580 eval $inlibc
9581
9582 : see if setpgrp2 exists
9583 set setpgrp2 d_setpgrp2
9584 eval $inlibc
9585
9586 : see if setpriority exists
9587 set setpriority d_setprior
9588 eval $inlibc
9589
9590 : see if setpwent exists
9591 set setpwent d_setpwent
9592 eval $inlibc
9593
9594 : see if setregid exists
9595 set setregid d_setregid
9596 eval $inlibc
9597 set setresgid d_setresgid
9598 eval $inlibc
9599
9600 : see if setreuid exists
9601 set setreuid d_setreuid
9602 eval $inlibc
9603 set setresuid d_setresuid
9604 eval $inlibc
9605
9606 : see if setrgid exists
9607 set setrgid d_setrgid
9608 eval $inlibc
9609
9610 : see if setruid exists
9611 set setruid d_setruid
9612 eval $inlibc
9613
9614 : see if setservent exists
9615 set setservent d_setsent
9616 eval $inlibc
9617
9618 : see if setsid exists
9619 set setsid d_setsid
9620 eval $inlibc
9621
9622 : see if setvbuf exists
9623 set setvbuf d_setvbuf
9624 eval $inlibc
9625
9626 : see if sfio.h is available
9627 set sfio.h i_sfio
9628 eval $inhdr
9629
9630
9631 : see if sfio library is available
9632 case "$i_sfio" in
9633 $define)
9634         val=''
9635         set sfreserve val
9636         eval $inlibc
9637         ;;
9638 *)
9639         val="$undef"
9640         ;;
9641 esac
9642 : Ok, but do we want to use it.
9643 case "$val" in
9644 $define)
9645         case "$usesfio" in
9646         true|$define|[yY]*) dflt='y';;
9647         *) dflt='n';;
9648         esac
9649         echo "$package can use the sfio library, but it is experimental."
9650         rp="You seem to have sfio available, do you want to try using it?"
9651         . ./myread
9652         case "$ans" in
9653         y|Y) ;;
9654         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9655                 val="$undef"
9656                 : Remove sfio from list of libraries to use
9657                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9658                 shift
9659                 libs="$*"
9660                 echo "libs = $libs" >&4
9661                 ;;
9662         esac
9663         ;;
9664 *)      case "$usesfio" in
9665         true|$define|[yY]*)
9666                 echo "Sorry, cannot find sfio on this machine" >&4
9667                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9668                 ;;
9669         esac
9670         ;;
9671 esac
9672 set d_sfio
9673 eval $setvar
9674 case "$d_sfio" in
9675 $define) usesfio='true';;
9676 *) usesfio='false';;
9677 esac
9678
9679 : see if shmctl exists
9680 set shmctl d_shmctl
9681 eval $inlibc
9682
9683 : see if shmget exists
9684 set shmget d_shmget
9685 eval $inlibc
9686
9687 : see if shmat exists
9688 set shmat d_shmat
9689 eval $inlibc
9690 : see what shmat returns
9691 case "$d_shmat" in
9692 "$define")
9693         $cat >shmat.c <<'END'
9694 #include <sys/shm.h>
9695 void *shmat();
9696 END
9697         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9698                 shmattype='void *'
9699         else
9700                 shmattype='char *'
9701         fi
9702         echo "and it returns ($shmattype)." >&4
9703         : see if a prototype for shmat is available
9704         xxx=`./findhdr sys/shm.h`
9705         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9706         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9707                 val="$define"
9708         else
9709                 val="$undef"
9710         fi
9711         $rm -f shmat.[co]
9712         ;;
9713 *)
9714         val="$undef"
9715         ;;
9716 esac
9717 set d_shmatprototype
9718 eval $setvar
9719
9720 : see if shmdt exists
9721 set shmdt d_shmdt
9722 eval $inlibc
9723
9724 : see how much of the 'shm*(2)' library is present.
9725 h_shm=true
9726 echo " "
9727 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9728 *"$undef"*) h_shm=false;;
9729 esac
9730 case "$osname" in
9731 freebsd)
9732     case "`ipcs 2>&1`" in
9733     "SVID shared memory"*"not configured"*)
9734         echo "Your $osname does not have the shm*(2) configured." >&4
9735         h_shm=false
9736         val="$undef"
9737         set shmctl d_shmctl
9738         evat $setvar
9739         set shmget d_shmget
9740         evat $setvar
9741         set shmat d_shmat
9742         evat $setvar
9743         set shmdt d_shmdt
9744         evat $setvar
9745         ;;
9746     esac
9747     ;;
9748 esac
9749 : we could also check for sys/ipc.h ...
9750 if $h_shm && $test `./findhdr sys/shm.h`; then
9751         echo "You have the full shm*(2) library." >&4
9752         val="$define"
9753 else
9754         echo "You don't have the full shm*(2) library." >&4
9755         val="$undef"
9756 fi
9757 set d_shm
9758 eval $setvar
9759
9760 echo " "
9761 : see if we have sigaction
9762 if set sigaction val -f d_sigaction; eval $csym; $val; then
9763         echo 'sigaction() found.' >&4
9764         $cat > try.c <<'EOP'
9765 #include <stdio.h>
9766 #include <sys/types.h>
9767 #include <signal.h>
9768 int main()
9769 {
9770     struct sigaction act, oact;
9771 }
9772 EOP
9773         set try
9774         if eval $compile_ok; then
9775                 val="$define"
9776         else
9777                 echo "But you don't seem to have a useable struct sigaction." >&4
9778                 val="$undef"
9779         fi
9780 else
9781         echo 'sigaction NOT found.' >&4
9782         val="$undef"
9783 fi
9784 set d_sigaction; eval $setvar
9785 $rm -f try try$_o try.c
9786
9787 : see if sigsetjmp exists
9788 echo " "
9789 case "$d_sigsetjmp" in
9790 '')
9791         $cat >try.c <<'EOP'
9792 #include <setjmp.h>
9793 sigjmp_buf env;
9794 int set = 1;
9795 int main()
9796 {
9797         if (sigsetjmp(env,1))
9798                 exit(set);
9799         set = 0;
9800         siglongjmp(env, 1);
9801         exit(1);
9802 }
9803 EOP
9804         set try
9805         if eval $compile; then
9806                 if ./try >/dev/null 2>&1; then
9807                         echo "POSIX sigsetjmp found." >&4
9808                         val="$define"
9809                 else
9810                         $cat >&4 <<EOM
9811 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9812 I'll ignore them.
9813 EOM
9814                         val="$undef"
9815                 fi
9816         else
9817                 echo "sigsetjmp not found." >&4
9818                 val="$undef"
9819         fi
9820         ;;
9821 *) val="$d_sigsetjmp"
9822         case "$d_sigsetjmp" in
9823         $define) echo "POSIX sigsetjmp found." >&4;;
9824         $undef) echo "sigsetjmp not found." >&4;;
9825         esac
9826         ;;
9827 esac
9828 set d_sigsetjmp
9829 eval $setvar
9830 $rm -f try.c try
9831
9832 : see if stat knows about block sizes
9833 echo " "
9834 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9835 eval $hasfield
9836
9837 : see if _ptr and _cnt from stdio act std
9838 echo " "
9839 if $contains '_IO_fpos_t' `./findhdr stdio.h` `./findhdr libio.h` >/dev/null 2>&1 ; then
9840         echo "(Looks like you have stdio.h from Linux.)"
9841         case "$stdio_ptr" in
9842         '') stdio_ptr='((fp)->_IO_read_ptr)'
9843                 ptr_lval=$define
9844                 ;;
9845         *)      ptr_lval=$d_stdio_ptr_lval;;
9846         esac
9847         case "$stdio_cnt" in
9848         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9849                 cnt_lval=$undef
9850                 ;;
9851         *)      cnt_lval=$d_stdio_cnt_lval;;
9852         esac
9853         case "$stdio_base" in
9854         '') stdio_base='((fp)->_IO_read_base)';;
9855         esac
9856         case "$stdio_bufsiz" in
9857         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9858         esac
9859 else
9860         case "$stdio_ptr" in
9861         '') stdio_ptr='((fp)->_ptr)'
9862                 ptr_lval=$define
9863                 ;;
9864         *)      ptr_lval=$d_stdio_ptr_lval;;
9865         esac
9866         case "$stdio_cnt" in
9867         '') stdio_cnt='((fp)->_cnt)'
9868                 cnt_lval=$define
9869                 ;;
9870         *)      cnt_lval=$d_stdio_cnt_lval;;
9871         esac
9872         case "$stdio_base" in
9873         '') stdio_base='((fp)->_base)';;
9874         esac
9875         case "$stdio_bufsiz" in
9876         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9877         esac
9878 fi
9879 : test whether _ptr and _cnt really work
9880 echo "Checking how std your stdio is..." >&4
9881 $cat >try.c <<EOP
9882 #include <stdio.h>
9883 #define FILE_ptr(fp)    $stdio_ptr
9884 #define FILE_cnt(fp)    $stdio_cnt
9885 int main() {
9886         FILE *fp = fopen("try.c", "r");
9887         char c = getc(fp);
9888         if (
9889                 18 <= FILE_cnt(fp) &&
9890                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9891         )
9892                 exit(0);
9893         exit(1);
9894 }
9895 EOP
9896 val="$undef"
9897 set try
9898 if eval $compile; then
9899         if ./try; then
9900                 echo "Your stdio acts pretty std."
9901                 val="$define"
9902         else
9903                 echo "Your stdio isn't very std."
9904         fi
9905 else
9906         echo "Your stdio doesn't appear very std."
9907 fi
9908 $rm -f try.c try
9909 set d_stdstdio
9910 eval $setvar
9911
9912 : Can _ptr be used as an lvalue?
9913 case "$d_stdstdio$ptr_lval" in
9914 $define$define) val=$define ;;
9915 *) val=$undef ;;
9916 esac
9917 set d_stdio_ptr_lval
9918 eval $setvar
9919
9920 : Can _cnt be used as an lvalue?
9921 case "$d_stdstdio$cnt_lval" in
9922 $define$define) val=$define ;;
9923 *) val=$undef ;;
9924 esac
9925 set d_stdio_cnt_lval
9926 eval $setvar
9927
9928 : see if _base is also standard
9929 val="$undef"
9930 case "$d_stdstdio" in
9931 $define)
9932         $cat >try.c <<EOP
9933 #include <stdio.h>
9934 #define FILE_base(fp)   $stdio_base
9935 #define FILE_bufsiz(fp) $stdio_bufsiz
9936 int main() {
9937         FILE *fp = fopen("try.c", "r");
9938         char c = getc(fp);
9939         if (
9940                 19 <= FILE_bufsiz(fp) &&
9941                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9942         )
9943                 exit(0);
9944         exit(1);
9945 }
9946 EOP
9947         set try
9948         if eval $compile; then
9949                 if ./try; then
9950                         echo "And its _base field acts std."
9951                         val="$define"
9952                 else
9953                         echo "But its _base field isn't std."
9954                 fi
9955         else
9956                 echo "However, it seems to be lacking the _base field."
9957         fi
9958         $rm -f try.c try
9959         ;;
9960 esac
9961 set d_stdiobase
9962 eval $setvar
9963
9964 $cat >&4 <<EOM
9965 Checking how to access stdio streams by file descriptor number...
9966 EOM
9967 case "$stdio_stream_array" in
9968 '')     $cat >try.c <<EOCP
9969 #include <stdio.h>
9970 int main() {
9971   if (&STDIO_STREAM_ARRAY[fileno(stdin)] == stdin)
9972     printf("yes\n");
9973 }
9974 EOCP
9975         for s in _iob __iob __sF
9976         do
9977                 set try -DSTDIO_STREAM_ARRAY=$s
9978                 if eval $compile; then
9979                         case "`./try$exe_ext`" in
9980                         yes)    stdio_stream_array=$s; break ;;
9981                         esac
9982                 fi
9983         done
9984         $rm -f try.* try$exe_ext
9985 esac
9986 case "$stdio_stream_array" in
9987 '')     $cat >&4 <<EOM
9988 I can't figure out how to access stdio streams by file descriptor number.
9989 EOM
9990         d_stdio_stream_array="$undef"
9991         ;;
9992 *)      $cat >&4 <<EOM
9993 You can access stdio streams by file descriptor number by the $stdio_stream_array array.
9994 EOM
9995         d_stdio_stream_array="$define"
9996         ;;
9997 esac
9998
9999 : see if strcoll exists
10000 set strcoll d_strcoll
10001 eval $inlibc
10002
10003 : check for structure copying
10004 echo " "
10005 echo "Checking to see if your C compiler can copy structs..." >&4
10006 $cat >try.c <<'EOCP'
10007 int main()
10008 {
10009         struct blurfl {
10010                 int dyick;
10011         } foo, bar;
10012
10013         foo = bar;
10014 }
10015 EOCP
10016 if $cc -c try.c >/dev/null 2>&1 ; then
10017         val="$define"
10018         echo "Yup, it can."
10019 else
10020         val="$undef"
10021         echo "Nope, it can't."
10022 fi
10023 set d_strctcpy
10024 eval $setvar
10025 $rm -f try.*
10026
10027 : see if strerror and/or sys_errlist[] exist
10028 echo " "
10029 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
10030     if set strerror val -f d_strerror; eval $csym; $val; then
10031                 echo 'strerror() found.' >&4
10032                 d_strerror="$define"
10033                 d_strerrm='strerror(e)'
10034                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10035                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
10036                         d_syserrlst="$define"
10037                 else
10038                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
10039                         d_syserrlst="$undef"
10040                 fi
10041     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
10042                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
10043                 echo 'strerror() found in string header.' >&4
10044                 d_strerror="$define"
10045                 d_strerrm='strerror(e)'
10046                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10047                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
10048                                 d_syserrlst="$define"
10049                 else
10050                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
10051                         d_syserrlst="$undef"
10052                 fi
10053     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
10054                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
10055                 d_strerror="$undef"
10056                 d_syserrlst="$define"
10057                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
10058     else
10059                 echo 'strerror() and sys_errlist[] NOT found.' >&4
10060                 d_strerror="$undef"
10061                 d_syserrlst="$undef"
10062                 d_strerrm='"unknown"'
10063     fi
10064 fi
10065
10066 : see if strtod exists
10067 set strtod d_strtod
10068 eval $inlibc
10069
10070 : see if strtol exists
10071 set strtol d_strtol
10072 eval $inlibc
10073
10074 : see if strtoul exists
10075 set strtoul d_strtoul
10076 eval $inlibc
10077
10078 : see if strxfrm exists
10079 set strxfrm d_strxfrm
10080 eval $inlibc
10081
10082 : see if symlink exists
10083 set symlink d_symlink
10084 eval $inlibc
10085
10086 : see if syscall exists
10087 set syscall d_syscall
10088 eval $inlibc
10089
10090 : see if sysconf exists
10091 set sysconf d_sysconf
10092 eval $inlibc
10093
10094 : see if system exists
10095 set system d_system
10096 eval $inlibc
10097
10098 : see if tcgetpgrp exists
10099 set tcgetpgrp d_tcgetpgrp
10100 eval $inlibc
10101
10102 : see if tcsetpgrp exists
10103 set tcsetpgrp d_tcsetpgrp
10104 eval $inlibc
10105
10106 : see if sys/types.h has to be included
10107 set sys/types.h i_systypes
10108 eval $inhdr
10109
10110 : see if prototype for telldir is available
10111 echo " "
10112 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10113 eval $hasproto
10114
10115 : define an is-a-typedef? function
10116 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10117 case "$inclist" in
10118 "") inclist="sys/types.h";;
10119 esac;
10120 eval "varval=\$$var";
10121 case "$varval" in
10122 "")
10123         $rm -f temp.c;
10124         for inc in $inclist; do
10125                 echo "#include <$inc>" >>temp.c;
10126         done;
10127         echo "#ifdef $type" >> temp.c;
10128         echo "printf(\"We have $type\");" >> temp.c;
10129         echo "#endif" >> temp.c;
10130         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10131         if $contains $type temp.E >/dev/null 2>&1; then
10132                 eval "$var=\$type";
10133         else
10134                 eval "$var=\$def";
10135         fi;
10136         $rm -f temp.?;;
10137 *) eval "$var=\$varval";;
10138 esac'
10139
10140 : define an is-a-typedef? function that prompts if the type is not available.
10141 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10142 case "$inclist" in
10143 "") inclist="sys/types.h";;
10144 esac;
10145 eval "varval=\$$var";
10146 case "$varval" in
10147 "")
10148         $rm -f temp.c;
10149         for inc in $inclist; do
10150                 echo "#include <$inc>" >>temp.c;
10151         done;
10152         echo "#ifdef $type" >> temp.c;
10153         echo "printf(\"We have $type\");" >> temp.c;
10154         echo "#endif" >> temp.c;
10155         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10156         echo " " ;
10157         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10158         if $contains $type temp.E >/dev/null 2>&1; then
10159                 echo "$type found." >&4;
10160                 eval "$var=\$type";
10161         else
10162                 echo "$type NOT found." >&4;
10163                 dflt="$def";
10164                 . ./myread ;
10165                 eval "$var=\$ans";
10166         fi;
10167         $rm -f temp.?;;
10168 *) eval "$var=\$varval";;
10169 esac'
10170
10171 : see if this is a sys/times.h system
10172 set sys/times.h i_systimes
10173 eval $inhdr
10174
10175 : see if times exists
10176 echo " "
10177 if set times val -f d_times; eval $csym; $val; then
10178         echo 'times() found.' >&4
10179         d_times="$define"
10180         inc=''
10181         case "$i_systimes" in
10182         "$define") inc='sys/times.h';;
10183         esac
10184         rp="What is the type returned by times() on this system?"
10185         set clock_t clocktype long stdio.h sys/types.h $inc
10186         eval $typedef_ask
10187 else
10188         echo 'times() NOT found, hope that will do.' >&4
10189         d_times="$undef"
10190         clocktype='int'
10191 fi
10192
10193 : see if truncate exists
10194 set truncate d_truncate
10195 eval $inlibc
10196
10197 : see if tzname[] exists
10198 echo " "
10199 if set tzname val -a d_tzname; eval $csym; $val; then
10200         val="$define"
10201         echo 'tzname[] found.' >&4
10202 else
10203         val="$undef"
10204         echo 'tzname[] NOT found.' >&4
10205 fi
10206 set d_tzname
10207 eval $setvar
10208
10209 : see if umask exists
10210 set umask d_umask
10211 eval $inlibc
10212
10213 : backward compatibility for d_hvfork
10214 if test X$d_hvfork != X; then
10215         d_vfork="$d_hvfork"
10216         d_hvfork=''
10217 fi
10218 : see if there is a vfork
10219 val=''
10220 set vfork val
10221 eval $inlibc
10222
10223 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10224 : perl on Solaris 2.x, and probably elsewhere.
10225 case "$val" in
10226 $define)
10227         echo " "
10228         case "$usevfork" in
10229         false) dflt='n';;
10230         *) dflt='y';;
10231         esac
10232         cat <<'EOM'
10233  
10234 Perl can only use a vfork() that doesn't suffer from strict
10235 restrictions on calling functions or modifying global data in
10236 the child.  For example, glibc-2.1 contains such a vfork()
10237 that is unsuitable.  If your system provides a proper fork()
10238 call, chances are that you do NOT want perl to use vfork().
10239
10240 EOM
10241         rp="Do you still want to use vfork()?"
10242         . ./myread
10243         case "$ans" in
10244         y|Y) ;;
10245         *)
10246                 echo "Ok, we won't use vfork()."
10247                 val="$undef"
10248                 ;;
10249         esac
10250         ;;
10251 esac
10252 set d_vfork
10253 eval $setvar
10254 case "$d_vfork" in
10255 $define) usevfork='true';;
10256 *) usevfork='false';;
10257 esac
10258
10259 : see if this is an sysdir system
10260 set sys/dir.h i_sysdir
10261 eval $inhdr
10262
10263 : see if this is an sysndir system
10264 set sys/ndir.h i_sysndir
10265 eval $inhdr
10266
10267 : see if closedir exists
10268 set closedir d_closedir
10269 eval $inlibc
10270
10271 case "$d_closedir" in
10272 "$define")
10273         echo " "
10274         echo "Checking whether closedir() returns a status..." >&4
10275         cat > closedir.c <<EOM
10276 #$i_dirent I_DIRENT             /**/
10277 #$i_sysdir I_SYS_DIR            /**/
10278 #$i_sysndir I_SYS_NDIR          /**/
10279 #$i_systypes I_SYS_TYPES        /**/
10280
10281 #if defined(I_SYS_TYPES)
10282 #include <sys/types.h>
10283 #endif
10284 #if defined(I_DIRENT)
10285 #include <dirent.h>
10286 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10287 #include <sys/dir.h>
10288 #endif
10289 #else
10290 #ifdef I_SYS_NDIR
10291 #include <sys/ndir.h>
10292 #else
10293 #ifdef I_SYS_DIR
10294 #ifdef hp9000s500
10295 #include <ndir.h>       /* may be wrong in the future */
10296 #else
10297 #include <sys/dir.h>
10298 #endif
10299 #endif
10300 #endif
10301 #endif 
10302 int main() { return closedir(opendir(".")); }
10303 EOM
10304         set closedir
10305         if eval $compile_ok; then
10306                 if ./closedir > /dev/null 2>&1 ; then
10307                         echo "Yes, it does."
10308                         val="$undef"
10309                 else
10310                         echo "No, it doesn't."
10311                         val="$define"
10312                 fi
10313         else
10314                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10315                 val="$define"
10316         fi
10317         ;;
10318 *)
10319         val="$undef";
10320         ;;
10321 esac
10322 set d_void_closedir
10323 eval $setvar
10324 $rm -f closedir*
10325 : check for volatile keyword
10326 echo " "
10327 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10328 $cat >try.c <<'EOCP'
10329 int main()
10330 {
10331         typedef struct _goo_struct goo_struct;
10332         goo_struct * volatile goo = ((goo_struct *)0);
10333         struct _goo_struct {
10334                 long long_int;
10335                 int reg_int;
10336                 char char_var;
10337         };
10338         typedef unsigned short foo_t;
10339         char *volatile foo;
10340         volatile int bar;
10341         volatile foo_t blech;
10342         foo = foo;
10343 }
10344 EOCP
10345 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10346         val="$define"
10347         echo "Yup, it does."
10348 else
10349         val="$undef"
10350         echo "Nope, it doesn't."
10351 fi
10352 set d_volatile
10353 eval $setvar
10354 $rm -f try.*
10355
10356 : see if there is a wait4
10357 set wait4 d_wait4
10358 eval $inlibc
10359
10360 : see if waitpid exists
10361 set waitpid d_waitpid
10362 eval $inlibc
10363
10364 : see if wcstombs exists
10365 set wcstombs d_wcstombs
10366 eval $inlibc
10367
10368 : see if wctomb exists
10369 set wctomb d_wctomb
10370 eval $inlibc
10371
10372 : see if writev exists
10373 set writev d_writev
10374 eval $inlibc
10375
10376 : preserve RCS keywords in files with variable substitution, grrr
10377 Date='$Date'
10378 Id='$Id'
10379 Log='$Log'
10380 RCSfile='$RCSfile'
10381 Revision='$Revision'
10382
10383 case "$crosscompile" in
10384 ''|[nN]*) crosscompile="$undef" ;;
10385 esac
10386
10387 case "$osname" in
10388 next|rhapsody) multiarch="$define" ;;
10389 esac
10390 case "$multiarch" in
10391 ''|[nN]*) multiarch="$undef" ;;
10392 esac
10393
10394 : check for alignment requirements
10395 echo " "
10396 case "$crosscompile$multiarch" in
10397 *$define*)
10398         $cat <<EOM
10399 You seem to be either cross-compiling or doing a multiarchitecture build,
10400 skipping the memory alignment check.
10401
10402 EOM
10403         case "$alignbytes" in
10404         '') alignbytes=8 ;;
10405         esac
10406         ;;
10407 *)
10408         case "$alignbytes" in
10409         '') echo "Checking alignment constraints..." >&4
10410                 $cat >try.c <<'EOCP'
10411 struct foobar {
10412         char foo;
10413         double bar;
10414 } try_algn;
10415 int main()
10416 {
10417         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10418 }
10419 EOCP
10420                 set try
10421                 if eval $compile_ok; then
10422                         dflt=`./try`
10423                 else
10424                         dflt='8'
10425                         echo "(I can't seem to compile the test program...)"
10426                 fi
10427                 ;;
10428         *) dflt="$alignbytes"
10429                 ;;
10430         esac
10431         rp="Doubles must be aligned on a how-many-byte boundary?"
10432         . ./myread
10433         alignbytes="$ans"
10434         $rm -f try.c try
10435         ;;
10436 esac
10437
10438
10439 : check for ordering of bytes in a long
10440 echo " "
10441 case "$crosscompile$multiarch" in
10442 *$define*)
10443         $cat <<EOM
10444 You seem to be either cross-compiling or doing a multiarchitecture build,
10445 skipping the byteorder check.
10446
10447 EOM
10448         byteorder=''
10449         ;;
10450 *)
10451         case "$byteorder" in
10452         '')
10453                 $cat <<'EOM'
10454 In the following, larger digits indicate more significance.  A big-endian
10455 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10456 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10457 machines may have weird orders like 3412.  A Cray will report 87654321. If
10458 the test program works the default is probably right.
10459 I'm now running the test program...
10460 EOM
10461                 $cat >try.c <<'EOCP'
10462 #include <stdio.h>
10463 int main()
10464 {
10465         int i;
10466         union {
10467                 unsigned long l;
10468                 char c[sizeof(long)];
10469         } u;
10470
10471         if (sizeof(long) > 4)
10472                 u.l = (0x08070605L << 32) | 0x04030201L;
10473         else
10474                 u.l = 0x04030201L;
10475         for (i = 0; i < sizeof(long); i++)
10476                 printf("%c", u.c[i]+'0');
10477         printf("\n");
10478         exit(0);
10479 }
10480 EOCP
10481                 xxx_prompt=y
10482                 set try
10483                 if eval $compile && ./try > /dev/null; then
10484                         dflt=`./try`
10485                         case "$dflt" in
10486                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10487                                 echo "(The test program ran ok.)"
10488                                 echo "byteorder=$dflt"
10489                                 xxx_prompt=n
10490                         ;;
10491                         ????|????????) echo "(The test program ran ok.)" ;;
10492                         *) echo "(The test program didn't run right for some reason.)" ;;
10493                         esac
10494                 else
10495                         dflt='4321'
10496                         cat <<'EOM'
10497 (I can't seem to compile the test program.  Guessing big-endian...)
10498 EOM
10499                 fi
10500                 case "$xxx_prompt" in
10501                 y)
10502                         rp="What is the order of bytes in a long?"
10503                         . ./myread
10504                         byteorder="$ans"
10505                         ;;
10506                 *)      byteorder=$dflt
10507                         ;;
10508                 esac
10509                 ;;
10510         esac
10511         $rm -f try.c try
10512         ;;
10513 esac
10514
10515
10516 : how do we catenate cpp tokens here?
10517 echo " "
10518 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10519 $cat >cpp_stuff.c <<'EOCP'
10520 #define RCAT(a,b)a/**/b
10521 #define ACAT(a,b)a ## b
10522 RCAT(Rei,ser)
10523 ACAT(Cir,cus)
10524 EOCP
10525 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10526 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10527         echo "Oh!  Smells like ANSI's been here." >&4
10528         echo "We can catify or stringify, separately or together!"
10529         cpp_stuff=42
10530 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10531         echo "Ah, yes!  The good old days!" >&4
10532         echo "However, in the good old days we don't know how to stringify and"
10533         echo "catify at the same time."
10534         cpp_stuff=1
10535 else
10536         $cat >&4 <<EOM
10537 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10538 to have to edit the values of CAT[2-5] in config.h...
10539 EOM
10540         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10541 fi
10542 $rm -f cpp_stuff.*
10543
10544 : see if this is a db.h system
10545 set db.h i_db
10546 eval $inhdr
10547
10548 case "$i_db" in
10549 $define)
10550         : Check db version.
10551         echo " "
10552         echo "Checking Berkeley DB version ..." >&4
10553         $cat >try.c <<EOCP
10554 #$d_const HASCONST
10555 #ifndef HASCONST
10556 #define const
10557 #endif
10558 #include <sys/types.h>
10559 #include <stdio.h>
10560 #include <db.h>
10561 int main()
10562 {
10563 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10564     int Major, Minor, Patch ;
10565     unsigned long Version ;
10566     (void)db_version(&Major, &Minor, &Patch) ;
10567     printf("You have Berkeley DB Version 2 or greater\n");
10568
10569     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10570                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10571     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10572                 Major, Minor, Patch) ;
10573
10574     /* check that db.h & libdb are compatible */
10575     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10576         printf("db.h and libdb are incompatible\n") ;
10577         exit(3);        
10578     }
10579
10580     printf("db.h and libdb are compatible\n") ;
10581
10582     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10583                 + DB_VERSION_PATCH ;
10584
10585     /* needs to be >= 2.3.4 */
10586     if (Version < 2003004) {
10587     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10588         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10589         exit(2);        
10590     }
10591
10592     exit(0);
10593 #else
10594 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10595     printf("You have Berkeley DB Version 1\n");
10596     exit(0);    /* DB version < 2: the coast is clear. */
10597 #else
10598     exit(1);    /* <db.h> not Berkeley DB? */
10599 #endif
10600 #endif
10601 }
10602 EOCP
10603         set try
10604         if eval $compile && ./try; then
10605                 echo 'Looks OK.' >&4
10606         else
10607                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10608                 i_db=$undef
10609                 case " $libs " in
10610                 *"-ldb "*)
10611                         : Remove db from list of libraries to use
10612                         echo "Removing unusable -ldb from library list" >&4
10613                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10614                         shift
10615                         libs="$*"
10616                         echo "libs = $libs" >&4
10617                         ;;
10618                 esac
10619         fi
10620         $rm -f try.*
10621         ;;
10622 esac
10623
10624 case "$i_db" in
10625 define)
10626         : Check the return type needed for hash 
10627         echo " "
10628         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10629         $cat >try.c <<EOCP
10630 #$d_const HASCONST
10631 #ifndef HASCONST
10632 #define const
10633 #endif
10634 #include <sys/types.h>
10635 #include <db.h>
10636
10637 #ifndef DB_VERSION_MAJOR
10638 u_int32_t hash_cb (ptr, size)
10639 const void *ptr;
10640 size_t size;
10641 {
10642 }
10643 HASHINFO info;
10644 int main()
10645 {
10646         info.hash = hash_cb;
10647 }
10648 #endif
10649 EOCP
10650         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10651                 if $contains warning try.out >>/dev/null 2>&1 ; then
10652                         db_hashtype='int'
10653                 else
10654                         db_hashtype='u_int32_t'
10655                 fi
10656         else
10657                 : XXX Maybe we should just give up here.
10658                 db_hashtype=u_int32_t
10659                 $cat try.out >&4
10660                 echo "Help:  I can't seem to compile the db test program." >&4
10661                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10662         fi
10663         $rm -f try.*
10664         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10665         ;;
10666 *)      db_hashtype=u_int32_t
10667         ;;
10668 esac
10669 case "$i_db" in
10670 define)
10671         : Check the return type needed for prefix 
10672         echo " "
10673         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10674         cat >try.c <<EOCP
10675 #$d_const HASCONST
10676 #ifndef HASCONST
10677 #define const
10678 #endif
10679 #include <sys/types.h>
10680 #include <db.h>
10681
10682 #ifndef DB_VERSION_MAJOR
10683 size_t prefix_cb (key1, key2)
10684 const DBT *key1;
10685 const DBT *key2;
10686 {
10687 }
10688 BTREEINFO info;
10689 int main()
10690 {
10691         info.prefix = prefix_cb;
10692 }
10693 #endif
10694 EOCP
10695         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10696                 if $contains warning try.out >>/dev/null 2>&1 ; then
10697                         db_prefixtype='int'
10698                 else
10699                         db_prefixtype='size_t'
10700                 fi
10701         else
10702                 db_prefixtype='size_t'
10703                 : XXX Maybe we should just give up here.
10704                 $cat try.out >&4
10705                 echo "Help:  I can't seem to compile the db test program." >&4
10706                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10707         fi
10708         $rm -f try.*
10709         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10710         ;;
10711 *)      db_prefixtype='size_t'
10712         ;;
10713 esac
10714
10715 : check for void type
10716 echo " "
10717 echo "Checking to see how well your C compiler groks the void type..." >&4
10718 case "$voidflags" in
10719 '')
10720         $cat >try.c <<'EOCP'
10721 #if TRY & 1
10722 void sub() {
10723 #else
10724 sub() {
10725 #endif
10726         extern void moo();      /* function returning void */
10727         void (*goo)();          /* ptr to func returning void */
10728 #if TRY & 8
10729         void *hue;              /* generic ptr */
10730 #endif
10731 #if TRY & 2
10732         void (*foo[10])();
10733 #endif
10734
10735 #if TRY & 4
10736         if(goo == moo) {
10737                 exit(0);
10738         }
10739 #endif
10740         exit(0);
10741 }
10742 int main() { sub(); }
10743 EOCP
10744         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10745                 voidflags=$defvoidused
10746         echo "Good.  It appears to support void to the level $package wants.">&4
10747                 if $contains warning .out >/dev/null 2>&1; then
10748                         echo "However, you might get some warnings that look like this:"
10749                         $cat .out
10750                 fi
10751         else
10752 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10753                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10754                         echo "It supports 1..."
10755                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10756                                 echo "It also supports 2..."
10757                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10758                                         voidflags=7
10759                                         echo "And it supports 4 but not 8 definitely."
10760                                 else
10761                                         echo "It doesn't support 4..."
10762                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10763                                                 voidflags=11
10764                                                 echo "But it supports 8."
10765                                         else
10766                                                 voidflags=3
10767                                                 echo "Neither does it support 8."
10768                                         fi
10769                                 fi
10770                         else
10771                                 echo "It does not support 2..."
10772                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10773                                         voidflags=13
10774                                         echo "But it supports 4 and 8."
10775                                 else
10776                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10777                                                 voidflags=5
10778                                                 echo "And it supports 4 but has not heard about 8."
10779                                         else
10780                                                 echo "However it supports 8 but not 4."
10781                                         fi
10782                                 fi
10783                         fi
10784                 else
10785                         echo "There is no support at all for void."
10786                         voidflags=0
10787                 fi
10788         fi
10789 esac
10790 case "$voidflags" in
10791 "$defvoidused") ;;
10792 *)      $cat >&4 <<'EOM'
10793   Support flag bits are:
10794     1: basic void declarations.
10795     2: arrays of pointers to functions returning void.
10796     4: operations between pointers to and addresses of void functions.
10797     8: generic void pointers.
10798 EOM
10799         dflt="$voidflags";
10800         rp="Your void support flags add up to what?"
10801         . ./myread
10802         voidflags="$ans"
10803         ;;
10804 esac
10805 $rm -f try.* .out
10806
10807
10808 : How can we generate normalized random numbers ?
10809 echo " "
10810 echo "Looking for a random number function..." >&4
10811 case "$randfunc" in
10812 '')
10813         if set drand48 val -f; eval $csym; $val; then
10814                 dflt="drand48"
10815                 echo "Good, found drand48()." >&4
10816         elif set random val -f; eval $csym; $val; then
10817                 dflt="random"
10818                 echo "OK, found random()." >&4
10819         else
10820                 dflt="rand"
10821                 echo "Yick, looks like I have to use rand()." >&4
10822         fi
10823         echo " "
10824         ;;
10825 *)
10826         dflt="$randfunc"
10827         ;;
10828 esac
10829 cont=true
10830
10831 case "$ccflags" in
10832 *-Dmy_rand=*|*-Dmy_srand=*)
10833         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10834         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10835         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10836         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10837         ;;
10838 esac
10839
10840 while $test "$cont"; do
10841         rp="Use which function to generate random numbers?"
10842         . ./myread
10843         if $test "$ans" = "$dflt"; then
10844                 : null
10845         else
10846                 randbits=''
10847         fi
10848         randfunc="$ans"
10849         if set $ans val -f; eval $csym; $val; then
10850                 cont=''
10851         else
10852                 dflt=y
10853                 rp="I cannot find function $ans. Use that name anyway?"
10854                 . ./myread
10855                 dflt=rand
10856                 case "$ans" in
10857                         [yY]*) cont='';;
10858                 esac
10859         fi
10860         case "$cont" in
10861         '')
10862                 case "$randfunc" in
10863                 drand48)
10864                         drand01="drand48()"
10865                         seedfunc="srand48"
10866                         randbits=48
10867                         randseedtype=long
10868                         ;;
10869                 rand|random)
10870                         case "$randbits" in
10871                         '')
10872 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10873                                 $cat >try.c <<EOCP
10874 #$i_unistd I_UNISTD
10875 #$i_stdlib I_STDLIB
10876 #include <stdio.h>
10877 #ifdef I_UNISTD
10878 #  include <unistd.h>
10879 #endif
10880 #ifdef I_STDLIB
10881 #  include <stdlib.h>
10882 #endif
10883 int main()
10884 {
10885         register int i;
10886         register unsigned long tmp;
10887         register unsigned long max = 0L;
10888
10889         for (i = 1000; i; i--) {
10890                 tmp = (unsigned long) $randfunc();
10891                 if (tmp > max) max = tmp;
10892         }
10893         for (i = 0; max; i++)
10894                 max /= 2;
10895         printf("%d\n",i);
10896 }
10897 EOCP
10898                                 set try
10899                                 if eval $compile_ok; then
10900                                         dflt=`try`
10901                                 else
10902                                         dflt='?'
10903                                         echo "(I can't seem to compile the test program...)"
10904                                 fi
10905                                 ;;
10906                         *)
10907                                 dflt="$randbits"
10908                                 ;;
10909                         esac
10910                         rp="How many bits does your $randfunc() function produce?"
10911                         . ./myread
10912                         randbits="$ans"
10913                         $rm -f try.c try
10914                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10915                         seedfunc="s$randfunc"
10916                         randseedtype=unsigned
10917                         ;;
10918                 *)
10919                         dflt="31"
10920                         rp="How many bits does your $randfunc() function produce?"
10921                         . ./myread
10922                         randbits="$ans"
10923                         seedfunc="s$randfunc"
10924                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10925                         if set $seedfunc val -f; eval $csym; $val; then
10926                                 echo "(Using $seedfunc() to seed random generator)"
10927                         else
10928                                 echo "(Warning: no $seedfunc() to seed random generator)"
10929                                 seedfunc=rand
10930                         fi
10931                         randseedtype=unsigned
10932                         ;;
10933                 esac
10934                 ;;
10935         esac
10936 done
10937
10938 echo " "
10939 echo "Determining whether or not we are on an EBCDIC system..." >&4
10940 $cat >tebcdic.c <<'EOM'
10941 int main()
10942 {
10943   if ('M'==0xd4) return 0;
10944   return 1;
10945 }
10946 EOM
10947
10948 val=$undef
10949 set tebcdic
10950 if eval $compile_ok; then
10951         if ./tebcdic; then
10952                 echo "You have EBCDIC." >&4
10953                 val="$define"
10954         else
10955                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10956         fi
10957 else
10958         echo "I'm unable to compile the test program." >&4
10959         echo "I'll assume ASCII or some ISO Latin." >&4
10960 fi
10961 $rm -f tebcdic.c tebcdic
10962 set ebcdic
10963 eval $setvar
10964
10965 $cat >&4 <<EOM
10966 Checking how to flush all pending stdio output...
10967 EOM
10968 # I only know how to find the first 32 possibly open files on SunOS.
10969 # See also hints/sunos_4_1.sh and util.c  --AD
10970 case "$osname" in
10971 sunos) $echo '#define PERL_FFLUSH_ALL_FOPEN_MAX 32' > try.c ;;
10972 esac
10973 $cat >>try.c <<EOCP
10974 #include <stdio.h>
10975 #$i_unistd I_UNISTD
10976 #ifdef I_UNISTD
10977 # include <unistd.h>
10978 #endif
10979 #$d_sysconf HAS_SYSCONF
10980 #$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
10981 #ifdef HAS_STDIO_STREAM_ARRAY
10982 # define STDIO_STREAM_ARRAY $stdio_stream_array
10983 #endif
10984 int main() {
10985   FILE* p = fopen("try.out", "w");
10986 #ifdef TRY_FPUTC
10987   fputc('x', p);
10988 #else
10989 # ifdef TRY_FPRINTF
10990   fprintf(p, "x");
10991 # endif
10992 #endif
10993 #ifdef TRY_FFLUSH_NULL
10994   fflush(NULL);
10995 #endif
10996 #ifdef TRY_FFLUSH_ALL
10997   {
10998     long open_max = -1;
10999 # ifdef PERL_FFLUSH_ALL_FOPEN_MAX
11000     open_max = PERL_FFLUSH_ALL_FOPEN_MAX;
11001 # else
11002 #  if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
11003     open_max = sysconf(_SC_OPEN_MAX);
11004 #  else
11005 #  ifdef FOPEN_MAX
11006     open_max = FOPEN_MAX;
11007 #   else
11008 #    ifdef OPEN_MAX
11009     open_max = OPEN_MAX;
11010 #    else
11011 #     ifdef _NFILE
11012     open_max = _NFILE;
11013 #     endif
11014 #    endif
11015 #   endif
11016 #  endif
11017 # ifdef HAS_STDIO_STREAM_ARRAY
11018     if (open_max > 0) {
11019       long i;
11020       for (i = 0; i < open_max; i++)
11021             if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
11022                 STDIO_STREAM_ARRAY[i]._file < open_max &&
11023                 STDIO_STREAM_ARRAY[i]._flag)
11024                 fflush(&STDIO_STREAM_ARRAY[i]);
11025     }   
11026   }
11027 # endif
11028 #endif
11029   _exit(42);
11030 }
11031 EOCP
11032 : first we have to find out how _not_ to flush
11033 if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
11034     output=''
11035     set try -DTRY_FPUTC
11036     $rm -f try.out
11037     if eval $compile; then
11038             ./try$exe_ext 2>/dev/null
11039             if $test ! -s try.out -a "X$?" = X42; then
11040                 output=-DTRY_FPUTC
11041             fi
11042     fi
11043     case "$output" in
11044     '')
11045             set try -DTRY_FPRINTF
11046             $rm -f try.out
11047             if eval $compile; then
11048                     ./try$exe_ext 2>/dev/null
11049                     if $test ! -s try.out -a "X$?" = X42; then
11050                         output=-DTRY_FPRINTF
11051                     fi
11052             fi
11053         ;;
11054     esac
11055 fi
11056 : check for fflush NULL behaviour
11057 case "$fflushNULL" in
11058 '')     set try -DTRY_FFLUSH_NULL $output
11059         $rm -f try.out
11060         if eval $compile; then
11061                 ./try$exe_ext 2>/dev/null
11062                 code="$?"
11063                 if $test -s try.out -a "X$code" = X42; then
11064                         fflushNULL="`$cat try.out`"
11065                 else
11066                         if $test "X$code" != X42; then
11067                                 $cat >&4 <<EOM
11068 (If this test failed, don't worry, we'll try another method shortly.)
11069 EOM
11070                         fi
11071                 fi
11072         fi
11073         $rm -f core try.core core.try.*
11074         case "$fflushNULL" in
11075         x)      $cat >&4 <<EOM
11076 Your fflush(NULL) works okay.
11077 EOM
11078                 fflushNULL="$define"
11079                 ;;
11080         '')     $cat >&4 <<EOM
11081 Your fflush(NULL) isn't working (contrary to ANSI C).
11082 EOM
11083                 fflushNULL="$undef"
11084                 ;;
11085         *)      $cat >&4 <<EOM
11086 Cannot figure out whether your fflush(NULL) works or not.
11087 I'm assuming it doesn't (contrary to ANSI C).
11088 EOM
11089                 fflushNULL="$undef"
11090                 ;;
11091         esac
11092         ;;
11093 $define|true|[yY]*)
11094         fflushNULL="$define"
11095         ;;
11096 *)
11097         fflushNULL="$undef"
11098         ;;
11099 esac
11100 : check explicit looping only if NULL did not work
11101 case "$fflushNULL" in
11102 "$undef")
11103         : check for fflush all behaviour
11104         case "$fflushall" in
11105         '')     set try -DTRY_FFLUSH_ALL $output
11106                 $rm -f try.out
11107                 if eval $compile; then
11108                 $cat >&4 <<EOM
11109 (Now testing the other method--but note that also this may fail.)
11110 EOM
11111                         ./try$exe_ext 2>/dev/null
11112                         if $test -s try.out -a "X$?" = X42; then
11113                                 fflushall="`$cat try.out`"
11114                         fi
11115                 fi
11116                 $rm -f core try.core core.try.*
11117                 case "$fflushall" in
11118                 x)      $cat >&4 <<EOM
11119 Whew. Flushing explicitly all the stdio streams works.
11120 EOM
11121                         fflushall="$define"
11122                         ;;
11123                 '')     $cat >&4 <<EOM
11124 Sigh. Flushing explicitly all the stdio streams doesn't work.
11125 EOM
11126                         fflushall="$undef"
11127                         ;;
11128                 *)      $cat >&4 <<EOM
11129 Cannot figure out whether flushing stdio streams explicitly works or not.
11130 I'm assuming it doesn't.
11131 EOM
11132                         fflushall="$undef"
11133                         ;;
11134                 esac
11135                 ;;
11136         "$define"|true|[yY]*)
11137                 fflushall="$define"
11138                 ;;
11139         *)
11140                 fflushall="$undef"
11141                 ;;
11142         esac
11143         ;;
11144 *)      fflushall="$undef"      
11145         ;;
11146 esac
11147 case "$fflushNULL$fflushall" in
11148 undefundef)
11149         $cat <<EOM
11150 I cannot figure out how to flush pending stdio output.
11151 EOM
11152         ;;
11153 esac
11154 $rm -f try.* try$exe_ext
11155
11156 : see what type file positions are declared as in the library
11157 rp="What is the type for file position used by fsetpos()?"
11158 set fpos_t fpostype long stdio.h sys/types.h
11159 eval $typedef_ask
11160
11161 : Store the full pathname to the ar program for use in the C program
11162 : Respect a hint or command line value for full_ar.
11163 case "$full_ar" in
11164 '') full_ar=$ar ;;
11165 esac
11166
11167 : Store the full pathname to the sed program for use in the C program
11168 full_sed=$sed
11169
11170 : see what type gids are declared as in the kernel
11171 echo " "
11172 echo "Looking for the type for group ids returned by getgid()."
11173 set gid_t gidtype xxx stdio.h sys/types.h
11174 eval $typedef
11175 case "$gidtype" in
11176 xxx)
11177         xxx=`./findhdr sys/user.h`
11178         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
11179         case $1 in
11180         unsigned) dflt="$1 $2" ;;
11181         *) dflt="$1" ;;
11182         esac
11183         ;;
11184 *) dflt="$gidtype";;
11185 esac
11186 case "$gidtype" in
11187 gid_t) echo "gid_t found." ;;
11188 *)      rp="What is the type for group ids returned by getgid()?"
11189         . ./myread
11190         gidtype="$ans"
11191         ;;
11192 esac
11193
11194 : see if getgroups exists
11195 set getgroups d_getgrps
11196 eval $inlibc
11197
11198 : see if setgroups exists
11199 set setgroups d_setgrps
11200 eval $inlibc
11201
11202
11203 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11204 echo " "
11205 case "$d_getgrps$d_setgrps" in
11206 *define*)
11207         case "$groupstype" in
11208         '') dflt="$gidtype" ;;
11209         *)  dflt="$groupstype" ;;
11210         esac
11211         $cat <<EOM
11212 What type of pointer is the second argument to getgroups() and setgroups()?
11213 Usually this is the same as group ids, $gidtype, but not always.
11214
11215 EOM
11216         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11217         . ./myread
11218         groupstype="$ans"
11219         ;;
11220 *)  groupstype="$gidtype";;
11221 esac
11222
11223 : see what type lseek is declared as in the kernel
11224 rp="What is the type used for lseek's offset on this system?"
11225 set off_t lseektype long stdio.h sys/types.h
11226 eval $typedef_ask
11227
11228 echo " "
11229 $echo $n "Checking to see how big your file offsets are...$c" >&4
11230 $cat >try.c <<EOCP
11231 #include <sys/types.h>
11232 #include <stdio.h>
11233 int main()
11234 {
11235         printf("%d\n", sizeof($lseektype));
11236 }
11237 EOCP
11238 set try
11239 if eval $compile_ok; then
11240         lseeksize=`./try`
11241         $echo " $lseeksize bytes." >&4
11242 else
11243         dflt='4'
11244         echo " "
11245         echo "(I can't seem to compile the test program.  Guessing...)"
11246         rp="What is the size of your file offsets (in bytes)?"
11247         . ./myread
11248         lseeksize="$ans"
11249 fi
11250 $rm -f try.c try
11251
11252 echo " "
11253 echo "Checking if your $make program sets \$(MAKE)..." >&4
11254 case "$make_set_make" in
11255 '')
11256         $sed 's/^X //' > testmake.mak << 'EOF'
11257 Xall:
11258 X       @echo 'maketemp="$(MAKE)"'
11259 EOF
11260         case "`$make -f testmake.mak 2>/dev/null`" in
11261         *maketemp=*) make_set_make='#' ;;
11262         *)      make_set_make="MAKE=$make" ;;
11263         esac
11264         $rm -f testmake.mak
11265         ;;
11266 esac
11267 case "$make_set_make" in
11268 '#') echo "Yup, it does.";;
11269 *) echo "Nope, it doesn't.";;
11270 esac
11271
11272 : see what type is used for mode_t
11273 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11274 set mode_t modetype int stdio.h sys/types.h
11275 eval $typedef_ask
11276
11277 : define a fucntion to check prototypes
11278 $cat > protochk <<EOSH
11279 $startsh
11280 cc="$cc"
11281 optimize="$optimize"
11282 ccflags="$ccflags"
11283 prototype="$prototype"
11284 define="$define"
11285 rm=$rm
11286 EOSH
11287
11288 $cat >> protochk <<'EOSH'
11289
11290 $rm -f try.c
11291 foo="$1"
11292 shift
11293 while test $# -ge 2; do
11294         case "$1" in
11295                 $define) echo "#include <$2>" >> try.c ;;
11296                 literal) echo "$2" >> try.c ;;
11297         esac
11298     shift 2
11299 done
11300 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11301 cat >> try.c <<'EOCP'
11302 #ifdef CAN_PROTOTYPE
11303 #define _(args) args
11304 #else
11305 #define _(args) ()
11306 #endif
11307 EOCP
11308 echo "$foo" >> try.c
11309 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11310 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11311 status=$?
11312 $rm -f try.[co]
11313 exit $status
11314 EOSH
11315 chmod +x protochk
11316 $eunicefix protochk
11317
11318 : see what type is used for size_t
11319 rp="What is the type used for the length parameter for string functions?"
11320 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11321 eval $typedef_ask
11322
11323 : check for type of arguments to gethostbyaddr. 
11324 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11325         case "$d_gethbyaddr" in
11326         $define)
11327                 $cat <<EOM
11328
11329 Checking to see what type of arguments are accepted by gethostbyaddr().
11330 EOM
11331                 hdrs="$define sys/types.h
11332                         $d_socket sys/socket.h 
11333                         $i_niin netinet/in.h 
11334                         $i_netdb netdb.h
11335                         $i_unistd unistd.h"
11336                 : The first arg can 'char *' or 'void *'
11337                 : The second arg is some of integral type
11338                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11339                         for yyy in size_t long int; do
11340                                 case "$netdb_host_type" in
11341                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11342                                         if ./protochk "$try" $hdrs; then
11343                                                 echo "Your system accepts $xxx for the first arg."
11344                                                 echo "...and $yyy for the second arg."
11345                                                 netdb_host_type="$xxx"
11346                                                 netdb_hlen_type="$yyy"
11347                                         fi
11348                                         ;;
11349                                 esac
11350                         done
11351                 done
11352                 : In case none of those worked, prompt the user.
11353                 case "$netdb_host_type" in
11354                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11355                         dflt='char *'
11356                         . ./myread
11357                         netdb_host_type=$ans
11358                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11359                         dflt="$sizetype"
11360                         . ./myread
11361                         netdb_hlen_type=$ans
11362                         ;;
11363                 esac
11364                 ;;
11365         *)      : no gethostbyaddr, so pick harmless defaults
11366                 netdb_host_type='char *'
11367                 netdb_hlen_type="$sizetype"
11368                 ;;
11369         esac
11370         # Remove the "const" if needed. -- but then we'll have a 
11371         # prototype clash!
11372         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11373 fi
11374
11375 : check for type of argument to gethostbyname. 
11376 if test "X$netdb_name_type" = X ; then
11377         case "$d_gethbyname" in
11378         $define)
11379                 $cat <<EOM
11380
11381 Checking to see what type of argument is accepted by gethostbyname().
11382 EOM
11383                 hdrs="$define sys/types.h
11384                         $d_socket sys/socket.h 
11385                         $i_niin netinet/in.h 
11386                         $i_netdb netdb.h
11387                         $i_unistd unistd.h"
11388                 for xxx in "const char *" "char *"; do
11389                         case "$netdb_name_type" in
11390                         '')     try="extern struct hostent *gethostbyname($xxx);"
11391                                 if ./protochk "$try" $hdrs; then
11392                                         echo "Your system accepts $xxx."
11393                                         netdb_name_type="$xxx"
11394                                 fi
11395                                 ;;
11396                         esac
11397                 done
11398                 : In case none of those worked, prompt the user.
11399                 case "$netdb_name_type" in
11400                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11401                         dflt='char *'
11402                         . ./myread
11403                         netdb_name_type=$ans
11404                         ;;
11405                 esac
11406                 ;;
11407         *)      : no gethostbyname, so pick harmless default
11408                 netdb_name_type='char *'
11409                 ;;
11410         esac
11411 fi
11412
11413 : check for type of 1st argument to getnetbyaddr. 
11414 if test "X$netdb_net_type" = X ; then
11415         case "$d_getnbyaddr" in
11416         $define)
11417                 $cat <<EOM
11418
11419 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11420 EOM
11421                 hdrs="$define sys/types.h
11422                         $d_socket sys/socket.h 
11423                         $i_niin netinet/in.h 
11424                         $i_netdb netdb.h
11425                         $i_unistd unistd.h"
11426                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11427                         case "$netdb_net_type" in
11428                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11429                                 if ./protochk "$try" $hdrs; then
11430                                         echo "Your system accepts $xxx."
11431                                         netdb_net_type="$xxx"
11432                                 fi
11433                                 ;;
11434                         esac
11435                 done
11436                 : In case none of those worked, prompt the user.
11437                 case "$netdb_net_type" in
11438                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11439                         dflt='long'
11440                         . ./myread
11441                         netdb_net_type=$ans
11442                         ;;
11443                 esac
11444                 ;;
11445         *)      : no getnetbyaddr, so pick harmless default
11446                 netdb_net_type='long'
11447                 ;;
11448         esac
11449 fi
11450 : locate the preferred pager for this system
11451 case "$pager" in
11452 '')
11453         dflt=''
11454         case "$pg" in
11455         /*) dflt=$pg;;
11456         esac
11457         case "$more" in
11458         /*) dflt=$more;;
11459         esac
11460         case "$less" in
11461         /*) dflt=$less;;
11462         esac
11463         case "$dflt" in
11464         '') dflt=/usr/ucb/more;;
11465         esac
11466         ;;
11467 *) dflt="$pager";;
11468 esac
11469 echo " "
11470 fn=f/
11471 rp='What pager is used on your system?'
11472 . ./getfile
11473 pager="$ans"
11474
11475 : see what type pids are declared as in the kernel
11476 rp="What is the type of process ids on this system?"
11477 set pid_t pidtype int stdio.h sys/types.h
11478 eval $typedef_ask
11479
11480 : check for length of pointer
11481 echo " "
11482 case "$ptrsize" in
11483 '')
11484         $echo $n "Checking to see how big your pointers are...$c" >&4
11485         if test "$voidflags" -gt 7; then
11486                 echo '#define VOID_PTR char *' > try.c
11487         else
11488                 echo '#define VOID_PTR void *' > try.c
11489         fi
11490         $cat >>try.c <<'EOCP'
11491 #include <stdio.h>
11492 int main()
11493 {
11494         printf("%d\n", sizeof(VOID_PTR));
11495         exit(0);
11496 }
11497 EOCP
11498         set try
11499         if eval $compile_ok; then
11500                 ptrsize=`./try`
11501                 $echo " $ptrsize bytes." >&4
11502         else
11503                 dflt='4'
11504                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11505                 rp="What is the size of a pointer (in bytes)?"
11506                 . ./myread
11507                 ptrsize="$ans"
11508         fi
11509         ;;
11510 esac
11511 $rm -f try.c try
11512
11513 : see if ar generates random libraries by itself
11514 echo " "
11515 echo "Checking how to generate random libraries on your machine..." >&4
11516 echo 'int bar1() { return bar2(); }' > bar1.c
11517 echo 'int bar2() { return 2; }' > bar2.c
11518 $cat > foo.c <<'EOP'
11519 int main() { printf("%d\n", bar1()); exit(0); }
11520 EOP
11521 $cc $ccflags -c bar1.c >/dev/null 2>&1
11522 $cc $ccflags -c bar2.c >/dev/null 2>&1
11523 $cc $ccflags -c foo.c >/dev/null 2>&1
11524 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11525 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11526         ./foobar >/dev/null 2>&1; then
11527         echo "$ar appears to generate random libraries itself."
11528         orderlib=false
11529         ranlib=":"
11530 elif $ar ts bar$_a >/dev/null 2>&1 &&
11531         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11532         ./foobar >/dev/null 2>&1; then
11533                 echo "a table of contents needs to be added with '$ar ts'."
11534                 orderlib=false
11535                 ranlib="$ar ts"
11536 else
11537         case "$ranlib" in
11538         :) ranlib='';;
11539         '')
11540                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11541                 $test -f $ranlib || ranlib=''
11542                 ;;
11543         esac
11544         if $test -n "$ranlib"; then
11545                 echo "your system has '$ranlib'; we'll use that."
11546                 orderlib=false
11547         else
11548                 echo "your system doesn't seem to support random libraries"
11549                 echo "so we'll use lorder and tsort to order the libraries."
11550                 orderlib=true
11551                 ranlib=":"
11552         fi
11553 fi
11554 $rm -f foo* bar* 
11555
11556 : check for type of arguments to select. 
11557 case "$selecttype" in
11558 '') case "$d_select" in
11559         $define)
11560                 $cat <<EOM
11561 Checking to see what type of arguments are accepted by select().
11562 EOM
11563                 hdrs="$define sys/types.h
11564                         $i_systime sys/time.h 
11565                         $i_sysselct sys/select.h
11566                         $d_socket sys/socket.h"
11567                 : The first arg can be int, unsigned, or size_t
11568                 : The last arg may or may not be 'const'
11569                 val=''
11570                 : void pointer has been seen but using that
11571                 : breaks the selectminbits test
11572                 for xxx in 'fd_set *' 'int *'; do
11573                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11574                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11575                                         case "$val" in
11576                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11577                                                 if ./protochk "$try" $hdrs; then
11578                                                         echo "Your system accepts $xxx."
11579                                                         val="$xxx"
11580                                                 fi
11581                                                 ;;
11582                                         esac
11583                                 done
11584                         done
11585                 done
11586                 case "$val" in
11587                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11588                         case "$d_fd_set" in
11589                                 $define) dflt="fd_set *" ;;
11590                                 *)              dflt="int *" ;;
11591                         esac
11592                         . ./myread
11593                         val=$ans
11594                         ;;
11595                 esac
11596                 selecttype="$val"
11597                 ;;
11598         *)      : no select, so pick a harmless default
11599                 selecttype='int *'
11600                 ;;
11601         esac
11602         ;;
11603 esac
11604
11605 : check for the select 'width'
11606 case "$selectminbits" in
11607 '') case "$d_select" in
11608         $define)
11609                 $cat <<EOM
11610
11611 Checking to see on how many bits at a time your select() operates...
11612 EOM
11613                 $cat >try.c <<EOCP
11614 #include <sys/types.h>
11615 #$i_time I_TIME
11616 #$i_systime I_SYS_TIME
11617 #$i_systimek I_SYS_TIME_KERNEL
11618 #ifdef I_TIME
11619 #   include <time.h>
11620 #endif
11621 #ifdef I_SYS_TIME
11622 #   ifdef I_SYS_TIME_KERNEL
11623 #       define KERNEL
11624 #   endif
11625 #   include <sys/time.h>
11626 #   ifdef I_SYS_TIME_KERNEL
11627 #       undef KERNEL
11628 #   endif
11629 #endif
11630 #$i_sysselct I_SYS_SELECT
11631 #ifdef I_SYS_SELECT
11632 #include <sys/select.h>
11633 #endif
11634 #include <stdio.h>
11635 $selecttype b;
11636 #define S sizeof(*(b))
11637 #define MINBITS 64
11638 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11639 #define NBITS  (NBYTES * 8)
11640 int main() {
11641     char s[NBYTES];
11642     struct timeval t;
11643     int i;
11644     FILE* fp;
11645     int fd;
11646
11647     fclose(stdin);
11648     fp = fopen("try.c", "r");
11649     if (fp == 0)
11650       exit(1);
11651     fd = fileno(fp);
11652     if (fd < 0)
11653       exit(2);
11654     b = ($selecttype)s;
11655     for (i = 0; i < NBITS; i++)
11656         FD_SET(i, b);
11657     t.tv_sec  = 0;
11658     t.tv_usec = 0;
11659     select(fd + 1, b, 0, 0, &t);
11660     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11661     printf("%d\n", i + 1);
11662     return 0;
11663 }
11664 EOCP
11665                 set try
11666                 if eval $compile_ok; then
11667                         selectminbits=`./try`
11668                         case "$selectminbits" in
11669                         '')     cat >&4 <<EOM
11670 Cannot figure out on how many bits at a time your select() operates.
11671 I'll play safe and guess it is 32 bits.
11672 EOM
11673                                 selectminbits=32
11674                                 bits="32 bits"
11675                                 ;;
11676                         1)      bits="1 bit" ;;
11677                         *)      bits="$selectminbits bits" ;;
11678                         esac
11679                         echo "Your select() operates on $bits at a time." >&4
11680                 else
11681                         rp='What is the minimum number of bits your select() operates on?'
11682                         case "$byteorder" in
11683                         1234|12345678)  dflt=32 ;;
11684                         *)              dflt=1  ;;
11685                         esac
11686                         . ./myread
11687                         val=$ans
11688                         selectminbits="$val"
11689                 fi
11690                 $rm -f try.* try
11691                 ;;
11692         *)      : no select, so pick a harmless default
11693                 selectminbits='32'
11694                 ;;
11695         esac
11696         ;;
11697 esac
11698
11699 : Trace out the files included by signal.h, then look for SIGxxx names.
11700 : Remove SIGARRAYSIZE used by HPUX.
11701 : Remove SIGSTKSIZE used by Linux.
11702 : Remove SIGSTKSZ used by Posix.
11703 : Remove SIGTYP void lines used by OS2.
11704 xxx=`echo '#include <signal.h>' |
11705         $cppstdin $cppminus $cppflags 2>/dev/null |
11706         $grep '^[       ]*#.*include' | 
11707         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11708 : Check this list of files to be sure we have parsed the cpp output ok.
11709 : This will also avoid potentially non-existent files, such 
11710 : as ../foo/bar.h
11711 xxxfiles=''
11712 for xx in $xxx /dev/null ; do
11713         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11714 done
11715 : If we have found no files, at least try signal.h
11716 case "$xxxfiles" in
11717 '')     xxxfiles=`./findhdr signal.h` ;;
11718 esac
11719 xxx=`awk '
11720 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11721         print substr($2, 4, 20)
11722 }
11723 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11724         print substr($3, 4, 20)
11725 }' $xxxfiles`
11726 : Append some common names just in case the awk scan failed.
11727 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11728 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11729 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11730 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11731 : generate a few handy files for later
11732 $cat > signal.c <<'EOCP'
11733 #include <sys/types.h>
11734 #include <signal.h>
11735 #include <stdio.h>
11736 int main() {
11737
11738 /* Strange style to avoid deeply-nested #if/#else/#endif */
11739 #ifndef NSIG
11740 #  ifdef _NSIG
11741 #    define NSIG (_NSIG)
11742 #  endif
11743 #endif
11744
11745 #ifndef NSIG
11746 #  ifdef SIGMAX
11747 #    define NSIG (SIGMAX+1)
11748 #  endif
11749 #endif
11750
11751 #ifndef NSIG
11752 #  ifdef SIG_MAX
11753 #    define NSIG (SIG_MAX+1)
11754 #  endif
11755 #endif
11756
11757 #ifndef NSIG
11758 #  ifdef MAXSIG
11759 #    define NSIG (MAXSIG+1)
11760 #  endif
11761 #endif
11762
11763 #ifndef NSIG
11764 #  ifdef MAX_SIG
11765 #    define NSIG (MAX_SIG+1)
11766 #  endif
11767 #endif
11768
11769 #ifndef NSIG
11770 #  ifdef SIGARRAYSIZE
11771 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11772 #  endif
11773 #endif
11774
11775 #ifndef NSIG
11776 #  ifdef _sys_nsig
11777 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11778 #  endif
11779 #endif
11780
11781 /* Default to some arbitrary number that's big enough to get most
11782    of the common signals.
11783 */
11784 #ifndef NSIG
11785 #    define NSIG 50
11786 #endif
11787
11788 printf("NSIG %d\n", NSIG);
11789
11790 #ifndef JUST_NSIG
11791
11792 EOCP
11793
11794 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11795 {
11796         printf "#ifdef SIG"; printf $1; printf "\n"
11797         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11798         printf $1; printf ");\n"
11799         printf "#endif\n"
11800 }
11801 END {
11802         printf "#endif /* JUST_NSIG */\n";
11803         printf "}\n";
11804 }
11805 ' >>signal.c
11806 $cat >signal.awk <<'EOP'
11807 BEGIN { ndups = 0 }
11808 $1 ~ /^NSIG$/ { nsig = $2 }
11809 ($1 !~ /^NSIG$/) && (NF == 2) {
11810     if ($2 > maxsig) { maxsig = $2 }
11811     if (sig_name[$2]) {
11812         dup_name[ndups] = $1
11813         dup_num[ndups] = $2
11814         ndups++ 
11815     }
11816     else {
11817         sig_name[$2] = $1
11818         sig_num[$2] = $2
11819     }
11820 }
11821 END { 
11822     if (nsig == 0) {
11823         nsig = maxsig + 1
11824     }
11825     printf("NSIG %d\n", nsig);
11826     for (n = 1; n < nsig; n++) {
11827         if (sig_name[n]) {
11828             printf("%s %d\n", sig_name[n], sig_num[n])
11829         }
11830         else {
11831             printf("NUM%d %d\n", n, n) 
11832         }
11833     }
11834     for (n = 0; n < ndups; n++) {
11835         printf("%s %d\n", dup_name[n], dup_num[n])
11836     }
11837 }
11838 EOP
11839 $cat >signal_cmd <<EOS
11840 $startsh
11841 if $test -s signal.lst; then
11842     echo "Using your existing signal.lst file"
11843         exit 0
11844 fi
11845 xxx="$xxx"
11846 EOS
11847 $cat >>signal_cmd <<'EOS'
11848
11849 set signal
11850 if eval $compile_ok; then
11851         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11852 else
11853         echo "(I can't seem be able to compile the whole test program)" >&4
11854         echo "(I'll try it in little pieces.)" >&4
11855         set signal -DJUST_NSIG
11856         if eval $compile_ok; then
11857                 ./signal$_exe > signal.nsg
11858                 $cat signal.nsg
11859         else
11860                 echo "I can't seem to figure out how many signals you have." >&4
11861                 echo "Guessing 50." >&4
11862                 echo 'NSIG 50' > signal.nsg
11863         fi
11864         : Now look at all the signal names, one at a time.
11865         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11866                 $cat > signal.c <<EOCP
11867 #include <sys/types.h>
11868 #include <signal.h>
11869 #include <stdio.h>
11870 int main() {
11871 printf("$xx %d\n", SIG${xx});
11872 return 0;
11873 }
11874 EOCP
11875                 set signal
11876                 if eval $compile; then
11877                         echo "SIG${xx} found."
11878                         ./signal$_exe  >> signal.ls1
11879                 else
11880                         echo "SIG${xx} NOT found."
11881                 fi
11882         done
11883         if $test -s signal.ls1; then
11884                 $cat signal.nsg signal.ls1 |
11885                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11886         fi
11887
11888 fi
11889 if $test -s signal.lst; then
11890         :
11891 else
11892         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11893         echo 'kill -l' >signal
11894         set X `csh -f <signal`
11895         $rm -f signal
11896         shift
11897         case $# in
11898         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11899         esac
11900         echo $@ | $tr ' ' $trnl | \
11901             $awk '{ printf "%s %d\n", $1, ++s; }
11902                   END { printf "NSIG %d\n", ++s }' >signal.lst
11903 fi
11904 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11905 EOS
11906 chmod a+x signal_cmd
11907 $eunicefix signal_cmd
11908
11909 : generate list of signal names
11910 echo " "
11911 case "$sig_name_init" in
11912 '') doinit=yes ;;
11913 *)  case "$sig_num_init" in
11914     ''|*,*) doinit=yes ;;
11915     esac ;;
11916 esac
11917 case "$doinit" in
11918 yes)
11919         echo "Generating a list of signal names and numbers..." >&4
11920         . ./signal_cmd
11921         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11922         sig_name=`$awk 'BEGIN { printf "ZERO " }
11923                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11924         sig_num=`$awk  'BEGIN { printf "0 " }
11925                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11926         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11927                              !/^NSIG/   { printf "\"%s\", ", $1 }
11928                              END        { printf "0\n" }' signal.lst`
11929         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11930                              !/^NSIG/   { printf "%d, ", $2}
11931                              END        { printf "0\n"}' signal.lst`
11932         ;;
11933 esac
11934 echo "The following $sig_count signals are available:"
11935 echo " "
11936 echo $sig_name | $awk \
11937 'BEGIN { linelen = 0 }
11938 {
11939         for (i = 1; i <= NF; i++) {
11940                 name = "SIG" $i " "
11941                 linelen = linelen + length(name)
11942                 if (linelen > 70) {
11943                         printf "\n"
11944                         linelen = length(name)
11945                 }
11946                 printf "%s", name
11947         }
11948         printf "\n"
11949 }'
11950 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11951
11952 : see what type is used for signed size_t
11953 set ssize_t ssizetype int stdio.h sys/types.h
11954 eval $typedef
11955 dflt="$ssizetype"
11956 $cat > ssize.c <<EOM
11957 #include <stdio.h>
11958 #include <sys/types.h>
11959 #define Size_t $sizetype
11960 #define SSize_t $dflt
11961 int main()
11962 {
11963         if (sizeof(Size_t) == sizeof(SSize_t))
11964                 printf("$dflt\n");
11965         else if (sizeof(Size_t) == sizeof(int))
11966                 printf("int\n");
11967         else 
11968                 printf("long\n");
11969         exit(0);
11970 }
11971 EOM
11972 echo " "
11973 set ssize
11974 if eval $compile_ok && ./ssize > /dev/null; then
11975         ssizetype=`./ssize`
11976         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11977 else
11978         $cat >&4 <<EOM
11979 Help! I can't compile and run the ssize_t test program: please enlighten me!
11980 (This is probably a misconfiguration in your system or libraries, and
11981 you really ought to fix it.  Still, I'll try anyway.)
11982
11983 I need a type that is the same size as $sizetype, but is guaranteed to
11984 be signed.  Common values are ssize_t, int and long.
11985
11986 EOM
11987         rp="What signed type is the same size as $sizetype?"
11988         . ./myread
11989         ssizetype="$ans"
11990 fi
11991 $rm -f ssize ssize.*
11992
11993 : see what type of char stdio uses.
11994 echo " "
11995 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11996         echo "Your stdio uses unsigned chars." >&4
11997         stdchar="unsigned char"
11998 else
11999         echo "Your stdio uses signed chars." >&4
12000         stdchar="char"
12001 fi
12002
12003 : see if time exists
12004 echo " "
12005 if test "X$d_time" = X -o X"$timetype" = X; then
12006     if set time val -f d_time; eval $csym; $val; then
12007                 echo 'time() found.' >&4
12008                 val="$define"
12009                 rp="What is the type returned by time() on this system?"
12010                 set time_t timetype long stdio.h sys/types.h
12011                 eval $typedef_ask
12012     else
12013                 echo 'time() not found, hope that will do.' >&4
12014                 val="$undef"
12015                 timetype='int';
12016     fi
12017     set d_time
12018     eval $setvar
12019 fi
12020
12021 : see what type uids are declared as in the kernel
12022 echo " "
12023 echo "Looking for the type for user ids returned by getuid()."
12024 set uid_t uidtype xxx stdio.h sys/types.h
12025 eval $typedef
12026 case "$uidtype" in
12027 xxx)
12028         xxx=`./findhdr sys/user.h`
12029         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
12030         case $1 in
12031         unsigned) dflt="$1 $2" ;;
12032         *) dflt="$1" ;;
12033         esac
12034         ;;
12035 *) dflt="$uidtype";;
12036 esac
12037 case "$uidtype" in
12038 uid_t)  echo "uid_t found." ;;
12039 *)      rp="What is the type for user ids returned by getuid()?"
12040         . ./myread
12041         uidtype="$ans"
12042         ;;
12043 esac
12044
12045 : see if dbm.h is available
12046 : see if dbmclose exists
12047 set dbmclose d_dbmclose
12048 eval $inlibc
12049
12050 case "$d_dbmclose" in
12051 $define)
12052         set dbm.h i_dbm
12053         eval $inhdr
12054         case "$i_dbm" in
12055         $define)
12056                 val="$undef"
12057                 set i_rpcsvcdbm
12058                 eval $setvar
12059                 ;;
12060         *)      set rpcsvc/dbm.h i_rpcsvcdbm
12061                 eval $inhdr
12062                 ;;
12063         esac
12064         ;;
12065 *)      echo "We won't be including <dbm.h>"
12066         val="$undef"
12067         set i_dbm
12068         eval $setvar
12069         val="$undef"
12070         set i_rpcsvcdbm
12071         eval $setvar
12072         ;;
12073 esac
12074
12075 : see if this is a sys/file.h system
12076 val=''
12077 set sys/file.h val
12078 eval $inhdr
12079
12080 : do we need to include sys/file.h ?
12081 case "$val" in
12082 "$define")
12083         echo " "
12084         if $h_sysfile; then
12085                 val="$define"
12086                 echo "We'll be including <sys/file.h>." >&4
12087         else
12088                 val="$undef"
12089                 echo "We won't be including <sys/file.h>." >&4
12090         fi
12091         ;;
12092 *)
12093         h_sysfile=false
12094         ;;
12095 esac
12096 set i_sysfile
12097 eval $setvar
12098
12099 : see if fcntl.h is there
12100 val=''
12101 set fcntl.h val
12102 eval $inhdr
12103
12104 : see if we can include fcntl.h
12105 case "$val" in
12106 "$define")
12107         echo " "
12108         if $h_fcntl; then
12109                 val="$define"
12110                 echo "We'll be including <fcntl.h>." >&4
12111         else
12112                 val="$undef"
12113                 if $h_sysfile; then
12114         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12115                 else
12116                         echo "We won't be including <fcntl.h>." >&4
12117                 fi
12118         fi
12119         ;;
12120 *)
12121         h_fcntl=false
12122         val="$undef"
12123         ;;
12124 esac
12125 set i_fcntl
12126 eval $setvar
12127
12128 : see if locale.h is available
12129 set locale.h i_locale
12130 eval $inhdr
12131
12132 : see if mach cthreads are available
12133 if test "X$usethreads" = "X$define"; then
12134         set mach/cthreads.h i_machcthr
12135         eval $inhdr
12136 else
12137         i_machcthr="$undef"
12138 fi
12139
12140
12141
12142 : see if this is a math.h system
12143 set math.h i_math
12144 eval $inhdr
12145
12146 : see if this is a mntent.h system
12147 set mntent.h i_mntent
12148 eval $inhdr
12149
12150 : see if ndbm.h is available
12151 set ndbm.h t_ndbm
12152 eval $inhdr
12153 case "$t_ndbm" in
12154 $define)
12155         : see if dbm_open exists
12156         set dbm_open d_dbm_open
12157         eval $inlibc
12158         case "$d_dbm_open" in
12159         $undef)
12160                 t_ndbm="$undef"
12161                 echo "We won't be including <ndbm.h>"
12162                 ;;
12163         esac
12164         ;;
12165 esac
12166 val="$t_ndbm"
12167 set i_ndbm
12168 eval $setvar
12169
12170 : see if net/errno.h is available
12171 val=''
12172 set net/errno.h val
12173 eval $inhdr
12174
12175 : Unfortunately, it causes problems on some systems.  Arrgh.
12176 case "$val" in
12177 $define)
12178         cat > try.c <<'EOM'
12179 #include <stdio.h>
12180 #include <errno.h>
12181 #include <net/errno.h>
12182 int func()
12183 {
12184         return ENOTSOCK;
12185 }
12186 EOM
12187         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12188                 echo "We'll be including <net/errno.h>." >&4
12189         else
12190                 echo "We won't be including <net/errno.h>." >&4
12191                 val="$undef"
12192         fi
12193         $rm -f try.* try
12194         ;;
12195 esac
12196 set i_neterrno
12197 eval $setvar
12198
12199 : see if netinet/tcp.h is available
12200 set netinet/tcp.h i_netinettcp
12201 eval $inhdr
12202
12203 : see if this is a poll.h system
12204 set poll.h i_poll
12205 eval $inhdr
12206
12207 : get C preprocessor symbols handy
12208 echo " "
12209 $echo $n "Hmm... $c"
12210 echo $al | $tr ' ' $trnl >Cppsym.know
12211 $cat <<EOSS >Cppsym
12212 $startsh
12213 case "\$1" in
12214 -l) list=true
12215         shift
12216         ;;
12217 esac
12218 unknown=''
12219 case "\$list\$#" in
12220 1|2)
12221         for sym do
12222                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12223                         exit 0
12224                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12225                         :
12226                 else
12227                         unknown="\$unknown \$sym"
12228                 fi
12229         done
12230         set X \$unknown
12231         shift
12232         ;;
12233 esac
12234 case \$# in
12235 0) exit 1;;
12236 esac
12237 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12238 #ifdef \1\\
12239 exit 0; _ _ _ _\1\\      \1\\
12240 #endif\\
12241 /' >Cppsym\$\$
12242 echo "exit 1; _ _ _" >>Cppsym\$\$
12243 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12244 case "\$list" in
12245 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12246 *)
12247         sh Cppsym2\$\$
12248         status=\$?
12249         ;;
12250 esac
12251 $rm -f Cppsym\$\$ Cppsym2\$\$
12252 exit \$status
12253 EOSS
12254 chmod +x Cppsym
12255 $eunicefix Cppsym
12256 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12257
12258 : now check the C compiler for additional symbols
12259 postprocess_cc_v=''
12260 case "$osname" in
12261 aix) postprocess_cc_v="|$tr , ' '" ;;
12262 esac
12263 $cat >ccsym <<EOS
12264 $startsh
12265 $cat >tmp.c <<EOF
12266 extern int foo;
12267 EOF
12268 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12269 do
12270         case "\$i" in
12271         -D*) echo "\$i" | $sed 's/^-D//';;
12272         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12273         esac
12274 done
12275 $rm -f try.c
12276 EOS
12277 postprocess_cc_v=''
12278 chmod +x ccsym
12279 $eunicefix ccsym
12280 ./ccsym > ccsym1.raw
12281 if $test -s ccsym1.raw; then
12282        $sort ccsym1.raw | $uniq >ccsym.raw
12283 else
12284        mv ccsym1.raw ccsym.raw
12285 fi
12286
12287 $awk '/\=/ { print $0; next }
12288         { print $0"=1" }' ccsym.raw >ccsym.list
12289 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12290 $comm -13 ccsym.true ccsym.list >ccsym.own
12291 $comm -12 ccsym.true ccsym.list >ccsym.com
12292 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12293 also=''
12294 if $test -z ccsym.raw; then
12295         echo "Your C compiler doesn't seem to define any symbols!" >&4
12296         echo " "
12297         echo "However, your C preprocessor defines the following symbols:"
12298         $cat Cppsym.true
12299         ccsymbols=''
12300         cppsymbols=`$cat Cppsym.true`
12301         cppsymbols=`echo $cppsymbols`
12302         cppccsymbols="$cppsymbols"
12303 else
12304         if $test -s ccsym.com; then
12305                 echo "Your C compiler and pre-processor define these symbols:"
12306                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12307                 also='also '
12308                 symbols='ones'
12309                 cppccsymbols=`$cat ccsym.com`
12310                 cppccsymbols=`echo $cppccsymbols`
12311                 $test "$silent" || sleep 1
12312         fi
12313         if $test -s ccsym.cpp; then
12314                 $test "$also" && echo " "
12315                 echo "Your C pre-processor ${also}defines the following symbols:"
12316                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12317                 also='further '
12318                 cppsymbols=`$cat ccsym.cpp`
12319                 cppsymbols=`echo $cppsymbols`
12320                 $test "$silent" || sleep 1
12321         fi
12322         if $test -s ccsym.own; then
12323                 $test "$also" && echo " "
12324                 echo "Your C compiler ${also}defines the following cpp symbols:"
12325                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12326                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12327                 ccsymbols=`$cat ccsym.own`
12328                 ccsymbols=`echo $ccsymbols`
12329                 $test "$silent" || sleep 1
12330         fi
12331 fi
12332 $rm -f ccsym*
12333
12334 : see if this is a termio system
12335 val="$undef"
12336 val2="$undef"
12337 val3="$undef"
12338 if $test `./findhdr termios.h`; then
12339         set tcsetattr i_termios
12340         eval $inlibc
12341         val3="$i_termios"
12342 fi
12343 echo " "
12344 case "$val3" in
12345 "$define") echo "You have POSIX termios.h... good!" >&4;;
12346 *) if ./Cppsym pyr; then
12347                 case "`/bin/universe`" in
12348                 ucb) if $test `./findhdr sgtty.h`; then
12349                                 val2="$define"
12350                                 echo "<sgtty.h> found." >&4
12351                         else
12352                                 echo "System is pyramid with BSD universe."
12353                                 echo "<sgtty.h> not found--you could have problems." >&4
12354                         fi;;
12355                 *) if $test `./findhdr termio.h`; then
12356                                 val="$define"
12357                                 echo "<termio.h> found." >&4
12358                         else
12359                                 echo "System is pyramid with USG universe."
12360                                 echo "<termio.h> not found--you could have problems." >&4
12361                         fi;;
12362                 esac
12363         elif ./usg; then
12364                 if $test `./findhdr termio.h`; then
12365                         echo "<termio.h> found." >&4
12366                         val="$define"
12367                 elif $test `./findhdr sgtty.h`; then
12368                         echo "<sgtty.h> found." >&4
12369                         val2="$define"
12370                 else
12371 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12372                 fi
12373         else
12374                 if $test `./findhdr sgtty.h`; then
12375                         echo "<sgtty.h> found." >&4
12376                         val2="$define"
12377                 elif $test `./findhdr termio.h`; then
12378                         echo "<termio.h> found." >&4
12379                         val="$define"
12380                 else
12381 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12382                 fi
12383         fi;;
12384 esac
12385 set i_termio; eval $setvar
12386 val=$val2; set i_sgtty; eval $setvar
12387 val=$val3; set i_termios; eval $setvar
12388
12389 : see if stdarg is available
12390 echo " "
12391 if $test `./findhdr stdarg.h`; then
12392         echo "<stdarg.h> found." >&4
12393         valstd="$define"
12394 else
12395         echo "<stdarg.h> NOT found." >&4
12396         valstd="$undef"
12397 fi
12398
12399 : see if varags is available
12400 echo " "
12401 if $test `./findhdr varargs.h`; then
12402         echo "<varargs.h> found." >&4
12403 else
12404         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12405 fi
12406
12407 : set up the varargs testing programs
12408 $cat > varargs.c <<EOP
12409 #ifdef I_STDARG
12410 #include <stdarg.h>
12411 #endif
12412 #ifdef I_VARARGS
12413 #include <varargs.h>
12414 #endif
12415
12416 #ifdef I_STDARG
12417 int f(char *p, ...)
12418 #else
12419 int f(va_alist)
12420 va_dcl
12421 #endif
12422 {
12423         va_list ap;
12424 #ifndef I_STDARG
12425         char *p;
12426 #endif
12427 #ifdef I_STDARG
12428         va_start(ap,p);
12429 #else
12430         va_start(ap);
12431         p = va_arg(ap, char *);
12432 #endif
12433         va_end(ap);
12434 }
12435 EOP
12436 $cat > varargs <<EOP
12437 $startsh
12438 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12439         echo "true"
12440 else
12441         echo "false"
12442 fi
12443 $rm -f varargs$_o
12444 EOP
12445 chmod +x varargs
12446
12447 : now check which varargs header should be included
12448 echo " "
12449 i_varhdr=''
12450 case "$valstd" in
12451 "$define")
12452         if `./varargs I_STDARG`; then
12453                 val='stdarg.h'
12454         elif `./varargs I_VARARGS`; then
12455                 val='varargs.h'
12456         fi
12457         ;;
12458 *)
12459         if `./varargs I_VARARGS`; then
12460                 val='varargs.h'
12461         fi
12462         ;;
12463 esac
12464 case "$val" in
12465 '')
12466 echo "I could not find the definition for va_dcl... You have problems..." >&4
12467         val="$undef"; set i_stdarg; eval $setvar
12468         val="$undef"; set i_varargs; eval $setvar
12469         ;;
12470 *) 
12471         set i_varhdr
12472         eval $setvar
12473         case "$i_varhdr" in
12474         stdarg.h)
12475                 val="$define"; set i_stdarg; eval $setvar
12476                 val="$undef"; set i_varargs; eval $setvar
12477                 ;;
12478         varargs.h)
12479                 val="$undef"; set i_stdarg; eval $setvar
12480                 val="$define"; set i_varargs; eval $setvar
12481                 ;;
12482         esac
12483         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12484 esac
12485 $rm -f varargs*
12486
12487 : see if stddef is available
12488 set stddef.h i_stddef
12489 eval $inhdr
12490
12491 : see if sys/access.h is available
12492 set sys/access.h i_sysaccess
12493 eval $inhdr
12494
12495 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12496 set sys/filio.h i_sysfilio
12497 eval $inhdr
12498 echo " "
12499 if $test `./findhdr sys/ioctl.h`; then
12500         val="$define"
12501         echo '<sys/ioctl.h> found.' >&4
12502 else
12503         val="$undef"
12504         if $test $i_sysfilio = "$define"; then
12505             echo '<sys/ioctl.h> NOT found.' >&4
12506         else
12507                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12508                 $test $i_termio = "$define" && xxx="termio.h"
12509                 $test $i_termios = "$define" && xxx="termios.h"
12510 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12511         fi
12512 fi
12513 set i_sysioctl
12514 eval $setvar
12515
12516 : see if sys/resource.h has to be included
12517 set sys/resource.h i_sysresrc
12518 eval $inhdr
12519
12520 : see if sys/security.h is available
12521 set sys/security.h i_syssecrt
12522 eval $inhdr
12523
12524 : see if this is a sys/statvfs.h system
12525 set sys/statvfs.h i_sysstatvfs
12526 eval $inhdr
12527
12528 : see if this is a sys/un.h system
12529 set sys/un.h i_sysun
12530 eval $inhdr
12531
12532 : see if this is a syswait system
12533 set sys/wait.h i_syswait
12534 eval $inhdr
12535
12536 : see if this is an utime system
12537 set utime.h i_utime
12538 eval $inhdr
12539
12540 : see if this is a values.h system
12541 set values.h i_values
12542 eval $inhdr
12543
12544 : see if this is a vfork system
12545 case "$d_vfork" in
12546 "$define")
12547         set vfork.h i_vfork
12548         eval $inhdr
12549         ;;
12550 *)
12551         i_vfork="$undef"
12552         ;;
12553 esac
12554
12555 : see if gdbm.h is available
12556 set gdbm.h t_gdbm
12557 eval $inhdr
12558 case "$t_gdbm" in
12559 $define)
12560         : see if gdbm_open exists
12561         set gdbm_open d_gdbm_open
12562         eval $inlibc
12563         case "$d_gdbm_open" in
12564         $undef)
12565                 t_gdbm="$undef"
12566                 echo "We won't be including <gdbm.h>"
12567                 ;;
12568         esac
12569         ;;
12570 esac
12571 val="$t_gdbm"
12572 set i_gdbm
12573 eval $setvar
12574
12575 echo " "
12576 echo "Looking for extensions..." >&4
12577 tdir=`pwd`
12578 cd $rsrc/ext
12579 : If we are using the old config.sh, known_extensions may contain
12580 : old or inaccurate or duplicate values.
12581 known_extensions=''
12582 nonxs_extensions=''
12583 : We do not use find because it might not be available.
12584 : We do not just use MANIFEST because the user may have dropped
12585 : some additional extensions into the source tree and expect them
12586 : to be built.
12587 for xxx in * ; do
12588         case "$xxx" in
12589         DynaLoader|dynaload) ;;
12590         *)      if $test -f $xxx/$xxx.xs; then
12591                         known_extensions="$known_extensions $xxx"
12592                 elif $test -f $xxx/Makefile.PL; then
12593                         nonxs_extensions="$nonxs_extensions $xxx"
12594                 else
12595                         if $test -d $xxx; then
12596                                 # Look for nested extensions, eg. Devel/Dprof.
12597                                 cd $xxx
12598                                 for yyy in * ; do
12599                                 if $test -f $yyy/$yyy.xs; then
12600                                         known_extensions="$known_extensions $xxx/$yyy"
12601                                 elif $test -f $yyy/Makefile.PL; then
12602                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12603                                 fi
12604                                 done
12605                                 cd ..
12606                         fi
12607                 fi 
12608                 ;;
12609         esac
12610 done
12611 set X $nonxs_extensions
12612 shift
12613 nonxs_extensions="$*"
12614 set X $known_extensions
12615 shift
12616 known_extensions="$*"
12617 cd $tdir
12618
12619 : Now see which are supported on this system.
12620 avail_ext=''
12621 for xxx in $known_extensions ; do
12622         case "$xxx" in
12623         DB_File|db_file)
12624                 case "$i_db" in
12625                 $define) avail_ext="$avail_ext $xxx" ;;
12626                 esac
12627                 ;;
12628         GDBM_File|gdbm_fil)
12629                 case "$i_gdbm" in 
12630                 $define) avail_ext="$avail_ext $xxx" ;;
12631                 esac
12632                 ;;
12633         NDBM_File|ndbm_fil)
12634                 case "$i_ndbm" in
12635                 $define) avail_ext="$avail_ext $xxx" ;;
12636                 esac
12637                 ;;
12638         ODBM_File|odbm_fil) 
12639                 case "${i_dbm}${i_rpcsvcdbm}" in
12640                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12641                 esac
12642                 ;;
12643         POSIX|posix)
12644                 case "$useposix" in
12645                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12646                 esac
12647                 ;;
12648         Opcode|opcode)
12649                 case "$useopcode" in
12650                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12651                 esac
12652                 ;;
12653         Socket|socket)
12654                 case "$d_socket" in 
12655                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12656                 esac
12657                 ;;
12658         Thread|thread)
12659                 case "$usethreads" in 
12660                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12661                 esac
12662                 ;;
12663         IPC/SysV|ipc/sysv)
12664                 : XXX Do we need a useipcsysv variable here
12665                 case "${d_msg}${d_sem}${d_shm}" in 
12666                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12667                 esac
12668                 ;;
12669         *)      avail_ext="$avail_ext $xxx"
12670                 ;;
12671         esac
12672 done
12673
12674 set X $avail_ext
12675 shift
12676 avail_ext="$*"
12677
12678 : Now see which nonxs extensions are supported on this system.
12679 : For now assume all are.
12680 nonxs_ext=''
12681 for xxx in $nonxs_extensions ; do
12682         case "$xxx" in
12683         *)      nonxs_ext="$nonxs_ext $xxx"
12684                 ;;
12685         esac
12686 done
12687
12688 set X $nonxs_ext
12689 shift
12690 nonxs_ext="$*"
12691
12692 case $usedl in
12693 $define)
12694         $cat <<EOM
12695 A number of extensions are supplied with $package.  You may choose to
12696 compile these extensions for dynamic loading (the default), compile
12697 them into the $package executable (static loading), or not include
12698 them at all.  Answer "none" to include no extensions.
12699 Note that DynaLoader is always built and need not be mentioned here.
12700
12701 EOM
12702         case "$dynamic_ext" in
12703         '') dflt="$avail_ext" ;;
12704         *)      dflt="$dynamic_ext"
12705                 # Perhaps we are reusing an old out-of-date config.sh.
12706                 case "$hint" in
12707                 previous)
12708                         if test X"$dynamic_ext" != X"$avail_ext"; then
12709                                 $cat <<EOM
12710 NOTICE:  Your previous config.sh list may be incorrect. 
12711 The extensions now available to you are 
12712         ${avail_ext}
12713 but the default list from your previous config.sh is
12714         ${dynamic_ext} 
12715
12716 EOM
12717                         fi
12718                         ;;
12719                 esac
12720                 ;;
12721         esac
12722         case "$dflt" in
12723         '')     dflt=none;;
12724         esac
12725         rp="What extensions do you wish to load dynamically?"
12726         . ./myread
12727         case "$ans" in
12728         none) dynamic_ext=' ' ;;
12729         *) dynamic_ext="$ans" ;;
12730         esac
12731
12732         case "$static_ext" in
12733         '')
12734                 : Exclude those already listed in dynamic linking
12735                 dflt=''
12736                 for xxx in $avail_ext; do
12737                         case " $dynamic_ext " in
12738                         *" $xxx "*) ;;
12739                         *) dflt="$dflt $xxx" ;;
12740                         esac
12741                 done
12742                 set X $dflt
12743                 shift
12744                 dflt="$*"
12745                 ;;
12746         *)  dflt="$static_ext" 
12747                 ;;
12748         esac
12749
12750         case "$dflt" in
12751         '')     dflt=none;;
12752         esac
12753         rp="What extensions do you wish to load statically?"
12754         . ./myread
12755         case "$ans" in
12756         none) static_ext=' ' ;;
12757         *) static_ext="$ans" ;;
12758         esac
12759         ;;
12760 *)
12761         $cat <<EOM
12762 A number of extensions are supplied with $package.  Answer "none" 
12763 to include no extensions. 
12764 Note that DynaLoader is always built and need not be mentioned here.
12765
12766 EOM
12767         case "$static_ext" in
12768         '') dflt="$avail_ext" ;;
12769         *)      dflt="$static_ext"
12770                 # Perhaps we are reusing an old out-of-date config.sh.
12771                 case "$hint" in
12772                 previous)
12773                         if test X"$static_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         ${static_ext} 
12780
12781 EOM
12782                         fi
12783                         ;;
12784                 esac
12785                 ;;
12786         esac
12787         : Exclude those that are not xs extensions
12788         case "$dflt" in
12789         '')     dflt=none;;
12790         esac
12791         rp="What extensions do you wish to include?"
12792         . ./myread
12793         case "$ans" in
12794         none) static_ext=' ' ;;
12795         *) static_ext="$ans" ;;
12796         esac
12797         ;;
12798 esac
12799
12800 set X $dynamic_ext $static_ext $nonxs_ext
12801 shift
12802 extensions="$*"
12803
12804 : Remove build directory name from cppstdin so it can be used from
12805 : either the present location or the final installed location.
12806 echo " "
12807 : Get out of the UU directory to get correct path name.
12808 cd ..
12809 case "$cppstdin" in
12810 `pwd`/cppstdin)
12811         echo "Stripping down cppstdin path name"
12812         cppstdin=cppstdin
12813         ;;
12814 esac
12815 cd UU
12816
12817 : end of configuration questions
12818 echo " "
12819 echo "End of configuration questions."
12820 echo " "
12821
12822 : back to where it started
12823 if test -d ../UU; then
12824         cd ..
12825 fi
12826
12827 : configuration may be patched via a 'config.over' file
12828 if $test -f config.over; then
12829         echo " "
12830         dflt=y
12831         rp='I see a config.over file.  Do you wish to load it?'
12832         . UU/myread
12833         case "$ans" in
12834         n*) echo "OK, I'll ignore it.";;
12835         *)      . ./config.over
12836                 echo "Configuration override changes have been loaded."
12837                 ;;
12838         esac
12839 fi
12840
12841 : in case they want portability, strip down executable paths
12842 case "$d_portable" in
12843 "$define")
12844         echo " "
12845         echo "Stripping down executable paths..." >&4
12846         for file in $loclist $trylist; do
12847                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12848                         eval $file="\$file"
12849                 fi
12850         done
12851         ;;
12852 esac
12853
12854 : create config.sh file
12855 echo " "
12856 echo "Creating config.sh..." >&4
12857 $spitshell <<EOT >config.sh
12858 $startsh
12859 #
12860 # This file was produced by running the Configure script. It holds all the
12861 # definitions figured out by Configure. Should you modify one of these values,
12862 # do not forget to propagate your changes by running "Configure -der". You may
12863 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12864 #
12865
12866 # Package name      : $package
12867 # Source directory  : $src
12868 # Configuration time: $cf_time
12869 # Configured by     : $cf_by
12870 # Target system     : $myuname
12871
12872 Author='$Author'
12873 Date='$Date'
12874 Header='$Header'
12875 Id='$Id'
12876 Locker='$Locker'
12877 Log='$Log'
12878 Mcc='$Mcc'
12879 RCSfile='$RCSfile'
12880 Revision='$Revision'
12881 Source='$Source'
12882 State='$State'
12883 _a='$_a'
12884 _exe='$_exe'
12885 _o='$_o'
12886 afs='$afs'
12887 alignbytes='$alignbytes'
12888 ansi2knr='$ansi2knr'
12889 aphostname='$aphostname'
12890 apiversion='$apiversion'
12891 ar='$ar'
12892 archlib='$archlib'
12893 archlibexp='$archlibexp'
12894 archname64='$archname64'
12895 archname='$archname'
12896 archobjs='$archobjs'
12897 awk='$awk'
12898 baserev='$baserev'
12899 bash='$bash'
12900 bin='$bin'
12901 binexp='$binexp'
12902 bison='$bison'
12903 byacc='$byacc'
12904 byteorder='$byteorder'
12905 c='$c'
12906 castflags='$castflags'
12907 cat='$cat'
12908 cc='$cc'
12909 cccdlflags='$cccdlflags'
12910 ccdlflags='$ccdlflags'
12911 ccflags='$ccflags'
12912 ccsymbols='$ccsymbols'
12913 cf_by='$cf_by'
12914 cf_email='$cf_email'
12915 cf_time='$cf_time'
12916 chgrp='$chgrp'
12917 chmod='$chmod'
12918 chown='$chown'
12919 clocktype='$clocktype'
12920 comm='$comm'
12921 compress='$compress'
12922 contains='$contains'
12923 cp='$cp'
12924 cpio='$cpio'
12925 cpp='$cpp'
12926 cpp_stuff='$cpp_stuff'
12927 cppccsymbols='$cppccsymbols'
12928 cppflags='$cppflags'
12929 cpplast='$cpplast'
12930 cppminus='$cppminus'
12931 cpprun='$cpprun'
12932 cppstdin='$cppstdin'
12933 cppsymbols='$cppsymbols'
12934 crosscompile='$crosscompile'
12935 cryptlib='$cryptlib'
12936 csh='$csh'
12937 d_Gconvert='$d_Gconvert'
12938 d_access='$d_access'
12939 d_accessx='$d_accessx'
12940 d_alarm='$d_alarm'
12941 d_archlib='$d_archlib'
12942 d_attribut='$d_attribut'
12943 d_bcmp='$d_bcmp'
12944 d_bcopy='$d_bcopy'
12945 d_bsd='$d_bsd'
12946 d_bsdgetpgrp='$d_bsdgetpgrp'
12947 d_bsdsetpgrp='$d_bsdsetpgrp'
12948 d_bzero='$d_bzero'
12949 d_casti32='$d_casti32'
12950 d_castneg='$d_castneg'
12951 d_charvspr='$d_charvspr'
12952 d_chown='$d_chown'
12953 d_chroot='$d_chroot'
12954 d_chsize='$d_chsize'
12955 d_closedir='$d_closedir'
12956 d_cmsghdr_s='$d_cmsghdr_s'
12957 d_const='$d_const'
12958 d_crypt='$d_crypt'
12959 d_csh='$d_csh'
12960 d_cuserid='$d_cuserid'
12961 d_dbl_dig='$d_dbl_dig'
12962 d_dbmclose64='$d_dbmclose64'
12963 d_dbminit64='$d_dbminit64'
12964 d_delete64='$d_delete64'
12965 d_difftime='$d_difftime'
12966 d_dirent64_s='$d_dirent64_s'
12967 d_dirnamlen='$d_dirnamlen'
12968 d_dlerror='$d_dlerror'
12969 d_dlopen='$d_dlopen'
12970 d_dlsymun='$d_dlsymun'
12971 d_dosuid='$d_dosuid'
12972 d_drand48proto='$d_drand48proto'
12973 d_dup2='$d_dup2'
12974 d_eaccess='$d_eaccess'
12975 d_endgrent='$d_endgrent'
12976 d_endhent='$d_endhent'
12977 d_endnent='$d_endnent'
12978 d_endpent='$d_endpent'
12979 d_endpwent='$d_endpwent'
12980 d_endsent='$d_endsent'
12981 d_eofnblk='$d_eofnblk'
12982 d_eunice='$d_eunice'
12983 d_fchmod='$d_fchmod'
12984 d_fchown='$d_fchown'
12985 d_fcntl='$d_fcntl'
12986 d_fd_macros='$d_fd_macros'
12987 d_fd_set='$d_fd_set'
12988 d_fds_bits='$d_fds_bits'
12989 d_fetch64='$d_fetch64'
12990 d_fgetpos64='$d_fgetpos64'
12991 d_fgetpos='$d_fgetpos'
12992 d_firstkey64='$d_firstkey64'
12993 d_flexfnam='$d_flexfnam'
12994 d_flock64_s='$d_flock64_s'
12995 d_flock='$d_flock'
12996 d_fopen64='$d_fopen64'
12997 d_fork='$d_fork'
12998 d_fpathconf='$d_fpathconf'
12999 d_freopen64='$d_freopen64'
13000 d_fseek64='$d_fseek64'
13001 d_fseeko64='$d_fseeko64'
13002 d_fseeko='$d_fseeko'
13003 d_fsetpos64='$d_fsetpos64'
13004 d_fsetpos='$d_fsetpos'
13005 d_fstat64='$d_fstat64'
13006 d_fstatfs='$d_fstatfs'
13007 d_fstatvfs='$d_fstatvfs'
13008 d_ftell64='$d_ftell64'
13009 d_ftello64='$d_ftello64'
13010 d_ftello='$d_ftello'
13011 d_ftime='$d_ftime'
13012 d_ftruncate64='$d_ftruncate64'
13013 d_getgrent='$d_getgrent'
13014 d_getgrps='$d_getgrps'
13015 d_gethbyaddr='$d_gethbyaddr'
13016 d_gethbyname='$d_gethbyname'
13017 d_gethent='$d_gethent'
13018 d_gethname='$d_gethname'
13019 d_gethostprotos='$d_gethostprotos'
13020 d_getlogin='$d_getlogin'
13021 d_getmntent='$d_getmntent'
13022 d_getnbyaddr='$d_getnbyaddr'
13023 d_getnbyname='$d_getnbyname'
13024 d_getnent='$d_getnent'
13025 d_getnetprotos='$d_getnetprotos'
13026 d_getpbyname='$d_getpbyname'
13027 d_getpbynumber='$d_getpbynumber'
13028 d_getpent='$d_getpent'
13029 d_getpgid='$d_getpgid'
13030 d_getpgrp2='$d_getpgrp2'
13031 d_getpgrp='$d_getpgrp'
13032 d_getppid='$d_getppid'
13033 d_getprior='$d_getprior'
13034 d_getprotoprotos='$d_getprotoprotos'
13035 d_getpwent='$d_getpwent'
13036 d_getsbyname='$d_getsbyname'
13037 d_getsbyport='$d_getsbyport'
13038 d_getsent='$d_getsent'
13039 d_getservprotos='$d_getservprotos'
13040 d_gettimeod='$d_gettimeod'
13041 d_gnulibc='$d_gnulibc'
13042 d_grpasswd='$d_grpasswd'
13043 d_hasmntopt='$d_hasmntopt'
13044 d_htonl='$d_htonl'
13045 d_index='$d_index'
13046 d_inetaton='$d_inetaton'
13047 d_ino64_t='$d_ino64_t'
13048 d_int64t='$d_int64t'
13049 d_iovec_s='$d_iovec_s'
13050 d_isascii='$d_isascii'
13051 d_killpg='$d_killpg'
13052 d_lchown='$d_lchown'
13053 d_link='$d_link'
13054 d_llseek='$d_llseek'
13055 d_locconv='$d_locconv'
13056 d_lockf64='$d_lockf64'
13057 d_lockf='$d_lockf'
13058 d_longdbl='$d_longdbl'
13059 d_longlong='$d_longlong'
13060 d_lseek64='$d_lseek64'
13061 d_lstat64='$d_lstat64'
13062 d_lstat='$d_lstat'
13063 d_madvise='$d_madvise'
13064 d_mblen='$d_mblen'
13065 d_mbstowcs='$d_mbstowcs'
13066 d_mbtowc='$d_mbtowc'
13067 d_memchr='$d_memchr'
13068 d_memcmp='$d_memcmp'
13069 d_memcpy='$d_memcpy'
13070 d_memmove='$d_memmove'
13071 d_memset='$d_memset'
13072 d_mkdir='$d_mkdir'
13073 d_mkfifo='$d_mkfifo'
13074 d_mktime='$d_mktime'
13075 d_mmap='$d_mmap'
13076 d_mprotect='$d_mprotect'
13077 d_msg='$d_msg'
13078 d_msg_ctrunc='$d_msg_ctrunc'
13079 d_msg_dontroute='$d_msg_dontroute'
13080 d_msg_oob='$d_msg_oob'
13081 d_msg_peek='$d_msg_peek'
13082 d_msg_proxy='$d_msg_proxy'
13083 d_msgctl='$d_msgctl'
13084 d_msgget='$d_msgget'
13085 d_msghdr_s='$d_msghdr_s'
13086 d_msgrcv='$d_msgrcv'
13087 d_msgsnd='$d_msgsnd'
13088 d_msync='$d_msync'
13089 d_munmap='$d_munmap'
13090 d_mymalloc='$d_mymalloc'
13091 d_nextkey64='$d_nextkey64'
13092 d_nice='$d_nice'
13093 d_off64_t='$d_off64_t'
13094 d_offset_t='$d_offset_t'
13095 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
13096 d_oldpthreads='$d_oldpthreads'
13097 d_oldsock='$d_oldsock'
13098 d_open3='$d_open3'
13099 d_open64='$d_open64'
13100 d_opendir64='$d_opendir64'
13101 d_pathconf='$d_pathconf'
13102 d_pause='$d_pause'
13103 d_phostname='$d_phostname'
13104 d_pipe='$d_pipe'
13105 d_poll='$d_poll'
13106 d_portable='$d_portable'
13107 d_pthread_yield='$d_pthread_yield'
13108 d_pwage='$d_pwage'
13109 d_pwchange='$d_pwchange'
13110 d_pwclass='$d_pwclass'
13111 d_pwcomment='$d_pwcomment'
13112 d_pwexpire='$d_pwexpire'
13113 d_pwgecos='$d_pwgecos'
13114 d_pwpasswd='$d_pwpasswd'
13115 d_pwquota='$d_pwquota'
13116 d_readdir64='$d_readdir64'
13117 d_readdir='$d_readdir'
13118 d_readlink='$d_readlink'
13119 d_readv='$d_readv'
13120 d_recvmsg='$d_recvmsg'
13121 d_rename='$d_rename'
13122 d_rewinddir='$d_rewinddir'
13123 d_rmdir='$d_rmdir'
13124 d_safebcpy='$d_safebcpy'
13125 d_safemcpy='$d_safemcpy'
13126 d_sanemcmp='$d_sanemcmp'
13127 d_sched_yield='$d_sched_yield'
13128 d_scm_rights='$d_scm_rights'
13129 d_seekdir64='$d_seekdir64'
13130 d_seekdir='$d_seekdir'
13131 d_select='$d_select'
13132 d_sem='$d_sem'
13133 d_semctl='$d_semctl'
13134 d_semctl_semid_ds='$d_semctl_semid_ds'
13135 d_semctl_semun='$d_semctl_semun'
13136 d_semget='$d_semget'
13137 d_semop='$d_semop'
13138 d_sendmsg='$d_sendmsg'
13139 d_setegid='$d_setegid'
13140 d_seteuid='$d_seteuid'
13141 d_setgrent='$d_setgrent'
13142 d_setgrps='$d_setgrps'
13143 d_sethent='$d_sethent'
13144 d_setlinebuf='$d_setlinebuf'
13145 d_setlocale='$d_setlocale'
13146 d_setnent='$d_setnent'
13147 d_setpent='$d_setpent'
13148 d_setpgid='$d_setpgid'
13149 d_setpgrp2='$d_setpgrp2'
13150 d_setpgrp='$d_setpgrp'
13151 d_setprior='$d_setprior'
13152 d_setpwent='$d_setpwent'
13153 d_setregid='$d_setregid'
13154 d_setresgid='$d_setresgid'
13155 d_setresuid='$d_setresuid'
13156 d_setreuid='$d_setreuid'
13157 d_setrgid='$d_setrgid'
13158 d_setruid='$d_setruid'
13159 d_setsent='$d_setsent'
13160 d_setsid='$d_setsid'
13161 d_setvbuf='$d_setvbuf'
13162 d_sfio='$d_sfio'
13163 d_shm='$d_shm'
13164 d_shmat='$d_shmat'
13165 d_shmatprototype='$d_shmatprototype'
13166 d_shmctl='$d_shmctl'
13167 d_shmdt='$d_shmdt'
13168 d_shmget='$d_shmget'
13169 d_sigaction='$d_sigaction'
13170 d_sigsetjmp='$d_sigsetjmp'
13171 d_socket='$d_socket'
13172 d_sockpair='$d_sockpair'
13173 d_stat64='$d_stat64'
13174 d_statblks='$d_statblks'
13175 d_statfs='$d_statfs'
13176 d_statfsflags='$d_statfsflags'
13177 d_statvfs='$d_statvfs'
13178 d_stdio_cnt_lval='$d_stdio_cnt_lval'
13179 d_stdio_ptr_lval='$d_stdio_ptr_lval'
13180 d_stdio_stream_array='$d_stdio_stream_array'
13181 d_stdiobase='$d_stdiobase'
13182 d_stdstdio='$d_stdstdio'
13183 d_store64='$d_store64'
13184 d_strchr='$d_strchr'
13185 d_strcoll='$d_strcoll'
13186 d_strctcpy='$d_strctcpy'
13187 d_strerrm='$d_strerrm'
13188 d_strerror='$d_strerror'
13189 d_strtod='$d_strtod'
13190 d_strtol='$d_strtol'
13191 d_strtoul='$d_strtoul'
13192 d_strxfrm='$d_strxfrm'
13193 d_suidsafe='$d_suidsafe'
13194 d_symlink='$d_symlink'
13195 d_syscall='$d_syscall'
13196 d_sysconf='$d_sysconf'
13197 d_sysernlst='$d_sysernlst'
13198 d_syserrlst='$d_syserrlst'
13199 d_system='$d_system'
13200 d_tcgetpgrp='$d_tcgetpgrp'
13201 d_tcsetpgrp='$d_tcsetpgrp'
13202 d_telldir64='$d_telldir64'
13203 d_telldir='$d_telldir'
13204 d_telldirproto='$d_telldirproto'
13205 d_time='$d_time'
13206 d_times='$d_times'
13207 d_tmpfile64='$d_tmpfile64'
13208 d_truncate64='$d_truncate64'
13209 d_truncate='$d_truncate'
13210 d_tzname='$d_tzname'
13211 d_umask='$d_umask'
13212 d_uname='$d_uname'
13213 d_union_semun='$d_union_semun'
13214 d_vfork='$d_vfork'
13215 d_void_closedir='$d_void_closedir'
13216 d_voidsig='$d_voidsig'
13217 d_voidtty='$d_voidtty'
13218 d_volatile='$d_volatile'
13219 d_vprintf='$d_vprintf'
13220 d_wait4='$d_wait4'
13221 d_waitpid='$d_waitpid'
13222 d_wcstombs='$d_wcstombs'
13223 d_wctomb='$d_wctomb'
13224 d_writev='$d_writev'
13225 d_xenix='$d_xenix'
13226 date='$date'
13227 db_hashtype='$db_hashtype'
13228 db_prefixtype='$db_prefixtype'
13229 defvoidused='$defvoidused'
13230 direntrytype='$direntrytype'
13231 dlext='$dlext'
13232 dlsrc='$dlsrc'
13233 doublesize='$doublesize'
13234 drand01='$drand01'
13235 dynamic_ext='$dynamic_ext'
13236 eagain='$eagain'
13237 ebcdic='$ebcdic'
13238 echo='$echo'
13239 egrep='$egrep'
13240 emacs='$emacs'
13241 eunicefix='$eunicefix'
13242 exe_ext='$exe_ext'
13243 expr='$expr'
13244 extensions='$extensions'
13245 fflushNULL='$fflushNULL'
13246 fflushall='$fflushall'
13247 find='$find'
13248 firstmakefile='$firstmakefile'
13249 flex='$flex'
13250 fpostype='$fpostype'
13251 freetype='$freetype'
13252 full_ar='$full_ar'
13253 full_csh='$full_csh'
13254 full_sed='$full_sed'
13255 gccversion='$gccversion'
13256 gidtype='$gidtype'
13257 glibpth='$glibpth'
13258 grep='$grep'
13259 groupcat='$groupcat'
13260 groupstype='$groupstype'
13261 gzip='$gzip'
13262 h_fcntl='$h_fcntl'
13263 h_sysfile='$h_sysfile'
13264 hint='$hint'
13265 hostcat='$hostcat'
13266 huge='$huge'
13267 i_arpainet='$i_arpainet'
13268 i_bsdioctl='$i_bsdioctl'
13269 i_db='$i_db'
13270 i_dbm='$i_dbm'
13271 i_dirent='$i_dirent'
13272 i_dld='$i_dld'
13273 i_dlfcn='$i_dlfcn'
13274 i_fcntl='$i_fcntl'
13275 i_float='$i_float'
13276 i_gdbm='$i_gdbm'
13277 i_grp='$i_grp'
13278 i_inttypes='$i_inttypes'
13279 i_limits='$i_limits'
13280 i_locale='$i_locale'
13281 i_machcthr='$i_machcthr'
13282 i_malloc='$i_malloc'
13283 i_math='$i_math'
13284 i_memory='$i_memory'
13285 i_mntent='$i_mntent'
13286 i_ndbm='$i_ndbm'
13287 i_netdb='$i_netdb'
13288 i_neterrno='$i_neterrno'
13289 i_netinettcp='$i_netinettcp'
13290 i_niin='$i_niin'
13291 i_poll='$i_poll'
13292 i_pthread='$i_pthread'
13293 i_pwd='$i_pwd'
13294 i_rpcsvcdbm='$i_rpcsvcdbm'
13295 i_sfio='$i_sfio'
13296 i_sgtty='$i_sgtty'
13297 i_stdarg='$i_stdarg'
13298 i_stddef='$i_stddef'
13299 i_stdlib='$i_stdlib'
13300 i_string='$i_string'
13301 i_sysaccess='$i_sysaccess'
13302 i_sysdir='$i_sysdir'
13303 i_sysfile='$i_sysfile'
13304 i_sysfilio='$i_sysfilio'
13305 i_sysin='$i_sysin'
13306 i_sysioctl='$i_sysioctl'
13307 i_sysmman='$i_sysmman'
13308 i_sysmount='$i_sysmount'
13309 i_sysndir='$i_sysndir'
13310 i_sysparam='$i_sysparam'
13311 i_sysresrc='$i_sysresrc'
13312 i_syssecrt='$i_syssecrt'
13313 i_sysselct='$i_sysselct'
13314 i_syssockio='$i_syssockio'
13315 i_sysstat='$i_sysstat'
13316 i_sysstatvfs='$i_sysstatvfs'
13317 i_systime='$i_systime'
13318 i_systimek='$i_systimek'
13319 i_systimes='$i_systimes'
13320 i_systypes='$i_systypes'
13321 i_sysuio='$i_sysuio'
13322 i_sysun='$i_sysun'
13323 i_syswait='$i_syswait'
13324 i_termio='$i_termio'
13325 i_termios='$i_termios'
13326 i_time='$i_time'
13327 i_unistd='$i_unistd'
13328 i_utime='$i_utime'
13329 i_values='$i_values'
13330 i_varargs='$i_varargs'
13331 i_varhdr='$i_varhdr'
13332 i_vfork='$i_vfork'
13333 ignore_versioned_solibs='$ignore_versioned_solibs'
13334 incpath='$incpath'
13335 inews='$inews'
13336 installarchlib='$installarchlib'
13337 installbin='$installbin'
13338 installman1dir='$installman1dir'
13339 installman3dir='$installman3dir'
13340 installprivlib='$installprivlib'
13341 installscript='$installscript'
13342 installsitearch='$installsitearch'
13343 installsitelib='$installsitelib'
13344 installusrbinperl='$installusrbinperl'
13345 intsize='$intsize'
13346 known_extensions='$known_extensions'
13347 ksh='$ksh'
13348 large='$large'
13349 ld='$ld'
13350 lddlflags='$lddlflags'
13351 ldflags='$ldflags'
13352 less='$less'
13353 lib_ext='$lib_ext'
13354 libc='$libc'
13355 libperl='$libperl'
13356 libpth='$libpth'
13357 libs='$libs'
13358 libswanted='$libswanted'
13359 line='$line'
13360 lint='$lint'
13361 lkflags='$lkflags'
13362 ln='$ln'
13363 lns='$lns'
13364 locincpth='$locincpth'
13365 loclibpth='$loclibpth'
13366 longdblsize='$longdblsize'
13367 longlongsize='$longlongsize'
13368 longsize='$longsize'
13369 lp='$lp'
13370 lpr='$lpr'
13371 ls='$ls'
13372 lseeksize='$lseeksize'
13373 lseektype='$lseektype'
13374 mail='$mail'
13375 mailx='$mailx'
13376 make='$make'
13377 make_set_make='$make_set_make'
13378 mallocobj='$mallocobj'
13379 mallocsrc='$mallocsrc'
13380 malloctype='$malloctype'
13381 man1dir='$man1dir'
13382 man1direxp='$man1direxp'
13383 man1ext='$man1ext'
13384 man3dir='$man3dir'
13385 man3direxp='$man3direxp'
13386 man3ext='$man3ext'
13387 medium='$medium'
13388 mips='$mips'
13389 mips_type='$mips_type'
13390 mkdir='$mkdir'
13391 mmaptype='$mmaptype'
13392 models='$models'
13393 modetype='$modetype'
13394 more='$more'
13395 multiarch='$multiarch'
13396 mv='$mv'
13397 myarchname='$myarchname'
13398 mydomain='$mydomain'
13399 myhostname='$myhostname'
13400 myuname='$myuname'
13401 n='$n'
13402 netdb_hlen_type='$netdb_hlen_type'
13403 netdb_host_type='$netdb_host_type'
13404 netdb_name_type='$netdb_name_type'
13405 netdb_net_type='$netdb_net_type'
13406 nm='$nm'
13407 nm_opt='$nm_opt'
13408 nm_so_opt='$nm_so_opt'
13409 nonxs_ext='$nonxs_ext'
13410 nroff='$nroff'
13411 o_nonblock='$o_nonblock'
13412 obj_ext='$obj_ext'
13413 old_pthread_create_joinable='$old_pthread_create_joinable'
13414 optimize='$optimize'
13415 orderlib='$orderlib'
13416 osname='$osname'
13417 osvers='$osvers'
13418 package='$package'
13419 pager='$pager'
13420 passcat='$passcat'
13421 patchlevel='$patchlevel'
13422 path_sep='$path_sep'
13423 perl='$perl'
13424 perladmin='$perladmin'
13425 perlpath='$perlpath'
13426 pg='$pg'
13427 phostname='$phostname'
13428 pidtype='$pidtype'
13429 plibpth='$plibpth'
13430 pmake='$pmake'
13431 pr='$pr'
13432 prefix='$prefix'
13433 prefixexp='$prefixexp'
13434 privlib='$privlib'
13435 privlibexp='$privlibexp'
13436 prototype='$prototype'
13437 ptrsize='$ptrsize'
13438 randbits='$randbits'
13439 randfunc='$randfunc'
13440 randseedtype='$randseedtype'
13441 ranlib='$ranlib'
13442 rd_nodata='$rd_nodata'
13443 rm='$rm'
13444 rmail='$rmail'
13445 runnm='$runnm'
13446 sched_yield='$sched_yield'
13447 scriptdir='$scriptdir'
13448 scriptdirexp='$scriptdirexp'
13449 sed='$sed'
13450 seedfunc='$seedfunc'
13451 selectminbits='$selectminbits'
13452 selecttype='$selecttype'
13453 sendmail='$sendmail'
13454 sh='$sh'
13455 shar='$shar'
13456 sharpbang='$sharpbang'
13457 shmattype='$shmattype'
13458 shortsize='$shortsize'
13459 shrpenv='$shrpenv'
13460 shsharp='$shsharp'
13461 sig_count='$sig_count'
13462 sig_name='$sig_name'
13463 sig_name_init='$sig_name_init'
13464 sig_num='$sig_num'
13465 sig_num_init='$sig_num_init'
13466 signal_t='$signal_t'
13467 sitearch='$sitearch'
13468 sitearchexp='$sitearchexp'
13469 sitelib='$sitelib'
13470 sitelibexp='$sitelibexp'
13471 sizetype='$sizetype'
13472 sleep='$sleep'
13473 smail='$smail'
13474 small='$small'
13475 so='$so'
13476 sockethdr='$sockethdr'
13477 socketlib='$socketlib'
13478 sort='$sort'
13479 spackage='$spackage'
13480 spitshell='$spitshell'
13481 split='$split'
13482 src='$src'
13483 ssizetype='$ssizetype'
13484 startperl='$startperl'
13485 startsh='$startsh'
13486 static_ext='$static_ext'
13487 stdchar='$stdchar'
13488 stdio_base='$stdio_base'
13489 stdio_bufsiz='$stdio_bufsiz'
13490 stdio_cnt='$stdio_cnt'
13491 stdio_filbuf='$stdio_filbuf'
13492 stdio_ptr='$stdio_ptr'
13493 stdio_stream_array='$stdio_stream_array'
13494 strings='$strings'
13495 submit='$submit'
13496 subversion='$subversion'
13497 sysman='$sysman'
13498 tail='$tail'
13499 tar='$tar'
13500 tbl='$tbl'
13501 tee='$tee'
13502 test='$test'
13503 timeincl='$timeincl'
13504 timetype='$timetype'
13505 touch='$touch'
13506 tr='$tr'
13507 trnl='$trnl'
13508 troff='$troff'
13509 uidtype='$uidtype'
13510 uname='$uname'
13511 uniq='$uniq'
13512 use64bits='$use64bits'
13513 usedl='$usedl'
13514 usemultiplicity='$usemultiplicity'
13515 usemymalloc='$usemymalloc'
13516 usenm='$usenm'
13517 useopcode='$useopcode'
13518 useperlio='$useperlio'
13519 useposix='$useposix'
13520 usesfio='$usesfio'
13521 useshrplib='$useshrplib'
13522 usethreads='$usethreads'
13523 usevfork='$usevfork'
13524 usrinc='$usrinc'
13525 uuname='$uuname'
13526 version='$version'
13527 vi='$vi'
13528 voidflags='$voidflags'
13529 xlibpth='$xlibpth'
13530 zcat='$zcat'
13531 zip='$zip'
13532 EOT
13533
13534 : Add in command line options if available
13535 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13536
13537 : add special variables
13538 $test -f $src/patchlevel.h && \
13539 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13540 echo "CONFIGDOTSH=true" >>config.sh
13541
13542 : propagate old symbols
13543 if $test -f UU/config.sh; then
13544         <UU/config.sh sort | uniq >UU/oldconfig.sh
13545         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13546         sort | uniq -u >UU/oldsyms
13547         set X `cat UU/oldsyms`
13548         shift
13549         case $# in
13550         0) ;;
13551         *)
13552                 cat <<EOM
13553 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13554 EOM
13555                 echo "# Variables propagated from previous config.sh file." >>config.sh
13556                 for sym in `cat UU/oldsyms`; do
13557                         echo "    Propagating $hint variable "'$'"$sym..."
13558                         eval 'tmp="$'"${sym}"'"'
13559                         echo "$tmp" | \
13560                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13561                 done
13562                 ;;
13563         esac
13564 fi
13565
13566 : Finish up by extracting the .SH files
13567 case "$alldone" in
13568 exit)
13569         $rm -rf UU
13570         echo "Done."
13571         exit 0
13572         ;;
13573 cont)
13574         ;;
13575 '')
13576         dflt=''
13577         nostick=true
13578         $cat <<EOM
13579
13580 If you'd like to make any changes to the config.sh file before I begin
13581 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13582
13583 EOM
13584         rp="Press return or use a shell escape to edit config.sh:"
13585         . UU/myread
13586         nostick=''
13587         case "$ans" in
13588         '') ;;
13589         *) : in case they cannot read
13590                 sh 1>&4 -c "$ans";;
13591         esac
13592         ;;
13593 esac
13594
13595 : if this fails, just run all the .SH files by hand
13596 . ./config.sh
13597
13598 echo " "
13599 exec 1>&4
13600 . ./UU/extract
13601
13602 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13603         dflt=y
13604         case "$silent" in
13605         true) ;;
13606         *)
13607                 $cat <<EOM
13608
13609 Now you need to generate make dependencies by running "$make depend".
13610 You might prefer to run it in background: "$make depend > makedepend.out &"
13611 It can take a while, so you might not want to run it right now.
13612
13613 EOM
13614                 ;;
13615         esac
13616         rp="Run $make depend now?"
13617         . UU/myread
13618         case "$ans" in
13619         y*)
13620                 $make depend && echo "Now you must run a $make."
13621                 ;;
13622         *)
13623                 echo "You must run '$make depend' then '$make'."
13624                 ;;
13625         esac
13626 elif test -f [Mm]akefile; then
13627         echo " "
13628         echo "Now you must run a $make."
13629 else
13630         echo "Done."
13631 fi
13632
13633 if $test -f Policy.sh; then
13634     $cat <<EOM
13635
13636 If you compile $package on a different machine or from a different object
13637 directory, copy the Policy.sh file from this object directory to the
13638 new one before you run Configure -- this will help you with most of
13639 the policy defaults.
13640
13641 EOM
13642 fi
13643 if $test -f config.msg; then
13644     echo "Hmm.  I also noted the following information while running:"
13645     echo " "
13646     $cat config.msg >&4
13647     $rm -f config.msg
13648 fi
13649 $rm -f kit*isdone ark*isdone
13650 $rm -rf UU
13651
13652 : End of Configure
13653