A better, shinier, and possibly even correctly working
[p5sagit/p5-mst-13.2.git] / Configure
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc and is available on CPAN under authors/id/RAM so
18 # you may fetch it yourself from your nearest archive site.)
19 #
20
21 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
22 #
23 # Generated on Wed May 12 13:22:22 EET DST 1999 [metaconfig 3.0 PL70]
24 # (with additional metaconfig patches by perlbug@perl.com)
25
26 cat >/tmp/c1$$ <<EOF
27 ARGGGHHHH!!!!!
28
29 SCO csh still thinks true is false.  Write to SCO today and tell them that next
30 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
31
32 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
33 we'd have to do is go in and swap the && and || tokens, wherever they are.)
34
35 [End of diatribe. We now return you to your regularly scheduled programming...]
36 EOF
37 cat >/tmp/c2$$ <<EOF
38
39 OOPS!  You naughty creature!  You didn't run Configure with sh!
40 I will attempt to remedy the situation by running sh for you...
41 EOF
42
43 true || cat /tmp/c1$$ /tmp/c2$$
44 true || exec sh $0 $argv:q
45
46 (exit $?0) || cat /tmp/c2$$
47 (exit $?0) || exec sh $0 $argv:q
48 rm -f /tmp/c1$$ /tmp/c2$$
49
50 : compute my invocation name
51 me=$0
52 case "$0" in
53 */*)
54         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55         test "$me" || me=$0
56         ;;
57 esac
58
59 : Proper separator for the PATH environment variable
60 p_=:
61 : On OS/2 this directory should exist if this is not floppy only system :-]
62 if test -d c:/. ; then
63     if test -n "$OS2_SHELL"; then
64                 p_=\;
65                 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
66                 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
67         elif test -n "$DJGPP"; then
68                 p_=\;
69         fi
70 fi
71
72 : Proper PATH setting
73 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
74 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
75 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
76 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
77 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80 paths="$paths /sbin /usr/sbin /usr/libexec"
81
82 for p in $paths
83 do
84         case "$p_$PATH$p_" in
85         *$p_$p$p_*) ;;
86         *) test -d $p && PATH=$PATH$p_$p ;;
87         esac
88 done
89
90 PATH=.$p_$PATH
91 export PATH
92
93 : shall we be using ksh?
94 inksh=''
95 needksh=''
96 avoidksh=''
97 newsh=/bin/ksh
98 changesh=''
99 if (PATH=.; alias -x) >/dev/null 2>&1; then
100                 inksh=true
101 fi
102 if test -f /hp-ux -a -f /bin/ksh; then
103         needksh='to avoid sh bug in "here document" expansion'
104 fi
105 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
106         if test X`/usr/bin/uname -v` = X4; then
107                 avoidksh="to avoid AIX 4's /bin/sh"
108                 newsh=/usr/bin/bsh
109         fi
110 fi
111 if test -f /osf_boot -a -f /usr/sbin/setld; then
112         if test X`/usr/bin/uname -s` = XOSF1; then
113                 avoidksh="to avoid Digital UNIX' ksh"
114                 newsh=/bin/sh
115                 unset BIN_SH # if this is 'xpg4' sh will start up ksh
116         fi
117 fi
118 case "$inksh/$needksh" in
119 /[a-z]*)
120                 ENV=''
121                 changesh=true
122                 reason="$needksh"
123         ;;
124 esac
125 case "$inksh/$avoidksh" in
126 true/[a-z]*)
127         changesh=true
128         reason="$avoidksh"
129         ;;
130 esac
131 case "$inksh/$needksh-$avoidksh-" in
132 true/--)
133                 cat <<EOM
134 (I see you are using the Korn shell.  Some ksh's blow up on $me,
135 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
136 EOM
137         ;;
138 esac
139 case "$changesh" in
140 true)
141         echo "(Feeding myself to $newsh $reason.)"
142         case "$0" in
143         Configure|*/Configure) exec $newsh $0 "$@";;
144         *) exec $newsh Configure "$@";;
145         esac
146         ;;
147 esac
148
149 : if needed set CDPATH to a harmless value that is not chatty
150 : avoid bash 2.02 problems with empty CDPATH.
151 case "$CDPATH" in
152 '')     ;;
153 *)      case "$SHELL" in
154         *bash*) CDPATH='.' ;;
155         *)              CDPATH='' ;;
156         esac
157         ;;
158 esac
159 : Configure runs within the UU subdirectory
160 test -d UU || mkdir UU
161 cd UU && rm -f ./*
162
163 ccsymbols=''
164 cppccsymbols=''
165 cppsymbols=''
166 dynamic_ext=''
167 extensions=''
168 known_extensions=''
169 nonxs_ext=''
170 static_ext=''
171 useopcode=''
172 useposix=''
173 d_bsd=''
174 d_eunice=''
175 d_xenix=''
176 eunicefix=''
177 Mcc=''
178 ar=''
179 awk=''
180 bash=''
181 bison=''
182 byacc=''
183 cat=''
184 chgrp=''
185 chmod=''
186 chown=''
187 comm=''
188 compress=''
189 cp=''
190 cpio=''
191 cpp=''
192 csh=''
193 date=''
194 echo=''
195 egrep=''
196 emacs=''
197 expr=''
198 find=''
199 flex=''
200 grep=''
201 gzip=''
202 inews=''
203 ksh=''
204 less=''
205 line=''
206 lint=''
207 ln=''
208 lp=''
209 lpr=''
210 ls=''
211 mail=''
212 mailx=''
213 make=''
214 mkdir=''
215 more=''
216 mv=''
217 nm=''
218 nroff=''
219 perl=''
220 pg=''
221 pmake=''
222 pr=''
223 rm=''
224 rmail=''
225 sed=''
226 sendmail=''
227 shar=''
228 sleep=''
229 smail=''
230 sort=''
231 submit=''
232 tail=''
233 tar=''
234 tbl=''
235 tee=''
236 test=''
237 touch=''
238 tr=''
239 troff=''
240 uname=''
241 uniq=''
242 uuname=''
243 vi=''
244 zcat=''
245 zip=''
246 full_ar=''
247 full_sed=''
248 libswanted=''
249 hint=''
250 myuname=''
251 osname=''
252 osvers=''
253 Author=''
254 Date=''
255 Header=''
256 Id=''
257 Locker=''
258 Log=''
259 RCSfile=''
260 Revision=''
261 Source=''
262 State=''
263 _a=''
264 _exe=''
265 _o=''
266 archobjs=''
267 exe_ext=''
268 firstmakefile=''
269 lib_ext=''
270 obj_ext=''
271 path_sep=''
272 afs=''
273 alignbytes=''
274 ansi2knr=''
275 archlib=''
276 archlibexp=''
277 d_archlib=''
278 installarchlib=''
279 archname=''
280 myarchname=''
281 baserev=''
282 bin=''
283 binexp=''
284 installbin=''
285 byteorder=''
286 cc=''
287 gccversion=''
288 ccflags=''
289 cppflags=''
290 ldflags=''
291 lkflags=''
292 locincpth=''
293 optimize=''
294 cf_email=''
295 cf_by=''
296 cf_time=''
297 contains=''
298 cpp_stuff=''
299 cpplast=''
300 cppminus=''
301 cpprun=''
302 cppstdin=''
303 crosscompile=''
304 d_access=''
305 d_accessx=''
306 d_alarm=''
307 d_attribut=''
308 d_bcmp=''
309 d_bcopy=''
310 d_bzero=''
311 d_casti32=''
312 castflags=''
313 d_castneg=''
314 d_chown=''
315 d_chroot=''
316 d_chsize=''
317 d_closedir=''
318 d_void_closedir=''
319 d_const=''
320 cryptlib=''
321 d_crypt=''
322 d_csh=''
323 full_csh=''
324 d_cuserid=''
325 d_dbl_dig=''
326 d_difftime=''
327 d_dlerror=''
328 d_dlopen=''
329 d_dlsymun=''
330 d_dosuid=''
331 d_suidsafe=''
332 d_drand48proto=''
333 d_dup2=''
334 d_eaccess=''
335 d_endgrent=''
336 d_endhent=''
337 d_endnent=''
338 d_endpent=''
339 d_endpwent=''
340 d_endsent=''
341 d_fchmod=''
342 d_fchown=''
343 d_fcntl=''
344 d_fd_macros=''
345 d_fd_set=''
346 d_fds_bits=''
347 d_fgetpos=''
348 d_flexfnam=''
349 d_flock=''
350 d_fork=''
351 d_fseeko=''
352 d_fsetpos=''
353 d_ftello=''
354 d_ftime=''
355 d_gettimeod=''
356 d_Gconvert=''
357 d_getgrent=''
358 d_getgrps=''
359 d_gethbyaddr=''
360 d_gethbyname=''
361 d_gethent=''
362 aphostname=''
363 d_gethname=''
364 d_phostname=''
365 d_uname=''
366 d_gethostprotos=''
367 d_getlogin=''
368 d_getmntent=''
369 d_getnbyaddr=''
370 d_getnbyname=''
371 d_getnent=''
372 d_getnetprotos=''
373 d_getpent=''
374 d_getpgid=''
375 d_getpgrp2=''
376 d_bsdgetpgrp=''
377 d_getpgrp=''
378 d_getppid=''
379 d_getprior=''
380 d_getpbyname=''
381 d_getpbynumber=''
382 d_getprotoprotos=''
383 d_getpwent=''
384 d_getsent=''
385 d_getservprotos=''
386 d_getsbyname=''
387 d_getsbyport=''
388 d_gnulibc=''
389 d_hasmntopt=''
390 d_htonl=''
391 d_inetaton=''
392 d_isascii=''
393 d_killpg=''
394 d_lchown=''
395 d_link=''
396 d_locconv=''
397 d_lockf=''
398 d_longdbl=''
399 longdblsize=''
400 d_longlong=''
401 longlongsize=''
402 d_lstat=''
403 d_madvise=''
404 d_mblen=''
405 d_mbstowcs=''
406 d_mbtowc=''
407 d_memcmp=''
408 d_memcpy=''
409 d_memmove=''
410 d_memset=''
411 d_mkdir=''
412 d_mkfifo=''
413 d_mktime=''
414 d_mmap=''
415 mmaptype=''
416 d_mprotect=''
417 d_msg=''
418 d_msgctl=''
419 d_msgget=''
420 d_msgrcv=''
421 d_msgsnd=''
422 d_msync=''
423 d_munmap=''
424 d_nice=''
425 d_open3=''
426 d_fpathconf=''
427 d_pathconf=''
428 d_pause=''
429 d_pipe=''
430 d_poll=''
431 d_portable=''
432 d_old_pthread_create_joinable=''
433 old_pthread_create_joinable=''
434 d_pthread_yield=''
435 d_sched_yield=''
436 sched_yield=''
437 d_readdir=''
438 d_rewinddir=''
439 d_seekdir=''
440 d_telldir=''
441 d_readlink=''
442 d_readv=''
443 d_rename=''
444 d_rmdir=''
445 d_safebcpy=''
446 d_safemcpy=''
447 d_sanemcmp=''
448 d_select=''
449 d_sem=''
450 d_semctl=''
451 d_semget=''
452 d_semop=''
453 d_setegid=''
454 d_seteuid=''
455 d_setgrent=''
456 d_setgrps=''
457 d_sethent=''
458 d_setlinebuf=''
459 d_setlocale=''
460 d_setnent=''
461 d_setpent=''
462 d_setpgid=''
463 d_setpgrp2=''
464 d_bsdsetpgrp=''
465 d_setpgrp=''
466 d_setprior=''
467 d_setpwent=''
468 d_setregid=''
469 d_setresgid=''
470 d_setresuid=''
471 d_setreuid=''
472 d_setrgid=''
473 d_setruid=''
474 d_setsent=''
475 d_setsid=''
476 d_setvbuf=''
477 d_sfio=''
478 usesfio=''
479 d_shm=''
480 d_shmat=''
481 d_shmatprototype=''
482 shmattype=''
483 d_shmctl=''
484 d_shmdt=''
485 d_shmget=''
486 d_sigaction=''
487 d_sigsetjmp=''
488 d_cmsghdr_s=''
489 d_msg_ctrunc=''
490 d_msg_dontroute=''
491 d_msg_oob=''
492 d_msg_peek=''
493 d_msg_proxy=''
494 d_msghdr_s=''
495 d_oldsock=''
496 d_recvmsg=''
497 d_scm_rights=''
498 d_sendmsg=''
499 d_socket=''
500 d_sockpair=''
501 sockethdr=''
502 socketlib=''
503 d_statblks=''
504 d_fstatfs=''
505 d_statfs=''
506 d_statfsflags=''
507 d_fstatvfs=''
508 d_statvfs=''
509 d_stdio_cnt_lval=''
510 d_stdio_ptr_lval=''
511 d_stdiobase=''
512 d_stdstdio=''
513 stdio_base=''
514 stdio_bufsiz=''
515 stdio_cnt=''
516 stdio_filbuf=''
517 stdio_ptr=''
518 d_index=''
519 d_strchr=''
520 d_strcoll=''
521 d_strctcpy=''
522 d_strerrm=''
523 d_strerror=''
524 d_sysernlst=''
525 d_syserrlst=''
526 d_strtod=''
527 d_strtol=''
528 d_strtoul=''
529 d_strxfrm=''
530 d_symlink=''
531 d_syscall=''
532 d_sysconf=''
533 d_system=''
534 d_tcgetpgrp=''
535 d_tcsetpgrp=''
536 d_telldirproto=''
537 d_time=''
538 timetype=''
539 clocktype=''
540 d_times=''
541 d_truncate=''
542 d_tzname=''
543 d_umask=''
544 d_semctl_semid_ds=''
545 d_semctl_semun=''
546 d_union_semun=''
547 d_vfork=''
548 usevfork=''
549 d_voidsig=''
550 signal_t=''
551 d_volatile=''
552 d_charvspr=''
553 d_vprintf=''
554 d_wait4=''
555 d_waitpid=''
556 d_wcstombs=''
557 d_wctomb=''
558 d_writev=''
559 d_dbmclose64=''
560 d_dbminit64=''
561 d_delete64=''
562 d_fetch64=''
563 d_firstkey64=''
564 d_nextkey64=''
565 d_store64=''
566 dlext=''
567 cccdlflags=''
568 ccdlflags=''
569 dlsrc=''
570 ld=''
571 lddlflags=''
572 usedl=''
573 doublesize=''
574 ebcdic=''
575 fflushNULL=''
576 fpostype=''
577 gidtype=''
578 groupstype=''
579 h_fcntl=''
580 h_sysfile=''
581 i_arpainet=''
582 db_hashtype=''
583 db_prefixtype=''
584 i_db=''
585 i_dbm=''
586 i_rpcsvcdbm=''
587 d_dirnamlen=''
588 direntrytype=''
589 i_dirent=''
590 i_dld=''
591 i_dlfcn=''
592 i_fcntl=''
593 i_float=''
594 i_gdbm=''
595 d_grpasswd=''
596 i_grp=''
597 d_int64t=''
598 i_inttypes=''
599 i_limits=''
600 i_locale=''
601 i_machcthr=''
602 i_malloc=''
603 i_math=''
604 i_memory=''
605 i_mntent=''
606 i_ndbm=''
607 i_netdb=''
608 i_neterrno=''
609 i_netinettcp=''
610 i_niin=''
611 i_sysin=''
612 i_poll=''
613 i_pthread=''
614 d_pwage=''
615 d_pwchange=''
616 d_pwclass=''
617 d_pwcomment=''
618 d_pwexpire=''
619 d_pwgecos=''
620 d_pwpasswd=''
621 d_pwquota=''
622 i_pwd=''
623 i_sfio=''
624 i_stddef=''
625 i_stdlib=''
626 i_string=''
627 strings=''
628 i_sysaccess=''
629 i_sysdir=''
630 i_sysfile=''
631 d_voidtty=''
632 i_bsdioctl=''
633 i_sysfilio=''
634 i_sysioctl=''
635 i_syssockio=''
636 i_sysmman=''
637 i_sysmount=''
638 i_sysndir=''
639 i_sysparam=''
640 i_sysresrc=''
641 i_syssecrt=''
642 i_sysselct=''
643 i_sysstat=''
644 i_sysstatvfs=''
645 i_systimes=''
646 i_systypes=''
647 d_iovec_s=''
648 i_sysuio=''
649 i_sysun=''
650 i_syswait=''
651 i_sgtty=''
652 i_termio=''
653 i_termios=''
654 i_systime=''
655 i_systimek=''
656 i_time=''
657 timeincl=''
658 i_unistd=''
659 i_utime=''
660 i_values=''
661 i_stdarg=''
662 i_varargs=''
663 i_varhdr=''
664 i_vfork=''
665 installusrbinperl=''
666 intsize=''
667 longsize=''
668 shortsize=''
669 d_dirent64_s=''
670 d_flock64_s=''
671 d_fstat64=''
672 d_ftruncate64=''
673 d_ino64_t=''
674 d_llseek=''
675 d_lockf64=''
676 d_lseek64=''
677 d_lstat64=''
678 d_off64_t=''
679 d_offset_t=''
680 d_open64=''
681 d_opendir64=''
682 d_readdir64=''
683 d_seekdir64=''
684 d_stat64=''
685 d_telldir64=''
686 d_truncate64=''
687 libc=''
688 libperl=''
689 shrpenv=''
690 useshrplib=''
691 glibpth=''
692 libpth=''
693 loclibpth=''
694 plibpth=''
695 xlibpth=''
696 ignore_versioned_solibs=''
697 libs=''
698 lns=''
699 lseeksize=''
700 lseektype=''
701 make_set_make=''
702 d_mymalloc=''
703 freetype=''
704 mallocobj=''
705 mallocsrc=''
706 malloctype=''
707 usemymalloc=''
708 installman1dir=''
709 man1dir=''
710 man1direxp=''
711 man1ext=''
712 installman3dir=''
713 man3dir=''
714 man3direxp=''
715 man3ext=''
716 huge=''
717 large=''
718 medium=''
719 models=''
720 small=''
721 split=''
722 modetype=''
723 multiarch=''
724 mydomain=''
725 myhostname=''
726 phostname=''
727 c=''
728 n=''
729 d_eofnblk=''
730 eagain=''
731 o_nonblock=''
732 rd_nodata=''
733 netdb_hlen_type=''
734 netdb_host_type=''
735 netdb_name_type=''
736 netdb_net_type=''
737 groupcat=''
738 hostcat=''
739 passcat=''
740 orderlib=''
741 ranlib=''
742 package=''
743 spackage=''
744 pager=''
745 apiversion=''
746 patchlevel=''
747 subversion=''
748 version=''
749 perladmin=''
750 perlpath=''
751 pidtype=''
752 prefix=''
753 prefixexp=''
754 installprivlib=''
755 privlib=''
756 privlibexp=''
757 prototype=''
758 ptrsize=''
759 drand01=''
760 randbits=''
761 randfunc=''
762 randseedtype=''
763 seedfunc=''
764 installscript=''
765 scriptdir=''
766 scriptdirexp=''
767 selectminbits=''
768 selecttype=''
769 sh=''
770 sig_count=''
771 sig_name=''
772 sig_name_init=''
773 sig_num=''
774 sig_num_init=''
775 installsitearch=''
776 sitearch=''
777 sitearchexp=''
778 installsitelib=''
779 sitelib=''
780 sitelibexp=''
781 sizetype=''
782 so=''
783 sharpbang=''
784 shsharp=''
785 spitshell=''
786 src=''
787 ssizetype=''
788 startperl=''
789 startsh=''
790 stdchar=''
791 d_fgetpos64=''
792 d_fopen64=''
793 d_freopen64=''
794 d_fseek64=''
795 d_fseeko64=''
796 d_fsetpos64=''
797 d_ftell64=''
798 d_ftello64=''
799 d_tmpfile64=''
800 sysman=''
801 trnl=''
802 uidtype=''
803 archname64=''
804 use64bits=''
805 usemultiplicity=''
806 nm_opt=''
807 nm_so_opt=''
808 runnm=''
809 usenm=''
810 useperlio=''
811 d_oldpthreads=''
812 usethreads=''
813 incpath=''
814 mips=''
815 mips_type=''
816 usrinc=''
817 defvoidused=''
818 voidflags=''
819 CONFIG=''
820
821 define='define'
822 undef='undef'
823 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
824 rmlist=''
825
826 : We must find out about Eunice early
827 eunicefix=':'
828 if test -f /etc/unixtovms; then
829         eunicefix=/etc/unixtovms
830 fi
831 if test -f /etc/unixtovms.exe; then
832         eunicefix=/etc/unixtovms.exe
833 fi
834
835 i_whoami=''
836 : Possible local include directories to search.
837 : Set locincpth to "" in a hint file to defeat local include searches.
838 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
839 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
840 :
841 : no include file wanted by default
842 inclwanted=''
843
844 : list of known cpp symbols, sorted alphabetically
845 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
846 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
847 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
848 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
849 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
850 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
851 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
852 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
853 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
854 al="$al VMS Xenix286"
855 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
856 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
857 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
858 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
859 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
860 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
861 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
862 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
863 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
864 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
865 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
866 al="$al __SVR4_2__ __UMAXV__"
867 al="$al ____386BSD____ __alpha __alpha__ __amiga"
868 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
869 al="$al __host_mips__"
870 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
871 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
872 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
873 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
874 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
875 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
876 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
877 al="$al __mc88100 __mc88100__ __mips __mips__"
878 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
879 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
880 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
881 al="$al _host_mips _mips _unix"
882 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
883 al="$al apollo ardent att386 att3b"
884 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
885 al="$al cadmus clipper concurrent convex cray ctix"
886 al="$al dmert encore gcos gcx gimpel gould"
887 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
888 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
889 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
890 al="$al i186 i286 i386 i486 i8086"
891 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
892 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
893 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
894 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
895 al="$al mc88000 mc88100 merlin mert mips mvs n16"
896 al="$al ncl_el ncl_mr"
897 al="$al news1500 news1700 news1800 news1900 news3700"
898 al="$al news700 news800 news900 ns16000 ns32000"
899 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
900 al="$al parisc pc532 pdp11 plexus posix pyr"
901 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
902 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
903 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
904 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
905 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
906 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
907 al="$al xenix z8000"
908
909 : Trailing extension.  Override this in a hint file, if needed.
910 _exe=''
911 : Extra object files, if any, needed on this platform.
912 archobjs=''
913 groupstype=''
914 : change the next line if compiling for Xenix/286 on Xenix/386
915 xlibpth='/usr/lib/386 /lib/386'
916
917 : Possible local library directories to search.
918 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
919 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
920
921 : general looking path for locating libraries
922 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
923 glibpth="$glibpth /lib /usr/lib $xlibpth"
924 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
925 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
926
927 : Private path used by Configure to find libraries.  Its value
928 : is prepended to libpth. This variable takes care of special
929 : machines, like the mips.  Usually, it should be empty.
930 plibpth=''
931
932 : default library list
933 libswanted=''
934 : some systems want to use only the non-versioned libso:s
935 ignore_versioned_solibs=''
936 : full support for void wanted by default
937 defvoidused=15
938
939 : set useposix=false in your hint file to disable the POSIX extension.
940 useposix=true
941 : set useopcode=false in your hint file to disable the Opcode extension.
942 useopcode=true
943 : set usemultiplicity on the Configure command line to enable multiplicity.
944 : set usethreads on the Configure command line to enable threads.
945 : List of libraries we want.
946 : If anyone needs -lnet, put it in a hint file.
947 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
948 libswanted="$libswanted dld ld sun m rt c cposix posix"
949 libswanted="$libswanted ndir dir crypt"
950 libswanted="$libswanted ucb bsd BSD PW x"
951 : We probably want to search /usr/shlib before most other libraries.
952 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
953 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
954 glibpth="/usr/shlib $glibpth"
955 : Do not use vfork unless overridden by a hint file.
956 usevfork=false
957
958 : Find the basic shell for Bourne shell scripts
959 case "$sh" in
960 '')
961         case "$SYSTYPE" in
962         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
963         *) xxx='/bin/sh';;
964         esac
965         if test -f "$xxx"; then
966                 sh="$xxx"
967         else
968                 : Build up a list and do a single loop so we can 'break' out.
969                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
970                 for xxx in sh bash ksh pdksh ash; do
971                         for p in $pth; do
972                                 try="$try ${p}/${xxx}"
973                         done
974                 done
975                 for xxx in $try; do
976                         if test -f "$xxx"; then
977                                 sh="$xxx";
978                                 break
979                         elif test -f "$xxx.exe"; then
980                                 sh="$xxx";
981                                 break
982                         fi
983                 done
984         fi
985         ;;
986 esac
987
988 case "$sh" in
989 '')     cat <<EOM >&2
990 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
991
992 Usually it's in /bin/sh.  How did you even get this far?
993 Please contact me (Perl Maintainers) at perlbug@perl.com and 
994 we'll try to straighten this all out.
995 EOM
996         exit 1
997         ;;
998 esac
999
1000 : see if sh knows # comments
1001 if `$sh -c '#' >/dev/null 2>&1`; then
1002         shsharp=true
1003         spitshell=cat
1004         xcat=/bin/cat
1005         test -f $xcat || xcat=/usr/bin/cat
1006         echo "#!$xcat" >try
1007         $eunicefix try
1008         chmod +x try
1009         ./try > today
1010         if test -s today; then
1011                 sharpbang='#!'
1012         else
1013                 echo "#! $xcat" > try
1014                 $eunicefix try
1015                 chmod +x try
1016                 ./try > today
1017                 if test -s today; then
1018                         sharpbang='#! '
1019                 else
1020                         sharpbang=': use '
1021                 fi
1022         fi
1023 else
1024         echo " "
1025         echo "Your $sh doesn't grok # comments--I will strip them later on."
1026         shsharp=false
1027         cd ..
1028         echo "exec grep -v '^[  ]*#'" >spitshell
1029         chmod +x spitshell
1030         $eunicefix spitshell
1031         spitshell=`pwd`/spitshell
1032         cd UU
1033         echo "I presume that if # doesn't work, #! won't work either!"
1034         sharpbang=': use '
1035 fi
1036 rm -f try today
1037
1038 : figure out how to guarantee sh startup
1039 case "$startsh" in
1040 '') startsh=${sharpbang}${sh} ;;
1041 *)
1042 esac
1043 cat >try <<EOSS
1044 $startsh
1045 set abc
1046 test "$?abc" != 1
1047 EOSS
1048
1049 chmod +x try
1050 $eunicefix try
1051 if ./try; then
1052         : echo "Yup, it does."
1053 else
1054         echo "Hmm... '$startsh' does not guarantee sh startup..."
1055         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1056 fi
1057 rm -f try
1058
1059
1060 : Save command line options in file UU/cmdline.opt for later use in
1061 : generating config.sh.
1062 cat > cmdline.opt <<EOSH
1063 # Configure command line arguments.
1064 config_arg0='$0'
1065 config_args='$*'
1066 config_argc=$#
1067 EOSH
1068 argn=1
1069 for arg in "$@"; do
1070         cat >>cmdline.opt <<EOSH
1071 config_arg$argn='$arg'
1072 EOSH
1073         argn=`expr $argn + 1`
1074 done
1075
1076 : produce awk script to parse command line options
1077 cat >options.awk <<'EOF'
1078 BEGIN {
1079         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1080
1081         len = length(optstr);
1082         for (i = 1; i <= len; i++) {
1083                 c = substr(optstr, i, 1);
1084                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1085                 if (a == ":") {
1086                         arg[c] = 1;
1087                         i++;
1088                 }
1089                 opt[c] = 1;
1090         }
1091 }
1092 {
1093         expect = 0;
1094         str = $0;
1095         if (substr(str, 1, 1) != "-") {
1096                 printf("'%s'\n", str);
1097                 next;
1098         }
1099         len = length($0);
1100         for (i = 2; i <= len; i++) {
1101                 c = substr(str, i, 1);
1102                 if (!opt[c]) {
1103                         printf("-%s\n", substr(str, i));
1104                         next;
1105                 }
1106                 printf("-%s\n", c);
1107                 if (arg[c]) {
1108                         if (i < len)
1109                                 printf("'%s'\n", substr(str, i + 1));
1110                         else
1111                                 expect = 1;
1112                         next;
1113                 }
1114         }
1115 }
1116 END {
1117         if (expect)
1118                 print "?";
1119 }
1120 EOF
1121
1122 : process the command line options
1123 set X `for arg in "$@"; do echo "X$arg"; done |
1124         sed -e s/X// | awk -f options.awk`
1125 eval "set $*"
1126 shift
1127 rm -f options.awk
1128
1129 : set up default values
1130 fastread=''
1131 reuseval=false
1132 config_sh=''
1133 alldone=''
1134 error=''
1135 silent=''
1136 extractsh=''
1137 override=''
1138 knowitall=''
1139 rm -f optdef.sh
1140 cat >optdef.sh <<EOS
1141 $startsh
1142 EOS
1143
1144
1145 : option parsing
1146 while test $# -gt 0; do
1147         case "$1" in
1148         -d) shift; fastread=yes;;
1149         -e) shift; alldone=cont;;
1150         -f)
1151                 shift
1152                 cd ..
1153                 if test -r "$1"; then
1154                         config_sh="$1"
1155                 else
1156                         echo "$me: cannot read config file $1." >&2
1157                         error=true
1158                 fi
1159                 cd UU
1160                 shift;;
1161         -h) shift; error=true;;
1162         -r) shift; reuseval=true;;
1163         -s) shift; silent=true; realsilent=true;;
1164         -E) shift; alldone=exit;;
1165         -K) shift; knowitall=true;;
1166         -O) shift; override=true;;
1167         -S) shift; silent=true; extractsh=true;;
1168         -D)
1169                 shift
1170                 case "$1" in
1171                 *=)
1172                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1173                         echo "$me: ignoring -D $1" >&2
1174                         ;;
1175                 *=*) echo "$1" | \
1176                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1177                 *) echo "$1='define'" >> optdef.sh;;
1178                 esac
1179                 shift
1180                 ;;
1181         -U)
1182                 shift
1183                 case "$1" in
1184                 *=) echo "$1" >> optdef.sh;;
1185                 *=*)
1186                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1187                         echo "$me: ignoring -U $1" >&2
1188                         ;;
1189                 *) echo "$1='undef'" >> optdef.sh;;
1190                 esac
1191                 shift
1192                 ;;
1193         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1194                 exit 0;;
1195         --) break;;
1196         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1197         *) break;;
1198         esac
1199 done
1200
1201 case "$error" in
1202 true)
1203         cat >&2 <<EOM
1204 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1205                  [-U symbol] [-U symbol=]
1206   -d : use defaults for all answers.
1207   -e : go on without questioning past the production of config.sh.
1208   -f : specify an alternate default configuration file.
1209   -h : print this help message and exit (with an error status).
1210   -r : reuse C symbols value if possible (skips costly nm extraction).
1211   -s : silent mode, only echoes questions and essential information.
1212   -D : define symbol to have some value:
1213          -D symbol         symbol gets the value 'define'
1214          -D symbol=value   symbol gets the value 'value'
1215   -E : stop at the end of questions, after having produced config.sh.
1216   -K : do not use unless you know what you are doing.
1217   -O : let -D and -U override definitions from loaded configuration file.
1218   -S : perform variable substitutions on all .SH files (can mix with -f)
1219   -U : undefine symbol:
1220          -U symbol    symbol gets the value 'undef'
1221          -U symbol=   symbol gets completely empty
1222   -V : print version number and exit (with a zero status).
1223 EOM
1224         exit 1
1225         ;;
1226 esac
1227
1228 : Sanity checks
1229 case "$fastread$alldone" in
1230 yescont|yesexit) ;;
1231 *)
1232         if test ! -t 0; then
1233                 echo "Say 'sh Configure', not 'sh <Configure'"
1234                 exit 1
1235         fi
1236         ;;
1237 esac
1238
1239 exec 4>&1
1240 case "$silent" in
1241 true) exec 1>/dev/null;;
1242 esac
1243
1244 : run the defines and the undefines, if any, but leave the file out there...
1245 touch optdef.sh
1246 . ./optdef.sh
1247
1248 : set package name
1249 package=perl5
1250 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1251 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1252 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1253 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1254 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1255 esac
1256
1257 : Some greps do not return status, grrr.
1258 echo "grimblepritz" >grimble
1259 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1260         contains=contains
1261 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1262         contains=grep
1263 else
1264         contains=contains
1265 fi
1266 rm -f grimble
1267 : the following should work in any shell
1268 case "$contains" in
1269 contains*)
1270         echo " "
1271         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1272         cat >contains <<'EOSS'
1273 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1274 EOSS
1275 chmod +x contains
1276 esac
1277
1278 : Find the path to the source tree
1279 case "$src" in
1280 '') case "$0" in
1281     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1282     *)   src='.';;
1283     esac;;
1284 esac
1285 case "$src" in
1286 '')     src=/
1287         rsrc=/
1288         ;;
1289 /*) rsrc="$src";;
1290 *) rsrc="../$src";;
1291 esac
1292 if test -f $rsrc/Configure && \
1293         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1294 then
1295    : found it, so we are ok.
1296 else
1297         rsrc=''
1298         for src in . .. ../.. ../../.. ../../../..; do
1299                 if test -f ../$src/Configure && \
1300                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1301                 then
1302                         rsrc=../$src
1303                         break
1304                 fi
1305         done
1306 fi
1307 case "$rsrc" in
1308 '')
1309         cat <<EOM >&4
1310
1311 Sorry, I can't seem to locate the source dir for $package.  Please start
1312 Configure with an explicit path -- i.e. /some/path/Configure.
1313
1314 EOM
1315         exit 1
1316         ;;
1317 ../.)   rsrc='..';;
1318 *)
1319         echo " "
1320         echo "Sources for $package found in \"$src\"." >&4
1321         ;;
1322 esac
1323
1324 : script used to extract .SH files with variable substitutions
1325 cat >extract <<'EOS'
1326 CONFIGDOTSH=true
1327 echo "Doing variable substitutions on .SH files..."
1328 if test -f $src/MANIFEST; then
1329         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1330 else
1331         echo "(Looking for .SH files under the source directory.)"
1332         set x `(cd $src; find . -name "*.SH" -print)`
1333 fi
1334 shift
1335 case $# in
1336 0) set x `(cd $src; echo *.SH)`; shift;;
1337 esac
1338 if test ! -f $src/$1; then
1339         shift
1340 fi
1341 mkdir_p='
1342 name=$1;
1343 create="";
1344 while test $name; do
1345         if test ! -d "$name"; then
1346                 create="$name $create";
1347                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1348                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1349         else
1350                 name="";
1351         fi;
1352 done;
1353 for file in $create; do
1354         mkdir $file;
1355 done
1356 '
1357 for file in $*; do
1358         case "$src" in
1359         ".")
1360                 case "$file" in
1361                 */*)
1362                         dir=`expr X$file : 'X\(.*\)/'`
1363                         file=`expr X$file : 'X.*/\(.*\)'`
1364                         (cd $dir && . ./$file)
1365                         ;;
1366                 *)
1367                         . ./$file
1368                         ;;
1369                 esac
1370                 ;;
1371         *)
1372                 case "$file" in
1373                 */*)
1374                         dir=`expr X$file : 'X\(.*\)/'`
1375                         file=`expr X$file : 'X.*/\(.*\)'`
1376                         (set x $dir; shift; eval $mkdir_p)
1377                         sh <$src/$dir/$file
1378                         ;;
1379                 *)
1380                         sh <$src/$file
1381                         ;;
1382                 esac
1383                 ;;
1384         esac
1385 done
1386 if test -f $src/config_h.SH; then
1387         if test ! -f config.h; then
1388         : oops, they left it out of MANIFEST, probably, so do it anyway.
1389         . $src/config_h.SH
1390         fi
1391 fi
1392 EOS
1393
1394 : extract files and exit if asked to do so
1395 case "$extractsh" in
1396 true)
1397         case "$realsilent" in
1398         true) ;;
1399         *) exec 1>&4;;
1400         esac
1401         case "$config_sh" in
1402         '') config_sh='config.sh';;
1403         esac
1404         echo " "
1405         echo "Fetching answers from $config_sh..."
1406         cd ..
1407         . $config_sh
1408         test "$override" && . ./optdef.sh
1409         echo " "
1410         . UU/extract
1411         rm -rf UU
1412         echo "Done."
1413         exit 0
1414         ;;
1415 esac
1416
1417 : Eunice requires " " instead of "", can you believe it
1418 echo " "
1419 : Here we go...
1420 echo "Beginning of configuration questions for $package."
1421
1422 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1423
1424 : first determine how to suppress newline on echo command
1425 echo " "
1426 echo "Checking echo to see how to suppress newlines..."
1427 (echo "hi there\c" ; echo " ") >.echotmp
1428 if $contains c .echotmp >/dev/null 2>&1 ; then
1429         echo "...using -n."
1430         n='-n'
1431         c=''
1432 else
1433         cat <<'EOM'
1434 ...using \c
1435 EOM
1436         n=''
1437         c='\c'
1438 fi
1439 echo $n "The star should be here-->$c"
1440 echo '*'
1441 rm -f .echotmp
1442
1443 : Now test for existence of everything in MANIFEST
1444 echo " "
1445 if test -f $rsrc/MANIFEST; then
1446         echo "First let's make sure your kit is complete.  Checking..." >&4
1447         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1448         rm -f missing
1449         tmppwd=`pwd`
1450         for filelist in x??; do
1451                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1452         done
1453         if test -s missing; then
1454                 cat missing >&4
1455                 cat >&4 <<'EOM'
1456
1457 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1458
1459 You have the option of continuing the configuration process, despite the
1460 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1461 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1462 and contact the author (perlbug@perl.com).
1463
1464 EOM
1465                 echo $n "Continue? [n] $c" >&4
1466                 read ans
1467                 case "$ans" in
1468                 y*)
1469                         echo "Continuing..." >&4
1470                         rm -f missing
1471                         ;;
1472                 *)
1473                         echo "ABORTING..." >&4
1474                         kill $$
1475                         ;;
1476                 esac
1477         else
1478                 echo "Looks good..."
1479         fi
1480 else
1481         echo "There is no MANIFEST file.  I hope your kit is complete !"
1482 fi
1483 rm -f missing x??
1484
1485 echo " "
1486 : Find the appropriate value for a newline for tr
1487 if test -n "$DJGPP"; then
1488        trnl='\012'
1489 fi
1490 if test X"$trnl" = X; then
1491         case "`echo foo|tr '\n' x 2>/dev/null`" in
1492         foox) trnl='\n' ;;
1493         esac
1494 fi
1495 if test X"$trnl" = X; then
1496         case "`echo foo|tr '\012' x 2>/dev/null`" in
1497         foox) trnl='\012' ;;
1498         esac
1499 fi
1500 if test X"$trnl" = X; then
1501         cat <<EOM >&2
1502
1503 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1504
1505 EOM
1506         exit 1
1507 fi
1508
1509 : compute the number of columns on the terminal for proper question formatting
1510 case "$COLUMNS" in
1511 '') COLUMNS='80';;
1512 esac
1513
1514 : set up the echo used in my read
1515 myecho="case \"\$xxxm\" in
1516 '') echo $n \"\$rp $c\" >&4;;
1517 *) case \"\$rp\" in
1518         '') echo $n \"[\$xxxm] $c\";;
1519         *)
1520                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1521                         echo \"\$rp\" >&4
1522                         echo $n \"[\$xxxm] $c\" >&4
1523                 else
1524                         echo $n \"\$rp [\$xxxm] $c\" >&4
1525                 fi
1526                 ;;
1527         esac;;
1528 esac"
1529
1530 : now set up to do reads with possible shell escape and default assignment
1531 cat <<EOSC >myread
1532 $startsh
1533 xxxm=\$dflt
1534 $myecho
1535 ans='!'
1536 case "\$fastread" in
1537 yes) case "\$dflt" in
1538         '') ;;
1539         *) ans='';
1540                 case "\$silent-\$rp" in
1541                 true-) ;;
1542                 *) echo " " >&4;;
1543                 esac;;
1544         esac;;
1545 *) case "\$silent" in
1546         true) case "\$rp" in
1547                 '') ans='';;
1548                 esac;;
1549         esac;;
1550 esac
1551 while expr "X\$ans" : "X!" >/dev/null; do
1552         read answ
1553         set x \$xxxm
1554         shift
1555         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1556         case  "\$answ" in
1557         "!")
1558                 sh 1>&4
1559                 echo " "
1560                 $myecho
1561                 ;;
1562         !*)
1563                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1564                 shift
1565                 sh 1>&4 -c "\$*"
1566                 echo " "
1567                 $myecho
1568                 ;;
1569         "\$ans")
1570                 case "\$ans" in
1571                 \\&*)
1572                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1573                         shift
1574                         case "\$1" in
1575                         -d)
1576                                 fastread=yes
1577                                 echo "(OK, I'll run with -d after this question.)" >&4
1578                                 ;;
1579                         -*)
1580                                 echo "*** Sorry, \$1 not supported yet." >&4
1581                                 ;;
1582                         esac
1583                         $myecho
1584                         ans=!
1585                         ;;
1586                 esac;;
1587         *)
1588                 case "\$aok" in
1589                 y)
1590                         echo "*** Substitution done -- please confirm."
1591                         xxxm="\$ans"
1592                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1593                         xxxm="\$ans"
1594                         ans=!
1595                         ;;
1596                 *)
1597                         echo "*** Error -- try again."
1598                         ans=!
1599                         ;;
1600                 esac
1601                 $myecho
1602                 ;;
1603         esac
1604         case "\$ans\$xxxm\$nostick" in
1605         '')
1606                 ans=!
1607                 $myecho
1608                 ;;
1609         esac
1610 done
1611 case "\$ans" in
1612 '') ans="\$xxxm";;
1613 esac
1614 EOSC
1615
1616 : create .config dir to save info across Configure sessions
1617 test -d ../.config || mkdir ../.config
1618 cat >../.config/README <<EOF
1619 This directory created by Configure to save information that should
1620 persist across sessions for $package.
1621
1622 You may safely delete it if you wish.
1623 EOF
1624
1625 : general instructions
1626 needman=true
1627 firsttime=true
1628 user=`(logname) 2>/dev/null`
1629 case "$user" in
1630 '') user=`whoami 2>&1`;;
1631 esac
1632 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1633         firsttime=false
1634         echo " "
1635         rp='Would you like to see the instructions?'
1636         dflt=n
1637         . ./myread
1638         case "$ans" in
1639         [yY]*) ;;
1640         *) needman=false;;
1641         esac
1642 fi
1643 if $needman; then
1644         cat <<EOH
1645
1646 This installation shell script will examine your system and ask you questions
1647 to determine how the perl5 package should be installed. If you get
1648 stuck on a question, you may use a ! shell escape to start a subshell or
1649 execute a command.  Many of the questions will have default answers in square
1650 brackets; typing carriage return will give you the default.
1651
1652 On some of the questions which ask for file or directory names you are allowed
1653 to use the ~name construct to specify the login directory belonging to "name",
1654 even if you don't have a shell which knows about that.  Questions where this is
1655 allowed will be marked "(~name ok)".
1656
1657 EOH
1658         rp=''
1659         dflt='Type carriage return to continue'
1660         . ./myread
1661         cat <<'EOH'
1662
1663 The prompter used in this script allows you to use shell variables and
1664 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1665 in the default answer, as if the default line was a set of arguments given to a
1666 script shell.  This means you may also use $* to repeat the whole default line,
1667 so you do not have to re-type everything to add something to the default.
1668
1669 Everytime there is a substitution, you will have to confirm.  If there is an
1670 error (e.g. an unmatched backtick), the default answer will remain unchanged
1671 and you will be prompted again.
1672
1673 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1674 the questions and use the computed defaults (or the previous answers if there
1675 was already a config.sh file). Type 'Configure -h' for a list of options.
1676 You may also start interactively and then answer '& -d' at any prompt to turn
1677 on the non-interactive behaviour for the remainder of the execution.
1678
1679 EOH
1680         . ./myread
1681         cat <<EOH
1682
1683 Much effort has been expended to ensure that this shell script will run on any
1684 Unix system.  If despite that it blows up on yours, your best bet is to edit
1685 Configure and run it again.  If you can't run Configure for some reason,
1686 you'll have to generate a config.sh file by hand.  Whatever problems you
1687 have, let me (perlbug@perl.com) know how I blew it.
1688
1689 This installation script affects things in two ways:
1690
1691 1) it may do direct variable substitutions on some of the files included
1692    in this kit.
1693 2) it builds a config.h file for inclusion in C programs.  You may edit
1694    any of these files as the need arises after running this script.
1695
1696 If you make a mistake on a question, there is no easy way to back up to it
1697 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1698 files.  Configure will offer to let you do this before it runs the SH files.
1699
1700 EOH
1701         dflt='Type carriage return to continue'
1702         . ./myread
1703         case "$firsttime" in
1704         true) echo $user >>../.config/instruct;;
1705         esac
1706 fi
1707
1708 : find out where common programs are
1709 echo " "
1710 echo "Locating common programs..." >&4
1711 cat <<EOSC >loc
1712 $startsh
1713 case \$# in
1714 0) exit 1;;
1715 esac
1716 thing=\$1
1717 shift
1718 dflt=\$1
1719 shift
1720 for dir in \$*; do
1721         case "\$thing" in
1722         .)
1723         if test -d \$dir/\$thing; then
1724                 echo \$dir
1725                 exit 0
1726         fi
1727         ;;
1728         *)
1729         for thisthing in \$dir/\$thing; do
1730                 : just loop through to pick last item
1731         done
1732         if test -f \$thisthing; then
1733                 echo \$thisthing
1734                 exit 0
1735         elif test -f \$dir/\$thing.exe; then
1736                 if test -n "$DJGPP"; then
1737                         echo \$dir/\$thing.exe
1738                 else
1739                         : on Eunice apparently
1740                         echo \$dir/\$thing
1741                 fi
1742                 exit 0
1743         fi
1744         ;;
1745         esac
1746 done
1747 echo \$dflt
1748 exit 1
1749 EOSC
1750 chmod +x loc
1751 $eunicefix loc
1752 loclist="
1753 awk
1754 cat
1755 comm
1756 cp
1757 echo
1758 expr
1759 grep
1760 ls
1761 make
1762 mkdir
1763 rm
1764 sed
1765 sort
1766 touch
1767 tr
1768 uniq
1769 "
1770 trylist="
1771 Mcc
1772 ar
1773 byacc
1774 cpp
1775 csh
1776 date
1777 egrep
1778 gzip
1779 less
1780 ln
1781 more
1782 nm
1783 nroff
1784 pg
1785 test
1786 uname
1787 zip
1788 "
1789 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1790 pth="$pth /lib /usr/lib"
1791 for file in $loclist; do
1792         eval xxx=\$$file
1793         case "$xxx" in
1794         /*|?:[\\/]*)
1795                 if test -f "$xxx"; then
1796                         : ok
1797                 else
1798                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1799                         xxx=`./loc $file $file $pth`
1800                 fi
1801                 ;;
1802         '') xxx=`./loc $file $file $pth`;;
1803         *) xxx=`./loc $xxx $xxx $pth`;;
1804         esac
1805         eval $file=$xxx
1806         eval _$file=$xxx
1807         case "$xxx" in
1808         /*)
1809                 echo $file is in $xxx.
1810                 ;;
1811         ?:[\\/]*)
1812                 echo $file is in $xxx.
1813                 ;;
1814         *)
1815                 echo "I don't know where '$file' is, and my life depends on it." >&4
1816                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1817                 exit 1
1818                 ;;
1819         esac
1820 done
1821 echo " "
1822 echo "Don't worry if any of the following aren't found..."
1823 say=offhand
1824 for file in $trylist; do
1825         eval xxx=\$$file
1826         case "$xxx" in
1827         /*|?:[\\/]*)
1828                 if test -f "$xxx"; then
1829                         : ok
1830                 else
1831                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1832                         xxx=`./loc $file $file $pth`
1833                 fi
1834                 ;;
1835         '') xxx=`./loc $file $file $pth`;;
1836         *) xxx=`./loc $xxx $xxx $pth`;;
1837         esac
1838         eval $file=$xxx
1839         eval _$file=$xxx
1840         case "$xxx" in
1841         /*)
1842                 echo $file is in $xxx.
1843                 ;;
1844         ?:[\\/]*)
1845                 echo $file is in $xxx.
1846                 ;;
1847         *)
1848                 echo "I don't see $file out there, $say."
1849                 say=either
1850                 ;;
1851         esac
1852 done
1853 case "$egrep" in
1854 egrep)
1855         echo "Substituting grep for egrep."
1856         egrep=$grep
1857         ;;
1858 esac
1859 case "$ln" in
1860 ln)
1861         echo "Substituting cp for ln."
1862         ln=$cp
1863         ;;
1864 esac
1865 case "$test" in
1866 test)
1867         echo "Hopefully test is built into your sh."
1868         ;;
1869 *)
1870         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1871                 echo "Using the test built into your sh."
1872                 test=test
1873                 _test=test
1874         fi
1875         ;;
1876 esac
1877 case "$echo" in
1878 echo)
1879         echo "Hopefully echo is built into your sh."
1880         ;;
1881 '') ;;
1882 *)
1883         echo " "
1884 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1885         $echo $n "hi there$c" >foo1
1886         echo $n "hi there$c" >foo2
1887         if cmp foo1 foo2 >/dev/null 2>&1; then
1888                 echo "They are compatible.  In fact, they may be identical."
1889         else
1890                 case "$n" in
1891                 '-n') n='' c='\c';;
1892                 *) n='-n' c='';;
1893                 esac
1894                 cat <<FOO
1895 They are not compatible!  You are probably running ksh on a non-USG system.
1896 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1897 have echo built in and we may have to run some Bourne shell scripts.  That
1898 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1899
1900 FOO
1901                 $echo $n "The star should be here-->$c"
1902                 $echo "*"
1903         fi
1904         $rm -f foo1 foo2
1905         ;;
1906 esac
1907
1908 : determine whether symbolic links are supported
1909 echo " "
1910 $touch blurfl
1911 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1912         echo "Symbolic links are supported." >&4
1913         lns="$ln -s"
1914 else
1915         echo "Symbolic links are NOT supported." >&4
1916         lns="$ln"
1917 fi
1918 $rm -f blurfl sym
1919
1920 : see whether [:lower:] and [:upper:] are supported character classes
1921 echo " "
1922 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1923 ABYZ)
1924         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1925         up='[:upper:]'
1926         low='[:lower:]'
1927         ;;
1928 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1929         # (0xc9 and 0xd1), therefore that is a nice testing point.
1930         if test "X$up" = X -o "X$low" = X; then
1931             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1932             ij) up='[A-Z]'
1933                 low='[a-z]'
1934                 ;;
1935             esac
1936         fi
1937         if test "X$up" = X -o "X$low" = X; then
1938             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1939             ij) up='A-Z'
1940                 low='a-z'
1941                 ;;
1942             esac
1943         fi
1944         if test "X$up" = X -o "X$low" = X; then
1945             case "`echo IJ | od -x 2>/dev/null`" in
1946             *C9D1*|*c9d1*)
1947                 echo "Hey, this might be EBCDIC." >&4
1948                 if test "X$up" = X -o "X$low" = X; then
1949                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1950                     ij) up='[A-IJ-RS-Z]'
1951                         low='[a-ij-rs-z]'
1952                         ;;
1953                     esac
1954                 fi
1955                 if test "X$up" = X -o "X$low" = X; then
1956                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1957                     ij) up='A-IJ-RS-Z'
1958                         low='a-ij-rs-z'
1959                         ;;
1960                     esac
1961                 fi
1962                 ;;
1963             esac
1964         fi
1965 esac
1966 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1967 ij)
1968     echo "Using $up and $low to convert case." >&4
1969     ;;
1970 *)
1971     echo "I don't know how to translate letters from upper to lower case." >&4
1972     echo "Your tr is not acting any way I know of." >&4
1973     exit 1
1974     ;;
1975 esac
1976 : set up the translation script tr, must be called with ./tr of course
1977 cat >tr <<EOSC
1978 $startsh
1979 case "\$1\$2" in
1980 '[A-Z][a-z]') exec $tr '$up' '$low';;
1981 '[a-z][A-Z]') exec $tr '$low' '$up';;
1982 esac
1983 exec $tr "\$@"
1984 EOSC
1985 chmod +x tr
1986 $eunicefix tr
1987
1988 : Try to determine whether config.sh was made on this system
1989 case "$config_sh" in
1990 '')
1991 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1992 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
1993 # because the A-Z/a-z are not consecutive.
1994 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
1995         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
1996 newmyuname="$myuname"
1997 dflt=n
1998 case "$knowitall" in
1999 '')
2000         if test -f ../config.sh; then
2001                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
2002                         eval "`grep myuname= ../config.sh`"
2003                 fi
2004                 if test "X$myuname" = "X$newmyuname"; then
2005                         dflt=y
2006                 fi
2007         fi
2008         ;;
2009 *) dflt=y;;
2010 esac
2011
2012 : Get old answers from old config file if Configure was run on the
2013 : same system, otherwise use the hints.
2014 hint=default
2015 cd ..
2016 if test -f config.sh; then
2017         echo " "
2018         rp="I see a config.sh file.  Shall I use it to set the defaults?"
2019         . UU/myread
2020         case "$ans" in
2021         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
2022         *)  echo "Fetching default answers from your old config.sh file..." >&4
2023                 tmp_n="$n"
2024                 tmp_c="$c"
2025                 tmp_sh="$sh"
2026                 . ./config.sh
2027                 cp config.sh UU
2028                 n="$tmp_n"
2029                 c="$tmp_c"
2030                 : Older versions did not always set $sh.  Catch re-use of such
2031                 : an old config.sh.
2032                 case "$sh" in
2033                 '') sh="$tmp_sh" ;;
2034                 esac
2035                 hint=previous
2036                 ;;
2037         esac
2038 fi
2039 if test ! -f config.sh; then
2040         $cat <<EOM
2041
2042 First time through, eh?  I have some defaults handy for some systems
2043 that need some extra help getting the Configure answers right:
2044
2045 EOM
2046         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2047         dflt=''
2048         : Half the following guesses are probably wrong... If you have better
2049         : tests or hints, please send them to perlbug@perl.com
2050         : The metaconfig authors would also appreciate a copy...
2051         $test -f /irix && osname=irix
2052         $test -f /xenix && osname=sco_xenix
2053         $test -f /dynix && osname=dynix
2054         $test -f /dnix && osname=dnix
2055         $test -f /lynx.os && osname=lynxos
2056         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2057         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2058         $test -f /bin/mips && /bin/mips && osname=mips
2059         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2060                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2061         $test -d /usr/apollo/bin && osname=apollo
2062         $test -f /etc/saf/_sactab && osname=svr4
2063         $test -d /usr/include/minix && osname=minix
2064         if $test -d /MachTen -o -d /MachTen_Folder; then
2065                 osname=machten
2066                 if $test -x /sbin/version; then
2067                         osvers=`/sbin/version | $awk '{print $2}' |
2068                         $sed -e 's/[A-Za-z]$//'`
2069                 elif $test -x /usr/etc/version; then
2070                         osvers=`/usr/etc/version | $awk '{print $2}' |
2071                         $sed -e 's/[A-Za-z]$//'`
2072                 else
2073                         osvers="$2.$3"
2074                 fi
2075         fi
2076        $test -f /sys/posix.dll &&
2077                $test -f /usr/bin/what &&
2078                set X `/usr/bin/what /sys/posix.dll` &&
2079                $test "$3" = UWIN &&
2080                osname=uwin &&
2081                osvers="$5"
2082         if $test -f $uname; then
2083                 set X $myuname
2084                 shift
2085
2086                 case "$5" in
2087                 fps*) osname=fps ;;
2088                 mips*)
2089                         case "$4" in
2090                         umips) osname=umips ;;
2091                         *) osname=mips ;;
2092                         esac;;
2093                 [23]100) osname=mips ;;
2094                 next*) osname=next ;;
2095                 i386*)
2096                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
2097                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
2098                                 osname='sco'
2099                                 osvers=$tmp
2100                         elif $test -f /etc/kconfig; then
2101                                 osname=isc
2102                                 if test "$lns" = "ln -s"; then
2103                                         osvers=4
2104                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2105                                         osvers=3
2106                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2107                                         osvers=2
2108                                 fi
2109                         fi
2110                         tmp=''
2111                         ;;
2112                 pc*)
2113                         if test -n "$DJGPP"; then
2114                                 osname=dos
2115                                 osvers=djgpp
2116                         fi
2117                         ;;
2118                 esac
2119
2120                 case "$1" in
2121                 aix) osname=aix
2122                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2123                         case "$tmp" in
2124                         'not found') osvers="$4"."$3" ;;
2125                         '<3240'|'<>3240') osvers=3.2.0 ;;
2126                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2127                         '=3250'|'>3250') osvers=3.2.5 ;;
2128                         *) osvers=$tmp;;
2129                         esac
2130                         ;;
2131                 *dc.osx) osname=dcosx
2132                         osvers="$3"
2133                         ;;
2134                 dnix) osname=dnix
2135                         osvers="$3"
2136                         ;;
2137                 domainos) osname=apollo
2138                         osvers="$3"
2139                         ;;
2140                 dgux) osname=dgux 
2141                         osvers="$3"
2142                         ;;
2143                 dynixptx*) osname=dynixptx
2144                         osvers=`echo "$4"|sed 's/^v//'`
2145                         ;;
2146                 freebsd) osname=freebsd 
2147                         osvers="$3" ;;
2148                 genix) osname=genix ;;
2149                 hp*) osname=hpux 
2150                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2151                         ;;
2152                 irix*) osname=irix
2153                         case "$3" in
2154                         4*) osvers=4 ;;
2155                         5*) osvers=5 ;;
2156                         *)      osvers="$3" ;;
2157                         esac
2158                         ;;
2159                 linux) osname=linux
2160                         case "$3" in
2161                         *)      osvers="$3" ;;
2162                         esac
2163                         ;;
2164                 MiNT) osname=mint
2165                         ;;
2166                 netbsd*) osname=netbsd
2167                         osvers="$3"
2168                         ;;
2169                 news-os) osvers="$3"
2170                         case "$3" in
2171                         4*) osname=newsos4 ;;
2172                         *) osname=newsos ;;
2173                         esac
2174                         ;;
2175                 bsd386) osname=bsd386
2176                         osvers=`$uname -r`
2177                         ;;
2178                 POSIX-BC | posix-bc ) osname=posix-bc
2179                         osvers="$3"
2180                         ;;
2181                 powerux | power_ux | powermax_os | powermaxos | \
2182                 powerunix | power_unix) osname=powerux
2183                         osvers="$3"
2184                         ;;
2185                 next*) osname=next ;;
2186                 solaris) osname=solaris
2187                         case "$3" in
2188                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2189                         *)      osvers="$3" ;;
2190                         esac
2191                         ;;
2192                 sunos) osname=sunos
2193                         case "$3" in
2194                         5*) osname=solaris
2195                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2196                         *)      osvers="$3" ;;
2197                         esac
2198                         ;;
2199                 titanos) osname=titanos
2200                         case "$3" in
2201                         1*) osvers=1 ;;
2202                         2*) osvers=2 ;;
2203                         3*) osvers=3 ;;
2204                         4*) osvers=4 ;;
2205                         *)      osvers="$3" ;;
2206                         esac
2207                         ;;
2208                 ultrix) osname=ultrix
2209                         osvers="$3"
2210                         ;;
2211                 osf1|mls+)      case "$5" in
2212                                 alpha)
2213                                         osname=dec_osf
2214                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2215                                         ;;
2216                         hp*)    osname=hp_osf1  ;;
2217                         mips)   osname=mips_osf1 ;;
2218                         esac
2219                         ;;
2220                 uts) osname=uts 
2221                         osvers="$3"
2222                         ;;
2223                 qnx) osname=qnx
2224                         osvers="$4"
2225                         ;;
2226                 $2) case "$osname" in
2227                         *isc*) ;;
2228                         *freebsd*) ;;
2229                         svr*)
2230                                 : svr4.x or possibly later
2231                                 case "svr$3" in 
2232                                 ${osname}*)
2233                                         osname=svr$3
2234                                         osvers=$4
2235                                         ;;
2236                                 esac
2237                                 case "$osname" in
2238                                 svr4.0)
2239                                         : Check for ESIX
2240                                         if test -f /stand/boot ; then
2241                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2242                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2243                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2244                                                         if test -n "$isesix"; then
2245                                                                 osname=esix4
2246                                                         fi
2247                                                 fi
2248                                         fi
2249                                         ;;
2250                                 esac
2251                                 ;;
2252                         *)      if test -f /etc/systemid; then
2253                                         osname=sco
2254                                         set `echo $3 | $sed 's/\./ /g'` $4
2255                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2256                                                 osvers=$1.$2.$3
2257                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2258                                                 osvers=$1.$2
2259                                         elif $test -f $src/hints/sco_$1.sh; then
2260                                                 osvers=$1
2261                                         fi
2262                                 else
2263                                         case "$osname" in
2264                                         '') : Still unknown.  Probably a generic Sys V.
2265                                                 osname="sysv"
2266                                                 osvers="$3"
2267                                                 ;;
2268                                         esac
2269                                 fi
2270                                 ;;
2271                         esac
2272                         ;;
2273                 *)      case "$osname" in
2274                         '') : Still unknown.  Probably a generic BSD.
2275                                 osname="$1"
2276                                 osvers="$3"
2277                                 ;;
2278                         esac
2279                         ;;
2280                 esac
2281         else
2282                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2283                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2284                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2285                                 osname=news_os
2286                         fi
2287                         $rm -f UU/kernel.what
2288                 elif test -d c:/.; then
2289                         set X $myuname
2290                         osname=os2
2291                         osvers="$5"
2292                 fi
2293         fi
2294         
2295         : Now look for a hint file osname_osvers, unless one has been
2296         : specified already.
2297         case "$hintfile" in
2298         ''|' ')
2299                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2300                 : Also try without trailing minor version numbers.
2301                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2302                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2303                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2304                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2305                 case "$file" in
2306                 '') dflt=none ;;
2307                 *)  case "$osvers" in
2308                         '') dflt=$file
2309                                 ;;
2310                         *)  if $test -f $src/hints/$file.sh ; then
2311                                         dflt=$file
2312                                 elif $test -f $src/hints/$xfile.sh ; then
2313                                         dflt=$xfile
2314                                 elif $test -f $src/hints/$xxfile.sh ; then
2315                                         dflt=$xxfile
2316                                 elif $test -f $src/hints/$xxxfile.sh ; then
2317                                         dflt=$xxxfile
2318                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2319                                         dflt=$xxxxfile
2320                                 elif $test -f "$src/hints/${osname}.sh" ; then
2321                                         dflt="${osname}"
2322                                 else
2323                                         dflt=none
2324                                 fi
2325                                 ;;
2326                         esac
2327                         ;;
2328                 esac
2329                 if $test -f Policy.sh ; then
2330                         case "$dflt" in
2331                         *Policy*) ;;
2332                         none) dflt="Policy" ;;
2333                         *) dflt="Policy $dflt" ;;
2334                         esac
2335                 fi
2336                 ;;
2337         *)
2338                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2339                 ;;
2340         esac
2341
2342         if $test -f Policy.sh ; then
2343                 $cat <<EOM
2344
2345 There's also a Policy hint file available, which should make the
2346 site-specific (policy) questions easier to answer.
2347 EOM
2348
2349         fi
2350
2351         $cat <<EOM
2352
2353 You may give one or more space-separated answers, or "none" if appropriate.
2354 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2355 is a good thing.  DO NOT give a wrong version.
2356
2357 EOM
2358
2359         rp="Which of these apply, if any?"
2360         . UU/myread
2361         tans=$ans
2362         for file in $tans; do
2363                 if $test X$file = XPolicy -a -f Policy.sh; then
2364                         . Policy.sh
2365                         $cat Policy.sh >> UU/config.sh
2366                 elif $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$tans = X -o X$tans = Xnone ; then
2370                         : nothing
2371                 else
2372                         : Give one chance to correct a possible typo.
2373                         echo "$file.sh does not exist"
2374                         dflt=$file
2375                         rp="hint to use instead?"
2376                         . UU/myread
2377                         for file in $ans; do
2378                                 if $test -f "$src/hints/$file.sh"; then
2379                                         . $src/hints/$file.sh
2380                                         $cat $src/hints/$file.sh >> UU/config.sh
2381                                 elif $test X$ans = X -o X$ans = Xnone ; then
2382                                         : nothing
2383                                 else
2384                                         echo "$file.sh does not exist -- ignored."
2385                                 fi
2386                         done
2387                 fi
2388         done
2389
2390         hint=recommended
2391         : Remember our hint file for later.
2392         if $test -f "$src/hints/$file.sh" ; then
2393                 hintfile="$file"
2394         else
2395                 hintfile=''
2396         fi
2397 fi
2398 cd UU
2399 ;;
2400 *)
2401         echo " "
2402         echo "Fetching default answers from $config_sh..." >&4
2403         tmp_n="$n"
2404         tmp_c="$c"
2405         cd ..
2406         cp $config_sh config.sh 2>/dev/null
2407         chmod +w config.sh
2408         . ./config.sh
2409         cd UU
2410         cp ../config.sh .
2411         n="$tmp_n"
2412         c="$tmp_c"
2413         hint=previous
2414         ;;
2415 esac
2416 test "$override" && . ./optdef.sh
2417 myuname="$newmyuname"
2418
2419 : Restore computed paths
2420 for file in $loclist $trylist; do
2421         eval $file="\$_$file"
2422 done
2423
2424 cat << EOM
2425
2426 Configure uses the operating system name and version to set some defaults.
2427 The default value is probably right if the name rings a bell. Otherwise,
2428 since spelling matters for me, either accept the default or answer "none"
2429 to leave it blank.
2430
2431 EOM
2432 case "$osname" in
2433         ''|' ')
2434                 case "$hintfile" in
2435                 ''|' '|none) dflt=none ;;
2436                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2437                 esac
2438                 ;;
2439         *) dflt="$osname" ;;
2440 esac
2441 rp="Operating system name?"
2442 . ./myread
2443 case "$ans" in
2444 none)  osname='' ;;
2445 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2446 esac
2447 echo " "
2448 case "$osvers" in
2449         ''|' ')
2450                 case "$hintfile" in
2451                 ''|' '|none) dflt=none ;;
2452                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2453                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2454                         case "$dflt" in
2455                         ''|' ') dflt=none ;;
2456                         esac
2457                         ;;
2458                 esac
2459                 ;;
2460         *) dflt="$osvers" ;;
2461 esac
2462 rp="Operating system version?"
2463 . ./myread
2464 case "$ans" in
2465 none)  osvers='' ;;
2466 *) osvers="$ans" ;;
2467 esac
2468
2469 : who configured the system
2470 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
2471 cf_by=`(logname) 2>/dev/null`
2472 case "$cf_by" in
2473 "")
2474         cf_by=`(whoami) 2>/dev/null`
2475         case "$cf_by" in
2476         "") cf_by=unknown ;;
2477         esac ;;
2478 esac
2479
2480 : set up the script used to warn in case of inconsistency
2481 cat <<EOS >whoa
2482 $startsh
2483 EOS
2484 cat <<'EOSC' >>whoa
2485 dflt=y
2486 echo " "
2487 echo "*** WHOA THERE!!! ***" >&4
2488 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2489 rp="    Keep the $hint value?"
2490 . ./myread
2491 case "$ans" in
2492 y) td=$was; tu=$was;;
2493 esac
2494 EOSC
2495
2496 : function used to set $1 to $val
2497 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2498 case "$val$was" in
2499 $define$undef) . ./whoa; eval "$var=\$td";;
2500 $undef$define) . ./whoa; eval "$var=\$tu";;
2501 *) eval "$var=$val";;
2502 esac'
2503
2504 cat <<EOM
2505
2506 Perl can be built to take advantage of threads, on some systems.
2507 To do so, Configure must be run with -Dusethreads.
2508
2509 Note that threading is a highly experimental feature, and
2510 some known race conditions still remain.  If you choose to try
2511 it, be very sure to not actually deploy it for production
2512 purposes.  README.threads has more details, and is required
2513 reading if you enable threads.
2514 EOM
2515 case "$usethreads" in
2516 $define|true|[yY]*)     dflt='y';;
2517 *) dflt='n';;
2518 esac
2519 rp='Build a threading Perl?'
2520 . ./myread
2521 case "$ans" in
2522 y|Y)    val="$define" ;;     
2523 *)      val="$undef" ;;
2524 esac
2525 set usethreads
2526 eval $setvar 
2527
2528 case "$d_oldpthreads" in
2529 '')     : Configure tests would be welcome here.  For now, assume undef.
2530         val="$undef" ;;
2531 *)      val="$d_oldpthreads" ;;
2532 esac
2533 set d_oldpthreads
2534 eval $setvar
2535
2536
2537 case "$usethreads" in
2538 "$define"|true|[yY]*)
2539 : Look for a hint-file generated 'call-back-unit'.  If the
2540 : user has specified that a threading perl is to be built,
2541 : we may need to set or change some other defaults.
2542         if $test -f usethreads.cbu; then
2543                 . ./usethreads.cbu
2544         fi
2545         case "$osname" in
2546         aix|dec_osf|dos_djgpp|freebsd|hpux|irix|linux|next|openbsd|os2|solaris|vmesa)
2547                 # Known thread-capable platforms.
2548                 ;;
2549         *)
2550                 cat >&4 <<EOM
2551 $osname is not known to support threads.
2552 Please let perlbug@perl.com know how to do that.
2553
2554 Cannot continue, aborting.
2555 EOM
2556                 exit 1
2557         ;;
2558         esac # $osname
2559     ;;
2560 esac # $usethreads
2561
2562 cat <<EOM
2563
2564 Perl can be built so that multiple Perl interpreters can coexist
2565 within the same Perl executable.  To do so, Configure must be run with
2566 -Dusemultiplicity.
2567
2568 Normally you do not need this and you should answer no.
2569
2570 EOM
2571 case "$usemultiplicity" in
2572 $define|true|[yY]*)     dflt='y';;
2573 *) dflt='n';;
2574 esac
2575 rp='Build Perl for multiplicity?'
2576 . ./myread
2577 case "$ans" in
2578 y|Y)    val="$define" ;;     
2579 *)      val="$undef" ;;
2580 esac
2581 set usemultiplicity
2582 eval $setvar 
2583
2584 cat <<EOM
2585
2586 Perl can be built to take advantage of explicit 64-bit interfaces,
2587 on some systems.  To do so, Configure must be run with -Duse64bits.
2588
2589 If this doesn't make any sense to you, just accept the default 'n'.
2590 EOM
2591 case "$use64bits" in
2592 $define|true|[yY]*)     dflt='y';;
2593 *) dflt='n';;
2594 esac
2595 rp='Try to use explicit 64-bit interfaces, if available?'
2596 . ./myread
2597 case "$ans" in
2598 y|Y) 
2599         val="$define"
2600         ;;     
2601 *)      
2602         val="$undef"
2603         ;;
2604 esac
2605 set use64bits
2606 eval $setvar
2607
2608 case "$archname64" in
2609 '') archname64='' ;;    # not a typo
2610 esac
2611
2612 case "$use64bits" in
2613 "$define"|true|[yY]*)
2614 : Look for a hint-file generated 'call-back-unit'.  If the
2615 : user has specified that a threading perl is to be built,
2616 : we may need to set or change some other defaults.
2617         if $test -f use64bits.cbu; then
2618                 . ./use64bits.cbu
2619         fi
2620         case "$osname" in
2621         dec_osf|hpux|irix|solaris|unicos)
2622                 # Known 64-bit capable platforms.
2623                 ;;
2624         *)
2625                 cat >&4 <<EOM
2626 $osname is not known to support 64-bit interfaces.
2627 Please let perlbug@perl.com know how to do that.
2628
2629 Cannot continue, aborting.
2630 EOM
2631                 exit 1
2632                 ;;
2633         esac
2634         ;;
2635 esac
2636
2637 : determine the architecture name
2638 echo " "
2639 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2640         tarch=`arch`"-$osname"
2641 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2642         if uname -m > tmparch 2>&1 ; then
2643                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2644                         -e 's/$/'"-$osname/" tmparch`
2645         else
2646                 tarch="$osname"
2647         fi
2648         $rm -f tmparch
2649 else
2650         tarch="$osname"
2651 fi
2652 case "$myarchname" in
2653 ''|"$tarch") ;;
2654 *)
2655         echo "(Your architecture name used to be $myarchname.)"
2656         archname=''
2657         ;;
2658 esac
2659 myarchname="$tarch"
2660 case "$archname" in
2661 '') dflt="$tarch";;
2662 *) dflt="$archname";;
2663 esac
2664 rp='What is your architecture name'
2665 . ./myread
2666 archname="$ans"
2667 case "$usethreads" in
2668 $define)
2669         echo "Threads selected." >&4
2670         case "$archname" in
2671         *-thread*) echo "...and architecture name already has -thread." >&4
2672                 ;;
2673         *)      archname="$archname-thread"
2674                 echo "...setting architecture name to $archname." >&4
2675                 ;;
2676         esac
2677         ;;
2678 esac
2679 case "$usemultiplicity" in
2680 $define)
2681         echo "Multiplicity selected." >&4
2682         case "$archname" in
2683         *-multi*) echo "...and architecture name already has -multi." >&4
2684                 ;;
2685         *)      archname="$archname-multi"
2686                 echo "...setting architecture name to $archname." >&4
2687                 ;;
2688         esac
2689         ;;
2690 esac
2691 case "$use64bits" in
2692 $define)
2693         echo "Explicit 64-bitness selected." >&4
2694         case "$archname64" in
2695         '')
2696                 ;;
2697         *)
2698                 case "$archname" in
2699                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2700                         ;;
2701                 *)      archname="$archname-$archname64"
2702                         echo "...setting architecture name to $archname." >&4
2703                         ;;
2704                 esac
2705                 ;;
2706         esac
2707 esac
2708
2709 : is AFS running?
2710 echo " "
2711 case "$afs" in
2712 $define|true)   afs=true ;;
2713 $undef|false)   afs=false ;;
2714 *)      if test -d /afs; then
2715                 afs=true
2716         else
2717                 afs=false
2718         fi
2719         ;;
2720 esac
2721 if $afs; then
2722         echo "AFS may be running... I'll be extra cautious then..." >&4
2723 else
2724         echo "AFS does not seem to be running..." >&4
2725 fi
2726
2727 : decide how portable to be.  Allow command line overrides.
2728 case "$d_portable" in
2729 "$undef") ;;
2730 *)      d_portable="$define" ;;
2731 esac
2732
2733 : set up shell script to do ~ expansion
2734 cat >filexp <<EOSS
2735 $startsh
2736 : expand filename
2737 case "\$1" in
2738  ~/*|~)
2739         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2740         ;;
2741  ~*)
2742         if $test -f /bin/csh; then
2743                 /bin/csh -f -c "glob \$1"
2744                 failed=\$?
2745                 echo ""
2746                 exit \$failed
2747         else
2748                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2749                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2750                 if $test ! -d "\$dir"; then
2751                         me=\`basename \$0\`
2752                         echo "\$me: can't locate home directory for: \$name" >&2
2753                         exit 1
2754                 fi
2755                 case "\$1" in
2756                 */*)
2757                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2758                         ;;
2759                 *)
2760                         echo \$dir
2761                         ;;
2762                 esac
2763         fi
2764         ;;
2765 *)
2766         echo \$1
2767         ;;
2768 esac
2769 EOSS
2770 chmod +x filexp
2771 $eunicefix filexp
2772
2773 : now set up to get a file name
2774 cat <<EOS >getfile
2775 $startsh
2776 EOS
2777 cat <<'EOSC' >>getfile
2778 tilde=''
2779 fullpath=''
2780 already=''
2781 skip=''
2782 none_ok=''
2783 exp_file=''
2784 nopath_ok=''
2785 orig_rp="$rp"
2786 orig_dflt="$dflt"
2787
2788 case "$fn" in
2789 *\(*)
2790         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2791         fn=`echo $fn | sed 's/(.*)//'`
2792         ;;
2793 esac
2794
2795 case "$fn" in
2796 *:*)
2797         loc_file=`expr $fn : '.*:\(.*\)'`
2798         fn=`expr $fn : '\(.*\):.*'`
2799         ;;
2800 esac
2801
2802 case "$fn" in
2803 *~*) tilde=true;;
2804 esac
2805 case "$fn" in
2806 */*) fullpath=true;;
2807 esac
2808 case "$fn" in
2809 *+*) skip=true;;
2810 esac
2811 case "$fn" in
2812 *n*) none_ok=true;;
2813 esac
2814 case "$fn" in
2815 *e*) exp_file=true;;
2816 esac
2817 case "$fn" in
2818 *p*) nopath_ok=true;;
2819 esac
2820
2821 case "$fn" in
2822 *f*) type='File';;
2823 *d*) type='Directory';;
2824 *l*) type='Locate';;
2825 esac
2826
2827 what="$type"
2828 case "$what" in
2829 Locate) what='File';;
2830 esac
2831
2832 case "$exp_file" in
2833 '')
2834         case "$d_portable" in
2835         "$define") ;;
2836         *) exp_file=true;;
2837         esac
2838         ;;
2839 esac
2840
2841 cd ..
2842 while test "$type"; do
2843         redo=''
2844         rp="$orig_rp"
2845         dflt="$orig_dflt"
2846         case "$tilde" in
2847         true) rp="$rp (~name ok)";;
2848         esac
2849         . UU/myread
2850         if test -f UU/getfile.ok && \
2851                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2852         then
2853                 value="$ans"
2854                 ansexp="$ans"
2855                 break
2856         fi
2857         case "$ans" in
2858         none)
2859                 value=''
2860                 ansexp=''
2861                 case "$none_ok" in
2862                 true) type='';;
2863                 esac
2864                 ;;
2865         *)
2866                 case "$tilde" in
2867                 '') value="$ans"
2868                         ansexp="$ans";;
2869                 *)
2870                         value=`UU/filexp $ans`
2871                         case $? in
2872                         0)
2873                                 if test "$ans" != "$value"; then
2874                                         echo "(That expands to $value on this system.)"
2875                                 fi
2876                                 ;;
2877                         *) value="$ans";;
2878                         esac
2879                         ansexp="$value"
2880                         case "$exp_file" in
2881                         '') value="$ans";;
2882                         esac
2883                         ;;
2884                 esac
2885                 case "$fullpath" in
2886                 true)
2887                         case "$ansexp" in
2888                         /*) value="$ansexp" ;;
2889                         *)
2890                                 redo=true
2891                                 case "$already" in
2892                                 true)
2893                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2894                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2895                                         ;;
2896                                 *)
2897                                 echo "Please give a full path name, starting with slash." >&4
2898                                         case "$tilde" in
2899                                         true)
2900                                 echo "Note that using ~name is ok provided it expands well." >&4
2901                                                 already=true
2902                                                 ;;
2903                                         esac
2904                                 esac
2905                                 ;;
2906                         esac
2907                         ;;
2908                 esac
2909                 case "$redo" in
2910                 '')
2911                         case "$type" in
2912                         File)
2913                                 if test -f "$ansexp"; then
2914                                         type=''
2915                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2916                                 then
2917                                         echo "($value is not a plain file, but that's ok.)"
2918                                         type=''
2919                                 fi
2920                                 ;;
2921                         Directory)
2922                                 if test -d "$ansexp"; then
2923                                         type=''
2924                                 fi
2925                                 ;;
2926                         Locate)
2927                                 if test -d "$ansexp"; then
2928                                         echo "(Looking for $loc_file in directory $value.)"
2929                                         value="$value/$loc_file"
2930                                         ansexp="$ansexp/$loc_file"
2931                                 fi
2932                                 if test -f "$ansexp"; then
2933                                         type=''
2934                                 fi
2935                                 case "$nopath_ok" in
2936                                 true)   case "$value" in
2937                                         */*) ;;
2938                                         *)      echo "Assuming $value will be in people's path."
2939                                                 type=''
2940                                                 ;;
2941                                         esac
2942                                         ;;
2943                                 esac
2944                                 ;;
2945                         esac
2946
2947                         case "$skip" in
2948                         true) type='';
2949                         esac
2950
2951                         case "$type" in
2952                         '') ;;
2953                         *)
2954                                 if test "$fastread" = yes; then
2955                                         dflt=y
2956                                 else
2957                                         dflt=n
2958                                 fi
2959                                 rp="$what $value doesn't exist.  Use that name anyway?"
2960                                 . UU/myread
2961                                 dflt=''
2962                                 case "$ans" in
2963                                 y*) type='';;
2964                                 *) echo " ";;
2965                                 esac
2966                                 ;;
2967                         esac
2968                         ;;
2969                 esac
2970                 ;;
2971         esac
2972 done
2973 cd UU
2974 ans="$value"
2975 rp="$orig_rp"
2976 dflt="$orig_dflt"
2977 rm -f getfile.ok
2978 EOSC
2979
2980 : determine root of directory hierarchy where package will be installed.
2981 case "$prefix" in
2982 '')
2983         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2984         ;;
2985 *)
2986         dflt="$prefix"
2987         ;;
2988 esac
2989 $cat <<EOM
2990
2991 By default, $package will be installed in $dflt/bin, manual
2992 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
2993 all installation directories. Typically set to /usr/local, but you
2994 may choose /usr if you wish to install $package among your system
2995 binaries. If you wish to have binaries under /bin but manual pages
2996 under /usr/local/man, that's ok: you will be prompted separately
2997 for each of the installation directories, the prefix being only used
2998 to set the defaults.
2999
3000 EOM
3001 fn=d~
3002 rp='Installation prefix to use?'
3003 . ./getfile
3004 oldprefix=''
3005 case "$prefix" in
3006 '') ;;
3007 *)
3008         case "$ans" in
3009         "$prefix") ;;
3010         *) oldprefix="$prefix";;
3011         esac
3012         ;;
3013 esac
3014 prefix="$ans"
3015 prefixexp="$ansexp"
3016
3017 : set the prefixit variable, to compute a suitable default value
3018 prefixit='case "$3" in
3019 ""|none)
3020         case "$oldprefix" in
3021         "") eval "$1=\"\$$2\"";;
3022         *)
3023                 case "$3" in
3024                 "") eval "$1=";;
3025                 none)
3026                         eval "tp=\"\$$2\"";
3027                         case "$tp" in
3028                         ""|" ") eval "$1=\"\$$2\"";;
3029                         *) eval "$1=";;
3030                         esac;;
3031                 esac;;
3032         esac;;
3033 *)
3034         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
3035         case "$tp" in
3036         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
3037         /*-$oldprefix/*|\~*-$oldprefix/*)
3038                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
3039         *) eval "$1=\"\$$2\"";;
3040         esac;;
3041 esac'
3042
3043 : set the base revision
3044 baserev=5.0
3045
3046 : get the patchlevel
3047 echo " "
3048 echo "Getting the current patchlevel..." >&4
3049 if $test -r $rsrc/patchlevel.h;then
3050         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
3051         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
3052 else
3053         patchlevel=0
3054         subversion=0
3055 fi
3056 $echo $n "(You have $package" $c
3057 case "$package" in
3058 "*$baserev")    ;;
3059 *)              $echo $n " $baserev" $c ;;
3060 esac
3061 $echo $n " patchlevel $patchlevel" $c
3062 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
3063 echo ".)"
3064
3065 if test 0 -eq "$subversion"; then
3066         version=`LC_ALL=C; export LC_ALL; \
3067                  echo $baserev $patchlevel | \
3068                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3069 else
3070         version=`LC_ALL=C; export LC_ALL; \
3071                  echo $baserev $patchlevel $subversion | \
3072                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
3073 fi
3074 : Figure out perl API version.  Perhaps this should be in patchlevel.h
3075 if test "$subversion" -lt 50; then
3076         apiversion=`LC_ALL=C; export LC_ALL; \
3077                  LANGUAGE=C; export LANGUAGE; \
3078                  echo $baserev $patchlevel | \
3079                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
3080 else
3081         apiversion="$version"
3082 fi
3083
3084 : determine where private library files go
3085 : Usual default is /usr/local/lib/perl5/$version.
3086 : Also allow things like /opt/perl/lib/$version, since 
3087 : /opt/perl/lib/perl5... would be redundant.
3088 case "$prefix" in
3089 *perl*) set dflt privlib lib/$version ;;
3090 *)       set dflt privlib lib/$package/$version ;;
3091 esac
3092 eval $prefixit
3093 $cat <<EOM
3094
3095 There are some auxiliary files for $package that need to be put into a
3096 private library directory that is accessible by everyone.
3097
3098 EOM
3099 fn=d~+
3100 rp='Pathname where the private library files will reside?'
3101 . ./getfile
3102 if $test "X$privlibexp" != "X$ansexp"; then
3103         installprivlib=''
3104 fi
3105 privlib="$ans"
3106 privlibexp="$ansexp"
3107 if $afs; then
3108         $cat <<EOM
3109
3110 Since you are running AFS, I need to distinguish the directory in which
3111 private files reside from the directory in which they are installed (and from
3112 which they are presumably copied to the former directory by occult means).
3113
3114 EOM
3115         case "$installprivlib" in
3116         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
3117         *) dflt="$installprivlib";;
3118         esac
3119         fn=de~
3120         rp='Where will private files be installed?'
3121         . ./getfile
3122         installprivlib="$ans"
3123 else
3124         installprivlib="$privlibexp"
3125 fi
3126
3127 : set the prefixup variable, to restore leading tilda escape
3128 prefixup='case "$prefixexp" in
3129 "$prefix") ;;
3130 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
3131 esac'
3132
3133 : determine where public architecture dependent libraries go
3134 set archlib archlib
3135 eval $prefixit
3136 : privlib default is /usr/local/lib/$package/$version
3137 : archlib default is /usr/local/lib/$package/$version/$archname
3138 : privlib may have an optional trailing /share.
3139 tdflt=`echo $privlib | $sed 's,/share$,,'`
3140 tdflt=$tdflt/$archname
3141 case "$archlib" in
3142 '')     dflt=$tdflt
3143         ;;
3144 *)      dflt="$archlib"
3145     ;;
3146 esac
3147 cat <<EOM
3148
3149 $spackage contains architecture-dependent library files.  If you are
3150 sharing libraries in a heterogeneous environment, you might store
3151 these files in a separate location.  Otherwise, you can just include
3152 them with the rest of the public library files.
3153
3154 EOM
3155 fn=d+~
3156 rp='Where do you want to put the public architecture-dependent libraries?'
3157 . ./getfile
3158 archlib="$ans"
3159 archlibexp="$ansexp"
3160
3161 if $afs; then
3162         $cat <<EOM
3163
3164 Since you are running AFS, I need to distinguish the directory in
3165 which architecture-dependent library files reside from the directory
3166 in which they are installed (and from which they are presumably copied
3167 to the former directory by occult means).
3168
3169 EOM
3170         case "$installarchlib" in
3171         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3172         *) dflt="$installarchlib";;
3173         esac
3174         fn=de~
3175         rp='Where will architecture-dependent library files be installed?'
3176         . ./getfile
3177         installarchlib="$ans"
3178 else
3179         installarchlib="$archlibexp"
3180 fi
3181 if $test X"$archlib" = X"$privlib"; then
3182         d_archlib="$undef"
3183 else
3184         d_archlib="$define"
3185 fi
3186
3187 : make some quick guesses about what we are up against
3188 echo " "
3189 $echo $n "Hmm...  $c"
3190 echo exit 1 >bsd
3191 echo exit 1 >usg
3192 echo exit 1 >v7
3193 echo exit 1 >osf1
3194 echo exit 1 >eunice
3195 echo exit 1 >xenix
3196 echo exit 1 >venix
3197 echo exit 1 >os2
3198 d_bsd="$undef"
3199 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3200 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3201 then
3202         echo "Looks kind of like an OSF/1 system, but we'll see..."
3203         echo exit 0 >osf1
3204 elif test `echo abc | tr a-z A-Z` = Abc ; then
3205         xxx=`./loc addbib blurfl $pth`
3206         if $test -f $xxx; then
3207         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3208                 echo exit 0 >bsd
3209                 echo exit 0 >usg
3210         else
3211                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3212                         echo "Looks kind of like an extended USG system, but we'll see..."
3213                 else
3214                         echo "Looks kind of like a USG system, but we'll see..."
3215                 fi
3216                 echo exit 0 >usg
3217         fi
3218 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3219         echo "Looks kind of like a BSD system, but we'll see..."
3220         d_bsd="$define"
3221         echo exit 0 >bsd
3222 else
3223         echo "Looks kind of like a Version 7 system, but we'll see..."
3224         echo exit 0 >v7
3225 fi
3226 case "$eunicefix" in
3227 *unixtovms*)
3228         $cat <<'EOI'
3229 There is, however, a strange, musty smell in the air that reminds me of
3230 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3231 EOI
3232         echo exit 0 >eunice
3233         d_eunice="$define"
3234 : it so happens the Eunice I know will not run shell scripts in Unix format
3235         ;;
3236 *)
3237         echo " "
3238         echo "Congratulations.  You aren't running Eunice."
3239         d_eunice="$undef"
3240         ;;
3241 esac
3242 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3243 case "$p_" in
3244 :) ;;
3245 *)
3246         $cat <<'EOI'
3247 I have the feeling something is not exactly right, however...don't tell me...
3248 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3249 EOI
3250         echo exit 0 >os2
3251         ;;
3252 esac
3253 if test -f /xenix; then
3254         echo "Actually, this looks more like a XENIX system..."
3255         echo exit 0 >xenix
3256         d_xenix="$define"
3257 else
3258         echo " "
3259         echo "It's not Xenix..."
3260         d_xenix="$undef"
3261 fi
3262 chmod +x xenix
3263 $eunicefix xenix
3264 if test -f /venix; then
3265         echo "Actually, this looks more like a VENIX system..."
3266         echo exit 0 >venix
3267 else
3268         echo " "
3269         if ./xenix; then
3270                 : null
3271         else
3272                 echo "Nor is it Venix..."
3273         fi
3274 fi
3275 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3276 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3277 $rm -f foo
3278
3279 : see if setuid scripts can be secure
3280 $cat <<EOM
3281
3282 Some kernels have a bug that prevents setuid #! scripts from being
3283 secure.  Some sites have disabled setuid #! scripts because of this.
3284
3285 First let's decide if your kernel supports secure setuid #! scripts.
3286 (If setuid #! scripts would be secure but have been disabled anyway,
3287 don't say that they are secure if asked.)
3288
3289 EOM
3290
3291 val="$undef"
3292 if $test -d /dev/fd; then
3293         echo "#!$ls" >reflect
3294         chmod +x,u+s reflect
3295         ./reflect >flect 2>&1
3296         if $contains "/dev/fd" flect >/dev/null; then
3297                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3298                 val="$define"
3299         else
3300                 $cat <<EOM
3301 If you are not sure if they are secure, I can check but I'll need a
3302 username and password different from the one you are using right now.
3303 If you don't have such a username or don't want me to test, simply
3304 enter 'none'.
3305
3306 EOM
3307                 rp='Other username to test security of setuid scripts with?'
3308                 dflt='none'
3309                 . ./myread
3310                 case "$ans" in
3311                 n|none)
3312                         case "$d_suidsafe" in
3313                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3314                                 dflt=n;;
3315                         "$undef")
3316                                 echo "Well, the $hint value is *not* secure." >&4
3317                                 dflt=n;;
3318                         *)      echo "Well, the $hint value *is* secure." >&4
3319                                 dflt=y;;
3320                         esac
3321                         ;;
3322                 *)
3323                         $rm -f reflect flect
3324                         echo "#!$ls" >reflect
3325                         chmod +x,u+s reflect
3326                         echo >flect
3327                         chmod a+w flect
3328                         echo '"su" will (probably) prompt you for '"$ans's password."
3329                         su $ans -c './reflect >flect'
3330                         if $contains "/dev/fd" flect >/dev/null; then
3331                                 echo "Okay, it looks like setuid scripts are secure." >&4
3332                                 dflt=y
3333                         else
3334                                 echo "I don't think setuid scripts are secure." >&4
3335                                 dflt=n
3336                         fi
3337                         ;;
3338                 esac
3339                 rp='Does your kernel have *secure* setuid scripts?'
3340                 . ./myread
3341                 case "$ans" in
3342                 [yY]*)  val="$define";;
3343                 *)      val="$undef";;
3344                 esac
3345         fi
3346 else
3347         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3348         echo "(That's for file descriptors, not floppy disks.)"
3349         val="$undef"
3350 fi
3351 set d_suidsafe
3352 eval $setvar
3353
3354 $rm -f reflect flect
3355
3356 : now see if they want to do setuid emulation
3357 echo " "
3358 val="$undef"
3359 case "$d_suidsafe" in
3360 "$define")
3361         val="$undef"
3362         echo "No need to emulate SUID scripts since they are secure here." >& 4
3363         ;;
3364 *)
3365         $cat <<EOM
3366 Some systems have disabled setuid scripts, especially systems where
3367 setuid scripts cannot be secure.  On systems where setuid scripts have
3368 been disabled, the setuid/setgid bits on scripts are currently
3369 useless.  It is possible for $package to detect those bits and emulate
3370 setuid/setgid in a secure fashion.  This emulation will only work if
3371 setuid scripts have been disabled in your kernel.
3372
3373 EOM
3374         case "$d_dosuid" in
3375         "$define") dflt=y ;;
3376         *) dflt=n ;;
3377         esac
3378         rp="Do you want to do setuid/setgid emulation?"
3379         . ./myread
3380         case "$ans" in
3381         [yY]*)  val="$define";;
3382         *)      val="$undef";;
3383         esac
3384         ;;
3385 esac
3386 set d_dosuid
3387 eval $setvar
3388
3389 : determine where manual pages are on this system
3390 echo " "
3391 case "$sysman" in
3392 '') 
3393         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3394         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3395         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3396         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3397         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3398         sysman=`./loc . /usr/man/man1 $syspath`
3399         ;;
3400 esac
3401 if $test -d "$sysman"; then
3402         echo "System manual is in $sysman." >&4
3403 else
3404         echo "Could not find manual pages in source form." >&4
3405 fi
3406
3407 : see what memory models we can support
3408 case "$models" in
3409 '')
3410         $cat >pdp11.c <<'EOP'
3411 int main() {
3412 #ifdef pdp11
3413         exit(0);
3414 #else
3415         exit(1);
3416 #endif
3417 }
3418 EOP
3419         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3420         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3421                 dflt='unsplit split'
3422         else
3423                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3424                 case "$tans" in
3425                 X) dflt='none';;
3426                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3427                                 dflt='small'
3428                         else
3429                                 dflt=''
3430                         fi
3431                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3432                                 dflt="$dflt medium"
3433                         fi
3434                         if $test -d /lib/large || $test -d /usr/lib/large; then
3435                                 dflt="$dflt large"
3436                         fi
3437                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3438                                 dflt="$dflt huge"
3439                         fi
3440                 esac
3441         fi;;
3442 *) dflt="$models";;
3443 esac
3444 $cat <<EOM
3445  
3446 Some systems have different model sizes.  On most systems they are called
3447 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3448 split.  If your system doesn't support different memory models, say "none".
3449 If you wish to force everything to one memory model, say "none" here and
3450 put the appropriate flags later when it asks you for other cc and ld flags.
3451 Venix systems may wish to put "none" and let the compiler figure things out.
3452 (In the following question multiple model names should be space separated.)
3453
3454 The default for most systems is "none".
3455
3456 EOM
3457 rp="Which memory models are supported?"
3458 . ./myread
3459 models="$ans"
3460
3461 case "$models" in
3462 none)
3463         small=''
3464         medium=''
3465         large=''
3466         huge=''
3467         unsplit=''
3468         split=''
3469         ;;
3470 *split)
3471         case "$split" in
3472         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3473                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3474                         dflt='-i'
3475                 else
3476                         dflt='none'
3477                 fi;;
3478         *) dflt="$split";;
3479         esac
3480         rp="What flag indicates separate I and D space?"
3481         . ./myread
3482         tans="$ans"
3483         case "$tans" in
3484         none) tans='';;
3485         esac
3486         split="$tans"
3487         unsplit='';;
3488 *large*|*small*|*medium*|*huge*)
3489         case "$models" in
3490         *large*)
3491                 case "$large" in
3492                 '') dflt='-Ml';;
3493                 *) dflt="$large";;
3494                 esac
3495         rp="What flag indicates large model?"
3496         . ./myread
3497         tans="$ans"
3498         case "$tans" in
3499         none) tans='';
3500         esac
3501         large="$tans";;
3502         *) large='';;
3503         esac
3504         case "$models" in
3505         *huge*) case "$huge" in
3506                 '') dflt='-Mh';;
3507                 *) dflt="$huge";;
3508                 esac
3509                 rp="What flag indicates huge model?"
3510                 . ./myread
3511                 tans="$ans"
3512                 case "$tans" in
3513                 none) tans='';
3514                 esac
3515                 huge="$tans";;
3516         *) huge="$large";;
3517         esac
3518         case "$models" in
3519         *medium*) case "$medium" in
3520                 '') dflt='-Mm';;
3521                 *) dflt="$medium";;
3522                 esac
3523                 rp="What flag indicates medium model?"
3524                 . ./myread
3525                 tans="$ans"
3526                 case "$tans" in
3527                 none) tans='';
3528                 esac
3529                 medium="$tans";;
3530         *) medium="$large";;
3531         esac
3532         case "$models" in
3533         *small*) case "$small" in
3534                 '') dflt='none';;
3535                 *) dflt="$small";;
3536                 esac
3537                 rp="What flag indicates small model?"
3538                 . ./myread
3539                 tans="$ans"
3540                 case "$tans" in
3541                 none) tans='';
3542                 esac
3543                 small="$tans";;
3544         *) small='';;
3545         esac
3546         ;;
3547 *)
3548         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3549         ;;
3550 esac
3551 $rm -f pdp11.* pdp11
3552
3553 : see if we need a special compiler
3554 echo " "
3555 if ./usg; then
3556         case "$cc" in
3557         '') case "$Mcc" in
3558                 /*) dflt='Mcc';;
3559                 *) case "$large" in
3560                         -M*) dflt='cc';;
3561                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3562                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3563                                                 dflt='cc'
3564                                         else
3565                                                 dflt='cc -M'
3566                                         fi
3567                                 else
3568                                         dflt='cc'
3569                                 fi;;
3570                         esac;;
3571                 esac;;
3572         *)  dflt="$cc";;
3573         esac
3574         case "$dflt" in
3575         *M*)    $cat <<'EOM'
3576 On some older systems the default C compiler will not resolve multiple global
3577 references that happen to have the same name.  On some such systems the "Mcc"
3578 command may be used to force these to be resolved.  On other systems a "cc -M"
3579 command is required.  (Note that the -M flag on other systems indicates a
3580 memory model to use!) If you have the Gnu C compiler, you might wish to use
3581 that instead.
3582
3583 EOM
3584         ;;
3585         esac
3586         rp="Use which C compiler?"
3587         . ./myread
3588         cc="$ans"
3589 else
3590         case "$cc" in
3591         '') dflt=cc;;
3592         *) dflt="$cc";;
3593         esac
3594         rp="Use which C compiler?"
3595         . ./myread
3596         cc="$ans"
3597 fi
3598 : Look for a hint-file generated 'call-back-unit'.  Now that the
3599 : user has specified the compiler, we may need to set or change some
3600 : other defaults.
3601 if $test -f cc.cbu; then
3602     . ./cc.cbu
3603 fi
3604 echo " "
3605 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3606 $cat >gccvers.c <<EOM
3607 #include <stdio.h>
3608 int main() {
3609 #ifdef __GNUC__
3610 #ifdef __VERSION__
3611         printf("%s\n", __VERSION__);
3612 #else
3613         printf("%s\n", "1");
3614 #endif
3615 #endif
3616         exit(0);
3617 }
3618 EOM
3619 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
3620         gccversion=`./gccvers`
3621         case "$gccversion" in
3622         '') echo "You are not using GNU cc." ;;
3623         *)  echo "You are using GNU cc $gccversion." ;;
3624         esac
3625 else
3626         echo " "
3627         echo "*** WHOA THERE!!! ***" >&4
3628         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3629         case "$knowitall" in
3630         '')
3631         echo "    You'd better start hunting for one and let me know about it." >&4
3632                 exit 1
3633                 ;;
3634         esac
3635 fi
3636 $rm -f gccvers*
3637 case "$gccversion" in
3638 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3639 esac
3640
3641 : What should the include directory be ?
3642 echo " "
3643 $echo $n "Hmm...  $c"
3644 dflt='/usr/include'
3645 incpath=''
3646 mips_type=''
3647 if $test -f /bin/mips && /bin/mips; then
3648         echo "Looks like a MIPS system..."
3649         $cat >usr.c <<'EOCP'
3650 #ifdef SYSTYPE_BSD43
3651 /bsd43
3652 #endif
3653 EOCP
3654         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3655                 dflt='/bsd43/usr/include'
3656                 incpath='/bsd43'
3657                 mips_type='BSD 4.3'
3658         else
3659                 mips_type='System V'
3660         fi
3661         $rm -f usr.c usr.out
3662         echo "and you're compiling with the $mips_type compiler and libraries."
3663         xxx_prompt=y
3664         echo "exit 0" >mips
3665 else
3666         echo "Doesn't look like a MIPS system."
3667         xxx_prompt=n
3668         echo "exit 1" >mips
3669 fi
3670 chmod +x mips
3671 $eunicefix mips
3672 case "$usrinc" in
3673 '') ;;
3674 *) dflt="$usrinc";;
3675 esac
3676 case "$xxx_prompt" in
3677 y)      fn=d/
3678         echo " "
3679         rp='Where are the include files you want to use?'
3680         . ./getfile
3681         usrinc="$ans"
3682         ;;
3683 *)      usrinc="$dflt"
3684         ;;
3685 esac
3686
3687 : see how we invoke the C preprocessor
3688 echo " "
3689 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3690 cat <<'EOT' >testcpp.c
3691 #define ABC abc
3692 #define XYZ xyz
3693 ABC.XYZ
3694 EOT
3695 cd ..
3696 if test ! -f cppstdin; then
3697         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3698 else
3699         echo "Keeping your $hint cppstdin wrapper."
3700 fi
3701 chmod 755 cppstdin
3702 wrapper=`pwd`/cppstdin
3703 ok='false'
3704 cd UU
3705
3706 if $test "X$cppstdin" != "X" && \
3707         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3708         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3709 then
3710         echo "You used to use $cppstdin $cppminus so we'll use that again."
3711         case "$cpprun" in
3712         '') echo "But let's see if we can live without a wrapper..." ;;
3713         *)
3714                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3715                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3716                 then
3717                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3718                         ok='true'
3719                 else
3720                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3721                 fi
3722                 ;;
3723         esac
3724 else
3725         case "$cppstdin" in
3726         '') ;;
3727         *)
3728                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3729                 ;;
3730         esac
3731 fi
3732
3733 if $ok; then
3734         : nothing
3735 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3736         $cc -E <testcpp.c >testcpp.out 2>&1; \
3737         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3738         echo "Yup, it does."
3739         x_cpp="$cc -E"
3740         x_minus='';
3741 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3742         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3743         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3744         echo "Yup, it does."
3745         x_cpp="$cc -E"
3746         x_minus='-';
3747 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3748         $cc -P <testcpp.c >testcpp.out 2>&1; \
3749         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3750         echo "Yipee, that works!"
3751         x_cpp="$cc -P"
3752         x_minus='';
3753 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3754         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3755         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3756         echo "At long last!"
3757         x_cpp="$cc -P"
3758         x_minus='-';
3759 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3760         $cpp <testcpp.c >testcpp.out 2>&1; \
3761         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3762         echo "It works!"
3763         x_cpp="$cpp"
3764         x_minus='';
3765 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3766         $cpp - <testcpp.c >testcpp.out 2>&1; \
3767         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3768         echo "Hooray, it works!  I was beginning to wonder."
3769         x_cpp="$cpp"
3770         x_minus='-';
3771 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3772         $wrapper <testcpp.c >testcpp.out 2>&1; \
3773         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3774         x_cpp="$wrapper"
3775         x_minus=''
3776         echo "Eureka!"
3777 else
3778         dflt=''
3779         rp="No dice.  I can't find a C preprocessor.  Name one:"
3780         . ./myread
3781         x_cpp="$ans"
3782         x_minus=''
3783         $x_cpp <testcpp.c >testcpp.out 2>&1
3784         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3785                 echo "OK, that will do." >&4
3786         else
3787 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3788                 exit 1
3789         fi
3790 fi
3791
3792 case "$ok" in
3793 false)
3794         cppstdin="$x_cpp"
3795         cppminus="$x_minus"
3796         cpprun="$x_cpp"
3797         cpplast="$x_minus"
3798         set X $x_cpp
3799         shift
3800         case "$1" in
3801         "$cpp")
3802                 echo "Perhaps can we force $cc -E using a wrapper..."
3803                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3804                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3805                 then
3806                         echo "Yup, we can."
3807                         cppstdin="$wrapper"
3808                         cppminus='';
3809                 else
3810                         echo "Nope, we'll have to live without it..."
3811                 fi
3812                 ;;
3813         esac
3814         case "$cpprun" in
3815         "$wrapper")
3816                 cpprun=''
3817                 cpplast=''
3818                 ;;
3819         esac
3820         ;;
3821 esac
3822
3823 case "$cppstdin" in
3824 "$wrapper"|'cppstdin') ;;
3825 *) $rm -f $wrapper;;
3826 esac
3827 $rm -f testcpp.c testcpp.out
3828
3829 : Set private lib path
3830 case "$plibpth" in
3831 '') if ./mips; then
3832                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3833         fi;;
3834 esac
3835 case "$libpth" in
3836 ' ') dlist='';;
3837 '') dlist="$loclibpth $plibpth $glibpth";;
3838 *) dlist="$libpth";;
3839 esac
3840
3841 : Now check and see which directories actually exist, avoiding duplicates
3842 libpth=''
3843 for xxx in $dlist
3844 do
3845     if $test -d $xxx; then
3846                 case " $libpth " in
3847                 *" $xxx "*) ;;
3848                 *) libpth="$libpth $xxx";;
3849                 esac
3850     fi
3851 done
3852 $cat <<'EOM'
3853
3854 Some systems have incompatible or broken versions of libraries.  Among
3855 the directories listed in the question below, please remove any you
3856 know not to be holding relevant libraries, and add any that are needed.
3857 Say "none" for none.
3858
3859 EOM
3860 case "$libpth" in
3861 '') dflt='none';;
3862 *)
3863         set X $libpth
3864         shift
3865         dflt=${1+"$@"}
3866         ;;
3867 esac
3868 rp="Directories to use for library searches?"
3869 . ./myread
3870 case "$ans" in
3871 none) libpth=' ';;
3872 *) libpth="$ans";;
3873 esac
3874
3875 : compute shared library extension
3876 case "$so" in
3877 '')
3878         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3879                 dflt='sl'
3880         else
3881                 dflt='so'
3882         fi
3883         ;;
3884 *) dflt="$so";;
3885 esac
3886 $cat <<EOM
3887
3888 On some systems, shared libraries may be available.  Answer 'none' if
3889 you want to suppress searching of shared libraries for the remaining
3890 of this configuration.
3891
3892 EOM
3893 rp='What is the file extension used for shared libraries?'
3894 . ./myread
3895 so="$ans"
3896
3897 : Define several unixisms.
3898 : Hints files or command line option can be used to override them.
3899 : The convoluted testing is in case hints files set either the old
3900 : or the new name.
3901 case "$_exe" in
3902 '')     case "$exe_ext" in
3903     '') ;;
3904         *)      _exe="$exe_ext" ;;
3905         esac
3906         ;;
3907 esac
3908 case "$_a" in
3909 '')     case "$lib_ext" in
3910     '') _a='.a';;
3911         *)      _a="$lib_ext" ;;
3912         esac
3913         ;;
3914 esac
3915 case "$_o" in
3916 '') case "$obj_ext" in
3917         '')     _o='.o';;
3918         *)      _o="$obj_ext";;
3919         esac
3920         ;;
3921 esac
3922 case "$p_" in
3923 '') case "$path_sep" in
3924         '')     p_=':';;
3925         *)      p_="$path_sep";;
3926         esac
3927         ;;
3928 esac
3929 exe_ext=$_exe
3930 lib_ext=$_a
3931 obj_ext=$_o
3932 path_sep=$p_
3933
3934 : Which makefile gets called first.  This is used by make depend.
3935 case "$firstmakefile" in
3936 '') firstmakefile='makefile';;
3937 esac
3938
3939 : Looking for optional libraries
3940 echo " "
3941 echo "Checking for optional libraries..." >&4
3942 case "$libs" in
3943 ' '|'') dflt='';;
3944 *) dflt="$libs";;
3945 esac
3946 case "$libswanted" in
3947 '') libswanted='c_s';;
3948 esac
3949 for thislib in $libswanted; do
3950         
3951         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3952                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3953                 echo "Found -l$thislib (shared)."
3954                 case " $dflt " in
3955                 *"-l$thislib "*);;
3956                 *) dflt="$dflt -l$thislib";;
3957                 esac
3958         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3959                 echo "Found -l$thislib (shared)."
3960                 case " $dflt " in
3961                 *"-l$thislib "*);;
3962                 *) dflt="$dflt -l$thislib";;
3963                 esac
3964         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
3965                 echo "Found -l$thislib."
3966                 case " $dflt " in
3967                 *"-l$thislib "*);;
3968                 *) dflt="$dflt -l$thislib";;
3969                 esac
3970         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
3971                 echo "Found -l$thislib."
3972                 case " $dflt " in
3973                 *"-l$thislib "*);;
3974                 *) dflt="$dflt -l$thislib";;
3975                 esac
3976         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
3977                 echo "Found -l${thislib}_s."
3978                 case " $dflt " in
3979                 *"-l$thislib "*);;
3980                 *) dflt="$dflt -l${thislib}_s";;
3981                 esac
3982         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
3983                 echo "Found -l$thislib."
3984                 case " $dflt " in
3985                 *"-l$thislib "*);;
3986                 *) dflt="$dflt -l$thislib";;
3987                 esac
3988         else
3989                 echo "No -l$thislib."
3990         fi
3991 done
3992 set X $dflt
3993 shift
3994 dflt="$*"
3995 case "$libs" in
3996 '') dflt="$dflt";;
3997 *) dflt="$libs";;
3998 esac
3999 case "$dflt" in
4000 ' '|'') dflt='none';;
4001 esac
4002
4003 $cat <<EOM
4004  
4005 Some versions of Unix support shared libraries, which make executables smaller
4006 but make load time slightly longer.
4007
4008 On some systems, mostly System V Release 3's, the shared library is included
4009 by putting the option "-lc_s" as the last thing on the cc command line when
4010 linking.  Other systems use shared libraries by default.  There may be other
4011 libraries needed to compile $package on your machine as well.  If your system
4012 needs the "-lc_s" option, include it here.  Include any other special libraries
4013 here as well.  Say "none" for none.
4014 EOM
4015
4016 echo " "
4017 rp="Any additional libraries?"
4018 . ./myread
4019 case "$ans" in
4020 none) libs=' ';;
4021 *) libs="$ans";;
4022 esac
4023
4024 : determine optimize, if desired, or use for debug flag also
4025 case "$optimize" in
4026 ' '|$undef) dflt='none';;
4027 '') dflt='-O';;
4028 *) dflt="$optimize";;
4029 esac
4030 $cat <<EOH
4031
4032 Some C compilers have problems with their optimizers.  By default, $package
4033 compiles with the -O flag to use the optimizer.  Alternately, you might want
4034 to use the symbolic debugger, which uses the -g flag (on traditional Unix
4035 systems).  Either flag can be specified here.  To use neither flag, specify
4036 the word "none".
4037
4038 EOH
4039 rp="What optimizer/debugger flag should be used?"
4040 . ./myread
4041 optimize="$ans"
4042 case "$optimize" in
4043 'none') optimize=" ";;
4044 esac
4045
4046 dflt=''
4047 : We will not override a previous value, but we might want to
4048 : augment a hint file
4049 case "$hint" in
4050 none|recommended)
4051         case "$gccversion" in
4052         1*) dflt='-fpcc-struct-return' ;;
4053         esac
4054         case "$optimize" in
4055         *-g*) dflt="$dflt -DDEBUGGING";;
4056         esac
4057         case "$gccversion" in
4058         2*) if test -d /etc/conf/kconfig.d &&
4059                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
4060                 then
4061                         dflt="$dflt -posix"
4062                 fi
4063                 ;;
4064         esac
4065         ;;
4066 esac
4067
4068 case "$mips_type" in
4069 *BSD*|'') inclwanted="$locincpth $usrinc";;
4070 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
4071 esac
4072 for thisincl in $inclwanted; do
4073         if $test -d $thisincl; then
4074                 if $test x$thisincl != x$usrinc; then
4075                         case "$dflt" in
4076                         *$thisincl*);;
4077                         *) dflt="$dflt -I$thisincl";;
4078                         esac
4079                 fi
4080         fi
4081 done
4082
4083 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
4084         xxx=true;
4085 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
4086         xxx=true;
4087 else
4088         xxx=false;
4089 fi;
4090 if $xxx; then
4091         case "$dflt" in
4092         *$2*);;
4093         *) dflt="$dflt -D$2";;
4094         esac;
4095 fi'
4096
4097 set signal.h LANGUAGE_C; eval $inctest
4098
4099 case "$hint" in
4100 none|recommended) dflt="$ccflags $dflt" ;;
4101 *) dflt="$ccflags";;
4102 esac
4103
4104 case "$dflt" in
4105 ''|' ') dflt=none;;
4106 esac
4107 $cat <<EOH
4108
4109 Your C compiler may want other flags.  For this question you should include
4110 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
4111 but you should NOT include libraries or ld flags like -lwhatever.  If you
4112 want $package to honor its debug switch, you should include -DDEBUGGING here.
4113 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
4114
4115 To use no flags, specify the word "none".
4116
4117 EOH
4118 set X $dflt
4119 shift
4120 dflt=${1+"$@"}
4121 rp="Any additional cc flags?"
4122 . ./myread
4123 case "$ans" in
4124 none) ccflags='';;
4125 *) ccflags="$ans";;
4126 esac
4127
4128 : the following weeds options from ccflags that are of no interest to cpp
4129 cppflags="$ccflags"
4130 case "$gccversion" in
4131 1*) cppflags="$cppflags -D__GNUC__"
4132 esac
4133 case "$mips_type" in
4134 '');;
4135 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
4136 esac
4137 case "$cppflags" in
4138 '');;
4139 *)
4140         echo " "
4141         echo "Let me guess what the preprocessor flags are..." >&4
4142         set X $cppflags
4143         shift
4144         cppflags=''
4145         $cat >cpp.c <<'EOM'
4146 #define BLURFL foo
4147
4148 BLURFL xx LFRULB
4149 EOM
4150         previous=''
4151         for flag in $*
4152         do
4153                 case "$flag" in
4154                 -*) ftry="$flag";;
4155                 *) ftry="$previous $flag";;
4156                 esac
4157                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4158                         >cpp1.out 2>/dev/null && \
4159                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4160                         >cpp2.out 2>/dev/null && \
4161                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4162                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4163                 then
4164                         cppflags="$cppflags $ftry"
4165                         previous=''
4166                 else
4167                         previous="$flag"
4168                 fi
4169         done
4170         set X $cppflags
4171         shift
4172         cppflags=${1+"$@"}
4173         case "$cppflags" in
4174         *-*)  echo "They appear to be: $cppflags";;
4175         esac
4176         $rm -f cpp.c cpp?.out
4177         ;;
4178 esac
4179
4180 : flags used in final linking phase
4181 case "$ldflags" in
4182 '') if ./venix; then
4183                 dflt='-i -z'
4184         else
4185                 dflt=''
4186         fi
4187         case "$ccflags" in
4188         *-posix*) dflt="$dflt -posix" ;;
4189         esac
4190         ;;
4191 *) dflt="$ldflags";;
4192 esac
4193
4194 : Try to guess additional flags to pick up local libraries.
4195 for thislibdir in $libpth; do
4196         case " $loclibpth " in
4197         *" $thislibdir "*)
4198                 case "$dflt " in 
4199                 *"-L$thislibdir "*) ;;
4200                 *)  dflt="$dflt -L$thislibdir" ;;
4201                 esac
4202                 ;;
4203         esac
4204 done
4205
4206 case "$dflt" in
4207 '') dflt='none' ;;
4208 esac
4209
4210 $cat <<EOH
4211
4212 Your C linker may need flags.  For this question you should
4213 include -L/whatever and any other flags used by the C linker, but you
4214 should NOT include libraries like -lwhatever.
4215
4216 Make sure you include the appropriate -L/path flags if your C linker
4217 does not normally search all of the directories you specified above,
4218 namely
4219         $libpth
4220 To use no flags, specify the word "none".
4221
4222 EOH
4223
4224 rp="Any additional ld flags (NOT including libraries)?"
4225 . ./myread
4226 case "$ans" in
4227 none) ldflags='';;
4228 *) ldflags="$ans";;
4229 esac
4230 rmlist="$rmlist pdp11"
4231
4232 : coherency check
4233 echo " "
4234 echo "Checking your choice of C compiler and flags for coherency..." >&4
4235 $cat > try.c <<'EOF'
4236 #include <stdio.h>
4237 int main() { printf("Ok\n"); exit(0); }
4238 EOF
4239 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4240 shift
4241 $cat >try.msg <<'EOM'
4242 I've tried to compile and run the following simple program:
4243
4244 EOM
4245 $cat try.c >> try.msg
4246
4247 $cat >> try.msg <<EOM
4248
4249 I used the command:
4250
4251         $*
4252         ./try
4253
4254 and I got the following output:
4255
4256 EOM
4257 dflt=y
4258 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4259         if sh -c './try' >>try.msg 2>&1; then
4260                 xxx=`./try`
4261                 case "$xxx" in
4262                 "Ok") dflt=n ;;
4263                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4264                         case " $libs " in
4265                         *" -lsfio "*)
4266                                 cat >> try.msg <<'EOQS'
4267 If $libs contains -lsfio, and sfio is mis-configured, then it
4268 sometimes (apparently) runs and exits with a 0 status, but with no
4269 output!  It may have to do with sfio's use of _exit vs. exit.
4270
4271 EOQS
4272                                 rp="You have a big problem.  Shall I abort Configure"
4273                                 dflt=y
4274                                 ;;
4275                         esac
4276                         ;;
4277                 esac
4278         else
4279                 echo "The program compiled OK, but exited with status $?." >>try.msg
4280                 rp="You have a problem.  Shall I abort Configure"
4281                 dflt=y
4282         fi
4283 else
4284         echo "I can't compile the test program." >>try.msg
4285         rp="You have a BIG problem.  Shall I abort Configure"
4286         dflt=y
4287 fi
4288 case "$dflt" in
4289 y)
4290         $cat try.msg >&4
4291         case "$knowitall" in
4292         '')
4293                 echo "(The supplied flags or libraries might be incorrect.)"
4294                 ;;
4295         *) dflt=n;;
4296         esac
4297         echo " "
4298         . ./myread
4299         case "$ans" in
4300         n*|N*) ;;
4301         *)      echo "Ok.  Stopping Configure." >&4
4302                 exit 1
4303                 ;;
4304         esac
4305         ;;
4306 n) echo "OK, that should do.";;
4307 esac
4308 $rm -f try try.* core
4309
4310 : determine filename position in cpp output
4311 echo " "
4312 echo "Computing filename position in cpp output for #include directives..." >&4
4313 echo '#include <stdio.h>' > foo.c
4314 $cat >fieldn <<EOF
4315 $startsh
4316 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4317 $grep '^[       ]*#.*stdio\.h' | \
4318 while read cline; do
4319         pos=1
4320         set \$cline
4321         while $test \$# -gt 0; do
4322                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4323                         echo "\$pos"
4324                         exit 0
4325                 fi
4326                 shift
4327                 pos=\`expr \$pos + 1\`
4328         done
4329 done
4330 EOF
4331 chmod +x fieldn
4332 fieldn=`./fieldn`
4333 $rm -f foo.c fieldn
4334 case $fieldn in
4335 '') pos='???';;
4336 1) pos=first;;
4337 2) pos=second;;
4338 3) pos=third;;
4339 *) pos="${fieldn}th";;
4340 esac
4341 echo "Your cpp writes the filename in the $pos field of the line."
4342
4343 : locate header file
4344 $cat >findhdr <<EOF
4345 $startsh
4346 wanted=\$1
4347 name=''
4348 for usrincdir in $usrinc
4349 do
4350         if test -f \$usrincdir/\$wanted; then
4351                 echo "\$usrincdir/\$wanted"
4352                 exit 0
4353         fi
4354 done
4355 awkprg='{ print \$$fieldn }'
4356 echo "#include <\$wanted>" > foo\$\$.c
4357 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4358 $grep "^[       ]*#.*\$wanted" | \
4359 while read cline; do
4360         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4361         case "\$name" in
4362         *[/\\\\]\$wanted) echo "\$name"; exit 0;;
4363         *) name='';;
4364         esac;
4365 done;
4366 $rm -f foo\$\$.c;
4367 case "\$name" in
4368 '') exit 1;;
4369 esac
4370 EOF
4371 chmod +x findhdr
4372
4373 : define an alternate in-header-list? function
4374 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4375 cont=true; xxf="echo \"<\$1> found.\" >&4";
4376 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4377 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4378 esac;
4379 case $# in 4) instead=instead;; *) instead="at last";; esac;
4380 while $test "$cont"; do
4381         xxx=`./findhdr $1`
4382         var=$2; eval "was=\$$2";
4383         if $test "$xxx" && $test -r "$xxx";
4384         then eval $xxf;
4385         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4386                 cont="";
4387         else eval $xxnf;
4388         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4389         set $yyy; shift; shift; yyy=$@;
4390         case $# in 0) cont="";;
4391         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4392                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4393         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4394                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4395         esac;
4396 done;
4397 while $test "$yyy";
4398 do set $yyy; var=$2; eval "was=\$$2";
4399         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4400         set $yyy; shift; shift; yyy=$@;
4401 done'
4402
4403 : see if this is a malloc.h system
4404 set malloc.h i_malloc
4405 eval $inhdr
4406
4407 : see if stdlib is available
4408 set stdlib.h i_stdlib
4409 eval $inhdr
4410
4411 : determine which malloc to compile in
4412 echo " "
4413 case "$usemymalloc" in
4414 ''|[yY]*|true|$define)  dflt='y' ;;
4415 *)      dflt='n' ;;
4416 esac
4417 rp="Do you wish to attempt to use the malloc that comes with $package?"
4418 . ./myread
4419 usemymalloc="$ans"
4420 case "$ans" in
4421 y*|true)
4422         usemymalloc='y'
4423         mallocsrc='malloc.c'
4424         mallocobj="malloc$_o"
4425         d_mymalloc="$define"
4426         case "$libs" in
4427         *-lmalloc*)
4428                 : Remove malloc from list of libraries to use
4429                 echo "Removing unneeded -lmalloc from library list" >&4
4430                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4431                 shift
4432                 libs="$*"
4433                 echo "libs = $libs" >&4
4434                 ;;
4435         esac
4436         ;;
4437 *)
4438         usemymalloc='n'
4439         mallocsrc=''
4440         mallocobj=''
4441         d_mymalloc="$undef"
4442         ;;
4443 esac
4444
4445 : compute the return types of malloc and free
4446 echo " "
4447 $cat >malloc.c <<END
4448 #$i_malloc I_MALLOC
4449 #$i_stdlib I_STDLIB
4450 #include <stdio.h>
4451 #include <sys/types.h>
4452 #ifdef I_MALLOC
4453 #include <malloc.h>
4454 #endif
4455 #ifdef I_STDLIB
4456 #include <stdlib.h>
4457 #endif
4458 #ifdef TRY_MALLOC
4459 void *malloc();
4460 #endif
4461 #ifdef TRY_FREE
4462 void free();
4463 #endif
4464 END
4465 case "$malloctype" in
4466 '')
4467         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4468                 malloctype='void *'
4469         else
4470                 malloctype='char *'
4471         fi
4472         ;;
4473 esac
4474 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4475
4476 case "$freetype" in
4477 '')
4478         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4479                 freetype='void'
4480         else
4481                 freetype='int'
4482         fi
4483         ;;
4484 esac
4485 echo "Your system uses $freetype free(), it would seem." >&4
4486 $rm -f malloc.[co]
4487 : Cruising for prototypes
4488 echo " "
4489 echo "Checking out function prototypes..." >&4
4490 $cat >prototype.c <<'EOCP'
4491 int main(int argc, char *argv[]) {
4492         exit(0);}
4493 EOCP
4494 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4495         echo "Your C compiler appears to support function prototypes."
4496         val="$define"
4497 else
4498         echo "Your C compiler doesn't seem to understand function prototypes."
4499         val="$undef"
4500 fi
4501 set prototype
4502 eval $setvar
4503 $rm -f prototype*
4504
4505 case "$prototype" in
4506 "$define") ;;
4507 *)      ansi2knr='ansi2knr'
4508         echo " "
4509         cat <<EOM >&4
4510
4511 $me:  FATAL ERROR:
4512 This version of $package can only be compiled by a compiler that 
4513 understands function prototypes.  Unfortunately, your C compiler 
4514         $cc $ccflags
4515 doesn't seem to understand them.  Sorry about that.
4516
4517 If GNU cc is available for your system, perhaps you could try that instead.  
4518
4519 Eventually, we hope to support building Perl with pre-ANSI compilers.
4520 If you would like to help in that effort, please contact <perlbug@perl.org>.
4521
4522 Aborting Configure now.
4523 EOM
4524         exit 2
4525         ;;
4526 esac
4527
4528 : determine where public executables go
4529 echo " "
4530 set dflt bin bin
4531 eval $prefixit
4532 fn=d~
4533 rp='Pathname where the public executables will reside?'
4534 . ./getfile
4535 if $test "X$ansexp" != "X$binexp"; then
4536         installbin=''
4537 fi
4538 bin="$ans"
4539 binexp="$ansexp"
4540 if $afs; then
4541         $cat <<EOM
4542
4543 Since you are running AFS, I need to distinguish the directory in which
4544 executables reside from the directory in which they are installed (and from
4545 which they are presumably copied to the former directory by occult means).
4546
4547 EOM
4548         case "$installbin" in
4549         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4550         *) dflt="$installbin";;
4551         esac
4552         fn=de~
4553         rp='Where will public executables be installed?'
4554         . ./getfile
4555         installbin="$ans"
4556 else
4557         installbin="$binexp"
4558 fi
4559
4560 : determine whether to install perl also as /usr/bin/perl
4561
4562 echo " "
4563 if test -d /usr/bin -a "X$installbin" != X/usr/bin; then
4564         $cat <<EOM
4565 Many scripts expect to perl to be installed as /usr/bin/perl.
4566 I can install the perl you are about to compile also as /usr/bin/perl
4567 (in addition to $installbin/perl).
4568 EOM
4569         case "$installusrbinperl" in
4570         "$undef"|[nN]*) dflt='n';;
4571         *)              dflt='y';;
4572         esac
4573         rp="Do you want to install perl as /usr/bin/perl?"
4574         . ./myread
4575         case "$ans" in
4576         [yY]*)  val="$define";;
4577         *)      val="$undef" ;;
4578         esac
4579 else
4580         val="$undef"
4581 fi
4582 set installusrbinperl
4583 eval $setvar
4584
4585 : define a shorthand compile call
4586 compile='
4587 mc_file=$1;
4588 shift;
4589 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4590 : define a shorthand compile call for compilations that should be ok.
4591 compile_ok='
4592 mc_file=$1;
4593 shift;
4594 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4595
4596 echo " "
4597 echo "Checking for GNU C Library..." >&4
4598 cat >gnulibc.c <<EOM
4599 #include <stdio.h>
4600 int main()
4601 {
4602 #ifdef __GLIBC__
4603     exit(0);
4604 #else
4605     exit(1);
4606 #endif
4607 }
4608 EOM
4609 set gnulibc
4610 if eval $compile_ok && ./gnulibc; then
4611         val="$define"
4612         echo "You are using the GNU C Library"
4613 else
4614         val="$undef"
4615         echo "You are not using the GNU C Library"
4616 fi
4617 $rm -f gnulibc*
4618 set d_gnulibc
4619 eval $setvar
4620
4621 : see if nm is to be used to determine whether a symbol is defined or not
4622 case "$usenm" in
4623 '')
4624         dflt=''
4625         case "$d_gnulibc" in
4626         "$define")
4627                 echo " "
4628                 echo "nm probably won't work on the GNU C Library." >&4
4629                 dflt=n
4630                 ;;
4631         esac
4632         case "$dflt" in
4633         '') 
4634                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4635                         echo " "
4636                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4637                         echo "'nm' won't be sufficient on this sytem." >&4
4638                         dflt=n
4639                 fi
4640                 ;;
4641         esac
4642         case "$dflt" in
4643         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4644                 if $test $dflt -gt 20; then
4645                         dflt=y
4646                 else
4647                         dflt=n
4648                 fi
4649                 ;;
4650         esac
4651         ;;
4652 *)
4653         case "$usenm" in
4654         true|$define) dflt=y;;
4655         *) dflt=n;;
4656         esac
4657         ;;
4658 esac
4659 $cat <<EOM
4660
4661 I can use $nm to extract the symbols from your C libraries. This
4662 is a time consuming task which may generate huge output on the disk (up
4663 to 3 megabytes) but that should make the symbols extraction faster. The
4664 alternative is to skip the 'nm' extraction part and to compile a small
4665 test program instead to determine whether each symbol is present. If
4666 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4667 this may be the best solution.
4668
4669 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4670
4671 EOM
4672 rp="Shall I use $nm to extract C symbols from the libraries?"
4673 . ./myread
4674 case "$ans" in
4675 [Nn]*) usenm=false;;
4676 *) usenm=true;;
4677 esac
4678
4679 runnm=$usenm
4680 case "$reuseval" in
4681 true) runnm=false;;
4682 esac
4683
4684 : nm options which may be necessary
4685 case "$nm_opt" in
4686 '') if $test -f /mach_boot; then
4687                 nm_opt=''       # Mach
4688         elif $test -d /usr/ccs/lib; then
4689                 nm_opt='-p'     # Solaris (and SunOS?)
4690         elif $test -f /dgux; then
4691                 nm_opt='-p'     # DG-UX
4692         elif $test -f /lib64/rld; then
4693                 nm_opt='-p'     # 64-bit Irix
4694         else
4695                 nm_opt=''
4696         fi;;
4697 esac
4698
4699 : nm options which may be necessary for shared libraries but illegal
4700 : for archive libraries.  Thank you, Linux.
4701 case "$nm_so_opt" in
4702 '')     case "$myuname" in
4703         *linux*)
4704                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4705                         nm_so_opt='--dynamic'
4706                 fi
4707                 ;;
4708         esac
4709         ;;
4710 esac
4711
4712 case "$runnm" in
4713 true)
4714 : get list of predefined functions in a handy place
4715 echo " "
4716 case "$libc" in
4717 '') libc=unknown
4718         case "$libs" in
4719         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4720         esac
4721         ;;
4722 esac
4723 libnames='';
4724 case "$libs" in
4725 '') ;;
4726 *)  for thislib in $libs; do
4727         case "$thislib" in
4728         -lc|-lc_s)
4729                 : Handle C library specially below.
4730                 ;;
4731         -l*)
4732                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4733                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4734                         :
4735                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4736                         :
4737                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4738                         :
4739                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4740                         :
4741                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4742                         :
4743                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4744                         :
4745                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4746                         :
4747                 else
4748                         try=''
4749                 fi
4750                 libnames="$libnames $try"
4751                 ;;
4752         *) libnames="$libnames $thislib" ;;
4753         esac
4754         done
4755         ;;
4756 esac
4757 xxx=normal
4758 case "$libc" in
4759 unknown)
4760         set /lib/libc.$so
4761         for xxx in $libpth; do
4762                 $test -r $1 || set $xxx/libc.$so
4763                 : The messy sed command sorts on library version numbers.
4764                 $test -r $1 || \
4765                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4766                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4767                                 h
4768                                 s/[0-9][0-9]*/0000&/g
4769                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4770                                 G
4771                                 s/\n/ /' | \
4772                          sort | $sed -e 's/^.* //'`
4773                 eval set \$$#
4774         done
4775         $test -r $1 || set /usr/ccs/lib/libc.$so
4776         $test -r $1 || set /lib/libsys_s$_a
4777         ;;
4778 *)
4779         set blurfl
4780         ;;
4781 esac
4782 if $test -r "$1"; then
4783         echo "Your (shared) C library seems to be in $1."
4784         libc="$1"
4785 elif $test -r /lib/libc && $test -r /lib/clib; then
4786         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4787         xxx=apollo
4788         libc='/lib/clib /lib/libc'
4789         if $test -r /lib/syslib; then
4790                 echo "(Your math library is in /lib/syslib.)"
4791                 libc="$libc /lib/syslib"
4792         fi
4793 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4794         echo "Your C library seems to be in $libc, as you said before."
4795 elif $test -r $incpath/usr/lib/libc$_a; then
4796         libc=$incpath/usr/lib/libc$_a;
4797         echo "Your C library seems to be in $libc.  That's fine."
4798 elif $test -r /lib/libc$_a; then
4799         libc=/lib/libc$_a;
4800         echo "Your C library seems to be in $libc.  You're normal."
4801 else
4802         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4803                 :
4804         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4805                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4806         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4807                 :
4808         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4809                 :
4810         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4811                 :
4812         else
4813                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4814         fi
4815         if $test -r "$tans"; then
4816                 echo "Your C library seems to be in $tans, of all places."
4817                 libc=$tans
4818         else
4819                 libc='blurfl'
4820         fi
4821 fi
4822 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4823         dflt="$libc"
4824         cat <<EOM
4825
4826 If the guess above is wrong (which it might be if you're using a strange
4827 compiler, or your machine supports multiple models), you can override it here.
4828
4829 EOM
4830 else
4831         dflt=''
4832         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4833         cat >&4 <<EOM
4834 I can't seem to find your C library.  I've looked in the following places:
4835
4836 EOM
4837         $sed 's/^/      /' libpath
4838         cat <<EOM
4839
4840 None of these seems to contain your C library. I need to get its name...
4841
4842 EOM
4843 fi
4844 fn=f
4845 rp='Where is your C library?'
4846 . ./getfile
4847 libc="$ans"
4848
4849 echo " "
4850 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4851 set X `cat libnames`
4852 shift
4853 xxx=files
4854 case $# in 1) xxx=file; esac
4855 echo "Extracting names from the following $xxx for later perusal:" >&4
4856 echo " "
4857 $sed 's/^/      /' libnames >&4
4858 echo " "
4859 $echo $n "This may take a while...$c" >&4
4860
4861 for file in $*; do
4862         case $file in
4863         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4864         *) $nm $nm_opt $file 2>/dev/null;;
4865         esac
4866 done >libc.tmp
4867
4868 $echo $n ".$c"
4869 $grep fprintf libc.tmp > libc.ptf
4870 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4871 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4872 xxx='[ADTSIW]'
4873 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4874         eval $xscan;\
4875         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4876                 eval $xrun
4877 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4878         eval $xscan;\
4879         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4880                 eval $xrun
4881 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4882         eval $xscan;\
4883         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4884                 eval $xrun
4885 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4886         eval $xscan;\
4887         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4888                 eval $xrun
4889 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4890         eval $xscan;\
4891         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4892                 eval $xrun
4893 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4894         eval $xscan;\
4895         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4896                 eval $xrun
4897 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4898                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4899         eval $xscan;\
4900         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4901                 eval $xrun
4902 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4903         eval $xscan;\
4904         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4905                 eval $xrun
4906 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4907         eval $xscan;\
4908         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4909                 eval $xrun
4910 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4911         eval $xscan;\
4912         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4913                 eval $xrun
4914 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4915         eval $xscan;\
4916         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4917                 eval $xrun
4918 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4919         eval $xscan;\
4920         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4921                 eval $xrun
4922 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4923         eval $xscan;\
4924         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4925                 eval $xrun
4926 elif com="sed -n -e 's/^__.*//' -e 's/[       ]*D[    ]*[0-9]*.*//p'";\
4927         eval $xscan;\
4928         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4929                 eval $xrun
4930 else
4931         $nm -p $* 2>/dev/null >libc.tmp
4932         $grep fprintf libc.tmp > libc.ptf
4933         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4934                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4935         then
4936                 nm_opt='-p'
4937                 eval $xrun
4938         else
4939                 echo " "
4940                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4941                 com=''
4942                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4943                         for thisname in $libnames $libc; do
4944                                 $ar t $thisname >>libc.tmp
4945                         done
4946                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4947                         echo "Ok." >&4
4948                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4949                         # Repeat libc to extract forwarders to DLL entries too
4950                         for thisname in $libnames $libc; do
4951                                 $ar tv $thisname >>libc.tmp
4952                                 # Revision 50 of EMX has bug in $ar.
4953                                 # it will not extract forwarders to DLL entries
4954                                 # Use emximp which will extract exactly them.
4955                                 emximp -o tmp.imp $thisname \
4956                                     2>/dev/null && \
4957                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4958                                     < tmp.imp >>libc.tmp
4959                                 $rm tmp.imp
4960                         done
4961                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
4962                         echo "Ok." >&4
4963                 else
4964                         echo "$ar didn't seem to work right." >&4
4965                         echo "Maybe this is a Cray...trying bld instead..." >&4
4966                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
4967                         then
4968                                 for thisname in $libnames; do
4969                                         bld t $libnames | \
4970                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
4971                                         $ar t $thisname >>libc.tmp
4972                                 done
4973                                 echo "Ok." >&4
4974                         else
4975                                 echo "That didn't work either.  Giving up." >&4
4976                                 exit 1
4977                         fi
4978                 fi
4979         fi
4980 fi
4981 nm_extract="$com"
4982 if $test -f /lib/syscalls.exp; then
4983         echo " "
4984         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
4985         $sed -n 's/^\([^        ]*\)[   ]*syscall[0-9]*$/\1/p' /lib/syscalls.exp >>libc.list
4986 fi
4987 ;;
4988 esac
4989 $rm -f libnames libpath
4990
4991 : see if dld is available
4992 set dld.h i_dld
4993 eval $inhdr
4994
4995 : is a C symbol defined?
4996 csym='tlook=$1;
4997 case "$3" in
4998 -v) tf=libc.tmp; tc=""; tdc="";;
4999 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
5000 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
5001 esac;
5002 tx=yes;
5003 case "$reuseval-$4" in
5004 true-) ;;
5005 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
5006 esac;
5007 case "$tx" in
5008 yes)
5009         case "$runnm" in
5010         true)
5011                 if $contains $tlook $tf >/dev/null 2>&1;
5012                 then tval=true;
5013                 else tval=false;
5014                 fi;;
5015         *)
5016                 echo "int main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
5017                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
5018                 then tval=true;
5019                 else tval=false;
5020                 fi;
5021                 $rm -f t t.c;;
5022         esac;;
5023 *)
5024         case "$tval" in
5025         $define) tval=true;;
5026         *) tval=false;;
5027         esac;;
5028 esac;
5029 eval "$2=$tval"'
5030
5031 : define an is-in-libc? function
5032 inlibc='echo " "; td=$define; tu=$undef;
5033 sym=$1; var=$2; eval "was=\$$2";
5034 tx=yes;
5035 case "$reuseval$was" in
5036 true) ;;
5037 true*) tx=no;;
5038 esac;
5039 case "$tx" in
5040 yes)
5041         set $sym tres -f;
5042         eval $csym;
5043         case "$tres" in
5044         true)
5045                 echo "$sym() found." >&4;
5046                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
5047         *)
5048                 echo "$sym() NOT found." >&4;
5049                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
5050         esac;;
5051 *)
5052         case "$was" in
5053         $define) echo "$sym() found." >&4;;
5054         *) echo "$sym() NOT found." >&4;;
5055         esac;;
5056 esac'
5057
5058 : see if dlopen exists
5059 xxx_runnm="$runnm"
5060 runnm=false
5061 set dlopen d_dlopen
5062 eval $inlibc
5063 runnm="$xxx_runnm"
5064
5065 : determine which dynamic loading, if any, to compile in
5066 echo " "
5067 dldir="ext/DynaLoader"
5068 case "$usedl" in
5069 $define|y|true)
5070         dflt='y'
5071         usedl="$define"
5072         ;;
5073 $undef|n|false)
5074         dflt='n'
5075         usedl="$undef"
5076         ;;
5077 *) 
5078         dflt='n'
5079         case "$d_dlopen" in
5080             $define) dflt='y' ;;
5081         esac
5082         case "$i_dld" in
5083             $define) dflt='y' ;;
5084         esac
5085         : Does a dl_xxx.xs file exist for this operating system
5086         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
5087         ;;
5088 esac
5089 rp="Do you wish to use dynamic loading?"
5090 . ./myread
5091 usedl="$ans"
5092 case "$ans" in
5093 y*) usedl="$define"
5094         case "$dlsrc" in
5095         '')
5096                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
5097                         dflt="$dldir/dl_${osname}.xs"
5098                 elif $test "$d_dlopen" = "$define" ; then
5099                         dflt="$dldir/dl_dlopen.xs"
5100                 elif $test "$i_dld" = "$define" ; then
5101                         dflt="$dldir/dl_dld.xs"
5102                 else
5103                         dflt=''
5104                 fi
5105                 ;;
5106         *)      dflt="$dldir/$dlsrc"
5107                 ;;
5108         esac
5109     echo "The following dynamic loading files are available:"
5110         : Can not go over to $dldir because getfile has path hard-coded in.
5111         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
5112         rp="Source file to use for dynamic loading"
5113         fn="fne"
5114         # XXX This getfile call will fail the existence check if you try 
5115         # building away from $src (this is not supported yet).
5116         . ./getfile
5117         usedl="$define"
5118         : emulate basename
5119         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
5120
5121         $cat << EOM
5122
5123 Some systems may require passing special flags to $cc -c to
5124 compile modules that will be used to create a shared library.
5125 To use no flags, say "none".
5126
5127 EOM
5128     case "$cccdlflags" in
5129     '') case "$gccversion" in
5130                 '') case "$osname" in
5131                         hpux)   dflt='+z' ;;
5132                         next)   dflt='none' ;;
5133                         irix*)  dflt='-KPIC' ;;
5134                         svr4*|esix*|solaris) dflt='-KPIC' ;;
5135                         sunos)  dflt='-pic' ;;
5136                         *)      dflt='none' ;;
5137                     esac
5138                         ;;
5139                 *)  case "$osname" in
5140                         svr4*|esix*|solaris) dflt='-fPIC' ;;
5141                         *)      dflt='-fpic' ;;
5142                     esac ;;
5143             esac ;;
5144         ' ') dflt='none' ;;
5145     *)  dflt="$cccdlflags" ;;
5146     esac
5147     rp="Any special flags to pass to $cc -c to compile shared library modules?"
5148     . ./myread
5149     case "$ans" in
5150     none) cccdlflags=' ' ;;
5151     *) cccdlflags="$ans" ;;
5152     esac
5153
5154     cat << EOM
5155
5156 Some systems use ld to create libraries that can be dynamically loaded,
5157 while other systems (such as those using ELF) use $cc.
5158
5159 EOM
5160         case "$ld" in
5161         '')     $cat >try.c <<'EOM'
5162 /* Test for whether ELF binaries are produced */
5163 #include <fcntl.h>
5164 #include <stdlib.h>
5165 int main() {
5166         char b[4];
5167         int i = open("a.out",O_RDONLY);
5168         if(i == -1) 
5169                 exit(1); /* fail */
5170         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
5171                 exit(0); /* succeed (yes, it's ELF) */
5172         else
5173                 exit(1); /* fail */
5174 }
5175 EOM
5176                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5177                         cat <<EOM
5178 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5179 EOM
5180                         dflt="$cc"
5181                 else
5182                         echo "I'll use ld to build dynamic libraries."
5183                         dflt='ld'
5184                 fi
5185                 rm -f try.c a.out
5186                 ;;
5187         *)      dflt="$ld"
5188                 ;;
5189         esac
5190
5191     rp="What command should be used to create dynamic libraries?"
5192     . ./myread
5193         ld="$ans"
5194
5195     cat << EOM
5196
5197 Some systems may require passing special flags to $ld to create a
5198 library that can be dynamically loaded.  If your ld flags include
5199 -L/other/path options to locate libraries outside your loader's normal
5200 search path, you may need to specify those -L options here as well.  To
5201 use no flags, say "none".
5202
5203 EOM
5204     case "$lddlflags" in
5205     '') case "$osname" in
5206                         beos) dflt='-nostart' ;;
5207                         hpux)  dflt='-b' ;;
5208                         linux|irix*)    dflt='-shared' ;;
5209                         next)  dflt='none' ;;
5210                         solaris) dflt='-G' ;;
5211                         sunos) dflt='-assert nodefinitions' ;;
5212                         svr4*|esix*) dflt="-G $ldflags" ;;
5213                 *)     dflt='none' ;;
5214                         esac
5215                         ;;
5216     *) dflt="$lddlflags" ;;
5217     esac
5218
5219         : Try to guess additional flags to pick up local libraries.
5220         : Be careful not to append to a plain 'none'
5221         case "$dflt" in
5222         none) dflt='' ;;
5223         esac
5224         for thisflag in $ldflags; do
5225                 case "$thisflag" in
5226                 -L*)
5227                         case " $dflt " in
5228                         *" $thisflag "*) ;;
5229                         *) dflt="$dflt $thisflag" ;;
5230                         esac
5231                         ;;
5232                 esac
5233         done
5234
5235         case "$dflt" in
5236         ''|' ') dflt='none' ;;
5237         esac
5238
5239     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5240     . ./myread
5241     case "$ans" in
5242     none) lddlflags=' ' ;;
5243     *) lddlflags="$ans" ;;
5244     esac
5245
5246         cat <<EOM
5247
5248 Some systems may require passing special flags to $cc to indicate that
5249 the resulting executable will use dynamic linking.  To use no flags,
5250 say "none".
5251
5252 EOM
5253     case "$ccdlflags" in
5254     '') case "$osname" in
5255                 hpux)   dflt='-Wl,-E' ;;
5256                 linux)  dflt='-rdynamic' ;;
5257                 next)   dflt='none' ;;
5258                 sunos)  dflt='none' ;;
5259                 *)      dflt='none' ;;
5260             esac ;;
5261     ' ')  dflt='none' ;;
5262     *)  dflt="$ccdlflags" ;;
5263     esac
5264     rp="Any special flags to pass to $cc to use dynamic loading?"
5265     . ./myread
5266     case "$ans" in
5267     none) ccdlflags=' ' ;;
5268     *) ccdlflags="$ans" ;;
5269     esac
5270     ;;
5271 *)  usedl="$undef"
5272         ld='ld'
5273     dlsrc='dl_none.xs'
5274     lddlflags=''
5275     ccdlflags=''
5276     ;;
5277 esac
5278
5279 also=''
5280 case "$usedl" in
5281 $undef)
5282         # No dynamic loading being used, so don't bother even to prompt.
5283         useshrplib='false'
5284         ;;
5285 *)      case "$useshrplib" in
5286         '')     case "$osname" in
5287                 svr4*|dgux|dynixptx|esix|powerux|beos)
5288                         dflt=y
5289                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5290                         ;;
5291                 next*)
5292                         case "$osvers" in
5293                         4*)     dflt=y
5294                                 also='Building a shared libperl is needed for MAB support.'
5295                                 ;;
5296                         *)      dflt=n
5297                                 ;;
5298                         esac
5299                         ;;
5300                 *)      dflt=n
5301                         ;;
5302                 esac
5303                 ;;
5304         $define|true|[Yy]*)
5305                 dflt=y
5306                 ;;
5307         *)      dflt=n
5308                 ;;
5309         esac
5310         $cat << EOM
5311
5312 The perl executable is normally obtained by linking perlmain.c with
5313 libperl${_a}, any static extensions (usually just DynaLoader), and
5314 any other libraries needed on this system (such as -lm, etc.).  Since
5315 your system supports dynamic loading, it is probably possible to build
5316 a shared libperl.$so.  If you will have more than one executable linked
5317 to libperl.$so, this will significantly reduce the size of each
5318 executable, but it may have a noticeable affect on performance.  The
5319 default is probably sensible for your system.
5320 $also
5321
5322 EOM
5323         rp="Build a shared libperl.$so (y/n)"
5324         . ./myread
5325         case "$ans" in
5326         true|$define|[Yy]*)
5327                 useshrplib='true'
5328                 # Why does next4 have to be so different?
5329                 case "${osname}${osvers}" in
5330                 next4*|rhapsody*)
5331                         xxx='DYLD_LIBRARY_PATH' ;;
5332                 os2*)   xxx='' ;; # Nothing special needed.
5333                 beos*)  xxx='' ;;
5334                 *)              xxx='LD_LIBRARY_PATH' ;;
5335                 esac
5336                 ;;
5337         *)      useshrplib='false' ;;
5338         esac
5339         ;;
5340 esac
5341
5342 case "$useshrplib" in
5343 true)
5344         case "$libperl" in
5345         '')
5346                 # Figure out a good name for libperl.so.  Since it gets stored in
5347                 # a version-specific architecture-dependent library, the version
5348                 # number isn't really that important, except for making cc/ld happy.
5349                 #
5350                 # A name such as libperl.so.3.1
5351                 majmin="libperl.$so.$patchlevel.$subversion"
5352                 # A name such as libperl.so.301
5353                 majonly=`echo $patchlevel $subversion |
5354                         $awk '{printf "%d%02d", $1, $2}'`
5355                 majonly=libperl.$so.$majonly
5356                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5357                 # rely on figuring it out from the naming of libc.
5358                 case "${osname}${osvers}" in
5359                 next4*)
5360                         dflt=libperl.5.$so
5361                         # XXX How handle the --version stuff for MAB?
5362                         ;;
5363                 linux*)  # ld won't link with a bare -lperl otherwise.
5364                         dflt=libperl.$so
5365                         ;;
5366                 *)      # Try to guess based on whether libc has major.minor.
5367                         case "$libc" in
5368                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5369                         *libc.$so.[0-9]*) dflt=$majonly ;;
5370                         *)      dflt=libperl.$so ;;
5371                         esac
5372                         ;;
5373                 esac
5374                 ;;
5375         *)      dflt=$libperl
5376                 ;;
5377         esac
5378         cat << EOM
5379
5380 I need to select a good name for the shared libperl.  If your system uses
5381 library names with major and minor numbers, then you might want something
5382 like $majmin.  Alternatively, if your system uses a single version
5383 number for shared libraries, then you might want to use $majonly.
5384 Or, your system might be quite happy with a simple libperl.$so.
5385
5386 Since the shared libperl will get installed into a version-specific
5387 architecture-dependent directory, the version number of the shared perl
5388 library probably isn't important, so the default should be o.k.
5389
5390 EOM
5391         rp='What name do you want to give to the shared libperl?'
5392         . ./myread
5393         libperl=$ans
5394         echo "Ok, I'll use $libperl"
5395         ;;
5396 *)
5397         libperl="libperl${_a}"
5398         ;;
5399 esac
5400
5401 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5402 case "$shrpdir" in
5403 '') ;;
5404 *)      $cat >&4 <<EOM
5405 WARNING:  Use of the shrpdir variable for the installation location of
5406 the shared $libperl is not supported.  It was never documented and
5407 will not work in this version.  Let me (perlbug@perl.com)
5408 know of any problems this may cause.
5409
5410 EOM
5411         case "$shrpdir" in
5412         "$archlibexp/CORE")
5413                 $cat >&4 <<EOM
5414 But your current setting of $shrpdir is
5415 the default anyway, so it's harmless.
5416 EOM
5417                 ;;
5418         *)
5419                 $cat >&4 <<EOM
5420 Further, your current attempted setting of $shrpdir
5421 conflicts with the value of $archlibexp/CORE
5422 that installperl will use.
5423 EOM
5424                 ;;
5425         esac
5426         ;;
5427 esac
5428
5429 # How will the perl executable find the installed shared $libperl?
5430 # Add $xxx to ccdlflags.
5431 # If we can't figure out a command-line option, use $shrpenv to
5432 # set env LD_RUN_PATH.  The main perl makefile uses this.
5433 shrpdir=$archlibexp/CORE
5434 xxx=''
5435 tmp_shrpenv=''
5436 if "$useshrplib"; then
5437     case "$osname" in 
5438         aix)
5439                 # We'll set it in Makefile.SH...
5440                 ;;
5441         solaris|netbsd)
5442                 xxx="-R $shrpdir"
5443                 ;;
5444         freebsd)
5445                 xxx="-Wl,-R$shrpdir"
5446                 ;;
5447         linux|irix*|dec_osf)
5448                 xxx="-Wl,-rpath,$shrpdir"
5449                 ;;
5450         next)
5451                 # next doesn't like the default...
5452                 ;;
5453         beos)
5454                 # beos doesn't like the default, either.
5455                 ;;
5456         hpux*)
5457                 # hpux doesn't like the default, either.
5458                 tmp_shrpenv="env LDOPTS=\"+s +b${shrpdir}\""
5459                 ;;
5460         *)
5461                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5462                 ;;
5463         esac
5464         case "$xxx" in
5465         '') ;;
5466         *)      
5467                 # Only add $xxx if it isn't already in ccdlflags.
5468                 case " $ccdlflags " in
5469                 *" $xxx "*)     ;;
5470                 *)      ccdlflags="$ccdlflags $xxx"
5471                         cat <<EOM >&4
5472
5473 Adding $xxx to the flags
5474 passed to $ld so that the perl executable will find the 
5475 installed shared $libperl.
5476
5477 EOM
5478                         ;;
5479                 esac
5480                 ;;
5481         esac
5482 fi
5483 # Respect a hint or command-line value.
5484 case "$shrpenv" in
5485 '') shrpenv="$tmp_shrpenv" ;;
5486 esac
5487
5488 : determine where manual pages go
5489 set man1dir man1dir none
5490 eval $prefixit
5491 $cat <<EOM
5492
5493 $spackage has manual pages available in source form.
5494 EOM
5495 case "$nroff" in
5496 nroff)
5497         echo "However, you don't have nroff, so they're probably useless to you."
5498         case "$man1dir" in
5499         '') man1dir="none";;
5500         esac;;
5501 esac
5502 echo "If you don't want the manual sources installed, answer 'none'."
5503 case "$man1dir" in
5504 ' ') dflt=none
5505         ;;
5506 '')
5507         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5508         lookpath="$lookpath $prefixexp/man/p_man/man1"
5509         lookpath="$lookpath $prefixexp/man/u_man/man1"
5510         lookpath="$lookpath $prefixexp/man/man.1"
5511         case "$sysman" in
5512         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5513         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5514         esac
5515         set dflt
5516         eval $prefixup
5517         ;;
5518 *)  dflt="$man1dir"
5519         ;;
5520 esac
5521 echo " "
5522 fn=dn+~
5523 rp="Where do the main $spackage manual pages (source) go?"
5524 . ./getfile
5525 if $test "X$man1direxp" != "X$ansexp"; then
5526         installman1dir=''
5527 fi
5528 man1dir="$ans"
5529 man1direxp="$ansexp"
5530 case "$man1dir" in
5531 '') man1dir=' '
5532         installman1dir='';;
5533 esac
5534 if $afs; then
5535         $cat <<EOM
5536
5537 Since you are running AFS, I need to distinguish the directory in which
5538 manual pages reside from the directory in which they are installed (and from
5539 which they are presumably copied to the former directory by occult means).
5540
5541 EOM
5542         case "$installman1dir" in
5543         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5544         *) dflt="$installman1dir";;
5545         esac
5546         fn=de~
5547         rp='Where will man pages be installed?'
5548         . ./getfile
5549         installman1dir="$ans"
5550 else
5551         installman1dir="$man1direxp"
5552 fi
5553
5554 : What suffix to use on installed man pages
5555
5556 case "$man1dir" in
5557 ' ')
5558         man1ext='0'
5559         ;;
5560 *)
5561         rp="What suffix should be used for the main $spackage man pages?"
5562         case "$man1ext" in
5563         '')     case "$man1dir" in
5564                 *1)  dflt=1 ;;
5565                 *1p) dflt=1p ;;
5566                 *1pm) dflt=1pm ;;
5567                 *l) dflt=l;;
5568                 *n) dflt=n;;
5569                 *o) dflt=o;;
5570                 *p) dflt=p;;
5571                 *C) dflt=C;;
5572                 *L) dflt=L;;
5573                 *L1) dflt=L1;;
5574                 *) dflt=1;;
5575                 esac
5576                 ;;
5577         *)      dflt="$man1ext";;
5578         esac
5579         . ./myread
5580         man1ext="$ans"
5581         ;;
5582 esac
5583
5584 : see if we can have long filenames
5585 echo " "
5586 rmlist="$rmlist /tmp/cf$$"
5587 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5588 first=123456789abcdef
5589 second=/tmp/cf$$/$first
5590 $rm -f $first $second
5591 if (echo hi >$first) 2>/dev/null; then
5592         if $test -f 123456789abcde; then
5593                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5594                 val="$undef"
5595         else
5596                 if (echo hi >$second) 2>/dev/null; then
5597                         if $test -f /tmp/cf$$/123456789abcde; then
5598                                 $cat <<'EOM'
5599 That's peculiar... You can have filenames longer than 14 characters, but only
5600 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5601 I shall consider your system cannot support long filenames at all.
5602 EOM
5603                                 val="$undef"
5604                         else
5605                                 echo 'You can have filenames longer than 14 characters.' >&4
5606                                 val="$define"
5607                         fi
5608                 else
5609                         $cat <<'EOM'
5610 How confusing! Some of your filesystems are sane enough to allow filenames
5611 longer than 14 characters but some others like /tmp can't even think about them.
5612 So, for now on, I shall assume your kernel does not allow them at all.
5613 EOM
5614                         val="$undef"
5615                 fi
5616         fi
5617 else
5618         $cat <<'EOM'
5619 You can't have filenames longer than 14 chars.  You can't even think about them!
5620 EOM
5621         val="$undef"
5622 fi 
5623 set d_flexfnam
5624 eval $setvar
5625 $rm -rf /tmp/cf$$ 123456789abcde*
5626
5627 : determine where library module manual pages go
5628 set man3dir man3dir none
5629 eval $prefixit
5630 $cat <<EOM
5631
5632 $spackage has manual pages for many of the library modules.
5633 EOM
5634
5635 case "$nroff" in
5636 nroff)
5637         $cat <<'EOM'
5638 However, you don't have nroff, so they're probably useless to you.
5639 EOM
5640         case "$man3dir" in
5641         '') man3dir="none";;
5642         esac;;
5643 esac
5644
5645 case "$d_flexfnam" in
5646 undef)
5647         $cat <<'EOM'
5648 However, your system can't handle the long file names like File::Basename.3. 
5649 EOM
5650         case "$man3dir" in
5651         '') man3dir="none";;
5652         esac;;
5653 esac
5654
5655 echo "If you don't want the manual sources installed, answer 'none'."
5656 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5657 case "$man3dir" in
5658 '')     case "$prefix" in 
5659         *$prog*) dflt=`echo $man1dir | 
5660                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5661         *)      dflt="$privlib/man/man3" ;;
5662         esac
5663         ;;
5664 ' ') dflt=none;;
5665 *)      dflt="$man3dir" ;;
5666 esac
5667 echo " "
5668
5669 fn=dn+~
5670 rp="Where do the $package library man pages (source) go?"
5671 . ./getfile
5672 if test "X$man3direxp" != "X$ansexp"; then
5673         installman3dir=''
5674 fi
5675
5676 man3dir="$ans"
5677 man3direxp="$ansexp"
5678 case "$man3dir" in
5679 '') man3dir=' '
5680         installman3dir='';;
5681 esac
5682 if $afs; then
5683         $cat <<EOM
5684
5685 Since you are running AFS, I need to distinguish the directory in which
5686 manual pages reside from the directory in which they are installed (and from
5687 which they are presumably copied to the former directory by occult means).
5688
5689 EOM
5690         case "$installman3dir" in
5691         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5692         *) dflt="$installman3dir";;
5693         esac
5694         fn=de~
5695         rp='Where will man pages be installed?'
5696         . ./getfile
5697         installman3dir="$ans"
5698 else
5699         installman3dir="$man3direxp"
5700 fi
5701
5702 : What suffix to use on installed man pages
5703
5704 case "$man3dir" in
5705 ' ')
5706         man3ext='0'
5707         ;;
5708 *)
5709         rp="What suffix should be used for the $package library man pages?"
5710         case "$man3ext" in
5711         '')     case "$man3dir" in
5712                 *3)  dflt=3 ;;
5713                 *3p) dflt=3p ;;
5714                 *3pm) dflt=3pm ;;
5715                 *l) dflt=l;;
5716                 *n) dflt=n;;
5717                 *o) dflt=o;;
5718                 *p) dflt=p;;
5719                 *C) dflt=C;;
5720                 *L) dflt=L;;
5721                 *L3) dflt=L3;;
5722                 *) dflt=3;;
5723                 esac
5724                 ;;
5725         *)      dflt="$man3ext";;
5726         esac
5727         . ./myread
5728         man3ext="$ans"
5729         ;;
5730 esac
5731
5732 : see if we have to deal with yellow pages, now NIS.
5733 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5734         if $test -f /usr/etc/nibindd; then
5735                 echo " "
5736                 echo "I'm fairly confident you're on a NeXT."
5737                 echo " "
5738                 rp='Do you get the hosts file via NetInfo?'
5739                 dflt=y
5740                 case "$hostcat" in
5741                 nidump*) ;;
5742                 '') ;;
5743                 *) dflt=n;;
5744                 esac
5745                 . ./myread
5746                 case "$ans" in
5747                 y*) hostcat='nidump hosts .';;
5748                 *)      case "$hostcat" in
5749                         nidump*) hostcat='';;
5750                         esac
5751                         ;;
5752                 esac
5753         fi
5754         case "$hostcat" in
5755         nidump*) ;;
5756         *)
5757                 case "$hostcat" in
5758                 *ypcat*) dflt=y;;
5759                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5760                                 dflt=y
5761                         else
5762                                 dflt=n
5763                         fi;;
5764                 *) dflt=n;;
5765                 esac
5766                 echo " "
5767                 rp='Are you getting the hosts file via yellow pages?'
5768                 . ./myread
5769                 case "$ans" in
5770                 y*) hostcat='ypcat hosts';;
5771                 *) hostcat='cat /etc/hosts';;
5772                 esac
5773                 ;;
5774         esac
5775 fi
5776 case "$hostcat" in
5777 '') hostcat='cat /etc/hosts';;
5778 esac
5779 case "$groupcat" in
5780 '') groupcat='cat /etc/group';;
5781 esac
5782 case "$passcat" in
5783 '') passcat='cat /etc/passwd';;
5784 esac
5785
5786 : now get the host name
5787 echo " "
5788 echo "Figuring out host name..." >&4
5789 case "$myhostname" in
5790 '') cont=true
5791         echo 'Maybe "hostname" will work...'
5792         if tans=`sh -c hostname 2>&1` ; then
5793                 myhostname=$tans
5794                 phostname=hostname
5795                 cont=''
5796         fi
5797         ;;
5798 *) cont='';;
5799 esac
5800 if $test "$cont"; then
5801         if ./xenix; then
5802                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5803                 if tans=`cat /etc/systemid 2>&1` ; then
5804                         myhostname=$tans
5805                         phostname='cat /etc/systemid'
5806                         echo "Whadyaknow.  Xenix always was a bit strange..."
5807                         cont=''
5808                 fi
5809         elif $test -r /etc/systemid; then
5810                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5811         fi
5812 fi
5813 if $test "$cont"; then
5814         echo 'No, maybe "uuname -l" will work...'
5815         if tans=`sh -c 'uuname -l' 2>&1` ; then
5816                 myhostname=$tans
5817                 phostname='uuname -l'
5818         else
5819                 echo 'Strange.  Maybe "uname -n" will work...'
5820                 if tans=`sh -c 'uname -n' 2>&1` ; then
5821                         myhostname=$tans
5822                         phostname='uname -n'
5823                 else
5824                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5825                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5826                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5827                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5828                         else
5829                                 case "$myhostname" in
5830                                 '') echo "Does this machine have an identity crisis or something?"
5831                                         phostname='';;
5832                                 *)
5833                                         echo "Well, you said $myhostname before..."
5834                                         phostname='echo $myhostname';;
5835                                 esac
5836                         fi
5837                 fi
5838         fi
5839 fi
5840 : you do not want to know about this
5841 set $myhostname
5842 myhostname=$1
5843
5844 : verify guess
5845 if $test "$myhostname" ; then
5846         dflt=y
5847         rp='Your host name appears to be "'$myhostname'".'" Right?"
5848         . ./myread
5849         case "$ans" in
5850         y*) ;;
5851         *) myhostname='';;
5852         esac
5853 fi
5854
5855 : bad guess or no guess
5856 while $test "X$myhostname" = X ; do
5857         dflt=''
5858         rp="Please type the (one word) name of your host:"
5859         . ./myread
5860         myhostname="$ans"
5861 done
5862
5863 : translate upper to lower if necessary
5864 case "$myhostname" in
5865 *[A-Z]*)
5866         echo "(Normalizing case in your host name)"
5867         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5868         ;;
5869 esac
5870
5871 case "$myhostname" in
5872 *.*)
5873         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5874         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5875         echo "(Trimming domain name from host name--host name is now $myhostname)"
5876         ;;
5877 *) case "$mydomain" in
5878         '')
5879                 {
5880                         test "X$hostcat" = "Xypcat hosts" &&
5881                         ypmatch "$myhostname" hosts 2>/dev/null |\
5882                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5883                         $test -s hosts
5884                 } || {
5885                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5886                                         /[       ]$myhostname[  . ]/p" > hosts
5887                 }
5888                 tmp_re="[       . ]"
5889                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5890                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5891                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5892                         hosts | $sort | $uniq | \
5893                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5894                 case `$echo X$dflt` in
5895                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5896                         dflt=.
5897                         ;;
5898                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5899                         ;;
5900                 esac
5901                 case "$dflt" in
5902                 .)
5903                         tans=`./loc resolv.conf X /etc /usr/etc`
5904                         if $test -f "$tans"; then
5905                                 echo "(Attempting domain name extraction from $tans)"
5906                                 dflt=.`$sed -n -e 's/   / /g' \
5907                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5908                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5909                                 case "$dflt" in
5910                                 .) dflt=.`$sed -n -e 's/        / /g' \
5911                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5912                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5913                                         ;;
5914                                 esac
5915                         fi
5916                         ;;
5917                 esac
5918                 case "$dflt" in
5919                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5920                         dflt=.`sh -c domainname 2>/dev/null`
5921                         case "$dflt" in
5922                         '') dflt='.';;
5923                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5924                         esac
5925                         ;;
5926                 esac
5927                 case "$dflt" in
5928                 .) echo "(Lost all hope -- silly guess then)"
5929                         dflt='.uucp'
5930                         ;;
5931                 esac
5932                 $rm -f hosts
5933                 ;;
5934         *) dflt="$mydomain";;
5935         esac;;
5936 esac
5937 echo " "
5938 rp="What is your domain name?"
5939 . ./myread
5940 tans="$ans"
5941 case "$ans" in
5942 '') ;;
5943 .*) ;;
5944 *) tans=".$tans";;
5945 esac
5946 mydomain="$tans"
5947
5948 : translate upper to lower if necessary
5949 case "$mydomain" in
5950 *[A-Z]*)
5951         echo "(Normalizing case in your domain name)"
5952         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5953         ;;
5954 esac
5955
5956 : a little sanity check here
5957 case "$phostname" in
5958 '') ;;
5959 *)
5960         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
5961         $myhostname$mydomain|$myhostname) ;;
5962         *)
5963                 case "$phostname" in
5964                 sed*)
5965                         echo "(That doesn't agree with your whoami.h file, by the way.)"
5966                         ;;
5967                 *)
5968                         echo "(That doesn't agree with your $phostname command, by the way.)"
5969                         ;;
5970                 esac
5971         ;;
5972         esac
5973         ;;
5974 esac
5975
5976 $cat <<EOM
5977
5978 I need to get your e-mail address in Internet format if possible, i.e.
5979 something like user@host.domain. Please answer accurately since I have
5980 no easy means to double check it. The default value provided below
5981 is most probably close to the reality but may not be valid from outside
5982 your organization...
5983
5984 EOM
5985 cont=x
5986 while test "$cont"; do
5987         case "$cf_email" in
5988         '') dflt="$cf_by@$myhostname$mydomain";;
5989         *) dflt="$cf_email";;
5990         esac
5991         rp='What is your e-mail address?'
5992         . ./myread
5993         cf_email="$ans"
5994         case "$cf_email" in
5995         *@*.*) cont='' ;;
5996         *)
5997                 rp='Address does not look like an Internet one.  Use it anyway?'
5998                 case "$fastread" in
5999                 yes) dflt=y ;;
6000                 *) dflt=n ;;
6001                 esac
6002                 . ./myread
6003                 case "$ans" in
6004                 y*) cont='' ;;
6005                 *) echo " " ;;
6006                 esac
6007                 ;;
6008         esac
6009 done
6010
6011 $cat <<EOM
6012
6013 If you or somebody else will be maintaining perl at your site, please
6014 fill in the correct e-mail address here so that they may be contacted
6015 if necessary. Currently, the "perlbug" program included with perl
6016 will send mail to this address in addition to perlbug@perl.com. You may
6017 enter "none" for no administrator.
6018
6019 EOM
6020 case "$perladmin" in
6021 '') dflt="$cf_email";;
6022 *) dflt="$perladmin";;
6023 esac
6024 rp='Perl administrator e-mail address'
6025 . ./myread
6026 perladmin="$ans"
6027
6028 : figure out how to guarantee perl startup
6029 case "$startperl" in
6030 '')
6031         case "$sharpbang" in
6032         *!)
6033                 $cat <<EOH
6034
6035 I can use the #! construct to start perl on your system. This will
6036 make startup of perl scripts faster, but may cause problems if you
6037 want to share those scripts and perl is not in a standard place
6038 ($binexp/perl) on all your platforms. The alternative is to force
6039 a shell by starting the script with a single ':' character.
6040
6041 EOH
6042                 dflt="$binexp/perl"
6043                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
6044                 . ./myread
6045                 case "$ans" in
6046                 none)   startperl=": # use perl";;
6047                 *)      startperl="#!$ans"
6048                         if $test 30 -lt `echo "$ans" | wc -c`; then
6049                                 $cat >&4 <<EOM
6050
6051 WARNING:  Some systems limit the #! command to 32 characters.
6052 If you experience difficulty running Perl scripts with #!, try
6053 installing Perl in a directory with a shorter pathname.
6054
6055 EOM
6056                         fi ;;
6057                 esac
6058                 ;;
6059         *) startperl=": # use perl"
6060                 ;;
6061         esac
6062         ;;
6063 esac
6064 echo "I'll use $startperl to start perl scripts."
6065
6066 : figure best path for perl in scripts
6067 case "$perlpath" in
6068 '')
6069         perlpath="$binexp/perl"
6070         case "$startperl" in
6071         *!*) ;;
6072         *)
6073                 $cat <<EOH
6074
6075 I will use the "eval 'exec'" idiom to start Perl on your system.
6076 I can use the full path of your Perl binary for this purpose, but
6077 doing so may cause problems if you want to share those scripts and
6078 Perl is not always in a standard place ($binexp/perl).
6079
6080 EOH
6081                 dflt="$binexp/perl"
6082                 rp="What path shall I use in \"eval 'exec'\"?"
6083                 . ./myread
6084                 perlpath="$ans"
6085                 ;;
6086         esac
6087         ;;
6088 esac
6089 case "$startperl" in
6090 *!*)    ;;
6091 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
6092 esac
6093
6094 : determine where public executable scripts go
6095 set scriptdir scriptdir
6096 eval $prefixit
6097 case "$scriptdir" in
6098 '')
6099         dflt="$bin"
6100         : guess some guesses
6101         $test -d /usr/share/scripts && dflt=/usr/share/scripts
6102         $test -d /usr/share/bin && dflt=/usr/share/bin
6103         $test -d /usr/local/script && dflt=/usr/local/script
6104         $test -d $prefixexp/script && dflt=$prefixexp/script
6105         set dflt
6106         eval $prefixup
6107         ;;
6108 *)  dflt="$scriptdir"
6109         ;;
6110 esac
6111 $cat <<EOM
6112  
6113 Some installations have a separate directory just for executable scripts so
6114 that they can mount it across multiple architectures but keep the scripts in
6115 one spot.  You might, for example, have a subdirectory of /usr/share for this.
6116 Or you might just lump your scripts in with all your other executables.
6117  
6118 EOM
6119 fn=d~
6120 rp='Where do you keep publicly executable scripts?'
6121 . ./getfile
6122 if $test "X$ansexp" != "X$scriptdirexp"; then
6123         installscript=''
6124 fi
6125 scriptdir="$ans"
6126 scriptdirexp="$ansexp"
6127 if $afs; then
6128         $cat <<EOM
6129
6130 Since you are running AFS, I need to distinguish the directory in which
6131 scripts reside from the directory in which they are installed (and from
6132 which they are presumably copied to the former directory by occult means).
6133
6134 EOM
6135         case "$installscript" in
6136         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
6137         *) dflt="$installscript";;
6138         esac
6139         fn=de~
6140         rp='Where will public scripts be installed?'
6141         . ./getfile
6142         installscript="$ans"
6143 else
6144         installscript="$scriptdirexp"
6145 fi
6146
6147 : determine where site specific libraries go.
6148 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
6149 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
6150 case "$prefix" in
6151 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
6152 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
6153 esac
6154 eval $prefixit
6155 $cat <<EOM
6156
6157 The installation process will also create a directory for
6158 site-specific extensions and modules.  Some users find it convenient
6159 to place all site-specific files in this directory rather than in the
6160 main distribution directory.
6161
6162 EOM
6163 fn=d~+
6164 rp='Pathname for the site-specific library files?'
6165 . ./getfile
6166 if $test "X$sitelibexp" != "X$ansexp"; then
6167         installsitelib=''
6168 fi
6169 sitelib="$ans"
6170 sitelibexp="$ansexp"
6171 if $afs; then
6172         $cat <<EOM
6173
6174 Since you are running AFS, I need to distinguish the directory in
6175 which site-specific files reside from the directory in which they are
6176 installed (and from which they are presumably copied to the former
6177 directory by occult means).
6178
6179 EOM
6180         case "$installsitelib" in
6181         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6182         *) dflt="$installsitelib";;
6183         esac
6184         fn=de~
6185         rp='Where will site-specific files be installed?'
6186         . ./getfile
6187         installsitelib="$ans"
6188 else
6189         installsitelib="$sitelibexp"
6190 fi
6191
6192 : determine where site specific architecture-dependent libraries go.
6193 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6194 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6195 : sitelib may have an optional trailing /share.
6196 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6197 tdflt="$tdflt/$archname"
6198 set sitearch sitearch none
6199 eval $prefixit
6200 case "$sitearch" in
6201 '')     dflt="$tdflt" ;;
6202 *)      dflt="$sitearch" ;;
6203 esac
6204 $cat <<EOM
6205
6206 The installation process will also create a directory for
6207 architecture-dependent site-specific extensions and modules.
6208
6209 EOM
6210 fn=nd~+
6211 rp='Pathname for the site-specific architecture-dependent library files?'
6212 . ./getfile
6213 if $test "X$sitearchexp" != "X$ansexp"; then
6214         installsitearch=''
6215 fi
6216 sitearch="$ans"
6217 sitearchexp="$ansexp"
6218 if $afs; then
6219         $cat <<EOM
6220
6221 Since you are running AFS, I need to distinguish the directory in
6222 which site-specific architecture-dependent library files reside from
6223 the directory in which they are installed (and from which they are
6224 presumably copied to the former directory by occult means).
6225
6226 EOM
6227         case "$installsitearch" in
6228         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6229         *) dflt="$installsitearch";;
6230         esac
6231         fn=de~
6232         rp='Where will site-specific architecture-dependent files be installed?'
6233         . ./getfile
6234         installsitearch="$ans"
6235 else
6236         installsitearch="$sitearchexp"
6237 fi
6238
6239 cat <<EOM
6240
6241 Previous version of $package used the standard IO mechanisms as defined
6242 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6243 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6244 the default.  This abstraction layer can use AT&T's sfio (if you already
6245 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6246 problems with some extension modules.  Using PerlIO with stdio is safe,
6247 but it is slower than plain stdio and therefore is not the default.
6248
6249 If this doesn't make any sense to you, just accept the default 'n'.
6250 EOM
6251 case "$useperlio" in
6252 $define|true|[yY]*)     dflt='y';;
6253 *) dflt='n';;
6254 esac
6255 rp='Use the experimental PerlIO abstraction layer?'
6256 . ./myread
6257 case "$ans" in
6258 y|Y) 
6259         val="$define"
6260         ;;     
6261 *)      
6262         echo "Ok, doing things the stdio way"
6263         val="$undef"
6264         ;;
6265 esac
6266 set useperlio
6267 eval $setvar 
6268
6269 : Check how to convert floats to strings.
6270 if test "X$d_Gconvert" = X; then
6271         echo " "
6272         echo "Checking for an efficient way to convert floats to strings."
6273         $cat >try.c <<'EOP'
6274 #ifdef TRY_gconvert
6275 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6276 char *myname = "gconvert";
6277 #endif
6278 #ifdef TRY_gcvt
6279 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6280 char *myname = "gcvt";
6281 #endif
6282 #ifdef TRY_sprintf
6283 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6284 char *myname = "sprintf";
6285 #endif
6286
6287 #include <stdio.h>
6288
6289 int
6290 checkit(expect, got)
6291 char *expect;
6292 char *got;
6293 {
6294     if (strcmp(expect, got)) {
6295                 printf("%s oddity:  Expected %s, got %s\n",
6296                         myname, expect, got);
6297                 exit(1);
6298         }
6299 }
6300
6301 int main()
6302
6303         char buf[64]; 
6304         buf[63] = '\0';
6305
6306         /* This must be 1st test on (which?) platform */
6307         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6308         Gconvert(0.1, 8, 0, buf);
6309         checkit("0.1", buf);
6310
6311         Gconvert(1.0, 8, 0, buf); 
6312         checkit("1", buf);
6313
6314         Gconvert(0.0, 8, 0, buf); 
6315         checkit("0", buf);
6316
6317         Gconvert(-1.0, 8, 0, buf); 
6318         checkit("-1", buf);
6319
6320         /* Some Linux gcvt's give 1.e+5 here. */
6321         Gconvert(100000.0, 8, 0, buf); 
6322         checkit("100000", buf);
6323         
6324         /* Some Linux gcvt's give -1.e+5 here. */
6325         Gconvert(-100000.0, 8, 0, buf); 
6326         checkit("-100000", buf);
6327
6328         exit(0);
6329 }
6330 EOP
6331         case "$d_Gconvert" in
6332         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6333         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6334         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6335         *) xxx_list='gconvert gcvt sprintf' ;;
6336         esac
6337
6338         for xxx_convert in $xxx_list; do
6339                 echo "Trying $xxx_convert"
6340                 $rm -f try try$_o
6341                 set try -DTRY_$xxx_convert
6342                 if eval $compile; then
6343                         echo "$xxx_convert" found. >&4
6344                         if ./try; then
6345                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6346                                 break;
6347                         else
6348                                 echo "...But $xxx_convert didn't work as I expected."
6349                         fi
6350                 else
6351                         echo "$xxx_convert NOT found." >&4
6352                 fi
6353         done
6354                 
6355         case "$xxx_convert" in
6356         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6357         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6358         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6359         esac
6360 fi
6361
6362 : Initialize h_fcntl
6363 h_fcntl=false
6364
6365 : Initialize h_sysfile
6366 h_sysfile=false
6367
6368 : access call always available on UNIX
6369 set access d_access
6370 eval $inlibc
6371
6372 : locate the flags for 'access()'
6373 case "$d_access" in
6374 "$define")
6375         echo " "
6376         $cat >access.c <<'EOCP'
6377 #include <sys/types.h>
6378 #ifdef I_FCNTL
6379 #include <fcntl.h>
6380 #endif
6381 #ifdef I_SYS_FILE
6382 #include <sys/file.h>
6383 #endif
6384 #ifdef I_UNISTD
6385 #include <unistd.h>
6386 #endif
6387 int main() {
6388         exit(R_OK);
6389 }
6390 EOCP
6391         : check sys/file.h first, no particular reason here
6392         if $test `./findhdr sys/file.h` && \
6393                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6394                 h_sysfile=true;
6395                 echo "<sys/file.h> defines the *_OK access constants." >&4
6396         elif $test `./findhdr fcntl.h` && \
6397                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6398                 h_fcntl=true;
6399                 echo "<fcntl.h> defines the *_OK access constants." >&4
6400         elif $test `./findhdr unistd.h` && \
6401                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6402                 echo "<unistd.h> defines the *_OK access constants." >&4
6403         else
6404                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6405         fi
6406         ;;
6407 esac
6408 $rm -f access*
6409
6410 : see if accessx exists
6411 set accessx d_accessx
6412 eval $inlibc
6413
6414 : see if alarm exists
6415 set alarm d_alarm
6416 eval $inlibc
6417
6418 : Look for GNU-cc style attribute checking
6419 echo " "
6420 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6421 $cat >attrib.c <<'EOCP'
6422 #include <stdio.h>
6423 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6424 EOCP
6425 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6426         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6427                 echo "Your C compiler doesn't fully support __attribute__."
6428                 val="$undef"
6429         else
6430                 echo "Your C compiler supports __attribute__."
6431                 val="$define"
6432         fi
6433 else
6434         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6435         val="$undef"
6436 fi
6437 set d_attribut
6438 eval $setvar
6439 $rm -f attrib*
6440
6441 : see if bcmp exists
6442 set bcmp d_bcmp
6443 eval $inlibc
6444
6445 : see if bcopy exists
6446 set bcopy d_bcopy
6447 eval $inlibc
6448
6449 : see if this is a unistd.h system
6450 set unistd.h i_unistd
6451 eval $inhdr
6452
6453 : see if getpgrp exists
6454 set getpgrp d_getpgrp
6455 eval $inlibc
6456
6457 case "$d_getpgrp" in
6458 "$define")
6459         echo " "
6460         echo "Checking to see which flavor of getpgrp is in use..."
6461         $cat >set.c <<EOP
6462 #$i_unistd I_UNISTD
6463 #include <sys/types.h>
6464 #ifdef I_UNISTD
6465 #  include <unistd.h>
6466 #endif
6467 int main()
6468 {
6469         if (getuid() == 0) {
6470                 printf("(I see you are running Configure as super-user...)\n");
6471                 setuid(1);
6472         }
6473 #ifdef TRY_BSD_PGRP
6474         if (getpgrp(1) == 0)
6475                 exit(0);
6476 #else
6477         if (getpgrp() > 0)
6478                 exit(0);
6479 #endif
6480         exit(1);
6481 }
6482 EOP
6483         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6484                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6485                 val="$define"
6486         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6487                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6488                 val="$undef"
6489         else
6490                 echo "I can't seem to compile and run the test program."
6491                 if ./usg; then
6492                         xxx="a USG one, i.e. you use getpgrp()."
6493                 else
6494                         # SVR4 systems can appear rather BSD-ish.
6495                         case "$i_unistd" in
6496                         $undef)
6497                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6498                                 val="$define"
6499                                 ;;
6500                         $define)
6501                                 xxx="probably a USG one, i.e. you use getpgrp()."
6502                                 val="$undef"
6503                                 ;;
6504                         esac
6505                 fi
6506                 echo "Assuming your getpgrp is $xxx" >&4
6507         fi
6508         ;;
6509 *) val="$undef";;
6510 esac
6511 set d_bsdgetpgrp
6512 eval $setvar
6513 $rm -f set set.c
6514
6515 : see if setpgrp exists
6516 set setpgrp d_setpgrp
6517 eval $inlibc
6518
6519 case "$d_setpgrp" in
6520 "$define")
6521         echo " "
6522         echo "Checking to see which flavor of setpgrp is in use..."
6523         $cat >set.c <<EOP
6524 #$i_unistd I_UNISTD
6525 #include <sys/types.h>
6526 #ifdef I_UNISTD
6527 #  include <unistd.h>
6528 #endif
6529 int main()
6530 {
6531         if (getuid() == 0) {
6532                 printf("(I see you are running Configure as super-user...)\n");
6533                 setuid(1);
6534         }
6535 #ifdef TRY_BSD_PGRP
6536         if (-1 == setpgrp(1, 1))
6537                 exit(0);
6538 #else
6539         if (setpgrp() != -1)
6540                 exit(0);
6541 #endif
6542         exit(1);
6543 }
6544 EOP
6545         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6546                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6547                 val="$define"
6548         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6549                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6550                 val="$undef"
6551         else
6552                 echo "(I can't seem to compile and run the test program.)"
6553                 if ./usg; then
6554                         xxx="a USG one, i.e. you use setpgrp()."
6555                 else
6556                         # SVR4 systems can appear rather BSD-ish.
6557                         case "$i_unistd" in
6558                         $undef)
6559                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6560                                 val="$define"
6561                                 ;;
6562                         $define)
6563                                 xxx="probably a USG one, i.e. you use setpgrp()."
6564                                 val="$undef"
6565                                 ;;
6566                         esac
6567                 fi
6568                 echo "Assuming your setpgrp is $xxx" >&4
6569         fi
6570         ;;
6571 *) val="$undef";;
6572 esac
6573 set d_bsdsetpgrp
6574 eval $setvar
6575 $rm -f set set.c
6576 : see if bzero exists
6577 set bzero d_bzero
6578 eval $inlibc
6579
6580 : check for lengths of integral types
6581 echo " "
6582 case "$intsize" in
6583 '')
6584         echo "Checking to see how big your integers are..." >&4
6585         $cat >intsize.c <<'EOCP'
6586 #include <stdio.h>
6587 int main()
6588 {
6589         printf("intsize=%d;\n", sizeof(int));
6590         printf("longsize=%d;\n", sizeof(long));
6591         printf("shortsize=%d;\n", sizeof(short));
6592         exit(0);
6593 }
6594 EOCP
6595         set intsize
6596         if eval $compile_ok && ./intsize > /dev/null; then
6597                 eval `./intsize`
6598                 echo "Your integers are $intsize bytes long."
6599                 echo "Your long integers are $longsize bytes long."
6600                 echo "Your short integers are $shortsize bytes long."
6601         else
6602                 $cat >&4 <<EOM
6603 !
6604 Help! I can't compile and run the intsize test program: please enlighten me!
6605 (This is probably a misconfiguration in your system or libraries, and
6606 you really ought to fix it.  Still, I'll try anyway.)
6607 !
6608 EOM
6609                 dflt=4
6610                 rp="What is the size of an integer (in bytes)?"
6611                 . ./myread
6612                 intsize="$ans"
6613                 dflt=$intsize
6614                 rp="What is the size of a long integer (in bytes)?"
6615                 . ./myread
6616                 longsize="$ans"
6617                 dflt=2
6618                 rp="What is the size of a short integer (in bytes)?"
6619                 . ./myread
6620                 shortsize="$ans"
6621         fi
6622         ;;
6623 esac
6624 $rm -f intsize intsize.*
6625
6626 : see if signal is declared as pointer to function returning int or void
6627 echo " "
6628 xxx=`./findhdr signal.h`
6629 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6630 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6631         echo "You have int (*signal())() instead of void." >&4
6632         val="$undef"
6633 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6634         echo "You have void (*signal())()." >&4
6635         val="$define"
6636 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6637         echo "You have int (*signal())() instead of void." >&4
6638         val="$undef"
6639 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6640         echo "You have void (*signal())()." >&4
6641         val="$define"
6642 else
6643         case "$d_voidsig" in
6644         '')
6645         echo "I can't determine whether signal handler returns void or int..." >&4
6646                 dflt=void
6647                 rp="What type does your signal handler return?"
6648                 . ./myread
6649                 case "$ans" in
6650                 v*) val="$define";;
6651                 *) val="$undef";;
6652                 esac;;
6653         "$define")
6654                 echo "As you already told me, signal handler returns void." >&4
6655                 val="$define"
6656                 ;;
6657         *)      echo "As you already told me, signal handler returns int." >&4
6658                 val="$undef"
6659                 ;;
6660         esac
6661 fi
6662 set d_voidsig
6663 eval $setvar
6664 case "$d_voidsig" in
6665 "$define") signal_t="void";;
6666 *) signal_t="int";;
6667 esac
6668 $rm -f $$.tmp
6669
6670 : check for ability to cast large floats to 32-bit ints.
6671 echo " "
6672 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6673 if $test "$intsize" -ge 4; then
6674         xxx=int
6675 else
6676         xxx=long
6677 fi
6678 $cat >try.c <<EOCP
6679 #include <stdio.h>
6680 #include <sys/types.h>
6681 #include <signal.h>
6682 $signal_t blech(s) int s; { exit(3); }
6683 int main()
6684 {
6685         $xxx i32;
6686         double f, g;
6687         int result = 0;
6688         char str[16];
6689         signal(SIGFPE, blech);
6690
6691         /* Don't let compiler optimize the test away.  Store the number 
6692            in a writable string for gcc to pass to sscanf under HP/UX.
6693         */
6694         sprintf(str, "2147483647");
6695         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6696         g = 10 * f;
6697         i32  = ($xxx) g;
6698
6699         /* x86 processors will probably give 0x8000 0000, which is a
6700        sign change.  We don't want that.  We want to mimic SPARC
6701            behavior here, which is to preserve the sign and give
6702            back 0x7fff ffff.
6703         */
6704         if (i32 != ($xxx) f)
6705                 result |= 1;
6706         exit(result);
6707 }
6708 EOCP
6709 set try
6710 if eval $compile_ok; then
6711         ./try
6712         yyy=$?
6713 else
6714         echo "(I can't seem to compile the test program--assuming it can't)"
6715         yyy=1
6716 fi
6717 case "$yyy" in
6718 0)      val="$define"
6719         echo "Yup, it can."
6720         ;;
6721 *)      val="$undef"
6722         echo "Nope, it can't."
6723         ;;
6724 esac
6725 set d_casti32
6726 eval $setvar
6727 $rm -f try try.*
6728
6729 : check for ability to cast negative floats to unsigned
6730 echo " "
6731 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6732 $cat >try.c <<EOCP
6733 #include <stdio.h>
6734 #include <sys/types.h>
6735 #include <signal.h>
6736 $signal_t blech(s) int s; { exit(7); }
6737 $signal_t blech_in_list(s) int s; { exit(4); }
6738 unsigned long dummy_long(p) unsigned long p; { return p; }
6739 unsigned int dummy_int(p) unsigned int p; { return p; }
6740 unsigned short dummy_short(p) unsigned short p; { return p; }
6741 int main()
6742 {
6743         double f;
6744         unsigned long along;
6745         unsigned int aint;
6746         unsigned short ashort;
6747         int result = 0;
6748         char str[16];
6749         
6750         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6751            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6752            optimized the whole file away
6753         */
6754         /* Store the number in a writable string for gcc to pass to 
6755            sscanf under HP/UX.
6756         */
6757         sprintf(str, "-123");
6758         sscanf(str, "%lf", &f);  /* f = -123.; */
6759
6760         signal(SIGFPE, blech);
6761         along = (unsigned long)f;
6762         aint = (unsigned int)f;
6763         ashort = (unsigned short)f;
6764         if (along != (unsigned long)-123)
6765                 result |= 1;
6766         if (aint != (unsigned int)-123)
6767                 result |= 1;
6768         if (ashort != (unsigned short)-123)
6769                 result |= 1;
6770         sprintf(str, "1073741824.");
6771         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6772         f = f + f;
6773         along = 0;
6774         along = (unsigned long)f;
6775         if (along != 0x80000000)
6776                 result |= 2;
6777         f -= 1.;
6778         along = 0;
6779         along = (unsigned long)f;
6780         if (along != 0x7fffffff)
6781                 result |= 1;
6782         f += 2.;
6783         along = 0;
6784         along = (unsigned long)f;
6785         if (along != 0x80000001)
6786                 result |= 2;
6787         if (result)
6788                 exit(result);
6789         signal(SIGFPE, blech_in_list);
6790         sprintf(str, "123.");
6791         sscanf(str, "%lf", &f);  /* f = 123.; */
6792         along = dummy_long((unsigned long)f);
6793         aint = dummy_int((unsigned int)f);
6794         ashort = dummy_short((unsigned short)f);
6795         if (along != (unsigned long)123)
6796                 result |= 4;
6797         if (aint != (unsigned int)123)
6798                 result |= 4;
6799         if (ashort != (unsigned short)123)
6800                 result |= 4;
6801         exit(result);
6802
6803 }
6804 EOCP
6805 set try
6806 if eval $compile_ok; then
6807         ./try
6808         castflags=$?
6809 else
6810         echo "(I can't seem to compile the test program--assuming it can't)"
6811         castflags=7
6812 fi
6813 case "$castflags" in
6814 0)      val="$define"
6815         echo "Yup, it can."
6816         ;;
6817 *)      val="$undef"
6818         echo "Nope, it can't."
6819         ;;
6820 esac
6821 set d_castneg
6822 eval $setvar
6823 $rm -f try.*
6824
6825 : see if vprintf exists
6826 echo " "
6827 if set vprintf val -f d_vprintf; eval $csym; $val; then
6828         echo 'vprintf() found.' >&4
6829         val="$define"
6830         $cat >vprintf.c <<'EOF'
6831 #include <varargs.h>
6832
6833 int main() { xxx("foo"); }
6834
6835 xxx(va_alist)
6836 va_dcl
6837 {
6838         va_list args;
6839         char buf[10];
6840
6841         va_start(args);
6842         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6843 }
6844 EOF
6845         set vprintf
6846         if eval $compile && ./vprintf; then
6847                 echo "Your vsprintf() returns (int)." >&4
6848                 val2="$undef"
6849         else
6850                 echo "Your vsprintf() returns (char*)." >&4
6851                 val2="$define"
6852         fi
6853 else
6854         echo 'vprintf() NOT found.' >&4
6855                 val="$undef"
6856                 val2="$undef"
6857 fi
6858 set d_vprintf
6859 eval $setvar
6860 val=$val2
6861 set d_charvspr
6862 eval $setvar
6863
6864 : see if chown exists
6865 set chown d_chown
6866 eval $inlibc
6867
6868 : see if chroot exists
6869 set chroot d_chroot
6870 eval $inlibc
6871
6872 : see if chsize exists
6873 set chsize d_chsize
6874 eval $inlibc
6875
6876 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6877 while $test $# -ge 2; do
6878         case "$1" in
6879         $define) echo "#include <$2>";;
6880         esac ;
6881     shift 2;
6882 done > try.c;
6883 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6884 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6885         val="$define";
6886 else
6887         val="$undef";
6888 fi;
6889 set $varname;
6890 eval $setvar;
6891 $rm -f try.c try.o'
6892
6893 : see if this is a sys/uio.h system
6894 set sys/uio.h i_sysuio
6895 eval $inhdr
6896
6897 echo "Checking to see if your system supports struct iovec..." >&4
6898 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6899 eval $hasfield
6900 case "$d_iovec_s" in
6901 "$define")      echo "Yup, it does." >&4
6902                 ;;
6903 *)              echo "Nope, it doesn't." >&4
6904                 ;;
6905 esac
6906
6907 socketlib=''
6908 sockethdr=''
6909 : see whether socket exists
6910 echo " "
6911 $echo $n "Hmm... $c" >&4
6912 if set socket val -f d_socket; eval $csym; $val; then
6913         echo "Looks like you have Berkeley networking support." >&4
6914         d_socket="$define"
6915         if set setsockopt val -f; eval $csym; $val; then
6916                 d_oldsock="$undef"
6917         else
6918                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6919                 d_oldsock="$define"
6920         fi
6921 else
6922         if $contains socklib libc.list >/dev/null 2>&1; then
6923                 echo "Looks like you have Berkeley networking support." >&4
6924                 d_socket="$define"
6925                 : we will have to assume that it supports the 4.2 BSD interface
6926                 d_oldsock="$undef"
6927         else
6928                 echo "You don't have Berkeley networking in libc$_a..." >&4
6929                 if test "X$d_socket" = "X$define"; then
6930                    echo "...but you seem to believe that you have sockets." >&4
6931                 else
6932                         for net in net socket
6933                         do
6934                                 if test -f /usr/lib/lib$net$_a; then
6935                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6936                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6937                                         if $contains socket libc.list >/dev/null 2>&1; then
6938                                                 d_socket="$define"
6939                                                 socketlib="-l$net"
6940                                                 case "$net" in
6941                                                 net)
6942                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6943                                                         sockethdr="-I/usr/netinclude"
6944                                                         ;;
6945                                                 esac
6946                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6947                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6948                                                         d_oldsock="$undef"
6949                                                 else
6950                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6951                                                         d_oldsock="$define"
6952                                                 fi
6953                                                 break
6954                                         fi
6955                                 fi
6956                         done
6957                         if test "X$d_socket" != "X$define"; then
6958                            echo "or anywhere else I see." >&4
6959                            d_socket="$undef"
6960                            d_oldsock="$undef"
6961                         fi
6962                 fi
6963         fi
6964 fi
6965
6966 : see if socketpair exists
6967 set socketpair d_sockpair
6968 eval $inlibc
6969
6970
6971 echo " "
6972 echo "Checking the availability of certain socket constants..." >& 4
6973 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
6974         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
6975         $cat >try.c <<EOF
6976 #include <sys/types.h>
6977 #include <sys/socket.h>
6978 int main() {
6979     int i = $ENUM;
6980 }
6981 EOF
6982         val="$undef"
6983         set try; if eval $compile; then
6984                 val="$define"
6985         fi
6986         set d_${enum}; eval $setvar
6987         $rm -f try.c try
6988 done
6989
6990 set sendmsg d_sendmsg
6991 eval $inlibc
6992
6993 set recvmsg d_recvmsg
6994 eval $inlibc
6995
6996 echo " "
6997 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
6998 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
6999 eval $hasfield
7000 case "$d_msghdr_s" in
7001 "$define")      echo "Yup, it does." >&4
7002                 ;;
7003 *)              echo "Nope, it doesn't." >&4
7004                 ;;
7005 esac
7006
7007 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
7008 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
7009 eval $hasfield
7010 case "$d_cmsghdr_s" in
7011 "$define")      echo "Yup, it does." >&4
7012                 ;;
7013 *)              echo "Nope, it doesn't." >&4
7014                 ;;
7015 esac
7016
7017 : check for const keyword
7018 echo " "
7019 echo 'Checking to see if your C compiler knows about "const"...' >&4
7020 $cat >const.c <<'EOCP'
7021 typedef struct spug { int drokk; } spug;
7022 int main()
7023 {
7024         const char *foo;
7025         const spug y;
7026 }
7027 EOCP
7028 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
7029         val="$define"
7030         echo "Yup, it does."
7031 else
7032         val="$undef"
7033         echo "Nope, it doesn't."
7034 fi
7035 set d_const
7036 eval $setvar
7037
7038 : see if crypt exists
7039 echo " "
7040 if set crypt val -f d_crypt; eval $csym; $val; then
7041         echo 'crypt() found.' >&4
7042         val="$define"
7043         cryptlib=''
7044 else
7045         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
7046         if $test -z "$cryptlib"; then
7047                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
7048         else
7049                 cryptlib=-lcrypt
7050         fi
7051         if $test -z "$cryptlib"; then
7052                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
7053         else
7054                 cryptlib=-lcrypt
7055         fi
7056         if $test -z "$cryptlib"; then
7057                 cryptlib=`./loc libcrypt$_a "" $libpth`
7058         else
7059                 cryptlib=-lcrypt
7060         fi
7061         if $test -z "$cryptlib"; then
7062                 echo 'crypt() NOT found.' >&4
7063                 val="$undef"
7064         else
7065                 val="$define"
7066         fi
7067 fi
7068 set d_crypt
7069 eval $setvar
7070
7071 : get csh whereabouts
7072 case "$csh" in
7073 'csh') val="$undef" ;;
7074 *) val="$define" ;;
7075 esac
7076 set d_csh
7077 eval $setvar
7078 : Respect a hint or command line value for full_csh.
7079 case "$full_csh" in
7080 '') full_csh=$csh ;;
7081 esac
7082
7083 : see if cuserid exists
7084 set cuserid d_cuserid
7085 eval $inlibc
7086
7087 : see if this is a limits.h system
7088 set limits.h i_limits
7089 eval $inhdr
7090
7091 : see if this is a float.h system
7092 set float.h i_float
7093 eval $inhdr
7094
7095 : See if number of significant digits in a double precision number is known
7096 echo " "
7097 $cat >dbl_dig.c <<EOM
7098 #$i_limits I_LIMITS
7099 #$i_float I_FLOAT
7100 #ifdef I_LIMITS
7101 #include <limits.h>
7102 #endif
7103 #ifdef I_FLOAT
7104 #include <float.h>
7105 #endif
7106 #ifdef DBL_DIG
7107 printf("Contains DBL_DIG");
7108 #endif
7109 EOM
7110 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
7111 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
7112         echo "DBL_DIG found." >&4
7113         val="$define"
7114 else
7115         echo "DBL_DIG NOT found." >&4
7116         val="$undef"
7117 fi
7118 $rm -f dbl_dig.?
7119 set d_dbl_dig
7120 eval $setvar
7121
7122
7123 if $test X"$use64bits" = X"$define"; then
7124         : see if dbminit64 exists
7125         set dbminit64 d_dbminit64
7126         eval $inlibc
7127
7128         : see if dbmclose64 exists
7129         set dbmclose64 d_dbmclose64
7130         eval $inlibc
7131
7132         : see if fetch64 exists
7133         set fetch64 d_fetch64
7134         eval $inlibc
7135
7136         : see if store64 exists
7137         set store64 d_store64
7138         eval $inlibc
7139
7140         : see if delete64 exists
7141         set delete64 d_delete64
7142         eval $inlibc
7143
7144         : see if firstkey64 exists
7145         set firstkey64 d_firstkey64
7146         eval $inlibc
7147
7148         : see if nextkey64 exists
7149         set nextkey64 d_nextkey64
7150         eval $inlibc
7151 else
7152         val="$undef"
7153         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
7154         do
7155                 set $xxx
7156                 eval $setvar
7157         done
7158 fi
7159
7160 : see if difftime exists
7161 set difftime d_difftime
7162 eval $inlibc
7163
7164 : see if sys/stat.h is available
7165 set sys/stat.h i_sysstat
7166 eval $inhdr
7167
7168 : see if this is a dirent system
7169 echo " "
7170 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
7171         val="$define"
7172         echo "<dirent.h> found." >&4
7173 else
7174         val="$undef"
7175         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7176                 echo "<sys/dir.h> found." >&4
7177                 echo " "
7178         else
7179                 xinc=`./findhdr sys/ndir.h`
7180         fi
7181         echo "<dirent.h> NOT found." >&4
7182 fi
7183 set i_dirent
7184 eval $setvar
7185
7186 : Look for type of directory structure.
7187 echo " "
7188 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7189
7190 case "$direntrytype" in
7191 ''|' ')
7192         case "$i_dirent" in
7193         $define) guess1='struct dirent' ;;
7194         *) guess1='struct direct'  ;;
7195         esac
7196         ;;
7197 *)      guess1="$direntrytype"
7198         ;;
7199 esac
7200
7201 case "$guess1" in
7202 'struct dirent') guess2='struct direct' ;;
7203 *) guess2='struct dirent' ;;
7204 esac
7205                 
7206 if $contains "$guess1" try.c >/dev/null 2>&1; then
7207         direntrytype="$guess1"
7208         echo "Your directory entries are $direntrytype." >&4
7209 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7210         direntrytype="$guess2"
7211         echo "Your directory entries seem to be $direntrytype." >&4
7212 else
7213         echo "I don't recognize your system's directory entries." >&4
7214         rp="What type is used for directory entries on this system?"
7215         dflt="$guess1"
7216         . ./myread
7217         direntrytype="$ans"
7218 fi
7219 $rm -f try.c
7220
7221
7222 : see if the directory entry stores field length
7223 echo " "
7224 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7225 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7226         echo "Good, your directory entry keeps length information in d_namlen." >&4
7227         val="$define"
7228 else
7229         echo "Your directory entry does not know about the d_namlen field." >&4
7230         val="$undef"
7231 fi
7232 set d_dirnamlen
7233 eval $setvar
7234 $rm -f try.c
7235
7236
7237 if $test X"$use64bits" = X"$define"; then
7238         : see if fstat64 exists
7239         set fstat64 d_fstat64
7240         eval $inlibc
7241
7242         : see if ftruncate64 exists
7243         set ftruncate64 d_ftruncate64
7244         eval $inlibc
7245
7246         : see if lockf64 exists
7247         set lockf64 d_lockf64
7248         eval $inlibc
7249
7250         : see if llseek exists
7251         set llseek d_llseek
7252         eval $inlibc
7253
7254         : see if lseek64 exists
7255         set lseek64 d_lseek64
7256         eval $inlibc
7257
7258         : see if lstat64 exists
7259         set lstat64 d_lstat64
7260         eval $inlibc
7261
7262         : see if open64 exists
7263         set open64 d_open64
7264         eval $inlibc
7265
7266         : see if opendir64 exists
7267         set opendir64 d_opendir64
7268         eval $inlibc
7269
7270         : see if readdir64 exists
7271         set readdir64 d_readdir64
7272         eval $inlibc
7273
7274         : see if seekdir64 exists
7275         set seekdir64 d_seekdir64
7276         eval $inlibc
7277
7278         : see if stat64 exists
7279         set stat64 d_stat64
7280         eval $inlibc
7281
7282         : see if telldir64 exists
7283         set telldir64 d_telldir64
7284         eval $inlibc
7285
7286         : see if truncate64 exists
7287         set truncate64 d_truncate64
7288         eval $inlibc
7289
7290         : check for off64_t
7291         echo " "
7292         echo $n "Checking to see if your system supports off64_t...$c" >&4
7293         $cat >try.c <<EOCP
7294 #include <sys/types.h>
7295 #include <unistd.h>
7296 off64_t foo() { off64_t x; x = 7; return x; }'
7297 EOCP
7298         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7299                 val="$define"
7300                 echo " Yup, it does." >&4
7301         else
7302                 val="$undef"
7303                 echo " Nope, it doesn't." >&4
7304         fi
7305         $rm -f try.*
7306         set d_off64_t
7307         eval $setvar
7308
7309         : check for offset_t
7310         echo " "
7311         echo $n "Checking to see if your system supports offset_t...$c" >&4
7312         $cat >try.c <<EOCP
7313 #include <sys/types.h>
7314 #include <unistd.h>
7315 offset_t foo() { offset_t x; x = 7; return x; }'
7316 EOCP
7317         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7318                 val="$define"
7319                 echo " Yup, it does." >&4
7320         else
7321                 val="$undef"
7322                 echo " Nope, it doesn't." >&4
7323         fi
7324         $rm -f try.*
7325         set d_offset_t
7326         eval $setvar
7327
7328         : check for ino64_t
7329         echo " "
7330         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7331         val="$undef"
7332         case "$i_sysstat" in
7333         "$define" )
7334                 $cat >try.c <<EOCP
7335 #include <sys/types.h>
7336 #include <sys/stat.h>
7337 ino64_t foo() { ino64_t x; x = 7; return x; }'
7338 EOCP
7339                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7340                         val="$define"
7341                 fi
7342                 $rm -f try.*
7343                 ;;
7344         esac
7345         if $test "X$val" = X"$define"; then
7346                 echo " Yup, it does." >&4
7347         else
7348                 echo " Nope, it doesn't." >&4
7349         fi
7350         set d_ino64_t
7351         eval $setvar
7352
7353         : check for struct flock64
7354         echo " "
7355         echo "Checking to see if your system supports struct flock64..." >&4
7356         if $h_fcntl; then
7357                 set d_flock64_s flock64 l_len define fcntl.h
7358                 eval $hasfield
7359         else
7360                 val="$undef"
7361                 set d_flock64_s
7362                 eval $setvar
7363         fi
7364         case "$d_flock64_s" in
7365         "$define")      echo "Yup, it does." >&4
7366                         ;;
7367         *)              echo "Nope, it doesn't." >&4
7368                         ;;
7369         esac
7370
7371         : check for struct dirent64
7372         echo " "
7373         echo "Checking to see if your system supports struct dirent64..." >&4
7374         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7375         eval $hasfield
7376         case "$d_dirent64_s" in
7377         "$define")      echo "Yup, it does." >&4
7378                         ;;
7379         *)              echo "Nope, it doesn't." >&4
7380                         ;;
7381         esac
7382
7383 else
7384         val="$undef"
7385         for xxx in d_fstat64 d_ftruncate64 d_lockf64 d_lseek64 d_lstat64 d_open64 d_opendir64 d_readdir64 d_seekdir64 d_stat64 d_telldir64 d_truncate64 d_off64_t d_offset_t d_ino64_t d_flock64_s d_dirent64_s
7386         do
7387                 set $xxx
7388                 eval $setvar
7389         done
7390 fi
7391
7392 : see if dlerror exists
7393 xxx_runnm="$runnm"
7394 runnm=false
7395 set dlerror d_dlerror
7396 eval $inlibc
7397 runnm="$xxx_runnm"
7398
7399 : see if dlfcn is available
7400 set dlfcn.h i_dlfcn
7401 eval $inhdr
7402
7403 case "$usedl" in
7404 $define|y|true)
7405         $cat << EOM
7406
7407 On a few systems, the dynamically loaded modules that perl generates and uses
7408 will need a different extension than shared libs. The default will probably
7409 be appropriate.
7410
7411 EOM
7412         case "$dlext" in
7413         '')     dflt="$so" ;;
7414         *)      dflt="$dlext" ;;
7415         esac
7416         rp='What is the extension of dynamically loaded modules'
7417         . ./myread
7418         dlext="$ans"
7419         ;;
7420 *)
7421         dlext="none"
7422         ;;
7423 esac
7424
7425 : Check if dlsym need a leading underscore
7426 echo " "
7427 val="$undef"
7428
7429 case "$dlsrc" in
7430 dl_dlopen.xs)
7431         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7432         $cat >dyna.c <<'EOM'
7433 fred () { }
7434 EOM
7435
7436 $cat >fred.c<<EOM
7437
7438 #include <stdio.h>
7439 #$i_dlfcn I_DLFCN
7440 #ifdef I_DLFCN
7441 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7442 #else
7443 #include <sys/types.h>
7444 #include <nlist.h>
7445 #include <link.h>
7446 #endif
7447
7448 extern int fred() ;
7449
7450 int main()
7451 {
7452     void * handle ;
7453     void * symbol ;
7454 #ifndef RTLD_LAZY
7455     int mode = 1 ;
7456 #else
7457     int mode = RTLD_LAZY ;
7458 #endif
7459     handle = dlopen("./dyna.$dlext", mode) ;
7460     if (handle == NULL) {
7461         printf ("1\n") ;
7462         fflush (stdout) ;
7463         exit(0);
7464     }
7465     symbol = dlsym(handle, "fred") ;
7466     if (symbol == NULL) {
7467         /* try putting a leading underscore */
7468         symbol = dlsym(handle, "_fred") ;
7469         if (symbol == NULL) {
7470             printf ("2\n") ;
7471             fflush (stdout) ;
7472             exit(0);
7473         }
7474         printf ("3\n") ;
7475     }
7476     else
7477         printf ("4\n") ;
7478     fflush (stdout) ;
7479     exit(0);
7480 }
7481 EOM
7482         : Call the object file tmp-dyna.o in case dlext=o.
7483         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7484                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7485                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7486                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7487                 xxx=`./fred`
7488                 case $xxx in
7489                 1)      echo "Test program failed using dlopen." >&4
7490                         echo "Perhaps you should not use dynamic loading." >&4;;
7491                 2)      echo "Test program failed using dlsym." >&4
7492                         echo "Perhaps you should not use dynamic loading." >&4;;
7493                 3)      echo "dlsym needs a leading underscore" >&4
7494                         val="$define" ;;
7495                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7496                 esac
7497         else
7498                 echo "I can't compile and run the test program." >&4
7499         fi
7500         ;;
7501 esac
7502                 
7503 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7504
7505 set d_dlsymun
7506 eval $setvar
7507
7508 hasproto='varname=$1; func=$2; shift; shift;
7509 while $test $# -ge 2; do
7510         case "$1" in
7511         $define) echo "#include <$2>";;
7512         esac ;
7513     shift 2;
7514 done > try.c;
7515 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7516 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7517         echo "$func() prototype found.";
7518         val="$define";
7519 else
7520         echo "$func() prototype NOT found.";
7521         val="$undef";
7522 fi;
7523 set $varname;
7524 eval $setvar;
7525 $rm -f try.c tryout.c'
7526
7527 : see if prototype for drand48 is available
7528 echo " "
7529 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7530 eval $hasproto
7531
7532 : see if dup2 exists
7533 set dup2 d_dup2
7534 eval $inlibc
7535
7536 : see if eaccess exists
7537 set eaccess d_eaccess
7538 eval $inlibc
7539
7540 : see if endgrent exists
7541 set endgrent d_endgrent
7542 eval $inlibc
7543
7544 : see if endhostent exists
7545 set endhostent d_endhent
7546 eval $inlibc
7547
7548 : see if endnetent exists
7549 set endnetent d_endnent
7550 eval $inlibc
7551
7552 : see if endprotoent exists
7553 set endprotoent d_endpent
7554 eval $inlibc
7555
7556 : see if endpwent exists
7557 set endpwent d_endpwent
7558 eval $inlibc
7559
7560 : see if endservent exists
7561 set endservent d_endsent
7562 eval $inlibc
7563
7564 : Locate the flags for 'open()'
7565 echo " "
7566 $cat >open3.c <<'EOCP'
7567 #include <sys/types.h>
7568 #ifdef I_FCNTL
7569 #include <fcntl.h>
7570 #endif
7571 #ifdef I_SYS_FILE
7572 #include <sys/file.h>
7573 #endif
7574 int main() {
7575         if(O_RDONLY);
7576 #ifdef O_TRUNC
7577         exit(0);
7578 #else
7579         exit(1);
7580 #endif
7581 }
7582 EOCP
7583 : check sys/file.h first to get FREAD on Sun
7584 if $test `./findhdr sys/file.h` && \
7585                 set open3 -DI_SYS_FILE && eval $compile; then
7586         h_sysfile=true;
7587         echo "<sys/file.h> defines the O_* constants..." >&4
7588         if ./open3; then
7589                 echo "and you have the 3 argument form of open()." >&4
7590                 val="$define"
7591         else
7592                 echo "but not the 3 argument form of open().  Oh, well." >&4
7593                 val="$undef"
7594         fi
7595 elif $test `./findhdr fcntl.h` && \
7596                 set open3 -DI_FCNTL && eval $compile; then
7597         h_fcntl=true;
7598         echo "<fcntl.h> defines the O_* constants..." >&4
7599         if ./open3; then
7600                 echo "and you have the 3 argument form of open()." >&4
7601                 val="$define"
7602         else
7603                 echo "but not the 3 argument form of open().  Oh, well." >&4
7604                 val="$undef"
7605         fi
7606 else
7607         val="$undef"
7608         echo "I can't find the O_* constant definitions!  You got problems." >&4
7609 fi
7610 set d_open3
7611 eval $setvar
7612 $rm -f open3*
7613
7614 : check for non-blocking I/O stuff
7615 case "$h_sysfile" in
7616 true) echo "#include <sys/file.h>" > head.c;;
7617 *)
7618         case "$h_fcntl" in
7619         true) echo "#include <fcntl.h>" > head.c;;
7620         *) echo "#include <sys/fcntl.h>" > head.c;;
7621         esac
7622         ;;
7623 esac
7624 echo " "
7625 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7626 case "$o_nonblock" in
7627 '')
7628         $cat head.c > try.c
7629         $cat >>try.c <<'EOCP'
7630 int main() {
7631 #ifdef O_NONBLOCK
7632         printf("O_NONBLOCK\n");
7633         exit(0);
7634 #endif
7635 #ifdef O_NDELAY
7636         printf("O_NDELAY\n");
7637         exit(0);
7638 #endif
7639 #ifdef FNDELAY
7640         printf("FNDELAY\n");
7641         exit(0);
7642 #endif
7643         exit(0);
7644 }
7645 EOCP
7646         set try
7647         if eval $compile_ok; then
7648                 o_nonblock=`./try`
7649                 case "$o_nonblock" in
7650                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7651                 *) echo "Seems like we can use $o_nonblock.";;
7652                 esac
7653         else
7654                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7655         fi
7656         ;;
7657 *) echo "Using $hint value $o_nonblock.";;
7658 esac
7659 $rm -f try try.* .out core
7660
7661 echo " "
7662 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7663 case "$eagain" in
7664 '')
7665         $cat head.c > try.c
7666         $cat >>try.c <<EOCP
7667 #include <errno.h>
7668 #include <sys/types.h>
7669 #include <signal.h>
7670 #define MY_O_NONBLOCK $o_nonblock
7671 #ifndef errno  /* XXX need better Configure test */
7672 extern int errno;
7673 #endif
7674 $signal_t blech(x) int x; { exit(3); }
7675 EOCP
7676         $cat >> try.c <<'EOCP'
7677 int main()
7678 {
7679         int pd[2];
7680         int pu[2];
7681         char buf[1];
7682         char string[100];
7683
7684         pipe(pd);       /* Down: child -> parent */
7685         pipe(pu);       /* Up: parent -> child */
7686         if (0 != fork()) {
7687                 int ret;
7688                 close(pd[1]);   /* Parent reads from pd[0] */
7689                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7690                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7691                         exit(1);
7692                 signal(SIGALRM, blech);
7693                 alarm(5);
7694                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7695                         exit(2);
7696                 sprintf(string, "%d\n", ret);
7697                 write(2, string, strlen(string));
7698                 alarm(0);
7699 #ifdef EAGAIN
7700                 if (errno == EAGAIN) {
7701                         printf("EAGAIN\n");
7702                         goto ok;
7703                 }
7704 #endif
7705 #ifdef EWOULDBLOCK
7706                 if (errno == EWOULDBLOCK)
7707                         printf("EWOULDBLOCK\n");
7708 #endif
7709         ok:
7710                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7711                 sleep(2);                               /* Give it time to close our pipe */
7712                 alarm(5);
7713                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7714                 alarm(0);
7715                 sprintf(string, "%d\n", ret);
7716                 write(3, string, strlen(string));
7717                 exit(0);
7718         }
7719
7720         close(pd[0]);                   /* We write to pd[1] */
7721         close(pu[1]);                   /* We read from pu[0] */
7722         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7723         close(pd[1]);                   /* Pipe pd is now fully closed! */
7724         exit(0);                                /* Bye bye, thank you for playing! */
7725 }
7726 EOCP
7727         set try
7728         if eval $compile_ok; then
7729                 echo "$startsh" >mtry
7730                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7731                 chmod +x mtry
7732                 ./mtry >/dev/null 2>&1
7733                 case $? in
7734                 0) eagain=`$cat try.out`;;
7735                 1) echo "Could not perform non-blocking setting!";;
7736                 2) echo "I did a successful read() for something that was not there!";;
7737                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7738                 *) echo "Something terribly wrong happened during testing.";;
7739                 esac
7740                 rd_nodata=`$cat try.ret`
7741                 echo "A read() system call with no data present returns $rd_nodata."
7742                 case "$rd_nodata" in
7743                 0|-1) ;;
7744                 *)
7745                         echo "(That's peculiar, fixing that to be -1.)"
7746                         rd_nodata=-1
7747                         ;;
7748                 esac
7749                 case "$eagain" in
7750                 '')
7751                         echo "Forcing errno EAGAIN on read() with no data available."
7752                         eagain=EAGAIN
7753                         ;;
7754                 *)
7755                         echo "Your read() sets errno to $eagain when no data is available."
7756                         ;;
7757                 esac
7758                 status=`$cat try.err`
7759                 case "$status" in
7760                 0) echo "And it correctly returns 0 to signal EOF.";;
7761                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7762                 *) echo "However, your read() returns '$status' on EOF??";;
7763                 esac
7764                 val="$define"
7765                 if test "$status" = "$rd_nodata"; then
7766                         echo "WARNING: you can't distinguish between EOF and no data!"
7767                         val="$undef"
7768                 fi
7769         else
7770                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7771                 eagain=EAGAIN
7772         fi
7773         set d_eofnblk
7774         eval $setvar
7775         ;;
7776 *)
7777         echo "Using $hint value $eagain."
7778         echo "Your read() returns $rd_nodata when no data is present."
7779         case "$d_eofnblk" in
7780         "$define") echo "And you can see EOF because read() returns 0.";;
7781         "$undef") echo "But you can't see EOF status from read() returned value.";;
7782         *)
7783                 echo "(Assuming you can't see EOF status from read anyway.)"
7784                 d_eofnblk=$undef
7785                 ;;
7786         esac
7787         ;;
7788 esac
7789 $rm -f try try.* .out core head.c mtry
7790
7791 : see if fchmod exists
7792 set fchmod d_fchmod
7793 eval $inlibc
7794
7795 : see if fchown exists
7796 set fchown d_fchown
7797 eval $inlibc
7798
7799 : see if this is an fcntl system
7800 set fcntl d_fcntl
7801 eval $inlibc
7802
7803 : see if sys/select.h has to be included
7804 set sys/select.h i_sysselct
7805 eval $inhdr
7806
7807 : see if we should include time.h, sys/time.h, or both
7808 echo " "
7809 if test "X$timeincl" = X; then
7810         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7811         $echo $n "I'm now running the test program...$c"
7812         $cat >try.c <<'EOCP'
7813 #include <sys/types.h>
7814 #ifdef I_TIME
7815 #include <time.h>
7816 #endif
7817 #ifdef I_SYSTIME
7818 #ifdef SYSTIMEKERNEL
7819 #define KERNEL
7820 #endif
7821 #include <sys/time.h>
7822 #endif
7823 #ifdef I_SYSSELECT
7824 #include <sys/select.h>
7825 #endif
7826 int main()
7827 {
7828         struct tm foo;
7829 #ifdef S_TIMEVAL
7830         struct timeval bar;
7831 #endif
7832 #ifdef S_TIMEZONE
7833         struct timezone tzp;
7834 #endif
7835         if (foo.tm_sec == foo.tm_sec)
7836                 exit(0);
7837 #ifdef S_TIMEVAL
7838         if (bar.tv_sec == bar.tv_sec)
7839                 exit(0);
7840 #endif
7841         exit(1);
7842 }
7843 EOCP
7844         flags=''
7845         for s_timezone in '-DS_TIMEZONE' ''; do
7846         sysselect=''
7847         for s_timeval in '-DS_TIMEVAL' ''; do
7848         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7849         for i_time in '' '-DI_TIME'; do
7850         for i_systime in '-DI_SYSTIME' ''; do
7851                 case "$flags" in
7852                 '') $echo $n ".$c"
7853                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7854                         if eval $compile; then
7855                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7856                                 shift
7857                                 flags="$*"
7858                                 echo " "
7859                                 $echo $n "Succeeded with $flags$c"
7860                         fi
7861                         ;;
7862                 esac
7863         done
7864         done
7865         done
7866         done
7867         done
7868         timeincl=''
7869         echo " "
7870         case "$flags" in
7871         *SYSTIMEKERNEL*) i_systimek="$define"
7872                 timeincl=`./findhdr sys/time.h`
7873                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7874         *) i_systimek="$undef";;
7875         esac
7876         case "$flags" in
7877         *I_TIME*) i_time="$define"
7878                 timeincl=`./findhdr time.h`" $timeincl"
7879                 echo "We'll include <time.h>." >&4;;
7880         *) i_time="$undef";;
7881         esac
7882         case "$flags" in
7883         *I_SYSTIME*) i_systime="$define"
7884                 timeincl=`./findhdr sys/time.h`" $timeincl"
7885                 echo "We'll include <sys/time.h>." >&4;;
7886         *) i_systime="$undef";;
7887         esac
7888         $rm -f try.c try
7889 fi
7890
7891 : check for fd_set items
7892 $cat <<EOM
7893
7894 Checking to see how well your C compiler handles fd_set and friends ...
7895 EOM
7896 $cat >fd_set.c <<EOCP
7897 #$i_systime I_SYS_TIME
7898 #$i_sysselct I_SYS_SELECT
7899 #$d_socket HAS_SOCKET
7900 #include <sys/types.h>
7901 #ifdef HAS_SOCKET
7902 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7903 #endif
7904 #ifdef I_SYS_TIME
7905 #include <sys/time.h>
7906 #endif
7907 #ifdef I_SYS_SELECT
7908 #include <sys/select.h>
7909 #endif
7910 int main() {
7911         fd_set fds;
7912
7913 #ifdef TRYBITS
7914         if(fds.fds_bits);
7915 #endif
7916
7917 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7918         exit(0);
7919 #else
7920         exit(1);
7921 #endif
7922 }
7923 EOCP
7924 set fd_set -DTRYBITS
7925 if eval $compile; then
7926         d_fds_bits="$define"
7927         d_fd_set="$define"
7928         echo "Well, your system knows about the normal fd_set typedef..." >&4
7929         if ./fd_set; then
7930                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7931                 d_fd_macros="$define"
7932         else
7933                 $cat >&4 <<'EOM'
7934 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7935 EOM
7936                 d_fd_macros="$undef"
7937         fi
7938 else
7939         $cat <<'EOM'
7940 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7941 EOM
7942         set fd_set
7943         if eval $compile; then
7944                 d_fds_bits="$undef"
7945                 d_fd_set="$define"
7946                 echo "Well, your system has some sort of fd_set available..." >&4
7947                 if ./fd_set; then
7948                         echo "and you have the normal fd_set macros." >&4
7949                         d_fd_macros="$define"
7950                 else
7951                         $cat <<'EOM'
7952 but not the normal fd_set macros!  Gross!  More work for me...
7953 EOM
7954                         d_fd_macros="$undef"
7955                 fi
7956         else
7957         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7958                 d_fd_set="$undef"
7959                 d_fds_bits="$undef"
7960                 d_fd_macros="$undef"
7961         fi
7962 fi
7963 $rm -f fd_set*
7964
7965 : see if fgetpos exists
7966 set fgetpos d_fgetpos
7967 eval $inlibc
7968
7969
7970 if $test X"$use64bits" = X"$define"; then
7971         : see if fgetpos64 exists
7972         set fgetpos64 d_fgetpos64
7973         eval $inlibc
7974
7975         : see if fopen64 exists
7976         set freopen64 d_fopen64
7977         eval $inlibc
7978
7979         : see if freopen64 exists
7980         set freopen64 d_freopen64
7981         eval $inlibc
7982
7983         : see if fseek64 exists
7984         set fseek64 d_fseek64
7985         eval $inlibc
7986
7987         : see if fseeko64 exists
7988         set fseeko64 d_fseeko64
7989         eval $inlibc
7990
7991         : see if fsetpos64 exists
7992         set fsetpos64 d_fsetpos64
7993         eval $inlibc
7994
7995         : see if ftell64 exists
7996         set ftell64 d_ftell64
7997         eval $inlibc
7998
7999         : see if ftello64 exists
8000         set ftello64 d_ftello64
8001         eval $inlibc
8002
8003         : see if tmpfile64 exists
8004         set tmpfile64 d_tmpfile64
8005         eval $inlibc
8006 else
8007         val="$undef"
8008         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
8009         do
8010                 set $xxx
8011                 eval $setvar
8012         done
8013 fi
8014
8015 : see if flock exists
8016 set flock d_flock
8017 eval $inlibc
8018
8019 : see if fork exists
8020 set fork d_fork
8021 eval $inlibc
8022
8023 : see if pathconf exists
8024 set pathconf d_pathconf
8025 eval $inlibc
8026
8027 : see if fpathconf exists
8028 set fpathconf d_fpathconf
8029 eval $inlibc
8030
8031 : see if fseeko exists
8032 set fseeko d_fseeko
8033 eval $inlibc
8034
8035 : see if fsetpos exists
8036 set fsetpos d_fsetpos
8037 eval $inlibc
8038
8039 : see if this is a sys/param system
8040 set sys/param.h i_sysparam
8041 eval $inhdr
8042
8043 : see if this is a sys/mount.h system
8044 set sys/mount.h i_sysmount
8045 eval $inhdr
8046
8047
8048 : see if statfs exists
8049 set statfs d_statfs
8050 eval $inlibc
8051
8052 : see if fstatfs exists
8053 set fstatfs d_fstatfs
8054 eval $inlibc
8055
8056 : see if statfs knows about mount flags
8057 set d_statfsflags statfs f_flags $i_sysparam sys/param.h $i_sysmount sys/mount.h
8058 eval $hasfield
8059
8060
8061 : see if statvfs exists
8062 set statvfs d_statvfs
8063 eval $inlibc
8064
8065 : see if fstatvfs exists
8066 set fstatvfs d_fstatvfs
8067 eval $inlibc
8068
8069
8070 : see if ftello exists
8071 set ftello d_ftello
8072 eval $inlibc
8073
8074 : see if getgrent exists
8075 set getgrent d_getgrent
8076 eval $inlibc
8077
8078 : see if gethostbyaddr exists
8079 set gethostbyaddr d_gethbyaddr
8080 eval $inlibc
8081
8082 : see if gethostbyname exists
8083 set gethostbyname d_gethbyname
8084 eval $inlibc
8085
8086 : see if gethostent exists
8087 set gethostent d_gethent
8088 eval $inlibc
8089
8090 : see how we will look up host name
8091 echo " "
8092 call=''
8093 if set gethostname val -f d_gethname; eval $csym; $val; then
8094         echo 'gethostname() found.' >&4
8095         d_gethname="$define"
8096         call=gethostname
8097 fi
8098 if set uname val -f d_uname; eval $csym; $val; then
8099         if ./xenix; then
8100                 $cat <<'EOM'
8101 uname() was found, but you're running xenix, and older versions of xenix
8102 have a broken uname(). If you don't really know whether your xenix is old
8103 enough to have a broken system call, use the default answer.
8104
8105 EOM
8106                 dflt=y
8107                 case "$d_uname" in
8108                 "$define") dflt=n;;
8109                 esac
8110                 rp='Is your uname() broken?'
8111                 . ./myread
8112                 case "$ans" in
8113                 n*) d_uname="$define"; call=uname;;
8114                 esac
8115         else
8116                 echo 'uname() found.' >&4
8117                 d_uname="$define"
8118                 case "$call" in
8119                 '') call=uname ;;
8120                 esac
8121         fi
8122 fi
8123 case "$d_gethname" in
8124 '') d_gethname="$undef";;
8125 esac
8126 case "$d_uname" in
8127 '') d_uname="$undef";;
8128 esac
8129 case "$d_uname$d_gethname" in
8130 *define*)
8131         dflt=n
8132         cat <<EOM
8133  
8134 Every now and then someone has a $call() that lies about the hostname
8135 but can't be fixed for political or economic reasons.  If you wish, I can
8136 pretend $call() isn't there and maybe compute hostname at run-time
8137 thanks to the '$phostname' command.
8138
8139 EOM
8140         rp="Shall I ignore $call() from now on?"
8141         . ./myread
8142         case "$ans" in
8143         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
8144         esac;;
8145 esac
8146 case "$phostname" in
8147 '') aphostname='';;
8148 *) case "$aphostname" in
8149         /*) ;;
8150         *) set X $phostname
8151                 shift
8152                 file=$1
8153                 shift
8154                 file=`./loc $file $file $pth`
8155                 aphostname=`echo $file $*`
8156                 ;;
8157         esac
8158         ;;
8159 esac
8160 case "$d_uname$d_gethname" in
8161 *define*) ;;
8162 *)
8163         case "$phostname" in
8164         '')
8165                 echo "There will be no way for $package to get your hostname." >&4;;
8166         *)
8167         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
8168                 ;;
8169         esac;;
8170 esac
8171 case "$d_phostname" in
8172 '') d_phostname="$undef";;
8173 esac
8174
8175 : see if this is a netdb.h system
8176 set netdb.h i_netdb
8177 eval $inhdr
8178
8179 : see if prototypes for various gethostxxx netdb.h functions are available
8180 echo " "
8181 set d_gethostprotos gethostent $i_netdb netdb.h
8182 eval $hasproto
8183
8184 : see if getlogin exists
8185 set getlogin d_getlogin
8186 eval $inlibc
8187
8188 : see if getmntent exists
8189 set getmntent d_getmntent
8190 eval $inlibc
8191
8192 : see if getnetbyaddr exists
8193 set getnetbyaddr d_getnbyaddr
8194 eval $inlibc
8195
8196 : see if getnetbyname exists
8197 set getnetbyname d_getnbyname
8198 eval $inlibc
8199
8200 : see if getnetent exists
8201 set getnetent d_getnent
8202 eval $inlibc
8203
8204 : see if prototypes for various getnetxxx netdb.h functions are available
8205 echo " "
8206 set d_getnetprotos getnetent $i_netdb netdb.h
8207 eval $hasproto
8208
8209
8210 : see if getprotobyname exists
8211 set getprotobyname d_getpbyname
8212 eval $inlibc
8213
8214 : see if getprotobynumber exists
8215 set getprotobynumber d_getpbynumber
8216 eval $inlibc
8217
8218 : see if getprotoent exists
8219 set getprotoent d_getpent
8220 eval $inlibc
8221
8222 : see if getpgid exists
8223 set getpgid d_getpgid
8224 eval $inlibc
8225
8226 : see if getpgrp2 exists
8227 set getpgrp2 d_getpgrp2
8228 eval $inlibc
8229
8230 : see if getppid exists
8231 set getppid d_getppid
8232 eval $inlibc
8233
8234 : see if getpriority exists
8235 set getpriority d_getprior
8236 eval $inlibc
8237
8238 : see if prototypes for various getprotoxxx netdb.h functions are available
8239 echo " "
8240 set d_getprotoprotos getprotoent $i_netdb netdb.h
8241 eval $hasproto
8242
8243 : see if getpwent exists
8244 set getpwent d_getpwent
8245 eval $inlibc
8246
8247
8248 : see if getservbyname exists
8249 set getservbyname d_getsbyname
8250 eval $inlibc
8251
8252 : see if getservbyport exists
8253 set getservbyport d_getsbyport
8254 eval $inlibc
8255
8256 : see if getservent exists
8257 set getservent d_getsent
8258 eval $inlibc
8259
8260 : see if prototypes for various getservxxx netdb.h functions are available
8261 echo " "
8262 set d_getservprotos getservent $i_netdb netdb.h
8263 eval $hasproto
8264
8265 : see if gettimeofday or ftime exists
8266 set gettimeofday d_gettimeod
8267 eval $inlibc
8268 case "$d_gettimeod" in
8269 "$undef")
8270         set ftime d_ftime 
8271         eval $inlibc
8272         ;;
8273 *)
8274         val="$undef"; set d_ftime; eval $setvar
8275         ;;
8276 esac
8277 case "$d_gettimeod$d_ftime" in
8278 "$undef$undef")
8279         echo " "
8280         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8281         ;;
8282 esac
8283
8284 : see if this is an grp system
8285 set grp.h i_grp
8286 eval $inhdr
8287
8288 case "$i_grp" in
8289 $define)
8290         xxx=`./findhdr grp.h`
8291         $cppstdin $cppflags $cppminus < $xxx >$$.h
8292
8293         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8294                 val="$define"
8295         else
8296                 val="$undef"
8297         fi
8298         set d_grpasswd
8299         eval $setvar
8300
8301         $rm -f $$.h
8302         ;;
8303 *)
8304         val="$undef";
8305         set d_grpasswd; eval $setvar
8306         ;;
8307 esac
8308
8309 : see if hasmntopt exists
8310 set hasmntopt d_hasmntopt
8311 eval $inlibc
8312
8313 : see if this is a netinet/in.h or sys/in.h system
8314 set netinet/in.h i_niin sys/in.h i_sysin
8315 eval $inhdr
8316
8317 : see if arpa/inet.h has to be included
8318 set arpa/inet.h i_arpainet
8319 eval $inhdr
8320
8321 : see if htonl --and friends-- exists
8322 val=''
8323 set htonl val
8324 eval $inlibc
8325
8326 : Maybe they are macros.
8327 case "$val" in
8328 $undef)
8329         $cat >htonl.c <<EOM
8330 #include <stdio.h>
8331 #include <sys/types.h>
8332 #$i_niin I_NETINET_IN
8333 #$i_sysin I_SYS_IN
8334 #$i_arpainet I_ARPA_INET
8335 #ifdef I_NETINET_IN
8336 #include <netinet/in.h>
8337 #endif
8338 #ifdef I_SYS_IN
8339 #include <sys/in.h>
8340 #endif
8341 #ifdef I_ARPA_INET
8342 #include <arpa/inet.h>
8343 #endif
8344 #ifdef htonl
8345 printf("Defined as a macro.");
8346 #endif
8347 EOM
8348         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8349         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8350                 val="$define"
8351                 echo "But it seems to be defined as a macro." >&4
8352         fi
8353         $rm -f htonl.?
8354         ;;
8355 esac
8356 set d_htonl
8357 eval $setvar
8358
8359 : see which of string.h or strings.h is needed
8360 echo " "
8361 strings=`./findhdr string.h`
8362 if $test "$strings" && $test -r "$strings"; then
8363         echo "Using <string.h> instead of <strings.h>." >&4
8364         val="$define"
8365 else
8366         val="$undef"
8367         strings=`./findhdr strings.h`
8368         if $test "$strings" && $test -r "$strings"; then
8369                 echo "Using <strings.h> instead of <string.h>." >&4
8370         else
8371                 echo "No string header found -- You'll surely have problems." >&4
8372         fi
8373 fi
8374 set i_string
8375 eval $setvar
8376 case "$i_string" in
8377 "$undef") strings=`./findhdr strings.h`;;
8378 *)        strings=`./findhdr string.h`;;
8379 esac
8380
8381 : index or strchr
8382 echo " "
8383 if set index val -f; eval $csym; $val; then
8384         if set strchr val -f d_strchr; eval $csym; $val; then
8385                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8386                         val="$define"
8387                         vali="$undef"
8388                         echo "strchr() found." >&4
8389                 else
8390                         val="$undef"
8391                         vali="$define"
8392                         echo "index() found." >&4
8393                 fi
8394         else
8395                 val="$undef"
8396                 vali="$define"
8397                 echo "index() found." >&4
8398         fi
8399 else
8400         if set strchr val -f d_strchr; eval $csym; $val; then
8401                 val="$define"
8402                 vali="$undef"
8403                 echo "strchr() found." >&4
8404         else
8405                 echo "No index() or strchr() found!" >&4
8406                 val="$undef"
8407                 vali="$undef"
8408         fi
8409 fi
8410 set d_strchr; eval $setvar
8411 val="$vali"
8412 set d_index; eval $setvar
8413
8414 : check whether inet_aton exists
8415 set inet_aton d_inetaton
8416 eval $inlibc
8417
8418 : see if inttypes.h is available
8419 : we want a real compile instead of Inhdr because some systems
8420 : have an inttypes.h which includes non-existent headers
8421 echo " "
8422 $cat >try.c <<EOCP
8423 #include <inttypes.h>
8424 int main() {
8425         static int32_t foo32 = 0x12345678;
8426 }
8427 EOCP
8428 set try
8429 if eval $compile; then
8430         echo "<inttypes.h> found." >&4
8431         val="$define"
8432 else
8433         echo "<inttypes.h> NOT found." >&4
8434         val="$undef"
8435 fi
8436 $rm -f try.c try
8437 set i_inttypes
8438 eval $setvar
8439
8440 : check for int64_t
8441 case "$use64bits" in
8442 "$define" )
8443         echo " "
8444         echo $n "Checking to see if your system supports int64_t...$c" >&4
8445         $cat >try.c <<EOCP
8446 #include <sys/types.h>
8447 #$i_inttypes I_INTTYPES
8448 #ifdef I_INTTYPES
8449 #include <inttypes.h>
8450 #endif
8451 int64_t foo() { int64_t x; x = 7; return x; }
8452 EOCP
8453         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8454                 val="$define"
8455                 echo " Yup, it does." >&4
8456         else
8457                 val="$undef"
8458                 echo " Nope, it doesn't." >&4
8459         fi
8460         $rm -f try.*
8461         ;;
8462 *)      val="$undef"
8463         ;;
8464 esac
8465 set d_int64t
8466 eval $setvar
8467
8468
8469 : Look for isascii
8470 echo " "
8471 $cat >isascii.c <<'EOCP'
8472 #include <stdio.h>
8473 #include <ctype.h>
8474 int main() {
8475         int c = 'A';
8476         if (isascii(c))
8477                 exit(0);
8478         else
8479                 exit(1);
8480 }
8481 EOCP
8482 set isascii
8483 if eval $compile; then
8484         echo "isascii() found." >&4
8485         val="$define"
8486 else
8487         echo "isascii() NOT found." >&4
8488         val="$undef"
8489 fi
8490 set d_isascii
8491 eval $setvar
8492 $rm -f isascii*
8493
8494 : see if killpg exists
8495 set killpg d_killpg
8496 eval $inlibc
8497
8498 : see if lchown exists
8499 echo " "
8500 $cat > try.c <<'EOCP'
8501 /* System header to define __stub macros and hopefully few prototypes,
8502     which can conflict with char lchown(); below.  */
8503 #include <assert.h>
8504 /* Override any gcc2 internal prototype to avoid an error.  */
8505 /* We use char because int might match the return type of a gcc2
8506    builtin and then its argument prototype would still apply.  */
8507 char lchown();
8508 int main() {
8509     /*  The GNU C library defines this for functions which it implements
8510         to always fail with ENOSYS.  Some functions are actually named
8511         something starting with __ and the normal name is an alias.  */
8512 #if defined (__stub_lchown) || defined (__stub___lchown)
8513 choke me
8514 #else
8515 lchown();
8516 #endif
8517 ; return 0; }
8518 EOCP
8519 set try
8520 if eval $compile; then
8521     $echo "lchown() found." >&4
8522     val="$define"
8523 else
8524     $echo "lchown() NOT found." >&4
8525     val="$undef"
8526 fi
8527 set d_lchown
8528 eval $setvar
8529
8530 : see if link exists
8531 set link d_link
8532 eval $inlibc
8533
8534 : see if localeconv exists
8535 set localeconv d_locconv
8536 eval $inlibc
8537
8538 : see if lockf exists
8539 set lockf d_lockf
8540 eval $inlibc
8541
8542 : check for length of double
8543 echo " "
8544 case "$doublesize" in
8545 '')
8546         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8547         $cat >try.c <<'EOCP'
8548 #include <stdio.h>
8549 int main()
8550 {
8551         printf("%d\n", sizeof(double));
8552 }
8553 EOCP
8554         set try
8555         if eval $compile_ok; then
8556                 doublesize=`./try`
8557                 $echo " $doublesize bytes." >&4
8558         else
8559                 dflt='8'
8560                 echo "(I can't seem to compile the test program.  Guessing...)"
8561                 rp="What is the size of a double precision number (in bytes)?"
8562                 . ./myread
8563                 doublesize="$ans"
8564         fi
8565         ;;
8566 esac
8567 $rm -f try.c try
8568
8569 : check for long doubles
8570 echo " "
8571 echo $n "Checking to see if your system supports long doubles...$c" >&4
8572 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8573 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8574         val="$define"
8575         echo " Yup, it does." >&4
8576 else
8577         val="$undef"
8578         echo " Nope, it doesn't." >&4
8579 fi
8580 $rm try.*
8581 set d_longdbl
8582 eval $setvar
8583
8584 : check for length of long double
8585 case "${d_longdbl}${longdblsize}" in
8586 $define)
8587         echo " "
8588         $echo $n "Checking to see how big your long doubles are...$c" >&4
8589         $cat >try.c <<'EOCP'
8590 #include <stdio.h>
8591 int main()
8592 {
8593         printf("%d\n", sizeof(long double));
8594 }
8595 EOCP
8596         set try
8597         if eval $compile; then
8598                 longdblsize=`./try`
8599                 $echo " $longdblsize bytes." >&4
8600         else
8601                 dflt='8'
8602                 echo " "
8603                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8604                 rp="What is the size of a long double (in bytes)?"
8605                 . ./myread
8606                 longdblsize="$ans"
8607         fi
8608         if $test "X$doublesize" = "X$longdblsize"; then
8609                 echo "(That isn't any different from an ordinary double.)"
8610         fi      
8611         ;;
8612 esac
8613 $rm -f try.c try
8614
8615 : check for long long
8616 echo " "
8617 echo $n "Checking to see if your system supports long long...$c" >&4
8618 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8619 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8620         val="$define"
8621         echo " Yup, it does." >&4
8622 else
8623         val="$undef"
8624         echo " Nope, it doesn't." >&4
8625 fi
8626 $rm try.*
8627 set d_longlong
8628 eval $setvar
8629
8630 : check for length of long long
8631 case "${d_longlong}${longlongsize}" in
8632 $define)
8633         echo " "
8634         $echo $n "Checking to see how big your long longs are...$c" >&4
8635         $cat >try.c <<'EOCP'
8636 #include <stdio.h>
8637 int main()
8638 {
8639         printf("%d\n", sizeof(long long));
8640 }
8641 EOCP
8642         set try
8643         if eval $compile_ok; then
8644                 longlongsize=`./try`
8645                 $echo " $longlongsize bytes." >&4
8646         else
8647                 dflt='8'
8648                 echo " "
8649                 echo "(I can't seem to compile the test program.  Guessing...)"
8650                 rp="What is the size of a long long (in bytes)?"
8651                 . ./myread
8652                 longlongsize="$ans"
8653         fi
8654         if $test "X$longsize" = "X$longlongsize"; then
8655                 echo "(That isn't any different from an ordinary long.)"
8656         fi      
8657         ;;
8658 esac
8659 $rm -f try.c try
8660
8661 : see if lstat exists
8662 set lstat d_lstat
8663 eval $inlibc
8664
8665 : see if madvise exists
8666 set madvise d_madvise
8667 eval $inlibc
8668
8669 : see if mblen exists
8670 set mblen d_mblen
8671 eval $inlibc
8672
8673 : see if mbstowcs exists
8674 set mbstowcs d_mbstowcs
8675 eval $inlibc
8676
8677 : see if mbtowc exists
8678 set mbtowc d_mbtowc
8679 eval $inlibc
8680
8681 : see if memcmp exists
8682 set memcmp d_memcmp
8683 eval $inlibc
8684
8685 : see if memcpy exists
8686 set memcpy d_memcpy
8687 eval $inlibc
8688
8689 : see if memmove exists
8690 set memmove d_memmove
8691 eval $inlibc
8692
8693 : see if memset exists
8694 set memset d_memset
8695 eval $inlibc
8696
8697 : see if mkdir exists
8698 set mkdir d_mkdir
8699 eval $inlibc
8700
8701 : see if mkfifo exists
8702 set mkfifo d_mkfifo
8703 eval $inlibc
8704
8705 : see if mktime exists
8706 set mktime d_mktime
8707 eval $inlibc
8708
8709 : see if this is a sys/mman.h system
8710 set sys/mman.h i_sysmman
8711 eval $inhdr
8712
8713 : see if mmap exists
8714 set mmap d_mmap
8715 eval $inlibc
8716 : see what shmat returns
8717 : default to something harmless
8718 mmaptype='void *'
8719 case "$i_sysmman$d_mmap" in
8720 "$define$define")
8721         $cat >mmap.c <<'END'
8722 #include <sys/mman.h>
8723 void *mmap();
8724 END
8725         if $cc $ccflags -c mmap.c >/dev/null 2>&1; then
8726                 mmaptype='void *'
8727         else
8728                 mmaptype='caddr_t'
8729         fi
8730         echo "and it returns ($mmaptype)." >&4
8731         ;;
8732 esac
8733
8734
8735
8736 : see if mprotect exists
8737 set mprotect d_mprotect
8738 eval $inlibc
8739
8740 : see if msgctl exists
8741 set msgctl d_msgctl
8742 eval $inlibc
8743
8744 : see if msgget exists
8745 set msgget d_msgget
8746 eval $inlibc
8747
8748 : see if msgsnd exists
8749 set msgsnd d_msgsnd
8750 eval $inlibc
8751
8752 : see if msgrcv exists
8753 set msgrcv d_msgrcv
8754 eval $inlibc
8755
8756 : see how much of the 'msg*(2)' library is present.
8757 h_msg=true
8758 echo " "
8759 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8760 *"$undef"*) h_msg=false;;
8761 esac
8762 case "$osname" in
8763 freebsd)
8764     case "`ipcs 2>&1`" in
8765     "SVID messages"*"not configured"*)
8766         echo "Your $osname does not have the msg*(2) configured." >&4
8767         h_msg=false
8768         val="$undef"
8769         set msgctl d_msgctl
8770         eval $setvar
8771         set msgget d_msgget
8772         eval $setvar
8773         set msgsnd d_msgsnd
8774         eval $setvar
8775         set msgrcv d_msgrcv
8776         eval $setvar
8777         ;;
8778     esac
8779     ;;
8780 esac
8781 : we could also check for sys/ipc.h ...
8782 if $h_msg && $test `./findhdr sys/msg.h`; then
8783         echo "You have the full msg*(2) library." >&4
8784         val="$define"
8785 else
8786         echo "You don't have the full msg*(2) library." >&4
8787         val="$undef"
8788 fi
8789 set d_msg
8790 eval $setvar
8791
8792 : see if msync exists
8793 set msync d_msync
8794 eval $inlibc
8795
8796 : see if munmap exists
8797 set munmap d_munmap
8798 eval $inlibc
8799
8800 : see if nice exists
8801 set nice d_nice
8802 eval $inlibc
8803
8804 : see if POSIX threads are available
8805 if test "X$usethreads" = "X$define"; then
8806         set pthread.h i_pthread
8807         eval $inhdr
8808 else
8809         i_pthread="$undef"
8810 fi
8811
8812
8813
8814 : how to create joinable pthreads
8815 if test "X$usethreads" = "X$define" -a "X$i_pthread" = "X$define"; then
8816         echo " "
8817         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8818         $cat >try.c <<'EOCP'
8819 #include <pthread.h>
8820 int main() {
8821     int detachstate = JOINABLE;
8822 }
8823 EOCP
8824         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8825         if eval $compile; then
8826                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&4
8827                 val="$undef" # Yes, undef.
8828                 set d_old_pthread_create_joinable
8829                 eval $setvar
8830                 val=""
8831                 set old_pthread_create_joinable
8832                 eval $setvar
8833         else
8834                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8835                 if eval $compile; then
8836                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&4
8837                         val="$define"
8838                         set d_old_pthread_create_joinable
8839                         eval $setvar
8840                         val=PTHREAD_CREATE_UNDETACHED
8841                         set old_pthread_create_joinable
8842                         eval $setvar
8843                 else            
8844                         set try -DJOINABLE=__UNDETACHED
8845                         if eval $compile; then
8846                                 echo "You seem to use __UNDETACHED." >&4
8847                                 val="$define"
8848                                 set d_old_pthread_create_joinable
8849                                 eval $setvar
8850                                 val=__UNDETACHED
8851                                 set old_pthread_create_joinable
8852                                 eval $setvar
8853                         else
8854                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&4
8855                                 val="$define"
8856                                 set d_old_pthread_create_joinable
8857                                 eval $setvar
8858                                 val=0
8859                                 set old_pthread_create_joinable
8860                                 eval $setvar
8861                         fi
8862                 fi
8863         fi
8864         $rm -f try try.*
8865 else
8866     d_old_pthread_create_joinable="$undef"
8867     old_pthread_create_joinable=""
8868 fi
8869
8870 : see if pause exists
8871 set pause d_pause
8872 eval $inlibc
8873
8874 : see if pipe exists
8875 set pipe d_pipe
8876 eval $inlibc
8877
8878 : see if poll exists
8879 set poll d_poll
8880 eval $inlibc
8881
8882
8883 : see whether the various POSIXish _yields exist
8884 $cat >try.c <<EOP
8885 #include <pthread.h>
8886 #include <stdio.h>
8887 int main() {
8888 #ifdef SCHED_YIELD
8889         sched_yield();
8890 #else
8891 #ifdef PTHREAD_YIELD
8892         pthread_yield();
8893 #else
8894 #ifdef PTHREAD_YIELD_NULL
8895         pthread_yield(NULL);
8896 #endif
8897 #endif
8898 #endif
8899 }
8900 EOP
8901 : see if sched_yield exists
8902 set try -DSCHED_YIELD
8903 if eval $compile; then
8904     val="$define"
8905     sched_yield='sched_yield()'
8906 else
8907     val="$undef"
8908 fi
8909 case "$usethreads" in
8910 $define)
8911         case "$val" in
8912         $define) echo 'sched_yield() found.' >&4        ;;
8913         *)       echo 'sched_yield() NOT found.' >&4    ;;
8914         esac
8915 esac
8916 set d_sched_yield
8917 eval $setvar
8918
8919 : see if pthread_yield exists
8920 set try -DPTHREAD_YIELD
8921 if eval $compile; then
8922     val="$define"
8923     case "$sched_yield" in
8924     '') sched_yield='pthread_yield()' ;;
8925     esac
8926 else
8927     set try -DPTHREAD_YIELD_NULL
8928     if eval $compile; then
8929         val="$define"
8930         case "$sched_yield" in
8931         '') sched_yield='pthread_yield(NULL)' ;;
8932         esac
8933     else
8934         val="$undef"
8935     fi
8936 fi
8937 case "$usethreads" in
8938 $define)
8939         case "$val" in
8940         $define) echo 'pthread_yield() found.' >&4      ;;
8941         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8942         esac
8943         ;;
8944 esac
8945 set d_pthread_yield
8946 eval $setvar
8947
8948 case "$sched_yield" in
8949 '') sched_yield=undef ;;
8950 esac
8951
8952 $rm -f try try.*
8953
8954 : see if this is a pwd.h system
8955 set pwd.h i_pwd
8956 eval $inhdr
8957
8958 case "$i_pwd" in
8959 $define)
8960         xxx=`./findhdr pwd.h`
8961         $cppstdin $cppflags $cppminus < $xxx >$$.h
8962
8963         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8964                 val="$define"
8965         else
8966                 val="$undef"
8967         fi
8968         set d_pwquota
8969         eval $setvar
8970
8971         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
8972                 val="$define"
8973         else
8974                 val="$undef"
8975         fi
8976         set d_pwage
8977         eval $setvar
8978
8979         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
8980                 val="$define"
8981         else
8982                 val="$undef"
8983         fi
8984         set d_pwchange
8985         eval $setvar
8986
8987         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
8988                 val="$define"
8989         else
8990                 val="$undef"
8991         fi
8992         set d_pwclass
8993         eval $setvar
8994
8995         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
8996                 val="$define"
8997         else
8998                 val="$undef"
8999         fi
9000         set d_pwexpire
9001         eval $setvar
9002
9003         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
9004                 val="$define"
9005         else
9006                 val="$undef"
9007         fi
9008         set d_pwcomment
9009         eval $setvar
9010
9011         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
9012                 val="$define"
9013         else
9014                 val="$undef"
9015         fi
9016         set d_pwgecos
9017         eval $setvar
9018
9019         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
9020                 val="$define"
9021         else
9022                 val="$undef"
9023         fi
9024         set d_pwpasswd
9025         eval $setvar
9026
9027         $rm -f $$.h
9028         ;;
9029 *)
9030         val="$undef"; 
9031         set d_pwquota; eval $setvar
9032         set d_pwage; eval $setvar
9033         set d_pwchange; eval $setvar
9034         set d_pwclass; eval $setvar
9035         set d_pwexpire; eval $setvar
9036         set d_pwcomment; eval $setvar
9037         set d_pwgecos; eval $setvar
9038         set d_pwpasswd; eval $setvar
9039         ;;
9040 esac
9041
9042 : see if readdir and friends exist
9043 set readdir d_readdir
9044 eval $inlibc
9045 set seekdir d_seekdir
9046 eval $inlibc
9047 set telldir d_telldir
9048 eval $inlibc
9049 set rewinddir d_rewinddir
9050 eval $inlibc
9051
9052 : see if readlink exists
9053 set readlink d_readlink
9054 eval $inlibc
9055
9056 : see if readv exists
9057 set readv d_readv
9058 eval $inlibc
9059
9060 : see if rename exists
9061 set rename d_rename
9062 eval $inlibc
9063
9064 : see if rmdir exists
9065 set rmdir d_rmdir
9066 eval $inlibc
9067
9068 : see if memory.h is available.
9069 val=''
9070 set memory.h val
9071 eval $inhdr
9072
9073 : See if it conflicts with string.h
9074 case "$val" in
9075 $define)
9076         case "$strings" in
9077         '') ;;
9078         *)
9079                 $cppstdin $cppflags $cppminus < $strings > mem.h
9080                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
9081                         echo " "
9082                         echo "We won't be including <memory.h>."
9083                         val="$undef"
9084                 fi
9085                 $rm -f mem.h
9086                 ;;
9087         esac
9088 esac
9089 set i_memory
9090 eval $setvar
9091
9092 : can bcopy handle overlapping blocks?
9093 val="$undef"
9094 case "$d_bcopy" in
9095 "$define")
9096         echo " "
9097         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
9098         $cat >try.c <<EOCP
9099 #$i_memory I_MEMORY
9100 #$i_stdlib I_STDLIB
9101 #$i_string I_STRING
9102 #$i_unistd I_UNISTD
9103 EOCP
9104         $cat >>try.c <<'EOCP'
9105 #include <stdio.h>
9106 #ifdef I_MEMORY
9107 #  include <memory.h>
9108 #endif
9109 #ifdef I_STDLIB
9110 #  include <stdlib.h>
9111 #endif
9112 #ifdef I_STRING
9113 #  include <string.h>
9114 #else
9115 #  include <strings.h>
9116 #endif
9117 #ifdef I_UNISTD
9118 #  include <unistd.h>  /* Needed for NetBSD */
9119 #endif
9120 int main()
9121 {
9122 char buf[128], abc[128];
9123 char *b;
9124 int len;
9125 int off;
9126 int align;
9127
9128 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
9129
9130 for (align = 7; align >= 0; align--) {
9131         for (len = 36; len; len--) {
9132                 b = buf+align;
9133                 bcopy(abc, b, len);
9134                 for (off = 1; off <= len; off++) {
9135                         bcopy(b, b+off, len);
9136                         bcopy(b+off, b, len);
9137                         if (bcmp(b, abc, len))
9138                                 exit(1);
9139                 }
9140         }
9141 }
9142 exit(0);
9143 }
9144 EOCP
9145         set try
9146         if eval $compile_ok; then
9147                 if ./try 2>/dev/null; then
9148                         echo "Yes, it can."
9149                         val="$define"
9150                 else
9151                         echo "It can't, sorry."
9152                         case "$d_memmove" in
9153                         "$define") echo "But that's Ok since you have memmove()." ;;
9154                         esac
9155                 fi
9156         else
9157                 echo "(I can't compile the test program, so we'll assume not...)"
9158                 case "$d_memmove" in
9159                 "$define") echo "But that's Ok since you have memmove()." ;;
9160                 esac
9161         fi
9162         ;;
9163 esac
9164 $rm -f try.* try core
9165 set d_safebcpy
9166 eval $setvar
9167
9168 : can memcpy handle overlapping blocks?
9169 val="$undef"
9170 case "$d_memcpy" in
9171 "$define")
9172         echo " "
9173         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
9174         $cat >try.c <<EOCP
9175 #$i_memory I_MEMORY
9176 #$i_stdlib I_STDLIB
9177 #$i_string I_STRING
9178 #$i_unistd I_UNISTD
9179 EOCP
9180         $cat >>try.c <<'EOCP'
9181 #include <stdio.h>
9182 #ifdef I_MEMORY
9183 #  include <memory.h>
9184 #endif
9185 #ifdef I_STDLIB
9186 #  include <stdlib.h>
9187 #endif
9188 #ifdef I_STRING
9189 #  include <string.h>
9190 #else
9191 #  include <strings.h>
9192 #endif
9193 #ifdef I_UNISTD
9194 #  include <unistd.h>  /* Needed for NetBSD */
9195 #endif
9196 int main()
9197 {
9198 char buf[128], abc[128];
9199 char *b;
9200 int len;
9201 int off;
9202 int align;
9203
9204 /* Copy "abcde..." string to char abc[] so that gcc doesn't
9205    try to store the string in read-only memory. */
9206 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
9207
9208 for (align = 7; align >= 0; align--) {
9209         for (len = 36; len; len--) {
9210                 b = buf+align;
9211                 memcpy(b, abc, len);
9212                 for (off = 1; off <= len; off++) {
9213                         memcpy(b+off, b, len);
9214                         memcpy(b, b+off, len);
9215                         if (memcmp(b, abc, len))
9216                                 exit(1);
9217                 }
9218         }
9219 }
9220 exit(0);
9221 }
9222 EOCP
9223         set try
9224         if eval $compile_ok; then
9225                 if ./try 2>/dev/null; then
9226                         echo "Yes, it can."
9227                         val="$define"
9228                 else
9229                         echo "It can't, sorry."
9230                         case "$d_memmove" in
9231                         "$define") echo "But that's Ok since you have memmove()." ;;
9232                         esac
9233                 fi
9234         else
9235                 echo "(I can't compile the test program, so we'll assume not...)"
9236                 case "$d_memmove" in
9237                 "$define") echo "But that's Ok since you have memmove()." ;;
9238                 esac
9239         fi
9240         ;;
9241 esac
9242 $rm -f try.* try core
9243 set d_safemcpy
9244 eval $setvar
9245
9246 : can memcmp be trusted to compare relative magnitude?
9247 val="$undef"
9248 case "$d_memcmp" in
9249 "$define")
9250         echo " "
9251         echo "Checking if your memcmp() can compare relative magnitude..." >&4
9252         $cat >try.c <<EOCP
9253 #$i_memory I_MEMORY
9254 #$i_stdlib I_STDLIB
9255 #$i_string I_STRING
9256 #$i_unistd I_UNISTD
9257 EOCP
9258         $cat >>try.c <<'EOCP'
9259 #include <stdio.h>
9260 #ifdef I_MEMORY
9261 #  include <memory.h>
9262 #endif
9263 #ifdef I_STDLIB
9264 #  include <stdlib.h>
9265 #endif
9266 #ifdef I_STRING
9267 #  include <string.h>
9268 #else
9269 #  include <strings.h>
9270 #endif
9271 #ifdef I_UNISTD
9272 #  include <unistd.h>  /* Needed for NetBSD */
9273 #endif
9274 int main()
9275 {
9276 char a = -1;
9277 char b = 0;
9278 if ((a < b) && memcmp(&a, &b, 1) < 0)
9279         exit(1);
9280 exit(0);
9281 }
9282 EOCP
9283         set try
9284         if eval $compile_ok; then
9285                 if ./try 2>/dev/null; then
9286                         echo "Yes, it can."
9287                         val="$define"
9288                 else
9289                         echo "No, it can't (it uses signed chars)."
9290                 fi
9291         else
9292                 echo "(I can't compile the test program, so we'll assume not...)"
9293         fi
9294         ;;
9295 esac
9296 $rm -f try.* try core
9297 set d_sanemcmp
9298 eval $setvar
9299
9300 : see if select exists
9301 set select d_select
9302 eval $inlibc
9303
9304 : see if semctl exists
9305 set semctl d_semctl
9306 eval $inlibc
9307
9308 : see if semget exists
9309 set semget d_semget
9310 eval $inlibc
9311
9312 : see if semop exists
9313 set semop d_semop
9314 eval $inlibc
9315
9316 : see how much of the 'sem*(2)' library is present.
9317 h_sem=true
9318 echo " "
9319 case "$d_semctl$d_semget$d_semop" in
9320 *"$undef"*) h_sem=false;;
9321 esac
9322 case "$osname" in
9323 freebsd)
9324     case "`ipcs 2>&1`" in
9325     "SVID messages"*"not configured"*)
9326         echo "Your $osname does not have the sem*(2) configured." >&4
9327         h_sem=false
9328         val="$undef"
9329         set semctl d_semctl
9330         eval $setvar
9331         set semget d_semget
9332         eval $setvar
9333         set semop d_semop
9334         eval $setvar
9335         ;;
9336     esac
9337     ;;
9338 esac
9339 : we could also check for sys/ipc.h ...
9340 if $h_sem && $test `./findhdr sys/sem.h`; then
9341         echo "You have the full sem*(2) library." >&4
9342         val="$define"
9343 else
9344         echo "You don't have the full sem*(2) library." >&4
9345         val="$undef"
9346 fi
9347 set d_sem
9348 eval $setvar
9349
9350 : see whether sys/sem.h defines union semun
9351 echo " "
9352 $cat > try.c <<'END'
9353 #include <sys/types.h>
9354 #include <sys/ipc.h>
9355 #include <sys/sem.h>
9356 int main () { union semun semun; semun.buf = 0; }
9357 END
9358 set try
9359 if eval $compile; then
9360     echo "You have union semun in <sys/sem.h>." >&4
9361     val="$define"
9362 else
9363     echo "You do not have union semun in <sys/sem.h>." >&4
9364     val="$undef"
9365 fi
9366 $rm -f try try.c try.h
9367 set d_union_semun
9368 eval $setvar
9369
9370 : see how to do semctl IPC_STAT
9371 case "$d_sem" in
9372 $define)
9373     : see whether semctl IPC_STAT can use union semun
9374     echo " "
9375     $cat > try.h <<END
9376 #ifndef S_IRUSR
9377 #   ifdef S_IREAD
9378 #       define S_IRUSR S_IREAD
9379 #       define S_IWUSR S_IWRITE
9380 #       define S_IXUSR S_IEXEC
9381 #   else
9382 #       define S_IRUSR 0400
9383 #       define S_IWUSR 0200
9384 #       define S_IXUSR 0100
9385 #   endif
9386 #   define S_IRGRP (S_IRUSR>>3)
9387 #   define S_IWGRP (S_IWUSR>>3)
9388 #   define S_IXGRP (S_IXUSR>>3)
9389 #   define S_IROTH (S_IRUSR>>6)
9390 #   define S_IWOTH (S_IWUSR>>6)
9391 #   define S_IXOTH (S_IXUSR>>6)
9392 #endif
9393 #ifndef S_IRWXU
9394 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9395 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9396 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9397 #endif
9398 END
9399
9400     $cat > try.c <<END
9401 #include <sys/types.h>
9402 #include <sys/ipc.h>
9403 #include <sys/sem.h>
9404 #include <sys/stat.h>
9405 #include <stdio.h>
9406 #include <errno.h>
9407 #include "try.h"
9408 #ifndef errno
9409 extern int errno;
9410 #endif
9411 #$d_union_semun HAS_UNION_SEMUN
9412 int main() {
9413     union semun
9414 #ifndef HAS_UNION_SEMUN
9415     {
9416         int val;
9417         struct semid_ds *buf;
9418         unsigned short *array;
9419     }
9420 #endif
9421     arg;
9422     int sem, st;
9423
9424 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9425     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9426     if (sem > -1) {
9427         struct semid_ds argbuf;
9428         arg.buf = &argbuf;
9429 #       ifdef IPC_STAT
9430         st = semctl(sem, 0, IPC_STAT, arg);
9431         if (st == 0)
9432             printf("semun\n");
9433         else
9434 #       endif /* IPC_STAT */
9435             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9436 #       ifdef IPC_RMID
9437         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9438 #       endif /* IPC_RMID */
9439             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9440     } else
9441 #endif /* IPC_PRIVATE && ... */
9442         printf("semget failed: errno = %d\n", errno);
9443   return 0;
9444 }
9445 END
9446     val="$undef"
9447     set try
9448     if eval $compile; then
9449         xxx=`./try`
9450         case "$xxx" in
9451         semun) val="$define" ;;
9452         esac
9453     fi
9454     $rm -f try try.c
9455     set d_semctl_semun
9456     eval $setvar
9457     case "$d_semctl_semun" in
9458     $define)
9459         echo "You can use union semun for semctl IPC_STAT." >&4
9460         also='also'
9461         ;;
9462     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9463         also=''
9464         ;;
9465     esac
9466
9467     : see whether semctl IPC_STAT can use struct semid_ds pointer
9468     $cat > try.c <<'END'
9469 #include <sys/types.h>
9470 #include <sys/ipc.h>
9471 #include <sys/sem.h>
9472 #include <sys/stat.h>
9473 #include "try.h"
9474 #include <stdio.h>
9475 #include <errno.h>
9476 #ifndef errno
9477 extern int errno;
9478 #endif
9479 int main() {
9480     struct semid_ds arg;
9481     int sem, st;
9482
9483 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9484     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9485     if (sem > -1) {
9486 #       ifdef IPC_STAT
9487         st = semctl(sem, 0, IPC_STAT, &arg);
9488         if (st == 0)
9489             printf("semid_ds\n");
9490         else
9491 #       endif /* IPC_STAT */
9492             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9493 #       ifdef IPC_RMID
9494         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9495 #       endif /* IPC_RMID */
9496             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9497     } else
9498 #endif /* IPC_PRIVATE && ... */
9499         printf("semget failed: errno = %d\n", errno);
9500
9501     return 0;
9502 }
9503 END
9504     val="$undef"
9505     set try
9506     if eval $compile; then
9507         xxx=`./try`
9508         case "$xxx" in
9509         semid_ds) val="$define" ;;
9510         esac
9511     fi
9512     $rm -f try try.c
9513     set d_semctl_semid_ds
9514     eval $setvar
9515     case "$d_semctl_semid_ds" in
9516     $define)
9517         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9518         ;;
9519     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9520         ;;
9521     esac
9522     $rm -f try.h
9523     ;;
9524 *)  val="$undef"
9525
9526     # We do not have the full sem*(2) library, so assume we can not
9527     # use either.
9528
9529     set d_semctl_semun
9530     eval $setvar
9531
9532     set d_semctl_semid_ds
9533     eval $setvar
9534     ;;
9535 esac
9536
9537 : see if setegid exists
9538 set setegid d_setegid
9539 eval $inlibc
9540
9541 : see if seteuid exists
9542 set seteuid d_seteuid
9543 eval $inlibc
9544
9545 : see if setgrent exists
9546 set setgrent d_setgrent
9547 eval $inlibc
9548
9549 : see if sethostent exists
9550 set sethostent d_sethent
9551 eval $inlibc
9552
9553 : see if setlinebuf exists
9554 set setlinebuf d_setlinebuf
9555 eval $inlibc
9556
9557 : see if setlocale exists
9558 set setlocale d_setlocale
9559 eval $inlibc
9560
9561 : see if setnetent exists
9562 set setnetent d_setnent
9563 eval $inlibc
9564
9565 : see if setprotoent exists
9566 set setprotoent d_setpent
9567 eval $inlibc
9568
9569 : see if setpgid exists
9570 set setpgid d_setpgid
9571 eval $inlibc
9572
9573 : see if setpgrp2 exists
9574 set setpgrp2 d_setpgrp2
9575 eval $inlibc
9576
9577 : see if setpriority exists
9578 set setpriority d_setprior
9579 eval $inlibc
9580
9581 : see if setpwent exists
9582 set setpwent d_setpwent
9583 eval $inlibc
9584
9585 : see if setregid exists
9586 set setregid d_setregid
9587 eval $inlibc
9588 set setresgid d_setresgid
9589 eval $inlibc
9590
9591 : see if setreuid exists
9592 set setreuid d_setreuid
9593 eval $inlibc
9594 set setresuid d_setresuid
9595 eval $inlibc
9596
9597 : see if setrgid exists
9598 set setrgid d_setrgid
9599 eval $inlibc
9600
9601 : see if setruid exists
9602 set setruid d_setruid
9603 eval $inlibc
9604
9605 : see if setservent exists
9606 set setservent d_setsent
9607 eval $inlibc
9608
9609 : see if setsid exists
9610 set setsid d_setsid
9611 eval $inlibc
9612
9613 : see if setvbuf exists
9614 set setvbuf d_setvbuf
9615 eval $inlibc
9616
9617 : see if sfio.h is available
9618 set sfio.h i_sfio
9619 eval $inhdr
9620
9621
9622 : see if sfio library is available
9623 case "$i_sfio" in
9624 $define)
9625         val=''
9626         set sfreserve val
9627         eval $inlibc
9628         ;;
9629 *)
9630         val="$undef"
9631         ;;
9632 esac
9633 : Ok, but do we want to use it.
9634 case "$val" in
9635 $define)
9636         case "$usesfio" in
9637         true|$define|[yY]*) dflt='y';;
9638         *) dflt='n';;
9639         esac
9640         echo "$package can use the sfio library, but it is experimental."
9641         rp="You seem to have sfio available, do you want to try using it?"
9642         . ./myread
9643         case "$ans" in
9644         y|Y) ;;
9645         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9646                 val="$undef"
9647                 : Remove sfio from list of libraries to use
9648                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9649                 shift
9650                 libs="$*"
9651                 echo "libs = $libs" >&4
9652                 ;;
9653         esac
9654         ;;
9655 *)      case "$usesfio" in
9656         true|$define|[yY]*)
9657                 echo "Sorry, cannot find sfio on this machine" >&4
9658                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9659                 ;;
9660         esac
9661         ;;
9662 esac
9663 set d_sfio
9664 eval $setvar
9665 case "$d_sfio" in
9666 $define) usesfio='true';;
9667 *) usesfio='false';;
9668 esac
9669
9670 : see if shmctl exists
9671 set shmctl d_shmctl
9672 eval $inlibc
9673
9674 : see if shmget exists
9675 set shmget d_shmget
9676 eval $inlibc
9677
9678 : see if shmat exists
9679 set shmat d_shmat
9680 eval $inlibc
9681 : see what shmat returns
9682 case "$d_shmat" in
9683 "$define")
9684         $cat >shmat.c <<'END'
9685 #include <sys/shm.h>
9686 void *shmat();
9687 END
9688         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9689                 shmattype='void *'
9690         else
9691                 shmattype='char *'
9692         fi
9693         echo "and it returns ($shmattype)." >&4
9694         : see if a prototype for shmat is available
9695         xxx=`./findhdr sys/shm.h`
9696         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9697         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9698                 val="$define"
9699         else
9700                 val="$undef"
9701         fi
9702         $rm -f shmat.[co]
9703         ;;
9704 *)
9705         val="$undef"
9706         ;;
9707 esac
9708 set d_shmatprototype
9709 eval $setvar
9710
9711 : see if shmdt exists
9712 set shmdt d_shmdt
9713 eval $inlibc
9714
9715 : see how much of the 'shm*(2)' library is present.
9716 h_shm=true
9717 echo " "
9718 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9719 *"$undef"*) h_shm=false;;
9720 esac
9721 case "$osname" in
9722 freebsd)
9723     case "`ipcs 2>&1`" in
9724     "SVID shared memory"*"not configured"*)
9725         echo "Your $osname does not have the shm*(2) configured." >&4
9726         h_shm=false
9727         val="$undef"
9728         set shmctl d_shmctl
9729         evat $setvar
9730         set shmget d_shmget
9731         evat $setvar
9732         set shmat d_shmat
9733         evat $setvar
9734         set shmdt d_shmdt
9735         evat $setvar
9736         ;;
9737     esac
9738     ;;
9739 esac
9740 : we could also check for sys/ipc.h ...
9741 if $h_shm && $test `./findhdr sys/shm.h`; then
9742         echo "You have the full shm*(2) library." >&4
9743         val="$define"
9744 else
9745         echo "You don't have the full shm*(2) library." >&4
9746         val="$undef"
9747 fi
9748 set d_shm
9749 eval $setvar
9750
9751 echo " "
9752 : see if we have sigaction
9753 if set sigaction val -f d_sigaction; eval $csym; $val; then
9754         echo 'sigaction() found.' >&4
9755         $cat > try.c <<'EOP'
9756 #include <stdio.h>
9757 #include <sys/types.h>
9758 #include <signal.h>
9759 int main()
9760 {
9761     struct sigaction act, oact;
9762 }
9763 EOP
9764         set try
9765         if eval $compile_ok; then
9766                 val="$define"
9767         else
9768                 echo "But you don't seem to have a useable struct sigaction." >&4
9769                 val="$undef"
9770         fi
9771 else
9772         echo 'sigaction NOT found.' >&4
9773         val="$undef"
9774 fi
9775 set d_sigaction; eval $setvar
9776 $rm -f try try$_o try.c
9777
9778 : see if sigsetjmp exists
9779 echo " "
9780 case "$d_sigsetjmp" in
9781 '')
9782         $cat >try.c <<'EOP'
9783 #include <setjmp.h>
9784 sigjmp_buf env;
9785 int set = 1;
9786 int main()
9787 {
9788         if (sigsetjmp(env,1))
9789                 exit(set);
9790         set = 0;
9791         siglongjmp(env, 1);
9792         exit(1);
9793 }
9794 EOP
9795         set try
9796         if eval $compile; then
9797                 if ./try >/dev/null 2>&1; then
9798                         echo "POSIX sigsetjmp found." >&4
9799                         val="$define"
9800                 else
9801                         $cat >&4 <<EOM
9802 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9803 I'll ignore them.
9804 EOM
9805                         val="$undef"
9806                 fi
9807         else
9808                 echo "sigsetjmp not found." >&4
9809                 val="$undef"
9810         fi
9811         ;;
9812 *) val="$d_sigsetjmp"
9813         case "$d_sigsetjmp" in
9814         $define) echo "POSIX sigsetjmp found." >&4;;
9815         $undef) echo "sigsetjmp not found." >&4;;
9816         esac
9817         ;;
9818 esac
9819 set d_sigsetjmp
9820 eval $setvar
9821 $rm -f try.c try
9822
9823 : see if stat knows about block sizes
9824 echo " "
9825 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9826 eval $hasfield
9827
9828 : see if _ptr and _cnt from stdio act std
9829 echo " "
9830 if $contains '_IO_fpos_t' `./findhdr stdio.h` >/dev/null 2>&1 ; then
9831         echo "(Looks like you have stdio.h from Linux.)"
9832         case "$stdio_ptr" in
9833         '') stdio_ptr='((fp)->_IO_read_ptr)'
9834                 ptr_lval=$define
9835                 ;;
9836         *)      ptr_lval=$d_stdio_ptr_lval;;
9837         esac
9838         case "$stdio_cnt" in
9839         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9840                 cnt_lval=$undef
9841                 ;;
9842         *)      cnt_lval=$d_stdio_cnt_lval;;
9843         esac
9844         case "$stdio_base" in
9845         '') stdio_base='((fp)->_IO_read_base)';;
9846         esac
9847         case "$stdio_bufsiz" in
9848         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9849         esac
9850 else
9851         case "$stdio_ptr" in
9852         '') stdio_ptr='((fp)->_ptr)'
9853                 ptr_lval=$define
9854                 ;;
9855         *)      ptr_lval=$d_stdio_ptr_lval;;
9856         esac
9857         case "$stdio_cnt" in
9858         '') stdio_cnt='((fp)->_cnt)'
9859                 cnt_lval=$define
9860                 ;;
9861         *)      cnt_lval=$d_stdio_cnt_lval;;
9862         esac
9863         case "$stdio_base" in
9864         '') stdio_base='((fp)->_base)';;
9865         esac
9866         case "$stdio_bufsiz" in
9867         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9868         esac
9869 fi
9870 : test whether _ptr and _cnt really work
9871 echo "Checking how std your stdio is..." >&4
9872 $cat >try.c <<EOP
9873 #include <stdio.h>
9874 #define FILE_ptr(fp)    $stdio_ptr
9875 #define FILE_cnt(fp)    $stdio_cnt
9876 int main() {
9877         FILE *fp = fopen("try.c", "r");
9878         char c = getc(fp);
9879         if (
9880                 18 <= FILE_cnt(fp) &&
9881                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9882         )
9883                 exit(0);
9884         exit(1);
9885 }
9886 EOP
9887 val="$undef"
9888 set try
9889 if eval $compile; then
9890         if ./try; then
9891                 echo "Your stdio acts pretty std."
9892                 val="$define"
9893         else
9894                 echo "Your stdio isn't very std."
9895         fi
9896 else
9897         echo "Your stdio doesn't appear very std."
9898 fi
9899 $rm -f try.c try
9900 set d_stdstdio
9901 eval $setvar
9902
9903 : Can _ptr be used as an lvalue?
9904 case "$d_stdstdio$ptr_lval" in
9905 $define$define) val=$define ;;
9906 *) val=$undef ;;
9907 esac
9908 set d_stdio_ptr_lval
9909 eval $setvar
9910
9911 : Can _cnt be used as an lvalue?
9912 case "$d_stdstdio$cnt_lval" in
9913 $define$define) val=$define ;;
9914 *) val=$undef ;;
9915 esac
9916 set d_stdio_cnt_lval
9917 eval $setvar
9918
9919 : see if _base is also standard
9920 val="$undef"
9921 case "$d_stdstdio" in
9922 $define)
9923         $cat >try.c <<EOP
9924 #include <stdio.h>
9925 #define FILE_base(fp)   $stdio_base
9926 #define FILE_bufsiz(fp) $stdio_bufsiz
9927 int main() {
9928         FILE *fp = fopen("try.c", "r");
9929         char c = getc(fp);
9930         if (
9931                 19 <= FILE_bufsiz(fp) &&
9932                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9933         )
9934                 exit(0);
9935         exit(1);
9936 }
9937 EOP
9938         set try
9939         if eval $compile; then
9940                 if ./try; then
9941                         echo "And its _base field acts std."
9942                         val="$define"
9943                 else
9944                         echo "But its _base field isn't std."
9945                 fi
9946         else
9947                 echo "However, it seems to be lacking the _base field."
9948         fi
9949         $rm -f try.c try
9950         ;;
9951 esac
9952 set d_stdiobase
9953 eval $setvar
9954
9955 : see if strcoll exists
9956 set strcoll d_strcoll
9957 eval $inlibc
9958
9959 : check for structure copying
9960 echo " "
9961 echo "Checking to see if your C compiler can copy structs..." >&4
9962 $cat >try.c <<'EOCP'
9963 int main()
9964 {
9965         struct blurfl {
9966                 int dyick;
9967         } foo, bar;
9968
9969         foo = bar;
9970 }
9971 EOCP
9972 if $cc -c try.c >/dev/null 2>&1 ; then
9973         val="$define"
9974         echo "Yup, it can."
9975 else
9976         val="$undef"
9977         echo "Nope, it can't."
9978 fi
9979 set d_strctcpy
9980 eval $setvar
9981 $rm -f try.*
9982
9983 : see if strerror and/or sys_errlist[] exist
9984 echo " "
9985 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
9986     if set strerror val -f d_strerror; eval $csym; $val; then
9987                 echo 'strerror() found.' >&4
9988                 d_strerror="$define"
9989                 d_strerrm='strerror(e)'
9990                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9991                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
9992                         d_syserrlst="$define"
9993                 else
9994                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
9995                         d_syserrlst="$undef"
9996                 fi
9997     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
9998                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
9999                 echo 'strerror() found in string header.' >&4
10000                 d_strerror="$define"
10001                 d_strerrm='strerror(e)'
10002                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
10003                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
10004                                 d_syserrlst="$define"
10005                 else
10006                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
10007                         d_syserrlst="$undef"
10008                 fi
10009     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
10010                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
10011                 d_strerror="$undef"
10012                 d_syserrlst="$define"
10013                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
10014     else
10015                 echo 'strerror() and sys_errlist[] NOT found.' >&4
10016                 d_strerror="$undef"
10017                 d_syserrlst="$undef"
10018                 d_strerrm='"unknown"'
10019     fi
10020 fi
10021
10022 : see if strtod exists
10023 set strtod d_strtod
10024 eval $inlibc
10025
10026 : see if strtol exists
10027 set strtol d_strtol
10028 eval $inlibc
10029
10030 : see if strtoul exists
10031 set strtoul d_strtoul
10032 eval $inlibc
10033
10034 : see if strxfrm exists
10035 set strxfrm d_strxfrm
10036 eval $inlibc
10037
10038 : see if symlink exists
10039 set symlink d_symlink
10040 eval $inlibc
10041
10042 : see if syscall exists
10043 set syscall d_syscall
10044 eval $inlibc
10045
10046 : see if sysconf exists
10047 set sysconf d_sysconf
10048 eval $inlibc
10049
10050 : see if system exists
10051 set system d_system
10052 eval $inlibc
10053
10054 : see if tcgetpgrp exists
10055 set tcgetpgrp d_tcgetpgrp
10056 eval $inlibc
10057
10058 : see if tcsetpgrp exists
10059 set tcsetpgrp d_tcsetpgrp
10060 eval $inlibc
10061
10062 : see if sys/types.h has to be included
10063 set sys/types.h i_systypes
10064 eval $inhdr
10065
10066 : see if prototype for telldir is available
10067 echo " "
10068 set d_telldirproto telldir $i_systypes sys/types.h $i_dirent dirent.h
10069 eval $hasproto
10070
10071 : define an is-a-typedef? function
10072 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10073 case "$inclist" in
10074 "") inclist="sys/types.h";;
10075 esac;
10076 eval "varval=\$$var";
10077 case "$varval" in
10078 "")
10079         $rm -f temp.c;
10080         for inc in $inclist; do
10081                 echo "#include <$inc>" >>temp.c;
10082         done;
10083         echo "#ifdef $type" >> temp.c;
10084         echo "printf(\"We have $type\");" >> temp.c;
10085         echo "#endif" >> temp.c;
10086         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10087         if $contains $type temp.E >/dev/null 2>&1; then
10088                 eval "$var=\$type";
10089         else
10090                 eval "$var=\$def";
10091         fi;
10092         $rm -f temp.?;;
10093 *) eval "$var=\$varval";;
10094 esac'
10095
10096 : define an is-a-typedef? function that prompts if the type is not available.
10097 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
10098 case "$inclist" in
10099 "") inclist="sys/types.h";;
10100 esac;
10101 eval "varval=\$$var";
10102 case "$varval" in
10103 "")
10104         $rm -f temp.c;
10105         for inc in $inclist; do
10106                 echo "#include <$inc>" >>temp.c;
10107         done;
10108         echo "#ifdef $type" >> temp.c;
10109         echo "printf(\"We have $type\");" >> temp.c;
10110         echo "#endif" >> temp.c;
10111         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
10112         echo " " ;
10113         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
10114         if $contains $type temp.E >/dev/null 2>&1; then
10115                 echo "$type found." >&4;
10116                 eval "$var=\$type";
10117         else
10118                 echo "$type NOT found." >&4;
10119                 dflt="$def";
10120                 . ./myread ;
10121                 eval "$var=\$ans";
10122         fi;
10123         $rm -f temp.?;;
10124 *) eval "$var=\$varval";;
10125 esac'
10126
10127 : see if this is a sys/times.h system
10128 set sys/times.h i_systimes
10129 eval $inhdr
10130
10131 : see if times exists
10132 echo " "
10133 if set times val -f d_times; eval $csym; $val; then
10134         echo 'times() found.' >&4
10135         d_times="$define"
10136         inc=''
10137         case "$i_systimes" in
10138         "$define") inc='sys/times.h';;
10139         esac
10140         rp="What is the type returned by times() on this system?"
10141         set clock_t clocktype long stdio.h sys/types.h $inc
10142         eval $typedef_ask
10143 else
10144         echo 'times() NOT found, hope that will do.' >&4
10145         d_times="$undef"
10146         clocktype='int'
10147 fi
10148
10149 : see if truncate exists
10150 set truncate d_truncate
10151 eval $inlibc
10152
10153 : see if tzname[] exists
10154 echo " "
10155 if set tzname val -a d_tzname; eval $csym; $val; then
10156         val="$define"
10157         echo 'tzname[] found.' >&4
10158 else
10159         val="$undef"
10160         echo 'tzname[] NOT found.' >&4
10161 fi
10162 set d_tzname
10163 eval $setvar
10164
10165 : see if umask exists
10166 set umask d_umask
10167 eval $inlibc
10168
10169 : backward compatibility for d_hvfork
10170 if test X$d_hvfork != X; then
10171         d_vfork="$d_hvfork"
10172         d_hvfork=''
10173 fi
10174 : see if there is a vfork
10175 val=''
10176 set vfork val
10177 eval $inlibc
10178
10179 : Ok, but do we want to use it. vfork is reportedly unreliable in 
10180 : perl on Solaris 2.x, and probably elsewhere.
10181 case "$val" in
10182 $define)
10183         echo " "
10184         case "$usevfork" in
10185         false) dflt='n';;
10186         *) dflt='y';;
10187         esac
10188         cat <<'EOM'
10189  
10190 Perl can only use a vfork() that doesn't suffer from strict
10191 restrictions on calling functions or modifying global data in
10192 the child.  For example, glibc-2.1 contains such a vfork()
10193 that is unsuitable.  If your system provides a proper fork()
10194 call, chances are that you do NOT want perl to use vfork().
10195
10196 EOM
10197         rp="Do you still want to use vfork()?"
10198         . ./myread
10199         case "$ans" in
10200         y|Y) ;;
10201         *)
10202                 echo "Ok, we won't use vfork()."
10203                 val="$undef"
10204                 ;;
10205         esac
10206         ;;
10207 esac
10208 set d_vfork
10209 eval $setvar
10210 case "$d_vfork" in
10211 $define) usevfork='true';;
10212 *) usevfork='false';;
10213 esac
10214
10215 : see if this is an sysdir system
10216 set sys/dir.h i_sysdir
10217 eval $inhdr
10218
10219 : see if this is an sysndir system
10220 set sys/ndir.h i_sysndir
10221 eval $inhdr
10222
10223 : see if closedir exists
10224 set closedir d_closedir
10225 eval $inlibc
10226
10227 case "$d_closedir" in
10228 "$define")
10229         echo " "
10230         echo "Checking whether closedir() returns a status..." >&4
10231         cat > closedir.c <<EOM
10232 #$i_dirent I_DIRENT             /**/
10233 #$i_sysdir I_SYS_DIR            /**/
10234 #$i_sysndir I_SYS_NDIR          /**/
10235 #$i_systypes I_SYS_TYPES        /**/
10236
10237 #if defined(I_SYS_TYPES)
10238 #include <sys/types.h>
10239 #endif
10240 #if defined(I_DIRENT)
10241 #include <dirent.h>
10242 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
10243 #include <sys/dir.h>
10244 #endif
10245 #else
10246 #ifdef I_SYS_NDIR
10247 #include <sys/ndir.h>
10248 #else
10249 #ifdef I_SYS_DIR
10250 #ifdef hp9000s500
10251 #include <ndir.h>       /* may be wrong in the future */
10252 #else
10253 #include <sys/dir.h>
10254 #endif
10255 #endif
10256 #endif
10257 #endif 
10258 int main() { return closedir(opendir(".")); }
10259 EOM
10260         set closedir
10261         if eval $compile_ok; then
10262                 if ./closedir > /dev/null 2>&1 ; then
10263                         echo "Yes, it does."
10264                         val="$undef"
10265                 else
10266                         echo "No, it doesn't."
10267                         val="$define"
10268                 fi
10269         else
10270                 echo "(I can't seem to compile the test program--assuming it doesn't)"
10271                 val="$define"
10272         fi
10273         ;;
10274 *)
10275         val="$undef";
10276         ;;
10277 esac
10278 set d_void_closedir
10279 eval $setvar
10280 $rm -f closedir*
10281 : check for volatile keyword
10282 echo " "
10283 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
10284 $cat >try.c <<'EOCP'
10285 int main()
10286 {
10287         typedef struct _goo_struct goo_struct;
10288         goo_struct * volatile goo = ((goo_struct *)0);
10289         struct _goo_struct {
10290                 long long_int;
10291                 int reg_int;
10292                 char char_var;
10293         };
10294         typedef unsigned short foo_t;
10295         char *volatile foo;
10296         volatile int bar;
10297         volatile foo_t blech;
10298         foo = foo;
10299 }
10300 EOCP
10301 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
10302         val="$define"
10303         echo "Yup, it does."
10304 else
10305         val="$undef"
10306         echo "Nope, it doesn't."
10307 fi
10308 set d_volatile
10309 eval $setvar
10310 $rm -f try.*
10311
10312 : see if there is a wait4
10313 set wait4 d_wait4
10314 eval $inlibc
10315
10316 : see if waitpid exists
10317 set waitpid d_waitpid
10318 eval $inlibc
10319
10320 : see if wcstombs exists
10321 set wcstombs d_wcstombs
10322 eval $inlibc
10323
10324 : see if wctomb exists
10325 set wctomb d_wctomb
10326 eval $inlibc
10327
10328 : see if writev exists
10329 set writev d_writev
10330 eval $inlibc
10331
10332 : preserve RCS keywords in files with variable substitution, grrr
10333 Date='$Date'
10334 Id='$Id'
10335 Log='$Log'
10336 RCSfile='$RCSfile'
10337 Revision='$Revision'
10338
10339 case "$crosscompile" in
10340 ''|[nN]*) crosscompile="$undef" ;;
10341 esac
10342
10343 case "$osname" in
10344 next|rhapsody) multiarch="$define" ;;
10345 esac
10346 case "$multiarch" in
10347 ''|[nN]*) multiarch="$undef" ;;
10348 esac
10349
10350 : check for alignment requirements
10351 echo " "
10352 case "$crosscompile$multiarch" in
10353 *$define*)
10354         $cat <<EOM
10355 You seem to be either cross-compiling or doing a multiarchitecture build,
10356 skipping the memory alignment check.
10357
10358 EOM
10359         case "$alignbytes" in
10360         '') alignbytes=8 ;;
10361         esac
10362         ;;
10363 *)
10364         case "$alignbytes" in
10365         '') echo "Checking alignment constraints..." >&4
10366                 $cat >try.c <<'EOCP'
10367 struct foobar {
10368         char foo;
10369         double bar;
10370 } try_algn;
10371 int main()
10372 {
10373         printf("%d\n", (char *)&try_algn.bar - (char *)&try_algn.foo);
10374 }
10375 EOCP
10376                 set try
10377                 if eval $compile_ok; then
10378                         dflt=`./try`
10379                 else
10380                         dflt='8'
10381                         echo "(I can't seem to compile the test program...)"
10382                 fi
10383                 ;;
10384         *) dflt="$alignbytes"
10385                 ;;
10386         esac
10387         rp="Doubles must be aligned on a how-many-byte boundary?"
10388         . ./myread
10389         alignbytes="$ans"
10390         $rm -f try.c try
10391         ;;
10392 esac
10393
10394
10395 : check for ordering of bytes in a long
10396 echo " "
10397 case "$crosscompile$multiarch" in
10398 *$define*)
10399         $cat <<EOM
10400 You seem to be either cross-compiling or doing a multiarchitecture build,
10401 skipping the byteorder check.
10402
10403 EOM
10404         byteorder=''
10405         ;;
10406 *)
10407         case "$byteorder" in
10408         '')
10409                 $cat <<'EOM'
10410 In the following, larger digits indicate more significance.  A big-endian
10411 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10412 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10413 machines may have weird orders like 3412.  A Cray will report 87654321. If
10414 the test program works the default is probably right.
10415 I'm now running the test program...
10416 EOM
10417                 $cat >try.c <<'EOCP'
10418 #include <stdio.h>
10419 int main()
10420 {
10421         int i;
10422         union {
10423                 unsigned long l;
10424                 char c[sizeof(long)];
10425         } u;
10426
10427         if (sizeof(long) > 4)
10428                 u.l = (0x08070605L << 32) | 0x04030201L;
10429         else
10430                 u.l = 0x04030201L;
10431         for (i = 0; i < sizeof(long); i++)
10432                 printf("%c", u.c[i]+'0');
10433         printf("\n");
10434         exit(0);
10435 }
10436 EOCP
10437                 xxx_prompt=y
10438                 set try
10439                 if eval $compile && ./try > /dev/null; then
10440                         dflt=`./try`
10441                         case "$dflt" in
10442                         [1-4][1-4][1-4][1-4]|12345678|87654321)
10443                                 echo "(The test program ran ok.)"
10444                                 echo "byteorder=$dflt"
10445                                 xxx_prompt=n
10446                         ;;
10447                         ????|????????) echo "(The test program ran ok.)" ;;
10448                         *) echo "(The test program didn't run right for some reason.)" ;;
10449                         esac
10450                 else
10451                         dflt='4321'
10452                         cat <<'EOM'
10453 (I can't seem to compile the test program.  Guessing big-endian...)
10454 EOM
10455                 fi
10456                 case "$xxx_prompt" in
10457                 y)
10458                         rp="What is the order of bytes in a long?"
10459                         . ./myread
10460                         byteorder="$ans"
10461                         ;;
10462                 *)      byteorder=$dflt
10463                         ;;
10464                 esac
10465                 ;;
10466         esac
10467         $rm -f try.c try
10468         ;;
10469 esac
10470
10471
10472 : how do we catenate cpp tokens here?
10473 echo " "
10474 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10475 $cat >cpp_stuff.c <<'EOCP'
10476 #define RCAT(a,b)a/**/b
10477 #define ACAT(a,b)a ## b
10478 RCAT(Rei,ser)
10479 ACAT(Cir,cus)
10480 EOCP
10481 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10482 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10483         echo "Oh!  Smells like ANSI's been here." >&4
10484         echo "We can catify or stringify, separately or together!"
10485         cpp_stuff=42
10486 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10487         echo "Ah, yes!  The good old days!" >&4
10488         echo "However, in the good old days we don't know how to stringify and"
10489         echo "catify at the same time."
10490         cpp_stuff=1
10491 else
10492         $cat >&4 <<EOM
10493 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10494 to have to edit the values of CAT[2-5] in config.h...
10495 EOM
10496         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10497 fi
10498 $rm -f cpp_stuff.*
10499
10500 : see if this is a db.h system
10501 set db.h i_db
10502 eval $inhdr
10503
10504 case "$i_db" in
10505 $define)
10506         : Check db version.
10507         echo " "
10508         echo "Checking Berkeley DB version ..." >&4
10509         $cat >try.c <<EOCP
10510 #$d_const HASCONST
10511 #ifndef HASCONST
10512 #define const
10513 #endif
10514 #include <sys/types.h>
10515 #include <stdio.h>
10516 #include <db.h>
10517 int main()
10518 {
10519 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10520     int Major, Minor, Patch ;
10521     unsigned long Version ;
10522     (void)db_version(&Major, &Minor, &Patch) ;
10523     printf("You have Berkeley DB Version 2 or greater\n");
10524
10525     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10526                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10527     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10528                 Major, Minor, Patch) ;
10529
10530     /* check that db.h & libdb are compatible */
10531     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10532         printf("db.h and libdb are incompatible\n") ;
10533         exit(3);        
10534     }
10535
10536     printf("db.h and libdb are compatible\n") ;
10537
10538     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10539                 + DB_VERSION_PATCH ;
10540
10541     /* needs to be >= 2.3.4 */
10542     if (Version < 2003004) {
10543     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10544         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10545         exit(2);        
10546     }
10547
10548     exit(0);
10549 #else
10550 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10551     printf("You have Berkeley DB Version 1\n");
10552     exit(0);    /* DB version < 2: the coast is clear. */
10553 #else
10554     exit(1);    /* <db.h> not Berkeley DB? */
10555 #endif
10556 #endif
10557 }
10558 EOCP
10559         set try
10560         if eval $compile && ./try; then
10561                 echo 'Looks OK.' >&4
10562         else
10563                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10564                 i_db=$undef
10565                 case " $libs " in
10566                 *"-ldb "*)
10567                         : Remove db from list of libraries to use
10568                         echo "Removing unusable -ldb from library list" >&4
10569                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10570                         shift
10571                         libs="$*"
10572                         echo "libs = $libs" >&4
10573                         ;;
10574                 esac
10575         fi
10576         $rm -f try.*
10577         ;;
10578 esac
10579
10580 case "$i_db" in
10581 define)
10582         : Check the return type needed for hash 
10583         echo " "
10584         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10585         $cat >try.c <<EOCP
10586 #$d_const HASCONST
10587 #ifndef HASCONST
10588 #define const
10589 #endif
10590 #include <sys/types.h>
10591 #include <db.h>
10592
10593 #ifndef DB_VERSION_MAJOR
10594 u_int32_t hash_cb (ptr, size)
10595 const void *ptr;
10596 size_t size;
10597 {
10598 }
10599 HASHINFO info;
10600 int main()
10601 {
10602         info.hash = hash_cb;
10603 }
10604 #endif
10605 EOCP
10606         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10607                 if $contains warning try.out >>/dev/null 2>&1 ; then
10608                         db_hashtype='int'
10609                 else
10610                         db_hashtype='u_int32_t'
10611                 fi
10612         else
10613                 : XXX Maybe we should just give up here.
10614                 db_hashtype=u_int32_t
10615                 $cat try.out >&4
10616                 echo "Help:  I can't seem to compile the db test program." >&4
10617                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10618         fi
10619         $rm -f try.*
10620         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10621         ;;
10622 *)      db_hashtype=u_int32_t
10623         ;;
10624 esac
10625 case "$i_db" in
10626 define)
10627         : Check the return type needed for prefix 
10628         echo " "
10629         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10630         cat >try.c <<EOCP
10631 #$d_const HASCONST
10632 #ifndef HASCONST
10633 #define const
10634 #endif
10635 #include <sys/types.h>
10636 #include <db.h>
10637
10638 #ifndef DB_VERSION_MAJOR
10639 size_t prefix_cb (key1, key2)
10640 const DBT *key1;
10641 const DBT *key2;
10642 {
10643 }
10644 BTREEINFO info;
10645 int main()
10646 {
10647         info.prefix = prefix_cb;
10648 }
10649 #endif
10650 EOCP
10651         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10652                 if $contains warning try.out >>/dev/null 2>&1 ; then
10653                         db_prefixtype='int'
10654                 else
10655                         db_prefixtype='size_t'
10656                 fi
10657         else
10658                 db_prefixtype='size_t'
10659                 : XXX Maybe we should just give up here.
10660                 $cat try.out >&4
10661                 echo "Help:  I can't seem to compile the db test program." >&4
10662                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10663         fi
10664         $rm -f try.*
10665         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10666         ;;
10667 *)      db_prefixtype='size_t'
10668         ;;
10669 esac
10670
10671 : check for void type
10672 echo " "
10673 echo "Checking to see how well your C compiler groks the void type..." >&4
10674 case "$voidflags" in
10675 '')
10676         $cat >try.c <<'EOCP'
10677 #if TRY & 1
10678 void sub() {
10679 #else
10680 sub() {
10681 #endif
10682         extern void moo();      /* function returning void */
10683         void (*goo)();          /* ptr to func returning void */
10684 #if TRY & 8
10685         void *hue;              /* generic ptr */
10686 #endif
10687 #if TRY & 2
10688         void (*foo[10])();
10689 #endif
10690
10691 #if TRY & 4
10692         if(goo == moo) {
10693                 exit(0);
10694         }
10695 #endif
10696         exit(0);
10697 }
10698 int main() { sub(); }
10699 EOCP
10700         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10701                 voidflags=$defvoidused
10702         echo "Good.  It appears to support void to the level $package wants.">&4
10703                 if $contains warning .out >/dev/null 2>&1; then
10704                         echo "However, you might get some warnings that look like this:"
10705                         $cat .out
10706                 fi
10707         else
10708 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10709                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10710                         echo "It supports 1..."
10711                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10712                                 echo "It also supports 2..."
10713                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10714                                         voidflags=7
10715                                         echo "And it supports 4 but not 8 definitely."
10716                                 else
10717                                         echo "It doesn't support 4..."
10718                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10719                                                 voidflags=11
10720                                                 echo "But it supports 8."
10721                                         else
10722                                                 voidflags=3
10723                                                 echo "Neither does it support 8."
10724                                         fi
10725                                 fi
10726                         else
10727                                 echo "It does not support 2..."
10728                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10729                                         voidflags=13
10730                                         echo "But it supports 4 and 8."
10731                                 else
10732                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10733                                                 voidflags=5
10734                                                 echo "And it supports 4 but has not heard about 8."
10735                                         else
10736                                                 echo "However it supports 8 but not 4."
10737                                         fi
10738                                 fi
10739                         fi
10740                 else
10741                         echo "There is no support at all for void."
10742                         voidflags=0
10743                 fi
10744         fi
10745 esac
10746 case "$voidflags" in
10747 "$defvoidused") ;;
10748 *)      $cat >&4 <<'EOM'
10749   Support flag bits are:
10750     1: basic void declarations.
10751     2: arrays of pointers to functions returning void.
10752     4: operations between pointers to and addresses of void functions.
10753     8: generic void pointers.
10754 EOM
10755         dflt="$voidflags";
10756         rp="Your void support flags add up to what?"
10757         . ./myread
10758         voidflags="$ans"
10759         ;;
10760 esac
10761 $rm -f try.* .out
10762
10763
10764 : How can we generate normalized random numbers ?
10765 echo " "
10766 echo "Looking for a random number function..." >&4
10767 case "$randfunc" in
10768 '')
10769         if set drand48 val -f; eval $csym; $val; then
10770                 dflt="drand48"
10771                 echo "Good, found drand48()." >&4
10772         elif set random val -f; eval $csym; $val; then
10773                 dflt="random"
10774                 echo "OK, found random()." >&4
10775         else
10776                 dflt="rand"
10777                 echo "Yick, looks like I have to use rand()." >&4
10778         fi
10779         echo " "
10780         ;;
10781 *)
10782         dflt="$randfunc"
10783         ;;
10784 esac
10785 cont=true
10786
10787 case "$ccflags" in
10788 *-Dmy_rand=*|*-Dmy_srand=*)
10789         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10790         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10791         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10792         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10793         ;;
10794 esac
10795
10796 while $test "$cont"; do
10797         rp="Use which function to generate random numbers?"
10798         . ./myread
10799         if $test "$ans" = "$dflt"; then
10800                 : null
10801         else
10802                 randbits=''
10803         fi
10804         randfunc="$ans"
10805         if set $ans val -f; eval $csym; $val; then
10806                 cont=''
10807         else
10808                 dflt=y
10809                 rp="I cannot find function $ans. Use that name anyway?"
10810                 . ./myread
10811                 dflt=rand
10812                 case "$ans" in
10813                         [yY]*) cont='';;
10814                 esac
10815         fi
10816         case "$cont" in
10817         '')
10818                 case "$randfunc" in
10819                 drand48)
10820                         drand01="drand48()"
10821                         seedfunc="srand48"
10822                         randbits=48
10823                         randseedtype=long
10824                         ;;
10825                 rand|random)
10826                         case "$randbits" in
10827                         '')
10828 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10829                                 $cat >try.c <<EOCP
10830 #$i_unistd I_UNISTD
10831 #$i_stdlib I_STDLIB
10832 #include <stdio.h>
10833 #ifdef I_UNISTD
10834 #  include <unistd.h>
10835 #endif
10836 #ifdef I_STDLIB
10837 #  include <stdlib.h>
10838 #endif
10839 int main()
10840 {
10841         register int i;
10842         register unsigned long tmp;
10843         register unsigned long max = 0L;
10844
10845         for (i = 1000; i; i--) {
10846                 tmp = (unsigned long) $randfunc();
10847                 if (tmp > max) max = tmp;
10848         }
10849         for (i = 0; max; i++)
10850                 max /= 2;
10851         printf("%d\n",i);
10852 }
10853 EOCP
10854                                 set try
10855                                 if eval $compile_ok; then
10856                                         dflt=`try`
10857                                 else
10858                                         dflt='?'
10859                                         echo "(I can't seem to compile the test program...)"
10860                                 fi
10861                                 ;;
10862                         *)
10863                                 dflt="$randbits"
10864                                 ;;
10865                         esac
10866                         rp="How many bits does your $randfunc() function produce?"
10867                         . ./myread
10868                         randbits="$ans"
10869                         $rm -f try.c try
10870                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10871                         seedfunc="s$randfunc"
10872                         randseedtype=unsigned
10873                         ;;
10874                 *)
10875                         dflt="31"
10876                         rp="How many bits does your $randfunc() function produce?"
10877                         . ./myread
10878                         randbits="$ans"
10879                         seedfunc="s$randfunc"
10880                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10881                         if set $seedfunc val -f; eval $csym; $val; then
10882                                 echo "(Using $seedfunc() to seed random generator)"
10883                         else
10884                                 echo "(Warning: no $seedfunc() to seed random generator)"
10885                                 seedfunc=rand
10886                         fi
10887                         randseedtype=unsigned
10888                         ;;
10889                 esac
10890                 ;;
10891         esac
10892 done
10893
10894 echo " "
10895 echo "Determining whether or not we are on an EBCDIC system..." >&4
10896 $cat >tebcdic.c <<'EOM'
10897 int main()
10898 {
10899   if ('M'==0xd4) return 0;
10900   return 1;
10901 }
10902 EOM
10903
10904 val=$undef
10905 set tebcdic
10906 if eval $compile_ok; then
10907         if ./tebcdic; then
10908                 echo "You have EBCDIC." >&4
10909                 val="$define"
10910         else
10911                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10912         fi
10913 else
10914         echo "I'm unable to compile the test program." >&4
10915         echo "I'll assume ASCII or some ISO Latin." >&4
10916 fi
10917 $rm -f tebcdic.c tebcdic
10918 set ebcdic
10919 eval $setvar
10920
10921 : check for fflush NULL behaviour
10922 case "$fflushNULL" in
10923 '') $cat <<EOM
10924
10925 Checking to see whether fflush(NULL) flushes all pending stdio output...
10926 EOM
10927         $cat >try.c <<EOCP
10928 #include <stdio.h>
10929 int main() {
10930   FILE* p = fopen("try.out", "w");
10931   fputc('x', p);
10932   fflush(NULL);
10933   _exit(0);
10934 }
10935 EOCP
10936         set try
10937         $rm -f try.out
10938         if eval $compile_ok; then
10939                 ./try$exe_ext
10940                 if $test -s try.out; then
10941                         fflushNULL="`$cat try.out`"
10942                 fi
10943         fi
10944         case "$fflushNULL" in
10945         x)      cat >&4 <<EOM
10946 Your fflush(NULL) works okay.
10947 EOM
10948                 fflushNULL=define
10949                 ;;
10950         '')     cat >&4 <<EOM
10951 Your fflush(NULL) isn't working (contrary to ANSI C).
10952 EOM
10953                 fflushNULL=undef
10954                 ;;
10955         *)      cat >&4 <<EOM
10956 Cannot figure out whether your fflush(NULL) works or not.
10957 I'm assuming it doesn't (contrary to ANSI C).
10958 EOM
10959                 fflushNULL=undef
10960                 ;;
10961         esac
10962         $rm -f try.* try
10963         ;;
10964 $define|true|[yY]*)
10965         fflushNULL=define
10966         ;;
10967 *)
10968         fflushNULL=undef
10969         ;;
10970 esac
10971
10972 : see what type file positions are declared as in the library
10973 rp="What is the type for file position used by fsetpos()?"
10974 set fpos_t fpostype long stdio.h sys/types.h
10975 eval $typedef_ask
10976
10977 : Store the full pathname to the ar program for use in the C program
10978 : Respect a hint or command line value for full_ar.
10979 case "$full_ar" in
10980 '') full_ar=$ar ;;
10981 esac
10982
10983 : Store the full pathname to the sed program for use in the C program
10984 full_sed=$sed
10985
10986 : see what type gids are declared as in the kernel
10987 echo " "
10988 echo "Looking for the type for group ids returned by getgid()."
10989 set gid_t gidtype xxx stdio.h sys/types.h
10990 eval $typedef
10991 case "$gidtype" in
10992 xxx)
10993         xxx=`./findhdr sys/user.h`
10994         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
10995         case $1 in
10996         unsigned) dflt="$1 $2" ;;
10997         *) dflt="$1" ;;
10998         esac
10999         ;;
11000 *) dflt="$gidtype";;
11001 esac
11002 case "$gidtype" in
11003 gid_t) echo "gid_t found." ;;
11004 *)      rp="What is the type for group ids returned by getgid()?"
11005         . ./myread
11006         gidtype="$ans"
11007         ;;
11008 esac
11009
11010 : see if getgroups exists
11011 set getgroups d_getgrps
11012 eval $inlibc
11013
11014 : see if setgroups exists
11015 set setgroups d_setgrps
11016 eval $inlibc
11017
11018
11019 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
11020 echo " "
11021 case "$d_getgrps$d_setgrps" in
11022 *define*)
11023         case "$groupstype" in
11024         '') dflt="$gidtype" ;;
11025         *)  dflt="$groupstype" ;;
11026         esac
11027         $cat <<EOM
11028 What type of pointer is the second argument to getgroups() and setgroups()?
11029 Usually this is the same as group ids, $gidtype, but not always.
11030
11031 EOM
11032         rp='What type pointer is the second argument to getgroups() and setgroups()?'
11033         . ./myread
11034         groupstype="$ans"
11035         ;;
11036 *)  groupstype="$gidtype";;
11037 esac
11038
11039 : see what type lseek is declared as in the kernel
11040 rp="What is the type used for lseek's offset on this system?"
11041 set off_t lseektype long stdio.h sys/types.h
11042 eval $typedef_ask
11043
11044 echo " "
11045 $echo $n "Checking to see how big your file offsets are...$c" >&4
11046 $cat >try.c <<EOCP
11047 #include <sys/types.h>
11048 #include <stdio.h>
11049 int main()
11050 {
11051         printf("%d\n", sizeof($lseektype));
11052 }
11053 EOCP
11054 set try
11055 if eval $compile_ok; then
11056         lseeksize=`./try`
11057         $echo " $lseeksize bytes." >&4
11058 else
11059         dflt='4'
11060         echo " "
11061         echo "(I can't seem to compile the test program.  Guessing...)"
11062         rp="What is the size of your file offsets (in bytes)?"
11063         . ./myread
11064         lseeksize="$ans"
11065 fi
11066 $rm -f try.c try
11067
11068 echo " "
11069 echo "Checking if your $make program sets \$(MAKE)..." >&4
11070 case "$make_set_make" in
11071 '')
11072         $sed 's/^X //' > testmake.mak << 'EOF'
11073 Xall:
11074 X       @echo 'maketemp="$(MAKE)"'
11075 EOF
11076         case "`$make -f testmake.mak 2>/dev/null`" in
11077         *maketemp=*) make_set_make='#' ;;
11078         *)      make_set_make="MAKE=$make" ;;
11079         esac
11080         $rm -f testmake.mak
11081         ;;
11082 esac
11083 case "$make_set_make" in
11084 '#') echo "Yup, it does.";;
11085 *) echo "Nope, it doesn't.";;
11086 esac
11087
11088 : see what type is used for mode_t
11089 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
11090 set mode_t modetype int stdio.h sys/types.h
11091 eval $typedef_ask
11092
11093 : define a fucntion to check prototypes
11094 $cat > protochk <<EOSH
11095 $startsh
11096 cc="$cc"
11097 optimize="$optimize"
11098 ccflags="$ccflags"
11099 prototype="$prototype"
11100 define="$define"
11101 rm=$rm
11102 EOSH
11103
11104 $cat >> protochk <<'EOSH'
11105
11106 $rm -f try.c
11107 foo="$1"
11108 shift
11109 while test $# -ge 2; do
11110         case "$1" in
11111                 $define) echo "#include <$2>" >> try.c ;;
11112                 literal) echo "$2" >> try.c ;;
11113         esac
11114     shift 2
11115 done
11116 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
11117 cat >> try.c <<'EOCP'
11118 #ifdef CAN_PROTOTYPE
11119 #define _(args) args
11120 #else
11121 #define _(args) ()
11122 #endif
11123 EOCP
11124 echo "$foo" >> try.c
11125 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
11126 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
11127 status=$?
11128 $rm -f try.[co]
11129 exit $status
11130 EOSH
11131 chmod +x protochk
11132 $eunicefix protochk
11133
11134 : see what type is used for size_t
11135 rp="What is the type used for the length parameter for string functions?"
11136 set size_t sizetype 'unsigned int' stdio.h sys/types.h
11137 eval $typedef_ask
11138
11139 : check for type of arguments to gethostbyaddr. 
11140 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
11141         case "$d_gethbyaddr" in
11142         $define)
11143                 $cat <<EOM
11144
11145 Checking to see what type of arguments are accepted by gethostbyaddr().
11146 EOM
11147                 hdrs="$define sys/types.h
11148                         $d_socket sys/socket.h 
11149                         $i_niin netinet/in.h 
11150                         $i_netdb netdb.h
11151                         $i_unistd unistd.h"
11152                 : The first arg can 'char *' or 'void *'
11153                 : The second arg is some of integral type
11154                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
11155                         for yyy in size_t long int; do
11156                                 case "$netdb_host_type" in
11157                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
11158                                         if ./protochk "$try" $hdrs; then
11159                                                 echo "Your system accepts $xxx for the first arg."
11160                                                 echo "...and $yyy for the second arg."
11161                                                 netdb_host_type="$xxx"
11162                                                 netdb_hlen_type="$yyy"
11163                                         fi
11164                                         ;;
11165                                 esac
11166                         done
11167                 done
11168                 : In case none of those worked, prompt the user.
11169                 case "$netdb_host_type" in
11170                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
11171                         dflt='char *'
11172                         . ./myread
11173                         netdb_host_type=$ans
11174                         rp='What is the type for the 2nd argument to gethostbyaddr?'
11175                         dflt="$sizetype"
11176                         . ./myread
11177                         netdb_hlen_type=$ans
11178                         ;;
11179                 esac
11180                 ;;
11181         *)      : no gethostbyaddr, so pick harmless defaults
11182                 netdb_host_type='char *'
11183                 netdb_hlen_type="$sizetype"
11184                 ;;
11185         esac
11186         # Remove the "const" if needed. -- but then we'll have a 
11187         # prototype clash!
11188         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
11189 fi
11190
11191 : check for type of argument to gethostbyname. 
11192 if test "X$netdb_name_type" = X ; then
11193         case "$d_gethbyname" in
11194         $define)
11195                 $cat <<EOM
11196
11197 Checking to see what type of argument is accepted by gethostbyname().
11198 EOM
11199                 hdrs="$define sys/types.h
11200                         $d_socket sys/socket.h 
11201                         $i_niin netinet/in.h 
11202                         $i_netdb netdb.h
11203                         $i_unistd unistd.h"
11204                 for xxx in "const char *" "char *"; do
11205                         case "$netdb_name_type" in
11206                         '')     try="extern struct hostent *gethostbyname($xxx);"
11207                                 if ./protochk "$try" $hdrs; then
11208                                         echo "Your system accepts $xxx."
11209                                         netdb_name_type="$xxx"
11210                                 fi
11211                                 ;;
11212                         esac
11213                 done
11214                 : In case none of those worked, prompt the user.
11215                 case "$netdb_name_type" in
11216                 '')     rp='What is the type for the 1st argument to gethostbyname?'
11217                         dflt='char *'
11218                         . ./myread
11219                         netdb_name_type=$ans
11220                         ;;
11221                 esac
11222                 ;;
11223         *)      : no gethostbyname, so pick harmless default
11224                 netdb_name_type='char *'
11225                 ;;
11226         esac
11227 fi
11228
11229 : check for type of 1st argument to getnetbyaddr. 
11230 if test "X$netdb_net_type" = X ; then
11231         case "$d_getnbyaddr" in
11232         $define)
11233                 $cat <<EOM
11234
11235 Checking to see what type of 1st argument is accepted by getnetbyaddr().
11236 EOM
11237                 hdrs="$define sys/types.h
11238                         $d_socket sys/socket.h 
11239                         $i_niin netinet/in.h 
11240                         $i_netdb netdb.h
11241                         $i_unistd unistd.h"
11242                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
11243                         case "$netdb_net_type" in
11244                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
11245                                 if ./protochk "$try" $hdrs; then
11246                                         echo "Your system accepts $xxx."
11247                                         netdb_net_type="$xxx"
11248                                 fi
11249                                 ;;
11250                         esac
11251                 done
11252                 : In case none of those worked, prompt the user.
11253                 case "$netdb_net_type" in
11254                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
11255                         dflt='long'
11256                         . ./myread
11257                         netdb_net_type=$ans
11258                         ;;
11259                 esac
11260                 ;;
11261         *)      : no getnetbyaddr, so pick harmless default
11262                 netdb_net_type='long'
11263                 ;;
11264         esac
11265 fi
11266 : locate the preferred pager for this system
11267 case "$pager" in
11268 '')
11269         dflt=''
11270         case "$pg" in
11271         /*) dflt=$pg;;
11272         esac
11273         case "$more" in
11274         /*) dflt=$more;;
11275         esac
11276         case "$less" in
11277         /*) dflt=$less;;
11278         esac
11279         case "$dflt" in
11280         '') dflt=/usr/ucb/more;;
11281         esac
11282         ;;
11283 *) dflt="$pager";;
11284 esac
11285 echo " "
11286 fn=f/
11287 rp='What pager is used on your system?'
11288 . ./getfile
11289 pager="$ans"
11290
11291 : see what type pids are declared as in the kernel
11292 rp="What is the type of process ids on this system?"
11293 set pid_t pidtype int stdio.h sys/types.h
11294 eval $typedef_ask
11295
11296 : check for length of pointer
11297 echo " "
11298 case "$ptrsize" in
11299 '')
11300         $echo $n "Checking to see how big your pointers are...$c" >&4
11301         if test "$voidflags" -gt 7; then
11302                 echo '#define VOID_PTR char *' > try.c
11303         else
11304                 echo '#define VOID_PTR void *' > try.c
11305         fi
11306         $cat >>try.c <<'EOCP'
11307 #include <stdio.h>
11308 int main()
11309 {
11310         printf("%d\n", sizeof(VOID_PTR));
11311         exit(0);
11312 }
11313 EOCP
11314         set try
11315         if eval $compile_ok; then
11316                 ptrsize=`./try`
11317                 $echo " $ptrsize bytes." >&4
11318         else
11319                 dflt='4'
11320                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
11321                 rp="What is the size of a pointer (in bytes)?"
11322                 . ./myread
11323                 ptrsize="$ans"
11324         fi
11325         ;;
11326 esac
11327 $rm -f try.c try
11328
11329 : see if ar generates random libraries by itself
11330 echo " "
11331 echo "Checking how to generate random libraries on your machine..." >&4
11332 echo 'int bar1() { return bar2(); }' > bar1.c
11333 echo 'int bar2() { return 2; }' > bar2.c
11334 $cat > foo.c <<'EOP'
11335 int main() { printf("%d\n", bar1()); exit(0); }
11336 EOP
11337 $cc $ccflags -c bar1.c >/dev/null 2>&1
11338 $cc $ccflags -c bar2.c >/dev/null 2>&1
11339 $cc $ccflags -c foo.c >/dev/null 2>&1
11340 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
11341 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11342         ./foobar >/dev/null 2>&1; then
11343         echo "$ar appears to generate random libraries itself."
11344         orderlib=false
11345         ranlib=":"
11346 elif $ar ts bar$_a >/dev/null 2>&1 &&
11347         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
11348         ./foobar >/dev/null 2>&1; then
11349                 echo "a table of contents needs to be added with '$ar ts'."
11350                 orderlib=false
11351                 ranlib="$ar ts"
11352 else
11353         case "$ranlib" in
11354         :) ranlib='';;
11355         '')
11356                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
11357                 $test -f $ranlib || ranlib=''
11358                 ;;
11359         esac
11360         if $test -n "$ranlib"; then
11361                 echo "your system has '$ranlib'; we'll use that."
11362                 orderlib=false
11363         else
11364                 echo "your system doesn't seem to support random libraries"
11365                 echo "so we'll use lorder and tsort to order the libraries."
11366                 orderlib=true
11367                 ranlib=":"
11368         fi
11369 fi
11370 $rm -f foo* bar* 
11371
11372 : check for type of arguments to select. 
11373 case "$selecttype" in
11374 '') case "$d_select" in
11375         $define)
11376                 $cat <<EOM
11377 Checking to see what type of arguments are accepted by select().
11378 EOM
11379                 hdrs="$define sys/types.h
11380                         $i_systime sys/time.h 
11381                         $i_sysselct sys/select.h
11382                         $d_socket sys/socket.h"
11383                 : The first arg can be int, unsigned, or size_t
11384                 : The last arg may or may not be 'const'
11385                 val=''
11386                 : void pointer has been seen but using that
11387                 : breaks the selectminbits test
11388                 for xxx in 'fd_set *' 'int *'; do
11389                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
11390                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
11391                                         case "$val" in
11392                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
11393                                                 if ./protochk "$try" $hdrs; then
11394                                                         echo "Your system accepts $xxx."
11395                                                         val="$xxx"
11396                                                 fi
11397                                                 ;;
11398                                         esac
11399                                 done
11400                         done
11401                 done
11402                 case "$val" in
11403                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11404                         case "$d_fd_set" in
11405                                 $define) dflt="fd_set *" ;;
11406                                 *)              dflt="int *" ;;
11407                         esac
11408                         . ./myread
11409                         val=$ans
11410                         ;;
11411                 esac
11412                 selecttype="$val"
11413                 ;;
11414         *)      : no select, so pick a harmless default
11415                 selecttype='int *'
11416                 ;;
11417         esac
11418         ;;
11419 esac
11420
11421 : check for the select 'width'
11422 case "$selectminbits" in
11423 '') case "$d_select" in
11424         $define)
11425                 $cat <<EOM
11426
11427 Checking to see on how many bits at a time your select() operates...
11428 EOM
11429                 $cat >try.c <<EOCP
11430 #include <sys/types.h>
11431 #$i_time I_TIME
11432 #$i_systime I_SYS_TIME
11433 #$i_systimek I_SYS_TIME_KERNEL
11434 #ifdef I_TIME
11435 #   include <time.h>
11436 #endif
11437 #ifdef I_SYS_TIME
11438 #   ifdef I_SYS_TIME_KERNEL
11439 #       define KERNEL
11440 #   endif
11441 #   include <sys/time.h>
11442 #   ifdef I_SYS_TIME_KERNEL
11443 #       undef KERNEL
11444 #   endif
11445 #endif
11446 #$i_sysselct I_SYS_SELECT
11447 #ifdef I_SYS_SELECT
11448 #include <sys/select.h>
11449 #endif
11450 #include <stdio.h>
11451 $selecttype b;
11452 #define S sizeof(*(b))
11453 #define MINBITS 64
11454 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11455 #define NBITS  (NBYTES * 8)
11456 int main() {
11457     char s[NBYTES];
11458     struct timeval t;
11459     int i;
11460     FILE* fp;
11461     int fd;
11462
11463     fclose(stdin);
11464     fp = fopen("try.c", "r");
11465     if (fp == 0)
11466       exit(1);
11467     fd = fileno(fp);
11468     if (fd < 0)
11469       exit(2);
11470     b = ($selecttype)s;
11471     for (i = 0; i < NBITS; i++)
11472         FD_SET(i, b);
11473     t.tv_sec  = 0;
11474     t.tv_usec = 0;
11475     select(fd + 1, b, 0, 0, &t);
11476     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11477     printf("%d\n", i + 1);
11478     return 0;
11479 }
11480 EOCP
11481                 set try
11482                 if eval $compile_ok; then
11483                         selectminbits=`./try`
11484                         case "$selectminbits" in
11485                         '')     cat >&4 <<EOM
11486 Cannot figure out on how many bits at a time your select() operates.
11487 I'll play safe and guess it is 32 bits.
11488 EOM
11489                                 selectminbits=32
11490                                 bits="32 bits"
11491                                 ;;
11492                         1)      bits="1 bit" ;;
11493                         *)      bits="$selectminbits bits" ;;
11494                         esac
11495                         echo "Your select() operates on $bits at a time." >&4
11496                 else
11497                         rp='What is the minimum number of bits your select() operates on?'
11498                         case "$byteorder" in
11499                         1234|12345678)  dflt=32 ;;
11500                         *)              dflt=1  ;;
11501                         esac
11502                         . ./myread
11503                         val=$ans
11504                         selectminbits="$val"
11505                 fi
11506                 $rm -f try.* try
11507                 ;;
11508         *)      : no select, so pick a harmless default
11509                 selectminbits='32'
11510                 ;;
11511         esac
11512         ;;
11513 esac
11514
11515 : Trace out the files included by signal.h, then look for SIGxxx names.
11516 : Remove SIGARRAYSIZE used by HPUX.
11517 : Remove SIGSTKSIZE used by Linux.
11518 : Remove SIGSTKSZ used by Posix.
11519 : Remove SIGTYP void lines used by OS2.
11520 xxx=`echo '#include <signal.h>' |
11521         $cppstdin $cppminus $cppflags 2>/dev/null |
11522         $grep '^[       ]*#.*include' | 
11523         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11524 : Check this list of files to be sure we have parsed the cpp output ok.
11525 : This will also avoid potentially non-existent files, such 
11526 : as ../foo/bar.h
11527 xxxfiles=''
11528 for xx in $xxx /dev/null ; do
11529         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11530 done
11531 : If we have found no files, at least try signal.h
11532 case "$xxxfiles" in
11533 '')     xxxfiles=`./findhdr signal.h` ;;
11534 esac
11535 xxx=`awk '
11536 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $2 !~ /SIGSTKSIZE/ && $2 !~ /SIGSTKSZ/ && $3 !~ /void/ {
11537         print substr($2, 4, 20)
11538 }
11539 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11540         print substr($3, 4, 20)
11541 }' $xxxfiles`
11542 : Append some common names just in case the awk scan failed.
11543 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11544 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11545 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11546 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11547 : generate a few handy files for later
11548 $cat > signal.c <<'EOCP'
11549 #include <sys/types.h>
11550 #include <signal.h>
11551 #include <stdio.h>
11552 int main() {
11553
11554 /* Strange style to avoid deeply-nested #if/#else/#endif */
11555 #ifndef NSIG
11556 #  ifdef _NSIG
11557 #    define NSIG (_NSIG)
11558 #  endif
11559 #endif
11560
11561 #ifndef NSIG
11562 #  ifdef SIGMAX
11563 #    define NSIG (SIGMAX+1)
11564 #  endif
11565 #endif
11566
11567 #ifndef NSIG
11568 #  ifdef SIG_MAX
11569 #    define NSIG (SIG_MAX+1)
11570 #  endif
11571 #endif
11572
11573 #ifndef NSIG
11574 #  ifdef MAXSIG
11575 #    define NSIG (MAXSIG+1)
11576 #  endif
11577 #endif
11578
11579 #ifndef NSIG
11580 #  ifdef MAX_SIG
11581 #    define NSIG (MAX_SIG+1)
11582 #  endif
11583 #endif
11584
11585 #ifndef NSIG
11586 #  ifdef SIGARRAYSIZE
11587 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11588 #  endif
11589 #endif
11590
11591 #ifndef NSIG
11592 #  ifdef _sys_nsig
11593 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11594 #  endif
11595 #endif
11596
11597 /* Default to some arbitrary number that's big enough to get most
11598    of the common signals.
11599 */
11600 #ifndef NSIG
11601 #    define NSIG 50
11602 #endif
11603
11604 printf("NSIG %d\n", NSIG);
11605
11606 #ifndef JUST_NSIG
11607
11608 EOCP
11609
11610 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11611 {
11612         printf "#ifdef SIG"; printf $1; printf "\n"
11613         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11614         printf $1; printf ");\n"
11615         printf "#endif\n"
11616 }
11617 END {
11618         printf "#endif /* JUST_NSIG */\n";
11619         printf "}\n";
11620 }
11621 ' >>signal.c
11622 $cat >signal.awk <<'EOP'
11623 BEGIN { ndups = 0 }
11624 $1 ~ /^NSIG$/ { nsig = $2 }
11625 ($1 !~ /^NSIG$/) && (NF == 2) {
11626     if ($2 > maxsig) { maxsig = $2 }
11627     if (sig_name[$2]) {
11628         dup_name[ndups] = $1
11629         dup_num[ndups] = $2
11630         ndups++ 
11631     }
11632     else {
11633         sig_name[$2] = $1
11634         sig_num[$2] = $2
11635     }
11636 }
11637 END { 
11638     if (nsig == 0) {
11639         nsig = maxsig + 1
11640     }
11641     printf("NSIG %d\n", nsig);
11642     for (n = 1; n < nsig; n++) {
11643         if (sig_name[n]) {
11644             printf("%s %d\n", sig_name[n], sig_num[n])
11645         }
11646         else {
11647             printf("NUM%d %d\n", n, n) 
11648         }
11649     }
11650     for (n = 0; n < ndups; n++) {
11651         printf("%s %d\n", dup_name[n], dup_num[n])
11652     }
11653 }
11654 EOP
11655 $cat >signal_cmd <<EOS
11656 $startsh
11657 if $test -s signal.lst; then
11658     echo "Using your existing signal.lst file"
11659         exit 0
11660 fi
11661 xxx="$xxx"
11662 EOS
11663 $cat >>signal_cmd <<'EOS'
11664
11665 set signal
11666 if eval $compile_ok; then
11667         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11668 else
11669         echo "(I can't seem be able to compile the whole test program)" >&4
11670         echo "(I'll try it in little pieces.)" >&4
11671         set signal -DJUST_NSIG
11672         if eval $compile_ok; then
11673                 ./signal$_exe > signal.nsg
11674                 $cat signal.nsg
11675         else
11676                 echo "I can't seem to figure out how many signals you have." >&4
11677                 echo "Guessing 50." >&4
11678                 echo 'NSIG 50' > signal.nsg
11679         fi
11680         : Now look at all the signal names, one at a time.
11681         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11682                 $cat > signal.c <<EOCP
11683 #include <sys/types.h>
11684 #include <signal.h>
11685 #include <stdio.h>
11686 int main() {
11687 printf("$xx %d\n", SIG${xx});
11688 return 0;
11689 }
11690 EOCP
11691                 set signal
11692                 if eval $compile; then
11693                         echo "SIG${xx} found."
11694                         ./signal$_exe  >> signal.ls1
11695                 else
11696                         echo "SIG${xx} NOT found."
11697                 fi
11698         done
11699         if $test -s signal.ls1; then
11700                 $cat signal.nsg signal.ls1 |
11701                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11702         fi
11703
11704 fi
11705 if $test -s signal.lst; then
11706         :
11707 else
11708         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11709         echo 'kill -l' >signal
11710         set X `csh -f <signal`
11711         $rm -f signal
11712         shift
11713         case $# in
11714         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11715         esac
11716         echo $@ | $tr ' ' $trnl | \
11717             $awk '{ printf "%s %d\n", $1, ++s; }
11718                   END { printf "NSIG %d\n", ++s }' >signal.lst
11719 fi
11720 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11721 EOS
11722 chmod a+x signal_cmd
11723 $eunicefix signal_cmd
11724
11725 : generate list of signal names
11726 echo " "
11727 case "$sig_name_init" in
11728 '') doinit=yes ;;
11729 *)  case "$sig_num_init" in
11730     ''|*,*) doinit=yes ;;
11731     esac ;;
11732 esac
11733 case "$doinit" in
11734 yes)
11735         echo "Generating a list of signal names and numbers..." >&4
11736         . ./signal_cmd
11737         sig_count=`$awk '/^NSIG/ { printf "%d", $2 }' signal.lst`
11738         sig_name=`$awk 'BEGIN { printf "ZERO " }
11739                         !/^NSIG/ { printf "%s ", $1 }' signal.lst`
11740         sig_num=`$awk  'BEGIN { printf "0 " }
11741                         !/^NSIG/ { printf "%d ", $2 }' signal.lst`
11742         sig_name_init=`$awk 'BEGIN      { printf "\"ZERO\", " }
11743                              !/^NSIG/   { printf "\"%s\", ", $1 }
11744                              END        { printf "0\n" }' signal.lst`
11745         sig_num_init=`$awk  'BEGIN      { printf "0, " }
11746                              !/^NSIG/   { printf "%d, ", $2}
11747                              END        { printf "0\n"}' signal.lst`
11748         ;;
11749 esac
11750 echo "The following $sig_count signals are available:"
11751 echo " "
11752 echo $sig_name | $awk \
11753 'BEGIN { linelen = 0 }
11754 {
11755         for (i = 1; i <= NF; i++) {
11756                 name = "SIG" $i " "
11757                 linelen = linelen + length(name)
11758                 if (linelen > 70) {
11759                         printf "\n"
11760                         linelen = length(name)
11761                 }
11762                 printf "%s", name
11763         }
11764         printf "\n"
11765 }'
11766 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11767
11768 : see what type is used for signed size_t
11769 set ssize_t ssizetype int stdio.h sys/types.h
11770 eval $typedef
11771 dflt="$ssizetype"
11772 $cat > ssize.c <<EOM
11773 #include <stdio.h>
11774 #include <sys/types.h>
11775 #define Size_t $sizetype
11776 #define SSize_t $dflt
11777 int main()
11778 {
11779         if (sizeof(Size_t) == sizeof(SSize_t))
11780                 printf("$dflt\n");
11781         else if (sizeof(Size_t) == sizeof(int))
11782                 printf("int\n");
11783         else 
11784                 printf("long\n");
11785         exit(0);
11786 }
11787 EOM
11788 echo " "
11789 set ssize
11790 if eval $compile_ok && ./ssize > /dev/null; then
11791         ssizetype=`./ssize`
11792         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11793 else
11794         $cat >&4 <<EOM
11795 Help! I can't compile and run the ssize_t test program: please enlighten me!
11796 (This is probably a misconfiguration in your system or libraries, and
11797 you really ought to fix it.  Still, I'll try anyway.)
11798
11799 I need a type that is the same size as $sizetype, but is guaranteed to
11800 be signed.  Common values are ssize_t, int and long.
11801
11802 EOM
11803         rp="What signed type is the same size as $sizetype?"
11804         . ./myread
11805         ssizetype="$ans"
11806 fi
11807 $rm -f ssize ssize.*
11808
11809 : see what type of char stdio uses.
11810 echo " "
11811 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11812         echo "Your stdio uses unsigned chars." >&4
11813         stdchar="unsigned char"
11814 else
11815         echo "Your stdio uses signed chars." >&4
11816         stdchar="char"
11817 fi
11818
11819 : see if time exists
11820 echo " "
11821 if test "X$d_time" = X -o X"$timetype" = X; then
11822     if set time val -f d_time; eval $csym; $val; then
11823                 echo 'time() found.' >&4
11824                 val="$define"
11825                 rp="What is the type returned by time() on this system?"
11826                 set time_t timetype long stdio.h sys/types.h
11827                 eval $typedef_ask
11828     else
11829                 echo 'time() not found, hope that will do.' >&4
11830                 val="$undef"
11831                 timetype='int';
11832     fi
11833     set d_time
11834     eval $setvar
11835 fi
11836
11837 : see what type uids are declared as in the kernel
11838 echo " "
11839 echo "Looking for the type for user ids returned by getuid()."
11840 set uid_t uidtype xxx stdio.h sys/types.h
11841 eval $typedef
11842 case "$uidtype" in
11843 xxx)
11844         xxx=`./findhdr sys/user.h`
11845         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
11846         case $1 in
11847         unsigned) dflt="$1 $2" ;;
11848         *) dflt="$1" ;;
11849         esac
11850         ;;
11851 *) dflt="$uidtype";;
11852 esac
11853 case "$uidtype" in
11854 uid_t)  echo "uid_t found." ;;
11855 *)      rp="What is the type for user ids returned by getuid()?"
11856         . ./myread
11857         uidtype="$ans"
11858         ;;
11859 esac
11860
11861 : see if dbm.h is available
11862 : see if dbmclose exists
11863 set dbmclose d_dbmclose
11864 eval $inlibc
11865
11866 case "$d_dbmclose" in
11867 $define)
11868         set dbm.h i_dbm
11869         eval $inhdr
11870         case "$i_dbm" in
11871         $define)
11872                 val="$undef"
11873                 set i_rpcsvcdbm
11874                 eval $setvar
11875                 ;;
11876         *)      set rpcsvc/dbm.h i_rpcsvcdbm
11877                 eval $inhdr
11878                 ;;
11879         esac
11880         ;;
11881 *)      echo "We won't be including <dbm.h>"
11882         val="$undef"
11883         set i_dbm
11884         eval $setvar
11885         val="$undef"
11886         set i_rpcsvcdbm
11887         eval $setvar
11888         ;;
11889 esac
11890
11891 : see if this is a sys/file.h system
11892 val=''
11893 set sys/file.h val
11894 eval $inhdr
11895
11896 : do we need to include sys/file.h ?
11897 case "$val" in
11898 "$define")
11899         echo " "
11900         if $h_sysfile; then
11901                 val="$define"
11902                 echo "We'll be including <sys/file.h>." >&4
11903         else
11904                 val="$undef"
11905                 echo "We won't be including <sys/file.h>." >&4
11906         fi
11907         ;;
11908 *)
11909         h_sysfile=false
11910         ;;
11911 esac
11912 set i_sysfile
11913 eval $setvar
11914
11915 : see if fcntl.h is there
11916 val=''
11917 set fcntl.h val
11918 eval $inhdr
11919
11920 : see if we can include fcntl.h
11921 case "$val" in
11922 "$define")
11923         echo " "
11924         if $h_fcntl; then
11925                 val="$define"
11926                 echo "We'll be including <fcntl.h>." >&4
11927         else
11928                 val="$undef"
11929                 if $h_sysfile; then
11930         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
11931                 else
11932                         echo "We won't be including <fcntl.h>." >&4
11933                 fi
11934         fi
11935         ;;
11936 *)
11937         h_fcntl=false
11938         val="$undef"
11939         ;;
11940 esac
11941 set i_fcntl
11942 eval $setvar
11943
11944 : see if locale.h is available
11945 set locale.h i_locale
11946 eval $inhdr
11947
11948 : see if mach cthreads are available
11949 if test "X$usethreads" = "X$define"; then
11950         set mach/cthreads.h i_machcthr
11951         eval $inhdr
11952 else
11953         i_machcthr="$undef"
11954 fi
11955
11956
11957
11958 : see if this is a math.h system
11959 set math.h i_math
11960 eval $inhdr
11961
11962 : see if this is a mntent.h system
11963 set mntent.h i_mntent
11964 eval $inhdr
11965
11966 : see if ndbm.h is available
11967 set ndbm.h t_ndbm
11968 eval $inhdr
11969 case "$t_ndbm" in
11970 $define)
11971         : see if dbm_open exists
11972         set dbm_open d_dbm_open
11973         eval $inlibc
11974         case "$d_dbm_open" in
11975         $undef)
11976                 t_ndbm="$undef"
11977                 echo "We won't be including <ndbm.h>"
11978                 ;;
11979         esac
11980         ;;
11981 esac
11982 val="$t_ndbm"
11983 set i_ndbm
11984 eval $setvar
11985
11986 : see if net/errno.h is available
11987 val=''
11988 set net/errno.h val
11989 eval $inhdr
11990
11991 : Unfortunately, it causes problems on some systems.  Arrgh.
11992 case "$val" in
11993 $define)
11994         cat > try.c <<'EOM'
11995 #include <stdio.h>
11996 #include <errno.h>
11997 #include <net/errno.h>
11998 int func()
11999 {
12000         return ENOTSOCK;
12001 }
12002 EOM
12003         if $cc $ccflags -c try.c >/dev/null 2>&1; then
12004                 echo "We'll be including <net/errno.h>." >&4
12005         else
12006                 echo "We won't be including <net/errno.h>." >&4
12007                 val="$undef"
12008         fi
12009         $rm -f try.* try
12010         ;;
12011 esac
12012 set i_neterrno
12013 eval $setvar
12014
12015 : see if netinet/tcp.h is available
12016 set netinet/tcp.h i_netinettcp
12017 eval $inhdr
12018
12019 : see if this is a poll.h system
12020 set poll.h i_poll
12021 eval $inhdr
12022
12023 : get C preprocessor symbols handy
12024 echo " "
12025 $echo $n "Hmm... $c"
12026 echo $al | $tr ' ' $trnl >Cppsym.know
12027 $cat <<EOSS >Cppsym
12028 $startsh
12029 case "\$1" in
12030 -l) list=true
12031         shift
12032         ;;
12033 esac
12034 unknown=''
12035 case "\$list\$#" in
12036 1|2)
12037         for sym do
12038                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
12039                         exit 0
12040                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
12041                         :
12042                 else
12043                         unknown="\$unknown \$sym"
12044                 fi
12045         done
12046         set X \$unknown
12047         shift
12048         ;;
12049 esac
12050 case \$# in
12051 0) exit 1;;
12052 esac
12053 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
12054 #ifdef \1\\
12055 exit 0; _ _ _ _\1\\      \1\\
12056 #endif\\
12057 /' >Cppsym\$\$
12058 echo "exit 1; _ _ _" >>Cppsym\$\$
12059 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
12060 case "\$list" in
12061 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
12062 *)
12063         sh Cppsym2\$\$
12064         status=\$?
12065         ;;
12066 esac
12067 $rm -f Cppsym\$\$ Cppsym2\$\$
12068 exit \$status
12069 EOSS
12070 chmod +x Cppsym
12071 $eunicefix Cppsym
12072 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
12073
12074 : now check the C compiler for additional symbols
12075 postprocess_cc_v=''
12076 case "$osname" in
12077 aix) postprocess_cc_v="|$tr , ' '" ;;
12078 esac
12079 $cat >ccsym <<EOS
12080 $startsh
12081 $cat >tmp.c <<EOF
12082 extern int foo;
12083 EOF
12084 for i in \`$cc -v -c tmp.c 2>&1 $postprocess_cc_v\`
12085 do
12086         case "\$i" in
12087         -D*) echo "\$i" | $sed 's/^-D//';;
12088         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
12089         esac
12090 done
12091 $rm -f try.c
12092 EOS
12093 postprocess_cc_v=''
12094 chmod +x ccsym
12095 $eunicefix ccsym
12096 ./ccsym > ccsym1.raw
12097 if $test -s ccsym1.raw; then
12098        $sort ccsym1.raw | $uniq >ccsym.raw
12099 else
12100        mv ccsym1.raw ccsym.raw
12101 fi
12102
12103 $awk '/\=/ { print $0; next }
12104         { print $0"=1" }' ccsym.raw >ccsym.list
12105 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
12106 $comm -13 ccsym.true ccsym.list >ccsym.own
12107 $comm -12 ccsym.true ccsym.list >ccsym.com
12108 $comm -23 ccsym.true ccsym.list >ccsym.cpp
12109 also=''
12110 if $test -z ccsym.raw; then
12111         echo "Your C compiler doesn't seem to define any symbols!" >&4
12112         echo " "
12113         echo "However, your C preprocessor defines the following symbols:"
12114         $cat Cppsym.true
12115         ccsymbols=''
12116         cppsymbols=`$cat Cppsym.true`
12117         cppsymbols=`echo $cppsymbols`
12118         cppccsymbols="$cppsymbols"
12119 else
12120         if $test -s ccsym.com; then
12121                 echo "Your C compiler and pre-processor define these symbols:"
12122                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
12123                 also='also '
12124                 symbols='ones'
12125                 cppccsymbols=`$cat ccsym.com`
12126                 cppccsymbols=`echo $cppccsymbols`
12127                 $test "$silent" || sleep 1
12128         fi
12129         if $test -s ccsym.cpp; then
12130                 $test "$also" && echo " "
12131                 echo "Your C pre-processor ${also}defines the following symbols:"
12132                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
12133                 also='further '
12134                 cppsymbols=`$cat ccsym.cpp`
12135                 cppsymbols=`echo $cppsymbols`
12136                 $test "$silent" || sleep 1
12137         fi
12138         if $test -s ccsym.own; then
12139                 $test "$also" && echo " "
12140                 echo "Your C compiler ${also}defines the following cpp symbols:"
12141                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
12142                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
12143                 ccsymbols=`$cat ccsym.own`
12144                 ccsymbols=`echo $ccsymbols`
12145                 $test "$silent" || sleep 1
12146         fi
12147 fi
12148 $rm -f ccsym*
12149
12150 : see if this is a termio system
12151 val="$undef"
12152 val2="$undef"
12153 val3="$undef"
12154 if $test `./findhdr termios.h`; then
12155         set tcsetattr i_termios
12156         eval $inlibc
12157         val3="$i_termios"
12158 fi
12159 echo " "
12160 case "$val3" in
12161 "$define") echo "You have POSIX termios.h... good!" >&4;;
12162 *) if ./Cppsym pyr; then
12163                 case "`/bin/universe`" in
12164                 ucb) if $test `./findhdr sgtty.h`; then
12165                                 val2="$define"
12166                                 echo "<sgtty.h> found." >&4
12167                         else
12168                                 echo "System is pyramid with BSD universe."
12169                                 echo "<sgtty.h> not found--you could have problems." >&4
12170                         fi;;
12171                 *) if $test `./findhdr termio.h`; then
12172                                 val="$define"
12173                                 echo "<termio.h> found." >&4
12174                         else
12175                                 echo "System is pyramid with USG universe."
12176                                 echo "<termio.h> not found--you could have problems." >&4
12177                         fi;;
12178                 esac
12179         elif ./usg; then
12180                 if $test `./findhdr termio.h`; then
12181                         echo "<termio.h> found." >&4
12182                         val="$define"
12183                 elif $test `./findhdr sgtty.h`; then
12184                         echo "<sgtty.h> found." >&4
12185                         val2="$define"
12186                 else
12187 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
12188                 fi
12189         else
12190                 if $test `./findhdr sgtty.h`; then
12191                         echo "<sgtty.h> found." >&4
12192                         val2="$define"
12193                 elif $test `./findhdr termio.h`; then
12194                         echo "<termio.h> found." >&4
12195                         val="$define"
12196                 else
12197 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
12198                 fi
12199         fi;;
12200 esac
12201 set i_termio; eval $setvar
12202 val=$val2; set i_sgtty; eval $setvar
12203 val=$val3; set i_termios; eval $setvar
12204
12205 : see if stdarg is available
12206 echo " "
12207 if $test `./findhdr stdarg.h`; then
12208         echo "<stdarg.h> found." >&4
12209         valstd="$define"
12210 else
12211         echo "<stdarg.h> NOT found." >&4
12212         valstd="$undef"
12213 fi
12214
12215 : see if varags is available
12216 echo " "
12217 if $test `./findhdr varargs.h`; then
12218         echo "<varargs.h> found." >&4
12219 else
12220         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
12221 fi
12222
12223 : set up the varargs testing programs
12224 $cat > varargs.c <<EOP
12225 #ifdef I_STDARG
12226 #include <stdarg.h>
12227 #endif
12228 #ifdef I_VARARGS
12229 #include <varargs.h>
12230 #endif
12231
12232 #ifdef I_STDARG
12233 int f(char *p, ...)
12234 #else
12235 int f(va_alist)
12236 va_dcl
12237 #endif
12238 {
12239         va_list ap;
12240 #ifndef I_STDARG
12241         char *p;
12242 #endif
12243 #ifdef I_STDARG
12244         va_start(ap,p);
12245 #else
12246         va_start(ap);
12247         p = va_arg(ap, char *);
12248 #endif
12249         va_end(ap);
12250 }
12251 EOP
12252 $cat > varargs <<EOP
12253 $startsh
12254 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
12255         echo "true"
12256 else
12257         echo "false"
12258 fi
12259 $rm -f varargs$_o
12260 EOP
12261 chmod +x varargs
12262
12263 : now check which varargs header should be included
12264 echo " "
12265 i_varhdr=''
12266 case "$valstd" in
12267 "$define")
12268         if `./varargs I_STDARG`; then
12269                 val='stdarg.h'
12270         elif `./varargs I_VARARGS`; then
12271                 val='varargs.h'
12272         fi
12273         ;;
12274 *)
12275         if `./varargs I_VARARGS`; then
12276                 val='varargs.h'
12277         fi
12278         ;;
12279 esac
12280 case "$val" in
12281 '')
12282 echo "I could not find the definition for va_dcl... You have problems..." >&4
12283         val="$undef"; set i_stdarg; eval $setvar
12284         val="$undef"; set i_varargs; eval $setvar
12285         ;;
12286 *) 
12287         set i_varhdr
12288         eval $setvar
12289         case "$i_varhdr" in
12290         stdarg.h)
12291                 val="$define"; set i_stdarg; eval $setvar
12292                 val="$undef"; set i_varargs; eval $setvar
12293                 ;;
12294         varargs.h)
12295                 val="$undef"; set i_stdarg; eval $setvar
12296                 val="$define"; set i_varargs; eval $setvar
12297                 ;;
12298         esac
12299         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
12300 esac
12301 $rm -f varargs*
12302
12303 : see if stddef is available
12304 set stddef.h i_stddef
12305 eval $inhdr
12306
12307 : see if sys/access.h is available
12308 set sys/access.h i_sysaccess
12309 eval $inhdr
12310
12311 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
12312 set sys/filio.h i_sysfilio
12313 eval $inhdr
12314 echo " "
12315 if $test `./findhdr sys/ioctl.h`; then
12316         val="$define"
12317         echo '<sys/ioctl.h> found.' >&4
12318 else
12319         val="$undef"
12320         if $test $i_sysfilio = "$define"; then
12321             echo '<sys/ioctl.h> NOT found.' >&4
12322         else
12323                 $test $i_sgtty = "$define" && xxx="sgtty.h"
12324                 $test $i_termio = "$define" && xxx="termio.h"
12325                 $test $i_termios = "$define" && xxx="termios.h"
12326 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
12327         fi
12328 fi
12329 set i_sysioctl
12330 eval $setvar
12331
12332 : see if sys/resource.h has to be included
12333 set sys/resource.h i_sysresrc
12334 eval $inhdr
12335
12336 : see if sys/security.h is available
12337 set sys/security.h i_syssecrt
12338 eval $inhdr
12339
12340 : see if this is a sys/statvfs.h system
12341 set sys/statvfs.h i_sysstatvfs
12342 eval $inhdr
12343
12344 : see if this is a sys/un.h system
12345 set sys/un.h i_sysun
12346 eval $inhdr
12347
12348 : see if this is a syswait system
12349 set sys/wait.h i_syswait
12350 eval $inhdr
12351
12352 : see if this is an utime system
12353 set utime.h i_utime
12354 eval $inhdr
12355
12356 : see if this is a values.h system
12357 set values.h i_values
12358 eval $inhdr
12359
12360 : see if this is a vfork system
12361 case "$d_vfork" in
12362 "$define")
12363         set vfork.h i_vfork
12364         eval $inhdr
12365         ;;
12366 *)
12367         i_vfork="$undef"
12368         ;;
12369 esac
12370
12371 : see if gdbm.h is available
12372 set gdbm.h t_gdbm
12373 eval $inhdr
12374 case "$t_gdbm" in
12375 $define)
12376         : see if gdbm_open exists
12377         set gdbm_open d_gdbm_open
12378         eval $inlibc
12379         case "$d_gdbm_open" in
12380         $undef)
12381                 t_gdbm="$undef"
12382                 echo "We won't be including <gdbm.h>"
12383                 ;;
12384         esac
12385         ;;
12386 esac
12387 val="$t_gdbm"
12388 set i_gdbm
12389 eval $setvar
12390
12391 echo " "
12392 echo "Looking for extensions..." >&4
12393 tdir=`pwd`
12394 cd $rsrc/ext
12395 : If we are using the old config.sh, known_extensions may contain
12396 : old or inaccurate or duplicate values.
12397 known_extensions=''
12398 nonxs_extensions=''
12399 : We do not use find because it might not be available.
12400 : We do not just use MANIFEST because the user may have dropped
12401 : some additional extensions into the source tree and expect them
12402 : to be built.
12403 for xxx in * ; do
12404         case "$xxx" in
12405         DynaLoader|dynaload) ;;
12406         *)      if $test -f $xxx/$xxx.xs; then
12407                         known_extensions="$known_extensions $xxx"
12408                 elif $test -f $xxx/Makefile.PL; then
12409                         nonxs_extensions="$nonxs_extensions $xxx"
12410                 else
12411                         if $test -d $xxx; then
12412                                 # Look for nested extensions, eg. Devel/Dprof.
12413                                 cd $xxx
12414                                 for yyy in * ; do
12415                                 if $test -f $yyy/$yyy.xs; then
12416                                         known_extensions="$known_extensions $xxx/$yyy"
12417                                 elif $test -f $yyy/Makefile.PL; then
12418                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
12419                                 fi
12420                                 done
12421                                 cd ..
12422                         fi
12423                 fi 
12424                 ;;
12425         esac
12426 done
12427 set X $nonxs_extensions
12428 shift
12429 nonxs_extensions="$*"
12430 set X $known_extensions
12431 shift
12432 known_extensions="$*"
12433 cd $tdir
12434
12435 : Now see which are supported on this system.
12436 avail_ext=''
12437 for xxx in $known_extensions ; do
12438         case "$xxx" in
12439         DB_File|db_file)
12440                 case "$i_db" in
12441                 $define) avail_ext="$avail_ext $xxx" ;;
12442                 esac
12443                 ;;
12444         GDBM_File|gdbm_fil)
12445                 case "$i_gdbm" in 
12446                 $define) avail_ext="$avail_ext $xxx" ;;
12447                 esac
12448                 ;;
12449         NDBM_File|ndbm_fil)
12450                 case "$i_ndbm" in
12451                 $define) avail_ext="$avail_ext $xxx" ;;
12452                 esac
12453                 ;;
12454         ODBM_File|odbm_fil) 
12455                 case "${i_dbm}${i_rpcsvcdbm}" in
12456                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12457                 esac
12458                 ;;
12459         POSIX|posix)
12460                 case "$useposix" in
12461                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12462                 esac
12463                 ;;
12464         Opcode|opcode)
12465                 case "$useopcode" in
12466                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12467                 esac
12468                 ;;
12469         Socket|socket)
12470                 case "$d_socket" in 
12471                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12472                 esac
12473                 ;;
12474         Thread|thread)
12475                 case "$usethreads" in 
12476                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12477                 esac
12478                 ;;
12479         IPC/SysV|ipc/sysv)
12480                 : XXX Do we need a useipcsysv variable here
12481                 case "${d_msg}${d_sem}${d_shm}" in 
12482                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12483                 esac
12484                 ;;
12485         *)      avail_ext="$avail_ext $xxx"
12486                 ;;
12487         esac
12488 done
12489
12490 set X $avail_ext
12491 shift
12492 avail_ext="$*"
12493
12494 : Now see which nonxs extensions are supported on this system.
12495 : For now assume all are.
12496 nonxs_ext=''
12497 for xxx in $nonxs_extensions ; do
12498         case "$xxx" in
12499         *)      nonxs_ext="$nonxs_ext $xxx"
12500                 ;;
12501         esac
12502 done
12503
12504 set X $nonxs_ext
12505 shift
12506 nonxs_ext="$*"
12507
12508 case $usedl in
12509 $define)
12510         $cat <<EOM
12511 A number of extensions are supplied with $package.  You may choose to
12512 compile these extensions for dynamic loading (the default), compile
12513 them into the $package executable (static loading), or not include
12514 them at all.  Answer "none" to include no extensions.
12515 Note that DynaLoader is always built and need not be mentioned here.
12516
12517 EOM
12518         case "$dynamic_ext" in
12519         '') dflt="$avail_ext" ;;
12520         *)      dflt="$dynamic_ext"
12521                 # Perhaps we are reusing an old out-of-date config.sh.
12522                 case "$hint" in
12523                 previous)
12524                         if test X"$dynamic_ext" != X"$avail_ext"; then
12525                                 $cat <<EOM
12526 NOTICE:  Your previous config.sh list may be incorrect. 
12527 The extensions now available to you are 
12528         ${avail_ext}
12529 but the default list from your previous config.sh is
12530         ${dynamic_ext} 
12531
12532 EOM
12533                         fi
12534                         ;;
12535                 esac
12536                 ;;
12537         esac
12538         case "$dflt" in
12539         '')     dflt=none;;
12540         esac
12541         rp="What extensions do you wish to load dynamically?"
12542         . ./myread
12543         case "$ans" in
12544         none) dynamic_ext=' ' ;;
12545         *) dynamic_ext="$ans" ;;
12546         esac
12547
12548         case "$static_ext" in
12549         '')
12550                 : Exclude those already listed in dynamic linking
12551                 dflt=''
12552                 for xxx in $avail_ext; do
12553                         case " $dynamic_ext " in
12554                         *" $xxx "*) ;;
12555                         *) dflt="$dflt $xxx" ;;
12556                         esac
12557                 done
12558                 set X $dflt
12559                 shift
12560                 dflt="$*"
12561                 ;;
12562         *)  dflt="$static_ext" 
12563                 ;;
12564         esac
12565
12566         case "$dflt" in
12567         '')     dflt=none;;
12568         esac
12569         rp="What extensions do you wish to load statically?"
12570         . ./myread
12571         case "$ans" in
12572         none) static_ext=' ' ;;
12573         *) static_ext="$ans" ;;
12574         esac
12575         ;;
12576 *)
12577         $cat <<EOM
12578 A number of extensions are supplied with $package.  Answer "none" 
12579 to include no extensions. 
12580 Note that DynaLoader is always built and need not be mentioned here.
12581
12582 EOM
12583         case "$static_ext" in
12584         '') dflt="$avail_ext" ;;
12585         *)      dflt="$static_ext"
12586                 # Perhaps we are reusing an old out-of-date config.sh.
12587                 case "$hint" in
12588                 previous)
12589                         if test X"$static_ext" != X"$avail_ext"; then
12590                                 $cat <<EOM
12591 NOTICE:  Your previous config.sh list may be incorrect. 
12592 The extensions now available to you are 
12593         ${avail_ext}
12594 but the default list from your previous config.sh is
12595         ${static_ext} 
12596
12597 EOM
12598                         fi
12599                         ;;
12600                 esac
12601                 ;;
12602         esac
12603         : Exclude those that are not xs extensions
12604         case "$dflt" in
12605         '')     dflt=none;;
12606         esac
12607         rp="What extensions do you wish to include?"
12608         . ./myread
12609         case "$ans" in
12610         none) static_ext=' ' ;;
12611         *) static_ext="$ans" ;;
12612         esac
12613         ;;
12614 esac
12615
12616 set X $dynamic_ext $static_ext $nonxs_ext
12617 shift
12618 extensions="$*"
12619
12620 : Remove build directory name from cppstdin so it can be used from
12621 : either the present location or the final installed location.
12622 echo " "
12623 : Get out of the UU directory to get correct path name.
12624 cd ..
12625 case "$cppstdin" in
12626 `pwd`/cppstdin)
12627         echo "Stripping down cppstdin path name"
12628         cppstdin=cppstdin
12629         ;;
12630 esac
12631 cd UU
12632
12633 : end of configuration questions
12634 echo " "
12635 echo "End of configuration questions."
12636 echo " "
12637
12638 : back to where it started
12639 if test -d ../UU; then
12640         cd ..
12641 fi
12642
12643 : configuration may be patched via a 'config.over' file
12644 if $test -f config.over; then
12645         echo " "
12646         dflt=y
12647         rp='I see a config.over file.  Do you wish to load it?'
12648         . UU/myread
12649         case "$ans" in
12650         n*) echo "OK, I'll ignore it.";;
12651         *)      . ./config.over
12652                 echo "Configuration override changes have been loaded."
12653                 ;;
12654         esac
12655 fi
12656
12657 : in case they want portability, strip down executable paths
12658 case "$d_portable" in
12659 "$define")
12660         echo " "
12661         echo "Stripping down executable paths..." >&4
12662         for file in $loclist $trylist; do
12663                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12664                         eval $file="\$file"
12665                 fi
12666         done
12667         ;;
12668 esac
12669
12670 : create config.sh file
12671 echo " "
12672 echo "Creating config.sh..." >&4
12673 $spitshell <<EOT >config.sh
12674 $startsh
12675 #
12676 # This file was produced by running the Configure script. It holds all the
12677 # definitions figured out by Configure. Should you modify one of these values,
12678 # do not forget to propagate your changes by running "Configure -der". You may
12679 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12680 #
12681
12682 # Package name      : $package
12683 # Source directory  : $src
12684 # Configuration time: $cf_time
12685 # Configured by     : $cf_by
12686 # Target system     : $myuname
12687
12688 Author='$Author'
12689 Date='$Date'
12690 Header='$Header'
12691 Id='$Id'
12692 Locker='$Locker'
12693 Log='$Log'
12694 Mcc='$Mcc'
12695 RCSfile='$RCSfile'
12696 Revision='$Revision'
12697 Source='$Source'
12698 State='$State'
12699 _a='$_a'
12700 _exe='$_exe'
12701 _o='$_o'
12702 afs='$afs'
12703 alignbytes='$alignbytes'
12704 ansi2knr='$ansi2knr'
12705 aphostname='$aphostname'
12706 apiversion='$apiversion'
12707 ar='$ar'
12708 archlib='$archlib'
12709 archlibexp='$archlibexp'
12710 archname64='$archname64'
12711 archname='$archname'
12712 archobjs='$archobjs'
12713 awk='$awk'
12714 baserev='$baserev'
12715 bash='$bash'
12716 bin='$bin'
12717 binexp='$binexp'
12718 bison='$bison'
12719 byacc='$byacc'
12720 byteorder='$byteorder'
12721 c='$c'
12722 castflags='$castflags'
12723 cat='$cat'
12724 cc='$cc'
12725 cccdlflags='$cccdlflags'
12726 ccdlflags='$ccdlflags'
12727 ccflags='$ccflags'
12728 ccsymbols='$ccsymbols'
12729 cf_by='$cf_by'
12730 cf_email='$cf_email'
12731 cf_time='$cf_time'
12732 chgrp='$chgrp'
12733 chmod='$chmod'
12734 chown='$chown'
12735 clocktype='$clocktype'
12736 comm='$comm'
12737 compress='$compress'
12738 contains='$contains'
12739 cp='$cp'
12740 cpio='$cpio'
12741 cpp='$cpp'
12742 cpp_stuff='$cpp_stuff'
12743 cppccsymbols='$cppccsymbols'
12744 cppflags='$cppflags'
12745 cpplast='$cpplast'
12746 cppminus='$cppminus'
12747 cpprun='$cpprun'
12748 cppstdin='$cppstdin'
12749 cppsymbols='$cppsymbols'
12750 crosscompile='$crosscompile'
12751 cryptlib='$cryptlib'
12752 csh='$csh'
12753 d_Gconvert='$d_Gconvert'
12754 d_access='$d_access'
12755 d_accessx='$d_accessx'
12756 d_alarm='$d_alarm'
12757 d_archlib='$d_archlib'
12758 d_attribut='$d_attribut'
12759 d_bcmp='$d_bcmp'
12760 d_bcopy='$d_bcopy'
12761 d_bsd='$d_bsd'
12762 d_bsdgetpgrp='$d_bsdgetpgrp'
12763 d_bsdsetpgrp='$d_bsdsetpgrp'
12764 d_bzero='$d_bzero'
12765 d_casti32='$d_casti32'
12766 d_castneg='$d_castneg'
12767 d_charvspr='$d_charvspr'
12768 d_chown='$d_chown'
12769 d_chroot='$d_chroot'
12770 d_chsize='$d_chsize'
12771 d_closedir='$d_closedir'
12772 d_cmsghdr_s='$d_cmsghdr_s'
12773 d_const='$d_const'
12774 d_crypt='$d_crypt'
12775 d_csh='$d_csh'
12776 d_cuserid='$d_cuserid'
12777 d_dbl_dig='$d_dbl_dig'
12778 d_dbmclose64='$d_dbmclose64'
12779 d_dbminit64='$d_dbminit64'
12780 d_delete64='$d_delete64'
12781 d_difftime='$d_difftime'
12782 d_dirent64_s='$d_dirent64_s'
12783 d_dirnamlen='$d_dirnamlen'
12784 d_dlerror='$d_dlerror'
12785 d_dlopen='$d_dlopen'
12786 d_dlsymun='$d_dlsymun'
12787 d_dosuid='$d_dosuid'
12788 d_drand48proto='$d_drand48proto'
12789 d_dup2='$d_dup2'
12790 d_eaccess='$d_eaccess'
12791 d_endgrent='$d_endgrent'
12792 d_endhent='$d_endhent'
12793 d_endnent='$d_endnent'
12794 d_endpent='$d_endpent'
12795 d_endpwent='$d_endpwent'
12796 d_endsent='$d_endsent'
12797 d_eofnblk='$d_eofnblk'
12798 d_eunice='$d_eunice'
12799 d_fchmod='$d_fchmod'
12800 d_fchown='$d_fchown'
12801 d_fcntl='$d_fcntl'
12802 d_fd_macros='$d_fd_macros'
12803 d_fd_set='$d_fd_set'
12804 d_fds_bits='$d_fds_bits'
12805 d_fetch64='$d_fetch64'
12806 d_fgetpos64='$d_fgetpos64'
12807 d_fgetpos='$d_fgetpos'
12808 d_firstkey64='$d_firstkey64'
12809 d_flexfnam='$d_flexfnam'
12810 d_flock64_s='$d_flock64_s'
12811 d_flock='$d_flock'
12812 d_fopen64='$d_fopen64'
12813 d_fork='$d_fork'
12814 d_fpathconf='$d_fpathconf'
12815 d_freopen64='$d_freopen64'
12816 d_fseek64='$d_fseek64'
12817 d_fseeko64='$d_fseeko64'
12818 d_fseeko='$d_fseeko'
12819 d_fsetpos64='$d_fsetpos64'
12820 d_fsetpos='$d_fsetpos'
12821 d_fstat64='$d_fstat64'
12822 d_fstatfs='$d_fstatfs'
12823 d_fstatvfs='$d_fstatvfs'
12824 d_ftell64='$d_ftell64'
12825 d_ftello64='$d_ftello64'
12826 d_ftello='$d_ftello'
12827 d_ftime='$d_ftime'
12828 d_ftruncate64='$d_ftruncate64'
12829 d_getgrent='$d_getgrent'
12830 d_getgrps='$d_getgrps'
12831 d_gethbyaddr='$d_gethbyaddr'
12832 d_gethbyname='$d_gethbyname'
12833 d_gethent='$d_gethent'
12834 d_gethname='$d_gethname'
12835 d_gethostprotos='$d_gethostprotos'
12836 d_getlogin='$d_getlogin'
12837 d_getmntent='$d_getmntent'
12838 d_getnbyaddr='$d_getnbyaddr'
12839 d_getnbyname='$d_getnbyname'
12840 d_getnent='$d_getnent'
12841 d_getnetprotos='$d_getnetprotos'
12842 d_getpbyname='$d_getpbyname'
12843 d_getpbynumber='$d_getpbynumber'
12844 d_getpent='$d_getpent'
12845 d_getpgid='$d_getpgid'
12846 d_getpgrp2='$d_getpgrp2'
12847 d_getpgrp='$d_getpgrp'
12848 d_getppid='$d_getppid'
12849 d_getprior='$d_getprior'
12850 d_getprotoprotos='$d_getprotoprotos'
12851 d_getpwent='$d_getpwent'
12852 d_getsbyname='$d_getsbyname'
12853 d_getsbyport='$d_getsbyport'
12854 d_getsent='$d_getsent'
12855 d_getservprotos='$d_getservprotos'
12856 d_gettimeod='$d_gettimeod'
12857 d_gnulibc='$d_gnulibc'
12858 d_grpasswd='$d_grpasswd'
12859 d_hasmntopt='$d_hasmntopt'
12860 d_htonl='$d_htonl'
12861 d_index='$d_index'
12862 d_inetaton='$d_inetaton'
12863 d_ino64_t='$d_ino64_t'
12864 d_int64t='$d_int64t'
12865 d_iovec_s='$d_iovec_s'
12866 d_isascii='$d_isascii'
12867 d_killpg='$d_killpg'
12868 d_lchown='$d_lchown'
12869 d_link='$d_link'
12870 d_llseek='$d_llseek'
12871 d_locconv='$d_locconv'
12872 d_lockf64='$d_lockf64'
12873 d_lockf='$d_lockf'
12874 d_longdbl='$d_longdbl'
12875 d_longlong='$d_longlong'
12876 d_lseek64='$d_lseek64'
12877 d_lstat64='$d_lstat64'
12878 d_lstat='$d_lstat'
12879 d_madvise='$d_madvise'
12880 d_mblen='$d_mblen'
12881 d_mbstowcs='$d_mbstowcs'
12882 d_mbtowc='$d_mbtowc'
12883 d_memcmp='$d_memcmp'
12884 d_memcpy='$d_memcpy'
12885 d_memmove='$d_memmove'
12886 d_memset='$d_memset'
12887 d_mkdir='$d_mkdir'
12888 d_mkfifo='$d_mkfifo'
12889 d_mktime='$d_mktime'
12890 d_mmap='$d_mmap'
12891 d_mprotect='$d_mprotect'
12892 d_msg='$d_msg'
12893 d_msg_ctrunc='$d_msg_ctrunc'
12894 d_msg_dontroute='$d_msg_dontroute'
12895 d_msg_oob='$d_msg_oob'
12896 d_msg_peek='$d_msg_peek'
12897 d_msg_proxy='$d_msg_proxy'
12898 d_msgctl='$d_msgctl'
12899 d_msgget='$d_msgget'
12900 d_msghdr_s='$d_msghdr_s'
12901 d_msgrcv='$d_msgrcv'
12902 d_msgsnd='$d_msgsnd'
12903 d_msync='$d_msync'
12904 d_munmap='$d_munmap'
12905 d_mymalloc='$d_mymalloc'
12906 d_nextkey64='$d_nextkey64'
12907 d_nice='$d_nice'
12908 d_off64_t='$d_off64_t'
12909 d_offset_t='$d_offset_t'
12910 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
12911 d_oldpthreads='$d_oldpthreads'
12912 d_oldsock='$d_oldsock'
12913 d_open3='$d_open3'
12914 d_open64='$d_open64'
12915 d_opendir64='$d_opendir64'
12916 d_pathconf='$d_pathconf'
12917 d_pause='$d_pause'
12918 d_phostname='$d_phostname'
12919 d_pipe='$d_pipe'
12920 d_poll='$d_poll'
12921 d_portable='$d_portable'
12922 d_pthread_yield='$d_pthread_yield'
12923 d_pwage='$d_pwage'
12924 d_pwchange='$d_pwchange'
12925 d_pwclass='$d_pwclass'
12926 d_pwcomment='$d_pwcomment'
12927 d_pwexpire='$d_pwexpire'
12928 d_pwgecos='$d_pwgecos'
12929 d_pwpasswd='$d_pwpasswd'
12930 d_pwquota='$d_pwquota'
12931 d_readdir64='$d_readdir64'
12932 d_readdir='$d_readdir'
12933 d_readlink='$d_readlink'
12934 d_readv='$d_readv'
12935 d_recvmsg='$d_recvmsg'
12936 d_rename='$d_rename'
12937 d_rewinddir='$d_rewinddir'
12938 d_rmdir='$d_rmdir'
12939 d_safebcpy='$d_safebcpy'
12940 d_safemcpy='$d_safemcpy'
12941 d_sanemcmp='$d_sanemcmp'
12942 d_sched_yield='$d_sched_yield'
12943 d_scm_rights='$d_scm_rights'
12944 d_seekdir64='$d_seekdir64'
12945 d_seekdir='$d_seekdir'
12946 d_select='$d_select'
12947 d_sem='$d_sem'
12948 d_semctl='$d_semctl'
12949 d_semctl_semid_ds='$d_semctl_semid_ds'
12950 d_semctl_semun='$d_semctl_semun'
12951 d_semget='$d_semget'
12952 d_semop='$d_semop'
12953 d_sendmsg='$d_sendmsg'
12954 d_setegid='$d_setegid'
12955 d_seteuid='$d_seteuid'
12956 d_setgrent='$d_setgrent'
12957 d_setgrps='$d_setgrps'
12958 d_sethent='$d_sethent'
12959 d_setlinebuf='$d_setlinebuf'
12960 d_setlocale='$d_setlocale'
12961 d_setnent='$d_setnent'
12962 d_setpent='$d_setpent'
12963 d_setpgid='$d_setpgid'
12964 d_setpgrp2='$d_setpgrp2'
12965 d_setpgrp='$d_setpgrp'
12966 d_setprior='$d_setprior'
12967 d_setpwent='$d_setpwent'
12968 d_setregid='$d_setregid'
12969 d_setresgid='$d_setresgid'
12970 d_setresuid='$d_setresuid'
12971 d_setreuid='$d_setreuid'
12972 d_setrgid='$d_setrgid'
12973 d_setruid='$d_setruid'
12974 d_setsent='$d_setsent'
12975 d_setsid='$d_setsid'
12976 d_setvbuf='$d_setvbuf'
12977 d_sfio='$d_sfio'
12978 d_shm='$d_shm'
12979 d_shmat='$d_shmat'
12980 d_shmatprototype='$d_shmatprototype'
12981 d_shmctl='$d_shmctl'
12982 d_shmdt='$d_shmdt'
12983 d_shmget='$d_shmget'
12984 d_sigaction='$d_sigaction'
12985 d_sigsetjmp='$d_sigsetjmp'
12986 d_socket='$d_socket'
12987 d_sockpair='$d_sockpair'
12988 d_stat64='$d_stat64'
12989 d_statblks='$d_statblks'
12990 d_statfs='$d_statfs'
12991 d_statfsflags='$d_statfsflags'
12992 d_statvfs='$d_statvfs'
12993 d_stdio_cnt_lval='$d_stdio_cnt_lval'
12994 d_stdio_ptr_lval='$d_stdio_ptr_lval'
12995 d_stdiobase='$d_stdiobase'
12996 d_stdstdio='$d_stdstdio'
12997 d_store64='$d_store64'
12998 d_strchr='$d_strchr'
12999 d_strcoll='$d_strcoll'
13000 d_strctcpy='$d_strctcpy'
13001 d_strerrm='$d_strerrm'
13002 d_strerror='$d_strerror'
13003 d_strtod='$d_strtod'
13004 d_strtol='$d_strtol'
13005 d_strtoul='$d_strtoul'
13006 d_strxfrm='$d_strxfrm'
13007 d_suidsafe='$d_suidsafe'
13008 d_symlink='$d_symlink'
13009 d_syscall='$d_syscall'
13010 d_sysconf='$d_sysconf'
13011 d_sysernlst='$d_sysernlst'
13012 d_syserrlst='$d_syserrlst'
13013 d_system='$d_system'
13014 d_tcgetpgrp='$d_tcgetpgrp'
13015 d_tcsetpgrp='$d_tcsetpgrp'
13016 d_telldir64='$d_telldir64'
13017 d_telldir='$d_telldir'
13018 d_telldirproto='$d_telldirproto'
13019 d_time='$d_time'
13020 d_times='$d_times'
13021 d_tmpfile64='$d_tmpfile64'
13022 d_truncate64='$d_truncate64'
13023 d_truncate='$d_truncate'
13024 d_tzname='$d_tzname'
13025 d_umask='$d_umask'
13026 d_uname='$d_uname'
13027 d_union_semun='$d_union_semun'
13028 d_vfork='$d_vfork'
13029 d_void_closedir='$d_void_closedir'
13030 d_voidsig='$d_voidsig'
13031 d_voidtty='$d_voidtty'
13032 d_volatile='$d_volatile'
13033 d_vprintf='$d_vprintf'
13034 d_wait4='$d_wait4'
13035 d_waitpid='$d_waitpid'
13036 d_wcstombs='$d_wcstombs'
13037 d_wctomb='$d_wctomb'
13038 d_writev='$d_writev'
13039 d_xenix='$d_xenix'
13040 date='$date'
13041 db_hashtype='$db_hashtype'
13042 db_prefixtype='$db_prefixtype'
13043 defvoidused='$defvoidused'
13044 direntrytype='$direntrytype'
13045 dlext='$dlext'
13046 dlsrc='$dlsrc'
13047 doublesize='$doublesize'
13048 drand01='$drand01'
13049 dynamic_ext='$dynamic_ext'
13050 eagain='$eagain'
13051 ebcdic='$ebcdic'
13052 echo='$echo'
13053 egrep='$egrep'
13054 emacs='$emacs'
13055 eunicefix='$eunicefix'
13056 exe_ext='$exe_ext'
13057 expr='$expr'
13058 extensions='$extensions'
13059 fflushNULL='$fflushNULL'
13060 find='$find'
13061 firstmakefile='$firstmakefile'
13062 flex='$flex'
13063 fpostype='$fpostype'
13064 freetype='$freetype'
13065 full_ar='$full_ar'
13066 full_csh='$full_csh'
13067 full_sed='$full_sed'
13068 gccversion='$gccversion'
13069 gidtype='$gidtype'
13070 glibpth='$glibpth'
13071 grep='$grep'
13072 groupcat='$groupcat'
13073 groupstype='$groupstype'
13074 gzip='$gzip'
13075 h_fcntl='$h_fcntl'
13076 h_sysfile='$h_sysfile'
13077 hint='$hint'
13078 hostcat='$hostcat'
13079 huge='$huge'
13080 i_arpainet='$i_arpainet'
13081 i_bsdioctl='$i_bsdioctl'
13082 i_db='$i_db'
13083 i_dbm='$i_dbm'
13084 i_dirent='$i_dirent'
13085 i_dld='$i_dld'
13086 i_dlfcn='$i_dlfcn'
13087 i_fcntl='$i_fcntl'
13088 i_float='$i_float'
13089 i_gdbm='$i_gdbm'
13090 i_grp='$i_grp'
13091 i_inttypes='$i_inttypes'
13092 i_limits='$i_limits'
13093 i_locale='$i_locale'
13094 i_machcthr='$i_machcthr'
13095 i_malloc='$i_malloc'
13096 i_math='$i_math'
13097 i_memory='$i_memory'
13098 i_mntent='$i_mntent'
13099 i_ndbm='$i_ndbm'
13100 i_netdb='$i_netdb'
13101 i_neterrno='$i_neterrno'
13102 i_netinettcp='$i_netinettcp'
13103 i_niin='$i_niin'
13104 i_poll='$i_poll'
13105 i_pthread='$i_pthread'
13106 i_pwd='$i_pwd'
13107 i_rpcsvcdbm='$i_rpcsvcdbm'
13108 i_sfio='$i_sfio'
13109 i_sgtty='$i_sgtty'
13110 i_stdarg='$i_stdarg'
13111 i_stddef='$i_stddef'
13112 i_stdlib='$i_stdlib'
13113 i_string='$i_string'
13114 i_sysaccess='$i_sysaccess'
13115 i_sysdir='$i_sysdir'
13116 i_sysfile='$i_sysfile'
13117 i_sysfilio='$i_sysfilio'
13118 i_sysin='$i_sysin'
13119 i_sysioctl='$i_sysioctl'
13120 i_sysmman='$i_sysmman'
13121 i_sysmount='$i_sysmount'
13122 i_sysndir='$i_sysndir'
13123 i_sysparam='$i_sysparam'
13124 i_sysresrc='$i_sysresrc'
13125 i_syssecrt='$i_syssecrt'
13126 i_sysselct='$i_sysselct'
13127 i_syssockio='$i_syssockio'
13128 i_sysstat='$i_sysstat'
13129 i_sysstatvfs='$i_sysstatvfs'
13130 i_systime='$i_systime'
13131 i_systimek='$i_systimek'
13132 i_systimes='$i_systimes'
13133 i_systypes='$i_systypes'
13134 i_sysuio='$i_sysuio'
13135 i_sysun='$i_sysun'
13136 i_syswait='$i_syswait'
13137 i_termio='$i_termio'
13138 i_termios='$i_termios'
13139 i_time='$i_time'
13140 i_unistd='$i_unistd'
13141 i_utime='$i_utime'
13142 i_values='$i_values'
13143 i_varargs='$i_varargs'
13144 i_varhdr='$i_varhdr'
13145 i_vfork='$i_vfork'
13146 ignore_versioned_solibs='$ignore_versioned_solibs'
13147 incpath='$incpath'
13148 inews='$inews'
13149 installarchlib='$installarchlib'
13150 installbin='$installbin'
13151 installman1dir='$installman1dir'
13152 installman3dir='$installman3dir'
13153 installprivlib='$installprivlib'
13154 installscript='$installscript'
13155 installsitearch='$installsitearch'
13156 installsitelib='$installsitelib'
13157 installusrbinperl='$installusrbinperl'
13158 intsize='$intsize'
13159 known_extensions='$known_extensions'
13160 ksh='$ksh'
13161 large='$large'
13162 ld='$ld'
13163 lddlflags='$lddlflags'
13164 ldflags='$ldflags'
13165 less='$less'
13166 lib_ext='$lib_ext'
13167 libc='$libc'
13168 libperl='$libperl'
13169 libpth='$libpth'
13170 libs='$libs'
13171 libswanted='$libswanted'
13172 line='$line'
13173 lint='$lint'
13174 lkflags='$lkflags'
13175 ln='$ln'
13176 lns='$lns'
13177 locincpth='$locincpth'
13178 loclibpth='$loclibpth'
13179 longdblsize='$longdblsize'
13180 longlongsize='$longlongsize'
13181 longsize='$longsize'
13182 lp='$lp'
13183 lpr='$lpr'
13184 ls='$ls'
13185 lseeksize='$lseeksize'
13186 lseektype='$lseektype'
13187 mail='$mail'
13188 mailx='$mailx'
13189 make='$make'
13190 make_set_make='$make_set_make'
13191 mallocobj='$mallocobj'
13192 mallocsrc='$mallocsrc'
13193 malloctype='$malloctype'
13194 man1dir='$man1dir'
13195 man1direxp='$man1direxp'
13196 man1ext='$man1ext'
13197 man3dir='$man3dir'
13198 man3direxp='$man3direxp'
13199 man3ext='$man3ext'
13200 medium='$medium'
13201 mips='$mips'
13202 mips_type='$mips_type'
13203 mkdir='$mkdir'
13204 mmaptype='$mmaptype'
13205 models='$models'
13206 modetype='$modetype'
13207 more='$more'
13208 multiarch='$multiarch'
13209 mv='$mv'
13210 myarchname='$myarchname'
13211 mydomain='$mydomain'
13212 myhostname='$myhostname'
13213 myuname='$myuname'
13214 n='$n'
13215 netdb_hlen_type='$netdb_hlen_type'
13216 netdb_host_type='$netdb_host_type'
13217 netdb_name_type='$netdb_name_type'
13218 netdb_net_type='$netdb_net_type'
13219 nm='$nm'
13220 nm_opt='$nm_opt'
13221 nm_so_opt='$nm_so_opt'
13222 nonxs_ext='$nonxs_ext'
13223 nroff='$nroff'
13224 o_nonblock='$o_nonblock'
13225 obj_ext='$obj_ext'
13226 old_pthread_create_joinable='$old_pthread_create_joinable'
13227 optimize='$optimize'
13228 orderlib='$orderlib'
13229 osname='$osname'
13230 osvers='$osvers'
13231 package='$package'
13232 pager='$pager'
13233 passcat='$passcat'
13234 patchlevel='$patchlevel'
13235 path_sep='$path_sep'
13236 perl='$perl'
13237 perladmin='$perladmin'
13238 perlpath='$perlpath'
13239 pg='$pg'
13240 phostname='$phostname'
13241 pidtype='$pidtype'
13242 plibpth='$plibpth'
13243 pmake='$pmake'
13244 pr='$pr'
13245 prefix='$prefix'
13246 prefixexp='$prefixexp'
13247 privlib='$privlib'
13248 privlibexp='$privlibexp'
13249 prototype='$prototype'
13250 ptrsize='$ptrsize'
13251 randbits='$randbits'
13252 randfunc='$randfunc'
13253 randseedtype='$randseedtype'
13254 ranlib='$ranlib'
13255 rd_nodata='$rd_nodata'
13256 rm='$rm'
13257 rmail='$rmail'
13258 runnm='$runnm'
13259 sched_yield='$sched_yield'
13260 scriptdir='$scriptdir'
13261 scriptdirexp='$scriptdirexp'
13262 sed='$sed'
13263 seedfunc='$seedfunc'
13264 selectminbits='$selectminbits'
13265 selecttype='$selecttype'
13266 sendmail='$sendmail'
13267 sh='$sh'
13268 shar='$shar'
13269 sharpbang='$sharpbang'
13270 shmattype='$shmattype'
13271 shortsize='$shortsize'
13272 shrpenv='$shrpenv'
13273 shsharp='$shsharp'
13274 sig_count='$sig_count'
13275 sig_name='$sig_name'
13276 sig_name_init='$sig_name_init'
13277 sig_num='$sig_num'
13278 sig_num_init='$sig_num_init'
13279 signal_t='$signal_t'
13280 sitearch='$sitearch'
13281 sitearchexp='$sitearchexp'
13282 sitelib='$sitelib'
13283 sitelibexp='$sitelibexp'
13284 sizetype='$sizetype'
13285 sleep='$sleep'
13286 smail='$smail'
13287 small='$small'
13288 so='$so'
13289 sockethdr='$sockethdr'
13290 socketlib='$socketlib'
13291 sort='$sort'
13292 spackage='$spackage'
13293 spitshell='$spitshell'
13294 split='$split'
13295 src='$src'
13296 ssizetype='$ssizetype'
13297 startperl='$startperl'
13298 startsh='$startsh'
13299 static_ext='$static_ext'
13300 stdchar='$stdchar'
13301 stdio_base='$stdio_base'
13302 stdio_bufsiz='$stdio_bufsiz'
13303 stdio_cnt='$stdio_cnt'
13304 stdio_filbuf='$stdio_filbuf'
13305 stdio_ptr='$stdio_ptr'
13306 strings='$strings'
13307 submit='$submit'
13308 subversion='$subversion'
13309 sysman='$sysman'
13310 tail='$tail'
13311 tar='$tar'
13312 tbl='$tbl'
13313 tee='$tee'
13314 test='$test'
13315 timeincl='$timeincl'
13316 timetype='$timetype'
13317 touch='$touch'
13318 tr='$tr'
13319 trnl='$trnl'
13320 troff='$troff'
13321 uidtype='$uidtype'
13322 uname='$uname'
13323 uniq='$uniq'
13324 use64bits='$use64bits'
13325 usedl='$usedl'
13326 usemultiplicity='$usemultiplicity'
13327 usemymalloc='$usemymalloc'
13328 usenm='$usenm'
13329 useopcode='$useopcode'
13330 useperlio='$useperlio'
13331 useposix='$useposix'
13332 usesfio='$usesfio'
13333 useshrplib='$useshrplib'
13334 usethreads='$usethreads'
13335 usevfork='$usevfork'
13336 usrinc='$usrinc'
13337 uuname='$uuname'
13338 version='$version'
13339 vi='$vi'
13340 voidflags='$voidflags'
13341 xlibpth='$xlibpth'
13342 zcat='$zcat'
13343 zip='$zip'
13344 EOT
13345
13346 : Add in command line options if available
13347 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
13348
13349 : add special variables
13350 $test -f $src/patchlevel.h && \
13351 awk '/^#define[         ]+PERL_/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
13352 echo "CONFIGDOTSH=true" >>config.sh
13353
13354 : propagate old symbols
13355 if $test -f UU/config.sh; then
13356         <UU/config.sh sort | uniq >UU/oldconfig.sh
13357         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
13358         sort | uniq -u >UU/oldsyms
13359         set X `cat UU/oldsyms`
13360         shift
13361         case $# in
13362         0) ;;
13363         *)
13364                 cat <<EOM
13365 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
13366 EOM
13367                 echo "# Variables propagated from previous config.sh file." >>config.sh
13368                 for sym in `cat UU/oldsyms`; do
13369                         echo "    Propagating $hint variable "'$'"$sym..."
13370                         eval 'tmp="$'"${sym}"'"'
13371                         echo "$tmp" | \
13372                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
13373                 done
13374                 ;;
13375         esac
13376 fi
13377
13378 : Finish up by extracting the .SH files
13379 case "$alldone" in
13380 exit)
13381         $rm -rf UU
13382         echo "Done."
13383         exit 0
13384         ;;
13385 cont)
13386         ;;
13387 '')
13388         dflt=''
13389         nostick=true
13390         $cat <<EOM
13391
13392 If you'd like to make any changes to the config.sh file before I begin
13393 to configure things, do it as a shell escape now (e.g. !vi config.sh).
13394
13395 EOM
13396         rp="Press return or use a shell escape to edit config.sh:"
13397         . UU/myread
13398         nostick=''
13399         case "$ans" in
13400         '') ;;
13401         *) : in case they cannot read
13402                 sh 1>&4 -c "$ans";;
13403         esac
13404         ;;
13405 esac
13406
13407 : if this fails, just run all the .SH files by hand
13408 . ./config.sh
13409
13410 echo " "
13411 exec 1>&4
13412 . ./UU/extract
13413
13414 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
13415         dflt=y
13416         case "$silent" in
13417         true) ;;
13418         *)
13419                 $cat <<EOM
13420
13421 Now you need to generate make dependencies by running "$make depend".
13422 You might prefer to run it in background: "$make depend > makedepend.out &"
13423 It can take a while, so you might not want to run it right now.
13424
13425 EOM
13426                 ;;
13427         esac
13428         rp="Run $make depend now?"
13429         . UU/myread
13430         case "$ans" in
13431         y*)
13432                 $make depend && echo "Now you must run a $make."
13433                 ;;
13434         *)
13435                 echo "You must run '$make depend' then '$make'."
13436                 ;;
13437         esac
13438 elif test -f [Mm]akefile; then
13439         echo " "
13440         echo "Now you must run a $make."
13441 else
13442         echo "Done."
13443 fi
13444
13445 if $test -f Policy.sh; then
13446     $cat <<EOM
13447
13448 If you compile $package on a different machine or from a different object
13449 directory, copy the Policy.sh file from this object directory to the
13450 new one before you run Configure -- this will help you with most of
13451 the policy defaults.
13452
13453 EOM
13454 fi
13455 if $test -f config.msg; then
13456     echo "Hmm.  I also noted the following information while running:"
13457     echo " "
13458     $cat config.msg >&4
13459     $rm -f config.msg
13460 fi
13461 $rm -f kit*isdone ark*isdone
13462 $rm -rf UU
13463
13464 : End of Configure
13465