6f2f171d18ea97ed0492128293fc754c21454b22
[p5sagit/p5-mst-13.2.git] / Configure
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc and is available on CPAN under authors/id/RAM so
18 # you may fetch it yourself from your nearest archive site.)
19 #
20
21 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
22 #
23 # Generated on Mon Feb 22 11:28:58 EET 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 case "$inksh/$needksh" in
112 /[a-z]*)
113                 ENV=''
114                 changesh=true
115                 reason="$needksh"
116         ;;
117 esac
118 case "$inksh/$avoidksh" in
119 true/[a-z]*)
120         changesh=true
121         reason="$avoidksh"
122         ;;
123 esac
124 case "$inksh/$needksh-$avoidksh-" in
125 true/--)
126                 cat <<EOM
127 (I see you are using the Korn shell.  Some ksh's blow up on $me,
128 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
129 EOM
130         ;;
131 esac
132 case "$changesh" in
133 true)
134         echo "(Feeding myself to $newsh $reason.)"
135         case "$0" in
136         Configure|*/Configure) exec $newsh $0 "$@";;
137         *) exec $newsh Configure "$@";;
138         esac
139         ;;
140 esac
141
142 : if needed set CDPATH to a harmless value that is not chatty
143 : avoid bash 2.02 problems with empty CDPATH.
144 case "$CDPATH" in
145 '')     ;;
146 *)      case "$SHELL" in
147         *bash*) CDPATH='.' ;;
148         *)              CDPATH='' ;;
149         esac
150         ;;
151 esac
152 : Configure runs within the UU subdirectory
153 test -d UU || mkdir UU
154 cd UU && rm -f ./*
155
156 ccsymbols=''
157 cppccsymbols=''
158 cppsymbols=''
159 dynamic_ext=''
160 extensions=''
161 known_extensions=''
162 nonxs_ext=''
163 static_ext=''
164 useopcode=''
165 useposix=''
166 d_bsd=''
167 d_eunice=''
168 d_xenix=''
169 eunicefix=''
170 Mcc=''
171 ar=''
172 awk=''
173 bash=''
174 bison=''
175 byacc=''
176 cat=''
177 chgrp=''
178 chmod=''
179 chown=''
180 comm=''
181 compress=''
182 cp=''
183 cpio=''
184 cpp=''
185 csh=''
186 date=''
187 echo=''
188 egrep=''
189 emacs=''
190 expr=''
191 find=''
192 flex=''
193 grep=''
194 gzip=''
195 inews=''
196 ksh=''
197 less=''
198 line=''
199 lint=''
200 ln=''
201 lp=''
202 lpr=''
203 ls=''
204 mail=''
205 mailx=''
206 make=''
207 mkdir=''
208 more=''
209 mv=''
210 nm=''
211 nroff=''
212 perl=''
213 pg=''
214 pmake=''
215 pr=''
216 rm=''
217 rmail=''
218 sed=''
219 sendmail=''
220 shar=''
221 sleep=''
222 smail=''
223 sort=''
224 submit=''
225 tail=''
226 tar=''
227 tbl=''
228 tee=''
229 test=''
230 touch=''
231 tr=''
232 troff=''
233 uname=''
234 uniq=''
235 uuname=''
236 vi=''
237 zcat=''
238 zip=''
239 full_ar=''
240 full_sed=''
241 libswanted=''
242 hint=''
243 myuname=''
244 osname=''
245 osvers=''
246 Author=''
247 Date=''
248 Header=''
249 Id=''
250 Locker=''
251 Log=''
252 RCSfile=''
253 Revision=''
254 Source=''
255 State=''
256 _a=''
257 _exe=''
258 _o=''
259 archobjs=''
260 exe_ext=''
261 firstmakefile=''
262 lib_ext=''
263 obj_ext=''
264 path_sep=''
265 afs=''
266 alignbytes=''
267 ansi2knr=''
268 archlib=''
269 archlibexp=''
270 d_archlib=''
271 installarchlib=''
272 archname=''
273 myarchname=''
274 baserev=''
275 bin=''
276 binexp=''
277 installbin=''
278 byteorder=''
279 cc=''
280 gccversion=''
281 ccflags=''
282 cppflags=''
283 ldflags=''
284 lkflags=''
285 locincpth=''
286 optimize=''
287 cf_email=''
288 cf_by=''
289 cf_time=''
290 contains=''
291 cpp_stuff=''
292 cpplast=''
293 cppminus=''
294 cpprun=''
295 cppstdin=''
296 crosscompile=''
297 d_access=''
298 d_accessx=''
299 d_alarm=''
300 d_attribut=''
301 d_bcmp=''
302 d_bcopy=''
303 d_bzero=''
304 d_casti32=''
305 castflags=''
306 d_castneg=''
307 d_chown=''
308 d_chroot=''
309 d_chsize=''
310 d_closedir=''
311 d_void_closedir=''
312 d_const=''
313 cryptlib=''
314 d_crypt=''
315 d_csh=''
316 full_csh=''
317 d_cuserid=''
318 d_dbl_dig=''
319 d_difftime=''
320 d_dlerror=''
321 d_dlopen=''
322 d_dlsymun=''
323 d_dosuid=''
324 d_suidsafe=''
325 d_drand48proto=''
326 d_dup2=''
327 d_eaccess=''
328 d_endgrent=''
329 d_endhent=''
330 d_endnent=''
331 d_endpent=''
332 d_endpwent=''
333 d_endsent=''
334 d_fchmod=''
335 d_fchown=''
336 d_fcntl=''
337 d_fd_macros=''
338 d_fd_set=''
339 d_fds_bits=''
340 d_fgetpos=''
341 d_flexfnam=''
342 d_flock=''
343 d_fork=''
344 d_fseeko=''
345 d_fsetpos=''
346 d_ftello=''
347 d_ftime=''
348 d_gettimeod=''
349 d_Gconvert=''
350 d_getgrent=''
351 d_getgrps=''
352 d_gethbyaddr=''
353 d_gethbyname=''
354 d_gethent=''
355 aphostname=''
356 d_gethname=''
357 d_phostname=''
358 d_uname=''
359 d_gethostprotos=''
360 d_getlogin=''
361 d_getmntent=''
362 d_getnbyaddr=''
363 d_getnbyname=''
364 d_getnent=''
365 d_getnetprotos=''
366 d_getpent=''
367 d_getpgid=''
368 d_getpgrp2=''
369 d_bsdgetpgrp=''
370 d_getpgrp=''
371 d_getppid=''
372 d_getprior=''
373 d_getpbyname=''
374 d_getpbynumber=''
375 d_getprotoprotos=''
376 d_getpwent=''
377 d_getsent=''
378 d_getservprotos=''
379 d_getsbyname=''
380 d_getsbyport=''
381 d_gnulibc=''
382 d_hasmntopt=''
383 d_htonl=''
384 d_inetaton=''
385 d_isascii=''
386 d_killpg=''
387 d_lchown=''
388 d_link=''
389 d_locconv=''
390 d_lockf=''
391 d_longdbl=''
392 longdblsize=''
393 d_longlong=''
394 longlongsize=''
395 d_lstat=''
396 d_madvise=''
397 d_mblen=''
398 d_mbstowcs=''
399 d_mbtowc=''
400 d_memcmp=''
401 d_memcpy=''
402 d_memmove=''
403 d_memset=''
404 d_mkdir=''
405 d_mkfifo=''
406 d_mktime=''
407 d_mmap=''
408 mmaptype=''
409 d_mprotect=''
410 d_msg=''
411 d_msgctl=''
412 d_msgget=''
413 d_msgrcv=''
414 d_msgsnd=''
415 d_msync=''
416 d_munmap=''
417 d_nice=''
418 d_open3=''
419 d_fpathconf=''
420 d_pathconf=''
421 d_pause=''
422 d_pipe=''
423 d_poll=''
424 d_portable=''
425 d_old_pthread_create_joinable=''
426 old_pthread_create_joinable=''
427 d_pthread_yield=''
428 d_sched_yield=''
429 sched_yield=''
430 d_readdir=''
431 d_rewinddir=''
432 d_seekdir=''
433 d_telldir=''
434 d_readlink=''
435 d_readv=''
436 d_rename=''
437 d_rmdir=''
438 d_safebcpy=''
439 d_safemcpy=''
440 d_sanemcmp=''
441 d_select=''
442 d_sem=''
443 d_semctl=''
444 d_semget=''
445 d_semop=''
446 d_setegid=''
447 d_seteuid=''
448 d_setgrent=''
449 d_setgrps=''
450 d_sethent=''
451 d_setlinebuf=''
452 d_setlocale=''
453 d_setnent=''
454 d_setpent=''
455 d_setpgid=''
456 d_setpgrp2=''
457 d_bsdsetpgrp=''
458 d_setpgrp=''
459 d_setprior=''
460 d_setpwent=''
461 d_setregid=''
462 d_setresgid=''
463 d_setresuid=''
464 d_setreuid=''
465 d_setrgid=''
466 d_setruid=''
467 d_setsent=''
468 d_setsid=''
469 d_setvbuf=''
470 d_sfio=''
471 usesfio=''
472 d_shm=''
473 d_shmat=''
474 d_shmatprototype=''
475 shmattype=''
476 d_shmctl=''
477 d_shmdt=''
478 d_shmget=''
479 d_sigaction=''
480 d_sigsetjmp=''
481 d_cmsghdr_s=''
482 d_msg_ctrunc=''
483 d_msg_dontroute=''
484 d_msg_oob=''
485 d_msg_peek=''
486 d_msg_proxy=''
487 d_msghdr_s=''
488 d_oldsock=''
489 d_recvmsg=''
490 d_scm_rights=''
491 d_sendmsg=''
492 d_socket=''
493 d_sockpair=''
494 sockethdr=''
495 socketlib=''
496 d_statblks=''
497 d_fstatfs=''
498 d_statfs=''
499 d_statfsflags=''
500 d_fstatvfs=''
501 d_statvfs=''
502 d_stdio_cnt_lval=''
503 d_stdio_ptr_lval=''
504 d_stdiobase=''
505 d_stdstdio=''
506 stdio_base=''
507 stdio_bufsiz=''
508 stdio_cnt=''
509 stdio_filbuf=''
510 stdio_ptr=''
511 d_index=''
512 d_strchr=''
513 d_strcoll=''
514 d_strctcpy=''
515 d_strerrm=''
516 d_strerror=''
517 d_sysernlst=''
518 d_syserrlst=''
519 d_strtod=''
520 d_strtol=''
521 d_strtoul=''
522 d_strxfrm=''
523 d_symlink=''
524 d_syscall=''
525 d_sysconf=''
526 d_system=''
527 d_tcgetpgrp=''
528 d_tcsetpgrp=''
529 d_telldirproto=''
530 d_time=''
531 timetype=''
532 clocktype=''
533 d_times=''
534 d_truncate=''
535 d_tzname=''
536 d_umask=''
537 d_semctl_semid_ds=''
538 d_semctl_semun=''
539 d_union_semun=''
540 d_vfork=''
541 usevfork=''
542 d_voidsig=''
543 signal_t=''
544 d_volatile=''
545 d_charvspr=''
546 d_vprintf=''
547 d_wait4=''
548 d_waitpid=''
549 d_wcstombs=''
550 d_wctomb=''
551 d_writev=''
552 d_dbmclose64=''
553 d_dbminit64=''
554 d_delete64=''
555 d_fetch64=''
556 d_firstkey64=''
557 d_nextkey64=''
558 d_store64=''
559 dlext=''
560 cccdlflags=''
561 ccdlflags=''
562 dlsrc=''
563 ld=''
564 lddlflags=''
565 usedl=''
566 doublesize=''
567 ebcdic=''
568 fpostype=''
569 gidtype=''
570 groupstype=''
571 h_fcntl=''
572 h_sysfile=''
573 i_arpainet=''
574 db_hashtype=''
575 db_prefixtype=''
576 i_db=''
577 i_dbm=''
578 i_rpcsvcdbm=''
579 d_dirnamlen=''
580 direntrytype=''
581 i_dirent=''
582 i_dld=''
583 i_dlfcn=''
584 i_fcntl=''
585 i_float=''
586 i_gdbm=''
587 d_grpasswd=''
588 i_grp=''
589 d_int64t=''
590 i_inttypes=''
591 i_limits=''
592 i_locale=''
593 i_machcthr=''
594 i_malloc=''
595 i_math=''
596 i_memory=''
597 i_mntent=''
598 i_ndbm=''
599 i_netdb=''
600 i_neterrno=''
601 i_niin=''
602 i_sysin=''
603 i_poll=''
604 d_pwage=''
605 d_pwchange=''
606 d_pwclass=''
607 d_pwcomment=''
608 d_pwexpire=''
609 d_pwgecos=''
610 d_pwpasswd=''
611 d_pwquota=''
612 i_pwd=''
613 i_sfio=''
614 i_stddef=''
615 i_stdlib=''
616 i_string=''
617 strings=''
618 i_sysaccess=''
619 i_sysdir=''
620 i_sysfile=''
621 d_voidtty=''
622 i_bsdioctl=''
623 i_sysfilio=''
624 i_sysioctl=''
625 i_syssockio=''
626 i_sysmman=''
627 i_sysmount=''
628 i_sysndir=''
629 i_sysparam=''
630 i_sysresrc=''
631 i_syssecrt=''
632 i_sysselct=''
633 i_sysstat=''
634 i_sysstatvfs=''
635 i_systimes=''
636 i_systypes=''
637 d_iovec_s=''
638 i_sysuio=''
639 i_sysun=''
640 i_syswait=''
641 i_sgtty=''
642 i_termio=''
643 i_termios=''
644 i_systime=''
645 i_systimek=''
646 i_time=''
647 timeincl=''
648 i_unistd=''
649 i_utime=''
650 i_values=''
651 i_stdarg=''
652 i_varargs=''
653 i_varhdr=''
654 i_vfork=''
655 installusrbinperl=''
656 intsize=''
657 longsize=''
658 shortsize=''
659 d_dirent64_s=''
660 d_flock64_s=''
661 d_fstat64=''
662 d_ftruncate64=''
663 d_ino64t=''
664 d_lockf64=''
665 d_lseek64=''
666 d_lstat64=''
667 d_off64t=''
668 d_open64=''
669 d_opendir64=''
670 d_readdir64=''
671 d_seekdir64=''
672 d_stat64=''
673 d_telldir64=''
674 d_truncate64=''
675 libc=''
676 libperl=''
677 shrpenv=''
678 useshrplib=''
679 glibpth=''
680 libpth=''
681 loclibpth=''
682 plibpth=''
683 xlibpth=''
684 ignore_versioned_solibs=''
685 libs=''
686 lns=''
687 lseeksize=''
688 lseektype=''
689 make_set_make=''
690 d_mymalloc=''
691 freetype=''
692 mallocobj=''
693 mallocsrc=''
694 malloctype=''
695 usemymalloc=''
696 installman1dir=''
697 man1dir=''
698 man1direxp=''
699 man1ext=''
700 installman3dir=''
701 man3dir=''
702 man3direxp=''
703 man3ext=''
704 huge=''
705 large=''
706 medium=''
707 models=''
708 small=''
709 split=''
710 modetype=''
711 multiarch=''
712 mydomain=''
713 myhostname=''
714 phostname=''
715 c=''
716 n=''
717 d_eofnblk=''
718 eagain=''
719 o_nonblock=''
720 rd_nodata=''
721 netdb_hlen_type=''
722 netdb_host_type=''
723 netdb_name_type=''
724 netdb_net_type=''
725 groupcat=''
726 hostcat=''
727 passcat=''
728 orderlib=''
729 ranlib=''
730 package=''
731 spackage=''
732 pager=''
733 apiversion=''
734 patchlevel=''
735 subversion=''
736 version=''
737 perladmin=''
738 perlpath=''
739 pidtype=''
740 prefix=''
741 prefixexp=''
742 installprivlib=''
743 privlib=''
744 privlibexp=''
745 prototype=''
746 ptrsize=''
747 drand01=''
748 randbits=''
749 randfunc=''
750 randseedtype=''
751 seedfunc=''
752 installscript=''
753 scriptdir=''
754 scriptdirexp=''
755 selectminbits=''
756 selecttype=''
757 sh=''
758 sig_name=''
759 sig_name_init=''
760 sig_num=''
761 sig_num_init=''
762 installsitearch=''
763 sitearch=''
764 sitearchexp=''
765 installsitelib=''
766 sitelib=''
767 sitelibexp=''
768 sizetype=''
769 so=''
770 sharpbang=''
771 shsharp=''
772 spitshell=''
773 src=''
774 ssizetype=''
775 startperl=''
776 startsh=''
777 stdchar=''
778 d_fgetpos64=''
779 d_fopen64=''
780 d_freopen64=''
781 d_fseek64=''
782 d_fseeko64=''
783 d_fsetpos64=''
784 d_ftell64=''
785 d_ftello64=''
786 d_tmpfile64=''
787 sysman=''
788 trnl=''
789 uidtype=''
790 archname64=''
791 use64bits=''
792 usemultiplicity=''
793 nm_opt=''
794 nm_so_opt=''
795 runnm=''
796 usenm=''
797 useperlio=''
798 d_oldpthreads=''
799 usethreads=''
800 incpath=''
801 mips=''
802 mips_type=''
803 usrinc=''
804 defvoidused=''
805 voidflags=''
806 CONFIG=''
807
808 define='define'
809 undef='undef'
810 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
811 rmlist=''
812
813 : We must find out about Eunice early
814 eunicefix=':'
815 if test -f /etc/unixtovms; then
816         eunicefix=/etc/unixtovms
817 fi
818 if test -f /etc/unixtovms.exe; then
819         eunicefix=/etc/unixtovms.exe
820 fi
821
822 i_whoami=''
823 : Possible local include directories to search.
824 : Set locincpth to "" in a hint file to defeat local include searches.
825 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
826 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
827 :
828 : no include file wanted by default
829 inclwanted=''
830
831 : list of known cpp symbols, sorted alphabetically
832 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
833 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
834 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
835 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
836 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
837 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
838 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
839 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
840 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
841 al="$al VMS Xenix286"
842 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
843 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
844 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
845 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
846 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
847 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
848 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
849 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
850 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
851 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
852 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
853 al="$al __SVR4_2__ __UMAXV__"
854 al="$al ____386BSD____ __alpha __alpha__ __amiga"
855 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
856 al="$al __host_mips__"
857 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
858 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
859 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
860 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
861 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
862 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
863 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
864 al="$al __mc88100 __mc88100__ __mips __mips__"
865 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
866 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
867 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
868 al="$al _host_mips _mips _unix"
869 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
870 al="$al apollo ardent att386 att3b"
871 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
872 al="$al cadmus clipper concurrent convex cray ctix"
873 al="$al dmert encore gcos gcx gimpel gould"
874 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
875 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
876 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
877 al="$al i186 i286 i386 i486 i8086"
878 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
879 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
880 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
881 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
882 al="$al mc88000 mc88100 merlin mert mips mvs n16"
883 al="$al ncl_el ncl_mr"
884 al="$al news1500 news1700 news1800 news1900 news3700"
885 al="$al news700 news800 news900 ns16000 ns32000"
886 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
887 al="$al parisc pc532 pdp11 plexus posix pyr"
888 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
889 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
890 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
891 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
892 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
893 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
894 al="$al xenix z8000"
895
896 : Trailing extension.  Override this in a hint file, if needed.
897 _exe=''
898 : Extra object files, if any, needed on this platform.
899 archobjs=''
900 groupstype=''
901 : change the next line if compiling for Xenix/286 on Xenix/386
902 xlibpth='/usr/lib/386 /lib/386'
903
904 : Possible local library directories to search.
905 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
906 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
907
908 : general looking path for locating libraries
909 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
910 glibpth="$glibpth /lib /usr/lib $xlibpth"
911 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
912 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
913
914 : Private path used by Configure to find libraries.  Its value
915 : is prepended to libpth. This variable takes care of special
916 : machines, like the mips.  Usually, it should be empty.
917 plibpth=''
918
919 : default library list
920 libswanted=''
921 : some systems want to use only the non-versioned libso:s
922 ignore_versioned_solibs=''
923 : full support for void wanted by default
924 defvoidused=15
925
926 : set useposix=false in your hint file to disable the POSIX extension.
927 useposix=true
928 : set useopcode=false in your hint file to disable the Opcode extension.
929 useopcode=true
930 : set usemultiplicity on the Configure command line to enable multiplicity.
931 : set usethreads on the Configure command line to enable threads.
932 : List of libraries we want.
933 : If anyone needs -lnet, put it in a hint file.
934 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
935 libswanted="$libswanted dld ld sun m c cposix posix ndir dir crypt"
936 libswanted="$libswanted ucb bsd BSD PW x"
937 : We probably want to search /usr/shlib before most other libraries.
938 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
939 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
940 glibpth="/usr/shlib $glibpth"
941 : Do not use vfork unless overridden by a hint file.
942 usevfork=false
943
944 : Find the basic shell for Bourne shell scripts
945 case "$sh" in
946 '')
947         case "$SYSTYPE" in
948         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
949         *) xxx='/bin/sh';;
950         esac
951         if test -f "$xxx"; then
952                 sh="$xxx"
953         else
954                 : Build up a list and do a single loop so we can 'break' out.
955                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
956                 for xxx in sh bash ksh pdksh ash; do
957                         for p in $pth; do
958                                 try="$try ${p}/${xxx}"
959                         done
960                 done
961                 for xxx in $try; do
962                         if test -f "$xxx"; then
963                                 sh="$xxx";
964                                 break
965                         elif test -f "$xxx.exe"; then
966                                 sh="$xxx";
967                                 break
968                         fi
969                 done
970         fi
971         ;;
972 esac
973
974 case "$sh" in
975 '')     cat <<EOM >&2
976 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
977
978 Usually it's in /bin/sh.  How did you even get this far?
979 Please contact me (Perl Maintainers) at perlbug@perl.com and 
980 we'll try to straighten this all out.
981 EOM
982         exit 1
983         ;;
984 esac
985
986 : see if sh knows # comments
987 if `$sh -c '#' >/dev/null 2>&1`; then
988         shsharp=true
989         spitshell=cat
990         xcat=/bin/cat
991         test -f $xcat || xcat=/usr/bin/cat
992         echo "#!$xcat" >try
993         $eunicefix try
994         chmod +x try
995         ./try > today
996         if test -s today; then
997                 sharpbang='#!'
998         else
999                 echo "#! $xcat" > try
1000                 $eunicefix try
1001                 chmod +x try
1002                 ./try > today
1003                 if test -s today; then
1004                         sharpbang='#! '
1005                 else
1006                         sharpbang=': use '
1007                 fi
1008         fi
1009 else
1010         echo " "
1011         echo "Your $sh doesn't grok # comments--I will strip them later on."
1012         shsharp=false
1013         cd ..
1014         echo "exec grep -v '^[  ]*#'" >spitshell
1015         chmod +x spitshell
1016         $eunicefix spitshell
1017         spitshell=`pwd`/spitshell
1018         cd UU
1019         echo "I presume that if # doesn't work, #! won't work either!"
1020         sharpbang=': use '
1021 fi
1022 rm -f try today
1023
1024 : figure out how to guarantee sh startup
1025 case "$startsh" in
1026 '') startsh=${sharpbang}${sh} ;;
1027 *)
1028 esac
1029 cat >try <<EOSS
1030 $startsh
1031 set abc
1032 test "$?abc" != 1
1033 EOSS
1034
1035 chmod +x try
1036 $eunicefix try
1037 if ./try; then
1038         : echo "Yup, it does."
1039 else
1040         echo "Hmm... '$startsh' does not guarantee sh startup..."
1041         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1042 fi
1043 rm -f try
1044
1045
1046 : Save command line options in file UU/cmdline.opt for later use in
1047 : generating config.sh.
1048 cat > cmdline.opt <<EOSH
1049 # Configure command line arguments.
1050 config_arg0='$0'
1051 config_args='$*'
1052 config_argc=$#
1053 EOSH
1054 argn=1
1055 for arg in "$@"; do
1056         cat >>cmdline.opt <<EOSH
1057 config_arg$argn='$arg'
1058 EOSH
1059         argn=`expr $argn + 1`
1060 done
1061
1062 : produce awk script to parse command line options
1063 cat >options.awk <<'EOF'
1064 BEGIN {
1065         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1066
1067         len = length(optstr);
1068         for (i = 1; i <= len; i++) {
1069                 c = substr(optstr, i, 1);
1070                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1071                 if (a == ":") {
1072                         arg[c] = 1;
1073                         i++;
1074                 }
1075                 opt[c] = 1;
1076         }
1077 }
1078 {
1079         expect = 0;
1080         str = $0;
1081         if (substr(str, 1, 1) != "-") {
1082                 printf("'%s'\n", str);
1083                 next;
1084         }
1085         len = length($0);
1086         for (i = 2; i <= len; i++) {
1087                 c = substr(str, i, 1);
1088                 if (!opt[c]) {
1089                         printf("-%s\n", substr(str, i));
1090                         next;
1091                 }
1092                 printf("-%s\n", c);
1093                 if (arg[c]) {
1094                         if (i < len)
1095                                 printf("'%s'\n", substr(str, i + 1));
1096                         else
1097                                 expect = 1;
1098                         next;
1099                 }
1100         }
1101 }
1102 END {
1103         if (expect)
1104                 print "?";
1105 }
1106 EOF
1107
1108 : process the command line options
1109 set X `for arg in "$@"; do echo "X$arg"; done |
1110         sed -e s/X// | awk -f options.awk`
1111 eval "set $*"
1112 shift
1113 rm -f options.awk
1114
1115 : set up default values
1116 fastread=''
1117 reuseval=false
1118 config_sh=''
1119 alldone=''
1120 error=''
1121 silent=''
1122 extractsh=''
1123 override=''
1124 knowitall=''
1125 rm -f optdef.sh
1126 cat >optdef.sh <<EOS
1127 $startsh
1128 EOS
1129
1130
1131 : option parsing
1132 while test $# -gt 0; do
1133         case "$1" in
1134         -d) shift; fastread=yes;;
1135         -e) shift; alldone=cont;;
1136         -f)
1137                 shift
1138                 cd ..
1139                 if test -r "$1"; then
1140                         config_sh="$1"
1141                 else
1142                         echo "$me: cannot read config file $1." >&2
1143                         error=true
1144                 fi
1145                 cd UU
1146                 shift;;
1147         -h) shift; error=true;;
1148         -r) shift; reuseval=true;;
1149         -s) shift; silent=true; realsilent=true;;
1150         -E) shift; alldone=exit;;
1151         -K) shift; knowitall=true;;
1152         -O) shift; override=true;;
1153         -S) shift; silent=true; extractsh=true;;
1154         -D)
1155                 shift
1156                 case "$1" in
1157                 *=)
1158                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1159                         echo "$me: ignoring -D $1" >&2
1160                         ;;
1161                 *=*) echo "$1" | \
1162                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1163                 *) echo "$1='define'" >> optdef.sh;;
1164                 esac
1165                 shift
1166                 ;;
1167         -U)
1168                 shift
1169                 case "$1" in
1170                 *=) echo "$1" >> optdef.sh;;
1171                 *=*)
1172                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1173                         echo "$me: ignoring -U $1" >&2
1174                         ;;
1175                 *) echo "$1='undef'" >> optdef.sh;;
1176                 esac
1177                 shift
1178                 ;;
1179         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1180                 exit 0;;
1181         --) break;;
1182         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1183         *) break;;
1184         esac
1185 done
1186
1187 case "$error" in
1188 true)
1189         cat >&2 <<EOM
1190 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1191                  [-U symbol] [-U symbol=]
1192   -d : use defaults for all answers.
1193   -e : go on without questioning past the production of config.sh.
1194   -f : specify an alternate default configuration file.
1195   -h : print this help message and exit (with an error status).
1196   -r : reuse C symbols value if possible (skips costly nm extraction).
1197   -s : silent mode, only echoes questions and essential information.
1198   -D : define symbol to have some value:
1199          -D symbol         symbol gets the value 'define'
1200          -D symbol=value   symbol gets the value 'value'
1201   -E : stop at the end of questions, after having produced config.sh.
1202   -K : do not use unless you know what you are doing.
1203   -O : let -D and -U override definitions from loaded configuration file.
1204   -S : perform variable substitutions on all .SH files (can mix with -f)
1205   -U : undefine symbol:
1206          -U symbol    symbol gets the value 'undef'
1207          -U symbol=   symbol gets completely empty
1208   -V : print version number and exit (with a zero status).
1209 EOM
1210         exit 1
1211         ;;
1212 esac
1213
1214 : Sanity checks
1215 case "$fastread$alldone" in
1216 yescont|yesexit) ;;
1217 *)
1218         if test ! -t 0; then
1219                 echo "Say 'sh Configure', not 'sh <Configure'"
1220                 exit 1
1221         fi
1222         ;;
1223 esac
1224
1225 exec 4>&1
1226 case "$silent" in
1227 true) exec 1>/dev/null;;
1228 esac
1229
1230 : run the defines and the undefines, if any, but leave the file out there...
1231 touch optdef.sh
1232 . ./optdef.sh
1233
1234 : set package name
1235 package=perl5
1236 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1237 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1238 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1239 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1240 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1241 esac
1242
1243 : Some greps do not return status, grrr.
1244 echo "grimblepritz" >grimble
1245 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1246         contains=contains
1247 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1248         contains=grep
1249 else
1250         contains=contains
1251 fi
1252 rm -f grimble
1253 : the following should work in any shell
1254 case "$contains" in
1255 contains*)
1256         echo " "
1257         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1258         cat >contains <<'EOSS'
1259 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1260 EOSS
1261 chmod +x contains
1262 esac
1263
1264 : Find the path to the source tree
1265 case "$src" in
1266 '') case "$0" in
1267     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1268     *)   src='.';;
1269     esac;;
1270 esac
1271 case "$src" in
1272 '')     src=/
1273         rsrc=/
1274         ;;
1275 /*) rsrc="$src";;
1276 *) rsrc="../$src";;
1277 esac
1278 if test -f $rsrc/Configure && \
1279         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1280 then
1281    : found it, so we are ok.
1282 else
1283         rsrc=''
1284         for src in . .. ../.. ../../.. ../../../..; do
1285                 if test -f ../$src/Configure && \
1286                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1287                 then
1288                         rsrc=../$src
1289                         break
1290                 fi
1291         done
1292 fi
1293 case "$rsrc" in
1294 '')
1295         cat <<EOM >&4
1296
1297 Sorry, I can't seem to locate the source dir for $package.  Please start
1298 Configure with an explicit path -- i.e. /some/path/Configure.
1299
1300 EOM
1301         exit 1
1302         ;;
1303 ../.)   rsrc='..';;
1304 *)
1305         echo " "
1306         echo "Sources for $package found in \"$src\"." >&4
1307         ;;
1308 esac
1309
1310 : script used to extract .SH files with variable substitutions
1311 cat >extract <<'EOS'
1312 CONFIG=true
1313 echo "Doing variable substitutions on .SH files..."
1314 if test -f $src/MANIFEST; then
1315         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1316 else
1317         echo "(Looking for .SH files under the source directory.)"
1318         set x `(cd $src; find . -name "*.SH" -print)`
1319 fi
1320 shift
1321 case $# in
1322 0) set x `(cd $src; echo *.SH)`; shift;;
1323 esac
1324 if test ! -f $src/$1; then
1325         shift
1326 fi
1327 mkdir_p='
1328 name=$1;
1329 create="";
1330 while test $name; do
1331         if test ! -d "$name"; then
1332                 create="$name $create";
1333                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1334                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1335         else
1336                 name="";
1337         fi;
1338 done;
1339 for file in $create; do
1340         mkdir $file;
1341 done
1342 '
1343 for file in $*; do
1344         case "$src" in
1345         ".")
1346                 case "$file" in
1347                 */*)
1348                         dir=`expr X$file : 'X\(.*\)/'`
1349                         file=`expr X$file : 'X.*/\(.*\)'`
1350                         (cd $dir && . ./$file)
1351                         ;;
1352                 *)
1353                         . ./$file
1354                         ;;
1355                 esac
1356                 ;;
1357         *)
1358                 case "$file" in
1359                 */*)
1360                         dir=`expr X$file : 'X\(.*\)/'`
1361                         file=`expr X$file : 'X.*/\(.*\)'`
1362                         (set x $dir; shift; eval $mkdir_p)
1363                         sh <$src/$dir/$file
1364                         ;;
1365                 *)
1366                         sh <$src/$file
1367                         ;;
1368                 esac
1369                 ;;
1370         esac
1371 done
1372 if test -f $src/config_h.SH; then
1373         if test ! -f config.h; then
1374         : oops, they left it out of MANIFEST, probably, so do it anyway.
1375         . $src/config_h.SH
1376         fi
1377 fi
1378 EOS
1379
1380 : extract files and exit if asked to do so
1381 case "$extractsh" in
1382 true)
1383         case "$realsilent" in
1384         true) ;;
1385         *) exec 1>&4;;
1386         esac
1387         case "$config_sh" in
1388         '') config_sh='config.sh';;
1389         esac
1390         echo " "
1391         echo "Fetching answers from $config_sh..."
1392         cd ..
1393         . $config_sh
1394         test "$override" && . ./optdef.sh
1395         echo " "
1396         . UU/extract
1397         rm -rf UU
1398         echo "Done."
1399         exit 0
1400         ;;
1401 esac
1402
1403 : Eunice requires " " instead of "", can you believe it
1404 echo " "
1405 : Here we go...
1406 echo "Beginning of configuration questions for $package."
1407
1408 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1409
1410 : first determine how to suppress newline on echo command
1411 echo " "
1412 echo "Checking echo to see how to suppress newlines..."
1413 (echo "hi there\c" ; echo " ") >.echotmp
1414 if $contains c .echotmp >/dev/null 2>&1 ; then
1415         echo "...using -n."
1416         n='-n'
1417         c=''
1418 else
1419         cat <<'EOM'
1420 ...using \c
1421 EOM
1422         n=''
1423         c='\c'
1424 fi
1425 echo $n "The star should be here-->$c"
1426 echo '*'
1427 rm -f .echotmp
1428
1429 : Now test for existence of everything in MANIFEST
1430 echo " "
1431 if test -f $rsrc/MANIFEST; then
1432         echo "First let's make sure your kit is complete.  Checking..." >&4
1433         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1434         rm -f missing
1435         tmppwd=`pwd`
1436         for filelist in x??; do
1437                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1438         done
1439         if test -s missing; then
1440                 cat missing >&4
1441                 cat >&4 <<'EOM'
1442
1443 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1444
1445 You have the option of continuing the configuration process, despite the
1446 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1447 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1448 and contact the author (perlbug@perl.com).
1449
1450 EOM
1451                 echo $n "Continue? [n] $c" >&4
1452                 read ans
1453                 case "$ans" in
1454                 y*)
1455                         echo "Continuing..." >&4
1456                         rm -f missing
1457                         ;;
1458                 *)
1459                         echo "ABORTING..." >&4
1460                         kill $$
1461                         ;;
1462                 esac
1463         else
1464                 echo "Looks good..."
1465         fi
1466 else
1467         echo "There is no MANIFEST file.  I hope your kit is complete !"
1468 fi
1469 rm -f missing x??
1470
1471 echo " "
1472 : Find the appropriate value for a newline for tr
1473 if test -n "$DJGPP"; then
1474        trnl='\012'
1475 fi
1476 if test X"$trnl" = X; then
1477         case "`echo foo|tr '\n' x 2>/dev/null`" in
1478         foox) trnl='\n' ;;
1479         esac
1480 fi
1481 if test X"$trnl" = X; then
1482         case "`echo foo|tr '\012' x 2>/dev/null`" in
1483         foox) trnl='\012' ;;
1484         esac
1485 fi
1486 if test X"$trnl" = X; then
1487         cat <<EOM >&2
1488
1489 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1490
1491 EOM
1492         exit 1
1493 fi
1494
1495 : compute the number of columns on the terminal for proper question formatting
1496 case "$COLUMNS" in
1497 '') COLUMNS='80';;
1498 esac
1499
1500 : set up the echo used in my read
1501 myecho="case \"\$xxxm\" in
1502 '') echo $n \"\$rp $c\" >&4;;
1503 *) case \"\$rp\" in
1504         '') echo $n \"[\$xxxm] $c\";;
1505         *)
1506                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1507                         echo \"\$rp\" >&4
1508                         echo $n \"[\$xxxm] $c\" >&4
1509                 else
1510                         echo $n \"\$rp [\$xxxm] $c\" >&4
1511                 fi
1512                 ;;
1513         esac;;
1514 esac"
1515
1516 : now set up to do reads with possible shell escape and default assignment
1517 cat <<EOSC >myread
1518 $startsh
1519 xxxm=\$dflt
1520 $myecho
1521 ans='!'
1522 case "\$fastread" in
1523 yes) case "\$dflt" in
1524         '') ;;
1525         *) ans='';
1526                 case "\$silent-\$rp" in
1527                 true-) ;;
1528                 *) echo " " >&4;;
1529                 esac;;
1530         esac;;
1531 *) case "\$silent" in
1532         true) case "\$rp" in
1533                 '') ans='';;
1534                 esac;;
1535         esac;;
1536 esac
1537 while expr "X\$ans" : "X!" >/dev/null; do
1538         read answ
1539         set x \$xxxm
1540         shift
1541         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1542         case  "\$answ" in
1543         "!")
1544                 sh 1>&4
1545                 echo " "
1546                 $myecho
1547                 ;;
1548         !*)
1549                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1550                 shift
1551                 sh 1>&4 -c "\$*"
1552                 echo " "
1553                 $myecho
1554                 ;;
1555         "\$ans")
1556                 case "\$ans" in
1557                 \\&*)
1558                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1559                         shift
1560                         case "\$1" in
1561                         -d)
1562                                 fastread=yes
1563                                 echo "(OK, I'll run with -d after this question.)" >&4
1564                                 ;;
1565                         -*)
1566                                 echo "*** Sorry, \$1 not supported yet." >&4
1567                                 ;;
1568                         esac
1569                         $myecho
1570                         ans=!
1571                         ;;
1572                 esac;;
1573         *)
1574                 case "\$aok" in
1575                 y)
1576                         echo "*** Substitution done -- please confirm."
1577                         xxxm="\$ans"
1578                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1579                         xxxm="\$ans"
1580                         ans=!
1581                         ;;
1582                 *)
1583                         echo "*** Error -- try again."
1584                         ans=!
1585                         ;;
1586                 esac
1587                 $myecho
1588                 ;;
1589         esac
1590         case "\$ans\$xxxm\$nostick" in
1591         '')
1592                 ans=!
1593                 $myecho
1594                 ;;
1595         esac
1596 done
1597 case "\$ans" in
1598 '') ans="\$xxxm";;
1599 esac
1600 EOSC
1601
1602 : create .config dir to save info across Configure sessions
1603 test -d ../.config || mkdir ../.config
1604 cat >../.config/README <<EOF
1605 This directory created by Configure to save information that should
1606 persist across sessions for $package.
1607
1608 You may safely delete it if you wish.
1609 EOF
1610
1611 : general instructions
1612 needman=true
1613 firsttime=true
1614 user=`(logname) 2>/dev/null`
1615 case "$user" in
1616 '') user=`whoami 2>&1`;;
1617 esac
1618 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1619         firsttime=false
1620         echo " "
1621         rp='Would you like to see the instructions?'
1622         dflt=n
1623         . ./myread
1624         case "$ans" in
1625         [yY]*) ;;
1626         *) needman=false;;
1627         esac
1628 fi
1629 if $needman; then
1630         cat <<EOH
1631
1632 This installation shell script will examine your system and ask you questions
1633 to determine how the perl5 package should be installed. If you get
1634 stuck on a question, you may use a ! shell escape to start a subshell or
1635 execute a command.  Many of the questions will have default answers in square
1636 brackets; typing carriage return will give you the default.
1637
1638 On some of the questions which ask for file or directory names you are allowed
1639 to use the ~name construct to specify the login directory belonging to "name",
1640 even if you don't have a shell which knows about that.  Questions where this is
1641 allowed will be marked "(~name ok)".
1642
1643 EOH
1644         rp=''
1645         dflt='Type carriage return to continue'
1646         . ./myread
1647         cat <<'EOH'
1648
1649 The prompter used in this script allows you to use shell variables and
1650 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1651 in the default answer, as if the default line was a set of arguments given to a
1652 script shell.  This means you may also use $* to repeat the whole default line,
1653 so you do not have to re-type everything to add something to the default.
1654
1655 Everytime there is a substitution, you will have to confirm.  If there is an
1656 error (e.g. an unmatched backtick), the default answer will remain unchanged
1657 and you will be prompted again.
1658
1659 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1660 the questions and use the computed defaults (or the previous answers if there
1661 was already a config.sh file). Type 'Configure -h' for a list of options.
1662 You may also start interactively and then answer '& -d' at any prompt to turn
1663 on the non-interactive behaviour for the remainder of the execution.
1664
1665 EOH
1666         . ./myread
1667         cat <<EOH
1668
1669 Much effort has been expended to ensure that this shell script will run on any
1670 Unix system.  If despite that it blows up on yours, your best bet is to edit
1671 Configure and run it again.  If you can't run Configure for some reason,
1672 you'll have to generate a config.sh file by hand.  Whatever problems you
1673 have, let me (perlbug@perl.com) know how I blew it.
1674
1675 This installation script affects things in two ways:
1676
1677 1) it may do direct variable substitutions on some of the files included
1678    in this kit.
1679 2) it builds a config.h file for inclusion in C programs.  You may edit
1680    any of these files as the need arises after running this script.
1681
1682 If you make a mistake on a question, there is no easy way to back up to it
1683 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1684 files.  Configure will offer to let you do this before it runs the SH files.
1685
1686 EOH
1687         dflt='Type carriage return to continue'
1688         . ./myread
1689         case "$firsttime" in
1690         true) echo $user >>../.config/instruct;;
1691         esac
1692 fi
1693
1694 : find out where common programs are
1695 echo " "
1696 echo "Locating common programs..." >&4
1697 cat <<EOSC >loc
1698 $startsh
1699 case \$# in
1700 0) exit 1;;
1701 esac
1702 thing=\$1
1703 shift
1704 dflt=\$1
1705 shift
1706 for dir in \$*; do
1707         case "\$thing" in
1708         .)
1709         if test -d \$dir/\$thing; then
1710                 echo \$dir
1711                 exit 0
1712         fi
1713         ;;
1714         *)
1715         for thisthing in \$dir/\$thing; do
1716                 : just loop through to pick last item
1717         done
1718         if test -f \$thisthing; then
1719                 echo \$thisthing
1720                 exit 0
1721         elif test -f \$dir/\$thing.exe; then
1722                 if test -n "$DJGPP"; then
1723                         echo \$dir/\$thing.exe
1724                 else
1725                         : on Eunice apparently
1726                         echo \$dir/\$thing
1727                 fi
1728                 exit 0
1729         fi
1730         ;;
1731         esac
1732 done
1733 echo \$dflt
1734 exit 1
1735 EOSC
1736 chmod +x loc
1737 $eunicefix loc
1738 loclist="
1739 awk
1740 cat
1741 comm
1742 cp
1743 echo
1744 expr
1745 grep
1746 ls
1747 make
1748 mkdir
1749 rm
1750 sed
1751 sort
1752 touch
1753 tr
1754 uniq
1755 "
1756 trylist="
1757 Mcc
1758 ar
1759 byacc
1760 cpp
1761 csh
1762 date
1763 egrep
1764 gzip
1765 less
1766 ln
1767 more
1768 nm
1769 nroff
1770 pg
1771 tee
1772 test
1773 uname
1774 zip
1775 "
1776 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1777 pth="$pth /lib /usr/lib"
1778 for file in $loclist; do
1779         eval xxx=\$$file
1780         case "$xxx" in
1781         /*|?:[\\/]*)
1782                 if test -f "$xxx"; then
1783                         : ok
1784                 else
1785                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1786                         xxx=`./loc $file $file $pth`
1787                 fi
1788                 ;;
1789         '') xxx=`./loc $file $file $pth`;;
1790         *) xxx=`./loc $xxx $xxx $pth`;;
1791         esac
1792         eval $file=$xxx
1793         eval _$file=$xxx
1794         case "$xxx" in
1795         /*)
1796                 echo $file is in $xxx.
1797                 ;;
1798         ?:[\\/]*)
1799                 echo $file is in $xxx.
1800                 ;;
1801         *)
1802                 echo "I don't know where '$file' is, and my life depends on it." >&4
1803                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1804                 exit 1
1805                 ;;
1806         esac
1807 done
1808 echo " "
1809 echo "Don't worry if any of the following aren't found..."
1810 say=offhand
1811 for file in $trylist; do
1812         eval xxx=\$$file
1813         case "$xxx" in
1814         /*|?:[\\/]*)
1815                 if test -f "$xxx"; then
1816                         : ok
1817                 else
1818                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1819                         xxx=`./loc $file $file $pth`
1820                 fi
1821                 ;;
1822         '') xxx=`./loc $file $file $pth`;;
1823         *) xxx=`./loc $xxx $xxx $pth`;;
1824         esac
1825         eval $file=$xxx
1826         eval _$file=$xxx
1827         case "$xxx" in
1828         /*)
1829                 echo $file is in $xxx.
1830                 ;;
1831         ?:[\\/]*)
1832                 echo $file is in $xxx.
1833                 ;;
1834         *)
1835                 echo "I don't see $file out there, $say."
1836                 say=either
1837                 ;;
1838         esac
1839 done
1840 case "$egrep" in
1841 egrep)
1842         echo "Substituting grep for egrep."
1843         egrep=$grep
1844         ;;
1845 esac
1846 case "$ln" in
1847 ln)
1848         echo "Substituting cp for ln."
1849         ln=$cp
1850         ;;
1851 esac
1852 case "$test" in
1853 test)
1854         echo "Hopefully test is built into your sh."
1855         ;;
1856 *)
1857         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1858                 echo "Using the test built into your sh."
1859                 test=test
1860                 _test=test
1861         fi
1862         ;;
1863 esac
1864 case "$echo" in
1865 echo)
1866         echo "Hopefully echo is built into your sh."
1867         ;;
1868 '') ;;
1869 *)
1870         echo " "
1871 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1872         $echo $n "hi there$c" >foo1
1873         echo $n "hi there$c" >foo2
1874         if cmp foo1 foo2 >/dev/null 2>&1; then
1875                 echo "They are compatible.  In fact, they may be identical."
1876         else
1877                 case "$n" in
1878                 '-n') n='' c='\c';;
1879                 *) n='-n' c='';;
1880                 esac
1881                 cat <<FOO
1882 They are not compatible!  You are probably running ksh on a non-USG system.
1883 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1884 have echo built in and we may have to run some Bourne shell scripts.  That
1885 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1886
1887 FOO
1888                 $echo $n "The star should be here-->$c"
1889                 $echo "*"
1890         fi
1891         $rm -f foo1 foo2
1892         ;;
1893 esac
1894
1895 : determine whether symbolic links are supported
1896 echo " "
1897 $touch blurfl
1898 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1899         echo "Symbolic links are supported." >&4
1900         lns="$ln -s"
1901 else
1902         echo "Symbolic links are NOT supported." >&4
1903         lns="$ln"
1904 fi
1905 $rm -f blurfl sym
1906
1907 : see whether [:lower:] and [:upper:] are supported character classes
1908 echo " "
1909 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1910 ABYZ)
1911         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1912         up='[:upper:]'
1913         low='[:lower:]'
1914         ;;
1915 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1916         # (0xc9 and 0xd1), therefore that is a nice testing point.
1917         if test "X$up" = X -o "X$low" = X; then
1918             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1919             ij) up='[A-Z]'
1920                 low='[a-z]'
1921                 ;;
1922             esac
1923         fi
1924         if test "X$up" = X -o "X$low" = X; then
1925             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1926             ij) up='A-Z'
1927                 low='a-z'
1928                 ;;
1929             esac
1930         fi
1931         if test "X$up" = X -o "X$low" = X; then
1932             case "`echo IJ | od -x 2>/dev/null`" in
1933             *C9D1*|*c9d1*)
1934                 echo "Hey, this might be EBCDIC." >&4
1935                 if test "X$up" = X -o "X$low" = X; then
1936                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1937                     ij) up='[A-IJ-RS-Z]'
1938                         low='[a-ij-rs-z]'
1939                         ;;
1940                     esac
1941                 fi
1942                 if test "X$up" = X -o "X$low" = X; then
1943                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1944                     ij) up='A-IJ-RS-Z'
1945                         low='a-ij-rs-z'
1946                         ;;
1947                     esac
1948                 fi
1949                 ;;
1950             esac
1951         fi
1952 esac
1953 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1954 ij)
1955     echo "Using $up and $low to convert case." >&4
1956     ;;
1957 *)
1958     echo "I don't know how to translate letters from upper to lower case." >&4
1959     echo "Your tr is not acting any way I know of." >&4
1960     exit 1
1961     ;;
1962 esac
1963 : set up the translation script tr, must be called with ./tr of course
1964 cat >tr <<EOSC
1965 $startsh
1966 case "\$1\$2" in
1967 '[A-Z][a-z]') exec $tr '$up' '$low';;
1968 '[a-z][A-Z]') exec $tr '$low' '$up';;
1969 esac
1970 exec $tr "\$@"
1971 EOSC
1972 chmod +x tr
1973 $eunicefix tr
1974
1975 : Try to determine whether config.sh was made on this system
1976 case "$config_sh" in
1977 '')
1978 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1979 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
1980 # because the A-Z/a-z are not consecutive.
1981 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
1982         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
1983 newmyuname="$myuname"
1984 dflt=n
1985 case "$knowitall" in
1986 '')
1987         if test -f ../config.sh; then
1988                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
1989                         eval "`grep myuname= ../config.sh`"
1990                 fi
1991                 if test "X$myuname" = "X$newmyuname"; then
1992                         dflt=y
1993                 fi
1994         fi
1995         ;;
1996 *) dflt=y;;
1997 esac
1998
1999 : Get old answers from old config file if Configure was run on the
2000 : same system, otherwise use the hints.
2001 hint=default
2002 cd ..
2003 if test -f config.sh; then
2004         echo " "
2005         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2006         . UU/myread
2007         case "$ans" in
2008         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2009         *)  echo "Fetching default answers from your old config.sh file..." >&4
2010                 tmp_n="$n"
2011                 tmp_c="$c"
2012                 tmp_sh="$sh"
2013                 . ./config.sh
2014                 cp config.sh UU
2015                 n="$tmp_n"
2016                 c="$tmp_c"
2017                 : Older versions did not always set $sh.  Catch re-use of such
2018                 : an old config.sh.
2019                 case "$sh" in
2020                 '') sh="$tmp_sh" ;;
2021                 esac
2022                 hint=previous
2023                 ;;
2024         esac
2025 fi
2026 if test ! -f config.sh; then
2027         $cat <<EOM
2028
2029 First time through, eh?  I have some defaults handy for some systems
2030 that need some extra help getting the Configure answers right:
2031
2032 EOM
2033         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2034         dflt=''
2035         : Half the following guesses are probably wrong... If you have better
2036         : tests or hints, please send them to perlbug@perl.com
2037         : The metaconfig authors would also appreciate a copy...
2038         $test -f /irix && osname=irix
2039         $test -f /xenix && osname=sco_xenix
2040         $test -f /dynix && osname=dynix
2041         $test -f /dnix && osname=dnix
2042         $test -f /lynx.os && osname=lynxos
2043         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2044         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2045         $test -f /bin/mips && /bin/mips && osname=mips
2046         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2047                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2048         $test -d /usr/apollo/bin && osname=apollo
2049         $test -f /etc/saf/_sactab && osname=svr4
2050         $test -d /usr/include/minix && osname=minix
2051         if $test -d /MachTen -o -d /MachTen_Folder; then
2052                 osname=machten
2053                 if $test -x /sbin/version; then
2054                         osvers=`/sbin/version | $awk '{print $2}' |
2055                         $sed -e 's/[A-Za-z]$//'`
2056                 elif $test -x /usr/etc/version; then
2057                         osvers=`/usr/etc/version | $awk '{print $2}' |
2058                         $sed -e 's/[A-Za-z]$//'`
2059                 else
2060                         osvers="$2.$3"
2061                 fi
2062         fi
2063        $test -f /sys/posix.dll &&
2064                $test -f /usr/bin/what &&
2065                set X `/usr/bin/what /sys/posix.dll` &&
2066                $test "$3" = UWIN &&
2067                osname=uwin &&
2068                osvers="$5"
2069         if $test -f $uname; then
2070                 set X $myuname
2071                 shift
2072
2073                 case "$5" in
2074                 fps*) osname=fps ;;
2075                 mips*)
2076                         case "$4" in
2077                         umips) osname=umips ;;
2078                         *) osname=mips ;;
2079                         esac;;
2080                 [23]100) osname=mips ;;
2081                 next*) osname=next ;;
2082                 i386*)
2083                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2084                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2085                                 osname='sco'
2086                                 osvers=$tmp
2087                         elif $test -f /etc/kconfig; then
2088                                 osname=isc
2089                                 if test "$lns" = "ln -s"; then
2090                                         osvers=4
2091                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2092                                         osvers=3
2093                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2094                                         osvers=2
2095                                 fi
2096                         fi
2097                         unset tmp
2098                         ;;
2099                 pc*)
2100                         if test -n "$DJGPP"; then
2101                                 osname=dos
2102                                 osvers=djgpp
2103                         fi
2104                         ;;
2105                 esac
2106
2107                 case "$1" in
2108                 aix) osname=aix
2109                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2110                         case "$tmp" in
2111                         'not found') osvers="$4"."$3" ;;
2112                         '<3240'|'<>3240') osvers=3.2.0 ;;
2113                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2114                         '=3250'|'>3250') osvers=3.2.5 ;;
2115                         *) osvers=$tmp;;
2116                         esac
2117                         ;;
2118                 *dc.osx) osname=dcosx
2119                         osvers="$3"
2120                         ;;
2121                 dnix) osname=dnix
2122                         osvers="$3"
2123                         ;;
2124                 domainos) osname=apollo
2125                         osvers="$3"
2126                         ;;
2127                 dgux) osname=dgux 
2128                         osvers="$3"
2129                         ;;
2130                 dynixptx*) osname=dynixptx
2131                         osvers=`echo "$4"|sed 's/^v//'`
2132                         ;;
2133                 freebsd) osname=freebsd 
2134                         osvers="$3" ;;
2135                 genix) osname=genix ;;
2136                 hp*) osname=hpux 
2137                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2138                         ;;
2139                 irix*) osname=irix
2140                         case "$3" in
2141                         4*) osvers=4 ;;
2142                         5*) osvers=5 ;;
2143                         *)      osvers="$3" ;;
2144                         esac
2145                         ;;
2146                 linux) osname=linux
2147                         case "$3" in
2148                         *)      osvers="$3" ;;
2149                         esac
2150                         ;;
2151                 MiNT) osname=mint
2152                         ;;
2153                 netbsd*) osname=netbsd
2154                         osvers="$3"
2155                         ;;
2156                 news-os) osvers="$3"
2157                         case "$3" in
2158                         4*) osname=newsos4 ;;
2159                         *) osname=newsos ;;
2160                         esac
2161                         ;;
2162                 bsd386) osname=bsd386
2163                         osvers=`$uname -r`
2164                         ;;
2165                 POSIX-BC | posix-bc ) osname=posix-bc
2166                         osvers="$3"
2167                         ;;
2168                 powerux | power_ux | powermax_os | powermaxos | \
2169                 powerunix | power_unix) osname=powerux
2170                         osvers="$3"
2171                         ;;
2172                 next*) osname=next ;;
2173                 solaris) osname=solaris
2174                         case "$3" in
2175                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2176                         *)      osvers="$3" ;;
2177                         esac
2178                         ;;
2179                 sunos) osname=sunos
2180                         case "$3" in
2181                         5*) osname=solaris
2182                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2183                         *)      osvers="$3" ;;
2184                         esac
2185                         ;;
2186                 titanos) osname=titanos
2187                         case "$3" in
2188                         1*) osvers=1 ;;
2189                         2*) osvers=2 ;;
2190                         3*) osvers=3 ;;
2191                         4*) osvers=4 ;;
2192                         *)      osvers="$3" ;;
2193                         esac
2194                         ;;
2195                 ultrix) osname=ultrix
2196                         osvers="$3"
2197                         ;;
2198                 osf1|mls+)      case "$5" in
2199                                 alpha)
2200                                         osname=dec_osf
2201                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2202                                         ;;
2203                         hp*)    osname=hp_osf1  ;;
2204                         mips)   osname=mips_osf1 ;;
2205                         esac
2206                         ;;
2207                 uts) osname=uts 
2208                         osvers="$3"
2209                         ;;
2210                 qnx) osname=qnx
2211                         osvers="$4"
2212                         ;;
2213                 $2) case "$osname" in
2214                         *isc*) ;;
2215                         *freebsd*) ;;
2216                         svr*)
2217                                 : svr4.x or possibly later
2218                                 case "svr$3" in 
2219                                 ${osname}*)
2220                                         osname=svr$3
2221                                         osvers=$4
2222                                         ;;
2223                                 esac
2224                                 case "$osname" in
2225                                 svr4.0)
2226                                         : Check for ESIX
2227                                         if test -f /stand/boot ; then
2228                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2229                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2230                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2231                                                         if test -n "$isesix"; then
2232                                                                 osname=esix4
2233                                                         fi
2234                                                 fi
2235                                         fi
2236                                         ;;
2237                                 esac
2238                                 ;;
2239                         *)      if test -f /etc/systemid; then
2240                                         osname=sco
2241                                         set `echo $3 | $sed 's/\./ /g'` $4
2242                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2243                                                 osvers=$1.$2.$3
2244                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2245                                                 osvers=$1.$2
2246                                         elif $test -f $src/hints/sco_$1.sh; then
2247                                                 osvers=$1
2248                                         fi
2249                                 else
2250                                         case "$osname" in
2251                                         '') : Still unknown.  Probably a generic Sys V.
2252                                                 osname="sysv"
2253                                                 osvers="$3"
2254                                                 ;;
2255                                         esac
2256                                 fi
2257                                 ;;
2258                         esac
2259                         ;;
2260                 *)      case "$osname" in
2261                         '') : Still unknown.  Probably a generic BSD.
2262                                 osname="$1"
2263                                 osvers="$3"
2264                                 ;;
2265                         esac
2266                         ;;
2267                 esac
2268         else
2269                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2270                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2271                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2272                                 osname=news_os
2273                         fi
2274                         $rm -f UU/kernel.what
2275                 elif test -d c:/.; then
2276                         set X $myuname
2277                         osname=os2
2278                         osvers="$5"
2279                 fi
2280         fi
2281         
2282         : Now look for a hint file osname_osvers, unless one has been
2283         : specified already.
2284         case "$hintfile" in
2285         ''|' ')
2286                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2287                 : Also try without trailing minor version numbers.
2288                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2289                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2290                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2291                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2292                 case "$file" in
2293                 '') dflt=none ;;
2294                 *)  case "$osvers" in
2295                         '') dflt=$file
2296                                 ;;
2297                         *)  if $test -f $src/hints/$file.sh ; then
2298                                         dflt=$file
2299                                 elif $test -f $src/hints/$xfile.sh ; then
2300                                         dflt=$xfile
2301                                 elif $test -f $src/hints/$xxfile.sh ; then
2302                                         dflt=$xxfile
2303                                 elif $test -f $src/hints/$xxxfile.sh ; then
2304                                         dflt=$xxxfile
2305                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2306                                         dflt=$xxxxfile
2307                                 elif $test -f "$src/hints/${osname}.sh" ; then
2308                                         dflt="${osname}"
2309                                 else
2310                                         dflt=none
2311                                 fi
2312                                 ;;
2313                         esac
2314                         ;;
2315                 esac
2316                 if $test -f Policy.sh ; then
2317                         case "$dflt" in
2318                         *Policy*) ;;
2319                         none) dflt="Policy" ;;
2320                         *) dflt="Policy $dflt" ;;
2321                         esac
2322                 fi
2323                 ;;
2324         *)
2325                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2326                 ;;
2327         esac
2328
2329         if $test -f Policy.sh ; then
2330                 $cat <<EOM
2331
2332 There's also a Policy hint file available, which should make the
2333 site-specific (policy) questions easier to answer.
2334 EOM
2335
2336         fi
2337
2338         $cat <<EOM
2339
2340 You may give one or more space-separated answers, or "none" if appropriate.
2341 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2342 is a good thing.  DO NOT give a wrong version.
2343
2344 EOM
2345
2346         rp="Which of these apply, if any?"
2347         . UU/myread
2348         tans=$ans
2349         for file in $tans; do
2350                 if $test X$file = XPolicy -a -f Policy.sh; then
2351                         . Policy.sh
2352                         $cat Policy.sh >> UU/config.sh
2353                 elif $test -f $src/hints/$file.sh; then
2354                         . $src/hints/$file.sh
2355                         $cat $src/hints/$file.sh >> UU/config.sh
2356                 elif $test X$tans = X -o X$tans = Xnone ; then
2357                         : nothing
2358                 else
2359                         : Give one chance to correct a possible typo.
2360                         echo "$file.sh does not exist"
2361                         dflt=$file
2362                         rp="hint to use instead?"
2363                         . UU/myread
2364                         for file in $ans; do
2365                                 if $test -f "$src/hints/$file.sh"; then
2366                                         . $src/hints/$file.sh
2367                                         $cat $src/hints/$file.sh >> UU/config.sh
2368                                 elif $test X$ans = X -o X$ans = Xnone ; then
2369                                         : nothing
2370                                 else
2371                                         echo "$file.sh does not exist -- ignored."
2372                                 fi
2373                         done
2374                 fi
2375         done
2376
2377         hint=recommended
2378         : Remember our hint file for later.
2379         if $test -f "$src/hints/$file.sh" ; then
2380                 hintfile="$file"
2381         else
2382                 hintfile=''
2383         fi
2384 fi
2385 cd UU
2386 ;;
2387 *)
2388         echo " "
2389         echo "Fetching default answers from $config_sh..." >&4
2390         tmp_n="$n"
2391         tmp_c="$c"
2392         cd ..
2393         cp $config_sh config.sh 2>/dev/null
2394         chmod +w config.sh
2395         . ./config.sh
2396         cd UU
2397         cp ../config.sh .
2398         n="$tmp_n"
2399         c="$tmp_c"
2400         hint=previous
2401         ;;
2402 esac
2403 test "$override" && . ./optdef.sh
2404 myuname="$newmyuname"
2405
2406 : Restore computed paths
2407 for file in $loclist $trylist; do
2408         eval $file="\$_$file"
2409 done
2410
2411 cat << EOM
2412
2413 Configure uses the operating system name and version to set some defaults.
2414 The default value is probably right if the name rings a bell. Otherwise,
2415 since spelling matters for me, either accept the default or answer "none"
2416 to leave it blank.
2417
2418 EOM
2419 case "$osname" in
2420         ''|' ')
2421                 case "$hintfile" in
2422                 ''|' '|none) dflt=none ;;
2423                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2424                 esac
2425                 ;;
2426         *) dflt="$osname" ;;
2427 esac
2428 rp="Operating system name?"
2429 . ./myread
2430 case "$ans" in
2431 none)  osname='' ;;
2432 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2433 esac
2434 echo " "
2435 case "$osvers" in
2436         ''|' ')
2437                 case "$hintfile" in
2438                 ''|' '|none) dflt=none ;;
2439                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2440                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2441                         case "$dflt" in
2442                         ''|' ') dflt=none ;;
2443                         esac
2444                         ;;
2445                 esac
2446                 ;;
2447         *) dflt="$osvers" ;;
2448 esac
2449 rp="Operating system version?"
2450 . ./myread
2451 case "$ans" in
2452 none)  osvers='' ;;
2453 *) osvers="$ans" ;;
2454 esac
2455
2456 : who configured the system
2457 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2458 cf_by=`(logname) 2>/dev/null`
2459 case "$cf_by" in
2460 "")
2461         cf_by=`(whoami) 2>/dev/null`
2462         case "$cf_by" in
2463         "") cf_by=unknown ;;
2464         esac ;;
2465 esac
2466
2467 : set up the script used to warn in case of inconsistency
2468 cat <<EOS >whoa
2469 $startsh
2470 EOS
2471 cat <<'EOSC' >>whoa
2472 dflt=y
2473 echo " "
2474 echo "*** WHOA THERE!!! ***" >&4
2475 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2476 rp="    Keep the $hint value?"
2477 . ./myread
2478 case "$ans" in
2479 y) td=$was; tu=$was;;
2480 esac
2481 EOSC
2482
2483 : function used to set $1 to $val
2484 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2485 case "$val$was" in
2486 $define$undef) . ./whoa; eval "$var=\$td";;
2487 $undef$define) . ./whoa; eval "$var=\$tu";;
2488 *) eval "$var=$val";;
2489 esac'
2490
2491 cat <<EOM
2492
2493 Perl can be built to take advantage of threads, on some systems.
2494 To do so, Configure must be run with -Dusethreads.
2495
2496 Note that threading is a highly experimental feature, and
2497 some known race conditions still remain.  If you choose to try
2498 it, be very sure to not actually deploy it for production
2499 purposes.  README.threads has more details, and is required
2500 reading if you enable threads.
2501 EOM
2502 case "$usethreads" in
2503 $define|true|[yY]*)     dflt='y';;
2504 *) dflt='n';;
2505 esac
2506 rp='Build a threading Perl?'
2507 . ./myread
2508 case "$ans" in
2509 y|Y)    val="$define" ;;     
2510 *)      val="$undef" ;;
2511 esac
2512 set usethreads
2513 eval $setvar 
2514
2515 case "$d_oldpthreads" in
2516 '')     : Configure tests would be welcome here.  For now, assume undef.
2517         val="$undef" ;;
2518 *)      val="$d_oldpthreads" ;;
2519 esac
2520 set d_oldpthreads
2521 eval $setvar
2522
2523
2524 case "$usethreads" in
2525 "$define"|true|[yY]*)
2526 : Look for a hint-file generated 'call-back-unit'.  If the
2527 : user has specified that a threading perl is to be built,
2528 : we may need to set or change some other defaults.
2529         if $test -f usethreads.cbu; then
2530                 . ./usethreads.cbu
2531         fi
2532         case "$osname" in
2533         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2534                 # Known thread-capable platforms.
2535                 ;;
2536         *)
2537                 cat >&4 <<EOM
2538 $osname is not known to support threads.
2539 Please let perlbug@perl.com know how to do that.
2540
2541 Cannot continue, aborting.
2542 EOM
2543                 exit 1
2544         ;;
2545         esac # $osname
2546     ;;
2547 esac # $usethreads
2548
2549 cat <<EOM
2550
2551 Perl can be built so that multiple Perl interpreters can coexist
2552 within the same Perl executable.  To do so, Configure must be run with
2553 -Dusemultiplicity.
2554
2555 Normally you do not need this and you should answer no.
2556
2557 EOM
2558 case "$usemultiplicity" in
2559 $define|true|[yY]*)     dflt='y';;
2560 *) dflt='n';;
2561 esac
2562 rp='Build Perl for multiplicity?'
2563 . ./myread
2564 case "$ans" in
2565 y|Y)    val="$define" ;;     
2566 *)      val="$undef" ;;
2567 esac
2568 set usemultiplicity
2569 eval $setvar 
2570
2571 cat <<EOM
2572
2573 Perl can be built to take advantage of explicit 64-bit interfaces,
2574 on some systems.  To do so, Configure must be run with -Duse64bits.
2575
2576 If this doesn't make any sense to you, just accept the default 'n'.
2577 EOM
2578 case "$use64bits" in
2579 $define|true|[yY]*)     dflt='y';;
2580 *) dflt='n';;
2581 esac
2582 rp='Try to use explicit 64-bit interfaces, if available?'
2583 . ./myread
2584 case "$ans" in
2585 y|Y) 
2586         val="$define"
2587         ;;     
2588 *)      
2589         val="$undef"
2590         ;;
2591 esac
2592 set use64bits
2593 eval $setvar
2594
2595 case "$archname64" in
2596 '') archname64='' ;;    # not a typo
2597 esac
2598
2599 case "$use64bits" in
2600 "$define"|true|[yY]*)
2601 : Look for a hint-file generated 'call-back-unit'.  If the
2602 : user has specified that a threading perl is to be built,
2603 : we may need to set or change some other defaults.
2604         if $test -f use64bits.cbu; then
2605                 . ./use64bits.cbu
2606         fi
2607         case "$osname" in
2608         dec_osf|hpux|irix|solaris|unicos)
2609                 # Known 64-bit capable platforms.
2610                 ;;
2611         *)
2612                 cat >&4 <<EOM
2613 $osname is not known to support 64-bit interfaces.
2614 Please let perlbug@perl.com know how to do that.
2615
2616 Cannot continue, aborting.
2617 EOM
2618                 exit 1
2619                 ;;
2620         esac
2621         ;;
2622 esac
2623
2624 : determine the architecture name
2625 echo " "
2626 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2627         tarch=`arch`"-$osname"
2628 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2629         if uname -m > tmparch 2>&1 ; then
2630                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2631                         -e 's/$/'"-$osname/" tmparch`
2632         else
2633                 tarch="$osname"
2634         fi
2635         $rm -f tmparch
2636 else
2637         tarch="$osname"
2638 fi
2639 case "$myarchname" in
2640 ''|"$tarch") ;;
2641 *)
2642         echo "(Your architecture name used to be $myarchname.)"
2643         archname=''
2644         ;;
2645 esac
2646 myarchname="$tarch"
2647 case "$archname" in
2648 '') dflt="$tarch";;
2649 *) dflt="$archname";;
2650 esac
2651 rp='What is your architecture name'
2652 . ./myread
2653 archname="$ans"
2654 case "$usethreads" in
2655 $define)
2656         echo "Threads selected." >&4
2657         case "$archname" in
2658         *-thread*) echo "...and architecture name already has -thread." >&4
2659                 ;;
2660         *)      archname="$archname-thread"
2661                 echo "...setting architecture name to $archname." >&4
2662                 ;;
2663         esac
2664         ;;
2665 esac
2666 case "$usemultiplicity" in
2667 $define)
2668         echo "Multiplicity selected." >&4
2669         case "$archname" in
2670         *-multi*) echo "...and architecture name already has -multi." >&4
2671                 ;;
2672         *)      archname="$archname-multi"
2673                 echo "...setting architecture name to $archname." >&4
2674                 ;;
2675         esac
2676         ;;
2677 esac
2678 case "$use64bits" in
2679 $define)
2680         echo "Explicit 64-bitness selected." >&4
2681         case "$archname64" in
2682         '')
2683                 ;;
2684         *)
2685                 case "$archname" in
2686                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2687                         ;;
2688                 *)      archname="$archname-$archname64"
2689                         echo "...setting architecture name to $archname." >&4
2690                         ;;
2691                 esac
2692                 ;;
2693         esac
2694 esac
2695
2696 : is AFS running?
2697 echo " "
2698 case "$afs" in
2699 $define|true)   afs=true ;;
2700 $undef|false)   afs=false ;;
2701 *)      if test -d /afs; then
2702                 afs=true
2703         else
2704                 afs=false
2705         fi
2706         ;;
2707 esac
2708 if $afs; then
2709         echo "AFS may be running... I'll be extra cautious then..." >&4
2710 else
2711         echo "AFS does not seem to be running..." >&4
2712 fi
2713
2714 : decide how portable to be.  Allow command line overrides.
2715 case "$d_portable" in
2716 "$undef") ;;
2717 *)      d_portable="$define" ;;
2718 esac
2719
2720 : set up shell script to do ~ expansion
2721 cat >filexp <<EOSS
2722 $startsh
2723 : expand filename
2724 case "\$1" in
2725  ~/*|~)
2726         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2727         ;;
2728  ~*)
2729         if $test -f /bin/csh; then
2730                 /bin/csh -f -c "glob \$1"
2731                 failed=\$?
2732                 echo ""
2733                 exit \$failed
2734         else
2735                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2736                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2737                 if $test ! -d "\$dir"; then
2738                         me=\`basename \$0\`
2739                         echo "\$me: can't locate home directory for: \$name" >&2
2740                         exit 1
2741                 fi
2742                 case "\$1" in
2743                 */*)
2744                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2745                         ;;
2746                 *)
2747                         echo \$dir
2748                         ;;
2749                 esac
2750         fi
2751         ;;
2752 *)
2753         echo \$1
2754         ;;
2755 esac
2756 EOSS
2757 chmod +x filexp
2758 $eunicefix filexp
2759
2760 : now set up to get a file name
2761 cat <<EOS >getfile
2762 $startsh
2763 EOS
2764 cat <<'EOSC' >>getfile
2765 tilde=''
2766 fullpath=''
2767 already=''
2768 skip=''
2769 none_ok=''
2770 exp_file=''
2771 nopath_ok=''
2772 orig_rp="$rp"
2773 orig_dflt="$dflt"
2774
2775 case "$fn" in
2776 *\(*)
2777         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2778         fn=`echo $fn | sed 's/(.*)//'`
2779         ;;
2780 esac
2781
2782 case "$fn" in
2783 *:*)
2784         loc_file=`expr $fn : '.*:\(.*\)'`
2785         fn=`expr $fn : '\(.*\):.*'`
2786         ;;
2787 esac
2788
2789 case "$fn" in
2790 *~*) tilde=true;;
2791 esac
2792 case "$fn" in
2793 */*) fullpath=true;;
2794 esac
2795 case "$fn" in
2796 *+*) skip=true;;
2797 esac
2798 case "$fn" in
2799 *n*) none_ok=true;;
2800 esac
2801 case "$fn" in
2802 *e*) exp_file=true;;
2803 esac
2804 case "$fn" in
2805 *p*) nopath_ok=true;;
2806 esac
2807
2808 case "$fn" in
2809 *f*) type='File';;
2810 *d*) type='Directory';;
2811 *l*) type='Locate';;
2812 esac
2813
2814 what="$type"
2815 case "$what" in
2816 Locate) what='File';;
2817 esac
2818
2819 case "$exp_file" in
2820 '')
2821         case "$d_portable" in
2822         "$define") ;;
2823         *) exp_file=true;;
2824         esac
2825         ;;
2826 esac
2827
2828 cd ..
2829 while test "$type"; do
2830         redo=''
2831         rp="$orig_rp"
2832         dflt="$orig_dflt"
2833         case "$tilde" in
2834         true) rp="$rp (~name ok)";;
2835         esac
2836         . UU/myread
2837         if test -f UU/getfile.ok && \
2838                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2839         then
2840                 value="$ans"
2841                 ansexp="$ans"
2842                 break
2843         fi
2844         case "$ans" in
2845         none)
2846                 value=''
2847                 ansexp=''
2848                 case "$none_ok" in
2849                 true) type='';;
2850                 esac
2851                 ;;
2852         *)
2853                 case "$tilde" in
2854                 '') value="$ans"
2855                         ansexp="$ans";;
2856                 *)
2857                         value=`UU/filexp $ans`
2858                         case $? in
2859                         0)
2860                                 if test "$ans" != "$value"; then
2861                                         echo "(That expands to $value on this system.)"
2862                                 fi
2863                                 ;;
2864                         *) value="$ans";;
2865                         esac
2866                         ansexp="$value"
2867                         case "$exp_file" in
2868                         '') value="$ans";;
2869                         esac
2870                         ;;
2871                 esac
2872                 case "$fullpath" in
2873                 true)
2874                         case "$ansexp" in
2875                         /*) value="$ansexp" ;;
2876                         *)
2877                                 redo=true
2878                                 case "$already" in
2879                                 true)
2880                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2881                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2882                                         ;;
2883                                 *)
2884                                 echo "Please give a full path name, starting with slash." >&4
2885                                         case "$tilde" in
2886                                         true)
2887                                 echo "Note that using ~name is ok provided it expands well." >&4
2888                                                 already=true
2889                                                 ;;
2890                                         esac
2891                                 esac
2892                                 ;;
2893                         esac
2894                         ;;
2895                 esac
2896                 case "$redo" in
2897                 '')
2898                         case "$type" in
2899                         File)
2900                                 if test -f "$ansexp"; then
2901                                         type=''
2902                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2903                                 then
2904                                         echo "($value is not a plain file, but that's ok.)"
2905                                         type=''
2906                                 fi
2907                                 ;;
2908                         Directory)
2909                                 if test -d "$ansexp"; then
2910                                         type=''
2911                                 fi
2912                                 ;;
2913                         Locate)
2914                                 if test -d "$ansexp"; then
2915                                         echo "(Looking for $loc_file in directory $value.)"
2916                                         value="$value/$loc_file"
2917                                         ansexp="$ansexp/$loc_file"
2918                                 fi
2919                                 if test -f "$ansexp"; then
2920                                         type=''
2921                                 fi
2922                                 case "$nopath_ok" in
2923                                 true)   case "$value" in
2924                                         */*) ;;
2925                                         *)      echo "Assuming $value will be in people's path."
2926                                                 type=''
2927                                                 ;;
2928                                         esac
2929                                         ;;
2930                                 esac
2931                                 ;;
2932                         esac
2933
2934                         case "$skip" in
2935                         true) type='';
2936                         esac
2937
2938                         case "$type" in
2939                         '') ;;
2940                         *)
2941                                 if test "$fastread" = yes; then
2942                                         dflt=y
2943                                 else
2944                                         dflt=n
2945                                 fi
2946                                 rp="$what $value doesn't exist.  Use that name anyway?"
2947                                 . UU/myread
2948                                 dflt=''
2949                                 case "$ans" in
2950                                 y*) type='';;
2951                                 *) echo " ";;
2952                                 esac
2953                                 ;;
2954                         esac
2955                         ;;
2956                 esac
2957                 ;;
2958         esac
2959 done
2960 cd UU
2961 ans="$value"
2962 rp="$orig_rp"
2963 dflt="$orig_dflt"
2964 rm -f getfile.ok
2965 EOSC
2966
2967 : determine root of directory hierarchy where package will be installed.
2968 case "$prefix" in
2969 '')
2970         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2971         ;;
2972 *)
2973         dflt="$prefix"
2974         ;;
2975 esac
2976 $cat <<EOM
2977
2978 By default, $package will be installed in $dflt/bin, manual
2979 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
2980 all installation directories. Typically set to /usr/local, but you
2981 may choose /usr if you wish to install $package among your system
2982 binaries. If you wish to have binaries under /bin but manual pages
2983 under /usr/local/man, that's ok: you will be prompted separately
2984 for each of the installation directories, the prefix being only used
2985 to set the defaults.
2986
2987 EOM
2988 fn=d~
2989 rp='Installation prefix to use?'
2990 . ./getfile
2991 oldprefix=''
2992 case "$prefix" in
2993 '') ;;
2994 *)
2995         case "$ans" in
2996         "$prefix") ;;
2997         *) oldprefix="$prefix";;
2998         esac
2999         ;;
3000 esac
3001 prefix="$ans"
3002 prefixexp="$ansexp"
3003
3004 : set the prefixit variable, to compute a suitable default value
3005 prefixit='case "$3" in
3006 ""|none)
3007         case "$oldprefix" in
3008         "") eval "$1=\"\$$2\"";;
3009         *)
3010                 case "$3" in
3011                 "") eval "$1=";;
3012                 none)
3013                         eval "tp=\"\$$2\"";
3014                         case "$tp" in
3015                         ""|" ") eval "$1=\"\$$2\"";;
3016                         *) eval "$1=";;
3017                         esac;;
3018                 esac;;
3019         esac;;
3020 *)
3021         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3022         case "$tp" in
3023         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3024         /*-$oldprefix/*|\~*-$oldprefix/*)
3025                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3026         *) eval "$1=\"\$$2\"";;
3027         esac;;
3028 esac'
3029
3030 : set the base revision
3031 baserev=5.0
3032
3033 : get the patchlevel
3034 echo " "
3035 echo "Getting the current patchlevel..." >&4
3036 if $test -r $rsrc/patchlevel.h;then
3037         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3038         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3039 else
3040         patchlevel=0
3041         subversion=0
3042 fi
3043 $echo $n "(You have $package" $c
3044 case "$package" in
3045 "*$baserev")    ;;
3046 *)              $echo $n " $baserev" $c ;;
3047 esac
3048 $echo $n " patchlevel $patchlevel" $c
3049 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3050 echo ".)"
3051
3052 if test 0 -eq "$subversion"; then
3053         version=`LC_ALL=C; export LC_ALL; \
3054                  echo $baserev $patchlevel | \
3055                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3056 else
3057         version=`LC_ALL=C; export LC_ALL; \
3058                  echo $baserev $patchlevel $subversion | \
3059                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3060 fi
3061 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3062 if test "$subversion" -lt 50; then
3063         apiversion=`LC_ALL=C; export LC_ALL; \
3064                  LANGUAGE=C; export LANGUAGE; \
3065                  echo $baserev $patchlevel | \
3066                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3067 else
3068         apiversion="$version"
3069 fi
3070
3071 : determine where private library files go
3072 : Usual default is /usr/local/lib/perl5/$version.
3073 : Also allow things like /opt/perl/lib/$version, since 
3074 : /opt/perl/lib/perl5... would be redundant.
3075 case "$prefix" in
3076 *perl*) set dflt privlib lib/$version ;;
3077 *)       set dflt privlib lib/$package/$version ;;
3078 esac
3079 eval $prefixit
3080 $cat <<EOM
3081
3082 There are some auxiliary files for $package that need to be put into a
3083 private library directory that is accessible by everyone.
3084
3085 EOM
3086 fn=d~+
3087 rp='Pathname where the private library files will reside?'
3088 . ./getfile
3089 if $test "X$privlibexp" != "X$ansexp"; then
3090         installprivlib=''
3091 fi
3092 privlib="$ans"
3093 privlibexp="$ansexp"
3094 if $afs; then
3095         $cat <<EOM
3096
3097 Since you are running AFS, I need to distinguish the directory in which
3098 private files reside from the directory in which they are installed (and from
3099 which they are presumably copied to the former directory by occult means).
3100
3101 EOM
3102         case "$installprivlib" in
3103         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3104         *) dflt="$installprivlib";;
3105         esac
3106         fn=de~
3107         rp='Where will private files be installed?'
3108         . ./getfile
3109         installprivlib="$ans"
3110 else
3111         installprivlib="$privlibexp"
3112 fi
3113
3114 : set the prefixup variable, to restore leading tilda escape
3115 prefixup='case "$prefixexp" in
3116 "$prefix") ;;
3117 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3118 esac'
3119
3120 : determine where public architecture dependent libraries go
3121 set archlib archlib
3122 eval $prefixit
3123 : privlib default is /usr/local/lib/$package/$version
3124 : archlib default is /usr/local/lib/$package/$version/$archname
3125 : privlib may have an optional trailing /share.
3126 tdflt=`echo $privlib | $sed 's,/share$,,'`
3127 tdflt=$tdflt/$archname
3128 case "$archlib" in
3129 '')     dflt=$tdflt
3130         ;;
3131 *)      dflt="$archlib"
3132     ;;
3133 esac
3134 cat <<EOM
3135
3136 $spackage contains architecture-dependent library files.  If you are
3137 sharing libraries in a heterogeneous environment, you might store
3138 these files in a separate location.  Otherwise, you can just include
3139 them with the rest of the public library files.
3140
3141 EOM
3142 fn=d+~
3143 rp='Where do you want to put the public architecture-dependent libraries?'
3144 . ./getfile
3145 archlib="$ans"
3146 archlibexp="$ansexp"
3147
3148 if $afs; then
3149         $cat <<EOM
3150
3151 Since you are running AFS, I need to distinguish the directory in
3152 which architecture-dependent library files reside from the directory
3153 in which they are installed (and from which they are presumably copied
3154 to the former directory by occult means).
3155
3156 EOM
3157         case "$installarchlib" in
3158         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3159         *) dflt="$installarchlib";;
3160         esac
3161         fn=de~
3162         rp='Where will architecture-dependent library files be installed?'
3163         . ./getfile
3164         installarchlib="$ans"
3165 else
3166         installarchlib="$archlibexp"
3167 fi
3168 if $test X"$archlib" = X"$privlib"; then
3169         d_archlib="$undef"
3170 else
3171         d_archlib="$define"
3172 fi
3173
3174 : make some quick guesses about what we are up against
3175 echo " "
3176 $echo $n "Hmm...  $c"
3177 echo exit 1 >bsd
3178 echo exit 1 >usg
3179 echo exit 1 >v7
3180 echo exit 1 >osf1
3181 echo exit 1 >eunice
3182 echo exit 1 >xenix
3183 echo exit 1 >venix
3184 echo exit 1 >os2
3185 d_bsd="$undef"
3186 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3187 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3188 then
3189         echo "Looks kind of like an OSF/1 system, but we'll see..."
3190         echo exit 0 >osf1
3191 elif test `echo abc | tr a-z A-Z` = Abc ; then
3192         xxx=`./loc addbib blurfl $pth`
3193         if $test -f $xxx; then
3194         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3195                 echo exit 0 >bsd
3196                 echo exit 0 >usg
3197         else
3198                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3199                         echo "Looks kind of like an extended USG system, but we'll see..."
3200                 else
3201                         echo "Looks kind of like a USG system, but we'll see..."
3202                 fi
3203                 echo exit 0 >usg
3204         fi
3205 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3206         echo "Looks kind of like a BSD system, but we'll see..."
3207         d_bsd="$define"
3208         echo exit 0 >bsd
3209 else
3210         echo "Looks kind of like a Version 7 system, but we'll see..."
3211         echo exit 0 >v7
3212 fi
3213 case "$eunicefix" in
3214 *unixtovms*)
3215         $cat <<'EOI'
3216 There is, however, a strange, musty smell in the air that reminds me of
3217 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3218 EOI
3219         echo exit 0 >eunice
3220         d_eunice="$define"
3221 : it so happens the Eunice I know will not run shell scripts in Unix format
3222         ;;
3223 *)
3224         echo " "
3225         echo "Congratulations.  You aren't running Eunice."
3226         d_eunice="$undef"
3227         ;;
3228 esac
3229 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3230 case "$p_" in
3231 :) ;;
3232 *)
3233         $cat <<'EOI'
3234 I have the feeling something is not exactly right, however...don't tell me...
3235 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3236 EOI
3237         echo exit 0 >os2
3238         ;;
3239 esac
3240 if test -f /xenix; then
3241         echo "Actually, this looks more like a XENIX system..."
3242         echo exit 0 >xenix
3243         d_xenix="$define"
3244 else
3245         echo " "
3246         echo "It's not Xenix..."
3247         d_xenix="$undef"
3248 fi
3249 chmod +x xenix
3250 $eunicefix xenix
3251 if test -f /venix; then
3252         echo "Actually, this looks more like a VENIX system..."
3253         echo exit 0 >venix
3254 else
3255         echo " "
3256         if ./xenix; then
3257                 : null
3258         else
3259                 echo "Nor is it Venix..."
3260         fi
3261 fi
3262 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3263 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3264 $rm -f foo
3265
3266 : see if setuid scripts can be secure
3267 $cat <<EOM
3268
3269 Some kernels have a bug that prevents setuid #! scripts from being
3270 secure.  Some sites have disabled setuid #! scripts because of this.
3271
3272 First let's decide if your kernel supports secure setuid #! scripts.
3273 (If setuid #! scripts would be secure but have been disabled anyway,
3274 don't say that they are secure if asked.)
3275
3276 EOM
3277
3278 val="$undef"
3279 if $test -d /dev/fd; then
3280         echo "#!$ls" >reflect
3281         chmod +x,u+s reflect
3282         ./reflect >flect 2>&1
3283         if $contains "/dev/fd" flect >/dev/null; then
3284                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3285                 val="$define"
3286         else
3287                 $cat <<EOM
3288 If you are not sure if they are secure, I can check but I'll need a
3289 username and password different from the one you are using right now.
3290 If you don't have such a username or don't want me to test, simply
3291 enter 'none'.
3292
3293 EOM
3294                 rp='Other username to test security of setuid scripts with?'
3295                 dflt='none'
3296                 . ./myread
3297                 case "$ans" in
3298                 n|none)
3299                         case "$d_suidsafe" in
3300                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3301                                 dflt=n;;
3302                         "$undef")
3303                                 echo "Well, the $hint value is *not* secure." >&4
3304                                 dflt=n;;
3305                         *)      echo "Well, the $hint value *is* secure." >&4
3306                                 dflt=y;;
3307                         esac
3308                         ;;
3309                 *)
3310                         $rm -f reflect flect
3311                         echo "#!$ls" >reflect
3312                         chmod +x,u+s reflect
3313                         echo >flect
3314                         chmod a+w flect
3315                         echo '"su" will (probably) prompt you for '"$ans's password."
3316                         su $ans -c './reflect >flect'
3317                         if $contains "/dev/fd" flect >/dev/null; then
3318                                 echo "Okay, it looks like setuid scripts are secure." >&4
3319                                 dflt=y
3320                         else
3321                                 echo "I don't think setuid scripts are secure." >&4
3322                                 dflt=n
3323                         fi
3324                         ;;
3325                 esac
3326                 rp='Does your kernel have *secure* setuid scripts?'
3327                 . ./myread
3328                 case "$ans" in
3329                 [yY]*)  val="$define";;
3330                 *)      val="$undef";;
3331                 esac
3332         fi
3333 else
3334         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3335         echo "(That's for file descriptors, not floppy disks.)"
3336         val="$undef"
3337 fi
3338 set d_suidsafe
3339 eval $setvar
3340
3341 $rm -f reflect flect
3342
3343 : now see if they want to do setuid emulation
3344 echo " "
3345 val="$undef"
3346 case "$d_suidsafe" in
3347 "$define")
3348         val="$undef"
3349         echo "No need to emulate SUID scripts since they are secure here." >& 4
3350         ;;
3351 *)
3352         $cat <<EOM
3353 Some systems have disabled setuid scripts, especially systems where
3354 setuid scripts cannot be secure.  On systems where setuid scripts have
3355 been disabled, the setuid/setgid bits on scripts are currently
3356 useless.  It is possible for $package to detect those bits and emulate
3357 setuid/setgid in a secure fashion.  This emulation will only work if
3358 setuid scripts have been disabled in your kernel.
3359
3360 EOM
3361         case "$d_dosuid" in
3362         "$define") dflt=y ;;
3363         *) dflt=n ;;
3364         esac
3365         rp="Do you want to do setuid/setgid emulation?"
3366         . ./myread
3367         case "$ans" in
3368         [yY]*)  val="$define";;
3369         *)      val="$undef";;
3370         esac
3371         ;;
3372 esac
3373 set d_dosuid
3374 eval $setvar
3375
3376 : determine where manual pages are on this system
3377 echo " "
3378 case "$sysman" in
3379 '') 
3380         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3381         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3382         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3383         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3384         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3385         sysman=`./loc . /usr/man/man1 $syspath`
3386         ;;
3387 esac
3388 if $test -d "$sysman"; then
3389         echo "System manual is in $sysman." >&4
3390 else
3391         echo "Could not find manual pages in source form." >&4
3392 fi
3393
3394 : see what memory models we can support
3395 case "$models" in
3396 '')
3397         $cat >pdp11.c <<'EOP'
3398 int main() {
3399 #ifdef pdp11
3400         exit(0);
3401 #else
3402         exit(1);
3403 #endif
3404 }
3405 EOP
3406         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3407         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3408                 dflt='unsplit split'
3409         else
3410                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3411                 case "$tans" in
3412                 X) dflt='none';;
3413                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3414                                 dflt='small'
3415                         else
3416                                 dflt=''
3417                         fi
3418                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3419                                 dflt="$dflt medium"
3420                         fi
3421                         if $test -d /lib/large || $test -d /usr/lib/large; then
3422                                 dflt="$dflt large"
3423                         fi
3424                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3425                                 dflt="$dflt huge"
3426                         fi
3427                 esac
3428         fi;;
3429 *) dflt="$models";;
3430 esac
3431 $cat <<EOM
3432  
3433 Some systems have different model sizes.  On most systems they are called
3434 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3435 split.  If your system doesn't support different memory models, say "none".
3436 If you wish to force everything to one memory model, say "none" here and
3437 put the appropriate flags later when it asks you for other cc and ld flags.
3438 Venix systems may wish to put "none" and let the compiler figure things out.
3439 (In the following question multiple model names should be space separated.)
3440
3441 The default for most systems is "none".
3442
3443 EOM
3444 rp="Which memory models are supported?"
3445 . ./myread
3446 models="$ans"
3447
3448 case "$models" in
3449 none)
3450         small=''
3451         medium=''
3452         large=''
3453         huge=''
3454         unsplit=''
3455         split=''
3456         ;;
3457 *split)
3458         case "$split" in
3459         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3460                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3461                         dflt='-i'
3462                 else
3463                         dflt='none'
3464                 fi;;
3465         *) dflt="$split";;
3466         esac
3467         rp="What flag indicates separate I and D space?"
3468         . ./myread
3469         tans="$ans"
3470         case "$tans" in
3471         none) tans='';;
3472         esac
3473         split="$tans"
3474         unsplit='';;
3475 *large*|*small*|*medium*|*huge*)
3476         case "$models" in
3477         *large*)
3478                 case "$large" in
3479                 '') dflt='-Ml';;
3480                 *) dflt="$large";;
3481                 esac
3482         rp="What flag indicates large model?"
3483         . ./myread
3484         tans="$ans"
3485         case "$tans" in
3486         none) tans='';
3487         esac
3488         large="$tans";;
3489         *) large='';;
3490         esac
3491         case "$models" in
3492         *huge*) case "$huge" in
3493                 '') dflt='-Mh';;
3494                 *) dflt="$huge";;
3495                 esac
3496                 rp="What flag indicates huge model?"
3497                 . ./myread
3498                 tans="$ans"
3499                 case "$tans" in
3500                 none) tans='';
3501                 esac
3502                 huge="$tans";;
3503         *) huge="$large";;
3504         esac
3505         case "$models" in
3506         *medium*) case "$medium" in
3507                 '') dflt='-Mm';;
3508                 *) dflt="$medium";;
3509                 esac
3510                 rp="What flag indicates medium model?"
3511                 . ./myread
3512                 tans="$ans"
3513                 case "$tans" in
3514                 none) tans='';
3515                 esac
3516                 medium="$tans";;
3517         *) medium="$large";;
3518         esac
3519         case "$models" in
3520         *small*) case "$small" in
3521                 '') dflt='none';;
3522                 *) dflt="$small";;
3523                 esac
3524                 rp="What flag indicates small model?"
3525                 . ./myread
3526                 tans="$ans"
3527                 case "$tans" in
3528                 none) tans='';
3529                 esac
3530                 small="$tans";;
3531         *) small='';;
3532         esac
3533         ;;
3534 *)
3535         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3536         ;;
3537 esac
3538 $rm -f pdp11.* pdp11
3539
3540 : see if we need a special compiler
3541 echo " "
3542 if ./usg; then
3543         case "$cc" in
3544         '') case "$Mcc" in
3545                 /*) dflt='Mcc';;
3546                 *) case "$large" in
3547                         -M*) dflt='cc';;
3548                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3549                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3550                                                 dflt='cc'
3551                                         else
3552                                                 dflt='cc -M'
3553                                         fi
3554                                 else
3555                                         dflt='cc'
3556                                 fi;;
3557                         esac;;
3558                 esac;;
3559         *)  dflt="$cc";;
3560         esac
3561         case "$dflt" in
3562         *M*)    $cat <<'EOM'
3563 On some older systems the default C compiler will not resolve multiple global
3564 references that happen to have the same name.  On some such systems the "Mcc"
3565 command may be used to force these to be resolved.  On other systems a "cc -M"
3566 command is required.  (Note that the -M flag on other systems indicates a
3567 memory model to use!) If you have the Gnu C compiler, you might wish to use
3568 that instead.
3569
3570 EOM
3571         ;;
3572         esac
3573         rp="Use which C compiler?"
3574         . ./myread
3575         cc="$ans"
3576 else
3577         case "$cc" in
3578         '') dflt=cc;;
3579         *) dflt="$cc";;
3580         esac
3581         rp="Use which C compiler?"
3582         . ./myread
3583         cc="$ans"
3584 fi
3585 : Look for a hint-file generated 'call-back-unit'.  Now that the
3586 : user has specified the compiler, we may need to set or change some
3587 : other defaults.
3588 if $test -f cc.cbu; then
3589     . ./cc.cbu
3590 fi
3591 echo " "
3592 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3593 $cat >gccvers.c <<EOM
3594 #include <stdio.h>
3595 int main() {
3596 #ifdef __GNUC__
3597 #ifdef __VERSION__
3598         printf("%s\n", __VERSION__);
3599 #else
3600         printf("%s\n", "1");
3601 #endif
3602 #endif
3603         exit(0);
3604 }
3605 EOM
3606 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
3607         gccversion=`./gccvers`
3608         case "$gccversion" in
3609         '') echo "You are not using GNU cc." ;;
3610         *)  echo "You are using GNU cc $gccversion." ;;
3611         esac
3612 else
3613         echo " "
3614         echo "*** WHOA THERE!!! ***" >&4
3615         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3616         case "$knowitall" in
3617         '')
3618         echo "    You'd better start hunting for one and let me know about it." >&4
3619                 exit 1
3620                 ;;
3621         esac
3622 fi
3623 $rm -f gccvers*
3624 case "$gccversion" in
3625 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3626 esac
3627
3628 : What should the include directory be ?
3629 echo " "
3630 $echo $n "Hmm...  $c"
3631 dflt='/usr/include'
3632 incpath=''
3633 mips_type=''
3634 if $test -f /bin/mips && /bin/mips; then
3635         echo "Looks like a MIPS system..."
3636         $cat >usr.c <<'EOCP'
3637 #ifdef SYSTYPE_BSD43
3638 /bsd43
3639 #endif
3640 EOCP
3641         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3642                 dflt='/bsd43/usr/include'
3643                 incpath='/bsd43'
3644                 mips_type='BSD 4.3'
3645         else
3646                 mips_type='System V'
3647         fi
3648         $rm -f usr.c usr.out
3649         echo "and you're compiling with the $mips_type compiler and libraries."
3650         xxx_prompt=y
3651         echo "exit 0" >mips
3652 else
3653         echo "Doesn't look like a MIPS system."
3654         xxx_prompt=n
3655         echo "exit 1" >mips
3656 fi
3657 chmod +x mips
3658 $eunicefix mips
3659 case "$usrinc" in
3660 '') ;;
3661 *) dflt="$usrinc";;
3662 esac
3663 case "$xxx_prompt" in
3664 y)      fn=d/
3665         echo " "
3666         rp='Where are the include files you want to use?'
3667         . ./getfile
3668         usrinc="$ans"
3669         ;;
3670 *)      usrinc="$dflt"
3671         ;;
3672 esac
3673
3674 : see how we invoke the C preprocessor
3675 echo " "
3676 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3677 cat <<'EOT' >testcpp.c
3678 #define ABC abc
3679 #define XYZ xyz
3680 ABC.XYZ
3681 EOT
3682 cd ..
3683 if test ! -f cppstdin; then
3684         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3685 else
3686         echo "Keeping your $hint cppstdin wrapper."
3687 fi
3688 chmod 755 cppstdin
3689 wrapper=`pwd`/cppstdin
3690 ok='false'
3691 cd UU
3692
3693 if $test "X$cppstdin" != "X" && \
3694         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3695         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3696 then
3697         echo "You used to use $cppstdin $cppminus so we'll use that again."
3698         case "$cpprun" in
3699         '') echo "But let's see if we can live without a wrapper..." ;;
3700         *)
3701                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3702                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3703                 then
3704                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3705                         ok='true'
3706                 else
3707                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3708                 fi
3709                 ;;
3710         esac
3711 else
3712         case "$cppstdin" in
3713         '') ;;
3714         *)
3715                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3716                 ;;
3717         esac
3718 fi
3719
3720 if $ok; then
3721         : nothing
3722 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3723         $cc -E <testcpp.c >testcpp.out 2>&1; \
3724         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3725         echo "Yup, it does."
3726         x_cpp="$cc -E"
3727         x_minus='';
3728 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3729         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3730         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3731         echo "Yup, it does."
3732         x_cpp="$cc -E"
3733         x_minus='-';
3734 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3735         $cc -P <testcpp.c >testcpp.out 2>&1; \
3736         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3737         echo "Yipee, that works!"
3738         x_cpp="$cc -P"
3739         x_minus='';
3740 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3741         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3742         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3743         echo "At long last!"
3744         x_cpp="$cc -P"
3745         x_minus='-';
3746 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3747         $cpp <testcpp.c >testcpp.out 2>&1; \
3748         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3749         echo "It works!"
3750         x_cpp="$cpp"
3751         x_minus='';
3752 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3753         $cpp - <testcpp.c >testcpp.out 2>&1; \
3754         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3755         echo "Hooray, it works!  I was beginning to wonder."
3756         x_cpp="$cpp"
3757         x_minus='-';
3758 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3759         $wrapper <testcpp.c >testcpp.out 2>&1; \
3760         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3761         x_cpp="$wrapper"
3762         x_minus=''
3763         echo "Eureka!"
3764 else
3765         dflt=''
3766         rp="No dice.  I can't find a C preprocessor.  Name one:"
3767         . ./myread
3768         x_cpp="$ans"
3769         x_minus=''
3770         $x_cpp <testcpp.c >testcpp.out 2>&1
3771         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3772                 echo "OK, that will do." >&4
3773         else
3774 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3775                 exit 1
3776         fi
3777 fi
3778
3779 case "$ok" in
3780 false)
3781         cppstdin="$x_cpp"
3782         cppminus="$x_minus"
3783         cpprun="$x_cpp"
3784         cpplast="$x_minus"
3785         set X $x_cpp
3786         shift
3787         case "$1" in
3788         "$cpp")
3789                 echo "Perhaps can we force $cc -E using a wrapper..."
3790                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3791                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3792                 then
3793                         echo "Yup, we can."
3794                         cppstdin="$wrapper"
3795                         cppminus='';
3796                 else
3797                         echo "Nope, we'll have to live without it..."
3798                 fi
3799                 ;;
3800         esac
3801         case "$cpprun" in
3802         "$wrapper")
3803                 cpprun=''
3804                 cpplast=''
3805                 ;;
3806         esac
3807         ;;
3808 esac
3809
3810 case "$cppstdin" in
3811 "$wrapper"|'cppstdin') ;;
3812 *) $rm -f $wrapper;;
3813 esac
3814 $rm -f testcpp.c testcpp.out
3815
3816 : Set private lib path
3817 case "$plibpth" in
3818 '') if ./mips; then
3819                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3820         fi;;
3821 esac
3822 case "$libpth" in
3823 ' ') dlist='';;
3824 '') dlist="$loclibpth $plibpth $glibpth";;
3825 *) dlist="$libpth";;
3826 esac
3827
3828 : Now check and see which directories actually exist, avoiding duplicates
3829 libpth=''
3830 for xxx in $dlist
3831 do
3832     if $test -d $xxx; then
3833                 case " $libpth " in
3834                 *" $xxx "*) ;;
3835                 *) libpth="$libpth $xxx";;
3836                 esac
3837     fi
3838 done
3839 $cat <<'EOM'
3840
3841 Some systems have incompatible or broken versions of libraries.  Among
3842 the directories listed in the question below, please remove any you
3843 know not to be holding relevant libraries, and add any that are needed.
3844 Say "none" for none.
3845
3846 EOM
3847 case "$libpth" in
3848 '') dflt='none';;
3849 *)
3850         set X $libpth
3851         shift
3852         dflt=${1+"$@"}
3853         ;;
3854 esac
3855 rp="Directories to use for library searches?"
3856 . ./myread
3857 case "$ans" in
3858 none) libpth=' ';;
3859 *) libpth="$ans";;
3860 esac
3861
3862 : compute shared library extension
3863 case "$so" in
3864 '')
3865         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3866                 dflt='sl'
3867         else
3868                 dflt='so'
3869         fi
3870         ;;
3871 *) dflt="$so";;
3872 esac
3873 $cat <<EOM
3874
3875 On some systems, shared libraries may be available.  Answer 'none' if
3876 you want to suppress searching of shared libraries for the remaining
3877 of this configuration.
3878
3879 EOM
3880 rp='What is the file extension used for shared libraries?'
3881 . ./myread
3882 so="$ans"
3883
3884 : Define several unixisms.
3885 : Hints files or command line option can be used to override them.
3886 : The convoluted testing is in case hints files set either the old
3887 : or the new name.
3888 case "$_exe" in
3889 '')     case "$exe_ext" in
3890     '') ;;
3891         *)      _exe="$exe_ext" ;;
3892         esac
3893         ;;
3894 esac
3895 case "$_a" in
3896 '')     case "$lib_ext" in
3897     '') _a='.a';;
3898         *)      _a="$lib_ext" ;;
3899         esac
3900         ;;
3901 esac
3902 case "$_o" in
3903 '') case "$obj_ext" in
3904         '')     _o='.o';;
3905         *)      _o="$obj_ext";;
3906         esac
3907         ;;
3908 esac
3909 case "$p_" in
3910 '') case "$path_sep" in
3911         '')     p_=':';;
3912         *)      p_="$path_sep";;
3913         esac
3914         ;;
3915 esac
3916 exe_ext=$_exe
3917 lib_ext=$_a
3918 obj_ext=$_o
3919 path_sep=$p_
3920
3921 : Which makefile gets called first.  This is used by make depend.
3922 case "$firstmakefile" in
3923 '') firstmakefile='makefile';;
3924 esac
3925
3926 : Looking for optional libraries
3927 echo " "
3928 echo "Checking for optional libraries..." >&4
3929 case "$libs" in
3930 ' '|'') dflt='';;
3931 *) dflt="$libs";;
3932 esac
3933 case "$libswanted" in
3934 '') libswanted='c_s';;
3935 esac
3936 for thislib in $libswanted; do
3937         
3938         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3939                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3940                 echo "Found -l$thislib (shared)."
3941                 case " $dflt " in
3942                 *"-l$thislib "*);;
3943                 *) dflt="$dflt -l$thislib";;
3944                 esac
3945         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3946                 echo "Found -l$thislib (shared)."
3947                 case " $dflt " in
3948                 *"-l$thislib "*);;
3949                 *) dflt="$dflt -l$thislib";;
3950                 esac
3951         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
3952                 echo "Found -l$thislib."
3953                 case " $dflt " in
3954                 *"-l$thislib "*);;
3955                 *) dflt="$dflt -l$thislib";;
3956                 esac
3957         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
3958                 echo "Found -l$thislib."
3959                 case " $dflt " in
3960                 *"-l$thislib "*);;
3961                 *) dflt="$dflt -l$thislib";;
3962                 esac
3963         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
3964                 echo "Found -l${thislib}_s."
3965                 case " $dflt " in
3966                 *"-l$thislib "*);;
3967                 *) dflt="$dflt -l${thislib}_s";;
3968                 esac
3969         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
3970                 echo "Found -l$thislib."
3971                 case " $dflt " in
3972                 *"-l$thislib "*);;
3973                 *) dflt="$dflt -l$thislib";;
3974                 esac
3975         else
3976                 echo "No -l$thislib."
3977         fi
3978 done
3979 set X $dflt
3980 shift
3981 dflt="$*"
3982 case "$libs" in
3983 '') dflt="$dflt";;
3984 *) dflt="$libs";;
3985 esac
3986 case "$dflt" in
3987 ' '|'') dflt='none';;
3988 esac
3989
3990 $cat <<EOM
3991  
3992 Some versions of Unix support shared libraries, which make executables smaller
3993 but make load time slightly longer.
3994
3995 On some systems, mostly System V Release 3's, the shared library is included
3996 by putting the option "-lc_s" as the last thing on the cc command line when
3997 linking.  Other systems use shared libraries by default.  There may be other
3998 libraries needed to compile $package on your machine as well.  If your system
3999 needs the "-lc_s" option, include it here.  Include any other special libraries
4000 here as well.  Say "none" for none.
4001 EOM
4002
4003 echo " "
4004 rp="Any additional libraries?"
4005 . ./myread
4006 case "$ans" in
4007 none) libs=' ';;
4008 *) libs="$ans";;
4009 esac
4010
4011 : determine optimize, if desired, or use for debug flag also
4012 case "$optimize" in
4013 ' '|$undef) dflt='none';;
4014 '') dflt='-O';;
4015 *) dflt="$optimize";;
4016 esac
4017 $cat <<EOH
4018
4019 Some C compilers have problems with their optimizers.  By default, $package
4020 compiles with the -O flag to use the optimizer.  Alternately, you might want
4021 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4022 systems).  Either flag can be specified here.  To use neither flag, specify
4023 the word "none".
4024
4025 EOH
4026 rp="What optimizer/debugger flag should be used?"
4027 . ./myread
4028 optimize="$ans"
4029 case "$optimize" in
4030 'none') optimize=" ";;
4031 esac
4032
4033 dflt=''
4034 : We will not override a previous value, but we might want to
4035 : augment a hint file
4036 case "$hint" in
4037 none|recommended)
4038         case "$gccversion" in
4039         1*) dflt='-fpcc-struct-return' ;;
4040         esac
4041         case "$optimize" in
4042         *-g*) dflt="$dflt -DDEBUGGING";;
4043         esac
4044         case "$gccversion" in
4045         2*) if test -d /etc/conf/kconfig.d &&
4046                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4047                 then
4048                         dflt="$dflt -posix"
4049                 fi
4050                 ;;
4051         esac
4052         ;;
4053 esac
4054
4055 case "$mips_type" in
4056 *BSD*|'') inclwanted="$locincpth $usrinc";;
4057 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4058 esac
4059 for thisincl in $inclwanted; do
4060         if $test -d $thisincl; then
4061                 if $test x$thisincl != x$usrinc; then
4062                         case "$dflt" in
4063                         *$thisincl*);;
4064                         *) dflt="$dflt -I$thisincl";;
4065                         esac
4066                 fi
4067         fi
4068 done
4069
4070 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4071         xxx=true;
4072 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4073         xxx=true;
4074 else
4075         xxx=false;
4076 fi;
4077 if $xxx; then
4078         case "$dflt" in
4079         *$2*);;
4080         *) dflt="$dflt -D$2";;
4081         esac;
4082 fi'
4083
4084 set signal.h LANGUAGE_C; eval $inctest
4085
4086 case "$hint" in
4087 none|recommended) dflt="$ccflags $dflt" ;;
4088 *) dflt="$ccflags";;
4089 esac
4090
4091 case "$dflt" in
4092 ''|' ') dflt=none;;
4093 esac
4094 $cat <<EOH
4095
4096 Your C compiler may want other flags.  For this question you should include
4097 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4098 but you should NOT include libraries or ld flags like -lwhatever.  If you
4099 want $package to honor its debug switch, you should include -DDEBUGGING here.
4100 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4101
4102 To use no flags, specify the word "none".
4103
4104 EOH
4105 set X $dflt
4106 shift
4107 dflt=${1+"$@"}
4108 rp="Any additional cc flags?"
4109 . ./myread
4110 case "$ans" in
4111 none) ccflags='';;
4112 *) ccflags="$ans";;
4113 esac
4114
4115 : the following weeds options from ccflags that are of no interest to cpp
4116 cppflags="$ccflags"
4117 case "$gccversion" in
4118 1*) cppflags="$cppflags -D__GNUC__"
4119 esac
4120 case "$mips_type" in
4121 '');;
4122 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4123 esac
4124 case "$cppflags" in
4125 '');;
4126 *)
4127         echo " "
4128         echo "Let me guess what the preprocessor flags are..." >&4
4129         set X $cppflags
4130         shift
4131         cppflags=''
4132         $cat >cpp.c <<'EOM'
4133 #define BLURFL foo
4134
4135 BLURFL xx LFRULB
4136 EOM
4137         previous=''
4138         for flag in $*
4139         do
4140                 case "$flag" in
4141                 -*) ftry="$flag";;
4142                 *) ftry="$previous $flag";;
4143                 esac
4144                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4145                         >cpp1.out 2>/dev/null && \
4146                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4147                         >cpp2.out 2>/dev/null && \
4148                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4149                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4150                 then
4151                         cppflags="$cppflags $ftry"
4152                         previous=''
4153                 else
4154                         previous="$flag"
4155                 fi
4156         done
4157         set X $cppflags
4158         shift
4159         cppflags=${1+"$@"}
4160         case "$cppflags" in
4161         *-*)  echo "They appear to be: $cppflags";;
4162         esac
4163         $rm -f cpp.c cpp?.out
4164         ;;
4165 esac
4166
4167 : flags used in final linking phase
4168 case "$ldflags" in
4169 '') if ./venix; then
4170                 dflt='-i -z'
4171         else
4172                 dflt=''
4173         fi
4174         case "$ccflags" in
4175         *-posix*) dflt="$dflt -posix" ;;
4176         esac
4177         ;;
4178 *) dflt="$ldflags";;
4179 esac
4180
4181 : Try to guess additional flags to pick up local libraries.
4182 for thislibdir in $libpth; do
4183         case " $loclibpth " in
4184         *" $thislibdir "*)
4185                 case "$dflt " in 
4186                 *"-L$thislibdir "*) ;;
4187                 *)  dflt="$dflt -L$thislibdir" ;;
4188                 esac
4189                 ;;
4190         esac
4191 done
4192
4193 case "$dflt" in
4194 '') dflt='none' ;;
4195 esac
4196
4197 $cat <<EOH
4198
4199 Your C linker may need flags.  For this question you should
4200 include -L/whatever and any other flags used by the C linker, but you
4201 should NOT include libraries like -lwhatever.
4202
4203 Make sure you include the appropriate -L/path flags if your C linker
4204 does not normally search all of the directories you specified above,
4205 namely
4206         $libpth
4207 To use no flags, specify the word "none".
4208
4209 EOH
4210
4211 rp="Any additional ld flags (NOT including libraries)?"
4212 . ./myread
4213 case "$ans" in
4214 none) ldflags='';;
4215 *) ldflags="$ans";;
4216 esac
4217 rmlist="$rmlist pdp11"
4218
4219 : coherency check
4220 echo " "
4221 echo "Checking your choice of C compiler and flags for coherency..." >&4
4222 $cat > try.c <<'EOF'
4223 #include <stdio.h>
4224 int main() { printf("Ok\n"); exit(0); }
4225 EOF
4226 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4227 shift
4228 $cat >try.msg <<'EOM'
4229 I've tried to compile and run the following simple program:
4230
4231 EOM
4232 $cat try.c >> try.msg
4233
4234 $cat >> try.msg <<EOM
4235
4236 I used the command:
4237
4238         $*
4239         ./try
4240
4241 and I got the following output:
4242
4243 EOM
4244 dflt=y
4245 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4246         if sh -c './try' >>try.msg 2>&1; then
4247                 xxx=`./try`
4248                 case "$xxx" in
4249                 "Ok") dflt=n ;;
4250                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4251                         case " $libs " in
4252                         *" -lsfio "*)
4253                                 cat >> try.msg <<'EOQS'
4254 If $libs contains -lsfio, and sfio is mis-configured, then it
4255 sometimes (apparently) runs and exits with a 0 status, but with no
4256 output!  It may have to do with sfio's use of _exit vs. exit.
4257
4258 EOQS
4259                                 rp="You have a big problem.  Shall I abort Configure"
4260                                 dflt=y
4261                                 ;;
4262                         esac
4263                         ;;
4264                 esac
4265         else
4266                 echo "The program compiled OK, but exited with status $?." >>try.msg
4267                 rp="You have a problem.  Shall I abort Configure"
4268                 dflt=y
4269         fi
4270 else
4271         echo "I can't compile the test program." >>try.msg
4272         rp="You have a BIG problem.  Shall I abort Configure"
4273         dflt=y
4274 fi
4275 case "$dflt" in
4276 y)
4277         $cat try.msg >&4
4278         case "$knowitall" in
4279         '')
4280                 echo "(The supplied flags or libraries might be incorrect.)"
4281                 ;;
4282         *) dflt=n;;
4283         esac
4284         echo " "
4285         . ./myread
4286         case "$ans" in
4287         n*|N*) ;;
4288         *)      echo "Ok.  Stopping Configure." >&4
4289                 exit 1
4290                 ;;
4291         esac
4292         ;;
4293 n) echo "OK, that should do.";;
4294 esac
4295 $rm -f try try.* core
4296
4297 : determine filename position in cpp output
4298 echo " "
4299 echo "Computing filename position in cpp output for #include directives..." >&4
4300 echo '#include <stdio.h>' > foo.c
4301 $cat >fieldn <<EOF
4302 $startsh
4303 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4304 $grep '^[       ]*#.*stdio\.h' | \
4305 while read cline; do
4306         pos=1
4307         set \$cline
4308         while $test \$# -gt 0; do
4309                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4310                         echo "\$pos"
4311                         exit 0
4312                 fi
4313                 shift
4314                 pos=\`expr \$pos + 1\`
4315         done
4316 done
4317 EOF
4318 chmod +x fieldn
4319 fieldn=`./fieldn`
4320 $rm -f foo.c fieldn
4321 case $fieldn in
4322 '') pos='???';;
4323 1) pos=first;;
4324 2) pos=second;;
4325 3) pos=third;;
4326 *) pos="${fieldn}th";;
4327 esac
4328 echo "Your cpp writes the filename in the $pos field of the line."
4329
4330 : locate header file
4331 $cat >findhdr <<EOF
4332 $startsh
4333 wanted=\$1
4334 name=''
4335 if test -f $usrinc/\$wanted; then
4336         echo "$usrinc/\$wanted"
4337         exit 0
4338 fi
4339 awkprg='{ print \$$fieldn }'
4340 echo "#include <\$wanted>" > foo\$\$.c
4341 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4342 $grep "^[       ]*#.*\$wanted" | \
4343 while read cline; do
4344         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4345         case "\$name" in
4346         */\$wanted) echo "\$name"; exit 0;;
4347         *) name='';;
4348         esac;
4349 done;
4350 $rm -f foo\$\$.c;
4351 case "\$name" in
4352 '') exit 1;;
4353 esac
4354 EOF
4355 chmod +x findhdr
4356
4357 : define an alternate in-header-list? function
4358 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4359 cont=true; xxf="echo \"<\$1> found.\" >&4";
4360 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4361 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4362 esac;
4363 case $# in 4) instead=instead;; *) instead="at last";; esac;
4364 while $test "$cont"; do
4365         xxx=`./findhdr $1`
4366         var=$2; eval "was=\$$2";
4367         if $test "$xxx" && $test -r "$xxx";
4368         then eval $xxf;
4369         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4370                 cont="";
4371         else eval $xxnf;
4372         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4373         set $yyy; shift; shift; yyy=$@;
4374         case $# in 0) cont="";;
4375         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4376                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4377         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4378                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4379         esac;
4380 done;
4381 while $test "$yyy";
4382 do set $yyy; var=$2; eval "was=\$$2";
4383         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4384         set $yyy; shift; shift; yyy=$@;
4385 done'
4386
4387 : see if this is a malloc.h system
4388 set malloc.h i_malloc
4389 eval $inhdr
4390
4391 : see if stdlib is available
4392 set stdlib.h i_stdlib
4393 eval $inhdr
4394
4395 : determine which malloc to compile in
4396 echo " "
4397 case "$usemymalloc" in
4398 ''|[yY]*|true|$define)  dflt='y' ;;
4399 *)      dflt='n' ;;
4400 esac
4401 rp="Do you wish to attempt to use the malloc that comes with $package?"
4402 . ./myread
4403 usemymalloc="$ans"
4404 case "$ans" in
4405 y*|true)
4406         usemymalloc='y'
4407         mallocsrc='malloc.c'
4408         mallocobj="malloc$_o"
4409         d_mymalloc="$define"
4410         case "$libs" in
4411         *-lmalloc*)
4412                 : Remove malloc from list of libraries to use
4413                 echo "Removing unneeded -lmalloc from library list" >&4
4414                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4415                 shift
4416                 libs="$*"
4417                 echo "libs = $libs" >&4
4418                 ;;
4419         esac
4420         ;;
4421 *)
4422         usemymalloc='n'
4423         mallocsrc=''
4424         mallocobj=''
4425         d_mymalloc="$undef"
4426         ;;
4427 esac
4428
4429 : compute the return types of malloc and free
4430 echo " "
4431 $cat >malloc.c <<END
4432 #$i_malloc I_MALLOC
4433 #$i_stdlib I_STDLIB
4434 #include <stdio.h>
4435 #include <sys/types.h>
4436 #ifdef I_MALLOC
4437 #include <malloc.h>
4438 #endif
4439 #ifdef I_STDLIB
4440 #include <stdlib.h>
4441 #endif
4442 #ifdef TRY_MALLOC
4443 void *malloc();
4444 #endif
4445 #ifdef TRY_FREE
4446 void free();
4447 #endif
4448 END
4449 case "$malloctype" in
4450 '')
4451         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4452                 malloctype='void *'
4453         else
4454                 malloctype='char *'
4455         fi
4456         ;;
4457 esac
4458 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4459
4460 case "$freetype" in
4461 '')
4462         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4463                 freetype='void'
4464         else
4465                 freetype='int'
4466         fi
4467         ;;
4468 esac
4469 echo "Your system uses $freetype free(), it would seem." >&4
4470 $rm -f malloc.[co]
4471 : Cruising for prototypes
4472 echo " "
4473 echo "Checking out function prototypes..." >&4
4474 $cat >prototype.c <<'EOCP'
4475 int main(int argc, char *argv[]) {
4476         exit(0);}
4477 EOCP
4478 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4479         echo "Your C compiler appears to support function prototypes."
4480         val="$define"
4481 else
4482         echo "Your C compiler doesn't seem to understand function prototypes."
4483         val="$undef"
4484 fi
4485 set prototype
4486 eval $setvar
4487 $rm -f prototype*
4488
4489 case "$prototype" in
4490 "$define") ;;
4491 *)      ansi2knr='ansi2knr'
4492         echo " "
4493         cat <<EOM >&4
4494
4495 $me:  FATAL ERROR:
4496 This version of $package can only be compiled by a compiler that 
4497 understands function prototypes.  Unfortunately, your C compiler 
4498         $cc $ccflags
4499 doesn't seem to understand them.  Sorry about that.
4500
4501 If GNU cc is available for your system, perhaps you could try that instead.  
4502
4503 Eventually, we hope to support building Perl with pre-ANSI compilers.
4504 If you would like to help in that effort, please contact <perlbug@perl.org>.
4505
4506 Aborting Configure now.
4507 EOM
4508         exit 2
4509         ;;
4510 esac
4511
4512 : determine where public executables go
4513 echo " "
4514 set dflt bin bin
4515 eval $prefixit
4516 fn=d~
4517 rp='Pathname where the public executables will reside?'
4518 . ./getfile
4519 if $test "X$ansexp" != "X$binexp"; then
4520         installbin=''
4521 fi
4522 bin="$ans"
4523 binexp="$ansexp"
4524 if $afs; then
4525         $cat <<EOM
4526
4527 Since you are running AFS, I need to distinguish the directory in which
4528 executables reside from the directory in which they are installed (and from
4529 which they are presumably copied to the former directory by occult means).
4530
4531 EOM
4532         case "$installbin" in
4533         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4534         *) dflt="$installbin";;
4535         esac
4536         fn=de~
4537         rp='Where will public executables be installed?'
4538         . ./getfile
4539         installbin="$ans"
4540 else
4541         installbin="$binexp"
4542 fi
4543
4544 case "$crosscompile" in
4545 ''|[nN]*) crosscompile="$undef" ;;
4546 esac
4547
4548 : determine whether to install perl also as /usr/bin/perl
4549
4550 echo " "
4551 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4552         $cat <<EOM
4553 Many scripts expect to perl to be installed as /usr/bin/perl.
4554 I can install the perl you are about to compile also as /usr/bin/perl
4555 (in addition to $installbin/perl).
4556 EOM
4557         case "$installusrbinperl" in
4558         "$undef"|[nN]*) dflt='n';;
4559         *)              dflt='y';;
4560         esac
4561         rp="Do you want to install perl as /usr/bin/perl?"
4562         . ./myread
4563         case "$ans" in
4564         [yY]*)  val="$define";;
4565         *)      val="$undef" ;;
4566         esac
4567 else
4568         val="$undef"
4569 fi
4570 set installusrbinperl
4571 eval $setvar
4572
4573 : define a shorthand compile call
4574 compile='
4575 mc_file=$1;
4576 shift;
4577 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4578 : define a shorthand compile call for compilations that should be ok.
4579 compile_ok='
4580 mc_file=$1;
4581 shift;
4582 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4583
4584 echo " "
4585 echo "Checking for GNU C Library..." >&4
4586 cat >gnulibc.c <<EOM
4587 #include <stdio.h>
4588 int main()
4589 {
4590 #ifdef __GLIBC__
4591     exit(0);
4592 #else
4593     exit(1);
4594 #endif
4595 }
4596 EOM
4597 set gnulibc
4598 if eval $compile_ok && ./gnulibc; then
4599         val="$define"
4600         echo "You are using the GNU C Library"
4601 else
4602         val="$undef"
4603         echo "You are not using the GNU C Library"
4604 fi
4605 $rm -f gnulibc*
4606 set d_gnulibc
4607 eval $setvar
4608
4609 : see if nm is to be used to determine whether a symbol is defined or not
4610 case "$usenm" in
4611 '')
4612         dflt=''
4613         case "$d_gnulibc" in
4614         "$define")
4615                 echo " "
4616                 echo "nm probably won't work on the GNU C Library." >&4
4617                 dflt=n
4618                 ;;
4619         esac
4620         case "$dflt" in
4621         '') 
4622                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4623                         echo " "
4624                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4625                         echo "'nm' won't be sufficient on this sytem." >&4
4626                         dflt=n
4627                 fi
4628                 ;;
4629         esac
4630         case "$dflt" in
4631         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4632                 if $test $dflt -gt 20; then
4633                         dflt=y
4634                 else
4635                         dflt=n
4636                 fi
4637                 ;;
4638         esac
4639         ;;
4640 *)
4641         case "$usenm" in
4642         true|$define) dflt=y;;
4643         *) dflt=n;;
4644         esac
4645         ;;
4646 esac
4647 $cat <<EOM
4648
4649 I can use $nm to extract the symbols from your C libraries. This
4650 is a time consuming task which may generate huge output on the disk (up
4651 to 3 megabytes) but that should make the symbols extraction faster. The
4652 alternative is to skip the 'nm' extraction part and to compile a small
4653 test program instead to determine whether each symbol is present. If
4654 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4655 this may be the best solution.
4656
4657 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4658
4659 EOM
4660 rp="Shall I use $nm to extract C symbols from the libraries?"
4661 . ./myread
4662 case "$ans" in
4663 [Nn]*) usenm=false;;
4664 *) usenm=true;;
4665 esac
4666
4667 runnm=$usenm
4668 case "$reuseval" in
4669 true) runnm=false;;
4670 esac
4671
4672 : nm options which may be necessary
4673 case "$nm_opt" in
4674 '') if $test -f /mach_boot; then
4675                 nm_opt=''       # Mach
4676         elif $test -d /usr/ccs/lib; then
4677                 nm_opt='-p'     # Solaris (and SunOS?)
4678         elif $test -f /dgux; then
4679                 nm_opt='-p'     # DG-UX
4680         elif $test -f /lib64/rld; then
4681                 nm_opt='-p'     # 64-bit Irix
4682         else
4683                 nm_opt=''
4684         fi;;
4685 esac
4686
4687 : nm options which may be necessary for shared libraries but illegal
4688 : for archive libraries.  Thank you, Linux.
4689 case "$nm_so_opt" in
4690 '')     case "$myuname" in
4691         *linux*)
4692                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4693                         nm_so_opt='--dynamic'
4694                 fi
4695                 ;;
4696         esac
4697         ;;
4698 esac
4699
4700 case "$runnm" in
4701 true)
4702 : get list of predefined functions in a handy place
4703 echo " "
4704 case "$libc" in
4705 '') libc=unknown
4706         case "$libs" in
4707         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4708         esac
4709         ;;
4710 esac
4711 libnames='';
4712 case "$libs" in
4713 '') ;;
4714 *)  for thislib in $libs; do
4715         case "$thislib" in
4716         -lc|-lc_s)
4717                 : Handle C library specially below.
4718                 ;;
4719         -l*)
4720                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4721                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4722                         :
4723                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4724                         :
4725                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4726                         :
4727                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4728                         :
4729                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4730                         :
4731                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4732                         :
4733                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4734                         :
4735                 else
4736                         try=''
4737                 fi
4738                 libnames="$libnames $try"
4739                 ;;
4740         *) libnames="$libnames $thislib" ;;
4741         esac
4742         done
4743         ;;
4744 esac
4745 xxx=normal
4746 case "$libc" in
4747 unknown)
4748         set /lib/libc.$so
4749         for xxx in $libpth; do
4750                 $test -r $1 || set $xxx/libc.$so
4751                 : The messy sed command sorts on library version numbers.
4752                 $test -r $1 || \
4753                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4754                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4755                                 h
4756                                 s/[0-9][0-9]*/0000&/g
4757                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4758                                 G
4759                                 s/\n/ /' | \
4760                          sort | $sed -e 's/^.* //'`
4761                 eval set \$$#
4762         done
4763         $test -r $1 || set /usr/ccs/lib/libc.$so
4764         $test -r $1 || set /lib/libsys_s$_a
4765         ;;
4766 *)
4767         set blurfl
4768         ;;
4769 esac
4770 if $test -r "$1"; then
4771         echo "Your (shared) C library seems to be in $1."
4772         libc="$1"
4773 elif $test -r /lib/libc && $test -r /lib/clib; then
4774         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4775         xxx=apollo
4776         libc='/lib/clib /lib/libc'
4777         if $test -r /lib/syslib; then
4778                 echo "(Your math library is in /lib/syslib.)"
4779                 libc="$libc /lib/syslib"
4780         fi
4781 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4782         echo "Your C library seems to be in $libc, as you said before."
4783 elif $test -r $incpath/usr/lib/libc$_a; then
4784         libc=$incpath/usr/lib/libc$_a;
4785         echo "Your C library seems to be in $libc.  That's fine."
4786 elif $test -r /lib/libc$_a; then
4787         libc=/lib/libc$_a;
4788         echo "Your C library seems to be in $libc.  You're normal."
4789 else
4790         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4791                 :
4792         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4793                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4794         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4795                 :
4796         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4797                 :
4798         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4799                 :
4800         else
4801                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4802         fi
4803         if $test -r "$tans"; then
4804                 echo "Your C library seems to be in $tans, of all places."
4805                 libc=$tans
4806         else
4807                 libc='blurfl'
4808         fi
4809 fi
4810 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4811         dflt="$libc"
4812         cat <<EOM
4813
4814 If the guess above is wrong (which it might be if you're using a strange
4815 compiler, or your machine supports multiple models), you can override it here.
4816
4817 EOM
4818 else
4819         dflt=''
4820         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4821         cat >&4 <<EOM
4822 I can't seem to find your C library.  I've looked in the following places:
4823
4824 EOM
4825         $sed 's/^/      /' libpath
4826         cat <<EOM
4827
4828 None of these seems to contain your C library. I need to get its name...
4829
4830 EOM
4831 fi
4832 fn=f
4833 rp='Where is your C library?'
4834 . ./getfile
4835 libc="$ans"
4836
4837 echo " "
4838 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4839 set X `cat libnames`
4840 shift
4841 xxx=files
4842 case $# in 1) xxx=file; esac
4843 echo "Extracting names from the following $xxx for later perusal:" >&4
4844 echo " "
4845 $sed 's/^/      /' libnames >&4
4846 echo " "
4847 $echo $n "This may take a while...$c" >&4
4848
4849 for file in $*; do
4850         case $file in
4851         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4852         *) $nm $nm_opt $file 2>/dev/null;;
4853         esac
4854 done >libc.tmp
4855
4856 $echo $n ".$c"
4857 $grep fprintf libc.tmp > libc.ptf
4858 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4859 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4860 xxx='[ADTSIW]'
4861 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4862         eval $xscan;\
4863         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4864                 eval $xrun
4865 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4866         eval $xscan;\
4867         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4868                 eval $xrun
4869 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4870         eval $xscan;\
4871         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4872                 eval $xrun
4873 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4874         eval $xscan;\
4875         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4876                 eval $xrun
4877 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4878         eval $xscan;\
4879         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4880                 eval $xrun
4881 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4882         eval $xscan;\
4883         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4884                 eval $xrun
4885 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4886                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4887         eval $xscan;\
4888         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4889                 eval $xrun
4890 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//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 '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4895         eval $xscan;\
4896         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4897                 eval $xrun
4898 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4899         eval $xscan;\
4900         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4901                 eval $xrun
4902 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4903         eval $xscan;\
4904         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4905                 eval $xrun
4906 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4907         eval $xscan;\
4908         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4909                 eval $xrun
4910 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4911         eval $xscan;\
4912         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4913                 eval $xrun
4914 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4915         eval $xscan;\
4916         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4917                 eval $xrun
4918 else
4919         $nm -p $* 2>/dev/null >libc.tmp
4920         $grep fprintf libc.tmp > libc.ptf
4921         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4922                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4923         then
4924                 nm_opt='-p'
4925                 eval $xrun
4926         else
4927                 echo " "
4928                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4929                 com=''
4930                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4931                         for thisname in $libnames $libc; do
4932                                 $ar t $thisname >>libc.tmp
4933                         done
4934                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4935                         echo "Ok." >&4
4936                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4937                         # Repeat libc to extract forwarders to DLL entries too
4938                         for thisname in $libnames $libc; do
4939                                 $ar tv $thisname >>libc.tmp
4940                                 # Revision 50 of EMX has bug in $ar.
4941                                 # it will not extract forwarders to DLL entries
4942                                 # Use emximp which will extract exactly them.
4943                                 emximp -o tmp.imp $thisname \
4944                                     2>/dev/null && \
4945                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4946                                     < tmp.imp >>libc.tmp
4947                                 $rm tmp.imp
4948                         done
4949                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
4950                         echo "Ok." >&4
4951                 else
4952                         echo "$ar didn't seem to work right." >&4
4953                         echo "Maybe this is a Cray...trying bld instead..." >&4
4954                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
4955                         then
4956                                 for thisname in $libnames; do
4957                                         bld t $libnames | \
4958                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
4959                                         $ar t $thisname >>libc.tmp
4960                                 done
4961                                 echo "Ok." >&4
4962                         else
4963                                 echo "That didn't work either.  Giving up." >&4
4964                                 exit 1
4965                         fi
4966                 fi
4967         fi
4968 fi
4969 nm_extract="$com"
4970 if $test -f /lib/syscalls.exp; then
4971         echo " "
4972         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
4973         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
4974 fi
4975 ;;
4976 esac
4977 $rm -f libnames libpath
4978
4979 : see if dld is available
4980 set dld.h i_dld
4981 eval $inhdr
4982
4983 : is a C symbol defined?
4984 csym='tlook=$1;
4985 case "$3" in
4986 -v) tf=libc.tmp; tc=""; tdc="";;
4987 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
4988 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
4989 esac;
4990 tx=yes;
4991 case "$reuseval-$4" in
4992 true-) ;;
4993 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
4994 esac;
4995 case "$tx" in
4996 yes)
4997         case "$runnm" in
4998         true)
4999                 if $contains $tlook $tf >/dev/null 2>&1;
5000                 then tval=true;
5001                 else tval=false;
5002                 fi;;
5003         *)
5004                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5005                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5006                 then tval=true;
5007                 else tval=false;
5008                 fi;
5009                 $rm -f t t.c;;
5010         esac;;
5011 *)
5012         case "$tval" in
5013         $define) tval=true;;
5014         *) tval=false;;
5015         esac;;
5016 esac;
5017 eval "$2=$tval"'
5018
5019 : define an is-in-libc? function
5020 inlibc='echo " "; td=$define; tu=$undef;
5021 sym=$1; var=$2; eval "was=\$$2";
5022 tx=yes;
5023 case "$reuseval$was" in
5024 true) ;;
5025 true*) tx=no;;
5026 esac;
5027 case "$tx" in
5028 yes)
5029         set $sym tres -f;
5030         eval $csym;
5031         case "$tres" in
5032         true)
5033                 echo "$sym() found." >&4;
5034                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5035         *)
5036                 echo "$sym() NOT found." >&4;
5037                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5038         esac;;
5039 *)
5040         case "$was" in
5041         $define) echo "$sym() found." >&4;;
5042         *) echo "$sym() NOT found." >&4;;
5043         esac;;
5044 esac'
5045
5046 : see if dlopen exists
5047 xxx_runnm="$runnm"
5048 runnm=false
5049 set dlopen d_dlopen
5050 eval $inlibc
5051 runnm="$xxx_runnm"
5052
5053 : determine which dynamic loading, if any, to compile in
5054 echo " "
5055 dldir="ext/DynaLoader"
5056 case "$usedl" in
5057 $define|y|true)
5058         dflt='y'
5059         usedl="$define"
5060         ;;
5061 $undef|n|false)
5062         dflt='n'
5063         usedl="$undef"
5064         ;;
5065 *) 
5066         dflt='n'
5067         case "$d_dlopen" in
5068             $define) dflt='y' ;;
5069         esac
5070         case "$i_dld" in
5071             $define) dflt='y' ;;
5072         esac
5073         : Does a dl_xxx.xs file exist for this operating system
5074         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5075         ;;
5076 esac
5077 rp="Do you wish to use dynamic loading?"
5078 . ./myread
5079 usedl="$ans"
5080 case "$ans" in
5081 y*) usedl="$define"
5082         case "$dlsrc" in
5083         '')
5084                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5085                         dflt="$dldir/dl_${osname}.xs"
5086                 elif $test "$d_dlopen" = "$define" ; then
5087                         dflt="$dldir/dl_dlopen.xs"
5088                 elif $test "$i_dld" = "$define" ; then
5089                         dflt="$dldir/dl_dld.xs"
5090                 else
5091                         dflt=''
5092                 fi
5093                 ;;
5094         *)      dflt="$dldir/$dlsrc"
5095                 ;;
5096         esac
5097     echo "The following dynamic loading files are available:"
5098         : Can not go over to $dldir because getfile has path hard-coded in.
5099         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5100         rp="Source file to use for dynamic loading"
5101         fn="fne"
5102         # XXX This getfile call will fail the existence check if you try 
5103         # building away from $src (this is not supported yet).
5104         . ./getfile
5105         usedl="$define"
5106         : emulate basename
5107         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5108
5109         $cat << EOM
5110
5111 Some systems may require passing special flags to $cc -c to
5112 compile modules that will be used to create a shared library.
5113 To use no flags, say "none".
5114
5115 EOM
5116     case "$cccdlflags" in
5117     '') case "$gccversion" in
5118                 '') case "$osname" in
5119                         hpux)   dflt='+z' ;;
5120                         next)   dflt='none' ;;
5121                         irix*)  dflt='-KPIC' ;;
5122                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5123                         sunos)  dflt='-pic' ;;
5124                         *)      dflt='none' ;;
5125                     esac
5126                         ;;
5127                 *)  case "$osname" in
5128                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5129                         *)      dflt='-fpic' ;;
5130                     esac ;;
5131             esac ;;
5132         ' ') dflt='none' ;;
5133     *)  dflt="$cccdlflags" ;;
5134     esac
5135     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5136     . ./myread
5137     case "$ans" in
5138     none) cccdlflags=' ' ;;
5139     *) cccdlflags="$ans" ;;
5140     esac
5141
5142     cat << EOM
5143
5144 Some systems use ld to create libraries that can be dynamically loaded,
5145 while other systems (such as those using ELF) use $cc.
5146
5147 EOM
5148         case "$ld" in
5149         '')     $cat >try.c <<'EOM'
5150 /* Test for whether ELF binaries are produced */
5151 #include <fcntl.h>
5152 #include <stdlib.h>
5153 int main() {
5154         char b[4];
5155         int i = open("a.out",O_RDONLY);
5156         if(i == -1) 
5157                 exit(1); /* fail */
5158         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5159                 exit(0); /* succeed (yes, it's ELF) */
5160         else
5161                 exit(1); /* fail */
5162 }
5163 EOM
5164                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5165                         cat <<EOM
5166 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5167 EOM
5168                         dflt="$cc"
5169                 else
5170                         echo "I'll use ld to build dynamic libraries."
5171                         dflt='ld'
5172                 fi
5173                 rm -f try.c a.out
5174                 ;;
5175         *)      dflt="$ld"
5176                 ;;
5177         esac
5178
5179     rp="What command should be used to create dynamic libraries?"
5180     . ./myread
5181         ld="$ans"
5182
5183     cat << EOM
5184
5185 Some systems may require passing special flags to $ld to create a
5186 library that can be dynamically loaded.  If your ld flags include
5187 -L/other/path options to locate libraries outside your loader's normal
5188 search path, you may need to specify those -L options here as well.  To
5189 use no flags, say "none".
5190
5191 EOM
5192     case "$lddlflags" in
5193     '') case "$osname" in
5194                         beos) dflt='-nostart' ;;
5195                         hpux)  dflt='-b' ;;
5196                         linux|irix*)    dflt='-shared' ;;
5197                         next)  dflt='none' ;;
5198                         solaris) dflt='-G' ;;
5199                         sunos) dflt='-assert nodefinitions' ;;
5200                         svr4*|esix*) dflt="-G $ldflags" ;;
5201                 *)     dflt='none' ;;
5202                         esac
5203                         ;;
5204     *) dflt="$lddlflags" ;;
5205     esac
5206
5207         : Try to guess additional flags to pick up local libraries.
5208         : Be careful not to append to a plain 'none'
5209         case "$dflt" in
5210         none) dflt='' ;;
5211         esac
5212         for thisflag in $ldflags; do
5213                 case "$thisflag" in
5214                 -L*)
5215                         case " $dflt " in
5216                         *" $thisflag "*) ;;
5217                         *) dflt="$dflt $thisflag" ;;
5218                         esac
5219                         ;;
5220                 esac
5221         done
5222
5223         case "$dflt" in
5224         ''|' ') dflt='none' ;;
5225         esac
5226
5227     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5228     . ./myread
5229     case "$ans" in
5230     none) lddlflags=' ' ;;
5231     *) lddlflags="$ans" ;;
5232     esac
5233
5234         cat <<EOM
5235
5236 Some systems may require passing special flags to $cc to indicate that
5237 the resulting executable will use dynamic linking.  To use no flags,
5238 say "none".
5239
5240 EOM
5241     case "$ccdlflags" in
5242     '') case "$osname" in
5243                 hpux)   dflt='-Wl,-E' ;;
5244                 linux)  dflt='-rdynamic' ;;
5245                 next)   dflt='none' ;;
5246                 sunos)  dflt='none' ;;
5247                 *)      dflt='none' ;;
5248             esac ;;
5249     ' ')  dflt='none' ;;
5250     *)  dflt="$ccdlflags" ;;
5251     esac
5252     rp="Any special flags to pass to $cc to use dynamic loading?"
5253     . ./myread
5254     case "$ans" in
5255     none) ccdlflags=' ' ;;
5256     *) ccdlflags="$ans" ;;
5257     esac
5258     ;;
5259 *)  usedl="$undef"
5260         ld='ld'
5261     dlsrc='dl_none.xs'
5262     lddlflags=''
5263     ccdlflags=''
5264     ;;
5265 esac
5266
5267 also=''
5268 case "$usedl" in
5269 $undef)
5270         # No dynamic loading being used, so don't bother even to prompt.
5271         useshrplib='false'
5272         ;;
5273 *)      case "$useshrplib" in
5274         '')     case "$osname" in
5275                 svr4*|dgux|dynixptx|esix|powerux|beos)
5276                         dflt=y
5277                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5278                         ;;
5279                 next*)
5280                         case "$osvers" in
5281                         4*)     dflt=y
5282                                 also='Building a shared libperl is needed for MAB support.'
5283                                 ;;
5284                         *)      dflt=n
5285                                 ;;
5286                         esac
5287                         ;;
5288                 *)      dflt=n
5289                         ;;
5290                 esac
5291                 ;;
5292         $define|true|[Yy]*)
5293                 dflt=y
5294                 ;;
5295         *)      dflt=n
5296                 ;;
5297         esac
5298         $cat << EOM
5299
5300 The perl executable is normally obtained by linking perlmain.c with
5301 libperl${_a}, any static extensions (usually just DynaLoader), and
5302 any other libraries needed on this system (such as -lm, etc.).  Since
5303 your system supports dynamic loading, it is probably possible to build
5304 a shared libperl.$so.  If you will have more than one executable linked
5305 to libperl.$so, this will significantly reduce the size of each
5306 executable, but it may have a noticeable affect on performance.  The
5307 default is probably sensible for your system.
5308 $also
5309
5310 EOM
5311         rp="Build a shared libperl.$so (y/n)"
5312         . ./myread
5313         case "$ans" in
5314         true|$define|[Yy]*)
5315                 useshrplib='true'
5316                 # Why does next4 have to be so different?
5317                 case "${osname}${osvers}" in
5318                 next4*) xxx='DYLD_LIBRARY_PATH' ;;
5319                 os2*)   xxx='' ;; # Nothing special needed.
5320                 beos*)  xxx='' ;;
5321                 *)              xxx='LD_LIBRARY_PATH' ;;
5322                 esac
5323                 if test X"$xxx" != "X"; then
5324                         $cat <<EOM  | $tee -a ../config.msg >&4
5325
5326 To build perl, you must add the current working directory to your
5327 $xxx environment variable before running make.  You can do
5328 this with
5329    $xxx=\`pwd\`:\$$xxx; export $xxx
5330 for Bourne-style shells, or
5331    setenv $xxx \`pwd\`
5332 for Csh-style shells.  You *MUST* do this before running make.
5333
5334 EOM
5335                 fi
5336                 ;;
5337         *)      useshrplib='false' ;;
5338         esac
5339         ;;
5340 esac
5341
5342 case "$useshrplib" in
5343 true)
5344         case "$libperl" in
5345         '')
5346                 # Figure out a good name for libperl.so.  Since it gets stored in
5347                 # a version-specific architecture-dependent library, the version
5348                 # number isn't really that important, except for making cc/ld happy.
5349                 #
5350                 # A name such as libperl.so.3.1
5351                 majmin="libperl.$so.$patchlevel.$subversion"
5352                 # A name such as libperl.so.301
5353                 majonly=`echo $patchlevel $subversion |
5354                         $awk '{printf "%d%02d", $1, $2}'`
5355                 majonly=libperl.$so.$majonly
5356                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5357                 # rely on figuring it out from the naming of libc.
5358                 case "${osname}${osvers}" in
5359                 next4*)
5360                         dflt=libperl.5.$so
5361                         # XXX How handle the --version stuff for MAB?
5362                         ;;
5363                 linux*)  # ld won't link with a bare -lperl otherwise.
5364                         dflt=libperl.$so
5365                         ;;
5366                 *)      # Try to guess based on whether libc has major.minor.
5367                         case "$libc" in
5368                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5369                         *libc.$so.[0-9]*) dflt=$majonly ;;
5370                         *)      dflt=libperl.$so ;;
5371                         esac
5372                         ;;
5373                 esac
5374                 ;;
5375         *)      dflt=$libperl
5376                 ;;
5377         esac
5378         cat << EOM
5379
5380 I need to select a good name for the shared libperl.  If your system uses
5381 library names with major and minor numbers, then you might want something
5382 like $majmin.  Alternatively, if your system uses a single version
5383 number for shared libraries, then you might want to use $majonly.
5384 Or, your system might be quite happy with a simple libperl.$so.
5385
5386 Since the shared libperl will get installed into a version-specific
5387 architecture-dependent directory, the version number of the shared perl
5388 library probably isn't important, so the default should be o.k.
5389
5390 EOM
5391         rp='What name do you want to give to the shared libperl?'
5392         . ./myread
5393         libperl=$ans
5394         echo "Ok, I'll use $libperl"
5395         ;;
5396 *)
5397         libperl="libperl${_a}"
5398         ;;
5399 esac
5400
5401 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5402 case "$shrpdir" in
5403 '') ;;
5404 *)      $cat >&4 <<EOM
5405 WARNING:  Use of the shrpdir variable for the installation location of
5406 the shared $libperl is not supported.  It was never documented and
5407 will not work in this version.  Let me (perlbug@perl.com)
5408 know of any problems this may cause.
5409
5410 EOM
5411         case "$shrpdir" in
5412         "$archlibexp/CORE")
5413                 $cat >&4 <<EOM
5414 But your current setting of $shrpdir is
5415 the default anyway, so it's harmless.
5416 EOM
5417                 ;;
5418         *)
5419                 $cat >&4 <<EOM
5420 Further, your current attempted setting of $shrpdir
5421 conflicts with the value of $archlibexp/CORE
5422 that installperl will use.
5423 EOM
5424                 ;;
5425         esac
5426         ;;
5427 esac
5428
5429 # How will the perl executable find the installed shared $libperl?
5430 # Add $xxx to ccdlflags.
5431 # If we can't figure out a command-line option, use $shrpenv to
5432 # set env LD_RUN_PATH.  The main perl makefile uses this.
5433 shrpdir=$archlibexp/CORE
5434 xxx=''
5435 tmp_shrpenv=''
5436 if "$useshrplib"; then
5437     case "$osname" in 
5438         aix)
5439                 # We'll set it in Makefile.SH...
5440                 ;;
5441         solaris|netbsd)
5442                 xxx="-R $shrpdir"
5443                 ;;
5444         freebsd)
5445                 xxx="-Wl,-R$shrpdir"
5446                 ;;
5447         linux|irix*|dec_osf)
5448                 xxx="-Wl,-rpath,$shrpdir"
5449                 ;;
5450         next)
5451                 # next doesn't like the default...
5452                 ;;
5453         beos)
5454                 # beos doesn't like the default, either.
5455                 ;;
5456         *)
5457                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5458                 ;;
5459         esac
5460         case "$xxx" in
5461         '') ;;
5462         *)      
5463                 # Only add $xxx if it isn't already in ccdlflags.
5464                 case " $ccdlflags " in
5465                 *" $xxx "*)     ;;
5466                 *)      ccdlflags="$ccdlflags $xxx"
5467                         cat <<EOM >&4
5468
5469 Adding $xxx to the flags
5470 passed to $ld so that the perl executable will find the 
5471 installed shared $libperl.
5472
5473 EOM
5474                         ;;
5475                 esac
5476                 ;;
5477         esac
5478 fi
5479 # Respect a hint or command-line value.
5480 case "$shrpenv" in
5481 '') shrpenv="$tmp_shrpenv" ;;
5482 esac
5483
5484 : determine where manual pages go
5485 set man1dir man1dir none
5486 eval $prefixit
5487 $cat <<EOM
5488
5489 $spackage has manual pages available in source form.
5490 EOM
5491 case "$nroff" in
5492 nroff)
5493         echo "However, you don't have nroff, so they're probably useless to you."
5494         case "$man1dir" in
5495         '') man1dir="none";;
5496         esac;;
5497 esac
5498 echo "If you don't want the manual sources installed, answer 'none'."
5499 case "$man1dir" in
5500 ' ') dflt=none
5501         ;;
5502 '')
5503         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5504         lookpath="$lookpath $prefixexp/man/p_man/man1"
5505         lookpath="$lookpath $prefixexp/man/u_man/man1"
5506         lookpath="$lookpath $prefixexp/man/man.1"
5507         case "$sysman" in
5508         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5509         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5510         esac
5511         set dflt
5512         eval $prefixup
5513         ;;
5514 *)  dflt="$man1dir"
5515         ;;
5516 esac
5517 echo " "
5518 fn=dn+~
5519 rp="Where do the main $spackage manual pages (source) go?"
5520 . ./getfile
5521 if $test "X$man1direxp" != "X$ansexp"; then
5522         installman1dir=''
5523 fi
5524 man1dir="$ans"
5525 man1direxp="$ansexp"
5526 case "$man1dir" in
5527 '') man1dir=' '
5528         installman1dir='';;
5529 esac
5530 if $afs; then
5531         $cat <<EOM
5532
5533 Since you are running AFS, I need to distinguish the directory in which
5534 manual pages reside from the directory in which they are installed (and from
5535 which they are presumably copied to the former directory by occult means).
5536
5537 EOM
5538         case "$installman1dir" in
5539         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5540         *) dflt="$installman1dir";;
5541         esac
5542         fn=de~
5543         rp='Where will man pages be installed?'
5544         . ./getfile
5545         installman1dir="$ans"
5546 else
5547         installman1dir="$man1direxp"
5548 fi
5549
5550 : What suffix to use on installed man pages
5551
5552 case "$man1dir" in
5553 ' ')
5554         man1ext='0'
5555         ;;
5556 *)
5557         rp="What suffix should be used for the main $spackage man pages?"
5558         case "$man1ext" in
5559         '')     case "$man1dir" in
5560                 *1)  dflt=1 ;;
5561                 *1p) dflt=1p ;;
5562                 *1pm) dflt=1pm ;;
5563                 *l) dflt=l;;
5564                 *n) dflt=n;;
5565                 *o) dflt=o;;
5566                 *p) dflt=p;;
5567                 *C) dflt=C;;
5568                 *L) dflt=L;;
5569                 *L1) dflt=L1;;
5570                 *) dflt=1;;
5571                 esac
5572                 ;;
5573         *)      dflt="$man1ext";;
5574         esac
5575         . ./myread
5576         man1ext="$ans"
5577         ;;
5578 esac
5579
5580 : see if we can have long filenames
5581 echo " "
5582 rmlist="$rmlist /tmp/cf$$"
5583 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5584 first=123456789abcdef
5585 second=/tmp/cf$$/$first
5586 $rm -f $first $second
5587 if (echo hi >$first) 2>/dev/null; then
5588         if $test -f 123456789abcde; then
5589                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5590                 val="$undef"
5591         else
5592                 if (echo hi >$second) 2>/dev/null; then
5593                         if $test -f /tmp/cf$$/123456789abcde; then
5594                                 $cat <<'EOM'
5595 That's peculiar... You can have filenames longer than 14 characters, but only
5596 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5597 I shall consider your system cannot support long filenames at all.
5598 EOM
5599                                 val="$undef"
5600                         else
5601                                 echo 'You can have filenames longer than 14 characters.' >&4
5602                                 val="$define"
5603                         fi
5604                 else
5605                         $cat <<'EOM'
5606 How confusing! Some of your filesystems are sane enough to allow filenames
5607 longer than 14 characters but some others like /tmp can't even think about them.
5608 So, for now on, I shall assume your kernel does not allow them at all.
5609 EOM
5610                         val="$undef"
5611                 fi
5612         fi
5613 else
5614         $cat <<'EOM'
5615 You can't have filenames longer than 14 chars.  You can't even think about them!
5616 EOM
5617         val="$undef"
5618 fi 
5619 set d_flexfnam
5620 eval $setvar
5621 $rm -rf /tmp/cf$$ 123456789abcde*
5622
5623 : determine where library module manual pages go
5624 set man3dir man3dir none
5625 eval $prefixit
5626 $cat <<EOM
5627
5628 $spackage has manual pages for many of the library modules.
5629 EOM
5630
5631 case "$nroff" in
5632 nroff)
5633         $cat <<'EOM'
5634 However, you don't have nroff, so they're probably useless to you.
5635 EOM
5636         case "$man3dir" in
5637         '') man3dir="none";;
5638         esac;;
5639 esac
5640
5641 case "$d_flexfnam" in
5642 undef)
5643         $cat <<'EOM'
5644 However, your system can't handle the long file names like File::Basename.3. 
5645 EOM
5646         case "$man3dir" in
5647         '') man3dir="none";;
5648         esac;;
5649 esac
5650
5651 echo "If you don't want the manual sources installed, answer 'none'."
5652 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5653 case "$man3dir" in
5654 '')     case "$prefix" in 
5655         *$prog*) dflt=`echo $man1dir | 
5656                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5657         *)      dflt="$privlib/man/man3" ;;
5658         esac
5659         ;;
5660 ' ') dflt=none;;
5661 *)      dflt="$man3dir" ;;
5662 esac
5663 echo " "
5664
5665 fn=dn+~
5666 rp="Where do the $package library man pages (source) go?"
5667 . ./getfile
5668 if test "X$man3direxp" != "X$ansexp"; then
5669         installman3dir=''
5670 fi
5671
5672 man3dir="$ans"
5673 man3direxp="$ansexp"
5674 case "$man3dir" in
5675 '') man3dir=' '
5676         installman3dir='';;
5677 esac
5678 if $afs; then
5679         $cat <<EOM
5680
5681 Since you are running AFS, I need to distinguish the directory in which
5682 manual pages reside from the directory in which they are installed (and from
5683 which they are presumably copied to the former directory by occult means).
5684
5685 EOM
5686         case "$installman3dir" in
5687         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5688         *) dflt="$installman3dir";;
5689         esac
5690         fn=de~
5691         rp='Where will man pages be installed?'
5692         . ./getfile
5693         installman3dir="$ans"
5694 else
5695         installman3dir="$man3direxp"
5696 fi
5697
5698 : What suffix to use on installed man pages
5699
5700 case "$man3dir" in
5701 ' ')
5702         man3ext='0'
5703         ;;
5704 *)
5705         rp="What suffix should be used for the $package library man pages?"
5706         case "$man3ext" in
5707         '')     case "$man3dir" in
5708                 *3)  dflt=3 ;;
5709                 *3p) dflt=3p ;;
5710                 *3pm) dflt=3pm ;;
5711                 *l) dflt=l;;
5712                 *n) dflt=n;;
5713                 *o) dflt=o;;
5714                 *p) dflt=p;;
5715                 *C) dflt=C;;
5716                 *L) dflt=L;;
5717                 *L3) dflt=L3;;
5718                 *) dflt=3;;
5719                 esac
5720                 ;;
5721         *)      dflt="$man3ext";;
5722         esac
5723         . ./myread
5724         man3ext="$ans"
5725         ;;
5726 esac
5727
5728 case "$osname" in
5729 next) multiarch="$define" ;;
5730 esac
5731 case "$multiarch" in
5732 ''|[nN]*) multiarch="$undef" ;;
5733 esac
5734
5735 : see if we have to deal with yellow pages, now NIS.
5736 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5737         if $test -f /usr/etc/nibindd; then
5738                 echo " "
5739                 echo "I'm fairly confident you're on a NeXT."
5740                 echo " "
5741                 rp='Do you get the hosts file via NetInfo?'
5742                 dflt=y
5743                 case "$hostcat" in
5744                 nidump*) ;;
5745                 '') ;;
5746                 *) dflt=n;;
5747                 esac
5748                 . ./myread
5749                 case "$ans" in
5750                 y*) hostcat='nidump hosts .';;
5751                 *)      case "$hostcat" in
5752                         nidump*) hostcat='';;
5753                         esac
5754                         ;;
5755                 esac
5756         fi
5757         case "$hostcat" in
5758         nidump*) ;;
5759         *)
5760                 case "$hostcat" in
5761                 *ypcat*) dflt=y;;
5762                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5763                                 dflt=y
5764                         else
5765                                 dflt=n
5766                         fi;;
5767                 *) dflt=n;;
5768                 esac
5769                 echo " "
5770                 rp='Are you getting the hosts file via yellow pages?'
5771                 . ./myread
5772                 case "$ans" in
5773                 y*) hostcat='ypcat hosts';;
5774                 *) hostcat='cat /etc/hosts';;
5775                 esac
5776                 ;;
5777         esac
5778 fi
5779 case "$hostcat" in
5780 '') hostcat='cat /etc/hosts';;
5781 esac
5782 case "$groupcat" in
5783 '') groupcat='cat /etc/group';;
5784 esac
5785 case "$passcat" in
5786 '') passcat='cat /etc/passwd';;
5787 esac
5788
5789 : now get the host name
5790 echo " "
5791 echo "Figuring out host name..." >&4
5792 case "$myhostname" in
5793 '') cont=true
5794         echo 'Maybe "hostname" will work...'
5795         if tans=`sh -c hostname 2>&1` ; then
5796                 myhostname=$tans
5797                 phostname=hostname
5798                 cont=''
5799         fi
5800         ;;
5801 *) cont='';;
5802 esac
5803 if $test "$cont"; then
5804         if ./xenix; then
5805                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5806                 if tans=`cat /etc/systemid 2>&1` ; then
5807                         myhostname=$tans
5808                         phostname='cat /etc/systemid'
5809                         echo "Whadyaknow.  Xenix always was a bit strange..."
5810                         cont=''
5811                 fi
5812         elif $test -r /etc/systemid; then
5813                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5814         fi
5815 fi
5816 if $test "$cont"; then
5817         echo 'No, maybe "uuname -l" will work...'
5818         if tans=`sh -c 'uuname -l' 2>&1` ; then
5819                 myhostname=$tans
5820                 phostname='uuname -l'
5821         else
5822                 echo 'Strange.  Maybe "uname -n" will work...'
5823                 if tans=`sh -c 'uname -n' 2>&1` ; then
5824                         myhostname=$tans
5825                         phostname='uname -n'
5826                 else
5827                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5828                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5829                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5830                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5831                         else
5832                                 case "$myhostname" in
5833                                 '') echo "Does this machine have an identity crisis or something?"
5834                                         phostname='';;
5835                                 *)
5836                                         echo "Well, you said $myhostname before..."
5837                                         phostname='echo $myhostname';;
5838                                 esac
5839                         fi
5840                 fi
5841         fi
5842 fi
5843 : you do not want to know about this
5844 set $myhostname
5845 myhostname=$1
5846
5847 : verify guess
5848 if $test "$myhostname" ; then
5849         dflt=y
5850         rp='Your host name appears to be "'$myhostname'".'" Right?"
5851         . ./myread
5852         case "$ans" in
5853         y*) ;;
5854         *) myhostname='';;
5855         esac
5856 fi
5857
5858 : bad guess or no guess
5859 while $test "X$myhostname" = X ; do
5860         dflt=''
5861         rp="Please type the (one word) name of your host:"
5862         . ./myread
5863         myhostname="$ans"
5864 done
5865
5866 : translate upper to lower if necessary
5867 case "$myhostname" in
5868 *[A-Z]*)
5869         echo "(Normalizing case in your host name)"
5870         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5871         ;;
5872 esac
5873
5874 case "$myhostname" in
5875 *.*)
5876         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5877         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5878         echo "(Trimming domain name from host name--host name is now $myhostname)"
5879         ;;
5880 *) case "$mydomain" in
5881         '')
5882                 {
5883                         test "X$hostcat" = "Xypcat hosts" &&
5884                         ypmatch "$myhostname" hosts 2>/dev/null |\
5885                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5886                         $test -s hosts
5887                 } || {
5888                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5889                                         /[       ]$myhostname[  . ]/p" > hosts
5890                 }
5891                 tmp_re="[       . ]"
5892                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5893                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5894                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5895                         hosts | $sort | $uniq | \
5896                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5897                 case `$echo X$dflt` in
5898                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5899                         dflt=.
5900                         ;;
5901                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5902                         ;;
5903                 esac
5904                 case "$dflt" in
5905                 .)
5906                         tans=`./loc resolv.conf X /etc /usr/etc`
5907                         if $test -f "$tans"; then
5908                                 echo "(Attempting domain name extraction from $tans)"
5909                                 dflt=.`$sed -n -e 's/   / /g' \
5910                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5911                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5912                                 case "$dflt" in
5913                                 .) dflt=.`$sed -n -e 's/        / /g' \
5914                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5915                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5916                                         ;;
5917                                 esac
5918                         fi
5919                         ;;
5920                 esac
5921                 case "$dflt" in
5922                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5923                         dflt=.`sh -c domainname 2>/dev/null`
5924                         case "$dflt" in
5925                         '') dflt='.';;
5926                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5927                         esac
5928                         ;;
5929                 esac
5930                 case "$dflt" in
5931                 .) echo "(Lost all hope -- silly guess then)"
5932                         dflt='.uucp'
5933                         ;;
5934                 esac
5935                 $rm -f hosts
5936                 ;;
5937         *) dflt="$mydomain";;
5938         esac;;
5939 esac
5940 echo " "
5941 rp="What is your domain name?"
5942 . ./myread
5943 tans="$ans"
5944 case "$ans" in
5945 '') ;;
5946 .*) ;;
5947 *) tans=".$tans";;
5948 esac
5949 mydomain="$tans"
5950
5951 : translate upper to lower if necessary
5952 case "$mydomain" in
5953 *[A-Z]*)
5954         echo "(Normalizing case in your domain name)"
5955         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5956         ;;
5957 esac
5958
5959 : a little sanity check here
5960 case "$phostname" in
5961 '') ;;
5962 *)
5963         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
5964         $myhostname$mydomain|$myhostname) ;;
5965         *)
5966                 case "$phostname" in
5967                 sed*)
5968                         echo "(That doesn't agree with your whoami.h file, by the way.)"
5969                         ;;
5970                 *)
5971                         echo "(That doesn't agree with your $phostname command, by the way.)"
5972                         ;;
5973                 esac
5974         ;;
5975         esac
5976         ;;
5977 esac
5978
5979 $cat <<EOM
5980
5981 I need to get your e-mail address in Internet format if possible, i.e.
5982 something like user@host.domain. Please answer accurately since I have
5983 no easy means to double check it. The default value provided below
5984 is most probably close to the reality but may not be valid from outside
5985 your organization...
5986
5987 EOM
5988 cont=x
5989 while test "$cont"; do
5990         case "$cf_email" in
5991         '') dflt="$cf_by@$myhostname$mydomain";;
5992         *) dflt="$cf_email";;
5993         esac
5994         rp='What is your e-mail address?'
5995         . ./myread
5996         cf_email="$ans"
5997         case "$cf_email" in
5998         *@*.*) cont='' ;;
5999         *)
6000                 rp='Address does not look like an Internet one.  Use it anyway?'
6001                 case "$fastread" in
6002                 yes) dflt=y ;;
6003                 *) dflt=n ;;
6004                 esac
6005                 . ./myread
6006                 case "$ans" in
6007                 y*) cont='' ;;
6008                 *) echo " " ;;
6009                 esac
6010                 ;;
6011         esac
6012 done
6013
6014 $cat <<EOM
6015
6016 If you or somebody else will be maintaining perl at your site, please
6017 fill in the correct e-mail address here so that they may be contacted
6018 if necessary. Currently, the "perlbug" program included with perl
6019 will send mail to this address in addition to perlbug@perl.com. You may
6020 enter "none" for no administrator.
6021
6022 EOM
6023 case "$perladmin" in
6024 '') dflt="$cf_email";;
6025 *) dflt="$perladmin";;
6026 esac
6027 rp='Perl administrator e-mail address'
6028 . ./myread
6029 perladmin="$ans"
6030
6031 : figure out how to guarantee perl startup
6032 case "$startperl" in
6033 '')
6034         case "$sharpbang" in
6035         *!)
6036                 $cat <<EOH
6037
6038 I can use the #! construct to start perl on your system. This will
6039 make startup of perl scripts faster, but may cause problems if you
6040 want to share those scripts and perl is not in a standard place
6041 ($binexp/perl) on all your platforms. The alternative is to force
6042 a shell by starting the script with a single ':' character.
6043
6044 EOH
6045                 dflt="$binexp/perl"
6046                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6047                 . ./myread
6048                 case "$ans" in
6049                 none)   startperl=": # use perl";;
6050                 *)      startperl="#!$ans"
6051                         if $test 30 -lt `echo "$ans" | wc -c`; then
6052                                 $cat >&4 <<EOM
6053
6054 WARNING:  Some systems limit the #! command to 32 characters.
6055 If you experience difficulty running Perl scripts with #!, try
6056 installing Perl in a directory with a shorter pathname.
6057
6058 EOM
6059                         fi ;;
6060                 esac
6061                 ;;
6062         *) startperl=": # use perl"
6063                 ;;
6064         esac
6065         ;;
6066 esac
6067 echo "I'll use $startperl to start perl scripts."
6068
6069 : figure best path for perl in scripts
6070 case "$perlpath" in
6071 '')
6072         perlpath="$binexp/perl"
6073         case "$startperl" in
6074         *!*) ;;
6075         *)
6076                 $cat <<EOH
6077
6078 I will use the "eval 'exec'" idiom to start Perl on your system.
6079 I can use the full path of your Perl binary for this purpose, but
6080 doing so may cause problems if you want to share those scripts and
6081 Perl is not always in a standard place ($binexp/perl).
6082
6083 EOH
6084                 dflt="$binexp/perl"
6085                 rp="What path shall I use in \"eval 'exec'\"?"
6086                 . ./myread
6087                 perlpath="$ans"
6088                 ;;
6089         esac
6090         ;;
6091 esac
6092 case "$startperl" in
6093 *!*)    ;;
6094 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6095 esac
6096
6097 : determine where public executable scripts go
6098 set scriptdir scriptdir
6099 eval $prefixit
6100 case "$scriptdir" in
6101 '')
6102         dflt="$bin"
6103         : guess some guesses
6104         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6105         $test -d /usr/share/bin && dflt=/usr/share/bin
6106         $test -d /usr/local/script && dflt=/usr/local/script
6107         $test -d $prefixexp/script && dflt=$prefixexp/script
6108         set dflt
6109         eval $prefixup
6110         ;;
6111 *)  dflt="$scriptdir"
6112         ;;
6113 esac
6114 $cat <<EOM
6115  
6116 Some installations have a separate directory just for executable scripts so
6117 that they can mount it across multiple architectures but keep the scripts in
6118 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6119 Or you might just lump your scripts in with all your other executables.
6120  
6121 EOM
6122 fn=d~
6123 rp='Where do you keep publicly executable scripts?'
6124 . ./getfile
6125 if $test "X$ansexp" != "X$scriptdirexp"; then
6126         installscript=''
6127 fi
6128 scriptdir="$ans"
6129 scriptdirexp="$ansexp"
6130 if $afs; then
6131         $cat <<EOM
6132
6133 Since you are running AFS, I need to distinguish the directory in which
6134 scripts reside from the directory in which they are installed (and from
6135 which they are presumably copied to the former directory by occult means).
6136
6137 EOM
6138         case "$installscript" in
6139         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6140         *) dflt="$installscript";;
6141         esac
6142         fn=de~
6143         rp='Where will public scripts be installed?'
6144         . ./getfile
6145         installscript="$ans"
6146 else
6147         installscript="$scriptdirexp"
6148 fi
6149
6150 : determine where site specific libraries go.
6151 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6152 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6153 case "$prefix" in
6154 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6155 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6156 esac
6157 eval $prefixit
6158 $cat <<EOM
6159
6160 The installation process will also create a directory for
6161 site-specific extensions and modules.  Some users find it convenient
6162 to place all site-specific files in this directory rather than in the
6163 main distribution directory.
6164
6165 EOM
6166 fn=d~+
6167 rp='Pathname for the site-specific library files?'
6168 . ./getfile
6169 if $test "X$sitelibexp" != "X$ansexp"; then
6170         installsitelib=''
6171 fi
6172 sitelib="$ans"
6173 sitelibexp="$ansexp"
6174 if $afs; then
6175         $cat <<EOM
6176
6177 Since you are running AFS, I need to distinguish the directory in
6178 which site-specific files reside from the directory in which they are
6179 installed (and from which they are presumably copied to the former
6180 directory by occult means).
6181
6182 EOM
6183         case "$installsitelib" in
6184         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6185         *) dflt="$installsitelib";;
6186         esac
6187         fn=de~
6188         rp='Where will site-specific files be installed?'
6189         . ./getfile
6190         installsitelib="$ans"
6191 else
6192         installsitelib="$sitelibexp"
6193 fi
6194
6195 : determine where site specific architecture-dependent libraries go.
6196 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6197 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6198 : sitelib may have an optional trailing /share.
6199 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6200 tdflt="$tdflt/$archname"
6201 set sitearch sitearch none
6202 eval $prefixit
6203 case "$sitearch" in
6204 '')     dflt="$tdflt" ;;
6205 *)      dflt="$sitearch" ;;
6206 esac
6207 $cat <<EOM
6208
6209 The installation process will also create a directory for
6210 architecture-dependent site-specific extensions and modules.
6211
6212 EOM
6213 fn=nd~+
6214 rp='Pathname for the site-specific architecture-dependent library files?'
6215 . ./getfile
6216 if $test "X$sitearchexp" != "X$ansexp"; then
6217         installsitearch=''
6218 fi
6219 sitearch="$ans"
6220 sitearchexp="$ansexp"
6221 if $afs; then
6222         $cat <<EOM
6223
6224 Since you are running AFS, I need to distinguish the directory in
6225 which site-specific architecture-dependent library files reside from
6226 the directory in which they are installed (and from which they are
6227 presumably copied to the former directory by occult means).
6228
6229 EOM
6230         case "$installsitearch" in
6231         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6232         *) dflt="$installsitearch";;
6233         esac
6234         fn=de~
6235         rp='Where will site-specific architecture-dependent files be installed?'
6236         . ./getfile
6237         installsitearch="$ans"
6238 else
6239         installsitearch="$sitearchexp"
6240 fi
6241
6242 cat <<EOM
6243
6244 Previous version of $package used the standard IO mechanisms as defined
6245 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6246 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6247 the default.  This abstraction layer can use AT&T's sfio (if you already
6248 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6249 problems with some extension modules.  Using PerlIO with stdio is safe,
6250 but it is slower than plain stdio and therefore is not the default.
6251
6252 If this doesn't make any sense to you, just accept the default 'n'.
6253 EOM
6254 case "$useperlio" in
6255 $define|true|[yY]*)     dflt='y';;
6256 *) dflt='n';;
6257 esac
6258 rp='Use the experimental PerlIO abstraction layer?'
6259 . ./myread
6260 case "$ans" in
6261 y|Y) 
6262         val="$define"
6263         ;;     
6264 *)      
6265         echo "Ok, doing things the stdio way"
6266         val="$undef"
6267         ;;
6268 esac
6269 set useperlio
6270 eval $setvar 
6271
6272 : Check how to convert floats to strings.
6273 if test "X$d_Gconvert" = X; then
6274         echo " "
6275         echo "Checking for an efficient way to convert floats to strings."
6276         $cat >try.c <<'EOP'
6277 #ifdef TRY_gconvert
6278 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6279 char *myname = "gconvert";
6280 #endif
6281 #ifdef TRY_gcvt
6282 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6283 char *myname = "gcvt";
6284 #endif
6285 #ifdef TRY_sprintf
6286 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6287 char *myname = "sprintf";
6288 #endif
6289
6290 #include <stdio.h>
6291
6292 int
6293 checkit(expect, got)
6294 char *expect;
6295 char *got;
6296 {
6297     if (strcmp(expect, got)) {
6298                 printf("%s oddity:  Expected %s, got %s\n",
6299                         myname, expect, got);
6300                 exit(1);
6301         }
6302 }
6303
6304 int main()
6305
6306         char buf[64]; 
6307         buf[63] = '\0';
6308
6309         /* This must be 1st test on (which?) platform */
6310         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6311         Gconvert(0.1, 8, 0, buf);
6312         checkit("0.1", buf);
6313
6314         Gconvert(1.0, 8, 0, buf); 
6315         checkit("1", buf);
6316
6317         Gconvert(0.0, 8, 0, buf); 
6318         checkit("0", buf);
6319
6320         Gconvert(-1.0, 8, 0, buf); 
6321         checkit("-1", buf);
6322
6323         /* Some Linux gcvt's give 1.e+5 here. */
6324         Gconvert(100000.0, 8, 0, buf); 
6325         checkit("100000", buf);
6326         
6327         /* Some Linux gcvt's give -1.e+5 here. */
6328         Gconvert(-100000.0, 8, 0, buf); 
6329         checkit("-100000", buf);
6330
6331         exit(0);
6332 }
6333 EOP
6334         case "$d_Gconvert" in
6335         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6336         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6337         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6338         *) xxx_list='gconvert gcvt sprintf' ;;
6339         esac
6340
6341         for xxx_convert in $xxx_list; do
6342                 echo "Trying $xxx_convert"
6343                 $rm -f try try$_o
6344                 set try -DTRY_$xxx_convert
6345                 if eval $compile; then
6346                         echo "$xxx_convert" found. >&4
6347                         if ./try; then
6348                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6349                                 break;
6350                         else
6351                                 echo "...But $xxx_convert didn't work as I expected."
6352                         fi
6353                 else
6354                         echo "$xxx_convert NOT found." >&4
6355                 fi
6356         done
6357                 
6358         case "$xxx_convert" in
6359         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6360         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6361         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6362         esac
6363 fi
6364
6365 : Initialize h_fcntl
6366 h_fcntl=false
6367
6368 : Initialize h_sysfile
6369 h_sysfile=false
6370
6371 : access call always available on UNIX
6372 set access d_access
6373 eval $inlibc
6374
6375 : locate the flags for 'access()'
6376 case "$d_access" in
6377 "$define")
6378         echo " "
6379         $cat >access.c <<'EOCP'
6380 #include <sys/types.h>
6381 #ifdef I_FCNTL
6382 #include <fcntl.h>
6383 #endif
6384 #ifdef I_SYS_FILE
6385 #include <sys/file.h>
6386 #endif
6387 #ifdef I_UNISTD
6388 #include <unistd.h>
6389 #endif
6390 int main() {
6391         exit(R_OK);
6392 }
6393 EOCP
6394         : check sys/file.h first, no particular reason here
6395         if $test `./findhdr sys/file.h` && \
6396                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6397                 h_sysfile=true;
6398                 echo "<sys/file.h> defines the *_OK access constants." >&4
6399         elif $test `./findhdr fcntl.h` && \
6400                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6401                 h_fcntl=true;
6402                 echo "<fcntl.h> defines the *_OK access constants." >&4
6403         elif $test `./findhdr unistd.h` && \
6404                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6405                 echo "<unistd.h> defines the *_OK access constants." >&4
6406         else
6407                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6408         fi
6409         ;;
6410 esac
6411 $rm -f access*
6412
6413 : see if accessx exists
6414 set accessx d_accessx
6415 eval $inlibc
6416
6417 : see if alarm exists
6418 set alarm d_alarm
6419 eval $inlibc
6420
6421 : Look for GNU-cc style attribute checking
6422 echo " "
6423 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6424 $cat >attrib.c <<'EOCP'
6425 #include <stdio.h>
6426 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6427 EOCP
6428 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6429         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6430                 echo "Your C compiler doesn't fully support __attribute__."
6431                 val="$undef"
6432         else
6433                 echo "Your C compiler supports __attribute__."
6434                 val="$define"
6435         fi
6436 else
6437         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6438         val="$undef"
6439 fi
6440 set d_attribut
6441 eval $setvar
6442 $rm -f attrib*
6443
6444 : see if bcmp exists
6445 set bcmp d_bcmp
6446 eval $inlibc
6447
6448 : see if bcopy exists
6449 set bcopy d_bcopy
6450 eval $inlibc
6451
6452 : see if this is a unistd.h system
6453 set unistd.h i_unistd
6454 eval $inhdr
6455
6456 : see if getpgrp exists
6457 set getpgrp d_getpgrp
6458 eval $inlibc
6459
6460 case "$d_getpgrp" in
6461 "$define")
6462         echo " "
6463         echo "Checking to see which flavor of getpgrp is in use..."
6464         $cat >set.c <<EOP
6465 #$i_unistd I_UNISTD
6466 #include <sys/types.h>
6467 #ifdef I_UNISTD
6468 #  include <unistd.h>
6469 #endif
6470 int main()
6471 {
6472         if (getuid() == 0) {
6473                 printf("(I see you are running Configure as super-user...)\n");
6474                 setuid(1);
6475         }
6476 #ifdef TRY_BSD_PGRP
6477         if (getpgrp(1) == 0)
6478                 exit(0);
6479 #else
6480         if (getpgrp() > 0)
6481                 exit(0);
6482 #endif
6483         exit(1);
6484 }
6485 EOP
6486         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6487                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6488                 val="$define"
6489         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6490                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6491                 val="$undef"
6492         else
6493                 echo "I can't seem to compile and run the test program."
6494                 if ./usg; then
6495                         xxx="a USG one, i.e. you use getpgrp()."
6496                 else
6497                         # SVR4 systems can appear rather BSD-ish.
6498                         case "$i_unistd" in
6499                         $undef)
6500                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6501                                 val="$define"
6502                                 ;;
6503                         $define)
6504                                 xxx="probably a USG one, i.e. you use getpgrp()."
6505                                 val="$undef"
6506                                 ;;
6507                         esac
6508                 fi
6509                 echo "Assuming your getpgrp is $xxx" >&4
6510         fi
6511         ;;
6512 *) val="$undef";;
6513 esac
6514 set d_bsdgetpgrp
6515 eval $setvar
6516 $rm -f set set.c
6517
6518 : see if setpgrp exists
6519 set setpgrp d_setpgrp
6520 eval $inlibc
6521
6522 case "$d_setpgrp" in
6523 "$define")
6524         echo " "
6525         echo "Checking to see which flavor of setpgrp is in use..."
6526         $cat >set.c <<EOP
6527 #$i_unistd I_UNISTD
6528 #include <sys/types.h>
6529 #ifdef I_UNISTD
6530 #  include <unistd.h>
6531 #endif
6532 int main()
6533 {
6534         if (getuid() == 0) {
6535                 printf("(I see you are running Configure as super-user...)\n");
6536                 setuid(1);
6537         }
6538 #ifdef TRY_BSD_PGRP
6539         if (-1 == setpgrp(1, 1))
6540                 exit(0);
6541 #else
6542         if (setpgrp() != -1)
6543                 exit(0);
6544 #endif
6545         exit(1);
6546 }
6547 EOP
6548         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6549                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6550                 val="$define"
6551         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6552                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6553                 val="$undef"
6554         else
6555                 echo "(I can't seem to compile and run the test program.)"
6556                 if ./usg; then
6557                         xxx="a USG one, i.e. you use setpgrp()."
6558                 else
6559                         # SVR4 systems can appear rather BSD-ish.
6560                         case "$i_unistd" in
6561                         $undef)
6562                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6563                                 val="$define"
6564                                 ;;
6565                         $define)
6566                                 xxx="probably a USG one, i.e. you use setpgrp()."
6567                                 val="$undef"
6568                                 ;;
6569                         esac
6570                 fi
6571                 echo "Assuming your setpgrp is $xxx" >&4
6572         fi
6573         ;;
6574 *) val="$undef";;
6575 esac
6576 set d_bsdsetpgrp
6577 eval $setvar
6578 $rm -f set set.c
6579 : see if bzero exists
6580 set bzero d_bzero
6581 eval $inlibc
6582
6583 : check for lengths of integral types
6584 echo " "
6585 case "$intsize" in
6586 '')
6587         echo "Checking to see how big your integers are..." >&4
6588         $cat >intsize.c <<'EOCP'
6589 #include <stdio.h>
6590 int main()
6591 {
6592         printf("intsize=%d;\n", sizeof(int));
6593         printf("longsize=%d;\n", sizeof(long));
6594         printf("shortsize=%d;\n", sizeof(short));
6595         exit(0);
6596 }
6597 EOCP
6598         set intsize
6599         if eval $compile_ok && ./intsize > /dev/null; then
6600                 eval `./intsize`
6601                 echo "Your integers are $intsize bytes long."
6602                 echo "Your long integers are $longsize bytes long."
6603                 echo "Your short integers are $shortsize bytes long."
6604         else
6605                 $cat >&4 <<EOM
6606 !
6607 Help! I can't compile and run the intsize test program: please enlighten me!
6608 (This is probably a misconfiguration in your system or libraries, and
6609 you really ought to fix it.  Still, I'll try anyway.)
6610 !
6611 EOM
6612                 dflt=4
6613                 rp="What is the size of an integer (in bytes)?"
6614                 . ./myread
6615                 intsize="$ans"
6616                 dflt=$intsize
6617                 rp="What is the size of a long integer (in bytes)?"
6618                 . ./myread
6619                 longsize="$ans"
6620                 dflt=2
6621                 rp="What is the size of a short integer (in bytes)?"
6622                 . ./myread
6623                 shortsize="$ans"
6624         fi
6625         ;;
6626 esac
6627 $rm -f intsize intsize.*
6628
6629 : see if signal is declared as pointer to function returning int or void
6630 echo " "
6631 xxx=`./findhdr signal.h`
6632 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6633 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6634         echo "You have int (*signal())() instead of void." >&4
6635         val="$undef"
6636 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6637         echo "You have void (*signal())()." >&4
6638         val="$define"
6639 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6640         echo "You have int (*signal())() instead of void." >&4
6641         val="$undef"
6642 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6643         echo "You have void (*signal())()." >&4
6644         val="$define"
6645 else
6646         case "$d_voidsig" in
6647         '')
6648         echo "I can't determine whether signal handler returns void or int..." >&4
6649                 dflt=void
6650                 rp="What type does your signal handler return?"
6651                 . ./myread
6652                 case "$ans" in
6653                 v*) val="$define";;
6654                 *) val="$undef";;
6655                 esac;;
6656         "$define")
6657                 echo "As you already told me, signal handler returns void." >&4
6658                 val="$define"
6659                 ;;
6660         *)      echo "As you already told me, signal handler returns int." >&4
6661                 val="$undef"
6662                 ;;
6663         esac
6664 fi
6665 set d_voidsig
6666 eval $setvar
6667 case "$d_voidsig" in
6668 "$define") signal_t="void";;
6669 *) signal_t="int";;
6670 esac
6671 $rm -f $$.tmp
6672
6673 : check for ability to cast large floats to 32-bit ints.
6674 echo " "
6675 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6676 if $test "$intsize" -ge 4; then
6677         xxx=int
6678 else
6679         xxx=long
6680 fi
6681 $cat >try.c <<EOCP
6682 #include <stdio.h>
6683 #include <sys/types.h>
6684 #include <signal.h>
6685 $signal_t blech(s) int s; { exit(3); }
6686 int main()
6687 {
6688         $xxx i32;
6689         double f, g;
6690         int result = 0;
6691         char str[16];
6692         signal(SIGFPE, blech);
6693
6694         /* Don't let compiler optimize the test away.  Store the number 
6695            in a writable string for gcc to pass to sscanf under HP/UX.
6696         */
6697         sprintf(str, "2147483647");
6698         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6699         g = 10 * f;
6700         i32  = ($xxx) g;
6701
6702         /* x86 processors will probably give 0x8000 0000, which is a
6703        sign change.  We don't want that.  We want to mimic SPARC
6704            behavior here, which is to preserve the sign and give
6705            back 0x7fff ffff.
6706         */
6707         if (i32 != ($xxx) f)
6708                 result |= 1;
6709         exit(result);
6710 }
6711 EOCP
6712 set try
6713 if eval $compile_ok; then
6714         ./try
6715         yyy=$?
6716 else
6717         echo "(I can't seem to compile the test program--assuming it can't)"
6718         yyy=1
6719 fi
6720 case "$yyy" in
6721 0)      val="$define"
6722         echo "Yup, it can."
6723         ;;
6724 *)      val="$undef"
6725         echo "Nope, it can't."
6726         ;;
6727 esac
6728 set d_casti32
6729 eval $setvar
6730 $rm -f try try.*
6731
6732 : check for ability to cast negative floats to unsigned
6733 echo " "
6734 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6735 $cat >try.c <<EOCP
6736 #include <stdio.h>
6737 #include <sys/types.h>
6738 #include <signal.h>
6739 $signal_t blech(s) int s; { exit(7); }
6740 $signal_t blech_in_list(s) int s; { exit(4); }
6741 unsigned long dummy_long(p) unsigned long p; { return p; }
6742 unsigned int dummy_int(p) unsigned int p; { return p; }
6743 unsigned short dummy_short(p) unsigned short p; { return p; }
6744 int main()
6745 {
6746         double f;
6747         unsigned long along;
6748         unsigned int aint;
6749         unsigned short ashort;
6750         int result = 0;
6751         char str[16];
6752         
6753         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6754            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6755            optimized the whole file away
6756         */
6757         /* Store the number in a writable string for gcc to pass to 
6758            sscanf under HP/UX.
6759         */
6760         sprintf(str, "-123");
6761         sscanf(str, "%lf", &f);  /* f = -123.; */
6762
6763         signal(SIGFPE, blech);
6764         along = (unsigned long)f;
6765         aint = (unsigned int)f;
6766         ashort = (unsigned short)f;
6767         if (along != (unsigned long)-123)
6768                 result |= 1;
6769         if (aint != (unsigned int)-123)
6770                 result |= 1;
6771         if (ashort != (unsigned short)-123)
6772                 result |= 1;
6773         sprintf(str, "1073741824.");
6774         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6775         f = f + f;
6776         along = 0;
6777         along = (unsigned long)f;
6778         if (along != 0x80000000)
6779                 result |= 2;
6780         f -= 1.;
6781         along = 0;
6782         along = (unsigned long)f;
6783         if (along != 0x7fffffff)
6784                 result |= 1;
6785         f += 2.;
6786         along = 0;
6787         along = (unsigned long)f;
6788         if (along != 0x80000001)
6789                 result |= 2;
6790         if (result)
6791                 exit(result);
6792         signal(SIGFPE, blech_in_list);
6793         sprintf(str, "123.");
6794         sscanf(str, "%lf", &f);  /* f = 123.; */
6795         along = dummy_long((unsigned long)f);
6796         aint = dummy_int((unsigned int)f);
6797         ashort = dummy_short((unsigned short)f);
6798         if (along != (unsigned long)123)
6799                 result |= 4;
6800         if (aint != (unsigned int)123)
6801                 result |= 4;
6802         if (ashort != (unsigned short)123)
6803                 result |= 4;
6804         exit(result);
6805
6806 }
6807 EOCP
6808 set try
6809 if eval $compile_ok; then
6810         ./try
6811         castflags=$?
6812 else
6813         echo "(I can't seem to compile the test program--assuming it can't)"
6814         castflags=7
6815 fi
6816 case "$castflags" in
6817 0)      val="$define"
6818         echo "Yup, it can."
6819         ;;
6820 *)      val="$undef"
6821         echo "Nope, it can't."
6822         ;;
6823 esac
6824 set d_castneg
6825 eval $setvar
6826 $rm -f try.*
6827
6828 : see if vprintf exists
6829 echo " "
6830 if set vprintf val -f d_vprintf; eval $csym; $val; then
6831         echo 'vprintf() found.' >&4
6832         val="$define"
6833         $cat >vprintf.c <<'EOF'
6834 #include <varargs.h>
6835
6836 int main() { xxx("foo"); }
6837
6838 xxx(va_alist)
6839 va_dcl
6840 {
6841         va_list args;
6842         char buf[10];
6843
6844         va_start(args);
6845         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6846 }
6847 EOF
6848         set vprintf
6849         if eval $compile && ./vprintf; then
6850                 echo "Your vsprintf() returns (int)." >&4
6851                 val2="$undef"
6852         else
6853                 echo "Your vsprintf() returns (char*)." >&4
6854                 val2="$define"
6855         fi
6856 else
6857         echo 'vprintf() NOT found.' >&4
6858                 val="$undef"
6859                 val2="$undef"
6860 fi
6861 set d_vprintf
6862 eval $setvar
6863 val=$val2
6864 set d_charvspr
6865 eval $setvar
6866
6867 : see if chown exists
6868 set chown d_chown
6869 eval $inlibc
6870
6871 : see if chroot exists
6872 set chroot d_chroot
6873 eval $inlibc
6874
6875 : see if chsize exists
6876 set chsize d_chsize
6877 eval $inlibc
6878
6879 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6880 while $test $# -ge 2; do
6881         case "$1" in
6882         $define) echo "#include <$2>";;
6883         esac ;
6884     shift 2;
6885 done > try.c;
6886 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6887 if eval $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6888         val="$define";
6889 else
6890         val="$undef";
6891 fi;
6892 set $varname;
6893 eval $setvar;
6894 $rm -f try.c try.o'
6895
6896 : see if this is a sys/uio.h system
6897 set sys/uio.h i_sysuio
6898 eval $inhdr
6899
6900 echo "Checking to see if your system supports struct iovec..." >&4
6901 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6902 eval $hasfield
6903 case "$d_iovec_s" in
6904 "$define")      echo "Yup, it does." >&4
6905                 ;;
6906 *)              echo "Nope, it doesn't." >&4
6907                 ;;
6908 esac
6909
6910 socketlib=''
6911 sockethdr=''
6912 : see whether socket exists
6913 echo " "
6914 $echo $n "Hmm... $c" >&4
6915 if set socket val -f d_socket; eval $csym; $val; then
6916         echo "Looks like you have Berkeley networking support." >&4
6917         d_socket="$define"
6918         if set setsockopt val -f; eval $csym; $val; then
6919                 d_oldsock="$undef"
6920         else
6921                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6922                 d_oldsock="$define"
6923         fi
6924 else
6925         if $contains socklib libc.list >/dev/null 2>&1; then
6926                 echo "Looks like you have Berkeley networking support." >&4
6927                 d_socket="$define"
6928                 : we will have to assume that it supports the 4.2 BSD interface
6929                 d_oldsock="$undef"
6930         else
6931                 echo "You don't have Berkeley networking in libc$_a..." >&4
6932                 if test "X$d_socket" = "X$define"; then
6933                    echo "...but you seem to believe that you have sockets." >&4
6934                 else
6935                         for net in net socket
6936                         do
6937                                 if test -f /usr/lib/lib$net$_a; then
6938                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6939                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6940                                         if $contains socket libc.list >/dev/null 2>&1; then
6941                                                 d_socket="$define"
6942                                                 socketlib="-l$net"
6943                                                 case "$net" in
6944                                                 net)
6945                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6946                                                         sockethdr="-I/usr/netinclude"
6947                                                         ;;
6948                                                 esac
6949                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6950                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6951                                                         d_oldsock="$undef"
6952                                                 else
6953                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6954                                                         d_oldsock="$define"
6955                                                 fi
6956                                                 break
6957                                         fi
6958                                 fi
6959                         done
6960                         if test "X$d_socket" != "X$define"; then
6961                            echo "or anywhere else I see." >&4
6962                            d_socket="$undef"
6963                            d_oldsock="$undef"
6964                         fi
6965                 fi
6966         fi
6967 fi
6968
6969 : see if socketpair exists
6970 set socketpair d_sockpair
6971 eval $inlibc
6972
6973
6974 echo " "
6975 echo "Checking the availability of certain socket constants..." >& 4
6976 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
6977         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
6978         $cat >try.c <<EOF
6979 #include <sys/types.h>
6980 #include <sys/socket.h>
6981 int main() {
6982     int i = $ENUM;
6983 }
6984 EOF
6985         val="$undef"
6986         set try; if eval $compile; then
6987                 val="$define"
6988         fi
6989         set d_${enum}; eval $setvar
6990         $rm -f try.c try
6991 done
6992
6993 set sendmsg d_sendmsg
6994 eval $inlibc
6995
6996 set recvmsg d_recvmsg
6997 eval $inlibc
6998
6999 echo " "
7000 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
7001 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7002 eval $hasfield
7003 case "$d_msghdr_s" in
7004 "$define")      echo "Yup, it does." >&4
7005                 ;;
7006 *)              echo "Nope, it doesn't." >&4
7007                 ;;
7008 esac
7009
7010 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7011 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7012 eval $hasfield
7013 case "$d_cmsghdr_s" in
7014 "$define")      echo "Yup, it does." >&4
7015                 ;;
7016 *)              echo "Nope, it doesn't." >&4
7017                 ;;
7018 esac
7019
7020 : check for const keyword
7021 echo " "
7022 echo 'Checking to see if your C compiler knows about "const"...' >&4
7023 $cat >const.c <<'EOCP'
7024 typedef struct spug { int drokk; } spug;
7025 int main()
7026 {
7027         const char *foo;
7028         const spug y;
7029 }
7030 EOCP
7031 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7032         val="$define"
7033         echo "Yup, it does."
7034 else
7035         val="$undef"
7036         echo "Nope, it doesn't."
7037 fi
7038 set d_const
7039 eval $setvar
7040
7041 : see if crypt exists
7042 echo " "
7043 if set crypt val -f d_crypt; eval $csym; $val; then
7044         echo 'crypt() found.' >&4
7045         val="$define"
7046         cryptlib=''
7047 else
7048         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7049         if $test -z "$cryptlib"; then
7050                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7051         else
7052                 cryptlib=-lcrypt
7053         fi
7054         if $test -z "$cryptlib"; then
7055                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7056         else
7057                 cryptlib=-lcrypt
7058         fi
7059         if $test -z "$cryptlib"; then
7060                 cryptlib=`./loc libcrypt$_a "" $libpth`
7061         else
7062                 cryptlib=-lcrypt
7063         fi
7064         if $test -z "$cryptlib"; then
7065                 echo 'crypt() NOT found.' >&4
7066                 val="$undef"
7067         else
7068                 val="$define"
7069         fi
7070 fi
7071 set d_crypt
7072 eval $setvar
7073
7074 : get csh whereabouts
7075 case "$csh" in
7076 'csh') val="$undef" ;;
7077 *) val="$define" ;;
7078 esac
7079 set d_csh
7080 eval $setvar
7081 : Respect a hint or command line value for full_csh.
7082 case "$full_csh" in
7083 '') full_csh=$csh ;;
7084 esac
7085
7086 : see if cuserid exists
7087 set cuserid d_cuserid
7088 eval $inlibc
7089
7090 : see if this is a limits.h system
7091 set limits.h i_limits
7092 eval $inhdr
7093
7094 : see if this is a float.h system
7095 set float.h i_float
7096 eval $inhdr
7097
7098 : See if number of significant digits in a double precision number is known
7099 echo " "
7100 $cat >dbl_dig.c <<EOM
7101 #$i_limits I_LIMITS
7102 #$i_float I_FLOAT
7103 #ifdef I_LIMITS
7104 #include <limits.h>
7105 #endif
7106 #ifdef I_FLOAT
7107 #include <float.h>
7108 #endif
7109 #ifdef DBL_DIG
7110 printf("Contains DBL_DIG");
7111 #endif
7112 EOM
7113 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7114 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7115         echo "DBL_DIG found." >&4
7116         val="$define"
7117 else
7118         echo "DBL_DIG NOT found." >&4
7119         val="$undef"
7120 fi
7121 $rm -f dbl_dig.?
7122 set d_dbl_dig
7123 eval $setvar
7124
7125
7126 if $test X"$use64bits" = X"$define"; then
7127         : see if dbminit64 exists
7128         set dbminit64 d_dbminit64
7129         eval $inlibc
7130
7131         : see if dbmclose64 exists
7132         set dbmclose64 d_dbmclose64
7133         eval $inlibc
7134
7135         : see if fetch64 exists
7136         set fetch64 d_fetch64
7137         eval $inlibc
7138
7139         : see if store64 exists
7140         set store64 d_store64
7141         eval $inlibc
7142
7143         : see if delete64 exists
7144         set delete64 d_delete64
7145         eval $inlibc
7146
7147         : see if firstkey64 exists
7148         set firstkey64 d_firstkey64
7149         eval $inlibc
7150
7151         : see if nextkey64 exists
7152         set nextkey64 d_nextkey64
7153         eval $inlibc
7154 else
7155         val="$undef"
7156         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7157         do
7158                 set $xxx
7159                 eval $setvar
7160         done
7161 fi
7162
7163 : see if difftime exists
7164 set difftime d_difftime
7165 eval $inlibc
7166
7167 : see if sys/stat.h is available
7168 set sys/stat.h i_sysstat
7169 eval $inhdr
7170
7171 : see if this is a dirent system
7172 echo " "
7173 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7174         val="$define"
7175         echo "<dirent.h> found." >&4
7176 else
7177         val="$undef"
7178         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7179                 echo "<sys/dir.h> found." >&4
7180                 echo " "
7181         else
7182                 xinc=`./findhdr sys/ndir.h`
7183         fi
7184         echo "<dirent.h> NOT found." >&4
7185 fi
7186 set i_dirent
7187 eval $setvar
7188
7189 : Look for type of directory structure.
7190 echo " "
7191 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7192
7193 case "$direntrytype" in
7194 ''|' ')
7195         case "$i_dirent" in
7196         $define) guess1='struct dirent' ;;
7197         *) guess1='struct direct'  ;;
7198         esac
7199         ;;
7200 *)      guess1="$direntrytype"
7201         ;;
7202 esac
7203
7204 case "$guess1" in
7205 'struct dirent') guess2='struct direct' ;;
7206 *) guess2='struct dirent' ;;
7207 esac
7208                 
7209 if $contains "$guess1" try.c >/dev/null 2>&1; then
7210         direntrytype="$guess1"
7211         echo "Your directory entries are $direntrytype." >&4
7212 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7213         direntrytype="$guess2"
7214         echo "Your directory entries seem to be $direntrytype." >&4
7215 else
7216         echo "I don't recognize your system's directory entries." >&4
7217         rp="What type is used for directory entries on this system?"
7218         dflt="$guess1"
7219         . ./myread
7220         direntrytype="$ans"
7221 fi
7222 $rm -f try.c
7223
7224
7225 : see if the directory entry stores field length
7226 echo " "
7227 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7228 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7229         echo "Good, your directory entry keeps length information in d_namlen." >&4
7230         val="$define"
7231 else
7232         echo "Your directory entry does not know about the d_namlen field." >&4
7233         val="$undef"
7234 fi
7235 set d_dirnamlen
7236 eval $setvar
7237 $rm -f try.c
7238
7239
7240 if $test X"$use64bits" = X"$define"; then
7241         : see if fstat64 exists
7242         set fstat64 d_fstat64
7243         eval $inlibc
7244
7245         : see if ftruncate64 exists
7246         set ftruncate64 d_ftruncate64
7247         eval $inlibc
7248
7249         : see if lockf64 exists
7250         set lockf64 d_lockf64
7251         eval $inlibc
7252
7253         : see if lseek64 exists
7254         set lseek64 d_lseek64
7255         eval $inlibc
7256
7257         : see if lstat64 exists
7258         set lstat64 d_lstat64
7259         eval $inlibc
7260
7261         : see if open64 exists
7262         set open64 d_open64
7263         eval $inlibc
7264
7265         : see if opendir64 exists
7266         set opendir64 d_opendir64
7267         eval $inlibc
7268
7269         : see if readdir64 exists
7270         set readdir64 d_readdir64
7271         eval $inlibc
7272
7273         : see if seekdir64 exists
7274         set seekdir64 d_seekdir64
7275         eval $inlibc
7276
7277         : see if stat64 exists
7278         set stat64 d_stat64
7279         eval $inlibc
7280
7281         : see if telldir64 exists
7282         set telldir64 d_telldir64
7283         eval $inlibc
7284
7285         : see if truncate64 exists
7286         set truncate64 d_truncate64
7287         eval $inlibc
7288
7289         : check for off64_t
7290         echo " "
7291         echo $n "Checking to see if your system supports off64_t...$c" >&4
7292         $cat >try.c <<EOCP
7293 #include <sys/types.h>
7294 off64_t foo() { off64_t x; x = 7; return x; }'
7295 EOCP
7296         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7297                 val="$define"
7298                 echo " Yup, it does." >&4
7299         else
7300                 val="$undef"
7301                 echo " Nope, it doesn't." >&4
7302         fi
7303         $rm -f try.*
7304         set d_off64t
7305         eval $setvar
7306
7307         : check for ino64_t
7308         echo " "
7309         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7310         val="$undef"
7311         case "$i_sysstat" in
7312         "$define" )
7313                 $cat >try.c <<EOCP
7314 #include <sys/types.h>
7315 #include <sys/stat.h>
7316 ino64_t foo() { ino64_t x; x = 7; return x; }'
7317 EOCP
7318                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7319                         val="$define"
7320                 fi
7321                 $rm -f try.*
7322                 ;;
7323         esac
7324         if $test "X$val" = X"$define"; then
7325                 echo " Yup, it does." >&4
7326         else
7327                 echo " Nope, it doesn't." >&4
7328         fi
7329         set d_ino64t
7330         eval $setvar
7331
7332         : check for struct flock64
7333         echo " "
7334         echo "Checking to see if your system supports struct flock64..." >&4
7335         if $h_fcntl; then
7336                 set d_flock64_s flock64 l_len define fcntl.h
7337                 eval $hasfield
7338         else
7339                 val="$undef"
7340                 set d_flock64_s
7341                 eval $setvar
7342         fi
7343         case "$d_flock64_s" in
7344         "$define")      echo "Yup, it does." >&4
7345                         ;;
7346         *)              echo "Nope, it doesn't." >&4
7347                         ;;
7348         esac
7349
7350         : check for struct dirent64
7351         echo " "
7352         echo "Checking to see if your system supports struct dirent64..." >&4
7353         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7354         eval $hasfield
7355         case "$d_dirent64_s" in
7356         "$define")      echo "Yup, it does." >&4
7357                         ;;
7358         *)              echo "Nope, it doesn't." >&4
7359                         ;;
7360         esac
7361
7362 else
7363         val="$undef"
7364         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_off64t d_ino64t d_flock64_s d_dirent64_s
7365         do
7366                 set $xxx
7367                 eval $setvar
7368         done
7369 fi
7370
7371 : see if dlerror exists
7372 xxx_runnm="$runnm"
7373 runnm=false
7374 set dlerror d_dlerror
7375 eval $inlibc
7376 runnm="$xxx_runnm"
7377
7378 : see if dlfcn is available
7379 set dlfcn.h i_dlfcn
7380 eval $inhdr
7381
7382 case "$usedl" in
7383 $define|y|true)
7384         $cat << EOM
7385
7386 On a few systems, the dynamically loaded modules that perl generates and uses
7387 will need a different extension than shared libs. The default will probably
7388 be appropriate.
7389
7390 EOM
7391         case "$dlext" in
7392         '')     dflt="$so" ;;
7393         *)      dflt="$dlext" ;;
7394         esac
7395         rp='What is the extension of dynamically loaded modules'
7396         . ./myread
7397         dlext="$ans"
7398         ;;
7399 *)
7400         dlext="none"
7401         ;;
7402 esac
7403
7404 : Check if dlsym need a leading underscore
7405 echo " "
7406 val="$undef"
7407
7408 case "$dlsrc" in
7409 dl_dlopen.xs)
7410         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7411         $cat >dyna.c <<'EOM'
7412 fred () { }
7413 EOM
7414
7415 $cat >fred.c<<EOM
7416
7417 #include <stdio.h>
7418 #$i_dlfcn I_DLFCN
7419 #ifdef I_DLFCN
7420 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7421 #else
7422 #include <sys/types.h>
7423 #include <nlist.h>
7424 #include <link.h>
7425 #endif
7426
7427 extern int fred() ;
7428
7429 int main()
7430 {
7431     void * handle ;
7432     void * symbol ;
7433 #ifndef RTLD_LAZY
7434     int mode = 1 ;
7435 #else
7436     int mode = RTLD_LAZY ;
7437 #endif
7438     handle = dlopen("./dyna.$dlext", mode) ;
7439     if (handle == NULL) {
7440         printf ("1\n") ;
7441         fflush (stdout) ;
7442         exit(0);
7443     }
7444     symbol = dlsym(handle, "fred") ;
7445     if (symbol == NULL) {
7446         /* try putting a leading underscore */
7447         symbol = dlsym(handle, "_fred") ;
7448         if (symbol == NULL) {
7449             printf ("2\n") ;
7450             fflush (stdout) ;
7451             exit(0);
7452         }
7453         printf ("3\n") ;
7454     }
7455     else
7456         printf ("4\n") ;
7457     fflush (stdout) ;
7458     exit(0);
7459 }
7460 EOM
7461         : Call the object file tmp-dyna.o in case dlext=o.
7462         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7463                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7464                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7465                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7466                 xxx=`./fred`
7467                 case $xxx in
7468                 1)      echo "Test program failed using dlopen." >&4
7469                         echo "Perhaps you should not use dynamic loading." >&4;;
7470                 2)      echo "Test program failed using dlsym." >&4
7471                         echo "Perhaps you should not use dynamic loading." >&4;;
7472                 3)      echo "dlsym needs a leading underscore" >&4
7473                         val="$define" ;;
7474                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7475                 esac
7476         else
7477                 echo "I can't compile and run the test program." >&4
7478         fi
7479         ;;
7480 esac
7481                 
7482 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7483
7484 set d_dlsymun
7485 eval $setvar
7486
7487 hasproto='varname=$1; func=$2; shift; shift;
7488 while $test $# -ge 2; do
7489         case "$1" in
7490         $define) echo "#include <$2>";;
7491         esac ;
7492     shift 2;
7493 done > try.c;
7494 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7495 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7496         echo "$func() prototype found.";
7497         val="$define";
7498 else
7499         echo "$func() prototype NOT found.";
7500         val="$undef";
7501 fi;
7502 set $varname;
7503 eval $setvar;
7504 $rm -f try.c tryout.c'
7505
7506 : see if prototype for drand48 is available
7507 echo " "
7508 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7509 eval $hasproto
7510
7511 : see if dup2 exists
7512 set dup2 d_dup2
7513 eval $inlibc
7514
7515 : see if eaccess exists
7516 set eaccess d_eaccess
7517 eval $inlibc
7518
7519 : see if endgrent exists
7520 set endgrent d_endgrent
7521 eval $inlibc
7522
7523 : see if endhostent exists
7524 set endhostent d_endhent
7525 eval $inlibc
7526
7527 : see if endnetent exists
7528 set endnetent d_endnent
7529 eval $inlibc
7530
7531 : see if endprotoent exists
7532 set endprotoent d_endpent
7533 eval $inlibc
7534
7535 : see if endpwent exists
7536 set endpwent d_endpwent
7537 eval $inlibc
7538
7539 : see if endservent exists
7540 set endservent d_endsent
7541 eval $inlibc
7542
7543 : Locate the flags for 'open()'
7544 echo " "
7545 $cat >open3.c <<'EOCP'
7546 #include <sys/types.h>
7547 #ifdef I_FCNTL
7548 #include <fcntl.h>
7549 #endif
7550 #ifdef I_SYS_FILE
7551 #include <sys/file.h>
7552 #endif
7553 int main() {
7554         if(O_RDONLY);
7555 #ifdef O_TRUNC
7556         exit(0);
7557 #else
7558         exit(1);
7559 #endif
7560 }
7561 EOCP
7562 : check sys/file.h first to get FREAD on Sun
7563 if $test `./findhdr sys/file.h` && \
7564                 set open3 -DI_SYS_FILE && eval $compile; then
7565         h_sysfile=true;
7566         echo "<sys/file.h> defines the O_* constants..." >&4
7567         if ./open3; then
7568                 echo "and you have the 3 argument form of open()." >&4
7569                 val="$define"
7570         else
7571                 echo "but not the 3 argument form of open().  Oh, well." >&4
7572                 val="$undef"
7573         fi
7574 elif $test `./findhdr fcntl.h` && \
7575                 set open3 -DI_FCNTL && eval $compile; then
7576         h_fcntl=true;
7577         echo "<fcntl.h> defines the O_* constants..." >&4
7578         if ./open3; then
7579                 echo "and you have the 3 argument form of open()." >&4
7580                 val="$define"
7581         else
7582                 echo "but not the 3 argument form of open().  Oh, well." >&4
7583                 val="$undef"
7584         fi
7585 else
7586         val="$undef"
7587         echo "I can't find the O_* constant definitions!  You got problems." >&4
7588 fi
7589 set d_open3
7590 eval $setvar
7591 $rm -f open3*
7592
7593 : check for non-blocking I/O stuff
7594 case "$h_sysfile" in
7595 true) echo "#include <sys/file.h>" > head.c;;
7596 *)
7597         case "$h_fcntl" in
7598         true) echo "#include <fcntl.h>" > head.c;;
7599         *) echo "#include <sys/fcntl.h>" > head.c;;
7600         esac
7601         ;;
7602 esac
7603 echo " "
7604 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7605 case "$o_nonblock" in
7606 '')
7607         $cat head.c > try.c
7608         $cat >>try.c <<'EOCP'
7609 int main() {
7610 #ifdef O_NONBLOCK
7611         printf("O_NONBLOCK\n");
7612         exit(0);
7613 #endif
7614 #ifdef O_NDELAY
7615         printf("O_NDELAY\n");
7616         exit(0);
7617 #endif
7618 #ifdef FNDELAY
7619         printf("FNDELAY\n");
7620         exit(0);
7621 #endif
7622         exit(0);
7623 }
7624 EOCP
7625         set try
7626         if eval $compile_ok; then
7627                 o_nonblock=`./try`
7628                 case "$o_nonblock" in
7629                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7630                 *) echo "Seems like we can use $o_nonblock.";;
7631                 esac
7632         else
7633                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7634         fi
7635         ;;
7636 *) echo "Using $hint value $o_nonblock.";;
7637 esac
7638 $rm -f try try.* .out core
7639
7640 echo " "
7641 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7642 case "$eagain" in
7643 '')
7644         $cat head.c > try.c
7645         $cat >>try.c <<EOCP
7646 #include <errno.h>
7647 #include <sys/types.h>
7648 #include <signal.h>
7649 #define MY_O_NONBLOCK $o_nonblock
7650 #ifndef errno  /* XXX need better Configure test */
7651 extern int errno;
7652 #endif
7653 $signal_t blech(x) int x; { exit(3); }
7654 EOCP
7655         $cat >> try.c <<'EOCP'
7656 int main()
7657 {
7658         int pd[2];
7659         int pu[2];
7660         char buf[1];
7661         char string[100];
7662
7663         pipe(pd);       /* Down: child -> parent */
7664         pipe(pu);       /* Up: parent -> child */
7665         if (0 != fork()) {
7666                 int ret;
7667                 close(pd[1]);   /* Parent reads from pd[0] */
7668                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7669                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7670                         exit(1);
7671                 signal(SIGALRM, blech);
7672                 alarm(5);
7673                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7674                         exit(2);
7675                 sprintf(string, "%d\n", ret);
7676                 write(2, string, strlen(string));
7677                 alarm(0);
7678 #ifdef EAGAIN
7679                 if (errno == EAGAIN) {
7680                         printf("EAGAIN\n");
7681                         goto ok;
7682                 }
7683 #endif
7684 #ifdef EWOULDBLOCK
7685                 if (errno == EWOULDBLOCK)
7686                         printf("EWOULDBLOCK\n");
7687 #endif
7688         ok:
7689                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7690                 sleep(2);                               /* Give it time to close our pipe */
7691                 alarm(5);
7692                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7693                 alarm(0);
7694                 sprintf(string, "%d\n", ret);
7695                 write(3, string, strlen(string));
7696                 exit(0);
7697         }
7698
7699         close(pd[0]);                   /* We write to pd[1] */
7700         close(pu[1]);                   /* We read from pu[0] */
7701         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7702         close(pd[1]);                   /* Pipe pd is now fully closed! */
7703         exit(0);                                /* Bye bye, thank you for playing! */
7704 }
7705 EOCP
7706         set try
7707         if eval $compile_ok; then
7708                 echo "$startsh" >mtry
7709                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7710                 chmod +x mtry
7711                 ./mtry >/dev/null 2>&1
7712                 case $? in
7713                 0) eagain=`$cat try.out`;;
7714                 1) echo "Could not perform non-blocking setting!";;
7715                 2) echo "I did a successful read() for something that was not there!";;
7716                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7717                 *) echo "Something terribly wrong happened during testing.";;
7718                 esac
7719                 rd_nodata=`$cat try.ret`
7720                 echo "A read() system call with no data present returns $rd_nodata."
7721                 case "$rd_nodata" in
7722                 0|-1) ;;
7723                 *)
7724                         echo "(That's peculiar, fixing that to be -1.)"
7725                         rd_nodata=-1
7726                         ;;
7727                 esac
7728                 case "$eagain" in
7729                 '')
7730                         echo "Forcing errno EAGAIN on read() with no data available."
7731                         eagain=EAGAIN
7732                         ;;
7733                 *)
7734                         echo "Your read() sets errno to $eagain when no data is available."
7735                         ;;
7736                 esac
7737                 status=`$cat try.err`
7738                 case "$status" in
7739                 0) echo "And it correctly returns 0 to signal EOF.";;
7740                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7741                 *) echo "However, your read() returns '$status' on EOF??";;
7742                 esac
7743                 val="$define"
7744                 if test "$status" = "$rd_nodata"; then
7745                         echo "WARNING: you can't distinguish between EOF and no data!"
7746                         val="$undef"
7747                 fi
7748         else
7749                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7750                 eagain=EAGAIN
7751         fi
7752         set d_eofnblk
7753         eval $setvar
7754         ;;
7755 *)
7756         echo "Using $hint value $eagain."
7757         echo "Your read() returns $rd_nodata when no data is present."
7758         case "$d_eofnblk" in
7759         "$define") echo "And you can see EOF because read() returns 0.";;
7760         "$undef") echo "But you can't see EOF status from read() returned value.";;
7761         *)
7762                 echo "(Assuming you can't see EOF status from read anyway.)"
7763                 d_eofnblk=$undef
7764                 ;;
7765         esac
7766         ;;
7767 esac
7768 $rm -f try try.* .out core head.c mtry
7769
7770 : see if fchmod exists
7771 set fchmod d_fchmod
7772 eval $inlibc
7773
7774 : see if fchown exists
7775 set fchown d_fchown
7776 eval $inlibc
7777
7778 : see if this is an fcntl system
7779 set fcntl d_fcntl
7780 eval $inlibc
7781
7782 : see if sys/select.h has to be included
7783 set sys/select.h i_sysselct
7784 eval $inhdr
7785
7786 : see if we should include time.h, sys/time.h, or both
7787 echo " "
7788 if test "X$timeincl" = X; then
7789         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7790         $echo $n "I'm now running the test program...$c"
7791         $cat >try.c <<'EOCP'
7792 #include <sys/types.h>
7793 #ifdef I_TIME
7794 #include <time.h>
7795 #endif
7796 #ifdef I_SYSTIME
7797 #ifdef SYSTIMEKERNEL
7798 #define KERNEL
7799 #endif
7800 #include <sys/time.h>
7801 #endif
7802 #ifdef I_SYSSELECT
7803 #include <sys/select.h>
7804 #endif
7805 int main()
7806 {
7807         struct tm foo;
7808 #ifdef S_TIMEVAL
7809         struct timeval bar;
7810 #endif
7811 #ifdef S_TIMEZONE
7812         struct timezone tzp;
7813 #endif
7814         if (foo.tm_sec == foo.tm_sec)
7815                 exit(0);
7816 #ifdef S_TIMEVAL
7817         if (bar.tv_sec == bar.tv_sec)
7818                 exit(0);
7819 #endif
7820         exit(1);
7821 }
7822 EOCP
7823         flags=''
7824         for s_timezone in '-DS_TIMEZONE' ''; do
7825         sysselect=''
7826         for s_timeval in '-DS_TIMEVAL' ''; do
7827         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7828         for i_time in '' '-DI_TIME'; do
7829         for i_systime in '-DI_SYSTIME' ''; do
7830                 case "$flags" in
7831                 '') $echo $n ".$c"
7832                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7833                         if eval $compile; then
7834                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7835                                 shift
7836                                 flags="$*"
7837                                 echo " "
7838                                 $echo $n "Succeeded with $flags$c"
7839                         fi
7840                         ;;
7841                 esac
7842         done
7843         done
7844         done
7845         done
7846         done
7847         timeincl=''
7848         echo " "
7849         case "$flags" in
7850         *SYSTIMEKERNEL*) i_systimek="$define"
7851                 timeincl=`./findhdr sys/time.h`
7852                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7853         *) i_systimek="$undef";;
7854         esac
7855         case "$flags" in
7856         *I_TIME*) i_time="$define"
7857                 timeincl=`./findhdr time.h`" $timeincl"
7858                 echo "We'll include <time.h>." >&4;;
7859         *) i_time="$undef";;
7860         esac
7861         case "$flags" in
7862         *I_SYSTIME*) i_systime="$define"
7863                 timeincl=`./findhdr sys/time.h`" $timeincl"
7864                 echo "We'll include <sys/time.h>." >&4;;
7865         *) i_systime="$undef";;
7866         esac
7867         $rm -f try.c try
7868 fi
7869
7870 : check for fd_set items
7871 $cat <<EOM
7872
7873 Checking to see how well your C compiler handles fd_set and friends ...
7874 EOM
7875 $cat >fd_set.c <<EOCP
7876 #$i_systime I_SYS_TIME
7877 #$i_sysselct I_SYS_SELECT
7878 #$d_socket HAS_SOCKET
7879 #include <sys/types.h>
7880 #ifdef HAS_SOCKET
7881 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7882 #endif
7883 #ifdef I_SYS_TIME
7884 #include <sys/time.h>
7885 #endif
7886 #ifdef I_SYS_SELECT
7887 #include <sys/select.h>
7888 #endif
7889 int main() {
7890         fd_set fds;
7891
7892 #ifdef TRYBITS
7893         if(fds.fds_bits);
7894 #endif
7895
7896 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7897         exit(0);
7898 #else
7899         exit(1);
7900 #endif
7901 }
7902 EOCP
7903 set fd_set -DTRYBITS
7904 if eval $compile; then
7905         d_fds_bits="$define"
7906         d_fd_set="$define"
7907         echo "Well, your system knows about the normal fd_set typedef..." >&4
7908         if ./fd_set; then
7909                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7910                 d_fd_macros="$define"
7911         else
7912                 $cat >&4 <<'EOM'
7913 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7914 EOM
7915                 d_fd_macros="$undef"
7916         fi
7917 else
7918         $cat <<'EOM'
7919 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7920 EOM
7921         set fd_set
7922         if eval $compile; then
7923                 d_fds_bits="$undef"
7924                 d_fd_set="$define"
7925                 echo "Well, your system has some sort of fd_set available..." >&4
7926                 if ./fd_set; then
7927                         echo "and you have the normal fd_set macros." >&4
7928                         d_fd_macros="$define"
7929                 else
7930                         $cat <<'EOM'
7931 but not the normal fd_set macros!  Gross!  More work for me...
7932 EOM
7933                         d_fd_macros="$undef"
7934                 fi
7935         else
7936         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7937                 d_fd_set="$undef"
7938                 d_fds_bits="$undef"
7939                 d_fd_macros="$undef"
7940         fi
7941 fi
7942 $rm -f fd_set*
7943
7944 : see if fgetpos exists
7945 set fgetpos d_fgetpos
7946 eval $inlibc
7947
7948
7949 if $test X"$use64bits" = X"$define"; then
7950         : see if fgetpos64 exists
7951         set fgetpos64 d_fgetpos64
7952         eval $inlibc
7953
7954         : see if fopen64 exists
7955         set freopen64 d_fopen64
7956         eval $inlibc
7957
7958         : see if freopen64 exists
7959         set freopen64 d_freopen64
7960         eval $inlibc
7961
7962         : see if fseek64 exists
7963         set fseek64 d_fseek64
7964         eval $inlibc
7965
7966         : see if fseeko64 exists
7967         set fseeko64 d_fseeko64
7968         eval $inlibc
7969
7970         : see if fsetpos64 exists
7971         set fsetpos64 d_fsetpos64
7972         eval $inlibc
7973
7974         : see if ftell64 exists
7975         set ftell64 d_ftell64
7976         eval $inlibc
7977
7978         : see if ftello64 exists
7979         set ftello64 d_ftello64
7980         eval $inlibc
7981
7982         : see if tmpfile64 exists
7983         set tmpfile64 d_tmpfile64
7984         eval $inlibc
7985 else
7986         val="$undef"
7987         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
7988         do
7989                 set $xxx
7990                 eval $setvar
7991         done
7992 fi
7993
7994 : see if flock exists
7995 set flock d_flock
7996 eval $inlibc
7997
7998 : see if fork exists
7999 set fork d_fork
8000 eval $inlibc
8001
8002 : see if pathconf exists
8003 set pathconf d_pathconf
8004 eval $inlibc
8005
8006 : see if fpathconf exists
8007 set fpathconf d_fpathconf
8008 eval $inlibc
8009
8010 : see if fseeko exists
8011 set fseeko d_fseeko
8012 eval $inlibc
8013
8014 : see if fsetpos exists
8015 set fsetpos d_fsetpos
8016 eval $inlibc
8017
8018 : see if this is a sys/param system
8019 set sys/param.h i_sysparam
8020 eval $inhdr
8021
8022 : see if this is a sys/mount.h system
8023 set sys/mount.h i_sysmount
8024 eval $inhdr
8025
8026
8027 : see if statfs exists
8028 set statfs d_statfs
8029 eval $inlibc
8030
8031 : see if fstatfs exists
8032 set fstatfs d_fstatfs
8033 eval $inlibc
8034
8035 : see if statfs knows about mount flags
8036 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8037 eval $hasfield
8038
8039
8040 : see if statvfs exists
8041 set statvfs d_statvfs
8042 eval $inlibc
8043
8044 : see if fstatvfs exists
8045 set fstatvfs d_fstatvfs
8046 eval $inlibc
8047
8048
8049 : see if ftello exists
8050 set ftello d_ftello
8051 eval $inlibc
8052
8053 : see if getgrent exists
8054 set getgrent d_getgrent
8055 eval $inlibc
8056
8057 : see if gethostbyaddr exists
8058 set gethostbyaddr d_gethbyaddr
8059 eval $inlibc
8060
8061 : see if gethostbyname exists
8062 set gethostbyname d_gethbyname
8063 eval $inlibc
8064
8065 : see if gethostent exists
8066 set gethostent d_gethent
8067 eval $inlibc
8068
8069 : see how we will look up host name
8070 echo " "
8071 if false; then
8072         : dummy stub to allow use of elif
8073 elif set gethostname val -f d_gethname; eval $csym; $val; then
8074         echo 'gethostname() found.' >&4
8075         d_gethname="$define"
8076         call=gethostname
8077 elif set uname val -f d_uname; eval $csym; $val; then
8078         if ./xenix; then
8079                 $cat <<'EOM'
8080 uname() was found, but you're running xenix, and older versions of xenix
8081 have a broken uname(). If you don't really know whether your xenix is old
8082 enough to have a broken system call, use the default answer.
8083
8084 EOM
8085                 dflt=y
8086                 case "$d_uname" in
8087                 "$define") dflt=n;;
8088                 esac
8089                 rp='Is your uname() broken?'
8090                 . ./myread
8091                 case "$ans" in
8092                 n*) d_uname="$define"; call=uname;;
8093                 esac
8094         else
8095                 echo 'uname() found.' >&4
8096                 d_uname="$define"
8097                 call=uname
8098         fi
8099 fi
8100 case "$d_gethname" in
8101 '') d_gethname="$undef";;
8102 esac
8103 case "$d_uname" in
8104 '') d_uname="$undef";;
8105 esac
8106 case "$d_uname$d_gethname" in
8107 *define*)
8108         dflt=n
8109         cat <<EOM
8110  
8111 Every now and then someone has a $call() that lies about the hostname
8112 but can't be fixed for political or economic reasons.  If you wish, I can
8113 pretend $call() isn't there and maybe compute hostname at run-time
8114 thanks to the '$phostname' command.
8115
8116 EOM
8117         rp="Shall I ignore $call() from now on?"
8118         . ./myread
8119         case "$ans" in
8120         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8121         esac;;
8122 esac
8123 case "$phostname" in
8124 '') aphostname='';;
8125 *) case "$aphostname" in
8126         /*) ;;
8127         *) set X $phostname
8128                 shift
8129                 file=$1
8130                 shift
8131                 file=`./loc $file $file $pth`
8132                 aphostname=`echo $file $*`
8133                 ;;
8134         esac
8135         ;;
8136 esac
8137 case "$d_uname$d_gethname" in
8138 *define*) ;;
8139 *)
8140         case "$phostname" in
8141         '')
8142                 echo "There will be no way for $package to get your hostname." >&4;;
8143         *)
8144         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8145                 ;;
8146         esac;;
8147 esac
8148 case "$d_phostname" in
8149 '') d_phostname="$undef";;
8150 esac
8151
8152 : see if this is a netdb.h system
8153 set netdb.h i_netdb
8154 eval $inhdr
8155
8156 : see if prototypes for various gethostxxx netdb.h functions are available
8157 echo " "
8158 set d_gethostprotos gethostent $i_netdb netdb.h
8159 eval $hasproto
8160
8161 : see if getlogin exists
8162 set getlogin d_getlogin
8163 eval $inlibc
8164
8165 : see if getmntent exists
8166 set getmntent d_getmntent
8167 eval $inlibc
8168
8169 : see if getnetbyaddr exists
8170 set getnetbyaddr d_getnbyaddr
8171 eval $inlibc
8172
8173 : see if getnetbyname exists
8174 set getnetbyname d_getnbyname
8175 eval $inlibc
8176
8177 : see if getnetent exists
8178 set getnetent d_getnent
8179 eval $inlibc
8180
8181 : see if prototypes for various getnetxxx netdb.h functions are available
8182 echo " "
8183 set d_getnetprotos getnetent $i_netdb netdb.h
8184 eval $hasproto
8185
8186
8187 : see if getprotobyname exists
8188 set getprotobyname d_getpbyname
8189 eval $inlibc
8190
8191 : see if getprotobynumber exists
8192 set getprotobynumber d_getpbynumber
8193 eval $inlibc
8194
8195 : see if getprotoent exists
8196 set getprotoent d_getpent
8197 eval $inlibc
8198
8199 : see if getpgid exists
8200 set getpgid d_getpgid
8201 eval $inlibc
8202
8203 : see if getpgrp2 exists
8204 set getpgrp2 d_getpgrp2
8205 eval $inlibc
8206
8207 : see if getppid exists
8208 set getppid d_getppid
8209 eval $inlibc
8210
8211 : see if getpriority exists
8212 set getpriority d_getprior
8213 eval $inlibc
8214
8215 : see if prototypes for various getprotoxxx netdb.h functions are available
8216 echo " "
8217 set d_getprotoprotos getprotoent $i_netdb netdb.h
8218 eval $hasproto
8219
8220 : see if getpwent exists
8221 set getpwent d_getpwent
8222 eval $inlibc
8223
8224
8225 : see if getservbyname exists
8226 set getservbyname d_getsbyname
8227 eval $inlibc
8228
8229 : see if getservbyport exists
8230 set getservbyport d_getsbyport
8231 eval $inlibc
8232
8233 : see if getservent exists
8234 set getservent d_getsent
8235 eval $inlibc
8236
8237 : see if prototypes for various getservxxx netdb.h functions are available
8238 echo " "
8239 set d_getservprotos getservent $i_netdb netdb.h
8240 eval $hasproto
8241
8242 : see if gettimeofday or ftime exists
8243 set gettimeofday d_gettimeod
8244 eval $inlibc
8245 case "$d_gettimeod" in
8246 "$undef")
8247         set ftime d_ftime 
8248         eval $inlibc
8249         ;;
8250 *)
8251         val="$undef"; set d_ftime; eval $setvar
8252         ;;
8253 esac
8254 case "$d_gettimeod$d_ftime" in
8255 "$undef$undef")
8256         echo " "
8257         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8258         ;;
8259 esac
8260
8261 : see if this is an grp system
8262 set grp.h i_grp
8263 eval $inhdr
8264
8265 case "$i_grp" in
8266 $define)
8267         xxx=`./findhdr grp.h`
8268         $cppstdin $cppflags $cppminus < $xxx >$$.h
8269
8270         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8271                 val="$define"
8272         else
8273                 val="$undef"
8274         fi
8275         set d_grpasswd
8276         eval $setvar
8277
8278         $rm -f $$.h
8279         ;;
8280 *)
8281         val="$undef";
8282         set d_grpasswd; eval $setvar
8283         ;;
8284 esac
8285
8286 : see if hasmntopt exists
8287 set hasmntopt d_hasmntopt
8288 eval $inlibc
8289
8290 : see if this is a netinet/in.h or sys/in.h system
8291 set netinet/in.h i_niin sys/in.h i_sysin
8292 eval $inhdr
8293
8294 : see if arpa/inet.h has to be included
8295 set arpa/inet.h i_arpainet
8296 eval $inhdr
8297
8298 : see if htonl --and friends-- exists
8299 val=''
8300 set htonl val
8301 eval $inlibc
8302
8303 : Maybe they are macros.
8304 case "$val" in
8305 $undef)
8306         $cat >htonl.c <<EOM
8307 #include <stdio.h>
8308 #include <sys/types.h>
8309 #$i_niin I_NETINET_IN
8310 #$i_sysin I_SYS_IN
8311 #$i_arpainet I_ARPA_INET
8312 #ifdef I_NETINET_IN
8313 #include <netinet/in.h>
8314 #endif
8315 #ifdef I_SYS_IN
8316 #include <sys/in.h>
8317 #endif
8318 #ifdef I_ARPA_INET
8319 #include <arpa/inet.h>
8320 #endif
8321 #ifdef htonl
8322 printf("Defined as a macro.");
8323 #endif
8324 EOM
8325         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8326         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8327                 val="$define"
8328                 echo "But it seems to be defined as a macro." >&4
8329         fi
8330         $rm -f htonl.?
8331         ;;
8332 esac
8333 set d_htonl
8334 eval $setvar
8335
8336 : see which of string.h or strings.h is needed
8337 echo " "
8338 strings=`./findhdr string.h`
8339 if $test "$strings" && $test -r "$strings"; then
8340         echo "Using <string.h> instead of <strings.h>." >&4
8341         val="$define"
8342 else
8343         val="$undef"
8344         strings=`./findhdr strings.h`
8345         if $test "$strings" && $test -r "$strings"; then
8346                 echo "Using <strings.h> instead of <string.h>." >&4
8347         else
8348                 echo "No string header found -- You'll surely have problems." >&4
8349         fi
8350 fi
8351 set i_string
8352 eval $setvar
8353 case "$i_string" in
8354 "$undef") strings=`./findhdr strings.h`;;
8355 *)        strings=`./findhdr string.h`;;
8356 esac
8357
8358 : index or strchr
8359 echo " "
8360 if set index val -f; eval $csym; $val; then
8361         if set strchr val -f d_strchr; eval $csym; $val; then
8362                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8363                         val="$define"
8364                         vali="$undef"
8365                         echo "strchr() found." >&4
8366                 else
8367                         val="$undef"
8368                         vali="$define"
8369                         echo "index() found." >&4
8370                 fi
8371         else
8372                 val="$undef"
8373                 vali="$define"
8374                 echo "index() found." >&4
8375         fi
8376 else
8377         if set strchr val -f d_strchr; eval $csym; $val; then
8378                 val="$define"
8379                 vali="$undef"
8380                 echo "strchr() found." >&4
8381         else
8382                 echo "No index() or strchr() found!" >&4
8383                 val="$undef"
8384                 vali="$undef"
8385         fi
8386 fi
8387 set d_strchr; eval $setvar
8388 val="$vali"
8389 set d_index; eval $setvar
8390
8391 : check whether inet_aton exists
8392 set inet_aton d_inetaton
8393 eval $inlibc
8394
8395 : see if inttypes.h is available
8396 : we want a real compile instead of Inhdr because some systems
8397 : have an inttypes.h which includes non-existent headers
8398 echo " "
8399 $cat >try.c <<EOCP
8400 #include <inttypes.h>
8401 int main() {
8402         static int32_t foo32 = 0x12345678;
8403 }
8404 EOCP
8405 set try
8406 if eval $compile; then
8407         echo "<inttypes.h> found." >&4
8408         val="$define"
8409 else
8410         echo "<inttypes.h> NOT found." >&4
8411         val="$undef"
8412 fi
8413 $rm -f try.c try
8414 set i_inttypes
8415 eval $setvar
8416
8417 : check for int64_t
8418 case "$use64bits" in
8419 "$define" )
8420         echo " "
8421         echo $n "Checking to see if your system supports int64_t...$c" >&4
8422         $cat >try.c <<EOCP
8423 #include <sys/types.h>
8424 #$i_inttypes I_INTTYPES
8425 #ifdef I_INTTYPES
8426 #include <inttypes.h>
8427 #endif
8428 int64_t foo() { int64_t x; x = 7; return x; }
8429 EOCP
8430         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8431                 val="$define"
8432                 echo " Yup, it does." >&4
8433         else
8434                 val="$undef"
8435                 echo " Nope, it doesn't." >&4
8436         fi
8437         $rm -f try.*
8438         ;;
8439 *)      val="$undef"
8440         ;;
8441 esac
8442 set d_int64t
8443 eval $setvar
8444
8445
8446 : Look for isascii
8447 echo " "
8448 $cat >isascii.c <<'EOCP'
8449 #include <stdio.h>
8450 #include <ctype.h>
8451 int main() {
8452         int c = 'A';
8453         if (isascii(c))
8454                 exit(0);
8455         else
8456                 exit(1);
8457 }
8458 EOCP
8459 set isascii
8460 if eval $compile; then
8461         echo "isascii() found." >&4
8462         val="$define"
8463 else
8464         echo "isascii() NOT found." >&4
8465         val="$undef"
8466 fi
8467 set d_isascii
8468 eval $setvar
8469 $rm -f isascii*
8470
8471 : see if killpg exists
8472 set killpg d_killpg
8473 eval $inlibc
8474
8475 : see if lchown exists
8476 echo " "
8477 $cat > try.c <<'EOCP'
8478 /* System header to define __stub macros and hopefully few prototypes,
8479     which can conflict with char lchown(); below.  */
8480 #include <assert.h>
8481 /* Override any gcc2 internal prototype to avoid an error.  */
8482 /* We use char because int might match the return type of a gcc2
8483    builtin and then its argument prototype would still apply.  */
8484 char lchown();
8485 int main() {
8486     /*  The GNU C library defines this for functions which it implements
8487         to always fail with ENOSYS.  Some functions are actually named
8488         something starting with __ and the normal name is an alias.  */
8489 #if defined (__stub_lchown) || defined (__stub___lchown)
8490 choke me
8491 #else
8492 lchown();
8493 #endif
8494 ; return 0; }
8495 EOCP
8496 set try
8497 if eval $compile; then
8498     $echo "lchown() found." >&4
8499     val="$define"
8500 else
8501     $echo "lchown() NOT found." >&4
8502     val="$undef"
8503 fi
8504 set d_lchown
8505 eval $setvar
8506
8507 : see if link exists
8508 set link d_link
8509 eval $inlibc
8510
8511 : see if localeconv exists
8512 set localeconv d_locconv
8513 eval $inlibc
8514
8515 : see if lockf exists
8516 set lockf d_lockf
8517 eval $inlibc
8518
8519 : check for length of double
8520 echo " "
8521 case "$doublesize" in
8522 '')
8523         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8524         $cat >try.c <<'EOCP'
8525 #include <stdio.h>
8526 int main()
8527 {
8528         printf("%d\n", sizeof(double));
8529 }
8530 EOCP
8531         set try
8532         if eval $compile_ok; then
8533                 doublesize=`./try`
8534                 $echo " $doublesize bytes." >&4
8535         else
8536                 dflt='8'
8537                 echo "(I can't seem to compile the test program.  Guessing...)"
8538                 rp="What is the size of a double precision number (in bytes)?"
8539                 . ./myread
8540                 doublesize="$ans"
8541         fi
8542         ;;
8543 esac
8544 $rm -f try.c try
8545
8546 : check for long doubles
8547 echo " "
8548 echo $n "Checking to see if your system supports long doubles...$c" >&4
8549 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8550 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8551         val="$define"
8552         echo " Yup, it does." >&4
8553 else
8554         val="$undef"
8555         echo " Nope, it doesn't." >&4
8556 fi
8557 $rm try.*
8558 set d_longdbl
8559 eval $setvar
8560
8561 : check for length of long double
8562 case "${d_longdbl}${longdblsize}" in
8563 $define)
8564         echo " "
8565         $echo $n "Checking to see how big your long doubles are...$c" >&4
8566         $cat >try.c <<'EOCP'
8567 #include <stdio.h>
8568 int main()
8569 {
8570         printf("%d\n", sizeof(long double));
8571 }
8572 EOCP
8573         set try
8574         if eval $compile; then
8575                 longdblsize=`./try`
8576                 $echo " $longdblsize bytes." >&4
8577         else
8578                 dflt='8'
8579                 echo " "
8580                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8581                 rp="What is the size of a long double (in bytes)?"
8582                 . ./myread
8583                 longdblsize="$ans"
8584         fi
8585         if $test "X$doublesize" = "X$longdblsize"; then
8586                 echo "(That isn't any different from an ordinary double.)"
8587         fi      
8588         ;;
8589 esac
8590 $rm -f try.c try
8591
8592 : check for long long
8593 echo " "
8594 echo $n "Checking to see if your system supports long long...$c" >&4
8595 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8596 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8597         val="$define"
8598         echo " Yup, it does." >&4
8599 else
8600         val="$undef"
8601         echo " Nope, it doesn't." >&4
8602 fi
8603 $rm try.*
8604 set d_longlong
8605 eval $setvar
8606
8607 : check for length of long long
8608 case "${d_longlong}${longlongsize}" in
8609 $define)
8610         echo " "
8611         $echo $n "Checking to see how big your long longs are...$c" >&4
8612         $cat >try.c <<'EOCP'
8613 #include <stdio.h>
8614 int main()
8615 {
8616         printf("%d\n", sizeof(long long));
8617 }
8618 EOCP
8619         set try
8620         if eval $compile_ok; then
8621                 longlongsize=`./try`
8622                 $echo " $longlongsize bytes." >&4
8623         else
8624                 dflt='8'
8625                 echo " "
8626                 echo "(I can't seem to compile the test program.  Guessing...)"
8627                 rp="What is the size of a long long (in bytes)?"
8628                 . ./myread
8629                 longlongsize="$ans"
8630         fi
8631         if $test "X$longsize" = "X$longlongsize"; then
8632                 echo "(That isn't any different from an ordinary long.)"
8633         fi      
8634         ;;
8635 esac
8636 $rm -f try.c try
8637
8638 : see if lstat exists
8639 set lstat d_lstat
8640 eval $inlibc
8641
8642 : see if madvise exists
8643 set madvise d_madvise
8644 eval $inlibc
8645
8646 : see if mblen exists
8647 set mblen d_mblen
8648 eval $inlibc
8649
8650 : see if mbstowcs exists
8651 set mbstowcs d_mbstowcs
8652 eval $inlibc
8653
8654 : see if mbtowc exists
8655 set mbtowc d_mbtowc
8656 eval $inlibc
8657
8658 : see if memcmp exists
8659 set memcmp d_memcmp
8660 eval $inlibc
8661
8662 : see if memcpy exists
8663 set memcpy d_memcpy
8664 eval $inlibc
8665
8666 : see if memmove exists
8667 set memmove d_memmove
8668 eval $inlibc
8669
8670 : see if memset exists
8671 set memset d_memset
8672 eval $inlibc
8673
8674 : see if mkdir exists
8675 set mkdir d_mkdir
8676 eval $inlibc
8677
8678 : see if mkfifo exists
8679 set mkfifo d_mkfifo
8680 eval $inlibc
8681
8682 : see if mktime exists
8683 set mktime d_mktime
8684 eval $inlibc
8685
8686 : see if this is a sys/mman.h system
8687 set sys/mman.h i_sysmman
8688 eval $inhdr
8689
8690 : see if mmap exists
8691 set mmap d_mmap
8692 eval $inlibc
8693 : see what shmat returns
8694 : default to something harmless
8695 mmaptype='void *'
8696 case "$i_sysmman$d_mmap" in
8697 "$define$define")
8698         $cat >mmap.c <<'END'
8699 #include <sys/mman.h>
8700 void *mmap();
8701 END
8702         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8703                 mmaptype='void *'
8704         else
8705                 mmaptype='caddr_t'
8706         fi
8707         echo "and it returns ($mmaptype)." >&4
8708         ;;
8709 esac
8710
8711
8712
8713 : see if mprotect exists
8714 set mprotect d_mprotect
8715 eval $inlibc
8716
8717 : see if msgctl exists
8718 set msgctl d_msgctl
8719 eval $inlibc
8720
8721 : see if msgget exists
8722 set msgget d_msgget
8723 eval $inlibc
8724
8725 : see if msgsnd exists
8726 set msgsnd d_msgsnd
8727 eval $inlibc
8728
8729 : see if msgrcv exists
8730 set msgrcv d_msgrcv
8731 eval $inlibc
8732
8733 : see how much of the 'msg*(2)' library is present.
8734 h_msg=true
8735 echo " "
8736 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8737 *"$undef"*) h_msg=false;;
8738 esac
8739 case "$osname" in
8740 freebsd)
8741     case "`ipcs 2>&1`" in
8742     "SVID messages"*"not configured"*)
8743         echo "Your $osname does not have the msg*(2) configured." >&4
8744         h_msg=false
8745         val="$undef"
8746         set msgctl d_msgctl
8747         eval $setvar
8748         set msgget d_msgget
8749         eval $setvar
8750         set msgsnd d_msgsnd
8751         eval $setvar
8752         set msgrcv d_msgrcv
8753         eval $setvar
8754         ;;
8755     esac
8756     ;;
8757 esac
8758 : we could also check for sys/ipc.h ...
8759 if $h_msg && $test `./findhdr sys/msg.h`; then
8760         echo "You have the full msg*(2) library." >&4
8761         val="$define"
8762 else
8763         echo "You don't have the full msg*(2) library." >&4
8764         val="$undef"
8765 fi
8766 set d_msg
8767 eval $setvar
8768
8769 : see if msync exists
8770 set msync d_msync
8771 eval $inlibc
8772
8773 : see if munmap exists
8774 set munmap d_munmap
8775 eval $inlibc
8776
8777 : see if nice exists
8778 set nice d_nice
8779 eval $inlibc
8780
8781 : how to create joinable pthreads
8782 if test "X$usethreads" = "X$define"; then
8783         echo " "
8784         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8785         $cat >try.c <<'EOCP'
8786 #include <pthread.h>
8787 int main() {
8788     int detachstate = JOINABLE;
8789 }
8790 EOCP
8791         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8792         if eval $compile; then
8793                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8794                 val="$undef" # Yes, undef.
8795                 set d_old_pthread_create_joinable
8796                 eval $setvar
8797                 val=""
8798                 set old_pthread_create_joinable
8799                 eval $setvar
8800         else
8801                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8802                 if eval $compile; then
8803                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8804                         val="$define"
8805                         set d_old_pthread_create_joinable
8806                         eval $setvar
8807                         val=PTHREAD_CREATE_UNDETACHED
8808                         set old_pthread_create_joinable
8809                         eval $setvar
8810                 else            
8811                         set try -DJOINABLE=__UNDETACHED
8812                         if eval $compile; then
8813                                 echo "You seem to use __UNDETACHED." >&4
8814                                 val="$define"
8815                                 set d_old_pthread_create_joinable
8816                                 eval $setvar
8817                                 val=__UNDETACHED
8818                                 set old_pthread_create_joinable
8819                                 eval $setvar
8820                         else
8821                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8822                                 val="$define"
8823                                 set d_old_pthread_create_joinable
8824                                 eval $setvar
8825                                 val=0
8826                                 set old_pthread_create_joinable
8827                                 eval $setvar
8828                         fi
8829                 fi
8830         fi
8831         $rm -f try try.*
8832 else
8833     d_old_pthread_create_joinable="$undef"
8834     old_pthread_create_joinable=""
8835 fi
8836
8837 : see if pause exists
8838 set pause d_pause
8839 eval $inlibc
8840
8841 : see if pipe exists
8842 set pipe d_pipe
8843 eval $inlibc
8844
8845 : see if poll exists
8846 set poll d_poll
8847 eval $inlibc
8848
8849
8850 : see whether the various POSIXish _yields exist
8851 $cat >try.c <<EOP
8852 #include <pthread.h>
8853 #include <stdio.h>
8854 int main() {
8855 #ifdef SCHED_YIELD
8856         sched_yield();
8857 #else
8858 #ifdef PTHREAD_YIELD
8859         pthread_yield();
8860 #else
8861 #ifdef PTHREAD_YIELD_NULL
8862         pthread_yield(NULL);
8863 #endif
8864 #endif
8865 #endif
8866 }
8867 EOP
8868 : see if sched_yield exists
8869 set try -DSCHED_YIELD
8870 if eval $compile; then
8871     val="$define"
8872     sched_yield='sched_yield()'
8873 else
8874     val="$undef"
8875 fi
8876 case "$usethreads" in
8877 $define)
8878         case "$val" in
8879         $define) echo 'sched_yield() found.' >&4        ;;
8880         *)       echo 'sched_yield() NOT found.' >&4    ;;
8881         esac
8882 esac
8883 set d_sched_yield
8884 eval $setvar
8885
8886 : see if pthread_yield exists
8887 set try -DPTHREAD_YIELD
8888 if eval $compile; then
8889     val="$define"
8890     case "$sched_yield" in
8891     '') sched_yield='pthread_yield()' ;;
8892     esac
8893 else
8894     set try -DPTHREAD_YIELD_NULL
8895     if eval $compile; then
8896         val="$define"
8897         case "$sched_yield" in
8898         '') sched_yield='pthread_yield(NULL)' ;;
8899         esac
8900     else
8901         val="$undef"
8902     fi
8903 fi
8904 case "$usethreads" in
8905 $define)
8906         case "$val" in
8907         $define) echo 'pthread_yield() found.' >&4      ;;
8908         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8909         esac
8910         ;;
8911 esac
8912 set d_pthread_yield
8913 eval $setvar
8914
8915 case "$sched_yield" in
8916 '') sched_yield=undef ;;
8917 esac
8918
8919 $rm -f try try.*
8920
8921 : see if this is a pwd.h system
8922 set pwd.h i_pwd
8923 eval $inhdr
8924
8925 case "$i_pwd" in
8926 $define)
8927         xxx=`./findhdr pwd.h`
8928         $cppstdin $cppflags $cppminus < $xxx >$$.h
8929
8930         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8931                 val="$define"
8932         else
8933                 val="$undef"
8934         fi
8935         set d_pwquota
8936         eval $setvar
8937
8938         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
8939                 val="$define"
8940         else
8941                 val="$undef"
8942         fi
8943         set d_pwage
8944         eval $setvar
8945
8946         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
8947                 val="$define"
8948         else
8949                 val="$undef"
8950         fi
8951         set d_pwchange
8952         eval $setvar
8953
8954         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
8955                 val="$define"
8956         else
8957                 val="$undef"
8958         fi
8959         set d_pwclass
8960         eval $setvar
8961
8962         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
8963                 val="$define"
8964         else
8965                 val="$undef"
8966         fi
8967         set d_pwexpire
8968         eval $setvar
8969
8970         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
8971                 val="$define"
8972         else
8973                 val="$undef"
8974         fi
8975         set d_pwcomment
8976         eval $setvar
8977
8978         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
8979                 val="$define"
8980         else
8981                 val="$undef"
8982         fi
8983         set d_pwgecos
8984         eval $setvar
8985
8986         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
8987                 val="$define"
8988         else
8989                 val="$undef"
8990         fi
8991         set d_pwpasswd
8992         eval $setvar
8993
8994         $rm -f $$.h
8995         ;;
8996 *)
8997         val="$undef"; 
8998         set d_pwquota; eval $setvar
8999         set d_pwage; eval $setvar
9000         set d_pwchange; eval $setvar
9001         set d_pwclass; eval $setvar
9002         set d_pwexpire; eval $setvar
9003         set d_pwcomment; eval $setvar
9004         set d_pwgecos; eval $setvar
9005         set d_pwpasswd; eval $setvar
9006         ;;
9007 esac
9008
9009 : see if readdir and friends exist
9010 set readdir d_readdir
9011 eval $inlibc
9012 set seekdir d_seekdir
9013 eval $inlibc
9014 set telldir d_telldir
9015 eval $inlibc
9016 set rewinddir d_rewinddir
9017 eval $inlibc
9018
9019 : see if readlink exists
9020 set readlink d_readlink
9021 eval $inlibc
9022
9023 : see if readv exists
9024 set readv d_readv
9025 eval $inlibc
9026
9027 : see if rename exists
9028 set rename d_rename
9029 eval $inlibc
9030
9031 : see if rmdir exists
9032 set rmdir d_rmdir
9033 eval $inlibc
9034
9035 : see if memory.h is available.
9036 val=''
9037 set memory.h val
9038 eval $inhdr
9039
9040 : See if it conflicts with string.h
9041 case "$val" in
9042 $define)
9043         case "$strings" in
9044         '') ;;
9045         *)
9046                 $cppstdin $cppflags $cppminus < $strings > mem.h
9047                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9048                         echo " "
9049                         echo "We won't be including <memory.h>."
9050                         val="$undef"
9051                 fi
9052                 $rm -f mem.h
9053                 ;;
9054         esac
9055 esac
9056 set i_memory
9057 eval $setvar
9058
9059 : can bcopy handle overlapping blocks?
9060 val="$undef"
9061 case "$d_bcopy" in
9062 "$define")
9063         echo " "
9064         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9065         $cat >try.c <<EOCP
9066 #$i_memory I_MEMORY
9067 #$i_stdlib I_STDLIB
9068 #$i_string I_STRING
9069 #$i_unistd I_UNISTD
9070 EOCP
9071         $cat >>try.c <<'EOCP'
9072 #include <stdio.h>
9073 #ifdef I_MEMORY
9074 #  include <memory.h>
9075 #endif
9076 #ifdef I_STDLIB
9077 #  include <stdlib.h>
9078 #endif
9079 #ifdef I_STRING
9080 #  include <string.h>
9081 #else
9082 #  include <strings.h>
9083 #endif
9084 #ifdef I_UNISTD
9085 #  include <unistd.h>  /* Needed for NetBSD */
9086 #endif
9087 int main()
9088 {
9089 char buf[128], abc[128];
9090 char *b;
9091 int len;
9092 int off;
9093 int align;
9094
9095 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9096
9097 for (align = 7; align >= 0; align--) {
9098         for (len = 36; len; len--) {
9099                 b = buf+align;
9100                 bcopy(abc, b, len);
9101                 for (off = 1; off <= len; off++) {
9102                         bcopy(b, b+off, len);
9103                         bcopy(b+off, b, len);
9104                         if (bcmp(b, abc, len))
9105                                 exit(1);
9106                 }
9107         }
9108 }
9109 exit(0);
9110 }
9111 EOCP
9112         set try
9113         if eval $compile_ok; then
9114                 if ./try 2>/dev/null; then
9115                         echo "Yes, it can."
9116                         val="$define"
9117                 else
9118                         echo "It can't, sorry."
9119                         case "$d_memmove" in
9120                         "$define") echo "But that's Ok since you have memmove()." ;;
9121                         esac
9122                 fi
9123         else
9124                 echo "(I can't compile the test program, so we'll assume not...)"
9125                 case "$d_memmove" in
9126                 "$define") echo "But that's Ok since you have memmove()." ;;
9127                 esac
9128         fi
9129         ;;
9130 esac
9131 $rm -f try.* try core
9132 set d_safebcpy
9133 eval $setvar
9134
9135 : can memcpy handle overlapping blocks?
9136 val="$undef"
9137 case "$d_memcpy" in
9138 "$define")
9139         echo " "
9140         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9141         $cat >try.c <<EOCP
9142 #$i_memory I_MEMORY
9143 #$i_stdlib I_STDLIB
9144 #$i_string I_STRING
9145 #$i_unistd I_UNISTD
9146 EOCP
9147         $cat >>try.c <<'EOCP'
9148 #include <stdio.h>
9149 #ifdef I_MEMORY
9150 #  include <memory.h>
9151 #endif
9152 #ifdef I_STDLIB
9153 #  include <stdlib.h>
9154 #endif
9155 #ifdef I_STRING
9156 #  include <string.h>
9157 #else
9158 #  include <strings.h>
9159 #endif
9160 #ifdef I_UNISTD
9161 #  include <unistd.h>  /* Needed for NetBSD */
9162 #endif
9163 int main()
9164 {
9165 char buf[128], abc[128];
9166 char *b;
9167 int len;
9168 int off;
9169 int align;
9170
9171 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9172    try to store the string in read-only memory. */
9173 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9174
9175 for (align = 7; align >= 0; align--) {
9176         for (len = 36; len; len--) {
9177                 b = buf+align;
9178                 memcpy(b, abc, len);
9179                 for (off = 1; off <= len; off++) {
9180                         memcpy(b+off, b, len);
9181                         memcpy(b, b+off, len);
9182                         if (memcmp(b, abc, len))
9183                                 exit(1);
9184                 }
9185         }
9186 }
9187 exit(0);
9188 }
9189 EOCP
9190         set try
9191         if eval $compile_ok; then
9192                 if ./try 2>/dev/null; then
9193                         echo "Yes, it can."
9194                         val="$define"
9195                 else
9196                         echo "It can't, sorry."
9197                         case "$d_memmove" in
9198                         "$define") echo "But that's Ok since you have memmove()." ;;
9199                         esac
9200                 fi
9201         else
9202                 echo "(I can't compile the test program, so we'll assume not...)"
9203                 case "$d_memmove" in
9204                 "$define") echo "But that's Ok since you have memmove()." ;;
9205                 esac
9206         fi
9207         ;;
9208 esac
9209 $rm -f try.* try core
9210 set d_safemcpy
9211 eval $setvar
9212
9213 : can memcmp be trusted to compare relative magnitude?
9214 val="$undef"
9215 case "$d_memcmp" in
9216 "$define")
9217         echo " "
9218         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9219         $cat >try.c <<EOCP
9220 #$i_memory I_MEMORY
9221 #$i_stdlib I_STDLIB
9222 #$i_string I_STRING
9223 #$i_unistd I_UNISTD
9224 EOCP
9225         $cat >>try.c <<'EOCP'
9226 #include <stdio.h>
9227 #ifdef I_MEMORY
9228 #  include <memory.h>
9229 #endif
9230 #ifdef I_STDLIB
9231 #  include <stdlib.h>
9232 #endif
9233 #ifdef I_STRING
9234 #  include <string.h>
9235 #else
9236 #  include <strings.h>
9237 #endif
9238 #ifdef I_UNISTD
9239 #  include <unistd.h>  /* Needed for NetBSD */
9240 #endif
9241 int main()
9242 {
9243 char a = -1;
9244 char b = 0;
9245 if ((a < b) && memcmp(&a, &b, 1) < 0)
9246         exit(1);
9247 exit(0);
9248 }
9249 EOCP
9250         set try
9251         if eval $compile_ok; then
9252                 if ./try 2>/dev/null; then
9253                         echo "Yes, it can."
9254                         val="$define"
9255                 else
9256                         echo "No, it can't (it uses signed chars)."
9257                 fi
9258         else
9259                 echo "(I can't compile the test program, so we'll assume not...)"
9260         fi
9261         ;;
9262 esac
9263 $rm -f try.* try core
9264 set d_sanemcmp
9265 eval $setvar
9266
9267 : see if select exists
9268 set select d_select
9269 eval $inlibc
9270
9271 : see if semctl exists
9272 set semctl d_semctl
9273 eval $inlibc
9274
9275 : see if semget exists
9276 set semget d_semget
9277 eval $inlibc
9278
9279 : see if semop exists
9280 set semop d_semop
9281 eval $inlibc
9282
9283 : see how much of the 'sem*(2)' library is present.
9284 h_sem=true
9285 echo " "
9286 case "$d_semctl$d_semget$d_semop" in
9287 *"$undef"*) h_sem=false;;
9288 esac
9289 case "$osname" in
9290 freebsd)
9291     case "`ipcs 2>&1`" in
9292     "SVID messages"*"not configured"*)
9293         echo "Your $osname does not have the sem*(2) configured." >&4
9294         h_sem=false
9295         val="$undef"
9296         set semctl d_semctl
9297         eval $setvar
9298         set semget d_semget
9299         eval $setvar
9300         set semop d_semop
9301         eval $setvar
9302         ;;
9303     esac
9304     ;;
9305 esac
9306 : we could also check for sys/ipc.h ...
9307 if $h_sem && $test `./findhdr sys/sem.h`; then
9308         echo "You have the full sem*(2) library." >&4
9309         val="$define"
9310 else
9311         echo "You don't have the full sem*(2) library." >&4
9312         val="$undef"
9313 fi
9314 set d_sem
9315 eval $setvar
9316
9317 : see whether sys/sem.h defines union semun
9318 echo " "
9319 $cat > try.c <<'END'
9320 #include <sys/types.h>
9321 #include <sys/ipc.h>
9322 #include <sys/sem.h>
9323 int main () { union semun semun; semun.buf = 0; }
9324 END
9325 set try
9326 if eval $compile; then
9327     echo "You have union semun in <sys/sem.h>." >&4
9328     val="$define"
9329 else
9330     echo "You do not have union semun in <sys/sem.h>." >&4
9331     val="$undef"
9332 fi
9333 $rm -f try try.c try.h
9334 set d_union_semun
9335 eval $setvar
9336
9337 : see how to do semctl IPC_STAT
9338 case "$d_sem" in
9339 $define)
9340     : see whether semctl IPC_STAT can use union semun
9341     echo " "
9342     $cat > try.h <<END
9343 #ifndef S_IRUSR
9344 #   ifdef S_IREAD
9345 #       define S_IRUSR S_IREAD
9346 #       define S_IWUSR S_IWRITE
9347 #       define S_IXUSR S_IEXEC
9348 #   else
9349 #       define S_IRUSR 0400
9350 #       define S_IWUSR 0200
9351 #       define S_IXUSR 0100
9352 #   endif
9353 #   define S_IRGRP (S_IRUSR>>3)
9354 #   define S_IWGRP (S_IWUSR>>3)
9355 #   define S_IXGRP (S_IXUSR>>3)
9356 #   define S_IROTH (S_IRUSR>>6)
9357 #   define S_IWOTH (S_IWUSR>>6)
9358 #   define S_IXOTH (S_IXUSR>>6)
9359 #endif
9360 #ifndef S_IRWXU
9361 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9362 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9363 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9364 #endif
9365 END
9366
9367     $cat > try.c <<END
9368 #include <sys/types.h>
9369 #include <sys/ipc.h>
9370 #include <sys/sem.h>
9371 #include <sys/stat.h>
9372 #include <stdio.h>
9373 #include <errno.h>
9374 #include "try.h"
9375 #ifndef errno
9376 extern int errno;
9377 #endif
9378 #$d_union_semun HAS_UNION_SEMUN
9379 int main() {
9380     union semun
9381 #ifndef HAS_UNION_SEMUN
9382     {
9383         int val;
9384         struct semid_ds *buf;
9385         unsigned short *array;
9386     }
9387 #endif
9388     arg;
9389     int sem, st;
9390
9391 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9392     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9393     if (sem > -1) {
9394         struct semid_ds argbuf;
9395         arg.buf = &argbuf;
9396 #       ifdef IPC_STAT
9397         st = semctl(sem, 0, IPC_STAT, arg);
9398         if (st == 0)
9399             printf("semun\n");
9400         else
9401 #       endif /* IPC_STAT */
9402             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9403 #       ifdef IPC_RMID
9404         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9405 #       endif /* IPC_RMID */
9406             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9407     } else
9408 #endif /* IPC_PRIVATE && ... */
9409         printf("semget failed: errno = %d\n", errno);
9410   return 0;
9411 }
9412 END
9413     val="$undef"
9414     set try
9415     if eval $compile; then
9416         xxx=`./try`
9417         case "$xxx" in
9418         semun) val="$define" ;;
9419         esac
9420     fi
9421     $rm -f try try.c
9422     set d_semctl_semun
9423     eval $setvar
9424     case "$d_semctl_semun" in
9425     $define)
9426         echo "You can use union semun for semctl IPC_STAT." >&4
9427         also='also'
9428         ;;
9429     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9430         also=''
9431         ;;
9432     esac
9433
9434     : see whether semctl IPC_STAT can use struct semid_ds pointer
9435     $cat > try.c <<'END'
9436 #include <sys/types.h>
9437 #include <sys/ipc.h>
9438 #include <sys/sem.h>
9439 #include <sys/stat.h>
9440 #include "try.h"
9441 #include <stdio.h>
9442 #include <errno.h>
9443 #ifndef errno
9444 extern int errno;
9445 #endif
9446 int main() {
9447     struct semid_ds arg;
9448     int sem, st;
9449
9450 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9451     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9452     if (sem > -1) {
9453 #       ifdef IPC_STAT
9454         st = semctl(sem, 0, IPC_STAT, &arg);
9455         if (st == 0)
9456             printf("semid_ds\n");
9457         else
9458 #       endif /* IPC_STAT */
9459             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9460 #       ifdef IPC_RMID
9461         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9462 #       endif /* IPC_RMID */
9463             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9464     } else
9465 #endif /* IPC_PRIVATE && ... */
9466         printf("semget failed: errno = %d\n", errno);
9467
9468     return 0;
9469 }
9470 END
9471     val="$undef"
9472     set try
9473     if eval $compile; then
9474         xxx=`./try`
9475         case "$xxx" in
9476         semid_ds) val="$define" ;;
9477         esac
9478     fi
9479     $rm -f try try.c
9480     set d_semctl_semid_ds
9481     eval $setvar
9482     case "$d_semctl_semid_ds" in
9483     $define)
9484         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9485         ;;
9486     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9487         ;;
9488     esac
9489     $rm -f try.h
9490     ;;
9491 *)  val="$undef"
9492
9493     # We do not have the full sem*(2) library, so assume we can not
9494     # use either.
9495
9496     set d_semctl_semun
9497     eval $setvar
9498
9499     set d_semctl_semid_ds
9500     eval $setvar
9501     ;;
9502 esac
9503
9504 : see if setegid exists
9505 set setegid d_setegid
9506 eval $inlibc
9507
9508 : see if seteuid exists
9509 set seteuid d_seteuid
9510 eval $inlibc
9511
9512 : see if setgrent exists
9513 set setgrent d_setgrent
9514 eval $inlibc
9515
9516 : see if sethostent exists
9517 set sethostent d_sethent
9518 eval $inlibc
9519
9520 : see if setlinebuf exists
9521 set setlinebuf d_setlinebuf
9522 eval $inlibc
9523
9524 : see if setlocale exists
9525 set setlocale d_setlocale
9526 eval $inlibc
9527
9528 : see if setnetent exists
9529 set setnetent d_setnent
9530 eval $inlibc
9531
9532 : see if setprotoent exists
9533 set setprotoent d_setpent
9534 eval $inlibc
9535
9536 : see if setpgid exists
9537 set setpgid d_setpgid
9538 eval $inlibc
9539
9540 : see if setpgrp2 exists
9541 set setpgrp2 d_setpgrp2
9542 eval $inlibc
9543
9544 : see if setpriority exists
9545 set setpriority d_setprior
9546 eval $inlibc
9547
9548 : see if setpwent exists
9549 set setpwent d_setpwent
9550 eval $inlibc
9551
9552 : see if setregid exists
9553 set setregid d_setregid
9554 eval $inlibc
9555 set setresgid d_setresgid
9556 eval $inlibc
9557
9558 : see if setreuid exists
9559 set setreuid d_setreuid
9560 eval $inlibc
9561 set setresuid d_setresuid
9562 eval $inlibc
9563
9564 : see if setrgid exists
9565 set setrgid d_setrgid
9566 eval $inlibc
9567
9568 : see if setruid exists
9569 set setruid d_setruid
9570 eval $inlibc
9571
9572 : see if setservent exists
9573 set setservent d_setsent
9574 eval $inlibc
9575
9576 : see if setsid exists
9577 set setsid d_setsid
9578 eval $inlibc
9579
9580 : see if setvbuf exists
9581 set setvbuf d_setvbuf
9582 eval $inlibc
9583
9584 : see if sfio.h is available
9585 set sfio.h i_sfio
9586 eval $inhdr
9587
9588
9589 : see if sfio library is available
9590 case "$i_sfio" in
9591 $define)
9592         val=''
9593         set sfreserve val
9594         eval $inlibc
9595         ;;
9596 *)
9597         val="$undef"
9598         ;;
9599 esac
9600 : Ok, but do we want to use it.
9601 case "$val" in
9602 $define)
9603         case "$usesfio" in
9604         true|$define|[yY]*) dflt='y';;
9605         *) dflt='n';;
9606         esac
9607         echo "$package can use the sfio library, but it is experimental."
9608         rp="You seem to have sfio available, do you want to try using it?"
9609         . ./myread
9610         case "$ans" in
9611         y|Y) ;;
9612         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9613                 val="$undef"
9614                 : Remove sfio from list of libraries to use
9615                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9616                 shift
9617                 libs="$*"
9618                 echo "libs = $libs" >&4
9619                 ;;
9620         esac
9621         ;;
9622 *)      case "$usesfio" in
9623         true|$define|[yY]*)
9624                 echo "Sorry, cannot find sfio on this machine" >&4
9625                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9626                 ;;
9627         esac
9628         ;;
9629 esac
9630 set d_sfio
9631 eval $setvar
9632 case "$d_sfio" in
9633 $define) usesfio='true';;
9634 *) usesfio='false';;
9635 esac
9636
9637 : see if shmctl exists
9638 set shmctl d_shmctl
9639 eval $inlibc
9640
9641 : see if shmget exists
9642 set shmget d_shmget
9643 eval $inlibc
9644
9645 : see if shmat exists
9646 set shmat d_shmat
9647 eval $inlibc
9648 : see what shmat returns
9649 case "$d_shmat" in
9650 "$define")
9651         $cat >shmat.c <<'END'
9652 #include <sys/shm.h>
9653 void *shmat();
9654 END
9655         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9656                 shmattype='void *'
9657         else
9658                 shmattype='char *'
9659         fi
9660         echo "and it returns ($shmattype)." >&4
9661         : see if a prototype for shmat is available
9662         xxx=`./findhdr sys/shm.h`
9663         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9664         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9665                 val="$define"
9666         else
9667                 val="$undef"
9668         fi
9669         $rm -f shmat.[co]
9670         ;;
9671 *)
9672         val="$undef"
9673         ;;
9674 esac
9675 set d_shmatprototype
9676 eval $setvar
9677
9678 : see if shmdt exists
9679 set shmdt d_shmdt
9680 eval $inlibc
9681
9682 : see how much of the 'shm*(2)' library is present.
9683 h_shm=true
9684 echo " "
9685 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9686 *"$undef"*) h_shm=false;;
9687 esac
9688 case "$osname" in
9689 freebsd)
9690     case "`ipcs 2>&1`" in
9691     "SVID shared memory"*"not configured"*)
9692         echo "Your $osname does not have the shm*(2) configured." >&4
9693         h_shm=false
9694         val="$undef"
9695         set shmctl d_shmctl
9696         evat $setvar
9697         set shmget d_shmget
9698         evat $setvar
9699         set shmat d_shmat
9700         evat $setvar
9701         set shmdt d_shmdt
9702         evat $setvar
9703         ;;
9704     esac
9705     ;;
9706 esac
9707 : we could also check for sys/ipc.h ...
9708 if $h_shm && $test `./findhdr sys/shm.h`; then
9709         echo "You have the full shm*(2) library." >&4
9710         val="$define"
9711 else
9712         echo "You don't have the full shm*(2) library." >&4
9713         val="$undef"
9714 fi
9715 set d_shm
9716 eval $setvar
9717
9718 echo " "
9719 : see if we have sigaction
9720 if set sigaction val -f d_sigaction; eval $csym; $val; then
9721         echo 'sigaction() found.' >&4
9722         $cat > try.c <<'EOP'
9723 #include <stdio.h>
9724 #include <sys/types.h>
9725 #include <signal.h>
9726 int main()
9727 {
9728     struct sigaction act, oact;
9729 }
9730 EOP
9731         set try
9732         if eval $compile_ok; then
9733                 val="$define"
9734         else
9735                 echo "But you don't seem to have a useable struct sigaction." >&4
9736                 val="$undef"
9737         fi
9738 else
9739         echo 'sigaction NOT found.' >&4
9740         val="$undef"
9741 fi
9742 set d_sigaction; eval $setvar
9743 $rm -f try try$_o try.c
9744
9745 : see if sigsetjmp exists
9746 echo " "
9747 case "$d_sigsetjmp" in
9748 '')
9749         $cat >try.c <<'EOP'
9750 #include <setjmp.h>
9751 sigjmp_buf env;
9752 int set = 1;
9753 int main()
9754 {
9755         if (sigsetjmp(env,1))
9756                 exit(set);
9757         set = 0;
9758         siglongjmp(env, 1);
9759         exit(1);
9760 }
9761 EOP
9762         set try
9763         if eval $compile; then
9764                 if ./try >/dev/null 2>&1; then
9765                         echo "POSIX sigsetjmp found." >&4
9766                         val="$define"
9767                 else
9768                         $cat >&4 <<EOM
9769 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9770 I'll ignore them.
9771 EOM
9772                         val="$undef"
9773                 fi
9774         else
9775                 echo "sigsetjmp not found." >&4
9776                 val="$undef"
9777         fi
9778         ;;
9779 *) val="$d_sigsetjmp"
9780         case "$d_sigsetjmp" in
9781         $define) echo "POSIX sigsetjmp found." >&4;;
9782         $undef) echo "sigsetjmp not found." >&4;;
9783         esac
9784         ;;
9785 esac
9786 set d_sigsetjmp
9787 eval $setvar
9788 $rm -f try.c try
9789
9790 : see if stat knows about block sizes
9791 echo " "
9792 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9793 eval $hasfield
9794
9795 : see if _ptr and _cnt from stdio act std
9796 echo " "
9797 if $contains '_IO_fpos_t' `./findhdr stdio.h` >/dev/null 2>&1 ; then
9798         echo "(Looks like you have stdio.h from Linux.)"
9799         case "$stdio_ptr" in
9800         '') stdio_ptr='((fp)->_IO_read_ptr)'
9801                 ptr_lval=$define
9802                 ;;
9803         *)      ptr_lval=$d_stdio_ptr_lval;;
9804         esac
9805         case "$stdio_cnt" in
9806         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9807                 cnt_lval=$undef
9808                 ;;
9809         *)      cnt_lval=$d_stdio_cnt_lval;;
9810         esac
9811         case "$stdio_base" in
9812         '') stdio_base='((fp)->_IO_read_base)';;
9813         esac
9814         case "$stdio_bufsiz" in
9815         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9816         esac
9817 else
9818         case "$stdio_ptr" in
9819         '') stdio_ptr='((fp)->_ptr)'
9820                 ptr_lval=$define
9821                 ;;
9822         *)      ptr_lval=$d_stdio_ptr_lval;;
9823         esac
9824         case "$stdio_cnt" in
9825         '') stdio_cnt='((fp)->_cnt)'
9826                 cnt_lval=$define
9827                 ;;
9828         *)      cnt_lval=$d_stdio_cnt_lval;;
9829         esac
9830         case "$stdio_base" in
9831         '') stdio_base='((fp)->_base)';;
9832         esac
9833         case "$stdio_bufsiz" in
9834         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9835         esac
9836 fi
9837 : test whether _ptr and _cnt really work
9838 echo "Checking how std your stdio is..." >&4
9839 $cat >try.c <<EOP
9840 #include <stdio.h>
9841 #define FILE_ptr(fp)    $stdio_ptr
9842 #define FILE_cnt(fp)    $stdio_cnt
9843 int main() {
9844         FILE *fp = fopen("try.c", "r");
9845         char c = getc(fp);
9846         if (
9847                 18 <= FILE_cnt(fp) &&
9848                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9849         )
9850                 exit(0);
9851         exit(1);
9852 }
9853 EOP
9854 val="$undef"
9855 set try
9856 if eval $compile; then
9857         if ./try; then
9858                 echo "Your stdio acts pretty std."
9859                 val="$define"
9860         else
9861                 echo "Your stdio isn't very std."
9862         fi
9863 else
9864         echo "Your stdio doesn't appear very std."
9865 fi
9866 $rm -f try.c try
9867 set d_stdstdio
9868 eval $setvar
9869
9870 : Can _ptr be used as an lvalue?
9871 case "$d_stdstdio$ptr_lval" in
9872 $define$define) val=$define ;;
9873 *) val=$undef ;;
9874 esac
9875 set d_stdio_ptr_lval
9876 eval $setvar
9877
9878 : Can _cnt be used as an lvalue?
9879 case "$d_stdstdio$cnt_lval" in
9880 $define$define) val=$define ;;
9881 *) val=$undef ;;
9882 esac
9883 set d_stdio_cnt_lval
9884 eval $setvar
9885
9886 : see if _base is also standard
9887 val="$undef"
9888 case "$d_stdstdio" in
9889 $define)
9890         $cat >try.c <<EOP
9891 #include <stdio.h>
9892 #define FILE_base(fp)   $stdio_base
9893 #define FILE_bufsiz(fp) $stdio_bufsiz
9894 int main() {
9895         FILE *fp = fopen("try.c", "r");
9896         char c = getc(fp);
9897         if (
9898                 19 <= FILE_bufsiz(fp) &&
9899                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9900         )
9901                 exit(0);
9902         exit(1);
9903 }
9904 EOP
9905         set try
9906         if eval $compile; then
9907                 if ./try; then
9908                         echo "And its _base field acts std."
9909                         val="$define"
9910                 else
9911                         echo "But its _base field isn't std."
9912                 fi
9913         else
9914                 echo "However, it seems to be lacking the _base field."
9915         fi
9916         $rm -f try.c try
9917         ;;
9918 esac
9919 set d_stdiobase
9920 eval $setvar
9921
9922 : see if strcoll exists
9923 set strcoll d_strcoll
9924 eval $inlibc
9925
9926 : check for structure copying
9927 echo " "
9928 echo "Checking to see if your C compiler can copy structs..." >&4
9929 $cat >try.c <<'EOCP'
9930 int main()
9931 {
9932         struct blurfl {
9933                 int dyick;
9934         } foo, bar;
9935
9936         foo = bar;
9937 }
9938 EOCP
9939 if $cc -c try.c >/dev/null 2>&1 ; then
9940         val="$define"
9941         echo "Yup, it can."
9942 else
9943         val="$undef"
9944         echo "Nope, it can't."
9945 fi
9946 set d_strctcpy
9947 eval $setvar
9948 $rm -f try.*
9949
9950 : see if strerror and/or sys_errlist[] exist
9951 echo " "
9952 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
9953     if set strerror val -f d_strerror; eval $csym; $val; then
9954                 echo 'strerror() found.' >&4
9955                 d_strerror="$define"
9956                 d_strerrm='strerror(e)'
9957                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9958                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
9959                         d_syserrlst="$define"
9960                 else
9961                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
9962                         d_syserrlst="$undef"
9963                 fi
9964     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
9965                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
9966                 echo 'strerror() found in string header.' >&4
9967                 d_strerror="$define"
9968                 d_strerrm='strerror(e)'
9969                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9970                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
9971                                 d_syserrlst="$define"
9972                 else
9973                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
9974                         d_syserrlst="$undef"
9975                 fi
9976     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
9977                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
9978                 d_strerror="$undef"
9979                 d_syserrlst="$define"
9980                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
9981     else
9982                 echo 'strerror() and sys_errlist[] NOT found.' >&4
9983                 d_strerror="$undef"
9984                 d_syserrlst="$undef"
9985                 d_strerrm='"unknown"'
9986     fi
9987 fi
9988
9989 : see if strtod exists
9990 set strtod d_strtod
9991 eval $inlibc
9992
9993 : see if strtol exists
9994 set strtol d_strtol
9995 eval $inlibc
9996
9997 : see if strtoul exists
9998 set strtoul d_strtoul
9999 eval $inlibc
10000
10001 : see if strxfrm exists
10002 set strxfrm d_strxfrm
10003 eval $inlibc
10004
10005 : see if symlink exists
10006 set symlink d_symlink
10007 eval $inlibc
10008
10009 : see if syscall exists
10010 set syscall d_syscall
10011 eval $inlibc
10012
10013 : see if sysconf exists
10014 set sysconf d_sysconf
10015 eval $inlibc
10016
10017 : see if system exists
10018 set system d_system
10019 eval $inlibc
10020
10021 : see if tcgetpgrp exists
10022 set tcgetpgrp d_tcgetpgrp
10023 eval $inlibc
10024
10025 : see if tcsetpgrp exists
10026 set tcsetpgrp d_tcsetpgrp
10027 eval $inlibc
10028
10029 : see if sys/types.h has to be included
10030 set sys/types.h i_systypes
10031 eval $inhdr
10032
10033 : see if prototype for telldir is available
10034 echo " "
10035 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10036 eval $hasproto
10037
10038 : define an is-a-typedef? function
10039 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10040 case "$inclist" in
10041 "") inclist="sys/types.h";;
10042 esac;
10043 eval "varval=\$$var";
10044 case "$varval" in
10045 "")
10046         $rm -f temp.c;
10047         for inc in $inclist; do
10048                 echo "#include <$inc>" >>temp.c;
10049         done;
10050         echo "#ifdef $type" >> temp.c;
10051         echo "printf(\"We have $type\");" >> temp.c;
10052         echo "#endif" >> temp.c;
10053         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10054         if $contains $type temp.E >/dev/null 2>&1; then
10055                 eval "$var=\$type";
10056         else
10057                 eval "$var=\$def";
10058         fi;
10059         $rm -f temp.?;;
10060 *) eval "$var=\$varval";;
10061 esac'
10062
10063 : define an is-a-typedef? function that prompts if the type is not available.
10064 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10065 case "$inclist" in
10066 "") inclist="sys/types.h";;
10067 esac;
10068 eval "varval=\$$var";
10069 case "$varval" in
10070 "")
10071         $rm -f temp.c;
10072         for inc in $inclist; do
10073                 echo "#include <$inc>" >>temp.c;
10074         done;
10075         echo "#ifdef $type" >> temp.c;
10076         echo "printf(\"We have $type\");" >> temp.c;
10077         echo "#endif" >> temp.c;
10078         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10079         echo " " ;
10080         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10081         if $contains $type temp.E >/dev/null 2>&1; then
10082                 echo "$type found." >&4;
10083                 eval "$var=\$type";
10084         else
10085                 echo "$type NOT found." >&4;
10086                 dflt="$def";
10087                 . ./myread ;
10088                 eval "$var=\$ans";
10089         fi;
10090         $rm -f temp.?;;
10091 *) eval "$var=\$varval";;
10092 esac'
10093
10094 : see if this is a sys/times.h system
10095 set sys/times.h i_systimes
10096 eval $inhdr
10097
10098 : see if times exists
10099 echo " "
10100 if set times val -f d_times; eval $csym; $val; then
10101         echo 'times() found.' >&4
10102         d_times="$define"
10103         inc=''
10104         case "$i_systimes" in
10105         "$define") inc='sys/times.h';;
10106         esac
10107         rp="What is the type returned by times() on this system?"
10108         set clock_t clocktype long stdio.h sys/types.h $inc
10109         eval $typedef_ask
10110 else
10111         echo 'times() NOT found, hope that will do.' >&4
10112         d_times="$undef"
10113         clocktype='int'
10114 fi
10115
10116 : see if truncate exists
10117 set truncate d_truncate
10118 eval $inlibc
10119
10120 : see if tzname[] exists
10121 echo " "
10122 if set tzname val -a d_tzname; eval $csym; $val; then
10123         val="$define"
10124         echo 'tzname[] found.' >&4
10125 else
10126         val="$undef"
10127         echo 'tzname[] NOT found.' >&4
10128 fi
10129 set d_tzname
10130 eval $setvar
10131
10132 : see if umask exists
10133 set umask d_umask
10134 eval $inlibc
10135
10136 : backward compatibility for d_hvfork
10137 if test X$d_hvfork != X; then
10138         d_vfork="$d_hvfork"
10139         d_hvfork=''
10140 fi
10141 : see if there is a vfork
10142 val=''
10143 set vfork val
10144 eval $inlibc
10145
10146 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10147 : perl on Solaris 2.x, and probably elsewhere.
10148 case "$val" in
10149 $define)
10150         echo " "
10151         case "$usevfork" in
10152         false) dflt='n';;
10153         *) dflt='y';;
10154         esac
10155         rp="Some systems have problems with vfork().  Do you want to use it?"
10156         . ./myread
10157         case "$ans" in
10158         y|Y) ;;
10159         *)
10160                 echo "Ok, we won't use vfork()."
10161                 val="$undef"
10162                 ;;
10163         esac
10164         ;;
10165 esac
10166 set d_vfork
10167 eval $setvar
10168 case "$d_vfork" in
10169 $define) usevfork='true';;
10170 *) usevfork='false';;
10171 esac
10172
10173 : see if this is an sysdir system
10174 set sys/dir.h i_sysdir
10175 eval $inhdr
10176
10177 : see if this is an sysndir system
10178 set sys/ndir.h i_sysndir
10179 eval $inhdr
10180
10181 : see if closedir exists
10182 set closedir d_closedir
10183 eval $inlibc
10184
10185 case "$d_closedir" in
10186 "$define")
10187         echo " "
10188         echo "Checking whether closedir() returns a status..." >&4
10189         cat > closedir.c <<EOM
10190 #$i_dirent I_DIRENT             /**/
10191 #$i_sysdir I_SYS_DIR            /**/
10192 #$i_sysndir I_SYS_NDIR          /**/
10193 #$i_systypes I_SYS_TYPES        /**/
10194
10195 #if defined(I_SYS_TYPES)
10196 #include <sys/types.h>
10197 #endif
10198 #if defined(I_DIRENT)
10199 #include <dirent.h>
10200 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10201 #include <sys/dir.h>
10202 #endif
10203 #else
10204 #ifdef I_SYS_NDIR
10205 #include <sys/ndir.h>
10206 #else
10207 #ifdef I_SYS_DIR
10208 #ifdef hp9000s500
10209 #include <ndir.h>       /* may be wrong in the future */
10210 #else
10211 #include <sys/dir.h>
10212 #endif
10213 #endif
10214 #endif
10215 #endif 
10216 int main() { return closedir(opendir(".")); }
10217 EOM
10218         set closedir
10219         if eval $compile_ok; then
10220                 if ./closedir > /dev/null 2>&1 ; then
10221                         echo "Yes, it does."
10222                         val="$undef"
10223                 else
10224                         echo "No, it doesn't."
10225                         val="$define"
10226                 fi
10227         else
10228                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10229                 val="$define"
10230         fi
10231         ;;
10232 *)
10233         val="$undef";
10234         ;;
10235 esac
10236 set d_void_closedir
10237 eval $setvar
10238 $rm -f closedir*
10239 : check for volatile keyword
10240 echo " "
10241 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10242 $cat >try.c <<'EOCP'
10243 int main()
10244 {
10245         typedef struct _goo_struct goo_struct;
10246         goo_struct * volatile goo = ((goo_struct *)0);
10247         struct _goo_struct {
10248                 long long_int;
10249                 int reg_int;
10250                 char char_var;
10251         };
10252         typedef unsigned short foo_t;
10253         char *volatile foo;
10254         volatile int bar;
10255         volatile foo_t blech;
10256         foo = foo;
10257 }
10258 EOCP
10259 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10260         val="$define"
10261         echo "Yup, it does."
10262 else
10263         val="$undef"
10264         echo "Nope, it doesn't."
10265 fi
10266 set d_volatile
10267 eval $setvar
10268 $rm -f try.*
10269
10270 : see if there is a wait4
10271 set wait4 d_wait4
10272 eval $inlibc
10273
10274 : see if waitpid exists
10275 set waitpid d_waitpid
10276 eval $inlibc
10277
10278 : see if wcstombs exists
10279 set wcstombs d_wcstombs
10280 eval $inlibc
10281
10282 : see if wctomb exists
10283 set wctomb d_wctomb
10284 eval $inlibc
10285
10286 : see if writev exists
10287 set writev d_writev
10288 eval $inlibc
10289
10290 : preserve RCS keywords in files with variable substitution, grrr
10291 Date='$Date'
10292 Id='$Id'
10293 Log='$Log'
10294 RCSfile='$RCSfile'
10295 Revision='$Revision'
10296
10297 : check for alignment requirements
10298 echo " "
10299 case "$crosscompile$multiarch" in
10300 *$define*)
10301 You seem to be cross-compiling, skipping the memory alignment check.
10302
10303 EOM
10304         case "$alignbytes" in
10305         '') alignbytes=8 ;;
10306         esac
10307         ;;
10308 *)
10309         case "$alignbytes" in
10310         '') echo "Checking alignment constraints..." >&4
10311                 $cat >try.c <<'EOCP'
10312 struct foobar {
10313         char foo;
10314         double bar;
10315 } try_algn;
10316 int main()
10317 {
10318         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10319 }
10320 EOCP
10321                 set try
10322                 if eval $compile_ok; then
10323                         dflt=`./try`
10324                 else
10325                         dflt='8'
10326                         echo "(I can't seem to compile the test program...)"
10327                 fi
10328                 ;;
10329         *) dflt="$alignbytes"
10330                 ;;
10331         esac
10332         rp="Doubles must be aligned on a how-many-byte boundary?"
10333         . ./myread
10334         alignbytes="$ans"
10335         $rm -f try.c try
10336         ;;
10337 esac
10338
10339
10340 : check for ordering of bytes in a long
10341 echo " "
10342 case "$crosscompile$multiarch" in
10343 *$define*)
10344         $cat <<EOM
10345 You seem to be cross-compiling, I'm skipping the byteorder check.
10346
10347 EOM
10348         ;;
10349 *)
10350         case "$byteorder" in
10351         '')
10352                 $cat <<'EOM'
10353 In the following, larger digits indicate more significance.  A big-endian
10354 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10355 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10356 machines may have weird orders like 3412.  A Cray will report 87654321. If
10357 the test program works the default is probably right.
10358 I'm now running the test program...
10359 EOM
10360                 $cat >try.c <<'EOCP'
10361 #include <stdio.h>
10362 int main()
10363 {
10364         int i;
10365         union {
10366                 unsigned long l;
10367                 char c[sizeof(long)];
10368         } u;
10369
10370         if (sizeof(long) > 4)
10371                 u.l = (0x08070605L << 32) | 0x04030201L;
10372         else
10373                 u.l = 0x04030201L;
10374         for (i = 0; i < sizeof(long); i++)
10375                 printf("%c", u.c[i]+'0');
10376         printf("\n");
10377         exit(0);
10378 }
10379 EOCP
10380                 xxx_prompt=y
10381                 set try
10382                 if eval $compile && ./try > /dev/null; then
10383                         dflt=`./try`
10384                         case "$dflt" in
10385                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10386                                 echo "(The test program ran ok.)"
10387                                 echo "byteorder=$dflt"
10388                                 xxx_prompt=n
10389                         ;;
10390                         ????|????????) echo "(The test program ran ok.)" ;;
10391                         *) echo "(The test program didn't run right for some reason.)" ;;
10392                         esac
10393                 else
10394                         dflt='4321'
10395                         cat <<'EOM'
10396 (I can't seem to compile the test program.  Guessing big-endian...)
10397 EOM
10398                 fi
10399                 case "$xxx_prompt" in
10400                 y)
10401                         rp="What is the order of bytes in a long?"
10402                         . ./myread
10403                         byteorder="$ans"
10404                         ;;
10405                 *)      byteorder=$dflt
10406                         ;;
10407                 esac
10408                 ;;
10409         esac
10410         $rm -f try.c try
10411         ;;
10412 esac
10413
10414
10415 : how do we catenate cpp tokens here?
10416 echo " "
10417 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10418 $cat >cpp_stuff.c <<'EOCP'
10419 #define RCAT(a,b)a/**/b
10420 #define ACAT(a,b)a ## b
10421 RCAT(Rei,ser)
10422 ACAT(Cir,cus)
10423 EOCP
10424 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10425 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10426         echo "Oh!  Smells like ANSI's been here." >&4
10427         echo "We can catify or stringify, separately or together!"
10428         cpp_stuff=42
10429 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10430         echo "Ah, yes!  The good old days!" >&4
10431         echo "However, in the good old days we don't know how to stringify and"
10432         echo "catify at the same time."
10433         cpp_stuff=1
10434 else
10435         $cat >&4 <<EOM
10436 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10437 to have to edit the values of CAT[2-5] in config.h...
10438 EOM
10439         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10440 fi
10441 $rm -f cpp_stuff.*
10442
10443 : see if this is a db.h system
10444 set db.h i_db
10445 eval $inhdr
10446
10447 case "$i_db" in
10448 $define)
10449         : Check db version.
10450         echo " "
10451         echo "Checking Berkeley DB version ..." >&4
10452         $cat >try.c <<EOCP
10453 #$d_const HASCONST
10454 #ifndef HASCONST
10455 #define const
10456 #endif
10457 #include <sys/types.h>
10458 #include <stdio.h>
10459 #include <db.h>
10460 int main()
10461 {
10462 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10463     int Major, Minor, Patch ;
10464     unsigned long Version ;
10465     (void)db_version(&Major, &Minor, &Patch) ;
10466     printf("You have Berkeley DB Version 2 or greater\n");
10467
10468     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10469                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10470     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10471                 Major, Minor, Patch) ;
10472
10473     /* check that db.h & libdb are compatible */
10474     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10475         printf("db.h and libdb are incompatible\n") ;
10476         exit(3);        
10477     }
10478
10479     printf("db.h and libdb are compatible\n") ;
10480
10481     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10482                 + DB_VERSION_PATCH ;
10483
10484     /* needs to be >= 2.3.4 */
10485     if (Version < 2003004) {
10486     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10487         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10488         exit(2);        
10489     }
10490
10491     exit(0);
10492 #else
10493 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10494     printf("You have Berkeley DB Version 1\n");
10495     exit(0);    /* DB version < 2: the coast is clear. */
10496 #else
10497     exit(1);    /* <db.h> not Berkeley DB? */
10498 #endif
10499 #endif
10500 }
10501 EOCP
10502         set try
10503         if eval $compile && ./try; then
10504                 echo 'Looks OK.' >&4
10505         else
10506                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10507                 i_db=$undef
10508                 case " $libs " in
10509                 *"-ldb "*)
10510                         : Remove db from list of libraries to use
10511                         echo "Removing unusable -ldb from library list" >&4
10512                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10513                         shift
10514                         libs="$*"
10515                         echo "libs = $libs" >&4
10516                         ;;
10517                 esac
10518         fi
10519         $rm -f try.*
10520         ;;
10521 esac
10522
10523 case "$i_db" in
10524 define)
10525         : Check the return type needed for hash 
10526         echo " "
10527         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10528         $cat >try.c <<EOCP
10529 #$d_const HASCONST
10530 #ifndef HASCONST
10531 #define const
10532 #endif
10533 #include <sys/types.h>
10534 #include <db.h>
10535
10536 #ifndef DB_VERSION_MAJOR
10537 u_int32_t hash_cb (ptr, size)
10538 const void *ptr;
10539 size_t size;
10540 {
10541 }
10542 HASHINFO info;
10543 int main()
10544 {
10545         info.hash = hash_cb;
10546 }
10547 #endif
10548 EOCP
10549         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10550                 if $contains warning try.out >>/dev/null 2>&1 ; then
10551                         db_hashtype='int'
10552                 else
10553                         db_hashtype='u_int32_t'
10554                 fi
10555         else
10556                 : XXX Maybe we should just give up here.
10557                 db_hashtype=u_int32_t
10558                 $cat try.out >&4
10559                 echo "Help:  I can't seem to compile the db test program." >&4
10560                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10561         fi
10562         $rm -f try.*
10563         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10564         ;;
10565 *)      db_hashtype=u_int32_t
10566         ;;
10567 esac
10568 case "$i_db" in
10569 define)
10570         : Check the return type needed for prefix 
10571         echo " "
10572         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10573         cat >try.c <<EOCP
10574 #$d_const HASCONST
10575 #ifndef HASCONST
10576 #define const
10577 #endif
10578 #include <sys/types.h>
10579 #include <db.h>
10580
10581 #ifndef DB_VERSION_MAJOR
10582 size_t prefix_cb (key1, key2)
10583 const DBT *key1;
10584 const DBT *key2;
10585 {
10586 }
10587 BTREEINFO info;
10588 int main()
10589 {
10590         info.prefix = prefix_cb;
10591 }
10592 #endif
10593 EOCP
10594         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10595                 if $contains warning try.out >>/dev/null 2>&1 ; then
10596                         db_prefixtype='int'
10597                 else
10598                         db_prefixtype='size_t'
10599                 fi
10600         else
10601                 db_prefixtype='size_t'
10602                 : XXX Maybe we should just give up here.
10603                 $cat try.out >&4
10604                 echo "Help:  I can't seem to compile the db test program." >&4
10605                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10606         fi
10607         $rm -f try.*
10608         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10609         ;;
10610 *)      db_prefixtype='size_t'
10611         ;;
10612 esac
10613
10614 : check for void type
10615 echo " "
10616 echo "Checking to see how well your C compiler groks the void type..." >&4
10617 case "$voidflags" in
10618 '')
10619         $cat >try.c <<'EOCP'
10620 #if TRY & 1
10621 void sub() {
10622 #else
10623 sub() {
10624 #endif
10625         extern void moo();      /* function returning void */
10626         void (*goo)();          /* ptr to func returning void */
10627 #if TRY & 8
10628         void *hue;              /* generic ptr */
10629 #endif
10630 #if TRY & 2
10631         void (*foo[10])();
10632 #endif
10633
10634 #if TRY & 4
10635         if(goo == moo) {
10636                 exit(0);
10637         }
10638 #endif
10639         exit(0);
10640 }
10641 int main() { sub(); }
10642 EOCP
10643         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10644                 voidflags=$defvoidused
10645         echo "Good.  It appears to support void to the level $package wants.">&4
10646                 if $contains warning .out >/dev/null 2>&1; then
10647                         echo "However, you might get some warnings that look like this:"
10648                         $cat .out
10649                 fi
10650         else
10651 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10652                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10653                         echo "It supports 1..."
10654                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10655                                 echo "It also supports 2..."
10656                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10657                                         voidflags=7
10658                                         echo "And it supports 4 but not 8 definitely."
10659                                 else
10660                                         echo "It doesn't support 4..."
10661                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10662                                                 voidflags=11
10663                                                 echo "But it supports 8."
10664                                         else
10665                                                 voidflags=3
10666                                                 echo "Neither does it support 8."
10667                                         fi
10668                                 fi
10669                         else
10670                                 echo "It does not support 2..."
10671                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10672                                         voidflags=13
10673                                         echo "But it supports 4 and 8."
10674                                 else
10675                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10676                                                 voidflags=5
10677                                                 echo "And it supports 4 but has not heard about 8."
10678                                         else
10679                                                 echo "However it supports 8 but not 4."
10680                                         fi
10681                                 fi
10682                         fi
10683                 else
10684                         echo "There is no support at all for void."
10685                         voidflags=0
10686                 fi
10687         fi
10688 esac
10689 case "$voidflags" in
10690 "$defvoidused") ;;
10691 *)      $cat >&4 <<'EOM'
10692   Support flag bits are:
10693     1: basic void declarations.
10694     2: arrays of pointers to functions returning void.
10695     4: operations between pointers to and addresses of void functions.
10696     8: generic void pointers.
10697 EOM
10698         dflt="$voidflags";
10699         rp="Your void support flags add up to what?"
10700         . ./myread
10701         voidflags="$ans"
10702         ;;
10703 esac
10704 $rm -f try.* .out
10705
10706
10707 : How can we generate normalized random numbers ?
10708 echo " "
10709 echo "Looking for a random number function..." >&4
10710 case "$randfunc" in
10711 '')
10712         if set drand48 val -f; eval $csym; $val; then
10713                 dflt="drand48"
10714                 echo "Good, found drand48()." >&4
10715         elif set random val -f; eval $csym; $val; then
10716                 dflt="random"
10717                 echo "OK, found random()." >&4
10718         else
10719                 dflt="rand"
10720                 echo "Yick, looks like I have to use rand()." >&4
10721         fi
10722         echo " "
10723         ;;
10724 *)
10725         dflt="$randfunc"
10726         ;;
10727 esac
10728 cont=true
10729
10730 case "$ccflags" in
10731 *-Dmy_rand=*|*-Dmy_srand=*)
10732         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10733         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10734         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10735         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10736         ;;
10737 esac
10738
10739 while $test "$cont"; do
10740         rp="Use which function to generate random numbers?"
10741         . ./myread
10742         if $test "$ans" = "$dflt"; then
10743                 : null
10744         else
10745                 randbits=''
10746         fi
10747         randfunc="$ans"
10748         if set $ans val -f; eval $csym; $val; then
10749                 cont=''
10750         else
10751                 dflt=y
10752                 rp="I cannot find function $ans. Use that name anyway?"
10753                 . ./myread
10754                 dflt=rand
10755                 case "$ans" in
10756                         [yY]*) cont='';;
10757                 esac
10758         fi
10759         case "$cont" in
10760         '')
10761                 case "$randfunc" in
10762                 drand48)
10763                         drand01="drand48()"
10764                         seedfunc="srand48"
10765                         randbits=48
10766                         randseedtype=long
10767                         ;;
10768                 rand|random)
10769                         case "$randbits" in
10770                         '')
10771 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10772                                 $cat >try.c <<EOCP
10773 #$i_unistd I_UNISTD
10774 #$i_stdlib I_STDLIB
10775 #include <stdio.h>
10776 #ifdef I_UNISTD
10777 #  include <unistd.h>
10778 #endif
10779 #ifdef I_STDLIB
10780 #  include <stdlib.h>
10781 #endif
10782 int main()
10783 {
10784         register int i;
10785         register unsigned long tmp;
10786         register unsigned long max = 0L;
10787
10788         for (i = 1000; i; i--) {
10789                 tmp = (unsigned long) $randfunc();
10790                 if (tmp > max) max = tmp;
10791         }
10792         for (i = 0; max; i++)
10793                 max /= 2;
10794         printf("%d\n",i);
10795 }
10796 EOCP
10797                                 set try
10798                                 if eval $compile_ok; then
10799                                         dflt=`try`
10800                                 else
10801                                         dflt='?'
10802                                         echo "(I can't seem to compile the test program...)"
10803                                 fi
10804                                 ;;
10805                         *)
10806                                 dflt="$randbits"
10807                                 ;;
10808                         esac
10809                         rp="How many bits does your $randfunc() function produce?"
10810                         . ./myread
10811                         randbits="$ans"
10812                         $rm -f try.c try
10813                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10814                         seedfunc="s$randfunc"
10815                         randseedtype=unsigned
10816                         ;;
10817                 *)
10818                         dflt="31"
10819                         rp="How many bits does your $randfunc() function produce?"
10820                         . ./myread
10821                         randbits="$ans"
10822                         seedfunc="s$randfunc"
10823                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10824                         if set $seedfunc val -f; eval $csym; $val; then
10825                                 echo "(Using $seedfunc() to seed random generator)"
10826                         else
10827                                 echo "(Warning: no $seedfunc() to seed random generator)"
10828                                 seedfunc=rand
10829                         fi
10830                         randseedtype=unsigned
10831                         ;;
10832                 esac
10833                 ;;
10834         esac
10835 done
10836
10837 echo " "
10838 echo "Determining whether or not we are on an EBCDIC system..." >&4
10839 $cat >tebcdic.c <<'EOM'
10840 int main()
10841 {
10842   if ('M'==0xd4) return 0;
10843   return 1;
10844 }
10845 EOM
10846
10847 val=$undef
10848 set tebcdic
10849 if eval $compile_ok; then
10850         if ./tebcdic; then
10851                 echo "You have EBCDIC." >&4
10852                 val="$define"
10853         else
10854                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10855         fi
10856 else
10857         echo "I'm unable to compile the test program." >&4
10858         echo "I'll assume ASCII or some ISO Latin." >&4
10859 fi
10860 $rm -f tebcdic.c tebcdic
10861 set ebcdic
10862 eval $setvar
10863
10864 : see what type file positions are declared as in the library
10865 rp="What is the type for file position used by fsetpos()?"
10866 set fpos_t fpostype long stdio.h sys/types.h
10867 eval $typedef_ask
10868
10869 : Store the full pathname to the ar program for use in the C program
10870 : Respect a hint or command line value for full_ar.
10871 case "$full_ar" in
10872 '') full_ar=$ar ;;
10873 esac
10874
10875 : Store the full pathname to the sed program for use in the C program
10876 full_sed=$sed
10877
10878 : see what type gids are declared as in the kernel
10879 echo " "
10880 echo "Looking for the type for group ids returned by getgid()."
10881 set gid_t gidtype xxx stdio.h sys/types.h
10882 eval $typedef
10883 case "$gidtype" in
10884 xxx)
10885         xxx=`./findhdr sys/user.h`
10886         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
10887         case $1 in
10888         unsigned) dflt="$1 $2" ;;
10889         *) dflt="$1" ;;
10890         esac
10891         ;;
10892 *) dflt="$gidtype";;
10893 esac
10894 case "$gidtype" in
10895 gid_t) echo "gid_t found." ;;
10896 *)      rp="What is the type for group ids returned by getgid()?"
10897         . ./myread
10898         gidtype="$ans"
10899         ;;
10900 esac
10901
10902 : see if getgroups exists
10903 set getgroups d_getgrps
10904 eval $inlibc
10905
10906 : see if setgroups exists
10907 set setgroups d_setgrps
10908 eval $inlibc
10909
10910
10911 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
10912 echo " "
10913 case "$d_getgrps$d_setgrps" in
10914 *define*)
10915         case "$groupstype" in
10916         '') dflt="$gidtype" ;;
10917         *)  dflt="$groupstype" ;;
10918         esac
10919         $cat <<EOM
10920 What type of pointer is the second argument to getgroups() and setgroups()?
10921 Usually this is the same as group ids, $gidtype, but not always.
10922
10923 EOM
10924         rp='What type pointer is the second argument to getgroups() and setgroups()?'
10925         . ./myread
10926         groupstype="$ans"
10927         ;;
10928 *)  groupstype="$gidtype";;
10929 esac
10930
10931 : see what type lseek is declared as in the kernel
10932 rp="What is the type used for lseek's offset on this system?"
10933 set off_t lseektype long stdio.h sys/types.h
10934 eval $typedef_ask
10935
10936 echo " "
10937 $echo $n "Checking to see how big your file offsets are...$c" >&4
10938 $cat >try.c <<EOCP
10939 #include <sys/types.h>
10940 #include <stdio.h>
10941 int main()
10942 {
10943         printf("%d\n", sizeof($lseektype));
10944 }
10945 EOCP
10946 set try
10947 if eval $compile_ok; then
10948         lseeksize=`./try`
10949         $echo " $lseeksize bytes." >&4
10950 else
10951         dflt='4'
10952         echo " "
10953         echo "(I can't seem to compile the test program.  Guessing...)"
10954         rp="What is the size of your file offsets (in bytes)?"
10955         . ./myread
10956         lseeksize="$ans"
10957 fi
10958 $rm -f try.c try
10959
10960 echo " "
10961 echo "Checking if your $make program sets \$(MAKE)..." >&4
10962 case "$make_set_make" in
10963 '')
10964         $sed 's/^X //' > testmake.mak << 'EOF'
10965 Xall:
10966 X       @echo 'maketemp="$(MAKE)"'
10967 EOF
10968         case "`$make -f testmake.mak 2>/dev/null`" in
10969         *maketemp=*) make_set_make='#' ;;
10970         *)      make_set_make="MAKE=$make" ;;
10971         esac
10972         $rm -f testmake.mak
10973         ;;
10974 esac
10975 case "$make_set_make" in
10976 '#') echo "Yup, it does.";;
10977 *) echo "Nope, it doesn't.";;
10978 esac
10979
10980 : see what type is used for mode_t
10981 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
10982 set mode_t modetype int stdio.h sys/types.h
10983 eval $typedef_ask
10984
10985 : define a fucntion to check prototypes
10986 $cat > protochk <<EOSH
10987 $startsh
10988 cc="$cc"
10989 optimize="$optimize"
10990 ccflags="$ccflags"
10991 prototype="$prototype"
10992 define="$define"
10993 rm=$rm
10994 EOSH
10995
10996 $cat >> protochk <<'EOSH'
10997
10998 $rm -f try.c
10999 foo="$1"
11000 shift
11001 while test $# -ge 2; do
11002         case "$1" in
11003                 $define) echo "#include <$2>" >> try.c ;;
11004                 literal) echo "$2" >> try.c ;;
11005         esac
11006     shift 2
11007 done
11008 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11009 cat >> try.c <<'EOCP'
11010 #ifdef CAN_PROTOTYPE
11011 #define _(args) args
11012 #else
11013 #define _(args) ()
11014 #endif
11015 EOCP
11016 echo "$foo" >> try.c
11017 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11018 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11019 status=$?
11020 $rm -f try.[co]
11021 exit $status
11022 EOSH
11023 chmod +x protochk
11024 $eunicefix protochk
11025
11026 : see what type is used for size_t
11027 rp="What is the type used for the length parameter for string functions?"
11028 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11029 eval $typedef_ask
11030
11031 : check for type of arguments to gethostbyaddr. 
11032 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11033         case "$d_gethbyaddr" in
11034         $define)
11035                 $cat <<EOM
11036
11037 Checking to see what type of arguments are accepted by gethostbyaddr().
11038 EOM
11039                 hdrs="$define sys/types.h
11040                         $d_socket sys/socket.h 
11041                         $i_niin netinet/in.h 
11042                         $i_netdb netdb.h
11043                         $i_unistd unistd.h"
11044                 : The first arg can 'char *' or 'void *'
11045                 : The second arg is some of integral type
11046                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11047                         for yyy in size_t long int; do
11048                                 case "$netdb_host_type" in
11049                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11050                                         if ./protochk "$try" $hdrs; then
11051                                                 echo "Your system accepts $xxx for the first arg."
11052                                                 echo "...and $yyy for the second arg."
11053                                                 netdb_host_type="$xxx"
11054                                                 netdb_hlen_type="$yyy"
11055                                         fi
11056                                         ;;
11057                                 esac
11058                         done
11059                 done
11060                 : In case none of those worked, prompt the user.
11061                 case "$netdb_host_type" in
11062                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11063                         dflt='char *'
11064                         . ./myread
11065                         netdb_host_type=$ans
11066                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11067                         dflt="$sizetype"
11068                         . ./myread
11069                         netdb_hlen_type=$ans
11070                         ;;
11071                 esac
11072                 ;;
11073         *)      : no gethostbyaddr, so pick harmless defaults
11074                 netdb_host_type='char *'
11075                 netdb_hlen_type="$sizetype"
11076                 ;;
11077         esac
11078         # Remove the "const" if needed. -- but then we'll have a 
11079         # prototype clash!
11080         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11081 fi
11082
11083 : check for type of argument to gethostbyname. 
11084 if test "X$netdb_name_type" = X ; then
11085         case "$d_gethbyname" in
11086         $define)
11087                 $cat <<EOM
11088
11089 Checking to see what type of argument is accepted by gethostbyname().
11090 EOM
11091                 hdrs="$define sys/types.h
11092                         $d_socket sys/socket.h 
11093                         $i_niin netinet/in.h 
11094                         $i_netdb netdb.h
11095                         $i_unistd unistd.h"
11096                 for xxx in "const char *" "char *"; do
11097                         case "$netdb_name_type" in
11098                         '')     try="extern struct hostent *gethostbyname($xxx);"
11099                                 if ./protochk "$try" $hdrs; then
11100                                         echo "Your system accepts $xxx."
11101                                         netdb_name_type="$xxx"
11102                                 fi
11103                                 ;;
11104                         esac
11105                 done
11106                 : In case none of those worked, prompt the user.
11107                 case "$netdb_name_type" in
11108                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11109                         dflt='char *'
11110                         . ./myread
11111                         netdb_name_type=$ans
11112                         ;;
11113                 esac
11114                 ;;
11115         *)      : no gethostbyname, so pick harmless default
11116                 netdb_name_type='char *'
11117                 ;;
11118         esac
11119 fi
11120
11121 : check for type of 1st argument to getnetbyaddr. 
11122 if test "X$netdb_net_type" = X ; then
11123         case "$d_getnbyaddr" in
11124         $define)
11125                 $cat <<EOM
11126
11127 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11128 EOM
11129                 hdrs="$define sys/types.h
11130                         $d_socket sys/socket.h 
11131                         $i_niin netinet/in.h 
11132                         $i_netdb netdb.h
11133                         $i_unistd unistd.h"
11134                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11135                         case "$netdb_net_type" in
11136                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11137                                 if ./protochk "$try" $hdrs; then
11138                                         echo "Your system accepts $xxx."
11139                                         netdb_net_type="$xxx"
11140                                 fi
11141                                 ;;
11142                         esac
11143                 done
11144                 : In case none of those worked, prompt the user.
11145                 case "$netdb_net_type" in
11146                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11147                         dflt='long'
11148                         . ./myread
11149                         netdb_net_type=$ans
11150                         ;;
11151                 esac
11152                 ;;
11153         *)      : no getnetbyaddr, so pick harmless default
11154                 netdb_net_type='long'
11155                 ;;
11156         esac
11157 fi
11158 : locate the preferred pager for this system
11159 case "$pager" in
11160 '')
11161         dflt=''
11162         case "$pg" in
11163         /*) dflt=$pg;;
11164         esac
11165         case "$more" in
11166         /*) dflt=$more;;
11167         esac
11168         case "$less" in
11169         /*) dflt=$less;;
11170         esac
11171         case "$dflt" in
11172         '') dflt=/usr/ucb/more;;
11173         esac
11174         ;;
11175 *) dflt="$pager";;
11176 esac
11177 echo " "
11178 fn=f/
11179 rp='What pager is used on your system?'
11180 . ./getfile
11181 pager="$ans"
11182
11183 : see what type pids are declared as in the kernel
11184 rp="What is the type of process ids on this system?"
11185 set pid_t pidtype int stdio.h sys/types.h
11186 eval $typedef_ask
11187
11188 : check for length of pointer
11189 echo " "
11190 case "$ptrsize" in
11191 '')
11192         $echo $n "Checking to see how big your pointers are...$c" >&4
11193         if test "$voidflags" -gt 7; then
11194                 echo '#define VOID_PTR char *' > try.c
11195         else
11196                 echo '#define VOID_PTR void *' > try.c
11197         fi
11198         $cat >>try.c <<'EOCP'
11199 #include <stdio.h>
11200 int main()
11201 {
11202         printf("%d\n", sizeof(VOID_PTR));
11203         exit(0);
11204 }
11205 EOCP
11206         set try
11207         if eval $compile_ok; then
11208                 ptrsize=`./try`
11209                 $echo " $ptrsize bytes." >&4
11210         else
11211                 dflt='4'
11212                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11213                 rp="What is the size of a pointer (in bytes)?"
11214                 . ./myread
11215                 ptrsize="$ans"
11216         fi
11217         ;;
11218 esac
11219 $rm -f try.c try
11220
11221 : see if ar generates random libraries by itself
11222 echo " "
11223 echo "Checking how to generate random libraries on your machine..." >&4
11224 echo 'int bar1() { return bar2(); }' > bar1.c
11225 echo 'int bar2() { return 2; }' > bar2.c
11226 $cat > foo.c <<'EOP'
11227 int main() { printf("%d\n", bar1()); exit(0); }
11228 EOP
11229 $cc $ccflags -c bar1.c >/dev/null 2>&1
11230 $cc $ccflags -c bar2.c >/dev/null 2>&1
11231 $cc $ccflags -c foo.c >/dev/null 2>&1
11232 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11233 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11234         ./foobar >/dev/null 2>&1; then
11235         echo "$ar appears to generate random libraries itself."
11236         orderlib=false
11237         ranlib=":"
11238 elif $ar ts bar$_a >/dev/null 2>&1 &&
11239         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11240         ./foobar >/dev/null 2>&1; then
11241                 echo "a table of contents needs to be added with '$ar ts'."
11242                 orderlib=false
11243                 ranlib="$ar ts"
11244 else
11245         case "$ranlib" in
11246         :) ranlib='';;
11247         '')
11248                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11249                 $test -f $ranlib || ranlib=''
11250                 ;;
11251         esac
11252         if $test -n "$ranlib"; then
11253                 echo "your system has '$ranlib'; we'll use that."
11254                 orderlib=false
11255         else
11256                 echo "your system doesn't seem to support random libraries"
11257                 echo "so we'll use lorder and tsort to order the libraries."
11258                 orderlib=true
11259                 ranlib=":"
11260         fi
11261 fi
11262 $rm -f foo* bar* 
11263
11264 : check for type of arguments to select. 
11265 case "$selecttype" in
11266 '') case "$d_select" in
11267         $define)
11268                 $cat <<EOM
11269 Checking to see what type of arguments are accepted by select().
11270 EOM
11271                 hdrs="$define sys/types.h
11272                         $i_systime sys/time.h 
11273                         $i_sysselct sys/select.h
11274                         $d_socket sys/socket.h"
11275                 : The first arg can be int, unsigned, or size_t
11276                 : The last arg may or may not be 'const'
11277                 val=''
11278                 : void pointer has been seen but using that
11279                 : breaks the selectminbits test
11280                 for xxx in 'fd_set *' 'int *'; do
11281                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11282                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11283                                         case "$val" in
11284                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11285                                                 if ./protochk "$try" $hdrs; then
11286                                                         echo "Your system accepts $xxx."
11287                                                         val="$xxx"
11288                                                 fi
11289                                                 ;;
11290                                         esac
11291                                 done
11292                         done
11293                 done
11294                 case "$val" in
11295                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11296                         case "$d_fd_set" in
11297                                 $define) dflt="fd_set *" ;;
11298                                 *)              dflt="int *" ;;
11299                         esac
11300                         . ./myread
11301                         val=$ans
11302                         ;;
11303                 esac
11304                 selecttype="$val"
11305                 ;;
11306         *)      : no select, so pick a harmless default
11307                 selecttype='int *'
11308                 ;;
11309         esac
11310         ;;
11311 esac
11312
11313 : check for the select 'width'
11314 case "$selectminbits" in
11315 '') case "$d_select" in
11316         $define)
11317                 $cat <<EOM
11318
11319 Checking to see on how many bits at a time your select() operates...
11320 EOM
11321                 $cat >try.c <<EOCP
11322 #include <sys/types.h>
11323 #$i_time I_TIME
11324 #$i_systime I_SYS_TIME
11325 #$i_systimek I_SYS_TIME_KERNEL
11326 #ifdef I_TIME
11327 #   include <time.h>
11328 #endif
11329 #ifdef I_SYS_TIME
11330 #   ifdef I_SYS_TIME_KERNEL
11331 #       define KERNEL
11332 #   endif
11333 #   include <sys/time.h>
11334 #   ifdef I_SYS_TIME_KERNEL
11335 #       undef KERNEL
11336 #   endif
11337 #endif
11338 #$i_sysselct I_SYS_SELECT
11339 #ifdef I_SYS_SELECT
11340 #include <sys/select.h>
11341 #endif
11342 #include <stdio.h>
11343 $selecttype b;
11344 #define S sizeof(*(b))
11345 #define MINBITS 64
11346 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11347 #define NBITS  (NBYTES * 8)
11348 int main() {
11349     char s[NBYTES];
11350     struct timeval t;
11351     int i;
11352     FILE* fp;
11353     int fd;
11354
11355     fclose(stdin);
11356     fp = fopen("try.c", "r");
11357     if (fp == 0)
11358       exit(1);
11359     fd = fileno(fp);
11360     if (fd < 0)
11361       exit(2);
11362     b = ($selecttype)s;
11363     for (i = 0; i < NBITS; i++)
11364         FD_SET(i, b);
11365     t.tv_sec  = 0;
11366     t.tv_usec = 0;
11367     select(fd + 1, b, 0, 0, &t);
11368     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11369     printf("%d\n", i + 1);
11370     return 0;
11371 }
11372 EOCP
11373                 set try
11374                 if eval $compile_ok; then
11375                         selectminbits=`./try`
11376                         case "$selectminbits" in
11377                         '')     cat >&4 <<EOM
11378 Cannot figure out on how many bits at a time your select() operates.
11379 I'll play safe and guess it is 32 bits.
11380 EOM
11381                                 selectminbits=32
11382                                 bits="32 bits"
11383                                 ;;
11384                         1)      bits="1 bit" ;;
11385                         *)      bits="$selectminbits bits" ;;
11386                         esac
11387                         echo "Your select() operates on $bits at a time." >&4
11388                 else
11389                         rp='What is the minimum number of bits your select() operates on?'
11390                         case "$byteorder" in
11391                         1234|12345678)  dflt=32 ;;
11392                         *)              dflt=1  ;;
11393                         esac
11394                         . ./myread
11395                         val=$ans
11396                         selectminbits="$val"
11397                 fi
11398                 $rm -f try.* try
11399                 ;;
11400         *)      : no select, so pick a harmless default
11401                 selectminbits='32'
11402                 ;;
11403         esac
11404         ;;
11405 esac
11406
11407 : Trace out the files included by signal.h, then look for SIGxxx names.
11408 : Remove SIGARRAYSIZE used by HPUX.
11409 : Remove SIGTYP void lines used by OS2.
11410 xxx=`echo '#include <signal.h>' |
11411         $cppstdin $cppminus $cppflags 2>/dev/null |
11412         $grep '^[       ]*#.*include' | 
11413         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11414 : Check this list of files to be sure we have parsed the cpp output ok.
11415 : This will also avoid potentially non-existent files, such 
11416 : as ../foo/bar.h
11417 xxxfiles=''
11418 for xx in $xxx /dev/null ; do
11419         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11420 done
11421 : If we have found no files, at least try signal.h
11422 case "$xxxfiles" in
11423 '')     xxxfiles=`./findhdr signal.h` ;;
11424 esac
11425 xxx=`awk '
11426 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $3 !~ /void/ {
11427         print substr($2, 4, 20)
11428 }
11429 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11430         print substr($3, 4, 20)
11431 }' $xxxfiles`
11432 : Append some common names just in case the awk scan failed.
11433 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11434 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11435 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11436 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11437 : generate a few handy files for later
11438 $cat > signal.c <<'EOCP'
11439 #include <sys/types.h>
11440 #include <signal.h>
11441 #include <stdio.h>
11442 int main() {
11443
11444 /* Strange style to avoid deeply-nested #if/#else/#endif */
11445 #ifndef NSIG
11446 #  ifdef _NSIG
11447 #    define NSIG (_NSIG)
11448 #  endif
11449 #endif
11450
11451 #ifndef NSIG
11452 #  ifdef SIGMAX
11453 #    define NSIG (SIGMAX+1)
11454 #  endif
11455 #endif
11456
11457 #ifndef NSIG
11458 #  ifdef SIG_MAX
11459 #    define NSIG (SIG_MAX+1)
11460 #  endif
11461 #endif
11462
11463 #ifndef NSIG
11464 #  ifdef MAXSIG
11465 #    define NSIG (MAXSIG+1)
11466 #  endif
11467 #endif
11468
11469 #ifndef NSIG
11470 #  ifdef MAX_SIG
11471 #    define NSIG (MAX_SIG+1)
11472 #  endif
11473 #endif
11474
11475 #ifndef NSIG
11476 #  ifdef SIGARRAYSIZE
11477 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11478 #  endif
11479 #endif
11480
11481 #ifndef NSIG
11482 #  ifdef _sys_nsig
11483 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11484 #  endif
11485 #endif
11486
11487 /* Default to some arbitrary number that's big enough to get most
11488    of the common signals.
11489 */
11490 #ifndef NSIG
11491 #    define NSIG 50
11492 #endif
11493
11494 printf("NSIG %d\n", NSIG);
11495
11496 #ifndef JUST_NSIG
11497
11498 EOCP
11499
11500 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11501 {
11502         printf "#ifdef SIG"; printf $1; printf "\n"
11503         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11504         printf $1; printf ");\n"
11505         printf "#endif\n"
11506 }
11507 END {
11508         printf "#endif /* JUST_NSIG */\n";
11509         printf "}\n";
11510 }
11511 ' >>signal.c
11512 $cat >signal.awk <<'EOP'
11513 BEGIN { ndups = 0 }
11514 $1 ~ /^NSIG$/ { nsig = $2 }
11515 ($1 !~ /^NSIG$/) && (NF == 2) {
11516     if ($2 > maxsig) { maxsig = $2 }
11517     if (sig_name[$2]) {
11518         dup_name[ndups] = $1
11519         dup_num[ndups] = $2
11520         ndups++ 
11521     }
11522     else {
11523         sig_name[$2] = $1
11524         sig_num[$2] = $2
11525     }
11526
11527 }
11528 END { 
11529     if (nsig == 0) { nsig = maxsig + 1 }
11530         for (n = 1; n < nsig; n++) {
11531                 if (sig_name[n]) {
11532                         printf("%s %d\n", sig_name[n], sig_num[n])
11533                 }
11534                 else {
11535                         printf("NUM%d %d\n", n, n) 
11536                 }
11537         }
11538     for (n = 0; n < ndups; n++) {
11539                 printf("%s %d\n", dup_name[n], dup_num[n])
11540     }
11541 }
11542 EOP
11543 $cat >signal_cmd <<EOS
11544 $startsh
11545 if $test -s signal.lst; then
11546     echo "Using your existing signal.lst file"
11547         exit 0
11548 fi
11549 xxx="$xxx"
11550 EOS
11551 $cat >>signal_cmd <<'EOS'
11552
11553 set signal
11554 if eval $compile_ok; then
11555         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11556 else
11557         echo "(I can't seem be able to compile the whole test program)" >&4
11558         echo "(I'll try it in little pieces.)" >&4
11559         set signal -DJUST_NSIG
11560         if eval $compile_ok; then
11561                 ./signal$_exe > signal.nsg
11562                 $cat signal.nsg
11563         else
11564                 echo "I can't seem to figure out how many signals you have." >&4
11565                 echo "Guessing 50." >&4
11566                 echo 'NSIG 50' > signal.nsg
11567         fi
11568         : Now look at all the signal names, one at a time.
11569         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11570                 $cat > signal.c <<EOCP
11571 #include <sys/types.h>
11572 #include <signal.h>
11573 #include <stdio.h>
11574 int main() {
11575 printf("$xx %d\n", SIG${xx});
11576 return 0;
11577 }
11578 EOCP
11579                 set signal
11580                 if eval $compile; then
11581                         echo "SIG${xx} found."
11582                         ./signal$_exe  >> signal.ls1
11583                 else
11584                         echo "SIG${xx} NOT found."
11585                 fi
11586         done
11587         if $test -s signal.ls1; then
11588                 $cat signal.nsg signal.ls1 |
11589                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11590         fi
11591
11592 fi
11593 if $test -s signal.lst; then
11594         :
11595 else
11596         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11597         echo 'kill -l' >signal
11598         set X `csh -f <signal`
11599         $rm -f signal
11600         shift
11601         case $# in
11602         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11603         esac
11604         echo $@ | $tr ' ' $trnl | \
11605                 $awk '{ printf $1; printf " %d\n", ++s; }' >signal.lst
11606 fi
11607 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11608 EOS
11609 chmod a+x signal_cmd
11610 $eunicefix signal_cmd
11611
11612 : generate list of signal names
11613 echo " "
11614 case "$sig_name_init" in
11615 '') doinit=yes ;;
11616 *)  case "$sig_num_init" in
11617     ''|*,*) doinit=yes ;;
11618     esac ;;
11619 esac
11620 case "$doinit" in
11621 yes)
11622         echo "Generating a list of signal names and numbers..." >&4
11623         . ./signal_cmd
11624         sig_name=`$awk '{printf "%s ", $1}' signal.lst`
11625         sig_name="ZERO $sig_name"
11626         sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
11627                                                 { printf "\"%s\", ", $1 }
11628                                                 END { printf "0\n" }' signal.lst`
11629         sig_num=`$awk '{printf "%d ", $2}' signal.lst`
11630         sig_num="0 $sig_num"
11631         sig_num_init=`$awk 'BEGIN { printf "0, " }
11632                                         { printf "%d, ", $2}
11633                                         END { printf "0\n"}' signal.lst`
11634         ;;
11635 esac
11636 echo "The following signals are available:"
11637 echo " "
11638 echo $sig_name | $awk \
11639 'BEGIN { linelen = 0 }
11640 {
11641         for (i = 1; i <= NF; i++) {
11642                 name = "SIG" $i " "
11643                 linelen = linelen + length(name)
11644                 if (linelen > 70) {
11645                         printf "\n"
11646                         linelen = length(name)
11647                 }
11648                 printf "%s", name
11649         }
11650         printf "\n"
11651 }'
11652 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11653
11654 : see what type is used for signed size_t
11655 set ssize_t ssizetype int stdio.h sys/types.h
11656 eval $typedef
11657 dflt="$ssizetype"
11658 $cat > ssize.c <<EOM
11659 #include <stdio.h>
11660 #include <sys/types.h>
11661 #define Size_t $sizetype
11662 #define SSize_t $dflt
11663 int main()
11664 {
11665         if (sizeof(Size_t) == sizeof(SSize_t))
11666                 printf("$dflt\n");
11667         else if (sizeof(Size_t) == sizeof(int))
11668                 printf("int\n");
11669         else 
11670                 printf("long\n");
11671         exit(0);
11672 }
11673 EOM
11674 echo " "
11675 set ssize
11676 if eval $compile_ok && ./ssize > /dev/null; then
11677         ssizetype=`./ssize`
11678         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11679 else
11680         $cat >&4 <<EOM
11681 Help! I can't compile and run the ssize_t test program: please enlighten me!
11682 (This is probably a misconfiguration in your system or libraries, and
11683 you really ought to fix it.  Still, I'll try anyway.)
11684
11685 I need a type that is the same size as $sizetype, but is guaranteed to
11686 be signed.  Common values are ssize_t, int and long.
11687
11688 EOM
11689         rp="What signed type is the same size as $sizetype?"
11690         . ./myread
11691         ssizetype="$ans"
11692 fi
11693 $rm -f ssize ssize.*
11694
11695 : see what type of char stdio uses.
11696 echo " "
11697 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11698         echo "Your stdio uses unsigned chars." >&4
11699         stdchar="unsigned char"
11700 else
11701         echo "Your stdio uses signed chars." >&4
11702         stdchar="char"
11703 fi
11704
11705 : see if time exists
11706 echo " "
11707 if test "X$d_time" = X -o X"$timetype" = X; then
11708     if set time val -f d_time; eval $csym; $val; then
11709                 echo 'time() found.' >&4
11710                 val="$define"
11711                 rp="What is the type returned by time() on this system?"
11712                 set time_t timetype long stdio.h sys/types.h
11713                 eval $typedef_ask
11714     else
11715                 echo 'time() not found, hope that will do.' >&4
11716                 val="$undef"
11717                 timetype='int';
11718     fi
11719     set d_time
11720     eval $setvar
11721 fi
11722
11723 : see what type uids are declared as in the kernel
11724 echo " "
11725 echo "Looking for the type for user ids returned by getuid()."
11726 set uid_t uidtype xxx stdio.h sys/types.h
11727 eval $typedef
11728 case "$uidtype" in
11729 xxx)
11730         xxx=`./findhdr sys/user.h`
11731         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
11732         case $1 in
11733         unsigned) dflt="$1 $2" ;;
11734         *) dflt="$1" ;;
11735         esac
11736         ;;
11737 *) dflt="$uidtype";;
11738 esac
11739 case "$uidtype" in
11740 uid_t)  echo "uid_t found." ;;
11741 *)      rp="What is the type for user ids returned by getuid()?"
11742         . ./myread
11743         uidtype="$ans"
11744         ;;
11745 esac
11746
11747 : see if dbm.h is available
11748 : see if dbmclose exists
11749 set dbmclose d_dbmclose
11750 eval $inlibc
11751
11752 case "$d_dbmclose" in
11753 $define)
11754         set dbm.h i_dbm
11755         eval $inhdr
11756         case "$i_dbm" in
11757         $define)
11758                 val="$undef"
11759                 set i_rpcsvcdbm
11760                 eval $setvar
11761                 ;;
11762         *)      set rpcsvc/dbm.h i_rpcsvcdbm
11763                 eval $inhdr
11764                 ;;
11765         esac
11766         ;;
11767 *)      echo "We won't be including <dbm.h>"
11768         val="$undef"
11769         set i_dbm
11770         eval $setvar
11771         val="$undef"
11772         set i_rpcsvcdbm
11773         eval $setvar
11774         ;;
11775 esac
11776
11777 : see if this is a sys/file.h system
11778 val=''
11779 set sys/file.h val
11780 eval $inhdr
11781
11782 : do we need to include sys/file.h ?
11783 case "$val" in
11784 "$define")
11785         echo " "
11786         if $h_sysfile; then
11787                 val="$define"
11788                 echo "We'll be including <sys/file.h>." >&4
11789         else
11790                 val="$undef"
11791                 echo "We won't be including <sys/file.h>." >&4
11792         fi
11793         ;;
11794 *)
11795         h_sysfile=false
11796         ;;
11797 esac
11798 set i_sysfile
11799 eval $setvar
11800
11801 : see if fcntl.h is there
11802 val=''
11803 set fcntl.h val
11804 eval $inhdr
11805
11806 : see if we can include fcntl.h
11807 case "$val" in
11808 "$define")
11809         echo " "
11810         if $h_fcntl; then
11811                 val="$define"
11812                 echo "We'll be including <fcntl.h>." >&4
11813         else
11814                 val="$undef"
11815                 if $h_sysfile; then
11816         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
11817                 else
11818                         echo "We won't be including <fcntl.h>." >&4
11819                 fi
11820         fi
11821         ;;
11822 *)
11823         h_fcntl=false
11824         val="$undef"
11825         ;;
11826 esac
11827 set i_fcntl
11828 eval $setvar
11829
11830 : see if locale.h is available
11831 set locale.h i_locale
11832 eval $inhdr
11833
11834 : see if mach cthreads are available
11835 if test "X$usethreads" = "X$define"; then
11836         set mach/cthreads.h i_machcthr
11837         eval $inhdr
11838 else
11839         i_machcthr="$undef"
11840 fi
11841
11842
11843
11844 : see if this is a math.h system
11845 set math.h i_math
11846 eval $inhdr
11847
11848 : see if this is a mntent.h system
11849 set mntent.h i_mntent
11850 eval $inhdr
11851
11852 : see if ndbm.h is available
11853 set ndbm.h t_ndbm
11854 eval $inhdr
11855 case "$t_ndbm" in
11856 $define)
11857         : see if dbm_open exists
11858         set dbm_open d_dbm_open
11859         eval $inlibc
11860         case "$d_dbm_open" in
11861         $undef)
11862                 t_ndbm="$undef"
11863                 echo "We won't be including <ndbm.h>"
11864                 ;;
11865         esac
11866         ;;
11867 esac
11868 val="$t_ndbm"
11869 set i_ndbm
11870 eval $setvar
11871
11872 : see if net/errno.h is available
11873 val=''
11874 set net/errno.h val
11875 eval $inhdr
11876
11877 : Unfortunately, it causes problems on some systems.  Arrgh.
11878 case "$val" in
11879 $define)
11880         cat > try.c <<'EOM'
11881 #include <stdio.h>
11882 #include <errno.h>
11883 #include <net/errno.h>
11884 int func()
11885 {
11886         return ENOTSOCK;
11887 }
11888 EOM
11889         if $cc $ccflags -c try.c >/dev/null 2>&1; then
11890                 echo "We'll be including <net/errno.h>." >&4
11891         else
11892                 echo "We won't be including <net/errno.h>." >&4
11893                 val="$undef"
11894         fi
11895         $rm -f try.* try
11896         ;;
11897 esac
11898 set i_neterrno
11899 eval $setvar
11900
11901 : see if this is a poll.h system
11902 set poll.h i_poll
11903 eval $inhdr
11904
11905 : get C preprocessor symbols handy
11906 echo " "
11907 $echo $n "Hmm... $c"
11908 echo $al | $tr ' ' $trnl >Cppsym.know
11909 $cat <<EOSS >Cppsym
11910 $startsh
11911 case "\$1" in
11912 -l) list=true
11913         shift
11914         ;;
11915 esac
11916 unknown=''
11917 case "\$list\$#" in
11918 1|2)
11919         for sym do
11920                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
11921                         exit 0
11922                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
11923                         :
11924                 else
11925                         unknown="\$unknown \$sym"
11926                 fi
11927         done
11928         set X \$unknown
11929         shift
11930         ;;
11931 esac
11932 case \$# in
11933 0) exit 1;;
11934 esac
11935 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
11936 #ifdef \1\\
11937 exit 0; _ _ _ _\1\\      \1\\
11938 #endif\\
11939 /' >Cppsym\$\$
11940 echo "exit 1; _ _ _" >>Cppsym\$\$
11941 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
11942 case "\$list" in
11943 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
11944 *)
11945         sh Cppsym2\$\$
11946         status=\$?
11947         ;;
11948 esac
11949 $rm -f Cppsym\$\$ Cppsym2\$\$
11950 exit \$status
11951 EOSS
11952 chmod +x Cppsym
11953 $eunicefix Cppsym
11954 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
11955
11956 : now check the C compiler for additional symbols
11957 $cat >ccsym <<EOS
11958 $startsh
11959 $cat >tmp.c <<EOF
11960 extern int foo;
11961 EOF
11962 for i in \`$cc -v -c tmp.c 2>&1\`
11963 do
11964         case "\$i" in
11965         -D*) echo "\$i" | $sed 's/^-D//';;
11966         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
11967         esac
11968 done
11969 $rm -f try.c
11970 EOS
11971 chmod +x ccsym
11972 $eunicefix ccsym
11973 ./ccsym > ccsym1.raw
11974 if $test -s ccsym1.raw; then
11975        $sort ccsym1.raw | $uniq >ccsym.raw
11976 else
11977        mv ccsym1.raw ccsym.raw
11978 fi
11979
11980 $awk '/\=/ { print $0; next }
11981         { print $0"=1" }' ccsym.raw >ccsym.list
11982 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
11983 $comm -13 ccsym.true ccsym.list >ccsym.own
11984 $comm -12 ccsym.true ccsym.list >ccsym.com
11985 $comm -23 ccsym.true ccsym.list >ccsym.cpp
11986 also=''
11987 if $test -z ccsym.raw; then
11988         echo "Your C compiler doesn't seem to define any symbols!" >&4
11989         echo " "
11990         echo "However, your C preprocessor defines the following symbols:"
11991         $cat Cppsym.true
11992         ccsymbols=''
11993         cppsymbols=`$cat Cppsym.true`
11994         cppsymbols=`echo $cppsymbols`
11995         cppccsymbols="$cppsymbols"
11996 else
11997         if $test -s ccsym.com; then
11998                 echo "Your C compiler and pre-processor define these symbols:"
11999                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12000                 also='also '
12001                 symbols='ones'
12002                 cppccsymbols=`$cat ccsym.com`
12003                 cppccsymbols=`echo $cppccsymbols`
12004                 $test "$silent" || sleep 1
12005         fi
12006         if $test -s ccsym.cpp; then
12007                 $test "$also" && echo " "
12008                 echo "Your C pre-processor ${also}defines the following symbols:"
12009                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12010                 also='further '
12011                 cppsymbols=`$cat ccsym.cpp`
12012                 cppsymbols=`echo $cppsymbols`
12013                 $test "$silent" || sleep 1
12014         fi
12015         if $test -s ccsym.own; then
12016                 $test "$also" && echo " "
12017                 echo "Your C compiler ${also}defines the following cpp symbols:"
12018                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12019                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12020                 ccsymbols=`$cat ccsym.own`
12021                 ccsymbols=`echo $ccsymbols`
12022                 $test "$silent" || sleep 1
12023         fi
12024 fi
12025 $rm -f ccsym*
12026
12027 : see if this is a termio system
12028 val="$undef"
12029 val2="$undef"
12030 val3="$undef"
12031 if $test `./findhdr termios.h`; then
12032         set tcsetattr i_termios
12033         eval $inlibc
12034         val3="$i_termios"
12035 fi
12036 echo " "
12037 case "$val3" in
12038 "$define") echo "You have POSIX termios.h... good!" >&4;;
12039 *) if ./Cppsym pyr; then
12040                 case "`/bin/universe`" in
12041                 ucb) if $test `./findhdr sgtty.h`; then
12042                                 val2="$define"
12043                                 echo "<sgtty.h> found." >&4
12044                         else
12045                                 echo "System is pyramid with BSD universe."
12046                                 echo "<sgtty.h> not found--you could have problems." >&4
12047                         fi;;
12048                 *) if $test `./findhdr termio.h`; then
12049                                 val="$define"
12050                                 echo "<termio.h> found." >&4
12051                         else
12052                                 echo "System is pyramid with USG universe."
12053                                 echo "<termio.h> not found--you could have problems." >&4
12054                         fi;;
12055                 esac
12056         elif ./usg; then
12057                 if $test `./findhdr termio.h`; then
12058                         echo "<termio.h> found." >&4
12059                         val="$define"
12060                 elif $test `./findhdr sgtty.h`; then
12061                         echo "<sgtty.h> found." >&4
12062                         val2="$define"
12063                 else
12064 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12065                 fi
12066         else
12067                 if $test `./findhdr sgtty.h`; then
12068                         echo "<sgtty.h> found." >&4
12069                         val2="$define"
12070                 elif $test `./findhdr termio.h`; then
12071                         echo "<termio.h> found." >&4
12072                         val="$define"
12073                 else
12074 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12075                 fi
12076         fi;;
12077 esac
12078 set i_termio; eval $setvar
12079 val=$val2; set i_sgtty; eval $setvar
12080 val=$val3; set i_termios; eval $setvar
12081
12082 : see if stdarg is available
12083 echo " "
12084 if $test `./findhdr stdarg.h`; then
12085         echo "<stdarg.h> found." >&4
12086         valstd="$define"
12087 else
12088         echo "<stdarg.h> NOT found." >&4
12089         valstd="$undef"
12090 fi
12091
12092 : see if varags is available
12093 echo " "
12094 if $test `./findhdr varargs.h`; then
12095         echo "<varargs.h> found." >&4
12096 else
12097         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12098 fi
12099
12100 : set up the varargs testing programs
12101 $cat > varargs.c <<EOP
12102 #ifdef I_STDARG
12103 #include <stdarg.h>
12104 #endif
12105 #ifdef I_VARARGS
12106 #include <varargs.h>
12107 #endif
12108
12109 #ifdef I_STDARG
12110 int f(char *p, ...)
12111 #else
12112 int f(va_alist)
12113 va_dcl
12114 #endif
12115 {
12116         va_list ap;
12117 #ifndef I_STDARG
12118         char *p;
12119 #endif
12120 #ifdef I_STDARG
12121         va_start(ap,p);
12122 #else
12123         va_start(ap);
12124         p = va_arg(ap, char *);
12125 #endif
12126         va_end(ap);
12127 }
12128 EOP
12129 $cat > varargs <<EOP
12130 $startsh
12131 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12132         echo "true"
12133 else
12134         echo "false"
12135 fi
12136 $rm -f varargs$_o
12137 EOP
12138 chmod +x varargs
12139
12140 : now check which varargs header should be included
12141 echo " "
12142 i_varhdr=''
12143 case "$valstd" in
12144 "$define")
12145         if `./varargs I_STDARG`; then
12146                 val='stdarg.h'
12147         elif `./varargs I_VARARGS`; then
12148                 val='varargs.h'
12149         fi
12150         ;;
12151 *)
12152         if `./varargs I_VARARGS`; then
12153                 val='varargs.h'
12154         fi
12155         ;;
12156 esac
12157 case "$val" in
12158 '')
12159 echo "I could not find the definition for va_dcl... You have problems..." >&4
12160         val="$undef"; set i_stdarg; eval $setvar
12161         val="$undef"; set i_varargs; eval $setvar
12162         ;;
12163 *) 
12164         set i_varhdr
12165         eval $setvar
12166         case "$i_varhdr" in
12167         stdarg.h)
12168                 val="$define"; set i_stdarg; eval $setvar
12169                 val="$undef"; set i_varargs; eval $setvar
12170                 ;;
12171         varargs.h)
12172                 val="$undef"; set i_stdarg; eval $setvar
12173                 val="$define"; set i_varargs; eval $setvar
12174                 ;;
12175         esac
12176         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12177 esac
12178 $rm -f varargs*
12179
12180 : see if stddef is available
12181 set stddef.h i_stddef
12182 eval $inhdr
12183
12184 : see if sys/access.h is available
12185 set sys/access.h i_sysaccess
12186 eval $inhdr
12187
12188 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12189 set sys/filio.h i_sysfilio
12190 eval $inhdr
12191 echo " "
12192 if $test `./findhdr sys/ioctl.h`; then
12193         val="$define"
12194         echo '<sys/ioctl.h> found.' >&4
12195 else
12196         val="$undef"
12197         if $test $i_sysfilio = "$define"; then
12198             echo '<sys/ioctl.h> NOT found.' >&4
12199         else
12200                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12201                 $test $i_termio = "$define" && xxx="termio.h"
12202                 $test $i_termios = "$define" && xxx="termios.h"
12203 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12204         fi
12205 fi
12206 set i_sysioctl
12207 eval $setvar
12208
12209 : see if sys/resource.h has to be included
12210 set sys/resource.h i_sysresrc
12211 eval $inhdr
12212
12213 : see if sys/security.h is available
12214 set sys/security.h i_syssecrt
12215 eval $inhdr
12216
12217 : see if this is a sys/statvfs.h system
12218 set sys/statvfs.h i_sysstatvfs
12219 eval $inhdr
12220
12221 : see if this is a sys/un.h system
12222 set sys/un.h i_sysun
12223 eval $inhdr
12224
12225 : see if this is a syswait system
12226 set sys/wait.h i_syswait
12227 eval $inhdr
12228
12229 : see if this is an utime system
12230 set utime.h i_utime
12231 eval $inhdr
12232
12233 : see if this is a values.h system
12234 set values.h i_values
12235 eval $inhdr
12236
12237 : see if this is a vfork system
12238 case "$d_vfork" in
12239 "$define")
12240         set vfork.h i_vfork
12241         eval $inhdr
12242         ;;
12243 *)
12244         i_vfork="$undef"
12245         ;;
12246 esac
12247
12248 : see if gdbm.h is available
12249 set gdbm.h t_gdbm
12250 eval $inhdr
12251 case "$t_gdbm" in
12252 $define)
12253         : see if gdbm_open exists
12254         set gdbm_open d_gdbm_open
12255         eval $inlibc
12256         case "$d_gdbm_open" in
12257         $undef)
12258                 t_gdbm="$undef"
12259                 echo "We won't be including <gdbm.h>"
12260                 ;;
12261         esac
12262         ;;
12263 esac
12264 val="$t_gdbm"
12265 set i_gdbm
12266 eval $setvar
12267
12268 echo " "
12269 echo "Looking for extensions..." >&4
12270 tdir=`pwd`
12271 cd $rsrc/ext
12272 : If we are using the old config.sh, known_extensions may contain
12273 : old or inaccurate or duplicate values.
12274 known_extensions=''
12275 nonxs_extensions=''
12276 : We do not use find because it might not be available.
12277 : We do not just use MANIFEST because the user may have dropped
12278 : some additional extensions into the source tree and expect them
12279 : to be built.
12280 for xxx in * ; do
12281         case "$xxx" in
12282         DynaLoader|dynaload) ;;
12283         *)      if $test -f $xxx/$xxx.xs; then
12284                         known_extensions="$known_extensions $xxx"
12285                 elif $test -f $xxx/Makefile.PL; then
12286                         nonxs_extensions="$nonxs_extensions $xxx"
12287                 else
12288                         if $test -d $xxx; then
12289                                 # Look for nested extensions, eg. Devel/Dprof.
12290                                 cd $xxx
12291                                 for yyy in * ; do
12292                                 if $test -f $yyy/$yyy.xs; then
12293                                         known_extensions="$known_extensions $xxx/$yyy"
12294                                 elif $test -f $yyy/Makefile.PL; then
12295                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12296                                 fi
12297                                 done
12298                                 cd ..
12299                         fi
12300                 fi 
12301                 ;;
12302         esac
12303 done
12304 set X $nonxs_extensions
12305 shift
12306 nonxs_extensions="$*"
12307 set X $known_extensions
12308 shift
12309 known_extensions="$*"
12310 cd $tdir
12311
12312 : Now see which are supported on this system.
12313 avail_ext=''
12314 for xxx in $known_extensions ; do
12315         case "$xxx" in
12316         DB_File|db_file)
12317                 case "$i_db" in
12318                 $define) avail_ext="$avail_ext $xxx" ;;
12319                 esac
12320                 ;;
12321         GDBM_File|gdbm_fil)
12322                 case "$i_gdbm" in 
12323                 $define) avail_ext="$avail_ext $xxx" ;;
12324                 esac
12325                 ;;
12326         NDBM_File|ndbm_fil)
12327                 case "$i_ndbm" in
12328                 $define) avail_ext="$avail_ext $xxx" ;;
12329                 esac
12330                 ;;
12331         ODBM_File|odbm_fil) 
12332                 case "${i_dbm}${i_rpcsvcdbm}" in
12333                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12334                 esac
12335                 ;;
12336         POSIX|posix)
12337                 case "$useposix" in
12338                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12339                 esac
12340                 ;;
12341         Opcode|opcode)
12342                 case "$useopcode" in
12343                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12344                 esac
12345                 ;;
12346         Socket|socket)
12347                 case "$d_socket" in 
12348                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12349                 esac
12350                 ;;
12351         Thread|thread)
12352                 case "$usethreads" in 
12353                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12354                 esac
12355                 ;;
12356         IPC/SysV|ipc/sysv)
12357                 : XXX Do we need a useipcsysv variable here
12358                 case "${d_msg}${d_sem}${d_shm}" in 
12359                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12360                 esac
12361                 ;;
12362         *)      avail_ext="$avail_ext $xxx"
12363                 ;;
12364         esac
12365 done
12366
12367 set X $avail_ext
12368 shift
12369 avail_ext="$*"
12370
12371 : Now see which nonxs extensions are supported on this system.
12372 : For now assume all are.
12373 nonxs_ext=''
12374 for xxx in $nonxs_extensions ; do
12375         case "$xxx" in
12376         *)      nonxs_ext="$nonxs_ext $xxx"
12377                 ;;
12378         esac
12379 done
12380
12381 set X $nonxs_ext
12382 shift
12383 nonxs_ext="$*"
12384
12385 case $usedl in
12386 $define)
12387         $cat <<EOM
12388 A number of extensions are supplied with $package.  You may choose to
12389 compile these extensions for dynamic loading (the default), compile
12390 them into the $package executable (static loading), or not include
12391 them at all.  Answer "none" to include no extensions.
12392 Note that DynaLoader is always built and need not be mentioned here.
12393
12394 EOM
12395         case "$dynamic_ext" in
12396         '') dflt="$avail_ext" ;;
12397         *)      dflt="$dynamic_ext"
12398                 # Perhaps we are reusing an old out-of-date config.sh.
12399                 case "$hint" in
12400                 previous)
12401                         if test X"$dynamic_ext" != X"$avail_ext"; then
12402                                 $cat <<EOM
12403 NOTICE:  Your previous config.sh list may be incorrect. 
12404 The extensions now available to you are 
12405         ${avail_ext}
12406 but the default list from your previous config.sh is
12407         ${dynamic_ext} 
12408
12409 EOM
12410                         fi
12411                         ;;
12412                 esac
12413                 ;;
12414         esac
12415         case "$dflt" in
12416         '')     dflt=none;;
12417         esac
12418         rp="What extensions do you wish to load dynamically?"
12419         . ./myread
12420         case "$ans" in
12421         none) dynamic_ext=' ' ;;
12422         *) dynamic_ext="$ans" ;;
12423         esac
12424
12425         case "$static_ext" in
12426         '')
12427                 : Exclude those already listed in dynamic linking
12428                 dflt=''
12429                 for xxx in $avail_ext; do
12430                         case " $dynamic_ext " in
12431                         *" $xxx "*) ;;
12432                         *) dflt="$dflt $xxx" ;;
12433                         esac
12434                 done
12435                 set X $dflt
12436                 shift
12437                 dflt="$*"
12438                 ;;
12439         *)  dflt="$static_ext" 
12440                 ;;
12441         esac
12442
12443         case "$dflt" in
12444         '')     dflt=none;;
12445         esac
12446         rp="What extensions do you wish to load statically?"
12447         . ./myread
12448         case "$ans" in
12449         none) static_ext=' ' ;;
12450         *) static_ext="$ans" ;;
12451         esac
12452         ;;
12453 *)
12454         $cat <<EOM
12455 A number of extensions are supplied with $package.  Answer "none" 
12456 to include no extensions. 
12457 Note that DynaLoader is always built and need not be mentioned here.
12458
12459 EOM
12460         case "$static_ext" in
12461         '') dflt="$avail_ext" ;;
12462         *)      dflt="$static_ext"
12463                 # Perhaps we are reusing an old out-of-date config.sh.
12464                 case "$hint" in
12465                 previous)
12466                         if test X"$static_ext" != X"$avail_ext"; then
12467                                 $cat <<EOM
12468 NOTICE:  Your previous config.sh list may be incorrect. 
12469 The extensions now available to you are 
12470         ${avail_ext}
12471 but the default list from your previous config.sh is
12472         ${static_ext} 
12473
12474 EOM
12475                         fi
12476                         ;;
12477                 esac
12478                 ;;
12479         esac
12480         : Exclude those that are not xs extensions
12481         case "$dflt" in
12482         '')     dflt=none;;
12483         esac
12484         rp="What extensions do you wish to include?"
12485         . ./myread
12486         case "$ans" in
12487         none) static_ext=' ' ;;
12488         *) static_ext="$ans" ;;
12489         esac
12490         ;;
12491 esac
12492
12493 set X $dynamic_ext $static_ext $nonxs_ext
12494 shift
12495 extensions="$*"
12496
12497 : Remove build directory name from cppstdin so it can be used from
12498 : either the present location or the final installed location.
12499 echo " "
12500 : Get out of the UU directory to get correct path name.
12501 cd ..
12502 case "$cppstdin" in
12503 `pwd`/cppstdin)
12504         echo "Stripping down cppstdin path name"
12505         cppstdin=cppstdin
12506         ;;
12507 esac
12508 cd UU
12509
12510 : end of configuration questions
12511 echo " "
12512 echo "End of configuration questions."
12513 echo " "
12514
12515 : back to where it started
12516 if test -d ../UU; then
12517         cd ..
12518 fi
12519
12520 : configuration may be patched via a 'config.over' file
12521 if $test -f config.over; then
12522         echo " "
12523         dflt=y
12524         rp='I see a config.over file.  Do you wish to load it?'
12525         . UU/myread
12526         case "$ans" in
12527         n*) echo "OK, I'll ignore it.";;
12528         *)      . ./config.over
12529                 echo "Configuration override changes have been loaded."
12530                 ;;
12531         esac
12532 fi
12533
12534 : in case they want portability, strip down executable paths
12535 case "$d_portable" in
12536 "$define")
12537         echo " "
12538         echo "Stripping down executable paths..." >&4
12539         for file in $loclist $trylist; do
12540                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12541                         eval $file="\$file"
12542                 fi
12543         done
12544         ;;
12545 esac
12546
12547 : create config.sh file
12548 echo " "
12549 echo "Creating config.sh..." >&4
12550 $spitshell <<EOT >config.sh
12551 $startsh
12552 #
12553 # This file was produced by running the Configure script. It holds all the
12554 # definitions figured out by Configure. Should you modify one of these values,
12555 # do not forget to propagate your changes by running "Configure -der". You may
12556 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12557 #
12558
12559 # Package name      : $package
12560 # Source directory  : $src
12561 # Configuration time: $cf_time
12562 # Configured by     : $cf_by
12563 # Target system     : $myuname
12564
12565 Author='$Author'
12566 Date='$Date'
12567 Header='$Header'
12568 Id='$Id'
12569 Locker='$Locker'
12570 Log='$Log'
12571 Mcc='$Mcc'
12572 RCSfile='$RCSfile'
12573 Revision='$Revision'
12574 Source='$Source'
12575 State='$State'
12576 _a='$_a'
12577 _exe='$_exe'
12578 _o='$_o'
12579 afs='$afs'
12580 alignbytes='$alignbytes'
12581 ansi2knr='$ansi2knr'
12582 aphostname='$aphostname'
12583 apiversion='$apiversion'
12584 ar='$ar'
12585 archlib='$archlib'
12586 archlibexp='$archlibexp'
12587 archname64='$archname64'
12588 archname='$archname'
12589 archobjs='$archobjs'
12590 awk='$awk'
12591 baserev='$baserev'
12592 bash='$bash'
12593 bin='$bin'
12594 binexp='$binexp'
12595 bison='$bison'
12596 byacc='$byacc'
12597 byteorder='$byteorder'
12598 c='$c'
12599 castflags='$castflags'
12600 cat='$cat'
12601 cc='$cc'
12602 cccdlflags='$cccdlflags'
12603 ccdlflags='$ccdlflags'
12604 ccflags='$ccflags'
12605 ccsymbols='$ccsymbols'
12606 cf_by='$cf_by'
12607 cf_email='$cf_email'
12608 cf_time='$cf_time'
12609 chgrp='$chgrp'
12610 chmod='$chmod'
12611 chown='$chown'
12612 clocktype='$clocktype'
12613 comm='$comm'
12614 compress='$compress'
12615 contains='$contains'
12616 cp='$cp'
12617 cpio='$cpio'
12618 cpp='$cpp'
12619 cpp_stuff='$cpp_stuff'
12620 cppccsymbols='$cppccsymbols'
12621 cppflags='$cppflags'
12622 cpplast='$cpplast'
12623 cppminus='$cppminus'
12624 cpprun='$cpprun'
12625 cppstdin='$cppstdin'
12626 cppsymbols='$cppsymbols'
12627 crosscompile='$crosscompile'
12628 cryptlib='$cryptlib'
12629 csh='$csh'
12630 d_Gconvert='$d_Gconvert'
12631 d_access='$d_access'
12632 d_accessx='$d_accessx'
12633 d_alarm='$d_alarm'
12634 d_archlib='$d_archlib'
12635 d_attribut='$d_attribut'
12636 d_bcmp='$d_bcmp'
12637 d_bcopy='$d_bcopy'
12638 d_bsd='$d_bsd'
12639 d_bsdgetpgrp='$d_bsdgetpgrp'
12640 d_bsdsetpgrp='$d_bsdsetpgrp'
12641 d_bzero='$d_bzero'
12642 d_casti32='$d_casti32'
12643 d_castneg='$d_castneg'
12644 d_charvspr='$d_charvspr'
12645 d_chown='$d_chown'
12646 d_chroot='$d_chroot'
12647 d_chsize='$d_chsize'
12648 d_closedir='$d_closedir'
12649 d_cmsghdr_s='$d_cmsghdr_s'
12650 d_const='$d_const'
12651 d_crypt='$d_crypt'
12652 d_csh='$d_csh'
12653 d_cuserid='$d_cuserid'
12654 d_dbl_dig='$d_dbl_dig'
12655 d_dbmclose64='$d_dbmclose64'
12656 d_dbminit64='$d_dbminit64'
12657 d_delete64='$d_delete64'
12658 d_difftime='$d_difftime'
12659 d_dirent64_s='$d_dirent64_s'
12660 d_dirnamlen='$d_dirnamlen'
12661 d_dlerror='$d_dlerror'
12662 d_dlopen='$d_dlopen'
12663 d_dlsymun='$d_dlsymun'
12664 d_dosuid='$d_dosuid'
12665 d_drand48proto='$d_drand48proto'
12666 d_dup2='$d_dup2'
12667 d_eaccess='$d_eaccess'
12668 d_endgrent='$d_endgrent'
12669 d_endhent='$d_endhent'
12670 d_endnent='$d_endnent'
12671 d_endpent='$d_endpent'
12672 d_endpwent='$d_endpwent'
12673 d_endsent='$d_endsent'
12674 d_eofnblk='$d_eofnblk'
12675 d_eunice='$d_eunice'
12676 d_fchmod='$d_fchmod'
12677 d_fchown='$d_fchown'
12678 d_fcntl='$d_fcntl'
12679 d_fd_macros='$d_fd_macros'
12680 d_fd_set='$d_fd_set'
12681 d_fds_bits='$d_fds_bits'
12682 d_fetch64='$d_fetch64'
12683 d_fgetpos64='$d_fgetpos64'
12684 d_fgetpos='$d_fgetpos'
12685 d_firstkey64='$d_firstkey64'
12686 d_flexfnam='$d_flexfnam'
12687 d_flock64_s='$d_flock64_s'
12688 d_flock='$d_flock'
12689 d_fopen64='$d_fopen64'
12690 d_fork='$d_fork'
12691 d_fpathconf='$d_fpathconf'
12692 d_freopen64='$d_freopen64'
12693 d_fseek64='$d_fseek64'
12694 d_fseeko64='$d_fseeko64'
12695 d_fseeko='$d_fseeko'
12696 d_fsetpos64='$d_fsetpos64'
12697 d_fsetpos='$d_fsetpos'
12698 d_fstat64='$d_fstat64'
12699 d_fstatfs='$d_fstatfs'
12700 d_fstatvfs='$d_fstatvfs'
12701 d_ftell64='$d_ftell64'
12702 d_ftello64='$d_ftello64'
12703 d_ftello='$d_ftello'
12704 d_ftime='$d_ftime'
12705 d_ftruncate64='$d_ftruncate64'
12706 d_getgrent='$d_getgrent'
12707 d_getgrps='$d_getgrps'
12708 d_gethbyaddr='$d_gethbyaddr'
12709 d_gethbyname='$d_gethbyname'
12710 d_gethent='$d_gethent'
12711 d_gethname='$d_gethname'
12712 d_gethostprotos='$d_gethostprotos'
12713 d_getlogin='$d_getlogin'
12714 d_getmntent='$d_getmntent'
12715 d_getnbyaddr='$d_getnbyaddr'
12716 d_getnbyname='$d_getnbyname'
12717 d_getnent='$d_getnent'
12718 d_getnetprotos='$d_getnetprotos'
12719 d_getpbyname='$d_getpbyname'
12720 d_getpbynumber='$d_getpbynumber'
12721 d_getpent='$d_getpent'
12722 d_getpgid='$d_getpgid'
12723 d_getpgrp2='$d_getpgrp2'
12724 d_getpgrp='$d_getpgrp'
12725 d_getppid='$d_getppid'
12726 d_getprior='$d_getprior'
12727 d_getprotoprotos='$d_getprotoprotos'
12728 d_getpwent='$d_getpwent'
12729 d_getsbyname='$d_getsbyname'
12730 d_getsbyport='$d_getsbyport'
12731 d_getsent='$d_getsent'
12732 d_getservprotos='$d_getservprotos'
12733 d_gettimeod='$d_gettimeod'
12734 d_gnulibc='$d_gnulibc'
12735 d_grpasswd='$d_grpasswd'
12736 d_hasmntopt='$d_hasmntopt'
12737 d_htonl='$d_htonl'
12738 d_index='$d_index'
12739 d_inetaton='$d_inetaton'
12740 d_ino64t='$d_ino64t'
12741 d_int64t='$d_int64t'
12742 d_iovec_s='$d_iovec_s'
12743 d_isascii='$d_isascii'
12744 d_killpg='$d_killpg'
12745 d_lchown='$d_lchown'
12746 d_link='$d_link'
12747 d_locconv='$d_locconv'
12748 d_lockf64='$d_lockf64'
12749 d_lockf='$d_lockf'
12750 d_longdbl='$d_longdbl'
12751 d_longlong='$d_longlong'
12752 d_lseek64='$d_lseek64'
12753 d_lstat64='$d_lstat64'
12754 d_lstat='$d_lstat'
12755 d_madvise='$d_madvise'
12756 d_mblen='$d_mblen'
12757 d_mbstowcs='$d_mbstowcs'
12758 d_mbtowc='$d_mbtowc'
12759 d_memcmp='$d_memcmp'
12760 d_memcpy='$d_memcpy'
12761 d_memmove='$d_memmove'
12762 d_memset='$d_memset'
12763 d_mkdir='$d_mkdir'
12764 d_mkfifo='$d_mkfifo'
12765 d_mktime='$d_mktime'
12766 d_mmap='$d_mmap'
12767 d_mprotect='$d_mprotect'
12768 d_msg='$d_msg'
12769 d_msg_ctrunc='$d_msg_ctrunc'
12770 d_msg_dontroute='$d_msg_dontroute'
12771 d_msg_oob='$d_msg_oob'
12772 d_msg_peek='$d_msg_peek'
12773 d_msg_proxy='$d_msg_proxy'
12774 d_msgctl='$d_msgctl'
12775 d_msgget='$d_msgget'
12776 d_msghdr_s='$d_msghdr_s'
12777 d_msgrcv='$d_msgrcv'
12778 d_msgsnd='$d_msgsnd'
12779 d_msync='$d_msync'
12780 d_munmap='$d_munmap'
12781 d_mymalloc='$d_mymalloc'
12782 d_nextkey64='$d_nextkey64'
12783 d_nice='$d_nice'
12784 d_off64t='$d_off64t'
12785 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
12786 d_oldpthreads='$d_oldpthreads'
12787 d_oldsock='$d_oldsock'
12788 d_open3='$d_open3'
12789 d_open64='$d_open64'
12790 d_opendir64='$d_opendir64'
12791 d_pathconf='$d_pathconf'
12792 d_pause='$d_pause'
12793 d_phostname='$d_phostname'
12794 d_pipe='$d_pipe'
12795 d_poll='$d_poll'
12796 d_portable='$d_portable'
12797 d_pthread_yield='$d_pthread_yield'
12798 d_pwage='$d_pwage'
12799 d_pwchange='$d_pwchange'
12800 d_pwclass='$d_pwclass'
12801 d_pwcomment='$d_pwcomment'
12802 d_pwexpire='$d_pwexpire'
12803 d_pwgecos='$d_pwgecos'
12804 d_pwpasswd='$d_pwpasswd'
12805 d_pwquota='$d_pwquota'
12806 d_readdir64='$d_readdir64'
12807 d_readdir='$d_readdir'
12808 d_readlink='$d_readlink'
12809 d_readv='$d_readv'
12810 d_recvmsg='$d_recvmsg'
12811 d_rename='$d_rename'
12812 d_rewinddir='$d_rewinddir'
12813 d_rmdir='$d_rmdir'
12814 d_safebcpy='$d_safebcpy'
12815 d_safemcpy='$d_safemcpy'
12816 d_sanemcmp='$d_sanemcmp'
12817 d_sched_yield='$d_sched_yield'
12818 d_scm_rights='$d_scm_rights'
12819 d_seekdir64='$d_seekdir64'
12820 d_seekdir='$d_seekdir'
12821 d_select='$d_select'
12822 d_sem='$d_sem'
12823 d_semctl='$d_semctl'
12824 d_semctl_semid_ds='$d_semctl_semid_ds'
12825 d_semctl_semun='$d_semctl_semun'
12826 d_semget='$d_semget'
12827 d_semop='$d_semop'
12828 d_sendmsg='$d_sendmsg'
12829 d_setegid='$d_setegid'
12830 d_seteuid='$d_seteuid'
12831 d_setgrent='$d_setgrent'
12832 d_setgrps='$d_setgrps'
12833 d_sethent='$d_sethent'
12834 d_setlinebuf='$d_setlinebuf'
12835 d_setlocale='$d_setlocale'
12836 d_setnent='$d_setnent'
12837 d_setpent='$d_setpent'
12838 d_setpgid='$d_setpgid'
12839 d_setpgrp2='$d_setpgrp2'
12840 d_setpgrp='$d_setpgrp'
12841 d_setprior='$d_setprior'
12842 d_setpwent='$d_setpwent'
12843 d_setregid='$d_setregid'
12844 d_setresgid='$d_setresgid'
12845 d_setresuid='$d_setresuid'
12846 d_setreuid='$d_setreuid'
12847 d_setrgid='$d_setrgid'
12848 d_setruid='$d_setruid'
12849 d_setsent='$d_setsent'
12850 d_setsid='$d_setsid'
12851 d_setvbuf='$d_setvbuf'
12852 d_sfio='$d_sfio'
12853 d_shm='$d_shm'
12854 d_shmat='$d_shmat'
12855 d_shmatprototype='$d_shmatprototype'
12856 d_shmctl='$d_shmctl'
12857 d_shmdt='$d_shmdt'
12858 d_shmget='$d_shmget'
12859 d_sigaction='$d_sigaction'
12860 d_sigsetjmp='$d_sigsetjmp'
12861 d_socket='$d_socket'
12862 d_sockpair='$d_sockpair'
12863 d_stat64='$d_stat64'
12864 d_statblks='$d_statblks'
12865 d_statfs='$d_statfs'
12866 d_statfsflags='$d_statfsflags'
12867 d_statvfs='$d_statvfs'
12868 d_stdio_cnt_lval='$d_stdio_cnt_lval'
12869 d_stdio_ptr_lval='$d_stdio_ptr_lval'
12870 d_stdiobase='$d_stdiobase'
12871 d_stdstdio='$d_stdstdio'
12872 d_store64='$d_store64'
12873 d_strchr='$d_strchr'
12874 d_strcoll='$d_strcoll'
12875 d_strctcpy='$d_strctcpy'
12876 d_strerrm='$d_strerrm'
12877 d_strerror='$d_strerror'
12878 d_strtod='$d_strtod'
12879 d_strtol='$d_strtol'
12880 d_strtoul='$d_strtoul'
12881 d_strxfrm='$d_strxfrm'
12882 d_suidsafe='$d_suidsafe'
12883 d_symlink='$d_symlink'
12884 d_syscall='$d_syscall'
12885 d_sysconf='$d_sysconf'
12886 d_sysernlst='$d_sysernlst'
12887 d_syserrlst='$d_syserrlst'
12888 d_system='$d_system'
12889 d_tcgetpgrp='$d_tcgetpgrp'
12890 d_tcsetpgrp='$d_tcsetpgrp'
12891 d_telldir64='$d_telldir64'
12892 d_telldir='$d_telldir'
12893 d_telldirproto='$d_telldirproto'
12894 d_time='$d_time'
12895 d_times='$d_times'
12896 d_tmpfile64='$d_tmpfile64'
12897 d_truncate64='$d_truncate64'
12898 d_truncate='$d_truncate'
12899 d_tzname='$d_tzname'
12900 d_umask='$d_umask'
12901 d_uname='$d_uname'
12902 d_union_semun='$d_union_semun'
12903 d_vfork='$d_vfork'
12904 d_void_closedir='$d_void_closedir'
12905 d_voidsig='$d_voidsig'
12906 d_voidtty='$d_voidtty'
12907 d_volatile='$d_volatile'
12908 d_vprintf='$d_vprintf'
12909 d_wait4='$d_wait4'
12910 d_waitpid='$d_waitpid'
12911 d_wcstombs='$d_wcstombs'
12912 d_wctomb='$d_wctomb'
12913 d_writev='$d_writev'
12914 d_xenix='$d_xenix'
12915 date='$date'
12916 db_hashtype='$db_hashtype'
12917 db_prefixtype='$db_prefixtype'
12918 defvoidused='$defvoidused'
12919 direntrytype='$direntrytype'
12920 dlext='$dlext'
12921 dlsrc='$dlsrc'
12922 doublesize='$doublesize'
12923 drand01='$drand01'
12924 dynamic_ext='$dynamic_ext'
12925 eagain='$eagain'
12926 ebcdic='$ebcdic'
12927 echo='$echo'
12928 egrep='$egrep'
12929 emacs='$emacs'
12930 eunicefix='$eunicefix'
12931 exe_ext='$exe_ext'
12932 expr='$expr'
12933 extensions='$extensions'
12934 find='$find'
12935 firstmakefile='$firstmakefile'
12936 flex='$flex'
12937 fpostype='$fpostype'
12938 freetype='$freetype'
12939 full_ar='$full_ar'
12940 full_csh='$full_csh'
12941 full_sed='$full_sed'
12942 gccversion='$gccversion'
12943 gidtype='$gidtype'
12944 glibpth='$glibpth'
12945 grep='$grep'
12946 groupcat='$groupcat'
12947 groupstype='$groupstype'
12948 gzip='$gzip'
12949 h_fcntl='$h_fcntl'
12950 h_sysfile='$h_sysfile'
12951 hint='$hint'
12952 hostcat='$hostcat'
12953 huge='$huge'
12954 i_arpainet='$i_arpainet'
12955 i_bsdioctl='$i_bsdioctl'
12956 i_db='$i_db'
12957 i_dbm='$i_dbm'
12958 i_dirent='$i_dirent'
12959 i_dld='$i_dld'
12960 i_dlfcn='$i_dlfcn'
12961 i_fcntl='$i_fcntl'
12962 i_float='$i_float'
12963 i_gdbm='$i_gdbm'
12964 i_grp='$i_grp'
12965 i_inttypes='$i_inttypes'
12966 i_limits='$i_limits'
12967 i_locale='$i_locale'
12968 i_machcthr='$i_machcthr'
12969 i_malloc='$i_malloc'
12970 i_math='$i_math'
12971 i_memory='$i_memory'
12972 i_mntent='$i_mntent'
12973 i_ndbm='$i_ndbm'
12974 i_netdb='$i_netdb'
12975 i_neterrno='$i_neterrno'
12976 i_niin='$i_niin'
12977 i_poll='$i_poll'
12978 i_pwd='$i_pwd'
12979 i_rpcsvcdbm='$i_rpcsvcdbm'
12980 i_sfio='$i_sfio'
12981 i_sgtty='$i_sgtty'
12982 i_stdarg='$i_stdarg'
12983 i_stddef='$i_stddef'
12984 i_stdlib='$i_stdlib'
12985 i_string='$i_string'
12986 i_sysaccess='$i_sysaccess'
12987 i_sysdir='$i_sysdir'
12988 i_sysfile='$i_sysfile'
12989 i_sysfilio='$i_sysfilio'
12990 i_sysin='$i_sysin'
12991 i_sysioctl='$i_sysioctl'
12992 i_sysmman='$i_sysmman'
12993 i_sysmount='$i_sysmount'
12994 i_sysndir='$i_sysndir'
12995 i_sysparam='$i_sysparam'
12996 i_sysresrc='$i_sysresrc'
12997 i_syssecrt='$i_syssecrt'
12998 i_sysselct='$i_sysselct'
12999 i_syssockio='$i_syssockio'
13000 i_sysstat='$i_sysstat'
13001 i_sysstatvfs='$i_sysstatvfs'
13002 i_systime='$i_systime'
13003 i_systimek='$i_systimek'
13004 i_systimes='$i_systimes'
13005 i_systypes='$i_systypes'
13006 i_sysuio='$i_sysuio'
13007 i_sysun='$i_sysun'
13008 i_syswait='$i_syswait'
13009 i_termio='$i_termio'
13010 i_termios='$i_termios'
13011 i_time='$i_time'
13012 i_unistd='$i_unistd'
13013 i_utime='$i_utime'
13014 i_values='$i_values'
13015 i_varargs='$i_varargs'
13016 i_varhdr='$i_varhdr'
13017 i_vfork='$i_vfork'
13018 ignore_versioned_solibs='$ignore_versioned_solibs'
13019 incpath='$incpath'
13020 inews='$inews'
13021 installarchlib='$installarchlib'
13022 installbin='$installbin'
13023 installman1dir='$installman1dir'
13024 installman3dir='$installman3dir'
13025 installprivlib='$installprivlib'
13026 installscript='$installscript'
13027 installsitearch='$installsitearch'
13028 installsitelib='$installsitelib'
13029 installusrbinperl='$installusrbinperl'
13030 intsize='$intsize'
13031 known_extensions='$known_extensions'
13032 ksh='$ksh'
13033 large='$large'
13034 ld='$ld'
13035 lddlflags='$lddlflags'
13036 ldflags='$ldflags'
13037 less='$less'
13038 lib_ext='$lib_ext'
13039 libc='$libc'
13040 libperl='$libperl'
13041 libpth='$libpth'
13042 libs='$libs'
13043 libswanted='$libswanted'
13044 line='$line'
13045 lint='$lint'
13046 lkflags='$lkflags'
13047 ln='$ln'
13048 lns='$lns'
13049 locincpth='$locincpth'
13050 loclibpth='$loclibpth'
13051 longdblsize='$longdblsize'
13052 longlongsize='$longlongsize'
13053 longsize='$longsize'
13054 lp='$lp'
13055 lpr='$lpr'
13056 ls='$ls'
13057 lseeksize='$lseeksize'
13058 lseektype='$lseektype'
13059 mail='$mail'
13060 mailx='$mailx'
13061 make='$make'
13062 make_set_make='$make_set_make'
13063 mallocobj='$mallocobj'
13064 mallocsrc='$mallocsrc'
13065 malloctype='$malloctype'
13066 man1dir='$man1dir'
13067 man1direxp='$man1direxp'
13068 man1ext='$man1ext'
13069 man3dir='$man3dir'
13070 man3direxp='$man3direxp'
13071 man3ext='$man3ext'
13072 medium='$medium'
13073 mips='$mips'
13074 mips_type='$mips_type'
13075 mkdir='$mkdir'
13076 mmaptype='$mmaptype'
13077 models='$models'
13078 modetype='$modetype'
13079 more='$more'
13080 multiarch='$multiarch'
13081 mv='$mv'
13082 myarchname='$myarchname'
13083 mydomain='$mydomain'
13084 myhostname='$myhostname'
13085 myuname='$myuname'
13086 n='$n'
13087 netdb_hlen_type='$netdb_hlen_type'
13088 netdb_host_type='$netdb_host_type'
13089 netdb_name_type='$netdb_name_type'
13090 netdb_net_type='$netdb_net_type'
13091 nm='$nm'
13092 nm_opt='$nm_opt'
13093 nm_so_opt='$nm_so_opt'
13094 nonxs_ext='$nonxs_ext'
13095 nroff='$nroff'
13096 o_nonblock='$o_nonblock'
13097 obj_ext='$obj_ext'
13098 old_pthread_create_joinable='$old_pthread_create_joinable'
13099 optimize='$optimize'
13100 orderlib='$orderlib'
13101 osname='$osname'
13102 osvers='$osvers'
13103 package='$package'
13104 pager='$pager'
13105 passcat='$passcat'
13106 patchlevel='$patchlevel'
13107 path_sep='$path_sep'
13108 perl='$perl'
13109 perladmin='$perladmin'
13110 perlpath='$perlpath'
13111 pg='$pg'
13112 phostname='$phostname'
13113 pidtype='$pidtype'
13114 plibpth='$plibpth'
13115 pmake='$pmake'
13116 pr='$pr'
13117 prefix='$prefix'
13118 prefixexp='$prefixexp'
13119 privlib='$privlib'
13120 privlibexp='$privlibexp'
13121 prototype='$prototype'
13122 ptrsize='$ptrsize'
13123 randbits='$randbits'
13124 randfunc='$randfunc'
13125 randseedtype='$randseedtype'
13126 ranlib='$ranlib'
13127 rd_nodata='$rd_nodata'
13128 rm='$rm'
13129 rmail='$rmail'
13130 runnm='$runnm'
13131 sched_yield='$sched_yield'
13132 scriptdir='$scriptdir'
13133 scriptdirexp='$scriptdirexp'
13134 sed='$sed'
13135 seedfunc='$seedfunc'
13136 selectminbits='$selectminbits'
13137 selecttype='$selecttype'
13138 sendmail='$sendmail'
13139 sh='$sh'
13140 shar='$shar'
13141 sharpbang='$sharpbang'
13142 shmattype='$shmattype'
13143 shortsize='$shortsize'
13144 shrpenv='$shrpenv'
13145 shsharp='$shsharp'
13146 sig_name='$sig_name'
13147 sig_name_init='$sig_name_init'
13148 sig_num='$sig_num'
13149 sig_num_init='$sig_num_init'
13150 signal_t='$signal_t'
13151 sitearch='$sitearch'
13152 sitearchexp='$sitearchexp'
13153 sitelib='$sitelib'
13154 sitelibexp='$sitelibexp'
13155 sizetype='$sizetype'
13156 sleep='$sleep'
13157 smail='$smail'
13158 small='$small'
13159 so='$so'
13160 sockethdr='$sockethdr'
13161 socketlib='$socketlib'
13162 sort='$sort'
13163 spackage='$spackage'
13164 spitshell='$spitshell'
13165 split='$split'
13166 src='$src'
13167 ssizetype='$ssizetype'
13168 startperl='$startperl'
13169 startsh='$startsh'
13170 static_ext='$static_ext'
13171 stdchar='$stdchar'
13172 stdio_base='$stdio_base'
13173 stdio_bufsiz='$stdio_bufsiz'
13174 stdio_cnt='$stdio_cnt'
13175 stdio_filbuf='$stdio_filbuf'
13176 stdio_ptr='$stdio_ptr'
13177 strings='$strings'
13178 submit='$submit'
13179 subversion='$subversion'
13180 sysman='$sysman'
13181 tail='$tail'
13182 tar='$tar'
13183 tbl='$tbl'
13184 tee='$tee'
13185 test='$test'
13186 timeincl='$timeincl'
13187 timetype='$timetype'
13188 touch='$touch'
13189 tr='$tr'
13190 trnl='$trnl'
13191 troff='$troff'
13192 uidtype='$uidtype'
13193 uname='$uname'
13194 uniq='$uniq'
13195 use64bits='$use64bits'
13196 usedl='$usedl'
13197 usemultiplicity='$usemultiplicity'
13198 usemymalloc='$usemymalloc'
13199 usenm='$usenm'
13200 useopcode='$useopcode'
13201 useperlio='$useperlio'
13202 useposix='$useposix'
13203 usesfio='$usesfio'
13204 useshrplib='$useshrplib'
13205 usethreads='$usethreads'
13206 usevfork='$usevfork'
13207 usrinc='$usrinc'
13208 uuname='$uuname'
13209 version='$version'
13210 vi='$vi'
13211 voidflags='$voidflags'
13212 xlibpth='$xlibpth'
13213 zcat='$zcat'
13214 zip='$zip'
13215 EOT
13216
13217 : Add in command line options if available
13218 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13219
13220 : add special variables
13221 $test -f $src/patchlevel.h && \
13222 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13223 echo "CONFIG=true" >>config.sh
13224
13225 : propagate old symbols
13226 if $test -f UU/config.sh; then
13227         <UU/config.sh sort | uniq >UU/oldconfig.sh
13228         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13229         sort | uniq -u >UU/oldsyms
13230         set X `cat UU/oldsyms`
13231         shift
13232         case $# in
13233         0) ;;
13234         *)
13235                 cat <<EOM
13236 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13237 EOM
13238                 echo "# Variables propagated from previous config.sh file." >>config.sh
13239                 for sym in `cat UU/oldsyms`; do
13240                         echo "    Propagating $hint variable "'$'"$sym..."
13241                         eval 'tmp="$'"${sym}"'"'
13242                         echo "$tmp" | \
13243                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13244                 done
13245                 ;;
13246         esac
13247 fi
13248
13249 : Finish up by extracting the .SH files
13250 case "$alldone" in
13251 exit)
13252         $rm -rf UU
13253         echo "Done."
13254         exit 0
13255         ;;
13256 cont)
13257         ;;
13258 '')
13259         dflt=''
13260         nostick=true
13261         $cat <<EOM
13262
13263 If you'd like to make any changes to the config.sh file before I begin
13264 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13265
13266 EOM
13267         rp="Press return or use a shell escape to edit config.sh:"
13268         . UU/myread
13269         nostick=''
13270         case "$ans" in
13271         '') ;;
13272         *) : in case they cannot read
13273                 sh 1>&4 -c "$ans";;
13274         esac
13275         ;;
13276 esac
13277
13278 : if this fails, just run all the .SH files by hand
13279 . ./config.sh
13280
13281 echo " "
13282 exec 1>&4
13283 . ./UU/extract
13284
13285 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13286         dflt=y
13287         case "$silent" in
13288         true) ;;
13289         *)
13290                 $cat <<EOM
13291
13292 Now you need to generate make dependencies by running "$make depend".
13293 You might prefer to run it in background: "$make depend > makedepend.out &"
13294 It can take a while, so you might not want to run it right now.
13295
13296 EOM
13297                 ;;
13298         esac
13299         rp="Run $make depend now?"
13300         . UU/myread
13301         case "$ans" in
13302         y*)
13303                 $make depend && echo "Now you must run a $make."
13304                 ;;
13305         *)
13306                 echo "You must run '$make depend' then '$make'."
13307                 ;;
13308         esac
13309 elif test -f [Mm]akefile; then
13310         echo " "
13311         echo "Now you must run a $make."
13312 else
13313         echo "Done."
13314 fi
13315
13316 if $test -f Policy.sh; then
13317     $cat <<EOM
13318
13319 If you compile $package on a different machine or from a different object
13320 directory, copy the Policy.sh file from this object directory to the
13321 new one before you run Configure -- this will help you with most of
13322 the policy defaults.
13323
13324 EOM
13325 fi
13326 if $test -f config.msg; then
13327     echo "Hmm.  I also noted the following information while running:"
13328     echo " "
13329     $cat config.msg >&4
13330     $rm -f config.msg
13331 fi
13332 $rm -f kit*isdone ark*isdone
13333 $rm -rf UU
13334
13335 : End of Configure
13336