37e4d895ef93eff5e04e0d1fc37657cb1c5cf15e
[p5sagit/p5-mst-13.2.git] / Configure
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc and is available on CPAN under authors/id/RAM so
18 # you may fetch it yourself from your nearest archive site.)
19 #
20
21 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
22 #
23 # Generated on Thu Feb 25 22:44:22 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 rt c cposix posix"
936 libswanted="$libswanted ndir dir crypt"
937 libswanted="$libswanted ucb bsd BSD PW x"
938 : We probably want to search /usr/shlib before most other libraries.
939 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
940 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
941 glibpth="/usr/shlib $glibpth"
942 : Do not use vfork unless overridden by a hint file.
943 usevfork=false
944
945 : Find the basic shell for Bourne shell scripts
946 case "$sh" in
947 '')
948         case "$SYSTYPE" in
949         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
950         *) xxx='/bin/sh';;
951         esac
952         if test -f "$xxx"; then
953                 sh="$xxx"
954         else
955                 : Build up a list and do a single loop so we can 'break' out.
956                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
957                 for xxx in sh bash ksh pdksh ash; do
958                         for p in $pth; do
959                                 try="$try ${p}/${xxx}"
960                         done
961                 done
962                 for xxx in $try; do
963                         if test -f "$xxx"; then
964                                 sh="$xxx";
965                                 break
966                         elif test -f "$xxx.exe"; then
967                                 sh="$xxx";
968                                 break
969                         fi
970                 done
971         fi
972         ;;
973 esac
974
975 case "$sh" in
976 '')     cat <<EOM >&2
977 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
978
979 Usually it's in /bin/sh.  How did you even get this far?
980 Please contact me (Perl Maintainers) at perlbug@perl.com and 
981 we'll try to straighten this all out.
982 EOM
983         exit 1
984         ;;
985 esac
986
987 : see if sh knows # comments
988 if `$sh -c '#' >/dev/null 2>&1`; then
989         shsharp=true
990         spitshell=cat
991         xcat=/bin/cat
992         test -f $xcat || xcat=/usr/bin/cat
993         echo "#!$xcat" >try
994         $eunicefix try
995         chmod +x try
996         ./try > today
997         if test -s today; then
998                 sharpbang='#!'
999         else
1000                 echo "#! $xcat" > try
1001                 $eunicefix try
1002                 chmod +x try
1003                 ./try > today
1004                 if test -s today; then
1005                         sharpbang='#! '
1006                 else
1007                         sharpbang=': use '
1008                 fi
1009         fi
1010 else
1011         echo " "
1012         echo "Your $sh doesn't grok # comments--I will strip them later on."
1013         shsharp=false
1014         cd ..
1015         echo "exec grep -v '^[  ]*#'" >spitshell
1016         chmod +x spitshell
1017         $eunicefix spitshell
1018         spitshell=`pwd`/spitshell
1019         cd UU
1020         echo "I presume that if # doesn't work, #! won't work either!"
1021         sharpbang=': use '
1022 fi
1023 rm -f try today
1024
1025 : figure out how to guarantee sh startup
1026 case "$startsh" in
1027 '') startsh=${sharpbang}${sh} ;;
1028 *)
1029 esac
1030 cat >try <<EOSS
1031 $startsh
1032 set abc
1033 test "$?abc" != 1
1034 EOSS
1035
1036 chmod +x try
1037 $eunicefix try
1038 if ./try; then
1039         : echo "Yup, it does."
1040 else
1041         echo "Hmm... '$startsh' does not guarantee sh startup..."
1042         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1043 fi
1044 rm -f try
1045
1046
1047 : Save command line options in file UU/cmdline.opt for later use in
1048 : generating config.sh.
1049 cat > cmdline.opt <<EOSH
1050 # Configure command line arguments.
1051 config_arg0='$0'
1052 config_args='$*'
1053 config_argc=$#
1054 EOSH
1055 argn=1
1056 for arg in "$@"; do
1057         cat >>cmdline.opt <<EOSH
1058 config_arg$argn='$arg'
1059 EOSH
1060         argn=`expr $argn + 1`
1061 done
1062
1063 : produce awk script to parse command line options
1064 cat >options.awk <<'EOF'
1065 BEGIN {
1066         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1067
1068         len = length(optstr);
1069         for (i = 1; i <= len; i++) {
1070                 c = substr(optstr, i, 1);
1071                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1072                 if (a == ":") {
1073                         arg[c] = 1;
1074                         i++;
1075                 }
1076                 opt[c] = 1;
1077         }
1078 }
1079 {
1080         expect = 0;
1081         str = $0;
1082         if (substr(str, 1, 1) != "-") {
1083                 printf("'%s'\n", str);
1084                 next;
1085         }
1086         len = length($0);
1087         for (i = 2; i <= len; i++) {
1088                 c = substr(str, i, 1);
1089                 if (!opt[c]) {
1090                         printf("-%s\n", substr(str, i));
1091                         next;
1092                 }
1093                 printf("-%s\n", c);
1094                 if (arg[c]) {
1095                         if (i < len)
1096                                 printf("'%s'\n", substr(str, i + 1));
1097                         else
1098                                 expect = 1;
1099                         next;
1100                 }
1101         }
1102 }
1103 END {
1104         if (expect)
1105                 print "?";
1106 }
1107 EOF
1108
1109 : process the command line options
1110 set X `for arg in "$@"; do echo "X$arg"; done |
1111         sed -e s/X// | awk -f options.awk`
1112 eval "set $*"
1113 shift
1114 rm -f options.awk
1115
1116 : set up default values
1117 fastread=''
1118 reuseval=false
1119 config_sh=''
1120 alldone=''
1121 error=''
1122 silent=''
1123 extractsh=''
1124 override=''
1125 knowitall=''
1126 rm -f optdef.sh
1127 cat >optdef.sh <<EOS
1128 $startsh
1129 EOS
1130
1131
1132 : option parsing
1133 while test $# -gt 0; do
1134         case "$1" in
1135         -d) shift; fastread=yes;;
1136         -e) shift; alldone=cont;;
1137         -f)
1138                 shift
1139                 cd ..
1140                 if test -r "$1"; then
1141                         config_sh="$1"
1142                 else
1143                         echo "$me: cannot read config file $1." >&2
1144                         error=true
1145                 fi
1146                 cd UU
1147                 shift;;
1148         -h) shift; error=true;;
1149         -r) shift; reuseval=true;;
1150         -s) shift; silent=true; realsilent=true;;
1151         -E) shift; alldone=exit;;
1152         -K) shift; knowitall=true;;
1153         -O) shift; override=true;;
1154         -S) shift; silent=true; extractsh=true;;
1155         -D)
1156                 shift
1157                 case "$1" in
1158                 *=)
1159                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1160                         echo "$me: ignoring -D $1" >&2
1161                         ;;
1162                 *=*) echo "$1" | \
1163                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1164                 *) echo "$1='define'" >> optdef.sh;;
1165                 esac
1166                 shift
1167                 ;;
1168         -U)
1169                 shift
1170                 case "$1" in
1171                 *=) echo "$1" >> optdef.sh;;
1172                 *=*)
1173                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1174                         echo "$me: ignoring -U $1" >&2
1175                         ;;
1176                 *) echo "$1='undef'" >> optdef.sh;;
1177                 esac
1178                 shift
1179                 ;;
1180         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1181                 exit 0;;
1182         --) break;;
1183         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1184         *) break;;
1185         esac
1186 done
1187
1188 case "$error" in
1189 true)
1190         cat >&2 <<EOM
1191 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1192                  [-U symbol] [-U symbol=]
1193   -d : use defaults for all answers.
1194   -e : go on without questioning past the production of config.sh.
1195   -f : specify an alternate default configuration file.
1196   -h : print this help message and exit (with an error status).
1197   -r : reuse C symbols value if possible (skips costly nm extraction).
1198   -s : silent mode, only echoes questions and essential information.
1199   -D : define symbol to have some value:
1200          -D symbol         symbol gets the value 'define'
1201          -D symbol=value   symbol gets the value 'value'
1202   -E : stop at the end of questions, after having produced config.sh.
1203   -K : do not use unless you know what you are doing.
1204   -O : let -D and -U override definitions from loaded configuration file.
1205   -S : perform variable substitutions on all .SH files (can mix with -f)
1206   -U : undefine symbol:
1207          -U symbol    symbol gets the value 'undef'
1208          -U symbol=   symbol gets completely empty
1209   -V : print version number and exit (with a zero status).
1210 EOM
1211         exit 1
1212         ;;
1213 esac
1214
1215 : Sanity checks
1216 case "$fastread$alldone" in
1217 yescont|yesexit) ;;
1218 *)
1219         if test ! -t 0; then
1220                 echo "Say 'sh Configure', not 'sh <Configure'"
1221                 exit 1
1222         fi
1223         ;;
1224 esac
1225
1226 exec 4>&1
1227 case "$silent" in
1228 true) exec 1>/dev/null;;
1229 esac
1230
1231 : run the defines and the undefines, if any, but leave the file out there...
1232 touch optdef.sh
1233 . ./optdef.sh
1234
1235 : set package name
1236 package=perl5
1237 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1238 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1239 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1240 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1241 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1242 esac
1243
1244 : Some greps do not return status, grrr.
1245 echo "grimblepritz" >grimble
1246 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1247         contains=contains
1248 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1249         contains=grep
1250 else
1251         contains=contains
1252 fi
1253 rm -f grimble
1254 : the following should work in any shell
1255 case "$contains" in
1256 contains*)
1257         echo " "
1258         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1259         cat >contains <<'EOSS'
1260 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1261 EOSS
1262 chmod +x contains
1263 esac
1264
1265 : Find the path to the source tree
1266 case "$src" in
1267 '') case "$0" in
1268     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1269     *)   src='.';;
1270     esac;;
1271 esac
1272 case "$src" in
1273 '')     src=/
1274         rsrc=/
1275         ;;
1276 /*) rsrc="$src";;
1277 *) rsrc="../$src";;
1278 esac
1279 if test -f $rsrc/Configure && \
1280         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1281 then
1282    : found it, so we are ok.
1283 else
1284         rsrc=''
1285         for src in . .. ../.. ../../.. ../../../..; do
1286                 if test -f ../$src/Configure && \
1287                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1288                 then
1289                         rsrc=../$src
1290                         break
1291                 fi
1292         done
1293 fi
1294 case "$rsrc" in
1295 '')
1296         cat <<EOM >&4
1297
1298 Sorry, I can't seem to locate the source dir for $package.  Please start
1299 Configure with an explicit path -- i.e. /some/path/Configure.
1300
1301 EOM
1302         exit 1
1303         ;;
1304 ../.)   rsrc='..';;
1305 *)
1306         echo " "
1307         echo "Sources for $package found in \"$src\"." >&4
1308         ;;
1309 esac
1310
1311 : script used to extract .SH files with variable substitutions
1312 cat >extract <<'EOS'
1313 CONFIG=true
1314 echo "Doing variable substitutions on .SH files..."
1315 if test -f $src/MANIFEST; then
1316         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1317 else
1318         echo "(Looking for .SH files under the source directory.)"
1319         set x `(cd $src; find . -name "*.SH" -print)`
1320 fi
1321 shift
1322 case $# in
1323 0) set x `(cd $src; echo *.SH)`; shift;;
1324 esac
1325 if test ! -f $src/$1; then
1326         shift
1327 fi
1328 mkdir_p='
1329 name=$1;
1330 create="";
1331 while test $name; do
1332         if test ! -d "$name"; then
1333                 create="$name $create";
1334                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1335                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1336         else
1337                 name="";
1338         fi;
1339 done;
1340 for file in $create; do
1341         mkdir $file;
1342 done
1343 '
1344 for file in $*; do
1345         case "$src" in
1346         ".")
1347                 case "$file" in
1348                 */*)
1349                         dir=`expr X$file : 'X\(.*\)/'`
1350                         file=`expr X$file : 'X.*/\(.*\)'`
1351                         (cd $dir && . ./$file)
1352                         ;;
1353                 *)
1354                         . ./$file
1355                         ;;
1356                 esac
1357                 ;;
1358         *)
1359                 case "$file" in
1360                 */*)
1361                         dir=`expr X$file : 'X\(.*\)/'`
1362                         file=`expr X$file : 'X.*/\(.*\)'`
1363                         (set x $dir; shift; eval $mkdir_p)
1364                         sh <$src/$dir/$file
1365                         ;;
1366                 *)
1367                         sh <$src/$file
1368                         ;;
1369                 esac
1370                 ;;
1371         esac
1372 done
1373 if test -f $src/config_h.SH; then
1374         if test ! -f config.h; then
1375         : oops, they left it out of MANIFEST, probably, so do it anyway.
1376         . $src/config_h.SH
1377         fi
1378 fi
1379 EOS
1380
1381 : extract files and exit if asked to do so
1382 case "$extractsh" in
1383 true)
1384         case "$realsilent" in
1385         true) ;;
1386         *) exec 1>&4;;
1387         esac
1388         case "$config_sh" in
1389         '') config_sh='config.sh';;
1390         esac
1391         echo " "
1392         echo "Fetching answers from $config_sh..."
1393         cd ..
1394         . $config_sh
1395         test "$override" && . ./optdef.sh
1396         echo " "
1397         . UU/extract
1398         rm -rf UU
1399         echo "Done."
1400         exit 0
1401         ;;
1402 esac
1403
1404 : Eunice requires " " instead of "", can you believe it
1405 echo " "
1406 : Here we go...
1407 echo "Beginning of configuration questions for $package."
1408
1409 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1410
1411 : first determine how to suppress newline on echo command
1412 echo " "
1413 echo "Checking echo to see how to suppress newlines..."
1414 (echo "hi there\c" ; echo " ") >.echotmp
1415 if $contains c .echotmp >/dev/null 2>&1 ; then
1416         echo "...using -n."
1417         n='-n'
1418         c=''
1419 else
1420         cat <<'EOM'
1421 ...using \c
1422 EOM
1423         n=''
1424         c='\c'
1425 fi
1426 echo $n "The star should be here-->$c"
1427 echo '*'
1428 rm -f .echotmp
1429
1430 : Now test for existence of everything in MANIFEST
1431 echo " "
1432 if test -f $rsrc/MANIFEST; then
1433         echo "First let's make sure your kit is complete.  Checking..." >&4
1434         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1435         rm -f missing
1436         tmppwd=`pwd`
1437         for filelist in x??; do
1438                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1439         done
1440         if test -s missing; then
1441                 cat missing >&4
1442                 cat >&4 <<'EOM'
1443
1444 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1445
1446 You have the option of continuing the configuration process, despite the
1447 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1448 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1449 and contact the author (perlbug@perl.com).
1450
1451 EOM
1452                 echo $n "Continue? [n] $c" >&4
1453                 read ans
1454                 case "$ans" in
1455                 y*)
1456                         echo "Continuing..." >&4
1457                         rm -f missing
1458                         ;;
1459                 *)
1460                         echo "ABORTING..." >&4
1461                         kill $$
1462                         ;;
1463                 esac
1464         else
1465                 echo "Looks good..."
1466         fi
1467 else
1468         echo "There is no MANIFEST file.  I hope your kit is complete !"
1469 fi
1470 rm -f missing x??
1471
1472 echo " "
1473 : Find the appropriate value for a newline for tr
1474 if test -n "$DJGPP"; then
1475        trnl='\012'
1476 fi
1477 if test X"$trnl" = X; then
1478         case "`echo foo|tr '\n' x 2>/dev/null`" in
1479         foox) trnl='\n' ;;
1480         esac
1481 fi
1482 if test X"$trnl" = X; then
1483         case "`echo foo|tr '\012' x 2>/dev/null`" in
1484         foox) trnl='\012' ;;
1485         esac
1486 fi
1487 if test X"$trnl" = X; then
1488         cat <<EOM >&2
1489
1490 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1491
1492 EOM
1493         exit 1
1494 fi
1495
1496 : compute the number of columns on the terminal for proper question formatting
1497 case "$COLUMNS" in
1498 '') COLUMNS='80';;
1499 esac
1500
1501 : set up the echo used in my read
1502 myecho="case \"\$xxxm\" in
1503 '') echo $n \"\$rp $c\" >&4;;
1504 *) case \"\$rp\" in
1505         '') echo $n \"[\$xxxm] $c\";;
1506         *)
1507                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1508                         echo \"\$rp\" >&4
1509                         echo $n \"[\$xxxm] $c\" >&4
1510                 else
1511                         echo $n \"\$rp [\$xxxm] $c\" >&4
1512                 fi
1513                 ;;
1514         esac;;
1515 esac"
1516
1517 : now set up to do reads with possible shell escape and default assignment
1518 cat <<EOSC >myread
1519 $startsh
1520 xxxm=\$dflt
1521 $myecho
1522 ans='!'
1523 case "\$fastread" in
1524 yes) case "\$dflt" in
1525         '') ;;
1526         *) ans='';
1527                 case "\$silent-\$rp" in
1528                 true-) ;;
1529                 *) echo " " >&4;;
1530                 esac;;
1531         esac;;
1532 *) case "\$silent" in
1533         true) case "\$rp" in
1534                 '') ans='';;
1535                 esac;;
1536         esac;;
1537 esac
1538 while expr "X\$ans" : "X!" >/dev/null; do
1539         read answ
1540         set x \$xxxm
1541         shift
1542         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1543         case  "\$answ" in
1544         "!")
1545                 sh 1>&4
1546                 echo " "
1547                 $myecho
1548                 ;;
1549         !*)
1550                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1551                 shift
1552                 sh 1>&4 -c "\$*"
1553                 echo " "
1554                 $myecho
1555                 ;;
1556         "\$ans")
1557                 case "\$ans" in
1558                 \\&*)
1559                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1560                         shift
1561                         case "\$1" in
1562                         -d)
1563                                 fastread=yes
1564                                 echo "(OK, I'll run with -d after this question.)" >&4
1565                                 ;;
1566                         -*)
1567                                 echo "*** Sorry, \$1 not supported yet." >&4
1568                                 ;;
1569                         esac
1570                         $myecho
1571                         ans=!
1572                         ;;
1573                 esac;;
1574         *)
1575                 case "\$aok" in
1576                 y)
1577                         echo "*** Substitution done -- please confirm."
1578                         xxxm="\$ans"
1579                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1580                         xxxm="\$ans"
1581                         ans=!
1582                         ;;
1583                 *)
1584                         echo "*** Error -- try again."
1585                         ans=!
1586                         ;;
1587                 esac
1588                 $myecho
1589                 ;;
1590         esac
1591         case "\$ans\$xxxm\$nostick" in
1592         '')
1593                 ans=!
1594                 $myecho
1595                 ;;
1596         esac
1597 done
1598 case "\$ans" in
1599 '') ans="\$xxxm";;
1600 esac
1601 EOSC
1602
1603 : create .config dir to save info across Configure sessions
1604 test -d ../.config || mkdir ../.config
1605 cat >../.config/README <<EOF
1606 This directory created by Configure to save information that should
1607 persist across sessions for $package.
1608
1609 You may safely delete it if you wish.
1610 EOF
1611
1612 : general instructions
1613 needman=true
1614 firsttime=true
1615 user=`(logname) 2>/dev/null`
1616 case "$user" in
1617 '') user=`whoami 2>&1`;;
1618 esac
1619 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1620         firsttime=false
1621         echo " "
1622         rp='Would you like to see the instructions?'
1623         dflt=n
1624         . ./myread
1625         case "$ans" in
1626         [yY]*) ;;
1627         *) needman=false;;
1628         esac
1629 fi
1630 if $needman; then
1631         cat <<EOH
1632
1633 This installation shell script will examine your system and ask you questions
1634 to determine how the perl5 package should be installed. If you get
1635 stuck on a question, you may use a ! shell escape to start a subshell or
1636 execute a command.  Many of the questions will have default answers in square
1637 brackets; typing carriage return will give you the default.
1638
1639 On some of the questions which ask for file or directory names you are allowed
1640 to use the ~name construct to specify the login directory belonging to "name",
1641 even if you don't have a shell which knows about that.  Questions where this is
1642 allowed will be marked "(~name ok)".
1643
1644 EOH
1645         rp=''
1646         dflt='Type carriage return to continue'
1647         . ./myread
1648         cat <<'EOH'
1649
1650 The prompter used in this script allows you to use shell variables and
1651 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1652 in the default answer, as if the default line was a set of arguments given to a
1653 script shell.  This means you may also use $* to repeat the whole default line,
1654 so you do not have to re-type everything to add something to the default.
1655
1656 Everytime there is a substitution, you will have to confirm.  If there is an
1657 error (e.g. an unmatched backtick), the default answer will remain unchanged
1658 and you will be prompted again.
1659
1660 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1661 the questions and use the computed defaults (or the previous answers if there
1662 was already a config.sh file). Type 'Configure -h' for a list of options.
1663 You may also start interactively and then answer '& -d' at any prompt to turn
1664 on the non-interactive behaviour for the remainder of the execution.
1665
1666 EOH
1667         . ./myread
1668         cat <<EOH
1669
1670 Much effort has been expended to ensure that this shell script will run on any
1671 Unix system.  If despite that it blows up on yours, your best bet is to edit
1672 Configure and run it again.  If you can't run Configure for some reason,
1673 you'll have to generate a config.sh file by hand.  Whatever problems you
1674 have, let me (perlbug@perl.com) know how I blew it.
1675
1676 This installation script affects things in two ways:
1677
1678 1) it may do direct variable substitutions on some of the files included
1679    in this kit.
1680 2) it builds a config.h file for inclusion in C programs.  You may edit
1681    any of these files as the need arises after running this script.
1682
1683 If you make a mistake on a question, there is no easy way to back up to it
1684 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1685 files.  Configure will offer to let you do this before it runs the SH files.
1686
1687 EOH
1688         dflt='Type carriage return to continue'
1689         . ./myread
1690         case "$firsttime" in
1691         true) echo $user >>../.config/instruct;;
1692         esac
1693 fi
1694
1695 : find out where common programs are
1696 echo " "
1697 echo "Locating common programs..." >&4
1698 cat <<EOSC >loc
1699 $startsh
1700 case \$# in
1701 0) exit 1;;
1702 esac
1703 thing=\$1
1704 shift
1705 dflt=\$1
1706 shift
1707 for dir in \$*; do
1708         case "\$thing" in
1709         .)
1710         if test -d \$dir/\$thing; then
1711                 echo \$dir
1712                 exit 0
1713         fi
1714         ;;
1715         *)
1716         for thisthing in \$dir/\$thing; do
1717                 : just loop through to pick last item
1718         done
1719         if test -f \$thisthing; then
1720                 echo \$thisthing
1721                 exit 0
1722         elif test -f \$dir/\$thing.exe; then
1723                 if test -n "$DJGPP"; then
1724                         echo \$dir/\$thing.exe
1725                 else
1726                         : on Eunice apparently
1727                         echo \$dir/\$thing
1728                 fi
1729                 exit 0
1730         fi
1731         ;;
1732         esac
1733 done
1734 echo \$dflt
1735 exit 1
1736 EOSC
1737 chmod +x loc
1738 $eunicefix loc
1739 loclist="
1740 awk
1741 cat
1742 comm
1743 cp
1744 echo
1745 expr
1746 grep
1747 ls
1748 make
1749 mkdir
1750 rm
1751 sed
1752 sort
1753 touch
1754 tr
1755 uniq
1756 "
1757 trylist="
1758 Mcc
1759 ar
1760 byacc
1761 cpp
1762 csh
1763 date
1764 egrep
1765 gzip
1766 less
1767 ln
1768 more
1769 nm
1770 nroff
1771 pg
1772 tee
1773 test
1774 uname
1775 zip
1776 "
1777 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1778 pth="$pth /lib /usr/lib"
1779 for file in $loclist; do
1780         eval xxx=\$$file
1781         case "$xxx" in
1782         /*|?:[\\/]*)
1783                 if test -f "$xxx"; then
1784                         : ok
1785                 else
1786                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1787                         xxx=`./loc $file $file $pth`
1788                 fi
1789                 ;;
1790         '') xxx=`./loc $file $file $pth`;;
1791         *) xxx=`./loc $xxx $xxx $pth`;;
1792         esac
1793         eval $file=$xxx
1794         eval _$file=$xxx
1795         case "$xxx" in
1796         /*)
1797                 echo $file is in $xxx.
1798                 ;;
1799         ?:[\\/]*)
1800                 echo $file is in $xxx.
1801                 ;;
1802         *)
1803                 echo "I don't know where '$file' is, and my life depends on it." >&4
1804                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1805                 exit 1
1806                 ;;
1807         esac
1808 done
1809 echo " "
1810 echo "Don't worry if any of the following aren't found..."
1811 say=offhand
1812 for file in $trylist; do
1813         eval xxx=\$$file
1814         case "$xxx" in
1815         /*|?:[\\/]*)
1816                 if test -f "$xxx"; then
1817                         : ok
1818                 else
1819                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1820                         xxx=`./loc $file $file $pth`
1821                 fi
1822                 ;;
1823         '') xxx=`./loc $file $file $pth`;;
1824         *) xxx=`./loc $xxx $xxx $pth`;;
1825         esac
1826         eval $file=$xxx
1827         eval _$file=$xxx
1828         case "$xxx" in
1829         /*)
1830                 echo $file is in $xxx.
1831                 ;;
1832         ?:[\\/]*)
1833                 echo $file is in $xxx.
1834                 ;;
1835         *)
1836                 echo "I don't see $file out there, $say."
1837                 say=either
1838                 ;;
1839         esac
1840 done
1841 case "$egrep" in
1842 egrep)
1843         echo "Substituting grep for egrep."
1844         egrep=$grep
1845         ;;
1846 esac
1847 case "$ln" in
1848 ln)
1849         echo "Substituting cp for ln."
1850         ln=$cp
1851         ;;
1852 esac
1853 case "$test" in
1854 test)
1855         echo "Hopefully test is built into your sh."
1856         ;;
1857 *)
1858         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1859                 echo "Using the test built into your sh."
1860                 test=test
1861                 _test=test
1862         fi
1863         ;;
1864 esac
1865 case "$echo" in
1866 echo)
1867         echo "Hopefully echo is built into your sh."
1868         ;;
1869 '') ;;
1870 *)
1871         echo " "
1872 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1873         $echo $n "hi there$c" >foo1
1874         echo $n "hi there$c" >foo2
1875         if cmp foo1 foo2 >/dev/null 2>&1; then
1876                 echo "They are compatible.  In fact, they may be identical."
1877         else
1878                 case "$n" in
1879                 '-n') n='' c='\c';;
1880                 *) n='-n' c='';;
1881                 esac
1882                 cat <<FOO
1883 They are not compatible!  You are probably running ksh on a non-USG system.
1884 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1885 have echo built in and we may have to run some Bourne shell scripts.  That
1886 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1887
1888 FOO
1889                 $echo $n "The star should be here-->$c"
1890                 $echo "*"
1891         fi
1892         $rm -f foo1 foo2
1893         ;;
1894 esac
1895
1896 : determine whether symbolic links are supported
1897 echo " "
1898 $touch blurfl
1899 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1900         echo "Symbolic links are supported." >&4
1901         lns="$ln -s"
1902 else
1903         echo "Symbolic links are NOT supported." >&4
1904         lns="$ln"
1905 fi
1906 $rm -f blurfl sym
1907
1908 : see whether [:lower:] and [:upper:] are supported character classes
1909 echo " "
1910 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1911 ABYZ)
1912         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1913         up='[:upper:]'
1914         low='[:lower:]'
1915         ;;
1916 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1917         # (0xc9 and 0xd1), therefore that is a nice testing point.
1918         if test "X$up" = X -o "X$low" = X; then
1919             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1920             ij) up='[A-Z]'
1921                 low='[a-z]'
1922                 ;;
1923             esac
1924         fi
1925         if test "X$up" = X -o "X$low" = X; then
1926             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1927             ij) up='A-Z'
1928                 low='a-z'
1929                 ;;
1930             esac
1931         fi
1932         if test "X$up" = X -o "X$low" = X; then
1933             case "`echo IJ | od -x 2>/dev/null`" in
1934             *C9D1*|*c9d1*)
1935                 echo "Hey, this might be EBCDIC." >&4
1936                 if test "X$up" = X -o "X$low" = X; then
1937                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1938                     ij) up='[A-IJ-RS-Z]'
1939                         low='[a-ij-rs-z]'
1940                         ;;
1941                     esac
1942                 fi
1943                 if test "X$up" = X -o "X$low" = X; then
1944                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1945                     ij) up='A-IJ-RS-Z'
1946                         low='a-ij-rs-z'
1947                         ;;
1948                     esac
1949                 fi
1950                 ;;
1951             esac
1952         fi
1953 esac
1954 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1955 ij)
1956     echo "Using $up and $low to convert case." >&4
1957     ;;
1958 *)
1959     echo "I don't know how to translate letters from upper to lower case." >&4
1960     echo "Your tr is not acting any way I know of." >&4
1961     exit 1
1962     ;;
1963 esac
1964 : set up the translation script tr, must be called with ./tr of course
1965 cat >tr <<EOSC
1966 $startsh
1967 case "\$1\$2" in
1968 '[A-Z][a-z]') exec $tr '$up' '$low';;
1969 '[a-z][A-Z]') exec $tr '$low' '$up';;
1970 esac
1971 exec $tr "\$@"
1972 EOSC
1973 chmod +x tr
1974 $eunicefix tr
1975
1976 : Try to determine whether config.sh was made on this system
1977 case "$config_sh" in
1978 '')
1979 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1980 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
1981 # because the A-Z/a-z are not consecutive.
1982 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
1983         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
1984 newmyuname="$myuname"
1985 dflt=n
1986 case "$knowitall" in
1987 '')
1988         if test -f ../config.sh; then
1989                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
1990                         eval "`grep myuname= ../config.sh`"
1991                 fi
1992                 if test "X$myuname" = "X$newmyuname"; then
1993                         dflt=y
1994                 fi
1995         fi
1996         ;;
1997 *) dflt=y;;
1998 esac
1999
2000 : Get old answers from old config file if Configure was run on the
2001 : same system, otherwise use the hints.
2002 hint=default
2003 cd ..
2004 if test -f config.sh; then
2005         echo " "
2006         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2007         . UU/myread
2008         case "$ans" in
2009         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2010         *)  echo "Fetching default answers from your old config.sh file..." >&4
2011                 tmp_n="$n"
2012                 tmp_c="$c"
2013                 tmp_sh="$sh"
2014                 . ./config.sh
2015                 cp config.sh UU
2016                 n="$tmp_n"
2017                 c="$tmp_c"
2018                 : Older versions did not always set $sh.  Catch re-use of such
2019                 : an old config.sh.
2020                 case "$sh" in
2021                 '') sh="$tmp_sh" ;;
2022                 esac
2023                 hint=previous
2024                 ;;
2025         esac
2026 fi
2027 if test ! -f config.sh; then
2028         $cat <<EOM
2029
2030 First time through, eh?  I have some defaults handy for some systems
2031 that need some extra help getting the Configure answers right:
2032
2033 EOM
2034         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2035         dflt=''
2036         : Half the following guesses are probably wrong... If you have better
2037         : tests or hints, please send them to perlbug@perl.com
2038         : The metaconfig authors would also appreciate a copy...
2039         $test -f /irix && osname=irix
2040         $test -f /xenix && osname=sco_xenix
2041         $test -f /dynix && osname=dynix
2042         $test -f /dnix && osname=dnix
2043         $test -f /lynx.os && osname=lynxos
2044         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2045         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2046         $test -f /bin/mips && /bin/mips && osname=mips
2047         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2048                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2049         $test -d /usr/apollo/bin && osname=apollo
2050         $test -f /etc/saf/_sactab && osname=svr4
2051         $test -d /usr/include/minix && osname=minix
2052         if $test -d /MachTen -o -d /MachTen_Folder; then
2053                 osname=machten
2054                 if $test -x /sbin/version; then
2055                         osvers=`/sbin/version | $awk '{print $2}' |
2056                         $sed -e 's/[A-Za-z]$//'`
2057                 elif $test -x /usr/etc/version; then
2058                         osvers=`/usr/etc/version | $awk '{print $2}' |
2059                         $sed -e 's/[A-Za-z]$//'`
2060                 else
2061                         osvers="$2.$3"
2062                 fi
2063         fi
2064        $test -f /sys/posix.dll &&
2065                $test -f /usr/bin/what &&
2066                set X `/usr/bin/what /sys/posix.dll` &&
2067                $test "$3" = UWIN &&
2068                osname=uwin &&
2069                osvers="$5"
2070         if $test -f $uname; then
2071                 set X $myuname
2072                 shift
2073
2074                 case "$5" in
2075                 fps*) osname=fps ;;
2076                 mips*)
2077                         case "$4" in
2078                         umips) osname=umips ;;
2079                         *) osname=mips ;;
2080                         esac;;
2081                 [23]100) osname=mips ;;
2082                 next*) osname=next ;;
2083                 i386*)
2084                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2085                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2086                                 osname='sco'
2087                                 osvers=$tmp
2088                         elif $test -f /etc/kconfig; then
2089                                 osname=isc
2090                                 if test "$lns" = "ln -s"; then
2091                                         osvers=4
2092                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2093                                         osvers=3
2094                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2095                                         osvers=2
2096                                 fi
2097                         fi
2098                         unset tmp
2099                         ;;
2100                 pc*)
2101                         if test -n "$DJGPP"; then
2102                                 osname=dos
2103                                 osvers=djgpp
2104                         fi
2105                         ;;
2106                 esac
2107
2108                 case "$1" in
2109                 aix) osname=aix
2110                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2111                         case "$tmp" in
2112                         'not found') osvers="$4"."$3" ;;
2113                         '<3240'|'<>3240') osvers=3.2.0 ;;
2114                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2115                         '=3250'|'>3250') osvers=3.2.5 ;;
2116                         *) osvers=$tmp;;
2117                         esac
2118                         ;;
2119                 *dc.osx) osname=dcosx
2120                         osvers="$3"
2121                         ;;
2122                 dnix) osname=dnix
2123                         osvers="$3"
2124                         ;;
2125                 domainos) osname=apollo
2126                         osvers="$3"
2127                         ;;
2128                 dgux) osname=dgux 
2129                         osvers="$3"
2130                         ;;
2131                 dynixptx*) osname=dynixptx
2132                         osvers=`echo "$4"|sed 's/^v//'`
2133                         ;;
2134                 freebsd) osname=freebsd 
2135                         osvers="$3" ;;
2136                 genix) osname=genix ;;
2137                 hp*) osname=hpux 
2138                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2139                         ;;
2140                 irix*) osname=irix
2141                         case "$3" in
2142                         4*) osvers=4 ;;
2143                         5*) osvers=5 ;;
2144                         *)      osvers="$3" ;;
2145                         esac
2146                         ;;
2147                 linux) osname=linux
2148                         case "$3" in
2149                         *)      osvers="$3" ;;
2150                         esac
2151                         ;;
2152                 MiNT) osname=mint
2153                         ;;
2154                 netbsd*) osname=netbsd
2155                         osvers="$3"
2156                         ;;
2157                 news-os) osvers="$3"
2158                         case "$3" in
2159                         4*) osname=newsos4 ;;
2160                         *) osname=newsos ;;
2161                         esac
2162                         ;;
2163                 bsd386) osname=bsd386
2164                         osvers=`$uname -r`
2165                         ;;
2166                 POSIX-BC | posix-bc ) osname=posix-bc
2167                         osvers="$3"
2168                         ;;
2169                 powerux | power_ux | powermax_os | powermaxos | \
2170                 powerunix | power_unix) osname=powerux
2171                         osvers="$3"
2172                         ;;
2173                 next*) osname=next ;;
2174                 solaris) osname=solaris
2175                         case "$3" in
2176                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2177                         *)      osvers="$3" ;;
2178                         esac
2179                         ;;
2180                 sunos) osname=sunos
2181                         case "$3" in
2182                         5*) osname=solaris
2183                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2184                         *)      osvers="$3" ;;
2185                         esac
2186                         ;;
2187                 titanos) osname=titanos
2188                         case "$3" in
2189                         1*) osvers=1 ;;
2190                         2*) osvers=2 ;;
2191                         3*) osvers=3 ;;
2192                         4*) osvers=4 ;;
2193                         *)      osvers="$3" ;;
2194                         esac
2195                         ;;
2196                 ultrix) osname=ultrix
2197                         osvers="$3"
2198                         ;;
2199                 osf1|mls+)      case "$5" in
2200                                 alpha)
2201                                         osname=dec_osf
2202                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2203                                         ;;
2204                         hp*)    osname=hp_osf1  ;;
2205                         mips)   osname=mips_osf1 ;;
2206                         esac
2207                         ;;
2208                 uts) osname=uts 
2209                         osvers="$3"
2210                         ;;
2211                 qnx) osname=qnx
2212                         osvers="$4"
2213                         ;;
2214                 $2) case "$osname" in
2215                         *isc*) ;;
2216                         *freebsd*) ;;
2217                         svr*)
2218                                 : svr4.x or possibly later
2219                                 case "svr$3" in 
2220                                 ${osname}*)
2221                                         osname=svr$3
2222                                         osvers=$4
2223                                         ;;
2224                                 esac
2225                                 case "$osname" in
2226                                 svr4.0)
2227                                         : Check for ESIX
2228                                         if test -f /stand/boot ; then
2229                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2230                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2231                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2232                                                         if test -n "$isesix"; then
2233                                                                 osname=esix4
2234                                                         fi
2235                                                 fi
2236                                         fi
2237                                         ;;
2238                                 esac
2239                                 ;;
2240                         *)      if test -f /etc/systemid; then
2241                                         osname=sco
2242                                         set `echo $3 | $sed 's/\./ /g'` $4
2243                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2244                                                 osvers=$1.$2.$3
2245                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2246                                                 osvers=$1.$2
2247                                         elif $test -f $src/hints/sco_$1.sh; then
2248                                                 osvers=$1
2249                                         fi
2250                                 else
2251                                         case "$osname" in
2252                                         '') : Still unknown.  Probably a generic Sys V.
2253                                                 osname="sysv"
2254                                                 osvers="$3"
2255                                                 ;;
2256                                         esac
2257                                 fi
2258                                 ;;
2259                         esac
2260                         ;;
2261                 *)      case "$osname" in
2262                         '') : Still unknown.  Probably a generic BSD.
2263                                 osname="$1"
2264                                 osvers="$3"
2265                                 ;;
2266                         esac
2267                         ;;
2268                 esac
2269         else
2270                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2271                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2272                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2273                                 osname=news_os
2274                         fi
2275                         $rm -f UU/kernel.what
2276                 elif test -d c:/.; then
2277                         set X $myuname
2278                         osname=os2
2279                         osvers="$5"
2280                 fi
2281         fi
2282         
2283         : Now look for a hint file osname_osvers, unless one has been
2284         : specified already.
2285         case "$hintfile" in
2286         ''|' ')
2287                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2288                 : Also try without trailing minor version numbers.
2289                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2290                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2291                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2292                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2293                 case "$file" in
2294                 '') dflt=none ;;
2295                 *)  case "$osvers" in
2296                         '') dflt=$file
2297                                 ;;
2298                         *)  if $test -f $src/hints/$file.sh ; then
2299                                         dflt=$file
2300                                 elif $test -f $src/hints/$xfile.sh ; then
2301                                         dflt=$xfile
2302                                 elif $test -f $src/hints/$xxfile.sh ; then
2303                                         dflt=$xxfile
2304                                 elif $test -f $src/hints/$xxxfile.sh ; then
2305                                         dflt=$xxxfile
2306                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2307                                         dflt=$xxxxfile
2308                                 elif $test -f "$src/hints/${osname}.sh" ; then
2309                                         dflt="${osname}"
2310                                 else
2311                                         dflt=none
2312                                 fi
2313                                 ;;
2314                         esac
2315                         ;;
2316                 esac
2317                 if $test -f Policy.sh ; then
2318                         case "$dflt" in
2319                         *Policy*) ;;
2320                         none) dflt="Policy" ;;
2321                         *) dflt="Policy $dflt" ;;
2322                         esac
2323                 fi
2324                 ;;
2325         *)
2326                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2327                 ;;
2328         esac
2329
2330         if $test -f Policy.sh ; then
2331                 $cat <<EOM
2332
2333 There's also a Policy hint file available, which should make the
2334 site-specific (policy) questions easier to answer.
2335 EOM
2336
2337         fi
2338
2339         $cat <<EOM
2340
2341 You may give one or more space-separated answers, or "none" if appropriate.
2342 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2343 is a good thing.  DO NOT give a wrong version.
2344
2345 EOM
2346
2347         rp="Which of these apply, if any?"
2348         . UU/myread
2349         tans=$ans
2350         for file in $tans; do
2351                 if $test X$file = XPolicy -a -f Policy.sh; then
2352                         . Policy.sh
2353                         $cat Policy.sh >> UU/config.sh
2354                 elif $test -f $src/hints/$file.sh; then
2355                         . $src/hints/$file.sh
2356                         $cat $src/hints/$file.sh >> UU/config.sh
2357                 elif $test X$tans = X -o X$tans = Xnone ; then
2358                         : nothing
2359                 else
2360                         : Give one chance to correct a possible typo.
2361                         echo "$file.sh does not exist"
2362                         dflt=$file
2363                         rp="hint to use instead?"
2364                         . UU/myread
2365                         for file in $ans; do
2366                                 if $test -f "$src/hints/$file.sh"; then
2367                                         . $src/hints/$file.sh
2368                                         $cat $src/hints/$file.sh >> UU/config.sh
2369                                 elif $test X$ans = X -o X$ans = Xnone ; then
2370                                         : nothing
2371                                 else
2372                                         echo "$file.sh does not exist -- ignored."
2373                                 fi
2374                         done
2375                 fi
2376         done
2377
2378         hint=recommended
2379         : Remember our hint file for later.
2380         if $test -f "$src/hints/$file.sh" ; then
2381                 hintfile="$file"
2382         else
2383                 hintfile=''
2384         fi
2385 fi
2386 cd UU
2387 ;;
2388 *)
2389         echo " "
2390         echo "Fetching default answers from $config_sh..." >&4
2391         tmp_n="$n"
2392         tmp_c="$c"
2393         cd ..
2394         cp $config_sh config.sh 2>/dev/null
2395         chmod +w config.sh
2396         . ./config.sh
2397         cd UU
2398         cp ../config.sh .
2399         n="$tmp_n"
2400         c="$tmp_c"
2401         hint=previous
2402         ;;
2403 esac
2404 test "$override" && . ./optdef.sh
2405 myuname="$newmyuname"
2406
2407 : Restore computed paths
2408 for file in $loclist $trylist; do
2409         eval $file="\$_$file"
2410 done
2411
2412 cat << EOM
2413
2414 Configure uses the operating system name and version to set some defaults.
2415 The default value is probably right if the name rings a bell. Otherwise,
2416 since spelling matters for me, either accept the default or answer "none"
2417 to leave it blank.
2418
2419 EOM
2420 case "$osname" in
2421         ''|' ')
2422                 case "$hintfile" in
2423                 ''|' '|none) dflt=none ;;
2424                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2425                 esac
2426                 ;;
2427         *) dflt="$osname" ;;
2428 esac
2429 rp="Operating system name?"
2430 . ./myread
2431 case "$ans" in
2432 none)  osname='' ;;
2433 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2434 esac
2435 echo " "
2436 case "$osvers" in
2437         ''|' ')
2438                 case "$hintfile" in
2439                 ''|' '|none) dflt=none ;;
2440                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2441                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2442                         case "$dflt" in
2443                         ''|' ') dflt=none ;;
2444                         esac
2445                         ;;
2446                 esac
2447                 ;;
2448         *) dflt="$osvers" ;;
2449 esac
2450 rp="Operating system version?"
2451 . ./myread
2452 case "$ans" in
2453 none)  osvers='' ;;
2454 *) osvers="$ans" ;;
2455 esac
2456
2457 : who configured the system
2458 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2459 cf_by=`(logname) 2>/dev/null`
2460 case "$cf_by" in
2461 "")
2462         cf_by=`(whoami) 2>/dev/null`
2463         case "$cf_by" in
2464         "") cf_by=unknown ;;
2465         esac ;;
2466 esac
2467
2468 : set up the script used to warn in case of inconsistency
2469 cat <<EOS >whoa
2470 $startsh
2471 EOS
2472 cat <<'EOSC' >>whoa
2473 dflt=y
2474 echo " "
2475 echo "*** WHOA THERE!!! ***" >&4
2476 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2477 rp="    Keep the $hint value?"
2478 . ./myread
2479 case "$ans" in
2480 y) td=$was; tu=$was;;
2481 esac
2482 EOSC
2483
2484 : function used to set $1 to $val
2485 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2486 case "$val$was" in
2487 $define$undef) . ./whoa; eval "$var=\$td";;
2488 $undef$define) . ./whoa; eval "$var=\$tu";;
2489 *) eval "$var=$val";;
2490 esac'
2491
2492 cat <<EOM
2493
2494 Perl can be built to take advantage of threads, on some systems.
2495 To do so, Configure must be run with -Dusethreads.
2496
2497 Note that threading is a highly experimental feature, and
2498 some known race conditions still remain.  If you choose to try
2499 it, be very sure to not actually deploy it for production
2500 purposes.  README.threads has more details, and is required
2501 reading if you enable threads.
2502 EOM
2503 case "$usethreads" in
2504 $define|true|[yY]*)     dflt='y';;
2505 *) dflt='n';;
2506 esac
2507 rp='Build a threading Perl?'
2508 . ./myread
2509 case "$ans" in
2510 y|Y)    val="$define" ;;     
2511 *)      val="$undef" ;;
2512 esac
2513 set usethreads
2514 eval $setvar 
2515
2516 case "$d_oldpthreads" in
2517 '')     : Configure tests would be welcome here.  For now, assume undef.
2518         val="$undef" ;;
2519 *)      val="$d_oldpthreads" ;;
2520 esac
2521 set d_oldpthreads
2522 eval $setvar
2523
2524
2525 case "$usethreads" in
2526 "$define"|true|[yY]*)
2527 : Look for a hint-file generated 'call-back-unit'.  If the
2528 : user has specified that a threading perl is to be built,
2529 : we may need to set or change some other defaults.
2530         if $test -f usethreads.cbu; then
2531                 . ./usethreads.cbu
2532         fi
2533         case "$osname" in
2534         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2535                 # Known thread-capable platforms.
2536                 ;;
2537         *)
2538                 cat >&4 <<EOM
2539 $osname is not known to support threads.
2540 Please let perlbug@perl.com know how to do that.
2541
2542 Cannot continue, aborting.
2543 EOM
2544                 exit 1
2545         ;;
2546         esac # $osname
2547     ;;
2548 esac # $usethreads
2549
2550 cat <<EOM
2551
2552 Perl can be built so that multiple Perl interpreters can coexist
2553 within the same Perl executable.  To do so, Configure must be run with
2554 -Dusemultiplicity.
2555
2556 Normally you do not need this and you should answer no.
2557
2558 EOM
2559 case "$usemultiplicity" in
2560 $define|true|[yY]*)     dflt='y';;
2561 *) dflt='n';;
2562 esac
2563 rp='Build Perl for multiplicity?'
2564 . ./myread
2565 case "$ans" in
2566 y|Y)    val="$define" ;;     
2567 *)      val="$undef" ;;
2568 esac
2569 set usemultiplicity
2570 eval $setvar 
2571
2572 cat <<EOM
2573
2574 Perl can be built to take advantage of explicit 64-bit interfaces,
2575 on some systems.  To do so, Configure must be run with -Duse64bits.
2576
2577 If this doesn't make any sense to you, just accept the default 'n'.
2578 EOM
2579 case "$use64bits" in
2580 $define|true|[yY]*)     dflt='y';;
2581 *) dflt='n';;
2582 esac
2583 rp='Try to use explicit 64-bit interfaces, if available?'
2584 . ./myread
2585 case "$ans" in
2586 y|Y) 
2587         val="$define"
2588         ;;     
2589 *)      
2590         val="$undef"
2591         ;;
2592 esac
2593 set use64bits
2594 eval $setvar
2595
2596 case "$archname64" in
2597 '') archname64='' ;;    # not a typo
2598 esac
2599
2600 case "$use64bits" in
2601 "$define"|true|[yY]*)
2602 : Look for a hint-file generated 'call-back-unit'.  If the
2603 : user has specified that a threading perl is to be built,
2604 : we may need to set or change some other defaults.
2605         if $test -f use64bits.cbu; then
2606                 . ./use64bits.cbu
2607         fi
2608         case "$osname" in
2609         dec_osf|hpux|irix|solaris|unicos)
2610                 # Known 64-bit capable platforms.
2611                 ;;
2612         *)
2613                 cat >&4 <<EOM
2614 $osname is not known to support 64-bit interfaces.
2615 Please let perlbug@perl.com know how to do that.
2616
2617 Cannot continue, aborting.
2618 EOM
2619                 exit 1
2620                 ;;
2621         esac
2622         ;;
2623 esac
2624
2625 : determine the architecture name
2626 echo " "
2627 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2628         tarch=`arch`"-$osname"
2629 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2630         if uname -m > tmparch 2>&1 ; then
2631                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2632                         -e 's/$/'"-$osname/" tmparch`
2633         else
2634                 tarch="$osname"
2635         fi
2636         $rm -f tmparch
2637 else
2638         tarch="$osname"
2639 fi
2640 case "$myarchname" in
2641 ''|"$tarch") ;;
2642 *)
2643         echo "(Your architecture name used to be $myarchname.)"
2644         archname=''
2645         ;;
2646 esac
2647 myarchname="$tarch"
2648 case "$archname" in
2649 '') dflt="$tarch";;
2650 *) dflt="$archname";;
2651 esac
2652 rp='What is your architecture name'
2653 . ./myread
2654 archname="$ans"
2655 case "$usethreads" in
2656 $define)
2657         echo "Threads selected." >&4
2658         case "$archname" in
2659         *-thread*) echo "...and architecture name already has -thread." >&4
2660                 ;;
2661         *)      archname="$archname-thread"
2662                 echo "...setting architecture name to $archname." >&4
2663                 ;;
2664         esac
2665         ;;
2666 esac
2667 case "$usemultiplicity" in
2668 $define)
2669         echo "Multiplicity selected." >&4
2670         case "$archname" in
2671         *-multi*) echo "...and architecture name already has -multi." >&4
2672                 ;;
2673         *)      archname="$archname-multi"
2674                 echo "...setting architecture name to $archname." >&4
2675                 ;;
2676         esac
2677         ;;
2678 esac
2679 case "$use64bits" in
2680 $define)
2681         echo "Explicit 64-bitness selected." >&4
2682         case "$archname64" in
2683         '')
2684                 ;;
2685         *)
2686                 case "$archname" in
2687                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2688                         ;;
2689                 *)      archname="$archname-$archname64"
2690                         echo "...setting architecture name to $archname." >&4
2691                         ;;
2692                 esac
2693                 ;;
2694         esac
2695 esac
2696
2697 : is AFS running?
2698 echo " "
2699 case "$afs" in
2700 $define|true)   afs=true ;;
2701 $undef|false)   afs=false ;;
2702 *)      if test -d /afs; then
2703                 afs=true
2704         else
2705                 afs=false
2706         fi
2707         ;;
2708 esac
2709 if $afs; then
2710         echo "AFS may be running... I'll be extra cautious then..." >&4
2711 else
2712         echo "AFS does not seem to be running..." >&4
2713 fi
2714
2715 : decide how portable to be.  Allow command line overrides.
2716 case "$d_portable" in
2717 "$undef") ;;
2718 *)      d_portable="$define" ;;
2719 esac
2720
2721 : set up shell script to do ~ expansion
2722 cat >filexp <<EOSS
2723 $startsh
2724 : expand filename
2725 case "\$1" in
2726  ~/*|~)
2727         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2728         ;;
2729  ~*)
2730         if $test -f /bin/csh; then
2731                 /bin/csh -f -c "glob \$1"
2732                 failed=\$?
2733                 echo ""
2734                 exit \$failed
2735         else
2736                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2737                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2738                 if $test ! -d "\$dir"; then
2739                         me=\`basename \$0\`
2740                         echo "\$me: can't locate home directory for: \$name" >&2
2741                         exit 1
2742                 fi
2743                 case "\$1" in
2744                 */*)
2745                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2746                         ;;
2747                 *)
2748                         echo \$dir
2749                         ;;
2750                 esac
2751         fi
2752         ;;
2753 *)
2754         echo \$1
2755         ;;
2756 esac
2757 EOSS
2758 chmod +x filexp
2759 $eunicefix filexp
2760
2761 : now set up to get a file name
2762 cat <<EOS >getfile
2763 $startsh
2764 EOS
2765 cat <<'EOSC' >>getfile
2766 tilde=''
2767 fullpath=''
2768 already=''
2769 skip=''
2770 none_ok=''
2771 exp_file=''
2772 nopath_ok=''
2773 orig_rp="$rp"
2774 orig_dflt="$dflt"
2775
2776 case "$fn" in
2777 *\(*)
2778         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2779         fn=`echo $fn | sed 's/(.*)//'`
2780         ;;
2781 esac
2782
2783 case "$fn" in
2784 *:*)
2785         loc_file=`expr $fn : '.*:\(.*\)'`
2786         fn=`expr $fn : '\(.*\):.*'`
2787         ;;
2788 esac
2789
2790 case "$fn" in
2791 *~*) tilde=true;;
2792 esac
2793 case "$fn" in
2794 */*) fullpath=true;;
2795 esac
2796 case "$fn" in
2797 *+*) skip=true;;
2798 esac
2799 case "$fn" in
2800 *n*) none_ok=true;;
2801 esac
2802 case "$fn" in
2803 *e*) exp_file=true;;
2804 esac
2805 case "$fn" in
2806 *p*) nopath_ok=true;;
2807 esac
2808
2809 case "$fn" in
2810 *f*) type='File';;
2811 *d*) type='Directory';;
2812 *l*) type='Locate';;
2813 esac
2814
2815 what="$type"
2816 case "$what" in
2817 Locate) what='File';;
2818 esac
2819
2820 case "$exp_file" in
2821 '')
2822         case "$d_portable" in
2823         "$define") ;;
2824         *) exp_file=true;;
2825         esac
2826         ;;
2827 esac
2828
2829 cd ..
2830 while test "$type"; do
2831         redo=''
2832         rp="$orig_rp"
2833         dflt="$orig_dflt"
2834         case "$tilde" in
2835         true) rp="$rp (~name ok)";;
2836         esac
2837         . UU/myread
2838         if test -f UU/getfile.ok && \
2839                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2840         then
2841                 value="$ans"
2842                 ansexp="$ans"
2843                 break
2844         fi
2845         case "$ans" in
2846         none)
2847                 value=''
2848                 ansexp=''
2849                 case "$none_ok" in
2850                 true) type='';;
2851                 esac
2852                 ;;
2853         *)
2854                 case "$tilde" in
2855                 '') value="$ans"
2856                         ansexp="$ans";;
2857                 *)
2858                         value=`UU/filexp $ans`
2859                         case $? in
2860                         0)
2861                                 if test "$ans" != "$value"; then
2862                                         echo "(That expands to $value on this system.)"
2863                                 fi
2864                                 ;;
2865                         *) value="$ans";;
2866                         esac
2867                         ansexp="$value"
2868                         case "$exp_file" in
2869                         '') value="$ans";;
2870                         esac
2871                         ;;
2872                 esac
2873                 case "$fullpath" in
2874                 true)
2875                         case "$ansexp" in
2876                         /*) value="$ansexp" ;;
2877                         *)
2878                                 redo=true
2879                                 case "$already" in
2880                                 true)
2881                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2882                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2883                                         ;;
2884                                 *)
2885                                 echo "Please give a full path name, starting with slash." >&4
2886                                         case "$tilde" in
2887                                         true)
2888                                 echo "Note that using ~name is ok provided it expands well." >&4
2889                                                 already=true
2890                                                 ;;
2891                                         esac
2892                                 esac
2893                                 ;;
2894                         esac
2895                         ;;
2896                 esac
2897                 case "$redo" in
2898                 '')
2899                         case "$type" in
2900                         File)
2901                                 if test -f "$ansexp"; then
2902                                         type=''
2903                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2904                                 then
2905                                         echo "($value is not a plain file, but that's ok.)"
2906                                         type=''
2907                                 fi
2908                                 ;;
2909                         Directory)
2910                                 if test -d "$ansexp"; then
2911                                         type=''
2912                                 fi
2913                                 ;;
2914                         Locate)
2915                                 if test -d "$ansexp"; then
2916                                         echo "(Looking for $loc_file in directory $value.)"
2917                                         value="$value/$loc_file"
2918                                         ansexp="$ansexp/$loc_file"
2919                                 fi
2920                                 if test -f "$ansexp"; then
2921                                         type=''
2922                                 fi
2923                                 case "$nopath_ok" in
2924                                 true)   case "$value" in
2925                                         */*) ;;
2926                                         *)      echo "Assuming $value will be in people's path."
2927                                                 type=''
2928                                                 ;;
2929                                         esac
2930                                         ;;
2931                                 esac
2932                                 ;;
2933                         esac
2934
2935                         case "$skip" in
2936                         true) type='';
2937                         esac
2938
2939                         case "$type" in
2940                         '') ;;
2941                         *)
2942                                 if test "$fastread" = yes; then
2943                                         dflt=y
2944                                 else
2945                                         dflt=n
2946                                 fi
2947                                 rp="$what $value doesn't exist.  Use that name anyway?"
2948                                 . UU/myread
2949                                 dflt=''
2950                                 case "$ans" in
2951                                 y*) type='';;
2952                                 *) echo " ";;
2953                                 esac
2954                                 ;;
2955                         esac
2956                         ;;
2957                 esac
2958                 ;;
2959         esac
2960 done
2961 cd UU
2962 ans="$value"
2963 rp="$orig_rp"
2964 dflt="$orig_dflt"
2965 rm -f getfile.ok
2966 EOSC
2967
2968 : determine root of directory hierarchy where package will be installed.
2969 case "$prefix" in
2970 '')
2971         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2972         ;;
2973 *)
2974         dflt="$prefix"
2975         ;;
2976 esac
2977 $cat <<EOM
2978
2979 By default, $package will be installed in $dflt/bin, manual
2980 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
2981 all installation directories. Typically set to /usr/local, but you
2982 may choose /usr if you wish to install $package among your system
2983 binaries. If you wish to have binaries under /bin but manual pages
2984 under /usr/local/man, that's ok: you will be prompted separately
2985 for each of the installation directories, the prefix being only used
2986 to set the defaults.
2987
2988 EOM
2989 fn=d~
2990 rp='Installation prefix to use?'
2991 . ./getfile
2992 oldprefix=''
2993 case "$prefix" in
2994 '') ;;
2995 *)
2996         case "$ans" in
2997         "$prefix") ;;
2998         *) oldprefix="$prefix";;
2999         esac
3000         ;;
3001 esac
3002 prefix="$ans"
3003 prefixexp="$ansexp"
3004
3005 : set the prefixit variable, to compute a suitable default value
3006 prefixit='case "$3" in
3007 ""|none)
3008         case "$oldprefix" in
3009         "") eval "$1=\"\$$2\"";;
3010         *)
3011                 case "$3" in
3012                 "") eval "$1=";;
3013                 none)
3014                         eval "tp=\"\$$2\"";
3015                         case "$tp" in
3016                         ""|" ") eval "$1=\"\$$2\"";;
3017                         *) eval "$1=";;
3018                         esac;;
3019                 esac;;
3020         esac;;
3021 *)
3022         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3023         case "$tp" in
3024         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3025         /*-$oldprefix/*|\~*-$oldprefix/*)
3026                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3027         *) eval "$1=\"\$$2\"";;
3028         esac;;
3029 esac'
3030
3031 : set the base revision
3032 baserev=5.0
3033
3034 : get the patchlevel
3035 echo " "
3036 echo "Getting the current patchlevel..." >&4
3037 if $test -r $rsrc/patchlevel.h;then
3038         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3039         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3040 else
3041         patchlevel=0
3042         subversion=0
3043 fi
3044 $echo $n "(You have $package" $c
3045 case "$package" in
3046 "*$baserev")    ;;
3047 *)              $echo $n " $baserev" $c ;;
3048 esac
3049 $echo $n " patchlevel $patchlevel" $c
3050 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3051 echo ".)"
3052
3053 if test 0 -eq "$subversion"; then
3054         version=`LC_ALL=C; export LC_ALL; \
3055                  echo $baserev $patchlevel | \
3056                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3057 else
3058         version=`LC_ALL=C; export LC_ALL; \
3059                  echo $baserev $patchlevel $subversion | \
3060                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3061 fi
3062 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3063 if test "$subversion" -lt 50; then
3064         apiversion=`LC_ALL=C; export LC_ALL; \
3065                  LANGUAGE=C; export LANGUAGE; \
3066                  echo $baserev $patchlevel | \
3067                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3068 else
3069         apiversion="$version"
3070 fi
3071
3072 : determine where private library files go
3073 : Usual default is /usr/local/lib/perl5/$version.
3074 : Also allow things like /opt/perl/lib/$version, since 
3075 : /opt/perl/lib/perl5... would be redundant.
3076 case "$prefix" in
3077 *perl*) set dflt privlib lib/$version ;;
3078 *)       set dflt privlib lib/$package/$version ;;
3079 esac
3080 eval $prefixit
3081 $cat <<EOM
3082
3083 There are some auxiliary files for $package that need to be put into a
3084 private library directory that is accessible by everyone.
3085
3086 EOM
3087 fn=d~+
3088 rp='Pathname where the private library files will reside?'
3089 . ./getfile
3090 if $test "X$privlibexp" != "X$ansexp"; then
3091         installprivlib=''
3092 fi
3093 privlib="$ans"
3094 privlibexp="$ansexp"
3095 if $afs; then
3096         $cat <<EOM
3097
3098 Since you are running AFS, I need to distinguish the directory in which
3099 private files reside from the directory in which they are installed (and from
3100 which they are presumably copied to the former directory by occult means).
3101
3102 EOM
3103         case "$installprivlib" in
3104         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3105         *) dflt="$installprivlib";;
3106         esac
3107         fn=de~
3108         rp='Where will private files be installed?'
3109         . ./getfile
3110         installprivlib="$ans"
3111 else
3112         installprivlib="$privlibexp"
3113 fi
3114
3115 : set the prefixup variable, to restore leading tilda escape
3116 prefixup='case "$prefixexp" in
3117 "$prefix") ;;
3118 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3119 esac'
3120
3121 : determine where public architecture dependent libraries go
3122 set archlib archlib
3123 eval $prefixit
3124 : privlib default is /usr/local/lib/$package/$version
3125 : archlib default is /usr/local/lib/$package/$version/$archname
3126 : privlib may have an optional trailing /share.
3127 tdflt=`echo $privlib | $sed 's,/share$,,'`
3128 tdflt=$tdflt/$archname
3129 case "$archlib" in
3130 '')     dflt=$tdflt
3131         ;;
3132 *)      dflt="$archlib"
3133     ;;
3134 esac
3135 cat <<EOM
3136
3137 $spackage contains architecture-dependent library files.  If you are
3138 sharing libraries in a heterogeneous environment, you might store
3139 these files in a separate location.  Otherwise, you can just include
3140 them with the rest of the public library files.
3141
3142 EOM
3143 fn=d+~
3144 rp='Where do you want to put the public architecture-dependent libraries?'
3145 . ./getfile
3146 archlib="$ans"
3147 archlibexp="$ansexp"
3148
3149 if $afs; then
3150         $cat <<EOM
3151
3152 Since you are running AFS, I need to distinguish the directory in
3153 which architecture-dependent library files reside from the directory
3154 in which they are installed (and from which they are presumably copied
3155 to the former directory by occult means).
3156
3157 EOM
3158         case "$installarchlib" in
3159         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3160         *) dflt="$installarchlib";;
3161         esac
3162         fn=de~
3163         rp='Where will architecture-dependent library files be installed?'
3164         . ./getfile
3165         installarchlib="$ans"
3166 else
3167         installarchlib="$archlibexp"
3168 fi
3169 if $test X"$archlib" = X"$privlib"; then
3170         d_archlib="$undef"
3171 else
3172         d_archlib="$define"
3173 fi
3174
3175 : make some quick guesses about what we are up against
3176 echo " "
3177 $echo $n "Hmm...  $c"
3178 echo exit 1 >bsd
3179 echo exit 1 >usg
3180 echo exit 1 >v7
3181 echo exit 1 >osf1
3182 echo exit 1 >eunice
3183 echo exit 1 >xenix
3184 echo exit 1 >venix
3185 echo exit 1 >os2
3186 d_bsd="$undef"
3187 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3188 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3189 then
3190         echo "Looks kind of like an OSF/1 system, but we'll see..."
3191         echo exit 0 >osf1
3192 elif test `echo abc | tr a-z A-Z` = Abc ; then
3193         xxx=`./loc addbib blurfl $pth`
3194         if $test -f $xxx; then
3195         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3196                 echo exit 0 >bsd
3197                 echo exit 0 >usg
3198         else
3199                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3200                         echo "Looks kind of like an extended USG system, but we'll see..."
3201                 else
3202                         echo "Looks kind of like a USG system, but we'll see..."
3203                 fi
3204                 echo exit 0 >usg
3205         fi
3206 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3207         echo "Looks kind of like a BSD system, but we'll see..."
3208         d_bsd="$define"
3209         echo exit 0 >bsd
3210 else
3211         echo "Looks kind of like a Version 7 system, but we'll see..."
3212         echo exit 0 >v7
3213 fi
3214 case "$eunicefix" in
3215 *unixtovms*)
3216         $cat <<'EOI'
3217 There is, however, a strange, musty smell in the air that reminds me of
3218 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3219 EOI
3220         echo exit 0 >eunice
3221         d_eunice="$define"
3222 : it so happens the Eunice I know will not run shell scripts in Unix format
3223         ;;
3224 *)
3225         echo " "
3226         echo "Congratulations.  You aren't running Eunice."
3227         d_eunice="$undef"
3228         ;;
3229 esac
3230 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3231 case "$p_" in
3232 :) ;;
3233 *)
3234         $cat <<'EOI'
3235 I have the feeling something is not exactly right, however...don't tell me...
3236 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3237 EOI
3238         echo exit 0 >os2
3239         ;;
3240 esac
3241 if test -f /xenix; then
3242         echo "Actually, this looks more like a XENIX system..."
3243         echo exit 0 >xenix
3244         d_xenix="$define"
3245 else
3246         echo " "
3247         echo "It's not Xenix..."
3248         d_xenix="$undef"
3249 fi
3250 chmod +x xenix
3251 $eunicefix xenix
3252 if test -f /venix; then
3253         echo "Actually, this looks more like a VENIX system..."
3254         echo exit 0 >venix
3255 else
3256         echo " "
3257         if ./xenix; then
3258                 : null
3259         else
3260                 echo "Nor is it Venix..."
3261         fi
3262 fi
3263 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3264 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3265 $rm -f foo
3266
3267 : see if setuid scripts can be secure
3268 $cat <<EOM
3269
3270 Some kernels have a bug that prevents setuid #! scripts from being
3271 secure.  Some sites have disabled setuid #! scripts because of this.
3272
3273 First let's decide if your kernel supports secure setuid #! scripts.
3274 (If setuid #! scripts would be secure but have been disabled anyway,
3275 don't say that they are secure if asked.)
3276
3277 EOM
3278
3279 val="$undef"
3280 if $test -d /dev/fd; then
3281         echo "#!$ls" >reflect
3282         chmod +x,u+s reflect
3283         ./reflect >flect 2>&1
3284         if $contains "/dev/fd" flect >/dev/null; then
3285                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3286                 val="$define"
3287         else
3288                 $cat <<EOM
3289 If you are not sure if they are secure, I can check but I'll need a
3290 username and password different from the one you are using right now.
3291 If you don't have such a username or don't want me to test, simply
3292 enter 'none'.
3293
3294 EOM
3295                 rp='Other username to test security of setuid scripts with?'
3296                 dflt='none'
3297                 . ./myread
3298                 case "$ans" in
3299                 n|none)
3300                         case "$d_suidsafe" in
3301                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3302                                 dflt=n;;
3303                         "$undef")
3304                                 echo "Well, the $hint value is *not* secure." >&4
3305                                 dflt=n;;
3306                         *)      echo "Well, the $hint value *is* secure." >&4
3307                                 dflt=y;;
3308                         esac
3309                         ;;
3310                 *)
3311                         $rm -f reflect flect
3312                         echo "#!$ls" >reflect
3313                         chmod +x,u+s reflect
3314                         echo >flect
3315                         chmod a+w flect
3316                         echo '"su" will (probably) prompt you for '"$ans's password."
3317                         su $ans -c './reflect >flect'
3318                         if $contains "/dev/fd" flect >/dev/null; then
3319                                 echo "Okay, it looks like setuid scripts are secure." >&4
3320                                 dflt=y
3321                         else
3322                                 echo "I don't think setuid scripts are secure." >&4
3323                                 dflt=n
3324                         fi
3325                         ;;
3326                 esac
3327                 rp='Does your kernel have *secure* setuid scripts?'
3328                 . ./myread
3329                 case "$ans" in
3330                 [yY]*)  val="$define";;
3331                 *)      val="$undef";;
3332                 esac
3333         fi
3334 else
3335         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3336         echo "(That's for file descriptors, not floppy disks.)"
3337         val="$undef"
3338 fi
3339 set d_suidsafe
3340 eval $setvar
3341
3342 $rm -f reflect flect
3343
3344 : now see if they want to do setuid emulation
3345 echo " "
3346 val="$undef"
3347 case "$d_suidsafe" in
3348 "$define")
3349         val="$undef"
3350         echo "No need to emulate SUID scripts since they are secure here." >& 4
3351         ;;
3352 *)
3353         $cat <<EOM
3354 Some systems have disabled setuid scripts, especially systems where
3355 setuid scripts cannot be secure.  On systems where setuid scripts have
3356 been disabled, the setuid/setgid bits on scripts are currently
3357 useless.  It is possible for $package to detect those bits and emulate
3358 setuid/setgid in a secure fashion.  This emulation will only work if
3359 setuid scripts have been disabled in your kernel.
3360
3361 EOM
3362         case "$d_dosuid" in
3363         "$define") dflt=y ;;
3364         *) dflt=n ;;
3365         esac
3366         rp="Do you want to do setuid/setgid emulation?"
3367         . ./myread
3368         case "$ans" in
3369         [yY]*)  val="$define";;
3370         *)      val="$undef";;
3371         esac
3372         ;;
3373 esac
3374 set d_dosuid
3375 eval $setvar
3376
3377 : determine where manual pages are on this system
3378 echo " "
3379 case "$sysman" in
3380 '') 
3381         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3382         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3383         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3384         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3385         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3386         sysman=`./loc . /usr/man/man1 $syspath`
3387         ;;
3388 esac
3389 if $test -d "$sysman"; then
3390         echo "System manual is in $sysman." >&4
3391 else
3392         echo "Could not find manual pages in source form." >&4
3393 fi
3394
3395 : see what memory models we can support
3396 case "$models" in
3397 '')
3398         $cat >pdp11.c <<'EOP'
3399 int main() {
3400 #ifdef pdp11
3401         exit(0);
3402 #else
3403         exit(1);
3404 #endif
3405 }
3406 EOP
3407         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3408         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3409                 dflt='unsplit split'
3410         else
3411                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3412                 case "$tans" in
3413                 X) dflt='none';;
3414                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3415                                 dflt='small'
3416                         else
3417                                 dflt=''
3418                         fi
3419                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3420                                 dflt="$dflt medium"
3421                         fi
3422                         if $test -d /lib/large || $test -d /usr/lib/large; then
3423                                 dflt="$dflt large"
3424                         fi
3425                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3426                                 dflt="$dflt huge"
3427                         fi
3428                 esac
3429         fi;;
3430 *) dflt="$models";;
3431 esac
3432 $cat <<EOM
3433  
3434 Some systems have different model sizes.  On most systems they are called
3435 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3436 split.  If your system doesn't support different memory models, say "none".
3437 If you wish to force everything to one memory model, say "none" here and
3438 put the appropriate flags later when it asks you for other cc and ld flags.
3439 Venix systems may wish to put "none" and let the compiler figure things out.
3440 (In the following question multiple model names should be space separated.)
3441
3442 The default for most systems is "none".
3443
3444 EOM
3445 rp="Which memory models are supported?"
3446 . ./myread
3447 models="$ans"
3448
3449 case "$models" in
3450 none)
3451         small=''
3452         medium=''
3453         large=''
3454         huge=''
3455         unsplit=''
3456         split=''
3457         ;;
3458 *split)
3459         case "$split" in
3460         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3461                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3462                         dflt='-i'
3463                 else
3464                         dflt='none'
3465                 fi;;
3466         *) dflt="$split";;
3467         esac
3468         rp="What flag indicates separate I and D space?"
3469         . ./myread
3470         tans="$ans"
3471         case "$tans" in
3472         none) tans='';;
3473         esac
3474         split="$tans"
3475         unsplit='';;
3476 *large*|*small*|*medium*|*huge*)
3477         case "$models" in
3478         *large*)
3479                 case "$large" in
3480                 '') dflt='-Ml';;
3481                 *) dflt="$large";;
3482                 esac
3483         rp="What flag indicates large model?"
3484         . ./myread
3485         tans="$ans"
3486         case "$tans" in
3487         none) tans='';
3488         esac
3489         large="$tans";;
3490         *) large='';;
3491         esac
3492         case "$models" in
3493         *huge*) case "$huge" in
3494                 '') dflt='-Mh';;
3495                 *) dflt="$huge";;
3496                 esac
3497                 rp="What flag indicates huge model?"
3498                 . ./myread
3499                 tans="$ans"
3500                 case "$tans" in
3501                 none) tans='';
3502                 esac
3503                 huge="$tans";;
3504         *) huge="$large";;
3505         esac
3506         case "$models" in
3507         *medium*) case "$medium" in
3508                 '') dflt='-Mm';;
3509                 *) dflt="$medium";;
3510                 esac
3511                 rp="What flag indicates medium model?"
3512                 . ./myread
3513                 tans="$ans"
3514                 case "$tans" in
3515                 none) tans='';
3516                 esac
3517                 medium="$tans";;
3518         *) medium="$large";;
3519         esac
3520         case "$models" in
3521         *small*) case "$small" in
3522                 '') dflt='none';;
3523                 *) dflt="$small";;
3524                 esac
3525                 rp="What flag indicates small model?"
3526                 . ./myread
3527                 tans="$ans"
3528                 case "$tans" in
3529                 none) tans='';
3530                 esac
3531                 small="$tans";;
3532         *) small='';;
3533         esac
3534         ;;
3535 *)
3536         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3537         ;;
3538 esac
3539 $rm -f pdp11.* pdp11
3540
3541 : see if we need a special compiler
3542 echo " "
3543 if ./usg; then
3544         case "$cc" in
3545         '') case "$Mcc" in
3546                 /*) dflt='Mcc';;
3547                 *) case "$large" in
3548                         -M*) dflt='cc';;
3549                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3550                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3551                                                 dflt='cc'
3552                                         else
3553                                                 dflt='cc -M'
3554                                         fi
3555                                 else
3556                                         dflt='cc'
3557                                 fi;;
3558                         esac;;
3559                 esac;;
3560         *)  dflt="$cc";;
3561         esac
3562         case "$dflt" in
3563         *M*)    $cat <<'EOM'
3564 On some older systems the default C compiler will not resolve multiple global
3565 references that happen to have the same name.  On some such systems the "Mcc"
3566 command may be used to force these to be resolved.  On other systems a "cc -M"
3567 command is required.  (Note that the -M flag on other systems indicates a
3568 memory model to use!) If you have the Gnu C compiler, you might wish to use
3569 that instead.
3570
3571 EOM
3572         ;;
3573         esac
3574         rp="Use which C compiler?"
3575         . ./myread
3576         cc="$ans"
3577 else
3578         case "$cc" in
3579         '') dflt=cc;;
3580         *) dflt="$cc";;
3581         esac
3582         rp="Use which C compiler?"
3583         . ./myread
3584         cc="$ans"
3585 fi
3586 : Look for a hint-file generated 'call-back-unit'.  Now that the
3587 : user has specified the compiler, we may need to set or change some
3588 : other defaults.
3589 if $test -f cc.cbu; then
3590     . ./cc.cbu
3591 fi
3592 echo " "
3593 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3594 $cat >gccvers.c <<EOM
3595 #include <stdio.h>
3596 int main() {
3597 #ifdef __GNUC__
3598 #ifdef __VERSION__
3599         printf("%s\n", __VERSION__);
3600 #else
3601         printf("%s\n", "1");
3602 #endif
3603 #endif
3604         exit(0);
3605 }
3606 EOM
3607 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
3608         gccversion=`./gccvers`
3609         case "$gccversion" in
3610         '') echo "You are not using GNU cc." ;;
3611         *)  echo "You are using GNU cc $gccversion." ;;
3612         esac
3613 else
3614         echo " "
3615         echo "*** WHOA THERE!!! ***" >&4
3616         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3617         case "$knowitall" in
3618         '')
3619         echo "    You'd better start hunting for one and let me know about it." >&4
3620                 exit 1
3621                 ;;
3622         esac
3623 fi
3624 $rm -f gccvers*
3625 case "$gccversion" in
3626 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3627 esac
3628
3629 : What should the include directory be ?
3630 echo " "
3631 $echo $n "Hmm...  $c"
3632 dflt='/usr/include'
3633 incpath=''
3634 mips_type=''
3635 if $test -f /bin/mips && /bin/mips; then
3636         echo "Looks like a MIPS system..."
3637         $cat >usr.c <<'EOCP'
3638 #ifdef SYSTYPE_BSD43
3639 /bsd43
3640 #endif
3641 EOCP
3642         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3643                 dflt='/bsd43/usr/include'
3644                 incpath='/bsd43'
3645                 mips_type='BSD 4.3'
3646         else
3647                 mips_type='System V'
3648         fi
3649         $rm -f usr.c usr.out
3650         echo "and you're compiling with the $mips_type compiler and libraries."
3651         xxx_prompt=y
3652         echo "exit 0" >mips
3653 else
3654         echo "Doesn't look like a MIPS system."
3655         xxx_prompt=n
3656         echo "exit 1" >mips
3657 fi
3658 chmod +x mips
3659 $eunicefix mips
3660 case "$usrinc" in
3661 '') ;;
3662 *) dflt="$usrinc";;
3663 esac
3664 case "$xxx_prompt" in
3665 y)      fn=d/
3666         echo " "
3667         rp='Where are the include files you want to use?'
3668         . ./getfile
3669         usrinc="$ans"
3670         ;;
3671 *)      usrinc="$dflt"
3672         ;;
3673 esac
3674
3675 : see how we invoke the C preprocessor
3676 echo " "
3677 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3678 cat <<'EOT' >testcpp.c
3679 #define ABC abc
3680 #define XYZ xyz
3681 ABC.XYZ
3682 EOT
3683 cd ..
3684 if test ! -f cppstdin; then
3685         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3686 else
3687         echo "Keeping your $hint cppstdin wrapper."
3688 fi
3689 chmod 755 cppstdin
3690 wrapper=`pwd`/cppstdin
3691 ok='false'
3692 cd UU
3693
3694 if $test "X$cppstdin" != "X" && \
3695         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3696         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3697 then
3698         echo "You used to use $cppstdin $cppminus so we'll use that again."
3699         case "$cpprun" in
3700         '') echo "But let's see if we can live without a wrapper..." ;;
3701         *)
3702                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3703                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3704                 then
3705                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3706                         ok='true'
3707                 else
3708                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3709                 fi
3710                 ;;
3711         esac
3712 else
3713         case "$cppstdin" in
3714         '') ;;
3715         *)
3716                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3717                 ;;
3718         esac
3719 fi
3720
3721 if $ok; then
3722         : nothing
3723 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3724         $cc -E <testcpp.c >testcpp.out 2>&1; \
3725         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3726         echo "Yup, it does."
3727         x_cpp="$cc -E"
3728         x_minus='';
3729 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3730         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3731         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3732         echo "Yup, it does."
3733         x_cpp="$cc -E"
3734         x_minus='-';
3735 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3736         $cc -P <testcpp.c >testcpp.out 2>&1; \
3737         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3738         echo "Yipee, that works!"
3739         x_cpp="$cc -P"
3740         x_minus='';
3741 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3742         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3743         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3744         echo "At long last!"
3745         x_cpp="$cc -P"
3746         x_minus='-';
3747 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3748         $cpp <testcpp.c >testcpp.out 2>&1; \
3749         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3750         echo "It works!"
3751         x_cpp="$cpp"
3752         x_minus='';
3753 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3754         $cpp - <testcpp.c >testcpp.out 2>&1; \
3755         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3756         echo "Hooray, it works!  I was beginning to wonder."
3757         x_cpp="$cpp"
3758         x_minus='-';
3759 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3760         $wrapper <testcpp.c >testcpp.out 2>&1; \
3761         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3762         x_cpp="$wrapper"
3763         x_minus=''
3764         echo "Eureka!"
3765 else
3766         dflt=''
3767         rp="No dice.  I can't find a C preprocessor.  Name one:"
3768         . ./myread
3769         x_cpp="$ans"
3770         x_minus=''
3771         $x_cpp <testcpp.c >testcpp.out 2>&1
3772         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3773                 echo "OK, that will do." >&4
3774         else
3775 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3776                 exit 1
3777         fi
3778 fi
3779
3780 case "$ok" in
3781 false)
3782         cppstdin="$x_cpp"
3783         cppminus="$x_minus"
3784         cpprun="$x_cpp"
3785         cpplast="$x_minus"
3786         set X $x_cpp
3787         shift
3788         case "$1" in
3789         "$cpp")
3790                 echo "Perhaps can we force $cc -E using a wrapper..."
3791                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3792                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3793                 then
3794                         echo "Yup, we can."
3795                         cppstdin="$wrapper"
3796                         cppminus='';
3797                 else
3798                         echo "Nope, we'll have to live without it..."
3799                 fi
3800                 ;;
3801         esac
3802         case "$cpprun" in
3803         "$wrapper")
3804                 cpprun=''
3805                 cpplast=''
3806                 ;;
3807         esac
3808         ;;
3809 esac
3810
3811 case "$cppstdin" in
3812 "$wrapper"|'cppstdin') ;;
3813 *) $rm -f $wrapper;;
3814 esac
3815 $rm -f testcpp.c testcpp.out
3816
3817 : Set private lib path
3818 case "$plibpth" in
3819 '') if ./mips; then
3820                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3821         fi;;
3822 esac
3823 case "$libpth" in
3824 ' ') dlist='';;
3825 '') dlist="$loclibpth $plibpth $glibpth";;
3826 *) dlist="$libpth";;
3827 esac
3828
3829 : Now check and see which directories actually exist, avoiding duplicates
3830 libpth=''
3831 for xxx in $dlist
3832 do
3833     if $test -d $xxx; then
3834                 case " $libpth " in
3835                 *" $xxx "*) ;;
3836                 *) libpth="$libpth $xxx";;
3837                 esac
3838     fi
3839 done
3840 $cat <<'EOM'
3841
3842 Some systems have incompatible or broken versions of libraries.  Among
3843 the directories listed in the question below, please remove any you
3844 know not to be holding relevant libraries, and add any that are needed.
3845 Say "none" for none.
3846
3847 EOM
3848 case "$libpth" in
3849 '') dflt='none';;
3850 *)
3851         set X $libpth
3852         shift
3853         dflt=${1+"$@"}
3854         ;;
3855 esac
3856 rp="Directories to use for library searches?"
3857 . ./myread
3858 case "$ans" in
3859 none) libpth=' ';;
3860 *) libpth="$ans";;
3861 esac
3862
3863 : compute shared library extension
3864 case "$so" in
3865 '')
3866         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3867                 dflt='sl'
3868         else
3869                 dflt='so'
3870         fi
3871         ;;
3872 *) dflt="$so";;
3873 esac
3874 $cat <<EOM
3875
3876 On some systems, shared libraries may be available.  Answer 'none' if
3877 you want to suppress searching of shared libraries for the remaining
3878 of this configuration.
3879
3880 EOM
3881 rp='What is the file extension used for shared libraries?'
3882 . ./myread
3883 so="$ans"
3884
3885 : Define several unixisms.
3886 : Hints files or command line option can be used to override them.
3887 : The convoluted testing is in case hints files set either the old
3888 : or the new name.
3889 case "$_exe" in
3890 '')     case "$exe_ext" in
3891     '') ;;
3892         *)      _exe="$exe_ext" ;;
3893         esac
3894         ;;
3895 esac
3896 case "$_a" in
3897 '')     case "$lib_ext" in
3898     '') _a='.a';;
3899         *)      _a="$lib_ext" ;;
3900         esac
3901         ;;
3902 esac
3903 case "$_o" in
3904 '') case "$obj_ext" in
3905         '')     _o='.o';;
3906         *)      _o="$obj_ext";;
3907         esac
3908         ;;
3909 esac
3910 case "$p_" in
3911 '') case "$path_sep" in
3912         '')     p_=':';;
3913         *)      p_="$path_sep";;
3914         esac
3915         ;;
3916 esac
3917 exe_ext=$_exe
3918 lib_ext=$_a
3919 obj_ext=$_o
3920 path_sep=$p_
3921
3922 : Which makefile gets called first.  This is used by make depend.
3923 case "$firstmakefile" in
3924 '') firstmakefile='makefile';;
3925 esac
3926
3927 : Looking for optional libraries
3928 echo " "
3929 echo "Checking for optional libraries..." >&4
3930 case "$libs" in
3931 ' '|'') dflt='';;
3932 *) dflt="$libs";;
3933 esac
3934 case "$libswanted" in
3935 '') libswanted='c_s';;
3936 esac
3937 for thislib in $libswanted; do
3938         
3939         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3940                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3941                 echo "Found -l$thislib (shared)."
3942                 case " $dflt " in
3943                 *"-l$thislib "*);;
3944                 *) dflt="$dflt -l$thislib";;
3945                 esac
3946         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3947                 echo "Found -l$thislib (shared)."
3948                 case " $dflt " in
3949                 *"-l$thislib "*);;
3950                 *) dflt="$dflt -l$thislib";;
3951                 esac
3952         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
3953                 echo "Found -l$thislib."
3954                 case " $dflt " in
3955                 *"-l$thislib "*);;
3956                 *) dflt="$dflt -l$thislib";;
3957                 esac
3958         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
3959                 echo "Found -l$thislib."
3960                 case " $dflt " in
3961                 *"-l$thislib "*);;
3962                 *) dflt="$dflt -l$thislib";;
3963                 esac
3964         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
3965                 echo "Found -l${thislib}_s."
3966                 case " $dflt " in
3967                 *"-l$thislib "*);;
3968                 *) dflt="$dflt -l${thislib}_s";;
3969                 esac
3970         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
3971                 echo "Found -l$thislib."
3972                 case " $dflt " in
3973                 *"-l$thislib "*);;
3974                 *) dflt="$dflt -l$thislib";;
3975                 esac
3976         else
3977                 echo "No -l$thislib."
3978         fi
3979 done
3980 set X $dflt
3981 shift
3982 dflt="$*"
3983 case "$libs" in
3984 '') dflt="$dflt";;
3985 *) dflt="$libs";;
3986 esac
3987 case "$dflt" in
3988 ' '|'') dflt='none';;
3989 esac
3990
3991 $cat <<EOM
3992  
3993 Some versions of Unix support shared libraries, which make executables smaller
3994 but make load time slightly longer.
3995
3996 On some systems, mostly System V Release 3's, the shared library is included
3997 by putting the option "-lc_s" as the last thing on the cc command line when
3998 linking.  Other systems use shared libraries by default.  There may be other
3999 libraries needed to compile $package on your machine as well.  If your system
4000 needs the "-lc_s" option, include it here.  Include any other special libraries
4001 here as well.  Say "none" for none.
4002 EOM
4003
4004 echo " "
4005 rp="Any additional libraries?"
4006 . ./myread
4007 case "$ans" in
4008 none) libs=' ';;
4009 *) libs="$ans";;
4010 esac
4011
4012 : determine optimize, if desired, or use for debug flag also
4013 case "$optimize" in
4014 ' '|$undef) dflt='none';;
4015 '') dflt='-O';;
4016 *) dflt="$optimize";;
4017 esac
4018 $cat <<EOH
4019
4020 Some C compilers have problems with their optimizers.  By default, $package
4021 compiles with the -O flag to use the optimizer.  Alternately, you might want
4022 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4023 systems).  Either flag can be specified here.  To use neither flag, specify
4024 the word "none".
4025
4026 EOH
4027 rp="What optimizer/debugger flag should be used?"
4028 . ./myread
4029 optimize="$ans"
4030 case "$optimize" in
4031 'none') optimize=" ";;
4032 esac
4033
4034 dflt=''
4035 : We will not override a previous value, but we might want to
4036 : augment a hint file
4037 case "$hint" in
4038 none|recommended)
4039         case "$gccversion" in
4040         1*) dflt='-fpcc-struct-return' ;;
4041         esac
4042         case "$optimize" in
4043         *-g*) dflt="$dflt -DDEBUGGING";;
4044         esac
4045         case "$gccversion" in
4046         2*) if test -d /etc/conf/kconfig.d &&
4047                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4048                 then
4049                         dflt="$dflt -posix"
4050                 fi
4051                 ;;
4052         esac
4053         ;;
4054 esac
4055
4056 case "$mips_type" in
4057 *BSD*|'') inclwanted="$locincpth $usrinc";;
4058 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4059 esac
4060 for thisincl in $inclwanted; do
4061         if $test -d $thisincl; then
4062                 if $test x$thisincl != x$usrinc; then
4063                         case "$dflt" in
4064                         *$thisincl*);;
4065                         *) dflt="$dflt -I$thisincl";;
4066                         esac
4067                 fi
4068         fi
4069 done
4070
4071 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4072         xxx=true;
4073 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4074         xxx=true;
4075 else
4076         xxx=false;
4077 fi;
4078 if $xxx; then
4079         case "$dflt" in
4080         *$2*);;
4081         *) dflt="$dflt -D$2";;
4082         esac;
4083 fi'
4084
4085 set signal.h LANGUAGE_C; eval $inctest
4086
4087 case "$hint" in
4088 none|recommended) dflt="$ccflags $dflt" ;;
4089 *) dflt="$ccflags";;
4090 esac
4091
4092 case "$dflt" in
4093 ''|' ') dflt=none;;
4094 esac
4095 $cat <<EOH
4096
4097 Your C compiler may want other flags.  For this question you should include
4098 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4099 but you should NOT include libraries or ld flags like -lwhatever.  If you
4100 want $package to honor its debug switch, you should include -DDEBUGGING here.
4101 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4102
4103 To use no flags, specify the word "none".
4104
4105 EOH
4106 set X $dflt
4107 shift
4108 dflt=${1+"$@"}
4109 rp="Any additional cc flags?"
4110 . ./myread
4111 case "$ans" in
4112 none) ccflags='';;
4113 *) ccflags="$ans";;
4114 esac
4115
4116 : the following weeds options from ccflags that are of no interest to cpp
4117 cppflags="$ccflags"
4118 case "$gccversion" in
4119 1*) cppflags="$cppflags -D__GNUC__"
4120 esac
4121 case "$mips_type" in
4122 '');;
4123 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4124 esac
4125 case "$cppflags" in
4126 '');;
4127 *)
4128         echo " "
4129         echo "Let me guess what the preprocessor flags are..." >&4
4130         set X $cppflags
4131         shift
4132         cppflags=''
4133         $cat >cpp.c <<'EOM'
4134 #define BLURFL foo
4135
4136 BLURFL xx LFRULB
4137 EOM
4138         previous=''
4139         for flag in $*
4140         do
4141                 case "$flag" in
4142                 -*) ftry="$flag";;
4143                 *) ftry="$previous $flag";;
4144                 esac
4145                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4146                         >cpp1.out 2>/dev/null && \
4147                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4148                         >cpp2.out 2>/dev/null && \
4149                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4150                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4151                 then
4152                         cppflags="$cppflags $ftry"
4153                         previous=''
4154                 else
4155                         previous="$flag"
4156                 fi
4157         done
4158         set X $cppflags
4159         shift
4160         cppflags=${1+"$@"}
4161         case "$cppflags" in
4162         *-*)  echo "They appear to be: $cppflags";;
4163         esac
4164         $rm -f cpp.c cpp?.out
4165         ;;
4166 esac
4167
4168 : flags used in final linking phase
4169 case "$ldflags" in
4170 '') if ./venix; then
4171                 dflt='-i -z'
4172         else
4173                 dflt=''
4174         fi
4175         case "$ccflags" in
4176         *-posix*) dflt="$dflt -posix" ;;
4177         esac
4178         ;;
4179 *) dflt="$ldflags";;
4180 esac
4181
4182 : Try to guess additional flags to pick up local libraries.
4183 for thislibdir in $libpth; do
4184         case " $loclibpth " in
4185         *" $thislibdir "*)
4186                 case "$dflt " in 
4187                 *"-L$thislibdir "*) ;;
4188                 *)  dflt="$dflt -L$thislibdir" ;;
4189                 esac
4190                 ;;
4191         esac
4192 done
4193
4194 case "$dflt" in
4195 '') dflt='none' ;;
4196 esac
4197
4198 $cat <<EOH
4199
4200 Your C linker may need flags.  For this question you should
4201 include -L/whatever and any other flags used by the C linker, but you
4202 should NOT include libraries like -lwhatever.
4203
4204 Make sure you include the appropriate -L/path flags if your C linker
4205 does not normally search all of the directories you specified above,
4206 namely
4207         $libpth
4208 To use no flags, specify the word "none".
4209
4210 EOH
4211
4212 rp="Any additional ld flags (NOT including libraries)?"
4213 . ./myread
4214 case "$ans" in
4215 none) ldflags='';;
4216 *) ldflags="$ans";;
4217 esac
4218 rmlist="$rmlist pdp11"
4219
4220 : coherency check
4221 echo " "
4222 echo "Checking your choice of C compiler and flags for coherency..." >&4
4223 $cat > try.c <<'EOF'
4224 #include <stdio.h>
4225 int main() { printf("Ok\n"); exit(0); }
4226 EOF
4227 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4228 shift
4229 $cat >try.msg <<'EOM'
4230 I've tried to compile and run the following simple program:
4231
4232 EOM
4233 $cat try.c >> try.msg
4234
4235 $cat >> try.msg <<EOM
4236
4237 I used the command:
4238
4239         $*
4240         ./try
4241
4242 and I got the following output:
4243
4244 EOM
4245 dflt=y
4246 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4247         if sh -c './try' >>try.msg 2>&1; then
4248                 xxx=`./try`
4249                 case "$xxx" in
4250                 "Ok") dflt=n ;;
4251                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4252                         case " $libs " in
4253                         *" -lsfio "*)
4254                                 cat >> try.msg <<'EOQS'
4255 If $libs contains -lsfio, and sfio is mis-configured, then it
4256 sometimes (apparently) runs and exits with a 0 status, but with no
4257 output!  It may have to do with sfio's use of _exit vs. exit.
4258
4259 EOQS
4260                                 rp="You have a big problem.  Shall I abort Configure"
4261                                 dflt=y
4262                                 ;;
4263                         esac
4264                         ;;
4265                 esac
4266         else
4267                 echo "The program compiled OK, but exited with status $?." >>try.msg
4268                 rp="You have a problem.  Shall I abort Configure"
4269                 dflt=y
4270         fi
4271 else
4272         echo "I can't compile the test program." >>try.msg
4273         rp="You have a BIG problem.  Shall I abort Configure"
4274         dflt=y
4275 fi
4276 case "$dflt" in
4277 y)
4278         $cat try.msg >&4
4279         case "$knowitall" in
4280         '')
4281                 echo "(The supplied flags or libraries might be incorrect.)"
4282                 ;;
4283         *) dflt=n;;
4284         esac
4285         echo " "
4286         . ./myread
4287         case "$ans" in
4288         n*|N*) ;;
4289         *)      echo "Ok.  Stopping Configure." >&4
4290                 exit 1
4291                 ;;
4292         esac
4293         ;;
4294 n) echo "OK, that should do.";;
4295 esac
4296 $rm -f try try.* core
4297
4298 : determine filename position in cpp output
4299 echo " "
4300 echo "Computing filename position in cpp output for #include directives..." >&4
4301 echo '#include <stdio.h>' > foo.c
4302 $cat >fieldn <<EOF
4303 $startsh
4304 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4305 $grep '^[       ]*#.*stdio\.h' | \
4306 while read cline; do
4307         pos=1
4308         set \$cline
4309         while $test \$# -gt 0; do
4310                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4311                         echo "\$pos"
4312                         exit 0
4313                 fi
4314                 shift
4315                 pos=\`expr \$pos + 1\`
4316         done
4317 done
4318 EOF
4319 chmod +x fieldn
4320 fieldn=`./fieldn`
4321 $rm -f foo.c fieldn
4322 case $fieldn in
4323 '') pos='???';;
4324 1) pos=first;;
4325 2) pos=second;;
4326 3) pos=third;;
4327 *) pos="${fieldn}th";;
4328 esac
4329 echo "Your cpp writes the filename in the $pos field of the line."
4330
4331 : locate header file
4332 $cat >findhdr <<EOF
4333 $startsh
4334 wanted=\$1
4335 name=''
4336 if test -f $usrinc/\$wanted; then
4337         echo "$usrinc/\$wanted"
4338         exit 0
4339 fi
4340 awkprg='{ print \$$fieldn }'
4341 echo "#include <\$wanted>" > foo\$\$.c
4342 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4343 $grep "^[       ]*#.*\$wanted" | \
4344 while read cline; do
4345         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4346         case "\$name" in
4347         */\$wanted) echo "\$name"; exit 0;;
4348         *) name='';;
4349         esac;
4350 done;
4351 $rm -f foo\$\$.c;
4352 case "\$name" in
4353 '') exit 1;;
4354 esac
4355 EOF
4356 chmod +x findhdr
4357
4358 : define an alternate in-header-list? function
4359 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4360 cont=true; xxf="echo \"<\$1> found.\" >&4";
4361 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4362 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4363 esac;
4364 case $# in 4) instead=instead;; *) instead="at last";; esac;
4365 while $test "$cont"; do
4366         xxx=`./findhdr $1`
4367         var=$2; eval "was=\$$2";
4368         if $test "$xxx" && $test -r "$xxx";
4369         then eval $xxf;
4370         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4371                 cont="";
4372         else eval $xxnf;
4373         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4374         set $yyy; shift; shift; yyy=$@;
4375         case $# in 0) cont="";;
4376         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4377                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4378         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4379                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4380         esac;
4381 done;
4382 while $test "$yyy";
4383 do set $yyy; var=$2; eval "was=\$$2";
4384         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4385         set $yyy; shift; shift; yyy=$@;
4386 done'
4387
4388 : see if this is a malloc.h system
4389 set malloc.h i_malloc
4390 eval $inhdr
4391
4392 : see if stdlib is available
4393 set stdlib.h i_stdlib
4394 eval $inhdr
4395
4396 : determine which malloc to compile in
4397 echo " "
4398 case "$usemymalloc" in
4399 ''|[yY]*|true|$define)  dflt='y' ;;
4400 *)      dflt='n' ;;
4401 esac
4402 rp="Do you wish to attempt to use the malloc that comes with $package?"
4403 . ./myread
4404 usemymalloc="$ans"
4405 case "$ans" in
4406 y*|true)
4407         usemymalloc='y'
4408         mallocsrc='malloc.c'
4409         mallocobj="malloc$_o"
4410         d_mymalloc="$define"
4411         case "$libs" in
4412         *-lmalloc*)
4413                 : Remove malloc from list of libraries to use
4414                 echo "Removing unneeded -lmalloc from library list" >&4
4415                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4416                 shift
4417                 libs="$*"
4418                 echo "libs = $libs" >&4
4419                 ;;
4420         esac
4421         ;;
4422 *)
4423         usemymalloc='n'
4424         mallocsrc=''
4425         mallocobj=''
4426         d_mymalloc="$undef"
4427         ;;
4428 esac
4429
4430 : compute the return types of malloc and free
4431 echo " "
4432 $cat >malloc.c <<END
4433 #$i_malloc I_MALLOC
4434 #$i_stdlib I_STDLIB
4435 #include <stdio.h>
4436 #include <sys/types.h>
4437 #ifdef I_MALLOC
4438 #include <malloc.h>
4439 #endif
4440 #ifdef I_STDLIB
4441 #include <stdlib.h>
4442 #endif
4443 #ifdef TRY_MALLOC
4444 void *malloc();
4445 #endif
4446 #ifdef TRY_FREE
4447 void free();
4448 #endif
4449 END
4450 case "$malloctype" in
4451 '')
4452         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4453                 malloctype='void *'
4454         else
4455                 malloctype='char *'
4456         fi
4457         ;;
4458 esac
4459 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4460
4461 case "$freetype" in
4462 '')
4463         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4464                 freetype='void'
4465         else
4466                 freetype='int'
4467         fi
4468         ;;
4469 esac
4470 echo "Your system uses $freetype free(), it would seem." >&4
4471 $rm -f malloc.[co]
4472 : Cruising for prototypes
4473 echo " "
4474 echo "Checking out function prototypes..." >&4
4475 $cat >prototype.c <<'EOCP'
4476 int main(int argc, char *argv[]) {
4477         exit(0);}
4478 EOCP
4479 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4480         echo "Your C compiler appears to support function prototypes."
4481         val="$define"
4482 else
4483         echo "Your C compiler doesn't seem to understand function prototypes."
4484         val="$undef"
4485 fi
4486 set prototype
4487 eval $setvar
4488 $rm -f prototype*
4489
4490 case "$prototype" in
4491 "$define") ;;
4492 *)      ansi2knr='ansi2knr'
4493         echo " "
4494         cat <<EOM >&4
4495
4496 $me:  FATAL ERROR:
4497 This version of $package can only be compiled by a compiler that 
4498 understands function prototypes.  Unfortunately, your C compiler 
4499         $cc $ccflags
4500 doesn't seem to understand them.  Sorry about that.
4501
4502 If GNU cc is available for your system, perhaps you could try that instead.  
4503
4504 Eventually, we hope to support building Perl with pre-ANSI compilers.
4505 If you would like to help in that effort, please contact <perlbug@perl.org>.
4506
4507 Aborting Configure now.
4508 EOM
4509         exit 2
4510         ;;
4511 esac
4512
4513 : determine where public executables go
4514 echo " "
4515 set dflt bin bin
4516 eval $prefixit
4517 fn=d~
4518 rp='Pathname where the public executables will reside?'
4519 . ./getfile
4520 if $test "X$ansexp" != "X$binexp"; then
4521         installbin=''
4522 fi
4523 bin="$ans"
4524 binexp="$ansexp"
4525 if $afs; then
4526         $cat <<EOM
4527
4528 Since you are running AFS, I need to distinguish the directory in which
4529 executables reside from the directory in which they are installed (and from
4530 which they are presumably copied to the former directory by occult means).
4531
4532 EOM
4533         case "$installbin" in
4534         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4535         *) dflt="$installbin";;
4536         esac
4537         fn=de~
4538         rp='Where will public executables be installed?'
4539         . ./getfile
4540         installbin="$ans"
4541 else
4542         installbin="$binexp"
4543 fi
4544
4545 : determine whether to install perl also as /usr/bin/perl
4546
4547 echo " "
4548 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4549         $cat <<EOM
4550 Many scripts expect to perl to be installed as /usr/bin/perl.
4551 I can install the perl you are about to compile also as /usr/bin/perl
4552 (in addition to $installbin/perl).
4553 EOM
4554         case "$installusrbinperl" in
4555         "$undef"|[nN]*) dflt='n';;
4556         *)              dflt='y';;
4557         esac
4558         rp="Do you want to install perl as /usr/bin/perl?"
4559         . ./myread
4560         case "$ans" in
4561         [yY]*)  val="$define";;
4562         *)      val="$undef" ;;
4563         esac
4564 else
4565         val="$undef"
4566 fi
4567 set installusrbinperl
4568 eval $setvar
4569
4570 : define a shorthand compile call
4571 compile='
4572 mc_file=$1;
4573 shift;
4574 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4575 : define a shorthand compile call for compilations that should be ok.
4576 compile_ok='
4577 mc_file=$1;
4578 shift;
4579 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4580
4581 echo " "
4582 echo "Checking for GNU C Library..." >&4
4583 cat >gnulibc.c <<EOM
4584 #include <stdio.h>
4585 int main()
4586 {
4587 #ifdef __GLIBC__
4588     exit(0);
4589 #else
4590     exit(1);
4591 #endif
4592 }
4593 EOM
4594 set gnulibc
4595 if eval $compile_ok && ./gnulibc; then
4596         val="$define"
4597         echo "You are using the GNU C Library"
4598 else
4599         val="$undef"
4600         echo "You are not using the GNU C Library"
4601 fi
4602 $rm -f gnulibc*
4603 set d_gnulibc
4604 eval $setvar
4605
4606 : see if nm is to be used to determine whether a symbol is defined or not
4607 case "$usenm" in
4608 '')
4609         dflt=''
4610         case "$d_gnulibc" in
4611         "$define")
4612                 echo " "
4613                 echo "nm probably won't work on the GNU C Library." >&4
4614                 dflt=n
4615                 ;;
4616         esac
4617         case "$dflt" in
4618         '') 
4619                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4620                         echo " "
4621                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4622                         echo "'nm' won't be sufficient on this sytem." >&4
4623                         dflt=n
4624                 fi
4625                 ;;
4626         esac
4627         case "$dflt" in
4628         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4629                 if $test $dflt -gt 20; then
4630                         dflt=y
4631                 else
4632                         dflt=n
4633                 fi
4634                 ;;
4635         esac
4636         ;;
4637 *)
4638         case "$usenm" in
4639         true|$define) dflt=y;;
4640         *) dflt=n;;
4641         esac
4642         ;;
4643 esac
4644 $cat <<EOM
4645
4646 I can use $nm to extract the symbols from your C libraries. This
4647 is a time consuming task which may generate huge output on the disk (up
4648 to 3 megabytes) but that should make the symbols extraction faster. The
4649 alternative is to skip the 'nm' extraction part and to compile a small
4650 test program instead to determine whether each symbol is present. If
4651 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4652 this may be the best solution.
4653
4654 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4655
4656 EOM
4657 rp="Shall I use $nm to extract C symbols from the libraries?"
4658 . ./myread
4659 case "$ans" in
4660 [Nn]*) usenm=false;;
4661 *) usenm=true;;
4662 esac
4663
4664 runnm=$usenm
4665 case "$reuseval" in
4666 true) runnm=false;;
4667 esac
4668
4669 : nm options which may be necessary
4670 case "$nm_opt" in
4671 '') if $test -f /mach_boot; then
4672                 nm_opt=''       # Mach
4673         elif $test -d /usr/ccs/lib; then
4674                 nm_opt='-p'     # Solaris (and SunOS?)
4675         elif $test -f /dgux; then
4676                 nm_opt='-p'     # DG-UX
4677         elif $test -f /lib64/rld; then
4678                 nm_opt='-p'     # 64-bit Irix
4679         else
4680                 nm_opt=''
4681         fi;;
4682 esac
4683
4684 : nm options which may be necessary for shared libraries but illegal
4685 : for archive libraries.  Thank you, Linux.
4686 case "$nm_so_opt" in
4687 '')     case "$myuname" in
4688         *linux*)
4689                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4690                         nm_so_opt='--dynamic'
4691                 fi
4692                 ;;
4693         esac
4694         ;;
4695 esac
4696
4697 case "$runnm" in
4698 true)
4699 : get list of predefined functions in a handy place
4700 echo " "
4701 case "$libc" in
4702 '') libc=unknown
4703         case "$libs" in
4704         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4705         esac
4706         ;;
4707 esac
4708 libnames='';
4709 case "$libs" in
4710 '') ;;
4711 *)  for thislib in $libs; do
4712         case "$thislib" in
4713         -lc|-lc_s)
4714                 : Handle C library specially below.
4715                 ;;
4716         -l*)
4717                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4718                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4719                         :
4720                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4721                         :
4722                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4723                         :
4724                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4725                         :
4726                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4727                         :
4728                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4729                         :
4730                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4731                         :
4732                 else
4733                         try=''
4734                 fi
4735                 libnames="$libnames $try"
4736                 ;;
4737         *) libnames="$libnames $thislib" ;;
4738         esac
4739         done
4740         ;;
4741 esac
4742 xxx=normal
4743 case "$libc" in
4744 unknown)
4745         set /lib/libc.$so
4746         for xxx in $libpth; do
4747                 $test -r $1 || set $xxx/libc.$so
4748                 : The messy sed command sorts on library version numbers.
4749                 $test -r $1 || \
4750                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4751                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4752                                 h
4753                                 s/[0-9][0-9]*/0000&/g
4754                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4755                                 G
4756                                 s/\n/ /' | \
4757                          sort | $sed -e 's/^.* //'`
4758                 eval set \$$#
4759         done
4760         $test -r $1 || set /usr/ccs/lib/libc.$so
4761         $test -r $1 || set /lib/libsys_s$_a
4762         ;;
4763 *)
4764         set blurfl
4765         ;;
4766 esac
4767 if $test -r "$1"; then
4768         echo "Your (shared) C library seems to be in $1."
4769         libc="$1"
4770 elif $test -r /lib/libc && $test -r /lib/clib; then
4771         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4772         xxx=apollo
4773         libc='/lib/clib /lib/libc'
4774         if $test -r /lib/syslib; then
4775                 echo "(Your math library is in /lib/syslib.)"
4776                 libc="$libc /lib/syslib"
4777         fi
4778 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4779         echo "Your C library seems to be in $libc, as you said before."
4780 elif $test -r $incpath/usr/lib/libc$_a; then
4781         libc=$incpath/usr/lib/libc$_a;
4782         echo "Your C library seems to be in $libc.  That's fine."
4783 elif $test -r /lib/libc$_a; then
4784         libc=/lib/libc$_a;
4785         echo "Your C library seems to be in $libc.  You're normal."
4786 else
4787         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4788                 :
4789         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4790                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4791         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4792                 :
4793         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4794                 :
4795         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4796                 :
4797         else
4798                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4799         fi
4800         if $test -r "$tans"; then
4801                 echo "Your C library seems to be in $tans, of all places."
4802                 libc=$tans
4803         else
4804                 libc='blurfl'
4805         fi
4806 fi
4807 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4808         dflt="$libc"
4809         cat <<EOM
4810
4811 If the guess above is wrong (which it might be if you're using a strange
4812 compiler, or your machine supports multiple models), you can override it here.
4813
4814 EOM
4815 else
4816         dflt=''
4817         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4818         cat >&4 <<EOM
4819 I can't seem to find your C library.  I've looked in the following places:
4820
4821 EOM
4822         $sed 's/^/      /' libpath
4823         cat <<EOM
4824
4825 None of these seems to contain your C library. I need to get its name...
4826
4827 EOM
4828 fi
4829 fn=f
4830 rp='Where is your C library?'
4831 . ./getfile
4832 libc="$ans"
4833
4834 echo " "
4835 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4836 set X `cat libnames`
4837 shift
4838 xxx=files
4839 case $# in 1) xxx=file; esac
4840 echo "Extracting names from the following $xxx for later perusal:" >&4
4841 echo " "
4842 $sed 's/^/      /' libnames >&4
4843 echo " "
4844 $echo $n "This may take a while...$c" >&4
4845
4846 for file in $*; do
4847         case $file in
4848         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4849         *) $nm $nm_opt $file 2>/dev/null;;
4850         esac
4851 done >libc.tmp
4852
4853 $echo $n ".$c"
4854 $grep fprintf libc.tmp > libc.ptf
4855 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4856 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4857 xxx='[ADTSIW]'
4858 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4859         eval $xscan;\
4860         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4861                 eval $xrun
4862 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4863         eval $xscan;\
4864         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4865                 eval $xrun
4866 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4867         eval $xscan;\
4868         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4869                 eval $xrun
4870 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4871         eval $xscan;\
4872         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4873                 eval $xrun
4874 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4875         eval $xscan;\
4876         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4877                 eval $xrun
4878 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4879         eval $xscan;\
4880         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4881                 eval $xrun
4882 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4883                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4884         eval $xscan;\
4885         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4886                 eval $xrun
4887 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4888         eval $xscan;\
4889         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4890                 eval $xrun
4891 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4892         eval $xscan;\
4893         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4894                 eval $xrun
4895 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4896         eval $xscan;\
4897         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4898                 eval $xrun
4899 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4900         eval $xscan;\
4901         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4902                 eval $xrun
4903 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4904         eval $xscan;\
4905         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4906                 eval $xrun
4907 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4908         eval $xscan;\
4909         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4910                 eval $xrun
4911 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4912         eval $xscan;\
4913         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4914                 eval $xrun
4915 else
4916         $nm -p $* 2>/dev/null >libc.tmp
4917         $grep fprintf libc.tmp > libc.ptf
4918         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4919                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4920         then
4921                 nm_opt='-p'
4922                 eval $xrun
4923         else
4924                 echo " "
4925                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4926                 com=''
4927                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4928                         for thisname in $libnames $libc; do
4929                                 $ar t $thisname >>libc.tmp
4930                         done
4931                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4932                         echo "Ok." >&4
4933                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4934                         # Repeat libc to extract forwarders to DLL entries too
4935                         for thisname in $libnames $libc; do
4936                                 $ar tv $thisname >>libc.tmp
4937                                 # Revision 50 of EMX has bug in $ar.
4938                                 # it will not extract forwarders to DLL entries
4939                                 # Use emximp which will extract exactly them.
4940                                 emximp -o tmp.imp $thisname \
4941                                     2>/dev/null && \
4942                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4943                                     < tmp.imp >>libc.tmp
4944                                 $rm tmp.imp
4945                         done
4946                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
4947                         echo "Ok." >&4
4948                 else
4949                         echo "$ar didn't seem to work right." >&4
4950                         echo "Maybe this is a Cray...trying bld instead..." >&4
4951                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
4952                         then
4953                                 for thisname in $libnames; do
4954                                         bld t $libnames | \
4955                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
4956                                         $ar t $thisname >>libc.tmp
4957                                 done
4958                                 echo "Ok." >&4
4959                         else
4960                                 echo "That didn't work either.  Giving up." >&4
4961                                 exit 1
4962                         fi
4963                 fi
4964         fi
4965 fi
4966 nm_extract="$com"
4967 if $test -f /lib/syscalls.exp; then
4968         echo " "
4969         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
4970         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
4971 fi
4972 ;;
4973 esac
4974 $rm -f libnames libpath
4975
4976 : see if dld is available
4977 set dld.h i_dld
4978 eval $inhdr
4979
4980 : is a C symbol defined?
4981 csym='tlook=$1;
4982 case "$3" in
4983 -v) tf=libc.tmp; tc=""; tdc="";;
4984 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
4985 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
4986 esac;
4987 tx=yes;
4988 case "$reuseval-$4" in
4989 true-) ;;
4990 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
4991 esac;
4992 case "$tx" in
4993 yes)
4994         case "$runnm" in
4995         true)
4996                 if $contains $tlook $tf >/dev/null 2>&1;
4997                 then tval=true;
4998                 else tval=false;
4999                 fi;;
5000         *)
5001                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5002                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5003                 then tval=true;
5004                 else tval=false;
5005                 fi;
5006                 $rm -f t t.c;;
5007         esac;;
5008 *)
5009         case "$tval" in
5010         $define) tval=true;;
5011         *) tval=false;;
5012         esac;;
5013 esac;
5014 eval "$2=$tval"'
5015
5016 : define an is-in-libc? function
5017 inlibc='echo " "; td=$define; tu=$undef;
5018 sym=$1; var=$2; eval "was=\$$2";
5019 tx=yes;
5020 case "$reuseval$was" in
5021 true) ;;
5022 true*) tx=no;;
5023 esac;
5024 case "$tx" in
5025 yes)
5026         set $sym tres -f;
5027         eval $csym;
5028         case "$tres" in
5029         true)
5030                 echo "$sym() found." >&4;
5031                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5032         *)
5033                 echo "$sym() NOT found." >&4;
5034                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5035         esac;;
5036 *)
5037         case "$was" in
5038         $define) echo "$sym() found." >&4;;
5039         *) echo "$sym() NOT found." >&4;;
5040         esac;;
5041 esac'
5042
5043 : see if dlopen exists
5044 xxx_runnm="$runnm"
5045 runnm=false
5046 set dlopen d_dlopen
5047 eval $inlibc
5048 runnm="$xxx_runnm"
5049
5050 : determine which dynamic loading, if any, to compile in
5051 echo " "
5052 dldir="ext/DynaLoader"
5053 case "$usedl" in
5054 $define|y|true)
5055         dflt='y'
5056         usedl="$define"
5057         ;;
5058 $undef|n|false)
5059         dflt='n'
5060         usedl="$undef"
5061         ;;
5062 *) 
5063         dflt='n'
5064         case "$d_dlopen" in
5065             $define) dflt='y' ;;
5066         esac
5067         case "$i_dld" in
5068             $define) dflt='y' ;;
5069         esac
5070         : Does a dl_xxx.xs file exist for this operating system
5071         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5072         ;;
5073 esac
5074 rp="Do you wish to use dynamic loading?"
5075 . ./myread
5076 usedl="$ans"
5077 case "$ans" in
5078 y*) usedl="$define"
5079         case "$dlsrc" in
5080         '')
5081                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5082                         dflt="$dldir/dl_${osname}.xs"
5083                 elif $test "$d_dlopen" = "$define" ; then
5084                         dflt="$dldir/dl_dlopen.xs"
5085                 elif $test "$i_dld" = "$define" ; then
5086                         dflt="$dldir/dl_dld.xs"
5087                 else
5088                         dflt=''
5089                 fi
5090                 ;;
5091         *)      dflt="$dldir/$dlsrc"
5092                 ;;
5093         esac
5094     echo "The following dynamic loading files are available:"
5095         : Can not go over to $dldir because getfile has path hard-coded in.
5096         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5097         rp="Source file to use for dynamic loading"
5098         fn="fne"
5099         # XXX This getfile call will fail the existence check if you try 
5100         # building away from $src (this is not supported yet).
5101         . ./getfile
5102         usedl="$define"
5103         : emulate basename
5104         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5105
5106         $cat << EOM
5107
5108 Some systems may require passing special flags to $cc -c to
5109 compile modules that will be used to create a shared library.
5110 To use no flags, say "none".
5111
5112 EOM
5113     case "$cccdlflags" in
5114     '') case "$gccversion" in
5115                 '') case "$osname" in
5116                         hpux)   dflt='+z' ;;
5117                         next)   dflt='none' ;;
5118                         irix*)  dflt='-KPIC' ;;
5119                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5120                         sunos)  dflt='-pic' ;;
5121                         *)      dflt='none' ;;
5122                     esac
5123                         ;;
5124                 *)  case "$osname" in
5125                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5126                         *)      dflt='-fpic' ;;
5127                     esac ;;
5128             esac ;;
5129         ' ') dflt='none' ;;
5130     *)  dflt="$cccdlflags" ;;
5131     esac
5132     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5133     . ./myread
5134     case "$ans" in
5135     none) cccdlflags=' ' ;;
5136     *) cccdlflags="$ans" ;;
5137     esac
5138
5139     cat << EOM
5140
5141 Some systems use ld to create libraries that can be dynamically loaded,
5142 while other systems (such as those using ELF) use $cc.
5143
5144 EOM
5145         case "$ld" in
5146         '')     $cat >try.c <<'EOM'
5147 /* Test for whether ELF binaries are produced */
5148 #include <fcntl.h>
5149 #include <stdlib.h>
5150 int main() {
5151         char b[4];
5152         int i = open("a.out",O_RDONLY);
5153         if(i == -1) 
5154                 exit(1); /* fail */
5155         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5156                 exit(0); /* succeed (yes, it's ELF) */
5157         else
5158                 exit(1); /* fail */
5159 }
5160 EOM
5161                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5162                         cat <<EOM
5163 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5164 EOM
5165                         dflt="$cc"
5166                 else
5167                         echo "I'll use ld to build dynamic libraries."
5168                         dflt='ld'
5169                 fi
5170                 rm -f try.c a.out
5171                 ;;
5172         *)      dflt="$ld"
5173                 ;;
5174         esac
5175
5176     rp="What command should be used to create dynamic libraries?"
5177     . ./myread
5178         ld="$ans"
5179
5180     cat << EOM
5181
5182 Some systems may require passing special flags to $ld to create a
5183 library that can be dynamically loaded.  If your ld flags include
5184 -L/other/path options to locate libraries outside your loader's normal
5185 search path, you may need to specify those -L options here as well.  To
5186 use no flags, say "none".
5187
5188 EOM
5189     case "$lddlflags" in
5190     '') case "$osname" in
5191                         beos) dflt='-nostart' ;;
5192                         hpux)  dflt='-b' ;;
5193                         linux|irix*)    dflt='-shared' ;;
5194                         next)  dflt='none' ;;
5195                         solaris) dflt='-G' ;;
5196                         sunos) dflt='-assert nodefinitions' ;;
5197                         svr4*|esix*) dflt="-G $ldflags" ;;
5198                 *)     dflt='none' ;;
5199                         esac
5200                         ;;
5201     *) dflt="$lddlflags" ;;
5202     esac
5203
5204         : Try to guess additional flags to pick up local libraries.
5205         : Be careful not to append to a plain 'none'
5206         case "$dflt" in
5207         none) dflt='' ;;
5208         esac
5209         for thisflag in $ldflags; do
5210                 case "$thisflag" in
5211                 -L*)
5212                         case " $dflt " in
5213                         *" $thisflag "*) ;;
5214                         *) dflt="$dflt $thisflag" ;;
5215                         esac
5216                         ;;
5217                 esac
5218         done
5219
5220         case "$dflt" in
5221         ''|' ') dflt='none' ;;
5222         esac
5223
5224     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5225     . ./myread
5226     case "$ans" in
5227     none) lddlflags=' ' ;;
5228     *) lddlflags="$ans" ;;
5229     esac
5230
5231         cat <<EOM
5232
5233 Some systems may require passing special flags to $cc to indicate that
5234 the resulting executable will use dynamic linking.  To use no flags,
5235 say "none".
5236
5237 EOM
5238     case "$ccdlflags" in
5239     '') case "$osname" in
5240                 hpux)   dflt='-Wl,-E' ;;
5241                 linux)  dflt='-rdynamic' ;;
5242                 next)   dflt='none' ;;
5243                 sunos)  dflt='none' ;;
5244                 *)      dflt='none' ;;
5245             esac ;;
5246     ' ')  dflt='none' ;;
5247     *)  dflt="$ccdlflags" ;;
5248     esac
5249     rp="Any special flags to pass to $cc to use dynamic loading?"
5250     . ./myread
5251     case "$ans" in
5252     none) ccdlflags=' ' ;;
5253     *) ccdlflags="$ans" ;;
5254     esac
5255     ;;
5256 *)  usedl="$undef"
5257         ld='ld'
5258     dlsrc='dl_none.xs'
5259     lddlflags=''
5260     ccdlflags=''
5261     ;;
5262 esac
5263
5264 also=''
5265 case "$usedl" in
5266 $undef)
5267         # No dynamic loading being used, so don't bother even to prompt.
5268         useshrplib='false'
5269         ;;
5270 *)      case "$useshrplib" in
5271         '')     case "$osname" in
5272                 svr4*|dgux|dynixptx|esix|powerux|beos)
5273                         dflt=y
5274                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5275                         ;;
5276                 next*)
5277                         case "$osvers" in
5278                         4*)     dflt=y
5279                                 also='Building a shared libperl is needed for MAB support.'
5280                                 ;;
5281                         *)      dflt=n
5282                                 ;;
5283                         esac
5284                         ;;
5285                 *)      dflt=n
5286                         ;;
5287                 esac
5288                 ;;
5289         $define|true|[Yy]*)
5290                 dflt=y
5291                 ;;
5292         *)      dflt=n
5293                 ;;
5294         esac
5295         $cat << EOM
5296
5297 The perl executable is normally obtained by linking perlmain.c with
5298 libperl${_a}, any static extensions (usually just DynaLoader), and
5299 any other libraries needed on this system (such as -lm, etc.).  Since
5300 your system supports dynamic loading, it is probably possible to build
5301 a shared libperl.$so.  If you will have more than one executable linked
5302 to libperl.$so, this will significantly reduce the size of each
5303 executable, but it may have a noticeable affect on performance.  The
5304 default is probably sensible for your system.
5305 $also
5306
5307 EOM
5308         rp="Build a shared libperl.$so (y/n)"
5309         . ./myread
5310         case "$ans" in
5311         true|$define|[Yy]*)
5312                 useshrplib='true'
5313                 # Why does next4 have to be so different?
5314                 case "${osname}${osvers}" in
5315                 next4*) xxx='DYLD_LIBRARY_PATH' ;;
5316                 os2*)   xxx='' ;; # Nothing special needed.
5317                 beos*)  xxx='' ;;
5318                 *)              xxx='LD_LIBRARY_PATH' ;;
5319                 esac
5320                 if test X"$xxx" != "X"; then
5321                         $cat <<EOM  | $tee -a ../config.msg >&4
5322
5323 To build perl, you must add the current working directory to your
5324 $xxx environment variable before running make.  You can do
5325 this with
5326    $xxx=\`pwd\`:\$$xxx; export $xxx
5327 for Bourne-style shells, or
5328    setenv $xxx \`pwd\`
5329 for Csh-style shells.  You *MUST* do this before running make.
5330
5331 EOM
5332                 fi
5333                 ;;
5334         *)      useshrplib='false' ;;
5335         esac
5336         ;;
5337 esac
5338
5339 case "$useshrplib" in
5340 true)
5341         case "$libperl" in
5342         '')
5343                 # Figure out a good name for libperl.so.  Since it gets stored in
5344                 # a version-specific architecture-dependent library, the version
5345                 # number isn't really that important, except for making cc/ld happy.
5346                 #
5347                 # A name such as libperl.so.3.1
5348                 majmin="libperl.$so.$patchlevel.$subversion"
5349                 # A name such as libperl.so.301
5350                 majonly=`echo $patchlevel $subversion |
5351                         $awk '{printf "%d%02d", $1, $2}'`
5352                 majonly=libperl.$so.$majonly
5353                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5354                 # rely on figuring it out from the naming of libc.
5355                 case "${osname}${osvers}" in
5356                 next4*)
5357                         dflt=libperl.5.$so
5358                         # XXX How handle the --version stuff for MAB?
5359                         ;;
5360                 linux*)  # ld won't link with a bare -lperl otherwise.
5361                         dflt=libperl.$so
5362                         ;;
5363                 *)      # Try to guess based on whether libc has major.minor.
5364                         case "$libc" in
5365                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5366                         *libc.$so.[0-9]*) dflt=$majonly ;;
5367                         *)      dflt=libperl.$so ;;
5368                         esac
5369                         ;;
5370                 esac
5371                 ;;
5372         *)      dflt=$libperl
5373                 ;;
5374         esac
5375         cat << EOM
5376
5377 I need to select a good name for the shared libperl.  If your system uses
5378 library names with major and minor numbers, then you might want something
5379 like $majmin.  Alternatively, if your system uses a single version
5380 number for shared libraries, then you might want to use $majonly.
5381 Or, your system might be quite happy with a simple libperl.$so.
5382
5383 Since the shared libperl will get installed into a version-specific
5384 architecture-dependent directory, the version number of the shared perl
5385 library probably isn't important, so the default should be o.k.
5386
5387 EOM
5388         rp='What name do you want to give to the shared libperl?'
5389         . ./myread
5390         libperl=$ans
5391         echo "Ok, I'll use $libperl"
5392         ;;
5393 *)
5394         libperl="libperl${_a}"
5395         ;;
5396 esac
5397
5398 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5399 case "$shrpdir" in
5400 '') ;;
5401 *)      $cat >&4 <<EOM
5402 WARNING:  Use of the shrpdir variable for the installation location of
5403 the shared $libperl is not supported.  It was never documented and
5404 will not work in this version.  Let me (perlbug@perl.com)
5405 know of any problems this may cause.
5406
5407 EOM
5408         case "$shrpdir" in
5409         "$archlibexp/CORE")
5410                 $cat >&4 <<EOM
5411 But your current setting of $shrpdir is
5412 the default anyway, so it's harmless.
5413 EOM
5414                 ;;
5415         *)
5416                 $cat >&4 <<EOM
5417 Further, your current attempted setting of $shrpdir
5418 conflicts with the value of $archlibexp/CORE
5419 that installperl will use.
5420 EOM
5421                 ;;
5422         esac
5423         ;;
5424 esac
5425
5426 # How will the perl executable find the installed shared $libperl?
5427 # Add $xxx to ccdlflags.
5428 # If we can't figure out a command-line option, use $shrpenv to
5429 # set env LD_RUN_PATH.  The main perl makefile uses this.
5430 shrpdir=$archlibexp/CORE
5431 xxx=''
5432 tmp_shrpenv=''
5433 if "$useshrplib"; then
5434     case "$osname" in 
5435         aix)
5436                 # We'll set it in Makefile.SH...
5437                 ;;
5438         solaris|netbsd)
5439                 xxx="-R $shrpdir"
5440                 ;;
5441         freebsd)
5442                 xxx="-Wl,-R$shrpdir"
5443                 ;;
5444         linux|irix*|dec_osf)
5445                 xxx="-Wl,-rpath,$shrpdir"
5446                 ;;
5447         next)
5448                 # next doesn't like the default...
5449                 ;;
5450         beos)
5451                 # beos doesn't like the default, either.
5452                 ;;
5453         *)
5454                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5455                 ;;
5456         esac
5457         case "$xxx" in
5458         '') ;;
5459         *)      
5460                 # Only add $xxx if it isn't already in ccdlflags.
5461                 case " $ccdlflags " in
5462                 *" $xxx "*)     ;;
5463                 *)      ccdlflags="$ccdlflags $xxx"
5464                         cat <<EOM >&4
5465
5466 Adding $xxx to the flags
5467 passed to $ld so that the perl executable will find the 
5468 installed shared $libperl.
5469
5470 EOM
5471                         ;;
5472                 esac
5473                 ;;
5474         esac
5475 fi
5476 # Respect a hint or command-line value.
5477 case "$shrpenv" in
5478 '') shrpenv="$tmp_shrpenv" ;;
5479 esac
5480
5481 : determine where manual pages go
5482 set man1dir man1dir none
5483 eval $prefixit
5484 $cat <<EOM
5485
5486 $spackage has manual pages available in source form.
5487 EOM
5488 case "$nroff" in
5489 nroff)
5490         echo "However, you don't have nroff, so they're probably useless to you."
5491         case "$man1dir" in
5492         '') man1dir="none";;
5493         esac;;
5494 esac
5495 echo "If you don't want the manual sources installed, answer 'none'."
5496 case "$man1dir" in
5497 ' ') dflt=none
5498         ;;
5499 '')
5500         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5501         lookpath="$lookpath $prefixexp/man/p_man/man1"
5502         lookpath="$lookpath $prefixexp/man/u_man/man1"
5503         lookpath="$lookpath $prefixexp/man/man.1"
5504         case "$sysman" in
5505         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5506         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5507         esac
5508         set dflt
5509         eval $prefixup
5510         ;;
5511 *)  dflt="$man1dir"
5512         ;;
5513 esac
5514 echo " "
5515 fn=dn+~
5516 rp="Where do the main $spackage manual pages (source) go?"
5517 . ./getfile
5518 if $test "X$man1direxp" != "X$ansexp"; then
5519         installman1dir=''
5520 fi
5521 man1dir="$ans"
5522 man1direxp="$ansexp"
5523 case "$man1dir" in
5524 '') man1dir=' '
5525         installman1dir='';;
5526 esac
5527 if $afs; then
5528         $cat <<EOM
5529
5530 Since you are running AFS, I need to distinguish the directory in which
5531 manual pages reside from the directory in which they are installed (and from
5532 which they are presumably copied to the former directory by occult means).
5533
5534 EOM
5535         case "$installman1dir" in
5536         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5537         *) dflt="$installman1dir";;
5538         esac
5539         fn=de~
5540         rp='Where will man pages be installed?'
5541         . ./getfile
5542         installman1dir="$ans"
5543 else
5544         installman1dir="$man1direxp"
5545 fi
5546
5547 : What suffix to use on installed man pages
5548
5549 case "$man1dir" in
5550 ' ')
5551         man1ext='0'
5552         ;;
5553 *)
5554         rp="What suffix should be used for the main $spackage man pages?"
5555         case "$man1ext" in
5556         '')     case "$man1dir" in
5557                 *1)  dflt=1 ;;
5558                 *1p) dflt=1p ;;
5559                 *1pm) dflt=1pm ;;
5560                 *l) dflt=l;;
5561                 *n) dflt=n;;
5562                 *o) dflt=o;;
5563                 *p) dflt=p;;
5564                 *C) dflt=C;;
5565                 *L) dflt=L;;
5566                 *L1) dflt=L1;;
5567                 *) dflt=1;;
5568                 esac
5569                 ;;
5570         *)      dflt="$man1ext";;
5571         esac
5572         . ./myread
5573         man1ext="$ans"
5574         ;;
5575 esac
5576
5577 : see if we can have long filenames
5578 echo " "
5579 rmlist="$rmlist /tmp/cf$$"
5580 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5581 first=123456789abcdef
5582 second=/tmp/cf$$/$first
5583 $rm -f $first $second
5584 if (echo hi >$first) 2>/dev/null; then
5585         if $test -f 123456789abcde; then
5586                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5587                 val="$undef"
5588         else
5589                 if (echo hi >$second) 2>/dev/null; then
5590                         if $test -f /tmp/cf$$/123456789abcde; then
5591                                 $cat <<'EOM'
5592 That's peculiar... You can have filenames longer than 14 characters, but only
5593 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5594 I shall consider your system cannot support long filenames at all.
5595 EOM
5596                                 val="$undef"
5597                         else
5598                                 echo 'You can have filenames longer than 14 characters.' >&4
5599                                 val="$define"
5600                         fi
5601                 else
5602                         $cat <<'EOM'
5603 How confusing! Some of your filesystems are sane enough to allow filenames
5604 longer than 14 characters but some others like /tmp can't even think about them.
5605 So, for now on, I shall assume your kernel does not allow them at all.
5606 EOM
5607                         val="$undef"
5608                 fi
5609         fi
5610 else
5611         $cat <<'EOM'
5612 You can't have filenames longer than 14 chars.  You can't even think about them!
5613 EOM
5614         val="$undef"
5615 fi 
5616 set d_flexfnam
5617 eval $setvar
5618 $rm -rf /tmp/cf$$ 123456789abcde*
5619
5620 : determine where library module manual pages go
5621 set man3dir man3dir none
5622 eval $prefixit
5623 $cat <<EOM
5624
5625 $spackage has manual pages for many of the library modules.
5626 EOM
5627
5628 case "$nroff" in
5629 nroff)
5630         $cat <<'EOM'
5631 However, you don't have nroff, so they're probably useless to you.
5632 EOM
5633         case "$man3dir" in
5634         '') man3dir="none";;
5635         esac;;
5636 esac
5637
5638 case "$d_flexfnam" in
5639 undef)
5640         $cat <<'EOM'
5641 However, your system can't handle the long file names like File::Basename.3. 
5642 EOM
5643         case "$man3dir" in
5644         '') man3dir="none";;
5645         esac;;
5646 esac
5647
5648 echo "If you don't want the manual sources installed, answer 'none'."
5649 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5650 case "$man3dir" in
5651 '')     case "$prefix" in 
5652         *$prog*) dflt=`echo $man1dir | 
5653                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5654         *)      dflt="$privlib/man/man3" ;;
5655         esac
5656         ;;
5657 ' ') dflt=none;;
5658 *)      dflt="$man3dir" ;;
5659 esac
5660 echo " "
5661
5662 fn=dn+~
5663 rp="Where do the $package library man pages (source) go?"
5664 . ./getfile
5665 if test "X$man3direxp" != "X$ansexp"; then
5666         installman3dir=''
5667 fi
5668
5669 man3dir="$ans"
5670 man3direxp="$ansexp"
5671 case "$man3dir" in
5672 '') man3dir=' '
5673         installman3dir='';;
5674 esac
5675 if $afs; then
5676         $cat <<EOM
5677
5678 Since you are running AFS, I need to distinguish the directory in which
5679 manual pages reside from the directory in which they are installed (and from
5680 which they are presumably copied to the former directory by occult means).
5681
5682 EOM
5683         case "$installman3dir" in
5684         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5685         *) dflt="$installman3dir";;
5686         esac
5687         fn=de~
5688         rp='Where will man pages be installed?'
5689         . ./getfile
5690         installman3dir="$ans"
5691 else
5692         installman3dir="$man3direxp"
5693 fi
5694
5695 : What suffix to use on installed man pages
5696
5697 case "$man3dir" in
5698 ' ')
5699         man3ext='0'
5700         ;;
5701 *)
5702         rp="What suffix should be used for the $package library man pages?"
5703         case "$man3ext" in
5704         '')     case "$man3dir" in
5705                 *3)  dflt=3 ;;
5706                 *3p) dflt=3p ;;
5707                 *3pm) dflt=3pm ;;
5708                 *l) dflt=l;;
5709                 *n) dflt=n;;
5710                 *o) dflt=o;;
5711                 *p) dflt=p;;
5712                 *C) dflt=C;;
5713                 *L) dflt=L;;
5714                 *L3) dflt=L3;;
5715                 *) dflt=3;;
5716                 esac
5717                 ;;
5718         *)      dflt="$man3ext";;
5719         esac
5720         . ./myread
5721         man3ext="$ans"
5722         ;;
5723 esac
5724
5725 : see if we have to deal with yellow pages, now NIS.
5726 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5727         if $test -f /usr/etc/nibindd; then
5728                 echo " "
5729                 echo "I'm fairly confident you're on a NeXT."
5730                 echo " "
5731                 rp='Do you get the hosts file via NetInfo?'
5732                 dflt=y
5733                 case "$hostcat" in
5734                 nidump*) ;;
5735                 '') ;;
5736                 *) dflt=n;;
5737                 esac
5738                 . ./myread
5739                 case "$ans" in
5740                 y*) hostcat='nidump hosts .';;
5741                 *)      case "$hostcat" in
5742                         nidump*) hostcat='';;
5743                         esac
5744                         ;;
5745                 esac
5746         fi
5747         case "$hostcat" in
5748         nidump*) ;;
5749         *)
5750                 case "$hostcat" in
5751                 *ypcat*) dflt=y;;
5752                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5753                                 dflt=y
5754                         else
5755                                 dflt=n
5756                         fi;;
5757                 *) dflt=n;;
5758                 esac
5759                 echo " "
5760                 rp='Are you getting the hosts file via yellow pages?'
5761                 . ./myread
5762                 case "$ans" in
5763                 y*) hostcat='ypcat hosts';;
5764                 *) hostcat='cat /etc/hosts';;
5765                 esac
5766                 ;;
5767         esac
5768 fi
5769 case "$hostcat" in
5770 '') hostcat='cat /etc/hosts';;
5771 esac
5772 case "$groupcat" in
5773 '') groupcat='cat /etc/group';;
5774 esac
5775 case "$passcat" in
5776 '') passcat='cat /etc/passwd';;
5777 esac
5778
5779 : now get the host name
5780 echo " "
5781 echo "Figuring out host name..." >&4
5782 case "$myhostname" in
5783 '') cont=true
5784         echo 'Maybe "hostname" will work...'
5785         if tans=`sh -c hostname 2>&1` ; then
5786                 myhostname=$tans
5787                 phostname=hostname
5788                 cont=''
5789         fi
5790         ;;
5791 *) cont='';;
5792 esac
5793 if $test "$cont"; then
5794         if ./xenix; then
5795                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5796                 if tans=`cat /etc/systemid 2>&1` ; then
5797                         myhostname=$tans
5798                         phostname='cat /etc/systemid'
5799                         echo "Whadyaknow.  Xenix always was a bit strange..."
5800                         cont=''
5801                 fi
5802         elif $test -r /etc/systemid; then
5803                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5804         fi
5805 fi
5806 if $test "$cont"; then
5807         echo 'No, maybe "uuname -l" will work...'
5808         if tans=`sh -c 'uuname -l' 2>&1` ; then
5809                 myhostname=$tans
5810                 phostname='uuname -l'
5811         else
5812                 echo 'Strange.  Maybe "uname -n" will work...'
5813                 if tans=`sh -c 'uname -n' 2>&1` ; then
5814                         myhostname=$tans
5815                         phostname='uname -n'
5816                 else
5817                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5818                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5819                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5820                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5821                         else
5822                                 case "$myhostname" in
5823                                 '') echo "Does this machine have an identity crisis or something?"
5824                                         phostname='';;
5825                                 *)
5826                                         echo "Well, you said $myhostname before..."
5827                                         phostname='echo $myhostname';;
5828                                 esac
5829                         fi
5830                 fi
5831         fi
5832 fi
5833 : you do not want to know about this
5834 set $myhostname
5835 myhostname=$1
5836
5837 : verify guess
5838 if $test "$myhostname" ; then
5839         dflt=y
5840         rp='Your host name appears to be "'$myhostname'".'" Right?"
5841         . ./myread
5842         case "$ans" in
5843         y*) ;;
5844         *) myhostname='';;
5845         esac
5846 fi
5847
5848 : bad guess or no guess
5849 while $test "X$myhostname" = X ; do
5850         dflt=''
5851         rp="Please type the (one word) name of your host:"
5852         . ./myread
5853         myhostname="$ans"
5854 done
5855
5856 : translate upper to lower if necessary
5857 case "$myhostname" in
5858 *[A-Z]*)
5859         echo "(Normalizing case in your host name)"
5860         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5861         ;;
5862 esac
5863
5864 case "$myhostname" in
5865 *.*)
5866         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5867         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5868         echo "(Trimming domain name from host name--host name is now $myhostname)"
5869         ;;
5870 *) case "$mydomain" in
5871         '')
5872                 {
5873                         test "X$hostcat" = "Xypcat hosts" &&
5874                         ypmatch "$myhostname" hosts 2>/dev/null |\
5875                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5876                         $test -s hosts
5877                 } || {
5878                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5879                                         /[       ]$myhostname[  . ]/p" > hosts
5880                 }
5881                 tmp_re="[       . ]"
5882                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5883                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5884                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5885                         hosts | $sort | $uniq | \
5886                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5887                 case `$echo X$dflt` in
5888                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5889                         dflt=.
5890                         ;;
5891                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5892                         ;;
5893                 esac
5894                 case "$dflt" in
5895                 .)
5896                         tans=`./loc resolv.conf X /etc /usr/etc`
5897                         if $test -f "$tans"; then
5898                                 echo "(Attempting domain name extraction from $tans)"
5899                                 dflt=.`$sed -n -e 's/   / /g' \
5900                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5901                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5902                                 case "$dflt" in
5903                                 .) dflt=.`$sed -n -e 's/        / /g' \
5904                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5905                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5906                                         ;;
5907                                 esac
5908                         fi
5909                         ;;
5910                 esac
5911                 case "$dflt" in
5912                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5913                         dflt=.`sh -c domainname 2>/dev/null`
5914                         case "$dflt" in
5915                         '') dflt='.';;
5916                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5917                         esac
5918                         ;;
5919                 esac
5920                 case "$dflt" in
5921                 .) echo "(Lost all hope -- silly guess then)"
5922                         dflt='.uucp'
5923                         ;;
5924                 esac
5925                 $rm -f hosts
5926                 ;;
5927         *) dflt="$mydomain";;
5928         esac;;
5929 esac
5930 echo " "
5931 rp="What is your domain name?"
5932 . ./myread
5933 tans="$ans"
5934 case "$ans" in
5935 '') ;;
5936 .*) ;;
5937 *) tans=".$tans";;
5938 esac
5939 mydomain="$tans"
5940
5941 : translate upper to lower if necessary
5942 case "$mydomain" in
5943 *[A-Z]*)
5944         echo "(Normalizing case in your domain name)"
5945         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5946         ;;
5947 esac
5948
5949 : a little sanity check here
5950 case "$phostname" in
5951 '') ;;
5952 *)
5953         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
5954         $myhostname$mydomain|$myhostname) ;;
5955         *)
5956                 case "$phostname" in
5957                 sed*)
5958                         echo "(That doesn't agree with your whoami.h file, by the way.)"
5959                         ;;
5960                 *)
5961                         echo "(That doesn't agree with your $phostname command, by the way.)"
5962                         ;;
5963                 esac
5964         ;;
5965         esac
5966         ;;
5967 esac
5968
5969 $cat <<EOM
5970
5971 I need to get your e-mail address in Internet format if possible, i.e.
5972 something like user@host.domain. Please answer accurately since I have
5973 no easy means to double check it. The default value provided below
5974 is most probably close to the reality but may not be valid from outside
5975 your organization...
5976
5977 EOM
5978 cont=x
5979 while test "$cont"; do
5980         case "$cf_email" in
5981         '') dflt="$cf_by@$myhostname$mydomain";;
5982         *) dflt="$cf_email";;
5983         esac
5984         rp='What is your e-mail address?'
5985         . ./myread
5986         cf_email="$ans"
5987         case "$cf_email" in
5988         *@*.*) cont='' ;;
5989         *)
5990                 rp='Address does not look like an Internet one.  Use it anyway?'
5991                 case "$fastread" in
5992                 yes) dflt=y ;;
5993                 *) dflt=n ;;
5994                 esac
5995                 . ./myread
5996                 case "$ans" in
5997                 y*) cont='' ;;
5998                 *) echo " " ;;
5999                 esac
6000                 ;;
6001         esac
6002 done
6003
6004 $cat <<EOM
6005
6006 If you or somebody else will be maintaining perl at your site, please
6007 fill in the correct e-mail address here so that they may be contacted
6008 if necessary. Currently, the "perlbug" program included with perl
6009 will send mail to this address in addition to perlbug@perl.com. You may
6010 enter "none" for no administrator.
6011
6012 EOM
6013 case "$perladmin" in
6014 '') dflt="$cf_email";;
6015 *) dflt="$perladmin";;
6016 esac
6017 rp='Perl administrator e-mail address'
6018 . ./myread
6019 perladmin="$ans"
6020
6021 : figure out how to guarantee perl startup
6022 case "$startperl" in
6023 '')
6024         case "$sharpbang" in
6025         *!)
6026                 $cat <<EOH
6027
6028 I can use the #! construct to start perl on your system. This will
6029 make startup of perl scripts faster, but may cause problems if you
6030 want to share those scripts and perl is not in a standard place
6031 ($binexp/perl) on all your platforms. The alternative is to force
6032 a shell by starting the script with a single ':' character.
6033
6034 EOH
6035                 dflt="$binexp/perl"
6036                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6037                 . ./myread
6038                 case "$ans" in
6039                 none)   startperl=": # use perl";;
6040                 *)      startperl="#!$ans"
6041                         if $test 30 -lt `echo "$ans" | wc -c`; then
6042                                 $cat >&4 <<EOM
6043
6044 WARNING:  Some systems limit the #! command to 32 characters.
6045 If you experience difficulty running Perl scripts with #!, try
6046 installing Perl in a directory with a shorter pathname.
6047
6048 EOM
6049                         fi ;;
6050                 esac
6051                 ;;
6052         *) startperl=": # use perl"
6053                 ;;
6054         esac
6055         ;;
6056 esac
6057 echo "I'll use $startperl to start perl scripts."
6058
6059 : figure best path for perl in scripts
6060 case "$perlpath" in
6061 '')
6062         perlpath="$binexp/perl"
6063         case "$startperl" in
6064         *!*) ;;
6065         *)
6066                 $cat <<EOH
6067
6068 I will use the "eval 'exec'" idiom to start Perl on your system.
6069 I can use the full path of your Perl binary for this purpose, but
6070 doing so may cause problems if you want to share those scripts and
6071 Perl is not always in a standard place ($binexp/perl).
6072
6073 EOH
6074                 dflt="$binexp/perl"
6075                 rp="What path shall I use in \"eval 'exec'\"?"
6076                 . ./myread
6077                 perlpath="$ans"
6078                 ;;
6079         esac
6080         ;;
6081 esac
6082 case "$startperl" in
6083 *!*)    ;;
6084 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6085 esac
6086
6087 : determine where public executable scripts go
6088 set scriptdir scriptdir
6089 eval $prefixit
6090 case "$scriptdir" in
6091 '')
6092         dflt="$bin"
6093         : guess some guesses
6094         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6095         $test -d /usr/share/bin && dflt=/usr/share/bin
6096         $test -d /usr/local/script && dflt=/usr/local/script
6097         $test -d $prefixexp/script && dflt=$prefixexp/script
6098         set dflt
6099         eval $prefixup
6100         ;;
6101 *)  dflt="$scriptdir"
6102         ;;
6103 esac
6104 $cat <<EOM
6105  
6106 Some installations have a separate directory just for executable scripts so
6107 that they can mount it across multiple architectures but keep the scripts in
6108 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6109 Or you might just lump your scripts in with all your other executables.
6110  
6111 EOM
6112 fn=d~
6113 rp='Where do you keep publicly executable scripts?'
6114 . ./getfile
6115 if $test "X$ansexp" != "X$scriptdirexp"; then
6116         installscript=''
6117 fi
6118 scriptdir="$ans"
6119 scriptdirexp="$ansexp"
6120 if $afs; then
6121         $cat <<EOM
6122
6123 Since you are running AFS, I need to distinguish the directory in which
6124 scripts reside from the directory in which they are installed (and from
6125 which they are presumably copied to the former directory by occult means).
6126
6127 EOM
6128         case "$installscript" in
6129         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6130         *) dflt="$installscript";;
6131         esac
6132         fn=de~
6133         rp='Where will public scripts be installed?'
6134         . ./getfile
6135         installscript="$ans"
6136 else
6137         installscript="$scriptdirexp"
6138 fi
6139
6140 : determine where site specific libraries go.
6141 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6142 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6143 case "$prefix" in
6144 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6145 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6146 esac
6147 eval $prefixit
6148 $cat <<EOM
6149
6150 The installation process will also create a directory for
6151 site-specific extensions and modules.  Some users find it convenient
6152 to place all site-specific files in this directory rather than in the
6153 main distribution directory.
6154
6155 EOM
6156 fn=d~+
6157 rp='Pathname for the site-specific library files?'
6158 . ./getfile
6159 if $test "X$sitelibexp" != "X$ansexp"; then
6160         installsitelib=''
6161 fi
6162 sitelib="$ans"
6163 sitelibexp="$ansexp"
6164 if $afs; then
6165         $cat <<EOM
6166
6167 Since you are running AFS, I need to distinguish the directory in
6168 which site-specific files reside from the directory in which they are
6169 installed (and from which they are presumably copied to the former
6170 directory by occult means).
6171
6172 EOM
6173         case "$installsitelib" in
6174         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6175         *) dflt="$installsitelib";;
6176         esac
6177         fn=de~
6178         rp='Where will site-specific files be installed?'
6179         . ./getfile
6180         installsitelib="$ans"
6181 else
6182         installsitelib="$sitelibexp"
6183 fi
6184
6185 : determine where site specific architecture-dependent libraries go.
6186 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6187 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6188 : sitelib may have an optional trailing /share.
6189 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6190 tdflt="$tdflt/$archname"
6191 set sitearch sitearch none
6192 eval $prefixit
6193 case "$sitearch" in
6194 '')     dflt="$tdflt" ;;
6195 *)      dflt="$sitearch" ;;
6196 esac
6197 $cat <<EOM
6198
6199 The installation process will also create a directory for
6200 architecture-dependent site-specific extensions and modules.
6201
6202 EOM
6203 fn=nd~+
6204 rp='Pathname for the site-specific architecture-dependent library files?'
6205 . ./getfile
6206 if $test "X$sitearchexp" != "X$ansexp"; then
6207         installsitearch=''
6208 fi
6209 sitearch="$ans"
6210 sitearchexp="$ansexp"
6211 if $afs; then
6212         $cat <<EOM
6213
6214 Since you are running AFS, I need to distinguish the directory in
6215 which site-specific architecture-dependent library files reside from
6216 the directory in which they are installed (and from which they are
6217 presumably copied to the former directory by occult means).
6218
6219 EOM
6220         case "$installsitearch" in
6221         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6222         *) dflt="$installsitearch";;
6223         esac
6224         fn=de~
6225         rp='Where will site-specific architecture-dependent files be installed?'
6226         . ./getfile
6227         installsitearch="$ans"
6228 else
6229         installsitearch="$sitearchexp"
6230 fi
6231
6232 cat <<EOM
6233
6234 Previous version of $package used the standard IO mechanisms as defined
6235 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6236 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6237 the default.  This abstraction layer can use AT&T's sfio (if you already
6238 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6239 problems with some extension modules.  Using PerlIO with stdio is safe,
6240 but it is slower than plain stdio and therefore is not the default.
6241
6242 If this doesn't make any sense to you, just accept the default 'n'.
6243 EOM
6244 case "$useperlio" in
6245 $define|true|[yY]*)     dflt='y';;
6246 *) dflt='n';;
6247 esac
6248 rp='Use the experimental PerlIO abstraction layer?'
6249 . ./myread
6250 case "$ans" in
6251 y|Y) 
6252         val="$define"
6253         ;;     
6254 *)      
6255         echo "Ok, doing things the stdio way"
6256         val="$undef"
6257         ;;
6258 esac
6259 set useperlio
6260 eval $setvar 
6261
6262 : Check how to convert floats to strings.
6263 if test "X$d_Gconvert" = X; then
6264         echo " "
6265         echo "Checking for an efficient way to convert floats to strings."
6266         $cat >try.c <<'EOP'
6267 #ifdef TRY_gconvert
6268 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6269 char *myname = "gconvert";
6270 #endif
6271 #ifdef TRY_gcvt
6272 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6273 char *myname = "gcvt";
6274 #endif
6275 #ifdef TRY_sprintf
6276 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6277 char *myname = "sprintf";
6278 #endif
6279
6280 #include <stdio.h>
6281
6282 int
6283 checkit(expect, got)
6284 char *expect;
6285 char *got;
6286 {
6287     if (strcmp(expect, got)) {
6288                 printf("%s oddity:  Expected %s, got %s\n",
6289                         myname, expect, got);
6290                 exit(1);
6291         }
6292 }
6293
6294 int main()
6295
6296         char buf[64]; 
6297         buf[63] = '\0';
6298
6299         /* This must be 1st test on (which?) platform */
6300         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6301         Gconvert(0.1, 8, 0, buf);
6302         checkit("0.1", buf);
6303
6304         Gconvert(1.0, 8, 0, buf); 
6305         checkit("1", buf);
6306
6307         Gconvert(0.0, 8, 0, buf); 
6308         checkit("0", buf);
6309
6310         Gconvert(-1.0, 8, 0, buf); 
6311         checkit("-1", buf);
6312
6313         /* Some Linux gcvt's give 1.e+5 here. */
6314         Gconvert(100000.0, 8, 0, buf); 
6315         checkit("100000", buf);
6316         
6317         /* Some Linux gcvt's give -1.e+5 here. */
6318         Gconvert(-100000.0, 8, 0, buf); 
6319         checkit("-100000", buf);
6320
6321         exit(0);
6322 }
6323 EOP
6324         case "$d_Gconvert" in
6325         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6326         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6327         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6328         *) xxx_list='gconvert gcvt sprintf' ;;
6329         esac
6330
6331         for xxx_convert in $xxx_list; do
6332                 echo "Trying $xxx_convert"
6333                 $rm -f try try$_o
6334                 set try -DTRY_$xxx_convert
6335                 if eval $compile; then
6336                         echo "$xxx_convert" found. >&4
6337                         if ./try; then
6338                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6339                                 break;
6340                         else
6341                                 echo "...But $xxx_convert didn't work as I expected."
6342                         fi
6343                 else
6344                         echo "$xxx_convert NOT found." >&4
6345                 fi
6346         done
6347                 
6348         case "$xxx_convert" in
6349         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6350         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6351         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6352         esac
6353 fi
6354
6355 : Initialize h_fcntl
6356 h_fcntl=false
6357
6358 : Initialize h_sysfile
6359 h_sysfile=false
6360
6361 : access call always available on UNIX
6362 set access d_access
6363 eval $inlibc
6364
6365 : locate the flags for 'access()'
6366 case "$d_access" in
6367 "$define")
6368         echo " "
6369         $cat >access.c <<'EOCP'
6370 #include <sys/types.h>
6371 #ifdef I_FCNTL
6372 #include <fcntl.h>
6373 #endif
6374 #ifdef I_SYS_FILE
6375 #include <sys/file.h>
6376 #endif
6377 #ifdef I_UNISTD
6378 #include <unistd.h>
6379 #endif
6380 int main() {
6381         exit(R_OK);
6382 }
6383 EOCP
6384         : check sys/file.h first, no particular reason here
6385         if $test `./findhdr sys/file.h` && \
6386                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6387                 h_sysfile=true;
6388                 echo "<sys/file.h> defines the *_OK access constants." >&4
6389         elif $test `./findhdr fcntl.h` && \
6390                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6391                 h_fcntl=true;
6392                 echo "<fcntl.h> defines the *_OK access constants." >&4
6393         elif $test `./findhdr unistd.h` && \
6394                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6395                 echo "<unistd.h> defines the *_OK access constants." >&4
6396         else
6397                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6398         fi
6399         ;;
6400 esac
6401 $rm -f access*
6402
6403 : see if accessx exists
6404 set accessx d_accessx
6405 eval $inlibc
6406
6407 : see if alarm exists
6408 set alarm d_alarm
6409 eval $inlibc
6410
6411 : Look for GNU-cc style attribute checking
6412 echo " "
6413 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6414 $cat >attrib.c <<'EOCP'
6415 #include <stdio.h>
6416 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6417 EOCP
6418 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6419         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6420                 echo "Your C compiler doesn't fully support __attribute__."
6421                 val="$undef"
6422         else
6423                 echo "Your C compiler supports __attribute__."
6424                 val="$define"
6425         fi
6426 else
6427         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6428         val="$undef"
6429 fi
6430 set d_attribut
6431 eval $setvar
6432 $rm -f attrib*
6433
6434 : see if bcmp exists
6435 set bcmp d_bcmp
6436 eval $inlibc
6437
6438 : see if bcopy exists
6439 set bcopy d_bcopy
6440 eval $inlibc
6441
6442 : see if this is a unistd.h system
6443 set unistd.h i_unistd
6444 eval $inhdr
6445
6446 : see if getpgrp exists
6447 set getpgrp d_getpgrp
6448 eval $inlibc
6449
6450 case "$d_getpgrp" in
6451 "$define")
6452         echo " "
6453         echo "Checking to see which flavor of getpgrp is in use..."
6454         $cat >set.c <<EOP
6455 #$i_unistd I_UNISTD
6456 #include <sys/types.h>
6457 #ifdef I_UNISTD
6458 #  include <unistd.h>
6459 #endif
6460 int main()
6461 {
6462         if (getuid() == 0) {
6463                 printf("(I see you are running Configure as super-user...)\n");
6464                 setuid(1);
6465         }
6466 #ifdef TRY_BSD_PGRP
6467         if (getpgrp(1) == 0)
6468                 exit(0);
6469 #else
6470         if (getpgrp() > 0)
6471                 exit(0);
6472 #endif
6473         exit(1);
6474 }
6475 EOP
6476         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6477                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6478                 val="$define"
6479         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6480                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6481                 val="$undef"
6482         else
6483                 echo "I can't seem to compile and run the test program."
6484                 if ./usg; then
6485                         xxx="a USG one, i.e. you use getpgrp()."
6486                 else
6487                         # SVR4 systems can appear rather BSD-ish.
6488                         case "$i_unistd" in
6489                         $undef)
6490                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6491                                 val="$define"
6492                                 ;;
6493                         $define)
6494                                 xxx="probably a USG one, i.e. you use getpgrp()."
6495                                 val="$undef"
6496                                 ;;
6497                         esac
6498                 fi
6499                 echo "Assuming your getpgrp is $xxx" >&4
6500         fi
6501         ;;
6502 *) val="$undef";;
6503 esac
6504 set d_bsdgetpgrp
6505 eval $setvar
6506 $rm -f set set.c
6507
6508 : see if setpgrp exists
6509 set setpgrp d_setpgrp
6510 eval $inlibc
6511
6512 case "$d_setpgrp" in
6513 "$define")
6514         echo " "
6515         echo "Checking to see which flavor of setpgrp is in use..."
6516         $cat >set.c <<EOP
6517 #$i_unistd I_UNISTD
6518 #include <sys/types.h>
6519 #ifdef I_UNISTD
6520 #  include <unistd.h>
6521 #endif
6522 int main()
6523 {
6524         if (getuid() == 0) {
6525                 printf("(I see you are running Configure as super-user...)\n");
6526                 setuid(1);
6527         }
6528 #ifdef TRY_BSD_PGRP
6529         if (-1 == setpgrp(1, 1))
6530                 exit(0);
6531 #else
6532         if (setpgrp() != -1)
6533                 exit(0);
6534 #endif
6535         exit(1);
6536 }
6537 EOP
6538         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6539                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6540                 val="$define"
6541         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6542                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6543                 val="$undef"
6544         else
6545                 echo "(I can't seem to compile and run the test program.)"
6546                 if ./usg; then
6547                         xxx="a USG one, i.e. you use setpgrp()."
6548                 else
6549                         # SVR4 systems can appear rather BSD-ish.
6550                         case "$i_unistd" in
6551                         $undef)
6552                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6553                                 val="$define"
6554                                 ;;
6555                         $define)
6556                                 xxx="probably a USG one, i.e. you use setpgrp()."
6557                                 val="$undef"
6558                                 ;;
6559                         esac
6560                 fi
6561                 echo "Assuming your setpgrp is $xxx" >&4
6562         fi
6563         ;;
6564 *) val="$undef";;
6565 esac
6566 set d_bsdsetpgrp
6567 eval $setvar
6568 $rm -f set set.c
6569 : see if bzero exists
6570 set bzero d_bzero
6571 eval $inlibc
6572
6573 : check for lengths of integral types
6574 echo " "
6575 case "$intsize" in
6576 '')
6577         echo "Checking to see how big your integers are..." >&4
6578         $cat >intsize.c <<'EOCP'
6579 #include <stdio.h>
6580 int main()
6581 {
6582         printf("intsize=%d;\n", sizeof(int));
6583         printf("longsize=%d;\n", sizeof(long));
6584         printf("shortsize=%d;\n", sizeof(short));
6585         exit(0);
6586 }
6587 EOCP
6588         set intsize
6589         if eval $compile_ok && ./intsize > /dev/null; then
6590                 eval `./intsize`
6591                 echo "Your integers are $intsize bytes long."
6592                 echo "Your long integers are $longsize bytes long."
6593                 echo "Your short integers are $shortsize bytes long."
6594         else
6595                 $cat >&4 <<EOM
6596 !
6597 Help! I can't compile and run the intsize test program: please enlighten me!
6598 (This is probably a misconfiguration in your system or libraries, and
6599 you really ought to fix it.  Still, I'll try anyway.)
6600 !
6601 EOM
6602                 dflt=4
6603                 rp="What is the size of an integer (in bytes)?"
6604                 . ./myread
6605                 intsize="$ans"
6606                 dflt=$intsize
6607                 rp="What is the size of a long integer (in bytes)?"
6608                 . ./myread
6609                 longsize="$ans"
6610                 dflt=2
6611                 rp="What is the size of a short integer (in bytes)?"
6612                 . ./myread
6613                 shortsize="$ans"
6614         fi
6615         ;;
6616 esac
6617 $rm -f intsize intsize.*
6618
6619 : see if signal is declared as pointer to function returning int or void
6620 echo " "
6621 xxx=`./findhdr signal.h`
6622 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6623 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6624         echo "You have int (*signal())() instead of void." >&4
6625         val="$undef"
6626 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6627         echo "You have void (*signal())()." >&4
6628         val="$define"
6629 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6630         echo "You have int (*signal())() instead of void." >&4
6631         val="$undef"
6632 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6633         echo "You have void (*signal())()." >&4
6634         val="$define"
6635 else
6636         case "$d_voidsig" in
6637         '')
6638         echo "I can't determine whether signal handler returns void or int..." >&4
6639                 dflt=void
6640                 rp="What type does your signal handler return?"
6641                 . ./myread
6642                 case "$ans" in
6643                 v*) val="$define";;
6644                 *) val="$undef";;
6645                 esac;;
6646         "$define")
6647                 echo "As you already told me, signal handler returns void." >&4
6648                 val="$define"
6649                 ;;
6650         *)      echo "As you already told me, signal handler returns int." >&4
6651                 val="$undef"
6652                 ;;
6653         esac
6654 fi
6655 set d_voidsig
6656 eval $setvar
6657 case "$d_voidsig" in
6658 "$define") signal_t="void";;
6659 *) signal_t="int";;
6660 esac
6661 $rm -f $$.tmp
6662
6663 : check for ability to cast large floats to 32-bit ints.
6664 echo " "
6665 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6666 if $test "$intsize" -ge 4; then
6667         xxx=int
6668 else
6669         xxx=long
6670 fi
6671 $cat >try.c <<EOCP
6672 #include <stdio.h>
6673 #include <sys/types.h>
6674 #include <signal.h>
6675 $signal_t blech(s) int s; { exit(3); }
6676 int main()
6677 {
6678         $xxx i32;
6679         double f, g;
6680         int result = 0;
6681         char str[16];
6682         signal(SIGFPE, blech);
6683
6684         /* Don't let compiler optimize the test away.  Store the number 
6685            in a writable string for gcc to pass to sscanf under HP/UX.
6686         */
6687         sprintf(str, "2147483647");
6688         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6689         g = 10 * f;
6690         i32  = ($xxx) g;
6691
6692         /* x86 processors will probably give 0x8000 0000, which is a
6693        sign change.  We don't want that.  We want to mimic SPARC
6694            behavior here, which is to preserve the sign and give
6695            back 0x7fff ffff.
6696         */
6697         if (i32 != ($xxx) f)
6698                 result |= 1;
6699         exit(result);
6700 }
6701 EOCP
6702 set try
6703 if eval $compile_ok; then
6704         ./try
6705         yyy=$?
6706 else
6707         echo "(I can't seem to compile the test program--assuming it can't)"
6708         yyy=1
6709 fi
6710 case "$yyy" in
6711 0)      val="$define"
6712         echo "Yup, it can."
6713         ;;
6714 *)      val="$undef"
6715         echo "Nope, it can't."
6716         ;;
6717 esac
6718 set d_casti32
6719 eval $setvar
6720 $rm -f try try.*
6721
6722 : check for ability to cast negative floats to unsigned
6723 echo " "
6724 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6725 $cat >try.c <<EOCP
6726 #include <stdio.h>
6727 #include <sys/types.h>
6728 #include <signal.h>
6729 $signal_t blech(s) int s; { exit(7); }
6730 $signal_t blech_in_list(s) int s; { exit(4); }
6731 unsigned long dummy_long(p) unsigned long p; { return p; }
6732 unsigned int dummy_int(p) unsigned int p; { return p; }
6733 unsigned short dummy_short(p) unsigned short p; { return p; }
6734 int main()
6735 {
6736         double f;
6737         unsigned long along;
6738         unsigned int aint;
6739         unsigned short ashort;
6740         int result = 0;
6741         char str[16];
6742         
6743         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6744            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6745            optimized the whole file away
6746         */
6747         /* Store the number in a writable string for gcc to pass to 
6748            sscanf under HP/UX.
6749         */
6750         sprintf(str, "-123");
6751         sscanf(str, "%lf", &f);  /* f = -123.; */
6752
6753         signal(SIGFPE, blech);
6754         along = (unsigned long)f;
6755         aint = (unsigned int)f;
6756         ashort = (unsigned short)f;
6757         if (along != (unsigned long)-123)
6758                 result |= 1;
6759         if (aint != (unsigned int)-123)
6760                 result |= 1;
6761         if (ashort != (unsigned short)-123)
6762                 result |= 1;
6763         sprintf(str, "1073741824.");
6764         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6765         f = f + f;
6766         along = 0;
6767         along = (unsigned long)f;
6768         if (along != 0x80000000)
6769                 result |= 2;
6770         f -= 1.;
6771         along = 0;
6772         along = (unsigned long)f;
6773         if (along != 0x7fffffff)
6774                 result |= 1;
6775         f += 2.;
6776         along = 0;
6777         along = (unsigned long)f;
6778         if (along != 0x80000001)
6779                 result |= 2;
6780         if (result)
6781                 exit(result);
6782         signal(SIGFPE, blech_in_list);
6783         sprintf(str, "123.");
6784         sscanf(str, "%lf", &f);  /* f = 123.; */
6785         along = dummy_long((unsigned long)f);
6786         aint = dummy_int((unsigned int)f);
6787         ashort = dummy_short((unsigned short)f);
6788         if (along != (unsigned long)123)
6789                 result |= 4;
6790         if (aint != (unsigned int)123)
6791                 result |= 4;
6792         if (ashort != (unsigned short)123)
6793                 result |= 4;
6794         exit(result);
6795
6796 }
6797 EOCP
6798 set try
6799 if eval $compile_ok; then
6800         ./try
6801         castflags=$?
6802 else
6803         echo "(I can't seem to compile the test program--assuming it can't)"
6804         castflags=7
6805 fi
6806 case "$castflags" in
6807 0)      val="$define"
6808         echo "Yup, it can."
6809         ;;
6810 *)      val="$undef"
6811         echo "Nope, it can't."
6812         ;;
6813 esac
6814 set d_castneg
6815 eval $setvar
6816 $rm -f try.*
6817
6818 : see if vprintf exists
6819 echo " "
6820 if set vprintf val -f d_vprintf; eval $csym; $val; then
6821         echo 'vprintf() found.' >&4
6822         val="$define"
6823         $cat >vprintf.c <<'EOF'
6824 #include <varargs.h>
6825
6826 int main() { xxx("foo"); }
6827
6828 xxx(va_alist)
6829 va_dcl
6830 {
6831         va_list args;
6832         char buf[10];
6833
6834         va_start(args);
6835         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6836 }
6837 EOF
6838         set vprintf
6839         if eval $compile && ./vprintf; then
6840                 echo "Your vsprintf() returns (int)." >&4
6841                 val2="$undef"
6842         else
6843                 echo "Your vsprintf() returns (char*)." >&4
6844                 val2="$define"
6845         fi
6846 else
6847         echo 'vprintf() NOT found.' >&4
6848                 val="$undef"
6849                 val2="$undef"
6850 fi
6851 set d_vprintf
6852 eval $setvar
6853 val=$val2
6854 set d_charvspr
6855 eval $setvar
6856
6857 : see if chown exists
6858 set chown d_chown
6859 eval $inlibc
6860
6861 : see if chroot exists
6862 set chroot d_chroot
6863 eval $inlibc
6864
6865 : see if chsize exists
6866 set chsize d_chsize
6867 eval $inlibc
6868
6869 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6870 while $test $# -ge 2; do
6871         case "$1" in
6872         $define) echo "#include <$2>";;
6873         esac ;
6874     shift 2;
6875 done > try.c;
6876 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6877 if eval $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6878         val="$define";
6879 else
6880         val="$undef";
6881 fi;
6882 set $varname;
6883 eval $setvar;
6884 $rm -f try.c try.o'
6885
6886 : see if this is a sys/uio.h system
6887 set sys/uio.h i_sysuio
6888 eval $inhdr
6889
6890 echo "Checking to see if your system supports struct iovec..." >&4
6891 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6892 eval $hasfield
6893 case "$d_iovec_s" in
6894 "$define")      echo "Yup, it does." >&4
6895                 ;;
6896 *)              echo "Nope, it doesn't." >&4
6897                 ;;
6898 esac
6899
6900 socketlib=''
6901 sockethdr=''
6902 : see whether socket exists
6903 echo " "
6904 $echo $n "Hmm... $c" >&4
6905 if set socket val -f d_socket; eval $csym; $val; then
6906         echo "Looks like you have Berkeley networking support." >&4
6907         d_socket="$define"
6908         if set setsockopt val -f; eval $csym; $val; then
6909                 d_oldsock="$undef"
6910         else
6911                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6912                 d_oldsock="$define"
6913         fi
6914 else
6915         if $contains socklib libc.list >/dev/null 2>&1; then
6916                 echo "Looks like you have Berkeley networking support." >&4
6917                 d_socket="$define"
6918                 : we will have to assume that it supports the 4.2 BSD interface
6919                 d_oldsock="$undef"
6920         else
6921                 echo "You don't have Berkeley networking in libc$_a..." >&4
6922                 if test "X$d_socket" = "X$define"; then
6923                    echo "...but you seem to believe that you have sockets." >&4
6924                 else
6925                         for net in net socket
6926                         do
6927                                 if test -f /usr/lib/lib$net$_a; then
6928                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6929                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6930                                         if $contains socket libc.list >/dev/null 2>&1; then
6931                                                 d_socket="$define"
6932                                                 socketlib="-l$net"
6933                                                 case "$net" in
6934                                                 net)
6935                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6936                                                         sockethdr="-I/usr/netinclude"
6937                                                         ;;
6938                                                 esac
6939                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6940                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6941                                                         d_oldsock="$undef"
6942                                                 else
6943                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6944                                                         d_oldsock="$define"
6945                                                 fi
6946                                                 break
6947                                         fi
6948                                 fi
6949                         done
6950                         if test "X$d_socket" != "X$define"; then
6951                            echo "or anywhere else I see." >&4
6952                            d_socket="$undef"
6953                            d_oldsock="$undef"
6954                         fi
6955                 fi
6956         fi
6957 fi
6958
6959 : see if socketpair exists
6960 set socketpair d_sockpair
6961 eval $inlibc
6962
6963
6964 echo " "
6965 echo "Checking the availability of certain socket constants..." >& 4
6966 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
6967         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
6968         $cat >try.c <<EOF
6969 #include <sys/types.h>
6970 #include <sys/socket.h>
6971 int main() {
6972     int i = $ENUM;
6973 }
6974 EOF
6975         val="$undef"
6976         set try; if eval $compile; then
6977                 val="$define"
6978         fi
6979         set d_${enum}; eval $setvar
6980         $rm -f try.c try
6981 done
6982
6983 set sendmsg d_sendmsg
6984 eval $inlibc
6985
6986 set recvmsg d_recvmsg
6987 eval $inlibc
6988
6989 echo " "
6990 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
6991 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
6992 eval $hasfield
6993 case "$d_msghdr_s" in
6994 "$define")      echo "Yup, it does." >&4
6995                 ;;
6996 *)              echo "Nope, it doesn't." >&4
6997                 ;;
6998 esac
6999
7000 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7001 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7002 eval $hasfield
7003 case "$d_cmsghdr_s" in
7004 "$define")      echo "Yup, it does." >&4
7005                 ;;
7006 *)              echo "Nope, it doesn't." >&4
7007                 ;;
7008 esac
7009
7010 : check for const keyword
7011 echo " "
7012 echo 'Checking to see if your C compiler knows about "const"...' >&4
7013 $cat >const.c <<'EOCP'
7014 typedef struct spug { int drokk; } spug;
7015 int main()
7016 {
7017         const char *foo;
7018         const spug y;
7019 }
7020 EOCP
7021 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7022         val="$define"
7023         echo "Yup, it does."
7024 else
7025         val="$undef"
7026         echo "Nope, it doesn't."
7027 fi
7028 set d_const
7029 eval $setvar
7030
7031 : see if crypt exists
7032 echo " "
7033 if set crypt val -f d_crypt; eval $csym; $val; then
7034         echo 'crypt() found.' >&4
7035         val="$define"
7036         cryptlib=''
7037 else
7038         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7039         if $test -z "$cryptlib"; then
7040                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7041         else
7042                 cryptlib=-lcrypt
7043         fi
7044         if $test -z "$cryptlib"; then
7045                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7046         else
7047                 cryptlib=-lcrypt
7048         fi
7049         if $test -z "$cryptlib"; then
7050                 cryptlib=`./loc libcrypt$_a "" $libpth`
7051         else
7052                 cryptlib=-lcrypt
7053         fi
7054         if $test -z "$cryptlib"; then
7055                 echo 'crypt() NOT found.' >&4
7056                 val="$undef"
7057         else
7058                 val="$define"
7059         fi
7060 fi
7061 set d_crypt
7062 eval $setvar
7063
7064 : get csh whereabouts
7065 case "$csh" in
7066 'csh') val="$undef" ;;
7067 *) val="$define" ;;
7068 esac
7069 set d_csh
7070 eval $setvar
7071 : Respect a hint or command line value for full_csh.
7072 case "$full_csh" in
7073 '') full_csh=$csh ;;
7074 esac
7075
7076 : see if cuserid exists
7077 set cuserid d_cuserid
7078 eval $inlibc
7079
7080 : see if this is a limits.h system
7081 set limits.h i_limits
7082 eval $inhdr
7083
7084 : see if this is a float.h system
7085 set float.h i_float
7086 eval $inhdr
7087
7088 : See if number of significant digits in a double precision number is known
7089 echo " "
7090 $cat >dbl_dig.c <<EOM
7091 #$i_limits I_LIMITS
7092 #$i_float I_FLOAT
7093 #ifdef I_LIMITS
7094 #include <limits.h>
7095 #endif
7096 #ifdef I_FLOAT
7097 #include <float.h>
7098 #endif
7099 #ifdef DBL_DIG
7100 printf("Contains DBL_DIG");
7101 #endif
7102 EOM
7103 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7104 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7105         echo "DBL_DIG found." >&4
7106         val="$define"
7107 else
7108         echo "DBL_DIG NOT found." >&4
7109         val="$undef"
7110 fi
7111 $rm -f dbl_dig.?
7112 set d_dbl_dig
7113 eval $setvar
7114
7115
7116 if $test X"$use64bits" = X"$define"; then
7117         : see if dbminit64 exists
7118         set dbminit64 d_dbminit64
7119         eval $inlibc
7120
7121         : see if dbmclose64 exists
7122         set dbmclose64 d_dbmclose64
7123         eval $inlibc
7124
7125         : see if fetch64 exists
7126         set fetch64 d_fetch64
7127         eval $inlibc
7128
7129         : see if store64 exists
7130         set store64 d_store64
7131         eval $inlibc
7132
7133         : see if delete64 exists
7134         set delete64 d_delete64
7135         eval $inlibc
7136
7137         : see if firstkey64 exists
7138         set firstkey64 d_firstkey64
7139         eval $inlibc
7140
7141         : see if nextkey64 exists
7142         set nextkey64 d_nextkey64
7143         eval $inlibc
7144 else
7145         val="$undef"
7146         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7147         do
7148                 set $xxx
7149                 eval $setvar
7150         done
7151 fi
7152
7153 : see if difftime exists
7154 set difftime d_difftime
7155 eval $inlibc
7156
7157 : see if sys/stat.h is available
7158 set sys/stat.h i_sysstat
7159 eval $inhdr
7160
7161 : see if this is a dirent system
7162 echo " "
7163 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7164         val="$define"
7165         echo "<dirent.h> found." >&4
7166 else
7167         val="$undef"
7168         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7169                 echo "<sys/dir.h> found." >&4
7170                 echo " "
7171         else
7172                 xinc=`./findhdr sys/ndir.h`
7173         fi
7174         echo "<dirent.h> NOT found." >&4
7175 fi
7176 set i_dirent
7177 eval $setvar
7178
7179 : Look for type of directory structure.
7180 echo " "
7181 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7182
7183 case "$direntrytype" in
7184 ''|' ')
7185         case "$i_dirent" in
7186         $define) guess1='struct dirent' ;;
7187         *) guess1='struct direct'  ;;
7188         esac
7189         ;;
7190 *)      guess1="$direntrytype"
7191         ;;
7192 esac
7193
7194 case "$guess1" in
7195 'struct dirent') guess2='struct direct' ;;
7196 *) guess2='struct dirent' ;;
7197 esac
7198                 
7199 if $contains "$guess1" try.c >/dev/null 2>&1; then
7200         direntrytype="$guess1"
7201         echo "Your directory entries are $direntrytype." >&4
7202 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7203         direntrytype="$guess2"
7204         echo "Your directory entries seem to be $direntrytype." >&4
7205 else
7206         echo "I don't recognize your system's directory entries." >&4
7207         rp="What type is used for directory entries on this system?"
7208         dflt="$guess1"
7209         . ./myread
7210         direntrytype="$ans"
7211 fi
7212 $rm -f try.c
7213
7214
7215 : see if the directory entry stores field length
7216 echo " "
7217 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7218 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7219         echo "Good, your directory entry keeps length information in d_namlen." >&4
7220         val="$define"
7221 else
7222         echo "Your directory entry does not know about the d_namlen field." >&4
7223         val="$undef"
7224 fi
7225 set d_dirnamlen
7226 eval $setvar
7227 $rm -f try.c
7228
7229
7230 if $test X"$use64bits" = X"$define"; then
7231         : see if fstat64 exists
7232         set fstat64 d_fstat64
7233         eval $inlibc
7234
7235         : see if ftruncate64 exists
7236         set ftruncate64 d_ftruncate64
7237         eval $inlibc
7238
7239         : see if lockf64 exists
7240         set lockf64 d_lockf64
7241         eval $inlibc
7242
7243         : see if lseek64 exists
7244         set lseek64 d_lseek64
7245         eval $inlibc
7246
7247         : see if lstat64 exists
7248         set lstat64 d_lstat64
7249         eval $inlibc
7250
7251         : see if open64 exists
7252         set open64 d_open64
7253         eval $inlibc
7254
7255         : see if opendir64 exists
7256         set opendir64 d_opendir64
7257         eval $inlibc
7258
7259         : see if readdir64 exists
7260         set readdir64 d_readdir64
7261         eval $inlibc
7262
7263         : see if seekdir64 exists
7264         set seekdir64 d_seekdir64
7265         eval $inlibc
7266
7267         : see if stat64 exists
7268         set stat64 d_stat64
7269         eval $inlibc
7270
7271         : see if telldir64 exists
7272         set telldir64 d_telldir64
7273         eval $inlibc
7274
7275         : see if truncate64 exists
7276         set truncate64 d_truncate64
7277         eval $inlibc
7278
7279         : check for off64_t
7280         echo " "
7281         echo $n "Checking to see if your system supports off64_t...$c" >&4
7282         $cat >try.c <<EOCP
7283 #include <sys/types.h>
7284 off64_t foo() { off64_t x; x = 7; return x; }'
7285 EOCP
7286         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7287                 val="$define"
7288                 echo " Yup, it does." >&4
7289         else
7290                 val="$undef"
7291                 echo " Nope, it doesn't." >&4
7292         fi
7293         $rm -f try.*
7294         set d_off64t
7295         eval $setvar
7296
7297         : check for ino64_t
7298         echo " "
7299         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7300         val="$undef"
7301         case "$i_sysstat" in
7302         "$define" )
7303                 $cat >try.c <<EOCP
7304 #include <sys/types.h>
7305 #include <sys/stat.h>
7306 ino64_t foo() { ino64_t x; x = 7; return x; }'
7307 EOCP
7308                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7309                         val="$define"
7310                 fi
7311                 $rm -f try.*
7312                 ;;
7313         esac
7314         if $test "X$val" = X"$define"; then
7315                 echo " Yup, it does." >&4
7316         else
7317                 echo " Nope, it doesn't." >&4
7318         fi
7319         set d_ino64t
7320         eval $setvar
7321
7322         : check for struct flock64
7323         echo " "
7324         echo "Checking to see if your system supports struct flock64..." >&4
7325         if $h_fcntl; then
7326                 set d_flock64_s flock64 l_len define fcntl.h
7327                 eval $hasfield
7328         else
7329                 val="$undef"
7330                 set d_flock64_s
7331                 eval $setvar
7332         fi
7333         case "$d_flock64_s" in
7334         "$define")      echo "Yup, it does." >&4
7335                         ;;
7336         *)              echo "Nope, it doesn't." >&4
7337                         ;;
7338         esac
7339
7340         : check for struct dirent64
7341         echo " "
7342         echo "Checking to see if your system supports struct dirent64..." >&4
7343         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7344         eval $hasfield
7345         case "$d_dirent64_s" in
7346         "$define")      echo "Yup, it does." >&4
7347                         ;;
7348         *)              echo "Nope, it doesn't." >&4
7349                         ;;
7350         esac
7351
7352 else
7353         val="$undef"
7354         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
7355         do
7356                 set $xxx
7357                 eval $setvar
7358         done
7359 fi
7360
7361 : see if dlerror exists
7362 xxx_runnm="$runnm"
7363 runnm=false
7364 set dlerror d_dlerror
7365 eval $inlibc
7366 runnm="$xxx_runnm"
7367
7368 : see if dlfcn is available
7369 set dlfcn.h i_dlfcn
7370 eval $inhdr
7371
7372 case "$usedl" in
7373 $define|y|true)
7374         $cat << EOM
7375
7376 On a few systems, the dynamically loaded modules that perl generates and uses
7377 will need a different extension than shared libs. The default will probably
7378 be appropriate.
7379
7380 EOM
7381         case "$dlext" in
7382         '')     dflt="$so" ;;
7383         *)      dflt="$dlext" ;;
7384         esac
7385         rp='What is the extension of dynamically loaded modules'
7386         . ./myread
7387         dlext="$ans"
7388         ;;
7389 *)
7390         dlext="none"
7391         ;;
7392 esac
7393
7394 : Check if dlsym need a leading underscore
7395 echo " "
7396 val="$undef"
7397
7398 case "$dlsrc" in
7399 dl_dlopen.xs)
7400         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7401         $cat >dyna.c <<'EOM'
7402 fred () { }
7403 EOM
7404
7405 $cat >fred.c<<EOM
7406
7407 #include <stdio.h>
7408 #$i_dlfcn I_DLFCN
7409 #ifdef I_DLFCN
7410 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7411 #else
7412 #include <sys/types.h>
7413 #include <nlist.h>
7414 #include <link.h>
7415 #endif
7416
7417 extern int fred() ;
7418
7419 int main()
7420 {
7421     void * handle ;
7422     void * symbol ;
7423 #ifndef RTLD_LAZY
7424     int mode = 1 ;
7425 #else
7426     int mode = RTLD_LAZY ;
7427 #endif
7428     handle = dlopen("./dyna.$dlext", mode) ;
7429     if (handle == NULL) {
7430         printf ("1\n") ;
7431         fflush (stdout) ;
7432         exit(0);
7433     }
7434     symbol = dlsym(handle, "fred") ;
7435     if (symbol == NULL) {
7436         /* try putting a leading underscore */
7437         symbol = dlsym(handle, "_fred") ;
7438         if (symbol == NULL) {
7439             printf ("2\n") ;
7440             fflush (stdout) ;
7441             exit(0);
7442         }
7443         printf ("3\n") ;
7444     }
7445     else
7446         printf ("4\n") ;
7447     fflush (stdout) ;
7448     exit(0);
7449 }
7450 EOM
7451         : Call the object file tmp-dyna.o in case dlext=o.
7452         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7453                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7454                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7455                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7456                 xxx=`./fred`
7457                 case $xxx in
7458                 1)      echo "Test program failed using dlopen." >&4
7459                         echo "Perhaps you should not use dynamic loading." >&4;;
7460                 2)      echo "Test program failed using dlsym." >&4
7461                         echo "Perhaps you should not use dynamic loading." >&4;;
7462                 3)      echo "dlsym needs a leading underscore" >&4
7463                         val="$define" ;;
7464                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7465                 esac
7466         else
7467                 echo "I can't compile and run the test program." >&4
7468         fi
7469         ;;
7470 esac
7471                 
7472 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7473
7474 set d_dlsymun
7475 eval $setvar
7476
7477 hasproto='varname=$1; func=$2; shift; shift;
7478 while $test $# -ge 2; do
7479         case "$1" in
7480         $define) echo "#include <$2>";;
7481         esac ;
7482     shift 2;
7483 done > try.c;
7484 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7485 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7486         echo "$func() prototype found.";
7487         val="$define";
7488 else
7489         echo "$func() prototype NOT found.";
7490         val="$undef";
7491 fi;
7492 set $varname;
7493 eval $setvar;
7494 $rm -f try.c tryout.c'
7495
7496 : see if prototype for drand48 is available
7497 echo " "
7498 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7499 eval $hasproto
7500
7501 : see if dup2 exists
7502 set dup2 d_dup2
7503 eval $inlibc
7504
7505 : see if eaccess exists
7506 set eaccess d_eaccess
7507 eval $inlibc
7508
7509 : see if endgrent exists
7510 set endgrent d_endgrent
7511 eval $inlibc
7512
7513 : see if endhostent exists
7514 set endhostent d_endhent
7515 eval $inlibc
7516
7517 : see if endnetent exists
7518 set endnetent d_endnent
7519 eval $inlibc
7520
7521 : see if endprotoent exists
7522 set endprotoent d_endpent
7523 eval $inlibc
7524
7525 : see if endpwent exists
7526 set endpwent d_endpwent
7527 eval $inlibc
7528
7529 : see if endservent exists
7530 set endservent d_endsent
7531 eval $inlibc
7532
7533 : Locate the flags for 'open()'
7534 echo " "
7535 $cat >open3.c <<'EOCP'
7536 #include <sys/types.h>
7537 #ifdef I_FCNTL
7538 #include <fcntl.h>
7539 #endif
7540 #ifdef I_SYS_FILE
7541 #include <sys/file.h>
7542 #endif
7543 int main() {
7544         if(O_RDONLY);
7545 #ifdef O_TRUNC
7546         exit(0);
7547 #else
7548         exit(1);
7549 #endif
7550 }
7551 EOCP
7552 : check sys/file.h first to get FREAD on Sun
7553 if $test `./findhdr sys/file.h` && \
7554                 set open3 -DI_SYS_FILE && eval $compile; then
7555         h_sysfile=true;
7556         echo "<sys/file.h> defines the O_* constants..." >&4
7557         if ./open3; then
7558                 echo "and you have the 3 argument form of open()." >&4
7559                 val="$define"
7560         else
7561                 echo "but not the 3 argument form of open().  Oh, well." >&4
7562                 val="$undef"
7563         fi
7564 elif $test `./findhdr fcntl.h` && \
7565                 set open3 -DI_FCNTL && eval $compile; then
7566         h_fcntl=true;
7567         echo "<fcntl.h> defines the O_* constants..." >&4
7568         if ./open3; then
7569                 echo "and you have the 3 argument form of open()." >&4
7570                 val="$define"
7571         else
7572                 echo "but not the 3 argument form of open().  Oh, well." >&4
7573                 val="$undef"
7574         fi
7575 else
7576         val="$undef"
7577         echo "I can't find the O_* constant definitions!  You got problems." >&4
7578 fi
7579 set d_open3
7580 eval $setvar
7581 $rm -f open3*
7582
7583 : check for non-blocking I/O stuff
7584 case "$h_sysfile" in
7585 true) echo "#include <sys/file.h>" > head.c;;
7586 *)
7587         case "$h_fcntl" in
7588         true) echo "#include <fcntl.h>" > head.c;;
7589         *) echo "#include <sys/fcntl.h>" > head.c;;
7590         esac
7591         ;;
7592 esac
7593 echo " "
7594 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7595 case "$o_nonblock" in
7596 '')
7597         $cat head.c > try.c
7598         $cat >>try.c <<'EOCP'
7599 int main() {
7600 #ifdef O_NONBLOCK
7601         printf("O_NONBLOCK\n");
7602         exit(0);
7603 #endif
7604 #ifdef O_NDELAY
7605         printf("O_NDELAY\n");
7606         exit(0);
7607 #endif
7608 #ifdef FNDELAY
7609         printf("FNDELAY\n");
7610         exit(0);
7611 #endif
7612         exit(0);
7613 }
7614 EOCP
7615         set try
7616         if eval $compile_ok; then
7617                 o_nonblock=`./try`
7618                 case "$o_nonblock" in
7619                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7620                 *) echo "Seems like we can use $o_nonblock.";;
7621                 esac
7622         else
7623                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7624         fi
7625         ;;
7626 *) echo "Using $hint value $o_nonblock.";;
7627 esac
7628 $rm -f try try.* .out core
7629
7630 echo " "
7631 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7632 case "$eagain" in
7633 '')
7634         $cat head.c > try.c
7635         $cat >>try.c <<EOCP
7636 #include <errno.h>
7637 #include <sys/types.h>
7638 #include <signal.h>
7639 #define MY_O_NONBLOCK $o_nonblock
7640 #ifndef errno  /* XXX need better Configure test */
7641 extern int errno;
7642 #endif
7643 $signal_t blech(x) int x; { exit(3); }
7644 EOCP
7645         $cat >> try.c <<'EOCP'
7646 int main()
7647 {
7648         int pd[2];
7649         int pu[2];
7650         char buf[1];
7651         char string[100];
7652
7653         pipe(pd);       /* Down: child -> parent */
7654         pipe(pu);       /* Up: parent -> child */
7655         if (0 != fork()) {
7656                 int ret;
7657                 close(pd[1]);   /* Parent reads from pd[0] */
7658                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7659                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7660                         exit(1);
7661                 signal(SIGALRM, blech);
7662                 alarm(5);
7663                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7664                         exit(2);
7665                 sprintf(string, "%d\n", ret);
7666                 write(2, string, strlen(string));
7667                 alarm(0);
7668 #ifdef EAGAIN
7669                 if (errno == EAGAIN) {
7670                         printf("EAGAIN\n");
7671                         goto ok;
7672                 }
7673 #endif
7674 #ifdef EWOULDBLOCK
7675                 if (errno == EWOULDBLOCK)
7676                         printf("EWOULDBLOCK\n");
7677 #endif
7678         ok:
7679                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7680                 sleep(2);                               /* Give it time to close our pipe */
7681                 alarm(5);
7682                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7683                 alarm(0);
7684                 sprintf(string, "%d\n", ret);
7685                 write(3, string, strlen(string));
7686                 exit(0);
7687         }
7688
7689         close(pd[0]);                   /* We write to pd[1] */
7690         close(pu[1]);                   /* We read from pu[0] */
7691         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7692         close(pd[1]);                   /* Pipe pd is now fully closed! */
7693         exit(0);                                /* Bye bye, thank you for playing! */
7694 }
7695 EOCP
7696         set try
7697         if eval $compile_ok; then
7698                 echo "$startsh" >mtry
7699                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7700                 chmod +x mtry
7701                 ./mtry >/dev/null 2>&1
7702                 case $? in
7703                 0) eagain=`$cat try.out`;;
7704                 1) echo "Could not perform non-blocking setting!";;
7705                 2) echo "I did a successful read() for something that was not there!";;
7706                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7707                 *) echo "Something terribly wrong happened during testing.";;
7708                 esac
7709                 rd_nodata=`$cat try.ret`
7710                 echo "A read() system call with no data present returns $rd_nodata."
7711                 case "$rd_nodata" in
7712                 0|-1) ;;
7713                 *)
7714                         echo "(That's peculiar, fixing that to be -1.)"
7715                         rd_nodata=-1
7716                         ;;
7717                 esac
7718                 case "$eagain" in
7719                 '')
7720                         echo "Forcing errno EAGAIN on read() with no data available."
7721                         eagain=EAGAIN
7722                         ;;
7723                 *)
7724                         echo "Your read() sets errno to $eagain when no data is available."
7725                         ;;
7726                 esac
7727                 status=`$cat try.err`
7728                 case "$status" in
7729                 0) echo "And it correctly returns 0 to signal EOF.";;
7730                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7731                 *) echo "However, your read() returns '$status' on EOF??";;
7732                 esac
7733                 val="$define"
7734                 if test "$status" = "$rd_nodata"; then
7735                         echo "WARNING: you can't distinguish between EOF and no data!"
7736                         val="$undef"
7737                 fi
7738         else
7739                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7740                 eagain=EAGAIN
7741         fi
7742         set d_eofnblk
7743         eval $setvar
7744         ;;
7745 *)
7746         echo "Using $hint value $eagain."
7747         echo "Your read() returns $rd_nodata when no data is present."
7748         case "$d_eofnblk" in
7749         "$define") echo "And you can see EOF because read() returns 0.";;
7750         "$undef") echo "But you can't see EOF status from read() returned value.";;
7751         *)
7752                 echo "(Assuming you can't see EOF status from read anyway.)"
7753                 d_eofnblk=$undef
7754                 ;;
7755         esac
7756         ;;
7757 esac
7758 $rm -f try try.* .out core head.c mtry
7759
7760 : see if fchmod exists
7761 set fchmod d_fchmod
7762 eval $inlibc
7763
7764 : see if fchown exists
7765 set fchown d_fchown
7766 eval $inlibc
7767
7768 : see if this is an fcntl system
7769 set fcntl d_fcntl
7770 eval $inlibc
7771
7772 : see if sys/select.h has to be included
7773 set sys/select.h i_sysselct
7774 eval $inhdr
7775
7776 : see if we should include time.h, sys/time.h, or both
7777 echo " "
7778 if test "X$timeincl" = X; then
7779         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7780         $echo $n "I'm now running the test program...$c"
7781         $cat >try.c <<'EOCP'
7782 #include <sys/types.h>
7783 #ifdef I_TIME
7784 #include <time.h>
7785 #endif
7786 #ifdef I_SYSTIME
7787 #ifdef SYSTIMEKERNEL
7788 #define KERNEL
7789 #endif
7790 #include <sys/time.h>
7791 #endif
7792 #ifdef I_SYSSELECT
7793 #include <sys/select.h>
7794 #endif
7795 int main()
7796 {
7797         struct tm foo;
7798 #ifdef S_TIMEVAL
7799         struct timeval bar;
7800 #endif
7801 #ifdef S_TIMEZONE
7802         struct timezone tzp;
7803 #endif
7804         if (foo.tm_sec == foo.tm_sec)
7805                 exit(0);
7806 #ifdef S_TIMEVAL
7807         if (bar.tv_sec == bar.tv_sec)
7808                 exit(0);
7809 #endif
7810         exit(1);
7811 }
7812 EOCP
7813         flags=''
7814         for s_timezone in '-DS_TIMEZONE' ''; do
7815         sysselect=''
7816         for s_timeval in '-DS_TIMEVAL' ''; do
7817         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7818         for i_time in '' '-DI_TIME'; do
7819         for i_systime in '-DI_SYSTIME' ''; do
7820                 case "$flags" in
7821                 '') $echo $n ".$c"
7822                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7823                         if eval $compile; then
7824                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7825                                 shift
7826                                 flags="$*"
7827                                 echo " "
7828                                 $echo $n "Succeeded with $flags$c"
7829                         fi
7830                         ;;
7831                 esac
7832         done
7833         done
7834         done
7835         done
7836         done
7837         timeincl=''
7838         echo " "
7839         case "$flags" in
7840         *SYSTIMEKERNEL*) i_systimek="$define"
7841                 timeincl=`./findhdr sys/time.h`
7842                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7843         *) i_systimek="$undef";;
7844         esac
7845         case "$flags" in
7846         *I_TIME*) i_time="$define"
7847                 timeincl=`./findhdr time.h`" $timeincl"
7848                 echo "We'll include <time.h>." >&4;;
7849         *) i_time="$undef";;
7850         esac
7851         case "$flags" in
7852         *I_SYSTIME*) i_systime="$define"
7853                 timeincl=`./findhdr sys/time.h`" $timeincl"
7854                 echo "We'll include <sys/time.h>." >&4;;
7855         *) i_systime="$undef";;
7856         esac
7857         $rm -f try.c try
7858 fi
7859
7860 : check for fd_set items
7861 $cat <<EOM
7862
7863 Checking to see how well your C compiler handles fd_set and friends ...
7864 EOM
7865 $cat >fd_set.c <<EOCP
7866 #$i_systime I_SYS_TIME
7867 #$i_sysselct I_SYS_SELECT
7868 #$d_socket HAS_SOCKET
7869 #include <sys/types.h>
7870 #ifdef HAS_SOCKET
7871 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7872 #endif
7873 #ifdef I_SYS_TIME
7874 #include <sys/time.h>
7875 #endif
7876 #ifdef I_SYS_SELECT
7877 #include <sys/select.h>
7878 #endif
7879 int main() {
7880         fd_set fds;
7881
7882 #ifdef TRYBITS
7883         if(fds.fds_bits);
7884 #endif
7885
7886 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7887         exit(0);
7888 #else
7889         exit(1);
7890 #endif
7891 }
7892 EOCP
7893 set fd_set -DTRYBITS
7894 if eval $compile; then
7895         d_fds_bits="$define"
7896         d_fd_set="$define"
7897         echo "Well, your system knows about the normal fd_set typedef..." >&4
7898         if ./fd_set; then
7899                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7900                 d_fd_macros="$define"
7901         else
7902                 $cat >&4 <<'EOM'
7903 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7904 EOM
7905                 d_fd_macros="$undef"
7906         fi
7907 else
7908         $cat <<'EOM'
7909 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7910 EOM
7911         set fd_set
7912         if eval $compile; then
7913                 d_fds_bits="$undef"
7914                 d_fd_set="$define"
7915                 echo "Well, your system has some sort of fd_set available..." >&4
7916                 if ./fd_set; then
7917                         echo "and you have the normal fd_set macros." >&4
7918                         d_fd_macros="$define"
7919                 else
7920                         $cat <<'EOM'
7921 but not the normal fd_set macros!  Gross!  More work for me...
7922 EOM
7923                         d_fd_macros="$undef"
7924                 fi
7925         else
7926         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7927                 d_fd_set="$undef"
7928                 d_fds_bits="$undef"
7929                 d_fd_macros="$undef"
7930         fi
7931 fi
7932 $rm -f fd_set*
7933
7934 : see if fgetpos exists
7935 set fgetpos d_fgetpos
7936 eval $inlibc
7937
7938
7939 if $test X"$use64bits" = X"$define"; then
7940         : see if fgetpos64 exists
7941         set fgetpos64 d_fgetpos64
7942         eval $inlibc
7943
7944         : see if fopen64 exists
7945         set freopen64 d_fopen64
7946         eval $inlibc
7947
7948         : see if freopen64 exists
7949         set freopen64 d_freopen64
7950         eval $inlibc
7951
7952         : see if fseek64 exists
7953         set fseek64 d_fseek64
7954         eval $inlibc
7955
7956         : see if fseeko64 exists
7957         set fseeko64 d_fseeko64
7958         eval $inlibc
7959
7960         : see if fsetpos64 exists
7961         set fsetpos64 d_fsetpos64
7962         eval $inlibc
7963
7964         : see if ftell64 exists
7965         set ftell64 d_ftell64
7966         eval $inlibc
7967
7968         : see if ftello64 exists
7969         set ftello64 d_ftello64
7970         eval $inlibc
7971
7972         : see if tmpfile64 exists
7973         set tmpfile64 d_tmpfile64
7974         eval $inlibc
7975 else
7976         val="$undef"
7977         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
7978         do
7979                 set $xxx
7980                 eval $setvar
7981         done
7982 fi
7983
7984 : see if flock exists
7985 set flock d_flock
7986 eval $inlibc
7987
7988 : see if fork exists
7989 set fork d_fork
7990 eval $inlibc
7991
7992 : see if pathconf exists
7993 set pathconf d_pathconf
7994 eval $inlibc
7995
7996 : see if fpathconf exists
7997 set fpathconf d_fpathconf
7998 eval $inlibc
7999
8000 : see if fseeko exists
8001 set fseeko d_fseeko
8002 eval $inlibc
8003
8004 : see if fsetpos exists
8005 set fsetpos d_fsetpos
8006 eval $inlibc
8007
8008 : see if this is a sys/param system
8009 set sys/param.h i_sysparam
8010 eval $inhdr
8011
8012 : see if this is a sys/mount.h system
8013 set sys/mount.h i_sysmount
8014 eval $inhdr
8015
8016
8017 : see if statfs exists
8018 set statfs d_statfs
8019 eval $inlibc
8020
8021 : see if fstatfs exists
8022 set fstatfs d_fstatfs
8023 eval $inlibc
8024
8025 : see if statfs knows about mount flags
8026 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8027 eval $hasfield
8028
8029
8030 : see if statvfs exists
8031 set statvfs d_statvfs
8032 eval $inlibc
8033
8034 : see if fstatvfs exists
8035 set fstatvfs d_fstatvfs
8036 eval $inlibc
8037
8038
8039 : see if ftello exists
8040 set ftello d_ftello
8041 eval $inlibc
8042
8043 : see if getgrent exists
8044 set getgrent d_getgrent
8045 eval $inlibc
8046
8047 : see if gethostbyaddr exists
8048 set gethostbyaddr d_gethbyaddr
8049 eval $inlibc
8050
8051 : see if gethostbyname exists
8052 set gethostbyname d_gethbyname
8053 eval $inlibc
8054
8055 : see if gethostent exists
8056 set gethostent d_gethent
8057 eval $inlibc
8058
8059 : see how we will look up host name
8060 echo " "
8061 if false; then
8062         : dummy stub to allow use of elif
8063 elif set gethostname val -f d_gethname; eval $csym; $val; then
8064         echo 'gethostname() found.' >&4
8065         d_gethname="$define"
8066         call=gethostname
8067 elif set uname val -f d_uname; eval $csym; $val; then
8068         if ./xenix; then
8069                 $cat <<'EOM'
8070 uname() was found, but you're running xenix, and older versions of xenix
8071 have a broken uname(). If you don't really know whether your xenix is old
8072 enough to have a broken system call, use the default answer.
8073
8074 EOM
8075                 dflt=y
8076                 case "$d_uname" in
8077                 "$define") dflt=n;;
8078                 esac
8079                 rp='Is your uname() broken?'
8080                 . ./myread
8081                 case "$ans" in
8082                 n*) d_uname="$define"; call=uname;;
8083                 esac
8084         else
8085                 echo 'uname() found.' >&4
8086                 d_uname="$define"
8087                 call=uname
8088         fi
8089 fi
8090 case "$d_gethname" in
8091 '') d_gethname="$undef";;
8092 esac
8093 case "$d_uname" in
8094 '') d_uname="$undef";;
8095 esac
8096 case "$d_uname$d_gethname" in
8097 *define*)
8098         dflt=n
8099         cat <<EOM
8100  
8101 Every now and then someone has a $call() that lies about the hostname
8102 but can't be fixed for political or economic reasons.  If you wish, I can
8103 pretend $call() isn't there and maybe compute hostname at run-time
8104 thanks to the '$phostname' command.
8105
8106 EOM
8107         rp="Shall I ignore $call() from now on?"
8108         . ./myread
8109         case "$ans" in
8110         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8111         esac;;
8112 esac
8113 case "$phostname" in
8114 '') aphostname='';;
8115 *) case "$aphostname" in
8116         /*) ;;
8117         *) set X $phostname
8118                 shift
8119                 file=$1
8120                 shift
8121                 file=`./loc $file $file $pth`
8122                 aphostname=`echo $file $*`
8123                 ;;
8124         esac
8125         ;;
8126 esac
8127 case "$d_uname$d_gethname" in
8128 *define*) ;;
8129 *)
8130         case "$phostname" in
8131         '')
8132                 echo "There will be no way for $package to get your hostname." >&4;;
8133         *)
8134         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8135                 ;;
8136         esac;;
8137 esac
8138 case "$d_phostname" in
8139 '') d_phostname="$undef";;
8140 esac
8141
8142 : see if this is a netdb.h system
8143 set netdb.h i_netdb
8144 eval $inhdr
8145
8146 : see if prototypes for various gethostxxx netdb.h functions are available
8147 echo " "
8148 set d_gethostprotos gethostent $i_netdb netdb.h
8149 eval $hasproto
8150
8151 : see if getlogin exists
8152 set getlogin d_getlogin
8153 eval $inlibc
8154
8155 : see if getmntent exists
8156 set getmntent d_getmntent
8157 eval $inlibc
8158
8159 : see if getnetbyaddr exists
8160 set getnetbyaddr d_getnbyaddr
8161 eval $inlibc
8162
8163 : see if getnetbyname exists
8164 set getnetbyname d_getnbyname
8165 eval $inlibc
8166
8167 : see if getnetent exists
8168 set getnetent d_getnent
8169 eval $inlibc
8170
8171 : see if prototypes for various getnetxxx netdb.h functions are available
8172 echo " "
8173 set d_getnetprotos getnetent $i_netdb netdb.h
8174 eval $hasproto
8175
8176
8177 : see if getprotobyname exists
8178 set getprotobyname d_getpbyname
8179 eval $inlibc
8180
8181 : see if getprotobynumber exists
8182 set getprotobynumber d_getpbynumber
8183 eval $inlibc
8184
8185 : see if getprotoent exists
8186 set getprotoent d_getpent
8187 eval $inlibc
8188
8189 : see if getpgid exists
8190 set getpgid d_getpgid
8191 eval $inlibc
8192
8193 : see if getpgrp2 exists
8194 set getpgrp2 d_getpgrp2
8195 eval $inlibc
8196
8197 : see if getppid exists
8198 set getppid d_getppid
8199 eval $inlibc
8200
8201 : see if getpriority exists
8202 set getpriority d_getprior
8203 eval $inlibc
8204
8205 : see if prototypes for various getprotoxxx netdb.h functions are available
8206 echo " "
8207 set d_getprotoprotos getprotoent $i_netdb netdb.h
8208 eval $hasproto
8209
8210 : see if getpwent exists
8211 set getpwent d_getpwent
8212 eval $inlibc
8213
8214
8215 : see if getservbyname exists
8216 set getservbyname d_getsbyname
8217 eval $inlibc
8218
8219 : see if getservbyport exists
8220 set getservbyport d_getsbyport
8221 eval $inlibc
8222
8223 : see if getservent exists
8224 set getservent d_getsent
8225 eval $inlibc
8226
8227 : see if prototypes for various getservxxx netdb.h functions are available
8228 echo " "
8229 set d_getservprotos getservent $i_netdb netdb.h
8230 eval $hasproto
8231
8232 : see if gettimeofday or ftime exists
8233 set gettimeofday d_gettimeod
8234 eval $inlibc
8235 case "$d_gettimeod" in
8236 "$undef")
8237         set ftime d_ftime 
8238         eval $inlibc
8239         ;;
8240 *)
8241         val="$undef"; set d_ftime; eval $setvar
8242         ;;
8243 esac
8244 case "$d_gettimeod$d_ftime" in
8245 "$undef$undef")
8246         echo " "
8247         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8248         ;;
8249 esac
8250
8251 : see if this is an grp system
8252 set grp.h i_grp
8253 eval $inhdr
8254
8255 case "$i_grp" in
8256 $define)
8257         xxx=`./findhdr grp.h`
8258         $cppstdin $cppflags $cppminus < $xxx >$$.h
8259
8260         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8261                 val="$define"
8262         else
8263                 val="$undef"
8264         fi
8265         set d_grpasswd
8266         eval $setvar
8267
8268         $rm -f $$.h
8269         ;;
8270 *)
8271         val="$undef";
8272         set d_grpasswd; eval $setvar
8273         ;;
8274 esac
8275
8276 : see if hasmntopt exists
8277 set hasmntopt d_hasmntopt
8278 eval $inlibc
8279
8280 : see if this is a netinet/in.h or sys/in.h system
8281 set netinet/in.h i_niin sys/in.h i_sysin
8282 eval $inhdr
8283
8284 : see if arpa/inet.h has to be included
8285 set arpa/inet.h i_arpainet
8286 eval $inhdr
8287
8288 : see if htonl --and friends-- exists
8289 val=''
8290 set htonl val
8291 eval $inlibc
8292
8293 : Maybe they are macros.
8294 case "$val" in
8295 $undef)
8296         $cat >htonl.c <<EOM
8297 #include <stdio.h>
8298 #include <sys/types.h>
8299 #$i_niin I_NETINET_IN
8300 #$i_sysin I_SYS_IN
8301 #$i_arpainet I_ARPA_INET
8302 #ifdef I_NETINET_IN
8303 #include <netinet/in.h>
8304 #endif
8305 #ifdef I_SYS_IN
8306 #include <sys/in.h>
8307 #endif
8308 #ifdef I_ARPA_INET
8309 #include <arpa/inet.h>
8310 #endif
8311 #ifdef htonl
8312 printf("Defined as a macro.");
8313 #endif
8314 EOM
8315         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8316         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8317                 val="$define"
8318                 echo "But it seems to be defined as a macro." >&4
8319         fi
8320         $rm -f htonl.?
8321         ;;
8322 esac
8323 set d_htonl
8324 eval $setvar
8325
8326 : see which of string.h or strings.h is needed
8327 echo " "
8328 strings=`./findhdr string.h`
8329 if $test "$strings" && $test -r "$strings"; then
8330         echo "Using <string.h> instead of <strings.h>." >&4
8331         val="$define"
8332 else
8333         val="$undef"
8334         strings=`./findhdr strings.h`
8335         if $test "$strings" && $test -r "$strings"; then
8336                 echo "Using <strings.h> instead of <string.h>." >&4
8337         else
8338                 echo "No string header found -- You'll surely have problems." >&4
8339         fi
8340 fi
8341 set i_string
8342 eval $setvar
8343 case "$i_string" in
8344 "$undef") strings=`./findhdr strings.h`;;
8345 *)        strings=`./findhdr string.h`;;
8346 esac
8347
8348 : index or strchr
8349 echo " "
8350 if set index val -f; eval $csym; $val; then
8351         if set strchr val -f d_strchr; eval $csym; $val; then
8352                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8353                         val="$define"
8354                         vali="$undef"
8355                         echo "strchr() found." >&4
8356                 else
8357                         val="$undef"
8358                         vali="$define"
8359                         echo "index() found." >&4
8360                 fi
8361         else
8362                 val="$undef"
8363                 vali="$define"
8364                 echo "index() found." >&4
8365         fi
8366 else
8367         if set strchr val -f d_strchr; eval $csym; $val; then
8368                 val="$define"
8369                 vali="$undef"
8370                 echo "strchr() found." >&4
8371         else
8372                 echo "No index() or strchr() found!" >&4
8373                 val="$undef"
8374                 vali="$undef"
8375         fi
8376 fi
8377 set d_strchr; eval $setvar
8378 val="$vali"
8379 set d_index; eval $setvar
8380
8381 : check whether inet_aton exists
8382 set inet_aton d_inetaton
8383 eval $inlibc
8384
8385 : see if inttypes.h is available
8386 : we want a real compile instead of Inhdr because some systems
8387 : have an inttypes.h which includes non-existent headers
8388 echo " "
8389 $cat >try.c <<EOCP
8390 #include <inttypes.h>
8391 int main() {
8392         static int32_t foo32 = 0x12345678;
8393 }
8394 EOCP
8395 set try
8396 if eval $compile; then
8397         echo "<inttypes.h> found." >&4
8398         val="$define"
8399 else
8400         echo "<inttypes.h> NOT found." >&4
8401         val="$undef"
8402 fi
8403 $rm -f try.c try
8404 set i_inttypes
8405 eval $setvar
8406
8407 : check for int64_t
8408 case "$use64bits" in
8409 "$define" )
8410         echo " "
8411         echo $n "Checking to see if your system supports int64_t...$c" >&4
8412         $cat >try.c <<EOCP
8413 #include <sys/types.h>
8414 #$i_inttypes I_INTTYPES
8415 #ifdef I_INTTYPES
8416 #include <inttypes.h>
8417 #endif
8418 int64_t foo() { int64_t x; x = 7; return x; }
8419 EOCP
8420         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8421                 val="$define"
8422                 echo " Yup, it does." >&4
8423         else
8424                 val="$undef"
8425                 echo " Nope, it doesn't." >&4
8426         fi
8427         $rm -f try.*
8428         ;;
8429 *)      val="$undef"
8430         ;;
8431 esac
8432 set d_int64t
8433 eval $setvar
8434
8435
8436 : Look for isascii
8437 echo " "
8438 $cat >isascii.c <<'EOCP'
8439 #include <stdio.h>
8440 #include <ctype.h>
8441 int main() {
8442         int c = 'A';
8443         if (isascii(c))
8444                 exit(0);
8445         else
8446                 exit(1);
8447 }
8448 EOCP
8449 set isascii
8450 if eval $compile; then
8451         echo "isascii() found." >&4
8452         val="$define"
8453 else
8454         echo "isascii() NOT found." >&4
8455         val="$undef"
8456 fi
8457 set d_isascii
8458 eval $setvar
8459 $rm -f isascii*
8460
8461 : see if killpg exists
8462 set killpg d_killpg
8463 eval $inlibc
8464
8465 : see if lchown exists
8466 echo " "
8467 $cat > try.c <<'EOCP'
8468 /* System header to define __stub macros and hopefully few prototypes,
8469     which can conflict with char lchown(); below.  */
8470 #include <assert.h>
8471 /* Override any gcc2 internal prototype to avoid an error.  */
8472 /* We use char because int might match the return type of a gcc2
8473    builtin and then its argument prototype would still apply.  */
8474 char lchown();
8475 int main() {
8476     /*  The GNU C library defines this for functions which it implements
8477         to always fail with ENOSYS.  Some functions are actually named
8478         something starting with __ and the normal name is an alias.  */
8479 #if defined (__stub_lchown) || defined (__stub___lchown)
8480 choke me
8481 #else
8482 lchown();
8483 #endif
8484 ; return 0; }
8485 EOCP
8486 set try
8487 if eval $compile; then
8488     $echo "lchown() found." >&4
8489     val="$define"
8490 else
8491     $echo "lchown() NOT found." >&4
8492     val="$undef"
8493 fi
8494 set d_lchown
8495 eval $setvar
8496
8497 : see if link exists
8498 set link d_link
8499 eval $inlibc
8500
8501 : see if localeconv exists
8502 set localeconv d_locconv
8503 eval $inlibc
8504
8505 : see if lockf exists
8506 set lockf d_lockf
8507 eval $inlibc
8508
8509 : check for length of double
8510 echo " "
8511 case "$doublesize" in
8512 '')
8513         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8514         $cat >try.c <<'EOCP'
8515 #include <stdio.h>
8516 int main()
8517 {
8518         printf("%d\n", sizeof(double));
8519 }
8520 EOCP
8521         set try
8522         if eval $compile_ok; then
8523                 doublesize=`./try`
8524                 $echo " $doublesize bytes." >&4
8525         else
8526                 dflt='8'
8527                 echo "(I can't seem to compile the test program.  Guessing...)"
8528                 rp="What is the size of a double precision number (in bytes)?"
8529                 . ./myread
8530                 doublesize="$ans"
8531         fi
8532         ;;
8533 esac
8534 $rm -f try.c try
8535
8536 : check for long doubles
8537 echo " "
8538 echo $n "Checking to see if your system supports long doubles...$c" >&4
8539 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8540 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8541         val="$define"
8542         echo " Yup, it does." >&4
8543 else
8544         val="$undef"
8545         echo " Nope, it doesn't." >&4
8546 fi
8547 $rm try.*
8548 set d_longdbl
8549 eval $setvar
8550
8551 : check for length of long double
8552 case "${d_longdbl}${longdblsize}" in
8553 $define)
8554         echo " "
8555         $echo $n "Checking to see how big your long doubles are...$c" >&4
8556         $cat >try.c <<'EOCP'
8557 #include <stdio.h>
8558 int main()
8559 {
8560         printf("%d\n", sizeof(long double));
8561 }
8562 EOCP
8563         set try
8564         if eval $compile; then
8565                 longdblsize=`./try`
8566                 $echo " $longdblsize bytes." >&4
8567         else
8568                 dflt='8'
8569                 echo " "
8570                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8571                 rp="What is the size of a long double (in bytes)?"
8572                 . ./myread
8573                 longdblsize="$ans"
8574         fi
8575         if $test "X$doublesize" = "X$longdblsize"; then
8576                 echo "(That isn't any different from an ordinary double.)"
8577         fi      
8578         ;;
8579 esac
8580 $rm -f try.c try
8581
8582 : check for long long
8583 echo " "
8584 echo $n "Checking to see if your system supports long long...$c" >&4
8585 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8586 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8587         val="$define"
8588         echo " Yup, it does." >&4
8589 else
8590         val="$undef"
8591         echo " Nope, it doesn't." >&4
8592 fi
8593 $rm try.*
8594 set d_longlong
8595 eval $setvar
8596
8597 : check for length of long long
8598 case "${d_longlong}${longlongsize}" in
8599 $define)
8600         echo " "
8601         $echo $n "Checking to see how big your long longs are...$c" >&4
8602         $cat >try.c <<'EOCP'
8603 #include <stdio.h>
8604 int main()
8605 {
8606         printf("%d\n", sizeof(long long));
8607 }
8608 EOCP
8609         set try
8610         if eval $compile_ok; then
8611                 longlongsize=`./try`
8612                 $echo " $longlongsize bytes." >&4
8613         else
8614                 dflt='8'
8615                 echo " "
8616                 echo "(I can't seem to compile the test program.  Guessing...)"
8617                 rp="What is the size of a long long (in bytes)?"
8618                 . ./myread
8619                 longlongsize="$ans"
8620         fi
8621         if $test "X$longsize" = "X$longlongsize"; then
8622                 echo "(That isn't any different from an ordinary long.)"
8623         fi      
8624         ;;
8625 esac
8626 $rm -f try.c try
8627
8628 : see if lstat exists
8629 set lstat d_lstat
8630 eval $inlibc
8631
8632 : see if madvise exists
8633 set madvise d_madvise
8634 eval $inlibc
8635
8636 : see if mblen exists
8637 set mblen d_mblen
8638 eval $inlibc
8639
8640 : see if mbstowcs exists
8641 set mbstowcs d_mbstowcs
8642 eval $inlibc
8643
8644 : see if mbtowc exists
8645 set mbtowc d_mbtowc
8646 eval $inlibc
8647
8648 : see if memcmp exists
8649 set memcmp d_memcmp
8650 eval $inlibc
8651
8652 : see if memcpy exists
8653 set memcpy d_memcpy
8654 eval $inlibc
8655
8656 : see if memmove exists
8657 set memmove d_memmove
8658 eval $inlibc
8659
8660 : see if memset exists
8661 set memset d_memset
8662 eval $inlibc
8663
8664 : see if mkdir exists
8665 set mkdir d_mkdir
8666 eval $inlibc
8667
8668 : see if mkfifo exists
8669 set mkfifo d_mkfifo
8670 eval $inlibc
8671
8672 : see if mktime exists
8673 set mktime d_mktime
8674 eval $inlibc
8675
8676 : see if this is a sys/mman.h system
8677 set sys/mman.h i_sysmman
8678 eval $inhdr
8679
8680 : see if mmap exists
8681 set mmap d_mmap
8682 eval $inlibc
8683 : see what shmat returns
8684 : default to something harmless
8685 mmaptype='void *'
8686 case "$i_sysmman$d_mmap" in
8687 "$define$define")
8688         $cat >mmap.c <<'END'
8689 #include <sys/mman.h>
8690 void *mmap();
8691 END
8692         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8693                 mmaptype='void *'
8694         else
8695                 mmaptype='caddr_t'
8696         fi
8697         echo "and it returns ($mmaptype)." >&4
8698         ;;
8699 esac
8700
8701
8702
8703 : see if mprotect exists
8704 set mprotect d_mprotect
8705 eval $inlibc
8706
8707 : see if msgctl exists
8708 set msgctl d_msgctl
8709 eval $inlibc
8710
8711 : see if msgget exists
8712 set msgget d_msgget
8713 eval $inlibc
8714
8715 : see if msgsnd exists
8716 set msgsnd d_msgsnd
8717 eval $inlibc
8718
8719 : see if msgrcv exists
8720 set msgrcv d_msgrcv
8721 eval $inlibc
8722
8723 : see how much of the 'msg*(2)' library is present.
8724 h_msg=true
8725 echo " "
8726 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8727 *"$undef"*) h_msg=false;;
8728 esac
8729 case "$osname" in
8730 freebsd)
8731     case "`ipcs 2>&1`" in
8732     "SVID messages"*"not configured"*)
8733         echo "Your $osname does not have the msg*(2) configured." >&4
8734         h_msg=false
8735         val="$undef"
8736         set msgctl d_msgctl
8737         eval $setvar
8738         set msgget d_msgget
8739         eval $setvar
8740         set msgsnd d_msgsnd
8741         eval $setvar
8742         set msgrcv d_msgrcv
8743         eval $setvar
8744         ;;
8745     esac
8746     ;;
8747 esac
8748 : we could also check for sys/ipc.h ...
8749 if $h_msg && $test `./findhdr sys/msg.h`; then
8750         echo "You have the full msg*(2) library." >&4
8751         val="$define"
8752 else
8753         echo "You don't have the full msg*(2) library." >&4
8754         val="$undef"
8755 fi
8756 set d_msg
8757 eval $setvar
8758
8759 : see if msync exists
8760 set msync d_msync
8761 eval $inlibc
8762
8763 : see if munmap exists
8764 set munmap d_munmap
8765 eval $inlibc
8766
8767 : see if nice exists
8768 set nice d_nice
8769 eval $inlibc
8770
8771 : how to create joinable pthreads
8772 if test "X$usethreads" = "X$define"; then
8773         echo " "
8774         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8775         $cat >try.c <<'EOCP'
8776 #include <pthread.h>
8777 int main() {
8778     int detachstate = JOINABLE;
8779 }
8780 EOCP
8781         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8782         if eval $compile; then
8783                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8784                 val="$undef" # Yes, undef.
8785                 set d_old_pthread_create_joinable
8786                 eval $setvar
8787                 val=""
8788                 set old_pthread_create_joinable
8789                 eval $setvar
8790         else
8791                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8792                 if eval $compile; then
8793                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8794                         val="$define"
8795                         set d_old_pthread_create_joinable
8796                         eval $setvar
8797                         val=PTHREAD_CREATE_UNDETACHED
8798                         set old_pthread_create_joinable
8799                         eval $setvar
8800                 else            
8801                         set try -DJOINABLE=__UNDETACHED
8802                         if eval $compile; then
8803                                 echo "You seem to use __UNDETACHED." >&4
8804                                 val="$define"
8805                                 set d_old_pthread_create_joinable
8806                                 eval $setvar
8807                                 val=__UNDETACHED
8808                                 set old_pthread_create_joinable
8809                                 eval $setvar
8810                         else
8811                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8812                                 val="$define"
8813                                 set d_old_pthread_create_joinable
8814                                 eval $setvar
8815                                 val=0
8816                                 set old_pthread_create_joinable
8817                                 eval $setvar
8818                         fi
8819                 fi
8820         fi
8821         $rm -f try try.*
8822 else
8823     d_old_pthread_create_joinable="$undef"
8824     old_pthread_create_joinable=""
8825 fi
8826
8827 : see if pause exists
8828 set pause d_pause
8829 eval $inlibc
8830
8831 : see if pipe exists
8832 set pipe d_pipe
8833 eval $inlibc
8834
8835 : see if poll exists
8836 set poll d_poll
8837 eval $inlibc
8838
8839
8840 : see whether the various POSIXish _yields exist
8841 $cat >try.c <<EOP
8842 #include <pthread.h>
8843 #include <stdio.h>
8844 int main() {
8845 #ifdef SCHED_YIELD
8846         sched_yield();
8847 #else
8848 #ifdef PTHREAD_YIELD
8849         pthread_yield();
8850 #else
8851 #ifdef PTHREAD_YIELD_NULL
8852         pthread_yield(NULL);
8853 #endif
8854 #endif
8855 #endif
8856 }
8857 EOP
8858 : see if sched_yield exists
8859 set try -DSCHED_YIELD
8860 if eval $compile; then
8861     val="$define"
8862     sched_yield='sched_yield()'
8863 else
8864     val="$undef"
8865 fi
8866 case "$usethreads" in
8867 $define)
8868         case "$val" in
8869         $define) echo 'sched_yield() found.' >&4        ;;
8870         *)       echo 'sched_yield() NOT found.' >&4    ;;
8871         esac
8872 esac
8873 set d_sched_yield
8874 eval $setvar
8875
8876 : see if pthread_yield exists
8877 set try -DPTHREAD_YIELD
8878 if eval $compile; then
8879     val="$define"
8880     case "$sched_yield" in
8881     '') sched_yield='pthread_yield()' ;;
8882     esac
8883 else
8884     set try -DPTHREAD_YIELD_NULL
8885     if eval $compile; then
8886         val="$define"
8887         case "$sched_yield" in
8888         '') sched_yield='pthread_yield(NULL)' ;;
8889         esac
8890     else
8891         val="$undef"
8892     fi
8893 fi
8894 case "$usethreads" in
8895 $define)
8896         case "$val" in
8897         $define) echo 'pthread_yield() found.' >&4      ;;
8898         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8899         esac
8900         ;;
8901 esac
8902 set d_pthread_yield
8903 eval $setvar
8904
8905 case "$sched_yield" in
8906 '') sched_yield=undef ;;
8907 esac
8908
8909 $rm -f try try.*
8910
8911 : see if this is a pwd.h system
8912 set pwd.h i_pwd
8913 eval $inhdr
8914
8915 case "$i_pwd" in
8916 $define)
8917         xxx=`./findhdr pwd.h`
8918         $cppstdin $cppflags $cppminus < $xxx >$$.h
8919
8920         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8921                 val="$define"
8922         else
8923                 val="$undef"
8924         fi
8925         set d_pwquota
8926         eval $setvar
8927
8928         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
8929                 val="$define"
8930         else
8931                 val="$undef"
8932         fi
8933         set d_pwage
8934         eval $setvar
8935
8936         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
8937                 val="$define"
8938         else
8939                 val="$undef"
8940         fi
8941         set d_pwchange
8942         eval $setvar
8943
8944         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
8945                 val="$define"
8946         else
8947                 val="$undef"
8948         fi
8949         set d_pwclass
8950         eval $setvar
8951
8952         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
8953                 val="$define"
8954         else
8955                 val="$undef"
8956         fi
8957         set d_pwexpire
8958         eval $setvar
8959
8960         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
8961                 val="$define"
8962         else
8963                 val="$undef"
8964         fi
8965         set d_pwcomment
8966         eval $setvar
8967
8968         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
8969                 val="$define"
8970         else
8971                 val="$undef"
8972         fi
8973         set d_pwgecos
8974         eval $setvar
8975
8976         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
8977                 val="$define"
8978         else
8979                 val="$undef"
8980         fi
8981         set d_pwpasswd
8982         eval $setvar
8983
8984         $rm -f $$.h
8985         ;;
8986 *)
8987         val="$undef"; 
8988         set d_pwquota; eval $setvar
8989         set d_pwage; eval $setvar
8990         set d_pwchange; eval $setvar
8991         set d_pwclass; eval $setvar
8992         set d_pwexpire; eval $setvar
8993         set d_pwcomment; eval $setvar
8994         set d_pwgecos; eval $setvar
8995         set d_pwpasswd; eval $setvar
8996         ;;
8997 esac
8998
8999 : see if readdir and friends exist
9000 set readdir d_readdir
9001 eval $inlibc
9002 set seekdir d_seekdir
9003 eval $inlibc
9004 set telldir d_telldir
9005 eval $inlibc
9006 set rewinddir d_rewinddir
9007 eval $inlibc
9008
9009 : see if readlink exists
9010 set readlink d_readlink
9011 eval $inlibc
9012
9013 : see if readv exists
9014 set readv d_readv
9015 eval $inlibc
9016
9017 : see if rename exists
9018 set rename d_rename
9019 eval $inlibc
9020
9021 : see if rmdir exists
9022 set rmdir d_rmdir
9023 eval $inlibc
9024
9025 : see if memory.h is available.
9026 val=''
9027 set memory.h val
9028 eval $inhdr
9029
9030 : See if it conflicts with string.h
9031 case "$val" in
9032 $define)
9033         case "$strings" in
9034         '') ;;
9035         *)
9036                 $cppstdin $cppflags $cppminus < $strings > mem.h
9037                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9038                         echo " "
9039                         echo "We won't be including <memory.h>."
9040                         val="$undef"
9041                 fi
9042                 $rm -f mem.h
9043                 ;;
9044         esac
9045 esac
9046 set i_memory
9047 eval $setvar
9048
9049 : can bcopy handle overlapping blocks?
9050 val="$undef"
9051 case "$d_bcopy" in
9052 "$define")
9053         echo " "
9054         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9055         $cat >try.c <<EOCP
9056 #$i_memory I_MEMORY
9057 #$i_stdlib I_STDLIB
9058 #$i_string I_STRING
9059 #$i_unistd I_UNISTD
9060 EOCP
9061         $cat >>try.c <<'EOCP'
9062 #include <stdio.h>
9063 #ifdef I_MEMORY
9064 #  include <memory.h>
9065 #endif
9066 #ifdef I_STDLIB
9067 #  include <stdlib.h>
9068 #endif
9069 #ifdef I_STRING
9070 #  include <string.h>
9071 #else
9072 #  include <strings.h>
9073 #endif
9074 #ifdef I_UNISTD
9075 #  include <unistd.h>  /* Needed for NetBSD */
9076 #endif
9077 int main()
9078 {
9079 char buf[128], abc[128];
9080 char *b;
9081 int len;
9082 int off;
9083 int align;
9084
9085 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9086
9087 for (align = 7; align >= 0; align--) {
9088         for (len = 36; len; len--) {
9089                 b = buf+align;
9090                 bcopy(abc, b, len);
9091                 for (off = 1; off <= len; off++) {
9092                         bcopy(b, b+off, len);
9093                         bcopy(b+off, b, len);
9094                         if (bcmp(b, abc, len))
9095                                 exit(1);
9096                 }
9097         }
9098 }
9099 exit(0);
9100 }
9101 EOCP
9102         set try
9103         if eval $compile_ok; then
9104                 if ./try 2>/dev/null; then
9105                         echo "Yes, it can."
9106                         val="$define"
9107                 else
9108                         echo "It can't, sorry."
9109                         case "$d_memmove" in
9110                         "$define") echo "But that's Ok since you have memmove()." ;;
9111                         esac
9112                 fi
9113         else
9114                 echo "(I can't compile the test program, so we'll assume not...)"
9115                 case "$d_memmove" in
9116                 "$define") echo "But that's Ok since you have memmove()." ;;
9117                 esac
9118         fi
9119         ;;
9120 esac
9121 $rm -f try.* try core
9122 set d_safebcpy
9123 eval $setvar
9124
9125 : can memcpy handle overlapping blocks?
9126 val="$undef"
9127 case "$d_memcpy" in
9128 "$define")
9129         echo " "
9130         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9131         $cat >try.c <<EOCP
9132 #$i_memory I_MEMORY
9133 #$i_stdlib I_STDLIB
9134 #$i_string I_STRING
9135 #$i_unistd I_UNISTD
9136 EOCP
9137         $cat >>try.c <<'EOCP'
9138 #include <stdio.h>
9139 #ifdef I_MEMORY
9140 #  include <memory.h>
9141 #endif
9142 #ifdef I_STDLIB
9143 #  include <stdlib.h>
9144 #endif
9145 #ifdef I_STRING
9146 #  include <string.h>
9147 #else
9148 #  include <strings.h>
9149 #endif
9150 #ifdef I_UNISTD
9151 #  include <unistd.h>  /* Needed for NetBSD */
9152 #endif
9153 int main()
9154 {
9155 char buf[128], abc[128];
9156 char *b;
9157 int len;
9158 int off;
9159 int align;
9160
9161 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9162    try to store the string in read-only memory. */
9163 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9164
9165 for (align = 7; align >= 0; align--) {
9166         for (len = 36; len; len--) {
9167                 b = buf+align;
9168                 memcpy(b, abc, len);
9169                 for (off = 1; off <= len; off++) {
9170                         memcpy(b+off, b, len);
9171                         memcpy(b, b+off, len);
9172                         if (memcmp(b, abc, len))
9173                                 exit(1);
9174                 }
9175         }
9176 }
9177 exit(0);
9178 }
9179 EOCP
9180         set try
9181         if eval $compile_ok; then
9182                 if ./try 2>/dev/null; then
9183                         echo "Yes, it can."
9184                         val="$define"
9185                 else
9186                         echo "It can't, sorry."
9187                         case "$d_memmove" in
9188                         "$define") echo "But that's Ok since you have memmove()." ;;
9189                         esac
9190                 fi
9191         else
9192                 echo "(I can't compile the test program, so we'll assume not...)"
9193                 case "$d_memmove" in
9194                 "$define") echo "But that's Ok since you have memmove()." ;;
9195                 esac
9196         fi
9197         ;;
9198 esac
9199 $rm -f try.* try core
9200 set d_safemcpy
9201 eval $setvar
9202
9203 : can memcmp be trusted to compare relative magnitude?
9204 val="$undef"
9205 case "$d_memcmp" in
9206 "$define")
9207         echo " "
9208         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9209         $cat >try.c <<EOCP
9210 #$i_memory I_MEMORY
9211 #$i_stdlib I_STDLIB
9212 #$i_string I_STRING
9213 #$i_unistd I_UNISTD
9214 EOCP
9215         $cat >>try.c <<'EOCP'
9216 #include <stdio.h>
9217 #ifdef I_MEMORY
9218 #  include <memory.h>
9219 #endif
9220 #ifdef I_STDLIB
9221 #  include <stdlib.h>
9222 #endif
9223 #ifdef I_STRING
9224 #  include <string.h>
9225 #else
9226 #  include <strings.h>
9227 #endif
9228 #ifdef I_UNISTD
9229 #  include <unistd.h>  /* Needed for NetBSD */
9230 #endif
9231 int main()
9232 {
9233 char a = -1;
9234 char b = 0;
9235 if ((a < b) && memcmp(&a, &b, 1) < 0)
9236         exit(1);
9237 exit(0);
9238 }
9239 EOCP
9240         set try
9241         if eval $compile_ok; then
9242                 if ./try 2>/dev/null; then
9243                         echo "Yes, it can."
9244                         val="$define"
9245                 else
9246                         echo "No, it can't (it uses signed chars)."
9247                 fi
9248         else
9249                 echo "(I can't compile the test program, so we'll assume not...)"
9250         fi
9251         ;;
9252 esac
9253 $rm -f try.* try core
9254 set d_sanemcmp
9255 eval $setvar
9256
9257 : see if select exists
9258 set select d_select
9259 eval $inlibc
9260
9261 : see if semctl exists
9262 set semctl d_semctl
9263 eval $inlibc
9264
9265 : see if semget exists
9266 set semget d_semget
9267 eval $inlibc
9268
9269 : see if semop exists
9270 set semop d_semop
9271 eval $inlibc
9272
9273 : see how much of the 'sem*(2)' library is present.
9274 h_sem=true
9275 echo " "
9276 case "$d_semctl$d_semget$d_semop" in
9277 *"$undef"*) h_sem=false;;
9278 esac
9279 case "$osname" in
9280 freebsd)
9281     case "`ipcs 2>&1`" in
9282     "SVID messages"*"not configured"*)
9283         echo "Your $osname does not have the sem*(2) configured." >&4
9284         h_sem=false
9285         val="$undef"
9286         set semctl d_semctl
9287         eval $setvar
9288         set semget d_semget
9289         eval $setvar
9290         set semop d_semop
9291         eval $setvar
9292         ;;
9293     esac
9294     ;;
9295 esac
9296 : we could also check for sys/ipc.h ...
9297 if $h_sem && $test `./findhdr sys/sem.h`; then
9298         echo "You have the full sem*(2) library." >&4
9299         val="$define"
9300 else
9301         echo "You don't have the full sem*(2) library." >&4
9302         val="$undef"
9303 fi
9304 set d_sem
9305 eval $setvar
9306
9307 : see whether sys/sem.h defines union semun
9308 echo " "
9309 $cat > try.c <<'END'
9310 #include <sys/types.h>
9311 #include <sys/ipc.h>
9312 #include <sys/sem.h>
9313 int main () { union semun semun; semun.buf = 0; }
9314 END
9315 set try
9316 if eval $compile; then
9317     echo "You have union semun in <sys/sem.h>." >&4
9318     val="$define"
9319 else
9320     echo "You do not have union semun in <sys/sem.h>." >&4
9321     val="$undef"
9322 fi
9323 $rm -f try try.c try.h
9324 set d_union_semun
9325 eval $setvar
9326
9327 : see how to do semctl IPC_STAT
9328 case "$d_sem" in
9329 $define)
9330     : see whether semctl IPC_STAT can use union semun
9331     echo " "
9332     $cat > try.h <<END
9333 #ifndef S_IRUSR
9334 #   ifdef S_IREAD
9335 #       define S_IRUSR S_IREAD
9336 #       define S_IWUSR S_IWRITE
9337 #       define S_IXUSR S_IEXEC
9338 #   else
9339 #       define S_IRUSR 0400
9340 #       define S_IWUSR 0200
9341 #       define S_IXUSR 0100
9342 #   endif
9343 #   define S_IRGRP (S_IRUSR>>3)
9344 #   define S_IWGRP (S_IWUSR>>3)
9345 #   define S_IXGRP (S_IXUSR>>3)
9346 #   define S_IROTH (S_IRUSR>>6)
9347 #   define S_IWOTH (S_IWUSR>>6)
9348 #   define S_IXOTH (S_IXUSR>>6)
9349 #endif
9350 #ifndef S_IRWXU
9351 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9352 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9353 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9354 #endif
9355 END
9356
9357     $cat > try.c <<END
9358 #include <sys/types.h>
9359 #include <sys/ipc.h>
9360 #include <sys/sem.h>
9361 #include <sys/stat.h>
9362 #include <stdio.h>
9363 #include <errno.h>
9364 #include "try.h"
9365 #ifndef errno
9366 extern int errno;
9367 #endif
9368 #$d_union_semun HAS_UNION_SEMUN
9369 int main() {
9370     union semun
9371 #ifndef HAS_UNION_SEMUN
9372     {
9373         int val;
9374         struct semid_ds *buf;
9375         unsigned short *array;
9376     }
9377 #endif
9378     arg;
9379     int sem, st;
9380
9381 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9382     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9383     if (sem > -1) {
9384         struct semid_ds argbuf;
9385         arg.buf = &argbuf;
9386 #       ifdef IPC_STAT
9387         st = semctl(sem, 0, IPC_STAT, arg);
9388         if (st == 0)
9389             printf("semun\n");
9390         else
9391 #       endif /* IPC_STAT */
9392             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9393 #       ifdef IPC_RMID
9394         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9395 #       endif /* IPC_RMID */
9396             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9397     } else
9398 #endif /* IPC_PRIVATE && ... */
9399         printf("semget failed: errno = %d\n", errno);
9400   return 0;
9401 }
9402 END
9403     val="$undef"
9404     set try
9405     if eval $compile; then
9406         xxx=`./try`
9407         case "$xxx" in
9408         semun) val="$define" ;;
9409         esac
9410     fi
9411     $rm -f try try.c
9412     set d_semctl_semun
9413     eval $setvar
9414     case "$d_semctl_semun" in
9415     $define)
9416         echo "You can use union semun for semctl IPC_STAT." >&4
9417         also='also'
9418         ;;
9419     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9420         also=''
9421         ;;
9422     esac
9423
9424     : see whether semctl IPC_STAT can use struct semid_ds pointer
9425     $cat > try.c <<'END'
9426 #include <sys/types.h>
9427 #include <sys/ipc.h>
9428 #include <sys/sem.h>
9429 #include <sys/stat.h>
9430 #include "try.h"
9431 #include <stdio.h>
9432 #include <errno.h>
9433 #ifndef errno
9434 extern int errno;
9435 #endif
9436 int main() {
9437     struct semid_ds arg;
9438     int sem, st;
9439
9440 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9441     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9442     if (sem > -1) {
9443 #       ifdef IPC_STAT
9444         st = semctl(sem, 0, IPC_STAT, &arg);
9445         if (st == 0)
9446             printf("semid_ds\n");
9447         else
9448 #       endif /* IPC_STAT */
9449             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9450 #       ifdef IPC_RMID
9451         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9452 #       endif /* IPC_RMID */
9453             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9454     } else
9455 #endif /* IPC_PRIVATE && ... */
9456         printf("semget failed: errno = %d\n", errno);
9457
9458     return 0;
9459 }
9460 END
9461     val="$undef"
9462     set try
9463     if eval $compile; then
9464         xxx=`./try`
9465         case "$xxx" in
9466         semid_ds) val="$define" ;;
9467         esac
9468     fi
9469     $rm -f try try.c
9470     set d_semctl_semid_ds
9471     eval $setvar
9472     case "$d_semctl_semid_ds" in
9473     $define)
9474         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9475         ;;
9476     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9477         ;;
9478     esac
9479     $rm -f try.h
9480     ;;
9481 *)  val="$undef"
9482
9483     # We do not have the full sem*(2) library, so assume we can not
9484     # use either.
9485
9486     set d_semctl_semun
9487     eval $setvar
9488
9489     set d_semctl_semid_ds
9490     eval $setvar
9491     ;;
9492 esac
9493
9494 : see if setegid exists
9495 set setegid d_setegid
9496 eval $inlibc
9497
9498 : see if seteuid exists
9499 set seteuid d_seteuid
9500 eval $inlibc
9501
9502 : see if setgrent exists
9503 set setgrent d_setgrent
9504 eval $inlibc
9505
9506 : see if sethostent exists
9507 set sethostent d_sethent
9508 eval $inlibc
9509
9510 : see if setlinebuf exists
9511 set setlinebuf d_setlinebuf
9512 eval $inlibc
9513
9514 : see if setlocale exists
9515 set setlocale d_setlocale
9516 eval $inlibc
9517
9518 : see if setnetent exists
9519 set setnetent d_setnent
9520 eval $inlibc
9521
9522 : see if setprotoent exists
9523 set setprotoent d_setpent
9524 eval $inlibc
9525
9526 : see if setpgid exists
9527 set setpgid d_setpgid
9528 eval $inlibc
9529
9530 : see if setpgrp2 exists
9531 set setpgrp2 d_setpgrp2
9532 eval $inlibc
9533
9534 : see if setpriority exists
9535 set setpriority d_setprior
9536 eval $inlibc
9537
9538 : see if setpwent exists
9539 set setpwent d_setpwent
9540 eval $inlibc
9541
9542 : see if setregid exists
9543 set setregid d_setregid
9544 eval $inlibc
9545 set setresgid d_setresgid
9546 eval $inlibc
9547
9548 : see if setreuid exists
9549 set setreuid d_setreuid
9550 eval $inlibc
9551 set setresuid d_setresuid
9552 eval $inlibc
9553
9554 : see if setrgid exists
9555 set setrgid d_setrgid
9556 eval $inlibc
9557
9558 : see if setruid exists
9559 set setruid d_setruid
9560 eval $inlibc
9561
9562 : see if setservent exists
9563 set setservent d_setsent
9564 eval $inlibc
9565
9566 : see if setsid exists
9567 set setsid d_setsid
9568 eval $inlibc
9569
9570 : see if setvbuf exists
9571 set setvbuf d_setvbuf
9572 eval $inlibc
9573
9574 : see if sfio.h is available
9575 set sfio.h i_sfio
9576 eval $inhdr
9577
9578
9579 : see if sfio library is available
9580 case "$i_sfio" in
9581 $define)
9582         val=''
9583         set sfreserve val
9584         eval $inlibc
9585         ;;
9586 *)
9587         val="$undef"
9588         ;;
9589 esac
9590 : Ok, but do we want to use it.
9591 case "$val" in
9592 $define)
9593         case "$usesfio" in
9594         true|$define|[yY]*) dflt='y';;
9595         *) dflt='n';;
9596         esac
9597         echo "$package can use the sfio library, but it is experimental."
9598         rp="You seem to have sfio available, do you want to try using it?"
9599         . ./myread
9600         case "$ans" in
9601         y|Y) ;;
9602         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9603                 val="$undef"
9604                 : Remove sfio from list of libraries to use
9605                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9606                 shift
9607                 libs="$*"
9608                 echo "libs = $libs" >&4
9609                 ;;
9610         esac
9611         ;;
9612 *)      case "$usesfio" in
9613         true|$define|[yY]*)
9614                 echo "Sorry, cannot find sfio on this machine" >&4
9615                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9616                 ;;
9617         esac
9618         ;;
9619 esac
9620 set d_sfio
9621 eval $setvar
9622 case "$d_sfio" in
9623 $define) usesfio='true';;
9624 *) usesfio='false';;
9625 esac
9626
9627 : see if shmctl exists
9628 set shmctl d_shmctl
9629 eval $inlibc
9630
9631 : see if shmget exists
9632 set shmget d_shmget
9633 eval $inlibc
9634
9635 : see if shmat exists
9636 set shmat d_shmat
9637 eval $inlibc
9638 : see what shmat returns
9639 case "$d_shmat" in
9640 "$define")
9641         $cat >shmat.c <<'END'
9642 #include <sys/shm.h>
9643 void *shmat();
9644 END
9645         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9646                 shmattype='void *'
9647         else
9648                 shmattype='char *'
9649         fi
9650         echo "and it returns ($shmattype)." >&4
9651         : see if a prototype for shmat is available
9652         xxx=`./findhdr sys/shm.h`
9653         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9654         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9655                 val="$define"
9656         else
9657                 val="$undef"
9658         fi
9659         $rm -f shmat.[co]
9660         ;;
9661 *)
9662         val="$undef"
9663         ;;
9664 esac
9665 set d_shmatprototype
9666 eval $setvar
9667
9668 : see if shmdt exists
9669 set shmdt d_shmdt
9670 eval $inlibc
9671
9672 : see how much of the 'shm*(2)' library is present.
9673 h_shm=true
9674 echo " "
9675 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9676 *"$undef"*) h_shm=false;;
9677 esac
9678 case "$osname" in
9679 freebsd)
9680     case "`ipcs 2>&1`" in
9681     "SVID shared memory"*"not configured"*)
9682         echo "Your $osname does not have the shm*(2) configured." >&4
9683         h_shm=false
9684         val="$undef"
9685         set shmctl d_shmctl
9686         evat $setvar
9687         set shmget d_shmget
9688         evat $setvar
9689         set shmat d_shmat
9690         evat $setvar
9691         set shmdt d_shmdt
9692         evat $setvar
9693         ;;
9694     esac
9695     ;;
9696 esac
9697 : we could also check for sys/ipc.h ...
9698 if $h_shm && $test `./findhdr sys/shm.h`; then
9699         echo "You have the full shm*(2) library." >&4
9700         val="$define"
9701 else
9702         echo "You don't have the full shm*(2) library." >&4
9703         val="$undef"
9704 fi
9705 set d_shm
9706 eval $setvar
9707
9708 echo " "
9709 : see if we have sigaction
9710 if set sigaction val -f d_sigaction; eval $csym; $val; then
9711         echo 'sigaction() found.' >&4
9712         $cat > try.c <<'EOP'
9713 #include <stdio.h>
9714 #include <sys/types.h>
9715 #include <signal.h>
9716 int main()
9717 {
9718     struct sigaction act, oact;
9719 }
9720 EOP
9721         set try
9722         if eval $compile_ok; then
9723                 val="$define"
9724         else
9725                 echo "But you don't seem to have a useable struct sigaction." >&4
9726                 val="$undef"
9727         fi
9728 else
9729         echo 'sigaction NOT found.' >&4
9730         val="$undef"
9731 fi
9732 set d_sigaction; eval $setvar
9733 $rm -f try try$_o try.c
9734
9735 : see if sigsetjmp exists
9736 echo " "
9737 case "$d_sigsetjmp" in
9738 '')
9739         $cat >try.c <<'EOP'
9740 #include <setjmp.h>
9741 sigjmp_buf env;
9742 int set = 1;
9743 int main()
9744 {
9745         if (sigsetjmp(env,1))
9746                 exit(set);
9747         set = 0;
9748         siglongjmp(env, 1);
9749         exit(1);
9750 }
9751 EOP
9752         set try
9753         if eval $compile; then
9754                 if ./try >/dev/null 2>&1; then
9755                         echo "POSIX sigsetjmp found." >&4
9756                         val="$define"
9757                 else
9758                         $cat >&4 <<EOM
9759 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9760 I'll ignore them.
9761 EOM
9762                         val="$undef"
9763                 fi
9764         else
9765                 echo "sigsetjmp not found." >&4
9766                 val="$undef"
9767         fi
9768         ;;
9769 *) val="$d_sigsetjmp"
9770         case "$d_sigsetjmp" in
9771         $define) echo "POSIX sigsetjmp found." >&4;;
9772         $undef) echo "sigsetjmp not found." >&4;;
9773         esac
9774         ;;
9775 esac
9776 set d_sigsetjmp
9777 eval $setvar
9778 $rm -f try.c try
9779
9780 : see if stat knows about block sizes
9781 echo " "
9782 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9783 eval $hasfield
9784
9785 : see if _ptr and _cnt from stdio act std
9786 echo " "
9787 if $contains '_IO_fpos_t' `./findhdr stdio.h` >/dev/null 2>&1 ; then
9788         echo "(Looks like you have stdio.h from Linux.)"
9789         case "$stdio_ptr" in
9790         '') stdio_ptr='((fp)->_IO_read_ptr)'
9791                 ptr_lval=$define
9792                 ;;
9793         *)      ptr_lval=$d_stdio_ptr_lval;;
9794         esac
9795         case "$stdio_cnt" in
9796         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9797                 cnt_lval=$undef
9798                 ;;
9799         *)      cnt_lval=$d_stdio_cnt_lval;;
9800         esac
9801         case "$stdio_base" in
9802         '') stdio_base='((fp)->_IO_read_base)';;
9803         esac
9804         case "$stdio_bufsiz" in
9805         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9806         esac
9807 else
9808         case "$stdio_ptr" in
9809         '') stdio_ptr='((fp)->_ptr)'
9810                 ptr_lval=$define
9811                 ;;
9812         *)      ptr_lval=$d_stdio_ptr_lval;;
9813         esac
9814         case "$stdio_cnt" in
9815         '') stdio_cnt='((fp)->_cnt)'
9816                 cnt_lval=$define
9817                 ;;
9818         *)      cnt_lval=$d_stdio_cnt_lval;;
9819         esac
9820         case "$stdio_base" in
9821         '') stdio_base='((fp)->_base)';;
9822         esac
9823         case "$stdio_bufsiz" in
9824         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9825         esac
9826 fi
9827 : test whether _ptr and _cnt really work
9828 echo "Checking how std your stdio is..." >&4
9829 $cat >try.c <<EOP
9830 #include <stdio.h>
9831 #define FILE_ptr(fp)    $stdio_ptr
9832 #define FILE_cnt(fp)    $stdio_cnt
9833 int main() {
9834         FILE *fp = fopen("try.c", "r");
9835         char c = getc(fp);
9836         if (
9837                 18 <= FILE_cnt(fp) &&
9838                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9839         )
9840                 exit(0);
9841         exit(1);
9842 }
9843 EOP
9844 val="$undef"
9845 set try
9846 if eval $compile; then
9847         if ./try; then
9848                 echo "Your stdio acts pretty std."
9849                 val="$define"
9850         else
9851                 echo "Your stdio isn't very std."
9852         fi
9853 else
9854         echo "Your stdio doesn't appear very std."
9855 fi
9856 $rm -f try.c try
9857 set d_stdstdio
9858 eval $setvar
9859
9860 : Can _ptr be used as an lvalue?
9861 case "$d_stdstdio$ptr_lval" in
9862 $define$define) val=$define ;;
9863 *) val=$undef ;;
9864 esac
9865 set d_stdio_ptr_lval
9866 eval $setvar
9867
9868 : Can _cnt be used as an lvalue?
9869 case "$d_stdstdio$cnt_lval" in
9870 $define$define) val=$define ;;
9871 *) val=$undef ;;
9872 esac
9873 set d_stdio_cnt_lval
9874 eval $setvar
9875
9876 : see if _base is also standard
9877 val="$undef"
9878 case "$d_stdstdio" in
9879 $define)
9880         $cat >try.c <<EOP
9881 #include <stdio.h>
9882 #define FILE_base(fp)   $stdio_base
9883 #define FILE_bufsiz(fp) $stdio_bufsiz
9884 int main() {
9885         FILE *fp = fopen("try.c", "r");
9886         char c = getc(fp);
9887         if (
9888                 19 <= FILE_bufsiz(fp) &&
9889                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9890         )
9891                 exit(0);
9892         exit(1);
9893 }
9894 EOP
9895         set try
9896         if eval $compile; then
9897                 if ./try; then
9898                         echo "And its _base field acts std."
9899                         val="$define"
9900                 else
9901                         echo "But its _base field isn't std."
9902                 fi
9903         else
9904                 echo "However, it seems to be lacking the _base field."
9905         fi
9906         $rm -f try.c try
9907         ;;
9908 esac
9909 set d_stdiobase
9910 eval $setvar
9911
9912 : see if strcoll exists
9913 set strcoll d_strcoll
9914 eval $inlibc
9915
9916 : check for structure copying
9917 echo " "
9918 echo "Checking to see if your C compiler can copy structs..." >&4
9919 $cat >try.c <<'EOCP'
9920 int main()
9921 {
9922         struct blurfl {
9923                 int dyick;
9924         } foo, bar;
9925
9926         foo = bar;
9927 }
9928 EOCP
9929 if $cc -c try.c >/dev/null 2>&1 ; then
9930         val="$define"
9931         echo "Yup, it can."
9932 else
9933         val="$undef"
9934         echo "Nope, it can't."
9935 fi
9936 set d_strctcpy
9937 eval $setvar
9938 $rm -f try.*
9939
9940 : see if strerror and/or sys_errlist[] exist
9941 echo " "
9942 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
9943     if set strerror val -f d_strerror; eval $csym; $val; then
9944                 echo 'strerror() found.' >&4
9945                 d_strerror="$define"
9946                 d_strerrm='strerror(e)'
9947                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9948                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
9949                         d_syserrlst="$define"
9950                 else
9951                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
9952                         d_syserrlst="$undef"
9953                 fi
9954     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
9955                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
9956                 echo 'strerror() found in string header.' >&4
9957                 d_strerror="$define"
9958                 d_strerrm='strerror(e)'
9959                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9960                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
9961                                 d_syserrlst="$define"
9962                 else
9963                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
9964                         d_syserrlst="$undef"
9965                 fi
9966     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
9967                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
9968                 d_strerror="$undef"
9969                 d_syserrlst="$define"
9970                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
9971     else
9972                 echo 'strerror() and sys_errlist[] NOT found.' >&4
9973                 d_strerror="$undef"
9974                 d_syserrlst="$undef"
9975                 d_strerrm='"unknown"'
9976     fi
9977 fi
9978
9979 : see if strtod exists
9980 set strtod d_strtod
9981 eval $inlibc
9982
9983 : see if strtol exists
9984 set strtol d_strtol
9985 eval $inlibc
9986
9987 : see if strtoul exists
9988 set strtoul d_strtoul
9989 eval $inlibc
9990
9991 : see if strxfrm exists
9992 set strxfrm d_strxfrm
9993 eval $inlibc
9994
9995 : see if symlink exists
9996 set symlink d_symlink
9997 eval $inlibc
9998
9999 : see if syscall exists
10000 set syscall d_syscall
10001 eval $inlibc
10002
10003 : see if sysconf exists
10004 set sysconf d_sysconf
10005 eval $inlibc
10006
10007 : see if system exists
10008 set system d_system
10009 eval $inlibc
10010
10011 : see if tcgetpgrp exists
10012 set tcgetpgrp d_tcgetpgrp
10013 eval $inlibc
10014
10015 : see if tcsetpgrp exists
10016 set tcsetpgrp d_tcsetpgrp
10017 eval $inlibc
10018
10019 : see if sys/types.h has to be included
10020 set sys/types.h i_systypes
10021 eval $inhdr
10022
10023 : see if prototype for telldir is available
10024 echo " "
10025 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10026 eval $hasproto
10027
10028 : define an is-a-typedef? function
10029 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10030 case "$inclist" in
10031 "") inclist="sys/types.h";;
10032 esac;
10033 eval "varval=\$$var";
10034 case "$varval" in
10035 "")
10036         $rm -f temp.c;
10037         for inc in $inclist; do
10038                 echo "#include <$inc>" >>temp.c;
10039         done;
10040         echo "#ifdef $type" >> temp.c;
10041         echo "printf(\"We have $type\");" >> temp.c;
10042         echo "#endif" >> temp.c;
10043         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10044         if $contains $type temp.E >/dev/null 2>&1; then
10045                 eval "$var=\$type";
10046         else
10047                 eval "$var=\$def";
10048         fi;
10049         $rm -f temp.?;;
10050 *) eval "$var=\$varval";;
10051 esac'
10052
10053 : define an is-a-typedef? function that prompts if the type is not available.
10054 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10055 case "$inclist" in
10056 "") inclist="sys/types.h";;
10057 esac;
10058 eval "varval=\$$var";
10059 case "$varval" in
10060 "")
10061         $rm -f temp.c;
10062         for inc in $inclist; do
10063                 echo "#include <$inc>" >>temp.c;
10064         done;
10065         echo "#ifdef $type" >> temp.c;
10066         echo "printf(\"We have $type\");" >> temp.c;
10067         echo "#endif" >> temp.c;
10068         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10069         echo " " ;
10070         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10071         if $contains $type temp.E >/dev/null 2>&1; then
10072                 echo "$type found." >&4;
10073                 eval "$var=\$type";
10074         else
10075                 echo "$type NOT found." >&4;
10076                 dflt="$def";
10077                 . ./myread ;
10078                 eval "$var=\$ans";
10079         fi;
10080         $rm -f temp.?;;
10081 *) eval "$var=\$varval";;
10082 esac'
10083
10084 : see if this is a sys/times.h system
10085 set sys/times.h i_systimes
10086 eval $inhdr
10087
10088 : see if times exists
10089 echo " "
10090 if set times val -f d_times; eval $csym; $val; then
10091         echo 'times() found.' >&4
10092         d_times="$define"
10093         inc=''
10094         case "$i_systimes" in
10095         "$define") inc='sys/times.h';;
10096         esac
10097         rp="What is the type returned by times() on this system?"
10098         set clock_t clocktype long stdio.h sys/types.h $inc
10099         eval $typedef_ask
10100 else
10101         echo 'times() NOT found, hope that will do.' >&4
10102         d_times="$undef"
10103         clocktype='int'
10104 fi
10105
10106 : see if truncate exists
10107 set truncate d_truncate
10108 eval $inlibc
10109
10110 : see if tzname[] exists
10111 echo " "
10112 if set tzname val -a d_tzname; eval $csym; $val; then
10113         val="$define"
10114         echo 'tzname[] found.' >&4
10115 else
10116         val="$undef"
10117         echo 'tzname[] NOT found.' >&4
10118 fi
10119 set d_tzname
10120 eval $setvar
10121
10122 : see if umask exists
10123 set umask d_umask
10124 eval $inlibc
10125
10126 : backward compatibility for d_hvfork
10127 if test X$d_hvfork != X; then
10128         d_vfork="$d_hvfork"
10129         d_hvfork=''
10130 fi
10131 : see if there is a vfork
10132 val=''
10133 set vfork val
10134 eval $inlibc
10135
10136 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10137 : perl on Solaris 2.x, and probably elsewhere.
10138 case "$val" in
10139 $define)
10140         echo " "
10141         case "$usevfork" in
10142         false) dflt='n';;
10143         *) dflt='y';;
10144         esac
10145         rp="Some systems have problems with vfork().  Do you want to use it?"
10146         . ./myread
10147         case "$ans" in
10148         y|Y) ;;
10149         *)
10150                 echo "Ok, we won't use vfork()."
10151                 val="$undef"
10152                 ;;
10153         esac
10154         ;;
10155 esac
10156 set d_vfork
10157 eval $setvar
10158 case "$d_vfork" in
10159 $define) usevfork='true';;
10160 *) usevfork='false';;
10161 esac
10162
10163 : see if this is an sysdir system
10164 set sys/dir.h i_sysdir
10165 eval $inhdr
10166
10167 : see if this is an sysndir system
10168 set sys/ndir.h i_sysndir
10169 eval $inhdr
10170
10171 : see if closedir exists
10172 set closedir d_closedir
10173 eval $inlibc
10174
10175 case "$d_closedir" in
10176 "$define")
10177         echo " "
10178         echo "Checking whether closedir() returns a status..." >&4
10179         cat > closedir.c <<EOM
10180 #$i_dirent I_DIRENT             /**/
10181 #$i_sysdir I_SYS_DIR            /**/
10182 #$i_sysndir I_SYS_NDIR          /**/
10183 #$i_systypes I_SYS_TYPES        /**/
10184
10185 #if defined(I_SYS_TYPES)
10186 #include <sys/types.h>
10187 #endif
10188 #if defined(I_DIRENT)
10189 #include <dirent.h>
10190 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10191 #include <sys/dir.h>
10192 #endif
10193 #else
10194 #ifdef I_SYS_NDIR
10195 #include <sys/ndir.h>
10196 #else
10197 #ifdef I_SYS_DIR
10198 #ifdef hp9000s500
10199 #include <ndir.h>       /* may be wrong in the future */
10200 #else
10201 #include <sys/dir.h>
10202 #endif
10203 #endif
10204 #endif
10205 #endif 
10206 int main() { return closedir(opendir(".")); }
10207 EOM
10208         set closedir
10209         if eval $compile_ok; then
10210                 if ./closedir > /dev/null 2>&1 ; then
10211                         echo "Yes, it does."
10212                         val="$undef"
10213                 else
10214                         echo "No, it doesn't."
10215                         val="$define"
10216                 fi
10217         else
10218                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10219                 val="$define"
10220         fi
10221         ;;
10222 *)
10223         val="$undef";
10224         ;;
10225 esac
10226 set d_void_closedir
10227 eval $setvar
10228 $rm -f closedir*
10229 : check for volatile keyword
10230 echo " "
10231 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10232 $cat >try.c <<'EOCP'
10233 int main()
10234 {
10235         typedef struct _goo_struct goo_struct;
10236         goo_struct * volatile goo = ((goo_struct *)0);
10237         struct _goo_struct {
10238                 long long_int;
10239                 int reg_int;
10240                 char char_var;
10241         };
10242         typedef unsigned short foo_t;
10243         char *volatile foo;
10244         volatile int bar;
10245         volatile foo_t blech;
10246         foo = foo;
10247 }
10248 EOCP
10249 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10250         val="$define"
10251         echo "Yup, it does."
10252 else
10253         val="$undef"
10254         echo "Nope, it doesn't."
10255 fi
10256 set d_volatile
10257 eval $setvar
10258 $rm -f try.*
10259
10260 : see if there is a wait4
10261 set wait4 d_wait4
10262 eval $inlibc
10263
10264 : see if waitpid exists
10265 set waitpid d_waitpid
10266 eval $inlibc
10267
10268 : see if wcstombs exists
10269 set wcstombs d_wcstombs
10270 eval $inlibc
10271
10272 : see if wctomb exists
10273 set wctomb d_wctomb
10274 eval $inlibc
10275
10276 : see if writev exists
10277 set writev d_writev
10278 eval $inlibc
10279
10280 : preserve RCS keywords in files with variable substitution, grrr
10281 Date='$Date'
10282 Id='$Id'
10283 Log='$Log'
10284 RCSfile='$RCSfile'
10285 Revision='$Revision'
10286
10287 case "$crosscompile" in
10288 ''|[nN]*) crosscompile="$undef" ;;
10289 esac
10290
10291 case "$osname" in
10292 next) multiarch="$define" ;;
10293 esac
10294 case "$multiarch" in
10295 ''|[nN]*) multiarch="$undef" ;;
10296 esac
10297
10298 : check for alignment requirements
10299 echo " "
10300 case "$crosscompile$multiarch" in
10301 *$define*)
10302         $cat <<EOM
10303 You seem to be either cross-compiling or doing a multiarchitecture build,
10304 skipping the memory alignment check.
10305
10306 EOM
10307         case "$alignbytes" in
10308         '') alignbytes=8 ;;
10309         esac
10310         ;;
10311 *)
10312         case "$alignbytes" in
10313         '') echo "Checking alignment constraints..." >&4
10314                 $cat >try.c <<'EOCP'
10315 struct foobar {
10316         char foo;
10317         double bar;
10318 } try_algn;
10319 int main()
10320 {
10321         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10322 }
10323 EOCP
10324                 set try
10325                 if eval $compile_ok; then
10326                         dflt=`./try`
10327                 else
10328                         dflt='8'
10329                         echo "(I can't seem to compile the test program...)"
10330                 fi
10331                 ;;
10332         *) dflt="$alignbytes"
10333                 ;;
10334         esac
10335         rp="Doubles must be aligned on a how-many-byte boundary?"
10336         . ./myread
10337         alignbytes="$ans"
10338         $rm -f try.c try
10339         ;;
10340 esac
10341
10342
10343 : check for ordering of bytes in a long
10344 echo " "
10345 case "$crosscompile$multiarch" in
10346 *$define*)
10347         $cat <<EOM
10348 You seem to be either cross-compiling or doing a multiarchitecture build,
10349 skipping the byteorder check.
10350
10351 EOM
10352         byteorder=''
10353         ;;
10354 *)
10355         case "$byteorder" in
10356         '')
10357                 $cat <<'EOM'
10358 In the following, larger digits indicate more significance.  A big-endian
10359 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10360 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10361 machines may have weird orders like 3412.  A Cray will report 87654321. If
10362 the test program works the default is probably right.
10363 I'm now running the test program...
10364 EOM
10365                 $cat >try.c <<'EOCP'
10366 #include <stdio.h>
10367 int main()
10368 {
10369         int i;
10370         union {
10371                 unsigned long l;
10372                 char c[sizeof(long)];
10373         } u;
10374
10375         if (sizeof(long) > 4)
10376                 u.l = (0x08070605L << 32) | 0x04030201L;
10377         else
10378                 u.l = 0x04030201L;
10379         for (i = 0; i < sizeof(long); i++)
10380                 printf("%c", u.c[i]+'0');
10381         printf("\n");
10382         exit(0);
10383 }
10384 EOCP
10385                 xxx_prompt=y
10386                 set try
10387                 if eval $compile && ./try > /dev/null; then
10388                         dflt=`./try`
10389                         case "$dflt" in
10390                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10391                                 echo "(The test program ran ok.)"
10392                                 echo "byteorder=$dflt"
10393                                 xxx_prompt=n
10394                         ;;
10395                         ????|????????) echo "(The test program ran ok.)" ;;
10396                         *) echo "(The test program didn't run right for some reason.)" ;;
10397                         esac
10398                 else
10399                         dflt='4321'
10400                         cat <<'EOM'
10401 (I can't seem to compile the test program.  Guessing big-endian...)
10402 EOM
10403                 fi
10404                 case "$xxx_prompt" in
10405                 y)
10406                         rp="What is the order of bytes in a long?"
10407                         . ./myread
10408                         byteorder="$ans"
10409                         ;;
10410                 *)      byteorder=$dflt
10411                         ;;
10412                 esac
10413                 ;;
10414         esac
10415         $rm -f try.c try
10416         ;;
10417 esac
10418
10419
10420 : how do we catenate cpp tokens here?
10421 echo " "
10422 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10423 $cat >cpp_stuff.c <<'EOCP'
10424 #define RCAT(a,b)a/**/b
10425 #define ACAT(a,b)a ## b
10426 RCAT(Rei,ser)
10427 ACAT(Cir,cus)
10428 EOCP
10429 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10430 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10431         echo "Oh!  Smells like ANSI's been here." >&4
10432         echo "We can catify or stringify, separately or together!"
10433         cpp_stuff=42
10434 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10435         echo "Ah, yes!  The good old days!" >&4
10436         echo "However, in the good old days we don't know how to stringify and"
10437         echo "catify at the same time."
10438         cpp_stuff=1
10439 else
10440         $cat >&4 <<EOM
10441 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10442 to have to edit the values of CAT[2-5] in config.h...
10443 EOM
10444         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10445 fi
10446 $rm -f cpp_stuff.*
10447
10448 : see if this is a db.h system
10449 set db.h i_db
10450 eval $inhdr
10451
10452 case "$i_db" in
10453 $define)
10454         : Check db version.
10455         echo " "
10456         echo "Checking Berkeley DB version ..." >&4
10457         $cat >try.c <<EOCP
10458 #$d_const HASCONST
10459 #ifndef HASCONST
10460 #define const
10461 #endif
10462 #include <sys/types.h>
10463 #include <stdio.h>
10464 #include <db.h>
10465 int main()
10466 {
10467 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10468     int Major, Minor, Patch ;
10469     unsigned long Version ;
10470     (void)db_version(&Major, &Minor, &Patch) ;
10471     printf("You have Berkeley DB Version 2 or greater\n");
10472
10473     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10474                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10475     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10476                 Major, Minor, Patch) ;
10477
10478     /* check that db.h & libdb are compatible */
10479     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10480         printf("db.h and libdb are incompatible\n") ;
10481         exit(3);        
10482     }
10483
10484     printf("db.h and libdb are compatible\n") ;
10485
10486     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10487                 + DB_VERSION_PATCH ;
10488
10489     /* needs to be >= 2.3.4 */
10490     if (Version < 2003004) {
10491     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10492         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10493         exit(2);        
10494     }
10495
10496     exit(0);
10497 #else
10498 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10499     printf("You have Berkeley DB Version 1\n");
10500     exit(0);    /* DB version < 2: the coast is clear. */
10501 #else
10502     exit(1);    /* <db.h> not Berkeley DB? */
10503 #endif
10504 #endif
10505 }
10506 EOCP
10507         set try
10508         if eval $compile && ./try; then
10509                 echo 'Looks OK.' >&4
10510         else
10511                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10512                 i_db=$undef
10513                 case " $libs " in
10514                 *"-ldb "*)
10515                         : Remove db from list of libraries to use
10516                         echo "Removing unusable -ldb from library list" >&4
10517                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10518                         shift
10519                         libs="$*"
10520                         echo "libs = $libs" >&4
10521                         ;;
10522                 esac
10523         fi
10524         $rm -f try.*
10525         ;;
10526 esac
10527
10528 case "$i_db" in
10529 define)
10530         : Check the return type needed for hash 
10531         echo " "
10532         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10533         $cat >try.c <<EOCP
10534 #$d_const HASCONST
10535 #ifndef HASCONST
10536 #define const
10537 #endif
10538 #include <sys/types.h>
10539 #include <db.h>
10540
10541 #ifndef DB_VERSION_MAJOR
10542 u_int32_t hash_cb (ptr, size)
10543 const void *ptr;
10544 size_t size;
10545 {
10546 }
10547 HASHINFO info;
10548 int main()
10549 {
10550         info.hash = hash_cb;
10551 }
10552 #endif
10553 EOCP
10554         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10555                 if $contains warning try.out >>/dev/null 2>&1 ; then
10556                         db_hashtype='int'
10557                 else
10558                         db_hashtype='u_int32_t'
10559                 fi
10560         else
10561                 : XXX Maybe we should just give up here.
10562                 db_hashtype=u_int32_t
10563                 $cat try.out >&4
10564                 echo "Help:  I can't seem to compile the db test program." >&4
10565                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10566         fi
10567         $rm -f try.*
10568         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10569         ;;
10570 *)      db_hashtype=u_int32_t
10571         ;;
10572 esac
10573 case "$i_db" in
10574 define)
10575         : Check the return type needed for prefix 
10576         echo " "
10577         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10578         cat >try.c <<EOCP
10579 #$d_const HASCONST
10580 #ifndef HASCONST
10581 #define const
10582 #endif
10583 #include <sys/types.h>
10584 #include <db.h>
10585
10586 #ifndef DB_VERSION_MAJOR
10587 size_t prefix_cb (key1, key2)
10588 const DBT *key1;
10589 const DBT *key2;
10590 {
10591 }
10592 BTREEINFO info;
10593 int main()
10594 {
10595         info.prefix = prefix_cb;
10596 }
10597 #endif
10598 EOCP
10599         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10600                 if $contains warning try.out >>/dev/null 2>&1 ; then
10601                         db_prefixtype='int'
10602                 else
10603                         db_prefixtype='size_t'
10604                 fi
10605         else
10606                 db_prefixtype='size_t'
10607                 : XXX Maybe we should just give up here.
10608                 $cat try.out >&4
10609                 echo "Help:  I can't seem to compile the db test program." >&4
10610                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10611         fi
10612         $rm -f try.*
10613         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10614         ;;
10615 *)      db_prefixtype='size_t'
10616         ;;
10617 esac
10618
10619 : check for void type
10620 echo " "
10621 echo "Checking to see how well your C compiler groks the void type..." >&4
10622 case "$voidflags" in
10623 '')
10624         $cat >try.c <<'EOCP'
10625 #if TRY & 1
10626 void sub() {
10627 #else
10628 sub() {
10629 #endif
10630         extern void moo();      /* function returning void */
10631         void (*goo)();          /* ptr to func returning void */
10632 #if TRY & 8
10633         void *hue;              /* generic ptr */
10634 #endif
10635 #if TRY & 2
10636         void (*foo[10])();
10637 #endif
10638
10639 #if TRY & 4
10640         if(goo == moo) {
10641                 exit(0);
10642         }
10643 #endif
10644         exit(0);
10645 }
10646 int main() { sub(); }
10647 EOCP
10648         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10649                 voidflags=$defvoidused
10650         echo "Good.  It appears to support void to the level $package wants.">&4
10651                 if $contains warning .out >/dev/null 2>&1; then
10652                         echo "However, you might get some warnings that look like this:"
10653                         $cat .out
10654                 fi
10655         else
10656 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10657                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10658                         echo "It supports 1..."
10659                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10660                                 echo "It also supports 2..."
10661                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10662                                         voidflags=7
10663                                         echo "And it supports 4 but not 8 definitely."
10664                                 else
10665                                         echo "It doesn't support 4..."
10666                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10667                                                 voidflags=11
10668                                                 echo "But it supports 8."
10669                                         else
10670                                                 voidflags=3
10671                                                 echo "Neither does it support 8."
10672                                         fi
10673                                 fi
10674                         else
10675                                 echo "It does not support 2..."
10676                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10677                                         voidflags=13
10678                                         echo "But it supports 4 and 8."
10679                                 else
10680                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10681                                                 voidflags=5
10682                                                 echo "And it supports 4 but has not heard about 8."
10683                                         else
10684                                                 echo "However it supports 8 but not 4."
10685                                         fi
10686                                 fi
10687                         fi
10688                 else
10689                         echo "There is no support at all for void."
10690                         voidflags=0
10691                 fi
10692         fi
10693 esac
10694 case "$voidflags" in
10695 "$defvoidused") ;;
10696 *)      $cat >&4 <<'EOM'
10697   Support flag bits are:
10698     1: basic void declarations.
10699     2: arrays of pointers to functions returning void.
10700     4: operations between pointers to and addresses of void functions.
10701     8: generic void pointers.
10702 EOM
10703         dflt="$voidflags";
10704         rp="Your void support flags add up to what?"
10705         . ./myread
10706         voidflags="$ans"
10707         ;;
10708 esac
10709 $rm -f try.* .out
10710
10711
10712 : How can we generate normalized random numbers ?
10713 echo " "
10714 echo "Looking for a random number function..." >&4
10715 case "$randfunc" in
10716 '')
10717         if set drand48 val -f; eval $csym; $val; then
10718                 dflt="drand48"
10719                 echo "Good, found drand48()." >&4
10720         elif set random val -f; eval $csym; $val; then
10721                 dflt="random"
10722                 echo "OK, found random()." >&4
10723         else
10724                 dflt="rand"
10725                 echo "Yick, looks like I have to use rand()." >&4
10726         fi
10727         echo " "
10728         ;;
10729 *)
10730         dflt="$randfunc"
10731         ;;
10732 esac
10733 cont=true
10734
10735 case "$ccflags" in
10736 *-Dmy_rand=*|*-Dmy_srand=*)
10737         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10738         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10739         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10740         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10741         ;;
10742 esac
10743
10744 while $test "$cont"; do
10745         rp="Use which function to generate random numbers?"
10746         . ./myread
10747         if $test "$ans" = "$dflt"; then
10748                 : null
10749         else
10750                 randbits=''
10751         fi
10752         randfunc="$ans"
10753         if set $ans val -f; eval $csym; $val; then
10754                 cont=''
10755         else
10756                 dflt=y
10757                 rp="I cannot find function $ans. Use that name anyway?"
10758                 . ./myread
10759                 dflt=rand
10760                 case "$ans" in
10761                         [yY]*) cont='';;
10762                 esac
10763         fi
10764         case "$cont" in
10765         '')
10766                 case "$randfunc" in
10767                 drand48)
10768                         drand01="drand48()"
10769                         seedfunc="srand48"
10770                         randbits=48
10771                         randseedtype=long
10772                         ;;
10773                 rand|random)
10774                         case "$randbits" in
10775                         '')
10776 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10777                                 $cat >try.c <<EOCP
10778 #$i_unistd I_UNISTD
10779 #$i_stdlib I_STDLIB
10780 #include <stdio.h>
10781 #ifdef I_UNISTD
10782 #  include <unistd.h>
10783 #endif
10784 #ifdef I_STDLIB
10785 #  include <stdlib.h>
10786 #endif
10787 int main()
10788 {
10789         register int i;
10790         register unsigned long tmp;
10791         register unsigned long max = 0L;
10792
10793         for (i = 1000; i; i--) {
10794                 tmp = (unsigned long) $randfunc();
10795                 if (tmp > max) max = tmp;
10796         }
10797         for (i = 0; max; i++)
10798                 max /= 2;
10799         printf("%d\n",i);
10800 }
10801 EOCP
10802                                 set try
10803                                 if eval $compile_ok; then
10804                                         dflt=`try`
10805                                 else
10806                                         dflt='?'
10807                                         echo "(I can't seem to compile the test program...)"
10808                                 fi
10809                                 ;;
10810                         *)
10811                                 dflt="$randbits"
10812                                 ;;
10813                         esac
10814                         rp="How many bits does your $randfunc() function produce?"
10815                         . ./myread
10816                         randbits="$ans"
10817                         $rm -f try.c try
10818                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10819                         seedfunc="s$randfunc"
10820                         randseedtype=unsigned
10821                         ;;
10822                 *)
10823                         dflt="31"
10824                         rp="How many bits does your $randfunc() function produce?"
10825                         . ./myread
10826                         randbits="$ans"
10827                         seedfunc="s$randfunc"
10828                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10829                         if set $seedfunc val -f; eval $csym; $val; then
10830                                 echo "(Using $seedfunc() to seed random generator)"
10831                         else
10832                                 echo "(Warning: no $seedfunc() to seed random generator)"
10833                                 seedfunc=rand
10834                         fi
10835                         randseedtype=unsigned
10836                         ;;
10837                 esac
10838                 ;;
10839         esac
10840 done
10841
10842 echo " "
10843 echo "Determining whether or not we are on an EBCDIC system..." >&4
10844 $cat >tebcdic.c <<'EOM'
10845 int main()
10846 {
10847   if ('M'==0xd4) return 0;
10848   return 1;
10849 }
10850 EOM
10851
10852 val=$undef
10853 set tebcdic
10854 if eval $compile_ok; then
10855         if ./tebcdic; then
10856                 echo "You have EBCDIC." >&4
10857                 val="$define"
10858         else
10859                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10860         fi
10861 else
10862         echo "I'm unable to compile the test program." >&4
10863         echo "I'll assume ASCII or some ISO Latin." >&4
10864 fi
10865 $rm -f tebcdic.c tebcdic
10866 set ebcdic
10867 eval $setvar
10868
10869 : see what type file positions are declared as in the library
10870 rp="What is the type for file position used by fsetpos()?"
10871 set fpos_t fpostype long stdio.h sys/types.h
10872 eval $typedef_ask
10873
10874 : Store the full pathname to the ar program for use in the C program
10875 : Respect a hint or command line value for full_ar.
10876 case "$full_ar" in
10877 '') full_ar=$ar ;;
10878 esac
10879
10880 : Store the full pathname to the sed program for use in the C program
10881 full_sed=$sed
10882
10883 : see what type gids are declared as in the kernel
10884 echo " "
10885 echo "Looking for the type for group ids returned by getgid()."
10886 set gid_t gidtype xxx stdio.h sys/types.h
10887 eval $typedef
10888 case "$gidtype" in
10889 xxx)
10890         xxx=`./findhdr sys/user.h`
10891         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
10892         case $1 in
10893         unsigned) dflt="$1 $2" ;;
10894         *) dflt="$1" ;;
10895         esac
10896         ;;
10897 *) dflt="$gidtype";;
10898 esac
10899 case "$gidtype" in
10900 gid_t) echo "gid_t found." ;;
10901 *)      rp="What is the type for group ids returned by getgid()?"
10902         . ./myread
10903         gidtype="$ans"
10904         ;;
10905 esac
10906
10907 : see if getgroups exists
10908 set getgroups d_getgrps
10909 eval $inlibc
10910
10911 : see if setgroups exists
10912 set setgroups d_setgrps
10913 eval $inlibc
10914
10915
10916 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
10917 echo " "
10918 case "$d_getgrps$d_setgrps" in
10919 *define*)
10920         case "$groupstype" in
10921         '') dflt="$gidtype" ;;
10922         *)  dflt="$groupstype" ;;
10923         esac
10924         $cat <<EOM
10925 What type of pointer is the second argument to getgroups() and setgroups()?
10926 Usually this is the same as group ids, $gidtype, but not always.
10927
10928 EOM
10929         rp='What type pointer is the second argument to getgroups() and setgroups()?'
10930         . ./myread
10931         groupstype="$ans"
10932         ;;
10933 *)  groupstype="$gidtype";;
10934 esac
10935
10936 : see what type lseek is declared as in the kernel
10937 rp="What is the type used for lseek's offset on this system?"
10938 set off_t lseektype long stdio.h sys/types.h
10939 eval $typedef_ask
10940
10941 echo " "
10942 $echo $n "Checking to see how big your file offsets are...$c" >&4
10943 $cat >try.c <<EOCP
10944 #include <sys/types.h>
10945 #include <stdio.h>
10946 int main()
10947 {
10948         printf("%d\n", sizeof($lseektype));
10949 }
10950 EOCP
10951 set try
10952 if eval $compile_ok; then
10953         lseeksize=`./try`
10954         $echo " $lseeksize bytes." >&4
10955 else
10956         dflt='4'
10957         echo " "
10958         echo "(I can't seem to compile the test program.  Guessing...)"
10959         rp="What is the size of your file offsets (in bytes)?"
10960         . ./myread
10961         lseeksize="$ans"
10962 fi
10963 $rm -f try.c try
10964
10965 echo " "
10966 echo "Checking if your $make program sets \$(MAKE)..." >&4
10967 case "$make_set_make" in
10968 '')
10969         $sed 's/^X //' > testmake.mak << 'EOF'
10970 Xall:
10971 X       @echo 'maketemp="$(MAKE)"'
10972 EOF
10973         case "`$make -f testmake.mak 2>/dev/null`" in
10974         *maketemp=*) make_set_make='#' ;;
10975         *)      make_set_make="MAKE=$make" ;;
10976         esac
10977         $rm -f testmake.mak
10978         ;;
10979 esac
10980 case "$make_set_make" in
10981 '#') echo "Yup, it does.";;
10982 *) echo "Nope, it doesn't.";;
10983 esac
10984
10985 : see what type is used for mode_t
10986 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
10987 set mode_t modetype int stdio.h sys/types.h
10988 eval $typedef_ask
10989
10990 : define a fucntion to check prototypes
10991 $cat > protochk <<EOSH
10992 $startsh
10993 cc="$cc"
10994 optimize="$optimize"
10995 ccflags="$ccflags"
10996 prototype="$prototype"
10997 define="$define"
10998 rm=$rm
10999 EOSH
11000
11001 $cat >> protochk <<'EOSH'
11002
11003 $rm -f try.c
11004 foo="$1"
11005 shift
11006 while test $# -ge 2; do
11007         case "$1" in
11008                 $define) echo "#include <$2>" >> try.c ;;
11009                 literal) echo "$2" >> try.c ;;
11010         esac
11011     shift 2
11012 done
11013 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11014 cat >> try.c <<'EOCP'
11015 #ifdef CAN_PROTOTYPE
11016 #define _(args) args
11017 #else
11018 #define _(args) ()
11019 #endif
11020 EOCP
11021 echo "$foo" >> try.c
11022 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11023 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11024 status=$?
11025 $rm -f try.[co]
11026 exit $status
11027 EOSH
11028 chmod +x protochk
11029 $eunicefix protochk
11030
11031 : see what type is used for size_t
11032 rp="What is the type used for the length parameter for string functions?"
11033 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11034 eval $typedef_ask
11035
11036 : check for type of arguments to gethostbyaddr. 
11037 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11038         case "$d_gethbyaddr" in
11039         $define)
11040                 $cat <<EOM
11041
11042 Checking to see what type of arguments are accepted by gethostbyaddr().
11043 EOM
11044                 hdrs="$define sys/types.h
11045                         $d_socket sys/socket.h 
11046                         $i_niin netinet/in.h 
11047                         $i_netdb netdb.h
11048                         $i_unistd unistd.h"
11049                 : The first arg can 'char *' or 'void *'
11050                 : The second arg is some of integral type
11051                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11052                         for yyy in size_t long int; do
11053                                 case "$netdb_host_type" in
11054                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11055                                         if ./protochk "$try" $hdrs; then
11056                                                 echo "Your system accepts $xxx for the first arg."
11057                                                 echo "...and $yyy for the second arg."
11058                                                 netdb_host_type="$xxx"
11059                                                 netdb_hlen_type="$yyy"
11060                                         fi
11061                                         ;;
11062                                 esac
11063                         done
11064                 done
11065                 : In case none of those worked, prompt the user.
11066                 case "$netdb_host_type" in
11067                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11068                         dflt='char *'
11069                         . ./myread
11070                         netdb_host_type=$ans
11071                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11072                         dflt="$sizetype"
11073                         . ./myread
11074                         netdb_hlen_type=$ans
11075                         ;;
11076                 esac
11077                 ;;
11078         *)      : no gethostbyaddr, so pick harmless defaults
11079                 netdb_host_type='char *'
11080                 netdb_hlen_type="$sizetype"
11081                 ;;
11082         esac
11083         # Remove the "const" if needed. -- but then we'll have a 
11084         # prototype clash!
11085         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11086 fi
11087
11088 : check for type of argument to gethostbyname. 
11089 if test "X$netdb_name_type" = X ; then
11090         case "$d_gethbyname" in
11091         $define)
11092                 $cat <<EOM
11093
11094 Checking to see what type of argument is accepted by gethostbyname().
11095 EOM
11096                 hdrs="$define sys/types.h
11097                         $d_socket sys/socket.h 
11098                         $i_niin netinet/in.h 
11099                         $i_netdb netdb.h
11100                         $i_unistd unistd.h"
11101                 for xxx in "const char *" "char *"; do
11102                         case "$netdb_name_type" in
11103                         '')     try="extern struct hostent *gethostbyname($xxx);"
11104                                 if ./protochk "$try" $hdrs; then
11105                                         echo "Your system accepts $xxx."
11106                                         netdb_name_type="$xxx"
11107                                 fi
11108                                 ;;
11109                         esac
11110                 done
11111                 : In case none of those worked, prompt the user.
11112                 case "$netdb_name_type" in
11113                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11114                         dflt='char *'
11115                         . ./myread
11116                         netdb_name_type=$ans
11117                         ;;
11118                 esac
11119                 ;;
11120         *)      : no gethostbyname, so pick harmless default
11121                 netdb_name_type='char *'
11122                 ;;
11123         esac
11124 fi
11125
11126 : check for type of 1st argument to getnetbyaddr. 
11127 if test "X$netdb_net_type" = X ; then
11128         case "$d_getnbyaddr" in
11129         $define)
11130                 $cat <<EOM
11131
11132 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11133 EOM
11134                 hdrs="$define sys/types.h
11135                         $d_socket sys/socket.h 
11136                         $i_niin netinet/in.h 
11137                         $i_netdb netdb.h
11138                         $i_unistd unistd.h"
11139                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11140                         case "$netdb_net_type" in
11141                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11142                                 if ./protochk "$try" $hdrs; then
11143                                         echo "Your system accepts $xxx."
11144                                         netdb_net_type="$xxx"
11145                                 fi
11146                                 ;;
11147                         esac
11148                 done
11149                 : In case none of those worked, prompt the user.
11150                 case "$netdb_net_type" in
11151                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11152                         dflt='long'
11153                         . ./myread
11154                         netdb_net_type=$ans
11155                         ;;
11156                 esac
11157                 ;;
11158         *)      : no getnetbyaddr, so pick harmless default
11159                 netdb_net_type='long'
11160                 ;;
11161         esac
11162 fi
11163 : locate the preferred pager for this system
11164 case "$pager" in
11165 '')
11166         dflt=''
11167         case "$pg" in
11168         /*) dflt=$pg;;
11169         esac
11170         case "$more" in
11171         /*) dflt=$more;;
11172         esac
11173         case "$less" in
11174         /*) dflt=$less;;
11175         esac
11176         case "$dflt" in
11177         '') dflt=/usr/ucb/more;;
11178         esac
11179         ;;
11180 *) dflt="$pager";;
11181 esac
11182 echo " "
11183 fn=f/
11184 rp='What pager is used on your system?'
11185 . ./getfile
11186 pager="$ans"
11187
11188 : see what type pids are declared as in the kernel
11189 rp="What is the type of process ids on this system?"
11190 set pid_t pidtype int stdio.h sys/types.h
11191 eval $typedef_ask
11192
11193 : check for length of pointer
11194 echo " "
11195 case "$ptrsize" in
11196 '')
11197         $echo $n "Checking to see how big your pointers are...$c" >&4
11198         if test "$voidflags" -gt 7; then
11199                 echo '#define VOID_PTR char *' > try.c
11200         else
11201                 echo '#define VOID_PTR void *' > try.c
11202         fi
11203         $cat >>try.c <<'EOCP'
11204 #include <stdio.h>
11205 int main()
11206 {
11207         printf("%d\n", sizeof(VOID_PTR));
11208         exit(0);
11209 }
11210 EOCP
11211         set try
11212         if eval $compile_ok; then
11213                 ptrsize=`./try`
11214                 $echo " $ptrsize bytes." >&4
11215         else
11216                 dflt='4'
11217                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11218                 rp="What is the size of a pointer (in bytes)?"
11219                 . ./myread
11220                 ptrsize="$ans"
11221         fi
11222         ;;
11223 esac
11224 $rm -f try.c try
11225
11226 : see if ar generates random libraries by itself
11227 echo " "
11228 echo "Checking how to generate random libraries on your machine..." >&4
11229 echo 'int bar1() { return bar2(); }' > bar1.c
11230 echo 'int bar2() { return 2; }' > bar2.c
11231 $cat > foo.c <<'EOP'
11232 int main() { printf("%d\n", bar1()); exit(0); }
11233 EOP
11234 $cc $ccflags -c bar1.c >/dev/null 2>&1
11235 $cc $ccflags -c bar2.c >/dev/null 2>&1
11236 $cc $ccflags -c foo.c >/dev/null 2>&1
11237 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11238 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11239         ./foobar >/dev/null 2>&1; then
11240         echo "$ar appears to generate random libraries itself."
11241         orderlib=false
11242         ranlib=":"
11243 elif $ar ts bar$_a >/dev/null 2>&1 &&
11244         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11245         ./foobar >/dev/null 2>&1; then
11246                 echo "a table of contents needs to be added with '$ar ts'."
11247                 orderlib=false
11248                 ranlib="$ar ts"
11249 else
11250         case "$ranlib" in
11251         :) ranlib='';;
11252         '')
11253                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11254                 $test -f $ranlib || ranlib=''
11255                 ;;
11256         esac
11257         if $test -n "$ranlib"; then
11258                 echo "your system has '$ranlib'; we'll use that."
11259                 orderlib=false
11260         else
11261                 echo "your system doesn't seem to support random libraries"
11262                 echo "so we'll use lorder and tsort to order the libraries."
11263                 orderlib=true
11264                 ranlib=":"
11265         fi
11266 fi
11267 $rm -f foo* bar* 
11268
11269 : check for type of arguments to select. 
11270 case "$selecttype" in
11271 '') case "$d_select" in
11272         $define)
11273                 $cat <<EOM
11274 Checking to see what type of arguments are accepted by select().
11275 EOM
11276                 hdrs="$define sys/types.h
11277                         $i_systime sys/time.h 
11278                         $i_sysselct sys/select.h
11279                         $d_socket sys/socket.h"
11280                 : The first arg can be int, unsigned, or size_t
11281                 : The last arg may or may not be 'const'
11282                 val=''
11283                 : void pointer has been seen but using that
11284                 : breaks the selectminbits test
11285                 for xxx in 'fd_set *' 'int *'; do
11286                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11287                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11288                                         case "$val" in
11289                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11290                                                 if ./protochk "$try" $hdrs; then
11291                                                         echo "Your system accepts $xxx."
11292                                                         val="$xxx"
11293                                                 fi
11294                                                 ;;
11295                                         esac
11296                                 done
11297                         done
11298                 done
11299                 case "$val" in
11300                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11301                         case "$d_fd_set" in
11302                                 $define) dflt="fd_set *" ;;
11303                                 *)              dflt="int *" ;;
11304                         esac
11305                         . ./myread
11306                         val=$ans
11307                         ;;
11308                 esac
11309                 selecttype="$val"
11310                 ;;
11311         *)      : no select, so pick a harmless default
11312                 selecttype='int *'
11313                 ;;
11314         esac
11315         ;;
11316 esac
11317
11318 : check for the select 'width'
11319 case "$selectminbits" in
11320 '') case "$d_select" in
11321         $define)
11322                 $cat <<EOM
11323
11324 Checking to see on how many bits at a time your select() operates...
11325 EOM
11326                 $cat >try.c <<EOCP
11327 #include <sys/types.h>
11328 #$i_time I_TIME
11329 #$i_systime I_SYS_TIME
11330 #$i_systimek I_SYS_TIME_KERNEL
11331 #ifdef I_TIME
11332 #   include <time.h>
11333 #endif
11334 #ifdef I_SYS_TIME
11335 #   ifdef I_SYS_TIME_KERNEL
11336 #       define KERNEL
11337 #   endif
11338 #   include <sys/time.h>
11339 #   ifdef I_SYS_TIME_KERNEL
11340 #       undef KERNEL
11341 #   endif
11342 #endif
11343 #$i_sysselct I_SYS_SELECT
11344 #ifdef I_SYS_SELECT
11345 #include <sys/select.h>
11346 #endif
11347 #include <stdio.h>
11348 $selecttype b;
11349 #define S sizeof(*(b))
11350 #define MINBITS 64
11351 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11352 #define NBITS  (NBYTES * 8)
11353 int main() {
11354     char s[NBYTES];
11355     struct timeval t;
11356     int i;
11357     FILE* fp;
11358     int fd;
11359
11360     fclose(stdin);
11361     fp = fopen("try.c", "r");
11362     if (fp == 0)
11363       exit(1);
11364     fd = fileno(fp);
11365     if (fd < 0)
11366       exit(2);
11367     b = ($selecttype)s;
11368     for (i = 0; i < NBITS; i++)
11369         FD_SET(i, b);
11370     t.tv_sec  = 0;
11371     t.tv_usec = 0;
11372     select(fd + 1, b, 0, 0, &t);
11373     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11374     printf("%d\n", i + 1);
11375     return 0;
11376 }
11377 EOCP
11378                 set try
11379                 if eval $compile_ok; then
11380                         selectminbits=`./try`
11381                         case "$selectminbits" in
11382                         '')     cat >&4 <<EOM
11383 Cannot figure out on how many bits at a time your select() operates.
11384 I'll play safe and guess it is 32 bits.
11385 EOM
11386                                 selectminbits=32
11387                                 bits="32 bits"
11388                                 ;;
11389                         1)      bits="1 bit" ;;
11390                         *)      bits="$selectminbits bits" ;;
11391                         esac
11392                         echo "Your select() operates on $bits at a time." >&4
11393                 else
11394                         rp='What is the minimum number of bits your select() operates on?'
11395                         case "$byteorder" in
11396                         1234|12345678)  dflt=32 ;;
11397                         *)              dflt=1  ;;
11398                         esac
11399                         . ./myread
11400                         val=$ans
11401                         selectminbits="$val"
11402                 fi
11403                 $rm -f try.* try
11404                 ;;
11405         *)      : no select, so pick a harmless default
11406                 selectminbits='32'
11407                 ;;
11408         esac
11409         ;;
11410 esac
11411
11412 : Trace out the files included by signal.h, then look for SIGxxx names.
11413 : Remove SIGARRAYSIZE used by HPUX.
11414 : Remove SIGTYP void lines used by OS2.
11415 xxx=`echo '#include <signal.h>' |
11416         $cppstdin $cppminus $cppflags 2>/dev/null |
11417         $grep '^[       ]*#.*include' | 
11418         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11419 : Check this list of files to be sure we have parsed the cpp output ok.
11420 : This will also avoid potentially non-existent files, such 
11421 : as ../foo/bar.h
11422 xxxfiles=''
11423 for xx in $xxx /dev/null ; do
11424         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11425 done
11426 : If we have found no files, at least try signal.h
11427 case "$xxxfiles" in
11428 '')     xxxfiles=`./findhdr signal.h` ;;
11429 esac
11430 xxx=`awk '
11431 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $3 !~ /void/ {
11432         print substr($2, 4, 20)
11433 }
11434 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11435         print substr($3, 4, 20)
11436 }' $xxxfiles`
11437 : Append some common names just in case the awk scan failed.
11438 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11439 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11440 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11441 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11442 : generate a few handy files for later
11443 $cat > signal.c <<'EOCP'
11444 #include <sys/types.h>
11445 #include <signal.h>
11446 #include <stdio.h>
11447 int main() {
11448
11449 /* Strange style to avoid deeply-nested #if/#else/#endif */
11450 #ifndef NSIG
11451 #  ifdef _NSIG
11452 #    define NSIG (_NSIG)
11453 #  endif
11454 #endif
11455
11456 #ifndef NSIG
11457 #  ifdef SIGMAX
11458 #    define NSIG (SIGMAX+1)
11459 #  endif
11460 #endif
11461
11462 #ifndef NSIG
11463 #  ifdef SIG_MAX
11464 #    define NSIG (SIG_MAX+1)
11465 #  endif
11466 #endif
11467
11468 #ifndef NSIG
11469 #  ifdef MAXSIG
11470 #    define NSIG (MAXSIG+1)
11471 #  endif
11472 #endif
11473
11474 #ifndef NSIG
11475 #  ifdef MAX_SIG
11476 #    define NSIG (MAX_SIG+1)
11477 #  endif
11478 #endif
11479
11480 #ifndef NSIG
11481 #  ifdef SIGARRAYSIZE
11482 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11483 #  endif
11484 #endif
11485
11486 #ifndef NSIG
11487 #  ifdef _sys_nsig
11488 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11489 #  endif
11490 #endif
11491
11492 /* Default to some arbitrary number that's big enough to get most
11493    of the common signals.
11494 */
11495 #ifndef NSIG
11496 #    define NSIG 50
11497 #endif
11498
11499 printf("NSIG %d\n", NSIG);
11500
11501 #ifndef JUST_NSIG
11502
11503 EOCP
11504
11505 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11506 {
11507         printf "#ifdef SIG"; printf $1; printf "\n"
11508         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11509         printf $1; printf ");\n"
11510         printf "#endif\n"
11511 }
11512 END {
11513         printf "#endif /* JUST_NSIG */\n";
11514         printf "}\n";
11515 }
11516 ' >>signal.c
11517 $cat >signal.awk <<'EOP'
11518 BEGIN { ndups = 0 }
11519 $1 ~ /^NSIG$/ { nsig = $2 }
11520 ($1 !~ /^NSIG$/) && (NF == 2) {
11521     if ($2 > maxsig) { maxsig = $2 }
11522     if (sig_name[$2]) {
11523         dup_name[ndups] = $1
11524         dup_num[ndups] = $2
11525         ndups++ 
11526     }
11527     else {
11528         sig_name[$2] = $1
11529         sig_num[$2] = $2
11530     }
11531
11532 }
11533 END { 
11534     if (nsig == 0) { nsig = maxsig + 1 }
11535         for (n = 1; n < nsig; n++) {
11536                 if (sig_name[n]) {
11537                         printf("%s %d\n", sig_name[n], sig_num[n])
11538                 }
11539                 else {
11540                         printf("NUM%d %d\n", n, n) 
11541                 }
11542         }
11543     for (n = 0; n < ndups; n++) {
11544                 printf("%s %d\n", dup_name[n], dup_num[n])
11545     }
11546 }
11547 EOP
11548 $cat >signal_cmd <<EOS
11549 $startsh
11550 if $test -s signal.lst; then
11551     echo "Using your existing signal.lst file"
11552         exit 0
11553 fi
11554 xxx="$xxx"
11555 EOS
11556 $cat >>signal_cmd <<'EOS'
11557
11558 set signal
11559 if eval $compile_ok; then
11560         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11561 else
11562         echo "(I can't seem be able to compile the whole test program)" >&4
11563         echo "(I'll try it in little pieces.)" >&4
11564         set signal -DJUST_NSIG
11565         if eval $compile_ok; then
11566                 ./signal$_exe > signal.nsg
11567                 $cat signal.nsg
11568         else
11569                 echo "I can't seem to figure out how many signals you have." >&4
11570                 echo "Guessing 50." >&4
11571                 echo 'NSIG 50' > signal.nsg
11572         fi
11573         : Now look at all the signal names, one at a time.
11574         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11575                 $cat > signal.c <<EOCP
11576 #include <sys/types.h>
11577 #include <signal.h>
11578 #include <stdio.h>
11579 int main() {
11580 printf("$xx %d\n", SIG${xx});
11581 return 0;
11582 }
11583 EOCP
11584                 set signal
11585                 if eval $compile; then
11586                         echo "SIG${xx} found."
11587                         ./signal$_exe  >> signal.ls1
11588                 else
11589                         echo "SIG${xx} NOT found."
11590                 fi
11591         done
11592         if $test -s signal.ls1; then
11593                 $cat signal.nsg signal.ls1 |
11594                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11595         fi
11596
11597 fi
11598 if $test -s signal.lst; then
11599         :
11600 else
11601         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11602         echo 'kill -l' >signal
11603         set X `csh -f <signal`
11604         $rm -f signal
11605         shift
11606         case $# in
11607         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11608         esac
11609         echo $@ | $tr ' ' $trnl | \
11610                 $awk '{ printf $1; printf " %d\n", ++s; }' >signal.lst
11611 fi
11612 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11613 EOS
11614 chmod a+x signal_cmd
11615 $eunicefix signal_cmd
11616
11617 : generate list of signal names
11618 echo " "
11619 case "$sig_name_init" in
11620 '') doinit=yes ;;
11621 *)  case "$sig_num_init" in
11622     ''|*,*) doinit=yes ;;
11623     esac ;;
11624 esac
11625 case "$doinit" in
11626 yes)
11627         echo "Generating a list of signal names and numbers..." >&4
11628         . ./signal_cmd
11629         sig_name=`$awk '{printf "%s ", $1}' signal.lst`
11630         sig_name="ZERO $sig_name"
11631         sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
11632                                                 { printf "\"%s\", ", $1 }
11633                                                 END { printf "0\n" }' signal.lst`
11634         sig_num=`$awk '{printf "%d ", $2}' signal.lst`
11635         sig_num="0 $sig_num"
11636         sig_num_init=`$awk 'BEGIN { printf "0, " }
11637                                         { printf "%d, ", $2}
11638                                         END { printf "0\n"}' signal.lst`
11639         ;;
11640 esac
11641 echo "The following signals are available:"
11642 echo " "
11643 echo $sig_name | $awk \
11644 'BEGIN { linelen = 0 }
11645 {
11646         for (i = 1; i <= NF; i++) {
11647                 name = "SIG" $i " "
11648                 linelen = linelen + length(name)
11649                 if (linelen > 70) {
11650                         printf "\n"
11651                         linelen = length(name)
11652                 }
11653                 printf "%s", name
11654         }
11655         printf "\n"
11656 }'
11657 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11658
11659 : see what type is used for signed size_t
11660 set ssize_t ssizetype int stdio.h sys/types.h
11661 eval $typedef
11662 dflt="$ssizetype"
11663 $cat > ssize.c <<EOM
11664 #include <stdio.h>
11665 #include <sys/types.h>
11666 #define Size_t $sizetype
11667 #define SSize_t $dflt
11668 int main()
11669 {
11670         if (sizeof(Size_t) == sizeof(SSize_t))
11671                 printf("$dflt\n");
11672         else if (sizeof(Size_t) == sizeof(int))
11673                 printf("int\n");
11674         else 
11675                 printf("long\n");
11676         exit(0);
11677 }
11678 EOM
11679 echo " "
11680 set ssize
11681 if eval $compile_ok && ./ssize > /dev/null; then
11682         ssizetype=`./ssize`
11683         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11684 else
11685         $cat >&4 <<EOM
11686 Help! I can't compile and run the ssize_t test program: please enlighten me!
11687 (This is probably a misconfiguration in your system or libraries, and
11688 you really ought to fix it.  Still, I'll try anyway.)
11689
11690 I need a type that is the same size as $sizetype, but is guaranteed to
11691 be signed.  Common values are ssize_t, int and long.
11692
11693 EOM
11694         rp="What signed type is the same size as $sizetype?"
11695         . ./myread
11696         ssizetype="$ans"
11697 fi
11698 $rm -f ssize ssize.*
11699
11700 : see what type of char stdio uses.
11701 echo " "
11702 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11703         echo "Your stdio uses unsigned chars." >&4
11704         stdchar="unsigned char"
11705 else
11706         echo "Your stdio uses signed chars." >&4
11707         stdchar="char"
11708 fi
11709
11710 : see if time exists
11711 echo " "
11712 if test "X$d_time" = X -o X"$timetype" = X; then
11713     if set time val -f d_time; eval $csym; $val; then
11714                 echo 'time() found.' >&4
11715                 val="$define"
11716                 rp="What is the type returned by time() on this system?"
11717                 set time_t timetype long stdio.h sys/types.h
11718                 eval $typedef_ask
11719     else
11720                 echo 'time() not found, hope that will do.' >&4
11721                 val="$undef"
11722                 timetype='int';
11723     fi
11724     set d_time
11725     eval $setvar
11726 fi
11727
11728 : see what type uids are declared as in the kernel
11729 echo " "
11730 echo "Looking for the type for user ids returned by getuid()."
11731 set uid_t uidtype xxx stdio.h sys/types.h
11732 eval $typedef
11733 case "$uidtype" in
11734 xxx)
11735         xxx=`./findhdr sys/user.h`
11736         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
11737         case $1 in
11738         unsigned) dflt="$1 $2" ;;
11739         *) dflt="$1" ;;
11740         esac
11741         ;;
11742 *) dflt="$uidtype";;
11743 esac
11744 case "$uidtype" in
11745 uid_t)  echo "uid_t found." ;;
11746 *)      rp="What is the type for user ids returned by getuid()?"
11747         . ./myread
11748         uidtype="$ans"
11749         ;;
11750 esac
11751
11752 : see if dbm.h is available
11753 : see if dbmclose exists
11754 set dbmclose d_dbmclose
11755 eval $inlibc
11756
11757 case "$d_dbmclose" in
11758 $define)
11759         set dbm.h i_dbm
11760         eval $inhdr
11761         case "$i_dbm" in
11762         $define)
11763                 val="$undef"
11764                 set i_rpcsvcdbm
11765                 eval $setvar
11766                 ;;
11767         *)      set rpcsvc/dbm.h i_rpcsvcdbm
11768                 eval $inhdr
11769                 ;;
11770         esac
11771         ;;
11772 *)      echo "We won't be including <dbm.h>"
11773         val="$undef"
11774         set i_dbm
11775         eval $setvar
11776         val="$undef"
11777         set i_rpcsvcdbm
11778         eval $setvar
11779         ;;
11780 esac
11781
11782 : see if this is a sys/file.h system
11783 val=''
11784 set sys/file.h val
11785 eval $inhdr
11786
11787 : do we need to include sys/file.h ?
11788 case "$val" in
11789 "$define")
11790         echo " "
11791         if $h_sysfile; then
11792                 val="$define"
11793                 echo "We'll be including <sys/file.h>." >&4
11794         else
11795                 val="$undef"
11796                 echo "We won't be including <sys/file.h>." >&4
11797         fi
11798         ;;
11799 *)
11800         h_sysfile=false
11801         ;;
11802 esac
11803 set i_sysfile
11804 eval $setvar
11805
11806 : see if fcntl.h is there
11807 val=''
11808 set fcntl.h val
11809 eval $inhdr
11810
11811 : see if we can include fcntl.h
11812 case "$val" in
11813 "$define")
11814         echo " "
11815         if $h_fcntl; then
11816                 val="$define"
11817                 echo "We'll be including <fcntl.h>." >&4
11818         else
11819                 val="$undef"
11820                 if $h_sysfile; then
11821         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
11822                 else
11823                         echo "We won't be including <fcntl.h>." >&4
11824                 fi
11825         fi
11826         ;;
11827 *)
11828         h_fcntl=false
11829         val="$undef"
11830         ;;
11831 esac
11832 set i_fcntl
11833 eval $setvar
11834
11835 : see if locale.h is available
11836 set locale.h i_locale
11837 eval $inhdr
11838
11839 : see if mach cthreads are available
11840 if test "X$usethreads" = "X$define"; then
11841         set mach/cthreads.h i_machcthr
11842         eval $inhdr
11843 else
11844         i_machcthr="$undef"
11845 fi
11846
11847
11848
11849 : see if this is a math.h system
11850 set math.h i_math
11851 eval $inhdr
11852
11853 : see if this is a mntent.h system
11854 set mntent.h i_mntent
11855 eval $inhdr
11856
11857 : see if ndbm.h is available
11858 set ndbm.h t_ndbm
11859 eval $inhdr
11860 case "$t_ndbm" in
11861 $define)
11862         : see if dbm_open exists
11863         set dbm_open d_dbm_open
11864         eval $inlibc
11865         case "$d_dbm_open" in
11866         $undef)
11867                 t_ndbm="$undef"
11868                 echo "We won't be including <ndbm.h>"
11869                 ;;
11870         esac
11871         ;;
11872 esac
11873 val="$t_ndbm"
11874 set i_ndbm
11875 eval $setvar
11876
11877 : see if net/errno.h is available
11878 val=''
11879 set net/errno.h val
11880 eval $inhdr
11881
11882 : Unfortunately, it causes problems on some systems.  Arrgh.
11883 case "$val" in
11884 $define)
11885         cat > try.c <<'EOM'
11886 #include <stdio.h>
11887 #include <errno.h>
11888 #include <net/errno.h>
11889 int func()
11890 {
11891         return ENOTSOCK;
11892 }
11893 EOM
11894         if $cc $ccflags -c try.c >/dev/null 2>&1; then
11895                 echo "We'll be including <net/errno.h>." >&4
11896         else
11897                 echo "We won't be including <net/errno.h>." >&4
11898                 val="$undef"
11899         fi
11900         $rm -f try.* try
11901         ;;
11902 esac
11903 set i_neterrno
11904 eval $setvar
11905
11906 : see if this is a poll.h system
11907 set poll.h i_poll
11908 eval $inhdr
11909
11910 : get C preprocessor symbols handy
11911 echo " "
11912 $echo $n "Hmm... $c"
11913 echo $al | $tr ' ' $trnl >Cppsym.know
11914 $cat <<EOSS >Cppsym
11915 $startsh
11916 case "\$1" in
11917 -l) list=true
11918         shift
11919         ;;
11920 esac
11921 unknown=''
11922 case "\$list\$#" in
11923 1|2)
11924         for sym do
11925                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
11926                         exit 0
11927                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
11928                         :
11929                 else
11930                         unknown="\$unknown \$sym"
11931                 fi
11932         done
11933         set X \$unknown
11934         shift
11935         ;;
11936 esac
11937 case \$# in
11938 0) exit 1;;
11939 esac
11940 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
11941 #ifdef \1\\
11942 exit 0; _ _ _ _\1\\      \1\\
11943 #endif\\
11944 /' >Cppsym\$\$
11945 echo "exit 1; _ _ _" >>Cppsym\$\$
11946 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
11947 case "\$list" in
11948 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
11949 *)
11950         sh Cppsym2\$\$
11951         status=\$?
11952         ;;
11953 esac
11954 $rm -f Cppsym\$\$ Cppsym2\$\$
11955 exit \$status
11956 EOSS
11957 chmod +x Cppsym
11958 $eunicefix Cppsym
11959 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
11960
11961 : now check the C compiler for additional symbols
11962 $cat >ccsym <<EOS
11963 $startsh
11964 $cat >tmp.c <<EOF
11965 extern int foo;
11966 EOF
11967 for i in \`$cc -v -c tmp.c 2>&1\`
11968 do
11969         case "\$i" in
11970         -D*) echo "\$i" | $sed 's/^-D//';;
11971         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
11972         esac
11973 done
11974 $rm -f try.c
11975 EOS
11976 chmod +x ccsym
11977 $eunicefix ccsym
11978 ./ccsym > ccsym1.raw
11979 if $test -s ccsym1.raw; then
11980        $sort ccsym1.raw | $uniq >ccsym.raw
11981 else
11982        mv ccsym1.raw ccsym.raw
11983 fi
11984
11985 $awk '/\=/ { print $0; next }
11986         { print $0"=1" }' ccsym.raw >ccsym.list
11987 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
11988 $comm -13 ccsym.true ccsym.list >ccsym.own
11989 $comm -12 ccsym.true ccsym.list >ccsym.com
11990 $comm -23 ccsym.true ccsym.list >ccsym.cpp
11991 also=''
11992 if $test -z ccsym.raw; then
11993         echo "Your C compiler doesn't seem to define any symbols!" >&4
11994         echo " "
11995         echo "However, your C preprocessor defines the following symbols:"
11996         $cat Cppsym.true
11997         ccsymbols=''
11998         cppsymbols=`$cat Cppsym.true`
11999         cppsymbols=`echo $cppsymbols`
12000         cppccsymbols="$cppsymbols"
12001 else
12002         if $test -s ccsym.com; then
12003                 echo "Your C compiler and pre-processor define these symbols:"
12004                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12005                 also='also '
12006                 symbols='ones'
12007                 cppccsymbols=`$cat ccsym.com`
12008                 cppccsymbols=`echo $cppccsymbols`
12009                 $test "$silent" || sleep 1
12010         fi
12011         if $test -s ccsym.cpp; then
12012                 $test "$also" && echo " "
12013                 echo "Your C pre-processor ${also}defines the following symbols:"
12014                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12015                 also='further '
12016                 cppsymbols=`$cat ccsym.cpp`
12017                 cppsymbols=`echo $cppsymbols`
12018                 $test "$silent" || sleep 1
12019         fi
12020         if $test -s ccsym.own; then
12021                 $test "$also" && echo " "
12022                 echo "Your C compiler ${also}defines the following cpp symbols:"
12023                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12024                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12025                 ccsymbols=`$cat ccsym.own`
12026                 ccsymbols=`echo $ccsymbols`
12027                 $test "$silent" || sleep 1
12028         fi
12029 fi
12030 $rm -f ccsym*
12031
12032 : see if this is a termio system
12033 val="$undef"
12034 val2="$undef"
12035 val3="$undef"
12036 if $test `./findhdr termios.h`; then
12037         set tcsetattr i_termios
12038         eval $inlibc
12039         val3="$i_termios"
12040 fi
12041 echo " "
12042 case "$val3" in
12043 "$define") echo "You have POSIX termios.h... good!" >&4;;
12044 *) if ./Cppsym pyr; then
12045                 case "`/bin/universe`" in
12046                 ucb) if $test `./findhdr sgtty.h`; then
12047                                 val2="$define"
12048                                 echo "<sgtty.h> found." >&4
12049                         else
12050                                 echo "System is pyramid with BSD universe."
12051                                 echo "<sgtty.h> not found--you could have problems." >&4
12052                         fi;;
12053                 *) if $test `./findhdr termio.h`; then
12054                                 val="$define"
12055                                 echo "<termio.h> found." >&4
12056                         else
12057                                 echo "System is pyramid with USG universe."
12058                                 echo "<termio.h> not found--you could have problems." >&4
12059                         fi;;
12060                 esac
12061         elif ./usg; then
12062                 if $test `./findhdr termio.h`; then
12063                         echo "<termio.h> found." >&4
12064                         val="$define"
12065                 elif $test `./findhdr sgtty.h`; then
12066                         echo "<sgtty.h> found." >&4
12067                         val2="$define"
12068                 else
12069 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12070                 fi
12071         else
12072                 if $test `./findhdr sgtty.h`; then
12073                         echo "<sgtty.h> found." >&4
12074                         val2="$define"
12075                 elif $test `./findhdr termio.h`; then
12076                         echo "<termio.h> found." >&4
12077                         val="$define"
12078                 else
12079 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12080                 fi
12081         fi;;
12082 esac
12083 set i_termio; eval $setvar
12084 val=$val2; set i_sgtty; eval $setvar
12085 val=$val3; set i_termios; eval $setvar
12086
12087 : see if stdarg is available
12088 echo " "
12089 if $test `./findhdr stdarg.h`; then
12090         echo "<stdarg.h> found." >&4
12091         valstd="$define"
12092 else
12093         echo "<stdarg.h> NOT found." >&4
12094         valstd="$undef"
12095 fi
12096
12097 : see if varags is available
12098 echo " "
12099 if $test `./findhdr varargs.h`; then
12100         echo "<varargs.h> found." >&4
12101 else
12102         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12103 fi
12104
12105 : set up the varargs testing programs
12106 $cat > varargs.c <<EOP
12107 #ifdef I_STDARG
12108 #include <stdarg.h>
12109 #endif
12110 #ifdef I_VARARGS
12111 #include <varargs.h>
12112 #endif
12113
12114 #ifdef I_STDARG
12115 int f(char *p, ...)
12116 #else
12117 int f(va_alist)
12118 va_dcl
12119 #endif
12120 {
12121         va_list ap;
12122 #ifndef I_STDARG
12123         char *p;
12124 #endif
12125 #ifdef I_STDARG
12126         va_start(ap,p);
12127 #else
12128         va_start(ap);
12129         p = va_arg(ap, char *);
12130 #endif
12131         va_end(ap);
12132 }
12133 EOP
12134 $cat > varargs <<EOP
12135 $startsh
12136 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12137         echo "true"
12138 else
12139         echo "false"
12140 fi
12141 $rm -f varargs$_o
12142 EOP
12143 chmod +x varargs
12144
12145 : now check which varargs header should be included
12146 echo " "
12147 i_varhdr=''
12148 case "$valstd" in
12149 "$define")
12150         if `./varargs I_STDARG`; then
12151                 val='stdarg.h'
12152         elif `./varargs I_VARARGS`; then
12153                 val='varargs.h'
12154         fi
12155         ;;
12156 *)
12157         if `./varargs I_VARARGS`; then
12158                 val='varargs.h'
12159         fi
12160         ;;
12161 esac
12162 case "$val" in
12163 '')
12164 echo "I could not find the definition for va_dcl... You have problems..." >&4
12165         val="$undef"; set i_stdarg; eval $setvar
12166         val="$undef"; set i_varargs; eval $setvar
12167         ;;
12168 *) 
12169         set i_varhdr
12170         eval $setvar
12171         case "$i_varhdr" in
12172         stdarg.h)
12173                 val="$define"; set i_stdarg; eval $setvar
12174                 val="$undef"; set i_varargs; eval $setvar
12175                 ;;
12176         varargs.h)
12177                 val="$undef"; set i_stdarg; eval $setvar
12178                 val="$define"; set i_varargs; eval $setvar
12179                 ;;
12180         esac
12181         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12182 esac
12183 $rm -f varargs*
12184
12185 : see if stddef is available
12186 set stddef.h i_stddef
12187 eval $inhdr
12188
12189 : see if sys/access.h is available
12190 set sys/access.h i_sysaccess
12191 eval $inhdr
12192
12193 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12194 set sys/filio.h i_sysfilio
12195 eval $inhdr
12196 echo " "
12197 if $test `./findhdr sys/ioctl.h`; then
12198         val="$define"
12199         echo '<sys/ioctl.h> found.' >&4
12200 else
12201         val="$undef"
12202         if $test $i_sysfilio = "$define"; then
12203             echo '<sys/ioctl.h> NOT found.' >&4
12204         else
12205                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12206                 $test $i_termio = "$define" && xxx="termio.h"
12207                 $test $i_termios = "$define" && xxx="termios.h"
12208 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12209         fi
12210 fi
12211 set i_sysioctl
12212 eval $setvar
12213
12214 : see if sys/resource.h has to be included
12215 set sys/resource.h i_sysresrc
12216 eval $inhdr
12217
12218 : see if sys/security.h is available
12219 set sys/security.h i_syssecrt
12220 eval $inhdr
12221
12222 : see if this is a sys/statvfs.h system
12223 set sys/statvfs.h i_sysstatvfs
12224 eval $inhdr
12225
12226 : see if this is a sys/un.h system
12227 set sys/un.h i_sysun
12228 eval $inhdr
12229
12230 : see if this is a syswait system
12231 set sys/wait.h i_syswait
12232 eval $inhdr
12233
12234 : see if this is an utime system
12235 set utime.h i_utime
12236 eval $inhdr
12237
12238 : see if this is a values.h system
12239 set values.h i_values
12240 eval $inhdr
12241
12242 : see if this is a vfork system
12243 case "$d_vfork" in
12244 "$define")
12245         set vfork.h i_vfork
12246         eval $inhdr
12247         ;;
12248 *)
12249         i_vfork="$undef"
12250         ;;
12251 esac
12252
12253 : see if gdbm.h is available
12254 set gdbm.h t_gdbm
12255 eval $inhdr
12256 case "$t_gdbm" in
12257 $define)
12258         : see if gdbm_open exists
12259         set gdbm_open d_gdbm_open
12260         eval $inlibc
12261         case "$d_gdbm_open" in
12262         $undef)
12263                 t_gdbm="$undef"
12264                 echo "We won't be including <gdbm.h>"
12265                 ;;
12266         esac
12267         ;;
12268 esac
12269 val="$t_gdbm"
12270 set i_gdbm
12271 eval $setvar
12272
12273 echo " "
12274 echo "Looking for extensions..." >&4
12275 tdir=`pwd`
12276 cd $rsrc/ext
12277 : If we are using the old config.sh, known_extensions may contain
12278 : old or inaccurate or duplicate values.
12279 known_extensions=''
12280 nonxs_extensions=''
12281 : We do not use find because it might not be available.
12282 : We do not just use MANIFEST because the user may have dropped
12283 : some additional extensions into the source tree and expect them
12284 : to be built.
12285 for xxx in * ; do
12286         case "$xxx" in
12287         DynaLoader|dynaload) ;;
12288         *)      if $test -f $xxx/$xxx.xs; then
12289                         known_extensions="$known_extensions $xxx"
12290                 elif $test -f $xxx/Makefile.PL; then
12291                         nonxs_extensions="$nonxs_extensions $xxx"
12292                 else
12293                         if $test -d $xxx; then
12294                                 # Look for nested extensions, eg. Devel/Dprof.
12295                                 cd $xxx
12296                                 for yyy in * ; do
12297                                 if $test -f $yyy/$yyy.xs; then
12298                                         known_extensions="$known_extensions $xxx/$yyy"
12299                                 elif $test -f $yyy/Makefile.PL; then
12300                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12301                                 fi
12302                                 done
12303                                 cd ..
12304                         fi
12305                 fi 
12306                 ;;
12307         esac
12308 done
12309 set X $nonxs_extensions
12310 shift
12311 nonxs_extensions="$*"
12312 set X $known_extensions
12313 shift
12314 known_extensions="$*"
12315 cd $tdir
12316
12317 : Now see which are supported on this system.
12318 avail_ext=''
12319 for xxx in $known_extensions ; do
12320         case "$xxx" in
12321         DB_File|db_file)
12322                 case "$i_db" in
12323                 $define) avail_ext="$avail_ext $xxx" ;;
12324                 esac
12325                 ;;
12326         GDBM_File|gdbm_fil)
12327                 case "$i_gdbm" in 
12328                 $define) avail_ext="$avail_ext $xxx" ;;
12329                 esac
12330                 ;;
12331         NDBM_File|ndbm_fil)
12332                 case "$i_ndbm" in
12333                 $define) avail_ext="$avail_ext $xxx" ;;
12334                 esac
12335                 ;;
12336         ODBM_File|odbm_fil) 
12337                 case "${i_dbm}${i_rpcsvcdbm}" in
12338                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12339                 esac
12340                 ;;
12341         POSIX|posix)
12342                 case "$useposix" in
12343                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12344                 esac
12345                 ;;
12346         Opcode|opcode)
12347                 case "$useopcode" in
12348                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12349                 esac
12350                 ;;
12351         Socket|socket)
12352                 case "$d_socket" in 
12353                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12354                 esac
12355                 ;;
12356         Thread|thread)
12357                 case "$usethreads" in 
12358                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12359                 esac
12360                 ;;
12361         IPC/SysV|ipc/sysv)
12362                 : XXX Do we need a useipcsysv variable here
12363                 case "${d_msg}${d_sem}${d_shm}" in 
12364                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12365                 esac
12366                 ;;
12367         *)      avail_ext="$avail_ext $xxx"
12368                 ;;
12369         esac
12370 done
12371
12372 set X $avail_ext
12373 shift
12374 avail_ext="$*"
12375
12376 : Now see which nonxs extensions are supported on this system.
12377 : For now assume all are.
12378 nonxs_ext=''
12379 for xxx in $nonxs_extensions ; do
12380         case "$xxx" in
12381         *)      nonxs_ext="$nonxs_ext $xxx"
12382                 ;;
12383         esac
12384 done
12385
12386 set X $nonxs_ext
12387 shift
12388 nonxs_ext="$*"
12389
12390 case $usedl in
12391 $define)
12392         $cat <<EOM
12393 A number of extensions are supplied with $package.  You may choose to
12394 compile these extensions for dynamic loading (the default), compile
12395 them into the $package executable (static loading), or not include
12396 them at all.  Answer "none" to include no extensions.
12397 Note that DynaLoader is always built and need not be mentioned here.
12398
12399 EOM
12400         case "$dynamic_ext" in
12401         '') dflt="$avail_ext" ;;
12402         *)      dflt="$dynamic_ext"
12403                 # Perhaps we are reusing an old out-of-date config.sh.
12404                 case "$hint" in
12405                 previous)
12406                         if test X"$dynamic_ext" != X"$avail_ext"; then
12407                                 $cat <<EOM
12408 NOTICE:  Your previous config.sh list may be incorrect. 
12409 The extensions now available to you are 
12410         ${avail_ext}
12411 but the default list from your previous config.sh is
12412         ${dynamic_ext} 
12413
12414 EOM
12415                         fi
12416                         ;;
12417                 esac
12418                 ;;
12419         esac
12420         case "$dflt" in
12421         '')     dflt=none;;
12422         esac
12423         rp="What extensions do you wish to load dynamically?"
12424         . ./myread
12425         case "$ans" in
12426         none) dynamic_ext=' ' ;;
12427         *) dynamic_ext="$ans" ;;
12428         esac
12429
12430         case "$static_ext" in
12431         '')
12432                 : Exclude those already listed in dynamic linking
12433                 dflt=''
12434                 for xxx in $avail_ext; do
12435                         case " $dynamic_ext " in
12436                         *" $xxx "*) ;;
12437                         *) dflt="$dflt $xxx" ;;
12438                         esac
12439                 done
12440                 set X $dflt
12441                 shift
12442                 dflt="$*"
12443                 ;;
12444         *)  dflt="$static_ext" 
12445                 ;;
12446         esac
12447
12448         case "$dflt" in
12449         '')     dflt=none;;
12450         esac
12451         rp="What extensions do you wish to load statically?"
12452         . ./myread
12453         case "$ans" in
12454         none) static_ext=' ' ;;
12455         *) static_ext="$ans" ;;
12456         esac
12457         ;;
12458 *)
12459         $cat <<EOM
12460 A number of extensions are supplied with $package.  Answer "none" 
12461 to include no extensions. 
12462 Note that DynaLoader is always built and need not be mentioned here.
12463
12464 EOM
12465         case "$static_ext" in
12466         '') dflt="$avail_ext" ;;
12467         *)      dflt="$static_ext"
12468                 # Perhaps we are reusing an old out-of-date config.sh.
12469                 case "$hint" in
12470                 previous)
12471                         if test X"$static_ext" != X"$avail_ext"; then
12472                                 $cat <<EOM
12473 NOTICE:  Your previous config.sh list may be incorrect. 
12474 The extensions now available to you are 
12475         ${avail_ext}
12476 but the default list from your previous config.sh is
12477         ${static_ext} 
12478
12479 EOM
12480                         fi
12481                         ;;
12482                 esac
12483                 ;;
12484         esac
12485         : Exclude those that are not xs extensions
12486         case "$dflt" in
12487         '')     dflt=none;;
12488         esac
12489         rp="What extensions do you wish to include?"
12490         . ./myread
12491         case "$ans" in
12492         none) static_ext=' ' ;;
12493         *) static_ext="$ans" ;;
12494         esac
12495         ;;
12496 esac
12497
12498 set X $dynamic_ext $static_ext $nonxs_ext
12499 shift
12500 extensions="$*"
12501
12502 : Remove build directory name from cppstdin so it can be used from
12503 : either the present location or the final installed location.
12504 echo " "
12505 : Get out of the UU directory to get correct path name.
12506 cd ..
12507 case "$cppstdin" in
12508 `pwd`/cppstdin)
12509         echo "Stripping down cppstdin path name"
12510         cppstdin=cppstdin
12511         ;;
12512 esac
12513 cd UU
12514
12515 : end of configuration questions
12516 echo " "
12517 echo "End of configuration questions."
12518 echo " "
12519
12520 : back to where it started
12521 if test -d ../UU; then
12522         cd ..
12523 fi
12524
12525 : configuration may be patched via a 'config.over' file
12526 if $test -f config.over; then
12527         echo " "
12528         dflt=y
12529         rp='I see a config.over file.  Do you wish to load it?'
12530         . UU/myread
12531         case "$ans" in
12532         n*) echo "OK, I'll ignore it.";;
12533         *)      . ./config.over
12534                 echo "Configuration override changes have been loaded."
12535                 ;;
12536         esac
12537 fi
12538
12539 : in case they want portability, strip down executable paths
12540 case "$d_portable" in
12541 "$define")
12542         echo " "
12543         echo "Stripping down executable paths..." >&4
12544         for file in $loclist $trylist; do
12545                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12546                         eval $file="\$file"
12547                 fi
12548         done
12549         ;;
12550 esac
12551
12552 : create config.sh file
12553 echo " "
12554 echo "Creating config.sh..." >&4
12555 $spitshell <<EOT >config.sh
12556 $startsh
12557 #
12558 # This file was produced by running the Configure script. It holds all the
12559 # definitions figured out by Configure. Should you modify one of these values,
12560 # do not forget to propagate your changes by running "Configure -der". You may
12561 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12562 #
12563
12564 # Package name      : $package
12565 # Source directory  : $src
12566 # Configuration time: $cf_time
12567 # Configured by     : $cf_by
12568 # Target system     : $myuname
12569
12570 Author='$Author'
12571 Date='$Date'
12572 Header='$Header'
12573 Id='$Id'
12574 Locker='$Locker'
12575 Log='$Log'
12576 Mcc='$Mcc'
12577 RCSfile='$RCSfile'
12578 Revision='$Revision'
12579 Source='$Source'
12580 State='$State'
12581 _a='$_a'
12582 _exe='$_exe'
12583 _o='$_o'
12584 afs='$afs'
12585 alignbytes='$alignbytes'
12586 ansi2knr='$ansi2knr'
12587 aphostname='$aphostname'
12588 apiversion='$apiversion'
12589 ar='$ar'
12590 archlib='$archlib'
12591 archlibexp='$archlibexp'
12592 archname64='$archname64'
12593 archname='$archname'
12594 archobjs='$archobjs'
12595 awk='$awk'
12596 baserev='$baserev'
12597 bash='$bash'
12598 bin='$bin'
12599 binexp='$binexp'
12600 bison='$bison'
12601 byacc='$byacc'
12602 byteorder='$byteorder'
12603 c='$c'
12604 castflags='$castflags'
12605 cat='$cat'
12606 cc='$cc'
12607 cccdlflags='$cccdlflags'
12608 ccdlflags='$ccdlflags'
12609 ccflags='$ccflags'
12610 ccsymbols='$ccsymbols'
12611 cf_by='$cf_by'
12612 cf_email='$cf_email'
12613 cf_time='$cf_time'
12614 chgrp='$chgrp'
12615 chmod='$chmod'
12616 chown='$chown'
12617 clocktype='$clocktype'
12618 comm='$comm'
12619 compress='$compress'
12620 contains='$contains'
12621 cp='$cp'
12622 cpio='$cpio'
12623 cpp='$cpp'
12624 cpp_stuff='$cpp_stuff'
12625 cppccsymbols='$cppccsymbols'
12626 cppflags='$cppflags'
12627 cpplast='$cpplast'
12628 cppminus='$cppminus'
12629 cpprun='$cpprun'
12630 cppstdin='$cppstdin'
12631 cppsymbols='$cppsymbols'
12632 crosscompile='$crosscompile'
12633 cryptlib='$cryptlib'
12634 csh='$csh'
12635 d_Gconvert='$d_Gconvert'
12636 d_access='$d_access'
12637 d_accessx='$d_accessx'
12638 d_alarm='$d_alarm'
12639 d_archlib='$d_archlib'
12640 d_attribut='$d_attribut'
12641 d_bcmp='$d_bcmp'
12642 d_bcopy='$d_bcopy'
12643 d_bsd='$d_bsd'
12644 d_bsdgetpgrp='$d_bsdgetpgrp'
12645 d_bsdsetpgrp='$d_bsdsetpgrp'
12646 d_bzero='$d_bzero'
12647 d_casti32='$d_casti32'
12648 d_castneg='$d_castneg'
12649 d_charvspr='$d_charvspr'
12650 d_chown='$d_chown'
12651 d_chroot='$d_chroot'
12652 d_chsize='$d_chsize'
12653 d_closedir='$d_closedir'
12654 d_cmsghdr_s='$d_cmsghdr_s'
12655 d_const='$d_const'
12656 d_crypt='$d_crypt'
12657 d_csh='$d_csh'
12658 d_cuserid='$d_cuserid'
12659 d_dbl_dig='$d_dbl_dig'
12660 d_dbmclose64='$d_dbmclose64'
12661 d_dbminit64='$d_dbminit64'
12662 d_delete64='$d_delete64'
12663 d_difftime='$d_difftime'
12664 d_dirent64_s='$d_dirent64_s'
12665 d_dirnamlen='$d_dirnamlen'
12666 d_dlerror='$d_dlerror'
12667 d_dlopen='$d_dlopen'
12668 d_dlsymun='$d_dlsymun'
12669 d_dosuid='$d_dosuid'
12670 d_drand48proto='$d_drand48proto'
12671 d_dup2='$d_dup2'
12672 d_eaccess='$d_eaccess'
12673 d_endgrent='$d_endgrent'
12674 d_endhent='$d_endhent'
12675 d_endnent='$d_endnent'
12676 d_endpent='$d_endpent'
12677 d_endpwent='$d_endpwent'
12678 d_endsent='$d_endsent'
12679 d_eofnblk='$d_eofnblk'
12680 d_eunice='$d_eunice'
12681 d_fchmod='$d_fchmod'
12682 d_fchown='$d_fchown'
12683 d_fcntl='$d_fcntl'
12684 d_fd_macros='$d_fd_macros'
12685 d_fd_set='$d_fd_set'
12686 d_fds_bits='$d_fds_bits'
12687 d_fetch64='$d_fetch64'
12688 d_fgetpos64='$d_fgetpos64'
12689 d_fgetpos='$d_fgetpos'
12690 d_firstkey64='$d_firstkey64'
12691 d_flexfnam='$d_flexfnam'
12692 d_flock64_s='$d_flock64_s'
12693 d_flock='$d_flock'
12694 d_fopen64='$d_fopen64'
12695 d_fork='$d_fork'
12696 d_fpathconf='$d_fpathconf'
12697 d_freopen64='$d_freopen64'
12698 d_fseek64='$d_fseek64'
12699 d_fseeko64='$d_fseeko64'
12700 d_fseeko='$d_fseeko'
12701 d_fsetpos64='$d_fsetpos64'
12702 d_fsetpos='$d_fsetpos'
12703 d_fstat64='$d_fstat64'
12704 d_fstatfs='$d_fstatfs'
12705 d_fstatvfs='$d_fstatvfs'
12706 d_ftell64='$d_ftell64'
12707 d_ftello64='$d_ftello64'
12708 d_ftello='$d_ftello'
12709 d_ftime='$d_ftime'
12710 d_ftruncate64='$d_ftruncate64'
12711 d_getgrent='$d_getgrent'
12712 d_getgrps='$d_getgrps'
12713 d_gethbyaddr='$d_gethbyaddr'
12714 d_gethbyname='$d_gethbyname'
12715 d_gethent='$d_gethent'
12716 d_gethname='$d_gethname'
12717 d_gethostprotos='$d_gethostprotos'
12718 d_getlogin='$d_getlogin'
12719 d_getmntent='$d_getmntent'
12720 d_getnbyaddr='$d_getnbyaddr'
12721 d_getnbyname='$d_getnbyname'
12722 d_getnent='$d_getnent'
12723 d_getnetprotos='$d_getnetprotos'
12724 d_getpbyname='$d_getpbyname'
12725 d_getpbynumber='$d_getpbynumber'
12726 d_getpent='$d_getpent'
12727 d_getpgid='$d_getpgid'
12728 d_getpgrp2='$d_getpgrp2'
12729 d_getpgrp='$d_getpgrp'
12730 d_getppid='$d_getppid'
12731 d_getprior='$d_getprior'
12732 d_getprotoprotos='$d_getprotoprotos'
12733 d_getpwent='$d_getpwent'
12734 d_getsbyname='$d_getsbyname'
12735 d_getsbyport='$d_getsbyport'
12736 d_getsent='$d_getsent'
12737 d_getservprotos='$d_getservprotos'
12738 d_gettimeod='$d_gettimeod'
12739 d_gnulibc='$d_gnulibc'
12740 d_grpasswd='$d_grpasswd'
12741 d_hasmntopt='$d_hasmntopt'
12742 d_htonl='$d_htonl'
12743 d_index='$d_index'
12744 d_inetaton='$d_inetaton'
12745 d_ino64t='$d_ino64t'
12746 d_int64t='$d_int64t'
12747 d_iovec_s='$d_iovec_s'
12748 d_isascii='$d_isascii'
12749 d_killpg='$d_killpg'
12750 d_lchown='$d_lchown'
12751 d_link='$d_link'
12752 d_locconv='$d_locconv'
12753 d_lockf64='$d_lockf64'
12754 d_lockf='$d_lockf'
12755 d_longdbl='$d_longdbl'
12756 d_longlong='$d_longlong'
12757 d_lseek64='$d_lseek64'
12758 d_lstat64='$d_lstat64'
12759 d_lstat='$d_lstat'
12760 d_madvise='$d_madvise'
12761 d_mblen='$d_mblen'
12762 d_mbstowcs='$d_mbstowcs'
12763 d_mbtowc='$d_mbtowc'
12764 d_memcmp='$d_memcmp'
12765 d_memcpy='$d_memcpy'
12766 d_memmove='$d_memmove'
12767 d_memset='$d_memset'
12768 d_mkdir='$d_mkdir'
12769 d_mkfifo='$d_mkfifo'
12770 d_mktime='$d_mktime'
12771 d_mmap='$d_mmap'
12772 d_mprotect='$d_mprotect'
12773 d_msg='$d_msg'
12774 d_msg_ctrunc='$d_msg_ctrunc'
12775 d_msg_dontroute='$d_msg_dontroute'
12776 d_msg_oob='$d_msg_oob'
12777 d_msg_peek='$d_msg_peek'
12778 d_msg_proxy='$d_msg_proxy'
12779 d_msgctl='$d_msgctl'
12780 d_msgget='$d_msgget'
12781 d_msghdr_s='$d_msghdr_s'
12782 d_msgrcv='$d_msgrcv'
12783 d_msgsnd='$d_msgsnd'
12784 d_msync='$d_msync'
12785 d_munmap='$d_munmap'
12786 d_mymalloc='$d_mymalloc'
12787 d_nextkey64='$d_nextkey64'
12788 d_nice='$d_nice'
12789 d_off64t='$d_off64t'
12790 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
12791 d_oldpthreads='$d_oldpthreads'
12792 d_oldsock='$d_oldsock'
12793 d_open3='$d_open3'
12794 d_open64='$d_open64'
12795 d_opendir64='$d_opendir64'
12796 d_pathconf='$d_pathconf'
12797 d_pause='$d_pause'
12798 d_phostname='$d_phostname'
12799 d_pipe='$d_pipe'
12800 d_poll='$d_poll'
12801 d_portable='$d_portable'
12802 d_pthread_yield='$d_pthread_yield'
12803 d_pwage='$d_pwage'
12804 d_pwchange='$d_pwchange'
12805 d_pwclass='$d_pwclass'
12806 d_pwcomment='$d_pwcomment'
12807 d_pwexpire='$d_pwexpire'
12808 d_pwgecos='$d_pwgecos'
12809 d_pwpasswd='$d_pwpasswd'
12810 d_pwquota='$d_pwquota'
12811 d_readdir64='$d_readdir64'
12812 d_readdir='$d_readdir'
12813 d_readlink='$d_readlink'
12814 d_readv='$d_readv'
12815 d_recvmsg='$d_recvmsg'
12816 d_rename='$d_rename'
12817 d_rewinddir='$d_rewinddir'
12818 d_rmdir='$d_rmdir'
12819 d_safebcpy='$d_safebcpy'
12820 d_safemcpy='$d_safemcpy'
12821 d_sanemcmp='$d_sanemcmp'
12822 d_sched_yield='$d_sched_yield'
12823 d_scm_rights='$d_scm_rights'
12824 d_seekdir64='$d_seekdir64'
12825 d_seekdir='$d_seekdir'
12826 d_select='$d_select'
12827 d_sem='$d_sem'
12828 d_semctl='$d_semctl'
12829 d_semctl_semid_ds='$d_semctl_semid_ds'
12830 d_semctl_semun='$d_semctl_semun'
12831 d_semget='$d_semget'
12832 d_semop='$d_semop'
12833 d_sendmsg='$d_sendmsg'
12834 d_setegid='$d_setegid'
12835 d_seteuid='$d_seteuid'
12836 d_setgrent='$d_setgrent'
12837 d_setgrps='$d_setgrps'
12838 d_sethent='$d_sethent'
12839 d_setlinebuf='$d_setlinebuf'
12840 d_setlocale='$d_setlocale'
12841 d_setnent='$d_setnent'
12842 d_setpent='$d_setpent'
12843 d_setpgid='$d_setpgid'
12844 d_setpgrp2='$d_setpgrp2'
12845 d_setpgrp='$d_setpgrp'
12846 d_setprior='$d_setprior'
12847 d_setpwent='$d_setpwent'
12848 d_setregid='$d_setregid'
12849 d_setresgid='$d_setresgid'
12850 d_setresuid='$d_setresuid'
12851 d_setreuid='$d_setreuid'
12852 d_setrgid='$d_setrgid'
12853 d_setruid='$d_setruid'
12854 d_setsent='$d_setsent'
12855 d_setsid='$d_setsid'
12856 d_setvbuf='$d_setvbuf'
12857 d_sfio='$d_sfio'
12858 d_shm='$d_shm'
12859 d_shmat='$d_shmat'
12860 d_shmatprototype='$d_shmatprototype'
12861 d_shmctl='$d_shmctl'
12862 d_shmdt='$d_shmdt'
12863 d_shmget='$d_shmget'
12864 d_sigaction='$d_sigaction'
12865 d_sigsetjmp='$d_sigsetjmp'
12866 d_socket='$d_socket'
12867 d_sockpair='$d_sockpair'
12868 d_stat64='$d_stat64'
12869 d_statblks='$d_statblks'
12870 d_statfs='$d_statfs'
12871 d_statfsflags='$d_statfsflags'
12872 d_statvfs='$d_statvfs'
12873 d_stdio_cnt_lval='$d_stdio_cnt_lval'
12874 d_stdio_ptr_lval='$d_stdio_ptr_lval'
12875 d_stdiobase='$d_stdiobase'
12876 d_stdstdio='$d_stdstdio'
12877 d_store64='$d_store64'
12878 d_strchr='$d_strchr'
12879 d_strcoll='$d_strcoll'
12880 d_strctcpy='$d_strctcpy'
12881 d_strerrm='$d_strerrm'
12882 d_strerror='$d_strerror'
12883 d_strtod='$d_strtod'
12884 d_strtol='$d_strtol'
12885 d_strtoul='$d_strtoul'
12886 d_strxfrm='$d_strxfrm'
12887 d_suidsafe='$d_suidsafe'
12888 d_symlink='$d_symlink'
12889 d_syscall='$d_syscall'
12890 d_sysconf='$d_sysconf'
12891 d_sysernlst='$d_sysernlst'
12892 d_syserrlst='$d_syserrlst'
12893 d_system='$d_system'
12894 d_tcgetpgrp='$d_tcgetpgrp'
12895 d_tcsetpgrp='$d_tcsetpgrp'
12896 d_telldir64='$d_telldir64'
12897 d_telldir='$d_telldir'
12898 d_telldirproto='$d_telldirproto'
12899 d_time='$d_time'
12900 d_times='$d_times'
12901 d_tmpfile64='$d_tmpfile64'
12902 d_truncate64='$d_truncate64'
12903 d_truncate='$d_truncate'
12904 d_tzname='$d_tzname'
12905 d_umask='$d_umask'
12906 d_uname='$d_uname'
12907 d_union_semun='$d_union_semun'
12908 d_vfork='$d_vfork'
12909 d_void_closedir='$d_void_closedir'
12910 d_voidsig='$d_voidsig'
12911 d_voidtty='$d_voidtty'
12912 d_volatile='$d_volatile'
12913 d_vprintf='$d_vprintf'
12914 d_wait4='$d_wait4'
12915 d_waitpid='$d_waitpid'
12916 d_wcstombs='$d_wcstombs'
12917 d_wctomb='$d_wctomb'
12918 d_writev='$d_writev'
12919 d_xenix='$d_xenix'
12920 date='$date'
12921 db_hashtype='$db_hashtype'
12922 db_prefixtype='$db_prefixtype'
12923 defvoidused='$defvoidused'
12924 direntrytype='$direntrytype'
12925 dlext='$dlext'
12926 dlsrc='$dlsrc'
12927 doublesize='$doublesize'
12928 drand01='$drand01'
12929 dynamic_ext='$dynamic_ext'
12930 eagain='$eagain'
12931 ebcdic='$ebcdic'
12932 echo='$echo'
12933 egrep='$egrep'
12934 emacs='$emacs'
12935 eunicefix='$eunicefix'
12936 exe_ext='$exe_ext'
12937 expr='$expr'
12938 extensions='$extensions'
12939 find='$find'
12940 firstmakefile='$firstmakefile'
12941 flex='$flex'
12942 fpostype='$fpostype'
12943 freetype='$freetype'
12944 full_ar='$full_ar'
12945 full_csh='$full_csh'
12946 full_sed='$full_sed'
12947 gccversion='$gccversion'
12948 gidtype='$gidtype'
12949 glibpth='$glibpth'
12950 grep='$grep'
12951 groupcat='$groupcat'
12952 groupstype='$groupstype'
12953 gzip='$gzip'
12954 h_fcntl='$h_fcntl'
12955 h_sysfile='$h_sysfile'
12956 hint='$hint'
12957 hostcat='$hostcat'
12958 huge='$huge'
12959 i_arpainet='$i_arpainet'
12960 i_bsdioctl='$i_bsdioctl'
12961 i_db='$i_db'
12962 i_dbm='$i_dbm'
12963 i_dirent='$i_dirent'
12964 i_dld='$i_dld'
12965 i_dlfcn='$i_dlfcn'
12966 i_fcntl='$i_fcntl'
12967 i_float='$i_float'
12968 i_gdbm='$i_gdbm'
12969 i_grp='$i_grp'
12970 i_inttypes='$i_inttypes'
12971 i_limits='$i_limits'
12972 i_locale='$i_locale'
12973 i_machcthr='$i_machcthr'
12974 i_malloc='$i_malloc'
12975 i_math='$i_math'
12976 i_memory='$i_memory'
12977 i_mntent='$i_mntent'
12978 i_ndbm='$i_ndbm'
12979 i_netdb='$i_netdb'
12980 i_neterrno='$i_neterrno'
12981 i_niin='$i_niin'
12982 i_poll='$i_poll'
12983 i_pwd='$i_pwd'
12984 i_rpcsvcdbm='$i_rpcsvcdbm'
12985 i_sfio='$i_sfio'
12986 i_sgtty='$i_sgtty'
12987 i_stdarg='$i_stdarg'
12988 i_stddef='$i_stddef'
12989 i_stdlib='$i_stdlib'
12990 i_string='$i_string'
12991 i_sysaccess='$i_sysaccess'
12992 i_sysdir='$i_sysdir'
12993 i_sysfile='$i_sysfile'
12994 i_sysfilio='$i_sysfilio'
12995 i_sysin='$i_sysin'
12996 i_sysioctl='$i_sysioctl'
12997 i_sysmman='$i_sysmman'
12998 i_sysmount='$i_sysmount'
12999 i_sysndir='$i_sysndir'
13000 i_sysparam='$i_sysparam'
13001 i_sysresrc='$i_sysresrc'
13002 i_syssecrt='$i_syssecrt'
13003 i_sysselct='$i_sysselct'
13004 i_syssockio='$i_syssockio'
13005 i_sysstat='$i_sysstat'
13006 i_sysstatvfs='$i_sysstatvfs'
13007 i_systime='$i_systime'
13008 i_systimek='$i_systimek'
13009 i_systimes='$i_systimes'
13010 i_systypes='$i_systypes'
13011 i_sysuio='$i_sysuio'
13012 i_sysun='$i_sysun'
13013 i_syswait='$i_syswait'
13014 i_termio='$i_termio'
13015 i_termios='$i_termios'
13016 i_time='$i_time'
13017 i_unistd='$i_unistd'
13018 i_utime='$i_utime'
13019 i_values='$i_values'
13020 i_varargs='$i_varargs'
13021 i_varhdr='$i_varhdr'
13022 i_vfork='$i_vfork'
13023 ignore_versioned_solibs='$ignore_versioned_solibs'
13024 incpath='$incpath'
13025 inews='$inews'
13026 installarchlib='$installarchlib'
13027 installbin='$installbin'
13028 installman1dir='$installman1dir'
13029 installman3dir='$installman3dir'
13030 installprivlib='$installprivlib'
13031 installscript='$installscript'
13032 installsitearch='$installsitearch'
13033 installsitelib='$installsitelib'
13034 installusrbinperl='$installusrbinperl'
13035 intsize='$intsize'
13036 known_extensions='$known_extensions'
13037 ksh='$ksh'
13038 large='$large'
13039 ld='$ld'
13040 lddlflags='$lddlflags'
13041 ldflags='$ldflags'
13042 less='$less'
13043 lib_ext='$lib_ext'
13044 libc='$libc'
13045 libperl='$libperl'
13046 libpth='$libpth'
13047 libs='$libs'
13048 libswanted='$libswanted'
13049 line='$line'
13050 lint='$lint'
13051 lkflags='$lkflags'
13052 ln='$ln'
13053 lns='$lns'
13054 locincpth='$locincpth'
13055 loclibpth='$loclibpth'
13056 longdblsize='$longdblsize'
13057 longlongsize='$longlongsize'
13058 longsize='$longsize'
13059 lp='$lp'
13060 lpr='$lpr'
13061 ls='$ls'
13062 lseeksize='$lseeksize'
13063 lseektype='$lseektype'
13064 mail='$mail'
13065 mailx='$mailx'
13066 make='$make'
13067 make_set_make='$make_set_make'
13068 mallocobj='$mallocobj'
13069 mallocsrc='$mallocsrc'
13070 malloctype='$malloctype'
13071 man1dir='$man1dir'
13072 man1direxp='$man1direxp'
13073 man1ext='$man1ext'
13074 man3dir='$man3dir'
13075 man3direxp='$man3direxp'
13076 man3ext='$man3ext'
13077 medium='$medium'
13078 mips='$mips'
13079 mips_type='$mips_type'
13080 mkdir='$mkdir'
13081 mmaptype='$mmaptype'
13082 models='$models'
13083 modetype='$modetype'
13084 more='$more'
13085 multiarch='$multiarch'
13086 mv='$mv'
13087 myarchname='$myarchname'
13088 mydomain='$mydomain'
13089 myhostname='$myhostname'
13090 myuname='$myuname'
13091 n='$n'
13092 netdb_hlen_type='$netdb_hlen_type'
13093 netdb_host_type='$netdb_host_type'
13094 netdb_name_type='$netdb_name_type'
13095 netdb_net_type='$netdb_net_type'
13096 nm='$nm'
13097 nm_opt='$nm_opt'
13098 nm_so_opt='$nm_so_opt'
13099 nonxs_ext='$nonxs_ext'
13100 nroff='$nroff'
13101 o_nonblock='$o_nonblock'
13102 obj_ext='$obj_ext'
13103 old_pthread_create_joinable='$old_pthread_create_joinable'
13104 optimize='$optimize'
13105 orderlib='$orderlib'
13106 osname='$osname'
13107 osvers='$osvers'
13108 package='$package'
13109 pager='$pager'
13110 passcat='$passcat'
13111 patchlevel='$patchlevel'
13112 path_sep='$path_sep'
13113 perl='$perl'
13114 perladmin='$perladmin'
13115 perlpath='$perlpath'
13116 pg='$pg'
13117 phostname='$phostname'
13118 pidtype='$pidtype'
13119 plibpth='$plibpth'
13120 pmake='$pmake'
13121 pr='$pr'
13122 prefix='$prefix'
13123 prefixexp='$prefixexp'
13124 privlib='$privlib'
13125 privlibexp='$privlibexp'
13126 prototype='$prototype'
13127 ptrsize='$ptrsize'
13128 randbits='$randbits'
13129 randfunc='$randfunc'
13130 randseedtype='$randseedtype'
13131 ranlib='$ranlib'
13132 rd_nodata='$rd_nodata'
13133 rm='$rm'
13134 rmail='$rmail'
13135 runnm='$runnm'
13136 sched_yield='$sched_yield'
13137 scriptdir='$scriptdir'
13138 scriptdirexp='$scriptdirexp'
13139 sed='$sed'
13140 seedfunc='$seedfunc'
13141 selectminbits='$selectminbits'
13142 selecttype='$selecttype'
13143 sendmail='$sendmail'
13144 sh='$sh'
13145 shar='$shar'
13146 sharpbang='$sharpbang'
13147 shmattype='$shmattype'
13148 shortsize='$shortsize'
13149 shrpenv='$shrpenv'
13150 shsharp='$shsharp'
13151 sig_name='$sig_name'
13152 sig_name_init='$sig_name_init'
13153 sig_num='$sig_num'
13154 sig_num_init='$sig_num_init'
13155 signal_t='$signal_t'
13156 sitearch='$sitearch'
13157 sitearchexp='$sitearchexp'
13158 sitelib='$sitelib'
13159 sitelibexp='$sitelibexp'
13160 sizetype='$sizetype'
13161 sleep='$sleep'
13162 smail='$smail'
13163 small='$small'
13164 so='$so'
13165 sockethdr='$sockethdr'
13166 socketlib='$socketlib'
13167 sort='$sort'
13168 spackage='$spackage'
13169 spitshell='$spitshell'
13170 split='$split'
13171 src='$src'
13172 ssizetype='$ssizetype'
13173 startperl='$startperl'
13174 startsh='$startsh'
13175 static_ext='$static_ext'
13176 stdchar='$stdchar'
13177 stdio_base='$stdio_base'
13178 stdio_bufsiz='$stdio_bufsiz'
13179 stdio_cnt='$stdio_cnt'
13180 stdio_filbuf='$stdio_filbuf'
13181 stdio_ptr='$stdio_ptr'
13182 strings='$strings'
13183 submit='$submit'
13184 subversion='$subversion'
13185 sysman='$sysman'
13186 tail='$tail'
13187 tar='$tar'
13188 tbl='$tbl'
13189 tee='$tee'
13190 test='$test'
13191 timeincl='$timeincl'
13192 timetype='$timetype'
13193 touch='$touch'
13194 tr='$tr'
13195 trnl='$trnl'
13196 troff='$troff'
13197 uidtype='$uidtype'
13198 uname='$uname'
13199 uniq='$uniq'
13200 use64bits='$use64bits'
13201 usedl='$usedl'
13202 usemultiplicity='$usemultiplicity'
13203 usemymalloc='$usemymalloc'
13204 usenm='$usenm'
13205 useopcode='$useopcode'
13206 useperlio='$useperlio'
13207 useposix='$useposix'
13208 usesfio='$usesfio'
13209 useshrplib='$useshrplib'
13210 usethreads='$usethreads'
13211 usevfork='$usevfork'
13212 usrinc='$usrinc'
13213 uuname='$uuname'
13214 version='$version'
13215 vi='$vi'
13216 voidflags='$voidflags'
13217 xlibpth='$xlibpth'
13218 zcat='$zcat'
13219 zip='$zip'
13220 EOT
13221
13222 : Add in command line options if available
13223 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13224
13225 : add special variables
13226 $test -f $src/patchlevel.h && \
13227 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13228 echo "CONFIG=true" >>config.sh
13229
13230 : propagate old symbols
13231 if $test -f UU/config.sh; then
13232         <UU/config.sh sort | uniq >UU/oldconfig.sh
13233         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13234         sort | uniq -u >UU/oldsyms
13235         set X `cat UU/oldsyms`
13236         shift
13237         case $# in
13238         0) ;;
13239         *)
13240                 cat <<EOM
13241 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13242 EOM
13243                 echo "# Variables propagated from previous config.sh file." >>config.sh
13244                 for sym in `cat UU/oldsyms`; do
13245                         echo "    Propagating $hint variable "'$'"$sym..."
13246                         eval 'tmp="$'"${sym}"'"'
13247                         echo "$tmp" | \
13248                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13249                 done
13250                 ;;
13251         esac
13252 fi
13253
13254 : Finish up by extracting the .SH files
13255 case "$alldone" in
13256 exit)
13257         $rm -rf UU
13258         echo "Done."
13259         exit 0
13260         ;;
13261 cont)
13262         ;;
13263 '')
13264         dflt=''
13265         nostick=true
13266         $cat <<EOM
13267
13268 If you'd like to make any changes to the config.sh file before I begin
13269 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13270
13271 EOM
13272         rp="Press return or use a shell escape to edit config.sh:"
13273         . UU/myread
13274         nostick=''
13275         case "$ans" in
13276         '') ;;
13277         *) : in case they cannot read
13278                 sh 1>&4 -c "$ans";;
13279         esac
13280         ;;
13281 esac
13282
13283 : if this fails, just run all the .SH files by hand
13284 . ./config.sh
13285
13286 echo " "
13287 exec 1>&4
13288 . ./UU/extract
13289
13290 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13291         dflt=y
13292         case "$silent" in
13293         true) ;;
13294         *)
13295                 $cat <<EOM
13296
13297 Now you need to generate make dependencies by running "$make depend".
13298 You might prefer to run it in background: "$make depend > makedepend.out &"
13299 It can take a while, so you might not want to run it right now.
13300
13301 EOM
13302                 ;;
13303         esac
13304         rp="Run $make depend now?"
13305         . UU/myread
13306         case "$ans" in
13307         y*)
13308                 $make depend && echo "Now you must run a $make."
13309                 ;;
13310         *)
13311                 echo "You must run '$make depend' then '$make'."
13312                 ;;
13313         esac
13314 elif test -f [Mm]akefile; then
13315         echo " "
13316         echo "Now you must run a $make."
13317 else
13318         echo "Done."
13319 fi
13320
13321 if $test -f Policy.sh; then
13322     $cat <<EOM
13323
13324 If you compile $package on a different machine or from a different object
13325 directory, copy the Policy.sh file from this object directory to the
13326 new one before you run Configure -- this will help you with most of
13327 the policy defaults.
13328
13329 EOM
13330 fi
13331 if $test -f config.msg; then
13332     echo "Hmm.  I also noted the following information while running:"
13333     echo " "
13334     $cat config.msg >&4
13335     $rm -f config.msg
13336 fi
13337 $rm -f kit*isdone ark*isdone
13338 $rm -rf UU
13339
13340 : End of Configure
13341