1dc7bae4eb8bda9a589285f3e2a07a7efe5b4739
[p5sagit/p5-mst-13.2.git] / Configure
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc and is available on CPAN under authors/id/RAM so
18 # you may fetch it yourself from your nearest archive site.)
19 #
20
21 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
22 #
23 # Generated on Thu Jan  7 13:54:35 EET 1999 [metaconfig 3.0 PL70]
24 # (with additional metaconfig patches by jhi@iki.fi)
25
26 cat >/tmp/c1$$ <<EOF
27 ARGGGHHHH!!!!!
28
29 SCO csh still thinks true is false.  Write to SCO today and tell them that next
30 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
31
32 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
33 we'd have to do is go in and swap the && and || tokens, wherever they are.)
34
35 [End of diatribe. We now return you to your regularly scheduled programming...]
36 EOF
37 cat >/tmp/c2$$ <<EOF
38
39 OOPS!  You naughty creature!  You didn't run Configure with sh!
40 I will attempt to remedy the situation by running sh for you...
41 EOF
42
43 true || cat /tmp/c1$$ /tmp/c2$$
44 true || exec sh $0 $argv:q
45
46 (exit $?0) || cat /tmp/c2$$
47 (exit $?0) || exec sh $0 $argv:q
48 rm -f /tmp/c1$$ /tmp/c2$$
49
50 : compute my invocation name
51 me=$0
52 case "$0" in
53 */*)
54         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
55         test "$me" || me=$0
56         ;;
57 esac
58
59 : Proper separator for the PATH environment variable
60 p_=:
61 : On OS/2 this directory should exist if this is not floppy only system :-]
62 if test -d c:/. ; then
63     if test -n "$OS2_SHELL"; then
64                 p_=\;
65                 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
66                 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
67         elif test -n "$DJGPP"; then
68                 p_=\;
69         fi
70 fi
71
72 : Proper PATH setting
73 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
74 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
75 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
76 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
77 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
78 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
79 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
80 paths="$paths /sbin /usr/sbin /usr/libexec"
81
82 for p in $paths
83 do
84         case "$p_$PATH$p_" in
85         *$p_$p$p_*) ;;
86         *) test -d $p && PATH=$PATH$p_$p ;;
87         esac
88 done
89
90 PATH=.$p_$PATH
91 export PATH
92
93 : shall we be using ksh?
94 inksh=''
95 needksh=''
96 avoidksh=''
97 newsh=/bin/ksh
98 changesh=''
99 if (PATH=.; alias -x) >/dev/null 2>&1; then
100                 inksh=true
101 fi
102 if test -f /hp-ux -a -f /bin/ksh; then
103         needksh='to avoid sh bug in "here document" expansion'
104 fi
105 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
106         if test X`/usr/bin/uname -v` = X4; then
107                 avoidksh="to avoid AIX 4's /bin/sh"
108                 newsh=/usr/bin/bsh
109         fi
110 fi
111 case "$inksh/$needksh" in
112 /[a-z]*)
113                 ENV=''
114                 changesh=true
115                 reason="$needksh"
116         ;;
117 esac
118 case "$inksh/$avoidksh" in
119 true/[a-z]*)
120         changesh=true
121         reason="$avoidksh"
122         ;;
123 esac
124 case "$inksh/$needksh-$avoidksh-" in
125 true/--)
126                 cat <<EOM
127 (I see you are using the Korn shell.  Some ksh's blow up on $me,
128 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
129 EOM
130         ;;
131 esac
132 case "$changesh" in
133 true)
134         echo "(Feeding myself to $newsh $reason.)"
135         case "$0" in
136         Configure|*/Configure) exec $newsh $0 "$@";;
137         *) exec $newsh Configure "$@";;
138         esac
139         ;;
140 esac
141
142 : if needed set CDPATH to a harmless value that is not chatty
143 : avoid bash 2.02 problems with empty CDPATH.
144 case "$CDPATH" in
145 '')     ;;
146 *)      case "$SHELL" in
147         *bash*) CDPATH='.' ;;
148         *)              CDPATH='' ;;
149         esac
150         ;;
151 esac
152 : Configure runs within the UU subdirectory
153 test -d UU || mkdir UU
154 cd UU && rm -f ./*
155
156 dynamic_ext=''
157 extensions=''
158 known_extensions=''
159 nonxs_ext=''
160 static_ext=''
161 useopcode=''
162 useposix=''
163 d_bsd=''
164 d_eunice=''
165 d_xenix=''
166 eunicefix=''
167 Mcc=''
168 ar=''
169 awk=''
170 bash=''
171 bison=''
172 byacc=''
173 cat=''
174 chgrp=''
175 chmod=''
176 chown=''
177 comm=''
178 compress=''
179 cp=''
180 cpio=''
181 cpp=''
182 csh=''
183 date=''
184 echo=''
185 egrep=''
186 emacs=''
187 expr=''
188 find=''
189 flex=''
190 grep=''
191 gzip=''
192 inews=''
193 ksh=''
194 less=''
195 line=''
196 lint=''
197 ln=''
198 lp=''
199 lpr=''
200 ls=''
201 mail=''
202 mailx=''
203 make=''
204 mkdir=''
205 more=''
206 mv=''
207 nm=''
208 nroff=''
209 perl=''
210 pg=''
211 pmake=''
212 pr=''
213 rm=''
214 rmail=''
215 sed=''
216 sendmail=''
217 shar=''
218 sleep=''
219 smail=''
220 sort=''
221 submit=''
222 tail=''
223 tar=''
224 tbl=''
225 tee=''
226 test=''
227 touch=''
228 tr=''
229 troff=''
230 uname=''
231 uniq=''
232 uuname=''
233 vi=''
234 zcat=''
235 zip=''
236 full_sed=''
237 libswanted=''
238 hint=''
239 myuname=''
240 osname=''
241 osvers=''
242 Author=''
243 Date=''
244 Header=''
245 Id=''
246 Locker=''
247 Log=''
248 RCSfile=''
249 Revision=''
250 Source=''
251 State=''
252 _a=''
253 _exe=''
254 _o=''
255 archobjs=''
256 exe_ext=''
257 firstmakefile=''
258 lib_ext=''
259 obj_ext=''
260 path_sep=''
261 afs=''
262 alignbytes=''
263 ansi2knr=''
264 archlib=''
265 archlibexp=''
266 d_archlib=''
267 installarchlib=''
268 archname=''
269 myarchname=''
270 baserev=''
271 bin=''
272 binexp=''
273 installbin=''
274 byteorder=''
275 cc=''
276 gccversion=''
277 ccflags=''
278 cppflags=''
279 ldflags=''
280 lkflags=''
281 locincpth=''
282 optimize=''
283 cf_email=''
284 cf_by=''
285 cf_time=''
286 contains=''
287 cpp_stuff=''
288 cpplast=''
289 cppminus=''
290 cpprun=''
291 cppstdin=''
292 d_access=''
293 d_accessx=''
294 d_alarm=''
295 d_attribut=''
296 d_bcmp=''
297 d_bcopy=''
298 d_bzero=''
299 d_casti32=''
300 castflags=''
301 d_castneg=''
302 d_chown=''
303 d_chroot=''
304 d_chsize=''
305 d_closedir=''
306 d_void_closedir=''
307 d_const=''
308 cryptlib=''
309 d_crypt=''
310 d_csh=''
311 full_csh=''
312 d_cuserid=''
313 d_dbl_dig=''
314 d_difftime=''
315 d_dlerror=''
316 d_dlopen=''
317 d_dlsymun=''
318 d_dosuid=''
319 d_suidsafe=''
320 d_drand48proto=''
321 d_dup2=''
322 d_eaccess=''
323 d_endgrent=''
324 d_endhent=''
325 d_endnent=''
326 d_endpent=''
327 d_endpwent=''
328 d_endsent=''
329 d_fchmod=''
330 d_fchown=''
331 d_fcntl=''
332 d_fd_macros=''
333 d_fd_set=''
334 d_fds_bits=''
335 d_fgetpos=''
336 d_flexfnam=''
337 d_flock=''
338 d_fork=''
339 d_fseeko=''
340 d_fsetpos=''
341 d_ftello=''
342 d_ftime=''
343 d_gettimeod=''
344 d_Gconvert=''
345 d_getgrent=''
346 d_getgrps=''
347 d_gethbyaddr=''
348 d_gethbyname=''
349 d_gethent=''
350 aphostname=''
351 d_gethname=''
352 d_phostname=''
353 d_uname=''
354 d_gethostprotos=''
355 d_getlogin=''
356 d_getnbyaddr=''
357 d_getnbyname=''
358 d_getnent=''
359 d_getnetprotos=''
360 d_getpent=''
361 d_getpgid=''
362 d_getpgrp2=''
363 d_bsdgetpgrp=''
364 d_getpgrp=''
365 d_getppid=''
366 d_getprior=''
367 d_getpbyname=''
368 d_getpbynumber=''
369 d_getprotoprotos=''
370 d_getpwent=''
371 d_getsent=''
372 d_getservprotos=''
373 d_getsbyname=''
374 d_getsbyport=''
375 d_gnulibc=''
376 d_htonl=''
377 d_inetaton=''
378 d_isascii=''
379 d_killpg=''
380 d_lchown=''
381 d_link=''
382 d_locconv=''
383 d_lockf=''
384 d_longdbl=''
385 longdblsize=''
386 d_longlong=''
387 longlongsize=''
388 d_lstat=''
389 d_mblen=''
390 d_mbstowcs=''
391 d_mbtowc=''
392 d_memcmp=''
393 d_memcpy=''
394 d_memmove=''
395 d_memset=''
396 d_mkdir=''
397 d_mkfifo=''
398 d_mktime=''
399 d_msg=''
400 d_msgctl=''
401 d_msgget=''
402 d_msgrcv=''
403 d_msgsnd=''
404 d_nice=''
405 d_open3=''
406 d_fpathconf=''
407 d_pathconf=''
408 d_pause=''
409 d_pipe=''
410 d_poll=''
411 d_portable=''
412 d_old_pthread_create_joinable=''
413 old_pthread_create_joinable=''
414 d_pthread_yield=''
415 d_sched_yield=''
416 sched_yield=''
417 d_readdir=''
418 d_rewinddir=''
419 d_seekdir=''
420 d_telldir=''
421 d_readlink=''
422 d_readv=''
423 d_rename=''
424 d_rmdir=''
425 d_safebcpy=''
426 d_safemcpy=''
427 d_sanemcmp=''
428 d_select=''
429 d_sem=''
430 d_semctl=''
431 d_semget=''
432 d_semop=''
433 d_setegid=''
434 d_seteuid=''
435 d_setgrent=''
436 d_setgrps=''
437 d_sethent=''
438 d_setlinebuf=''
439 d_setlocale=''
440 d_setnent=''
441 d_setpent=''
442 d_setpgid=''
443 d_setpgrp2=''
444 d_bsdsetpgrp=''
445 d_setpgrp=''
446 d_setprior=''
447 d_setpwent=''
448 d_setregid=''
449 d_setresgid=''
450 d_setresuid=''
451 d_setreuid=''
452 d_setrgid=''
453 d_setruid=''
454 d_setsent=''
455 d_setsid=''
456 d_setvbuf=''
457 d_sfio=''
458 usesfio=''
459 d_shm=''
460 d_shmat=''
461 d_shmatprototype=''
462 shmattype=''
463 d_shmctl=''
464 d_shmdt=''
465 d_shmget=''
466 d_sigaction=''
467 d_sigsetjmp=''
468 d_cmsghdr_s=''
469 d_msg_ctrunc=''
470 d_msg_dontroute=''
471 d_msg_oob=''
472 d_msg_peek=''
473 d_msg_proxy=''
474 d_msghdr_s=''
475 d_oldsock=''
476 d_recvmsg=''
477 d_scm_rights=''
478 d_sendmsg=''
479 d_socket=''
480 d_sockpair=''
481 sockethdr=''
482 socketlib=''
483 d_statblks=''
484 d_stdio_cnt_lval=''
485 d_stdio_ptr_lval=''
486 d_stdiobase=''
487 d_stdstdio=''
488 stdio_base=''
489 stdio_bufsiz=''
490 stdio_cnt=''
491 stdio_filbuf=''
492 stdio_ptr=''
493 d_index=''
494 d_strchr=''
495 d_strcoll=''
496 d_strctcpy=''
497 d_strerrm=''
498 d_strerror=''
499 d_sysernlst=''
500 d_syserrlst=''
501 d_strtod=''
502 d_strtol=''
503 d_strtoul=''
504 d_strxfrm=''
505 d_symlink=''
506 d_syscall=''
507 d_sysconf=''
508 d_system=''
509 d_tcgetpgrp=''
510 d_tcsetpgrp=''
511 d_time=''
512 timetype=''
513 clocktype=''
514 d_times=''
515 d_truncate=''
516 d_tzname=''
517 d_umask=''
518 d_semctl_semid_ds=''
519 d_semctl_semun=''
520 d_union_semun=''
521 d_vfork=''
522 usevfork=''
523 d_voidsig=''
524 signal_t=''
525 d_volatile=''
526 d_charvspr=''
527 d_vprintf=''
528 d_wait4=''
529 d_waitpid=''
530 d_wcstombs=''
531 d_wctomb=''
532 d_writev=''
533 d_dbmclose64=''
534 d_dbminit64=''
535 d_delete64=''
536 d_fetch64=''
537 d_firstkey64=''
538 d_nextkey64=''
539 d_store64=''
540 dlext=''
541 cccdlflags=''
542 ccdlflags=''
543 dlsrc=''
544 ld=''
545 lddlflags=''
546 usedl=''
547 doublesize=''
548 ebcdic=''
549 fpostype=''
550 gidtype=''
551 groupstype=''
552 h_fcntl=''
553 h_sysfile=''
554 i_arpainet=''
555 db_hashtype=''
556 db_prefixtype=''
557 i_db=''
558 i_dbm=''
559 i_rpcsvcdbm=''
560 d_dirnamlen=''
561 direntrytype=''
562 i_dirent=''
563 i_dld=''
564 i_dlfcn=''
565 i_fcntl=''
566 i_float=''
567 i_gdbm=''
568 d_grpasswd=''
569 i_grp=''
570 d_int64t=''
571 i_inttypes=''
572 i_limits=''
573 i_locale=''
574 i_machcthr=''
575 i_malloc=''
576 i_math=''
577 i_memory=''
578 i_ndbm=''
579 i_netdb=''
580 i_neterrno=''
581 i_niin=''
582 i_sysin=''
583 i_poll=''
584 d_pwage=''
585 d_pwchange=''
586 d_pwclass=''
587 d_pwcomment=''
588 d_pwexpire=''
589 d_pwgecos=''
590 d_pwpasswd=''
591 d_pwquota=''
592 i_pwd=''
593 i_sfio=''
594 i_stddef=''
595 i_stdlib=''
596 i_string=''
597 strings=''
598 i_sysaccess=''
599 i_sysdir=''
600 i_sysfile=''
601 d_voidtty=''
602 i_bsdioctl=''
603 i_sysfilio=''
604 i_sysioctl=''
605 i_syssockio=''
606 i_sysndir=''
607 i_sysparam=''
608 i_sysresrc=''
609 i_syssecrt=''
610 i_sysselct=''
611 i_sysstat=''
612 i_systimes=''
613 i_systypes=''
614 d_iovec_s=''
615 i_sysuio=''
616 i_sysun=''
617 i_syswait=''
618 i_sgtty=''
619 i_termio=''
620 i_termios=''
621 i_systime=''
622 i_systimek=''
623 i_time=''
624 timeincl=''
625 i_unistd=''
626 i_utime=''
627 i_values=''
628 i_stdarg=''
629 i_varargs=''
630 i_varhdr=''
631 i_vfork=''
632 intsize=''
633 longsize=''
634 shortsize=''
635 d_dirent64_s=''
636 d_flock64_s=''
637 d_fstat64=''
638 d_ftruncate64=''
639 d_ino64t=''
640 d_lockf64=''
641 d_lseek64=''
642 d_lstat64=''
643 d_off64t=''
644 d_open64=''
645 d_opendir64=''
646 d_readdir64=''
647 d_seekdir64=''
648 d_stat64=''
649 d_telldir64=''
650 d_truncate64=''
651 libc=''
652 libperl=''
653 shrpenv=''
654 useshrplib=''
655 glibpth=''
656 libpth=''
657 loclibpth=''
658 plibpth=''
659 xlibpth=''
660 ignore_versioned_solibs=''
661 libs=''
662 lns=''
663 lseeksize=''
664 lseektype=''
665 make_set_make=''
666 d_mymalloc=''
667 freetype=''
668 mallocobj=''
669 mallocsrc=''
670 malloctype=''
671 usemymalloc=''
672 installman1dir=''
673 man1dir=''
674 man1direxp=''
675 man1ext=''
676 installman3dir=''
677 man3dir=''
678 man3direxp=''
679 man3ext=''
680 huge=''
681 large=''
682 medium=''
683 models=''
684 small=''
685 split=''
686 modetype=''
687 mydomain=''
688 myhostname=''
689 phostname=''
690 c=''
691 n=''
692 d_eofnblk=''
693 eagain=''
694 o_nonblock=''
695 rd_nodata=''
696 netdb_hlen_type=''
697 netdb_host_type=''
698 netdb_name_type=''
699 netdb_net_type=''
700 groupcat=''
701 hostcat=''
702 passcat=''
703 orderlib=''
704 ranlib=''
705 package=''
706 spackage=''
707 pager=''
708 apiversion=''
709 patchlevel=''
710 subversion=''
711 version=''
712 perladmin=''
713 perlpath=''
714 pidtype=''
715 prefix=''
716 prefixexp=''
717 installprivlib=''
718 privlib=''
719 privlibexp=''
720 prototype=''
721 ptrsize=''
722 drand01=''
723 randbits=''
724 randfunc=''
725 randseedtype=''
726 seedfunc=''
727 installscript=''
728 scriptdir=''
729 scriptdirexp=''
730 selectminbits=''
731 selecttype=''
732 sh=''
733 sig_name=''
734 sig_name_init=''
735 sig_num=''
736 sig_num_init=''
737 installsitearch=''
738 sitearch=''
739 sitearchexp=''
740 installsitelib=''
741 sitelib=''
742 sitelibexp=''
743 sizetype=''
744 so=''
745 sharpbang=''
746 shsharp=''
747 spitshell=''
748 src=''
749 ssizetype=''
750 startperl=''
751 startsh=''
752 stdchar=''
753 d_fgetpos64=''
754 d_fopen64=''
755 d_freopen64=''
756 d_fseek64=''
757 d_fseeko64=''
758 d_fsetpos64=''
759 d_ftell64=''
760 d_ftello64=''
761 d_tmpfile64=''
762 sysman=''
763 trnl=''
764 uidtype=''
765 archname64=''
766 use64bits=''
767 usemultiplicity=''
768 nm_opt=''
769 nm_so_opt=''
770 runnm=''
771 usenm=''
772 useperlio=''
773 d_oldpthreads=''
774 usethreads=''
775 incpath=''
776 mips=''
777 mips_type=''
778 usrinc=''
779 defvoidused=''
780 voidflags=''
781 CONFIG=''
782
783 define='define'
784 undef='undef'
785 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
786 rmlist=''
787
788 : We must find out about Eunice early
789 eunicefix=':'
790 if test -f /etc/unixtovms; then
791         eunicefix=/etc/unixtovms
792 fi
793 if test -f /etc/unixtovms.exe; then
794         eunicefix=/etc/unixtovms.exe
795 fi
796
797 i_whoami=''
798 : change the next line if compiling for Xenix/286 on Xenix/386
799 xlibpth='/usr/lib/386 /lib/386'
800
801 : Possible local library directories to search.
802 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
803 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
804
805 : general looking path for locating libraries
806 glibpth="/shlib /usr/shlib /lib/pa1.1 /usr/lib/large"
807 glibpth="$glibpth /lib /usr/lib $xlibpth"
808 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
809 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
810
811 : Private path used by Configure to find libraries.  Its value
812 : is prepended to libpth. This variable takes care of special
813 : machines, like the mips.  Usually, it should be empty.
814 plibpth=''
815
816 : Possible local include directories to search.
817 : Set locincpth to "" in a hint file to defeat local include searches.
818 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
819 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
820 :
821 : no include file wanted by default
822 inclwanted=''
823
824 : list of known cpp symbols, sorted alphabetically
825 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
826 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
827 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
828 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
829 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
830 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
831 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
832 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
833 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
834 al="$al VMS Xenix286"
835 al="$al _AIX _AIX32 _AIX370 _AIX41 _AM29000 _COFF _CRAY _CX_UX _EPI"
836 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET _POWER"
837 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
838 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
839 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
840 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
841 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
842 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
843 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
844 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
845 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
846 al="$al __SVR4_2__ __UMAXV__"
847 al="$al ____386BSD____ __alpha __alpha__ __amiga"
848 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
849 al="$al __host_mips__"
850 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
851 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
852 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
853 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
854 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
855 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
856 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
857 al="$al __mc88100 __mc88100__ __mips __mips__"
858 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
859 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
860 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
861 al="$al _host_mips _mips _unix"
862 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
863 al="$al apollo ardent att386 att3b"
864 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
865 al="$al cadmus clipper concurrent convex cray ctix"
866 al="$al dmert encore gcos gcx gimpel gould"
867 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
868 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
869 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
870 al="$al i186 i286 i386 i486 i8086"
871 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
872 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
873 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
874 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
875 al="$al mc88000 mc88100 merlin mert mips mvs n16"
876 al="$al ncl_el ncl_mr"
877 al="$al news1500 news1700 news1800 news1900 news3700"
878 al="$al news700 news800 news900 ns16000 ns32000"
879 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
880 al="$al parisc pc532 pdp11 plexus posix pyr"
881 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
882 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
883 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
884 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
885 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
886 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
887 al="$al xenix z8000"
888
889 : Trailing extension.  Override this in a hint file, if needed.
890 _exe=''
891 : Extra object files, if any, needed on this platform.
892 archobjs=''
893 groupstype=''
894 : default library list
895 libswanted=''
896 : some systems want to use only the non-versioned libso:s
897 ignore_versioned_solibs=''
898 : full support for void wanted by default
899 defvoidused=15
900
901 : set useposix=false in your hint file to disable the POSIX extension.
902 useposix=true
903 : set useopcode=false in your hint file to disable the Opcode extension.
904 useopcode=true
905 : set use64bits on the Configure command line to enable 64 bit support.
906 : set usemultiplicity on the Configure command line to enable multiplicity.
907 : set usethreads on the Configure command line to enable threads.
908 : List of libraries we want.
909 : If anyone needs -lnet, put it in a hint file.
910 libswanted='sfio socket inet nsl nm ndbm gdbm dbm db malloc dl'
911 libswanted="$libswanted dld ld sun m c cposix posix ndir dir crypt"
912 libswanted="$libswanted ucb bsd BSD PW x"
913 : We probably want to search /usr/shlib before most other libraries.
914 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
915 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
916 glibpth="/usr/shlib $glibpth"
917 : Do not use vfork unless overridden by a hint file.
918 usevfork=false
919
920 : Find the basic shell for Bourne shell scripts
921 case "$sh" in
922 '')
923         case "$SYSTYPE" in
924         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
925         *) xxx='/bin/sh';;
926         esac
927         if test -f "$xxx"; then
928                 sh="$xxx"
929         else
930                 : Build up a list and do a single loop so we can 'break' out.
931                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
932                 for xxx in sh bash ksh pdksh ash; do
933                         for p in $pth; do
934                                 try="$try ${p}/${xxx}"
935                         done
936                 done
937                 for xxx in $try; do
938                         if test -f "$xxx"; then
939                                 sh="$xxx";
940                                 break
941                         elif test -f "$xxx.exe"; then
942                                 sh="$xxx";
943                                 break
944                         fi
945                 done
946         fi
947         ;;
948 esac
949
950 case "$sh" in
951 '')     cat <<EOM >&2
952 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
953
954 Usually it's in /bin/sh.  How did you even get this far?
955 Please contact me (Jarkko Hietaniemi) at jhi@iki.fi and 
956 we'll try to straighten this all out.
957 EOM
958         exit 1
959         ;;
960 esac
961
962 : see if sh knows # comments
963 if `$sh -c '#' >/dev/null 2>&1`; then
964         shsharp=true
965         spitshell=cat
966         xcat=/bin/cat
967         test -f $xcat || xcat=/usr/bin/cat
968         echo "#!$xcat" >try
969         $eunicefix try
970         chmod +x try
971         ./try > today
972         if test -s today; then
973                 sharpbang='#!'
974         else
975                 echo "#! $xcat" > try
976                 $eunicefix try
977                 chmod +x try
978                 ./try > today
979                 if test -s today; then
980                         sharpbang='#! '
981                 else
982                         sharpbang=': use '
983                 fi
984         fi
985 else
986         echo " "
987         echo "Your $sh doesn't grok # comments--I will strip them later on."
988         shsharp=false
989         cd ..
990         echo "exec grep -v '^[  ]*#'" >spitshell
991         chmod +x spitshell
992         $eunicefix spitshell
993         spitshell=`pwd`/spitshell
994         cd UU
995         echo "I presume that if # doesn't work, #! won't work either!"
996         sharpbang=': use '
997 fi
998 rm -f try today
999
1000 : figure out how to guarantee sh startup
1001 case "$startsh" in
1002 '') startsh=${sharpbang}${sh} ;;
1003 *)
1004 esac
1005 cat >try <<EOSS
1006 $startsh
1007 set abc
1008 test "$?abc" != 1
1009 EOSS
1010
1011 chmod +x try
1012 $eunicefix try
1013 if ./try; then
1014         : echo "Yup, it does."
1015 else
1016         echo "Hmm... '$startsh' does not guarantee sh startup..."
1017         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1018 fi
1019 rm -f try
1020
1021
1022 : Save command line options in file UU/cmdline.opt for later use in
1023 : generating config.sh.
1024 cat > cmdline.opt <<EOSH
1025 # Configure command line arguments.
1026 config_arg0='$0'
1027 config_args='$*'
1028 config_argc=$#
1029 EOSH
1030 argn=1
1031 for arg in "$@"; do
1032         cat >>cmdline.opt <<EOSH
1033 config_arg$argn='$arg'
1034 EOSH
1035         argn=`expr $argn + 1`
1036 done
1037
1038 : produce awk script to parse command line options
1039 cat >options.awk <<'EOF'
1040 BEGIN {
1041         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
1042
1043         len = length(optstr);
1044         for (i = 1; i <= len; i++) {
1045                 c = substr(optstr, i, 1);
1046                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1047                 if (a == ":") {
1048                         arg[c] = 1;
1049                         i++;
1050                 }
1051                 opt[c] = 1;
1052         }
1053 }
1054 {
1055         expect = 0;
1056         str = $0;
1057         if (substr(str, 1, 1) != "-") {
1058                 printf("'%s'\n", str);
1059                 next;
1060         }
1061         len = length($0);
1062         for (i = 2; i <= len; i++) {
1063                 c = substr(str, i, 1);
1064                 if (!opt[c]) {
1065                         printf("-%s\n", substr(str, i));
1066                         next;
1067                 }
1068                 printf("-%s\n", c);
1069                 if (arg[c]) {
1070                         if (i < len)
1071                                 printf("'%s'\n", substr(str, i + 1));
1072                         else
1073                                 expect = 1;
1074                         next;
1075                 }
1076         }
1077 }
1078 END {
1079         if (expect)
1080                 print "?";
1081 }
1082 EOF
1083
1084 : process the command line options
1085 set X `for arg in "$@"; do echo "X$arg"; done |
1086         sed -e s/X// | awk -f options.awk`
1087 eval "set $*"
1088 shift
1089 rm -f options.awk
1090
1091 : set up default values
1092 fastread=''
1093 reuseval=false
1094 config_sh=''
1095 alldone=''
1096 error=''
1097 silent=''
1098 extractsh=''
1099 override=''
1100 knowitall=''
1101 rm -f optdef.sh
1102 cat >optdef.sh <<EOS
1103 $startsh
1104 EOS
1105
1106
1107 : option parsing
1108 while test $# -gt 0; do
1109         case "$1" in
1110         -d) shift; fastread=yes;;
1111         -e) shift; alldone=cont;;
1112         -f)
1113                 shift
1114                 cd ..
1115                 if test -r "$1"; then
1116                         config_sh="$1"
1117                 else
1118                         echo "$me: cannot read config file $1." >&2
1119                         error=true
1120                 fi
1121                 cd UU
1122                 shift;;
1123         -h) shift; error=true;;
1124         -r) shift; reuseval=true;;
1125         -s) shift; silent=true; realsilent=true;;
1126         -E) shift; alldone=exit;;
1127         -K) shift; knowitall=true;;
1128         -O) shift; override=true;;
1129         -S) shift; silent=true; extractsh=true;;
1130         -D)
1131                 shift
1132                 case "$1" in
1133                 *=)
1134                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1135                         echo "$me: ignoring -D $1" >&2
1136                         ;;
1137                 *=*) echo "$1" | \
1138                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1139                 *) echo "$1='define'" >> optdef.sh;;
1140                 esac
1141                 shift
1142                 ;;
1143         -U)
1144                 shift
1145                 case "$1" in
1146                 *=) echo "$1" >> optdef.sh;;
1147                 *=*)
1148                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1149                         echo "$me: ignoring -U $1" >&2
1150                         ;;
1151                 *) echo "$1='undef'" >> optdef.sh;;
1152                 esac
1153                 shift
1154                 ;;
1155         -V) echo "$me generated by metaconfig 3.0 PL70." >&2
1156                 exit 0;;
1157         --) break;;
1158         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1159         *) break;;
1160         esac
1161 done
1162
1163 case "$error" in
1164 true)
1165         cat >&2 <<EOM
1166 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1167                  [-U symbol] [-U symbol=]
1168   -d : use defaults for all answers.
1169   -e : go on without questioning past the production of config.sh.
1170   -f : specify an alternate default configuration file.
1171   -h : print this help message and exit (with an error status).
1172   -r : reuse C symbols value if possible (skips costly nm extraction).
1173   -s : silent mode, only echoes questions and essential information.
1174   -D : define symbol to have some value:
1175          -D symbol         symbol gets the value 'define'
1176          -D symbol=value   symbol gets the value 'value'
1177   -E : stop at the end of questions, after having produced config.sh.
1178   -K : do not use unless you know what you are doing.
1179   -O : let -D and -U override definitions from loaded configuration file.
1180   -S : perform variable substitutions on all .SH files (can mix with -f)
1181   -U : undefine symbol:
1182          -U symbol    symbol gets the value 'undef'
1183          -U symbol=   symbol gets completely empty
1184   -V : print version number and exit (with a zero status).
1185 EOM
1186         exit 1
1187         ;;
1188 esac
1189
1190 : Sanity checks
1191 case "$fastread$alldone" in
1192 yescont|yesexit) ;;
1193 *)
1194         if test ! -t 0; then
1195                 echo "Say 'sh Configure', not 'sh <Configure'"
1196                 exit 1
1197         fi
1198         ;;
1199 esac
1200
1201 exec 4>&1
1202 case "$silent" in
1203 true) exec 1>/dev/null;;
1204 esac
1205
1206 : run the defines and the undefines, if any, but leave the file out there...
1207 touch optdef.sh
1208 . ./optdef.sh
1209
1210 : set package name
1211 package=perl5
1212 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1213 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1214 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1215 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1216 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1217 esac
1218
1219 : Some greps do not return status, grrr.
1220 echo "grimblepritz" >grimble
1221 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1222         contains=contains
1223 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1224         contains=grep
1225 else
1226         contains=contains
1227 fi
1228 rm -f grimble
1229 : the following should work in any shell
1230 case "$contains" in
1231 contains*)
1232         echo " "
1233         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1234         cat >contains <<'EOSS'
1235 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1236 EOSS
1237 chmod +x contains
1238 esac
1239
1240 : Find the path to the source tree
1241 case "$src" in
1242 '') case "$0" in
1243     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`;;
1244     *)   src='.';;
1245     esac;;
1246 esac
1247 case "$src" in
1248 '')     src=/
1249         rsrc=/
1250         ;;
1251 /*) rsrc="$src";;
1252 *) rsrc="../$src";;
1253 esac
1254 if test -f $rsrc/Configure && \
1255         $contains "^package=$package$" $rsrc/Configure >/dev/null 2>&1
1256 then
1257    : found it, so we are ok.
1258 else
1259         rsrc=''
1260         for src in . .. ../.. ../../.. ../../../..; do
1261                 if test -f ../$src/Configure && \
1262                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1263                 then
1264                         rsrc=../$src
1265                         break
1266                 fi
1267         done
1268 fi
1269 case "$rsrc" in
1270 '')
1271         cat <<EOM >&4
1272
1273 Sorry, I can't seem to locate the source dir for $package.  Please start
1274 Configure with an explicit path -- i.e. /some/path/Configure.
1275
1276 EOM
1277         exit 1
1278         ;;
1279 ../.)   rsrc='..';;
1280 *)
1281         echo " "
1282         echo "Sources for $package found in \"$src\"." >&4
1283         ;;
1284 esac
1285
1286 : script used to extract .SH files with variable substitutions
1287 cat >extract <<'EOS'
1288 CONFIG=true
1289 echo "Doing variable substitutions on .SH files..."
1290 if test -f $src/MANIFEST; then
1291         set x `awk '{print $1}' <$src/MANIFEST | grep '\.SH$'`
1292 else
1293         echo "(Looking for .SH files under the source directory.)"
1294         set x `(cd $src; find . -name "*.SH" -print)`
1295 fi
1296 shift
1297 case $# in
1298 0) set x `(cd $src; echo *.SH)`; shift;;
1299 esac
1300 if test ! -f $src/$1; then
1301         shift
1302 fi
1303 mkdir_p='
1304 name=$1;
1305 create="";
1306 while test $name; do
1307         if test ! -d "$name"; then
1308                 create="$name $create";
1309                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1310                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1311         else
1312                 name="";
1313         fi;
1314 done;
1315 for file in $create; do
1316         mkdir $file;
1317 done
1318 '
1319 for file in $*; do
1320         case "$src" in
1321         ".")
1322                 case "$file" in
1323                 */*)
1324                         dir=`expr X$file : 'X\(.*\)/'`
1325                         file=`expr X$file : 'X.*/\(.*\)'`
1326                         (cd $dir && . ./$file)
1327                         ;;
1328                 *)
1329                         . ./$file
1330                         ;;
1331                 esac
1332                 ;;
1333         *)
1334                 case "$file" in
1335                 */*)
1336                         dir=`expr X$file : 'X\(.*\)/'`
1337                         file=`expr X$file : 'X.*/\(.*\)'`
1338                         (set x $dir; shift; eval $mkdir_p)
1339                         sh <$src/$dir/$file
1340                         ;;
1341                 *)
1342                         sh <$src/$file
1343                         ;;
1344                 esac
1345                 ;;
1346         esac
1347 done
1348 if test -f $src/config_h.SH; then
1349         if test ! -f config.h; then
1350         : oops, they left it out of MANIFEST, probably, so do it anyway.
1351         . $src/config_h.SH
1352         fi
1353 fi
1354 EOS
1355
1356 : extract files and exit if asked to do so
1357 case "$extractsh" in
1358 true)
1359         case "$realsilent" in
1360         true) ;;
1361         *) exec 1>&4;;
1362         esac
1363         case "$config_sh" in
1364         '') config_sh='config.sh';;
1365         esac
1366         echo " "
1367         echo "Fetching answers from $config_sh..."
1368         cd ..
1369         . $config_sh
1370         test "$override" && . ./optdef.sh
1371         echo " "
1372         . UU/extract
1373         rm -rf UU
1374         echo "Done."
1375         exit 0
1376         ;;
1377 esac
1378
1379 : Eunice requires " " instead of "", can you believe it
1380 echo " "
1381 : Here we go...
1382 echo "Beginning of configuration questions for $package."
1383
1384 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1385
1386 : first determine how to suppress newline on echo command
1387 echo " "
1388 echo "Checking echo to see how to suppress newlines..."
1389 (echo "hi there\c" ; echo " ") >.echotmp
1390 if $contains c .echotmp >/dev/null 2>&1 ; then
1391         echo "...using -n."
1392         n='-n'
1393         c=''
1394 else
1395         cat <<'EOM'
1396 ...using \c
1397 EOM
1398         n=''
1399         c='\c'
1400 fi
1401 echo $n "The star should be here-->$c"
1402 echo '*'
1403 rm -f .echotmp
1404
1405 : Now test for existence of everything in MANIFEST
1406 echo " "
1407 if test -f $rsrc/MANIFEST; then
1408         echo "First let's make sure your kit is complete.  Checking..." >&4
1409         awk '$1 !~ /PACK[A-Z]+/ {print $1}' $rsrc/MANIFEST | split -50
1410         rm -f missing
1411         tmppwd=`pwd`
1412         for filelist in x??; do
1413                 (cd $rsrc; ls `cat $tmppwd/$filelist` >/dev/null 2>>$tmppwd/missing)
1414         done
1415         if test -s missing; then
1416                 cat missing >&4
1417                 cat >&4 <<'EOM'
1418
1419 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1420
1421 You have the option of continuing the configuration process, despite the
1422 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1423 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1424 and contact the author (jhi@iki.fi).
1425
1426 EOM
1427                 echo $n "Continue? [n] $c" >&4
1428                 read ans
1429                 case "$ans" in
1430                 y*)
1431                         echo "Continuing..." >&4
1432                         rm -f missing
1433                         ;;
1434                 *)
1435                         echo "ABORTING..." >&4
1436                         kill $$
1437                         ;;
1438                 esac
1439         else
1440                 echo "Looks good..."
1441         fi
1442 else
1443         echo "There is no MANIFEST file.  I hope your kit is complete !"
1444 fi
1445 rm -f missing x??
1446
1447 echo " "
1448 : Find the appropriate value for a newline for tr
1449 if test -n "$DJGPP"; then
1450        trnl='\012'
1451 fi
1452 if test X"$trnl" = X; then
1453         case "`echo foo|tr '\n' x 2>/dev/null`" in
1454         foox) trnl='\n' ;;
1455         esac
1456 fi
1457 if test X"$trnl" = X; then
1458         case "`echo foo|tr '\012' x 2>/dev/null`" in
1459         foox) trnl='\012' ;;
1460         esac
1461 fi
1462 if test X"$trnl" = X; then
1463         cat <<EOM >&2
1464
1465 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
1466
1467 EOM
1468         exit 1
1469 fi
1470
1471 : compute the number of columns on the terminal for proper question formatting
1472 case "$COLUMNS" in
1473 '') COLUMNS='80';;
1474 esac
1475
1476 : set up the echo used in my read
1477 myecho="case \"\$xxxm\" in
1478 '') echo $n \"\$rp $c\" >&4;;
1479 *) case \"\$rp\" in
1480         '') echo $n \"[\$xxxm] $c\";;
1481         *)
1482                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1483                         echo \"\$rp\" >&4
1484                         echo $n \"[\$xxxm] $c\" >&4
1485                 else
1486                         echo $n \"\$rp [\$xxxm] $c\" >&4
1487                 fi
1488                 ;;
1489         esac;;
1490 esac"
1491
1492 : now set up to do reads with possible shell escape and default assignment
1493 cat <<EOSC >myread
1494 $startsh
1495 xxxm=\$dflt
1496 $myecho
1497 ans='!'
1498 case "\$fastread" in
1499 yes) case "\$dflt" in
1500         '') ;;
1501         *) ans='';
1502                 case "\$silent-\$rp" in
1503                 true-) ;;
1504                 *) echo " " >&4;;
1505                 esac;;
1506         esac;;
1507 *) case "\$silent" in
1508         true) case "\$rp" in
1509                 '') ans='';;
1510                 esac;;
1511         esac;;
1512 esac
1513 while expr "X\$ans" : "X!" >/dev/null; do
1514         read answ
1515         set x \$xxxm
1516         shift
1517         aok=''; eval "ans=\\"\$answ\\"" && aok=y
1518         case  "\$answ" in
1519         "!")
1520                 sh 1>&4
1521                 echo " "
1522                 $myecho
1523                 ;;
1524         !*)
1525                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1526                 shift
1527                 sh 1>&4 -c "\$*"
1528                 echo " "
1529                 $myecho
1530                 ;;
1531         "\$ans")
1532                 case "\$ans" in
1533                 \\&*)
1534                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1535                         shift
1536                         case "\$1" in
1537                         -d)
1538                                 fastread=yes
1539                                 echo "(OK, I'll run with -d after this question.)" >&4
1540                                 ;;
1541                         -*)
1542                                 echo "*** Sorry, \$1 not supported yet." >&4
1543                                 ;;
1544                         esac
1545                         $myecho
1546                         ans=!
1547                         ;;
1548                 esac;;
1549         *)
1550                 case "\$aok" in
1551                 y)
1552                         echo "*** Substitution done -- please confirm."
1553                         xxxm="\$ans"
1554                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
1555                         xxxm="\$ans"
1556                         ans=!
1557                         ;;
1558                 *)
1559                         echo "*** Error -- try again."
1560                         ans=!
1561                         ;;
1562                 esac
1563                 $myecho
1564                 ;;
1565         esac
1566         case "\$ans\$xxxm\$nostick" in
1567         '')
1568                 ans=!
1569                 $myecho
1570                 ;;
1571         esac
1572 done
1573 case "\$ans" in
1574 '') ans="\$xxxm";;
1575 esac
1576 EOSC
1577
1578 : create .config dir to save info across Configure sessions
1579 test -d ../.config || mkdir ../.config
1580 cat >../.config/README <<EOF
1581 This directory created by Configure to save information that should
1582 persist across sessions for $package.
1583
1584 You may safely delete it if you wish.
1585 EOF
1586
1587 : general instructions
1588 needman=true
1589 firsttime=true
1590 user=`(logname) 2>/dev/null`
1591 case "$user" in
1592 '') user=`whoami 2>&1`;;
1593 esac
1594 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1595         firsttime=false
1596         echo " "
1597         rp='Would you like to see the instructions?'
1598         dflt=n
1599         . ./myread
1600         case "$ans" in
1601         [yY]*) ;;
1602         *) needman=false;;
1603         esac
1604 fi
1605 if $needman; then
1606         cat <<EOH
1607
1608 This installation shell script will examine your system and ask you questions
1609 to determine how the perl5 package should be installed. If you get
1610 stuck on a question, you may use a ! shell escape to start a subshell or
1611 execute a command.  Many of the questions will have default answers in square
1612 brackets; typing carriage return will give you the default.
1613
1614 On some of the questions which ask for file or directory names you are allowed
1615 to use the ~name construct to specify the login directory belonging to "name",
1616 even if you don't have a shell which knows about that.  Questions where this is
1617 allowed will be marked "(~name ok)".
1618
1619 EOH
1620         rp=''
1621         dflt='Type carriage return to continue'
1622         . ./myread
1623         cat <<'EOH'
1624
1625 The prompter used in this script allows you to use shell variables and
1626 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1627 in the default answer, as if the default line was a set of arguments given to a
1628 script shell.  This means you may also use $* to repeat the whole default line,
1629 so you do not have to re-type everything to add something to the default.
1630
1631 Everytime there is a substitution, you will have to confirm.  If there is an
1632 error (e.g. an unmatched backtick), the default answer will remain unchanged
1633 and you will be prompted again.
1634
1635 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1636 the questions and use the computed defaults (or the previous answers if there
1637 was already a config.sh file). Type 'Configure -h' for a list of options.
1638 You may also start interactively and then answer '& -d' at any prompt to turn
1639 on the non-interactive behaviour for the remainder of the execution.
1640
1641 EOH
1642         . ./myread
1643         cat <<EOH
1644
1645 Much effort has been expended to ensure that this shell script will run on any
1646 Unix system.  If despite that it blows up on yours, your best bet is to edit
1647 Configure and run it again.  If you can't run Configure for some reason,
1648 you'll have to generate a config.sh file by hand.  Whatever problems you
1649 have, let me (jhi@iki.fi) know how I blew it.
1650
1651 This installation script affects things in two ways:
1652
1653 1) it may do direct variable substitutions on some of the files included
1654    in this kit.
1655 2) it builds a config.h file for inclusion in C programs.  You may edit
1656    any of these files as the need arises after running this script.
1657
1658 If you make a mistake on a question, there is no easy way to back up to it
1659 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1660 files.  Configure will offer to let you do this before it runs the SH files.
1661
1662 EOH
1663         dflt='Type carriage return to continue'
1664         . ./myread
1665         case "$firsttime" in
1666         true) echo $user >>../.config/instruct;;
1667         esac
1668 fi
1669
1670 : find out where common programs are
1671 echo " "
1672 echo "Locating common programs..." >&4
1673 cat <<EOSC >loc
1674 $startsh
1675 case \$# in
1676 0) exit 1;;
1677 esac
1678 thing=\$1
1679 shift
1680 dflt=\$1
1681 shift
1682 for dir in \$*; do
1683         case "\$thing" in
1684         .)
1685         if test -d \$dir/\$thing; then
1686                 echo \$dir
1687                 exit 0
1688         fi
1689         ;;
1690         *)
1691         for thisthing in \$dir/\$thing; do
1692                 : just loop through to pick last item
1693         done
1694         if test -f \$thisthing; then
1695                 echo \$thisthing
1696                 exit 0
1697         elif test -f \$dir/\$thing.exe; then
1698                 if test -n "$DJGPP"; then
1699                         echo \$dir/\$thing.exe
1700                 else
1701                         : on Eunice apparently
1702                         echo \$dir/\$thing
1703                 fi
1704                 exit 0
1705         fi
1706         ;;
1707         esac
1708 done
1709 echo \$dflt
1710 exit 1
1711 EOSC
1712 chmod +x loc
1713 $eunicefix loc
1714 loclist="
1715 awk
1716 cat
1717 comm
1718 cp
1719 echo
1720 expr
1721 grep
1722 ls
1723 make
1724 mkdir
1725 rm
1726 sed
1727 sort
1728 touch
1729 tr
1730 uniq
1731 "
1732 trylist="
1733 Mcc
1734 ar
1735 byacc
1736 cpp
1737 csh
1738 date
1739 egrep
1740 gzip
1741 less
1742 ln
1743 more
1744 nm
1745 nroff
1746 pg
1747 tee
1748 test
1749 uname
1750 zip
1751 "
1752 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1753 pth="$pth /lib /usr/lib"
1754 for file in $loclist; do
1755         eval xxx=\$$file
1756         case "$xxx" in
1757         /*|?:[\\/]*)
1758                 if test -f "$xxx"; then
1759                         : ok
1760                 else
1761                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1762                         xxx=`./loc $file $file $pth`
1763                 fi
1764                 ;;
1765         '') xxx=`./loc $file $file $pth`;;
1766         *) xxx=`./loc $xxx $xxx $pth`;;
1767         esac
1768         eval $file=$xxx
1769         eval _$file=$xxx
1770         case "$xxx" in
1771         /*)
1772                 echo $file is in $xxx.
1773                 ;;
1774         ?:[\\/]*)
1775                 echo $file is in $xxx.
1776                 ;;
1777         *)
1778                 echo "I don't know where '$file' is, and my life depends on it." >&4
1779                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1780                 exit 1
1781                 ;;
1782         esac
1783 done
1784 echo " "
1785 echo "Don't worry if any of the following aren't found..."
1786 say=offhand
1787 for file in $trylist; do
1788         eval xxx=\$$file
1789         case "$xxx" in
1790         /*|?:[\\/]*)
1791                 if test -f "$xxx"; then
1792                         : ok
1793                 else
1794                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
1795                         xxx=`./loc $file $file $pth`
1796                 fi
1797                 ;;
1798         '') xxx=`./loc $file $file $pth`;;
1799         *) xxx=`./loc $xxx $xxx $pth`;;
1800         esac
1801         eval $file=$xxx
1802         eval _$file=$xxx
1803         case "$xxx" in
1804         /*)
1805                 echo $file is in $xxx.
1806                 ;;
1807         ?:[\\/]*)
1808                 echo $file is in $xxx.
1809                 ;;
1810         *)
1811                 echo "I don't see $file out there, $say."
1812                 say=either
1813                 ;;
1814         esac
1815 done
1816 case "$egrep" in
1817 egrep)
1818         echo "Substituting grep for egrep."
1819         egrep=$grep
1820         ;;
1821 esac
1822 case "$ln" in
1823 ln)
1824         echo "Substituting cp for ln."
1825         ln=$cp
1826         ;;
1827 esac
1828 case "$test" in
1829 test)
1830         echo "Hopefully test is built into your sh."
1831         ;;
1832 *)
1833         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1834                 echo "Using the test built into your sh."
1835                 test=test
1836                 _test=test
1837         fi
1838         ;;
1839 esac
1840 case "$echo" in
1841 echo)
1842         echo "Hopefully echo is built into your sh."
1843         ;;
1844 '') ;;
1845 *)
1846         echo " "
1847 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1848         $echo $n "hi there$c" >foo1
1849         echo $n "hi there$c" >foo2
1850         if cmp foo1 foo2 >/dev/null 2>&1; then
1851                 echo "They are compatible.  In fact, they may be identical."
1852         else
1853                 case "$n" in
1854                 '-n') n='' c='\c';;
1855                 *) n='-n' c='';;
1856                 esac
1857                 cat <<FOO
1858 They are not compatible!  You are probably running ksh on a non-USG system.
1859 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1860 have echo built in and we may have to run some Bourne shell scripts.  That
1861 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1862
1863 FOO
1864                 $echo $n "The star should be here-->$c"
1865                 $echo "*"
1866         fi
1867         $rm -f foo1 foo2
1868         ;;
1869 esac
1870
1871 : determine whether symbolic links are supported
1872 echo " "
1873 $touch blurfl
1874 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1875         echo "Symbolic links are supported." >&4
1876         lns="$ln -s"
1877 else
1878         echo "Symbolic links are NOT supported." >&4
1879         lns="$ln"
1880 fi
1881 $rm -f blurfl sym
1882
1883 : see whether [:lower:] and [:upper:] are supported character classes
1884 echo " "
1885 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1886 ABYZ)
1887         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1888         up='[:upper:]'
1889         low='[:lower:]'
1890         ;;
1891 *)      # There is a discontinuity in EBCDIC between 'I' and 'J'
1892         # (0xc9 and 0xd1), therefore that is a nice testing point.
1893         if test "X$up" = X -o "X$low" = X; then
1894             case "`echo IJ | $tr '[I-J]' '[i-j]' 2>/dev/null`" in
1895             ij) up='[A-Z]'
1896                 low='[a-z]'
1897                 ;;
1898             esac
1899         fi
1900         if test "X$up" = X -o "X$low" = X; then
1901             case "`echo IJ | $tr I-J i-j 2>/dev/null`" in
1902             ij) up='A-Z'
1903                 low='a-z'
1904                 ;;
1905             esac
1906         fi
1907         if test "X$up" = X -o "X$low" = X; then
1908             case "`echo IJ | od -x 2>/dev/null`" in
1909             *C9D1*|*c9d1*)
1910                 echo "Hey, this might be EBCDIC." >&4
1911                 if test "X$up" = X -o "X$low" = X; then
1912                     case "`echo IJ | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
1913                     ij) up='[A-IJ-RS-Z]'
1914                         low='[a-ij-rs-z]'
1915                         ;;
1916                     esac
1917                 fi
1918                 if test "X$up" = X -o "X$low" = X; then
1919                     case "`echo IJ | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
1920                     ij) up='A-IJ-RS-Z'
1921                         low='a-ij-rs-z'
1922                         ;;
1923                     esac
1924                 fi
1925                 ;;
1926             esac
1927         fi
1928 esac
1929 case "`echo IJ | $tr \"$up\" \"$low\" 2>/dev/null`" in
1930 ij)
1931     echo "Using $up and $low to convert case." >&4
1932     ;;
1933 *)
1934     echo "I don't know how to translate letters from upper to lower case." >&4
1935     echo "Your tr is not acting any way I know of." >&4
1936     exit 1
1937     ;;
1938 esac
1939 : set up the translation script tr, must be called with ./tr of course
1940 cat >tr <<EOSC
1941 $startsh
1942 case "\$1\$2" in
1943 '[A-Z][a-z]') exec $tr '$up' '$low';;
1944 '[a-z][A-Z]') exec $tr '$low' '$up';;
1945 esac
1946 exec $tr "\$@"
1947 EOSC
1948 chmod +x tr
1949 $eunicefix tr
1950
1951 : Try to determine whether config.sh was made on this system
1952 case "$config_sh" in
1953 '')
1954 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1955 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
1956 # because the A-Z/a-z are not consecutive.
1957 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
1958         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
1959 newmyuname="$myuname"
1960 dflt=n
1961 case "$knowitall" in
1962 '')
1963         if test -f ../config.sh; then
1964                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
1965                         eval "`grep myuname= ../config.sh`"
1966                 fi
1967                 if test "X$myuname" = "X$newmyuname"; then
1968                         dflt=y
1969                 fi
1970         fi
1971         ;;
1972 *) dflt=y;;
1973 esac
1974
1975 : Get old answers from old config file if Configure was run on the
1976 : same system, otherwise use the hints.
1977 hint=default
1978 cd ..
1979 if test -f config.sh; then
1980         echo " "
1981         rp="I see a config.sh file.  Shall I use it to set the defaults?"
1982         . UU/myread
1983         case "$ans" in
1984         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
1985         *)  echo "Fetching default answers from your old config.sh file..." >&4
1986                 tmp_n="$n"
1987                 tmp_c="$c"
1988                 tmp_sh="$sh"
1989                 . ./config.sh
1990                 cp config.sh UU
1991                 n="$tmp_n"
1992                 c="$tmp_c"
1993                 : Older versions did not always set $sh.  Catch re-use of such
1994                 : an old config.sh.
1995                 case "$sh" in
1996                 '') sh="$tmp_sh" ;;
1997                 esac
1998                 hint=previous
1999                 ;;
2000         esac
2001 fi
2002 if test ! -f config.sh; then
2003         $cat <<EOM
2004
2005 First time through, eh?  I have some defaults handy for some systems
2006 that need some extra help getting the Configure answers right:
2007
2008 EOM
2009         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
2010         dflt=''
2011         : Half the following guesses are probably wrong... If you have better
2012         : tests or hints, please send them to jhi@iki.fi
2013         : The metaconfig authors would also appreciate a copy...
2014         $test -f /irix && osname=irix
2015         $test -f /xenix && osname=sco_xenix
2016         $test -f /dynix && osname=dynix
2017         $test -f /dnix && osname=dnix
2018         $test -f /lynx.os && osname=lynxos
2019         $test -f /unicos && osname=unicos && osvers=`$uname -r`
2020         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
2021         $test -f /bin/mips && /bin/mips && osname=mips
2022         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
2023                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
2024         $test -d /usr/apollo/bin && osname=apollo
2025         $test -f /etc/saf/_sactab && osname=svr4
2026         $test -d /usr/include/minix && osname=minix
2027         if $test -d /MachTen -o -d /MachTen_Folder; then
2028                 osname=machten
2029                 if $test -x /sbin/version; then
2030                         osvers=`/sbin/version | $awk '{print $2}' |
2031                         $sed -e 's/[A-Za-z]$//'`
2032                 elif $test -x /usr/etc/version; then
2033                         osvers=`/usr/etc/version | $awk '{print $2}' |
2034                         $sed -e 's/[A-Za-z]$//'`
2035                 else
2036                         osvers="$2.$3"
2037                 fi
2038         fi
2039        $test -f /sys/posix.dll &&
2040                $test -f /usr/bin/what &&
2041                set X `/usr/bin/what /sys/posix.dll` &&
2042                $test "$3" = UWIN &&
2043                osname=uwin &&
2044                osvers="$5"
2045         if $test -f $uname; then
2046                 set X $myuname
2047                 shift
2048
2049                 case "$5" in
2050                 fps*) osname=fps ;;
2051                 mips*)
2052                         case "$4" in
2053                         umips) osname=umips ;;
2054                         *) osname=mips ;;
2055                         esac;;
2056                 [23]100) osname=mips ;;
2057                 next*) osname=next ;;
2058                 i386*)
2059                         if $test -f /etc/kconfig; then
2060                                 osname=isc
2061                                 if test "$lns" = "ln -s"; then
2062                                         osvers=4
2063                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
2064                                         osvers=3
2065                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
2066                                         osvers=2
2067                                 fi
2068                         fi
2069                         ;;
2070                 pc*)
2071                         if test -n "$DJGPP"; then
2072                                 osname=dos
2073                                 osvers=djgpp
2074                         fi
2075                         ;;
2076                 esac
2077
2078                 case "$1" in
2079                 aix) osname=aix
2080                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
2081                         case "$tmp" in
2082                         'not found') osvers="$4"."$3" ;;
2083                         '<3240'|'<>3240') osvers=3.2.0 ;;
2084                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
2085                         '=3250'|'>3250') osvers=3.2.5 ;;
2086                         *) osvers=$tmp;;
2087                         esac
2088                         ;;
2089                 *dc.osx) osname=dcosx
2090                         osvers="$3"
2091                         ;;
2092                 dnix) osname=dnix
2093                         osvers="$3"
2094                         ;;
2095                 domainos) osname=apollo
2096                         osvers="$3"
2097                         ;;
2098                 dgux) osname=dgux 
2099                         osvers="$3"
2100                         ;;
2101                 dynixptx*) osname=dynixptx
2102                         osvers=`echo "$4"|sed 's/^v//'`
2103                         ;;
2104                 freebsd) osname=freebsd 
2105                         osvers="$3" ;;
2106                 genix) osname=genix ;;
2107                 hp*) osname=hpux 
2108                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
2109                         ;;
2110                 irix*) osname=irix
2111                         case "$3" in
2112                         4*) osvers=4 ;;
2113                         5*) osvers=5 ;;
2114                         *)      osvers="$3" ;;
2115                         esac
2116                         ;;
2117                 linux) osname=linux
2118                         case "$3" in
2119                         *)      osvers="$3" ;;
2120                         esac
2121                         ;;
2122                 MiNT) osname=mint
2123                         ;;
2124                 netbsd*) osname=netbsd
2125                         osvers="$3"
2126                         ;;
2127                 news-os) osvers="$3"
2128                         case "$3" in
2129                         4*) osname=newsos4 ;;
2130                         *) osname=newsos ;;
2131                         esac
2132                         ;;
2133                 bsd386) osname=bsd386
2134                         osvers=`$uname -r`
2135                         ;;
2136                 POSIX-BC | posix-bc ) osname=posix-bc
2137                         osvers="$3"
2138                         ;;
2139                 powerux | power_ux | powermax_os | powermaxos | \
2140                 powerunix | power_unix) osname=powerux
2141                         osvers="$3"
2142                         ;;
2143                 next*) osname=next ;;
2144                 solaris) osname=solaris
2145                         case "$3" in
2146                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2147                         *)      osvers="$3" ;;
2148                         esac
2149                         ;;
2150                 sunos) osname=sunos
2151                         case "$3" in
2152                         5*) osname=solaris
2153                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
2154                         *)      osvers="$3" ;;
2155                         esac
2156                         ;;
2157                 titanos) osname=titanos
2158                         case "$3" in
2159                         1*) osvers=1 ;;
2160                         2*) osvers=2 ;;
2161                         3*) osvers=3 ;;
2162                         4*) osvers=4 ;;
2163                         *)      osvers="$3" ;;
2164                         esac
2165                         ;;
2166                 ultrix) osname=ultrix
2167                         osvers="$3"
2168                         ;;
2169                 osf1|mls+)      case "$5" in
2170                                 alpha)
2171                                         osname=dec_osf
2172                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
2173                                         ;;
2174                         hp*)    osname=hp_osf1  ;;
2175                         mips)   osname=mips_osf1 ;;
2176                         esac
2177                         ;;
2178                 uts) osname=uts 
2179                         osvers="$3"
2180                         ;;
2181                 qnx) osname=qnx
2182                         osvers="$4"
2183                         ;;
2184                 $2) case "$osname" in
2185                         *isc*) ;;
2186                         *freebsd*) ;;
2187                         svr*)
2188                                 : svr4.x or possibly later
2189                                 case "svr$3" in 
2190                                 ${osname}*)
2191                                         osname=svr$3
2192                                         osvers=$4
2193                                         ;;
2194                                 esac
2195                                 case "$osname" in
2196                                 svr4.0)
2197                                         : Check for ESIX
2198                                         if test -f /stand/boot ; then
2199                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
2200                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
2201                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
2202                                                         if test -n "$isesix"; then
2203                                                                 osname=esix4
2204                                                         fi
2205                                                 fi
2206                                         fi
2207                                         ;;
2208                                 esac
2209                                 ;;
2210                         *)      if test -f /etc/systemid; then
2211                                         osname=sco
2212                                         set `echo $3 | $sed 's/\./ /g'` $4
2213                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
2214                                                 osvers=$1.$2.$3
2215                                         elif $test -f $src/hints/sco_$1_$2.sh; then
2216                                                 osvers=$1.$2
2217                                         elif $test -f $src/hints/sco_$1.sh; then
2218                                                 osvers=$1
2219                                         fi
2220                                 else
2221                                         case "$osname" in
2222                                         '') : Still unknown.  Probably a generic Sys V.
2223                                                 osname="sysv"
2224                                                 osvers="$3"
2225                                                 ;;
2226                                         esac
2227                                 fi
2228                                 ;;
2229                         esac
2230                         ;;
2231                 *)      case "$osname" in
2232                         '') : Still unknown.  Probably a generic BSD.
2233                                 osname="$1"
2234                                 osvers="$3"
2235                                 ;;
2236                         esac
2237                         ;;
2238                 esac
2239         else
2240                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
2241                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
2242                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
2243                                 osname=news_os
2244                         fi
2245                         $rm -f UU/kernel.what
2246                 elif test -d c:/.; then
2247                         set X $myuname
2248                         osname=os2
2249                         osvers="$5"
2250                 fi
2251         fi
2252         
2253         : Now look for a hint file osname_osvers, unless one has been
2254         : specified already.
2255         case "$hintfile" in
2256         ''|' ')
2257                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
2258                 : Also try without trailing minor version numbers.
2259                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
2260                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
2261                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
2262                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
2263                 case "$file" in
2264                 '') dflt=none ;;
2265                 *)  case "$osvers" in
2266                         '') dflt=$file
2267                                 ;;
2268                         *)  if $test -f $src/hints/$file.sh ; then
2269                                         dflt=$file
2270                                 elif $test -f $src/hints/$xfile.sh ; then
2271                                         dflt=$xfile
2272                                 elif $test -f $src/hints/$xxfile.sh ; then
2273                                         dflt=$xxfile
2274                                 elif $test -f $src/hints/$xxxfile.sh ; then
2275                                         dflt=$xxxfile
2276                                 elif $test -f $src/hints/$xxxxfile.sh ; then
2277                                         dflt=$xxxxfile
2278                                 elif $test -f "$src/hints/${osname}.sh" ; then
2279                                         dflt="${osname}"
2280                                 else
2281                                         dflt=none
2282                                 fi
2283                                 ;;
2284                         esac
2285                         ;;
2286                 esac
2287                 if $test -f Policy.sh ; then
2288                         case "$dflt" in
2289                         *Policy*) ;;
2290                         none) dflt="Policy" ;;
2291                         *) dflt="Policy $dflt" ;;
2292                         esac
2293                 fi
2294                 ;;
2295         *)
2296                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
2297                 ;;
2298         esac
2299
2300         if $test -f Policy.sh ; then
2301                 $cat <<EOM
2302
2303 There's also a Policy hint file available, which should make the
2304 site-specific (policy) questions easier to answer.
2305 EOM
2306
2307         fi
2308
2309         $cat <<EOM
2310
2311 You may give one or more space-separated answers, or "none" if appropriate.
2312 A well-behaved OS will have no hints, so answering "none" or just "Policy"
2313 is a good thing.  DO NOT give a wrong version.
2314
2315 EOM
2316
2317         rp="Which of these apply, if any?"
2318         . UU/myread
2319         tans=$ans
2320         for file in $tans; do
2321                 if $test X$file = XPolicy -a -f Policy.sh; then
2322                         . Policy.sh
2323                         $cat Policy.sh >> UU/config.sh
2324                 elif $test -f $src/hints/$file.sh; then
2325                         . $src/hints/$file.sh
2326                         $cat $src/hints/$file.sh >> UU/config.sh
2327                 elif $test X$tans = X -o X$tans = Xnone ; then
2328                         : nothing
2329                 else
2330                         : Give one chance to correct a possible typo.
2331                         echo "$file.sh does not exist"
2332                         dflt=$file
2333                         rp="hint to use instead?"
2334                         . UU/myread
2335                         for file in $ans; do
2336                                 if $test -f "$src/hints/$file.sh"; then
2337                                         . $src/hints/$file.sh
2338                                         $cat $src/hints/$file.sh >> UU/config.sh
2339                                 elif $test X$ans = X -o X$ans = Xnone ; then
2340                                         : nothing
2341                                 else
2342                                         echo "$file.sh does not exist -- ignored."
2343                                 fi
2344                         done
2345                 fi
2346         done
2347
2348         hint=recommended
2349         : Remember our hint file for later.
2350         if $test -f "$src/hints/$file.sh" ; then
2351                 hintfile="$file"
2352         else
2353                 hintfile=''
2354         fi
2355 fi
2356 cd UU
2357 ;;
2358 *)
2359         echo " "
2360         echo "Fetching default answers from $config_sh..." >&4
2361         tmp_n="$n"
2362         tmp_c="$c"
2363         cd ..
2364         cp $config_sh config.sh 2>/dev/null
2365         chmod +w config.sh
2366         . ./config.sh
2367         cd UU
2368         cp ../config.sh .
2369         n="$tmp_n"
2370         c="$tmp_c"
2371         hint=previous
2372         ;;
2373 esac
2374 test "$override" && . ./optdef.sh
2375 myuname="$newmyuname"
2376
2377 : Restore computed paths
2378 for file in $loclist $trylist; do
2379         eval $file="\$_$file"
2380 done
2381
2382 cat << EOM
2383
2384 Configure uses the operating system name and version to set some defaults.
2385 The default value is probably right if the name rings a bell. Otherwise,
2386 since spelling matters for me, either accept the default or answer "none"
2387 to leave it blank.
2388
2389 EOM
2390 case "$osname" in
2391         ''|' ')
2392                 case "$hintfile" in
2393                 ''|' '|none) dflt=none ;;
2394                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2395                 esac
2396                 ;;
2397         *) dflt="$osname" ;;
2398 esac
2399 rp="Operating system name?"
2400 . ./myread
2401 case "$ans" in
2402 none)  osname='' ;;
2403 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2404 esac
2405 echo " "
2406 case "$osvers" in
2407         ''|' ')
2408                 case "$hintfile" in
2409                 ''|' '|none) dflt=none ;;
2410                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2411                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2412                         case "$dflt" in
2413                         ''|' ') dflt=none ;;
2414                         esac
2415                         ;;
2416                 esac
2417                 ;;
2418         *) dflt="$osvers" ;;
2419 esac
2420 rp="Operating system version?"
2421 . ./myread
2422 case "$ans" in
2423 none)  osvers='' ;;
2424 *) osvers="$ans" ;;
2425 esac
2426
2427 : who configured the system
2428 cf_time=`LC_ALL=C; export LC_ALL; $date 2>&1`
2429 cf_by=`(logname) 2>/dev/null`
2430 case "$cf_by" in
2431 "")
2432         cf_by=`(whoami) 2>/dev/null`
2433         case "$cf_by" in
2434         "") cf_by=unknown ;;
2435         esac ;;
2436 esac
2437
2438 : set up the script used to warn in case of inconsistency
2439 cat <<EOS >whoa
2440 $startsh
2441 EOS
2442 cat <<'EOSC' >>whoa
2443 dflt=y
2444 echo " "
2445 echo "*** WHOA THERE!!! ***" >&4
2446 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2447 rp="    Keep the $hint value?"
2448 . ./myread
2449 case "$ans" in
2450 y) td=$was; tu=$was;;
2451 esac
2452 EOSC
2453
2454 : function used to set $1 to $val
2455 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2456 case "$val$was" in
2457 $define$undef) . ./whoa; eval "$var=\$td";;
2458 $undef$define) . ./whoa; eval "$var=\$tu";;
2459 *) eval "$var=$val";;
2460 esac'
2461
2462 : Look for a hint-file generated 'call-back-unit'.  If the
2463 : user has specified that a threading perl is to be built,
2464 : we may need to set or change some other defaults.
2465 case "$usethreads" in
2466 $define|true|[yY]*)
2467         if $test -f usethreads.cbu; then
2468                 . ./usethreads.cbu
2469         fi
2470         ;;
2471 esac
2472 case "$d_oldpthreads" in
2473 '')     : Configure tests would be welcome here.  For now, assume undef.
2474         val="$undef" ;;
2475 *)      val="$d_oldpthreads" ;;
2476 esac
2477 set d_oldpthreads
2478 eval $setvar
2479
2480 case "$usemultiplicity" in
2481 $define|true|[yY]*)     usemultiplicity="$define" ;;
2482 *)                      usemultiplicity="$undef"  ;;
2483 esac
2484 case "$use64bits" in
2485 $define|true|[yY]*)     use64bits="$define" ;;
2486 *)                      use64bits="$undef"  ;;
2487 esac
2488
2489 archname64=''
2490
2491 : determine the architecture name
2492 echo " "
2493 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2494         tarch=`arch`"-$osname"
2495 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2496         if uname -m > tmparch 2>&1 ; then
2497                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2498                         -e 's/$/'"-$osname/" tmparch`
2499         else
2500                 tarch="$osname"
2501         fi
2502         $rm -f tmparch
2503 else
2504         tarch="$osname"
2505 fi
2506 case "$myarchname" in
2507 ''|"$tarch") ;;
2508 *)
2509         echo "(Your architecture name used to be $myarchname.)"
2510         archname=''
2511         ;;
2512 esac
2513 myarchname="$tarch"
2514 case "$archname" in
2515 '') dflt="$tarch";;
2516 *) dflt="$archname";;
2517 esac
2518 rp='What is your architecture name'
2519 . ./myread
2520 archname="$ans"
2521 case "$usethreads" in
2522 $define)
2523         echo "Threads selected." >&4
2524         case "$archname" in
2525         *-thread*) echo "...and architecture name already has -thread." >&4
2526                 ;;
2527         *)      archname="$archname-thread"
2528                 echo "...setting architecture name to $archname." >&4
2529                 ;;
2530         esac
2531         ;;
2532 esac
2533 case "$usemultiplicity" in
2534 $define)
2535         echo "Multiplicity selected." >&4
2536         case "$archname" in
2537         *-multi*) echo "...and architecture name already has -multi." >&4
2538                 ;;
2539         *)      archname="$archname-multi"
2540                 echo "...setting architecture name to $archname." >&4
2541                 ;;
2542         esac
2543         ;;
2544 esac
2545 case "$use64bits" in
2546 $define)
2547         echo "Explicit 64-bitness selected." >&4
2548         case "$archname64" in
2549         '')
2550                 ;;
2551         *)
2552                 case "$archname" in
2553                 *-$archname64*) echo "...and architecture name already has $archname64." >&4
2554                         ;;
2555                 *)      archname="$archname-$archname64"
2556                         echo "...setting architecture name to $archname." >&4
2557                         ;;
2558                 esac
2559                 ;;
2560         esac
2561 esac
2562
2563 : is AFS running?
2564 echo " "
2565 case "$afs" in
2566 $define|true)   afs=true ;;
2567 $undef|false)   afs=false ;;
2568 *)      if test -d /afs; then
2569                 afs=true
2570         else
2571                 afs=false
2572         fi
2573         ;;
2574 esac
2575 if $afs; then
2576         echo "AFS may be running... I'll be extra cautious then..." >&4
2577 else
2578         echo "AFS does not seem to be running..." >&4
2579 fi
2580
2581 : decide how portable to be.  Allow command line overrides.
2582 case "$d_portable" in
2583 "$undef") ;;
2584 *)      d_portable="$define" ;;
2585 esac
2586
2587 : set up shell script to do ~ expansion
2588 cat >filexp <<EOSS
2589 $startsh
2590 : expand filename
2591 case "\$1" in
2592  ~/*|~)
2593         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2594         ;;
2595  ~*)
2596         if $test -f /bin/csh; then
2597                 /bin/csh -f -c "glob \$1"
2598                 failed=\$?
2599                 echo ""
2600                 exit \$failed
2601         else
2602                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2603                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2604                 if $test ! -d "\$dir"; then
2605                         me=\`basename \$0\`
2606                         echo "\$me: can't locate home directory for: \$name" >&2
2607                         exit 1
2608                 fi
2609                 case "\$1" in
2610                 */*)
2611                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2612                         ;;
2613                 *)
2614                         echo \$dir
2615                         ;;
2616                 esac
2617         fi
2618         ;;
2619 *)
2620         echo \$1
2621         ;;
2622 esac
2623 EOSS
2624 chmod +x filexp
2625 $eunicefix filexp
2626
2627 : now set up to get a file name
2628 cat <<EOS >getfile
2629 $startsh
2630 EOS
2631 cat <<'EOSC' >>getfile
2632 tilde=''
2633 fullpath=''
2634 already=''
2635 skip=''
2636 none_ok=''
2637 exp_file=''
2638 nopath_ok=''
2639 orig_rp="$rp"
2640 orig_dflt="$dflt"
2641
2642 case "$fn" in
2643 *\(*)
2644         expr $fn : '.*(\(.*\)).*' | tr ',' $trnl >getfile.ok
2645         fn=`echo $fn | sed 's/(.*)//'`
2646         ;;
2647 esac
2648
2649 case "$fn" in
2650 *:*)
2651         loc_file=`expr $fn : '.*:\(.*\)'`
2652         fn=`expr $fn : '\(.*\):.*'`
2653         ;;
2654 esac
2655
2656 case "$fn" in
2657 *~*) tilde=true;;
2658 esac
2659 case "$fn" in
2660 */*) fullpath=true;;
2661 esac
2662 case "$fn" in
2663 *+*) skip=true;;
2664 esac
2665 case "$fn" in
2666 *n*) none_ok=true;;
2667 esac
2668 case "$fn" in
2669 *e*) exp_file=true;;
2670 esac
2671 case "$fn" in
2672 *p*) nopath_ok=true;;
2673 esac
2674
2675 case "$fn" in
2676 *f*) type='File';;
2677 *d*) type='Directory';;
2678 *l*) type='Locate';;
2679 esac
2680
2681 what="$type"
2682 case "$what" in
2683 Locate) what='File';;
2684 esac
2685
2686 case "$exp_file" in
2687 '')
2688         case "$d_portable" in
2689         "$define") ;;
2690         *) exp_file=true;;
2691         esac
2692         ;;
2693 esac
2694
2695 cd ..
2696 while test "$type"; do
2697         redo=''
2698         rp="$orig_rp"
2699         dflt="$orig_dflt"
2700         case "$tilde" in
2701         true) rp="$rp (~name ok)";;
2702         esac
2703         . UU/myread
2704         if test -f UU/getfile.ok && \
2705                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2706         then
2707                 value="$ans"
2708                 ansexp="$ans"
2709                 break
2710         fi
2711         case "$ans" in
2712         none)
2713                 value=''
2714                 ansexp=''
2715                 case "$none_ok" in
2716                 true) type='';;
2717                 esac
2718                 ;;
2719         *)
2720                 case "$tilde" in
2721                 '') value="$ans"
2722                         ansexp="$ans";;
2723                 *)
2724                         value=`UU/filexp $ans`
2725                         case $? in
2726                         0)
2727                                 if test "$ans" != "$value"; then
2728                                         echo "(That expands to $value on this system.)"
2729                                 fi
2730                                 ;;
2731                         *) value="$ans";;
2732                         esac
2733                         ansexp="$value"
2734                         case "$exp_file" in
2735                         '') value="$ans";;
2736                         esac
2737                         ;;
2738                 esac
2739                 case "$fullpath" in
2740                 true)
2741                         case "$ansexp" in
2742                         /*) value="$ansexp" ;;
2743                         *)
2744                                 redo=true
2745                                 case "$already" in
2746                                 true)
2747                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2748                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2749                                         ;;
2750                                 *)
2751                                 echo "Please give a full path name, starting with slash." >&4
2752                                         case "$tilde" in
2753                                         true)
2754                                 echo "Note that using ~name is ok provided it expands well." >&4
2755                                                 already=true
2756                                                 ;;
2757                                         esac
2758                                 esac
2759                                 ;;
2760                         esac
2761                         ;;
2762                 esac
2763                 case "$redo" in
2764                 '')
2765                         case "$type" in
2766                         File)
2767                                 if test -f "$ansexp"; then
2768                                         type=''
2769                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2770                                 then
2771                                         echo "($value is not a plain file, but that's ok.)"
2772                                         type=''
2773                                 fi
2774                                 ;;
2775                         Directory)
2776                                 if test -d "$ansexp"; then
2777                                         type=''
2778                                 fi
2779                                 ;;
2780                         Locate)
2781                                 if test -d "$ansexp"; then
2782                                         echo "(Looking for $loc_file in directory $value.)"
2783                                         value="$value/$loc_file"
2784                                         ansexp="$ansexp/$loc_file"
2785                                 fi
2786                                 if test -f "$ansexp"; then
2787                                         type=''
2788                                 fi
2789                                 case "$nopath_ok" in
2790                                 true)   case "$value" in
2791                                         */*) ;;
2792                                         *)      echo "Assuming $value will be in people's path."
2793                                                 type=''
2794                                                 ;;
2795                                         esac
2796                                         ;;
2797                                 esac
2798                                 ;;
2799                         esac
2800
2801                         case "$skip" in
2802                         true) type='';
2803                         esac
2804
2805                         case "$type" in
2806                         '') ;;
2807                         *)
2808                                 if test "$fastread" = yes; then
2809                                         dflt=y
2810                                 else
2811                                         dflt=n
2812                                 fi
2813                                 rp="$what $value doesn't exist.  Use that name anyway?"
2814                                 . UU/myread
2815                                 dflt=''
2816                                 case "$ans" in
2817                                 y*) type='';;
2818                                 *) echo " ";;
2819                                 esac
2820                                 ;;
2821                         esac
2822                         ;;
2823                 esac
2824                 ;;
2825         esac
2826 done
2827 cd UU
2828 ans="$value"
2829 rp="$orig_rp"
2830 dflt="$orig_dflt"
2831 rm -f getfile.ok
2832 EOSC
2833
2834 : determine root of directory hierarchy where package will be installed.
2835 case "$prefix" in
2836 '')
2837         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2838         ;;
2839 *)
2840         dflt="$prefix"
2841         ;;
2842 esac
2843 $cat <<EOM
2844
2845 By default, $package will be installed in $dflt/bin, manual
2846 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
2847 all installation directories. Typically set to /usr/local, but you
2848 may choose /usr if you wish to install $package among your system
2849 binaries. If you wish to have binaries under /bin but manual pages
2850 under /usr/local/man, that's ok: you will be prompted separately
2851 for each of the installation directories, the prefix being only used
2852 to set the defaults.
2853
2854 EOM
2855 fn=d~
2856 rp='Installation prefix to use?'
2857 . ./getfile
2858 oldprefix=''
2859 case "$prefix" in
2860 '') ;;
2861 *)
2862         case "$ans" in
2863         "$prefix") ;;
2864         *) oldprefix="$prefix";;
2865         esac
2866         ;;
2867 esac
2868 prefix="$ans"
2869 prefixexp="$ansexp"
2870
2871 : set the prefixit variable, to compute a suitable default value
2872 prefixit='case "$3" in
2873 ""|none)
2874         case "$oldprefix" in
2875         "") eval "$1=\"\$$2\"";;
2876         *)
2877                 case "$3" in
2878                 "") eval "$1=";;
2879                 none)
2880                         eval "tp=\"\$$2\"";
2881                         case "$tp" in
2882                         ""|" ") eval "$1=\"\$$2\"";;
2883                         *) eval "$1=";;
2884                         esac;;
2885                 esac;;
2886         esac;;
2887 *)
2888         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
2889         case "$tp" in
2890         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
2891         /*-$oldprefix/*|\~*-$oldprefix/*)
2892                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
2893         *) eval "$1=\"\$$2\"";;
2894         esac;;
2895 esac'
2896
2897 : set the base revision
2898 baserev=5.0
2899
2900 : get the patchlevel
2901 echo " "
2902 echo "Getting the current patchlevel..." >&4
2903 if $test -r $rsrc/patchlevel.h;then
2904         patchlevel=`awk '/define[       ]+PATCHLEVEL/ {print $3}' $rsrc/patchlevel.h`
2905         subversion=`awk '/define[       ]+SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
2906 else
2907         patchlevel=0
2908         subversion=0
2909 fi
2910 $echo $n "(You have $package" $c
2911 case "$package" in
2912 "*$baserev")    ;;
2913 *)              $echo $n " $baserev" $c ;;
2914 esac
2915 $echo $n " patchlevel $patchlevel" $c
2916 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
2917 echo ".)"
2918
2919 if test 0 -eq "$subversion"; then
2920         version=`LC_ALL=C; export LC_ALL; \
2921                  echo $baserev $patchlevel | \
2922                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
2923 else
2924         version=`LC_ALL=C; export LC_ALL; \
2925                  echo $baserev $patchlevel $subversion | \
2926                  $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
2927 fi
2928 : Figure out perl API version.  Perhaps this should be in patchlevel.h
2929 if test "$subversion" -lt 50; then
2930         apiversion=`LC_ALL=C; export LC_ALL; \
2931                  echo $baserev $patchlevel | \
2932                  $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
2933 else
2934         apiversion="$version"
2935 fi
2936
2937 : determine where private library files go
2938 : Usual default is /usr/local/lib/perl5/$version.
2939 : Also allow things like /opt/perl/lib/$version, since 
2940 : /opt/perl/lib/perl5... would be redundant.
2941 case "$prefix" in
2942 *perl*) set dflt privlib lib/$version ;;
2943 *)       set dflt privlib lib/$package/$version ;;
2944 esac
2945 eval $prefixit
2946 $cat <<EOM
2947
2948 There are some auxiliary files for $package that need to be put into a
2949 private library directory that is accessible by everyone.
2950
2951 EOM
2952 fn=d~+
2953 rp='Pathname where the private library files will reside?'
2954 . ./getfile
2955 if $test "X$privlibexp" != "X$ansexp"; then
2956         installprivlib=''
2957 fi
2958 privlib="$ans"
2959 privlibexp="$ansexp"
2960 if $afs; then
2961         $cat <<EOM
2962
2963 Since you are running AFS, I need to distinguish the directory in which
2964 private files reside from the directory in which they are installed (and from
2965 which they are presumably copied to the former directory by occult means).
2966
2967 EOM
2968         case "$installprivlib" in
2969         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
2970         *) dflt="$installprivlib";;
2971         esac
2972         fn=de~
2973         rp='Where will private files be installed?'
2974         . ./getfile
2975         installprivlib="$ans"
2976 else
2977         installprivlib="$privlibexp"
2978 fi
2979
2980 : set the prefixup variable, to restore leading tilda escape
2981 prefixup='case "$prefixexp" in
2982 "$prefix") ;;
2983 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
2984 esac'
2985
2986 : determine where public architecture dependent libraries go
2987 set archlib archlib
2988 eval $prefixit
2989 : privlib default is /usr/local/lib/$package/$version
2990 : archlib default is /usr/local/lib/$package/$version/$archname
2991 : privlib may have an optional trailing /share.
2992 tdflt=`echo $privlib | $sed 's,/share$,,'`
2993 tdflt=$tdflt/$archname
2994 case "$archlib" in
2995 '')     dflt=$tdflt
2996         ;;
2997 *)      dflt="$archlib"
2998     ;;
2999 esac
3000 cat <<EOM
3001
3002 $spackage contains architecture-dependent library files.  If you are
3003 sharing libraries in a heterogeneous environment, you might store
3004 these files in a separate location.  Otherwise, you can just include
3005 them with the rest of the public library files.
3006
3007 EOM
3008 fn=d+~
3009 rp='Where do you want to put the public architecture-dependent libraries?'
3010 . ./getfile
3011 archlib="$ans"
3012 archlibexp="$ansexp"
3013
3014 if $afs; then
3015         $cat <<EOM
3016
3017 Since you are running AFS, I need to distinguish the directory in
3018 which architecture-dependent library files reside from the directory
3019 in which they are installed (and from which they are presumably copied
3020 to the former directory by occult means).
3021
3022 EOM
3023         case "$installarchlib" in
3024         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
3025         *) dflt="$installarchlib";;
3026         esac
3027         fn=de~
3028         rp='Where will architecture-dependent library files be installed?'
3029         . ./getfile
3030         installarchlib="$ans"
3031 else
3032         installarchlib="$archlibexp"
3033 fi
3034 if $test X"$archlib" = X"$privlib"; then
3035         d_archlib="$undef"
3036 else
3037         d_archlib="$define"
3038 fi
3039
3040 : make some quick guesses about what we are up against
3041 echo " "
3042 $echo $n "Hmm...  $c"
3043 echo exit 1 >bsd
3044 echo exit 1 >usg
3045 echo exit 1 >v7
3046 echo exit 1 >osf1
3047 echo exit 1 >eunice
3048 echo exit 1 >xenix
3049 echo exit 1 >venix
3050 echo exit 1 >os2
3051 d_bsd="$undef"
3052 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
3053 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
3054 then
3055         echo "Looks kind of like an OSF/1 system, but we'll see..."
3056         echo exit 0 >osf1
3057 elif test `echo abc | tr a-z A-Z` = Abc ; then
3058         xxx=`./loc addbib blurfl $pth`
3059         if $test -f $xxx; then
3060         echo "Looks kind of like a USG system with BSD features, but we'll see..."
3061                 echo exit 0 >bsd
3062                 echo exit 0 >usg
3063         else
3064                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
3065                         echo "Looks kind of like an extended USG system, but we'll see..."
3066                 else
3067                         echo "Looks kind of like a USG system, but we'll see..."
3068                 fi
3069                 echo exit 0 >usg
3070         fi
3071 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
3072         echo "Looks kind of like a BSD system, but we'll see..."
3073         d_bsd="$define"
3074         echo exit 0 >bsd
3075 else
3076         echo "Looks kind of like a Version 7 system, but we'll see..."
3077         echo exit 0 >v7
3078 fi
3079 case "$eunicefix" in
3080 *unixtovms*)
3081         $cat <<'EOI'
3082 There is, however, a strange, musty smell in the air that reminds me of
3083 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
3084 EOI
3085         echo exit 0 >eunice
3086         d_eunice="$define"
3087 : it so happens the Eunice I know will not run shell scripts in Unix format
3088         ;;
3089 *)
3090         echo " "
3091         echo "Congratulations.  You aren't running Eunice."
3092         d_eunice="$undef"
3093         ;;
3094 esac
3095 : Detect OS2.  The p_ variable is set above in the Head.U unit.
3096 case "$p_" in
3097 :) ;;
3098 *)
3099         $cat <<'EOI'
3100 I have the feeling something is not exactly right, however...don't tell me...
3101 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
3102 EOI
3103         echo exit 0 >os2
3104         ;;
3105 esac
3106 if test -f /xenix; then
3107         echo "Actually, this looks more like a XENIX system..."
3108         echo exit 0 >xenix
3109         d_xenix="$define"
3110 else
3111         echo " "
3112         echo "It's not Xenix..."
3113         d_xenix="$undef"
3114 fi
3115 chmod +x xenix
3116 $eunicefix xenix
3117 if test -f /venix; then
3118         echo "Actually, this looks more like a VENIX system..."
3119         echo exit 0 >venix
3120 else
3121         echo " "
3122         if ./xenix; then
3123                 : null
3124         else
3125                 echo "Nor is it Venix..."
3126         fi
3127 fi
3128 chmod +x bsd usg v7 osf1 eunice xenix venix os2
3129 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
3130 $rm -f foo
3131
3132 : see if setuid scripts can be secure
3133 $cat <<EOM
3134
3135 Some kernels have a bug that prevents setuid #! scripts from being
3136 secure.  Some sites have disabled setuid #! scripts because of this.
3137
3138 First let's decide if your kernel supports secure setuid #! scripts.
3139 (If setuid #! scripts would be secure but have been disabled anyway,
3140 don't say that they are secure if asked.)
3141
3142 EOM
3143
3144 val="$undef"
3145 if $test -d /dev/fd; then
3146         echo "#!$ls" >reflect
3147         chmod +x,u+s reflect
3148         ./reflect >flect 2>&1
3149         if $contains "/dev/fd" flect >/dev/null; then
3150                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
3151                 val="$define"
3152         else
3153                 $cat <<EOM
3154 If you are not sure if they are secure, I can check but I'll need a
3155 username and password different from the one you are using right now.
3156 If you don't have such a username or don't want me to test, simply
3157 enter 'none'.
3158
3159 EOM
3160                 rp='Other username to test security of setuid scripts with?'
3161                 dflt='none'
3162                 . ./myread
3163                 case "$ans" in
3164                 n|none)
3165                         case "$d_suidsafe" in
3166                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
3167                                 dflt=n;;
3168                         "$undef")
3169                                 echo "Well, the $hint value is *not* secure." >&4
3170                                 dflt=n;;
3171                         *)      echo "Well, the $hint value *is* secure." >&4
3172                                 dflt=y;;
3173                         esac
3174                         ;;
3175                 *)
3176                         $rm -f reflect flect
3177                         echo "#!$ls" >reflect
3178                         chmod +x,u+s reflect
3179                         echo >flect
3180                         chmod a+w flect
3181                         echo '"su" will (probably) prompt you for '"$ans's password."
3182                         su $ans -c './reflect >flect'
3183                         if $contains "/dev/fd" flect >/dev/null; then
3184                                 echo "Okay, it looks like setuid scripts are secure." >&4
3185                                 dflt=y
3186                         else
3187                                 echo "I don't think setuid scripts are secure." >&4
3188                                 dflt=n
3189                         fi
3190                         ;;
3191                 esac
3192                 rp='Does your kernel have *secure* setuid scripts?'
3193                 . ./myread
3194                 case "$ans" in
3195                 [yY]*)  val="$define";;
3196                 *)      val="$undef";;
3197                 esac
3198         fi
3199 else
3200         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
3201         echo "(That's for file descriptors, not floppy disks.)"
3202         val="$undef"
3203 fi
3204 set d_suidsafe
3205 eval $setvar
3206
3207 $rm -f reflect flect
3208
3209 : now see if they want to do setuid emulation
3210 echo " "
3211 val="$undef"
3212 case "$d_suidsafe" in
3213 "$define")
3214         val="$undef"
3215         echo "No need to emulate SUID scripts since they are secure here." >& 4
3216         ;;
3217 *)
3218         $cat <<EOM
3219 Some systems have disabled setuid scripts, especially systems where
3220 setuid scripts cannot be secure.  On systems where setuid scripts have
3221 been disabled, the setuid/setgid bits on scripts are currently
3222 useless.  It is possible for $package to detect those bits and emulate
3223 setuid/setgid in a secure fashion.  This emulation will only work if
3224 setuid scripts have been disabled in your kernel.
3225
3226 EOM
3227         case "$d_dosuid" in
3228         "$define") dflt=y ;;
3229         *) dflt=n ;;
3230         esac
3231         rp="Do you want to do setuid/setgid emulation?"
3232         . ./myread
3233         case "$ans" in
3234         [yY]*)  val="$define";;
3235         *)      val="$undef";;
3236         esac
3237         ;;
3238 esac
3239 set d_dosuid
3240 eval $setvar
3241
3242 : determine where manual pages are on this system
3243 echo " "
3244 case "$sysman" in
3245 '') 
3246         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
3247         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3248         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3249         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3250         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3251         sysman=`./loc . /usr/man/man1 $syspath`
3252         ;;
3253 esac
3254 if $test -d "$sysman"; then
3255         echo "System manual is in $sysman." >&4
3256 else
3257         echo "Could not find manual pages in source form." >&4
3258 fi
3259
3260 : see what memory models we can support
3261 case "$models" in
3262 '')
3263         $cat >pdp11.c <<'EOP'
3264 main() {
3265 #ifdef pdp11
3266         exit(0);
3267 #else
3268         exit(1);
3269 #endif
3270 }
3271 EOP
3272         ( cc -o pdp11 pdp11.c ) >/dev/null 2>&1
3273         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3274                 dflt='unsplit split'
3275         else
3276                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3277                 case "$tans" in
3278                 X) dflt='none';;
3279                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3280                                 dflt='small'
3281                         else
3282                                 dflt=''
3283                         fi
3284                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3285                                 dflt="$dflt medium"
3286                         fi
3287                         if $test -d /lib/large || $test -d /usr/lib/large; then
3288                                 dflt="$dflt large"
3289                         fi
3290                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3291                                 dflt="$dflt huge"
3292                         fi
3293                 esac
3294         fi;;
3295 *) dflt="$models";;
3296 esac
3297 $cat <<EOM
3298  
3299 Some systems have different model sizes.  On most systems they are called
3300 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3301 split.  If your system doesn't support different memory models, say "none".
3302 If you wish to force everything to one memory model, say "none" here and
3303 put the appropriate flags later when it asks you for other cc and ld flags.
3304 Venix systems may wish to put "none" and let the compiler figure things out.
3305 (In the following question multiple model names should be space separated.)
3306
3307 The default for most systems is "none".
3308
3309 EOM
3310 rp="Which memory models are supported?"
3311 . ./myread
3312 models="$ans"
3313
3314 case "$models" in
3315 none)
3316         small=''
3317         medium=''
3318         large=''
3319         huge=''
3320         unsplit=''
3321         split=''
3322         ;;
3323 *split)
3324         case "$split" in
3325         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3326                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3327                         dflt='-i'
3328                 else
3329                         dflt='none'
3330                 fi;;
3331         *) dflt="$split";;
3332         esac
3333         rp="What flag indicates separate I and D space?"
3334         . ./myread
3335         tans="$ans"
3336         case "$tans" in
3337         none) tans='';;
3338         esac
3339         split="$tans"
3340         unsplit='';;
3341 *large*|*small*|*medium*|*huge*)
3342         case "$models" in
3343         *large*)
3344                 case "$large" in
3345                 '') dflt='-Ml';;
3346                 *) dflt="$large";;
3347                 esac
3348         rp="What flag indicates large model?"
3349         . ./myread
3350         tans="$ans"
3351         case "$tans" in
3352         none) tans='';
3353         esac
3354         large="$tans";;
3355         *) large='';;
3356         esac
3357         case "$models" in
3358         *huge*) case "$huge" in
3359                 '') dflt='-Mh';;
3360                 *) dflt="$huge";;
3361                 esac
3362                 rp="What flag indicates huge model?"
3363                 . ./myread
3364                 tans="$ans"
3365                 case "$tans" in
3366                 none) tans='';
3367                 esac
3368                 huge="$tans";;
3369         *) huge="$large";;
3370         esac
3371         case "$models" in
3372         *medium*) case "$medium" in
3373                 '') dflt='-Mm';;
3374                 *) dflt="$medium";;
3375                 esac
3376                 rp="What flag indicates medium model?"
3377                 . ./myread
3378                 tans="$ans"
3379                 case "$tans" in
3380                 none) tans='';
3381                 esac
3382                 medium="$tans";;
3383         *) medium="$large";;
3384         esac
3385         case "$models" in
3386         *small*) case "$small" in
3387                 '') dflt='none';;
3388                 *) dflt="$small";;
3389                 esac
3390                 rp="What flag indicates small model?"
3391                 . ./myread
3392                 tans="$ans"
3393                 case "$tans" in
3394                 none) tans='';
3395                 esac
3396                 small="$tans";;
3397         *) small='';;
3398         esac
3399         ;;
3400 *)
3401         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3402         ;;
3403 esac
3404 $rm -f pdp11.* pdp11
3405
3406 : see if we need a special compiler
3407 echo " "
3408 if ./usg; then
3409         case "$cc" in
3410         '') case "$Mcc" in
3411                 /*) dflt='Mcc';;
3412                 *) case "$large" in
3413                         -M*) dflt='cc';;
3414                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3415                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3416                                                 dflt='cc'
3417                                         else
3418                                                 dflt='cc -M'
3419                                         fi
3420                                 else
3421                                         dflt='cc'
3422                                 fi;;
3423                         esac;;
3424                 esac;;
3425         *)  dflt="$cc";;
3426         esac
3427         case "$dflt" in
3428         *M*)    $cat <<'EOM'
3429 On some older systems the default C compiler will not resolve multiple global
3430 references that happen to have the same name.  On some such systems the "Mcc"
3431 command may be used to force these to be resolved.  On other systems a "cc -M"
3432 command is required.  (Note that the -M flag on other systems indicates a
3433 memory model to use!) If you have the Gnu C compiler, you might wish to use
3434 that instead.
3435
3436 EOM
3437         ;;
3438         esac
3439         rp="Use which C compiler?"
3440         . ./myread
3441         cc="$ans"
3442 else
3443         case "$cc" in
3444         '') dflt=cc;;
3445         *) dflt="$cc";;
3446         esac
3447         rp="Use which C compiler?"
3448         . ./myread
3449         cc="$ans"
3450 fi
3451 : Look for a hint-file generated 'call-back-unit'.  Now that the
3452 : user has specified the compiler, we may need to set or change some
3453 : other defaults.
3454 if $test -f cc.cbu; then
3455     . ./cc.cbu
3456 fi
3457 echo " "
3458 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3459 $cat >gccvers.c <<EOM
3460 #include <stdio.h>
3461 int main() {
3462 #ifdef __GNUC__
3463 #ifdef __VERSION__
3464         printf("%s\n", __VERSION__);
3465 #else
3466         printf("%s\n", "1");
3467 #endif
3468 #endif
3469         exit(0);
3470 }
3471 EOM
3472 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
3473         gccversion=`./gccvers`
3474         case "$gccversion" in
3475         '') echo "You are not using GNU cc." ;;
3476         *)  echo "You are using GNU cc $gccversion." ;;
3477         esac
3478 else
3479         echo " "
3480         echo "*** WHOA THERE!!! ***" >&4
3481         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3482         case "$knowitall" in
3483         '')
3484         echo "    You'd better start hunting for one and let me know about it." >&4
3485                 exit 1
3486                 ;;
3487         esac
3488 fi
3489 $rm -f gccvers*
3490 case "$gccversion" in
3491 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3492 esac
3493
3494 : What should the include directory be ?
3495 echo " "
3496 $echo $n "Hmm...  $c"
3497 dflt='/usr/include'
3498 incpath=''
3499 mips_type=''
3500 if $test -f /bin/mips && /bin/mips; then
3501         echo "Looks like a MIPS system..."
3502         $cat >usr.c <<'EOCP'
3503 #ifdef SYSTYPE_BSD43
3504 /bsd43
3505 #endif
3506 EOCP
3507         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3508                 dflt='/bsd43/usr/include'
3509                 incpath='/bsd43'
3510                 mips_type='BSD 4.3'
3511         else
3512                 mips_type='System V'
3513         fi
3514         $rm -f usr.c usr.out
3515         echo "and you're compiling with the $mips_type compiler and libraries."
3516         xxx_prompt=y
3517         echo "exit 0" >mips
3518 else
3519         echo "Doesn't look like a MIPS system."
3520         xxx_prompt=n
3521         echo "exit 1" >mips
3522 fi
3523 chmod +x mips
3524 $eunicefix mips
3525 case "$usrinc" in
3526 '') ;;
3527 *) dflt="$usrinc";;
3528 esac
3529 case "$xxx_prompt" in
3530 y)      fn=d/
3531         echo " "
3532         rp='Where are the include files you want to use?'
3533         . ./getfile
3534         usrinc="$ans"
3535         ;;
3536 *)      usrinc="$dflt"
3537         ;;
3538 esac
3539
3540 : see how we invoke the C preprocessor
3541 echo " "
3542 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3543 cat <<'EOT' >testcpp.c
3544 #define ABC abc
3545 #define XYZ xyz
3546 ABC.XYZ
3547 EOT
3548 cd ..
3549 if test ! -f cppstdin; then
3550         echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3551 else
3552         echo "Keeping your $hint cppstdin wrapper."
3553 fi
3554 chmod 755 cppstdin
3555 wrapper=`pwd`/cppstdin
3556 ok='false'
3557 cd UU
3558
3559 if $test "X$cppstdin" != "X" && \
3560         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3561         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3562 then
3563         echo "You used to use $cppstdin $cppminus so we'll use that again."
3564         case "$cpprun" in
3565         '') echo "But let's see if we can live without a wrapper..." ;;
3566         *)
3567                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3568                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3569                 then
3570                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3571                         ok='true'
3572                 else
3573                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3574                 fi
3575                 ;;
3576         esac
3577 else
3578         case "$cppstdin" in
3579         '') ;;
3580         *)
3581                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3582                 ;;
3583         esac
3584 fi
3585
3586 if $ok; then
3587         : nothing
3588 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3589         $cc -E <testcpp.c >testcpp.out 2>&1; \
3590         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3591         echo "Yup, it does."
3592         x_cpp="$cc -E"
3593         x_minus='';
3594 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3595         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3596         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3597         echo "Yup, it does."
3598         x_cpp="$cc -E"
3599         x_minus='-';
3600 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3601         $cc -P <testcpp.c >testcpp.out 2>&1; \
3602         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3603         echo "Yipee, that works!"
3604         x_cpp="$cc -P"
3605         x_minus='';
3606 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3607         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3608         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3609         echo "At long last!"
3610         x_cpp="$cc -P"
3611         x_minus='-';
3612 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3613         $cpp <testcpp.c >testcpp.out 2>&1; \
3614         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3615         echo "It works!"
3616         x_cpp="$cpp"
3617         x_minus='';
3618 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3619         $cpp - <testcpp.c >testcpp.out 2>&1; \
3620         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3621         echo "Hooray, it works!  I was beginning to wonder."
3622         x_cpp="$cpp"
3623         x_minus='-';
3624 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3625         $wrapper <testcpp.c >testcpp.out 2>&1; \
3626         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3627         x_cpp="$wrapper"
3628         x_minus=''
3629         echo "Eureka!"
3630 else
3631         dflt=''
3632         rp="No dice.  I can't find a C preprocessor.  Name one:"
3633         . ./myread
3634         x_cpp="$ans"
3635         x_minus=''
3636         $x_cpp <testcpp.c >testcpp.out 2>&1
3637         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3638                 echo "OK, that will do." >&4
3639         else
3640 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3641                 exit 1
3642         fi
3643 fi
3644
3645 case "$ok" in
3646 false)
3647         cppstdin="$x_cpp"
3648         cppminus="$x_minus"
3649         cpprun="$x_cpp"
3650         cpplast="$x_minus"
3651         set X $x_cpp
3652         shift
3653         case "$1" in
3654         "$cpp")
3655                 echo "Perhaps can we force $cc -E using a wrapper..."
3656                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3657                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3658                 then
3659                         echo "Yup, we can."
3660                         cppstdin="$wrapper"
3661                         cppminus='';
3662                 else
3663                         echo "Nope, we'll have to live without it..."
3664                 fi
3665                 ;;
3666         esac
3667         case "$cpprun" in
3668         "$wrapper")
3669                 cpprun=''
3670                 cpplast=''
3671                 ;;
3672         esac
3673         ;;
3674 esac
3675
3676 case "$cppstdin" in
3677 "$wrapper") ;;
3678 *) $rm -f $wrapper;;
3679 esac
3680 $rm -f testcpp.c testcpp.out
3681
3682 : Set private lib path
3683 case "$plibpth" in
3684 '') if ./mips; then
3685                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3686         fi;;
3687 esac
3688 case "$libpth" in
3689 ' ') dlist='';;
3690 '') dlist="$loclibpth $plibpth $glibpth";;
3691 *) dlist="$libpth";;
3692 esac
3693
3694 : Now check and see which directories actually exist, avoiding duplicates
3695 libpth=''
3696 for xxx in $dlist
3697 do
3698     if $test -d $xxx; then
3699                 case " $libpth " in
3700                 *" $xxx "*) ;;
3701                 *) libpth="$libpth $xxx";;
3702                 esac
3703     fi
3704 done
3705 $cat <<'EOM'
3706
3707 Some systems have incompatible or broken versions of libraries.  Among
3708 the directories listed in the question below, please remove any you
3709 know not to be holding relevant libraries, and add any that are needed.
3710 Say "none" for none.
3711
3712 EOM
3713 case "$libpth" in
3714 '') dflt='none';;
3715 *)
3716         set X $libpth
3717         shift
3718         dflt=${1+"$@"}
3719         ;;
3720 esac
3721 rp="Directories to use for library searches?"
3722 . ./myread
3723 case "$ans" in
3724 none) libpth=' ';;
3725 *) libpth="$ans";;
3726 esac
3727
3728 : compute shared library extension
3729 case "$so" in
3730 '')
3731         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3732                 dflt='sl'
3733         else
3734                 dflt='so'
3735         fi
3736         ;;
3737 *) dflt="$so";;
3738 esac
3739 $cat <<EOM
3740
3741 On some systems, shared libraries may be available.  Answer 'none' if
3742 you want to suppress searching of shared libraries for the remaining
3743 of this configuration.
3744
3745 EOM
3746 rp='What is the file extension used for shared libraries?'
3747 . ./myread
3748 so="$ans"
3749
3750 : Define several unixisms.
3751 : Hints files or command line option can be used to override them.
3752 : The convoluted testing is in case hints files set either the old
3753 : or the new name.
3754 case "$_exe" in
3755 '')     case "$exe_ext" in
3756     '') ;;
3757         *)      _exe="$exe_ext" ;;
3758         esac
3759         ;;
3760 esac
3761 case "$_a" in
3762 '')     case "$lib_ext" in
3763     '') _a='.a';;
3764         *)      _a="$lib_ext" ;;
3765         esac
3766         ;;
3767 esac
3768 case "$_o" in
3769 '') case "$obj_ext" in
3770         '')     _o='.o';;
3771         *)      _o="$obj_ext";;
3772         esac
3773         ;;
3774 esac
3775 case "$p_" in
3776 '') case "$path_sep" in
3777         '')     p_=':';;
3778         *)      p_="$path_sep";;
3779         esac
3780         ;;
3781 esac
3782 exe_ext=$_exe
3783 lib_ext=$_a
3784 obj_ext=$_o
3785 path_sep=$p_
3786
3787 : Which makefile gets called first.  This is used by make depend.
3788 case "$firstmakefile" in
3789 '') firstmakefile='makefile';;
3790 esac
3791
3792 : Looking for optional libraries
3793 echo " "
3794 echo "Checking for optional libraries..." >&4
3795 case "$libs" in
3796 ' '|'') dflt='';;
3797 *) dflt="$libs";;
3798 esac
3799 case "$libswanted" in
3800 '') libswanted='c_s';;
3801 esac
3802 for thislib in $libswanted; do
3803         
3804         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`;
3805                 $test -f "$xxx" -a "X$ignore_versioned_solibs" = "X"; then
3806                 echo "Found -l$thislib (shared)."
3807                 case " $dflt " in
3808                 *"-l$thislib "*);;
3809                 *) dflt="$dflt -l$thislib";;
3810                 esac
3811         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3812                 echo "Found -l$thislib (shared)."
3813                 case " $dflt " in
3814                 *"-l$thislib "*);;
3815                 *) dflt="$dflt -l$thislib";;
3816                 esac
3817         elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
3818                 echo "Found -l$thislib."
3819                 case " $dflt " in
3820                 *"-l$thislib "*);;
3821                 *) dflt="$dflt -l$thislib";;
3822                 esac
3823         elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
3824                 echo "Found -l$thislib."
3825                 case " $dflt " in
3826                 *"-l$thislib "*);;
3827                 *) dflt="$dflt -l$thislib";;
3828                 esac
3829         elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
3830                 echo "Found -l${thislib}_s."
3831                 case " $dflt " in
3832                 *"-l$thislib "*);;
3833                 *) dflt="$dflt -l${thislib}_s";;
3834                 esac
3835         elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
3836                 echo "Found -l$thislib."
3837                 case " $dflt " in
3838                 *"-l$thislib "*);;
3839                 *) dflt="$dflt -l$thislib";;
3840                 esac
3841         else
3842                 echo "No -l$thislib."
3843         fi
3844 done
3845 set X $dflt
3846 shift
3847 dflt="$*"
3848 case "$libs" in
3849 '') dflt="$dflt";;
3850 *) dflt="$libs";;
3851 esac
3852 case "$dflt" in
3853 ' '|'') dflt='none';;
3854 esac
3855
3856 $cat <<EOM
3857  
3858 Some versions of Unix support shared libraries, which make executables smaller
3859 but make load time slightly longer.
3860
3861 On some systems, mostly System V Release 3's, the shared library is included
3862 by putting the option "-lc_s" as the last thing on the cc command line when
3863 linking.  Other systems use shared libraries by default.  There may be other
3864 libraries needed to compile $package on your machine as well.  If your system
3865 needs the "-lc_s" option, include it here.  Include any other special libraries
3866 here as well.  Say "none" for none.
3867 EOM
3868
3869 echo " "
3870 rp="Any additional libraries?"
3871 . ./myread
3872 case "$ans" in
3873 none) libs=' ';;
3874 *) libs="$ans";;
3875 esac
3876
3877 : determine optimize, if desired, or use for debug flag also
3878 case "$optimize" in
3879 ' '|$undef) dflt='none';;
3880 '') dflt='-O';;
3881 *) dflt="$optimize";;
3882 esac
3883 $cat <<EOH
3884
3885 Some C compilers have problems with their optimizers.  By default, $package
3886 compiles with the -O flag to use the optimizer.  Alternately, you might want
3887 to use the symbolic debugger, which uses the -g flag (on traditional Unix
3888 systems).  Either flag can be specified here.  To use neither flag, specify
3889 the word "none".
3890
3891 EOH
3892 rp="What optimizer/debugger flag should be used?"
3893 . ./myread
3894 optimize="$ans"
3895 case "$optimize" in
3896 'none') optimize=" ";;
3897 esac
3898
3899 dflt=''
3900 : We will not override a previous value, but we might want to
3901 : augment a hint file
3902 case "$hint" in
3903 none|recommended)
3904         case "$gccversion" in
3905         1*) dflt='-fpcc-struct-return' ;;
3906         esac
3907         case "$optimize" in
3908         *-g*) dflt="$dflt -DDEBUGGING";;
3909         esac
3910         case "$gccversion" in
3911         2*) if test -d /etc/conf/kconfig.d &&
3912                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
3913                 then
3914                         dflt="$dflt -posix"
3915                 fi
3916                 ;;
3917         esac
3918         ;;
3919 esac
3920
3921 case "$mips_type" in
3922 *BSD*|'') inclwanted="$locincpth $usrinc";;
3923 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
3924 esac
3925 for thisincl in $inclwanted; do
3926         if $test -d $thisincl; then
3927                 if $test x$thisincl != x$usrinc; then
3928                         case "$dflt" in
3929                         *$thisincl*);;
3930                         *) dflt="$dflt -I$thisincl";;
3931                         esac
3932                 fi
3933         fi
3934 done
3935
3936 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
3937         xxx=true;
3938 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
3939         xxx=true;
3940 else
3941         xxx=false;
3942 fi;
3943 if $xxx; then
3944         case "$dflt" in
3945         *$2*);;
3946         *) dflt="$dflt -D$2";;
3947         esac;
3948 fi'
3949
3950 if ./osf1; then
3951         set signal.h __LANGUAGE_C__; eval $inctest
3952 else
3953         set signal.h LANGUAGE_C; eval $inctest
3954 fi
3955
3956 case "$hint" in
3957 none|recommended) dflt="$ccflags $dflt" ;;
3958 *) dflt="$ccflags";;
3959 esac
3960
3961 case "$dflt" in
3962 ''|' ') dflt=none;;
3963 esac
3964 $cat <<EOH
3965
3966 Your C compiler may want other flags.  For this question you should include
3967 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
3968 but you should NOT include libraries or ld flags like -lwhatever.  If you
3969 want $package to honor its debug switch, you should include -DDEBUGGING here.
3970 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE.
3971
3972 To use no flags, specify the word "none".
3973
3974 EOH
3975 set X $dflt
3976 shift
3977 dflt=${1+"$@"}
3978 rp="Any additional cc flags?"
3979 . ./myread
3980 case "$ans" in
3981 none) ccflags='';;
3982 *) ccflags="$ans";;
3983 esac
3984
3985 : the following weeds options from ccflags that are of no interest to cpp
3986 cppflags="$ccflags"
3987 case "$gccversion" in
3988 1*) cppflags="$cppflags -D__GNUC__"
3989 esac
3990 case "$mips_type" in
3991 '');;
3992 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
3993 esac
3994 case "$cppflags" in
3995 '');;
3996 *)
3997         echo " "
3998         echo "Let me guess what the preprocessor flags are..." >&4
3999         set X $cppflags
4000         shift
4001         cppflags=''
4002         $cat >cpp.c <<'EOM'
4003 #define BLURFL foo
4004
4005 BLURFL xx LFRULB
4006 EOM
4007         previous=''
4008         for flag in $*
4009         do
4010                 case "$flag" in
4011                 -*) ftry="$flag";;
4012                 *) ftry="$previous $flag";;
4013                 esac
4014                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
4015                         >cpp1.out 2>/dev/null && \
4016                         $cpprun -DLFRULB=bar $cppflags $ftry $cpplast <cpp.c \
4017                         >cpp2.out 2>/dev/null && \
4018                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
4019                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
4020                 then
4021                         cppflags="$cppflags $ftry"
4022                         previous=''
4023                 else
4024                         previous="$flag"
4025                 fi
4026         done
4027         set X $cppflags
4028         shift
4029         cppflags=${1+"$@"}
4030         case "$cppflags" in
4031         *-*)  echo "They appear to be: $cppflags";;
4032         esac
4033         $rm -f cpp.c cpp?.out
4034         ;;
4035 esac
4036
4037 : flags used in final linking phase
4038 case "$ldflags" in
4039 '') if ./venix; then
4040                 dflt='-i -z'
4041         else
4042                 dflt=''
4043         fi
4044         case "$ccflags" in
4045         *-posix*) dflt="$dflt -posix" ;;
4046         esac
4047         ;;
4048 *) dflt="$ldflags";;
4049 esac
4050
4051 : Try to guess additional flags to pick up local libraries.
4052 for thislibdir in $libpth; do
4053         case " $loclibpth " in
4054         *" $thislibdir "*)
4055                 case "$dflt " in 
4056                 *"-L$thislibdir "*) ;;
4057                 *)  dflt="$dflt -L$thislibdir" ;;
4058                 esac
4059                 ;;
4060         esac
4061 done
4062
4063 case "$dflt" in
4064 '') dflt='none' ;;
4065 esac
4066
4067 $cat <<EOH
4068
4069 Your C linker may need flags.  For this question you should
4070 include -L/whatever and any other flags used by the C linker, but you
4071 should NOT include libraries like -lwhatever.
4072
4073 Make sure you include the appropriate -L/path flags if your C linker
4074 does not normally search all of the directories you specified above,
4075 namely
4076         $libpth
4077 To use no flags, specify the word "none".
4078
4079 EOH
4080
4081 rp="Any additional ld flags (NOT including libraries)?"
4082 . ./myread
4083 case "$ans" in
4084 none) ldflags='';;
4085 *) ldflags="$ans";;
4086 esac
4087 rmlist="$rmlist pdp11"
4088
4089 : coherency check
4090 echo " "
4091 echo "Checking your choice of C compiler and flags for coherency..." >&4
4092 $cat > try.c <<'EOF'
4093 #include <stdio.h>
4094 main() { printf("Ok\n"); exit(0); }
4095 EOF
4096 set X $cc $optimize $ccflags -o try $ldflags try.c $libs
4097 shift
4098 $cat >try.msg <<'EOM'
4099 I've tried to compile and run the following simple program:
4100
4101 EOM
4102 $cat try.c >> try.msg
4103
4104 $cat >> try.msg <<EOM
4105
4106 I used the command:
4107
4108         $*
4109         ./try
4110
4111 and I got the following output:
4112
4113 EOM
4114 dflt=y
4115 if sh -c "$cc $optimize $ccflags -o try $ldflags try.c $libs" >>try.msg 2>&1; then
4116         if sh -c './try' >>try.msg 2>&1; then
4117                 xxx=`./try`
4118                 case "$xxx" in
4119                 "Ok") dflt=n ;;
4120                 *)      echo 'The program compiled OK, but produced no output.' >> try.msg
4121                         case " $libs " in
4122                         *" -lsfio "*)
4123                                 cat >> try.msg <<'EOQS'
4124 If $libs contains -lsfio, and sfio is mis-configured, then it
4125 sometimes (apparently) runs and exits with a 0 status, but with no
4126 output!  It may have to do with sfio's use of _exit vs. exit.
4127
4128 EOQS
4129                                 rp="You have a big problem.  Shall I abort Configure"
4130                                 dflt=y
4131                                 ;;
4132                         esac
4133                         ;;
4134                 esac
4135         else
4136                 echo "The program compiled OK, but exited with status $?." >>try.msg
4137                 rp="You have a problem.  Shall I abort Configure"
4138                 dflt=y
4139         fi
4140 else
4141         echo "I can't compile the test program." >>try.msg
4142         rp="You have a BIG problem.  Shall I abort Configure"
4143         dflt=y
4144 fi
4145 case "$dflt" in
4146 y)
4147         $cat try.msg >&4
4148         case "$knowitall" in
4149         '')
4150                 echo "(The supplied flags or libraries might be incorrect.)"
4151                 ;;
4152         *) dflt=n;;
4153         esac
4154         echo " "
4155         . ./myread
4156         case "$ans" in
4157         n*|N*) ;;
4158         *)      echo "Ok.  Stopping Configure." >&4
4159                 exit 1
4160                 ;;
4161         esac
4162         ;;
4163 n) echo "OK, that should do.";;
4164 esac
4165 $rm -f try try.* core
4166
4167 : determine filename position in cpp output
4168 echo " "
4169 echo "Computing filename position in cpp output for #include directives..." >&4
4170 echo '#include <stdio.h>' > foo.c
4171 $cat >fieldn <<EOF
4172 $startsh
4173 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4174 $grep '^[       ]*#.*stdio\.h' | \
4175 while read cline; do
4176         pos=1
4177         set \$cline
4178         while $test \$# -gt 0; do
4179                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4180                         echo "\$pos"
4181                         exit 0
4182                 fi
4183                 shift
4184                 pos=\`expr \$pos + 1\`
4185         done
4186 done
4187 EOF
4188 chmod +x fieldn
4189 fieldn=`./fieldn`
4190 $rm -f foo.c fieldn
4191 case $fieldn in
4192 '') pos='???';;
4193 1) pos=first;;
4194 2) pos=second;;
4195 3) pos=third;;
4196 *) pos="${fieldn}th";;
4197 esac
4198 echo "Your cpp writes the filename in the $pos field of the line."
4199
4200 : locate header file
4201 $cat >findhdr <<EOF
4202 $startsh
4203 wanted=\$1
4204 name=''
4205 if test -f $usrinc/\$wanted; then
4206         echo "$usrinc/\$wanted"
4207         exit 0
4208 fi
4209 awkprg='{ print \$$fieldn }'
4210 echo "#include <\$wanted>" > foo\$\$.c
4211 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4212 $grep "^[       ]*#.*\$wanted" | \
4213 while read cline; do
4214         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4215         case "\$name" in
4216         */\$wanted) echo "\$name"; exit 0;;
4217         *) name='';;
4218         esac;
4219 done;
4220 $rm -f foo\$\$.c;
4221 case "\$name" in
4222 '') exit 1;;
4223 esac
4224 EOF
4225 chmod +x findhdr
4226
4227 : define an alternate in-header-list? function
4228 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4229 cont=true; xxf="echo \"<\$1> found.\" >&4";
4230 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4231 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4232 esac;
4233 case $# in 4) instead=instead;; *) instead="at last";; esac;
4234 while $test "$cont"; do
4235         xxx=`./findhdr $1`
4236         var=$2; eval "was=\$$2";
4237         if $test "$xxx" && $test -r "$xxx";
4238         then eval $xxf;
4239         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4240                 cont="";
4241         else eval $xxnf;
4242         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4243         set $yyy; shift; shift; yyy=$@;
4244         case $# in 0) cont="";;
4245         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4246                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4247         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4248                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4249         esac;
4250 done;
4251 while $test "$yyy";
4252 do set $yyy; var=$2; eval "was=\$$2";
4253         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4254         set $yyy; shift; shift; yyy=$@;
4255 done'
4256
4257 : see if this is a malloc.h system
4258 set malloc.h i_malloc
4259 eval $inhdr
4260
4261 : see if stdlib is available
4262 set stdlib.h i_stdlib
4263 eval $inhdr
4264
4265 : determine which malloc to compile in
4266 echo " "
4267 case "$usemymalloc" in
4268 ''|[yY]*|true|$define)  dflt='y' ;;
4269 *)      dflt='n' ;;
4270 esac
4271 rp="Do you wish to attempt to use the malloc that comes with $package?"
4272 . ./myread
4273 usemymalloc="$ans"
4274 case "$ans" in
4275 y*|true)
4276         usemymalloc='y'
4277         mallocsrc='malloc.c'
4278         mallocobj="malloc$_o"
4279         d_mymalloc="$define"
4280         case "$libs" in
4281         *-lmalloc*)
4282                 : Remove malloc from list of libraries to use
4283                 echo "Removing unneeded -lmalloc from library list" >&4
4284                 set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
4285                 shift
4286                 libs="$*"
4287                 echo "libs = $libs" >&4
4288                 ;;
4289         esac
4290         ;;
4291 *)
4292         usemymalloc='n'
4293         mallocsrc=''
4294         mallocobj=''
4295         d_mymalloc="$undef"
4296         ;;
4297 esac
4298
4299 : compute the return types of malloc and free
4300 echo " "
4301 $cat >malloc.c <<END
4302 #$i_malloc I_MALLOC
4303 #$i_stdlib I_STDLIB
4304 #include <stdio.h>
4305 #include <sys/types.h>
4306 #ifdef I_MALLOC
4307 #include <malloc.h>
4308 #endif
4309 #ifdef I_STDLIB
4310 #include <stdlib.h>
4311 #endif
4312 #ifdef TRY_MALLOC
4313 void *malloc();
4314 #endif
4315 #ifdef TRY_FREE
4316 void free();
4317 #endif
4318 END
4319 case "$malloctype" in
4320 '')
4321         if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
4322                 malloctype='void *'
4323         else
4324                 malloctype='char *'
4325         fi
4326         ;;
4327 esac
4328 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
4329
4330 case "$freetype" in
4331 '')
4332         if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
4333                 freetype='void'
4334         else
4335                 freetype='int'
4336         fi
4337         ;;
4338 esac
4339 echo "Your system uses $freetype free(), it would seem." >&4
4340 $rm -f malloc.[co]
4341 : Cruising for prototypes
4342 echo " "
4343 echo "Checking out function prototypes..." >&4
4344 $cat >prototype.c <<'EOCP'
4345 int main(int argc, char *argv[]) {
4346         exit(0);}
4347 EOCP
4348 if $cc $ccflags -c prototype.c >prototype.out 2>&1 ; then
4349         echo "Your C compiler appears to support function prototypes."
4350         val="$define"
4351 else
4352         echo "Your C compiler doesn't seem to understand function prototypes."
4353         val="$undef"
4354 fi
4355 set prototype
4356 eval $setvar
4357 $rm -f prototype*
4358
4359 case "$prototype" in
4360 "$define") ;;
4361 *)      ansi2knr='ansi2knr'
4362         echo " "
4363         cat <<EOM >&4
4364
4365 $me:  FATAL ERROR:
4366 This version of $package can only be compiled by a compiler that 
4367 understands function prototypes.  Unfortunately, your C compiler 
4368         $cc $ccflags
4369 doesn't seem to understand them.  Sorry about that.
4370
4371 If GNU cc is available for your system, perhaps you could try that instead.  
4372
4373 Eventually, we hope to support building Perl with pre-ANSI compilers.
4374 If you would like to help in that effort, please contact <perlbug@perl.org>.
4375
4376 Aborting Configure now.
4377 EOM
4378         exit 2
4379         ;;
4380 esac
4381
4382 : determine where public executables go
4383 echo " "
4384 set dflt bin bin
4385 eval $prefixit
4386 fn=d~
4387 rp='Pathname where the public executables will reside?'
4388 . ./getfile
4389 if $test "X$ansexp" != "X$binexp"; then
4390         installbin=''
4391 fi
4392 bin="$ans"
4393 binexp="$ansexp"
4394 if $afs; then
4395         $cat <<EOM
4396
4397 Since you are running AFS, I need to distinguish the directory in which
4398 executables reside from the directory in which they are installed (and from
4399 which they are presumably copied to the former directory by occult means).
4400
4401 EOM
4402         case "$installbin" in
4403         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
4404         *) dflt="$installbin";;
4405         esac
4406         fn=de~
4407         rp='Where will public executables be installed?'
4408         . ./getfile
4409         installbin="$ans"
4410 else
4411         installbin="$binexp"
4412 fi
4413
4414 : define a shorthand compile call
4415 compile='
4416 mc_file=$1;
4417 shift;
4418 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs > /dev/null 2>&1;'
4419 : define a shorthand compile call for compilations that should be ok.
4420 compile_ok='
4421 mc_file=$1;
4422 shift;
4423 $cc $optimize $ccflags $ldflags -o ${mc_file} $* ${mc_file}.c $libs;'
4424
4425 echo " "
4426 echo "Checking for GNU C Library..." >&4
4427 cat >gnulibc.c <<EOM
4428 #include <stdio.h>
4429 int main()
4430 {
4431 #ifdef __GLIBC__
4432     exit(0);
4433 #else
4434     exit(1);
4435 #endif
4436 }
4437 EOM
4438 set gnulibc
4439 if eval $compile_ok && ./gnulibc; then
4440         val="$define"
4441         echo "You are using the GNU C Library"
4442 else
4443         val="$undef"
4444         echo "You are not using the GNU C Library"
4445 fi
4446 $rm -f gnulibc*
4447 set d_gnulibc
4448 eval $setvar
4449
4450 : see if nm is to be used to determine whether a symbol is defined or not
4451 case "$usenm" in
4452 '')
4453         dflt=''
4454         case "$d_gnulibc" in
4455         "$define")
4456                 echo " "
4457                 echo "nm probably won't work on the GNU C Library." >&4
4458                 dflt=n
4459                 ;;
4460         esac
4461         case "$dflt" in
4462         '') 
4463                 if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
4464                         echo " "
4465                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
4466                         echo "'nm' won't be sufficient on this sytem." >&4
4467                         dflt=n
4468                 fi
4469                 ;;
4470         esac
4471         case "$dflt" in
4472         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
4473                 if $test $dflt -gt 20; then
4474                         dflt=y
4475                 else
4476                         dflt=n
4477                 fi
4478                 ;;
4479         esac
4480         ;;
4481 *)
4482         case "$usenm" in
4483         true|$define) dflt=y;;
4484         *) dflt=n;;
4485         esac
4486         ;;
4487 esac
4488 $cat <<EOM
4489
4490 I can use $nm to extract the symbols from your C libraries. This
4491 is a time consuming task which may generate huge output on the disk (up
4492 to 3 megabytes) but that should make the symbols extraction faster. The
4493 alternative is to skip the 'nm' extraction part and to compile a small
4494 test program instead to determine whether each symbol is present. If
4495 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
4496 this may be the best solution.
4497
4498 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
4499
4500 EOM
4501 rp="Shall I use $nm to extract C symbols from the libraries?"
4502 . ./myread
4503 case "$ans" in
4504 [Nn]*) usenm=false;;
4505 *) usenm=true;;
4506 esac
4507
4508 runnm=$usenm
4509 case "$reuseval" in
4510 true) runnm=false;;
4511 esac
4512
4513 : nm options which may be necessary
4514 case "$nm_opt" in
4515 '') if $test -f /mach_boot; then
4516                 nm_opt=''       # Mach
4517         elif $test -d /usr/ccs/lib; then
4518                 nm_opt='-p'     # Solaris (and SunOS?)
4519         elif $test -f /dgux; then
4520                 nm_opt='-p'     # DG-UX
4521         elif $test -f /lib64/rld; then
4522                 nm_opt='-p'     # 64-bit Irix
4523         else
4524                 nm_opt=''
4525         fi;;
4526 esac
4527
4528 : nm options which may be necessary for shared libraries but illegal
4529 : for archive libraries.  Thank you, Linux.
4530 case "$nm_so_opt" in
4531 '')     case "$myuname" in
4532         *linux*)
4533                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
4534                         nm_so_opt='--dynamic'
4535                 fi
4536                 ;;
4537         esac
4538         ;;
4539 esac
4540
4541 case "$runnm" in
4542 true)
4543 : get list of predefined functions in a handy place
4544 echo " "
4545 case "$libc" in
4546 '') libc=unknown
4547         case "$libs" in
4548         *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
4549         esac
4550         ;;
4551 esac
4552 libnames='';
4553 case "$libs" in
4554 '') ;;
4555 *)  for thislib in $libs; do
4556         case "$thislib" in
4557         -lc|-lc_s)
4558                 : Handle C library specially below.
4559                 ;;
4560         -l*)
4561                 thislib=`echo $thislib | $sed -e 's/^-l//'`
4562                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
4563                         :
4564                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
4565                         :
4566                 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
4567                         :
4568                 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
4569                         :
4570                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
4571                         :
4572                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
4573                         :
4574                 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
4575                         :
4576                 else
4577                         try=''
4578                 fi
4579                 libnames="$libnames $try"
4580                 ;;
4581         *) libnames="$libnames $thislib" ;;
4582         esac
4583         done
4584         ;;
4585 esac
4586 xxx=normal
4587 case "$libc" in
4588 unknown)
4589         set /lib/libc.$so
4590         for xxx in $libpth; do
4591                 $test -r $1 || set $xxx/libc.$so
4592                 : The messy sed command sorts on library version numbers.
4593                 $test -r $1 || \
4594                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4595                         tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
4596                                 h
4597                                 s/[0-9][0-9]*/0000&/g
4598                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4599                                 G
4600                                 s/\n/ /' | \
4601                          sort | $sed -e 's/^.* //'`
4602                 eval set \$$#
4603         done
4604         $test -r $1 || set /usr/ccs/lib/libc.$so
4605         $test -r $1 || set /lib/libsys_s$_a
4606         ;;
4607 *)
4608         set blurfl
4609         ;;
4610 esac
4611 if $test -r "$1"; then
4612         echo "Your (shared) C library seems to be in $1."
4613         libc="$1"
4614 elif $test -r /lib/libc && $test -r /lib/clib; then
4615         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4616         xxx=apollo
4617         libc='/lib/clib /lib/libc'
4618         if $test -r /lib/syslib; then
4619                 echo "(Your math library is in /lib/syslib.)"
4620                 libc="$libc /lib/syslib"
4621         fi
4622 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4623         echo "Your C library seems to be in $libc, as you said before."
4624 elif $test -r $incpath/usr/lib/libc$_a; then
4625         libc=$incpath/usr/lib/libc$_a;
4626         echo "Your C library seems to be in $libc.  That's fine."
4627 elif $test -r /lib/libc$_a; then
4628         libc=/lib/libc$_a;
4629         echo "Your C library seems to be in $libc.  You're normal."
4630 else
4631         if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
4632                 :
4633         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4634                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4635         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4636                 :
4637         elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4638                 :
4639         elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
4640                 :
4641         else
4642                 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
4643         fi
4644         if $test -r "$tans"; then
4645                 echo "Your C library seems to be in $tans, of all places."
4646                 libc=$tans
4647         else
4648                 libc='blurfl'
4649         fi
4650 fi
4651 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4652         dflt="$libc"
4653         cat <<EOM
4654
4655 If the guess above is wrong (which it might be if you're using a strange
4656 compiler, or your machine supports multiple models), you can override it here.
4657
4658 EOM
4659 else
4660         dflt=''
4661         echo $libpth | tr ' ' $trnl | sort | uniq > libpath
4662         cat >&4 <<EOM
4663 I can't seem to find your C library.  I've looked in the following places:
4664
4665 EOM
4666         $sed 's/^/      /' libpath
4667         cat <<EOM
4668
4669 None of these seems to contain your C library. I need to get its name...
4670
4671 EOM
4672 fi
4673 fn=f
4674 rp='Where is your C library?'
4675 . ./getfile
4676 libc="$ans"
4677
4678 echo " "
4679 echo $libc $libnames | tr ' ' $trnl | sort | uniq > libnames
4680 set X `cat libnames`
4681 shift
4682 xxx=files
4683 case $# in 1) xxx=file; esac
4684 echo "Extracting names from the following $xxx for later perusal:" >&4
4685 echo " "
4686 $sed 's/^/      /' libnames >&4
4687 echo " "
4688 $echo $n "This may take a while...$c" >&4
4689
4690 for file in $*; do
4691         case $file in
4692         *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
4693         *) $nm $nm_opt $file 2>/dev/null;;
4694         esac
4695 done >libc.tmp
4696
4697 $echo $n ".$c"
4698 $grep fprintf libc.tmp > libc.ptf
4699 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4700 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4701 xxx='[ADTSIW]'
4702 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4703         eval $xscan;\
4704         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4705                 eval $xrun
4706 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4707         eval $xscan;\
4708         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4709                 eval $xrun
4710 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4711         eval $xscan;\
4712         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4713                 eval $xrun
4714 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4715         eval $xscan;\
4716         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4717                 eval $xrun
4718 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4719         eval $xscan;\
4720         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4721                 eval $xrun
4722 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4723         eval $xscan;\
4724         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4725                 eval $xrun
4726 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4727                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4728         eval $xscan;\
4729         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4730                 eval $xrun
4731 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4732         eval $xscan;\
4733         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4734                 eval $xrun
4735 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4736         eval $xscan;\
4737         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4738                 eval $xrun
4739 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4740         eval $xscan;\
4741         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4742                 eval $xrun
4743 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4744         eval $xscan;\
4745         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4746                 eval $xrun
4747 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4748         eval $xscan;\
4749         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4750                 eval $xrun
4751 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4752         eval $xscan;\
4753         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4754                 eval $xrun
4755 else
4756         $nm -p $* 2>/dev/null >libc.tmp
4757         $grep fprintf libc.tmp > libc.ptf
4758         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4759                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4760         then
4761                 nm_opt='-p'
4762                 eval $xrun
4763         else
4764                 echo " "
4765                 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
4766                 com=''
4767                 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
4768                         for thisname in $libnames $libc; do
4769                                 $ar t $thisname >>libc.tmp
4770                         done
4771                         $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
4772                         echo "Ok." >&4
4773                 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
4774                         # Repeat libc to extract forwarders to DLL entries too
4775                         for thisname in $libnames $libc; do
4776                                 $ar tv $thisname >>libc.tmp
4777                                 # Revision 50 of EMX has bug in $ar.
4778                                 # it will not extract forwarders to DLL entries
4779                                 # Use emximp which will extract exactly them.
4780                                 emximp -o tmp.imp $thisname \
4781                                     2>/dev/null && \
4782                                     $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
4783                                     < tmp.imp >>libc.tmp
4784                                 $rm tmp.imp
4785                         done
4786                         $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
4787                         echo "Ok." >&4
4788                 else
4789                         echo "$ar didn't seem to work right." >&4
4790                         echo "Maybe this is a Cray...trying bld instead..." >&4
4791                         if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
4792                         then
4793                                 for thisname in $libnames; do
4794                                         bld t $libnames | \
4795                                         $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
4796                                         $ar t $thisname >>libc.tmp
4797                                 done
4798                                 echo "Ok." >&4
4799                         else
4800                                 echo "That didn't work either.  Giving up." >&4
4801                                 exit 1
4802                         fi
4803                 fi
4804         fi
4805 fi
4806 nm_extract="$com"
4807 if $test -f /lib/syscalls.exp; then
4808         echo " "
4809         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
4810         $sed -n 's/^\([^        ]*\)[   ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
4811 fi
4812 ;;
4813 esac
4814 $rm -f libnames libpath
4815
4816 : see if dld is available
4817 set dld.h i_dld
4818 eval $inhdr
4819
4820 : is a C symbol defined?
4821 csym='tlook=$1;
4822 case "$3" in
4823 -v) tf=libc.tmp; tc=""; tdc="";;
4824 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
4825 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
4826 esac;
4827 tx=yes;
4828 case "$reuseval-$4" in
4829 true-) ;;
4830 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
4831 esac;
4832 case "$tx" in
4833 yes)
4834         case "$runnm" in
4835         true)
4836                 if $contains $tlook $tf >/dev/null 2>&1;
4837                 then tval=true;
4838                 else tval=false;
4839                 fi;;
4840         *)
4841                 echo "main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
4842                 if $cc $optimize $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
4843                 then tval=true;
4844                 else tval=false;
4845                 fi;
4846                 $rm -f t t.c;;
4847         esac;;
4848 *)
4849         case "$tval" in
4850         $define) tval=true;;
4851         *) tval=false;;
4852         esac;;
4853 esac;
4854 eval "$2=$tval"'
4855
4856 : define an is-in-libc? function
4857 inlibc='echo " "; td=$define; tu=$undef;
4858 sym=$1; var=$2; eval "was=\$$2";
4859 tx=yes;
4860 case "$reuseval$was" in
4861 true) ;;
4862 true*) tx=no;;
4863 esac;
4864 case "$tx" in
4865 yes)
4866         set $sym tres -f;
4867         eval $csym;
4868         case "$tres" in
4869         true)
4870                 echo "$sym() found." >&4;
4871                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
4872         *)
4873                 echo "$sym() NOT found." >&4;
4874                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
4875         esac;;
4876 *)
4877         case "$was" in
4878         $define) echo "$sym() found." >&4;;
4879         *) echo "$sym() NOT found." >&4;;
4880         esac;;
4881 esac'
4882
4883 : see if dlopen exists
4884 xxx_runnm="$runnm"
4885 runnm=false
4886 set dlopen d_dlopen
4887 eval $inlibc
4888 runnm="$xxx_runnm"
4889
4890 : determine which dynamic loading, if any, to compile in
4891 echo " "
4892 dldir="ext/DynaLoader"
4893 case "$usedl" in
4894 $define|y|true)
4895         dflt='y'
4896         usedl="$define"
4897         ;;
4898 $undef|n|false)
4899         dflt='n'
4900         usedl="$undef"
4901         ;;
4902 *) 
4903         dflt='n'
4904         case "$d_dlopen" in
4905             $define) dflt='y' ;;
4906         esac
4907         case "$i_dld" in
4908             $define) dflt='y' ;;
4909         esac
4910         : Does a dl_xxx.xs file exist for this operating system
4911         $test -f $rsrc/$dldir/dl_${osname}.xs && dflt='y'
4912         ;;
4913 esac
4914 rp="Do you wish to use dynamic loading?"
4915 . ./myread
4916 usedl="$ans"
4917 case "$ans" in
4918 y*) usedl="$define"
4919         case "$dlsrc" in
4920         '')
4921                 if $test -f $rsrc/$dldir/dl_${osname}.xs ; then
4922                         dflt="$dldir/dl_${osname}.xs"
4923                 elif $test "$d_dlopen" = "$define" ; then
4924                         dflt="$dldir/dl_dlopen.xs"
4925                 elif $test "$i_dld" = "$define" ; then
4926                         dflt="$dldir/dl_dld.xs"
4927                 else
4928                         dflt=''
4929                 fi
4930                 ;;
4931         *)      dflt="$dldir/$dlsrc"
4932                 ;;
4933         esac
4934     echo "The following dynamic loading files are available:"
4935         : Can not go over to $dldir because getfile has path hard-coded in.
4936         tdir=`pwd`; cd $rsrc; $ls -C $dldir/dl*.xs; cd $tdir
4937         rp="Source file to use for dynamic loading"
4938         fn="fne"
4939         # XXX This getfile call will fail the existence check if you try 
4940         # building away from $src (this is not supported yet).
4941         . ./getfile
4942         usedl="$define"
4943         : emulate basename
4944         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
4945
4946         $cat << EOM
4947
4948 Some systems may require passing special flags to $cc -c to
4949 compile modules that will be used to create a shared library.
4950 To use no flags, say "none".
4951
4952 EOM
4953     case "$cccdlflags" in
4954     '') case "$gccversion" in
4955                 '') case "$osname" in
4956                         hpux)   dflt='+z' ;;
4957                         next)   dflt='none' ;;
4958                         irix*)  dflt='-KPIC' ;;
4959                         svr4*|esix*|solaris) dflt='-KPIC' ;;
4960                         sunos)  dflt='-pic' ;;
4961                         *)      dflt='none' ;;
4962                     esac
4963                         ;;
4964                 *)  case "$osname" in
4965                         svr4*|esix*|solaris) dflt='-fPIC' ;;
4966                         *)      dflt='-fpic' ;;
4967                     esac ;;
4968             esac ;;
4969         ' ') dflt='none' ;;
4970     *)  dflt="$cccdlflags" ;;
4971     esac
4972     rp="Any special flags to pass to $cc -c to compile shared library modules?"
4973     . ./myread
4974     case "$ans" in
4975     none) cccdlflags=' ' ;;
4976     *) cccdlflags="$ans" ;;
4977     esac
4978
4979     cat << EOM
4980
4981 Some systems use ld to create libraries that can be dynamically loaded,
4982 while other systems (such as those using ELF) use $cc.
4983
4984 EOM
4985         case "$ld" in
4986         '')     $cat >try.c <<'EOM'
4987 /* Test for whether ELF binaries are produced */
4988 #include <fcntl.h>
4989 #include <stdlib.h>
4990 int main() {
4991         char b[4];
4992         int i = open("a.out",O_RDONLY);
4993         if(i == -1) 
4994                 exit(1); /* fail */
4995         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
4996                 exit(0); /* succeed (yes, it's ELF) */
4997         else
4998                 exit(1); /* fail */
4999 }
5000 EOM
5001                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
5002                         cat <<EOM
5003 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
5004 EOM
5005                         dflt="$cc"
5006                 else
5007                         echo "I'll use ld to build dynamic libraries."
5008                         dflt='ld'
5009                 fi
5010                 rm -f try.c a.out
5011                 ;;
5012         *)      dflt="$ld"
5013                 ;;
5014         esac
5015
5016     rp="What command should be used to create dynamic libraries?"
5017     . ./myread
5018         ld="$ans"
5019
5020     cat << EOM
5021
5022 Some systems may require passing special flags to $ld to create a
5023 library that can be dynamically loaded.  If your ld flags include
5024 -L/other/path options to locate libraries outside your loader's normal
5025 search path, you may need to specify those -L options here as well.  To
5026 use no flags, say "none".
5027
5028 EOM
5029     case "$lddlflags" in
5030     '') case "$osname" in
5031                         hpux)  dflt='-b' ;;
5032                         linux|irix*)    dflt='-shared' ;;
5033                         next)  dflt='none' ;;
5034                         solaris) dflt='-G' ;;
5035                         sunos) dflt='-assert nodefinitions' ;;
5036                         svr4*|esix*) dflt="-G $ldflags" ;;
5037                 *)     dflt='none' ;;
5038                         esac
5039                         ;;
5040     *) dflt="$lddlflags" ;;
5041     esac
5042
5043         : Try to guess additional flags to pick up local libraries.
5044         : Be careful not to append to a plain 'none'
5045         case "$dflt" in
5046         none) dflt='' ;;
5047         esac
5048         for thisflag in $ldflags; do
5049                 case "$thisflag" in
5050                 -L*)
5051                         case " $dflt " in
5052                         *" $thisflag "*) ;;
5053                         *) dflt="$dflt $thisflag" ;;
5054                         esac
5055                         ;;
5056                 esac
5057         done
5058
5059         case "$dflt" in
5060         ''|' ') dflt='none' ;;
5061         esac
5062
5063     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
5064     . ./myread
5065     case "$ans" in
5066     none) lddlflags=' ' ;;
5067     *) lddlflags="$ans" ;;
5068     esac
5069
5070         cat <<EOM
5071
5072 Some systems may require passing special flags to $cc to indicate that
5073 the resulting executable will use dynamic linking.  To use no flags,
5074 say "none".
5075
5076 EOM
5077     case "$ccdlflags" in
5078     '') case "$osname" in
5079                 hpux)   dflt='-Wl,-E' ;;
5080                 linux)  dflt='-rdynamic' ;;
5081                 next)   dflt='none' ;;
5082                 sunos)  dflt='none' ;;
5083                 *)      dflt='none' ;;
5084             esac ;;
5085     ' ')  dflt='none' ;;
5086     *)  dflt="$ccdlflags" ;;
5087     esac
5088     rp="Any special flags to pass to $cc to use dynamic loading?"
5089     . ./myread
5090     case "$ans" in
5091     none) ccdlflags=' ' ;;
5092     *) ccdlflags="$ans" ;;
5093     esac
5094     ;;
5095 *)  usedl="$undef"
5096         ld='ld'
5097     dlsrc='dl_none.xs'
5098     lddlflags=''
5099     ccdlflags=''
5100     ;;
5101 esac
5102
5103 also=''
5104 case "$usedl" in
5105 $undef)
5106         # No dynamic loading being used, so don't bother even to prompt.
5107         useshrplib='false'
5108         ;;
5109 *)      case "$useshrplib" in
5110         '')     case "$osname" in
5111                 svr4*|dgux|dynixptx|esix|powerux)
5112                         dflt=y
5113                         also='Building a shared libperl is required for dynamic loading to work on your system.'
5114                         ;;
5115                 next*)
5116                         case "$osvers" in
5117                         4*)     dflt=y
5118                                 also='Building a shared libperl is needed for MAB support.'
5119                                 ;;
5120                         *)      dflt=n
5121                                 ;;
5122                         esac
5123                         ;;
5124                 *)      dflt=n
5125                         ;;
5126                 esac
5127                 ;;
5128         $define|true|[Yy]*)
5129                 dflt=y
5130                 ;;
5131         *)      dflt=n
5132                 ;;
5133         esac
5134         $cat << EOM
5135
5136 The perl executable is normally obtained by linking perlmain.c with
5137 libperl${_a}, any static extensions (usually just DynaLoader), and
5138 any other libraries needed on this system (such as -lm, etc.).  Since
5139 your system supports dynamic loading, it is probably possible to build
5140 a shared libperl.$so.  If you will have more than one executable linked
5141 to libperl.$so, this will significantly reduce the size of each
5142 executable, but it may have a noticeable affect on performance.  The
5143 default is probably sensible for your system.
5144 $also
5145
5146 EOM
5147         rp="Build a shared libperl.$so (y/n)"
5148         . ./myread
5149         case "$ans" in
5150         true|$define|[Yy]*)
5151                 useshrplib='true'
5152                 # Why does next4 have to be so different?
5153                 case "${osname}${osvers}" in
5154                 next4*) xxx='DYLD_LIBRARY_PATH' ;;
5155                 os2*)   xxx='' ;; # Nothing special needed.
5156                 *)              xxx='LD_LIBRARY_PATH' ;;
5157                 esac
5158                 if test X"$xxx" != "X"; then
5159                         $cat <<EOM  | $tee -a ../config.msg >&4
5160
5161 To build perl, you must add the current working directory to your
5162 $xxx environment variable before running make.  You can do
5163 this with
5164    $xxx=\`pwd\`:\$$xxx; export $xxx
5165 for Bourne-style shells, or
5166    setenv $xxx \`pwd\`
5167 for Csh-style shells.  You *MUST* do this before running make.
5168
5169 EOM
5170                 fi
5171                 ;;
5172         *)      useshrplib='false' ;;
5173         esac
5174         ;;
5175 esac
5176
5177 case "$useshrplib" in
5178 true)
5179         case "$libperl" in
5180         '')
5181                 # Figure out a good name for libperl.so.  Since it gets stored in
5182                 # a version-specific architecture-dependent library, the version
5183                 # number isn't really that important, except for making cc/ld happy.
5184                 #
5185                 # A name such as libperl.so.3.1
5186                 majmin="libperl.$so.$patchlevel.$subversion"
5187                 # A name such as libperl.so.301
5188                 majonly=`echo $patchlevel $subversion |
5189                         $awk '{printf "%d%02d", $1, $2}'`
5190                 majonly=libperl.$so.$majonly
5191                 # I'd prefer to keep the os-specific stuff here to a minimum, and
5192                 # rely on figuring it out from the naming of libc.
5193                 case "${osname}${osvers}" in
5194                 next4*)
5195                         dflt=libperl.5.$so
5196                         # XXX How handle the --version stuff for MAB?
5197                         ;;
5198                 linux*)  # ld won't link with a bare -lperl otherwise.
5199                         dflt=libperl.$so
5200                         ;;
5201                 *)      # Try to guess based on whether libc has major.minor.
5202                         case "$libc" in
5203                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
5204                         *libc.$so.[0-9]*) dflt=$majonly ;;
5205                         *)      dflt=libperl.$so ;;
5206                         esac
5207                         ;;
5208                 esac
5209                 ;;
5210         *)      dflt=$libperl
5211                 ;;
5212         esac
5213         cat << EOM
5214
5215 I need to select a good name for the shared libperl.  If your system uses
5216 library names with major and minor numbers, then you might want something
5217 like $majmin.  Alternatively, if your system uses a single version
5218 number for shared libraries, then you might want to use $majonly.
5219 Or, your system might be quite happy with a simple libperl.$so.
5220
5221 Since the shared libperl will get installed into a version-specific
5222 architecture-dependent directory, the version number of the shared perl
5223 library probably isn't important, so the default should be o.k.
5224
5225 EOM
5226         rp='What name do you want to give to the shared libperl?'
5227         . ./myread
5228         libperl=$ans
5229         echo "Ok, I'll use $libperl"
5230         ;;
5231 *)
5232         libperl="libperl${_a}"
5233         ;;
5234 esac
5235
5236 # Detect old use of shrpdir via undocumented Configure -Dshrpdir
5237 case "$shrpdir" in
5238 '') ;;
5239 *)      $cat >&4 <<EOM
5240 WARNING:  Use of the shrpdir variable for the installation location of
5241 the shared $libperl is not supported.  It was never documented and
5242 will not work in this version.  Let me (jhi@iki.fi)
5243 know of any problems this may cause.
5244
5245 EOM
5246         case "$shrpdir" in
5247         "$archlibexp/CORE")
5248                 $cat >&4 <<EOM
5249 But your current setting of $shrpdir is
5250 the default anyway, so it's harmless.
5251 EOM
5252                 ;;
5253         *)
5254                 $cat >&4 <<EOM
5255 Further, your current attempted setting of $shrpdir
5256 conflicts with the value of $archlibexp/CORE
5257 that installperl will use.
5258 EOM
5259                 ;;
5260         esac
5261         ;;
5262 esac
5263
5264 # How will the perl executable find the installed shared $libperl?
5265 # Add $xxx to ccdlflags.
5266 # If we can't figure out a command-line option, use $shrpenv to
5267 # set env LD_RUN_PATH.  The main perl makefile uses this.
5268 shrpdir=$archlibexp/CORE
5269 xxx=''
5270 tmp_shrpenv=''
5271 if "$useshrplib"; then
5272     case "$osname" in 
5273         aix)
5274                 # We'll set it in Makefile.SH...
5275                 ;;
5276         solaris|netbsd)
5277                 xxx="-R $shrpdir"
5278                 ;;
5279         freebsd)
5280                 xxx="-Wl,-R$shrpdir"
5281                 ;;
5282         linux|irix*|dec_osf)
5283                 xxx="-Wl,-rpath,$shrpdir"
5284                 ;;
5285         next)
5286                 # next doesn't like the default...
5287                 ;;
5288         *)
5289                 tmp_shrpenv="env LD_RUN_PATH=$shrpdir"
5290                 ;;
5291         esac
5292         case "$xxx" in
5293         '') ;;
5294         *)      
5295                 # Only add $xxx if it isn't already in ccdlflags.
5296                 case " $ccdlflags " in
5297                 *" $xxx "*)     ;;
5298                 *)      ccdlflags="$ccdlflags $xxx"
5299                         cat <<EOM >&4
5300
5301 Adding $xxx to the flags
5302 passed to $ld so that the perl executable will find the 
5303 installed shared $libperl.
5304
5305 EOM
5306                         ;;
5307                 esac
5308                 ;;
5309         esac
5310 fi
5311 # Respect a hint or command-line value.
5312 case "$shrpenv" in
5313 '') shrpenv="$tmp_shrpenv" ;;
5314 esac
5315
5316 : determine where manual pages go
5317 set man1dir man1dir none
5318 eval $prefixit
5319 $cat <<EOM
5320
5321 $spackage has manual pages available in source form.
5322 EOM
5323 case "$nroff" in
5324 nroff)
5325         echo "However, you don't have nroff, so they're probably useless to you."
5326         case "$man1dir" in
5327         '') man1dir="none";;
5328         esac;;
5329 esac
5330 echo "If you don't want the manual sources installed, answer 'none'."
5331 case "$man1dir" in
5332 ' ') dflt=none
5333         ;;
5334 '')
5335         lookpath="$prefixexp/man/man1 $prefixexp/man/l_man/man1"
5336         lookpath="$lookpath $prefixexp/man/p_man/man1"
5337         lookpath="$lookpath $prefixexp/man/u_man/man1"
5338         lookpath="$lookpath $prefixexp/man/man.1"
5339         case "$sysman" in
5340         */?_man*)       dflt=`./loc . $prefixexp/l_man/man1 $lookpath` ;;
5341         *)      dflt=`./loc . $prefixexp/man/man1 $lookpath` ;;
5342         esac
5343         set dflt
5344         eval $prefixup
5345         ;;
5346 *)  dflt="$man1dir"
5347         ;;
5348 esac
5349 echo " "
5350 fn=dn+~
5351 rp="Where do the main $spackage manual pages (source) go?"
5352 . ./getfile
5353 if $test "X$man1direxp" != "X$ansexp"; then
5354         installman1dir=''
5355 fi
5356 man1dir="$ans"
5357 man1direxp="$ansexp"
5358 case "$man1dir" in
5359 '') man1dir=' '
5360         installman1dir='';;
5361 esac
5362 if $afs; then
5363         $cat <<EOM
5364
5365 Since you are running AFS, I need to distinguish the directory in which
5366 manual pages reside from the directory in which they are installed (and from
5367 which they are presumably copied to the former directory by occult means).
5368
5369 EOM
5370         case "$installman1dir" in
5371         '') dflt=`echo $man1direxp | sed 's#^/afs/#/afs/.#'`;;
5372         *) dflt="$installman1dir";;
5373         esac
5374         fn=de~
5375         rp='Where will man pages be installed?'
5376         . ./getfile
5377         installman1dir="$ans"
5378 else
5379         installman1dir="$man1direxp"
5380 fi
5381
5382 : What suffix to use on installed man pages
5383
5384 case "$man1dir" in
5385 ' ')
5386         man1ext='0'
5387         ;;
5388 *)
5389         rp="What suffix should be used for the main $spackage man pages?"
5390         case "$man1ext" in
5391         '')     case "$man1dir" in
5392                 *1)  dflt=1 ;;
5393                 *1p) dflt=1p ;;
5394                 *1pm) dflt=1pm ;;
5395                 *l) dflt=l;;
5396                 *n) dflt=n;;
5397                 *o) dflt=o;;
5398                 *p) dflt=p;;
5399                 *C) dflt=C;;
5400                 *L) dflt=L;;
5401                 *L1) dflt=L1;;
5402                 *) dflt=1;;
5403                 esac
5404                 ;;
5405         *)      dflt="$man1ext";;
5406         esac
5407         . ./myread
5408         man1ext="$ans"
5409         ;;
5410 esac
5411
5412 : see if we can have long filenames
5413 echo " "
5414 rmlist="$rmlist /tmp/cf$$"
5415 $test -d /tmp/cf$$ || mkdir /tmp/cf$$
5416 first=123456789abcdef
5417 second=/tmp/cf$$/$first
5418 $rm -f $first $second
5419 if (echo hi >$first) 2>/dev/null; then
5420         if $test -f 123456789abcde; then
5421                 echo 'You cannot have filenames longer than 14 characters.  Sigh.' >&4
5422                 val="$undef"
5423         else
5424                 if (echo hi >$second) 2>/dev/null; then
5425                         if $test -f /tmp/cf$$/123456789abcde; then
5426                                 $cat <<'EOM'
5427 That's peculiar... You can have filenames longer than 14 characters, but only
5428 on some of the filesystems.  Maybe you are using NFS.  Anyway, to avoid problems
5429 I shall consider your system cannot support long filenames at all.
5430 EOM
5431                                 val="$undef"
5432                         else
5433                                 echo 'You can have filenames longer than 14 characters.' >&4
5434                                 val="$define"
5435                         fi
5436                 else
5437                         $cat <<'EOM'
5438 How confusing! Some of your filesystems are sane enough to allow filenames
5439 longer than 14 characters but some others like /tmp can't even think about them.
5440 So, for now on, I shall assume your kernel does not allow them at all.
5441 EOM
5442                         val="$undef"
5443                 fi
5444         fi
5445 else
5446         $cat <<'EOM'
5447 You can't have filenames longer than 14 chars.  You can't even think about them!
5448 EOM
5449         val="$undef"
5450 fi 
5451 set d_flexfnam
5452 eval $setvar
5453 $rm -rf /tmp/cf$$ 123456789abcde*
5454
5455 : determine where library module manual pages go
5456 set man3dir man3dir none
5457 eval $prefixit
5458 $cat <<EOM
5459
5460 $spackage has manual pages for many of the library modules.
5461 EOM
5462
5463 case "$nroff" in
5464 nroff)
5465         $cat <<'EOM'
5466 However, you don't have nroff, so they're probably useless to you.
5467 EOM
5468         case "$man3dir" in
5469         '') man3dir="none";;
5470         esac;;
5471 esac
5472
5473 case "$d_flexfnam" in
5474 undef)
5475         $cat <<'EOM'
5476 However, your system can't handle the long file names like File::Basename.3. 
5477 EOM
5478         case "$man3dir" in
5479         '') man3dir="none";;
5480         esac;;
5481 esac
5482
5483 echo "If you don't want the manual sources installed, answer 'none'."
5484 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5485 case "$man3dir" in
5486 '')     case "$prefix" in 
5487         *$prog*) dflt=`echo $man1dir | 
5488                         $sed -e 's/man1/man3/g' -e 's/man\.1/man\.3/g'` ;;
5489         *)      dflt="$privlib/man/man3" ;;
5490         esac
5491         ;;
5492 ' ') dflt=none;;
5493 *)      dflt="$man3dir" ;;
5494 esac
5495 echo " "
5496
5497 fn=dn+~
5498 rp="Where do the $package library man pages (source) go?"
5499 . ./getfile
5500 if test "X$man3direxp" != "X$ansexp"; then
5501         installman3dir=''
5502 fi
5503
5504 man3dir="$ans"
5505 man3direxp="$ansexp"
5506 case "$man3dir" in
5507 '') man3dir=' '
5508         installman3dir='';;
5509 esac
5510 if $afs; then
5511         $cat <<EOM
5512
5513 Since you are running AFS, I need to distinguish the directory in which
5514 manual pages reside from the directory in which they are installed (and from
5515 which they are presumably copied to the former directory by occult means).
5516
5517 EOM
5518         case "$installman3dir" in
5519         '') dflt=`echo $man3direxp | sed 's#^/afs/#/afs/.#'`;;
5520         *) dflt="$installman3dir";;
5521         esac
5522         fn=de~
5523         rp='Where will man pages be installed?'
5524         . ./getfile
5525         installman3dir="$ans"
5526 else
5527         installman3dir="$man3direxp"
5528 fi
5529
5530 : What suffix to use on installed man pages
5531
5532 case "$man3dir" in
5533 ' ')
5534         man3ext='0'
5535         ;;
5536 *)
5537         rp="What suffix should be used for the $package library man pages?"
5538         case "$man3ext" in
5539         '')     case "$man3dir" in
5540                 *3)  dflt=3 ;;
5541                 *3p) dflt=3p ;;
5542                 *3pm) dflt=3pm ;;
5543                 *l) dflt=l;;
5544                 *n) dflt=n;;
5545                 *o) dflt=o;;
5546                 *p) dflt=p;;
5547                 *C) dflt=C;;
5548                 *L) dflt=L;;
5549                 *L3) dflt=L3;;
5550                 *) dflt=3;;
5551                 esac
5552                 ;;
5553         *)      dflt="$man3ext";;
5554         esac
5555         . ./myread
5556         man3ext="$ans"
5557         ;;
5558 esac
5559
5560 : see if we have to deal with yellow pages, now NIS.
5561 if $test -d /usr/etc/yp || $test -d /etc/yp; then
5562         if $test -f /usr/etc/nibindd; then
5563                 echo " "
5564                 echo "I'm fairly confident you're on a NeXT."
5565                 echo " "
5566                 rp='Do you get the hosts file via NetInfo?'
5567                 dflt=y
5568                 case "$hostcat" in
5569                 nidump*) ;;
5570                 '') ;;
5571                 *) dflt=n;;
5572                 esac
5573                 . ./myread
5574                 case "$ans" in
5575                 y*) hostcat='nidump hosts .';;
5576                 *)      case "$hostcat" in
5577                         nidump*) hostcat='';;
5578                         esac
5579                         ;;
5580                 esac
5581         fi
5582         case "$hostcat" in
5583         nidump*) ;;
5584         *)
5585                 case "$hostcat" in
5586                 *ypcat*) dflt=y;;
5587                 '') if $contains '^\+' /etc/passwd >/dev/null 2>&1; then
5588                                 dflt=y
5589                         else
5590                                 dflt=n
5591                         fi;;
5592                 *) dflt=n;;
5593                 esac
5594                 echo " "
5595                 rp='Are you getting the hosts file via yellow pages?'
5596                 . ./myread
5597                 case "$ans" in
5598                 y*) hostcat='ypcat hosts';;
5599                 *) hostcat='cat /etc/hosts';;
5600                 esac
5601                 ;;
5602         esac
5603 fi
5604 case "$hostcat" in
5605 '') hostcat='cat /etc/hosts';;
5606 esac
5607 case "$groupcat" in
5608 '') groupcat='cat /etc/group';;
5609 esac
5610 case "$passcat" in
5611 '') passcat='cat /etc/passwd';;
5612 esac
5613
5614 : now get the host name
5615 echo " "
5616 echo "Figuring out host name..." >&4
5617 case "$myhostname" in
5618 '') cont=true
5619         echo 'Maybe "hostname" will work...'
5620         if tans=`sh -c hostname 2>&1` ; then
5621                 myhostname=$tans
5622                 phostname=hostname
5623                 cont=''
5624         fi
5625         ;;
5626 *) cont='';;
5627 esac
5628 if $test "$cont"; then
5629         if ./xenix; then
5630                 echo 'Oh, dear.  Maybe "/etc/systemid" is the key...'
5631                 if tans=`cat /etc/systemid 2>&1` ; then
5632                         myhostname=$tans
5633                         phostname='cat /etc/systemid'
5634                         echo "Whadyaknow.  Xenix always was a bit strange..."
5635                         cont=''
5636                 fi
5637         elif $test -r /etc/systemid; then
5638                 echo "(What is a non-Xenix system doing with /etc/systemid?)"
5639         fi
5640 fi
5641 if $test "$cont"; then
5642         echo 'No, maybe "uuname -l" will work...'
5643         if tans=`sh -c 'uuname -l' 2>&1` ; then
5644                 myhostname=$tans
5645                 phostname='uuname -l'
5646         else
5647                 echo 'Strange.  Maybe "uname -n" will work...'
5648                 if tans=`sh -c 'uname -n' 2>&1` ; then
5649                         myhostname=$tans
5650                         phostname='uname -n'
5651                 else
5652                         echo 'Oh well, maybe I can mine it out of whoami.h...'
5653                         if tans=`sh -c $contains' sysname $usrinc/whoami.h' 2>&1` ; then
5654                                 myhostname=`echo "$tans" | $sed 's/^.*"\(.*\)"/\1/'`
5655                                 phostname="sed -n -e '"'/sysname/s/^.*\"\\(.*\\)\"/\1/{'"' -e p -e q -e '}' <$usrinc/whoami.h"
5656                         else
5657                                 case "$myhostname" in
5658                                 '') echo "Does this machine have an identity crisis or something?"
5659                                         phostname='';;
5660                                 *)
5661                                         echo "Well, you said $myhostname before..."
5662                                         phostname='echo $myhostname';;
5663                                 esac
5664                         fi
5665                 fi
5666         fi
5667 fi
5668 : you do not want to know about this
5669 set $myhostname
5670 myhostname=$1
5671
5672 : verify guess
5673 if $test "$myhostname" ; then
5674         dflt=y
5675         rp='Your host name appears to be "'$myhostname'".'" Right?"
5676         . ./myread
5677         case "$ans" in
5678         y*) ;;
5679         *) myhostname='';;
5680         esac
5681 fi
5682
5683 : bad guess or no guess
5684 while $test "X$myhostname" = X ; do
5685         dflt=''
5686         rp="Please type the (one word) name of your host:"
5687         . ./myread
5688         myhostname="$ans"
5689 done
5690
5691 : translate upper to lower if necessary
5692 case "$myhostname" in
5693 *[A-Z]*)
5694         echo "(Normalizing case in your host name)"
5695         myhostname=`echo $myhostname | ./tr '[A-Z]' '[a-z]'`
5696         ;;
5697 esac
5698
5699 case "$myhostname" in
5700 *.*)
5701         dflt=`expr "X$myhostname" : "X[^.]*\(\..*\)"`
5702         myhostname=`expr "X$myhostname" : "X\([^.]*\)\."`
5703         echo "(Trimming domain name from host name--host name is now $myhostname)"
5704         ;;
5705 *) case "$mydomain" in
5706         '')
5707                 {
5708                         test "X$hostcat" = "Xypcat hosts" &&
5709                         ypmatch "$myhostname" hosts 2>/dev/null |\
5710                                 $sed -e 's/[     ]*#.*//; s/$/ /' > hosts && \
5711                         $test -s hosts
5712                 } || {
5713                         $hostcat | $sed -n -e "s/[       ]*#.*//; s/\$/ /
5714                                         /[       ]$myhostname[  . ]/p" > hosts
5715                 }
5716                 tmp_re="[       . ]"
5717                 $test x`$awk "/[0-9].*[  ]$myhostname$tmp_re/ { sum++ }
5718                              END { print sum }" hosts` = x1 || tmp_re="[         ]"
5719                 dflt=.`$awk "/[0-9].*[   ]$myhostname$tmp_re/ {for(i=2; i<=NF;i++) print \\\$i}" \
5720                         hosts | $sort | $uniq | \
5721                         $sed -n -e "s/$myhostname\.\([-a-zA-Z0-9_.]\)/\1/p"`
5722                 case `$echo X$dflt` in
5723                 X*\ *)  echo "(Several hosts in /etc/hosts matched hostname)"
5724                         dflt=.
5725                         ;;
5726                 X.) echo "(You do not have fully-qualified names in /etc/hosts)"
5727                         ;;
5728                 esac
5729                 case "$dflt" in
5730                 .)
5731                         tans=`./loc resolv.conf X /etc /usr/etc`
5732                         if $test -f "$tans"; then
5733                                 echo "(Attempting domain name extraction from $tans)"
5734                                 dflt=.`$sed -n -e 's/   / /g' \
5735                                   -e 's/^search  *\([^ ]*\).*/\1/p' $tans \
5736                                   | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5737                                 case "$dflt" in
5738                                 .) dflt=.`$sed -n -e 's/        / /g' \
5739                                      -e 's/^domain  *\([^ ]*\).*/\1/p' $tans \
5740                                      | ./tr '[A-Z]' '[a-z]' 2>/dev/null`
5741                                         ;;
5742                                 esac
5743                         fi
5744                         ;;
5745                 esac
5746                 case "$dflt" in
5747                 .) echo "(No help from resolv.conf either -- attempting clever guess)"
5748                         dflt=.`sh -c domainname 2>/dev/null`
5749                         case "$dflt" in
5750                         '') dflt='.';;
5751                         .nis.*|.yp.*|.main.*) dflt=`echo $dflt | $sed -e 's/^\.[^.]*//'`;;
5752                         esac
5753                         ;;
5754                 esac
5755                 case "$dflt" in
5756                 .) echo "(Lost all hope -- silly guess then)"
5757                         dflt='.uucp'
5758                         ;;
5759                 esac
5760                 $rm -f hosts
5761                 ;;
5762         *) dflt="$mydomain";;
5763         esac;;
5764 esac
5765 echo " "
5766 rp="What is your domain name?"
5767 . ./myread
5768 tans="$ans"
5769 case "$ans" in
5770 '') ;;
5771 .*) ;;
5772 *) tans=".$tans";;
5773 esac
5774 mydomain="$tans"
5775
5776 : translate upper to lower if necessary
5777 case "$mydomain" in
5778 *[A-Z]*)
5779         echo "(Normalizing case in your domain name)"
5780         mydomain=`echo $mydomain | ./tr '[A-Z]' '[a-z]'`
5781         ;;
5782 esac
5783
5784 : a little sanity check here
5785 case "$phostname" in
5786 '') ;;
5787 *)
5788         case `$phostname | ./tr '[A-Z]' '[a-z]'` in
5789         $myhostname$mydomain|$myhostname) ;;
5790         *)
5791                 case "$phostname" in
5792                 sed*)
5793                         echo "(That doesn't agree with your whoami.h file, by the way.)"
5794                         ;;
5795                 *)
5796                         echo "(That doesn't agree with your $phostname command, by the way.)"
5797                         ;;
5798                 esac
5799         ;;
5800         esac
5801         ;;
5802 esac
5803
5804 $cat <<EOM
5805
5806 I need to get your e-mail address in Internet format if possible, i.e.
5807 something like user@host.domain. Please answer accurately since I have
5808 no easy means to double check it. The default value provided below
5809 is most probably close to the reality but may not be valid from outside
5810 your organization...
5811
5812 EOM
5813 cont=x
5814 while test "$cont"; do
5815         case "$cf_email" in
5816         '') dflt="$cf_by@$myhostname$mydomain";;
5817         *) dflt="$cf_email";;
5818         esac
5819         rp='What is your e-mail address?'
5820         . ./myread
5821         cf_email="$ans"
5822         case "$cf_email" in
5823         *@*.*) cont='' ;;
5824         *)
5825                 rp='Address does not look like an Internet one.  Use it anyway?'
5826                 case "$fastread" in
5827                 yes) dflt=y ;;
5828                 *) dflt=n ;;
5829                 esac
5830                 . ./myread
5831                 case "$ans" in
5832                 y*) cont='' ;;
5833                 *) echo " " ;;
5834                 esac
5835                 ;;
5836         esac
5837 done
5838
5839 $cat <<EOM
5840
5841 If you or somebody else will be maintaining perl at your site, please
5842 fill in the correct e-mail address here so that they may be contacted
5843 if necessary. Currently, the "perlbug" program included with perl
5844 will send mail to this address in addition to perlbug@perl.com. You may
5845 enter "none" for no administrator.
5846
5847 EOM
5848 case "$perladmin" in
5849 '') dflt="$cf_email";;
5850 *) dflt="$perladmin";;
5851 esac
5852 rp='Perl administrator e-mail address'
5853 . ./myread
5854 perladmin="$ans"
5855
5856 : figure out how to guarantee perl startup
5857 case "$startperl" in
5858 '')
5859         case "$sharpbang" in
5860         *!)
5861                 $cat <<EOH
5862
5863 I can use the #! construct to start perl on your system. This will
5864 make startup of perl scripts faster, but may cause problems if you
5865 want to share those scripts and perl is not in a standard place
5866 ($binexp/perl) on all your platforms. The alternative is to force
5867 a shell by starting the script with a single ':' character.
5868
5869 EOH
5870                 dflt="$binexp/perl"
5871                 rp='What shall I put after the #! to start up perl ("none" to not use #!)?'
5872                 . ./myread
5873                 case "$ans" in
5874                 none)   startperl=": # use perl";;
5875                 *)      startperl="#!$ans"
5876                         if $test 30 -lt `echo "$ans" | wc -c`; then
5877                                 $cat >&4 <<EOM
5878
5879 WARNING:  Some systems limit the #! command to 32 characters.
5880 If you experience difficulty running Perl scripts with #!, try
5881 installing Perl in a directory with a shorter pathname.
5882
5883 EOM
5884                         fi ;;
5885                 esac
5886                 ;;
5887         *) startperl=": # use perl"
5888                 ;;
5889         esac
5890         ;;
5891 esac
5892 echo "I'll use $startperl to start perl scripts."
5893
5894 : figure best path for perl in scripts
5895 case "$perlpath" in
5896 '')
5897         perlpath="$binexp/perl"
5898         case "$startperl" in
5899         *!*) ;;
5900         *)
5901                 $cat <<EOH
5902
5903 I will use the "eval 'exec'" idiom to start Perl on your system.
5904 I can use the full path of your Perl binary for this purpose, but
5905 doing so may cause problems if you want to share those scripts and
5906 Perl is not always in a standard place ($binexp/perl).
5907
5908 EOH
5909                 dflt="$binexp/perl"
5910                 rp="What path shall I use in \"eval 'exec'\"?"
5911                 . ./myread
5912                 perlpath="$ans"
5913                 ;;
5914         esac
5915         ;;
5916 esac
5917 case "$startperl" in
5918 *!*)    ;;
5919 *)      echo "I'll use $perlpath in \"eval 'exec'\"" ;;
5920 esac
5921
5922 : determine where public executable scripts go
5923 set scriptdir scriptdir
5924 eval $prefixit
5925 case "$scriptdir" in
5926 '')
5927         dflt="$bin"
5928         : guess some guesses
5929         $test -d /usr/share/scripts && dflt=/usr/share/scripts
5930         $test -d /usr/share/bin && dflt=/usr/share/bin
5931         $test -d /usr/local/script && dflt=/usr/local/script
5932         $test -d $prefixexp/script && dflt=$prefixexp/script
5933         set dflt
5934         eval $prefixup
5935         ;;
5936 *)  dflt="$scriptdir"
5937         ;;
5938 esac
5939 $cat <<EOM
5940  
5941 Some installations have a separate directory just for executable scripts so
5942 that they can mount it across multiple architectures but keep the scripts in
5943 one spot.  You might, for example, have a subdirectory of /usr/share for this.
5944 Or you might just lump your scripts in with all your other executables.
5945  
5946 EOM
5947 fn=d~
5948 rp='Where do you keep publicly executable scripts?'
5949 . ./getfile
5950 if $test "X$ansexp" != "X$scriptdirexp"; then
5951         installscript=''
5952 fi
5953 scriptdir="$ans"
5954 scriptdirexp="$ansexp"
5955 if $afs; then
5956         $cat <<EOM
5957
5958 Since you are running AFS, I need to distinguish the directory in which
5959 scripts reside from the directory in which they are installed (and from
5960 which they are presumably copied to the former directory by occult means).
5961
5962 EOM
5963         case "$installscript" in
5964         '') dflt=`echo $scriptdirexp | sed 's#^/afs/#/afs/.#'`;;
5965         *) dflt="$installscript";;
5966         esac
5967         fn=de~
5968         rp='Where will public scripts be installed?'
5969         . ./getfile
5970         installscript="$ans"
5971 else
5972         installscript="$scriptdirexp"
5973 fi
5974
5975 : determine where site specific libraries go.
5976 : Usual default is /usr/local/lib/perl5/site_perl/$apiversion
5977 prog=`echo $package | $sed 's/-*[0-9.]*$//'`
5978 case "$prefix" in
5979 *perl*) set dflt sitelib lib/site_$prog/$apiversion ;;
5980 *)       set dflt sitelib lib/$package/site_$prog/$apiversion ;;
5981 esac
5982 eval $prefixit
5983 $cat <<EOM
5984
5985 The installation process will also create a directory for
5986 site-specific extensions and modules.  Some users find it convenient
5987 to place all local files in this directory rather than in the main
5988 distribution directory.
5989
5990 EOM
5991 fn=d~+
5992 rp='Pathname for the site-specific library files?'
5993 . ./getfile
5994 if $test "X$sitelibexp" != "X$ansexp"; then
5995         installsitelib=''
5996 fi
5997 sitelib="$ans"
5998 sitelibexp="$ansexp"
5999 if $afs; then
6000         $cat <<EOM
6001
6002 Since you are running AFS, I need to distinguish the directory in
6003 which site-specific files reside from the directory in which they are
6004 installed (and from which they are presumably copied to the former
6005 directory by occult means).
6006
6007 EOM
6008         case "$installsitelib" in
6009         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
6010         *) dflt="$installsitelib";;
6011         esac
6012         fn=de~
6013         rp='Where will site-specific files be installed?'
6014         . ./getfile
6015         installsitelib="$ans"
6016 else
6017         installsitelib="$sitelibexp"
6018 fi
6019
6020 : determine where site specific architecture-dependent libraries go.
6021 : sitelib  default is /usr/local/lib/perl5/site_perl/$apiversion
6022 : sitearch default is /usr/local/lib/perl5/site_perl/$apiversion/$archname
6023 : sitelib may have an optional trailing /share.
6024 tdflt=`echo $sitelib | $sed 's,/share$,,'`
6025 tdflt="$tdflt/$archname"
6026 set sitearch sitearch none
6027 eval $prefixit
6028 case "$sitearch" in
6029 '')     dflt="$tdflt" ;;
6030 *)      dflt="$sitearch" ;;
6031 esac
6032 $cat <<EOM
6033
6034 The installation process will also create a directory for
6035 architecture-dependent site-specific extensions and modules.
6036
6037 EOM
6038 fn=nd~+
6039 rp='Pathname for the site-specific architecture-dependent library files?'
6040 . ./getfile
6041 if $test "X$sitearchexp" != "X$ansexp"; then
6042         installsitearch=''
6043 fi
6044 sitearch="$ans"
6045 sitearchexp="$ansexp"
6046 if $afs; then
6047         $cat <<EOM
6048
6049 Since you are running AFS, I need to distinguish the directory in
6050 which site-specific architecture-dependent library files reside from
6051 the directory in which they are installed (and from which they are
6052 presumably copied to the former directory by occult means).
6053
6054 EOM
6055         case "$installsitearch" in
6056         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
6057         *) dflt="$installsitearch";;
6058         esac
6059         fn=de~
6060         rp='Where will site-specific architecture-dependent files be installed?'
6061         . ./getfile
6062         installsitearch="$ans"
6063 else
6064         installsitearch="$sitearchexp"
6065 fi
6066
6067 cat <<EOM
6068
6069 Previous version of $package used the standard IO mechanisms as defined
6070 in <stdio.h>.  Versions 5.003_02 and later of perl allow alternate IO
6071 mechanisms via a "PerlIO" abstraction, but the stdio mechanism is still
6072 the default.  This abstraction layer can use AT&T's sfio (if you already
6073 have sfio installed) or regular stdio.  Using PerlIO with sfio may cause
6074 problems with some extension modules.  Using PerlIO with stdio is safe,
6075 but it is slower than plain stdio and therefore is not the default.
6076
6077 If this doesn't make any sense to you, just accept the default 'n'.
6078 EOM
6079 case "$useperlio" in
6080 $define|true|[yY]*)     dflt='y';;
6081 *) dflt='n';;
6082 esac
6083 rp='Use the experimental PerlIO abstraction layer?'
6084 . ./myread
6085 case "$ans" in
6086 y|Y) 
6087         val="$define"
6088         ;;     
6089 *)      
6090         echo "Ok, doing things the stdio way"
6091         val="$undef"
6092         ;;
6093 esac
6094 set useperlio
6095 eval $setvar 
6096
6097 : Check how to convert floats to strings.
6098 if test "X$d_Gconvert" = X; then
6099         echo " "
6100         echo "Checking for an efficient way to convert floats to strings."
6101         $cat >try.c <<'EOP'
6102 #ifdef TRY_gconvert
6103 #define Gconvert(x,n,t,b) gconvert((x),(n),(t),(b))
6104 char *myname = "gconvert";
6105 #endif
6106 #ifdef TRY_gcvt
6107 #define Gconvert(x,n,t,b) gcvt((x),(n),(b))
6108 char *myname = "gcvt";
6109 #endif
6110 #ifdef TRY_sprintf
6111 #define Gconvert(x,n,t,b) sprintf((b),"%.*g",(n),(x))
6112 char *myname = "sprintf";
6113 #endif
6114
6115 #include <stdio.h>
6116
6117 int
6118 checkit(expect, got)
6119 char *expect;
6120 char *got;
6121 {
6122     if (strcmp(expect, got)) {
6123                 printf("%s oddity:  Expected %s, got %s\n",
6124                         myname, expect, got);
6125                 exit(1);
6126         }
6127 }
6128
6129 int main()
6130
6131         char buf[64]; 
6132         buf[63] = '\0';
6133
6134         /* This must be 1st test on (which?) platform */
6135         /* Alan Burlison <AlanBurlsin@unn.unisys.com> */
6136         Gconvert(0.1, 8, 0, buf);
6137         checkit("0.1", buf);
6138
6139         Gconvert(1.0, 8, 0, buf); 
6140         checkit("1", buf);
6141
6142         Gconvert(0.0, 8, 0, buf); 
6143         checkit("0", buf);
6144
6145         Gconvert(-1.0, 8, 0, buf); 
6146         checkit("-1", buf);
6147
6148         /* Some Linux gcvt's give 1.e+5 here. */
6149         Gconvert(100000.0, 8, 0, buf); 
6150         checkit("100000", buf);
6151         
6152         /* Some Linux gcvt's give -1.e+5 here. */
6153         Gconvert(-100000.0, 8, 0, buf); 
6154         checkit("-100000", buf);
6155
6156         exit(0);
6157 }
6158 EOP
6159         case "$d_Gconvert" in
6160         gconvert*) xxx_list='gconvert gcvt sprintf' ;;
6161         gcvt*) xxx_list='gcvt gconvert sprintf' ;;
6162         sprintf*) xxx_list='sprintf gconvert gcvt' ;;
6163         *) xxx_list='gconvert gcvt sprintf' ;;
6164         esac
6165
6166         for xxx_convert in $xxx_list; do
6167                 echo "Trying $xxx_convert"
6168                 $rm -f try try$_o
6169                 set try -DTRY_$xxx_convert
6170                 if eval $compile; then
6171                         echo "$xxx_convert" found. >&4
6172                         if ./try; then
6173                                 echo "I'll use $xxx_convert to convert floats into a string." >&4
6174                                 break;
6175                         else
6176                                 echo "...But $xxx_convert didn't work as I expected."
6177                         fi
6178                 else
6179                         echo "$xxx_convert NOT found." >&4
6180                 fi
6181         done
6182                 
6183         case "$xxx_convert" in
6184         gconvert) d_Gconvert='gconvert((x),(n),(t),(b))' ;;
6185         gcvt) d_Gconvert='gcvt((x),(n),(b))' ;;
6186         *) d_Gconvert='sprintf((b),"%.*g",(n),(x))' ;;
6187         esac
6188 fi
6189
6190 : Initialize h_fcntl
6191 h_fcntl=false
6192
6193 : Initialize h_sysfile
6194 h_sysfile=false
6195
6196 : access call always available on UNIX
6197 set access d_access
6198 eval $inlibc
6199
6200 : locate the flags for 'access()'
6201 case "$d_access" in
6202 "$define")
6203         echo " "
6204         $cat >access.c <<'EOCP'
6205 #include <sys/types.h>
6206 #ifdef I_FCNTL
6207 #include <fcntl.h>
6208 #endif
6209 #ifdef I_SYS_FILE
6210 #include <sys/file.h>
6211 #endif
6212 #ifdef I_UNISTD
6213 #include <unistd.h>
6214 #endif
6215 main() {
6216         exit(R_OK);
6217 }
6218 EOCP
6219         : check sys/file.h first, no particular reason here
6220         if $test `./findhdr sys/file.h` && \
6221                 $cc $cppflags -DI_SYS_FILE -o access access.c >/dev/null 2>&1 ; then
6222                 h_sysfile=true;
6223                 echo "<sys/file.h> defines the *_OK access constants." >&4
6224         elif $test `./findhdr fcntl.h` && \
6225                 $cc $cppflags -DI_FCNTL -o access access.c >/dev/null 2>&1 ; then
6226                 h_fcntl=true;
6227                 echo "<fcntl.h> defines the *_OK access constants." >&4
6228         elif $test `./findhdr unistd.h` && \
6229                 $cc $cppflags -DI_UNISTD -o access access.c >/dev/null 2>&1 ; then
6230                 echo "<unistd.h> defines the *_OK access constants." >&4
6231         else
6232                 echo "I can't find the four *_OK access constants--I'll use mine." >&4
6233         fi
6234         ;;
6235 esac
6236 $rm -f access*
6237
6238 : see if accessx exists
6239 set accessx d_accessx
6240 eval $inlibc
6241
6242 : see if alarm exists
6243 set alarm d_alarm
6244 eval $inlibc
6245
6246 : Look for GNU-cc style attribute checking
6247 echo " "
6248 echo "Checking whether your compiler can handle __attribute__ ..." >&4
6249 $cat >attrib.c <<'EOCP'
6250 #include <stdio.h>
6251 void croak (char* pat,...) __attribute__((format(printf,1,2),noreturn));
6252 EOCP
6253 if $cc $ccflags -c attrib.c >attrib.out 2>&1 ; then
6254         if $contains 'warning' attrib.out >/dev/null 2>&1; then
6255                 echo "Your C compiler doesn't fully support __attribute__."
6256                 val="$undef"
6257         else
6258                 echo "Your C compiler supports __attribute__."
6259                 val="$define"
6260         fi
6261 else
6262         echo "Your C compiler doesn't seem to understand __attribute__ at all."
6263         val="$undef"
6264 fi
6265 set d_attribut
6266 eval $setvar
6267 $rm -f attrib*
6268
6269 : see if bcmp exists
6270 set bcmp d_bcmp
6271 eval $inlibc
6272
6273 : see if bcopy exists
6274 set bcopy d_bcopy
6275 eval $inlibc
6276
6277 : see if this is a unistd.h system
6278 set unistd.h i_unistd
6279 eval $inhdr
6280
6281 : see if getpgrp exists
6282 set getpgrp d_getpgrp
6283 eval $inlibc
6284
6285 case "$d_getpgrp" in
6286 "$define")
6287         echo " "
6288         echo "Checking to see which flavor of getpgrp is in use..."
6289         $cat >set.c <<EOP
6290 #$i_unistd I_UNISTD
6291 #include <sys/types.h>
6292 #ifdef I_UNISTD
6293 #  include <unistd.h>
6294 #endif
6295 int main()
6296 {
6297         if (getuid() == 0) {
6298                 printf("(I see you are running Configure as super-user...)\n");
6299                 setuid(1);
6300         }
6301 #ifdef TRY_BSD_PGRP
6302         if (getpgrp(1) == 0)
6303                 exit(0);
6304 #else
6305         if (getpgrp() > 0)
6306                 exit(0);
6307 #endif
6308         exit(1);
6309 }
6310 EOP
6311         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6312                 echo "You have to use getpgrp(pid) instead of getpgrp()." >&4
6313                 val="$define"
6314         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6315                 echo "You have to use getpgrp() instead of getpgrp(pid)." >&4
6316                 val="$undef"
6317         else
6318                 echo "I can't seem to compile and run the test program."
6319                 if ./usg; then
6320                         xxx="a USG one, i.e. you use getpgrp()."
6321                 else
6322                         # SVR4 systems can appear rather BSD-ish.
6323                         case "$i_unistd" in
6324                         $undef)
6325                                 xxx="a BSD one, i.e. you use getpgrp(pid)."
6326                                 val="$define"
6327                                 ;;
6328                         $define)
6329                                 xxx="probably a USG one, i.e. you use getpgrp()."
6330                                 val="$undef"
6331                                 ;;
6332                         esac
6333                 fi
6334                 echo "Assuming your getpgrp is $xxx" >&4
6335         fi
6336         ;;
6337 *) val="$undef";;
6338 esac
6339 set d_bsdgetpgrp
6340 eval $setvar
6341 $rm -f set set.c
6342
6343 : see if setpgrp exists
6344 set setpgrp d_setpgrp
6345 eval $inlibc
6346
6347 case "$d_setpgrp" in
6348 "$define")
6349         echo " "
6350         echo "Checking to see which flavor of setpgrp is in use..."
6351         $cat >set.c <<EOP
6352 #$i_unistd I_UNISTD
6353 #include <sys/types.h>
6354 #ifdef I_UNISTD
6355 #  include <unistd.h>
6356 #endif
6357 int main()
6358 {
6359         if (getuid() == 0) {
6360                 printf("(I see you are running Configure as super-user...)\n");
6361                 setuid(1);
6362         }
6363 #ifdef TRY_BSD_PGRP
6364         if (-1 == setpgrp(1, 1))
6365                 exit(0);
6366 #else
6367         if (setpgrp() != -1)
6368                 exit(0);
6369 #endif
6370         exit(1);
6371 }
6372 EOP
6373         if $cc -DTRY_BSD_PGRP $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6374                 echo 'You have to use setpgrp(pid,pgrp) instead of setpgrp().' >&4
6375                 val="$define"
6376         elif $cc $ccflags $ldflags -o set set.c $libs >/dev/null 2>&1 && ./set; then
6377                 echo 'You have to use setpgrp() instead of setpgrp(pid,pgrp).' >&4
6378                 val="$undef"
6379         else
6380                 echo "(I can't seem to compile and run the test program.)"
6381                 if ./usg; then
6382                         xxx="a USG one, i.e. you use setpgrp()."
6383                 else
6384                         # SVR4 systems can appear rather BSD-ish.
6385                         case "$i_unistd" in
6386                         $undef)
6387                                 xxx="a BSD one, i.e. you use setpgrp(pid,pgrp)."
6388                                 val="$define"
6389                                 ;;
6390                         $define)
6391                                 xxx="probably a USG one, i.e. you use setpgrp()."
6392                                 val="$undef"
6393                                 ;;
6394                         esac
6395                 fi
6396                 echo "Assuming your setpgrp is $xxx" >&4
6397         fi
6398         ;;
6399 *) val="$undef";;
6400 esac
6401 set d_bsdsetpgrp
6402 eval $setvar
6403 $rm -f set set.c
6404 : see if bzero exists
6405 set bzero d_bzero
6406 eval $inlibc
6407
6408 : check for lengths of integral types
6409 echo " "
6410 case "$intsize" in
6411 '')
6412         echo "Checking to see how big your integers are..." >&4
6413         $cat >intsize.c <<'EOCP'
6414 #include <stdio.h>
6415 main()
6416 {
6417         printf("intsize=%d;\n", sizeof(int));
6418         printf("longsize=%d;\n", sizeof(long));
6419         printf("shortsize=%d;\n", sizeof(short));
6420         exit(0);
6421 }
6422 EOCP
6423         set intsize
6424         if eval $compile_ok && ./intsize > /dev/null; then
6425                 eval `./intsize`
6426                 echo "Your integers are $intsize bytes long."
6427                 echo "Your long integers are $longsize bytes long."
6428                 echo "Your short integers are $shortsize bytes long."
6429         else
6430                 $cat >&4 <<EOM
6431 !
6432 Help! I can't compile and run the intsize test program: please enlighten me!
6433 (This is probably a misconfiguration in your system or libraries, and
6434 you really ought to fix it.  Still, I'll try anyway.)
6435 !
6436 EOM
6437                 dflt=4
6438                 rp="What is the size of an integer (in bytes)?"
6439                 . ./myread
6440                 intsize="$ans"
6441                 dflt=$intsize
6442                 rp="What is the size of a long integer (in bytes)?"
6443                 . ./myread
6444                 longsize="$ans"
6445                 dflt=2
6446                 rp="What is the size of a short integer (in bytes)?"
6447                 . ./myread
6448                 shortsize="$ans"
6449         fi
6450         ;;
6451 esac
6452 $rm -f intsize intsize.*
6453
6454 : see if signal is declared as pointer to function returning int or void
6455 echo " "
6456 xxx=`./findhdr signal.h`
6457 $test "$xxx" && $cppstdin $cppminus $cppflags < $xxx >$$.tmp 2>/dev/null
6458 if $contains 'int.*\*[  ]*signal' $$.tmp >/dev/null 2>&1 ; then
6459         echo "You have int (*signal())() instead of void." >&4
6460         val="$undef"
6461 elif $contains 'void.*\*[       ]*signal' $$.tmp >/dev/null 2>&1 ; then
6462         echo "You have void (*signal())()." >&4
6463         val="$define"
6464 elif $contains 'extern[         ]*[(\*]*signal' $$.tmp >/dev/null 2>&1 ; then
6465         echo "You have int (*signal())() instead of void." >&4
6466         val="$undef"
6467 elif $contains 'void.*\*.*sig' $$.tmp >/dev/null 2>&1 ; then
6468         echo "You have void (*signal())()." >&4
6469         val="$define"
6470 else
6471         case "$d_voidsig" in
6472         '')
6473         echo "I can't determine whether signal handler returns void or int..." >&4
6474                 dflt=void
6475                 rp="What type does your signal handler return?"
6476                 . ./myread
6477                 case "$ans" in
6478                 v*) val="$define";;
6479                 *) val="$undef";;
6480                 esac;;
6481         "$define")
6482                 echo "As you already told me, signal handler returns void." >&4
6483                 val="$define"
6484                 ;;
6485         *)      echo "As you already told me, signal handler returns int." >&4
6486                 val="$undef"
6487                 ;;
6488         esac
6489 fi
6490 set d_voidsig
6491 eval $setvar
6492 case "$d_voidsig" in
6493 "$define") signal_t="void";;
6494 *) signal_t="int";;
6495 esac
6496 $rm -f $$.tmp
6497
6498 : check for ability to cast large floats to 32-bit ints.
6499 echo " "
6500 echo 'Checking whether your C compiler can cast large floats to int32.' >&4
6501 if $test "$intsize" -ge 4; then
6502         xxx=int
6503 else
6504         xxx=long
6505 fi
6506 $cat >try.c <<EOCP
6507 #include <stdio.h>
6508 #include <sys/types.h>
6509 #include <signal.h>
6510 $signal_t blech(s) int s; { exit(3); }
6511 main()
6512 {
6513         $xxx i32;
6514         double f, g;
6515         int result = 0;
6516         char str[16];
6517         signal(SIGFPE, blech);
6518
6519         /* Don't let compiler optimize the test away.  Store the number 
6520            in a writable string for gcc to pass to sscanf under HP/UX.
6521         */
6522         sprintf(str, "2147483647");
6523         sscanf(str, "%lf", &f); /* f = (double) 0x7fffffff; */
6524         g = 10 * f;
6525         i32  = ($xxx) g;
6526
6527         /* x86 processors will probably give 0x8000 0000, which is a
6528        sign change.  We don't want that.  We want to mimic SPARC
6529            behavior here, which is to preserve the sign and give
6530            back 0x7fff ffff.
6531         */
6532         if (i32 != ($xxx) f)
6533                 result |= 1;
6534         exit(result);
6535 }
6536 EOCP
6537 set try
6538 if eval $compile_ok; then
6539         ./try
6540         yyy=$?
6541 else
6542         echo "(I can't seem to compile the test program--assuming it can't)"
6543         yyy=1
6544 fi
6545 case "$yyy" in
6546 0)      val="$define"
6547         echo "Yup, it can."
6548         ;;
6549 *)      val="$undef"
6550         echo "Nope, it can't."
6551         ;;
6552 esac
6553 set d_casti32
6554 eval $setvar
6555 $rm -f try try.*
6556
6557 : check for ability to cast negative floats to unsigned
6558 echo " "
6559 echo 'Checking whether your C compiler can cast negative float to unsigned.' >&4
6560 $cat >try.c <<EOCP
6561 #include <stdio.h>
6562 #include <sys/types.h>
6563 #include <signal.h>
6564 $signal_t blech(s) int s; { exit(7); }
6565 $signal_t blech_in_list(s) int s; { exit(4); }
6566 unsigned long dummy_long(p) unsigned long p; { return p; }
6567 unsigned int dummy_int(p) unsigned int p; { return p; }
6568 unsigned short dummy_short(p) unsigned short p; { return p; }
6569 main()
6570 {
6571         double f;
6572         unsigned long along;
6573         unsigned int aint;
6574         unsigned short ashort;
6575         int result = 0;
6576         char str[16];
6577         
6578         /* Frustrate gcc-2.7.2's optimizer which failed this test with
6579            a direct f = -123. assignment.  gcc-2.8.0 reportedly
6580            optimized the whole file away
6581         */
6582         /* Store the number in a writable string for gcc to pass to 
6583            sscanf under HP/UX.
6584         */
6585         sprintf(str, "-123");
6586         sscanf(str, "%lf", &f);  /* f = -123.; */
6587
6588         signal(SIGFPE, blech);
6589         along = (unsigned long)f;
6590         aint = (unsigned int)f;
6591         ashort = (unsigned short)f;
6592         if (along != (unsigned long)-123)
6593                 result |= 1;
6594         if (aint != (unsigned int)-123)
6595                 result |= 1;
6596         if (ashort != (unsigned short)-123)
6597                 result |= 1;
6598         sprintf(str, "1073741824.");
6599         sscanf(str, "%lf", &f); /* f = (double)0x40000000; */
6600         f = f + f;
6601         along = 0;
6602         along = (unsigned long)f;
6603         if (along != 0x80000000)
6604                 result |= 2;
6605         f -= 1.;
6606         along = 0;
6607         along = (unsigned long)f;
6608         if (along != 0x7fffffff)
6609                 result |= 1;
6610         f += 2.;
6611         along = 0;
6612         along = (unsigned long)f;
6613         if (along != 0x80000001)
6614                 result |= 2;
6615         if (result)
6616                 exit(result);
6617         signal(SIGFPE, blech_in_list);
6618         sprintf(str, "123.");
6619         sscanf(str, "%lf", &f);  /* f = 123.; */
6620         along = dummy_long((unsigned long)f);
6621         aint = dummy_int((unsigned int)f);
6622         ashort = dummy_short((unsigned short)f);
6623         if (along != (unsigned long)123)
6624                 result |= 4;
6625         if (aint != (unsigned int)123)
6626                 result |= 4;
6627         if (ashort != (unsigned short)123)
6628                 result |= 4;
6629         exit(result);
6630
6631 }
6632 EOCP
6633 set try
6634 if eval $compile_ok; then
6635         ./try
6636         castflags=$?
6637 else
6638         echo "(I can't seem to compile the test program--assuming it can't)"
6639         castflags=7
6640 fi
6641 case "$castflags" in
6642 0)      val="$define"
6643         echo "Yup, it can."
6644         ;;
6645 *)      val="$undef"
6646         echo "Nope, it can't."
6647         ;;
6648 esac
6649 set d_castneg
6650 eval $setvar
6651 $rm -f try.*
6652
6653 : see if vprintf exists
6654 echo " "
6655 if set vprintf val -f d_vprintf; eval $csym; $val; then
6656         echo 'vprintf() found.' >&4
6657         val="$define"
6658         $cat >vprintf.c <<'EOF'
6659 #include <varargs.h>
6660
6661 main() { xxx("foo"); }
6662
6663 xxx(va_alist)
6664 va_dcl
6665 {
6666         va_list args;
6667         char buf[10];
6668
6669         va_start(args);
6670         exit((unsigned long)vsprintf(buf,"%s",args) > 10L);
6671 }
6672 EOF
6673         set vprintf
6674         if eval $compile && ./vprintf; then
6675                 echo "Your vsprintf() returns (int)." >&4
6676                 val2="$undef"
6677         else
6678                 echo "Your vsprintf() returns (char*)." >&4
6679                 val2="$define"
6680         fi
6681 else
6682         echo 'vprintf() NOT found.' >&4
6683                 val="$undef"
6684                 val2="$undef"
6685 fi
6686 set d_vprintf
6687 eval $setvar
6688 val=$val2
6689 set d_charvspr
6690 eval $setvar
6691
6692 : see if chown exists
6693 set chown d_chown
6694 eval $inlibc
6695
6696 : see if chroot exists
6697 set chroot d_chroot
6698 eval $inlibc
6699
6700 : see if chsize exists
6701 set chsize d_chsize
6702 eval $inlibc
6703
6704 hasfield='varname=$1; struct=$2; field=$3; shift; shift; shift;
6705 while $test $# -ge 2; do
6706         case "$1" in
6707         $define) echo "#include <$2>";;
6708         esac ;
6709     shift 2;
6710 done > try.c;
6711 echo "int main () { struct $struct foo; foo.$field = 0; }" >> try.c;
6712 if eval $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
6713         val="$define";
6714 else
6715         val="$undef";
6716 fi;
6717 set $varname;
6718 eval $setvar;
6719 $rm -f try.c try.o'
6720
6721 : see if this is a sys/uio.h system
6722 set sys/uio.h i_sysuio
6723 eval $inhdr
6724
6725 echo "Checking to see if your system supports struct iovec..." >&4
6726 set d_iovec_s iovec iov_base $i_sysuio sys/uio.h
6727 eval $hasfield
6728 case "$d_iovec_s" in
6729 "$define")      echo "Yup, it does." >&4
6730                 ;;
6731 *)              echo "Nope, it doesn't." >&4
6732                 ;;
6733 esac
6734
6735 socketlib=''
6736 sockethdr=''
6737 : see whether socket exists
6738 echo " "
6739 $echo $n "Hmm... $c" >&4
6740 if set socket val -f d_socket; eval $csym; $val; then
6741         echo "Looks like you have Berkeley networking support." >&4
6742         d_socket="$define"
6743         if set setsockopt val -f; eval $csym; $val; then
6744                 d_oldsock="$undef"
6745         else
6746                 echo "...but it uses the old BSD 4.1c interface, rather than 4.2." >&4
6747                 d_oldsock="$define"
6748         fi
6749 else
6750         if $contains socklib libc.list >/dev/null 2>&1; then
6751                 echo "Looks like you have Berkeley networking support." >&4
6752                 d_socket="$define"
6753                 : we will have to assume that it supports the 4.2 BSD interface
6754                 d_oldsock="$undef"
6755         else
6756                 echo "You don't have Berkeley networking in libc$_a..." >&4
6757                 if test "X$d_socket" = "X$define"; then
6758                    echo "...but you seem to believe that you have sockets." >&4
6759                 else
6760                         for net in net socket
6761                         do
6762                                 if test -f /usr/lib/lib$net$_a; then
6763                                         ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
6764                                         $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
6765                                         if $contains socket libc.list >/dev/null 2>&1; then
6766                                                 d_socket="$define"
6767                                                 socketlib="-l$net"
6768                                                 case "$net" in
6769                                                 net)
6770                                                         echo "...but the Wollongong group seems to have hacked it in." >&4
6771                                                         sockethdr="-I/usr/netinclude"
6772                                                         ;;
6773                                                 esac
6774                                                 echo "Found Berkeley sockets interface in lib$net." >& 4 
6775                                                 if $contains setsockopt libc.list >/dev/null 2>&1; then
6776                                                         d_oldsock="$undef"
6777                                                 else
6778                                                         echo "...using the old BSD 4.1c interface, rather than 4.2." >&4
6779                                                         d_oldsock="$define"
6780                                                 fi
6781                                                 break
6782                                         fi
6783                                 fi
6784                         done
6785                         if test "X$d_socket" != "X$define"; then
6786                            echo "or anywhere else I see." >&4
6787                            d_socket="$undef"
6788                            d_oldsock="$undef"
6789                         fi
6790                 fi
6791         fi
6792 fi
6793
6794 : see if socketpair exists
6795 set socketpair d_sockpair
6796 eval $inlibc
6797
6798
6799 echo " "
6800 echo "Checking the availability of certain socket constants..." >& 4
6801 for ENUM in MSG_CTRUNC MSG_DONTROUTE MSG_OOB MSG_PEEK MSG_PROXY SCM_RIGHTS; do
6802         enum=`$echo $ENUM|./tr '[A-Z]' '[a-z]'`
6803         $cat >try.c <<EOF
6804 #include <sys/types.h>
6805 #include <sys/socket.h>
6806 int main() {
6807     int i = $ENUM;
6808 }
6809 EOF
6810         val="$undef"
6811         set try; if eval $compile; then
6812                 val="$define"
6813         fi
6814         set d_${enum}; eval $setvar
6815         $rm -f try.c try
6816 done
6817
6818 set sendmsg d_sendmsg
6819 eval $inlibc
6820
6821 set recvmsg d_recvmsg
6822 eval $inlibc
6823
6824 echo " "
6825 $echo $n "Checking to see if your system supports struct msghdr...$c" >&4
6826 set d_msghdr_s msghdr msg_name define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
6827 eval $hasfield
6828 case "$d_msghdr_s" in
6829 "$define")      echo "Yup, it does." >&4
6830                 ;;
6831 *)              echo "Nope, it doesn't." >&4
6832                 ;;
6833 esac
6834
6835 $echo $n "Checking to see if your system supports struct cmsghdr...$c" >&4
6836 set d_cmsghdr_s cmsghdr cmsg_len define sys/types.h $d_socket sys/socket.h $i_sysuio sys/uio.h
6837 eval $hasfield
6838 case "$d_cmsghdr_s" in
6839 "$define")      echo "Yup, it does." >&4
6840                 ;;
6841 *)              echo "Nope, it doesn't." >&4
6842                 ;;
6843 esac
6844
6845 : check for const keyword
6846 echo " "
6847 echo 'Checking to see if your C compiler knows about "const"...' >&4
6848 $cat >const.c <<'EOCP'
6849 typedef struct spug { int drokk; } spug;
6850 int main()
6851 {
6852         const char *foo;
6853         const spug y;
6854 }
6855 EOCP
6856 if $cc -c $ccflags const.c >/dev/null 2>&1 ; then
6857         val="$define"
6858         echo "Yup, it does."
6859 else
6860         val="$undef"
6861         echo "Nope, it doesn't."
6862 fi
6863 set d_const
6864 eval $setvar
6865
6866 : see if crypt exists
6867 echo " "
6868 if set crypt val -f d_crypt; eval $csym; $val; then
6869         echo 'crypt() found.' >&4
6870         val="$define"
6871         cryptlib=''
6872 else
6873         cryptlib=`./loc Slibcrypt$_a "" $xlibpth`
6874         if $test -z "$cryptlib"; then
6875                 cryptlib=`./loc Mlibcrypt$_a "" $xlibpth`
6876         else
6877                 cryptlib=-lcrypt
6878         fi
6879         if $test -z "$cryptlib"; then
6880                 cryptlib=`./loc Llibcrypt$_a "" $xlibpth`
6881         else
6882                 cryptlib=-lcrypt
6883         fi
6884         if $test -z "$cryptlib"; then
6885                 cryptlib=`./loc libcrypt$_a "" $libpth`
6886         else
6887                 cryptlib=-lcrypt
6888         fi
6889         if $test -z "$cryptlib"; then
6890                 echo 'crypt() NOT found.' >&4
6891                 val="$undef"
6892         else
6893                 val="$define"
6894         fi
6895 fi
6896 set d_crypt
6897 eval $setvar
6898
6899 : get csh whereabouts
6900 case "$csh" in
6901 'csh') val="$undef" ;;
6902 *) val="$define" ;;
6903 esac
6904 set d_csh
6905 eval $setvar
6906 : Respect a hint or command line value for full_csh.
6907 case "$full_csh" in
6908 '') full_csh=$csh ;;
6909 esac
6910
6911 : see if cuserid exists
6912 set cuserid d_cuserid
6913 eval $inlibc
6914
6915 : see if this is a limits.h system
6916 set limits.h i_limits
6917 eval $inhdr
6918
6919 : see if this is a float.h system
6920 set float.h i_float
6921 eval $inhdr
6922
6923 : See if number of significant digits in a double precision number is known
6924 echo " "
6925 $cat >dbl_dig.c <<EOM
6926 #$i_limits I_LIMITS
6927 #$i_float I_FLOAT
6928 #ifdef I_LIMITS
6929 #include <limits.h>
6930 #endif
6931 #ifdef I_FLOAT
6932 #include <float.h>
6933 #endif
6934 #ifdef DBL_DIG
6935 printf("Contains DBL_DIG");
6936 #endif
6937 EOM
6938 $cppstdin $cppflags $cppminus < dbl_dig.c >dbl_dig.E 2>/dev/null
6939 if $contains 'DBL_DIG' dbl_dig.E >/dev/null 2>&1; then
6940         echo "DBL_DIG found." >&4
6941         val="$define"
6942 else
6943         echo "DBL_DIG NOT found." >&4
6944         val="$undef"
6945 fi
6946 $rm -f dbl_dig.?
6947 set d_dbl_dig
6948 eval $setvar
6949
6950
6951 if $test X"$use64bits" = X"$define"; then
6952         : see if dbminit64 exists
6953         set dbminit64 d_dbminit64
6954         eval $inlibc
6955
6956         : see if dbmclose64 exists
6957         set dbmclose64 d_dbmclose64
6958         eval $inlibc
6959
6960         : see if fetch64 exists
6961         set fetch64 d_fetch64
6962         eval $inlibc
6963
6964         : see if store64 exists
6965         set store64 d_store64
6966         eval $inlibc
6967
6968         : see if delete64 exists
6969         set delete64 d_delete64
6970         eval $inlibc
6971
6972         : see if firstkey64 exists
6973         set firstkey64 d_firstkey64
6974         eval $inlibc
6975
6976         : see if nextkey64 exists
6977         set nextkey64 d_nextkey64
6978         eval $inlibc
6979 else
6980         val="$undef"
6981         for xxx in d_dbminit64 d_dbmclose64 d_fetch64 d_store64 d_delete64 d_firstkey64 d_nextkey64
6982         do
6983                 set $xxx
6984                 eval $setvar
6985         done
6986 fi
6987
6988 : see if difftime exists
6989 set difftime d_difftime
6990 eval $inlibc
6991
6992 : see if sys/stat.h is available
6993 set sys/stat.h i_sysstat
6994 eval $inhdr
6995
6996 : see if this is a dirent system
6997 echo " "
6998 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
6999         val="$define"
7000         echo "<dirent.h> found." >&4
7001 else
7002         val="$undef"
7003         if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
7004                 echo "<sys/dir.h> found." >&4
7005                 echo " "
7006         else
7007                 xinc=`./findhdr sys/ndir.h`
7008         fi
7009         echo "<dirent.h> NOT found." >&4
7010 fi
7011 set i_dirent
7012 eval $setvar
7013
7014 : Look for type of directory structure.
7015 echo " "
7016 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7017
7018 case "$direntrytype" in
7019 ''|' ')
7020         case "$i_dirent" in
7021         $define) guess1='struct dirent' ;;
7022         *) guess1='struct direct'  ;;
7023         esac
7024         ;;
7025 *)      guess1="$direntrytype"
7026         ;;
7027 esac
7028
7029 case "$guess1" in
7030 'struct dirent') guess2='struct direct' ;;
7031 *) guess2='struct dirent' ;;
7032 esac
7033                 
7034 if $contains "$guess1" try.c >/dev/null 2>&1; then
7035         direntrytype="$guess1"
7036         echo "Your directory entries are $direntrytype." >&4
7037 elif $contains "$guess2" try.c >/dev/null 2>&1; then
7038         direntrytype="$guess2"
7039         echo "Your directory entries seem to be $direntrytype." >&4
7040 else
7041         echo "I don't recognize your system's directory entries." >&4
7042         rp="What type is used for directory entries on this system?"
7043         dflt="$guess1"
7044         . ./myread
7045         direntrytype="$ans"
7046 fi
7047 $rm -f try.c
7048
7049
7050 : see if the directory entry stores field length
7051 echo " "
7052 $cppstdin $cppflags $cppminus < "$xinc" > try.c
7053 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
7054         echo "Good, your directory entry keeps length information in d_namlen." >&4
7055         val="$define"
7056 else
7057         echo "Your directory entry does not know about the d_namlen field." >&4
7058         val="$undef"
7059 fi
7060 set d_dirnamlen
7061 eval $setvar
7062 $rm -f try.c
7063
7064
7065 if $test X"$use64bits" = X"$define"; then
7066         : see if fstat64 exists
7067         set fstat64 d_fstat64
7068         eval $inlibc
7069
7070         : see if ftruncate64 exists
7071         set ftruncate64 d_ftruncate64
7072         eval $inlibc
7073
7074         : see if lockf64 exists
7075         set lockf64 d_lockf64
7076         eval $inlibc
7077
7078         : see if lseek64 exists
7079         set lseek64 d_lseek64
7080         eval $inlibc
7081
7082         : see if lstat64 exists
7083         set lstat64 d_lstat64
7084         eval $inlibc
7085
7086         : see if open64 exists
7087         set open64 d_open64
7088         eval $inlibc
7089
7090         : see if opendir64 exists
7091         set opendir64 d_opendir64
7092         eval $inlibc
7093
7094         : see if readdir64 exists
7095         set readdir64 d_readdir64
7096         eval $inlibc
7097
7098         : see if seekdir64 exists
7099         set seekdir64 d_seekdir64
7100         eval $inlibc
7101
7102         : see if stat64 exists
7103         set stat64 d_stat64
7104         eval $inlibc
7105
7106         : see if telldir64 exists
7107         set telldir64 d_telldir64
7108         eval $inlibc
7109
7110         : see if truncate64 exists
7111         set truncate64 d_truncate64
7112         eval $inlibc
7113
7114         : check for off64_t
7115         echo " "
7116         echo $n "Checking to see if your system supports off64_t...$c" >&4
7117         $cat >try.c <<EOCP
7118 #include <sys/types.h>
7119 off64_t foo() { off64_t x; x = 7; return x; }'
7120 EOCP
7121         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7122                 val="$define"
7123                 echo " Yup, it does." >&4
7124         else
7125                 val="$undef"
7126                 echo " Nope, it doesn't." >&4
7127         fi
7128         $rm -f try.*
7129         set d_off64t
7130         eval $setvar
7131
7132         : check for ino64_t
7133         echo " "
7134         echo $n "Checking to see if your system supports ino64_t...$c" >&4
7135         val="$undef"
7136         case "$i_sysstat" in
7137         "$define" )
7138                 $cat >try.c <<EOCP
7139 #include <sys/types.h>
7140 #include <sys/stat.h>
7141 ino64_t foo() { ino64_t x; x = 7; return x; }'
7142 EOCP
7143                 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
7144                         val="$define"
7145                 fi
7146                 $rm -f try.*
7147                 ;;
7148         esac
7149         if $test "X$val" = X"$define"; then
7150                 echo " Yup, it does." >&4
7151         else
7152                 echo " Nope, it doesn't." >&4
7153         fi
7154         set d_ino64t
7155         eval $setvar
7156
7157         : check for struct flock64
7158         echo " "
7159         echo "Checking to see if your system supports struct flock64..." >&4
7160         if $h_fcntl; then
7161                 set d_flock64_s flock64 l_len define fcntl.h
7162                 eval $hasfield
7163         else
7164                 val="$undef"
7165                 set d_flock64_s
7166                 eval $setvar
7167         fi
7168         case "$d_flock64_s" in
7169         "$define")      echo "Yup, it does." >&4
7170                         ;;
7171         *)              echo "Nope, it doesn't." >&4
7172                         ;;
7173         esac
7174
7175         : check for struct dirent64
7176         echo " "
7177         echo "Checking to see if your system supports struct dirent64..." >&4
7178         set d_dirent64_s dirent64 d_off $i_dirent dirent.h
7179         eval $hasfield
7180         case "$d_dirent64_s" in
7181         "$define")      echo "Yup, it does." >&4
7182                         ;;
7183         *)              echo "Nope, it doesn't." >&4
7184                         ;;
7185         esac
7186
7187 else
7188         val="$undef"
7189         for xxx in d_fstat64 d_ftruncate64 d_lockf64 d_lseek64 d_lstat64 d_open64 d_opendir64 d_readdir64 d_seekdir64 d_stat64 d_telldir64 d_truncate64 d_off64t d_ino64t d_flock64_s d_dirent64_s
7190         do
7191                 set $xxx
7192                 eval $setvar
7193         done
7194 fi
7195
7196 : see if dlerror exists
7197 xxx_runnm="$runnm"
7198 runnm=false
7199 set dlerror d_dlerror
7200 eval $inlibc
7201 runnm="$xxx_runnm"
7202
7203 : see if dlfcn is available
7204 set dlfcn.h i_dlfcn
7205 eval $inhdr
7206
7207 case "$usedl" in
7208 $define|y|true)
7209         $cat << EOM
7210
7211 On a few systems, the dynamically loaded modules that perl generates and uses
7212 will need a different extension than shared libs. The default will probably
7213 be appropriate.
7214
7215 EOM
7216         case "$dlext" in
7217         '')     dflt="$so" ;;
7218         *)      dflt="$dlext" ;;
7219         esac
7220         rp='What is the extension of dynamically loaded modules'
7221         . ./myread
7222         dlext="$ans"
7223         ;;
7224 *)
7225         dlext="none"
7226         ;;
7227 esac
7228
7229 : Check if dlsym need a leading underscore
7230 echo " "
7231 val="$undef"
7232
7233 case "$dlsrc" in
7234 dl_dlopen.xs)
7235         echo "Checking whether your dlsym() needs a leading underscore ..." >&4
7236         $cat >dyna.c <<'EOM'
7237 fred () { }
7238 EOM
7239
7240 $cat >fred.c<<EOM
7241
7242 #include <stdio.h>
7243 #$i_dlfcn I_DLFCN
7244 #ifdef I_DLFCN
7245 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
7246 #else
7247 #include <sys/types.h>
7248 #include <nlist.h>
7249 #include <link.h>
7250 #endif
7251
7252 extern int fred() ;
7253
7254 int main()
7255 {
7256     void * handle ;
7257     void * symbol ;
7258 #ifndef RTLD_LAZY
7259     int mode = 1 ;
7260 #else
7261     int mode = RTLD_LAZY ;
7262 #endif
7263     handle = dlopen("./dyna.$dlext", mode) ;
7264     if (handle == NULL) {
7265         printf ("1\n") ;
7266         fflush (stdout) ;
7267         exit(0);
7268     }
7269     symbol = dlsym(handle, "fred") ;
7270     if (symbol == NULL) {
7271         /* try putting a leading underscore */
7272         symbol = dlsym(handle, "_fred") ;
7273         if (symbol == NULL) {
7274             printf ("2\n") ;
7275             fflush (stdout) ;
7276             exit(0);
7277         }
7278         printf ("3\n") ;
7279     }
7280     else
7281         printf ("4\n") ;
7282     fflush (stdout) ;
7283     exit(0);
7284 }
7285 EOM
7286         : Call the object file tmp-dyna.o in case dlext=o.
7287         if $cc $ccflags $cccdlflags -c dyna.c > /dev/null 2>&1 && 
7288                 mv dyna${_o} tmp-dyna${_o} > /dev/null 2>&1 && 
7289                 $ld $lddlflags -o dyna.$dlext tmp-dyna${_o} > /dev/null 2>&1 && 
7290                 $cc $ccflags -o fred $ldflags $cccdlflags $ccdlflags fred.c $libs > /dev/null 2>&1; then
7291                 xxx=`./fred`
7292                 case $xxx in
7293                 1)      echo "Test program failed using dlopen." >&4
7294                         echo "Perhaps you should not use dynamic loading." >&4;;
7295                 2)      echo "Test program failed using dlsym." >&4
7296                         echo "Perhaps you should not use dynamic loading." >&4;;
7297                 3)      echo "dlsym needs a leading underscore" >&4
7298                         val="$define" ;;
7299                 4)      echo "dlsym doesn't need a leading underscore." >&4;;
7300                 esac
7301         else
7302                 echo "I can't compile and run the test program." >&4
7303         fi
7304         ;;
7305 esac
7306                 
7307 $rm -f fred fred.? dyna.$dlext dyna.? tmp-dyna.?
7308
7309 set d_dlsymun
7310 eval $setvar
7311
7312 hasproto='varname=$1; func=$2; shift; shift;
7313 while $test $# -ge 2; do
7314         case "$1" in
7315         $define) echo "#include <$2>";;
7316         esac ;
7317     shift 2;
7318 done > try.c;
7319 $cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
7320 if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
7321         echo "$func() prototype found.";
7322         val="$define";
7323 else
7324         echo "$func() prototype NOT found.";
7325         val="$undef";
7326 fi;
7327 set $varname;
7328 eval $setvar;
7329 $rm -f try.c tryout.c'
7330
7331 : see if prototype for drand48 is available
7332 echo " "
7333 set d_drand48proto drand48 $i_stdlib stdlib.h $i_unistd unistd.h
7334 eval $hasproto
7335
7336 : see if dup2 exists
7337 set dup2 d_dup2
7338 eval $inlibc
7339
7340 : see if eaccess exists
7341 set eaccess d_eaccess
7342 eval $inlibc
7343
7344 : see if endgrent exists
7345 set endgrent d_endgrent
7346 eval $inlibc
7347
7348 : see if endhostent exists
7349 set endhostent d_endhent
7350 eval $inlibc
7351
7352 : see if endnetent exists
7353 set endnetent d_endnent
7354 eval $inlibc
7355
7356 : see if endprotoent exists
7357 set endprotoent d_endpent
7358 eval $inlibc
7359
7360 : see if endpwent exists
7361 set endpwent d_endpwent
7362 eval $inlibc
7363
7364 : see if endservent exists
7365 set endservent d_endsent
7366 eval $inlibc
7367
7368 : Locate the flags for 'open()'
7369 echo " "
7370 $cat >open3.c <<'EOCP'
7371 #include <sys/types.h>
7372 #ifdef I_FCNTL
7373 #include <fcntl.h>
7374 #endif
7375 #ifdef I_SYS_FILE
7376 #include <sys/file.h>
7377 #endif
7378 main() {
7379         if(O_RDONLY);
7380 #ifdef O_TRUNC
7381         exit(0);
7382 #else
7383         exit(1);
7384 #endif
7385 }
7386 EOCP
7387 : check sys/file.h first to get FREAD on Sun
7388 if $test `./findhdr sys/file.h` && \
7389                 set open3 -DI_SYS_FILE && eval $compile; then
7390         h_sysfile=true;
7391         echo "<sys/file.h> defines the O_* constants..." >&4
7392         if ./open3; then
7393                 echo "and you have the 3 argument form of open()." >&4
7394                 val="$define"
7395         else
7396                 echo "but not the 3 argument form of open().  Oh, well." >&4
7397                 val="$undef"
7398         fi
7399 elif $test `./findhdr fcntl.h` && \
7400                 set open3 -DI_FCNTL && eval $compile; then
7401         h_fcntl=true;
7402         echo "<fcntl.h> defines the O_* constants..." >&4
7403         if ./open3; then
7404                 echo "and you have the 3 argument form of open()." >&4
7405                 val="$define"
7406         else
7407                 echo "but not the 3 argument form of open().  Oh, well." >&4
7408                 val="$undef"
7409         fi
7410 else
7411         val="$undef"
7412         echo "I can't find the O_* constant definitions!  You got problems." >&4
7413 fi
7414 set d_open3
7415 eval $setvar
7416 $rm -f open3*
7417
7418 : check for non-blocking I/O stuff
7419 case "$h_sysfile" in
7420 true) echo "#include <sys/file.h>" > head.c;;
7421 *)
7422         case "$h_fcntl" in
7423         true) echo "#include <fcntl.h>" > head.c;;
7424         *) echo "#include <sys/fcntl.h>" > head.c;;
7425         esac
7426         ;;
7427 esac
7428 echo " "
7429 echo "Figuring out the flag used by open() for non-blocking I/O..." >&4
7430 case "$o_nonblock" in
7431 '')
7432         $cat head.c > try.c
7433         $cat >>try.c <<'EOCP'
7434 main() {
7435 #ifdef O_NONBLOCK
7436         printf("O_NONBLOCK\n");
7437         exit(0);
7438 #endif
7439 #ifdef O_NDELAY
7440         printf("O_NDELAY\n");
7441         exit(0);
7442 #endif
7443 #ifdef FNDELAY
7444         printf("FNDELAY\n");
7445         exit(0);
7446 #endif
7447         exit(0);
7448 }
7449 EOCP
7450         set try
7451         if eval $compile_ok; then
7452                 o_nonblock=`./try`
7453                 case "$o_nonblock" in
7454                 '') echo "I can't figure it out, assuming O_NONBLOCK will do.";;
7455                 *) echo "Seems like we can use $o_nonblock.";;
7456                 esac
7457         else
7458                 echo "(I can't compile the test program; pray O_NONBLOCK is right!)"
7459         fi
7460         ;;
7461 *) echo "Using $hint value $o_nonblock.";;
7462 esac
7463 $rm -f try try.* .out core
7464
7465 echo " "
7466 echo "Let's see what value errno gets from read() on a $o_nonblock file..." >&4
7467 case "$eagain" in
7468 '')
7469         $cat head.c > try.c
7470         $cat >>try.c <<EOCP
7471 #include <errno.h>
7472 #include <sys/types.h>
7473 #include <signal.h>
7474 #define MY_O_NONBLOCK $o_nonblock
7475 #ifndef errno  /* XXX need better Configure test */
7476 extern int errno;
7477 #endif
7478 $signal_t blech(x) int x; { exit(3); }
7479 EOCP
7480         $cat >> try.c <<'EOCP'
7481 main()
7482 {
7483         int pd[2];
7484         int pu[2];
7485         char buf[1];
7486         char string[100];
7487
7488         pipe(pd);       /* Down: child -> parent */
7489         pipe(pu);       /* Up: parent -> child */
7490         if (0 != fork()) {
7491                 int ret;
7492                 close(pd[1]);   /* Parent reads from pd[0] */
7493                 close(pu[0]);   /* Parent writes (blocking) to pu[1] */
7494                 if (-1 == fcntl(pd[0], F_SETFL, MY_O_NONBLOCK))
7495                         exit(1);
7496                 signal(SIGALRM, blech);
7497                 alarm(5);
7498                 if ((ret = read(pd[0], buf, 1)) > 0)    /* Nothing to read! */
7499                         exit(2);
7500                 sprintf(string, "%d\n", ret);
7501                 write(2, string, strlen(string));
7502                 alarm(0);
7503 #ifdef EAGAIN
7504                 if (errno == EAGAIN) {
7505                         printf("EAGAIN\n");
7506                         goto ok;
7507                 }
7508 #endif
7509 #ifdef EWOULDBLOCK
7510                 if (errno == EWOULDBLOCK)
7511                         printf("EWOULDBLOCK\n");
7512 #endif
7513         ok:
7514                 write(pu[1], buf, 1);   /* Unblocks child, tell it to close our pipe */
7515                 sleep(2);                               /* Give it time to close our pipe */
7516                 alarm(5);
7517                 ret = read(pd[0], buf, 1);      /* Should read EOF */
7518                 alarm(0);
7519                 sprintf(string, "%d\n", ret);
7520                 write(3, string, strlen(string));
7521                 exit(0);
7522         }
7523
7524         close(pd[0]);                   /* We write to pd[1] */
7525         close(pu[1]);                   /* We read from pu[0] */
7526         read(pu[0], buf, 1);    /* Wait for parent to signal us we may continue */
7527         close(pd[1]);                   /* Pipe pd is now fully closed! */
7528         exit(0);                                /* Bye bye, thank you for playing! */
7529 }
7530 EOCP
7531         set try
7532         if eval $compile_ok; then
7533                 echo "$startsh" >mtry
7534                 echo "./try >try.out 2>try.ret 3>try.err || exit 4" >>mtry
7535                 chmod +x mtry
7536                 ./mtry >/dev/null 2>&1
7537                 case $? in
7538                 0) eagain=`$cat try.out`;;
7539                 1) echo "Could not perform non-blocking setting!";;
7540                 2) echo "I did a successful read() for something that was not there!";;
7541                 3) echo "Hmm... non-blocking I/O does not seem to be working!";;
7542                 *) echo "Something terribly wrong happened during testing.";;
7543                 esac
7544                 rd_nodata=`$cat try.ret`
7545                 echo "A read() system call with no data present returns $rd_nodata."
7546                 case "$rd_nodata" in
7547                 0|-1) ;;
7548                 *)
7549                         echo "(That's peculiar, fixing that to be -1.)"
7550                         rd_nodata=-1
7551                         ;;
7552                 esac
7553                 case "$eagain" in
7554                 '')
7555                         echo "Forcing errno EAGAIN on read() with no data available."
7556                         eagain=EAGAIN
7557                         ;;
7558                 *)
7559                         echo "Your read() sets errno to $eagain when no data is available."
7560                         ;;
7561                 esac
7562                 status=`$cat try.err`
7563                 case "$status" in
7564                 0) echo "And it correctly returns 0 to signal EOF.";;
7565                 -1) echo "But it also returns -1 to signal EOF, so be careful!";;
7566                 *) echo "However, your read() returns '$status' on EOF??";;
7567                 esac
7568                 val="$define"
7569                 if test "$status" = "$rd_nodata"; then
7570                         echo "WARNING: you can't distinguish between EOF and no data!"
7571                         val="$undef"
7572                 fi
7573         else
7574                 echo "I can't compile the test program--assuming errno EAGAIN will do."
7575                 eagain=EAGAIN
7576         fi
7577         set d_eofnblk
7578         eval $setvar
7579         ;;
7580 *)
7581         echo "Using $hint value $eagain."
7582         echo "Your read() returns $rd_nodata when no data is present."
7583         case "$d_eofnblk" in
7584         "$define") echo "And you can see EOF because read() returns 0.";;
7585         "$undef") echo "But you can't see EOF status from read() returned value.";;
7586         *)
7587                 echo "(Assuming you can't see EOF status from read anyway.)"
7588                 d_eofnblk=$undef
7589                 ;;
7590         esac
7591         ;;
7592 esac
7593 $rm -f try try.* .out core head.c mtry
7594
7595 : see if fchmod exists
7596 set fchmod d_fchmod
7597 eval $inlibc
7598
7599 : see if fchown exists
7600 set fchown d_fchown
7601 eval $inlibc
7602
7603 : see if this is an fcntl system
7604 set fcntl d_fcntl
7605 eval $inlibc
7606
7607 : see if sys/select.h has to be included
7608 set sys/select.h i_sysselct
7609 eval $inhdr
7610
7611 : see if we should include time.h, sys/time.h, or both
7612 echo " "
7613 if test "X$timeincl" = X; then
7614         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7615         $echo $n "I'm now running the test program...$c"
7616         $cat >try.c <<'EOCP'
7617 #include <sys/types.h>
7618 #ifdef I_TIME
7619 #include <time.h>
7620 #endif
7621 #ifdef I_SYSTIME
7622 #ifdef SYSTIMEKERNEL
7623 #define KERNEL
7624 #endif
7625 #include <sys/time.h>
7626 #endif
7627 #ifdef I_SYSSELECT
7628 #include <sys/select.h>
7629 #endif
7630 main()
7631 {
7632         struct tm foo;
7633 #ifdef S_TIMEVAL
7634         struct timeval bar;
7635 #endif
7636 #ifdef S_TIMEZONE
7637         struct timezone tzp;
7638 #endif
7639         if (foo.tm_sec == foo.tm_sec)
7640                 exit(0);
7641 #ifdef S_TIMEVAL
7642         if (bar.tv_sec == bar.tv_sec)
7643                 exit(0);
7644 #endif
7645         exit(1);
7646 }
7647 EOCP
7648         flags=''
7649         for s_timezone in '-DS_TIMEZONE' ''; do
7650         sysselect=''
7651         for s_timeval in '-DS_TIMEVAL' ''; do
7652         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7653         for i_time in '' '-DI_TIME'; do
7654         for i_systime in '-DI_SYSTIME' ''; do
7655                 case "$flags" in
7656                 '') $echo $n ".$c"
7657                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7658                         if eval $compile; then
7659                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7660                                 shift
7661                                 flags="$*"
7662                                 echo " "
7663                                 $echo $n "Succeeded with $flags$c"
7664                         fi
7665                         ;;
7666                 esac
7667         done
7668         done
7669         done
7670         done
7671         done
7672         timeincl=''
7673         echo " "
7674         case "$flags" in
7675         *SYSTIMEKERNEL*) i_systimek="$define"
7676                 timeincl=`./findhdr sys/time.h`
7677                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7678         *) i_systimek="$undef";;
7679         esac
7680         case "$flags" in
7681         *I_TIME*) i_time="$define"
7682                 timeincl=`./findhdr time.h`" $timeincl"
7683                 echo "We'll include <time.h>." >&4;;
7684         *) i_time="$undef";;
7685         esac
7686         case "$flags" in
7687         *I_SYSTIME*) i_systime="$define"
7688                 timeincl=`./findhdr sys/time.h`" $timeincl"
7689                 echo "We'll include <sys/time.h>." >&4;;
7690         *) i_systime="$undef";;
7691         esac
7692         $rm -f try.c try
7693 fi
7694
7695 : check for fd_set items
7696 $cat <<EOM
7697
7698 Checking to see how well your C compiler handles fd_set and friends ...
7699 EOM
7700 $cat >fd_set.c <<EOCP
7701 #$i_systime I_SYS_TIME
7702 #$i_sysselct I_SYS_SELECT
7703 #$d_socket HAS_SOCKET
7704 #include <sys/types.h>
7705 #ifdef HAS_SOCKET
7706 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7707 #endif
7708 #ifdef I_SYS_TIME
7709 #include <sys/time.h>
7710 #endif
7711 #ifdef I_SYS_SELECT
7712 #include <sys/select.h>
7713 #endif
7714 main() {
7715         fd_set fds;
7716
7717 #ifdef TRYBITS
7718         if(fds.fds_bits);
7719 #endif
7720
7721 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7722         exit(0);
7723 #else
7724         exit(1);
7725 #endif
7726 }
7727 EOCP
7728 set fd_set -DTRYBITS
7729 if eval $compile; then
7730         d_fds_bits="$define"
7731         d_fd_set="$define"
7732         echo "Well, your system knows about the normal fd_set typedef..." >&4
7733         if ./fd_set; then
7734                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7735                 d_fd_macros="$define"
7736         else
7737                 $cat >&4 <<'EOM'
7738 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7739 EOM
7740                 d_fd_macros="$undef"
7741         fi
7742 else
7743         $cat <<'EOM'
7744 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7745 EOM
7746         set fd_set
7747         if eval $compile; then
7748                 d_fds_bits="$undef"
7749                 d_fd_set="$define"
7750                 echo "Well, your system has some sort of fd_set available..." >&4
7751                 if ./fd_set; then
7752                         echo "and you have the normal fd_set macros." >&4
7753                         d_fd_macros="$define"
7754                 else
7755                         $cat <<'EOM'
7756 but not the normal fd_set macros!  Gross!  More work for me...
7757 EOM
7758                         d_fd_macros="$undef"
7759                 fi
7760         else
7761         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7762                 d_fd_set="$undef"
7763                 d_fds_bits="$undef"
7764                 d_fd_macros="$undef"
7765         fi
7766 fi
7767 $rm -f fd_set*
7768
7769 : see if fgetpos exists
7770 set fgetpos d_fgetpos
7771 eval $inlibc
7772
7773
7774 if $test X"$use64bits" = X"$define"; then
7775         : see if fgetpos64 exists
7776         set fgetpos64 d_fgetpos64
7777         eval $inlibc
7778
7779         : see if fopen64 exists
7780         set freopen64 d_fopen64
7781         eval $inlibc
7782
7783         : see if freopen64 exists
7784         set freopen64 d_freopen64
7785         eval $inlibc
7786
7787         : see if fseek64 exists
7788         set fseek64 d_fseek64
7789         eval $inlibc
7790
7791         : see if fseeko64 exists
7792         set fseeko64 d_fseeko64
7793         eval $inlibc
7794
7795         : see if fsetpos64 exists
7796         set fsetpos64 d_fsetpos64
7797         eval $inlibc
7798
7799         : see if ftell64 exists
7800         set ftell64 d_ftell64
7801         eval $inlibc
7802
7803         : see if ftello64 exists
7804         set ftello64 d_ftello64
7805         eval $inlibc
7806
7807         : see if tmpfile64 exists
7808         set tmpfile64 d_tmpfile64
7809         eval $inlibc
7810 else
7811         val="$undef"
7812         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
7813         do
7814                 set $xxx
7815                 eval $setvar
7816         done
7817 fi
7818
7819 : see if flock exists
7820 set flock d_flock
7821 eval $inlibc
7822
7823 : see if fork exists
7824 set fork d_fork
7825 eval $inlibc
7826
7827 : see if pathconf exists
7828 set pathconf d_pathconf
7829 eval $inlibc
7830
7831 : see if fpathconf exists
7832 set fpathconf d_fpathconf
7833 eval $inlibc
7834
7835 : see if fseeko exists
7836 set fseeko d_fseeko
7837 eval $inlibc
7838
7839 : see if fsetpos exists
7840 set fsetpos d_fsetpos
7841 eval $inlibc
7842
7843 : see if ftello exists
7844 set ftello d_ftello
7845 eval $inlibc
7846
7847 : see if getgrent exists
7848 set getgrent d_getgrent
7849 eval $inlibc
7850
7851 : see if gethostbyaddr exists
7852 set gethostbyaddr d_gethbyaddr
7853 eval $inlibc
7854
7855 : see if gethostbyname exists
7856 set gethostbyname d_gethbyname
7857 eval $inlibc
7858
7859 : see if gethostent exists
7860 set gethostent d_gethent
7861 eval $inlibc
7862
7863 : see how we will look up host name
7864 echo " "
7865 if false; then
7866         : dummy stub to allow use of elif
7867 elif set gethostname val -f d_gethname; eval $csym; $val; then
7868         echo 'gethostname() found.' >&4
7869         d_gethname="$define"
7870         call=gethostname
7871 elif set uname val -f d_uname; eval $csym; $val; then
7872         if ./xenix; then
7873                 $cat <<'EOM'
7874 uname() was found, but you're running xenix, and older versions of xenix
7875 have a broken uname(). If you don't really know whether your xenix is old
7876 enough to have a broken system call, use the default answer.
7877
7878 EOM
7879                 dflt=y
7880                 case "$d_uname" in
7881                 "$define") dflt=n;;
7882                 esac
7883                 rp='Is your uname() broken?'
7884                 . ./myread
7885                 case "$ans" in
7886                 n*) d_uname="$define"; call=uname;;
7887                 esac
7888         else
7889                 echo 'uname() found.' >&4
7890                 d_uname="$define"
7891                 call=uname
7892         fi
7893 fi
7894 case "$d_gethname" in
7895 '') d_gethname="$undef";;
7896 esac
7897 case "$d_uname" in
7898 '') d_uname="$undef";;
7899 esac
7900 case "$d_uname$d_gethname" in
7901 *define*)
7902         dflt=n
7903         cat <<EOM
7904  
7905 Every now and then someone has a $call() that lies about the hostname
7906 but can't be fixed for political or economic reasons.  If you wish, I can
7907 pretend $call() isn't there and maybe compute hostname at run-time
7908 thanks to the '$phostname' command.
7909
7910 EOM
7911         rp="Shall I ignore $call() from now on?"
7912         . ./myread
7913         case "$ans" in
7914         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
7915         esac;;
7916 esac
7917 case "$phostname" in
7918 '') aphostname='';;
7919 *) case "$aphostname" in
7920         /*) ;;
7921         *) set X $phostname
7922                 shift
7923                 file=$1
7924                 shift
7925                 file=`./loc $file $file $pth`
7926                 aphostname=`echo $file $*`
7927                 ;;
7928         esac
7929         ;;
7930 esac
7931 case "$d_uname$d_gethname" in
7932 *define*) ;;
7933 *)
7934         case "$phostname" in
7935         '')
7936                 echo "There will be no way for $package to get your hostname." >&4;;
7937         *)
7938         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
7939                 ;;
7940         esac;;
7941 esac
7942 case "$d_phostname" in
7943 '') d_phostname="$undef";;
7944 esac
7945
7946 : see if this is a netdb.h system
7947 set netdb.h i_netdb
7948 eval $inhdr
7949
7950 : see if prototypes for various gethostxxx netdb.h functions are available
7951 echo " "
7952 set d_gethostprotos gethostent $i_netdb netdb.h
7953 eval $hasproto
7954
7955 : see if getlogin exists
7956 set getlogin d_getlogin
7957 eval $inlibc
7958
7959 : see if getnetbyaddr exists
7960 set getnetbyaddr d_getnbyaddr
7961 eval $inlibc
7962
7963 : see if getnetbyname exists
7964 set getnetbyname d_getnbyname
7965 eval $inlibc
7966
7967 : see if getnetent exists
7968 set getnetent d_getnent
7969 eval $inlibc
7970
7971 : see if prototypes for various getnetxxx netdb.h functions are available
7972 echo " "
7973 set d_getnetprotos getnetent $i_netdb netdb.h
7974 eval $hasproto
7975
7976
7977 : see if getprotobyname exists
7978 set getprotobyname d_getpbyname
7979 eval $inlibc
7980
7981 : see if getprotobynumber exists
7982 set getprotobynumber d_getpbynumber
7983 eval $inlibc
7984
7985 : see if getprotoent exists
7986 set getprotoent d_getpent
7987 eval $inlibc
7988
7989 : see if getpgid exists
7990 set getpgid d_getpgid
7991 eval $inlibc
7992
7993 : see if getpgrp2 exists
7994 set getpgrp2 d_getpgrp2
7995 eval $inlibc
7996
7997 : see if getppid exists
7998 set getppid d_getppid
7999 eval $inlibc
8000
8001 : see if getpriority exists
8002 set getpriority d_getprior
8003 eval $inlibc
8004
8005 : see if prototypes for various getprotoxxx netdb.h functions are available
8006 echo " "
8007 set d_getprotoprotos getprotoent $i_netdb netdb.h
8008 eval $hasproto
8009
8010 : see if getpwent exists
8011 set getpwent d_getpwent
8012 eval $inlibc
8013
8014
8015 : see if getservbyname exists
8016 set getservbyname d_getsbyname
8017 eval $inlibc
8018
8019 : see if getservbyport exists
8020 set getservbyport d_getsbyport
8021 eval $inlibc
8022
8023 : see if getservent exists
8024 set getservent d_getsent
8025 eval $inlibc
8026
8027 : see if prototypes for various getservxxx netdb.h functions are available
8028 echo " "
8029 set d_getservprotos getservent $i_netdb netdb.h
8030 eval $hasproto
8031
8032 : see if gettimeofday or ftime exists
8033 set gettimeofday d_gettimeod
8034 eval $inlibc
8035 case "$d_gettimeod" in
8036 "$undef")
8037         set ftime d_ftime 
8038         eval $inlibc
8039         ;;
8040 *)
8041         val="$undef"; set d_ftime; eval $setvar
8042         ;;
8043 esac
8044 case "$d_gettimeod$d_ftime" in
8045 "$undef$undef")
8046         echo " "
8047         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8048         ;;
8049 esac
8050
8051 : see if this is an grp system
8052 set grp.h i_grp
8053 eval $inhdr
8054
8055 case "$i_grp" in
8056 $define)
8057         xxx=`./findhdr grp.h`
8058         $cppstdin $cppflags $cppminus < $xxx >$$.h
8059
8060         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8061                 val="$define"
8062         else
8063                 val="$undef"
8064         fi
8065         set d_grpasswd
8066         eval $setvar
8067
8068         $rm -f $$.h
8069         ;;
8070 *)
8071         val="$undef";
8072         set d_grpasswd; eval $setvar
8073         ;;
8074 esac
8075
8076 : see if this is a netinet/in.h or sys/in.h system
8077 set netinet/in.h i_niin sys/in.h i_sysin
8078 eval $inhdr
8079
8080 : see if arpa/inet.h has to be included
8081 set arpa/inet.h i_arpainet
8082 eval $inhdr
8083
8084 : see if htonl --and friends-- exists
8085 val=''
8086 set htonl val
8087 eval $inlibc
8088
8089 : Maybe they are macros.
8090 case "$val" in
8091 $undef)
8092         $cat >htonl.c <<EOM
8093 #include <stdio.h>
8094 #include <sys/types.h>
8095 #$i_niin I_NETINET_IN
8096 #$i_sysin I_SYS_IN
8097 #$i_arpainet I_ARPA_INET
8098 #ifdef I_NETINET_IN
8099 #include <netinet/in.h>
8100 #endif
8101 #ifdef I_SYS_IN
8102 #include <sys/in.h>
8103 #endif
8104 #ifdef I_ARPA_INET
8105 #include <arpa/inet.h>
8106 #endif
8107 #ifdef htonl
8108 printf("Defined as a macro.");
8109 #endif
8110 EOM
8111         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8112         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8113                 val="$define"
8114                 echo "But it seems to be defined as a macro." >&4
8115         fi
8116         $rm -f htonl.?
8117         ;;
8118 esac
8119 set d_htonl
8120 eval $setvar
8121
8122 : see which of string.h or strings.h is needed
8123 echo " "
8124 strings=`./findhdr string.h`
8125 if $test "$strings" && $test -r "$strings"; then
8126         echo "Using <string.h> instead of <strings.h>." >&4
8127         val="$define"
8128 else
8129         val="$undef"
8130         strings=`./findhdr strings.h`
8131         if $test "$strings" && $test -r "$strings"; then
8132                 echo "Using <strings.h> instead of <string.h>." >&4
8133         else
8134                 echo "No string header found -- You'll surely have problems." >&4
8135         fi
8136 fi
8137 set i_string
8138 eval $setvar
8139 case "$i_string" in
8140 "$undef") strings=`./findhdr strings.h`;;
8141 *)        strings=`./findhdr string.h`;;
8142 esac
8143
8144 : index or strchr
8145 echo " "
8146 if set index val -f; eval $csym; $val; then
8147         if set strchr val -f d_strchr; eval $csym; $val; then
8148                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8149                         val="$define"
8150                         vali="$undef"
8151                         echo "strchr() found." >&4
8152                 else
8153                         val="$undef"
8154                         vali="$define"
8155                         echo "index() found." >&4
8156                 fi
8157         else
8158                 val="$undef"
8159                 vali="$define"
8160                 echo "index() found." >&4
8161         fi
8162 else
8163         if set strchr val -f d_strchr; eval $csym; $val; then
8164                 val="$define"
8165                 vali="$undef"
8166                 echo "strchr() found." >&4
8167         else
8168                 echo "No index() or strchr() found!" >&4
8169                 val="$undef"
8170                 vali="$undef"
8171         fi
8172 fi
8173 set d_strchr; eval $setvar
8174 val="$vali"
8175 set d_index; eval $setvar
8176
8177 : check whether inet_aton exists
8178 set inet_aton d_inetaton
8179 eval $inlibc
8180
8181 : see if inttypes.h is available
8182 : we want a real compile instead of Inhdr because some systems
8183 : have an inttypes.h which includes non-existent headers
8184 echo " "
8185 $cat >try.c <<EOCP
8186 #include <inttypes.h>
8187 int main() {
8188         static int32_t foo32 = 0x12345678;
8189 }
8190 EOCP
8191 set try
8192 if eval $compile; then
8193         echo "<inttypes.h> found." >&4
8194         val="$define"
8195 else
8196         echo "<inttypes.h> NOT found." >&4
8197         val="$undef"
8198 fi
8199 $rm -f try.c try
8200 set i_inttypes
8201 eval $setvar
8202
8203 : check for int64_t
8204 case "$use64bits" in
8205 "$define" )
8206         echo " "
8207         echo $n "Checking to see if your system supports int64_t...$c" >&4
8208         $cat >try.c <<EOCP
8209 #include <sys/types.h>
8210 #$i_inttypes I_INTTYPES
8211 #ifdef I_INTTYPES
8212 #include <inttypes.h>
8213 #endif
8214 int64_t foo() { int64_t x; x = 7; return x; }
8215 EOCP
8216         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8217                 val="$define"
8218                 echo " Yup, it does." >&4
8219         else
8220                 val="$undef"
8221                 echo " Nope, it doesn't." >&4
8222         fi
8223         $rm -f try.*
8224         ;;
8225 *)      val="$undef"
8226         ;;
8227 esac
8228 set d_int64t
8229 eval $setvar
8230
8231
8232 : Look for isascii
8233 echo " "
8234 $cat >isascii.c <<'EOCP'
8235 #include <stdio.h>
8236 #include <ctype.h>
8237 main() {
8238         int c = 'A';
8239         if (isascii(c))
8240                 exit(0);
8241         else
8242                 exit(1);
8243 }
8244 EOCP
8245 set isascii
8246 if eval $compile; then
8247         echo "isascii() found." >&4
8248         val="$define"
8249 else
8250         echo "isascii() NOT found." >&4
8251         val="$undef"
8252 fi
8253 set d_isascii
8254 eval $setvar
8255 $rm -f isascii*
8256
8257 : see if killpg exists
8258 set killpg d_killpg
8259 eval $inlibc
8260
8261 : see if lchown exists
8262 echo " "
8263 $cat > try.c <<'EOCP'
8264 /* System header to define __stub macros and hopefully few prototypes,
8265     which can conflict with char lchown(); below.  */
8266 #include <assert.h>
8267 /* Override any gcc2 internal prototype to avoid an error.  */
8268 /* We use char because int might match the return type of a gcc2
8269    builtin and then its argument prototype would still apply.  */
8270 char lchown();
8271 int main() {
8272     /*  The GNU C library defines this for functions which it implements
8273         to always fail with ENOSYS.  Some functions are actually named
8274         something starting with __ and the normal name is an alias.  */
8275 #if defined (__stub_lchown) || defined (__stub___lchown)
8276 choke me
8277 #else
8278 lchown();
8279 #endif
8280 ; return 0; }
8281 EOCP
8282 set try
8283 if eval $compile; then
8284     $echo "lchown() found." >&4
8285     val="$define"
8286 else
8287     $echo "lchown() NOT found." >&4
8288     val="$undef"
8289 fi
8290 set d_lchown
8291 eval $setvar
8292
8293 : see if link exists
8294 set link d_link
8295 eval $inlibc
8296
8297 : see if localeconv exists
8298 set localeconv d_locconv
8299 eval $inlibc
8300
8301 : see if lockf exists
8302 set lockf d_lockf
8303 eval $inlibc
8304
8305 : check for length of double
8306 echo " "
8307 case "$doublesize" in
8308 '')
8309         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8310         $cat >try.c <<'EOCP'
8311 #include <stdio.h>
8312 main()
8313 {
8314         printf("%d\n", sizeof(double));
8315 }
8316 EOCP
8317         set try
8318         if eval $compile_ok; then
8319                 doublesize=`./try`
8320                 $echo " $doublesize bytes." >&4
8321         else
8322                 dflt='8'
8323                 echo "(I can't seem to compile the test program.  Guessing...)"
8324                 rp="What is the size of a double precision number (in bytes)?"
8325                 . ./myread
8326                 doublesize="$ans"
8327         fi
8328         ;;
8329 esac
8330 $rm -f try.c try
8331
8332 : check for long doubles
8333 echo " "
8334 echo $n "Checking to see if your system supports long doubles...$c" >&4
8335 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8336 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8337         val="$define"
8338         echo " Yup, it does." >&4
8339 else
8340         val="$undef"
8341         echo " Nope, it doesn't." >&4
8342 fi
8343 $rm try.*
8344 set d_longdbl
8345 eval $setvar
8346
8347 : check for length of long double
8348 case "${d_longdbl}${longdblsize}" in
8349 $define)
8350         echo " "
8351         $echo $n "Checking to see how big your long doubles are...$c" >&4
8352         $cat >try.c <<'EOCP'
8353 #include <stdio.h>
8354 int main()
8355 {
8356         printf("%d\n", sizeof(long double));
8357 }
8358 EOCP
8359         set try
8360         if eval $compile; then
8361                 longdblsize=`./try`
8362                 $echo " $longdblsize bytes." >&4
8363         else
8364                 dflt='8'
8365                 echo " "
8366                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8367                 rp="What is the size of a long double (in bytes)?"
8368                 . ./myread
8369                 longdblsize="$ans"
8370         fi
8371         if $test "X$doublesize" = "X$longdblsize"; then
8372                 echo "(That isn't any different from an ordinary double.)"
8373         fi      
8374         ;;
8375 esac
8376 $rm -f try.c try
8377
8378 : check for long long
8379 echo " "
8380 echo $n "Checking to see if your system supports long long...$c" >&4
8381 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8382 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8383         val="$define"
8384         echo " Yup, it does." >&4
8385 else
8386         val="$undef"
8387         echo " Nope, it doesn't." >&4
8388 fi
8389 $rm try.*
8390 set d_longlong
8391 eval $setvar
8392
8393 : check for length of long long
8394 case "${d_longlong}${longlongsize}" in
8395 $define)
8396         echo " "
8397         $echo $n "Checking to see how big your long longs are...$c" >&4
8398         $cat >try.c <<'EOCP'
8399 #include <stdio.h>
8400 int main()
8401 {
8402         printf("%d\n", sizeof(long long));
8403 }
8404 EOCP
8405         set try
8406         if eval $compile_ok; then
8407                 longlongsize=`./try`
8408                 $echo " $longlongsize bytes." >&4
8409         else
8410                 dflt='8'
8411                 echo " "
8412                 echo "(I can't seem to compile the test program.  Guessing...)"
8413                 rp="What is the size of a long long (in bytes)?"
8414                 . ./myread
8415                 longlongsize="$ans"
8416         fi
8417         if $test "X$longsize" = "X$longlongsize"; then
8418                 echo "(That isn't any different from an ordinary long.)"
8419         fi      
8420         ;;
8421 esac
8422 $rm -f try.c try
8423
8424 : see if lstat exists
8425 set lstat d_lstat
8426 eval $inlibc
8427
8428 : see if mblen exists
8429 set mblen d_mblen
8430 eval $inlibc
8431
8432 : see if mbstowcs exists
8433 set mbstowcs d_mbstowcs
8434 eval $inlibc
8435
8436 : see if mbtowc exists
8437 set mbtowc d_mbtowc
8438 eval $inlibc
8439
8440 : see if memcmp exists
8441 set memcmp d_memcmp
8442 eval $inlibc
8443
8444 : see if memcpy exists
8445 set memcpy d_memcpy
8446 eval $inlibc
8447
8448 : see if memmove exists
8449 set memmove d_memmove
8450 eval $inlibc
8451
8452 : see if memset exists
8453 set memset d_memset
8454 eval $inlibc
8455
8456 : see if mkdir exists
8457 set mkdir d_mkdir
8458 eval $inlibc
8459
8460 : see if mkfifo exists
8461 set mkfifo d_mkfifo
8462 eval $inlibc
8463
8464 : see if mktime exists
8465 set mktime d_mktime
8466 eval $inlibc
8467
8468 : see if msgctl exists
8469 set msgctl d_msgctl
8470 eval $inlibc
8471
8472 : see if msgget exists
8473 set msgget d_msgget
8474 eval $inlibc
8475
8476 : see if msgsnd exists
8477 set msgsnd d_msgsnd
8478 eval $inlibc
8479
8480 : see if msgrcv exists
8481 set msgrcv d_msgrcv
8482 eval $inlibc
8483
8484 : see how much of the 'msg*(2)' library is present.
8485 h_msg=true
8486 echo " "
8487 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8488 *"$undef"*) h_msg=false;;
8489 esac
8490 case "$osname" in
8491 freebsd)
8492     case "`ipcs 2>&1`" in
8493     "SVID messages"*"not configured"*)
8494         echo "Your $osname does not have the msg*(2) configured." >&4
8495         h_msg=false
8496         val="$undef"
8497         set msgctl d_msgctl
8498         eval $setvar
8499         set msgget d_msgget
8500         eval $setvar
8501         set msgsnd d_msgsnd
8502         eval $setvar
8503         set msgrcv d_msgrcv
8504         eval $setvar
8505         ;;
8506     esac
8507     ;;
8508 esac
8509 : we could also check for sys/ipc.h ...
8510 if $h_msg && $test `./findhdr sys/msg.h`; then
8511         echo "You have the full msg*(2) library." >&4
8512         val="$define"
8513 else
8514         echo "You don't have the full msg*(2) library." >&4
8515         val="$undef"
8516 fi
8517 set d_msg
8518 eval $setvar
8519
8520 : see if nice exists
8521 set nice d_nice
8522 eval $inlibc
8523
8524 : how to create joinable pthreads
8525 if test "X$usethreads" = "X$define"; then
8526         echo " "
8527         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8528         $cat >try.c <<'EOCP'
8529 #include <pthread.h>
8530 int main() {
8531     int detachstate = JOINABLE;
8532 }
8533 EOCP
8534         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8535         if eval $compile; then
8536                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&2
8537                 val="$undef" # Yes, undef.
8538                 set d_old_pthread_create_joinable
8539                 eval $setvar
8540                 val=""
8541                 set old_pthread_create_joinable
8542                 eval $setvar
8543         else
8544                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8545                 if eval $compile; then
8546                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&2
8547                         val="$define"
8548                         set d_old_pthread_create_joinable
8549                         eval $setvar
8550                         val=PTHREAD_CREATE_UNDETACHED
8551                         set old_pthread_create_joinable
8552                         eval $setvar
8553                 else            
8554                         set try -DJOINABLE=__UNDETACHED
8555                         if eval $compile; then
8556                                 echo "You seem to use __UNDETACHED." >&2
8557                                 val="$define"
8558                                 set d_old_pthread_create_joinable
8559                                 eval $setvar
8560                                 val=__UNDETACHED
8561                                 set old_pthread_create_joinable
8562                                 eval $setvar
8563                         else
8564                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&2
8565                                 val="$define"
8566                                 set d_old_pthread_create_joinable
8567                                 eval $setvar
8568                                 val=0
8569                                 set old_pthread_create_joinable
8570                                 eval $setvar
8571                         fi
8572                 fi
8573         fi
8574         $rm -f try try.*
8575 else
8576     d_old_pthread_create_joinable="$undef"
8577     old_pthread_create_joinable=""
8578 fi
8579
8580 : see if pause exists
8581 set pause d_pause
8582 eval $inlibc
8583
8584 : see if pipe exists
8585 set pipe d_pipe
8586 eval $inlibc
8587
8588 : see if poll exists
8589 set poll d_poll
8590 eval $inlibc
8591
8592
8593 : see whether the various POSIXish _yields exist
8594 $cat >try.c <<EOP
8595 #include <pthread.h>
8596 #include <stdio.h>
8597 int main() {
8598 #ifdef SCHED_YIELD
8599         sched_yield();
8600 #else
8601 #ifdef PTHREAD_YIELD
8602         pthread_yield();
8603 #else
8604 #ifdef PTHREAD_YIELD_NULL
8605         pthread_yield(NULL);
8606 #endif
8607 #endif
8608 #endif
8609 }
8610 EOP
8611 : see if sched_yield exists
8612 set try -DSCHED_YIELD
8613 if eval $compile; then
8614     val="$define"
8615     sched_yield='sched_yield()'
8616 else
8617     val="$undef"
8618 fi
8619 case "$usethreads" in
8620 $define)
8621         case "$val" in
8622         $define) echo 'sched_yield() found.' >&4        ;;
8623         *)       echo 'sched_yield() NOT found.' >&4    ;;
8624         esac
8625 esac
8626 set d_sched_yield
8627 eval $setvar
8628
8629 : see if pthread_yield exists
8630 set try -DPTHREAD_YIELD
8631 if eval $compile; then
8632     val="$define"
8633     case "$sched_yield" in
8634     '') sched_yield='pthread_yield()' ;;
8635     esac
8636 else
8637     set try -DPTHREAD_YIELD_NULL
8638     if eval $compile; then
8639         val="$define"
8640         case "$sched_yield" in
8641         '') sched_yield='pthread_yield(NULL)' ;;
8642         esac
8643     else
8644         val="$undef"
8645     fi
8646 fi
8647 case "$usethreads" in
8648 $define)
8649         case "$val" in
8650         $define) echo 'pthread_yield() found.' >&4      ;;
8651         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8652         esac
8653         ;;
8654 esac
8655 set d_pthread_yield
8656 eval $setvar
8657
8658 case "$sched_yield" in
8659 '') sched_yield=undef ;;
8660 esac
8661
8662 $rm -f try try.*
8663
8664 : see if this is a pwd.h system
8665 set pwd.h i_pwd
8666 eval $inhdr
8667
8668 case "$i_pwd" in
8669 $define)
8670         xxx=`./findhdr pwd.h`
8671         $cppstdin $cppflags $cppminus < $xxx >$$.h
8672
8673         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8674                 val="$define"
8675         else
8676                 val="$undef"
8677         fi
8678         set d_pwquota
8679         eval $setvar
8680
8681         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
8682                 val="$define"
8683         else
8684                 val="$undef"
8685         fi
8686         set d_pwage
8687         eval $setvar
8688
8689         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
8690                 val="$define"
8691         else
8692                 val="$undef"
8693         fi
8694         set d_pwchange
8695         eval $setvar
8696
8697         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
8698                 val="$define"
8699         else
8700                 val="$undef"
8701         fi
8702         set d_pwclass
8703         eval $setvar
8704
8705         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
8706                 val="$define"
8707         else
8708                 val="$undef"
8709         fi
8710         set d_pwexpire
8711         eval $setvar
8712
8713         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
8714                 val="$define"
8715         else
8716                 val="$undef"
8717         fi
8718         set d_pwcomment
8719         eval $setvar
8720
8721         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
8722                 val="$define"
8723         else
8724                 val="$undef"
8725         fi
8726         set d_pwgecos
8727         eval $setvar
8728
8729         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
8730                 val="$define"
8731         else
8732                 val="$undef"
8733         fi
8734         set d_pwpasswd
8735         eval $setvar
8736
8737         $rm -f $$.h
8738         ;;
8739 *)
8740         val="$undef"; 
8741         set d_pwquota; eval $setvar
8742         set d_pwage; eval $setvar
8743         set d_pwchange; eval $setvar
8744         set d_pwclass; eval $setvar
8745         set d_pwexpire; eval $setvar
8746         set d_pwcomment; eval $setvar
8747         set d_pwgecos; eval $setvar
8748         set d_pwpasswd; eval $setvar
8749         ;;
8750 esac
8751
8752 : see if readdir and friends exist
8753 set readdir d_readdir
8754 eval $inlibc
8755 set seekdir d_seekdir
8756 eval $inlibc
8757 set telldir d_telldir
8758 eval $inlibc
8759 set rewinddir d_rewinddir
8760 eval $inlibc
8761
8762 : see if readlink exists
8763 set readlink d_readlink
8764 eval $inlibc
8765
8766 : see if readv exists
8767 set readv d_readv
8768 eval $inlibc
8769
8770 : see if rename exists
8771 set rename d_rename
8772 eval $inlibc
8773
8774 : see if rmdir exists
8775 set rmdir d_rmdir
8776 eval $inlibc
8777
8778 : see if memory.h is available.
8779 val=''
8780 set memory.h val
8781 eval $inhdr
8782
8783 : See if it conflicts with string.h
8784 case "$val" in
8785 $define)
8786         case "$strings" in
8787         '') ;;
8788         *)
8789                 $cppstdin $cppflags $cppminus < $strings > mem.h
8790                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
8791                         echo " "
8792                         echo "We won't be including <memory.h>."
8793                         val="$undef"
8794                 fi
8795                 $rm -f mem.h
8796                 ;;
8797         esac
8798 esac
8799 set i_memory
8800 eval $setvar
8801
8802 : can bcopy handle overlapping blocks?
8803 val="$undef"
8804 case "$d_bcopy" in
8805 "$define")
8806         echo " "
8807         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
8808         $cat >try.c <<EOCP
8809 #$i_memory I_MEMORY
8810 #$i_stdlib I_STDLIB
8811 #$i_string I_STRING
8812 #$i_unistd I_UNISTD
8813 EOCP
8814         $cat >>try.c <<'EOCP'
8815 #include <stdio.h>
8816 #ifdef I_MEMORY
8817 #  include <memory.h>
8818 #endif
8819 #ifdef I_STDLIB
8820 #  include <stdlib.h>
8821 #endif
8822 #ifdef I_STRING
8823 #  include <string.h>
8824 #else
8825 #  include <strings.h>
8826 #endif
8827 #ifdef I_UNISTD
8828 #  include <unistd.h>  /* Needed for NetBSD */
8829 #endif
8830 main()
8831 {
8832 char buf[128], abc[128];
8833 char *b;
8834 int len;
8835 int off;
8836 int align;
8837
8838 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
8839
8840 for (align = 7; align >= 0; align--) {
8841         for (len = 36; len; len--) {
8842                 b = buf+align;
8843                 bcopy(abc, b, len);
8844                 for (off = 1; off <= len; off++) {
8845                         bcopy(b, b+off, len);
8846                         bcopy(b+off, b, len);
8847                         if (bcmp(b, abc, len))
8848                                 exit(1);
8849                 }
8850         }
8851 }
8852 exit(0);
8853 }
8854 EOCP
8855         set try
8856         if eval $compile_ok; then
8857                 if ./try 2>/dev/null; then
8858                         echo "Yes, it can."
8859                         val="$define"
8860                 else
8861                         echo "It can't, sorry."
8862                         case "$d_memmove" in
8863                         "$define") echo "But that's Ok since you have memmove()." ;;
8864                         esac
8865                 fi
8866         else
8867                 echo "(I can't compile the test program, so we'll assume not...)"
8868                 case "$d_memmove" in
8869                 "$define") echo "But that's Ok since you have memmove()." ;;
8870                 esac
8871         fi
8872         ;;
8873 esac
8874 $rm -f try.* try core
8875 set d_safebcpy
8876 eval $setvar
8877
8878 : can memcpy handle overlapping blocks?
8879 val="$undef"
8880 case "$d_memcpy" in
8881 "$define")
8882         echo " "
8883         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
8884         $cat >try.c <<EOCP
8885 #$i_memory I_MEMORY
8886 #$i_stdlib I_STDLIB
8887 #$i_string I_STRING
8888 #$i_unistd I_UNISTD
8889 EOCP
8890         $cat >>try.c <<'EOCP'
8891 #include <stdio.h>
8892 #ifdef I_MEMORY
8893 #  include <memory.h>
8894 #endif
8895 #ifdef I_STDLIB
8896 #  include <stdlib.h>
8897 #endif
8898 #ifdef I_STRING
8899 #  include <string.h>
8900 #else
8901 #  include <strings.h>
8902 #endif
8903 #ifdef I_UNISTD
8904 #  include <unistd.h>  /* Needed for NetBSD */
8905 #endif
8906 main()
8907 {
8908 char buf[128], abc[128];
8909 char *b;
8910 int len;
8911 int off;
8912 int align;
8913
8914 /* Copy "abcde..." string to char abc[] so that gcc doesn't
8915    try to store the string in read-only memory. */
8916 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
8917
8918 for (align = 7; align >= 0; align--) {
8919         for (len = 36; len; len--) {
8920                 b = buf+align;
8921                 memcpy(b, abc, len);
8922                 for (off = 1; off <= len; off++) {
8923                         memcpy(b+off, b, len);
8924                         memcpy(b, b+off, len);
8925                         if (memcmp(b, abc, len))
8926                                 exit(1);
8927                 }
8928         }
8929 }
8930 exit(0);
8931 }
8932 EOCP
8933         set try
8934         if eval $compile_ok; then
8935                 if ./try 2>/dev/null; then
8936                         echo "Yes, it can."
8937                         val="$define"
8938                 else
8939                         echo "It can't, sorry."
8940                         case "$d_memmove" in
8941                         "$define") echo "But that's Ok since you have memmove()." ;;
8942                         esac
8943                 fi
8944         else
8945                 echo "(I can't compile the test program, so we'll assume not...)"
8946                 case "$d_memmove" in
8947                 "$define") echo "But that's Ok since you have memmove()." ;;
8948                 esac
8949         fi
8950         ;;
8951 esac
8952 $rm -f try.* try core
8953 set d_safemcpy
8954 eval $setvar
8955
8956 : can memcmp be trusted to compare relative magnitude?
8957 val="$undef"
8958 case "$d_memcmp" in
8959 "$define")
8960         echo " "
8961         echo "Checking if your memcmp() can compare relative magnitude..." >&4
8962         $cat >try.c <<EOCP
8963 #$i_memory I_MEMORY
8964 #$i_stdlib I_STDLIB
8965 #$i_string I_STRING
8966 #$i_unistd I_UNISTD
8967 EOCP
8968         $cat >>try.c <<'EOCP'
8969 #include <stdio.h>
8970 #ifdef I_MEMORY
8971 #  include <memory.h>
8972 #endif
8973 #ifdef I_STDLIB
8974 #  include <stdlib.h>
8975 #endif
8976 #ifdef I_STRING
8977 #  include <string.h>
8978 #else
8979 #  include <strings.h>
8980 #endif
8981 #ifdef I_UNISTD
8982 #  include <unistd.h>  /* Needed for NetBSD */
8983 #endif
8984 main()
8985 {
8986 char a = -1;
8987 char b = 0;
8988 if ((a < b) && memcmp(&a, &b, 1) < 0)
8989         exit(1);
8990 exit(0);
8991 }
8992 EOCP
8993         set try
8994         if eval $compile_ok; then
8995                 if ./try 2>/dev/null; then
8996                         echo "Yes, it can."
8997                         val="$define"
8998                 else
8999                         echo "No, it can't (it uses signed chars)."
9000                 fi
9001         else
9002                 echo "(I can't compile the test program, so we'll assume not...)"
9003         fi
9004         ;;
9005 esac
9006 $rm -f try.* try core
9007 set d_sanemcmp
9008 eval $setvar
9009
9010 : see if select exists
9011 set select d_select
9012 eval $inlibc
9013
9014 : see if semctl exists
9015 set semctl d_semctl
9016 eval $inlibc
9017
9018 : see if semget exists
9019 set semget d_semget
9020 eval $inlibc
9021
9022 : see if semop exists
9023 set semop d_semop
9024 eval $inlibc
9025
9026 : see how much of the 'sem*(2)' library is present.
9027 h_sem=true
9028 echo " "
9029 case "$d_semctl$d_semget$d_semop" in
9030 *"$undef"*) h_sem=false;;
9031 esac
9032 case "$osname" in
9033 freebsd)
9034     case "`ipcs 2>&1`" in
9035     "SVID messages"*"not configured"*)
9036         echo "Your $osname does not have the sem*(2) configured." >&4
9037         h_sem=false
9038         val="$undef"
9039         set semctl d_semctl
9040         eval $setvar
9041         set semget d_semget
9042         eval $setvar
9043         set semop d_semop
9044         eval $setvar
9045         ;;
9046     esac
9047     ;;
9048 esac
9049 : we could also check for sys/ipc.h ...
9050 if $h_sem && $test `./findhdr sys/sem.h`; then
9051         echo "You have the full sem*(2) library." >&4
9052         val="$define"
9053 else
9054         echo "You don't have the full sem*(2) library." >&4
9055         val="$undef"
9056 fi
9057 set d_sem
9058 eval $setvar
9059
9060 : see whether sys/sem.h defines union semun
9061 echo " "
9062 $cat > try.c <<'END'
9063 #include <sys/types.h>
9064 #include <sys/ipc.h>
9065 #include <sys/sem.h>
9066 int main () { union semun semun; semun.buf = 0; }
9067 END
9068 set try
9069 if eval $compile; then
9070     echo "You have union semun in <sys/sem.h>." >&4
9071     val="$define"
9072 else
9073     echo "You do not have union semun in <sys/sem.h>." >&4
9074     val="$undef"
9075 fi
9076 $rm -f try try.c try.h
9077 set d_union_semun
9078 eval $setvar
9079
9080 : see how to do semctl IPC_STAT
9081 case "$d_sem" in
9082 $define)
9083     : see whether semctl IPC_STAT can use union semun
9084     echo " "
9085     $cat > try.h <<END
9086 #ifndef S_IRUSR
9087 #   ifdef S_IREAD
9088 #       define S_IRUSR S_IREAD
9089 #       define S_IWUSR S_IWRITE
9090 #       define S_IXUSR S_IEXEC
9091 #   else
9092 #       define S_IRUSR 0400
9093 #       define S_IWUSR 0200
9094 #       define S_IXUSR 0100
9095 #   endif
9096 #   define S_IRGRP (S_IRUSR>>3)
9097 #   define S_IWGRP (S_IWUSR>>3)
9098 #   define S_IXGRP (S_IXUSR>>3)
9099 #   define S_IROTH (S_IRUSR>>6)
9100 #   define S_IWOTH (S_IWUSR>>6)
9101 #   define S_IXOTH (S_IXUSR>>6)
9102 #endif
9103 #ifndef S_IRWXU
9104 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9105 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9106 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9107 #endif
9108 END
9109
9110     $cat > try.c <<END
9111 #include <sys/types.h>
9112 #include <sys/ipc.h>
9113 #include <sys/sem.h>
9114 #include <sys/stat.h>
9115 #include <stdio.h>
9116 #include <errno.h>
9117 #include "try.h"
9118 #ifndef errno
9119 extern int errno;
9120 #endif
9121 #$d_union_semun HAS_UNION_SEMUN
9122 int main() {
9123     union semun
9124 #ifndef HAS_UNION_SEMUN
9125     {
9126         int val;
9127         struct semid_ds *buf;
9128         unsigned short *array;
9129     }
9130 #endif
9131     arg;
9132     int sem, st;
9133
9134 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9135     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9136     if (sem > -1) {
9137         struct semid_ds argbuf;
9138         arg.buf = &argbuf;
9139 #       ifdef IPC_STAT
9140         st = semctl(sem, 0, IPC_STAT, arg);
9141         if (st == 0)
9142             printf("semun\n");
9143         else
9144 #       endif /* IPC_STAT */
9145             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9146 #       ifdef IPC_RMID
9147         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9148 #       endif /* IPC_RMID */
9149             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9150     } else
9151 #endif /* IPC_PRIVATE && ... */
9152         printf("semget failed: errno = %d\n", errno);
9153   return 0;
9154 }
9155 END
9156     val="$undef"
9157     set try
9158     if eval $compile; then
9159         xxx=`./try`
9160         case "$xxx" in
9161         semun) val="$define" ;;
9162         esac
9163     fi
9164     $rm -f try try.c
9165     set d_semctl_semun
9166     eval $setvar
9167     case "$d_semctl_semun" in
9168     $define)
9169         echo "You can use union semun for semctl IPC_STAT." >&4
9170         also='also'
9171         ;;
9172     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9173         also=''
9174         ;;
9175     esac
9176
9177     : see whether semctl IPC_STAT can use struct semid_ds pointer
9178     $cat > try.c <<'END'
9179 #include <sys/types.h>
9180 #include <sys/ipc.h>
9181 #include <sys/sem.h>
9182 #include <sys/stat.h>
9183 #include "try.h"
9184 #include <stdio.h>
9185 #include <errno.h>
9186 #ifndef errno
9187 extern int errno;
9188 #endif
9189 int main() {
9190     struct semid_ds arg;
9191     int sem, st;
9192
9193 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9194     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9195     if (sem > -1) {
9196 #       ifdef IPC_STAT
9197         st = semctl(sem, 0, IPC_STAT, &arg);
9198         if (st == 0)
9199             printf("semid_ds\n");
9200         else
9201 #       endif /* IPC_STAT */
9202             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9203 #       ifdef IPC_RMID
9204         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9205 #       endif /* IPC_RMID */
9206             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9207     } else
9208 #endif /* IPC_PRIVATE && ... */
9209         printf("semget failed: errno = %d\n", errno);
9210
9211     return 0;
9212 }
9213 END
9214     val="$undef"
9215     set try
9216     if eval $compile; then
9217         xxx=`./try`
9218         case "$xxx" in
9219         semid_ds) val="$define" ;;
9220         esac
9221     fi
9222     $rm -f try try.c
9223     set d_semctl_semid_ds
9224     eval $setvar
9225     case "$d_semctl_semid_ds" in
9226     $define)
9227         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9228         ;;
9229     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9230         ;;
9231     esac
9232     $rm -f try.h
9233     ;;
9234 *)  val="$undef"
9235
9236     # We do not have the full sem*(2) library, so assume we can not
9237     # use either.
9238
9239     set d_semctl_semun
9240     eval $setvar
9241
9242     set d_semctl_semid_ds
9243     eval $setvar
9244     ;;
9245 esac
9246
9247 : see if setegid exists
9248 set setegid d_setegid
9249 eval $inlibc
9250
9251 : see if seteuid exists
9252 set seteuid d_seteuid
9253 eval $inlibc
9254
9255 : see if setgrent exists
9256 set setgrent d_setgrent
9257 eval $inlibc
9258
9259 : see if sethostent exists
9260 set sethostent d_sethent
9261 eval $inlibc
9262
9263 : see if setlinebuf exists
9264 set setlinebuf d_setlinebuf
9265 eval $inlibc
9266
9267 : see if setlocale exists
9268 set setlocale d_setlocale
9269 eval $inlibc
9270
9271 : see if setnetent exists
9272 set setnetent d_setnent
9273 eval $inlibc
9274
9275 : see if setprotoent exists
9276 set setprotoent d_setpent
9277 eval $inlibc
9278
9279 : see if setpgid exists
9280 set setpgid d_setpgid
9281 eval $inlibc
9282
9283 : see if setpgrp2 exists
9284 set setpgrp2 d_setpgrp2
9285 eval $inlibc
9286
9287 : see if setpriority exists
9288 set setpriority d_setprior
9289 eval $inlibc
9290
9291 : see if setpwent exists
9292 set setpwent d_setpwent
9293 eval $inlibc
9294
9295 : see if setregid exists
9296 set setregid d_setregid
9297 eval $inlibc
9298 set setresgid d_setresgid
9299 eval $inlibc
9300
9301 : see if setreuid exists
9302 set setreuid d_setreuid
9303 eval $inlibc
9304 set setresuid d_setresuid
9305 eval $inlibc
9306
9307 : see if setrgid exists
9308 set setrgid d_setrgid
9309 eval $inlibc
9310
9311 : see if setruid exists
9312 set setruid d_setruid
9313 eval $inlibc
9314
9315 : see if setservent exists
9316 set setservent d_setsent
9317 eval $inlibc
9318
9319 : see if setsid exists
9320 set setsid d_setsid
9321 eval $inlibc
9322
9323 : see if setvbuf exists
9324 set setvbuf d_setvbuf
9325 eval $inlibc
9326
9327 : see if sfio.h is available
9328 set sfio.h i_sfio
9329 eval $inhdr
9330
9331
9332 : see if sfio library is available
9333 case "$i_sfio" in
9334 $define)
9335         val=''
9336         set sfreserve val
9337         eval $inlibc
9338         ;;
9339 *)
9340         val="$undef"
9341         ;;
9342 esac
9343 : Ok, but do we want to use it.
9344 case "$val" in
9345 $define)
9346         case "$usesfio" in
9347         true|$define|[yY]*) dflt='y';;
9348         *) dflt='n';;
9349         esac
9350         echo "$package can use the sfio library, but it is experimental."
9351         rp="You seem to have sfio available, do you want to try using it?"
9352         . ./myread
9353         case "$ans" in
9354         y|Y) ;;
9355         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9356                 val="$undef"
9357                 : Remove sfio from list of libraries to use
9358                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9359                 shift
9360                 libs="$*"
9361                 echo "libs = $libs" >&4
9362                 ;;
9363         esac
9364         ;;
9365 *)      case "$usesfio" in
9366         true|$define|[yY]*)
9367                 echo "Sorry, cannot find sfio on this machine" >&4
9368                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9369                 ;;
9370         esac
9371         ;;
9372 esac
9373 set d_sfio
9374 eval $setvar
9375 case "$d_sfio" in
9376 $define) usesfio='true';;
9377 *) usesfio='false';;
9378 esac
9379
9380 : see if shmctl exists
9381 set shmctl d_shmctl
9382 eval $inlibc
9383
9384 : see if shmget exists
9385 set shmget d_shmget
9386 eval $inlibc
9387
9388 : see if shmat exists
9389 set shmat d_shmat
9390 eval $inlibc
9391 : see what shmat returns
9392 case "$d_shmat" in
9393 "$define")
9394         $cat >shmat.c <<'END'
9395 #include <sys/shm.h>
9396 void *shmat();
9397 END
9398         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9399                 shmattype='void *'
9400         else
9401                 shmattype='char *'
9402         fi
9403         echo "and it returns ($shmattype)." >&4
9404         : see if a prototype for shmat is available
9405         xxx=`./findhdr sys/shm.h`
9406         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9407         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9408                 val="$define"
9409         else
9410                 val="$undef"
9411         fi
9412         $rm -f shmat.[co]
9413         ;;
9414 *)
9415         val="$undef"
9416         ;;
9417 esac
9418 set d_shmatprototype
9419 eval $setvar
9420
9421 : see if shmdt exists
9422 set shmdt d_shmdt
9423 eval $inlibc
9424
9425 : see how much of the 'shm*(2)' library is present.
9426 h_shm=true
9427 echo " "
9428 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9429 *"$undef"*) h_shm=false;;
9430 esac
9431 case "$osname" in
9432 freebsd)
9433     case "`ipcs 2>&1`" in
9434     "SVID shared memory"*"not configured"*)
9435         echo "Your $osname does not have the shm*(2) configured." >&4
9436         h_shm=false
9437         val="$undef"
9438         set shmctl d_shmctl
9439         evat $setvar
9440         set shmget d_shmget
9441         evat $setvar
9442         set shmat d_shmat
9443         evat $setvar
9444         set shmdt d_shmdt
9445         evat $setvar
9446         ;;
9447     esac
9448     ;;
9449 esac
9450 : we could also check for sys/ipc.h ...
9451 if $h_shm && $test `./findhdr sys/shm.h`; then
9452         echo "You have the full shm*(2) library." >&4
9453         val="$define"
9454 else
9455         echo "You don't have the full shm*(2) library." >&4
9456         val="$undef"
9457 fi
9458 set d_shm
9459 eval $setvar
9460
9461 echo " "
9462 : see if we have sigaction
9463 if set sigaction val -f d_sigaction; eval $csym; $val; then
9464         echo 'sigaction() found.' >&4
9465         $cat > try.c <<'EOP'
9466 #include <stdio.h>
9467 #include <sys/types.h>
9468 #include <signal.h>
9469 main()
9470 {
9471     struct sigaction act, oact;
9472 }
9473 EOP
9474         set try
9475         if eval $compile_ok; then
9476                 val="$define"
9477         else
9478                 echo "But you don't seem to have a useable struct sigaction." >&4
9479                 val="$undef"
9480         fi
9481 else
9482         echo 'sigaction NOT found.' >&4
9483         val="$undef"
9484 fi
9485 set d_sigaction; eval $setvar
9486 $rm -f try try$_o try.c
9487
9488 : see if sigsetjmp exists
9489 echo " "
9490 case "$d_sigsetjmp" in
9491 '')
9492         $cat >try.c <<'EOP'
9493 #include <setjmp.h>
9494 sigjmp_buf env;
9495 int set = 1;
9496 main()
9497 {
9498         if (sigsetjmp(env,1))
9499                 exit(set);
9500         set = 0;
9501         siglongjmp(env, 1);
9502         exit(1);
9503 }
9504 EOP
9505         set try
9506         if eval $compile; then
9507                 if ./try >/dev/null 2>&1; then
9508                         echo "POSIX sigsetjmp found." >&4
9509                         val="$define"
9510                 else
9511                         $cat >&4 <<EOM
9512 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9513 I'll ignore them.
9514 EOM
9515                         val="$undef"
9516                 fi
9517         else
9518                 echo "sigsetjmp not found." >&4
9519                 val="$undef"
9520         fi
9521         ;;
9522 *) val="$d_sigsetjmp"
9523         case "$d_sigsetjmp" in
9524         $define) echo "POSIX sigsetjmp found." >&4;;
9525         $undef) echo "sigsetjmp not found." >&4;;
9526         esac
9527         ;;
9528 esac
9529 set d_sigsetjmp
9530 eval $setvar
9531 $rm -f try.c try
9532
9533 : see if stat knows about block sizes
9534 echo " "
9535 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9536 eval $hasfield
9537
9538 : see if _ptr and _cnt from stdio act std
9539 echo " "
9540 if $contains '_IO_fpos_t' `./findhdr stdio.h` >/dev/null 2>&1 ; then
9541         echo "(Looks like you have stdio.h from Linux.)"
9542         case "$stdio_ptr" in
9543         '') stdio_ptr='((fp)->_IO_read_ptr)'
9544                 ptr_lval=$define
9545                 ;;
9546         *)      ptr_lval=$d_stdio_ptr_lval;;
9547         esac
9548         case "$stdio_cnt" in
9549         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9550                 cnt_lval=$undef
9551                 ;;
9552         *)      cnt_lval=$d_stdio_cnt_lval;;
9553         esac
9554         case "$stdio_base" in
9555         '') stdio_base='((fp)->_IO_read_base)';;
9556         esac
9557         case "$stdio_bufsiz" in
9558         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9559         esac
9560 else
9561         case "$stdio_ptr" in
9562         '') stdio_ptr='((fp)->_ptr)'
9563                 ptr_lval=$define
9564                 ;;
9565         *)      ptr_lval=$d_stdio_ptr_lval;;
9566         esac
9567         case "$stdio_cnt" in
9568         '') stdio_cnt='((fp)->_cnt)'
9569                 cnt_lval=$define
9570                 ;;
9571         *)      cnt_lval=$d_stdio_cnt_lval;;
9572         esac
9573         case "$stdio_base" in
9574         '') stdio_base='((fp)->_base)';;
9575         esac
9576         case "$stdio_bufsiz" in
9577         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9578         esac
9579 fi
9580 : test whether _ptr and _cnt really work
9581 echo "Checking how std your stdio is..." >&4
9582 $cat >try.c <<EOP
9583 #include <stdio.h>
9584 #define FILE_ptr(fp)    $stdio_ptr
9585 #define FILE_cnt(fp)    $stdio_cnt
9586 main() {
9587         FILE *fp = fopen("try.c", "r");
9588         char c = getc(fp);
9589         if (
9590                 18 <= FILE_cnt(fp) &&
9591                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9592         )
9593                 exit(0);
9594         exit(1);
9595 }
9596 EOP
9597 val="$undef"
9598 set try
9599 if eval $compile; then
9600         if ./try; then
9601                 echo "Your stdio acts pretty std."
9602                 val="$define"
9603         else
9604                 echo "Your stdio isn't very std."
9605         fi
9606 else
9607         echo "Your stdio doesn't appear very std."
9608 fi
9609 $rm -f try.c try
9610 set d_stdstdio
9611 eval $setvar
9612
9613 : Can _ptr be used as an lvalue?
9614 case "$d_stdstdio$ptr_lval" in
9615 $define$define) val=$define ;;
9616 *) val=$undef ;;
9617 esac
9618 set d_stdio_ptr_lval
9619 eval $setvar
9620
9621 : Can _cnt be used as an lvalue?
9622 case "$d_stdstdio$cnt_lval" in
9623 $define$define) val=$define ;;
9624 *) val=$undef ;;
9625 esac
9626 set d_stdio_cnt_lval
9627 eval $setvar
9628
9629 : see if _base is also standard
9630 val="$undef"
9631 case "$d_stdstdio" in
9632 $define)
9633         $cat >try.c <<EOP
9634 #include <stdio.h>
9635 #define FILE_base(fp)   $stdio_base
9636 #define FILE_bufsiz(fp) $stdio_bufsiz
9637 main() {
9638         FILE *fp = fopen("try.c", "r");
9639         char c = getc(fp);
9640         if (
9641                 19 <= FILE_bufsiz(fp) &&
9642                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9643         )
9644                 exit(0);
9645         exit(1);
9646 }
9647 EOP
9648         set try
9649         if eval $compile; then
9650                 if ./try; then
9651                         echo "And its _base field acts std."
9652                         val="$define"
9653                 else
9654                         echo "But its _base field isn't std."
9655                 fi
9656         else
9657                 echo "However, it seems to be lacking the _base field."
9658         fi
9659         $rm -f try.c try
9660         ;;
9661 esac
9662 set d_stdiobase
9663 eval $setvar
9664
9665 : see if strcoll exists
9666 set strcoll d_strcoll
9667 eval $inlibc
9668
9669 : check for structure copying
9670 echo " "
9671 echo "Checking to see if your C compiler can copy structs..." >&4
9672 $cat >try.c <<'EOCP'
9673 int main()
9674 {
9675         struct blurfl {
9676                 int dyick;
9677         } foo, bar;
9678
9679         foo = bar;
9680 }
9681 EOCP
9682 if $cc -c try.c >/dev/null 2>&1 ; then
9683         val="$define"
9684         echo "Yup, it can."
9685 else
9686         val="$undef"
9687         echo "Nope, it can't."
9688 fi
9689 set d_strctcpy
9690 eval $setvar
9691 $rm -f try.*
9692
9693 : see if strerror and/or sys_errlist[] exist
9694 echo " "
9695 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
9696     if set strerror val -f d_strerror; eval $csym; $val; then
9697                 echo 'strerror() found.' >&4
9698                 d_strerror="$define"
9699                 d_strerrm='strerror(e)'
9700                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9701                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
9702                         d_syserrlst="$define"
9703                 else
9704                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
9705                         d_syserrlst="$undef"
9706                 fi
9707     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
9708                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
9709                 echo 'strerror() found in string header.' >&4
9710                 d_strerror="$define"
9711                 d_strerrm='strerror(e)'
9712                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9713                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
9714                                 d_syserrlst="$define"
9715                 else
9716                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
9717                         d_syserrlst="$undef"
9718                 fi
9719     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
9720                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
9721                 d_strerror="$undef"
9722                 d_syserrlst="$define"
9723                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
9724     else
9725                 echo 'strerror() and sys_errlist[] NOT found.' >&4
9726                 d_strerror="$undef"
9727                 d_syserrlst="$undef"
9728                 d_strerrm='"unknown"'
9729     fi
9730 fi
9731
9732 : see if strtod exists
9733 set strtod d_strtod
9734 eval $inlibc
9735
9736 : see if strtol exists
9737 set strtol d_strtol
9738 eval $inlibc
9739
9740 : see if strtoul exists
9741 set strtoul d_strtoul
9742 eval $inlibc
9743
9744 : see if strxfrm exists
9745 set strxfrm d_strxfrm
9746 eval $inlibc
9747
9748 : see if symlink exists
9749 set symlink d_symlink
9750 eval $inlibc
9751
9752 : see if syscall exists
9753 set syscall d_syscall
9754 eval $inlibc
9755
9756 : see if sysconf exists
9757 set sysconf d_sysconf
9758 eval $inlibc
9759
9760 : see if system exists
9761 set system d_system
9762 eval $inlibc
9763
9764 : see if tcgetpgrp exists
9765 set tcgetpgrp d_tcgetpgrp
9766 eval $inlibc
9767
9768 : see if tcsetpgrp exists
9769 set tcsetpgrp d_tcsetpgrp
9770 eval $inlibc
9771
9772 : define an is-a-typedef? function
9773 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9774 case "$inclist" in
9775 "") inclist="sys/types.h";;
9776 esac;
9777 eval "varval=\$$var";
9778 case "$varval" in
9779 "")
9780         $rm -f temp.c;
9781         for inc in $inclist; do
9782                 echo "#include <$inc>" >>temp.c;
9783         done;
9784         echo "#ifdef $type" >> temp.c;
9785         echo "printf(\"We have $type\");" >> temp.c;
9786         echo "#endif" >> temp.c;
9787         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9788         if $contains $type temp.E >/dev/null 2>&1; then
9789                 eval "$var=\$type";
9790         else
9791                 eval "$var=\$def";
9792         fi;
9793         $rm -f temp.?;;
9794 *) eval "$var=\$varval";;
9795 esac'
9796
9797 : define an is-a-typedef? function that prompts if the type is not available.
9798 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9799 case "$inclist" in
9800 "") inclist="sys/types.h";;
9801 esac;
9802 eval "varval=\$$var";
9803 case "$varval" in
9804 "")
9805         $rm -f temp.c;
9806         for inc in $inclist; do
9807                 echo "#include <$inc>" >>temp.c;
9808         done;
9809         echo "#ifdef $type" >> temp.c;
9810         echo "printf(\"We have $type\");" >> temp.c;
9811         echo "#endif" >> temp.c;
9812         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9813         echo " " ;
9814         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
9815         if $contains $type temp.E >/dev/null 2>&1; then
9816                 echo "$type found." >&4;
9817                 eval "$var=\$type";
9818         else
9819                 echo "$type NOT found." >&4;
9820                 dflt="$def";
9821                 . ./myread ;
9822                 eval "$var=\$ans";
9823         fi;
9824         $rm -f temp.?;;
9825 *) eval "$var=\$varval";;
9826 esac'
9827
9828 : see if this is a sys/times.h system
9829 set sys/times.h i_systimes
9830 eval $inhdr
9831
9832 : see if times exists
9833 echo " "
9834 if set times val -f d_times; eval $csym; $val; then
9835         echo 'times() found.' >&4
9836         d_times="$define"
9837         inc=''
9838         case "$i_systimes" in
9839         "$define") inc='sys/times.h';;
9840         esac
9841         rp="What is the type returned by times() on this system?"
9842         set clock_t clocktype long stdio.h sys/types.h $inc
9843         eval $typedef_ask
9844 else
9845         echo 'times() NOT found, hope that will do.' >&4
9846         d_times="$undef"
9847         clocktype='int'
9848 fi
9849
9850 : see if truncate exists
9851 set truncate d_truncate
9852 eval $inlibc
9853
9854 : see if tzname[] exists
9855 echo " "
9856 if set tzname val -a d_tzname; eval $csym; $val; then
9857         val="$define"
9858         echo 'tzname[] found.' >&4
9859 else
9860         val="$undef"
9861         echo 'tzname[] NOT found.' >&4
9862 fi
9863 set d_tzname
9864 eval $setvar
9865
9866 : see if umask exists
9867 set umask d_umask
9868 eval $inlibc
9869
9870 : backward compatibility for d_hvfork
9871 if test X$d_hvfork != X; then
9872         d_vfork="$d_hvfork"
9873         d_hvfork=''
9874 fi
9875 : see if there is a vfork
9876 val=''
9877 set vfork val
9878 eval $inlibc
9879
9880 : Ok, but do we want to use it. vfork is reportedly unreliable in 
9881 : perl on Solaris 2.x, and probably elsewhere.
9882 case "$val" in
9883 $define)
9884         echo " "
9885         case "$usevfork" in
9886         false) dflt='n';;
9887         *) dflt='y';;
9888         esac
9889         rp="Some systems have problems with vfork().  Do you want to use it?"
9890         . ./myread
9891         case "$ans" in
9892         y|Y) ;;
9893         *)
9894                 echo "Ok, we won't use vfork()."
9895                 val="$undef"
9896                 ;;
9897         esac
9898         ;;
9899 esac
9900 set d_vfork
9901 eval $setvar
9902 case "$d_vfork" in
9903 $define) usevfork='true';;
9904 *) usevfork='false';;
9905 esac
9906
9907 : see if this is an sysdir system
9908 set sys/dir.h i_sysdir
9909 eval $inhdr
9910
9911 : see if this is an sysndir system
9912 set sys/ndir.h i_sysndir
9913 eval $inhdr
9914
9915 : see if sys/types.h has to be included
9916 set sys/types.h i_systypes
9917 eval $inhdr
9918
9919 : see if closedir exists
9920 set closedir d_closedir
9921 eval $inlibc
9922
9923 case "$d_closedir" in
9924 "$define")
9925         echo " "
9926         echo "Checking whether closedir() returns a status..." >&4
9927         cat > closedir.c <<EOM
9928 #$i_dirent I_DIRENT             /**/
9929 #$i_sysdir I_SYS_DIR            /**/
9930 #$i_sysndir I_SYS_NDIR          /**/
9931 #$i_systypes I_SYS_TYPES        /**/
9932
9933 #if defined(I_SYS_TYPES)
9934 #include <sys/types.h>
9935 #endif
9936 #if defined(I_DIRENT)
9937 #include <dirent.h>
9938 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
9939 #include <sys/dir.h>
9940 #endif
9941 #else
9942 #ifdef I_SYS_NDIR
9943 #include <sys/ndir.h>
9944 #else
9945 #ifdef I_SYS_DIR
9946 #ifdef hp9000s500
9947 #include <ndir.h>       /* may be wrong in the future */
9948 #else
9949 #include <sys/dir.h>
9950 #endif
9951 #endif
9952 #endif
9953 #endif 
9954 int main() { return closedir(opendir(".")); }
9955 EOM
9956         set closedir
9957         if eval $compile_ok; then
9958                 if ./closedir > /dev/null 2>&1 ; then
9959                         echo "Yes, it does."
9960                         val="$undef"
9961                 else
9962                         echo "No, it doesn't."
9963                         val="$define"
9964                 fi
9965         else
9966                 echo "(I can't seem to compile the test program--assuming it doesn't)"
9967                 val="$define"
9968         fi
9969         ;;
9970 *)
9971         val="$undef";
9972         ;;
9973 esac
9974 set d_void_closedir
9975 eval $setvar
9976 $rm -f closedir*
9977 : check for volatile keyword
9978 echo " "
9979 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
9980 $cat >try.c <<'EOCP'
9981 int main()
9982 {
9983         typedef struct _goo_struct goo_struct;
9984         goo_struct * volatile goo = ((goo_struct *)0);
9985         struct _goo_struct {
9986                 long long_int;
9987                 int reg_int;
9988                 char char_var;
9989         };
9990         typedef unsigned short foo_t;
9991         char *volatile foo;
9992         volatile int bar;
9993         volatile foo_t blech;
9994         foo = foo;
9995 }
9996 EOCP
9997 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
9998         val="$define"
9999         echo "Yup, it does."
10000 else
10001         val="$undef"
10002         echo "Nope, it doesn't."
10003 fi
10004 set d_volatile
10005 eval $setvar
10006 $rm -f try.*
10007
10008 : see if there is a wait4
10009 set wait4 d_wait4
10010 eval $inlibc
10011
10012 : see if waitpid exists
10013 set waitpid d_waitpid
10014 eval $inlibc
10015
10016 : see if wcstombs exists
10017 set wcstombs d_wcstombs
10018 eval $inlibc
10019
10020 : see if wctomb exists
10021 set wctomb d_wctomb
10022 eval $inlibc
10023
10024 : see if writev exists
10025 set writev d_writev
10026 eval $inlibc
10027
10028 : preserve RCS keywords in files with variable substitution, grrr
10029 Date='$Date'
10030 Id='$Id'
10031 Log='$Log'
10032 RCSfile='$RCSfile'
10033 Revision='$Revision'
10034
10035 : check for alignment requirements
10036 echo " "
10037 case "$alignbytes" in
10038 '') echo "Checking alignment constraints..." >&4
10039         $cat >try.c <<'EOCP'
10040 struct foobar {
10041         char foo;
10042         double bar;
10043 } try;
10044 main()
10045 {
10046         printf("%d\n", (char *)&try.bar - (char *)&try.foo);
10047 }
10048 EOCP
10049         set try
10050         if eval $compile_ok; then
10051                 dflt=`./try`
10052         else
10053                 dflt='8'
10054                 echo "(I can't seem to compile the test program...)"
10055         fi
10056         ;;
10057 *) dflt="$alignbytes"
10058         ;;
10059 esac
10060 rp="Doubles must be aligned on a how-many-byte boundary?"
10061 . ./myread
10062 alignbytes="$ans"
10063 $rm -f try.c try
10064
10065 : check for ordering of bytes in a long
10066 case "$byteorder" in
10067 '')
10068         $cat <<'EOM'
10069   
10070 In the following, larger digits indicate more significance.  A big-endian
10071 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10072 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10073 machines may have weird orders like 3412.  A Cray will report 87654321. If
10074 the test program works the default is probably right.
10075 I'm now running the test program...
10076 EOM
10077         $cat >try.c <<'EOCP'
10078 #include <stdio.h>
10079 main()
10080 {
10081         int i;
10082         union {
10083                 unsigned long l;
10084                 char c[sizeof(long)];
10085         } u;
10086
10087         if (sizeof(long) > 4)
10088                 u.l = (0x08070605L << 32) | 0x04030201L;
10089         else
10090                 u.l = 0x04030201L;
10091         for (i = 0; i < sizeof(long); i++)
10092                 printf("%c", u.c[i]+'0');
10093         printf("\n");
10094         exit(0);
10095 }
10096 EOCP
10097         xxx_prompt=y
10098         set try
10099         if eval $compile && ./try > /dev/null; then
10100                 dflt=`./try`
10101                 case "$dflt" in
10102                 [1-4][1-4][1-4][1-4]|12345678|87654321)
10103                         echo "(The test program ran ok.)"
10104                         echo "byteorder=$dflt"
10105                         xxx_prompt=n
10106                         ;;
10107                 ????|????????) echo "(The test program ran ok.)" ;;
10108                 *) echo "(The test program didn't run right for some reason.)" ;;
10109                 esac
10110         else
10111                 dflt='4321'
10112                 cat <<'EOM'
10113 (I can't seem to compile the test program.  Guessing big-endian...)
10114 EOM
10115         fi
10116         case "$xxx_prompt" in
10117         y)
10118                 rp="What is the order of bytes in a long?"
10119                 . ./myread
10120                 byteorder="$ans"
10121                 ;;
10122         *)      byteorder=$dflt
10123                 ;;
10124         esac
10125         ;;
10126 esac
10127 $rm -f try.c try
10128
10129 : how do we catenate cpp tokens here?
10130 echo " "
10131 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10132 $cat >cpp_stuff.c <<'EOCP'
10133 #define RCAT(a,b)a/**/b
10134 #define ACAT(a,b)a ## b
10135 RCAT(Rei,ser)
10136 ACAT(Cir,cus)
10137 EOCP
10138 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10139 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10140         echo "Oh!  Smells like ANSI's been here." >&4
10141         echo "We can catify or stringify, separately or together!"
10142         cpp_stuff=42
10143 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10144         echo "Ah, yes!  The good old days!" >&4
10145         echo "However, in the good old days we don't know how to stringify and"
10146         echo "catify at the same time."
10147         cpp_stuff=1
10148 else
10149         $cat >&4 <<EOM
10150 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10151 to have to edit the values of CAT[2-5] in config.h...
10152 EOM
10153         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10154 fi
10155 $rm -f cpp_stuff.*
10156
10157 : see if this is a db.h system
10158 set db.h i_db
10159 eval $inhdr
10160
10161 case "$i_db" in
10162 $define)
10163         : Check db version.
10164         echo " "
10165         echo "Checking Berkeley DB version ..." >&4
10166         $cat >try.c <<EOCP
10167 #$d_const HASCONST
10168 #ifndef HASCONST
10169 #define const
10170 #endif
10171 #include <sys/types.h>
10172 #include <stdio.h>
10173 #include <db.h>
10174 main()
10175 {
10176 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10177     int Major, Minor, Patch ;
10178     unsigned long Version ;
10179     (void)db_version(&Major, &Minor, &Patch) ;
10180     printf("You have Berkeley DB Version 2 or greater\n");
10181
10182     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10183                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10184     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10185                 Major, Minor, Patch) ;
10186
10187     /* check that db.h & libdb are compatible */
10188     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10189         printf("db.h and libdb are incompatible\n") ;
10190         exit(3);        
10191     }
10192
10193     printf("db.h and libdb are compatible\n") ;
10194
10195     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10196                 + DB_VERSION_PATCH ;
10197
10198     /* needs to be >= 2.3.4 */
10199     if (Version < 2003004) {
10200     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10201         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10202         exit(2);        
10203     }
10204
10205     exit(0);
10206 #else
10207 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10208     printf("You have Berkeley DB Version 1\n");
10209     exit(0);    /* DB version < 2: the coast is clear. */
10210 #else
10211     exit(1);    /* <db.h> not Berkeley DB? */
10212 #endif
10213 #endif
10214 }
10215 EOCP
10216         set try
10217         if eval $compile && ./try; then
10218                 echo 'Looks OK.' >&4
10219         else
10220                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10221                 i_db=$undef
10222                 case " $libs " in
10223                 *"-ldb "*)
10224                         : Remove db from list of libraries to use
10225                         echo "Removing unusable -ldb from library list" >&4
10226                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10227                         shift
10228                         libs="$*"
10229                         echo "libs = $libs" >&4
10230                         ;;
10231                 esac
10232         fi
10233         $rm -f try.*
10234         ;;
10235 esac
10236
10237 case "$i_db" in
10238 define)
10239         : Check the return type needed for hash 
10240         echo " "
10241         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10242         $cat >try.c <<EOCP
10243 #$d_const HASCONST
10244 #ifndef HASCONST
10245 #define const
10246 #endif
10247 #include <sys/types.h>
10248 #include <db.h>
10249
10250 #ifndef DB_VERSION_MAJOR
10251 u_int32_t hash_cb (ptr, size)
10252 const void *ptr;
10253 size_t size;
10254 {
10255 }
10256 HASHINFO info;
10257 main()
10258 {
10259         info.hash = hash_cb;
10260 }
10261 #endif
10262 EOCP
10263         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10264                 if $contains warning try.out >>/dev/null 2>&1 ; then
10265                         db_hashtype='int'
10266                 else
10267                         db_hashtype='u_int32_t'
10268                 fi
10269         else
10270                 : XXX Maybe we should just give up here.
10271                 db_hashtype=u_int32_t
10272                 $cat try.out >&4
10273                 echo "Help:  I can't seem to compile the db test program." >&4
10274                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10275         fi
10276         $rm -f try.*
10277         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10278         ;;
10279 *)      db_hashtype=u_int32_t
10280         ;;
10281 esac
10282 case "$i_db" in
10283 define)
10284         : Check the return type needed for prefix 
10285         echo " "
10286         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10287         cat >try.c <<EOCP
10288 #$d_const HASCONST
10289 #ifndef HASCONST
10290 #define const
10291 #endif
10292 #include <sys/types.h>
10293 #include <db.h>
10294
10295 #ifndef DB_VERSION_MAJOR
10296 size_t prefix_cb (key1, key2)
10297 const DBT *key1;
10298 const DBT *key2;
10299 {
10300 }
10301 BTREEINFO info;
10302 main()
10303 {
10304         info.prefix = prefix_cb;
10305 }
10306 #endif
10307 EOCP
10308         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10309                 if $contains warning try.out >>/dev/null 2>&1 ; then
10310                         db_prefixtype='int'
10311                 else
10312                         db_prefixtype='size_t'
10313                 fi
10314         else
10315                 db_prefixtype='size_t'
10316                 : XXX Maybe we should just give up here.
10317                 $cat try.out >&4
10318                 echo "Help:  I can't seem to compile the db test program." >&4
10319                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10320         fi
10321         $rm -f try.*
10322         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10323         ;;
10324 *)      db_prefixtype='size_t'
10325         ;;
10326 esac
10327
10328 : check for void type
10329 echo " "
10330 echo "Checking to see how well your C compiler groks the void type..." >&4
10331 case "$voidflags" in
10332 '')
10333         $cat >try.c <<'EOCP'
10334 #if TRY & 1
10335 void sub() {
10336 #else
10337 sub() {
10338 #endif
10339         extern void moo();      /* function returning void */
10340         void (*goo)();          /* ptr to func returning void */
10341 #if TRY & 8
10342         void *hue;              /* generic ptr */
10343 #endif
10344 #if TRY & 2
10345         void (*foo[10])();
10346 #endif
10347
10348 #if TRY & 4
10349         if(goo == moo) {
10350                 exit(0);
10351         }
10352 #endif
10353         exit(0);
10354 }
10355 main() { sub(); }
10356 EOCP
10357         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10358                 voidflags=$defvoidused
10359         echo "Good.  It appears to support void to the level $package wants.">&4
10360                 if $contains warning .out >/dev/null 2>&1; then
10361                         echo "However, you might get some warnings that look like this:"
10362                         $cat .out
10363                 fi
10364         else
10365 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10366                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10367                         echo "It supports 1..."
10368                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10369                                 echo "It also supports 2..."
10370                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10371                                         voidflags=7
10372                                         echo "And it supports 4 but not 8 definitely."
10373                                 else
10374                                         echo "It doesn't support 4..."
10375                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10376                                                 voidflags=11
10377                                                 echo "But it supports 8."
10378                                         else
10379                                                 voidflags=3
10380                                                 echo "Neither does it support 8."
10381                                         fi
10382                                 fi
10383                         else
10384                                 echo "It does not support 2..."
10385                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10386                                         voidflags=13
10387                                         echo "But it supports 4 and 8."
10388                                 else
10389                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10390                                                 voidflags=5
10391                                                 echo "And it supports 4 but has not heard about 8."
10392                                         else
10393                                                 echo "However it supports 8 but not 4."
10394                                         fi
10395                                 fi
10396                         fi
10397                 else
10398                         echo "There is no support at all for void."
10399                         voidflags=0
10400                 fi
10401         fi
10402 esac
10403 case "$voidflags" in
10404 "$defvoidused") ;;
10405 *)      $cat >&4 <<'EOM'
10406   Support flag bits are:
10407     1: basic void declarations.
10408     2: arrays of pointers to functions returning void.
10409     4: operations between pointers to and addresses of void functions.
10410     8: generic void pointers.
10411 EOM
10412         dflt="$voidflags";
10413         rp="Your void support flags add up to what?"
10414         . ./myread
10415         voidflags="$ans"
10416         ;;
10417 esac
10418 $rm -f try.* .out
10419
10420
10421 : How can we generate normalized random numbers ?
10422 echo " "
10423 echo "Looking for a random number function..." >&4
10424 case "$randfunc" in
10425 '')
10426         if set drand48 val -f; eval $csym; $val; then
10427                 dflt="drand48"
10428                 echo "Good, found drand48()." >&4
10429         elif set random val -f; eval $csym; $val; then
10430                 dflt="random"
10431                 echo "OK, found random()." >&4
10432         else
10433                 dflt="rand"
10434                 echo "Yick, looks like I have to use rand()." >&4
10435         fi
10436         echo " "
10437         ;;
10438 *)
10439         dflt="$randfunc"
10440         ;;
10441 esac
10442 cont=true
10443
10444 case "$ccflags" in
10445 *-Dmy_rand=*|*-Dmy_srand=*)
10446         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10447         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10448         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10449         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10450         ;;
10451 esac
10452
10453 while $test "$cont"; do
10454         rp="Use which function to generate random numbers?"
10455         . ./myread
10456         if $test "$ans" = "$dflt"; then
10457                 : null
10458         else
10459                 randbits=''
10460         fi
10461         randfunc="$ans"
10462         if set $ans val -f; eval $csym; $val; then
10463                 cont=''
10464         else
10465                 dflt=y
10466                 rp="I cannot find function $ans. Use that name anyway?"
10467                 . ./myread
10468                 dflt=rand
10469                 case "$ans" in
10470                         [yY]*) cont='';;
10471                 esac
10472         fi
10473         case "$cont" in
10474         '')
10475                 case "$randfunc" in
10476                 drand48)
10477                         drand01="drand48()"
10478                         seedfunc="srand48"
10479                         randbits=48
10480                         randseedtype=long
10481                         ;;
10482                 rand|random)
10483                         case "$randbits" in
10484                         '')
10485 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10486                                 $cat >try.c <<EOCP
10487 #$i_unistd I_UNISTD
10488 #$i_stdlib I_STDLIB
10489 #include <stdio.h>
10490 #ifdef I_UNISTD
10491 #  include <unistd.h>
10492 #endif
10493 #ifdef I_STDLIB
10494 #  include <stdlib.h>
10495 #endif
10496 main()
10497 {
10498         register int i;
10499         register unsigned long tmp;
10500         register unsigned long max = 0L;
10501
10502         for (i = 1000; i; i--) {
10503                 tmp = (unsigned long) $randfunc();
10504                 if (tmp > max) max = tmp;
10505         }
10506         for (i = 0; max; i++)
10507                 max /= 2;
10508         printf("%d\n",i);
10509 }
10510 EOCP
10511                                 set try
10512                                 if eval $compile_ok; then
10513                                         dflt=`try`
10514                                 else
10515                                         dflt='?'
10516                                         echo "(I can't seem to compile the test program...)"
10517                                 fi
10518                                 ;;
10519                         *)
10520                                 dflt="$randbits"
10521                                 ;;
10522                         esac
10523                         rp="How many bits does your $randfunc() function produce?"
10524                         . ./myread
10525                         randbits="$ans"
10526                         $rm -f try.c try
10527                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10528                         seedfunc="s$randfunc"
10529                         randseedtype=unsigned
10530                         ;;
10531                 *)
10532                         dflt="31"
10533                         rp="How many bits does your $randfunc() function produce?"
10534                         . ./myread
10535                         randbits="$ans"
10536                         seedfunc="s$randfunc"
10537                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10538                         if set $seedfunc val -f; eval $csym; $val; then
10539                                 echo "(Using $seedfunc() to seed random generator)"
10540                         else
10541                                 echo "(Warning: no $seedfunc() to seed random generator)"
10542                                 seedfunc=rand
10543                         fi
10544                         randseedtype=unsigned
10545                         ;;
10546                 esac
10547                 ;;
10548         esac
10549 done
10550
10551 echo " "
10552 echo "Determining whether or not we are on an EBCDIC system..." >&4
10553 $cat >tebcdic.c <<'EOM'
10554 int main()
10555 {
10556   if ('M'==0xd4) return 0;
10557   return 1;
10558 }
10559 EOM
10560
10561 val=$undef
10562 set tebcdic
10563 if eval $compile_ok; then
10564         if ./tebcdic; then
10565                 echo "You have EBCDIC." >&4
10566                 val="$define"
10567         else
10568                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10569         fi
10570 else
10571         echo "I'm unable to compile the test program." >&4
10572         echo "I'll assume ASCII or some ISO Latin." >&4
10573 fi
10574 $rm -f tebcdic.c tebcdic
10575 set ebcdic
10576 eval $setvar
10577
10578 : see what type file positions are declared as in the library
10579 rp="What is the type for file position used by fsetpos()?"
10580 set fpos_t fpostype long stdio.h sys/types.h
10581 eval $typedef_ask
10582
10583 : Store the full pathname to the sed program for use in the C program
10584 full_sed=$sed
10585
10586 : see what type gids are declared as in the kernel
10587 echo " "
10588 echo "Looking for the type for group ids returned by getgid()."
10589 set gid_t gidtype xxx stdio.h sys/types.h
10590 eval $typedef
10591 case "$gidtype" in
10592 xxx)
10593         xxx=`./findhdr sys/user.h`
10594         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
10595         case $1 in
10596         unsigned) dflt="$1 $2" ;;
10597         *) dflt="$1" ;;
10598         esac
10599         ;;
10600 *) dflt="$gidtype";;
10601 esac
10602 case "$gidtype" in
10603 gid_t) echo "gid_t found." ;;
10604 *)      rp="What is the type for group ids returned by getgid()?"
10605         . ./myread
10606         gidtype="$ans"
10607         ;;
10608 esac
10609
10610 : see if getgroups exists
10611 set getgroups d_getgrps
10612 eval $inlibc
10613
10614 : see if setgroups exists
10615 set setgroups d_setgrps
10616 eval $inlibc
10617
10618
10619 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
10620 echo " "
10621 case "$d_getgrps$d_setgrps" in
10622 *define*)
10623         case "$groupstype" in
10624         '') dflt="$gidtype" ;;
10625         *)  dflt="$groupstype" ;;
10626         esac
10627         $cat <<EOM
10628 What type of pointer is the second argument to getgroups() and setgroups()?
10629 Usually this is the same as group ids, $gidtype, but not always.
10630
10631 EOM
10632         rp='What type pointer is the second argument to getgroups() and setgroups()?'
10633         . ./myread
10634         groupstype="$ans"
10635         ;;
10636 *)  groupstype="$gidtype";;
10637 esac
10638
10639 : see what type lseek is declared as in the kernel
10640 rp="What is the type used for lseek's offset on this system?"
10641 set off_t lseektype long stdio.h sys/types.h
10642 eval $typedef_ask
10643
10644 echo " "
10645 $echo $n "Checking to see how big your file offsets are...$c" >&4
10646 $cat >try.c <<EOCP
10647 #include <sys/types.h>
10648 #include <stdio.h>
10649 int main()
10650 {
10651         printf("%d\n", sizeof($lseektype));
10652 }
10653 EOCP
10654 set try
10655 if eval $compile_ok; then
10656         lseeksize=`./try`
10657         $echo " $lseeksize bytes." >&4
10658 else
10659         dflt='4'
10660         echo " "
10661         echo "(I can't seem to compile the test program.  Guessing...)"
10662         rp="What is the size of your file offsets (in bytes)?"
10663         . ./myread
10664         lseeksize="$ans"
10665 fi
10666 $rm -f try.c try
10667
10668 echo " "
10669 echo "Checking if your $make program sets \$(MAKE)..." >&4
10670 case "$make_set_make" in
10671 '')
10672         $sed 's/^X //' > testmake.mak << 'EOF'
10673 Xall:
10674 X       @echo 'maketemp="$(MAKE)"'
10675 EOF
10676         case "`$make -f testmake.mak 2>/dev/null`" in
10677         *maketemp=*) make_set_make='#' ;;
10678         *)      make_set_make="MAKE=$make" ;;
10679         esac
10680         $rm -f testmake.mak
10681         ;;
10682 esac
10683 case "$make_set_make" in
10684 '#') echo "Yup, it does.";;
10685 *) echo "Nope, it doesn't.";;
10686 esac
10687
10688 : see what type is used for mode_t
10689 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
10690 set mode_t modetype int stdio.h sys/types.h
10691 eval $typedef_ask
10692
10693 : define a fucntion to check prototypes
10694 $cat > protochk <<EOSH
10695 $startsh
10696 cc="$cc"
10697 optimize="$optimize"
10698 ccflags="$ccflags"
10699 prototype="$prototype"
10700 define="$define"
10701 rm=$rm
10702 EOSH
10703
10704 $cat >> protochk <<'EOSH'
10705
10706 $rm -f try.c
10707 foo="$1"
10708 shift
10709 while test $# -ge 2; do
10710         case "$1" in
10711                 $define) echo "#include <$2>" >> try.c ;;
10712                 literal) echo "$2" >> try.c ;;
10713         esac
10714     shift 2
10715 done
10716 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
10717 cat >> try.c <<'EOCP'
10718 #ifdef CAN_PROTOTYPE
10719 #define _(args) args
10720 #else
10721 #define _(args) ()
10722 #endif
10723 EOCP
10724 echo "$foo" >> try.c
10725 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
10726 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
10727 status=$?
10728 $rm -f try.[co]
10729 exit $status
10730 EOSH
10731 chmod +x protochk
10732 $eunicefix protochk
10733
10734 : see what type is used for size_t
10735 rp="What is the type used for the length parameter for string functions?"
10736 set size_t sizetype 'unsigned int' stdio.h sys/types.h
10737 eval $typedef_ask
10738
10739 : check for type of arguments to gethostbyaddr. 
10740 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
10741         case "$d_gethbyaddr" in
10742         $define)
10743                 $cat <<EOM
10744
10745 Checking to see what type of arguments are accepted by gethostbyaddr().
10746 EOM
10747                 hdrs="$define sys/types.h
10748                         $d_socket sys/socket.h 
10749                         $i_niin netinet/in.h 
10750                         $i_netdb netdb.h
10751                         $i_unistd unistd.h"
10752                 : The first arg can 'char *' or 'void *'
10753                 : The second arg is some of integral type
10754                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
10755                         for yyy in size_t long int; do
10756                                 case "$netdb_host_type" in
10757                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
10758                                         if ./protochk "$try" $hdrs; then
10759                                                 echo "Your system accepts $xxx for the first arg."
10760                                                 echo "...and $yyy for the second arg."
10761                                                 netdb_host_type="$xxx"
10762                                                 netdb_hlen_type="$yyy"
10763                                         fi
10764                                         ;;
10765                                 esac
10766                         done
10767                 done
10768                 : In case none of those worked, prompt the user.
10769                 case "$netdb_host_type" in
10770                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
10771                         dflt='char *'
10772                         . ./myread
10773                         netdb_host_type=$ans
10774                         rp='What is the type for the 2nd argument to gethostbyaddr?'
10775                         dflt="$sizetype"
10776                         . ./myread
10777                         netdb_hlen_type=$ans
10778                         ;;
10779                 esac
10780                 ;;
10781         *)      : no gethostbyaddr, so pick harmless defaults
10782                 netdb_host_type='char *'
10783                 netdb_hlen_type="$sizetype"
10784                 ;;
10785         esac
10786         # Remove the "const" if needed. -- but then we'll have a 
10787         # prototype clash!
10788         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
10789 fi
10790
10791 : check for type of argument to gethostbyname. 
10792 if test "X$netdb_name_type" = X ; then
10793         case "$d_gethbyname" in
10794         $define)
10795                 $cat <<EOM
10796
10797 Checking to see what type of argument is accepted by gethostbyname().
10798 EOM
10799                 hdrs="$define sys/types.h
10800                         $d_socket sys/socket.h 
10801                         $i_niin netinet/in.h 
10802                         $i_netdb netdb.h
10803                         $i_unistd unistd.h"
10804                 for xxx in "const char *" "char *"; do
10805                         case "$netdb_name_type" in
10806                         '')     try="extern struct hostent *gethostbyname($xxx);"
10807                                 if ./protochk "$try" $hdrs; then
10808                                         echo "Your system accepts $xxx."
10809                                         netdb_name_type="$xxx"
10810                                 fi
10811                                 ;;
10812                         esac
10813                 done
10814                 : In case none of those worked, prompt the user.
10815                 case "$netdb_name_type" in
10816                 '')     rp='What is the type for the 1st argument to gethostbyname?'
10817                         dflt='char *'
10818                         . ./myread
10819                         netdb_name_type=$ans
10820                         ;;
10821                 esac
10822                 ;;
10823         *)      : no gethostbyname, so pick harmless default
10824                 netdb_name_type='char *'
10825                 ;;
10826         esac
10827 fi
10828
10829 : check for type of 1st argument to getnetbyaddr. 
10830 if test "X$netdb_net_type" = X ; then
10831         case "$d_getnbyaddr" in
10832         $define)
10833                 $cat <<EOM
10834
10835 Checking to see what type of 1st argument is accepted by getnetbyaddr().
10836 EOM
10837                 hdrs="$define sys/types.h
10838                         $d_socket sys/socket.h 
10839                         $i_niin netinet/in.h 
10840                         $i_netdb netdb.h
10841                         $i_unistd unistd.h"
10842                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
10843                         case "$netdb_net_type" in
10844                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
10845                                 if ./protochk "$try" $hdrs; then
10846                                         echo "Your system accepts $xxx."
10847                                         netdb_net_type="$xxx"
10848                                 fi
10849                                 ;;
10850                         esac
10851                 done
10852                 : In case none of those worked, prompt the user.
10853                 case "$netdb_net_type" in
10854                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
10855                         dflt='long'
10856                         . ./myread
10857                         netdb_net_type=$ans
10858                         ;;
10859                 esac
10860                 ;;
10861         *)      : no getnetbyaddr, so pick harmless default
10862                 netdb_net_type='long'
10863                 ;;
10864         esac
10865 fi
10866 : locate the preferred pager for this system
10867 case "$pager" in
10868 '')
10869         dflt=''
10870         case "$pg" in
10871         /*) dflt=$pg;;
10872         esac
10873         case "$more" in
10874         /*) dflt=$more;;
10875         esac
10876         case "$less" in
10877         /*) dflt=$less;;
10878         esac
10879         case "$dflt" in
10880         '') dflt=/usr/ucb/more;;
10881         esac
10882         ;;
10883 *) dflt="$pager";;
10884 esac
10885 echo " "
10886 fn=f/
10887 rp='What pager is used on your system?'
10888 . ./getfile
10889 pager="$ans"
10890
10891 : see what type pids are declared as in the kernel
10892 rp="What is the type of process ids on this system?"
10893 set pid_t pidtype int stdio.h sys/types.h
10894 eval $typedef_ask
10895
10896 : check for length of pointer
10897 echo " "
10898 case "$ptrsize" in
10899 '')
10900         $echo $n "Checking to see how big your pointers are...$c" >&4
10901         if test "$voidflags" -gt 7; then
10902                 echo '#define VOID_PTR char *' > try.c
10903         else
10904                 echo '#define VOID_PTR void *' > try.c
10905         fi
10906         $cat >>try.c <<'EOCP'
10907 #include <stdio.h>
10908 main()
10909 {
10910         printf("%d\n", sizeof(VOID_PTR));
10911         exit(0);
10912 }
10913 EOCP
10914         set try
10915         if eval $compile_ok; then
10916                 ptrsize=`./try`
10917                 $echo " $ptrsize bytes." >&4
10918         else
10919                 dflt='4'
10920                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
10921                 rp="What is the size of a pointer (in bytes)?"
10922                 . ./myread
10923                 ptrsize="$ans"
10924         fi
10925         ;;
10926 esac
10927 $rm -f try.c try
10928
10929 : see if ar generates random libraries by itself
10930 echo " "
10931 echo "Checking how to generate random libraries on your machine..." >&4
10932 echo 'int bar1() { return bar2(); }' > bar1.c
10933 echo 'int bar2() { return 2; }' > bar2.c
10934 $cat > foo.c <<'EOP'
10935 main() { printf("%d\n", bar1()); exit(0); }
10936 EOP
10937 $cc $ccflags -c bar1.c >/dev/null 2>&1
10938 $cc $ccflags -c bar2.c >/dev/null 2>&1
10939 $cc $ccflags -c foo.c >/dev/null 2>&1
10940 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
10941 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
10942         ./foobar >/dev/null 2>&1; then
10943         echo "$ar appears to generate random libraries itself."
10944         orderlib=false
10945         ranlib=":"
10946 elif $ar ts bar$_a >/dev/null 2>&1 &&
10947         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
10948         ./foobar >/dev/null 2>&1; then
10949                 echo "a table of contents needs to be added with '$ar ts'."
10950                 orderlib=false
10951                 ranlib="$ar ts"
10952 else
10953         case "$ranlib" in
10954         :) ranlib='';;
10955         '')
10956                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
10957                 $test -f $ranlib || ranlib=''
10958                 ;;
10959         esac
10960         if $test -n "$ranlib"; then
10961                 echo "your system has '$ranlib'; we'll use that."
10962                 orderlib=false
10963         else
10964                 echo "your system doesn't seem to support random libraries"
10965                 echo "so we'll use lorder and tsort to order the libraries."
10966                 orderlib=true
10967                 ranlib=":"
10968         fi
10969 fi
10970 $rm -f foo* bar* 
10971
10972 : check for type of arguments to select. 
10973 case "$selecttype" in
10974 '') case "$d_select" in
10975         $define)
10976                 $cat <<EOM
10977 Checking to see what type of arguments are accepted by select().
10978 EOM
10979                 hdrs="$define sys/types.h
10980                         $i_systime sys/time.h 
10981                         $i_sysselct sys/select.h
10982                         $d_socket sys/socket.h"
10983                 : The first arg can be int, unsigned, or size_t
10984                 : The last arg may or may not be 'const'
10985                 val=''
10986                 : void pointer has been seen but using that
10987                 : breaks the selectminbits test
10988                 for xxx in 'fd_set *' 'int *'; do
10989                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
10990                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
10991                                         case "$val" in
10992                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
10993                                                 if ./protochk "$try" $hdrs; then
10994                                                         echo "Your system accepts $xxx."
10995                                                         val="$xxx"
10996                                                 fi
10997                                                 ;;
10998                                         esac
10999                                 done
11000                         done
11001                 done
11002                 case "$val" in
11003                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
11004                         case "$d_fd_set" in
11005                                 $define) dflt="fd_set *" ;;
11006                                 *)              dflt="int *" ;;
11007                         esac
11008                         . ./myread
11009                         val=$ans
11010                         ;;
11011                 esac
11012                 selecttype="$val"
11013                 ;;
11014         *)      : no select, so pick a harmless default
11015                 selecttype='int *'
11016                 ;;
11017         esac
11018         ;;
11019 esac
11020
11021 : check for the select 'width'
11022 case "$selectminbits" in
11023 '') case "$d_select" in
11024         $define)
11025                 $cat <<EOM
11026
11027 Checking to see on how many bits at a time your select() operates...
11028 EOM
11029                 $cat >try.c <<EOCP
11030 #include <sys/types.h>
11031 #$i_time I_TIME
11032 #$i_systime I_SYS_TIME
11033 #$i_systimek I_SYS_TIME_KERNEL
11034 #ifdef I_TIME
11035 #   include <time.h>
11036 #endif
11037 #ifdef I_SYS_TIME
11038 #   ifdef I_SYS_TIME_KERNEL
11039 #       define KERNEL
11040 #   endif
11041 #   include <sys/time.h>
11042 #   ifdef I_SYS_TIME_KERNEL
11043 #       undef KERNEL
11044 #   endif
11045 #endif
11046 #$i_sysselct I_SYS_SELECT
11047 #ifdef I_SYS_SELECT
11048 #include <sys/select.h>
11049 #endif
11050 #include <stdio.h>
11051 $selecttype b;
11052 #define S sizeof(*(b))
11053 #define MINBITS 64
11054 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11055 #define NBITS  (NBYTES * 8)
11056 int main() {
11057     char s[NBYTES];
11058     struct timeval t;
11059     int i;
11060     FILE* fp;
11061     int fd;
11062
11063     fclose(stdin);
11064     fp = fopen("try.c", "r");
11065     if (fp == 0)
11066       exit(1);
11067     fd = fileno(fp);
11068     if (fd < 0)
11069       exit(2);
11070     b = ($selecttype)s;
11071     for (i = 0; i < NBITS; i++)
11072         FD_SET(i, b);
11073     t.tv_sec  = 0;
11074     t.tv_usec = 0;
11075     select(fd + 1, b, 0, 0, &t);
11076     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11077     printf("%d\n", i + 1);
11078     return 0;
11079 }
11080 EOCP
11081                 set try
11082                 if eval $compile_ok; then
11083                         selectminbits=`./try`
11084                         case "$selectminbits" in
11085                         '')     cat >&4 <<EOM
11086 Cannot figure out on how many bits at a time your select() operates.
11087 I'll play safe and guess it is 32 bits.
11088 EOM
11089                                 selectminbits=32
11090                                 bits="32 bits"
11091                                 ;;
11092                         1)      bits="1 bit" ;;
11093                         *)      bits="$selectminbits bits" ;;
11094                         esac
11095                         echo "Your select() operates on $bits at a time." >&4
11096                 else
11097                         rp='What is the minimum number of bits your select() operates on?'
11098                         case "$byteorder" in
11099                         1234|12345678)  dflt=32 ;;
11100                         *)              dflt=1  ;;
11101                         esac
11102                         . ./myread
11103                         val=$ans
11104                         selectminbits="$val"
11105                 fi
11106                 $rm -f try.* try
11107                 ;;
11108         *)      : no select, so pick a harmless default
11109                 selectminbits='32'
11110                 ;;
11111         esac
11112         ;;
11113 esac
11114
11115 : Trace out the files included by signal.h, then look for SIGxxx names.
11116 : Remove SIGARRAYSIZE used by HPUX.
11117 : Remove SIGTYP void lines used by OS2.
11118 xxx=`echo '#include <signal.h>' |
11119         $cppstdin $cppminus $cppflags 2>/dev/null |
11120         $grep '^[       ]*#.*include' | 
11121         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11122 : Check this list of files to be sure we have parsed the cpp output ok.
11123 : This will also avoid potentially non-existent files, such 
11124 : as ../foo/bar.h
11125 xxxfiles=''
11126 for xx in $xxx /dev/null ; do
11127         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11128 done
11129 : If we have found no files, at least try signal.h
11130 case "$xxxfiles" in
11131 '')     xxxfiles=`./findhdr signal.h` ;;
11132 esac
11133 xxx=`awk '
11134 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $3 !~ /void/ {
11135         print substr($2, 4, 20)
11136 }
11137 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11138         print substr($3, 4, 20)
11139 }' $xxxfiles`
11140 : Append some common names just in case the awk scan failed.
11141 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11142 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11143 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11144 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11145 : generate a few handy files for later
11146 $cat > signal.c <<'EOCP'
11147 #include <sys/types.h>
11148 #include <signal.h>
11149 #include <stdio.h>
11150 int main() {
11151
11152 /* Strange style to avoid deeply-nested #if/#else/#endif */
11153 #ifndef NSIG
11154 #  ifdef _NSIG
11155 #    define NSIG (_NSIG)
11156 #  endif
11157 #endif
11158
11159 #ifndef NSIG
11160 #  ifdef SIGMAX
11161 #    define NSIG (SIGMAX+1)
11162 #  endif
11163 #endif
11164
11165 #ifndef NSIG
11166 #  ifdef SIG_MAX
11167 #    define NSIG (SIG_MAX+1)
11168 #  endif
11169 #endif
11170
11171 #ifndef NSIG
11172 #  ifdef MAXSIG
11173 #    define NSIG (MAXSIG+1)
11174 #  endif
11175 #endif
11176
11177 #ifndef NSIG
11178 #  ifdef MAX_SIG
11179 #    define NSIG (MAX_SIG+1)
11180 #  endif
11181 #endif
11182
11183 #ifndef NSIG
11184 #  ifdef SIGARRAYSIZE
11185 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11186 #  endif
11187 #endif
11188
11189 #ifndef NSIG
11190 #  ifdef _sys_nsig
11191 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11192 #  endif
11193 #endif
11194
11195 /* Default to some arbitrary number that's big enough to get most
11196    of the common signals.
11197 */
11198 #ifndef NSIG
11199 #    define NSIG 50
11200 #endif
11201
11202 printf("NSIG %d\n", NSIG);
11203
11204 #ifndef JUST_NSIG
11205
11206 EOCP
11207
11208 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11209 {
11210         printf "#ifdef SIG"; printf $1; printf "\n"
11211         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11212         printf $1; printf ");\n"
11213         printf "#endif\n"
11214 }
11215 END {
11216         printf "#endif /* JUST_NSIG */\n";
11217         printf "}\n";
11218 }
11219 ' >>signal.c
11220 $cat >signal.awk <<'EOP'
11221 BEGIN { ndups = 0 }
11222 $1 ~ /^NSIG$/ { nsig = $2 }
11223 ($1 !~ /^NSIG$/) && (NF == 2) {
11224     if ($2 > maxsig) { maxsig = $2 }
11225     if (sig_name[$2]) {
11226         dup_name[ndups] = $1
11227         dup_num[ndups] = $2
11228         ndups++ 
11229     }
11230     else {
11231         sig_name[$2] = $1
11232         sig_num[$2] = $2
11233     }
11234
11235 }
11236 END { 
11237     if (nsig == 0) { nsig = maxsig + 1 }
11238         for (n = 1; n < nsig; n++) {
11239                 if (sig_name[n]) {
11240                         printf("%s %d\n", sig_name[n], sig_num[n])
11241                 }
11242                 else {
11243                         printf("NUM%d %d\n", n, n) 
11244                 }
11245         }
11246     for (n = 0; n < ndups; n++) {
11247                 printf("%s %d\n", dup_name[n], dup_num[n])
11248     }
11249 }
11250 EOP
11251 $cat >signal_cmd <<EOS
11252 $startsh
11253 if $test -s signal.lst; then
11254     echo "Using your existing signal.lst file"
11255         exit 0
11256 fi
11257 xxx="$xxx"
11258 EOS
11259 $cat >>signal_cmd <<'EOS'
11260
11261 set signal
11262 if eval $compile_ok; then
11263         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11264 else
11265         echo "(I can't seem be able to compile the whole test program)" >&4
11266         echo "(I'll try it in little pieces.)" >&4
11267         set signal -DJUST_NSIG
11268         if eval $compile_ok; then
11269                 ./signal$_exe > signal.nsg
11270                 $cat signal.nsg
11271         else
11272                 echo "I can't seem to figure out how many signals you have." >&4
11273                 echo "Guessing 50." >&4
11274                 echo 'NSIG 50' > signal.nsg
11275         fi
11276         : Now look at all the signal names, one at a time.
11277         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11278                 $cat > signal.c <<EOCP
11279 #include <sys/types.h>
11280 #include <signal.h>
11281 #include <stdio.h>
11282 int main() {
11283 printf("$xx %d\n", SIG${xx});
11284 return 0;
11285 }
11286 EOCP
11287                 set signal
11288                 if eval $compile; then
11289                         echo "SIG${xx} found."
11290                         ./signal$_exe  >> signal.ls1
11291                 else
11292                         echo "SIG${xx} NOT found."
11293                 fi
11294         done
11295         if $test -s signal.ls1; then
11296                 $cat signal.nsg signal.ls1 |
11297                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11298         fi
11299
11300 fi
11301 if $test -s signal.lst; then
11302         :
11303 else
11304         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11305         echo 'kill -l' >signal
11306         set X `csh -f <signal`
11307         $rm -f signal
11308         shift
11309         case $# in
11310         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11311         esac
11312         echo $@ | $tr ' ' $trnl | \
11313                 $awk '{ printf $1; printf " %d\n", ++s; }' >signal.lst
11314 fi
11315 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11316 EOS
11317 chmod a+x signal_cmd
11318 $eunicefix signal_cmd
11319
11320 : generate list of signal names
11321 echo " "
11322 case "$sig_name_init" in
11323 '') doinit=yes ;;
11324 *)  case "$sig_num_init" in
11325     ''|*,*) doinit=yes ;;
11326     esac ;;
11327 esac
11328 case "$doinit" in
11329 yes)
11330         echo "Generating a list of signal names and numbers..." >&4
11331         . ./signal_cmd
11332         sig_name=`$awk '{printf "%s ", $1}' signal.lst`
11333         sig_name="ZERO $sig_name"
11334         sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
11335                                                 { printf "\"%s\", ", $1 }
11336                                                 END { printf "0\n" }' signal.lst`
11337         sig_num=`$awk '{printf "%d ", $2}' signal.lst`
11338         sig_num="0 $sig_num"
11339         sig_num_init=`$awk 'BEGIN { printf "0, " }
11340                                         { printf "%d, ", $2}
11341                                         END { printf "0\n"}' signal.lst`
11342         ;;
11343 esac
11344 echo "The following signals are available:"
11345 echo " "
11346 echo $sig_name | $awk \
11347 'BEGIN { linelen = 0 }
11348 {
11349         for (i = 1; i <= NF; i++) {
11350                 name = "SIG" $i " "
11351                 linelen = linelen + length(name)
11352                 if (linelen > 70) {
11353                         printf "\n"
11354                         linelen = length(name)
11355                 }
11356                 printf "%s", name
11357         }
11358         printf "\n"
11359 }'
11360 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11361
11362 : see what type is used for signed size_t
11363 set ssize_t ssizetype int stdio.h sys/types.h
11364 eval $typedef
11365 dflt="$ssizetype"
11366 $cat > ssize.c <<EOM
11367 #include <stdio.h>
11368 #include <sys/types.h>
11369 #define Size_t $sizetype
11370 #define SSize_t $dflt
11371 main()
11372 {
11373         if (sizeof(Size_t) == sizeof(SSize_t))
11374                 printf("$dflt\n");
11375         else if (sizeof(Size_t) == sizeof(int))
11376                 printf("int\n");
11377         else 
11378                 printf("long\n");
11379         exit(0);
11380 }
11381 EOM
11382 echo " "
11383 set ssize
11384 if eval $compile_ok && ./ssize > /dev/null; then
11385         ssizetype=`./ssize`
11386         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11387 else
11388         $cat >&4 <<EOM
11389 Help! I can't compile and run the ssize_t test program: please enlighten me!
11390 (This is probably a misconfiguration in your system or libraries, and
11391 you really ought to fix it.  Still, I'll try anyway.)
11392
11393 I need a type that is the same size as $sizetype, but is guaranteed to
11394 be signed.  Common values are ssize_t, int and long.
11395
11396 EOM
11397         rp="What signed type is the same size as $sizetype?"
11398         . ./myread
11399         ssizetype="$ans"
11400 fi
11401 $rm -f ssize ssize.*
11402
11403 : see what type of char stdio uses.
11404 echo " "
11405 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11406         echo "Your stdio uses unsigned chars." >&4
11407         stdchar="unsigned char"
11408 else
11409         echo "Your stdio uses signed chars." >&4
11410         stdchar="char"
11411 fi
11412
11413 : see if time exists
11414 echo " "
11415 if test "X$d_time" = X -o X"$timetype" = X; then
11416     if set time val -f d_time; eval $csym; $val; then
11417                 echo 'time() found.' >&4
11418                 val="$define"
11419                 rp="What is the type returned by time() on this system?"
11420                 set time_t timetype long stdio.h sys/types.h
11421                 eval $typedef_ask
11422     else
11423                 echo 'time() not found, hope that will do.' >&4
11424                 val="$undef"
11425                 timetype='int';
11426     fi
11427     set d_time
11428     eval $setvar
11429 fi
11430
11431 : see what type uids are declared as in the kernel
11432 echo " "
11433 echo "Looking for the type for user ids returned by getuid()."
11434 set uid_t uidtype xxx stdio.h sys/types.h
11435 eval $typedef
11436 case "$uidtype" in
11437 xxx)
11438         xxx=`./findhdr sys/user.h`
11439         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
11440         case $1 in
11441         unsigned) dflt="$1 $2" ;;
11442         *) dflt="$1" ;;
11443         esac
11444         ;;
11445 *) dflt="$uidtype";;
11446 esac
11447 case "$uidtype" in
11448 uid_t)  echo "uid_t found." ;;
11449 *)      rp="What is the type for user ids returned by getuid()?"
11450         . ./myread
11451         uidtype="$ans"
11452         ;;
11453 esac
11454
11455 : see if dbm.h is available
11456 : see if dbmclose exists
11457 set dbmclose d_dbmclose
11458 eval $inlibc
11459
11460 case "$d_dbmclose" in
11461 $define)
11462         set dbm.h i_dbm
11463         eval $inhdr
11464         case "$i_dbm" in
11465         $define)
11466                 val="$undef"
11467                 set i_rpcsvcdbm
11468                 eval $setvar
11469                 ;;
11470         *)      set rpcsvc/dbm.h i_rpcsvcdbm
11471                 eval $inhdr
11472                 ;;
11473         esac
11474         ;;
11475 *)      echo "We won't be including <dbm.h>"
11476         val="$undef"
11477         set i_dbm
11478         eval $setvar
11479         val="$undef"
11480         set i_rpcsvcdbm
11481         eval $setvar
11482         ;;
11483 esac
11484
11485 : see if this is a sys/file.h system
11486 val=''
11487 set sys/file.h val
11488 eval $inhdr
11489
11490 : do we need to include sys/file.h ?
11491 case "$val" in
11492 "$define")
11493         echo " "
11494         if $h_sysfile; then
11495                 val="$define"
11496                 echo "We'll be including <sys/file.h>." >&4
11497         else
11498                 val="$undef"
11499                 echo "We won't be including <sys/file.h>." >&4
11500         fi
11501         ;;
11502 *)
11503         h_sysfile=false
11504         ;;
11505 esac
11506 set i_sysfile
11507 eval $setvar
11508
11509 : see if fcntl.h is there
11510 val=''
11511 set fcntl.h val
11512 eval $inhdr
11513
11514 : see if we can include fcntl.h
11515 case "$val" in
11516 "$define")
11517         echo " "
11518         if $h_fcntl; then
11519                 val="$define"
11520                 echo "We'll be including <fcntl.h>." >&4
11521         else
11522                 val="$undef"
11523                 if $h_sysfile; then
11524         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
11525                 else
11526                         echo "We won't be including <fcntl.h>." >&4
11527                 fi
11528         fi
11529         ;;
11530 *)
11531         h_fcntl=false
11532         val="$undef"
11533         ;;
11534 esac
11535 set i_fcntl
11536 eval $setvar
11537
11538 : see if locale.h is available
11539 set locale.h i_locale
11540 eval $inhdr
11541
11542 : see if mach cthreads are available
11543 if test "X$usethreads" = "X$define"; then
11544         set mach/cthreads.h i_machcthr
11545         eval $inhdr
11546 else
11547         i_machcthr="$undef"
11548 fi
11549
11550
11551
11552 : see if this is a math.h system
11553 set math.h i_math
11554 eval $inhdr
11555
11556 : see if ndbm.h is available
11557 set ndbm.h t_ndbm
11558 eval $inhdr
11559 case "$t_ndbm" in
11560 $define)
11561         : see if dbm_open exists
11562         set dbm_open d_dbm_open
11563         eval $inlibc
11564         case "$d_dbm_open" in
11565         $undef)
11566                 t_ndbm="$undef"
11567                 echo "We won't be including <ndbm.h>"
11568                 ;;
11569         esac
11570         ;;
11571 esac
11572 val="$t_ndbm"
11573 set i_ndbm
11574 eval $setvar
11575
11576 : see if net/errno.h is available
11577 val=''
11578 set net/errno.h val
11579 eval $inhdr
11580
11581 : Unfortunately, it causes problems on some systems.  Arrgh.
11582 case "$val" in
11583 $define)
11584         cat > try.c <<'EOM'
11585 #include <stdio.h>
11586 #include <errno.h>
11587 #include <net/errno.h>
11588 int func()
11589 {
11590         return ENOTSOCK;
11591 }
11592 EOM
11593         if $cc $ccflags -c try.c >/dev/null 2>&1; then
11594                 echo "We'll be including <net/errno.h>." >&4
11595         else
11596                 echo "We won't be including <net/errno.h>." >&4
11597                 val="$undef"
11598         fi
11599         $rm -f try.* try
11600         ;;
11601 esac
11602 set i_neterrno
11603 eval $setvar
11604
11605 : see if this is a poll.h system
11606 set poll.h i_poll
11607 eval $inhdr
11608
11609 : get C preprocessor symbols handy
11610 echo " "
11611 $echo $n "Hmm... $c"
11612 echo $al | $tr ' ' $trnl >Cppsym.know
11613 $cat <<EOSS >Cppsym
11614 $startsh
11615 case "\$1" in
11616 -l) list=true
11617         shift
11618         ;;
11619 esac
11620 unknown=''
11621 case "\$list\$#" in
11622 1|2)
11623         for sym do
11624                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
11625                         exit 0
11626                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
11627                         :
11628                 else
11629                         unknown="\$unknown \$sym"
11630                 fi
11631         done
11632         set X \$unknown
11633         shift
11634         ;;
11635 esac
11636 case \$# in
11637 0) exit 1;;
11638 esac
11639 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
11640 #ifdef \1\\
11641 exit 0; _ _ _ _\1\\      \1\\
11642 #endif\\
11643 /' >Cppsym\$\$
11644 echo "exit 1; _ _ _" >>Cppsym\$\$
11645 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
11646 case "\$list" in
11647 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
11648 *)
11649         sh Cppsym2\$\$
11650         status=\$?
11651         ;;
11652 esac
11653 $rm -f Cppsym\$\$ Cppsym2\$\$
11654 exit \$status
11655 EOSS
11656 chmod +x Cppsym
11657 $eunicefix Cppsym
11658 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
11659
11660 : now check the C compiler for additional symbols
11661 $cat >ccsym <<EOS
11662 $startsh
11663 $cat >tmp.c <<EOF
11664 extern int foo;
11665 EOF
11666 for i in \`$cc -v -c tmp.c 2>&1\`
11667 do
11668         case "\$i" in
11669         -D*) echo "\$i" | $sed 's/^-D//';;
11670         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
11671         esac
11672 done
11673 $rm -f try.c
11674 EOS
11675 chmod +x ccsym
11676 $eunicefix ccsym
11677 ./ccsym > ccsym1.raw
11678 if $test -s ccsym1.raw; then
11679        $sort ccsym1.raw | $uniq >ccsym.raw
11680 else
11681        mv ccsym1.raw ccsym.raw
11682 fi
11683
11684 $awk '/\=/ { print $0; next }
11685         { print $0"=1" }' ccsym.raw >ccsym.list
11686 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
11687 $comm -13 ccsym.true ccsym.list >ccsym.own
11688 $comm -12 ccsym.true ccsym.list >ccsym.com
11689 $comm -23 ccsym.true ccsym.list >ccsym.cpp
11690 also=''
11691 symbols='symbols'
11692 if $test -z ccsym.raw; then
11693         echo "Your C compiler doesn't seem to define any symbol!" >&4
11694         echo " "
11695         echo "However, your C preprocessor defines the following ones:"
11696         $cat Cppsym.true
11697 else
11698         if $test -s ccsym.com; then
11699                 echo "Your C compiler and pre-processor define these symbols:"
11700                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
11701                 also='also '
11702                 symbols='ones'
11703                 $test "$silent" || sleep 1
11704         fi
11705         if $test -s ccsym.cpp; then
11706                 $test "$also" && echo " "
11707                 echo "Your C pre-processor ${also}defines the following $symbols:"
11708                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
11709                 also='further '
11710                 $test "$silent" || sleep 1
11711         fi
11712         if $test -s ccsym.own; then
11713                 $test "$also" && echo " "
11714                 echo "Your C compiler ${also}defines the following cpp variables:"
11715                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
11716                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
11717                 $test "$silent" || sleep 1
11718         fi
11719 fi
11720 $rm -f ccsym*
11721
11722 : see if this is a termio system
11723 val="$undef"
11724 val2="$undef"
11725 val3="$undef"
11726 if $test `./findhdr termios.h`; then
11727         set tcsetattr i_termios
11728         eval $inlibc
11729         val3="$i_termios"
11730 fi
11731 echo " "
11732 case "$val3" in
11733 "$define") echo "You have POSIX termios.h... good!" >&4;;
11734 *) if ./Cppsym pyr; then
11735                 case "`/bin/universe`" in
11736                 ucb) if $test `./findhdr sgtty.h`; then
11737                                 val2="$define"
11738                                 echo "<sgtty.h> found." >&4
11739                         else
11740                                 echo "System is pyramid with BSD universe."
11741                                 echo "<sgtty.h> not found--you could have problems." >&4
11742                         fi;;
11743                 *) if $test `./findhdr termio.h`; then
11744                                 val="$define"
11745                                 echo "<termio.h> found." >&4
11746                         else
11747                                 echo "System is pyramid with USG universe."
11748                                 echo "<termio.h> not found--you could have problems." >&4
11749                         fi;;
11750                 esac
11751         elif ./usg; then
11752                 if $test `./findhdr termio.h`; then
11753                         echo "<termio.h> found." >&4
11754                         val="$define"
11755                 elif $test `./findhdr sgtty.h`; then
11756                         echo "<sgtty.h> found." >&4
11757                         val2="$define"
11758                 else
11759 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
11760                 fi
11761         else
11762                 if $test `./findhdr sgtty.h`; then
11763                         echo "<sgtty.h> found." >&4
11764                         val2="$define"
11765                 elif $test `./findhdr termio.h`; then
11766                         echo "<termio.h> found." >&4
11767                         val="$define"
11768                 else
11769 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
11770                 fi
11771         fi;;
11772 esac
11773 set i_termio; eval $setvar
11774 val=$val2; set i_sgtty; eval $setvar
11775 val=$val3; set i_termios; eval $setvar
11776
11777 : see if stdarg is available
11778 echo " "
11779 if $test `./findhdr stdarg.h`; then
11780         echo "<stdarg.h> found." >&4
11781         valstd="$define"
11782 else
11783         echo "<stdarg.h> NOT found." >&4
11784         valstd="$undef"
11785 fi
11786
11787 : see if varags is available
11788 echo " "
11789 if $test `./findhdr varargs.h`; then
11790         echo "<varargs.h> found." >&4
11791 else
11792         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
11793 fi
11794
11795 : set up the varargs testing programs
11796 $cat > varargs.c <<EOP
11797 #ifdef I_STDARG
11798 #include <stdarg.h>
11799 #endif
11800 #ifdef I_VARARGS
11801 #include <varargs.h>
11802 #endif
11803
11804 #ifdef I_STDARG
11805 int f(char *p, ...)
11806 #else
11807 int f(va_alist)
11808 va_dcl
11809 #endif
11810 {
11811         va_list ap;
11812 #ifndef I_STDARG
11813         char *p;
11814 #endif
11815 #ifdef I_STDARG
11816         va_start(ap,p);
11817 #else
11818         va_start(ap);
11819         p = va_arg(ap, char *);
11820 #endif
11821         va_end(ap);
11822 }
11823 EOP
11824 $cat > varargs <<EOP
11825 $startsh
11826 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
11827         echo "true"
11828 else
11829         echo "false"
11830 fi
11831 $rm -f varargs$_o
11832 EOP
11833 chmod +x varargs
11834
11835 : now check which varargs header should be included
11836 echo " "
11837 i_varhdr=''
11838 case "$valstd" in
11839 "$define")
11840         if `./varargs I_STDARG`; then
11841                 val='stdarg.h'
11842         elif `./varargs I_VARARGS`; then
11843                 val='varargs.h'
11844         fi
11845         ;;
11846 *)
11847         if `./varargs I_VARARGS`; then
11848                 val='varargs.h'
11849         fi
11850         ;;
11851 esac
11852 case "$val" in
11853 '')
11854 echo "I could not find the definition for va_dcl... You have problems..." >&4
11855         val="$undef"; set i_stdarg; eval $setvar
11856         val="$undef"; set i_varargs; eval $setvar
11857         ;;
11858 *) 
11859         set i_varhdr
11860         eval $setvar
11861         case "$i_varhdr" in
11862         stdarg.h)
11863                 val="$define"; set i_stdarg; eval $setvar
11864                 val="$undef"; set i_varargs; eval $setvar
11865                 ;;
11866         varargs.h)
11867                 val="$undef"; set i_stdarg; eval $setvar
11868                 val="$define"; set i_varargs; eval $setvar
11869                 ;;
11870         esac
11871         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
11872 esac
11873 $rm -f varargs*
11874
11875 : see if stddef is available
11876 set stddef.h i_stddef
11877 eval $inhdr
11878
11879 : see if sys/access.h is available
11880 set sys/access.h i_sysaccess
11881 eval $inhdr
11882
11883 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
11884 set sys/filio.h i_sysfilio
11885 eval $inhdr
11886 echo " "
11887 if $test `./findhdr sys/ioctl.h`; then
11888         val="$define"
11889         echo '<sys/ioctl.h> found.' >&4
11890 else
11891         val="$undef"
11892         if $test $i_sysfilio = "$define"; then
11893             echo '<sys/ioctl.h> NOT found.' >&4
11894         else
11895                 $test $i_sgtty = "$define" && xxx="sgtty.h"
11896                 $test $i_termio = "$define" && xxx="termio.h"
11897                 $test $i_termios = "$define" && xxx="termios.h"
11898 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
11899         fi
11900 fi
11901 set i_sysioctl
11902 eval $setvar
11903
11904 : see if this is a sys/param system
11905 set sys/param.h i_sysparam
11906 eval $inhdr
11907
11908 : see if sys/resource.h has to be included
11909 set sys/resource.h i_sysresrc
11910 eval $inhdr
11911
11912 : see if sys/security.h is available
11913 set sys/security.h i_syssecrt
11914 eval $inhdr
11915
11916 : see if this is a sys/un.h system
11917 set sys/un.h i_sysun
11918 eval $inhdr
11919
11920 : see if this is a syswait system
11921 set sys/wait.h i_syswait
11922 eval $inhdr
11923
11924 : see if this is an utime system
11925 set utime.h i_utime
11926 eval $inhdr
11927
11928 : see if this is a values.h system
11929 set values.h i_values
11930 eval $inhdr
11931
11932 : see if this is a vfork system
11933 case "$d_vfork" in
11934 "$define")
11935         set vfork.h i_vfork
11936         eval $inhdr
11937         ;;
11938 *)
11939         i_vfork="$undef"
11940         ;;
11941 esac
11942
11943 : see if gdbm.h is available
11944 set gdbm.h t_gdbm
11945 eval $inhdr
11946 case "$t_gdbm" in
11947 $define)
11948         : see if gdbm_open exists
11949         set gdbm_open d_gdbm_open
11950         eval $inlibc
11951         case "$d_gdbm_open" in
11952         $undef)
11953                 t_gdbm="$undef"
11954                 echo "We won't be including <gdbm.h>"
11955                 ;;
11956         esac
11957         ;;
11958 esac
11959 val="$t_gdbm"
11960 set i_gdbm
11961 eval $setvar
11962
11963 echo " "
11964 echo "Looking for extensions..." >&4
11965 tdir=`pwd`
11966 cd $rsrc/ext
11967 : If we are using the old config.sh, known_extensions may contain
11968 : old or inaccurate or duplicate values.
11969 known_extensions=''
11970 nonxs_extensions=''
11971 : We do not use find because it might not be available.
11972 : We do not just use MANIFEST because the user may have dropped
11973 : some additional extensions into the source tree and expect them
11974 : to be built.
11975 for xxx in * ; do
11976         case "$xxx" in
11977         DynaLoader|dynaload) ;;
11978         *)      if $test -f $xxx/$xxx.xs; then
11979                         known_extensions="$known_extensions $xxx"
11980                 elif $test -f $xxx/Makefile.PL; then
11981                         nonxs_extensions="$nonxs_extensions $xxx"
11982                 else
11983                         if $test -d $xxx; then
11984                                 # Look for nested extensions, eg. Devel/Dprof.
11985                                 cd $xxx
11986                                 for yyy in * ; do
11987                                 if $test -f $yyy/$yyy.xs; then
11988                                         known_extensions="$known_extensions $xxx/$yyy"
11989                                 elif $test -f $yyy/Makefile.PL; then
11990                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
11991                                 fi
11992                                 done
11993                                 cd ..
11994                         fi
11995                 fi 
11996                 ;;
11997         esac
11998 done
11999 set X $nonxs_extensions
12000 shift
12001 nonxs_extensions="$*"
12002 set X $known_extensions
12003 shift
12004 known_extensions="$*"
12005 cd $tdir
12006
12007 : Now see which are supported on this system.
12008 avail_ext=''
12009 for xxx in $known_extensions ; do
12010         case "$xxx" in
12011         DB_File|db_file)
12012                 case "$i_db" in
12013                 $define) avail_ext="$avail_ext $xxx" ;;
12014                 esac
12015                 ;;
12016         GDBM_File|gdbm_fil)
12017                 case "$i_gdbm" in 
12018                 $define) avail_ext="$avail_ext $xxx" ;;
12019                 esac
12020                 ;;
12021         NDBM_File|ndbm_fil)
12022                 case "$i_ndbm" in
12023                 $define) avail_ext="$avail_ext $xxx" ;;
12024                 esac
12025                 ;;
12026         ODBM_File|odbm_fil) 
12027                 case "${i_dbm}${i_rpcsvcdbm}" in
12028                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12029                 esac
12030                 ;;
12031         POSIX|posix)
12032                 case "$useposix" in
12033                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12034                 esac
12035                 ;;
12036         Opcode|opcode)
12037                 case "$useopcode" in
12038                 true|define|y) avail_ext="$avail_ext $xxx" ;;
12039                 esac
12040                 ;;
12041         Socket|socket)
12042                 case "$d_socket" in 
12043                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12044                 esac
12045                 ;;
12046         Thread|thread)
12047                 case "$usethreads" in 
12048                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12049                 esac
12050                 ;;
12051         IPC/SysV|ipc/sysv)
12052                 : XXX Do we need a useipcsysv variable here
12053                 case "${d_msg}${d_sem}${d_shm}" in 
12054                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12055                 esac
12056                 ;;
12057         *)      avail_ext="$avail_ext $xxx"
12058                 ;;
12059         esac
12060 done
12061
12062 set X $avail_ext
12063 shift
12064 avail_ext="$*"
12065
12066 : Now see which nonxs extensions are supported on this system.
12067 : For now assume all are.
12068 nonxs_ext=''
12069 for xxx in $nonxs_extensions ; do
12070         case "$xxx" in
12071         *)      nonxs_ext="$nonxs_ext $xxx"
12072                 ;;
12073         esac
12074 done
12075
12076 set X $nonxs_ext
12077 shift
12078 nonxs_ext="$*"
12079
12080 case $usedl in
12081 $define)
12082         $cat <<EOM
12083 A number of extensions are supplied with $package.  You may choose to
12084 compile these extensions for dynamic loading (the default), compile
12085 them into the $package executable (static loading), or not include
12086 them at all.  Answer "none" to include no extensions.
12087 Note that DynaLoader is always built and need not be mentioned here.
12088
12089 EOM
12090         case "$dynamic_ext" in
12091         '') dflt="$avail_ext" ;;
12092         *)      dflt="$dynamic_ext"
12093                 # Perhaps we are reusing an old out-of-date config.sh.
12094                 case "$hint" in
12095                 previous)
12096                         if test X"$dynamic_ext" != X"$avail_ext"; then
12097                                 $cat <<EOM
12098 NOTICE:  Your previous config.sh list may be incorrect. 
12099 The extensions now available to you are 
12100         ${avail_ext}
12101 but the default list from your previous config.sh is
12102         ${dynamic_ext} 
12103
12104 EOM
12105                         fi
12106                         ;;
12107                 esac
12108                 ;;
12109         esac
12110         case "$dflt" in
12111         '')     dflt=none;;
12112         esac
12113         rp="What extensions do you wish to load dynamically?"
12114         . ./myread
12115         case "$ans" in
12116         none) dynamic_ext=' ' ;;
12117         *) dynamic_ext="$ans" ;;
12118         esac
12119
12120         case "$static_ext" in
12121         '')
12122                 : Exclude those already listed in dynamic linking
12123                 dflt=''
12124                 for xxx in $avail_ext; do
12125                         case " $dynamic_ext " in
12126                         *" $xxx "*) ;;
12127                         *) dflt="$dflt $xxx" ;;
12128                         esac
12129                 done
12130                 set X $dflt
12131                 shift
12132                 dflt="$*"
12133                 ;;
12134         *)  dflt="$static_ext" 
12135                 ;;
12136         esac
12137
12138         case "$dflt" in
12139         '')     dflt=none;;
12140         esac
12141         rp="What extensions do you wish to load statically?"
12142         . ./myread
12143         case "$ans" in
12144         none) static_ext=' ' ;;
12145         *) static_ext="$ans" ;;
12146         esac
12147         ;;
12148 *)
12149         $cat <<EOM
12150 A number of extensions are supplied with $package.  Answer "none" 
12151 to include no extensions. 
12152 Note that DynaLoader is always built and need not be mentioned here.
12153
12154 EOM
12155         case "$static_ext" in
12156         '') dflt="$avail_ext" ;;
12157         *)      dflt="$static_ext"
12158                 # Perhaps we are reusing an old out-of-date config.sh.
12159                 case "$hint" in
12160                 previous)
12161                         if test X"$static_ext" != X"$avail_ext"; then
12162                                 $cat <<EOM
12163 NOTICE:  Your previous config.sh list may be incorrect. 
12164 The extensions now available to you are 
12165         ${avail_ext}
12166 but the default list from your previous config.sh is
12167         ${static_ext} 
12168
12169 EOM
12170                         fi
12171                         ;;
12172                 esac
12173                 ;;
12174         esac
12175         : Exclude those that are not xs extensions
12176         case "$dflt" in
12177         '')     dflt=none;;
12178         esac
12179         rp="What extensions do you wish to include?"
12180         . ./myread
12181         case "$ans" in
12182         none) static_ext=' ' ;;
12183         *) static_ext="$ans" ;;
12184         esac
12185         ;;
12186 esac
12187
12188 set X $dynamic_ext $static_ext $nonxs_ext
12189 shift
12190 extensions="$*"
12191
12192 : Remove build directory name from cppstdin so it can be used from
12193 : either the present location or the final installed location.
12194 echo " "
12195 : Get out of the UU directory to get correct path name.
12196 cd ..
12197 case "$cppstdin" in
12198 `pwd`/cppstdin)
12199         echo "Stripping down cppstdin path name"
12200         cppstdin=cppstdin
12201         ;;
12202 esac
12203 cd UU
12204
12205 : end of configuration questions
12206 echo " "
12207 echo "End of configuration questions."
12208 echo " "
12209
12210 : back to where it started
12211 if test -d ../UU; then
12212         cd ..
12213 fi
12214
12215 : configuration may be patched via a 'config.over' file
12216 if $test -f config.over; then
12217         echo " "
12218         dflt=y
12219         rp='I see a config.over file.  Do you wish to load it?'
12220         . UU/myread
12221         case "$ans" in
12222         n*) echo "OK, I'll ignore it.";;
12223         *)      . ./config.over
12224                 echo "Configuration override changes have been loaded."
12225                 ;;
12226         esac
12227 fi
12228
12229 : in case they want portability, strip down executable paths
12230 case "$d_portable" in
12231 "$define")
12232         echo " "
12233         echo "Stripping down executable paths..." >&4
12234         for file in $loclist $trylist; do
12235                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12236                         eval $file="\$file"
12237                 fi
12238         done
12239         ;;
12240 esac
12241
12242 : create config.sh file
12243 echo " "
12244 echo "Creating config.sh..." >&4
12245 $spitshell <<EOT >config.sh
12246 $startsh
12247 #
12248 # This file was produced by running the Configure script. It holds all the
12249 # definitions figured out by Configure. Should you modify one of these values,
12250 # do not forget to propagate your changes by running "Configure -der". You may
12251 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12252 #
12253
12254 # Package name      : $package
12255 # Source directory  : $src
12256 # Configuration time: $cf_time
12257 # Configured by     : $cf_by
12258 # Target system     : $myuname
12259
12260 Author='$Author'
12261 Date='$Date'
12262 Header='$Header'
12263 Id='$Id'
12264 Locker='$Locker'
12265 Log='$Log'
12266 Mcc='$Mcc'
12267 RCSfile='$RCSfile'
12268 Revision='$Revision'
12269 Source='$Source'
12270 State='$State'
12271 _a='$_a'
12272 _exe='$_exe'
12273 _o='$_o'
12274 afs='$afs'
12275 alignbytes='$alignbytes'
12276 ansi2knr='$ansi2knr'
12277 aphostname='$aphostname'
12278 apiversion='$apiversion'
12279 ar='$ar'
12280 archlib='$archlib'
12281 archlibexp='$archlibexp'
12282 archname64='$archname64'
12283 archname='$archname'
12284 archobjs='$archobjs'
12285 awk='$awk'
12286 baserev='$baserev'
12287 bash='$bash'
12288 bin='$bin'
12289 binexp='$binexp'
12290 bison='$bison'
12291 byacc='$byacc'
12292 byteorder='$byteorder'
12293 c='$c'
12294 castflags='$castflags'
12295 cat='$cat'
12296 cc='$cc'
12297 cccdlflags='$cccdlflags'
12298 ccdlflags='$ccdlflags'
12299 ccflags='$ccflags'
12300 cf_by='$cf_by'
12301 cf_email='$cf_email'
12302 cf_time='$cf_time'
12303 chgrp='$chgrp'
12304 chmod='$chmod'
12305 chown='$chown'
12306 clocktype='$clocktype'
12307 comm='$comm'
12308 compress='$compress'
12309 contains='$contains'
12310 cp='$cp'
12311 cpio='$cpio'
12312 cpp='$cpp'
12313 cpp_stuff='$cpp_stuff'
12314 cppflags='$cppflags'
12315 cpplast='$cpplast'
12316 cppminus='$cppminus'
12317 cpprun='$cpprun'
12318 cppstdin='$cppstdin'
12319 cryptlib='$cryptlib'
12320 csh='$csh'
12321 d_Gconvert='$d_Gconvert'
12322 d_access='$d_access'
12323 d_accessx='$d_accessx'
12324 d_alarm='$d_alarm'
12325 d_archlib='$d_archlib'
12326 d_attribut='$d_attribut'
12327 d_bcmp='$d_bcmp'
12328 d_bcopy='$d_bcopy'
12329 d_bsd='$d_bsd'
12330 d_bsdgetpgrp='$d_bsdgetpgrp'
12331 d_bsdsetpgrp='$d_bsdsetpgrp'
12332 d_bzero='$d_bzero'
12333 d_casti32='$d_casti32'
12334 d_castneg='$d_castneg'
12335 d_charvspr='$d_charvspr'
12336 d_chown='$d_chown'
12337 d_chroot='$d_chroot'
12338 d_chsize='$d_chsize'
12339 d_closedir='$d_closedir'
12340 d_cmsghdr_s='$d_cmsghdr_s'
12341 d_const='$d_const'
12342 d_crypt='$d_crypt'
12343 d_csh='$d_csh'
12344 d_cuserid='$d_cuserid'
12345 d_dbl_dig='$d_dbl_dig'
12346 d_dbmclose64='$d_dbmclose64'
12347 d_dbminit64='$d_dbminit64'
12348 d_delete64='$d_delete64'
12349 d_difftime='$d_difftime'
12350 d_dirent64_s='$d_dirent64_s'
12351 d_dirnamlen='$d_dirnamlen'
12352 d_dlerror='$d_dlerror'
12353 d_dlopen='$d_dlopen'
12354 d_dlsymun='$d_dlsymun'
12355 d_dosuid='$d_dosuid'
12356 d_drand48proto='$d_drand48proto'
12357 d_dup2='$d_dup2'
12358 d_eaccess='$d_eaccess'
12359 d_endgrent='$d_endgrent'
12360 d_endhent='$d_endhent'
12361 d_endnent='$d_endnent'
12362 d_endpent='$d_endpent'
12363 d_endpwent='$d_endpwent'
12364 d_endsent='$d_endsent'
12365 d_eofnblk='$d_eofnblk'
12366 d_eunice='$d_eunice'
12367 d_fchmod='$d_fchmod'
12368 d_fchown='$d_fchown'
12369 d_fcntl='$d_fcntl'
12370 d_fd_macros='$d_fd_macros'
12371 d_fd_set='$d_fd_set'
12372 d_fds_bits='$d_fds_bits'
12373 d_fetch64='$d_fetch64'
12374 d_fgetpos64='$d_fgetpos64'
12375 d_fgetpos='$d_fgetpos'
12376 d_firstkey64='$d_firstkey64'
12377 d_flexfnam='$d_flexfnam'
12378 d_flock64_s='$d_flock64_s'
12379 d_flock='$d_flock'
12380 d_fopen64='$d_fopen64'
12381 d_fork='$d_fork'
12382 d_fpathconf='$d_fpathconf'
12383 d_freopen64='$d_freopen64'
12384 d_fseek64='$d_fseek64'
12385 d_fseeko64='$d_fseeko64'
12386 d_fseeko='$d_fseeko'
12387 d_fsetpos64='$d_fsetpos64'
12388 d_fsetpos='$d_fsetpos'
12389 d_fstat64='$d_fstat64'
12390 d_ftell64='$d_ftell64'
12391 d_ftello64='$d_ftello64'
12392 d_ftello='$d_ftello'
12393 d_ftime='$d_ftime'
12394 d_ftruncate64='$d_ftruncate64'
12395 d_getgrent='$d_getgrent'
12396 d_getgrps='$d_getgrps'
12397 d_gethbyaddr='$d_gethbyaddr'
12398 d_gethbyname='$d_gethbyname'
12399 d_gethent='$d_gethent'
12400 d_gethname='$d_gethname'
12401 d_gethostprotos='$d_gethostprotos'
12402 d_getlogin='$d_getlogin'
12403 d_getnbyaddr='$d_getnbyaddr'
12404 d_getnbyname='$d_getnbyname'
12405 d_getnent='$d_getnent'
12406 d_getnetprotos='$d_getnetprotos'
12407 d_getpbyname='$d_getpbyname'
12408 d_getpbynumber='$d_getpbynumber'
12409 d_getpent='$d_getpent'
12410 d_getpgid='$d_getpgid'
12411 d_getpgrp2='$d_getpgrp2'
12412 d_getpgrp='$d_getpgrp'
12413 d_getppid='$d_getppid'
12414 d_getprior='$d_getprior'
12415 d_getprotoprotos='$d_getprotoprotos'
12416 d_getpwent='$d_getpwent'
12417 d_getsbyname='$d_getsbyname'
12418 d_getsbyport='$d_getsbyport'
12419 d_getsent='$d_getsent'
12420 d_getservprotos='$d_getservprotos'
12421 d_gettimeod='$d_gettimeod'
12422 d_gnulibc='$d_gnulibc'
12423 d_grpasswd='$d_grpasswd'
12424 d_htonl='$d_htonl'
12425 d_index='$d_index'
12426 d_inetaton='$d_inetaton'
12427 d_ino64t='$d_ino64t'
12428 d_int64t='$d_int64t'
12429 d_iovec_s='$d_iovec_s'
12430 d_isascii='$d_isascii'
12431 d_killpg='$d_killpg'
12432 d_lchown='$d_lchown'
12433 d_link='$d_link'
12434 d_locconv='$d_locconv'
12435 d_lockf64='$d_lockf64'
12436 d_lockf='$d_lockf'
12437 d_longdbl='$d_longdbl'
12438 d_longlong='$d_longlong'
12439 d_lseek64='$d_lseek64'
12440 d_lstat64='$d_lstat64'
12441 d_lstat='$d_lstat'
12442 d_mblen='$d_mblen'
12443 d_mbstowcs='$d_mbstowcs'
12444 d_mbtowc='$d_mbtowc'
12445 d_memcmp='$d_memcmp'
12446 d_memcpy='$d_memcpy'
12447 d_memmove='$d_memmove'
12448 d_memset='$d_memset'
12449 d_mkdir='$d_mkdir'
12450 d_mkfifo='$d_mkfifo'
12451 d_mktime='$d_mktime'
12452 d_msg='$d_msg'
12453 d_msg_ctrunc='$d_msg_ctrunc'
12454 d_msg_dontroute='$d_msg_dontroute'
12455 d_msg_oob='$d_msg_oob'
12456 d_msg_peek='$d_msg_peek'
12457 d_msg_proxy='$d_msg_proxy'
12458 d_msgctl='$d_msgctl'
12459 d_msgget='$d_msgget'
12460 d_msghdr_s='$d_msghdr_s'
12461 d_msgrcv='$d_msgrcv'
12462 d_msgsnd='$d_msgsnd'
12463 d_mymalloc='$d_mymalloc'
12464 d_nextkey64='$d_nextkey64'
12465 d_nice='$d_nice'
12466 d_off64t='$d_off64t'
12467 d_old_pthread_create_joinable='$d_old_pthread_create_joinable'
12468 d_oldpthreads='$d_oldpthreads'
12469 d_oldsock='$d_oldsock'
12470 d_open3='$d_open3'
12471 d_open64='$d_open64'
12472 d_opendir64='$d_opendir64'
12473 d_pathconf='$d_pathconf'
12474 d_pause='$d_pause'
12475 d_phostname='$d_phostname'
12476 d_pipe='$d_pipe'
12477 d_poll='$d_poll'
12478 d_portable='$d_portable'
12479 d_pthread_yield='$d_pthread_yield'
12480 d_pwage='$d_pwage'
12481 d_pwchange='$d_pwchange'
12482 d_pwclass='$d_pwclass'
12483 d_pwcomment='$d_pwcomment'
12484 d_pwexpire='$d_pwexpire'
12485 d_pwgecos='$d_pwgecos'
12486 d_pwpasswd='$d_pwpasswd'
12487 d_pwquota='$d_pwquota'
12488 d_readdir64='$d_readdir64'
12489 d_readdir='$d_readdir'
12490 d_readlink='$d_readlink'
12491 d_readv='$d_readv'
12492 d_recvmsg='$d_recvmsg'
12493 d_rename='$d_rename'
12494 d_rewinddir='$d_rewinddir'
12495 d_rmdir='$d_rmdir'
12496 d_safebcpy='$d_safebcpy'
12497 d_safemcpy='$d_safemcpy'
12498 d_sanemcmp='$d_sanemcmp'
12499 d_sched_yield='$d_sched_yield'
12500 d_scm_rights='$d_scm_rights'
12501 d_seekdir64='$d_seekdir64'
12502 d_seekdir='$d_seekdir'
12503 d_select='$d_select'
12504 d_sem='$d_sem'
12505 d_semctl='$d_semctl'
12506 d_semctl_semid_ds='$d_semctl_semid_ds'
12507 d_semctl_semun='$d_semctl_semun'
12508 d_semget='$d_semget'
12509 d_semop='$d_semop'
12510 d_sendmsg='$d_sendmsg'
12511 d_setegid='$d_setegid'
12512 d_seteuid='$d_seteuid'
12513 d_setgrent='$d_setgrent'
12514 d_setgrps='$d_setgrps'
12515 d_sethent='$d_sethent'
12516 d_setlinebuf='$d_setlinebuf'
12517 d_setlocale='$d_setlocale'
12518 d_setnent='$d_setnent'
12519 d_setpent='$d_setpent'
12520 d_setpgid='$d_setpgid'
12521 d_setpgrp2='$d_setpgrp2'
12522 d_setpgrp='$d_setpgrp'
12523 d_setprior='$d_setprior'
12524 d_setpwent='$d_setpwent'
12525 d_setregid='$d_setregid'
12526 d_setresgid='$d_setresgid'
12527 d_setresuid='$d_setresuid'
12528 d_setreuid='$d_setreuid'
12529 d_setrgid='$d_setrgid'
12530 d_setruid='$d_setruid'
12531 d_setsent='$d_setsent'
12532 d_setsid='$d_setsid'
12533 d_setvbuf='$d_setvbuf'
12534 d_sfio='$d_sfio'
12535 d_shm='$d_shm'
12536 d_shmat='$d_shmat'
12537 d_shmatprototype='$d_shmatprototype'
12538 d_shmctl='$d_shmctl'
12539 d_shmdt='$d_shmdt'
12540 d_shmget='$d_shmget'
12541 d_sigaction='$d_sigaction'
12542 d_sigsetjmp='$d_sigsetjmp'
12543 d_socket='$d_socket'
12544 d_sockpair='$d_sockpair'
12545 d_stat64='$d_stat64'
12546 d_statblks='$d_statblks'
12547 d_stdio_cnt_lval='$d_stdio_cnt_lval'
12548 d_stdio_ptr_lval='$d_stdio_ptr_lval'
12549 d_stdiobase='$d_stdiobase'
12550 d_stdstdio='$d_stdstdio'
12551 d_store64='$d_store64'
12552 d_strchr='$d_strchr'
12553 d_strcoll='$d_strcoll'
12554 d_strctcpy='$d_strctcpy'
12555 d_strerrm='$d_strerrm'
12556 d_strerror='$d_strerror'
12557 d_strtod='$d_strtod'
12558 d_strtol='$d_strtol'
12559 d_strtoul='$d_strtoul'
12560 d_strxfrm='$d_strxfrm'
12561 d_suidsafe='$d_suidsafe'
12562 d_symlink='$d_symlink'
12563 d_syscall='$d_syscall'
12564 d_sysconf='$d_sysconf'
12565 d_sysernlst='$d_sysernlst'
12566 d_syserrlst='$d_syserrlst'
12567 d_system='$d_system'
12568 d_tcgetpgrp='$d_tcgetpgrp'
12569 d_tcsetpgrp='$d_tcsetpgrp'
12570 d_telldir64='$d_telldir64'
12571 d_telldir='$d_telldir'
12572 d_time='$d_time'
12573 d_times='$d_times'
12574 d_tmpfile64='$d_tmpfile64'
12575 d_truncate64='$d_truncate64'
12576 d_truncate='$d_truncate'
12577 d_tzname='$d_tzname'
12578 d_umask='$d_umask'
12579 d_uname='$d_uname'
12580 d_union_semun='$d_union_semun'
12581 d_vfork='$d_vfork'
12582 d_void_closedir='$d_void_closedir'
12583 d_voidsig='$d_voidsig'
12584 d_voidtty='$d_voidtty'
12585 d_volatile='$d_volatile'
12586 d_vprintf='$d_vprintf'
12587 d_wait4='$d_wait4'
12588 d_waitpid='$d_waitpid'
12589 d_wcstombs='$d_wcstombs'
12590 d_wctomb='$d_wctomb'
12591 d_writev='$d_writev'
12592 d_xenix='$d_xenix'
12593 date='$date'
12594 db_hashtype='$db_hashtype'
12595 db_prefixtype='$db_prefixtype'
12596 defvoidused='$defvoidused'
12597 direntrytype='$direntrytype'
12598 dlext='$dlext'
12599 dlsrc='$dlsrc'
12600 doublesize='$doublesize'
12601 drand01='$drand01'
12602 dynamic_ext='$dynamic_ext'
12603 eagain='$eagain'
12604 ebcdic='$ebcdic'
12605 echo='$echo'
12606 egrep='$egrep'
12607 emacs='$emacs'
12608 eunicefix='$eunicefix'
12609 exe_ext='$exe_ext'
12610 expr='$expr'
12611 extensions='$extensions'
12612 find='$find'
12613 firstmakefile='$firstmakefile'
12614 flex='$flex'
12615 fpostype='$fpostype'
12616 freetype='$freetype'
12617 full_csh='$full_csh'
12618 full_sed='$full_sed'
12619 gccversion='$gccversion'
12620 gidtype='$gidtype'
12621 glibpth='$glibpth'
12622 grep='$grep'
12623 groupcat='$groupcat'
12624 groupstype='$groupstype'
12625 gzip='$gzip'
12626 h_fcntl='$h_fcntl'
12627 h_sysfile='$h_sysfile'
12628 hint='$hint'
12629 hostcat='$hostcat'
12630 huge='$huge'
12631 i_arpainet='$i_arpainet'
12632 i_bsdioctl='$i_bsdioctl'
12633 i_db='$i_db'
12634 i_dbm='$i_dbm'
12635 i_dirent='$i_dirent'
12636 i_dld='$i_dld'
12637 i_dlfcn='$i_dlfcn'
12638 i_fcntl='$i_fcntl'
12639 i_float='$i_float'
12640 i_gdbm='$i_gdbm'
12641 i_grp='$i_grp'
12642 i_inttypes='$i_inttypes'
12643 i_limits='$i_limits'
12644 i_locale='$i_locale'
12645 i_machcthr='$i_machcthr'
12646 i_malloc='$i_malloc'
12647 i_math='$i_math'
12648 i_memory='$i_memory'
12649 i_ndbm='$i_ndbm'
12650 i_netdb='$i_netdb'
12651 i_neterrno='$i_neterrno'
12652 i_niin='$i_niin'
12653 i_poll='$i_poll'
12654 i_pwd='$i_pwd'
12655 i_rpcsvcdbm='$i_rpcsvcdbm'
12656 i_sfio='$i_sfio'
12657 i_sgtty='$i_sgtty'
12658 i_stdarg='$i_stdarg'
12659 i_stddef='$i_stddef'
12660 i_stdlib='$i_stdlib'
12661 i_string='$i_string'
12662 i_sysaccess='$i_sysaccess'
12663 i_sysdir='$i_sysdir'
12664 i_sysfile='$i_sysfile'
12665 i_sysfilio='$i_sysfilio'
12666 i_sysin='$i_sysin'
12667 i_sysioctl='$i_sysioctl'
12668 i_sysndir='$i_sysndir'
12669 i_sysparam='$i_sysparam'
12670 i_sysresrc='$i_sysresrc'
12671 i_syssecrt='$i_syssecrt'
12672 i_sysselct='$i_sysselct'
12673 i_syssockio='$i_syssockio'
12674 i_sysstat='$i_sysstat'
12675 i_systime='$i_systime'
12676 i_systimek='$i_systimek'
12677 i_systimes='$i_systimes'
12678 i_systypes='$i_systypes'
12679 i_sysuio='$i_sysuio'
12680 i_sysun='$i_sysun'
12681 i_syswait='$i_syswait'
12682 i_termio='$i_termio'
12683 i_termios='$i_termios'
12684 i_time='$i_time'
12685 i_unistd='$i_unistd'
12686 i_utime='$i_utime'
12687 i_values='$i_values'
12688 i_varargs='$i_varargs'
12689 i_varhdr='$i_varhdr'
12690 i_vfork='$i_vfork'
12691 ignore_versioned_solibs='$ignore_versioned_solibs'
12692 incpath='$incpath'
12693 inews='$inews'
12694 installarchlib='$installarchlib'
12695 installbin='$installbin'
12696 installman1dir='$installman1dir'
12697 installman3dir='$installman3dir'
12698 installprivlib='$installprivlib'
12699 installscript='$installscript'
12700 installsitearch='$installsitearch'
12701 installsitelib='$installsitelib'
12702 intsize='$intsize'
12703 known_extensions='$known_extensions'
12704 ksh='$ksh'
12705 large='$large'
12706 ld='$ld'
12707 lddlflags='$lddlflags'
12708 ldflags='$ldflags'
12709 less='$less'
12710 lib_ext='$lib_ext'
12711 libc='$libc'
12712 libperl='$libperl'
12713 libpth='$libpth'
12714 libs='$libs'
12715 libswanted='$libswanted'
12716 line='$line'
12717 lint='$lint'
12718 lkflags='$lkflags'
12719 ln='$ln'
12720 lns='$lns'
12721 locincpth='$locincpth'
12722 loclibpth='$loclibpth'
12723 longdblsize='$longdblsize'
12724 longlongsize='$longlongsize'
12725 longsize='$longsize'
12726 lp='$lp'
12727 lpr='$lpr'
12728 ls='$ls'
12729 lseeksize='$lseeksize'
12730 lseektype='$lseektype'
12731 mail='$mail'
12732 mailx='$mailx'
12733 make='$make'
12734 make_set_make='$make_set_make'
12735 mallocobj='$mallocobj'
12736 mallocsrc='$mallocsrc'
12737 malloctype='$malloctype'
12738 man1dir='$man1dir'
12739 man1direxp='$man1direxp'
12740 man1ext='$man1ext'
12741 man3dir='$man3dir'
12742 man3direxp='$man3direxp'
12743 man3ext='$man3ext'
12744 medium='$medium'
12745 mips='$mips'
12746 mips_type='$mips_type'
12747 mkdir='$mkdir'
12748 models='$models'
12749 modetype='$modetype'
12750 more='$more'
12751 mv='$mv'
12752 myarchname='$myarchname'
12753 mydomain='$mydomain'
12754 myhostname='$myhostname'
12755 myuname='$myuname'
12756 n='$n'
12757 netdb_hlen_type='$netdb_hlen_type'
12758 netdb_host_type='$netdb_host_type'
12759 netdb_name_type='$netdb_name_type'
12760 netdb_net_type='$netdb_net_type'
12761 nm='$nm'
12762 nm_opt='$nm_opt'
12763 nm_so_opt='$nm_so_opt'
12764 nonxs_ext='$nonxs_ext'
12765 nroff='$nroff'
12766 o_nonblock='$o_nonblock'
12767 obj_ext='$obj_ext'
12768 old_pthread_create_joinable='$old_pthread_create_joinable'
12769 optimize='$optimize'
12770 orderlib='$orderlib'
12771 osname='$osname'
12772 osvers='$osvers'
12773 package='$package'
12774 pager='$pager'
12775 passcat='$passcat'
12776 patchlevel='$patchlevel'
12777 path_sep='$path_sep'
12778 perl='$perl'
12779 perladmin='$perladmin'
12780 perlpath='$perlpath'
12781 pg='$pg'
12782 phostname='$phostname'
12783 pidtype='$pidtype'
12784 plibpth='$plibpth'
12785 pmake='$pmake'
12786 pr='$pr'
12787 prefix='$prefix'
12788 prefixexp='$prefixexp'
12789 privlib='$privlib'
12790 privlibexp='$privlibexp'
12791 prototype='$prototype'
12792 ptrsize='$ptrsize'
12793 randbits='$randbits'
12794 randfunc='$randfunc'
12795 randseedtype='$randseedtype'
12796 ranlib='$ranlib'
12797 rd_nodata='$rd_nodata'
12798 rm='$rm'
12799 rmail='$rmail'
12800 runnm='$runnm'
12801 sched_yield='$sched_yield'
12802 scriptdir='$scriptdir'
12803 scriptdirexp='$scriptdirexp'
12804 sed='$sed'
12805 seedfunc='$seedfunc'
12806 selectminbits='$selectminbits'
12807 selecttype='$selecttype'
12808 sendmail='$sendmail'
12809 sh='$sh'
12810 shar='$shar'
12811 sharpbang='$sharpbang'
12812 shmattype='$shmattype'
12813 shortsize='$shortsize'
12814 shrpenv='$shrpenv'
12815 shsharp='$shsharp'
12816 sig_name='$sig_name'
12817 sig_name_init='$sig_name_init'
12818 sig_num='$sig_num'
12819 sig_num_init='$sig_num_init'
12820 signal_t='$signal_t'
12821 sitearch='$sitearch'
12822 sitearchexp='$sitearchexp'
12823 sitelib='$sitelib'
12824 sitelibexp='$sitelibexp'
12825 sizetype='$sizetype'
12826 sleep='$sleep'
12827 smail='$smail'
12828 small='$small'
12829 so='$so'
12830 sockethdr='$sockethdr'
12831 socketlib='$socketlib'
12832 sort='$sort'
12833 spackage='$spackage'
12834 spitshell='$spitshell'
12835 split='$split'
12836 src='$src'
12837 ssizetype='$ssizetype'
12838 startperl='$startperl'
12839 startsh='$startsh'
12840 static_ext='$static_ext'
12841 stdchar='$stdchar'
12842 stdio_base='$stdio_base'
12843 stdio_bufsiz='$stdio_bufsiz'
12844 stdio_cnt='$stdio_cnt'
12845 stdio_filbuf='$stdio_filbuf'
12846 stdio_ptr='$stdio_ptr'
12847 strings='$strings'
12848 submit='$submit'
12849 subversion='$subversion'
12850 sysman='$sysman'
12851 tail='$tail'
12852 tar='$tar'
12853 tbl='$tbl'
12854 tee='$tee'
12855 test='$test'
12856 timeincl='$timeincl'
12857 timetype='$timetype'
12858 touch='$touch'
12859 tr='$tr'
12860 trnl='$trnl'
12861 troff='$troff'
12862 uidtype='$uidtype'
12863 uname='$uname'
12864 uniq='$uniq'
12865 use64bits='$use64bits'
12866 usedl='$usedl'
12867 usemultiplicity='$usemultiplicity'
12868 usemymalloc='$usemymalloc'
12869 usenm='$usenm'
12870 useopcode='$useopcode'
12871 useperlio='$useperlio'
12872 useposix='$useposix'
12873 usesfio='$usesfio'
12874 useshrplib='$useshrplib'
12875 usethreads='$usethreads'
12876 usevfork='$usevfork'
12877 usrinc='$usrinc'
12878 uuname='$uuname'
12879 version='$version'
12880 vi='$vi'
12881 voidflags='$voidflags'
12882 xlibpth='$xlibpth'
12883 zcat='$zcat'
12884 zip='$zip'
12885 EOT
12886
12887 : Add in command line options if available
12888 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
12889
12890 : add special variables
12891 $test -f $src/patchlevel.h && \
12892 awk '/^#define/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
12893 echo "CONFIG=true" >>config.sh
12894
12895 : propagate old symbols
12896 if $test -f UU/config.sh; then
12897         <UU/config.sh sort | uniq >UU/oldconfig.sh
12898         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
12899         sort | uniq -u >UU/oldsyms
12900         set X `cat UU/oldsyms`
12901         shift
12902         case $# in
12903         0) ;;
12904         *)
12905                 cat <<EOM
12906 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
12907 EOM
12908                 echo "# Variables propagated from previous config.sh file." >>config.sh
12909                 for sym in `cat UU/oldsyms`; do
12910                         echo "    Propagating $hint variable "'$'"$sym..."
12911                         eval 'tmp="$'"${sym}"'"'
12912                         echo "$tmp" | \
12913                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
12914                 done
12915                 ;;
12916         esac
12917 fi
12918
12919 : Finish up by extracting the .SH files
12920 case "$alldone" in
12921 exit)
12922         $rm -rf UU
12923         echo "Done."
12924         exit 0
12925         ;;
12926 cont)
12927         ;;
12928 '')
12929         dflt=''
12930         nostick=true
12931         $cat <<EOM
12932
12933 If you'd like to make any changes to the config.sh file before I begin
12934 to configure things, do it as a shell escape now (e.g. !vi config.sh).
12935
12936 EOM
12937         rp="Press return or use a shell escape to edit config.sh:"
12938         . UU/myread
12939         nostick=''
12940         case "$ans" in
12941         '') ;;
12942         *) : in case they cannot read
12943                 sh 1>&4 -c "$ans";;
12944         esac
12945         ;;
12946 esac
12947
12948 : if this fails, just run all the .SH files by hand
12949 . ./config.sh
12950
12951 echo " "
12952 exec 1>&4
12953 . ./UU/extract
12954
12955 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
12956         dflt=y
12957         case "$silent" in
12958         true) ;;
12959         *)
12960                 $cat <<EOM
12961
12962 Now you need to generate make dependencies by running "$make depend".
12963 You might prefer to run it in background: "$make depend > makedepend.out &"
12964 It can take a while, so you might not want to run it right now.
12965
12966 EOM
12967                 ;;
12968         esac
12969         rp="Run $make depend now?"
12970         . UU/myread
12971         case "$ans" in
12972         y*)
12973                 $make depend && echo "Now you must run a $make."
12974                 ;;
12975         *)
12976                 echo "You must run '$make depend' then '$make'."
12977                 ;;
12978         esac
12979 elif test -f [Mm]akefile; then
12980         echo " "
12981         echo "Now you must run a $make."
12982 else
12983         echo "Done."
12984 fi
12985
12986 if $test -f Policy.sh; then
12987     $cat <<EOM
12988
12989 If you compile $package on a different machine or from a different object
12990 directory, copy the Policy.sh file from this object directory to the
12991 new one before you run Configure -- this will help you with most of
12992 the policy defaults.
12993
12994 EOM
12995 fi
12996 if $test -f config.msg; then
12997     echo "Hmm.  I also noted the following information while running:"
12998     echo " "
12999     $cat config.msg >&4
13000     $rm -f config.msg
13001 fi
13002 $rm -f kit*isdone ark*isdone
13003 $rm -rf UU
13004
13005 : End of Configure
13006