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