Make Configure recognise glibc 2.1 stdio
[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 Wed May 26 01:56:24 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 # SunOS has a <unistd.h> which we generally avoid, but need for this test.
10966 # For everyone else, we'll trust i_unistd.
10967 t_unistd=$i_unistd
10968 case "$osname" in
10969 sunos) $test -f /usr/include/unistd.h && t_unistd=$define ;;
10970 esac
10971 $cat >&4 <<EOM
10972 Checking how to flush all pending stdio output...
10973 EOM
10974 $cat >try.c <<EOCP
10975 #include <stdio.h>
10976 #$t_unistd I_UNISTD
10977 #ifdef I_UNISTD
10978 # include <unistd.h>
10979 #endif
10980 #$d_sysconf HAS_SYSCONF
10981 #$d_stdio_stream_array HAS_STDIO_STREAM_ARRAY
10982 #ifdef HAS_STDIO_STREAM_ARRAY
10983 # define STDIO_STREAM_ARRAY $stdio_stream_array
10984 #endif
10985 int main() {
10986   FILE* p = fopen("try.out", "w");
10987 #ifdef TRY_FPUTC
10988   fputc('x', p);
10989 #else
10990 # ifdef TRY_FPRINTF
10991   fprintf(p, "x");
10992 # endif
10993 #endif
10994 #ifdef TRY_FFLUSH_NULL
10995   fflush(NULL);
10996 #endif
10997 #ifdef TRY_FFLUSH_ALL
10998   {
10999     long open_max = -1;
11000 # if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
11001     open_max = sysconf(_SC_OPEN_MAX);
11002 # else
11003 #  ifdef FOPEN_MAX
11004 #   open_max = FOPEN_MAX;
11005 #  else
11006 #   ifdef OPEN_MAX
11007 #   open_max = OPEN_MAX;
11008 #   else
11009 #    ifdef _NFILE
11010 #   open_max = _NFILE;
11011 #    endif
11012 #   endif
11013 #  endif
11014 # endif
11015 # ifdef HAS_STDIO_STREAM_ARRAY
11016     if (open_max > 0) {
11017       long i;
11018       for (i = 0; i < open_max; i++)
11019          fflush(&$stdio_stream_array[i]);
11020     }   
11021   }
11022 # endif
11023 #endif
11024   _exit(42);
11025 }
11026 EOCP
11027 : first we have to find out how _not_ to flush
11028 if $test "X$fflushNULL" = X -o "X$fflushall" = X; then
11029     output=''
11030     set try -DTRY_FPUTC
11031     $rm -f try.out
11032     if eval $compile; then
11033             ./try$exe_ext 2>/dev/null
11034             if $test ! -s try.out -a "X$?" = X42; then
11035                 output=-DTRY_FPUTC
11036             fi
11037     fi
11038     case "$output" in
11039     '')
11040             set try -DTRY_FPRINTF
11041             $rm -f try.out
11042             if eval $compile; then
11043                     ./try$exe_ext 2>/dev/null
11044                     if $test ! -s try.out -a "X$?" = X42; then
11045                         output=-DTRY_FPRINTF
11046                     fi
11047             fi
11048         ;;
11049     esac
11050 fi
11051 : check for fflush NULL behaviour
11052 case "$fflushNULL" in
11053 '')     set try -DTRY_FFLUSH_NULL $output
11054         $rm -f try.out
11055         if eval $compile; then
11056                 ./try$exe_ext 2>/dev/null
11057                 code="$?"
11058                 if $test -s try.out -a "X$code" = X42; then
11059                         fflushNULL="`$cat try.out`"
11060                 else
11061                         if $test "X$code" != X42; then
11062                                 $cat >&4 <<EOM
11063 (If this test failed, don't worry, we'll try another method shortly.)
11064 EOM
11065                         fi
11066                 fi
11067         fi
11068         $rm -f core try.core core.try.*
11069         case "$fflushNULL" in
11070         x)      $cat >&4 <<EOM
11071 Your fflush(NULL) works okay.
11072 EOM
11073                 fflushNULL="$define"
11074                 ;;
11075         '')     $cat >&4 <<EOM
11076 Your fflush(NULL) isn't working (contrary to ANSI C).
11077 EOM
11078                 fflushNULL="$undef"
11079                 ;;
11080         *)      $cat >&4 <<EOM
11081 Cannot figure out whether your fflush(NULL) works or not.
11082 I'm assuming it doesn't (contrary to ANSI C).
11083 EOM
11084                 fflushNULL="$undef"
11085                 ;;
11086         esac
11087         ;;
11088 $define|true|[yY]*)
11089         fflushNULL="$define"
11090         ;;
11091 *)
11092         fflushNULL="$undef"
11093         ;;
11094 esac
11095 : check explicit looping only if NULL did not work
11096 case "$fflushNULL" in
11097 "$undef")
11098         : check for fflush all behaviour
11099         case "$fflushall" in
11100         '')     set try -DTRY_FFLUSH_ALL $output
11101                 $rm -f try.out
11102                 if eval $compile; then
11103                 $cat >&4 <<EOM
11104 (Now testing the other method--but note that also this may fail.)
11105 EOM
11106                         ./try$exe_ext 2>/dev/null
11107                         if $test -s try.out -a "X$?" = X42; then
11108                                 fflushall="`$cat try.out`"
11109                         fi
11110                 fi
11111                 $rm -f core try.core core.try.*
11112                 case "$fflushall" in
11113                 x)      $cat >&4 <<EOM
11114 Whew. Flushing explicitly all the stdio streams works.
11115 EOM
11116                         fflushall="$define"
11117                         ;;
11118                 '')     $cat >&4 <<EOM
11119 Sigh. Flushing explicitly all the stdio streams doesn't work.
11120 EOM
11121                         fflushall="$undef"
11122                         ;;
11123                 *)      $cat >&4 <<EOM
11124 Cannot figure out whether flushing stdio streams explicitly works or not.
11125 I'm assuming it doesn't.
11126 EOM
11127                         fflushall="$undef"
11128                         ;;
11129                 esac
11130                 ;;
11131         "$define"|true|[yY]*)
11132                 fflushall="$define"
11133                 ;;
11134         *)
11135                 fflushall="$undef"
11136                 ;;
11137         esac
11138         ;;
11139 *)      fflushall="$undef"      
11140         ;;
11141 esac
11142 case "$fflushNULL$fflushall" in
11143 undefundef)
11144         $cat <<EOM
11145 I cannot figure out how to flush pending stdio output.
11146 EOM
11147         ;;
11148 esac
11149 $rm -f try.* try$exe_ext
11150
11151 : see what type file positions are declared as in the library
11152 rp="What is the type for file position used by fsetpos()?"
11153 set fpos_t fpostype long stdio.h sys/types.h
11154 eval $typedef_ask
11155
11156 : Store the full pathname to the ar program for use in the C program
11157 : Respect a hint or command line value for full_ar.
11158 case "$full_ar" in
11159 '') full_ar=$ar ;;
11160 esac
11161
11162 : Store the full pathname to the sed program for use in the C program
11163 full_sed=$sed
11164
11165 : see what type gids are declared as in the kernel
11166 echo " "
11167 echo "Looking for the type for group ids returned by getgid()."
11168 set gid_t gidtype xxx stdio.h sys/types.h
11169 eval $typedef
11170 case "$gidtype" in
11171 xxx)
11172         xxx=`./findhdr sys/user.h`
11173         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
11174         case $1 in
11175         unsigned) dflt="$1 $2" ;;
11176         *) dflt="$1" ;;
11177         esac
11178         ;;
11179 *) dflt="$gidtype";;
11180 esac
11181 case "$gidtype" in
11182 gid_t) echo "gid_t found." ;;
11183 *)      rp="What is the type for group ids returned by getgid()?"
11184         . ./myread
11185         gidtype="$ans"
11186         ;;
11187 esac
11188
11189 : see if getgroups exists
11190 set getgroups d_getgrps
11191 eval $inlibc
11192
11193 : see if setgroups exists
11194 set setgroups d_setgrps
11195 eval $inlibc
11196
11197
11198 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11199 echo " "
11200 case "$d_getgrps$d_setgrps" in
11201 *define*)
11202         case "$groupstype" in
11203         '') dflt="$gidtype" ;;
11204         *)  dflt="$groupstype" ;;
11205         esac
11206         $cat <<EOM
11207 What type of pointer is the second argument to getgroups() and setgroups()?
11208 Usually this is the same as group ids, $gidtype, but not always.
11209
11210 EOM
11211         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11212         . ./myread
11213         groupstype="$ans"
11214         ;;
11215 *)  groupstype="$gidtype";;
11216 esac
11217
11218 : see what type lseek is declared as in the kernel
11219 rp="What is the type used for lseek's offset on this system?"
11220 set off_t lseektype long stdio.h sys/types.h
11221 eval $typedef_ask
11222
11223 echo " "
11224 $echo $n "Checking to see how big your file offsets are...$c" >&4
11225 $cat >try.c <<EOCP
11226 #include <sys/types.h>
11227 #include <stdio.h>
11228 int main()
11229 {
11230         printf("%d\n", sizeof($lseektype));
11231 }
11232 EOCP
11233 set try
11234 if eval $compile_ok; then
11235         lseeksize=`./try`
11236         $echo " $lseeksize bytes." >&4
11237 else
11238         dflt='4'
11239         echo " "
11240         echo "(I can't seem to compile the test program.  Guessing...)"
11241         rp="What is the size of your file offsets (in bytes)?"
11242         . ./myread
11243         lseeksize="$ans"
11244 fi
11245 $rm -f try.c try
11246
11247 echo " "
11248 echo "Checking if your $make program sets \$(MAKE)..." >&4
11249 case "$make_set_make" in
11250 '')
11251         $sed 's/^X //' > testmake.mak << 'EOF'
11252 Xall:
11253 X       @echo 'maketemp="$(MAKE)"'
11254 EOF
11255         case "`$make -f testmake.mak 2>/dev/null`" in
11256         *maketemp=*) make_set_make='#' ;;
11257         *)      make_set_make="MAKE=$make" ;;
11258         esac
11259         $rm -f testmake.mak
11260         ;;
11261 esac
11262 case "$make_set_make" in
11263 '#') echo "Yup, it does.";;
11264 *) echo "Nope, it doesn't.";;
11265 esac
11266
11267 : see what type is used for mode_t
11268 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11269 set mode_t modetype int stdio.h sys/types.h
11270 eval $typedef_ask
11271
11272 : define a fucntion to check prototypes
11273 $cat > protochk <<EOSH
11274 $startsh
11275 cc="$cc"
11276 optimize="$optimize"
11277 ccflags="$ccflags"
11278 prototype="$prototype"
11279 define="$define"
11280 rm=$rm
11281 EOSH
11282
11283 $cat >> protochk <<'EOSH'
11284
11285 $rm -f try.c
11286 foo="$1"
11287 shift
11288 while test $# -ge 2; do
11289         case "$1" in
11290                 $define) echo "#include <$2>" >> try.c ;;
11291                 literal) echo "$2" >> try.c ;;
11292         esac
11293     shift 2
11294 done
11295 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11296 cat >> try.c <<'EOCP'
11297 #ifdef CAN_PROTOTYPE
11298 #define _(args) args
11299 #else
11300 #define _(args) ()
11301 #endif
11302 EOCP
11303 echo "$foo" >> try.c
11304 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11305 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11306 status=$?
11307 $rm -f try.[co]
11308 exit $status
11309 EOSH
11310 chmod +x protochk
11311 $eunicefix protochk
11312
11313 : see what type is used for size_t
11314 rp="What is the type used for the length parameter for string functions?"
11315 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11316 eval $typedef_ask
11317
11318 : check for type of arguments to gethostbyaddr. 
11319 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11320         case "$d_gethbyaddr" in
11321         $define)
11322                 $cat <<EOM
11323
11324 Checking to see what type of arguments are accepted by gethostbyaddr().
11325 EOM
11326                 hdrs="$define sys/types.h
11327                         $d_socket sys/socket.h 
11328                         $i_niin netinet/in.h 
11329                         $i_netdb netdb.h
11330                         $i_unistd unistd.h"
11331                 : The first arg can 'char *' or 'void *'
11332                 : The second arg is some of integral type
11333                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11334                         for yyy in size_t long int; do
11335                                 case "$netdb_host_type" in
11336                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11337                                         if ./protochk "$try" $hdrs; then
11338                                                 echo "Your system accepts $xxx for the first arg."
11339                                                 echo "...and $yyy for the second arg."
11340                                                 netdb_host_type="$xxx"
11341                                                 netdb_hlen_type="$yyy"
11342                                         fi
11343                                         ;;
11344                                 esac
11345                         done
11346                 done
11347                 : In case none of those worked, prompt the user.
11348                 case "$netdb_host_type" in
11349                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11350                         dflt='char *'
11351                         . ./myread
11352                         netdb_host_type=$ans
11353                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11354                         dflt="$sizetype"
11355                         . ./myread
11356                         netdb_hlen_type=$ans
11357                         ;;
11358                 esac
11359                 ;;
11360         *)      : no gethostbyaddr, so pick harmless defaults
11361                 netdb_host_type='char *'
11362                 netdb_hlen_type="$sizetype"
11363                 ;;
11364         esac
11365         # Remove the "const" if needed. -- but then we'll have a 
11366         # prototype clash!
11367         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11368 fi
11369
11370 : check for type of argument to gethostbyname. 
11371 if test "X$netdb_name_type" = X ; then
11372         case "$d_gethbyname" in
11373         $define)
11374                 $cat <<EOM
11375
11376 Checking to see what type of argument is accepted by gethostbyname().
11377 EOM
11378                 hdrs="$define sys/types.h
11379                         $d_socket sys/socket.h 
11380                         $i_niin netinet/in.h 
11381                         $i_netdb netdb.h
11382                         $i_unistd unistd.h"
11383                 for xxx in "const char *" "char *"; do
11384                         case "$netdb_name_type" in
11385                         '')     try="extern struct hostent *gethostbyname($xxx);"
11386                                 if ./protochk "$try" $hdrs; then
11387                                         echo "Your system accepts $xxx."
11388                                         netdb_name_type="$xxx"
11389                                 fi
11390                                 ;;
11391                         esac
11392                 done
11393                 : In case none of those worked, prompt the user.
11394                 case "$netdb_name_type" in
11395                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11396                         dflt='char *'
11397                         . ./myread
11398                         netdb_name_type=$ans
11399                         ;;
11400                 esac
11401                 ;;
11402         *)      : no gethostbyname, so pick harmless default
11403                 netdb_name_type='char *'
11404                 ;;
11405         esac
11406 fi
11407
11408 : check for type of 1st argument to getnetbyaddr. 
11409 if test "X$netdb_net_type" = X ; then
11410         case "$d_getnbyaddr" in
11411         $define)
11412                 $cat <<EOM
11413
11414 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11415 EOM
11416                 hdrs="$define sys/types.h
11417                         $d_socket sys/socket.h 
11418                         $i_niin netinet/in.h 
11419                         $i_netdb netdb.h
11420                         $i_unistd unistd.h"
11421                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11422                         case "$netdb_net_type" in
11423                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11424                                 if ./protochk "$try" $hdrs; then
11425                                         echo "Your system accepts $xxx."
11426                                         netdb_net_type="$xxx"
11427                                 fi
11428                                 ;;
11429                         esac
11430                 done
11431                 : In case none of those worked, prompt the user.
11432                 case "$netdb_net_type" in
11433                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11434                         dflt='long'
11435                         . ./myread
11436                         netdb_net_type=$ans
11437                         ;;
11438                 esac
11439                 ;;
11440         *)      : no getnetbyaddr, so pick harmless default
11441                 netdb_net_type='long'
11442                 ;;
11443         esac
11444 fi
11445 : locate the preferred pager for this system
11446 case "$pager" in
11447 '')
11448         dflt=''
11449         case "$pg" in
11450         /*) dflt=$pg;;
11451         esac
11452         case "$more" in
11453         /*) dflt=$more;;
11454         esac
11455         case "$less" in
11456         /*) dflt=$less;;
11457         esac
11458         case "$dflt" in
11459         '') dflt=/usr/ucb/more;;
11460         esac
11461         ;;
11462 *) dflt="$pager";;
11463 esac
11464 echo " "
11465 fn=f/
11466 rp='What pager is used on your system?'
11467 . ./getfile
11468 pager="$ans"
11469
11470 : see what type pids are declared as in the kernel
11471 rp="What is the type of process ids on this system?"
11472 set pid_t pidtype int stdio.h sys/types.h
11473 eval $typedef_ask
11474
11475 : check for length of pointer
11476 echo " "
11477 case "$ptrsize" in
11478 '')
11479         $echo $n "Checking to see how big your pointers are...$c" >&4
11480         if test "$voidflags" -gt 7; then
11481                 echo '#define VOID_PTR char *' > try.c
11482         else
11483                 echo '#define VOID_PTR void *' > try.c
11484         fi
11485         $cat >>try.c <<'EOCP'
11486 #include <stdio.h>
11487 int main()
11488 {
11489         printf("%d\n", sizeof(VOID_PTR));
11490         exit(0);
11491 }
11492 EOCP
11493         set try
11494         if eval $compile_ok; then
11495                 ptrsize=`./try`
11496                 $echo " $ptrsize bytes." >&4
11497         else
11498                 dflt='4'
11499                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11500                 rp="What is the size of a pointer (in bytes)?"
11501                 . ./myread
11502                 ptrsize="$ans"
11503         fi
11504         ;;
11505 esac
11506 $rm -f try.c try
11507
11508 : see if ar generates random libraries by itself
11509 echo " "
11510 echo "Checking how to generate random libraries on your machine..." >&4
11511 echo 'int bar1() { return bar2(); }' > bar1.c
11512 echo 'int bar2() { return 2; }' > bar2.c
11513 $cat > foo.c <<'EOP'
11514 int main() { printf("%d\n", bar1()); exit(0); }
11515 EOP
11516 $cc $ccflags -c bar1.c >/dev/null 2>&1
11517 $cc $ccflags -c bar2.c >/dev/null 2>&1
11518 $cc $ccflags -c foo.c >/dev/null 2>&1
11519 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11520 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11521         ./foobar >/dev/null 2>&1; then
11522         echo "$ar appears to generate random libraries itself."
11523         orderlib=false
11524         ranlib=":"
11525 elif $ar ts bar$_a >/dev/null 2>&1 &&
11526         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11527         ./foobar >/dev/null 2>&1; then
11528                 echo "a table of contents needs to be added with '$ar ts'."
11529                 orderlib=false
11530                 ranlib="$ar ts"
11531 else
11532         case "$ranlib" in
11533         :) ranlib='';;
11534         '')
11535                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11536                 $test -f $ranlib || ranlib=''
11537                 ;;
11538         esac
11539         if $test -n "$ranlib"; then
11540                 echo "your system has '$ranlib'; we'll use that."
11541                 orderlib=false
11542         else
11543                 echo "your system doesn't seem to support random libraries"
11544                 echo "so we'll use lorder and tsort to order the libraries."
11545                 orderlib=true
11546                 ranlib=":"
11547         fi
11548 fi
11549 $rm -f foo* bar* 
11550
11551 : check for type of arguments to select. 
11552 case "$selecttype" in
11553 '') case "$d_select" in
11554         $define)
11555                 $cat <<EOM
11556 Checking to see what type of arguments are accepted by select().
11557 EOM
11558                 hdrs="$define sys/types.h
11559                         $i_systime sys/time.h 
11560                         $i_sysselct sys/select.h
11561                         $d_socket sys/socket.h"
11562                 : The first arg can be int, unsigned, or size_t
11563                 : The last arg may or may not be 'const'
11564                 val=''
11565                 : void pointer has been seen but using that
11566                 : breaks the selectminbits test
11567                 for xxx in 'fd_set *' 'int *'; do
11568                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11569                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11570                                         case "$val" in
11571                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11572                                                 if ./protochk "$try" $hdrs; then
11573                                                         echo "Your system accepts $xxx."
11574                                                         val="$xxx"
11575                                                 fi
11576                                                 ;;
11577                                         esac
11578                                 done
11579                         done
11580                 done
11581                 case "$val" in
11582                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11583                         case "$d_fd_set" in
11584                                 $define) dflt="fd_set *" ;;
11585                                 *)              dflt="int *" ;;
11586                         esac
11587                         . ./myread
11588                         val=$ans
11589                         ;;
11590                 esac
11591                 selecttype="$val"
11592                 ;;
11593         *)      : no select, so pick a harmless default
11594                 selecttype='int *'
11595                 ;;
11596         esac
11597         ;;
11598 esac
11599
11600 : check for the select 'width'
11601 case "$selectminbits" in
11602 '') case "$d_select" in
11603         $define)
11604                 $cat <<EOM
11605
11606 Checking to see on how many bits at a time your select() operates...
11607 EOM
11608                 $cat >try.c <<EOCP
11609 #include <sys/types.h>
11610 #$i_time I_TIME
11611 #$i_systime I_SYS_TIME
11612 #$i_systimek I_SYS_TIME_KERNEL
11613 #ifdef I_TIME
11614 #   include <time.h>
11615 #endif
11616 #ifdef I_SYS_TIME
11617 #   ifdef I_SYS_TIME_KERNEL
11618 #       define KERNEL
11619 #   endif
11620 #   include <sys/time.h>
11621 #   ifdef I_SYS_TIME_KERNEL
11622 #       undef KERNEL
11623 #   endif
11624 #endif
11625 #$i_sysselct I_SYS_SELECT
11626 #ifdef I_SYS_SELECT
11627 #include <sys/select.h>
11628 #endif
11629 #include <stdio.h>
11630 $selecttype b;
11631 #define S sizeof(*(b))
11632 #define MINBITS 64
11633 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11634 #define NBITS  (NBYTES * 8)
11635 int main() {
11636     char s[NBYTES];
11637     struct timeval t;
11638     int i;
11639     FILE* fp;
11640     int fd;
11641
11642     fclose(stdin);
11643     fp = fopen("try.c", "r");
11644     if (fp == 0)
11645       exit(1);
11646     fd = fileno(fp);
11647     if (fd < 0)
11648       exit(2);
11649     b = ($selecttype)s;
11650     for (i = 0; i < NBITS; i++)
11651         FD_SET(i, b);
11652     t.tv_sec  = 0;
11653     t.tv_usec = 0;
11654     select(fd + 1, b, 0, 0, &t);
11655     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11656     printf("%d\n", i + 1);
11657     return 0;
11658 }
11659 EOCP
11660                 set try
11661                 if eval $compile_ok; then
11662                         selectminbits=`./try`
11663                         case "$selectminbits" in
11664                         '')     cat >&4 <<EOM
11665 Cannot figure out on how many bits at a time your select() operates.
11666 I'll play safe and guess it is 32 bits.
11667 EOM
11668                                 selectminbits=32
11669                                 bits="32 bits"
11670                                 ;;
11671                         1)      bits="1 bit" ;;
11672                         *)      bits="$selectminbits bits" ;;
11673                         esac
11674                         echo "Your select() operates on $bits at a time." >&4
11675                 else
11676                         rp='What is the minimum number of bits your select() operates on?'
11677                         case "$byteorder" in
11678                         1234|12345678)  dflt=32 ;;
11679                         *)              dflt=1  ;;
11680                         esac
11681                         . ./myread
11682                         val=$ans
11683                         selectminbits="$val"
11684                 fi
11685                 $rm -f try.* try
11686                 ;;
11687         *)      : no select, so pick a harmless default
11688                 selectminbits='32'
11689                 ;;
11690         esac
11691         ;;
11692 esac
11693
11694 : Trace out the files included by signal.h, then look for SIGxxx names.
11695 : Remove SIGARRAYSIZE used by HPUX.
11696 : Remove SIGSTKSIZE used by Linux.
11697 : Remove SIGSTKSZ used by Posix.
11698 : Remove SIGTYP void lines used by OS2.
11699 xxx=`echo '#include <signal.h>' |
11700         $cppstdin $cppminus $cppflags 2>/dev/null |
11701         $grep '^[       ]*#.*include' | 
11702         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11703 : Check this list of files to be sure we have parsed the cpp output ok.
11704 : This will also avoid potentially non-existent files, such 
11705 : as ../foo/bar.h
11706 xxxfiles=''
11707 for xx in $xxx /dev/null ; do
11708         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11709 done
11710 : If we have found no files, at least try signal.h
11711 case "$xxxfiles" in
11712 '')     xxxfiles=`./findhdr signal.h` ;;
11713 esac
11714 xxx=`awk '
11715 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11716         print substr($2, 4, 20)
11717 }
11718 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11719         print substr($3, 4, 20)
11720 }' $xxxfiles`
11721 : Append some common names just in case the awk scan failed.
11722 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11723 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11724 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11725 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11726 : generate a few handy files for later
11727 $cat > signal.c <<'EOCP'
11728 #include <sys/types.h>
11729 #include <signal.h>
11730 #include <stdio.h>
11731 int main() {
11732
11733 /* Strange style to avoid deeply-nested #if/#else/#endif */
11734 #ifndef NSIG
11735 #  ifdef _NSIG
11736 #    define NSIG (_NSIG)
11737 #  endif
11738 #endif
11739
11740 #ifndef NSIG
11741 #  ifdef SIGMAX
11742 #    define NSIG (SIGMAX+1)
11743 #  endif
11744 #endif
11745
11746 #ifndef NSIG
11747 #  ifdef SIG_MAX
11748 #    define NSIG (SIG_MAX+1)
11749 #  endif
11750 #endif
11751
11752 #ifndef NSIG
11753 #  ifdef MAXSIG
11754 #    define NSIG (MAXSIG+1)
11755 #  endif
11756 #endif
11757
11758 #ifndef NSIG
11759 #  ifdef MAX_SIG
11760 #    define NSIG (MAX_SIG+1)
11761 #  endif
11762 #endif
11763
11764 #ifndef NSIG
11765 #  ifdef SIGARRAYSIZE
11766 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11767 #  endif
11768 #endif
11769
11770 #ifndef NSIG
11771 #  ifdef _sys_nsig
11772 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11773 #  endif
11774 #endif
11775
11776 /* Default to some arbitrary number that's big enough to get most
11777    of the common signals.
11778 */
11779 #ifndef NSIG
11780 #    define NSIG 50
11781 #endif
11782
11783 printf("NSIG %d\n", NSIG);
11784
11785 #ifndef JUST_NSIG
11786
11787 EOCP
11788
11789 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11790 {
11791         printf "#ifdef SIG"; printf $1; printf "\n"
11792         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11793         printf $1; printf ");\n"
11794         printf "#endif\n"
11795 }
11796 END {
11797         printf "#endif /* JUST_NSIG */\n";
11798         printf "}\n";
11799 }
11800 ' >>signal.c
11801 $cat >signal.awk <<'EOP'
11802 BEGIN { ndups = 0 }
11803 $1 ~ /^NSIG$/ { nsig = $2 }
11804 ($1 !~ /^NSIG$/) && (NF == 2) {
11805     if ($2 > maxsig) { maxsig = $2 }
11806     if (sig_name[$2]) {
11807         dup_name[ndups] = $1
11808         dup_num[ndups] = $2
11809         ndups++ 
11810     }
11811     else {
11812         sig_name[$2] = $1
11813         sig_num[$2] = $2
11814     }
11815 }
11816 END { 
11817     if (nsig == 0) {
11818         nsig = maxsig + 1
11819     }
11820     printf("NSIG %d\n", nsig);
11821     for (n = 1; n < nsig; n++) {
11822         if (sig_name[n]) {
11823             printf("%s %d\n", sig_name[n], sig_num[n])
11824         }
11825         else {
11826             printf("NUM%d %d\n", n, n) 
11827         }
11828     }
11829     for (n = 0; n < ndups; n++) {
11830         printf("%s %d\n", dup_name[n], dup_num[n])
11831     }
11832 }
11833 EOP
11834 $cat >signal_cmd <<EOS
11835 $startsh
11836 if $test -s signal.lst; then
11837     echo "Using your existing signal.lst file"
11838         exit 0
11839 fi
11840 xxx="$xxx"
11841 EOS
11842 $cat >>signal_cmd <<'EOS'
11843
11844 set signal
11845 if eval $compile_ok; then
11846         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11847 else
11848         echo "(I can't seem be able to compile the whole test program)" >&4
11849         echo "(I'll try it in little pieces.)" >&4
11850         set signal -DJUST_NSIG
11851         if eval $compile_ok; then
11852                 ./signal$_exe > signal.nsg
11853                 $cat signal.nsg
11854         else
11855                 echo "I can't seem to figure out how many signals you have." >&4
11856                 echo "Guessing 50." >&4
11857                 echo 'NSIG 50' > signal.nsg
11858         fi
11859         : Now look at all the signal names, one at a time.
11860         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11861                 $cat > signal.c <<EOCP
11862 #include <sys/types.h>
11863 #include <signal.h>
11864 #include <stdio.h>
11865 int main() {
11866 printf("$xx %d\n", SIG${xx});
11867 return 0;
11868 }
11869 EOCP
11870                 set signal
11871                 if eval $compile; then
11872                         echo "SIG${xx} found."
11873                         ./signal$_exe  >> signal.ls1
11874                 else
11875                         echo "SIG${xx} NOT found."
11876                 fi
11877         done
11878         if $test -s signal.ls1; then
11879                 $cat signal.nsg signal.ls1 |
11880                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11881         fi
11882
11883 fi
11884 if $test -s signal.lst; then
11885         :
11886 else
11887         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11888         echo 'kill -l' >signal
11889         set X `csh -f <signal`
11890         $rm -f signal
11891         shift
11892         case $# in
11893         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11894         esac
11895         echo $@ | $tr ' ' $trnl | \
11896             $awk '{ printf "%s %d\n", $1, ++s; }
11897                   END { printf "NSIG %d\n", ++s }' >signal.lst
11898 fi
11899 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11900 EOS
11901 chmod a+x signal_cmd
11902 $eunicefix signal_cmd
11903
11904 : generate list of signal names
11905 echo " "
11906 case "$sig_name_init" in
11907 '') doinit=yes ;;
11908 *)  case "$sig_num_init" in
11909     ''|*,*) doinit=yes ;;
11910     esac ;;
11911 esac
11912 case "$doinit" in
11913 yes)
11914         echo "Generating a list of signal names and numbers..." >&4
11915         . ./signal_cmd
11916         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11917         sig_name=`$awk 'BEGIN { printf "ZERO " }
11918                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11919         sig_num=`$awk  'BEGIN { printf "0 " }
11920                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11921         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11922                              !/^NSIG/   { printf "\"%s\", ", $1 }
11923                              END        { printf "0\n" }' signal.lst`
11924         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11925                              !/^NSIG/   { printf "%d, ", $2}
11926                              END        { printf "0\n"}' signal.lst`
11927         ;;
11928 esac
11929 echo "The following $sig_count signals are available:"
11930 echo " "
11931 echo $sig_name | $awk \
11932 'BEGIN { linelen = 0 }
11933 {
11934         for (i = 1; i <= NF; i++) {
11935                 name = "SIG" $i " "
11936                 linelen = linelen + length(name)
11937                 if (linelen > 70) {
11938                         printf "\n"
11939                         linelen = length(name)
11940                 }
11941                 printf "%s", name
11942         }
11943         printf "\n"
11944 }'
11945 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11946
11947 : see what type is used for signed size_t
11948 set ssize_t ssizetype int stdio.h sys/types.h
11949 eval $typedef
11950 dflt="$ssizetype"
11951 $cat > ssize.c <<EOM
11952 #include <stdio.h>
11953 #include <sys/types.h>
11954 #define Size_t $sizetype
11955 #define SSize_t $dflt
11956 int main()
11957 {
11958         if (sizeof(Size_t) == sizeof(SSize_t))
11959                 printf("$dflt\n");
11960         else if (sizeof(Size_t) == sizeof(int))
11961                 printf("int\n");
11962         else 
11963                 printf("long\n");
11964         exit(0);
11965 }
11966 EOM
11967 echo " "
11968 set ssize
11969 if eval $compile_ok && ./ssize > /dev/null; then
11970         ssizetype=`./ssize`
11971         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11972 else
11973         $cat >&4 <<EOM
11974 Help! I can't compile and run the ssize_t test program: please enlighten me!
11975 (This is probably a misconfiguration in your system or libraries, and
11976 you really ought to fix it.  Still, I'll try anyway.)
11977
11978 I need a type that is the same size as $sizetype, but is guaranteed to
11979 be signed.  Common values are ssize_t, int and long.
11980
11981 EOM
11982         rp="What signed type is the same size as $sizetype?"
11983         . ./myread
11984         ssizetype="$ans"
11985 fi
11986 $rm -f ssize ssize.*
11987
11988 : see what type of char stdio uses.
11989 echo " "
11990 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11991         echo "Your stdio uses unsigned chars." >&4
11992         stdchar="unsigned char"
11993 else
11994         echo "Your stdio uses signed chars." >&4
11995         stdchar="char"
11996 fi
11997
11998 : see if time exists
11999 echo " "
12000 if test "X$d_time" = X -o X"$timetype" = X; then
12001     if set time val -f d_time; eval $csym; $val; then
12002                 echo 'time() found.' >&4
12003                 val="$define"
12004                 rp="What is the type returned by time() on this system?"
12005                 set time_t timetype long stdio.h sys/types.h
12006                 eval $typedef_ask
12007     else
12008                 echo 'time() not found, hope that will do.' >&4
12009                 val="$undef"
12010                 timetype='int';
12011     fi
12012     set d_time
12013     eval $setvar
12014 fi
12015
12016 : see what type uids are declared as in the kernel
12017 echo " "
12018 echo "Looking for the type for user ids returned by getuid()."
12019 set uid_t uidtype xxx stdio.h sys/types.h
12020 eval $typedef
12021 case "$uidtype" in
12022 xxx)
12023         xxx=`./findhdr sys/user.h`
12024         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
12025         case $1 in
12026         unsigned) dflt="$1 $2" ;;
12027         *) dflt="$1" ;;
12028         esac
12029         ;;
12030 *) dflt="$uidtype";;
12031 esac
12032 case "$uidtype" in
12033 uid_t)  echo "uid_t found." ;;
12034 *)      rp="What is the type for user ids returned by getuid()?"
12035         . ./myread
12036         uidtype="$ans"
12037         ;;
12038 esac
12039
12040 : see if dbm.h is available
12041 : see if dbmclose exists
12042 set dbmclose d_dbmclose
12043 eval $inlibc
12044
12045 case "$d_dbmclose" in
12046 $define)
12047         set dbm.h i_dbm
12048         eval $inhdr
12049         case "$i_dbm" in
12050         $define)
12051                 val="$undef"
12052                 set i_rpcsvcdbm
12053                 eval $setvar
12054                 ;;
12055         *)      set rpcsvc/dbm.h i_rpcsvcdbm
12056                 eval $inhdr
12057                 ;;
12058         esac
12059         ;;
12060 *)      echo "We won't be including <dbm.h>"
12061         val="$undef"
12062         set i_dbm
12063         eval $setvar
12064         val="$undef"
12065         set i_rpcsvcdbm
12066         eval $setvar
12067         ;;
12068 esac
12069
12070 : see if this is a sys/file.h system
12071 val=''
12072 set sys/file.h val
12073 eval $inhdr
12074
12075 : do we need to include sys/file.h ?
12076 case "$val" in
12077 "$define")
12078         echo " "
12079         if $h_sysfile; then
12080                 val="$define"
12081                 echo "We'll be including <sys/file.h>." >&4
12082         else
12083                 val="$undef"
12084                 echo "We won't be including <sys/file.h>." >&4
12085         fi
12086         ;;
12087 *)
12088         h_sysfile=false
12089         ;;
12090 esac
12091 set i_sysfile
12092 eval $setvar
12093
12094 : see if fcntl.h is there
12095 val=''
12096 set fcntl.h val
12097 eval $inhdr
12098
12099 : see if we can include fcntl.h
12100 case "$val" in
12101 "$define")
12102         echo " "
12103         if $h_fcntl; then
12104                 val="$define"
12105                 echo "We'll be including <fcntl.h>." >&4
12106         else
12107                 val="$undef"
12108                 if $h_sysfile; then
12109         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
12110                 else
12111                         echo "We won't be including <fcntl.h>." >&4
12112                 fi
12113         fi
12114         ;;
12115 *)
12116         h_fcntl=false
12117         val="$undef"
12118         ;;
12119 esac
12120 set i_fcntl
12121 eval $setvar
12122
12123 : see if locale.h is available
12124 set locale.h i_locale
12125 eval $inhdr
12126
12127 : see if mach cthreads are available
12128 if test "X$usethreads" = "X$define"; then
12129         set mach/cthreads.h i_machcthr
12130         eval $inhdr
12131 else
12132         i_machcthr="$undef"
12133 fi
12134
12135
12136
12137 : see if this is a math.h system
12138 set math.h i_math
12139 eval $inhdr
12140
12141 : see if this is a mntent.h system
12142 set mntent.h i_mntent
12143 eval $inhdr
12144
12145 : see if ndbm.h is available
12146 set ndbm.h t_ndbm
12147 eval $inhdr
12148 case "$t_ndbm" in
12149 $define)
12150         : see if dbm_open exists
12151         set dbm_open d_dbm_open
12152         eval $inlibc
12153         case "$d_dbm_open" in
12154         $undef)
12155                 t_ndbm="$undef"
12156                 echo "We won't be including <ndbm.h>"
12157                 ;;
12158         esac
12159         ;;
12160 esac
12161 val="$t_ndbm"
12162 set i_ndbm
12163 eval $setvar
12164
12165 : see if net/errno.h is available
12166 val=''
12167 set net/errno.h val
12168 eval $inhdr
12169
12170 : Unfortunately, it causes problems on some systems.  Arrgh.
12171 case "$val" in
12172 $define)
12173         cat > try.c <<'EOM'
12174 #include <stdio.h>
12175 #include <errno.h>
12176 #include <net/errno.h>
12177 int func()
12178 {
12179         return ENOTSOCK;
12180 }
12181 EOM
12182         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12183                 echo "We'll be including <net/errno.h>." >&4
12184         else
12185                 echo "We won't be including <net/errno.h>." >&4
12186                 val="$undef"
12187         fi
12188         $rm -f try.* try
12189         ;;
12190 esac
12191 set i_neterrno
12192 eval $setvar
12193
12194 : see if netinet/tcp.h is available
12195 set netinet/tcp.h i_netinettcp
12196 eval $inhdr
12197
12198 : see if this is a poll.h system
12199 set poll.h i_poll
12200 eval $inhdr
12201
12202 : get C preprocessor symbols handy
12203 echo " "
12204 $echo $n "Hmm... $c"
12205 echo $al | $tr ' ' $trnl >Cppsym.know
12206 $cat <<EOSS >Cppsym
12207 $startsh
12208 case "\$1" in
12209 -l) list=true
12210         shift
12211         ;;
12212 esac
12213 unknown=''
12214 case "\$list\$#" in
12215 1|2)
12216         for sym do
12217                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12218                         exit 0
12219                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12220                         :
12221                 else
12222                         unknown="\$unknown \$sym"
12223                 fi
12224         done
12225         set X \$unknown
12226         shift
12227         ;;
12228 esac
12229 case \$# in
12230 0) exit 1;;
12231 esac
12232 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12233 #ifdef \1\\
12234 exit 0; _ _ _ _\1\\      \1\\
12235 #endif\\
12236 /' >Cppsym\$\$
12237 echo "exit 1; _ _ _" >>Cppsym\$\$
12238 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12239 case "\$list" in
12240 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12241 *)
12242         sh Cppsym2\$\$
12243         status=\$?
12244         ;;
12245 esac
12246 $rm -f Cppsym\$\$ Cppsym2\$\$
12247 exit \$status
12248 EOSS
12249 chmod +x Cppsym
12250 $eunicefix Cppsym
12251 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12252
12253 : now check the C compiler for additional symbols
12254 postprocess_cc_v=''
12255 case "$osname" in
12256 aix) postprocess_cc_v="|$tr , ' '" ;;
12257 esac
12258 $cat >ccsym <<EOS
12259 $startsh
12260 $cat >tmp.c <<EOF
12261 extern int foo;
12262 EOF
12263 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12264 do
12265         case "\$i" in
12266         -D*) echo "\$i" | $sed 's/^-D//';;
12267         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12268         esac
12269 done
12270 $rm -f try.c
12271 EOS
12272 postprocess_cc_v=''
12273 chmod +x ccsym
12274 $eunicefix ccsym
12275 ./ccsym > ccsym1.raw
12276 if $test -s ccsym1.raw; then
12277        $sort ccsym1.raw | $uniq >ccsym.raw
12278 else
12279        mv ccsym1.raw ccsym.raw
12280 fi
12281
12282 $awk '/\=/ { print $0; next }
12283         { print $0"=1" }' ccsym.raw >ccsym.list
12284 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12285 $comm -13 ccsym.true ccsym.list >ccsym.own
12286 $comm -12 ccsym.true ccsym.list >ccsym.com
12287 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12288 also=''
12289 if $test -z ccsym.raw; then
12290         echo "Your C compiler doesn't seem to define any symbols!" >&4
12291         echo " "
12292         echo "However, your C preprocessor defines the following symbols:"
12293         $cat Cppsym.true
12294         ccsymbols=''
12295         cppsymbols=`$cat Cppsym.true`
12296         cppsymbols=`echo $cppsymbols`
12297         cppccsymbols="$cppsymbols"
12298 else
12299         if $test -s ccsym.com; then
12300                 echo "Your C compiler and pre-processor define these symbols:"
12301                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12302                 also='also '
12303                 symbols='ones'
12304                 cppccsymbols=`$cat ccsym.com`
12305                 cppccsymbols=`echo $cppccsymbols`
12306                 $test "$silent" || sleep 1
12307         fi
12308         if $test -s ccsym.cpp; then
12309                 $test "$also" && echo " "
12310                 echo "Your C pre-processor ${also}defines the following symbols:"
12311                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12312                 also='further '
12313                 cppsymbols=`$cat ccsym.cpp`
12314                 cppsymbols=`echo $cppsymbols`
12315                 $test "$silent" || sleep 1
12316         fi
12317         if $test -s ccsym.own; then
12318                 $test "$also" && echo " "
12319                 echo "Your C compiler ${also}defines the following cpp symbols:"
12320                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12321                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12322                 ccsymbols=`$cat ccsym.own`
12323                 ccsymbols=`echo $ccsymbols`
12324                 $test "$silent" || sleep 1
12325         fi
12326 fi
12327 $rm -f ccsym*
12328
12329 : see if this is a termio system
12330 val="$undef"
12331 val2="$undef"
12332 val3="$undef"
12333 if $test `./findhdr termios.h`; then
12334         set tcsetattr i_termios
12335         eval $inlibc
12336         val3="$i_termios"
12337 fi
12338 echo " "
12339 case "$val3" in
12340 "$define") echo "You have POSIX termios.h... good!" >&4;;
12341 *) if ./Cppsym pyr; then
12342                 case "`/bin/universe`" in
12343                 ucb) if $test `./findhdr sgtty.h`; then
12344                                 val2="$define"
12345                                 echo "<sgtty.h> found." >&4
12346                         else
12347                                 echo "System is pyramid with BSD universe."
12348                                 echo "<sgtty.h> not found--you could have problems." >&4
12349                         fi;;
12350                 *) if $test `./findhdr termio.h`; then
12351                                 val="$define"
12352                                 echo "<termio.h> found." >&4
12353                         else
12354                                 echo "System is pyramid with USG universe."
12355                                 echo "<termio.h> not found--you could have problems." >&4
12356                         fi;;
12357                 esac
12358         elif ./usg; then
12359                 if $test `./findhdr termio.h`; then
12360                         echo "<termio.h> found." >&4
12361                         val="$define"
12362                 elif $test `./findhdr sgtty.h`; then
12363                         echo "<sgtty.h> found." >&4
12364                         val2="$define"
12365                 else
12366 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12367                 fi
12368         else
12369                 if $test `./findhdr sgtty.h`; then
12370                         echo "<sgtty.h> found." >&4
12371                         val2="$define"
12372                 elif $test `./findhdr termio.h`; then
12373                         echo "<termio.h> found." >&4
12374                         val="$define"
12375                 else
12376 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12377                 fi
12378         fi;;
12379 esac
12380 set i_termio; eval $setvar
12381 val=$val2; set i_sgtty; eval $setvar
12382 val=$val3; set i_termios; eval $setvar
12383
12384 : see if stdarg is available
12385 echo " "
12386 if $test `./findhdr stdarg.h`; then
12387         echo "<stdarg.h> found." >&4
12388         valstd="$define"
12389 else
12390         echo "<stdarg.h> NOT found." >&4
12391         valstd="$undef"
12392 fi
12393
12394 : see if varags is available
12395 echo " "
12396 if $test `./findhdr varargs.h`; then
12397         echo "<varargs.h> found." >&4
12398 else
12399         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12400 fi
12401
12402 : set up the varargs testing programs
12403 $cat > varargs.c <<EOP
12404 #ifdef I_STDARG
12405 #include <stdarg.h>
12406 #endif
12407 #ifdef I_VARARGS
12408 #include <varargs.h>
12409 #endif
12410
12411 #ifdef I_STDARG
12412 int f(char *p, ...)
12413 #else
12414 int f(va_alist)
12415 va_dcl
12416 #endif
12417 {
12418         va_list ap;
12419 #ifndef I_STDARG
12420         char *p;
12421 #endif
12422 #ifdef I_STDARG
12423         va_start(ap,p);
12424 #else
12425         va_start(ap);
12426         p = va_arg(ap, char *);
12427 #endif
12428         va_end(ap);
12429 }
12430 EOP
12431 $cat > varargs <<EOP
12432 $startsh
12433 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12434         echo "true"
12435 else
12436         echo "false"
12437 fi
12438 $rm -f varargs$_o
12439 EOP
12440 chmod +x varargs
12441
12442 : now check which varargs header should be included
12443 echo " "
12444 i_varhdr=''
12445 case "$valstd" in
12446 "$define")
12447         if `./varargs I_STDARG`; then
12448                 val='stdarg.h'
12449         elif `./varargs I_VARARGS`; then
12450                 val='varargs.h'
12451         fi
12452         ;;
12453 *)
12454         if `./varargs I_VARARGS`; then
12455                 val='varargs.h'
12456         fi
12457         ;;
12458 esac
12459 case "$val" in
12460 '')
12461 echo "I could not find the definition for va_dcl... You have problems..." >&4
12462         val="$undef"; set i_stdarg; eval $setvar
12463         val="$undef"; set i_varargs; eval $setvar
12464         ;;
12465 *) 
12466         set i_varhdr
12467         eval $setvar
12468         case "$i_varhdr" in
12469         stdarg.h)
12470                 val="$define"; set i_stdarg; eval $setvar
12471                 val="$undef"; set i_varargs; eval $setvar
12472                 ;;
12473         varargs.h)
12474                 val="$undef"; set i_stdarg; eval $setvar
12475                 val="$define"; set i_varargs; eval $setvar
12476                 ;;
12477         esac
12478         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12479 esac
12480 $rm -f varargs*
12481
12482 : see if stddef is available
12483 set stddef.h i_stddef
12484 eval $inhdr
12485
12486 : see if sys/access.h is available
12487 set sys/access.h i_sysaccess
12488 eval $inhdr
12489
12490 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12491 set sys/filio.h i_sysfilio
12492 eval $inhdr
12493 echo " "
12494 if $test `./findhdr sys/ioctl.h`; then
12495         val="$define"
12496         echo '<sys/ioctl.h> found.' >&4
12497 else
12498         val="$undef"
12499         if $test $i_sysfilio = "$define"; then
12500             echo '<sys/ioctl.h> NOT found.' >&4
12501         else
12502                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12503                 $test $i_termio = "$define" && xxx="termio.h"
12504                 $test $i_termios = "$define" && xxx="termios.h"
12505 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12506         fi
12507 fi
12508 set i_sysioctl
12509 eval $setvar
12510
12511 : see if sys/resource.h has to be included
12512 set sys/resource.h i_sysresrc
12513 eval $inhdr
12514
12515 : see if sys/security.h is available
12516 set sys/security.h i_syssecrt
12517 eval $inhdr
12518
12519 : see if this is a sys/statvfs.h system
12520 set sys/statvfs.h i_sysstatvfs
12521 eval $inhdr
12522
12523 : see if this is a sys/un.h system
12524 set sys/un.h i_sysun
12525 eval $inhdr
12526
12527 : see if this is a syswait system
12528 set sys/wait.h i_syswait
12529 eval $inhdr
12530
12531 : see if this is an utime system
12532 set utime.h i_utime
12533 eval $inhdr
12534
12535 : see if this is a values.h system
12536 set values.h i_values
12537 eval $inhdr
12538
12539 : see if this is a vfork system
12540 case "$d_vfork" in
12541 "$define")
12542         set vfork.h i_vfork
12543         eval $inhdr
12544         ;;
12545 *)
12546         i_vfork="$undef"
12547         ;;
12548 esac
12549
12550 : see if gdbm.h is available
12551 set gdbm.h t_gdbm
12552 eval $inhdr
12553 case "$t_gdbm" in
12554 $define)
12555         : see if gdbm_open exists
12556         set gdbm_open d_gdbm_open
12557         eval $inlibc
12558         case "$d_gdbm_open" in
12559         $undef)
12560                 t_gdbm="$undef"
12561                 echo "We won't be including <gdbm.h>"
12562                 ;;
12563         esac
12564         ;;
12565 esac
12566 val="$t_gdbm"
12567 set i_gdbm
12568 eval $setvar
12569
12570 echo " "
12571 echo "Looking for extensions..." >&4
12572 tdir=`pwd`
12573 cd $rsrc/ext
12574 : If we are using the old config.sh, known_extensions may contain
12575 : old or inaccurate or duplicate values.
12576 known_extensions=''
12577 nonxs_extensions=''
12578 : We do not use find because it might not be available.
12579 : We do not just use MANIFEST because the user may have dropped
12580 : some additional extensions into the source tree and expect them
12581 : to be built.
12582 for xxx in * ; do
12583         case "$xxx" in
12584         DynaLoader|dynaload) ;;
12585         *)      if $test -f $xxx/$xxx.xs; then
12586                         known_extensions="$known_extensions $xxx"
12587                 elif $test -f $xxx/Makefile.PL; then
12588                         nonxs_extensions="$nonxs_extensions $xxx"
12589                 else
12590                         if $test -d $xxx; then
12591                                 # Look for nested extensions, eg. Devel/Dprof.
12592                                 cd $xxx
12593                                 for yyy in * ; do
12594                                 if $test -f $yyy/$yyy.xs; then
12595                                         known_extensions="$known_extensions $xxx/$yyy"
12596                                 elif $test -f $yyy/Makefile.PL; then
12597                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12598                                 fi
12599                                 done
12600                                 cd ..
12601                         fi
12602                 fi 
12603                 ;;
12604         esac
12605 done
12606 set X $nonxs_extensions
12607 shift
12608 nonxs_extensions="$*"
12609 set X $known_extensions
12610 shift
12611 known_extensions="$*"
12612 cd $tdir
12613
12614 : Now see which are supported on this system.
12615 avail_ext=''
12616 for xxx in $known_extensions ; do
12617         case "$xxx" in
12618         DB_File|db_file)
12619                 case "$i_db" in
12620                 $define) avail_ext="$avail_ext $xxx" ;;
12621                 esac
12622                 ;;
12623         GDBM_File|gdbm_fil)
12624                 case "$i_gdbm" in 
12625                 $define) avail_ext="$avail_ext $xxx" ;;
12626                 esac
12627                 ;;
12628         NDBM_File|ndbm_fil)
12629                 case "$i_ndbm" in
12630                 $define) avail_ext="$avail_ext $xxx" ;;
12631                 esac
12632                 ;;
12633         ODBM_File|odbm_fil) 
12634                 case "${i_dbm}${i_rpcsvcdbm}" in
12635                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12636                 esac
12637                 ;;
12638         POSIX|posix)
12639                 case "$useposix" in
12640                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12641                 esac
12642                 ;;
12643         Opcode|opcode)
12644                 case "$useopcode" in
12645                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12646                 esac
12647                 ;;
12648         Socket|socket)
12649                 case "$d_socket" in 
12650                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12651                 esac
12652                 ;;
12653         Thread|thread)
12654                 case "$usethreads" in 
12655                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12656                 esac
12657                 ;;
12658         IPC/SysV|ipc/sysv)
12659                 : XXX Do we need a useipcsysv variable here
12660                 case "${d_msg}${d_sem}${d_shm}" in 
12661                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12662                 esac
12663                 ;;
12664         *)      avail_ext="$avail_ext $xxx"
12665                 ;;
12666         esac
12667 done
12668
12669 set X $avail_ext
12670 shift
12671 avail_ext="$*"
12672
12673 : Now see which nonxs extensions are supported on this system.
12674 : For now assume all are.
12675 nonxs_ext=''
12676 for xxx in $nonxs_extensions ; do
12677         case "$xxx" in
12678         *)      nonxs_ext="$nonxs_ext $xxx"
12679                 ;;
12680         esac
12681 done
12682
12683 set X $nonxs_ext
12684 shift
12685 nonxs_ext="$*"
12686
12687 case $usedl in
12688 $define)
12689         $cat <<EOM
12690 A number of extensions are supplied with $package.  You may choose to
12691 compile these extensions for dynamic loading (the default), compile
12692 them into the $package executable (static loading), or not include
12693 them at all.  Answer "none" to include no extensions.
12694 Note that DynaLoader is always built and need not be mentioned here.
12695
12696 EOM
12697         case "$dynamic_ext" in
12698         '') dflt="$avail_ext" ;;
12699         *)      dflt="$dynamic_ext"
12700                 # Perhaps we are reusing an old out-of-date config.sh.
12701                 case "$hint" in
12702                 previous)
12703                         if test X"$dynamic_ext" != X"$avail_ext"; then
12704                                 $cat <<EOM
12705 NOTICE:  Your previous config.sh list may be incorrect. 
12706 The extensions now available to you are 
12707         ${avail_ext}
12708 but the default list from your previous config.sh is
12709         ${dynamic_ext} 
12710
12711 EOM
12712                         fi
12713                         ;;
12714                 esac
12715                 ;;
12716         esac
12717         case "$dflt" in
12718         '')     dflt=none;;
12719         esac
12720         rp="What extensions do you wish to load dynamically?"
12721         . ./myread
12722         case "$ans" in
12723         none) dynamic_ext=' ' ;;
12724         *) dynamic_ext="$ans" ;;
12725         esac
12726
12727         case "$static_ext" in
12728         '')
12729                 : Exclude those already listed in dynamic linking
12730                 dflt=''
12731                 for xxx in $avail_ext; do
12732                         case " $dynamic_ext " in
12733                         *" $xxx "*) ;;
12734                         *) dflt="$dflt $xxx" ;;
12735                         esac
12736                 done
12737                 set X $dflt
12738                 shift
12739                 dflt="$*"
12740                 ;;
12741         *)  dflt="$static_ext" 
12742                 ;;
12743         esac
12744
12745         case "$dflt" in
12746         '')     dflt=none;;
12747         esac
12748         rp="What extensions do you wish to load statically?"
12749         . ./myread
12750         case "$ans" in
12751         none) static_ext=' ' ;;
12752         *) static_ext="$ans" ;;
12753         esac
12754         ;;
12755 *)
12756         $cat <<EOM
12757 A number of extensions are supplied with $package.  Answer "none" 
12758 to include no extensions. 
12759 Note that DynaLoader is always built and need not be mentioned here.
12760
12761 EOM
12762         case "$static_ext" in
12763         '') dflt="$avail_ext" ;;
12764         *)      dflt="$static_ext"
12765                 # Perhaps we are reusing an old out-of-date config.sh.
12766                 case "$hint" in
12767                 previous)
12768                         if test X"$static_ext" != X"$avail_ext"; then
12769                                 $cat <<EOM
12770 NOTICE:  Your previous config.sh list may be incorrect. 
12771 The extensions now available to you are 
12772         ${avail_ext}
12773 but the default list from your previous config.sh is
12774         ${static_ext} 
12775
12776 EOM
12777                         fi
12778                         ;;
12779                 esac
12780                 ;;
12781         esac
12782         : Exclude those that are not xs extensions
12783         case "$dflt" in
12784         '')     dflt=none;;
12785         esac
12786         rp="What extensions do you wish to include?"
12787         . ./myread
12788         case "$ans" in
12789         none) static_ext=' ' ;;
12790         *) static_ext="$ans" ;;
12791         esac
12792         ;;
12793 esac
12794
12795 set X $dynamic_ext $static_ext $nonxs_ext
12796 shift
12797 extensions="$*"
12798
12799 : Remove build directory name from cppstdin so it can be used from
12800 : either the present location or the final installed location.
12801 echo " "
12802 : Get out of the UU directory to get correct path name.
12803 cd ..
12804 case "$cppstdin" in
12805 `pwd`/cppstdin)
12806         echo "Stripping down cppstdin path name"
12807         cppstdin=cppstdin
12808         ;;
12809 esac
12810 cd UU
12811
12812 : end of configuration questions
12813 echo " "
12814 echo "End of configuration questions."
12815 echo " "
12816
12817 : back to where it started
12818 if test -d ../UU; then
12819         cd ..
12820 fi
12821
12822 : configuration may be patched via a 'config.over' file
12823 if $test -f config.over; then
12824         echo " "
12825         dflt=y
12826         rp='I see a config.over file.  Do you wish to load it?'
12827         . UU/myread
12828         case "$ans" in
12829         n*) echo "OK, I'll ignore it.";;
12830         *)      . ./config.over
12831                 echo "Configuration override changes have been loaded."
12832                 ;;
12833         esac
12834 fi
12835
12836 : in case they want portability, strip down executable paths
12837 case "$d_portable" in
12838 "$define")
12839         echo " "
12840         echo "Stripping down executable paths..." >&4
12841         for file in $loclist $trylist; do
12842                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12843                         eval $file="\$file"
12844                 fi
12845         done
12846         ;;
12847 esac
12848
12849 : create config.sh file
12850 echo " "
12851 echo "Creating config.sh..." >&4
12852 $spitshell <<EOT >config.sh
12853 $startsh
12854 #
12855 # This file was produced by running the Configure script. It holds all the
12856 # definitions figured out by Configure. Should you modify one of these values,
12857 # do not forget to propagate your changes by running "Configure -der". You may
12858 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12859 #
12860
12861 # Package name      : $package
12862 # Source directory  : $src
12863 # Configuration time: $cf_time
12864 # Configured by     : $cf_by
12865 # Target system     : $myuname
12866
12867 Author='$Author'
12868 Date='$Date'
12869 Header='$Header'
12870 Id='$Id'
12871 Locker='$Locker'
12872 Log='$Log'
12873 Mcc='$Mcc'
12874 RCSfile='$RCSfile'
12875 Revision='$Revision'
12876 Source='$Source'
12877 State='$State'
12878 _a='$_a'
12879 _exe='$_exe'
12880 _o='$_o'
12881 afs='$afs'
12882 alignbytes='$alignbytes'
12883 ansi2knr='$ansi2knr'
12884 aphostname='$aphostname'
12885 apiversion='$apiversion'
12886 ar='$ar'
12887 archlib='$archlib'
12888 archlibexp='$archlibexp'
12889 archname64='$archname64'
12890 archname='$archname'
12891 archobjs='$archobjs'
12892 awk='$awk'
12893 baserev='$baserev'
12894 bash='$bash'
12895 bin='$bin'
12896 binexp='$binexp'
12897 bison='$bison'
12898 byacc='$byacc'
12899 byteorder='$byteorder'
12900 c='$c'
12901 castflags='$castflags'
12902 cat='$cat'
12903 cc='$cc'
12904 cccdlflags='$cccdlflags'
12905 ccdlflags='$ccdlflags'
12906 ccflags='$ccflags'
12907 ccsymbols='$ccsymbols'
12908 cf_by='$cf_by'
12909 cf_email='$cf_email'
12910 cf_time='$cf_time'
12911 chgrp='$chgrp'
12912 chmod='$chmod'
12913 chown='$chown'
12914 clocktype='$clocktype'
12915 comm='$comm'
12916 compress='$compress'
12917 contains='$contains'
12918 cp='$cp'
12919 cpio='$cpio'
12920 cpp='$cpp'
12921 cpp_stuff='$cpp_stuff'
12922 cppccsymbols='$cppccsymbols'
12923 cppflags='$cppflags'
12924 cpplast='$cpplast'
12925 cppminus='$cppminus'
12926 cpprun='$cpprun'
12927 cppstdin='$cppstdin'
12928 cppsymbols='$cppsymbols'
12929 crosscompile='$crosscompile'
12930 cryptlib='$cryptlib'
12931 csh='$csh'
12932 d_Gconvert='$d_Gconvert'
12933 d_access='$d_access'
12934 d_accessx='$d_accessx'
12935 d_alarm='$d_alarm'
12936 d_archlib='$d_archlib'
12937 d_attribut='$d_attribut'
12938 d_bcmp='$d_bcmp'
12939 d_bcopy='$d_bcopy'
12940 d_bsd='$d_bsd'
12941 d_bsdgetpgrp='$d_bsdgetpgrp'
12942 d_bsdsetpgrp='$d_bsdsetpgrp'
12943 d_bzero='$d_bzero'
12944 d_casti32='$d_casti32'
12945 d_castneg='$d_castneg'
12946 d_charvspr='$d_charvspr'
12947 d_chown='$d_chown'
12948 d_chroot='$d_chroot'
12949 d_chsize='$d_chsize'
12950 d_closedir='$d_closedir'
12951 d_cmsghdr_s='$d_cmsghdr_s'
12952 d_const='$d_const'
12953 d_crypt='$d_crypt'
12954 d_csh='$d_csh'
12955 d_cuserid='$d_cuserid'
12956 d_dbl_dig='$d_dbl_dig'
12957 d_dbmclose64='$d_dbmclose64'
12958 d_dbminit64='$d_dbminit64'
12959 d_delete64='$d_delete64'
12960 d_difftime='$d_difftime'
12961 d_dirent64_s='$d_dirent64_s'
12962 d_dirnamlen='$d_dirnamlen'
12963 d_dlerror='$d_dlerror'
12964 d_dlopen='$d_dlopen'
12965 d_dlsymun='$d_dlsymun'
12966 d_dosuid='$d_dosuid'
12967 d_drand48proto='$d_drand48proto'
12968 d_dup2='$d_dup2'
12969 d_eaccess='$d_eaccess'
12970 d_endgrent='$d_endgrent'
12971 d_endhent='$d_endhent'
12972 d_endnent='$d_endnent'
12973 d_endpent='$d_endpent'
12974 d_endpwent='$d_endpwent'
12975 d_endsent='$d_endsent'
12976 d_eofnblk='$d_eofnblk'
12977 d_eunice='$d_eunice'
12978 d_fchmod='$d_fchmod'
12979 d_fchown='$d_fchown'
12980 d_fcntl='$d_fcntl'
12981 d_fd_macros='$d_fd_macros'
12982 d_fd_set='$d_fd_set'
12983 d_fds_bits='$d_fds_bits'
12984 d_fetch64='$d_fetch64'
12985 d_fgetpos64='$d_fgetpos64'
12986 d_fgetpos='$d_fgetpos'
12987 d_firstkey64='$d_firstkey64'
12988 d_flexfnam='$d_flexfnam'
12989 d_flock64_s='$d_flock64_s'
12990 d_flock='$d_flock'
12991 d_fopen64='$d_fopen64'
12992 d_fork='$d_fork'
12993 d_fpathconf='$d_fpathconf'
12994 d_freopen64='$d_freopen64'
12995 d_fseek64='$d_fseek64'
12996 d_fseeko64='$d_fseeko64'
12997 d_fseeko='$d_fseeko'
12998 d_fsetpos64='$d_fsetpos64'
12999 d_fsetpos='$d_fsetpos'
13000 d_fstat64='$d_fstat64'
13001 d_fstatfs='$d_fstatfs'
13002 d_fstatvfs='$d_fstatvfs'
13003 d_ftell64='$d_ftell64'
13004 d_ftello64='$d_ftello64'
13005 d_ftello='$d_ftello'
13006 d_ftime='$d_ftime'
13007 d_ftruncate64='$d_ftruncate64'
13008 d_getgrent='$d_getgrent'
13009 d_getgrps='$d_getgrps'
13010 d_gethbyaddr='$d_gethbyaddr'
13011 d_gethbyname='$d_gethbyname'
13012 d_gethent='$d_gethent'
13013 d_gethname='$d_gethname'
13014 d_gethostprotos='$d_gethostprotos'
13015 d_getlogin='$d_getlogin'
13016 d_getmntent='$d_getmntent'
13017 d_getnbyaddr='$d_getnbyaddr'
13018 d_getnbyname='$d_getnbyname'
13019 d_getnent='$d_getnent'
13020 d_getnetprotos='$d_getnetprotos'
13021 d_getpbyname='$d_getpbyname'
13022 d_getpbynumber='$d_getpbynumber'
13023 d_getpent='$d_getpent'
13024 d_getpgid='$d_getpgid'
13025 d_getpgrp2='$d_getpgrp2'
13026 d_getpgrp='$d_getpgrp'
13027 d_getppid='$d_getppid'
13028 d_getprior='$d_getprior'
13029 d_getprotoprotos='$d_getprotoprotos'
13030 d_getpwent='$d_getpwent'
13031 d_getsbyname='$d_getsbyname'
13032 d_getsbyport='$d_getsbyport'
13033 d_getsent='$d_getsent'
13034 d_getservprotos='$d_getservprotos'
13035 d_gettimeod='$d_gettimeod'
13036 d_gnulibc='$d_gnulibc'
13037 d_grpasswd='$d_grpasswd'
13038 d_hasmntopt='$d_hasmntopt'
13039 d_htonl='$d_htonl'
13040 d_index='$d_index'
13041 d_inetaton='$d_inetaton'
13042 d_ino64_t='$d_ino64_t'
13043 d_int64t='$d_int64t'
13044 d_iovec_s='$d_iovec_s'
13045 d_isascii='$d_isascii'
13046 d_killpg='$d_killpg'
13047 d_lchown='$d_lchown'
13048 d_link='$d_link'
13049 d_llseek='$d_llseek'
13050 d_locconv='$d_locconv'
13051 d_lockf64='$d_lockf64'
13052 d_lockf='$d_lockf'
13053 d_longdbl='$d_longdbl'
13054 d_longlong='$d_longlong'
13055 d_lseek64='$d_lseek64'
13056 d_lstat64='$d_lstat64'
13057 d_lstat='$d_lstat'
13058 d_madvise='$d_madvise'
13059 d_mblen='$d_mblen'
13060 d_mbstowcs='$d_mbstowcs'
13061 d_mbtowc='$d_mbtowc'
13062 d_memchr='$d_memchr'
13063 d_memcmp='$d_memcmp'
13064 d_memcpy='$d_memcpy'
13065 d_memmove='$d_memmove'
13066 d_memset='$d_memset'
13067 d_mkdir='$d_mkdir'
13068 d_mkfifo='$d_mkfifo'
13069 d_mktime='$d_mktime'
13070 d_mmap='$d_mmap'
13071 d_mprotect='$d_mprotect'
13072 d_msg='$d_msg'
13073 d_msg_ctrunc='$d_msg_ctrunc'
13074 d_msg_dontroute='$d_msg_dontroute'
13075 d_msg_oob='$d_msg_oob'
13076 d_msg_peek='$d_msg_peek'
13077 d_msg_proxy='$d_msg_proxy'
13078 d_msgctl='$d_msgctl'
13079 d_msgget='$d_msgget'
13080 d_msghdr_s='$d_msghdr_s'
13081 d_msgrcv='$d_msgrcv'
13082 d_msgsnd='$d_msgsnd'
13083 d_msync='$d_msync'
13084 d_munmap='$d_munmap'
13085 d_mymalloc='$d_mymalloc'
13086 d_nextkey64='$d_nextkey64'
13087 d_nice='$d_nice'
13088 d_off64_t='$d_off64_t'
13089 d_offset_t='$d_offset_t'
13090 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
13091 d_oldpthreads='$d_oldpthreads'
13092 d_oldsock='$d_oldsock'
13093 d_open3='$d_open3'
13094 d_open64='$d_open64'
13095 d_opendir64='$d_opendir64'
13096 d_pathconf='$d_pathconf'
13097 d_pause='$d_pause'
13098 d_phostname='$d_phostname'
13099 d_pipe='$d_pipe'
13100 d_poll='$d_poll'
13101 d_portable='$d_portable'
13102 d_pthread_yield='$d_pthread_yield'
13103 d_pwage='$d_pwage'
13104 d_pwchange='$d_pwchange'
13105 d_pwclass='$d_pwclass'
13106 d_pwcomment='$d_pwcomment'
13107 d_pwexpire='$d_pwexpire'
13108 d_pwgecos='$d_pwgecos'
13109 d_pwpasswd='$d_pwpasswd'
13110 d_pwquota='$d_pwquota'
13111 d_readdir64='$d_readdir64'
13112 d_readdir='$d_readdir'
13113 d_readlink='$d_readlink'
13114 d_readv='$d_readv'
13115 d_recvmsg='$d_recvmsg'
13116 d_rename='$d_rename'
13117 d_rewinddir='$d_rewinddir'
13118 d_rmdir='$d_rmdir'
13119 d_safebcpy='$d_safebcpy'
13120 d_safemcpy='$d_safemcpy'
13121 d_sanemcmp='$d_sanemcmp'
13122 d_sched_yield='$d_sched_yield'
13123 d_scm_rights='$d_scm_rights'
13124 d_seekdir64='$d_seekdir64'
13125 d_seekdir='$d_seekdir'
13126 d_select='$d_select'
13127 d_sem='$d_sem'
13128 d_semctl='$d_semctl'
13129 d_semctl_semid_ds='$d_semctl_semid_ds'
13130 d_semctl_semun='$d_semctl_semun'
13131 d_semget='$d_semget'
13132 d_semop='$d_semop'
13133 d_sendmsg='$d_sendmsg'
13134 d_setegid='$d_setegid'
13135 d_seteuid='$d_seteuid'
13136 d_setgrent='$d_setgrent'
13137 d_setgrps='$d_setgrps'
13138 d_sethent='$d_sethent'
13139 d_setlinebuf='$d_setlinebuf'
13140 d_setlocale='$d_setlocale'
13141 d_setnent='$d_setnent'
13142 d_setpent='$d_setpent'
13143 d_setpgid='$d_setpgid'
13144 d_setpgrp2='$d_setpgrp2'
13145 d_setpgrp='$d_setpgrp'
13146 d_setprior='$d_setprior'
13147 d_setpwent='$d_setpwent'
13148 d_setregid='$d_setregid'
13149 d_setresgid='$d_setresgid'
13150 d_setresuid='$d_setresuid'
13151 d_setreuid='$d_setreuid'
13152 d_setrgid='$d_setrgid'
13153 d_setruid='$d_setruid'
13154 d_setsent='$d_setsent'
13155 d_setsid='$d_setsid'
13156 d_setvbuf='$d_setvbuf'
13157 d_sfio='$d_sfio'
13158 d_shm='$d_shm'
13159 d_shmat='$d_shmat'
13160 d_shmatprototype='$d_shmatprototype'
13161 d_shmctl='$d_shmctl'
13162 d_shmdt='$d_shmdt'
13163 d_shmget='$d_shmget'
13164 d_sigaction='$d_sigaction'
13165 d_sigsetjmp='$d_sigsetjmp'
13166 d_socket='$d_socket'
13167 d_sockpair='$d_sockpair'
13168 d_stat64='$d_stat64'
13169 d_statblks='$d_statblks'
13170 d_statfs='$d_statfs'
13171 d_statfsflags='$d_statfsflags'
13172 d_statvfs='$d_statvfs'
13173 d_stdio_cnt_lval='$d_stdio_cnt_lval'
13174 d_stdio_ptr_lval='$d_stdio_ptr_lval'
13175 d_stdio_stream_array='$d_stdio_stream_array'
13176 d_stdiobase='$d_stdiobase'
13177 d_stdstdio='$d_stdstdio'
13178 d_store64='$d_store64'
13179 d_strchr='$d_strchr'
13180 d_strcoll='$d_strcoll'
13181 d_strctcpy='$d_strctcpy'
13182 d_strerrm='$d_strerrm'
13183 d_strerror='$d_strerror'
13184 d_strtod='$d_strtod'
13185 d_strtol='$d_strtol'
13186 d_strtoul='$d_strtoul'
13187 d_strxfrm='$d_strxfrm'
13188 d_suidsafe='$d_suidsafe'
13189 d_symlink='$d_symlink'
13190 d_syscall='$d_syscall'
13191 d_sysconf='$d_sysconf'
13192 d_sysernlst='$d_sysernlst'
13193 d_syserrlst='$d_syserrlst'
13194 d_system='$d_system'
13195 d_tcgetpgrp='$d_tcgetpgrp'
13196 d_tcsetpgrp='$d_tcsetpgrp'
13197 d_telldir64='$d_telldir64'
13198 d_telldir='$d_telldir'
13199 d_telldirproto='$d_telldirproto'
13200 d_time='$d_time'
13201 d_times='$d_times'
13202 d_tmpfile64='$d_tmpfile64'
13203 d_truncate64='$d_truncate64'
13204 d_truncate='$d_truncate'
13205 d_tzname='$d_tzname'
13206 d_umask='$d_umask'
13207 d_uname='$d_uname'
13208 d_union_semun='$d_union_semun'
13209 d_vfork='$d_vfork'
13210 d_void_closedir='$d_void_closedir'
13211 d_voidsig='$d_voidsig'
13212 d_voidtty='$d_voidtty'
13213 d_volatile='$d_volatile'
13214 d_vprintf='$d_vprintf'
13215 d_wait4='$d_wait4'
13216 d_waitpid='$d_waitpid'
13217 d_wcstombs='$d_wcstombs'
13218 d_wctomb='$d_wctomb'
13219 d_writev='$d_writev'
13220 d_xenix='$d_xenix'
13221 date='$date'
13222 db_hashtype='$db_hashtype'
13223 db_prefixtype='$db_prefixtype'
13224 defvoidused='$defvoidused'
13225 direntrytype='$direntrytype'
13226 dlext='$dlext'
13227 dlsrc='$dlsrc'
13228 doublesize='$doublesize'
13229 drand01='$drand01'
13230 dynamic_ext='$dynamic_ext'
13231 eagain='$eagain'
13232 ebcdic='$ebcdic'
13233 echo='$echo'
13234 egrep='$egrep'
13235 emacs='$emacs'
13236 eunicefix='$eunicefix'
13237 exe_ext='$exe_ext'
13238 expr='$expr'
13239 extensions='$extensions'
13240 fflushNULL='$fflushNULL'
13241 fflushall='$fflushall'
13242 find='$find'
13243 firstmakefile='$firstmakefile'
13244 flex='$flex'
13245 fpostype='$fpostype'
13246 freetype='$freetype'
13247 full_ar='$full_ar'
13248 full_csh='$full_csh'
13249 full_sed='$full_sed'
13250 gccversion='$gccversion'
13251 gidtype='$gidtype'
13252 glibpth='$glibpth'
13253 grep='$grep'
13254 groupcat='$groupcat'
13255 groupstype='$groupstype'
13256 gzip='$gzip'
13257 h_fcntl='$h_fcntl'
13258 h_sysfile='$h_sysfile'
13259 hint='$hint'
13260 hostcat='$hostcat'
13261 huge='$huge'
13262 i_arpainet='$i_arpainet'
13263 i_bsdioctl='$i_bsdioctl'
13264 i_db='$i_db'
13265 i_dbm='$i_dbm'
13266 i_dirent='$i_dirent'
13267 i_dld='$i_dld'
13268 i_dlfcn='$i_dlfcn'
13269 i_fcntl='$i_fcntl'
13270 i_float='$i_float'
13271 i_gdbm='$i_gdbm'
13272 i_grp='$i_grp'
13273 i_inttypes='$i_inttypes'
13274 i_limits='$i_limits'
13275 i_locale='$i_locale'
13276 i_machcthr='$i_machcthr'
13277 i_malloc='$i_malloc'
13278 i_math='$i_math'
13279 i_memory='$i_memory'
13280 i_mntent='$i_mntent'
13281 i_ndbm='$i_ndbm'
13282 i_netdb='$i_netdb'
13283 i_neterrno='$i_neterrno'
13284 i_netinettcp='$i_netinettcp'
13285 i_niin='$i_niin'
13286 i_poll='$i_poll'
13287 i_pthread='$i_pthread'
13288 i_pwd='$i_pwd'
13289 i_rpcsvcdbm='$i_rpcsvcdbm'
13290 i_sfio='$i_sfio'
13291 i_sgtty='$i_sgtty'
13292 i_stdarg='$i_stdarg'
13293 i_stddef='$i_stddef'
13294 i_stdlib='$i_stdlib'
13295 i_string='$i_string'
13296 i_sysaccess='$i_sysaccess'
13297 i_sysdir='$i_sysdir'
13298 i_sysfile='$i_sysfile'
13299 i_sysfilio='$i_sysfilio'
13300 i_sysin='$i_sysin'
13301 i_sysioctl='$i_sysioctl'
13302 i_sysmman='$i_sysmman'
13303 i_sysmount='$i_sysmount'
13304 i_sysndir='$i_sysndir'
13305 i_sysparam='$i_sysparam'
13306 i_sysresrc='$i_sysresrc'
13307 i_syssecrt='$i_syssecrt'
13308 i_sysselct='$i_sysselct'
13309 i_syssockio='$i_syssockio'
13310 i_sysstat='$i_sysstat'
13311 i_sysstatvfs='$i_sysstatvfs'
13312 i_systime='$i_systime'
13313 i_systimek='$i_systimek'
13314 i_systimes='$i_systimes'
13315 i_systypes='$i_systypes'
13316 i_sysuio='$i_sysuio'
13317 i_sysun='$i_sysun'
13318 i_syswait='$i_syswait'
13319 i_termio='$i_termio'
13320 i_termios='$i_termios'
13321 i_time='$i_time'
13322 i_unistd='$i_unistd'
13323 i_utime='$i_utime'
13324 i_values='$i_values'
13325 i_varargs='$i_varargs'
13326 i_varhdr='$i_varhdr'
13327 i_vfork='$i_vfork'
13328 ignore_versioned_solibs='$ignore_versioned_solibs'
13329 incpath='$incpath'
13330 inews='$inews'
13331 installarchlib='$installarchlib'
13332 installbin='$installbin'
13333 installman1dir='$installman1dir'
13334 installman3dir='$installman3dir'
13335 installprivlib='$installprivlib'
13336 installscript='$installscript'
13337 installsitearch='$installsitearch'
13338 installsitelib='$installsitelib'
13339 installusrbinperl='$installusrbinperl'
13340 intsize='$intsize'
13341 known_extensions='$known_extensions'
13342 ksh='$ksh'
13343 large='$large'
13344 ld='$ld'
13345 lddlflags='$lddlflags'
13346 ldflags='$ldflags'
13347 less='$less'
13348 lib_ext='$lib_ext'
13349 libc='$libc'
13350 libperl='$libperl'
13351 libpth='$libpth'
13352 libs='$libs'
13353 libswanted='$libswanted'
13354 line='$line'
13355 lint='$lint'
13356 lkflags='$lkflags'
13357 ln='$ln'
13358 lns='$lns'
13359 locincpth='$locincpth'
13360 loclibpth='$loclibpth'
13361 longdblsize='$longdblsize'
13362 longlongsize='$longlongsize'
13363 longsize='$longsize'
13364 lp='$lp'
13365 lpr='$lpr'
13366 ls='$ls'
13367 lseeksize='$lseeksize'
13368 lseektype='$lseektype'
13369 mail='$mail'
13370 mailx='$mailx'
13371 make='$make'
13372 make_set_make='$make_set_make'
13373 mallocobj='$mallocobj'
13374 mallocsrc='$mallocsrc'
13375 malloctype='$malloctype'
13376 man1dir='$man1dir'
13377 man1direxp='$man1direxp'
13378 man1ext='$man1ext'
13379 man3dir='$man3dir'
13380 man3direxp='$man3direxp'
13381 man3ext='$man3ext'
13382 medium='$medium'
13383 mips='$mips'
13384 mips_type='$mips_type'
13385 mkdir='$mkdir'
13386 mmaptype='$mmaptype'
13387 models='$models'
13388 modetype='$modetype'
13389 more='$more'
13390 multiarch='$multiarch'
13391 mv='$mv'
13392 myarchname='$myarchname'
13393 mydomain='$mydomain'
13394 myhostname='$myhostname'
13395 myuname='$myuname'
13396 n='$n'
13397 netdb_hlen_type='$netdb_hlen_type'
13398 netdb_host_type='$netdb_host_type'
13399 netdb_name_type='$netdb_name_type'
13400 netdb_net_type='$netdb_net_type'
13401 nm='$nm'
13402 nm_opt='$nm_opt'
13403 nm_so_opt='$nm_so_opt'
13404 nonxs_ext='$nonxs_ext'
13405 nroff='$nroff'
13406 o_nonblock='$o_nonblock'
13407 obj_ext='$obj_ext'
13408 old_pthread_create_joinable='$old_pthread_create_joinable'
13409 optimize='$optimize'
13410 orderlib='$orderlib'
13411 osname='$osname'
13412 osvers='$osvers'
13413 package='$package'
13414 pager='$pager'
13415 passcat='$passcat'
13416 patchlevel='$patchlevel'
13417 path_sep='$path_sep'
13418 perl='$perl'
13419 perladmin='$perladmin'
13420 perlpath='$perlpath'
13421 pg='$pg'
13422 phostname='$phostname'
13423 pidtype='$pidtype'
13424 plibpth='$plibpth'
13425 pmake='$pmake'
13426 pr='$pr'
13427 prefix='$prefix'
13428 prefixexp='$prefixexp'
13429 privlib='$privlib'
13430 privlibexp='$privlibexp'
13431 prototype='$prototype'
13432 ptrsize='$ptrsize'
13433 randbits='$randbits'
13434 randfunc='$randfunc'
13435 randseedtype='$randseedtype'
13436 ranlib='$ranlib'
13437 rd_nodata='$rd_nodata'
13438 rm='$rm'
13439 rmail='$rmail'
13440 runnm='$runnm'
13441 sched_yield='$sched_yield'
13442 scriptdir='$scriptdir'
13443 scriptdirexp='$scriptdirexp'
13444 sed='$sed'
13445 seedfunc='$seedfunc'
13446 selectminbits='$selectminbits'
13447 selecttype='$selecttype'
13448 sendmail='$sendmail'
13449 sh='$sh'
13450 shar='$shar'
13451 sharpbang='$sharpbang'
13452 shmattype='$shmattype'
13453 shortsize='$shortsize'
13454 shrpenv='$shrpenv'
13455 shsharp='$shsharp'
13456 sig_count='$sig_count'
13457 sig_name='$sig_name'
13458 sig_name_init='$sig_name_init'
13459 sig_num='$sig_num'
13460 sig_num_init='$sig_num_init'
13461 signal_t='$signal_t'
13462 sitearch='$sitearch'
13463 sitearchexp='$sitearchexp'
13464 sitelib='$sitelib'
13465 sitelibexp='$sitelibexp'
13466 sizetype='$sizetype'
13467 sleep='$sleep'
13468 smail='$smail'
13469 small='$small'
13470 so='$so'
13471 sockethdr='$sockethdr'
13472 socketlib='$socketlib'
13473 sort='$sort'
13474 spackage='$spackage'
13475 spitshell='$spitshell'
13476 split='$split'
13477 src='$src'
13478 ssizetype='$ssizetype'
13479 startperl='$startperl'
13480 startsh='$startsh'
13481 static_ext='$static_ext'
13482 stdchar='$stdchar'
13483 stdio_base='$stdio_base'
13484 stdio_bufsiz='$stdio_bufsiz'
13485 stdio_cnt='$stdio_cnt'
13486 stdio_filbuf='$stdio_filbuf'
13487 stdio_ptr='$stdio_ptr'
13488 stdio_stream_array='$stdio_stream_array'
13489 strings='$strings'
13490 submit='$submit'
13491 subversion='$subversion'
13492 sysman='$sysman'
13493 tail='$tail'
13494 tar='$tar'
13495 tbl='$tbl'
13496 tee='$tee'
13497 test='$test'
13498 timeincl='$timeincl'
13499 timetype='$timetype'
13500 touch='$touch'
13501 tr='$tr'
13502 trnl='$trnl'
13503 troff='$troff'
13504 uidtype='$uidtype'
13505 uname='$uname'
13506 uniq='$uniq'
13507 use64bits='$use64bits'
13508 usedl='$usedl'
13509 usemultiplicity='$usemultiplicity'
13510 usemymalloc='$usemymalloc'
13511 usenm='$usenm'
13512 useopcode='$useopcode'
13513 useperlio='$useperlio'
13514 useposix='$useposix'
13515 usesfio='$usesfio'
13516 useshrplib='$useshrplib'
13517 usethreads='$usethreads'
13518 usevfork='$usevfork'
13519 usrinc='$usrinc'
13520 uuname='$uuname'
13521 version='$version'
13522 vi='$vi'
13523 voidflags='$voidflags'
13524 xlibpth='$xlibpth'
13525 zcat='$zcat'
13526 zip='$zip'
13527 EOT
13528
13529 : Add in command line options if available
13530 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13531
13532 : add special variables
13533 $test -f $src/patchlevel.h && \
13534 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13535 echo "CONFIGDOTSH=true" >>config.sh
13536
13537 : propagate old symbols
13538 if $test -f UU/config.sh; then
13539         <UU/config.sh sort | uniq >UU/oldconfig.sh
13540         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13541         sort | uniq -u >UU/oldsyms
13542         set X `cat UU/oldsyms`
13543         shift
13544         case $# in
13545         0) ;;
13546         *)
13547                 cat <<EOM
13548 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13549 EOM
13550                 echo "# Variables propagated from previous config.sh file." >>config.sh
13551                 for sym in `cat UU/oldsyms`; do
13552                         echo "    Propagating $hint variable "'$'"$sym..."
13553                         eval 'tmp="$'"${sym}"'"'
13554                         echo "$tmp" | \
13555                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13556                 done
13557                 ;;
13558         esac
13559 fi
13560
13561 : Finish up by extracting the .SH files
13562 case "$alldone" in
13563 exit)
13564         $rm -rf UU
13565         echo "Done."
13566         exit 0
13567         ;;
13568 cont)
13569         ;;
13570 '')
13571         dflt=''
13572         nostick=true
13573         $cat <<EOM
13574
13575 If you'd like to make any changes to the config.sh file before I begin
13576 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13577
13578 EOM
13579         rp="Press return or use a shell escape to edit config.sh:"
13580         . UU/myread
13581         nostick=''
13582         case "$ans" in
13583         '') ;;
13584         *) : in case they cannot read
13585                 sh 1>&4 -c "$ans";;
13586         esac
13587         ;;
13588 esac
13589
13590 : if this fails, just run all the .SH files by hand
13591 . ./config.sh
13592
13593 echo " "
13594 exec 1>&4
13595 . ./UU/extract
13596
13597 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13598         dflt=y
13599         case "$silent" in
13600         true) ;;
13601         *)
13602                 $cat <<EOM
13603
13604 Now you need to generate make dependencies by running "$make depend".
13605 You might prefer to run it in background: "$make depend > makedepend.out &"
13606 It can take a while, so you might not want to run it right now.
13607
13608 EOM
13609                 ;;
13610         esac
13611         rp="Run $make depend now?"
13612         . UU/myread
13613         case "$ans" in
13614         y*)
13615                 $make depend && echo "Now you must run a $make."
13616                 ;;
13617         *)
13618                 echo "You must run '$make depend' then '$make'."
13619                 ;;
13620         esac
13621 elif test -f [Mm]akefile; then
13622         echo " "
13623         echo "Now you must run a $make."
13624 else
13625         echo "Done."
13626 fi
13627
13628 if $test -f Policy.sh; then
13629     $cat <<EOM
13630
13631 If you compile $package on a different machine or from a different object
13632 directory, copy the Policy.sh file from this object directory to the
13633 new one before you run Configure -- this will help you with most of
13634 the policy defaults.
13635
13636 EOM
13637 fi
13638 if $test -f config.msg; then
13639     echo "Hmm.  I also noted the following information while running:"
13640     echo " "
13641     $cat config.msg >&4
13642     $rm -f config.msg
13643 fi
13644 $rm -f kit*isdone ark*isdone
13645 $rm -rf UU
13646
13647 : End of Configure
13648