phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
[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  5 14:26:57 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 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                 for net in net socket
7539                 do
7540                         if test -f /usr/lib/lib$net$_a; then
7541                                 ( ($nm $nm_opt /usr/lib/lib$net$_a | eval $nm_extract) ||  \
7542                                 $ar t /usr/lib/lib$net$_a) 2>/dev/null >> libc.list
7543                                 if $contains socket libc.list >/dev/null 2>&1; then
7544                                         d_socket="$define"
7545                                         case "$net" in
7546                                         net)
7547                                                 echo "...but the Wollongong group seems to have hacked it in." >&4
7548                                                 socketlib="-lnet"
7549                                                 sockethdr="-I/usr/netinclude"
7550                                                 ;;
7551                                         esac
7552                                         if $contains setsockopt libc.list >/dev/null 2>&1; then
7553                                                 d_oldsock="$undef"
7554                                         else
7555                                                 echo "...using the old 4.1c interface, rather than 4.2" >&4
7556                                                 d_oldsock="$define"
7557                                         fi
7558                                         break
7559                                 fi
7560                         fi
7561                 done
7562                 if test "X$d_socket" != "X$define"; then
7563                         echo "or anywhere else I see." >&4
7564                         d_socket="$undef"
7565                         d_oldsock="$undef"
7566                 fi
7567         fi
7568 fi
7569
7570 : see if socketpair exists
7571 set socketpair d_sockpair
7572 eval $inlibc
7573
7574 : see if sys/select.h has to be included
7575 set sys/select.h i_sysselct
7576 eval $inhdr
7577
7578 : see if we should include time.h, sys/time.h, or both
7579 echo " "
7580 if test "X$timeincl" = X; then
7581         echo "Testing to see if we should include <time.h>, <sys/time.h> or both." >&4
7582         $echo $n "I'm now running the test program...$c"
7583         $cat >try.c <<'EOCP'
7584 #include <sys/types.h>
7585 #ifdef I_TIME
7586 #include <time.h>
7587 #endif
7588 #ifdef I_SYSTIME
7589 #ifdef SYSTIMEKERNEL
7590 #define KERNEL
7591 #endif
7592 #include <sys/time.h>
7593 #endif
7594 #ifdef I_SYSSELECT
7595 #include <sys/select.h>
7596 #endif
7597 main()
7598 {
7599         struct tm foo;
7600 #ifdef S_TIMEVAL
7601         struct timeval bar;
7602 #endif
7603 #ifdef S_TIMEZONE
7604         struct timezone tzp;
7605 #endif
7606         if (foo.tm_sec == foo.tm_sec)
7607                 exit(0);
7608 #ifdef S_TIMEVAL
7609         if (bar.tv_sec == bar.tv_sec)
7610                 exit(0);
7611 #endif
7612         exit(1);
7613 }
7614 EOCP
7615         flags=''
7616         for s_timezone in '-DS_TIMEZONE' ''; do
7617         sysselect=''
7618         for s_timeval in '-DS_TIMEVAL' ''; do
7619         for i_systimek in '' '-DSYSTIMEKERNEL'; do
7620         for i_time in '' '-DI_TIME'; do
7621         for i_systime in '-DI_SYSTIME' ''; do
7622                 case "$flags" in
7623                 '') $echo $n ".$c"
7624                         set try $i_time $i_systime $i_systimek $sysselect $s_timeval $s_timezone
7625                         if eval $compile; then
7626                                 set X $i_time $i_systime $i_systimek $sysselect $s_timeval
7627                                 shift
7628                                 flags="$*"
7629                                 echo " "
7630                                 $echo $n "Succeeded with $flags$c"
7631                         fi
7632                         ;;
7633                 esac
7634         done
7635         done
7636         done
7637         done
7638         done
7639         timeincl=''
7640         echo " "
7641         case "$flags" in
7642         *SYSTIMEKERNEL*) i_systimek="$define"
7643                 timeincl=`./findhdr sys/time.h`
7644                 echo "We'll include <sys/time.h> with KERNEL defined." >&4;;
7645         *) i_systimek="$undef";;
7646         esac
7647         case "$flags" in
7648         *I_TIME*) i_time="$define"
7649                 timeincl=`./findhdr time.h`" $timeincl"
7650                 echo "We'll include <time.h>." >&4;;
7651         *) i_time="$undef";;
7652         esac
7653         case "$flags" in
7654         *I_SYSTIME*) i_systime="$define"
7655                 timeincl=`./findhdr sys/time.h`" $timeincl"
7656                 echo "We'll include <sys/time.h>." >&4;;
7657         *) i_systime="$undef";;
7658         esac
7659         $rm -f try.c try
7660 fi
7661
7662 : check for fd_set items
7663 $cat <<EOM
7664
7665 Checking to see how well your C compiler handles fd_set and friends ...
7666 EOM
7667 $cat >fd_set.c <<EOCP
7668 #$i_systime I_SYS_TIME
7669 #$i_sysselct I_SYS_SELECT
7670 #$d_socket HAS_SOCKET
7671 #include <sys/types.h>
7672 #ifdef HAS_SOCKET
7673 #include <sys/socket.h> /* Might include <sys/bsdtypes.h> */
7674 #endif
7675 #ifdef I_SYS_TIME
7676 #include <sys/time.h>
7677 #endif
7678 #ifdef I_SYS_SELECT
7679 #include <sys/select.h>
7680 #endif
7681 main() {
7682         fd_set fds;
7683
7684 #ifdef TRYBITS
7685         if(fds.fds_bits);
7686 #endif
7687
7688 #if defined(FD_SET) && defined(FD_CLR) && defined(FD_ISSET) && defined(FD_ZERO)
7689         exit(0);
7690 #else
7691         exit(1);
7692 #endif
7693 }
7694 EOCP
7695 set fd_set -DTRYBITS
7696 if eval $compile; then
7697         d_fds_bits="$define"
7698         d_fd_set="$define"
7699         echo "Well, your system knows about the normal fd_set typedef..." >&4
7700         if ./fd_set; then
7701                 echo "and you have the normal fd_set macros (just as I'd expect)." >&4
7702                 d_fd_macros="$define"
7703         else
7704                 $cat >&4 <<'EOM'
7705 but not the normal fd_set macros!  Gaaack!  I'll have to cover for you.
7706 EOM
7707                 d_fd_macros="$undef"
7708         fi
7709 else
7710         $cat <<'EOM'
7711 Hmm, your compiler has some difficulty with fd_set.  Checking further...
7712 EOM
7713         set fd_set
7714         if eval $compile; then
7715                 d_fds_bits="$undef"
7716                 d_fd_set="$define"
7717                 echo "Well, your system has some sort of fd_set available..." >&4
7718                 if ./fd_set; then
7719                         echo "and you have the normal fd_set macros." >&4
7720                         d_fd_macros="$define"
7721                 else
7722                         $cat <<'EOM'
7723 but not the normal fd_set macros!  Gross!  More work for me...
7724 EOM
7725                         d_fd_macros="$undef"
7726                 fi
7727         else
7728         echo "Well, you got zip.  That's OK, I can roll my own fd_set stuff." >&4
7729                 d_fd_set="$undef"
7730                 d_fds_bits="$undef"
7731                 d_fd_macros="$undef"
7732         fi
7733 fi
7734 $rm -f fd_set*
7735
7736 : see if fgetpos exists
7737 set fgetpos d_fgetpos
7738 eval $inlibc
7739
7740
7741 if $test X"$use64bits" = X"$define"; then
7742         : see if fgetpos64 exists
7743         set fgetpos64 d_fgetpos64
7744         eval $inlibc
7745
7746         : see if fopen64 exists
7747         set freopen64 d_fopen64
7748         eval $inlibc
7749
7750         : see if freopen64 exists
7751         set freopen64 d_freopen64
7752         eval $inlibc
7753
7754         : see if fseek64 exists
7755         set fseek64 d_fseek64
7756         eval $inlibc
7757
7758         : see if fseeko64 exists
7759         set fseeko64 d_fseeko64
7760         eval $inlibc
7761
7762         : see if fsetpos64 exists
7763         set fsetpos64 d_fsetpos64
7764         eval $inlibc
7765
7766         : see if ftell64 exists
7767         set ftell64 d_ftell64
7768         eval $inlibc
7769
7770         : see if ftello64 exists
7771         set ftello64 d_ftello64
7772         eval $inlibc
7773
7774         : see if tmpfile64 exists
7775         set tmpfile64 d_tmpfile64
7776         eval $inlibc
7777 else
7778         val="$undef"
7779         for xxx in d_fgetpos64 d_fopen64 d_freopen64 d_fseek64 d_fseeko64 d_fsetpos64 d_ftell64 d_ftello64 d_tmpfile64
7780         do
7781                 set $xxx
7782                 eval $setvar
7783         done
7784 fi
7785
7786 : see if flock exists
7787 set flock d_flock
7788 eval $inlibc
7789
7790 : see if fork exists
7791 set fork d_fork
7792 eval $inlibc
7793
7794 : see if pathconf exists
7795 set pathconf d_pathconf
7796 eval $inlibc
7797
7798 : see if fpathconf exists
7799 set fpathconf d_fpathconf
7800 eval $inlibc
7801
7802 : see if fseeko exists
7803 set fseeko d_fseeko
7804 eval $inlibc
7805
7806 : see if fsetpos exists
7807 set fsetpos d_fsetpos
7808 eval $inlibc
7809
7810 : see if ftello exists
7811 set ftello d_ftello
7812 eval $inlibc
7813
7814 : see if getgrent exists
7815 set getgrent d_getgrent
7816 eval $inlibc
7817
7818 : see if gethostbyaddr exists
7819 set gethostbyaddr d_gethbyaddr
7820 eval $inlibc
7821
7822 : see if gethostbyname exists
7823 set gethostbyname d_gethbyname
7824 eval $inlibc
7825
7826 : see if gethostent exists
7827 set gethostent d_gethent
7828 eval $inlibc
7829
7830 : see how we will look up host name
7831 echo " "
7832 if false; then
7833         : dummy stub to allow use of elif
7834 elif set gethostname val -f d_gethname; eval $csym; $val; then
7835         echo 'gethostname() found.' >&4
7836         d_gethname="$define"
7837         call=gethostname
7838 elif set uname val -f d_uname; eval $csym; $val; then
7839         if ./xenix; then
7840                 $cat <<'EOM'
7841 uname() was found, but you're running xenix, and older versions of xenix
7842 have a broken uname(). If you don't really know whether your xenix is old
7843 enough to have a broken system call, use the default answer.
7844
7845 EOM
7846                 dflt=y
7847                 case "$d_uname" in
7848                 "$define") dflt=n;;
7849                 esac
7850                 rp='Is your uname() broken?'
7851                 . ./myread
7852                 case "$ans" in
7853                 n*) d_uname="$define"; call=uname;;
7854                 esac
7855         else
7856                 echo 'uname() found.' >&4
7857                 d_uname="$define"
7858                 call=uname
7859         fi
7860 fi
7861 case "$d_gethname" in
7862 '') d_gethname="$undef";;
7863 esac
7864 case "$d_uname" in
7865 '') d_uname="$undef";;
7866 esac
7867 case "$d_uname$d_gethname" in
7868 *define*)
7869         dflt=n
7870         cat <<EOM
7871  
7872 Every now and then someone has a $call() that lies about the hostname
7873 but can't be fixed for political or economic reasons.  If you wish, I can
7874 pretend $call() isn't there and maybe compute hostname at run-time
7875 thanks to the '$phostname' command.
7876
7877 EOM
7878         rp="Shall I ignore $call() from now on?"
7879         . ./myread
7880         case "$ans" in
7881         y*) d_uname="$undef" d_gethname="$undef"; $echo $n "Okay...$c";;
7882         esac;;
7883 esac
7884 case "$phostname" in
7885 '') aphostname='';;
7886 *) case "$aphostname" in
7887         /*) ;;
7888         *) set X $phostname
7889                 shift
7890                 file=$1
7891                 shift
7892                 file=`./loc $file $file $pth`
7893                 aphostname=`echo $file $*`
7894                 ;;
7895         esac
7896         ;;
7897 esac
7898 case "$d_uname$d_gethname" in
7899 *define*) ;;
7900 *)
7901         case "$phostname" in
7902         '')
7903                 echo "There will be no way for $package to get your hostname." >&4;;
7904         *)
7905         echo "I'll use 'popen("'"'$aphostname'", "r")'"' to get your hostname." >&4
7906                 ;;
7907         esac;;
7908 esac
7909 case "$d_phostname" in
7910 '') d_phostname="$undef";;
7911 esac
7912
7913 : see if this is a netdb.h system
7914 set netdb.h i_netdb
7915 eval $inhdr
7916
7917 : see if prototypes for various gethostxxx netdb.h functions are available
7918 echo " "
7919 set d_gethostprotos gethostent $i_netdb netdb.h
7920 eval $hasproto
7921
7922 : see if getlogin exists
7923 set getlogin d_getlogin
7924 eval $inlibc
7925
7926 : see if getnetbyaddr exists
7927 set getnetbyaddr d_getnbyaddr
7928 eval $inlibc
7929
7930 : see if getnetbyname exists
7931 set getnetbyname d_getnbyname
7932 eval $inlibc
7933
7934 : see if getnetent exists
7935 set getnetent d_getnent
7936 eval $inlibc
7937
7938 : see if prototypes for various getnetxxx netdb.h functions are available
7939 echo " "
7940 set d_getnetprotos getnetent $i_netdb netdb.h
7941 eval $hasproto
7942
7943
7944 : see if getprotobyname exists
7945 set getprotobyname d_getpbyname
7946 eval $inlibc
7947
7948 : see if getprotobynumber exists
7949 set getprotobynumber d_getpbynumber
7950 eval $inlibc
7951
7952 : see if getprotoent exists
7953 set getprotoent d_getpent
7954 eval $inlibc
7955
7956 : see if getpgid exists
7957 set getpgid d_getpgid
7958 eval $inlibc
7959
7960 : see if getpgrp2 exists
7961 set getpgrp2 d_getpgrp2
7962 eval $inlibc
7963
7964 : see if getppid exists
7965 set getppid d_getppid
7966 eval $inlibc
7967
7968 : see if getpriority exists
7969 set getpriority d_getprior
7970 eval $inlibc
7971
7972 : see if prototypes for various getprotoxxx netdb.h functions are available
7973 echo " "
7974 set d_getprotoprotos getprotoent $i_netdb netdb.h
7975 eval $hasproto
7976
7977 : see if getpwent exists
7978 set getpwent d_getpwent
7979 eval $inlibc
7980
7981
7982 : see if getservbyname exists
7983 set getservbyname d_getsbyname
7984 eval $inlibc
7985
7986 : see if getservbyport exists
7987 set getservbyport d_getsbyport
7988 eval $inlibc
7989
7990 : see if getservent exists
7991 set getservent d_getsent
7992 eval $inlibc
7993
7994 : see if prototypes for various getservxxx netdb.h functions are available
7995 echo " "
7996 set d_getservprotos getservent $i_netdb netdb.h
7997 eval $hasproto
7998
7999 : see if gettimeofday or ftime exists
8000 set gettimeofday d_gettimeod
8001 eval $inlibc
8002 case "$d_gettimeod" in
8003 "$undef")
8004         set ftime d_ftime 
8005         eval $inlibc
8006         ;;
8007 *)
8008         val="$undef"; set d_ftime; eval $setvar
8009         ;;
8010 esac
8011 case "$d_gettimeod$d_ftime" in
8012 "$undef$undef")
8013         echo " "
8014         echo 'No ftime() nor gettimeofday() -- timing may be less accurate.' >&4
8015         ;;
8016 esac
8017
8018 : see if this is an grp system
8019 set grp.h i_grp
8020 eval $inhdr
8021
8022 case "$i_grp" in
8023 $define)
8024         xxx=`./findhdr grp.h`
8025         $cppstdin $cppflags $cppminus < $xxx >$$.h
8026
8027         if $contains 'gr_passwd' $$.h >/dev/null 2>&1; then
8028                 val="$define"
8029         else
8030                 val="$undef"
8031         fi
8032         set d_grpasswd
8033         eval $setvar
8034
8035         $rm -f $$.h
8036         ;;
8037 *)
8038         val="$undef";
8039         set d_grpasswd; eval $setvar
8040         ;;
8041 esac
8042
8043 : see if this is a netinet/in.h or sys/in.h system
8044 set netinet/in.h i_niin sys/in.h i_sysin
8045 eval $inhdr
8046
8047 : see if arpa/inet.h has to be included
8048 set arpa/inet.h i_arpainet
8049 eval $inhdr
8050
8051 : see if htonl --and friends-- exists
8052 val=''
8053 set htonl val
8054 eval $inlibc
8055
8056 : Maybe they are macros.
8057 case "$val" in
8058 $undef)
8059         $cat >htonl.c <<EOM
8060 #include <stdio.h>
8061 #include <sys/types.h>
8062 #$i_niin I_NETINET_IN
8063 #$i_sysin I_SYS_IN
8064 #$i_arpainet I_ARPA_INET
8065 #ifdef I_NETINET_IN
8066 #include <netinet/in.h>
8067 #endif
8068 #ifdef I_SYS_IN
8069 #include <sys/in.h>
8070 #endif
8071 #ifdef I_ARPA_INET
8072 #include <arpa/inet.h>
8073 #endif
8074 #ifdef htonl
8075 printf("Defined as a macro.");
8076 #endif
8077 EOM
8078         $cppstdin $cppflags $cppminus < htonl.c >htonl.E 2>/dev/null
8079         if $contains 'Defined as a macro' htonl.E >/dev/null 2>&1; then
8080                 val="$define"
8081                 echo "But it seems to be defined as a macro." >&4
8082         fi
8083         $rm -f htonl.?
8084         ;;
8085 esac
8086 set d_htonl
8087 eval $setvar
8088
8089 : see which of string.h or strings.h is needed
8090 echo " "
8091 strings=`./findhdr string.h`
8092 if $test "$strings" && $test -r "$strings"; then
8093         echo "Using <string.h> instead of <strings.h>." >&4
8094         val="$define"
8095 else
8096         val="$undef"
8097         strings=`./findhdr strings.h`
8098         if $test "$strings" && $test -r "$strings"; then
8099                 echo "Using <strings.h> instead of <string.h>." >&4
8100         else
8101                 echo "No string header found -- You'll surely have problems." >&4
8102         fi
8103 fi
8104 set i_string
8105 eval $setvar
8106 case "$i_string" in
8107 "$undef") strings=`./findhdr strings.h`;;
8108 *)        strings=`./findhdr string.h`;;
8109 esac
8110
8111 : index or strchr
8112 echo " "
8113 if set index val -f; eval $csym; $val; then
8114         if set strchr val -f d_strchr; eval $csym; $val; then
8115                 if $contains strchr "$strings" >/dev/null 2>&1 ; then
8116                         val="$define"
8117                         vali="$undef"
8118                         echo "strchr() found." >&4
8119                 else
8120                         val="$undef"
8121                         vali="$define"
8122                         echo "index() found." >&4
8123                 fi
8124         else
8125                 val="$undef"
8126                 vali="$define"
8127                 echo "index() found." >&4
8128         fi
8129 else
8130         if set strchr val -f d_strchr; eval $csym; $val; then
8131                 val="$define"
8132                 vali="$undef"
8133                 echo "strchr() found." >&4
8134         else
8135                 echo "No index() or strchr() found!" >&4
8136                 val="$undef"
8137                 vali="$undef"
8138         fi
8139 fi
8140 set d_strchr; eval $setvar
8141 val="$vali"
8142 set d_index; eval $setvar
8143
8144 : check whether inet_aton exists
8145 set inet_aton d_inetaton
8146 eval $inlibc
8147
8148 : see if inttypes.h is available
8149 : we want a real compile instead of Inhdr because some systems
8150 : have an inttypes.h which includes non-existent headers
8151 echo " "
8152 $cat >try.c <<EOCP
8153 #include <inttypes.h>
8154 main() {
8155         static int32_t foo32 = 0x12345678;
8156 }
8157 EOCP
8158 set try
8159 if eval $compile; then
8160         echo "<inttypes.h> found." >&4
8161         val="$define"
8162 else
8163         echo "<inttypes.h> NOT found." >&4
8164         val="$undef"
8165 fi
8166 $rm -f try.c try
8167 set i_inttypes
8168 eval $setvar
8169
8170 : check for int64_t
8171 case "$use64bits" in
8172 "$define" )
8173         echo " "
8174         echo $n "Checking to see if your system supports int64_t...$c" >&4
8175         $cat >try.c <<EOCP
8176 #include <sys/types.h>
8177 #$i_inttypes I_INTTYPES
8178 #ifdef I_INTTYPES
8179 #include <inttypes.h>
8180 #endif
8181 int64_t foo() { int64_t x; x = 7; return x; }
8182 EOCP
8183         if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8184                 val="$define"
8185                 echo " Yup, it does." >&4
8186         else
8187                 val="$undef"
8188                 echo " Nope, it doesn't." >&4
8189         fi
8190         $rm -f try.*
8191         ;;
8192 *)      val="$undef"
8193         ;;
8194 esac
8195 set d_int64t
8196 eval $setvar
8197
8198
8199 : Look for isascii
8200 echo " "
8201 $cat >isascii.c <<'EOCP'
8202 #include <stdio.h>
8203 #include <ctype.h>
8204 main() {
8205         int c = 'A';
8206         if (isascii(c))
8207                 exit(0);
8208         else
8209                 exit(1);
8210 }
8211 EOCP
8212 set isascii
8213 if eval $compile; then
8214         echo "isascii() found." >&4
8215         val="$define"
8216 else
8217         echo "isascii() NOT found." >&4
8218         val="$undef"
8219 fi
8220 set d_isascii
8221 eval $setvar
8222 $rm -f isascii*
8223
8224 : see if killpg exists
8225 set killpg d_killpg
8226 eval $inlibc
8227
8228 : see if lchown exists
8229 echo " "
8230 $cat > try.c <<'EOCP'
8231 /* System header to define __stub macros and hopefully few prototypes,
8232     which can conflict with char lchown(); below.  */
8233 #include <assert.h>
8234 /* Override any gcc2 internal prototype to avoid an error.  */
8235 /* We use char because int might match the return type of a gcc2
8236    builtin and then its argument prototype would still apply.  */
8237 char lchown();
8238 int main() {
8239     /*  The GNU C library defines this for functions which it implements
8240         to always fail with ENOSYS.  Some functions are actually named
8241         something starting with __ and the normal name is an alias.  */
8242 #if defined (__stub_lchown) || defined (__stub___lchown)
8243 choke me
8244 #else
8245 lchown();
8246 #endif
8247 ; return 0; }
8248 EOCP
8249 set try
8250 if eval $compile; then
8251     $echo "lchown() found." >&4
8252     val="$define"
8253 else
8254     $echo "lchown() NOT found." >&4
8255     val="$undef"
8256 fi
8257 set d_lchown
8258 eval $setvar
8259
8260 : see if link exists
8261 set link d_link
8262 eval $inlibc
8263
8264 : see if localeconv exists
8265 set localeconv d_locconv
8266 eval $inlibc
8267
8268 : see if lockf exists
8269 set lockf d_lockf
8270 eval $inlibc
8271
8272 : check for length of double
8273 echo " "
8274 case "$doublesize" in
8275 '')
8276         $echo $n "Checking to see how big your double precision numbers are...$c" >&4
8277         $cat >try.c <<'EOCP'
8278 #include <stdio.h>
8279 main()
8280 {
8281         printf("%d\n", sizeof(double));
8282 }
8283 EOCP
8284         set try
8285         if eval $compile_ok; then
8286                 doublesize=`./try`
8287                 $echo " $doublesize bytes." >&4
8288         else
8289                 dflt='8'
8290                 echo "(I can't seem to compile the test program.  Guessing...)"
8291                 rp="What is the size of a double precision number (in bytes)?"
8292                 . ./myread
8293                 doublesize="$ans"
8294         fi
8295         ;;
8296 esac
8297 $rm -f try.c try
8298
8299 : check for long doubles
8300 echo " "
8301 echo $n "Checking to see if your system supports long doubles...$c" >&4
8302 echo 'long double foo() { long double x; x = 7.0; return x; }' > try.c
8303 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8304         val="$define"
8305         echo " Yup, it does." >&4
8306 else
8307         val="$undef"
8308         echo " Nope, it doesn't." >&4
8309 fi
8310 $rm try.*
8311 set d_longdbl
8312 eval $setvar
8313
8314 : check for length of long double
8315 case "${d_longdbl}${longdblsize}" in
8316 $define)
8317         echo " "
8318         $echo $n "Checking to see how big your long doubles are...$c" >&4
8319         $cat >try.c <<'EOCP'
8320 #include <stdio.h>
8321 main()
8322 {
8323         printf("%d\n", sizeof(long double));
8324 }
8325 EOCP
8326         set try
8327         if eval $compile; then
8328                 longdblsize=`./try`
8329                 $echo " $longdblsize bytes." >&4
8330         else
8331                 dflt='8'
8332                 echo " "
8333                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
8334                 rp="What is the size of a long double (in bytes)?"
8335                 . ./myread
8336                 longdblsize="$ans"
8337         fi
8338         if $test "X$doublesize" = "X$longdblsize"; then
8339                 echo "(That isn't any different from an ordinary double.)"
8340         fi      
8341         ;;
8342 esac
8343 $rm -f try.c try
8344
8345 : check for long long
8346 echo " "
8347 echo $n "Checking to see if your system supports long long...$c" >&4
8348 echo 'long long foo() { long long x; x = 7; return x; }' > try.c
8349 if $cc $optimize $ccflags -c try.c >/dev/null 2>&1; then
8350         val="$define"
8351         echo " Yup, it does." >&4
8352 else
8353         val="$undef"
8354         echo " Nope, it doesn't." >&4
8355 fi
8356 $rm try.*
8357 set d_longlong
8358 eval $setvar
8359
8360 : check for length of long long
8361 case "${d_longlong}${longlongsize}" in
8362 $define)
8363         echo " "
8364         $echo $n "Checking to see how big your long longs are...$c" >&4
8365         $cat >try.c <<'EOCP'
8366 #include <stdio.h>
8367 main()
8368 {
8369         printf("%d\n", sizeof(long long));
8370 }
8371 EOCP
8372         set try
8373         if eval $compile_ok; then
8374                 longlongsize=`./try`
8375                 $echo " $longlongsize bytes." >&4
8376         else
8377                 dflt='8'
8378                 echo " "
8379                 echo "(I can't seem to compile the test program.  Guessing...)"
8380                 rp="What is the size of a long long (in bytes)?"
8381                 . ./myread
8382                 longlongsize="$ans"
8383         fi
8384         if $test "X$longsize" = "X$longlongsize"; then
8385                 echo "(That isn't any different from an ordinary long.)"
8386         fi      
8387         ;;
8388 esac
8389 $rm -f try.c try
8390
8391 : see if lstat exists
8392 set lstat d_lstat
8393 eval $inlibc
8394
8395 : see if mblen exists
8396 set mblen d_mblen
8397 eval $inlibc
8398
8399 : see if mbstowcs exists
8400 set mbstowcs d_mbstowcs
8401 eval $inlibc
8402
8403 : see if mbtowc exists
8404 set mbtowc d_mbtowc
8405 eval $inlibc
8406
8407 : see if memcmp exists
8408 set memcmp d_memcmp
8409 eval $inlibc
8410
8411 : see if memcpy exists
8412 set memcpy d_memcpy
8413 eval $inlibc
8414
8415 : see if memmove exists
8416 set memmove d_memmove
8417 eval $inlibc
8418
8419 : see if memset exists
8420 set memset d_memset
8421 eval $inlibc
8422
8423 : see if mkdir exists
8424 set mkdir d_mkdir
8425 eval $inlibc
8426
8427 : see if mkfifo exists
8428 set mkfifo d_mkfifo
8429 eval $inlibc
8430
8431 : see if mktime exists
8432 set mktime d_mktime
8433 eval $inlibc
8434
8435 : see if msgctl exists
8436 set msgctl d_msgctl
8437 eval $inlibc
8438
8439 : see if msgget exists
8440 set msgget d_msgget
8441 eval $inlibc
8442
8443 : see if msgsnd exists
8444 set msgsnd d_msgsnd
8445 eval $inlibc
8446
8447 : see if msgrcv exists
8448 set msgrcv d_msgrcv
8449 eval $inlibc
8450
8451 : see how much of the 'msg*(2)' library is present.
8452 h_msg=true
8453 echo " "
8454 case "$d_msgctl$d_msgget$d_msgsnd$d_msgrcv" in
8455 *"$undef"*) h_msg=false;;
8456 esac
8457 case "$osname" in
8458 freebsd)
8459     case "`ipcs 2>&1`" in
8460     "SVID messages"*"not configured"*)
8461         echo "Your $osname does not have the msg*(2) configured." >&4
8462         h_msg=false
8463         val="$undef"
8464         set msgctl d_msgctl
8465         eval $setvar
8466         set msgget d_msgget
8467         eval $setvar
8468         set msgsnd d_msgsnd
8469         eval $setvar
8470         set msgrcv d_msgrcv
8471         eval $setvar
8472         ;;
8473     esac
8474     ;;
8475 esac
8476 : we could also check for sys/ipc.h ...
8477 if $h_msg && $test `./findhdr sys/msg.h`; then
8478         echo "You have the full msg*(2) library." >&4
8479         val="$define"
8480 else
8481         echo "You don't have the full msg*(2) library." >&4
8482         val="$undef"
8483 fi
8484 set d_msg
8485 eval $setvar
8486
8487 : see if nice exists
8488 set nice d_nice
8489 eval $inlibc
8490
8491 : see if pause exists
8492 set pause d_pause
8493 eval $inlibc
8494
8495 : see if pipe exists
8496 set pipe d_pipe
8497 eval $inlibc
8498
8499 : see if poll exists
8500 set poll d_poll
8501 eval $inlibc
8502
8503 : how to create joinable pthreads
8504 if test "X$usethreads" = "X$define"; then
8505         echo " "
8506         echo "Checking what constant to use for creating joinable pthreads..." >&4 
8507         $cat >try.c <<'EOCP'
8508 #include <pthread.h>
8509 int main() {
8510     int detachstate = JOINABLE;
8511 }
8512 EOCP
8513         set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
8514         if eval $compile; then
8515                 echo "You seem to use PTHREAD_CREATE_JOINABLE." >&2
8516                 val="$undef"
8517                 set d_pthread_create_joinable
8518                 eval $setvar
8519                 val=0
8520                 set pthread_create_joinable
8521                 eval $setvar
8522         else
8523                 set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
8524                 if eval $compile; then
8525                         echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&2
8526                         val="$define"
8527                         set d_pthread_create_joinable
8528                         eval $setvar
8529                         val=PTHREAD_CREATE_UNDETACHED
8530                         set pthread_create_joinable
8531                         eval $setvar
8532                 else            
8533                         set try -DJOINABLE=__UNDETACHED
8534                         if eval $compile; then
8535                                 echo "You seem to use __UNDETACHED." >&2
8536                                 val="$define"
8537                                 set d_pthread_create_joinable
8538                                 eval $setvar
8539                                 val=__UNDETACHED
8540                                 set pthread_create_joinable
8541                                 eval $setvar
8542                         else
8543                                 echo "Egads, nothing obvious found.  Guessing that you use 0." >&2
8544                                 val="$define"
8545                                 set d_pthread_create_joinable
8546                                 eval $setvar
8547                                 val=0
8548                                 set pthread_create_joinable
8549                                 eval $setvar
8550                         fi
8551                 fi
8552         fi
8553         $rm -f try try.*
8554 else
8555     d_pthread_create_joinable="$undef"
8556     pthread_create_joinable=0
8557 fi
8558
8559
8560 : see whether the various POSIXish _yields exist
8561 $cat >try.c <<EOP
8562 #include <pthread.h>
8563 #include <stdio.h>
8564 main() {
8565 #ifdef SCHED_YIELD
8566         sched_yield();
8567 #else
8568 #ifdef PTHREAD_YIELD
8569         pthread_yield();
8570 #else
8571 #ifdef PTHREAD_YIELD_NULL
8572         pthread_yield(NULL);
8573 #endif
8574 #endif
8575 #endif
8576 }
8577 EOP
8578 : see if sched_yield exists
8579 set try -DSCHED_YIELD
8580 if eval $compile; then
8581     val="$define"
8582     sched_yield='sched_yield()'
8583 else
8584     val="$undef"
8585 fi
8586 case "$usethreads" in
8587 $define)
8588         case "$val" in
8589         $define) echo 'sched_yield() found.' >&4        ;;
8590         *)       echo 'sched_yield() NOT found.' >&4    ;;
8591         esac
8592 esac
8593 set d_sched_yield
8594 eval $setvar
8595
8596 : see if pthread_yield exists
8597 set try -DPTHREAD_YIELD
8598 if eval $compile; then
8599     val="$define"
8600     case "$sched_yield" in
8601     '') sched_yield='pthread_yield()' ;;
8602     esac
8603 else
8604     set try -DPTHREAD_YIELD_NULL
8605     if eval $compile; then
8606         val="$define"
8607         case "$sched_yield" in
8608         '') sched_yield='pthread_yield(NULL)' ;;
8609         esac
8610     else
8611         val="$undef"
8612     fi
8613 fi
8614 case "$usethreads" in
8615 $define)
8616         case "$val" in
8617         $define) echo 'pthread_yield() found.' >&4      ;;
8618         *)       echo 'pthread_yield() NOT found.' >&4  ;;
8619         esac
8620         ;;
8621 esac
8622 set d_pthread_yield
8623 eval $setvar
8624
8625 case "$sched_yield" in
8626 '') sched_yield=undef ;;
8627 esac
8628
8629 $rm -f try try.*
8630
8631 : see if this is a pwd.h system
8632 set pwd.h i_pwd
8633 eval $inhdr
8634
8635 case "$i_pwd" in
8636 $define)
8637         xxx=`./findhdr pwd.h`
8638         $cppstdin $cppflags $cppminus < $xxx >$$.h
8639
8640         if $contains 'pw_quota' $$.h >/dev/null 2>&1; then
8641                 val="$define"
8642         else
8643                 val="$undef"
8644         fi
8645         set d_pwquota
8646         eval $setvar
8647
8648         if $contains 'pw_age' $$.h >/dev/null 2>&1; then
8649                 val="$define"
8650         else
8651                 val="$undef"
8652         fi
8653         set d_pwage
8654         eval $setvar
8655
8656         if $contains 'pw_change' $$.h >/dev/null 2>&1; then
8657                 val="$define"
8658         else
8659                 val="$undef"
8660         fi
8661         set d_pwchange
8662         eval $setvar
8663
8664         if $contains 'pw_class' $$.h >/dev/null 2>&1; then
8665                 val="$define"
8666         else
8667                 val="$undef"
8668         fi
8669         set d_pwclass
8670         eval $setvar
8671
8672         if $contains 'pw_expire' $$.h >/dev/null 2>&1; then
8673                 val="$define"
8674         else
8675                 val="$undef"
8676         fi
8677         set d_pwexpire
8678         eval $setvar
8679
8680         if $contains 'pw_comment' $$.h >/dev/null 2>&1; then
8681                 val="$define"
8682         else
8683                 val="$undef"
8684         fi
8685         set d_pwcomment
8686         eval $setvar
8687
8688         if $contains 'pw_gecos' $$.h >/dev/null 2>&1; then
8689                 val="$define"
8690         else
8691                 val="$undef"
8692         fi
8693         set d_pwgecos
8694         eval $setvar
8695
8696         if $contains 'pw_passwd' $$.h >/dev/null 2>&1; then
8697                 val="$define"
8698         else
8699                 val="$undef"
8700         fi
8701         set d_pwpasswd
8702         eval $setvar
8703
8704         $rm -f $$.h
8705         ;;
8706 *)
8707         val="$undef"; 
8708         set d_pwquota; eval $setvar
8709         set d_pwage; eval $setvar
8710         set d_pwchange; eval $setvar
8711         set d_pwclass; eval $setvar
8712         set d_pwexpire; eval $setvar
8713         set d_pwcomment; eval $setvar
8714         set d_pwgecos; eval $setvar
8715         set d_pwpasswd; eval $setvar
8716         ;;
8717 esac
8718
8719 : see if readdir and friends exist
8720 set readdir d_readdir
8721 eval $inlibc
8722 set seekdir d_seekdir
8723 eval $inlibc
8724 set telldir d_telldir
8725 eval $inlibc
8726 set rewinddir d_rewinddir
8727 eval $inlibc
8728
8729 : see if readlink exists
8730 set readlink d_readlink
8731 eval $inlibc
8732
8733 : see if rename exists
8734 set rename d_rename
8735 eval $inlibc
8736
8737 : see if rmdir exists
8738 set rmdir d_rmdir
8739 eval $inlibc
8740
8741 : see if memory.h is available.
8742 val=''
8743 set memory.h val
8744 eval $inhdr
8745
8746 : See if it conflicts with string.h
8747 case "$val" in
8748 $define)
8749         case "$strings" in
8750         '') ;;
8751         *)
8752                 $cppstdin $cppflags $cppminus < $strings > mem.h
8753                 if $contains 'memcpy' mem.h >/dev/null 2>&1; then
8754                         echo " "
8755                         echo "We won't be including <memory.h>."
8756                         val="$undef"
8757                 fi
8758                 $rm -f mem.h
8759                 ;;
8760         esac
8761 esac
8762 set i_memory
8763 eval $setvar
8764
8765 : can bcopy handle overlapping blocks?
8766 val="$undef"
8767 case "$d_bcopy" in
8768 "$define")
8769         echo " "
8770         echo "Checking to see if your bcopy() can do overlapping copies..." >&4
8771         $cat >try.c <<EOCP
8772 #$i_memory I_MEMORY
8773 #$i_stdlib I_STDLIB
8774 #$i_string I_STRING
8775 #$i_unistd I_UNISTD
8776 EOCP
8777         $cat >>try.c <<'EOCP'
8778 #include <stdio.h>
8779 #ifdef I_MEMORY
8780 #  include <memory.h>
8781 #endif
8782 #ifdef I_STDLIB
8783 #  include <stdlib.h>
8784 #endif
8785 #ifdef I_STRING
8786 #  include <string.h>
8787 #else
8788 #  include <strings.h>
8789 #endif
8790 #ifdef I_UNISTD
8791 #  include <unistd.h>  /* Needed for NetBSD */
8792 #endif
8793 main()
8794 {
8795 char buf[128], abc[128];
8796 char *b;
8797 int len;
8798 int off;
8799 int align;
8800
8801 bcopy("abcdefghijklmnopqrstuvwxyz0123456789", abc, 36);
8802
8803 for (align = 7; align >= 0; align--) {
8804         for (len = 36; len; len--) {
8805                 b = buf+align;
8806                 bcopy(abc, b, len);
8807                 for (off = 1; off <= len; off++) {
8808                         bcopy(b, b+off, len);
8809                         bcopy(b+off, b, len);
8810                         if (bcmp(b, abc, len))
8811                                 exit(1);
8812                 }
8813         }
8814 }
8815 exit(0);
8816 }
8817 EOCP
8818         set try
8819         if eval $compile_ok; then
8820                 if ./try 2>/dev/null; then
8821                         echo "Yes, it can."
8822                         val="$define"
8823                 else
8824                         echo "It can't, sorry."
8825                         case "$d_memmove" in
8826                         "$define") echo "But that's Ok since you have memmove()." ;;
8827                         esac
8828                 fi
8829         else
8830                 echo "(I can't compile the test program, so we'll assume not...)"
8831                 case "$d_memmove" in
8832                 "$define") echo "But that's Ok since you have memmove()." ;;
8833                 esac
8834         fi
8835         ;;
8836 esac
8837 $rm -f try.* try core
8838 set d_safebcpy
8839 eval $setvar
8840
8841 : can memcpy handle overlapping blocks?
8842 val="$undef"
8843 case "$d_memcpy" in
8844 "$define")
8845         echo " "
8846         echo "Checking to see if your memcpy() can do overlapping copies..." >&4
8847         $cat >try.c <<EOCP
8848 #$i_memory I_MEMORY
8849 #$i_stdlib I_STDLIB
8850 #$i_string I_STRING
8851 #$i_unistd I_UNISTD
8852 EOCP
8853         $cat >>try.c <<'EOCP'
8854 #include <stdio.h>
8855 #ifdef I_MEMORY
8856 #  include <memory.h>
8857 #endif
8858 #ifdef I_STDLIB
8859 #  include <stdlib.h>
8860 #endif
8861 #ifdef I_STRING
8862 #  include <string.h>
8863 #else
8864 #  include <strings.h>
8865 #endif
8866 #ifdef I_UNISTD
8867 #  include <unistd.h>  /* Needed for NetBSD */
8868 #endif
8869 main()
8870 {
8871 char buf[128], abc[128];
8872 char *b;
8873 int len;
8874 int off;
8875 int align;
8876
8877 /* Copy "abcde..." string to char abc[] so that gcc doesn't
8878    try to store the string in read-only memory. */
8879 memcpy(abc, "abcdefghijklmnopqrstuvwxyz0123456789", 36);
8880
8881 for (align = 7; align >= 0; align--) {
8882         for (len = 36; len; len--) {
8883                 b = buf+align;
8884                 memcpy(b, abc, len);
8885                 for (off = 1; off <= len; off++) {
8886                         memcpy(b+off, b, len);
8887                         memcpy(b, b+off, len);
8888                         if (memcmp(b, abc, len))
8889                                 exit(1);
8890                 }
8891         }
8892 }
8893 exit(0);
8894 }
8895 EOCP
8896         set try
8897         if eval $compile_ok; then
8898                 if ./try 2>/dev/null; then
8899                         echo "Yes, it can."
8900                         val="$define"
8901                 else
8902                         echo "It can't, sorry."
8903                         case "$d_memmove" in
8904                         "$define") echo "But that's Ok since you have memmove()." ;;
8905                         esac
8906                 fi
8907         else
8908                 echo "(I can't compile the test program, so we'll assume not...)"
8909                 case "$d_memmove" in
8910                 "$define") echo "But that's Ok since you have memmove()." ;;
8911                 esac
8912         fi
8913         ;;
8914 esac
8915 $rm -f try.* try core
8916 set d_safemcpy
8917 eval $setvar
8918
8919 : can memcmp be trusted to compare relative magnitude?
8920 val="$undef"
8921 case "$d_memcmp" in
8922 "$define")
8923         echo " "
8924         echo "Checking if your memcmp() can compare relative magnitude..." >&4
8925         $cat >try.c <<EOCP
8926 #$i_memory I_MEMORY
8927 #$i_stdlib I_STDLIB
8928 #$i_string I_STRING
8929 #$i_unistd I_UNISTD
8930 EOCP
8931         $cat >>try.c <<'EOCP'
8932 #include <stdio.h>
8933 #ifdef I_MEMORY
8934 #  include <memory.h>
8935 #endif
8936 #ifdef I_STDLIB
8937 #  include <stdlib.h>
8938 #endif
8939 #ifdef I_STRING
8940 #  include <string.h>
8941 #else
8942 #  include <strings.h>
8943 #endif
8944 #ifdef I_UNISTD
8945 #  include <unistd.h>  /* Needed for NetBSD */
8946 #endif
8947 main()
8948 {
8949 char a = -1;
8950 char b = 0;
8951 if ((a < b) && memcmp(&a, &b, 1) < 0)
8952         exit(1);
8953 exit(0);
8954 }
8955 EOCP
8956         set try
8957         if eval $compile_ok; then
8958                 if ./try 2>/dev/null; then
8959                         echo "Yes, it can."
8960                         val="$define"
8961                 else
8962                         echo "No, it can't (it uses signed chars)."
8963                 fi
8964         else
8965                 echo "(I can't compile the test program, so we'll assume not...)"
8966         fi
8967         ;;
8968 esac
8969 $rm -f try.* try core
8970 set d_sanemcmp
8971 eval $setvar
8972
8973 : see if select exists
8974 set select d_select
8975 eval $inlibc
8976
8977 : see if semctl exists
8978 set semctl d_semctl
8979 eval $inlibc
8980
8981 : see if semget exists
8982 set semget d_semget
8983 eval $inlibc
8984
8985 : see if semop exists
8986 set semop d_semop
8987 eval $inlibc
8988
8989 : see how much of the 'sem*(2)' library is present.
8990 h_sem=true
8991 echo " "
8992 case "$d_semctl$d_semget$d_semop" in
8993 *"$undef"*) h_sem=false;;
8994 esac
8995 case "$osname" in
8996 freebsd)
8997     case "`ipcs 2>&1`" in
8998     "SVID messages"*"not configured"*)
8999         echo "Your $osname does not have the sem*(2) configured." >&4
9000         h_sem=false
9001         val="$undef"
9002         set semctl d_semctl
9003         eval $setvar
9004         set semget d_semget
9005         eval $setvar
9006         set semop d_semop
9007         eval $setvar
9008         ;;
9009     esac
9010     ;;
9011 esac
9012 : we could also check for sys/ipc.h ...
9013 if $h_sem && $test `./findhdr sys/sem.h`; then
9014         echo "You have the full sem*(2) library." >&4
9015         val="$define"
9016 else
9017         echo "You don't have the full sem*(2) library." >&4
9018         val="$undef"
9019 fi
9020 set d_sem
9021 eval $setvar
9022
9023 : see whether sys/sem.h defines union semun
9024 echo " "
9025 $cat > try.c <<'END'
9026 #include <sys/types.h>
9027 #include <sys/ipc.h>
9028 #include <sys/sem.h>
9029 int main () { union semun semun; semun.buf = 0; }
9030 END
9031 set try
9032 if eval $compile; then
9033     echo "You have union semun in <sys/sem.h>." >&4
9034     val="$define"
9035 else
9036     echo "You do not have union semun in <sys/sem.h>." >&4
9037     val="$undef"
9038 fi
9039 $rm -f try try.c try.h
9040 set d_union_semun
9041 eval $setvar
9042
9043 : see how to do semctl IPC_STAT
9044 case "$d_sem" in
9045 $define)
9046     : see whether semctl IPC_STAT can use union semun
9047     echo " "
9048     $cat > try.h <<END
9049 #ifndef S_IRUSR
9050 #   ifdef S_IREAD
9051 #       define S_IRUSR S_IREAD
9052 #       define S_IWUSR S_IWRITE
9053 #       define S_IXUSR S_IEXEC
9054 #   else
9055 #       define S_IRUSR 0400
9056 #       define S_IWUSR 0200
9057 #       define S_IXUSR 0100
9058 #   endif
9059 #   define S_IRGRP (S_IRUSR>>3)
9060 #   define S_IWGRP (S_IWUSR>>3)
9061 #   define S_IXGRP (S_IXUSR>>3)
9062 #   define S_IROTH (S_IRUSR>>6)
9063 #   define S_IWOTH (S_IWUSR>>6)
9064 #   define S_IXOTH (S_IXUSR>>6)
9065 #endif
9066 #ifndef S_IRWXU
9067 #   define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
9068 #   define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
9069 #   define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
9070 #endif
9071 END
9072
9073     $cat > try.c <<END
9074 #include <sys/types.h>
9075 #include <sys/ipc.h>
9076 #include <sys/sem.h>
9077 #include <sys/stat.h>
9078 #include <stdio.h>
9079 #include <errno.h>
9080 #include "try.h"
9081 #ifndef errno
9082 extern int errno;
9083 #endif
9084 #$d_union_semun HAS_UNION_SEMUN
9085 int main() {
9086     union semun
9087 #ifndef HAS_UNION_SEMUN
9088     {
9089         int val;
9090         struct semid_ds *buf;
9091         unsigned short *array;
9092     }
9093 #endif
9094     arg;
9095     int sem, st;
9096
9097 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) && defined(S_IRWXO) && defined(IPC_CREAT)
9098     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9099     if (sem > -1) {
9100         struct semid_ds argbuf;
9101         arg.buf = &argbuf;
9102 #       ifdef IPC_STAT
9103         st = semctl(sem, 0, IPC_STAT, arg);
9104         if (st == 0)
9105             printf("semun\n");
9106         else
9107 #       endif /* IPC_STAT */
9108             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9109 #       ifdef IPC_RMID
9110         if (semctl(sem, 0, IPC_RMID, arg) != 0)
9111 #       endif /* IPC_RMID */
9112             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9113     } else
9114 #endif /* IPC_PRIVATE && ... */
9115         printf("semget failed: errno = %d\n", errno);
9116   return 0;
9117 }
9118 END
9119     val="$undef"
9120     set try
9121     if eval $compile; then
9122         xxx=`./try`
9123         case "$xxx" in
9124         semun) val="$define" ;;
9125         esac
9126     fi
9127     $rm -f try try.c
9128     set d_semctl_semun
9129     eval $setvar
9130     case "$d_semctl_semun" in
9131     $define)
9132         echo "You can use union semun for semctl IPC_STAT." >&4
9133         also='also'
9134         ;;
9135     *)  echo "You cannot use union semun for semctl IPC_STAT." >&4
9136         also=''
9137         ;;
9138     esac
9139
9140     : see whether semctl IPC_STAT can use struct semid_ds pointer
9141     $cat > try.c <<'END'
9142 #include <sys/types.h>
9143 #include <sys/ipc.h>
9144 #include <sys/sem.h>
9145 #include <sys/stat.h>
9146 #include "try.h"
9147 #include <stdio.h>
9148 #include <errno.h>
9149 #ifndef errno
9150 extern int errno;
9151 #endif
9152 int main() {
9153     struct semid_ds arg;
9154     int sem, st;
9155
9156 #if defined(IPC_PRIVATE) && defined(S_IRWXU) && defined(S_IRWXG) &&  defined(S_IRWXO) && defined(IPC_CREAT)
9157     sem = semget(IPC_PRIVATE, 1, S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT);
9158     if (sem > -1) {
9159 #       ifdef IPC_STAT
9160         st = semctl(sem, 0, IPC_STAT, &arg);
9161         if (st == 0)
9162             printf("semid_ds\n");
9163         else
9164 #       endif /* IPC_STAT */
9165             printf("semctl IPC_STAT failed: errno = %d\n", errno);
9166 #       ifdef IPC_RMID
9167         if (semctl(sem, 0, IPC_RMID, &arg) != 0)
9168 #       endif /* IPC_RMID */
9169             printf("semctl IPC_RMID failed: errno = %d\n", errno);
9170     } else
9171 #endif /* IPC_PRIVATE && ... */
9172         printf("semget failed: errno = %d\n", errno);
9173
9174     return 0;
9175 }
9176 END
9177     val="$undef"
9178     set try
9179     if eval $compile; then
9180         xxx=`./try`
9181         case "$xxx" in
9182         semid_ds) val="$define" ;;
9183         esac
9184     fi
9185     $rm -f try try.c
9186     set d_semctl_semid_ds
9187     eval $setvar
9188     case "$d_semctl_semid_ds" in
9189     $define)
9190         echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
9191         ;;
9192     *)  echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
9193         ;;
9194     esac
9195     $rm -f try.h
9196     ;;
9197 *)  val="$undef"
9198
9199     # We do not have the full sem*(2) library, so assume we can not
9200     # use either.
9201
9202     set d_semctl_semun
9203     eval $setvar
9204
9205     set d_semctl_semid_ds
9206     eval $setvar
9207     ;;
9208 esac
9209
9210 : see if setegid exists
9211 set setegid d_setegid
9212 eval $inlibc
9213
9214 : see if seteuid exists
9215 set seteuid d_seteuid
9216 eval $inlibc
9217
9218 : see if setgrent exists
9219 set setgrent d_setgrent
9220 eval $inlibc
9221
9222 : see if sethostent exists
9223 set sethostent d_sethent
9224 eval $inlibc
9225
9226 : see if setlinebuf exists
9227 set setlinebuf d_setlinebuf
9228 eval $inlibc
9229
9230 : see if setlocale exists
9231 set setlocale d_setlocale
9232 eval $inlibc
9233
9234 : see if setnetent exists
9235 set setnetent d_setnent
9236 eval $inlibc
9237
9238 : see if setprotoent exists
9239 set setprotoent d_setpent
9240 eval $inlibc
9241
9242 : see if setpgid exists
9243 set setpgid d_setpgid
9244 eval $inlibc
9245
9246 : see if setpgrp2 exists
9247 set setpgrp2 d_setpgrp2
9248 eval $inlibc
9249
9250 : see if setpriority exists
9251 set setpriority d_setprior
9252 eval $inlibc
9253
9254 : see if setpwent exists
9255 set setpwent d_setpwent
9256 eval $inlibc
9257
9258 : see if setregid exists
9259 set setregid d_setregid
9260 eval $inlibc
9261 set setresgid d_setresgid
9262 eval $inlibc
9263
9264 : see if setreuid exists
9265 set setreuid d_setreuid
9266 eval $inlibc
9267 set setresuid d_setresuid
9268 eval $inlibc
9269
9270 : see if setrgid exists
9271 set setrgid d_setrgid
9272 eval $inlibc
9273
9274 : see if setruid exists
9275 set setruid d_setruid
9276 eval $inlibc
9277
9278 : see if setservent exists
9279 set setservent d_setsent
9280 eval $inlibc
9281
9282 : see if setsid exists
9283 set setsid d_setsid
9284 eval $inlibc
9285
9286 : see if setvbuf exists
9287 set setvbuf d_setvbuf
9288 eval $inlibc
9289
9290 : see if sfio.h is available
9291 set sfio.h i_sfio
9292 eval $inhdr
9293
9294
9295 : see if sfio library is available
9296 case "$i_sfio" in
9297 $define)
9298         val=''
9299         set sfreserve val
9300         eval $inlibc
9301         ;;
9302 *)
9303         val="$undef"
9304         ;;
9305 esac
9306 : Ok, but do we want to use it.
9307 case "$val" in
9308 $define)
9309         case "$usesfio" in
9310         true|$define|[yY]*) dflt='y';;
9311         *) dflt='n';;
9312         esac
9313         echo "$package can use the sfio library, but it is experimental."
9314         rp="You seem to have sfio available, do you want to try using it?"
9315         . ./myread
9316         case "$ans" in
9317         y|Y) ;;
9318         *)      echo "Ok, avoiding sfio this time.  I'll use stdio instead."
9319                 val="$undef"
9320                 : Remove sfio from list of libraries to use
9321                 set `echo X $libs | $sed -e 's/-lsfio / /' -e 's/-lsfio$//'`
9322                 shift
9323                 libs="$*"
9324                 echo "libs = $libs" >&4
9325                 ;;
9326         esac
9327         ;;
9328 *)      case "$usesfio" in
9329         true|$define|[yY]*)
9330                 echo "Sorry, cannot find sfio on this machine" >&4
9331                 echo "Ignoring your setting of usesfio=$usesfio" >&4
9332                 ;;
9333         esac
9334         ;;
9335 esac
9336 set d_sfio
9337 eval $setvar
9338 case "$d_sfio" in
9339 $define) usesfio='true';;
9340 *) usesfio='false';;
9341 esac
9342
9343 : see if shmctl exists
9344 set shmctl d_shmctl
9345 eval $inlibc
9346
9347 : see if shmget exists
9348 set shmget d_shmget
9349 eval $inlibc
9350
9351 : see if shmat exists
9352 set shmat d_shmat
9353 eval $inlibc
9354 : see what shmat returns
9355 case "$d_shmat" in
9356 "$define")
9357         $cat >shmat.c <<'END'
9358 #include <sys/shm.h>
9359 void *shmat();
9360 END
9361         if $cc $ccflags -c shmat.c >/dev/null 2>&1; then
9362                 shmattype='void *'
9363         else
9364                 shmattype='char *'
9365         fi
9366         echo "and it returns ($shmattype)." >&4
9367         : see if a prototype for shmat is available
9368         xxx=`./findhdr sys/shm.h`
9369         $cppstdin $cppflags $cppminus < $xxx > shmat.c 2>/dev/null
9370         if $contains 'shmat.*(' shmat.c >/dev/null 2>&1; then
9371                 val="$define"
9372         else
9373                 val="$undef"
9374         fi
9375         $rm -f shmat.[co]
9376         ;;
9377 *)
9378         val="$undef"
9379         ;;
9380 esac
9381 set d_shmatprototype
9382 eval $setvar
9383
9384 : see if shmdt exists
9385 set shmdt d_shmdt
9386 eval $inlibc
9387
9388 : see how much of the 'shm*(2)' library is present.
9389 h_shm=true
9390 echo " "
9391 case "$d_shmctl$d_shmget$d_shmat$d_shmdt" in
9392 *"$undef"*) h_shm=false;;
9393 esac
9394 case "$osname" in
9395 freebsd)
9396     case "`ipcs 2>&1`" in
9397     "SVID shared memory"*"not configured"*)
9398         echo "Your $osname does not have the shm*(2) configured." >&4
9399         h_shm=false
9400         val="$undef"
9401         set shmctl d_shmctl
9402         evat $setvar
9403         set shmget d_shmget
9404         evat $setvar
9405         set shmat d_shmat
9406         evat $setvar
9407         set shmdt d_shmdt
9408         evat $setvar
9409         ;;
9410     esac
9411     ;;
9412 esac
9413 : we could also check for sys/ipc.h ...
9414 if $h_shm && $test `./findhdr sys/shm.h`; then
9415         echo "You have the full shm*(2) library." >&4
9416         val="$define"
9417 else
9418         echo "You don't have the full shm*(2) library." >&4
9419         val="$undef"
9420 fi
9421 set d_shm
9422 eval $setvar
9423
9424 echo " "
9425 : see if we have sigaction
9426 if set sigaction val -f d_sigaction; eval $csym; $val; then
9427         echo 'sigaction() found.' >&4
9428         $cat > try.c <<'EOP'
9429 #include <stdio.h>
9430 #include <sys/types.h>
9431 #include <signal.h>
9432 main()
9433 {
9434     struct sigaction act, oact;
9435 }
9436 EOP
9437         set try
9438         if eval $compile_ok; then
9439                 val="$define"
9440         else
9441                 echo "But you don't seem to have a useable struct sigaction." >&4
9442                 val="$undef"
9443         fi
9444 else
9445         echo 'sigaction NOT found.' >&4
9446         val="$undef"
9447 fi
9448 set d_sigaction; eval $setvar
9449 $rm -f try try$_o try.c
9450
9451 : see if sigsetjmp exists
9452 echo " "
9453 case "$d_sigsetjmp" in
9454 '')
9455         $cat >try.c <<'EOP'
9456 #include <setjmp.h>
9457 sigjmp_buf env;
9458 int set = 1;
9459 main()
9460 {
9461         if (sigsetjmp(env,1))
9462                 exit(set);
9463         set = 0;
9464         siglongjmp(env, 1);
9465         exit(1);
9466 }
9467 EOP
9468         set try
9469         if eval $compile; then
9470                 if ./try >/dev/null 2>&1; then
9471                         echo "POSIX sigsetjmp found." >&4
9472                         val="$define"
9473                 else
9474                         $cat >&4 <<EOM
9475 Uh-Oh! You have POSIX sigsetjmp and siglongjmp, but they do not work properly!!
9476 I'll ignore them.
9477 EOM
9478                         val="$undef"
9479                 fi
9480         else
9481                 echo "sigsetjmp not found." >&4
9482                 val="$undef"
9483         fi
9484         ;;
9485 *) val="$d_sigsetjmp"
9486         case "$d_sigsetjmp" in
9487         $define) echo "POSIX sigsetjmp found." >&4;;
9488         $undef) echo "sigsetjmp not found." >&4;;
9489         esac
9490         ;;
9491 esac
9492 set d_sigsetjmp
9493 eval $setvar
9494 $rm -f try.c try
9495
9496 : see if stat knows about block sizes
9497 echo " "
9498 set d_statblks stat st_blocks $i_sysstat sys/stat.h
9499 eval $hasfield
9500
9501 : see if _ptr and _cnt from stdio act std
9502 echo " "
9503 if $contains '_IO_fpos_t' `./findhdr stdio.h` >/dev/null 2>&1 ; then
9504         echo "(Looks like you have stdio.h from Linux.)"
9505         case "$stdio_ptr" in
9506         '') stdio_ptr='((fp)->_IO_read_ptr)'
9507                 ptr_lval=$define
9508                 ;;
9509         *)      ptr_lval=$d_stdio_ptr_lval;;
9510         esac
9511         case "$stdio_cnt" in
9512         '') stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)'
9513                 cnt_lval=$undef
9514                 ;;
9515         *)      cnt_lval=$d_stdio_cnt_lval;;
9516         esac
9517         case "$stdio_base" in
9518         '') stdio_base='((fp)->_IO_read_base)';;
9519         esac
9520         case "$stdio_bufsiz" in
9521         '') stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)';;
9522         esac
9523 else
9524         case "$stdio_ptr" in
9525         '') stdio_ptr='((fp)->_ptr)'
9526                 ptr_lval=$define
9527                 ;;
9528         *)      ptr_lval=$d_stdio_ptr_lval;;
9529         esac
9530         case "$stdio_cnt" in
9531         '') stdio_cnt='((fp)->_cnt)'
9532                 cnt_lval=$define
9533                 ;;
9534         *)      cnt_lval=$d_stdio_cnt_lval;;
9535         esac
9536         case "$stdio_base" in
9537         '') stdio_base='((fp)->_base)';;
9538         esac
9539         case "$stdio_bufsiz" in
9540         '') stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)';;
9541         esac
9542 fi
9543 : test whether _ptr and _cnt really work
9544 echo "Checking how std your stdio is..." >&4
9545 $cat >try.c <<EOP
9546 #include <stdio.h>
9547 #define FILE_ptr(fp)    $stdio_ptr
9548 #define FILE_cnt(fp)    $stdio_cnt
9549 main() {
9550         FILE *fp = fopen("try.c", "r");
9551         char c = getc(fp);
9552         if (
9553                 18 <= FILE_cnt(fp) &&
9554                 strncmp(FILE_ptr(fp), "include <stdio.h>\n", 18) == 0
9555         )
9556                 exit(0);
9557         exit(1);
9558 }
9559 EOP
9560 val="$undef"
9561 set try
9562 if eval $compile; then
9563         if ./try; then
9564                 echo "Your stdio acts pretty std."
9565                 val="$define"
9566         else
9567                 echo "Your stdio isn't very std."
9568         fi
9569 else
9570         echo "Your stdio doesn't appear very std."
9571 fi
9572 $rm -f try.c try
9573 set d_stdstdio
9574 eval $setvar
9575
9576 : Can _ptr be used as an lvalue?
9577 case "$d_stdstdio$ptr_lval" in
9578 $define$define) val=$define ;;
9579 *) val=$undef ;;
9580 esac
9581 set d_stdio_ptr_lval
9582 eval $setvar
9583
9584 : Can _cnt be used as an lvalue?
9585 case "$d_stdstdio$cnt_lval" in
9586 $define$define) val=$define ;;
9587 *) val=$undef ;;
9588 esac
9589 set d_stdio_cnt_lval
9590 eval $setvar
9591
9592 : see if _base is also standard
9593 val="$undef"
9594 case "$d_stdstdio" in
9595 $define)
9596         $cat >try.c <<EOP
9597 #include <stdio.h>
9598 #define FILE_base(fp)   $stdio_base
9599 #define FILE_bufsiz(fp) $stdio_bufsiz
9600 main() {
9601         FILE *fp = fopen("try.c", "r");
9602         char c = getc(fp);
9603         if (
9604                 19 <= FILE_bufsiz(fp) &&
9605                 strncmp(FILE_base(fp), "#include <stdio.h>\n", 19) == 0
9606         )
9607                 exit(0);
9608         exit(1);
9609 }
9610 EOP
9611         set try
9612         if eval $compile; then
9613                 if ./try; then
9614                         echo "And its _base field acts std."
9615                         val="$define"
9616                 else
9617                         echo "But its _base field isn't std."
9618                 fi
9619         else
9620                 echo "However, it seems to be lacking the _base field."
9621         fi
9622         $rm -f try.c try
9623         ;;
9624 esac
9625 set d_stdiobase
9626 eval $setvar
9627
9628 : see if strcoll exists
9629 set strcoll d_strcoll
9630 eval $inlibc
9631
9632 : check for structure copying
9633 echo " "
9634 echo "Checking to see if your C compiler can copy structs..." >&4
9635 $cat >try.c <<'EOCP'
9636 main()
9637 {
9638         struct blurfl {
9639                 int dyick;
9640         } foo, bar;
9641
9642         foo = bar;
9643 }
9644 EOCP
9645 if $cc -c try.c >/dev/null 2>&1 ; then
9646         val="$define"
9647         echo "Yup, it can."
9648 else
9649         val="$undef"
9650         echo "Nope, it can't."
9651 fi
9652 set d_strctcpy
9653 eval $setvar
9654 $rm -f try.*
9655
9656 : see if strerror and/or sys_errlist[] exist
9657 echo " "
9658 if test "X$d_strerror" = X -o "X$d_syserrlst" = X; then
9659     if set strerror val -f d_strerror; eval $csym; $val; then
9660                 echo 'strerror() found.' >&4
9661                 d_strerror="$define"
9662                 d_strerrm='strerror(e)'
9663                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9664                         echo "(You also have sys_errlist[], so we could roll our own strerror.)" 
9665                         d_syserrlst="$define"
9666                 else
9667                         echo "(Since you don't have sys_errlist[], sterror() is welcome.)"
9668                         d_syserrlst="$undef"
9669                 fi
9670     elif xxx=`./findhdr string.h`; test "$xxx" || xxx=`./findhdr strings.h`; \
9671                         $contains '#[   ]*define.*strerror' "$xxx" >/dev/null 2>&1; then
9672                 echo 'strerror() found in string header.' >&4
9673                 d_strerror="$define"
9674                 d_strerrm='strerror(e)'
9675                 if set sys_errlist val -a d_syserrlst; eval $csym; $val; then   
9676                         echo "(Most probably, strerror() uses sys_errlist[] for descriptions.)"
9677                                 d_syserrlst="$define"
9678                 else
9679                         echo "(You don't appear to have any sys_errlist[], how can this be?)"
9680                         d_syserrlst="$undef"
9681                 fi
9682     elif set sys_errlist val -a d_syserrlst; eval $csym; $val; then
9683                 echo "strerror() not found, but you have sys_errlist[] so we'll use that." >&4
9684                 d_strerror="$undef"
9685                 d_syserrlst="$define"
9686                 d_strerrm='((e)<0||(e)>=sys_nerr?"unknown":sys_errlist[e])'
9687     else
9688                 echo 'strerror() and sys_errlist[] NOT found.' >&4
9689                 d_strerror="$undef"
9690                 d_syserrlst="$undef"
9691                 d_strerrm='"unknown"'
9692     fi
9693 fi
9694
9695 : see if strtod exists
9696 set strtod d_strtod
9697 eval $inlibc
9698
9699 : see if strtol exists
9700 set strtol d_strtol
9701 eval $inlibc
9702
9703 : see if strtoul exists
9704 set strtoul d_strtoul
9705 eval $inlibc
9706
9707 : see if strxfrm exists
9708 set strxfrm d_strxfrm
9709 eval $inlibc
9710
9711 : see if symlink exists
9712 set symlink d_symlink
9713 eval $inlibc
9714
9715 : see if syscall exists
9716 set syscall d_syscall
9717 eval $inlibc
9718
9719 : see if sysconf exists
9720 set sysconf d_sysconf
9721 eval $inlibc
9722
9723 : see if system exists
9724 set system d_system
9725 eval $inlibc
9726
9727 : see if tcgetpgrp exists
9728 set tcgetpgrp d_tcgetpgrp
9729 eval $inlibc
9730
9731 : see if tcsetpgrp exists
9732 set tcsetpgrp d_tcsetpgrp
9733 eval $inlibc
9734
9735 : define an is-a-typedef? function
9736 typedef='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9737 case "$inclist" in
9738 "") inclist="sys/types.h";;
9739 esac;
9740 eval "varval=\$$var";
9741 case "$varval" in
9742 "")
9743         $rm -f temp.c;
9744         for inc in $inclist; do
9745                 echo "#include <$inc>" >>temp.c;
9746         done;
9747         echo "#ifdef $type" >> temp.c;
9748         echo "printf(\"We have $type\");" >> temp.c;
9749         echo "#endif" >> temp.c;
9750         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9751         if $contains $type temp.E >/dev/null 2>&1; then
9752                 eval "$var=\$type";
9753         else
9754                 eval "$var=\$def";
9755         fi;
9756         $rm -f temp.?;;
9757 *) eval "$var=\$varval";;
9758 esac'
9759
9760 : define an is-a-typedef? function that prompts if the type is not available.
9761 typedef_ask='type=$1; var=$2; def=$3; shift; shift; shift; inclist=$@;
9762 case "$inclist" in
9763 "") inclist="sys/types.h";;
9764 esac;
9765 eval "varval=\$$var";
9766 case "$varval" in
9767 "")
9768         $rm -f temp.c;
9769         for inc in $inclist; do
9770                 echo "#include <$inc>" >>temp.c;
9771         done;
9772         echo "#ifdef $type" >> temp.c;
9773         echo "printf(\"We have $type\");" >> temp.c;
9774         echo "#endif" >> temp.c;
9775         $cppstdin $cppflags $cppminus < temp.c >temp.E 2>/dev/null;
9776         echo " " ;
9777         echo "$rp" | $sed -e "s/What is/Looking for/" -e "s/?/./";
9778         if $contains $type temp.E >/dev/null 2>&1; then
9779                 echo "$type found." >&4;
9780                 eval "$var=\$type";
9781         else
9782                 echo "$type NOT found." >&4;
9783                 dflt="$def";
9784                 . ./myread ;
9785                 eval "$var=\$ans";
9786         fi;
9787         $rm -f temp.?;;
9788 *) eval "$var=\$varval";;
9789 esac'
9790
9791 : see if this is a sys/times.h system
9792 set sys/times.h i_systimes
9793 eval $inhdr
9794
9795 : see if times exists
9796 echo " "
9797 if set times val -f d_times; eval $csym; $val; then
9798         echo 'times() found.' >&4
9799         d_times="$define"
9800         inc=''
9801         case "$i_systimes" in
9802         "$define") inc='sys/times.h';;
9803         esac
9804         rp="What is the type returned by times() on this system?"
9805         set clock_t clocktype long stdio.h sys/types.h $inc
9806         eval $typedef_ask
9807 else
9808         echo 'times() NOT found, hope that will do.' >&4
9809         d_times="$undef"
9810         clocktype='int'
9811 fi
9812
9813 : see if truncate exists
9814 set truncate d_truncate
9815 eval $inlibc
9816
9817 : see if tzname[] exists
9818 echo " "
9819 if set tzname val -a d_tzname; eval $csym; $val; then
9820         val="$define"
9821         echo 'tzname[] found.' >&4
9822 else
9823         val="$undef"
9824         echo 'tzname[] NOT found.' >&4
9825 fi
9826 set d_tzname
9827 eval $setvar
9828
9829 : see if umask exists
9830 set umask d_umask
9831 eval $inlibc
9832
9833 : backward compatibility for d_hvfork
9834 if test X$d_hvfork != X; then
9835         d_vfork="$d_hvfork"
9836         d_hvfork=''
9837 fi
9838 : see if there is a vfork
9839 val=''
9840 set vfork val
9841 eval $inlibc
9842
9843 : Ok, but do we want to use it. vfork is reportedly unreliable in 
9844 : perl on Solaris 2.x, and probably elsewhere.
9845 case "$val" in
9846 $define)
9847         echo " "
9848         case "$usevfork" in
9849         false) dflt='n';;
9850         *) dflt='y';;
9851         esac
9852         rp="Some systems have problems with vfork().  Do you want to use it?"
9853         . ./myread
9854         case "$ans" in
9855         y|Y) ;;
9856         *)
9857                 echo "Ok, we won't use vfork()."
9858                 val="$undef"
9859                 ;;
9860         esac
9861         ;;
9862 esac
9863 set d_vfork
9864 eval $setvar
9865 case "$d_vfork" in
9866 $define) usevfork='true';;
9867 *) usevfork='false';;
9868 esac
9869
9870 : see if this is an sysdir system
9871 set sys/dir.h i_sysdir
9872 eval $inhdr
9873
9874 : see if this is an sysndir system
9875 set sys/ndir.h i_sysndir
9876 eval $inhdr
9877
9878 : see if sys/types.h has to be included
9879 set sys/types.h i_systypes
9880 eval $inhdr
9881
9882 : see if closedir exists
9883 set closedir d_closedir
9884 eval $inlibc
9885
9886 case "$d_closedir" in
9887 "$define")
9888         echo " "
9889         echo "Checking whether closedir() returns a status..." >&4
9890         cat > closedir.c <<EOM
9891 #$i_dirent I_DIRENT             /**/
9892 #$i_sysdir I_SYS_DIR            /**/
9893 #$i_sysndir I_SYS_NDIR          /**/
9894 #$i_systypes I_SYS_TYPES        /**/
9895
9896 #if defined(I_SYS_TYPES)
9897 #include <sys/types.h>
9898 #endif
9899 #if defined(I_DIRENT)
9900 #include <dirent.h>
9901 #if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
9902 #include <sys/dir.h>
9903 #endif
9904 #else
9905 #ifdef I_SYS_NDIR
9906 #include <sys/ndir.h>
9907 #else
9908 #ifdef I_SYS_DIR
9909 #ifdef hp9000s500
9910 #include <ndir.h>       /* may be wrong in the future */
9911 #else
9912 #include <sys/dir.h>
9913 #endif
9914 #endif
9915 #endif
9916 #endif 
9917 int main() { return closedir(opendir(".")); }
9918 EOM
9919         set closedir
9920         if eval $compile_ok; then
9921                 if ./closedir > /dev/null 2>&1 ; then
9922                         echo "Yes, it does."
9923                         val="$undef"
9924                 else
9925                         echo "No, it doesn't."
9926                         val="$define"
9927                 fi
9928         else
9929                 echo "(I can't seem to compile the test program--assuming it doesn't)"
9930                 val="$define"
9931         fi
9932         ;;
9933 *)
9934         val="$undef";
9935         ;;
9936 esac
9937 set d_void_closedir
9938 eval $setvar
9939 $rm -f closedir*
9940 : check for volatile keyword
9941 echo " "
9942 echo 'Checking to see if your C compiler knows about "volatile"...' >&4
9943 $cat >try.c <<'EOCP'
9944 main()
9945 {
9946         typedef struct _goo_struct goo_struct;
9947         goo_struct * volatile goo = ((goo_struct *)0);
9948         struct _goo_struct {
9949                 long long_int;
9950                 int reg_int;
9951                 char char_var;
9952         };
9953         typedef unsigned short foo_t;
9954         char *volatile foo;
9955         volatile int bar;
9956         volatile foo_t blech;
9957         foo = foo;
9958 }
9959 EOCP
9960 if $cc -c $ccflags try.c >/dev/null 2>&1 ; then
9961         val="$define"
9962         echo "Yup, it does."
9963 else
9964         val="$undef"
9965         echo "Nope, it doesn't."
9966 fi
9967 set d_volatile
9968 eval $setvar
9969 $rm -f try.*
9970
9971 : see if there is a wait4
9972 set wait4 d_wait4
9973 eval $inlibc
9974
9975 : see if waitpid exists
9976 set waitpid d_waitpid
9977 eval $inlibc
9978
9979 : see if wcstombs exists
9980 set wcstombs d_wcstombs
9981 eval $inlibc
9982
9983 : see if wctomb exists
9984 set wctomb d_wctomb
9985 eval $inlibc
9986
9987 : preserve RCS keywords in files with variable substitution, grrr
9988 Date='$Date'
9989 Id='$Id'
9990 Log='$Log'
9991 RCSfile='$RCSfile'
9992 Revision='$Revision'
9993
9994 : check for alignment requirements
9995 echo " "
9996 case "$alignbytes" in
9997 '') echo "Checking alignment constraints..." >&4
9998         $cat >try.c <<'EOCP'
9999 struct foobar {
10000         char foo;
10001         double bar;
10002 } try;
10003 main()
10004 {
10005         printf("%d\n", (char *)&try.bar - (char *)&try.foo);
10006 }
10007 EOCP
10008         set try
10009         if eval $compile_ok; then
10010                 dflt=`./try`
10011         else
10012                 dflt='8'
10013                 echo "(I can't seem to compile the test program...)"
10014         fi
10015         ;;
10016 *) dflt="$alignbytes"
10017         ;;
10018 esac
10019 rp="Doubles must be aligned on a how-many-byte boundary?"
10020 . ./myread
10021 alignbytes="$ans"
10022 $rm -f try.c try
10023
10024 : check for ordering of bytes in a long
10025 case "$byteorder" in
10026 '')
10027         $cat <<'EOM'
10028   
10029 In the following, larger digits indicate more significance.  A big-endian
10030 machine like a Pyramid or a Motorola 680?0 chip will come out to 4321. A
10031 little-endian machine like a Vax or an Intel 80?86 chip would be 1234. Other
10032 machines may have weird orders like 3412.  A Cray will report 87654321. If
10033 the test program works the default is probably right.
10034 I'm now running the test program...
10035 EOM
10036         $cat >try.c <<'EOCP'
10037 #include <stdio.h>
10038 main()
10039 {
10040         int i;
10041         union {
10042                 unsigned long l;
10043                 char c[sizeof(long)];
10044         } u;
10045
10046         if (sizeof(long) > 4)
10047                 u.l = (0x08070605L << 32) | 0x04030201L;
10048         else
10049                 u.l = 0x04030201L;
10050         for (i = 0; i < sizeof(long); i++)
10051                 printf("%c", u.c[i]+'0');
10052         printf("\n");
10053         exit(0);
10054 }
10055 EOCP
10056         xxx_prompt=y
10057         set try
10058         if eval $compile && ./try > /dev/null; then
10059                 dflt=`./try`
10060                 case "$dflt" in
10061                 [1-4][1-4][1-4][1-4]|12345678|87654321)
10062                         echo "(The test program ran ok.)"
10063                         echo "byteorder=$dflt"
10064                         xxx_prompt=n
10065                         ;;
10066                 ????|????????) echo "(The test program ran ok.)" ;;
10067                 *) echo "(The test program didn't run right for some reason.)" ;;
10068                 esac
10069         else
10070                 dflt='4321'
10071                 cat <<'EOM'
10072 (I can't seem to compile the test program.  Guessing big-endian...)
10073 EOM
10074         fi
10075         case "$xxx_prompt" in
10076         y)
10077                 rp="What is the order of bytes in a long?"
10078                 . ./myread
10079                 byteorder="$ans"
10080                 ;;
10081         *)      byteorder=$dflt
10082                 ;;
10083         esac
10084         ;;
10085 esac
10086 $rm -f try.c try
10087
10088 : how do we catenate cpp tokens here?
10089 echo " "
10090 echo "Checking to see how your cpp does stuff like catenate tokens..." >&4
10091 $cat >cpp_stuff.c <<'EOCP'
10092 #define RCAT(a,b)a/**/b
10093 #define ACAT(a,b)a ## b
10094 RCAT(Rei,ser)
10095 ACAT(Cir,cus)
10096 EOCP
10097 $cppstdin $cppflags $cppminus <cpp_stuff.c >cpp_stuff.out 2>&1
10098 if $contains 'Circus' cpp_stuff.out >/dev/null 2>&1; then
10099         echo "Oh!  Smells like ANSI's been here." >&4
10100         echo "We can catify or stringify, separately or together!"
10101         cpp_stuff=42
10102 elif $contains 'Reiser' cpp_stuff.out >/dev/null 2>&1; then
10103         echo "Ah, yes!  The good old days!" >&4
10104         echo "However, in the good old days we don't know how to stringify and"
10105         echo "catify at the same time."
10106         cpp_stuff=1
10107 else
10108         $cat >&4 <<EOM
10109 Hmm, I don't seem to be able to catenate tokens with your cpp.  You're going
10110 to have to edit the values of CAT[2-5] in config.h...
10111 EOM
10112         cpp_stuff="/* Help! How do we handle cpp_stuff? */*/"
10113 fi
10114 $rm -f cpp_stuff.*
10115
10116 : see if this is a db.h system
10117 set db.h i_db
10118 eval $inhdr
10119
10120 case "$i_db" in
10121 $define)
10122         : Check db version.
10123         echo " "
10124         echo "Checking Berkeley DB version ..." >&4
10125         $cat >try.c <<EOCP
10126 #$d_const HASCONST
10127 #ifndef HASCONST
10128 #define const
10129 #endif
10130 #include <sys/types.h>
10131 #include <stdio.h>
10132 #include <db.h>
10133 main()
10134 {
10135 #ifdef DB_VERSION_MAJOR /* DB version >= 2 */
10136     int Major, Minor, Patch ;
10137     unsigned long Version ;
10138     (void)db_version(&Major, &Minor, &Patch) ;
10139     printf("You have Berkeley DB Version 2 or greater\n");
10140
10141     printf("db.h is from Berkeley DB Version %d.%d.%d\n",
10142                 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
10143     printf("libdb is from Berkeley DB Version %d.%d.%d\n",
10144                 Major, Minor, Patch) ;
10145
10146     /* check that db.h & libdb are compatible */
10147     if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) {
10148         printf("db.h and libdb are incompatible\n") ;
10149         exit(3);        
10150     }
10151
10152     printf("db.h and libdb are compatible\n") ;
10153
10154     Version = DB_VERSION_MAJOR * 1000000 + DB_VERSION_MINOR * 1000
10155                 + DB_VERSION_PATCH ;
10156
10157     /* needs to be >= 2.3.4 */
10158     if (Version < 2003004) {
10159     /* if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { */
10160         printf("but Perl needs Berkeley DB 2.3.4 or greater\n") ;
10161         exit(2);        
10162     }
10163
10164     exit(0);
10165 #else
10166 #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC)
10167     printf("You have Berkeley DB Version 1\n");
10168     exit(0);    /* DB version < 2: the coast is clear. */
10169 #else
10170     exit(1);    /* <db.h> not Berkeley DB? */
10171 #endif
10172 #endif
10173 }
10174 EOCP
10175         set try
10176         if eval $compile && ./try; then
10177                 echo 'Looks OK.' >&4
10178         else
10179                 echo "I can't use Berkeley DB with your <db.h>.  I'll disable Berkeley DB." >&4
10180                 i_db=$undef
10181                 case " $libs " in
10182                 *"-ldb "*)
10183                         : Remove db from list of libraries to use
10184                         echo "Removing unusable -ldb from library list" >&4
10185                         set `echo X $libs | $sed -e 's/-ldb / /' -e 's/-ldb$//'`
10186                         shift
10187                         libs="$*"
10188                         echo "libs = $libs" >&4
10189                         ;;
10190                 esac
10191         fi
10192         $rm -f try.*
10193         ;;
10194 esac
10195
10196 case "$i_db" in
10197 define)
10198         : Check the return type needed for hash 
10199         echo " "
10200         echo "Checking return type needed for hash for Berkeley DB ..." >&4
10201         $cat >try.c <<EOCP
10202 #$d_const HASCONST
10203 #ifndef HASCONST
10204 #define const
10205 #endif
10206 #include <sys/types.h>
10207 #include <db.h>
10208
10209 #ifndef DB_VERSION_MAJOR
10210 u_int32_t hash_cb (ptr, size)
10211 const void *ptr;
10212 size_t size;
10213 {
10214 }
10215 HASHINFO info;
10216 main()
10217 {
10218         info.hash = hash_cb;
10219 }
10220 #endif
10221 EOCP
10222         if $cc $ccflags -c try.c >try.out 2>&1 ; then
10223                 if $contains warning try.out >>/dev/null 2>&1 ; then
10224                         db_hashtype='int'
10225                 else
10226                         db_hashtype='u_int32_t'
10227                 fi
10228         else
10229                 : XXX Maybe we should just give up here.
10230                 db_hashtype=u_int32_t
10231                 $cat try.out >&4
10232                 echo "Help:  I can't seem to compile the db test program." >&4
10233                 echo "Something's wrong, but I'll assume you use $db_hashtype." >&4
10234         fi
10235         $rm -f try.*
10236         echo "Your version of Berkeley DB uses $db_hashtype for hash."
10237         ;;
10238 *)      db_hashtype=u_int32_t
10239         ;;
10240 esac
10241 case "$i_db" in
10242 define)
10243         : Check the return type needed for prefix 
10244         echo " "
10245         echo "Checking return type needed for prefix for Berkeley DB ..." >&4
10246         cat >try.c <<EOCP
10247 #$d_const HASCONST
10248 #ifndef HASCONST
10249 #define const
10250 #endif
10251 #include <sys/types.h>
10252 #include <db.h>
10253
10254 #ifndef DB_VERSION_MAJOR
10255 size_t prefix_cb (key1, key2)
10256 const DBT *key1;
10257 const DBT *key2;
10258 {
10259 }
10260 BTREEINFO info;
10261 main()
10262 {
10263         info.prefix = prefix_cb;
10264 }
10265 #endif
10266 EOCP
10267         if $cc $ccflags -c try.c  >try.out 2>&1 ; then
10268                 if $contains warning try.out >>/dev/null 2>&1 ; then
10269                         db_prefixtype='int'
10270                 else
10271                         db_prefixtype='size_t'
10272                 fi
10273         else
10274                 db_prefixtype='size_t'
10275                 : XXX Maybe we should just give up here.
10276                 $cat try.out >&4
10277                 echo "Help:  I can't seem to compile the db test program." >&4
10278                 echo "Something's wrong, but I'll assume you use $db_prefixtype." >&4
10279         fi
10280         $rm -f try.*
10281         echo "Your version of Berkeley DB uses $db_prefixtype for prefix."
10282         ;;
10283 *)      db_prefixtype='size_t'
10284         ;;
10285 esac
10286
10287 : check for void type
10288 echo " "
10289 echo "Checking to see how well your C compiler groks the void type..." >&4
10290 case "$voidflags" in
10291 '')
10292         $cat >try.c <<'EOCP'
10293 #if TRY & 1
10294 void sub() {
10295 #else
10296 sub() {
10297 #endif
10298         extern void moo();      /* function returning void */
10299         void (*goo)();          /* ptr to func returning void */
10300 #if TRY & 8
10301         void *hue;              /* generic ptr */
10302 #endif
10303 #if TRY & 2
10304         void (*foo[10])();
10305 #endif
10306
10307 #if TRY & 4
10308         if(goo == moo) {
10309                 exit(0);
10310         }
10311 #endif
10312         exit(0);
10313 }
10314 main() { sub(); }
10315 EOCP
10316         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
10317                 voidflags=$defvoidused
10318         echo "Good.  It appears to support void to the level $package wants.">&4
10319                 if $contains warning .out >/dev/null 2>&1; then
10320                         echo "However, you might get some warnings that look like this:"
10321                         $cat .out
10322                 fi
10323         else
10324 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
10325                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
10326                         echo "It supports 1..."
10327                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
10328                                 echo "It also supports 2..."
10329                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
10330                                         voidflags=7
10331                                         echo "And it supports 4 but not 8 definitely."
10332                                 else
10333                                         echo "It doesn't support 4..."
10334                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
10335                                                 voidflags=11
10336                                                 echo "But it supports 8."
10337                                         else
10338                                                 voidflags=3
10339                                                 echo "Neither does it support 8."
10340                                         fi
10341                                 fi
10342                         else
10343                                 echo "It does not support 2..."
10344                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
10345                                         voidflags=13
10346                                         echo "But it supports 4 and 8."
10347                                 else
10348                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
10349                                                 voidflags=5
10350                                                 echo "And it supports 4 but has not heard about 8."
10351                                         else
10352                                                 echo "However it supports 8 but not 4."
10353                                         fi
10354                                 fi
10355                         fi
10356                 else
10357                         echo "There is no support at all for void."
10358                         voidflags=0
10359                 fi
10360         fi
10361 esac
10362 case "$voidflags" in
10363 "$defvoidused") ;;
10364 *)      $cat >&4 <<'EOM'
10365   Support flag bits are:
10366     1: basic void declarations.
10367     2: arrays of pointers to functions returning void.
10368     4: operations between pointers to and addresses of void functions.
10369     8: generic void pointers.
10370 EOM
10371         dflt="$voidflags";
10372         rp="Your void support flags add up to what?"
10373         . ./myread
10374         voidflags="$ans"
10375         ;;
10376 esac
10377 $rm -f try.* .out
10378
10379
10380 : How can we generate normalized random numbers ?
10381 echo " "
10382 case "$randfunc" in
10383 '')
10384         if set drand48 val -f; eval $csym; $val; then
10385                 dflt="drand48"
10386                 echo "Good, found drand48()." >&4
10387         elif set random val -f; eval $csym; $val; then
10388                 dflt="random"
10389                 echo "OK, found random()." >&4
10390         else
10391                 dflt="rand"
10392                 echo "Yick, looks like I have to use rand()." >&4
10393         fi
10394         echo " "
10395         ;;
10396 *)
10397         dflt="$randfunc"
10398         ;;
10399 esac
10400 cont=true
10401
10402 case "$ccflags" in
10403 *-Dmy_rand=*|*-Dmy_srand=*)
10404         echo "Removing obsolete -Dmy_rand, -Dmy_srand, and -Drandbits from ccflags." >&4
10405         ccflags="`echo $ccflags | sed -e 's/-Dmy_rand=random/ /'`"
10406         ccflags="`echo $ccflags | sed -e 's/-Dmy_srand=srandom/ /'`"
10407         ccflags="`echo $ccflags | sed -e 's/-Drandbits=[0-9][0-9]*/ /'`"
10408         ;;
10409 esac
10410
10411 while $test "$cont"; do
10412         rp="Use which function to generate random numbers?"
10413         . ./myread
10414         if $test "$ans" = "$dflt"; then
10415                 : null
10416         else
10417                 randbits=''
10418         fi
10419         randfunc="$ans"
10420         if set $ans val -f; eval $csym; $val; then
10421                 cont=''
10422         else
10423                 dflt=n
10424                 rp="Function $ans does not exists. Use that name anyway?"
10425                 . ./myread
10426                 dflt=rand
10427                 case "$ans" in
10428                         [yY]*) cont='';;
10429                 esac
10430         fi
10431         case "$cont" in
10432         '')
10433                 case "$randfunc" in
10434                 drand48)
10435                         drand01="drand48()"
10436                         seedfunc="srand48"
10437                         randbits=48
10438                         randseedtype=long
10439                         ;;
10440                 rand|random)
10441                         case "$randbits" in
10442                         '')
10443 echo "Checking to see how many bits your $randfunc() function produces..." >&4
10444                                 $cat >try.c <<EOCP
10445 #$i_unistd I_UNISTD
10446 #$i_stdlib I_STDLIB
10447 #include <stdio.h>
10448 #ifdef I_UNISTD
10449 #  include <unistd.h>
10450 #endif
10451 #ifdef I_STDLIB
10452 #  include <stdlib.h>
10453 #endif
10454 main()
10455 {
10456         register int i;
10457         register unsigned long tmp;
10458         register unsigned long max = 0L;
10459
10460         for (i = 1000; i; i--) {
10461                 tmp = (unsigned long) $randfunc();
10462                 if (tmp > max) max = tmp;
10463         }
10464         for (i = 0; max; i++)
10465                 max /= 2;
10466         printf("%d\n",i);
10467 }
10468 EOCP
10469                                 set try
10470                                 if eval $compile_ok; then
10471                                         dflt=`try`
10472                                 else
10473                                         dflt='?'
10474                                         echo "(I can't seem to compile the test program...)"
10475                                 fi
10476                                 ;;
10477                         *)
10478                                 dflt="$randbits"
10479                                 ;;
10480                         esac
10481                         rp="How many bits does your $randfunc() function produce?"
10482                         . ./myread
10483                         randbits="$ans"
10484                         $rm -f try.c try
10485                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10486                         seedfunc="s$randfunc"
10487                         randseedtype=unsigned
10488                         ;;
10489                 *)
10490                         dflt="31"
10491                         rp="How many bits does your $randfunc() function produce?"
10492                         . ./myread
10493                         randbits="$ans"
10494                         seedfunc="s$randfunc"
10495                         drand01="($randfunc() / (double) ((unsigned long)1 << $randbits))"
10496                         if set $seedfunc val -f; eval $csym; $val; then
10497                                 echo "(Using $seedfunc() to seed random generator)"
10498                         else
10499                                 echo "(Warning: no $seedfunc() to seed random generator)"
10500                                 seedfunc=rand
10501                         fi
10502                         randseedtype=unsigned
10503                         ;;
10504                 esac
10505                 ;;
10506         esac
10507 done
10508
10509 echo " "
10510 echo "Determining whether or not we are on an EBCDIC system..." >&4
10511 $cat >tebcdic.c <<'EOM'
10512 int main()
10513 {
10514   if ('M'==0xd4) return 0;
10515   return 1;
10516 }
10517 EOM
10518
10519 val=$undef
10520 set tebcdic
10521 if eval $compile_ok; then
10522         if ./tebcdic; then
10523                 echo "You have EBCDIC." >&4
10524                 val="$define"
10525         else
10526                 echo "Nope, no EBCDIC.  Assuming ASCII or some ISO Latin." >&4
10527         fi
10528 else
10529         echo "$me: I'm unable to compile the test program." >&4
10530         echo "I'll assume ASCII or some ISO Latin." >&4
10531 fi
10532 $rm -f tebcdic.c tebcdic
10533 set ebcdic
10534 eval $setvar
10535
10536 : see what type file positions are declared as in the library
10537 rp="What is the type for file position used by fsetpos()?"
10538 set fpos_t fpostype long stdio.h sys/types.h
10539 eval $typedef_ask
10540
10541 : Store the full pathname to the sed program for use in the C program
10542 full_sed=$sed
10543
10544 : see what type gids are declared as in the kernel
10545 echo " "
10546 echo "Looking for the type for group ids returned by getgid()."
10547 set gid_t gidtype xxx stdio.h sys/types.h
10548 eval $typedef
10549 case "$gidtype" in
10550 xxx)
10551         xxx=`./findhdr sys/user.h`
10552         set `grep 'groups\[NGROUPS\];' "$xxx" 2>/dev/null` unsigned short
10553         case $1 in
10554         unsigned) dflt="$1 $2" ;;
10555         *) dflt="$1" ;;
10556         esac
10557         ;;
10558 *) dflt="$gidtype";;
10559 esac
10560 case "$gidtype" in
10561 gid_t) echo "gid_t found." ;;
10562 *)      rp="What is the type for group ids returned by getgid()?"
10563         . ./myread
10564         gidtype="$ans"
10565         ;;
10566 esac
10567
10568 : see if getgroups exists
10569 set getgroups d_getgrps
10570 eval $inlibc
10571
10572 : see if setgroups exists
10573 set setgroups d_setgrps
10574 eval $inlibc
10575
10576
10577 : Find type of 2nd arg to 'getgroups()' and 'setgroups()'
10578 echo " "
10579 case "$d_getgrps$d_setgrps" in
10580 *define*)
10581         case "$groupstype" in
10582         '') dflt="$gidtype" ;;
10583         *)  dflt="$groupstype" ;;
10584         esac
10585         $cat <<EOM
10586 What type of pointer is the second argument to getgroups() and setgroups()?
10587 Usually this is the same as group ids, $gidtype, but not always.
10588
10589 EOM
10590         rp='What type pointer is the second argument to getgroups() and setgroups()?'
10591         . ./myread
10592         groupstype="$ans"
10593         ;;
10594 *)  groupstype="$gidtype";;
10595 esac
10596
10597 : see what type lseek is declared as in the kernel
10598 rp="What is the type used for lseek's offset on this system?"
10599 set off_t lseektype long stdio.h sys/types.h
10600 eval $typedef_ask
10601
10602 echo " "
10603 $echo $n "Checking to see how big your file offsets are...$c" >&4
10604 $cat >try.c <<EOCP
10605 #include <sys/types.h>
10606 #include <stdio.h>
10607 main()
10608 {
10609         printf("%d\n", sizeof($lseektype));
10610 }
10611 EOCP
10612 set try
10613 if eval $compile_ok; then
10614         lseeksize=`./try`
10615         $echo " $lseeksize bytes." >&4
10616 else
10617         dflt='4'
10618         echo " "
10619         echo "(I can't seem to compile the test program.  Guessing...)"
10620         rp="What is the size of your file offsets (in bytes)?"
10621         . ./myread
10622         lseeksize="$ans"
10623 fi
10624 $rm -f try.c try
10625
10626 echo " "
10627 echo "Checking if your $make program sets \$(MAKE)..." >&4
10628 case "$make_set_make" in
10629 '')
10630         $sed 's/^X //' > testmake.mak << 'EOF'
10631 Xall:
10632 X       @echo 'maketemp="$(MAKE)"'
10633 EOF
10634         case "`$make -f testmake.mak 2>/dev/null`" in
10635         *maketemp=*) make_set_make='#' ;;
10636         *)      make_set_make="MAKE=$make" ;;
10637         esac
10638         $rm -f testmake.mak
10639         ;;
10640 esac
10641 case "$make_set_make" in
10642 '#') echo "Yup, it does.";;
10643 *) echo "Nope, it doesn't.";;
10644 esac
10645
10646 : see what type is used for mode_t
10647 rp="What is the type used for file modes for system calls (e.g. fchmod())?"
10648 set mode_t modetype int stdio.h sys/types.h
10649 eval $typedef_ask
10650
10651 : define a fucntion to check prototypes
10652 $cat > protochk <<EOSH
10653 $startsh
10654 cc="$cc"
10655 optimize="$optimize"
10656 ccflags="$ccflags"
10657 prototype="$prototype"
10658 define="$define"
10659 rm=$rm
10660 EOSH
10661
10662 $cat >> protochk <<'EOSH'
10663
10664 $rm -f try.c
10665 foo="$1"
10666 shift
10667 while test $# -ge 2; do
10668         case "$1" in
10669                 $define) echo "#include <$2>" >> try.c ;;
10670                 literal) echo "$2" >> try.c ;;
10671         esac
10672     shift 2
10673 done
10674 test "$prototype" = "$define"  && echo '#define CAN_PROTOTYPE' >> try.c
10675 cat >> try.c <<'EOCP'
10676 #ifdef CAN_PROTOTYPE
10677 #define _(args) args
10678 #else
10679 #define _(args) ()
10680 #endif
10681 EOCP
10682 echo "$foo" >> try.c
10683 echo 'int no_real_function_has_this_name _((void)) { return 0; }' >> try.c
10684 $cc $optimize $ccflags -c try.c > /dev/null 2>&1
10685 status=$?
10686 $rm -f try.[co]
10687 exit $status
10688 EOSH
10689 chmod +x protochk
10690 $eunicefix protochk
10691
10692 : see what type is used for size_t
10693 rp="What is the type used for the length parameter for string functions?"
10694 set size_t sizetype 'unsigned int' stdio.h sys/types.h
10695 eval $typedef_ask
10696
10697 : check for type of arguments to gethostbyaddr. 
10698 if test "X$netdb_host_type" = X -o "X$netdb_hlen_type" = X; then
10699         case "$d_gethbyaddr" in
10700         $define)
10701                 $cat <<EOM
10702
10703 Checking to see what type of arguments are accepted by gethostbyaddr().
10704 EOM
10705                 hdrs="$define sys/types.h
10706                         $d_socket sys/socket.h 
10707                         $i_niin netinet/in.h 
10708                         $i_netdb netdb.h
10709                         $i_unistd unistd.h"
10710                 : The first arg can 'char *' or 'void *'
10711                 : The second arg is some of integral type
10712                 for xxx in in_addr_t 'const void *' 'const char *' 'void *' 'char *'; do
10713                         for yyy in size_t long int; do
10714                                 case "$netdb_host_type" in
10715                                 '')     try="extern struct hostent *gethostbyaddr($xxx, $yyy, int);"
10716                                         if ./protochk "$try" $hdrs; then
10717                                                 echo "Your system accepts $xxx for the first arg."
10718                                                 echo "...and $yyy for the second arg."
10719                                                 netdb_host_type="$xxx"
10720                                                 netdb_hlen_type="$yyy"
10721                                         fi
10722                                         ;;
10723                                 esac
10724                         done
10725                 done
10726                 : In case none of those worked, prompt the user.
10727                 case "$netdb_host_type" in
10728                 '')     rp='What is the type for the 1st argument to gethostbyaddr?'
10729                         dflt='char *'
10730                         . ./myread
10731                         netdb_host_type=$ans
10732                         rp='What is the type for the 2nd argument to gethostbyaddr?'
10733                         dflt="$sizetype"
10734                         . ./myread
10735                         netdb_hlen_type=$ans
10736                         ;;
10737                 esac
10738                 ;;
10739         *)      : no gethostbyaddr, so pick harmless defaults
10740                 netdb_host_type='char *'
10741                 netdb_hlen_type="$sizetype"
10742                 ;;
10743         esac
10744         # Remove the "const" if needed. -- but then we'll have a 
10745         # prototype clash!
10746         # netdb_host_type=`echo "$netdb_host_type" | sed 's/^const //'`
10747 fi
10748
10749 : check for type of argument to gethostbyname. 
10750 if test "X$netdb_name_type" = X ; then
10751         case "$d_gethbyname" in
10752         $define)
10753                 $cat <<EOM
10754
10755 Checking to see what type of argument is accepted by gethostbyname().
10756 EOM
10757                 hdrs="$define sys/types.h
10758                         $d_socket sys/socket.h 
10759                         $i_niin netinet/in.h 
10760                         $i_netdb netdb.h
10761                         $i_unistd unistd.h"
10762                 for xxx in "const char *" "char *"; do
10763                         case "$netdb_name_type" in
10764                         '')     try="extern struct hostent *gethostbyname($xxx);"
10765                                 if ./protochk "$try" $hdrs; then
10766                                         echo "Your system accepts $xxx."
10767                                         netdb_name_type="$xxx"
10768                                 fi
10769                                 ;;
10770                         esac
10771                 done
10772                 : In case none of those worked, prompt the user.
10773                 case "$netdb_name_type" in
10774                 '')     rp='What is the type for the 1st argument to gethostbyname?'
10775                         dflt='char *'
10776                         . ./myread
10777                         netdb_name_type=$ans
10778                         ;;
10779                 esac
10780                 ;;
10781         *)      : no gethostbyname, so pick harmless default
10782                 netdb_name_type='char *'
10783                 ;;
10784         esac
10785 fi
10786
10787 : check for type of 1st argument to getnetbyaddr. 
10788 if test "X$netdb_net_type" = X ; then
10789         case "$d_getnbyaddr" in
10790         $define)
10791                 $cat <<EOM
10792
10793 Checking to see what type of 1st argument is accepted by getnetbyaddr().
10794 EOM
10795                 hdrs="$define sys/types.h
10796                         $d_socket sys/socket.h 
10797                         $i_niin netinet/in.h 
10798                         $i_netdb netdb.h
10799                         $i_unistd unistd.h"
10800                 for xxx in in_addr_t "unsigned long" long "unsigned int" int; do
10801                         case "$netdb_net_type" in
10802                         '')     try="extern struct netent *getnetbyaddr($xxx, int);"
10803                                 if ./protochk "$try" $hdrs; then
10804                                         echo "Your system accepts $xxx."
10805                                         netdb_net_type="$xxx"
10806                                 fi
10807                                 ;;
10808                         esac
10809                 done
10810                 : In case none of those worked, prompt the user.
10811                 case "$netdb_net_type" in
10812                 '')     rp='What is the type for the 1st argument to getnetbyaddr?'
10813                         dflt='long'
10814                         . ./myread
10815                         netdb_net_type=$ans
10816                         ;;
10817                 esac
10818                 ;;
10819         *)      : no getnetbyaddr, so pick harmless default
10820                 netdb_net_type='long'
10821                 ;;
10822         esac
10823 fi
10824 : locate the preferred pager for this system
10825 case "$pager" in
10826 '')
10827         dflt=''
10828         case "$pg" in
10829         /*) dflt=$pg;;
10830         esac
10831         case "$more" in
10832         /*) dflt=$more;;
10833         esac
10834         case "$less" in
10835         /*) dflt=$less;;
10836         esac
10837         case "$dflt" in
10838         '') dflt=/usr/ucb/more;;
10839         esac
10840         ;;
10841 *) dflt="$pager";;
10842 esac
10843 echo " "
10844 fn=f/
10845 rp='What pager is used on your system?'
10846 . ./getfile
10847 pager="$ans"
10848
10849 : see what type pids are declared as in the kernel
10850 rp="What is the type of process ids on this system?"
10851 set pid_t pidtype int stdio.h sys/types.h
10852 eval $typedef_ask
10853
10854 : check for length of pointer
10855 echo " "
10856 case "$ptrsize" in
10857 '')
10858         $echo $n "Checking to see how big your pointers are...$c" >&4
10859         if test "$voidflags" -gt 7; then
10860                 echo '#define VOID_PTR char *' > try.c
10861         else
10862                 echo '#define VOID_PTR void *' > try.c
10863         fi
10864         $cat >>try.c <<'EOCP'
10865 #include <stdio.h>
10866 main()
10867 {
10868         printf("%d\n", sizeof(VOID_PTR));
10869         exit(0);
10870 }
10871 EOCP
10872         set try
10873         if eval $compile_ok; then
10874                 ptrsize=`./try`
10875                 $echo " $ptrsize bytes." >&4
10876         else
10877                 dflt='4'
10878                 echo "(I can't seem to compile the test program.  Guessing...)" >&4
10879                 rp="What is the size of a pointer (in bytes)?"
10880                 . ./myread
10881                 ptrsize="$ans"
10882         fi
10883         ;;
10884 esac
10885 $rm -f try.c try
10886
10887 : see if ar generates random libraries by itself
10888 echo " "
10889 echo "Checking how to generate random libraries on your machine..." >&4
10890 echo 'int bar1() { return bar2(); }' > bar1.c
10891 echo 'int bar2() { return 2; }' > bar2.c
10892 $cat > foo.c <<'EOP'
10893 main() { printf("%d\n", bar1()); exit(0); }
10894 EOP
10895 $cc $ccflags -c bar1.c >/dev/null 2>&1
10896 $cc $ccflags -c bar2.c >/dev/null 2>&1
10897 $cc $ccflags -c foo.c >/dev/null 2>&1
10898 $ar rc bar$_a bar2$_o bar1$_o >/dev/null 2>&1
10899 if $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
10900         ./foobar >/dev/null 2>&1; then
10901         echo "$ar appears to generate random libraries itself."
10902         orderlib=false
10903         ranlib=":"
10904 elif $ar ts bar$_a >/dev/null 2>&1 &&
10905         $cc $ccflags $ldflags -o foobar foo$_o bar$_a $libs > /dev/null 2>&1 &&
10906         ./foobar >/dev/null 2>&1; then
10907                 echo "a table of contents needs to be added with '$ar ts'."
10908                 orderlib=false
10909                 ranlib="$ar ts"
10910 else
10911         case "$ranlib" in
10912         :) ranlib='';;
10913         '')
10914                 ranlib=`./loc ranlib X /usr/bin /bin /usr/local/bin`
10915                 $test -f $ranlib || ranlib=''
10916                 ;;
10917         esac
10918         if $test -n "$ranlib"; then
10919                 echo "your system has '$ranlib'; we'll use that."
10920                 orderlib=false
10921         else
10922                 echo "your system doesn't seem to support random libraries"
10923                 echo "so we'll use lorder and tsort to order the libraries."
10924                 orderlib=true
10925                 ranlib=":"
10926         fi
10927 fi
10928 $rm -f foo* bar* 
10929
10930 : check for type of arguments to select. 
10931 case "$selecttype" in
10932 '') case "$d_select" in
10933         $define)
10934                 $cat <<EOM
10935 Checking to see what type of arguments are accepted by select().
10936 EOM
10937                 hdrs="$define sys/types.h
10938                         $i_systime sys/time.h 
10939                         $i_sysselct sys/select.h
10940                         $d_socket sys/socket.h"
10941                 : The first arg can be int, unsigned, or size_t
10942                 : The last arg may or may not be 'const'
10943                 val=''
10944                 : void pointer has been seen but using that
10945                 : breaks the selectminbits test
10946                 for xxx in 'fd_set *' 'int *'; do
10947                         for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
10948                                 for tmo in 'struct timeval *' 'const struct timeval *'; do
10949                                         case "$val" in
10950                                         '')     try="extern select _(($nfd, $xxx, $xxx, $xxx, $tmo));"
10951                                                 if ./protochk "$try" $hdrs; then
10952                                                         echo "Your system accepts $xxx."
10953                                                         val="$xxx"
10954                                                 fi
10955                                                 ;;
10956                                         esac
10957                                 done
10958                         done
10959                 done
10960                 case "$val" in
10961                 '')     rp='What is the type for the 2nd, 3rd, and 4th arguments to select?'
10962                         case "$d_fd_set" in
10963                                 $define) dflt="fd_set *" ;;
10964                                 *)              dflt="int *" ;;
10965                         esac
10966                         . ./myread
10967                         val=$ans
10968                         ;;
10969                 esac
10970                 selecttype="$val"
10971                 ;;
10972         *)      : no select, so pick a harmless default
10973                 selecttype='int *'
10974                 ;;
10975         esac
10976         ;;
10977 esac
10978
10979 : check for the select 'width'
10980 case "$selectminbits" in
10981 '') case "$d_select" in
10982         $define)
10983                 $cat <<EOM
10984
10985 Checking to see on how many bits at a time your select() operates...
10986 EOM
10987                 $cat >try.c <<EOCP
10988 #include <sys/types.h>
10989 #$i_time I_TIME
10990 #$i_systime I_SYS_TIME
10991 #$i_systimek I_SYS_TIME_KERNEL
10992 #ifdef I_TIME
10993 #   include <time.h>
10994 #endif
10995 #ifdef I_SYS_TIME
10996 #   ifdef I_SYS_TIME_KERNEL
10997 #       define KERNEL
10998 #   endif
10999 #   include <sys/time.h>
11000 #   ifdef I_SYS_TIME_KERNEL
11001 #       undef KERNEL
11002 #   endif
11003 #endif
11004 #$i_sysselct I_SYS_SELECT
11005 #ifdef I_SYS_SELECT
11006 #include <sys/select.h>
11007 #endif
11008 #include <stdio.h>
11009 $selecttype b;
11010 #define S sizeof(*(b))
11011 #define MINBITS 64
11012 #define NBYTES (S * 8 > MINBITS ? S : MINBITS/8)
11013 #define NBITS  (NBYTES * 8)
11014 int main() {
11015     char s[NBYTES];
11016     struct timeval t;
11017     int i;
11018     FILE* fp;
11019     int fd;
11020
11021     fclose(stdin);
11022     fp = fopen("try.c", "r");
11023     if (fp == 0)
11024       exit(1);
11025     fd = fileno(fp);
11026     if (fd < 0)
11027       exit(2);
11028     b = ($selecttype)s;
11029     for (i = 0; i < NBITS; i++)
11030         FD_SET(i, b);
11031     t.tv_sec  = 0;
11032     t.tv_usec = 0;
11033     select(fd + 1, b, 0, 0, &t);
11034     for (i = NBITS - 1; i > fd && FD_ISSET(i, b); i--);
11035     printf("%d\n", i + 1);
11036     return 0;
11037 }
11038 EOCP
11039                 set try
11040                 if eval $compile_ok; then
11041                         selectminbits=`./try`
11042                         case "$selectminbits" in
11043                         '')     cat >&4 <<EOM
11044 Cannot figure out on how many bits at a time your select() operates.
11045 I'll play safe and guess it is 32 bits.
11046 EOM
11047                                 selectminbits=32
11048                                 bits="32 bits"
11049                                 ;;
11050                         1)      bits="1 bit" ;;
11051                         *)      bits="$selectminbits bits" ;;
11052                         esac
11053                         echo "Your select() operates on $bits at a time." >&4
11054                 else
11055                         rp='What is the minimum number of bits your select() operates on?'
11056                         case "$byteorder" in
11057                         1234|12345678)  dflt=32 ;;
11058                         *)              dflt=1  ;;
11059                         esac
11060                         . ./myread
11061                         val=$ans
11062                         selectminbits="$val"
11063                 fi
11064                 $rm -f try.* try
11065                 ;;
11066         *)      : no select, so pick a harmless default
11067                 selectminbits='32'
11068                 ;;
11069         esac
11070         ;;
11071 esac
11072
11073 : Trace out the files included by signal.h, then look for SIGxxx names.
11074 : Remove SIGARRAYSIZE used by HPUX.
11075 : Remove SIGTYP void lines used by OS2.
11076 xxx=`echo '#include <signal.h>' |
11077         $cppstdin $cppminus $cppflags 2>/dev/null |
11078         $grep '^[       ]*#.*include' | 
11079         $awk "{print \\$$fieldn}" | $sed 's!"!!g' | $sort | $uniq`
11080 : Check this list of files to be sure we have parsed the cpp output ok.
11081 : This will also avoid potentially non-existent files, such 
11082 : as ../foo/bar.h
11083 xxxfiles=''
11084 for xx in $xxx /dev/null ; do
11085         $test -f "$xx" && xxxfiles="$xxxfiles $xx"
11086 done
11087 : If we have found no files, at least try signal.h
11088 case "$xxxfiles" in
11089 '')     xxxfiles=`./findhdr signal.h` ;;
11090 esac
11091 xxx=`awk '
11092 $1 ~ /^#define$/ && $2 ~ /^SIG[A-Z0-9]*$/ && $2 !~ /SIGARRAYSIZE/ && $3 !~ /void/ {
11093         print substr($2, 4, 20)
11094 }
11095 $1 == "#" && $2 ~ /^define$/ && $3 ~ /^SIG[A-Z0-9]*$/ && $3 !~ /SIGARRAYSIZE/ && $4 !~ /void/ {
11096         print substr($3, 4, 20)
11097 }' $xxxfiles`
11098 : Append some common names just in case the awk scan failed.
11099 xxx="$xxx ABRT ALRM BUS CHLD CLD CONT DIL EMT FPE HUP ILL INT IO IOT KILL"
11100 xxx="$xxx LOST PHONE PIPE POLL PROF PWR QUIT SEGV STKFLT STOP SYS TERM TRAP"
11101 xxx="$xxx TSTP TTIN TTOU URG USR1 USR2 USR3 USR4 VTALRM"
11102 xxx="$xxx WINCH WIND WINDOW XCPU XFSZ"
11103 : generate a few handy files for later
11104 $cat > signal.c <<'EOCP'
11105 #include <sys/types.h>
11106 #include <signal.h>
11107 #include <stdio.h>
11108 int main() {
11109
11110 /* Strange style to avoid deeply-nested #if/#else/#endif */
11111 #ifndef NSIG
11112 #  ifdef _NSIG
11113 #    define NSIG (_NSIG)
11114 #  endif
11115 #endif
11116
11117 #ifndef NSIG
11118 #  ifdef SIGMAX
11119 #    define NSIG (SIGMAX+1)
11120 #  endif
11121 #endif
11122
11123 #ifndef NSIG
11124 #  ifdef SIG_MAX
11125 #    define NSIG (SIG_MAX+1)
11126 #  endif
11127 #endif
11128
11129 #ifndef NSIG
11130 #  ifdef MAXSIG
11131 #    define NSIG (MAXSIG+1)
11132 #  endif
11133 #endif
11134
11135 #ifndef NSIG
11136 #  ifdef MAX_SIG
11137 #    define NSIG (MAX_SIG+1)
11138 #  endif
11139 #endif
11140
11141 #ifndef NSIG
11142 #  ifdef SIGARRAYSIZE
11143 #    define NSIG (SIGARRAYSIZE+1) /* Not sure of the +1 */
11144 #  endif
11145 #endif
11146
11147 #ifndef NSIG
11148 #  ifdef _sys_nsig
11149 #    define NSIG (_sys_nsig) /* Solaris 2.5 */
11150 #  endif
11151 #endif
11152
11153 /* Default to some arbitrary number that's big enough to get most
11154    of the common signals.
11155 */
11156 #ifndef NSIG
11157 #    define NSIG 50
11158 #endif
11159
11160 printf("NSIG %d\n", NSIG);
11161
11162 #ifndef JUST_NSIG
11163
11164 EOCP
11165
11166 echo $xxx | $tr ' ' $trnl | $sort | $uniq | $awk '
11167 {
11168         printf "#ifdef SIG"; printf $1; printf "\n"
11169         printf "printf(\""; printf $1; printf " %%d\\n\",SIG";
11170         printf $1; printf ");\n"
11171         printf "#endif\n"
11172 }
11173 END {
11174         printf "#endif /* JUST_NSIG */\n";
11175         printf "}\n";
11176 }
11177 ' >>signal.c
11178 $cat >signal.awk <<'EOP'
11179 BEGIN { ndups = 0 }
11180 $1 ~ /^NSIG$/ { nsig = $2 }
11181 ($1 !~ /^NSIG$/) && (NF == 2) {
11182     if ($2 > maxsig) { maxsig = $2 }
11183     if (sig_name[$2]) {
11184         dup_name[ndups] = $1
11185         dup_num[ndups] = $2
11186         ndups++ 
11187     }
11188     else {
11189         sig_name[$2] = $1
11190         sig_num[$2] = $2
11191     }
11192
11193 }
11194 END { 
11195     if (nsig == 0) { nsig = maxsig + 1 }
11196         for (n = 1; n < nsig; n++) {
11197                 if (sig_name[n]) {
11198                         printf("%s %d\n", sig_name[n], sig_num[n])
11199                 }
11200                 else {
11201                         printf("NUM%d %d\n", n, n) 
11202                 }
11203         }
11204     for (n = 0; n < ndups; n++) {
11205                 printf("%s %d\n", dup_name[n], dup_num[n])
11206     }
11207 }
11208 EOP
11209 $cat >signal_cmd <<EOS
11210 $startsh
11211 if $test -s signal.lst; then
11212     echo "Using your existing signal.lst file"
11213         exit 0
11214 fi
11215 xxx="$xxx"
11216 EOS
11217 $cat >>signal_cmd <<'EOS'
11218
11219 set signal
11220 if eval $compile_ok; then
11221         ./signal$_exe | $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11222 else
11223         echo "(I can't seem be able to compile the whole test program)" >&4
11224         echo "(I'll try it in little pieces.)" >&4
11225         set signal -DJUST_NSIG
11226         if eval $compile_ok; then
11227                 ./signal$_exe > signal.nsg
11228                 $cat signal.nsg
11229         else
11230                 echo "I can't seem to figure out how many signals you have." >&4
11231                 echo "Guessing 50." >&4
11232                 echo 'NSIG 50' > signal.nsg
11233         fi
11234         : Now look at all the signal names, one at a time.
11235         for xx in `echo $xxx | $tr ' ' $trnl | $sort | $uniq`; do
11236                 $cat > signal.c <<EOCP
11237 #include <sys/types.h>
11238 #include <signal.h>
11239 #include <stdio.h>
11240 int main() {
11241 printf("$xx %d\n", SIG${xx});
11242 return 0;
11243 }
11244 EOCP
11245                 set signal
11246                 if eval $compile; then
11247                         echo "SIG${xx} found."
11248                         ./signal$_exe  >> signal.ls1
11249                 else
11250                         echo "SIG${xx} NOT found."
11251                 fi
11252         done
11253         if $test -s signal.ls1; then
11254                 $cat signal.nsg signal.ls1 |
11255                         $sort -n +1 | $uniq | $awk -f signal.awk >signal.lst
11256         fi
11257
11258 fi
11259 if $test -s signal.lst; then
11260         :
11261 else
11262         echo "(AAK! I can't compile the test programs -- Guessing)" >&4
11263         echo 'kill -l' >signal
11264         set X `csh -f <signal`
11265         $rm -f signal
11266         shift
11267         case $# in
11268         0) set HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM;;
11269         esac
11270         echo $@ | $tr ' ' $trnl | \
11271                 $awk '{ printf $1; printf " %d\n", ++s; }' >signal.lst
11272 fi
11273 $rm -f signal.c signal$_exe signal$_o signal.nsg signal.ls1
11274 EOS
11275 chmod a+x signal_cmd
11276 $eunicefix signal_cmd
11277
11278 : generate list of signal names
11279 echo " "
11280 case "$sig_name_init" in
11281 '') doinit=yes ;;
11282 *)  case "$sig_num_init" in
11283     ''|*,*) doinit=yes ;;
11284     esac ;;
11285 esac
11286 case "$doinit" in
11287 yes)
11288         echo "Generating a list of signal names and numbers..." >&4
11289         . ./signal_cmd
11290         sig_name=`$awk '{printf "%s ", $1}' signal.lst`
11291         sig_name="ZERO $sig_name"
11292         sig_name_init=`$awk 'BEGIN { printf "\"ZERO\", " }
11293                                                 { printf "\"%s\", ", $1 }
11294                                                 END { printf "0\n" }' signal.lst`
11295         sig_num=`$awk '{printf "%d ", $2}' signal.lst`
11296         sig_num="0 $sig_num"
11297         sig_num_init=`$awk 'BEGIN { printf "0, " }
11298                                         { printf "%d, ", $2}
11299                                         END { printf "0\n"}' signal.lst`
11300         ;;
11301 esac
11302 echo "The following signals are available:"
11303 echo " "
11304 echo $sig_name | $awk \
11305 'BEGIN { linelen = 0 }
11306 {
11307         for (i = 1; i <= NF; i++) {
11308                 name = "SIG" $i " "
11309                 linelen = linelen + length(name)
11310                 if (linelen > 70) {
11311                         printf "\n"
11312                         linelen = length(name)
11313                 }
11314                 printf "%s", name
11315         }
11316         printf "\n"
11317 }'
11318 $rm -f signal signal.c signal.awk signal.lst signal_cmd 
11319
11320 : see what type is used for signed size_t
11321 set ssize_t ssizetype int stdio.h sys/types.h
11322 eval $typedef
11323 dflt="$ssizetype"
11324 $cat > ssize.c <<EOM
11325 #include <stdio.h>
11326 #include <sys/types.h>
11327 #define Size_t $sizetype
11328 #define SSize_t $dflt
11329 main()
11330 {
11331         if (sizeof(Size_t) == sizeof(SSize_t))
11332                 printf("$dflt\n");
11333         else if (sizeof(Size_t) == sizeof(int))
11334                 printf("int\n");
11335         else 
11336                 printf("long\n");
11337         exit(0);
11338 }
11339 EOM
11340 echo " "
11341 set ssize
11342 if eval $compile_ok && ./ssize > /dev/null; then
11343         ssizetype=`./ssize`
11344         echo "I'll be using $ssizetype for functions returning a byte count." >&4
11345 else
11346         $cat >&4 <<EOM
11347 Help! I can't compile and run the ssize_t test program: please enlighten me!
11348 (This is probably a misconfiguration in your system or libraries, and
11349 you really ought to fix it.  Still, I'll try anyway.)
11350
11351 I need a type that is the same size as $sizetype, but is guaranteed to
11352 be signed.  Common values are ssize_t, int and long.
11353
11354 EOM
11355         rp="What signed type is the same size as $sizetype?"
11356         . ./myread
11357         ssizetype="$ans"
11358 fi
11359 $rm -f ssize ssize.*
11360
11361 : see what type of char stdio uses.
11362 echo " "
11363 if $contains 'unsigned.*char.*_ptr;' `./findhdr stdio.h` >/dev/null 2>&1 ; then
11364         echo "Your stdio uses unsigned chars." >&4
11365         stdchar="unsigned char"
11366 else
11367         echo "Your stdio uses signed chars." >&4
11368         stdchar="char"
11369 fi
11370
11371 : see if time exists
11372 echo " "
11373 if test "X$d_time" = X -o X"$timetype" = X; then
11374     if set time val -f d_time; eval $csym; $val; then
11375                 echo 'time() found.' >&4
11376                 val="$define"
11377                 rp="What is the type returned by time() on this system?"
11378                 set time_t timetype long stdio.h sys/types.h
11379                 eval $typedef_ask
11380     else
11381                 echo 'time() not found, hope that will do.' >&4
11382                 val="$undef"
11383                 timetype='int';
11384     fi
11385     set d_time
11386     eval $setvar
11387 fi
11388
11389 : see what type uids are declared as in the kernel
11390 echo " "
11391 echo "Looking for the type for user ids returned by getuid()."
11392 set uid_t uidtype xxx stdio.h sys/types.h
11393 eval $typedef
11394 case "$uidtype" in
11395 xxx)
11396         xxx=`./findhdr sys/user.h`
11397         set `grep '_ruid;' "$xxx" 2>/dev/null` unsigned short
11398         case $1 in
11399         unsigned) dflt="$1 $2" ;;
11400         *) dflt="$1" ;;
11401         esac
11402         ;;
11403 *) dflt="$uidtype";;
11404 esac
11405 case "$uidtype" in
11406 uid_t)  echo "uid_t found." ;;
11407 *)      rp="What is the type for user ids returned by getuid()?"
11408         . ./myread
11409         uidtype="$ans"
11410         ;;
11411 esac
11412
11413 : see if dbm.h is available
11414 : see if dbmclose exists
11415 set dbmclose d_dbmclose
11416 eval $inlibc
11417
11418 case "$d_dbmclose" in
11419 $define)
11420         set dbm.h i_dbm
11421         eval $inhdr
11422         case "$i_dbm" in
11423         $define)
11424                 val="$undef"
11425                 set i_rpcsvcdbm
11426                 eval $setvar
11427                 ;;
11428         *)      set rpcsvc/dbm.h i_rpcsvcdbm
11429                 eval $inhdr
11430                 ;;
11431         esac
11432         ;;
11433 *)      echo "We won't be including <dbm.h>"
11434         val="$undef"
11435         set i_dbm
11436         eval $setvar
11437         val="$undef"
11438         set i_rpcsvcdbm
11439         eval $setvar
11440         ;;
11441 esac
11442
11443 : see if this is a sys/file.h system
11444 val=''
11445 set sys/file.h val
11446 eval $inhdr
11447
11448 : do we need to include sys/file.h ?
11449 case "$val" in
11450 "$define")
11451         echo " "
11452         if $h_sysfile; then
11453                 val="$define"
11454                 echo "We'll be including <sys/file.h>." >&4
11455         else
11456                 val="$undef"
11457                 echo "We won't be including <sys/file.h>." >&4
11458         fi
11459         ;;
11460 *)
11461         h_sysfile=false
11462         ;;
11463 esac
11464 set i_sysfile
11465 eval $setvar
11466
11467 : see if fcntl.h is there
11468 val=''
11469 set fcntl.h val
11470 eval $inhdr
11471
11472 : see if we can include fcntl.h
11473 case "$val" in
11474 "$define")
11475         echo " "
11476         if $h_fcntl; then
11477                 val="$define"
11478                 echo "We'll be including <fcntl.h>." >&4
11479         else
11480                 val="$undef"
11481                 if $h_sysfile; then
11482         echo "We don't need to include <fcntl.h> if we include <sys/file.h>." >&4
11483                 else
11484                         echo "We won't be including <fcntl.h>." >&4
11485                 fi
11486         fi
11487         ;;
11488 *)
11489         h_fcntl=false
11490         val="$undef"
11491         ;;
11492 esac
11493 set i_fcntl
11494 eval $setvar
11495
11496 : see if locale.h is available
11497 set locale.h i_locale
11498 eval $inhdr
11499
11500 : see if mach cthreads are available
11501 if test "X$usethreads" = "X$define"; then
11502         set mach/cthreads.h i_machcthr
11503         eval $inhdr
11504 else
11505         i_machcthr="$undef"
11506 fi
11507
11508
11509
11510 : see if this is a math.h system
11511 set math.h i_math
11512 eval $inhdr
11513
11514 : see if ndbm.h is available
11515 set ndbm.h t_ndbm
11516 eval $inhdr
11517 case "$t_ndbm" in
11518 $define)
11519         : see if dbm_open exists
11520         set dbm_open d_dbm_open
11521         eval $inlibc
11522         case "$d_dbm_open" in
11523         $undef)
11524                 t_ndbm="$undef"
11525                 echo "We won't be including <ndbm.h>"
11526                 ;;
11527         esac
11528         ;;
11529 esac
11530 val="$t_ndbm"
11531 set i_ndbm
11532 eval $setvar
11533
11534 : see if net/errno.h is available
11535 val=''
11536 set net/errno.h val
11537 eval $inhdr
11538
11539 : Unfortunately, it causes problems on some systems.  Arrgh.
11540 case "$val" in
11541 $define)
11542         cat > try.c <<'EOM'
11543 #include <stdio.h>
11544 #include <errno.h>
11545 #include <net/errno.h>
11546 int func()
11547 {
11548         return ENOTSOCK;
11549 }
11550 EOM
11551         if $cc $ccflags -c try.c >/dev/null 2>&1; then
11552                 echo "We'll be including <net/errno.h>." >&4
11553         else
11554                 echo "We won't be including <net/errno.h>." >&4
11555                 val="$undef"
11556         fi
11557         $rm -f try.* try
11558         ;;
11559 esac
11560 set i_neterrno
11561 eval $setvar
11562
11563 : get C preprocessor symbols handy
11564 echo " "
11565 $echo $n "Hmm... $c"
11566 echo $al | $tr ' ' $trnl >Cppsym.know
11567 $cat <<EOSS >Cppsym
11568 $startsh
11569 case "\$1" in
11570 -l) list=true
11571         shift
11572         ;;
11573 esac
11574 unknown=''
11575 case "\$list\$#" in
11576 1|2)
11577         for sym do
11578                 if $contains "^\$1$" Cppsym.true >/dev/null 2>&1; then
11579                         exit 0
11580                 elif $contains "^\$1$" Cppsym.know >/dev/null 2>&1; then
11581                         :
11582                 else
11583                         unknown="\$unknown \$sym"
11584                 fi
11585         done
11586         set X \$unknown
11587         shift
11588         ;;
11589 esac
11590 case \$# in
11591 0) exit 1;;
11592 esac
11593 echo \$* | $tr ' ' '$trnl' | $sed -e 's/\(.*\)/\\
11594 #ifdef \1\\
11595 exit 0; _ _ _ _\1\\      \1\\
11596 #endif\\
11597 /' >Cppsym\$\$
11598 echo "exit 1; _ _ _" >>Cppsym\$\$
11599 $cppstdin $cppminus <Cppsym\$\$ | $grep '^exit [01]; _ _'  >Cppsym2\$\$
11600 case "\$list" in
11601 true) $awk 'NF > 5 {print substr(\$6,2,100)}' <Cppsym2\$\$ ;;
11602 *)
11603         sh Cppsym2\$\$
11604         status=\$?
11605         ;;
11606 esac
11607 $rm -f Cppsym\$\$ Cppsym2\$\$
11608 exit \$status
11609 EOSS
11610 chmod +x Cppsym
11611 $eunicefix Cppsym
11612 ./Cppsym -l $al | $sort | $grep -v '^$' >Cppsym.true
11613
11614 : now check the C compiler for additional symbols
11615 $cat >ccsym <<EOS
11616 $startsh
11617 $cat >tmp.c <<EOF
11618 extern int foo;
11619 EOF
11620 for i in \`$cc -v -c tmp.c 2>&1\`
11621 do
11622         case "\$i" in
11623         -D*) echo "\$i" | $sed 's/^-D//';;
11624         -A*) $test "$gccversion" && echo "\$i" | $sed 's/^-A\(.*\)(\(.*\))/\1=\2/';;
11625         esac
11626 done
11627 $rm -f try.c
11628 EOS
11629 chmod +x ccsym
11630 $eunicefix ccsym
11631 ./ccsym > ccsym1.raw
11632 if $test -s ccsym1.raw; then
11633        $sort ccsym1.raw | $uniq >ccsym.raw
11634 else
11635        mv ccsym1.raw ccsym.raw
11636 fi
11637
11638 $awk '/\=/ { print $0; next }
11639         { print $0"=1" }' ccsym.raw >ccsym.list
11640 $awk '{ print $0"=1" }' Cppsym.true >ccsym.true
11641 $comm -13 ccsym.true ccsym.list >ccsym.own
11642 $comm -12 ccsym.true ccsym.list >ccsym.com
11643 $comm -23 ccsym.true ccsym.list >ccsym.cpp
11644 also=''
11645 symbols='symbols'
11646 if $test -z ccsym.raw; then
11647         echo "Your C compiler doesn't seem to define any symbol!" >&4
11648         echo " "
11649         echo "However, your C preprocessor defines the following ones:"
11650         $cat Cppsym.true
11651 else
11652         if $test -s ccsym.com; then
11653                 echo "Your C compiler and pre-processor define these symbols:"
11654                 $sed -e 's/\(.*\)=.*/\1/' ccsym.com
11655                 also='also '
11656                 symbols='ones'
11657                 $test "$silent" || sleep 1
11658         fi
11659         if $test -s ccsym.cpp; then
11660                 $test "$also" && echo " "
11661                 echo "Your C pre-processor ${also}defines the following $symbols:"
11662                 $sed -e 's/\(.*\)=.*/\1/' ccsym.cpp
11663                 also='further '
11664                 $test "$silent" || sleep 1
11665         fi
11666         if $test -s ccsym.own; then
11667                 $test "$also" && echo " "
11668                 echo "Your C compiler ${also}defines the following cpp variables:"
11669                 $sed -e 's/\(.*\)=1/\1/' ccsym.own
11670                 $sed -e 's/\(.*\)=.*/\1/' ccsym.own | $uniq >>Cppsym.true
11671                 $test "$silent" || sleep 1
11672         fi
11673 fi
11674 $rm -f ccsym*
11675
11676 : see if this is a termio system
11677 val="$undef"
11678 val2="$undef"
11679 val3="$undef"
11680 if $test `./findhdr termios.h`; then
11681         set tcsetattr i_termios
11682         eval $inlibc
11683         val3="$i_termios"
11684 fi
11685 echo " "
11686 case "$val3" in
11687 "$define") echo "You have POSIX termios.h... good!" >&4;;
11688 *) if ./Cppsym pyr; then
11689                 case "`/bin/universe`" in
11690                 ucb) if $test `./findhdr sgtty.h`; then
11691                                 val2="$define"
11692                                 echo "<sgtty.h> found." >&4
11693                         else
11694                                 echo "System is pyramid with BSD universe."
11695                                 echo "<sgtty.h> not found--you could have problems." >&4
11696                         fi;;
11697                 *) if $test `./findhdr termio.h`; then
11698                                 val="$define"
11699                                 echo "<termio.h> found." >&4
11700                         else
11701                                 echo "System is pyramid with USG universe."
11702                                 echo "<termio.h> not found--you could have problems." >&4
11703                         fi;;
11704                 esac
11705         elif ./usg; then
11706                 if $test `./findhdr termio.h`; then
11707                         echo "<termio.h> found." >&4
11708                         val="$define"
11709                 elif $test `./findhdr sgtty.h`; then
11710                         echo "<sgtty.h> found." >&4
11711                         val2="$define"
11712                 else
11713 echo "Neither <termio.h> nor <sgtty.h> found--you could have problems." >&4
11714                 fi
11715         else
11716                 if $test `./findhdr sgtty.h`; then
11717                         echo "<sgtty.h> found." >&4
11718                         val2="$define"
11719                 elif $test `./findhdr termio.h`; then
11720                         echo "<termio.h> found." >&4
11721                         val="$define"
11722                 else
11723 echo "Neither <sgtty.h> nor <termio.h> found--you could have problems." >&4
11724                 fi
11725         fi;;
11726 esac
11727 set i_termio; eval $setvar
11728 val=$val2; set i_sgtty; eval $setvar
11729 val=$val3; set i_termios; eval $setvar
11730
11731 : see if stdarg is available
11732 echo " "
11733 if $test `./findhdr stdarg.h`; then
11734         echo "<stdarg.h> found." >&4
11735         valstd="$define"
11736 else
11737         echo "<stdarg.h> NOT found." >&4
11738         valstd="$undef"
11739 fi
11740
11741 : see if varags is available
11742 echo " "
11743 if $test `./findhdr varargs.h`; then
11744         echo "<varargs.h> found." >&4
11745 else
11746         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
11747 fi
11748
11749 : set up the varargs testing programs
11750 $cat > varargs.c <<EOP
11751 #ifdef I_STDARG
11752 #include <stdarg.h>
11753 #endif
11754 #ifdef I_VARARGS
11755 #include <varargs.h>
11756 #endif
11757
11758 #ifdef I_STDARG
11759 int f(char *p, ...)
11760 #else
11761 int f(va_alist)
11762 va_dcl
11763 #endif
11764 {
11765         va_list ap;
11766 #ifndef I_STDARG
11767         char *p;
11768 #endif
11769 #ifdef I_STDARG
11770         va_start(ap,p);
11771 #else
11772         va_start(ap);
11773         p = va_arg(ap, char *);
11774 #endif
11775         va_end(ap);
11776 }
11777 EOP
11778 $cat > varargs <<EOP
11779 $startsh
11780 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
11781         echo "true"
11782 else
11783         echo "false"
11784 fi
11785 $rm -f varargs$_o
11786 EOP
11787 chmod +x varargs
11788
11789 : now check which varargs header should be included
11790 echo " "
11791 i_varhdr=''
11792 case "$valstd" in
11793 "$define")
11794         if `./varargs I_STDARG`; then
11795                 val='stdarg.h'
11796         elif `./varargs I_VARARGS`; then
11797                 val='varargs.h'
11798         fi
11799         ;;
11800 *)
11801         if `./varargs I_VARARGS`; then
11802                 val='varargs.h'
11803         fi
11804         ;;
11805 esac
11806 case "$val" in
11807 '')
11808 echo "I could not find the definition for va_dcl... You have problems..." >&4
11809         val="$undef"; set i_stdarg; eval $setvar
11810         val="$undef"; set i_varargs; eval $setvar
11811         ;;
11812 *) 
11813         set i_varhdr
11814         eval $setvar
11815         case "$i_varhdr" in
11816         stdarg.h)
11817                 val="$define"; set i_stdarg; eval $setvar
11818                 val="$undef"; set i_varargs; eval $setvar
11819                 ;;
11820         varargs.h)
11821                 val="$undef"; set i_stdarg; eval $setvar
11822                 val="$define"; set i_varargs; eval $setvar
11823                 ;;
11824         esac
11825         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
11826 esac
11827 $rm -f varargs*
11828
11829 : see if stddef is available
11830 set stddef.h i_stddef
11831 eval $inhdr
11832
11833 : see if sys/access.h is available
11834 set sys/access.h i_sysaccess
11835 eval $inhdr
11836
11837 : see if ioctl defs are in sgtty, termio, sys/filio or sys/ioctl
11838 set sys/filio.h i_sysfilio
11839 eval $inhdr
11840 echo " "
11841 if $test `./findhdr sys/ioctl.h`; then
11842         val="$define"
11843         echo '<sys/ioctl.h> found.' >&4
11844 else
11845         val="$undef"
11846         if $test $i_sysfilio = "$define"; then
11847             echo '<sys/ioctl.h> NOT found.' >&4
11848         else
11849                 $test $i_sgtty = "$define" && xxx="sgtty.h"
11850                 $test $i_termio = "$define" && xxx="termio.h"
11851                 $test $i_termios = "$define" && xxx="termios.h"
11852 echo "No <sys/ioctl.h> found, assuming ioctl args are defined in <$xxx>." >&4
11853         fi
11854 fi
11855 set i_sysioctl
11856 eval $setvar
11857
11858 : see if this is a sys/param system
11859 set sys/param.h i_sysparam
11860 eval $inhdr
11861
11862 : see if sys/resource.h has to be included
11863 set sys/resource.h i_sysresrc
11864 eval $inhdr
11865
11866 : see if sys/security.h is available
11867 set sys/security.h i_syssecrt
11868 eval $inhdr
11869
11870 : see if this is a sys/un.h system
11871 set sys/un.h i_sysun
11872 eval $inhdr
11873
11874 : see if this is a syswait system
11875 set sys/wait.h i_syswait
11876 eval $inhdr
11877
11878 : see if this is an utime system
11879 set utime.h i_utime
11880 eval $inhdr
11881
11882 : see if this is a values.h system
11883 set values.h i_values
11884 eval $inhdr
11885
11886 : see if this is a vfork system
11887 case "$d_vfork" in
11888 "$define")
11889         set vfork.h i_vfork
11890         eval $inhdr
11891         ;;
11892 *)
11893         i_vfork="$undef"
11894         ;;
11895 esac
11896
11897 : see if gdbm.h is available
11898 set gdbm.h t_gdbm
11899 eval $inhdr
11900 case "$t_gdbm" in
11901 $define)
11902         : see if gdbm_open exists
11903         set gdbm_open d_gdbm_open
11904         eval $inlibc
11905         case "$d_gdbm_open" in
11906         $undef)
11907                 t_gdbm="$undef"
11908                 echo "We won't be including <gdbm.h>"
11909                 ;;
11910         esac
11911         ;;
11912 esac
11913 val="$t_gdbm"
11914 set i_gdbm
11915 eval $setvar
11916
11917 echo " "
11918 echo "Looking for extensions..." >&4
11919 tdir=`pwd`
11920 cd $rsrc/ext
11921 : If we are using the old config.sh, known_extensions may contain
11922 : old or inaccurate or duplicate values.
11923 known_extensions=''
11924 nonxs_extensions=''
11925 : We do not use find because it might not be available.
11926 : We do not just use MANIFEST because the user may have dropped
11927 : some additional extensions into the source tree and expect them
11928 : to be built.
11929 for xxx in * ; do
11930         case "$xxx" in
11931         DynaLoader|dynaload) ;;
11932         *)      if $test -f $xxx/$xxx.xs; then
11933                         known_extensions="$known_extensions $xxx"
11934                 elif $test -f $xxx/Makefile.PL; then
11935                         nonxs_extensions="$nonxs_extensions $xxx"
11936                 else
11937                         if $test -d $xxx; then
11938                                 # Look for nested extensions, eg. Devel/Dprof.
11939                                 cd $xxx
11940                                 for yyy in * ; do
11941                                 if $test -f $yyy/$yyy.xs; then
11942                                         known_extensions="$known_extensions $xxx/$yyy"
11943                                 elif $test -f $yyy/Makefile.PL; then
11944                                         nonxs_extensions="$nonxs_extensions $xxx/$yyy"
11945                                 fi
11946                                 done
11947                                 cd ..
11948                         fi
11949                 fi 
11950                 ;;
11951         esac
11952 done
11953 set X $nonxs_extensions
11954 shift
11955 nonxs_extensions="$*"
11956 set X $known_extensions
11957 shift
11958 known_extensions="$*"
11959 cd $tdir
11960
11961 : Now see which are supported on this system.
11962 avail_ext=''
11963 for xxx in $known_extensions ; do
11964         case "$xxx" in
11965         DB_File|db_file)
11966                 case "$i_db" in
11967                 $define) avail_ext="$avail_ext $xxx" ;;
11968                 esac
11969                 ;;
11970         GDBM_File|gdbm_fil)
11971                 case "$i_gdbm" in 
11972                 $define) avail_ext="$avail_ext $xxx" ;;
11973                 esac
11974                 ;;
11975         NDBM_File|ndbm_fil)
11976                 case "$i_ndbm" in
11977                 $define) avail_ext="$avail_ext $xxx" ;;
11978                 esac
11979                 ;;
11980         ODBM_File|odbm_fil) 
11981                 case "${i_dbm}${i_rpcsvcdbm}" in
11982                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
11983                 esac
11984                 ;;
11985         POSIX|posix)
11986                 case "$useposix" in
11987                 true|define|y) avail_ext="$avail_ext $xxx" ;;
11988                 esac
11989                 ;;
11990         Opcode|opcode)
11991                 case "$useopcode" in
11992                 true|define|y) avail_ext="$avail_ext $xxx" ;;
11993                 esac
11994                 ;;
11995         Socket|socket)
11996                 case "$d_socket" in 
11997                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
11998                 esac
11999                 ;;
12000         Thread|thread)
12001                 case "$usethreads" in 
12002                 true|$define|y) avail_ext="$avail_ext $xxx" ;;
12003                 esac
12004                 ;;
12005         IPC/SysV|ipc/sysv)
12006                 : XXX Do we need a useipcsysv variable here
12007                 case "${d_msg}${d_sem}${d_shm}" in 
12008                 *"${define}"*) avail_ext="$avail_ext $xxx" ;;
12009                 esac
12010                 ;;
12011         *)      avail_ext="$avail_ext $xxx"
12012                 ;;
12013         esac
12014 done
12015
12016 set X $avail_ext
12017 shift
12018 avail_ext="$*"
12019
12020 : Now see which nonxs extensions are supported on this system.
12021 : For now assume all are.
12022 nonxs_ext=''
12023 for xxx in $nonxs_extensions ; do
12024         case "$xxx" in
12025         *)      nonxs_ext="$nonxs_ext $xxx"
12026                 ;;
12027         esac
12028 done
12029
12030 set X $nonxs_ext
12031 shift
12032 nonxs_ext="$*"
12033
12034 case $usedl in
12035 $define)
12036         $cat <<EOM
12037 A number of extensions are supplied with $package.  You may choose to
12038 compile these extensions for dynamic loading (the default), compile
12039 them into the $package executable (static loading), or not include
12040 them at all.  Answer "none" to include no extensions.
12041 Note that DynaLoader is always built and need not be mentioned here.
12042
12043 EOM
12044         case "$dynamic_ext" in
12045         '') dflt="$avail_ext" ;;
12046         *)      dflt="$dynamic_ext"
12047                 # Perhaps we are reusing an old out-of-date config.sh.
12048                 case "$hint" in
12049                 previous)
12050                         if test X"$dynamic_ext" != X"$avail_ext"; then
12051                                 $cat <<EOM
12052 NOTICE:  Your previous config.sh list may be incorrect. 
12053 The extensions now available to you are 
12054         ${avail_ext}
12055 but the default list from your previous config.sh is
12056         ${dynamic_ext} 
12057
12058 EOM
12059                         fi
12060                         ;;
12061                 esac
12062                 ;;
12063         esac
12064         case "$dflt" in
12065         '')     dflt=none;;
12066         esac
12067         rp="What extensions do you wish to load dynamically?"
12068         . ./myread
12069         case "$ans" in
12070         none) dynamic_ext=' ' ;;
12071         *) dynamic_ext="$ans" ;;
12072         esac
12073
12074         case "$static_ext" in
12075         '')
12076                 : Exclude those already listed in dynamic linking
12077                 dflt=''
12078                 for xxx in $avail_ext; do
12079                         case " $dynamic_ext " in
12080                         *" $xxx "*) ;;
12081                         *) dflt="$dflt $xxx" ;;
12082                         esac
12083                 done
12084                 set X $dflt
12085                 shift
12086                 dflt="$*"
12087                 ;;
12088         *)  dflt="$static_ext" 
12089                 ;;
12090         esac
12091
12092         case "$dflt" in
12093         '')     dflt=none;;
12094         esac
12095         rp="What extensions do you wish to load statically?"
12096         . ./myread
12097         case "$ans" in
12098         none) static_ext=' ' ;;
12099         *) static_ext="$ans" ;;
12100         esac
12101         ;;
12102 *)
12103         $cat <<EOM
12104 A number of extensions are supplied with $package.  Answer "none" 
12105 to include no extensions. 
12106 Note that DynaLoader is always built and need not be mentioned here.
12107
12108 EOM
12109         case "$static_ext" in
12110         '') dflt="$avail_ext" ;;
12111         *)      dflt="$static_ext"
12112                 # Perhaps we are reusing an old out-of-date config.sh.
12113                 case "$hint" in
12114                 previous)
12115                         if test X"$static_ext" != X"$avail_ext"; then
12116                                 $cat <<EOM
12117 NOTICE:  Your previous config.sh list may be incorrect. 
12118 The extensions now available to you are 
12119         ${avail_ext}
12120 but the default list from your previous config.sh is
12121         ${static_ext} 
12122
12123 EOM
12124                         fi
12125                         ;;
12126                 esac
12127                 ;;
12128         esac
12129         : Exclude those that are not xs extensions
12130         case "$dflt" in
12131         '')     dflt=none;;
12132         esac
12133         rp="What extensions do you wish to include?"
12134         . ./myread
12135         case "$ans" in
12136         none) static_ext=' ' ;;
12137         *) static_ext="$ans" ;;
12138         esac
12139         ;;
12140 esac
12141
12142 set X $dynamic_ext $static_ext $nonxs_ext
12143 shift
12144 extensions="$*"
12145
12146 : Remove build directory name from cppstdin so it can be used from
12147 : either the present location or the final installed location.
12148 echo " "
12149 : Get out of the UU directory to get correct path name.
12150 cd ..
12151 case "$cppstdin" in
12152 `pwd`/cppstdin)
12153         echo "Stripping down cppstdin path name"
12154         cppstdin=cppstdin
12155         ;;
12156 esac
12157 cd UU
12158
12159 : end of configuration questions
12160 echo " "
12161 echo "End of configuration questions."
12162 echo " "
12163
12164 : back to where it started
12165 if test -d ../UU; then
12166         cd ..
12167 fi
12168
12169 : configuration may be patched via a 'config.over' file
12170 if $test -f config.over; then
12171         echo " "
12172         dflt=y
12173         rp='I see a config.over file.  Do you wish to load it?'
12174         . UU/myread
12175         case "$ans" in
12176         n*) echo "OK, I'll ignore it.";;
12177         *)      . ./config.over
12178                 echo "Configuration override changes have been loaded."
12179                 ;;
12180         esac
12181 fi
12182
12183 : in case they want portability, strip down executable paths
12184 case "$d_portable" in
12185 "$define")
12186         echo " "
12187         echo "Stripping down executable paths..." >&4
12188         for file in $loclist $trylist; do
12189                 if test X$file != Xln -a X$file != Xar -o X$osname != Xos2; then
12190                         eval $file="\$file"
12191                 fi
12192         done
12193         ;;
12194 esac
12195
12196 : create config.sh file
12197 echo " "
12198 echo "Creating config.sh..." >&4
12199 $spitshell <<EOT >config.sh
12200 $startsh
12201 #
12202 # This file was produced by running the Configure script. It holds all the
12203 # definitions figured out by Configure. Should you modify one of these values,
12204 # do not forget to propagate your changes by running "Configure -der". You may
12205 # instead choose to run each of the .SH files by yourself, or "Configure -S".
12206 #
12207
12208 # Package name      : $package
12209 # Source directory  : $src
12210 # Configuration time: $cf_time
12211 # Configured by     : $cf_by
12212 # Target system     : $myuname
12213
12214 Author='$Author'
12215 Date='$Date'
12216 Header='$Header'
12217 Id='$Id'
12218 Locker='$Locker'
12219 Log='$Log'
12220 Mcc='$Mcc'
12221 RCSfile='$RCSfile'
12222 Revision='$Revision'
12223 Source='$Source'
12224 State='$State'
12225 _a='$_a'
12226 _exe='$_exe'
12227 _o='$_o'
12228 afs='$afs'
12229 alignbytes='$alignbytes'
12230 ansi2knr='$ansi2knr'
12231 aphostname='$aphostname'
12232 apiversion='$apiversion'
12233 ar='$ar'
12234 archlib='$archlib'
12235 archlibexp='$archlibexp'
12236 archname64='$archname64'
12237 archname='$archname'
12238 archobjs='$archobjs'
12239 awk='$awk'
12240 baserev='$baserev'
12241 bash='$bash'
12242 bin='$bin'
12243 binexp='$binexp'
12244 bison='$bison'
12245 byacc='$byacc'
12246 byteorder='$byteorder'
12247 c='$c'
12248 castflags='$castflags'
12249 cat='$cat'
12250 cc='$cc'
12251 cccdlflags='$cccdlflags'
12252 ccdlflags='$ccdlflags'
12253 ccflags='$ccflags'
12254 cf_by='$cf_by'
12255 cf_email='$cf_email'
12256 cf_time='$cf_time'
12257 chgrp='$chgrp'
12258 chmod='$chmod'
12259 chown='$chown'
12260 clocktype='$clocktype'
12261 comm='$comm'
12262 compress='$compress'
12263 contains='$contains'
12264 cp='$cp'
12265 cpio='$cpio'
12266 cpp='$cpp'
12267 cpp_stuff='$cpp_stuff'
12268 cppflags='$cppflags'
12269 cpplast='$cpplast'
12270 cppminus='$cppminus'
12271 cpprun='$cpprun'
12272 cppstdin='$cppstdin'
12273 cryptlib='$cryptlib'
12274 csh='$csh'
12275 d_Gconvert='$d_Gconvert'
12276 d_access='$d_access'
12277 d_accessx='$d_accessx'
12278 d_alarm='$d_alarm'
12279 d_archlib='$d_archlib'
12280 d_attribut='$d_attribut'
12281 d_bcmp='$d_bcmp'
12282 d_bcopy='$d_bcopy'
12283 d_bsd='$d_bsd'
12284 d_bsdgetpgrp='$d_bsdgetpgrp'
12285 d_bsdsetpgrp='$d_bsdsetpgrp'
12286 d_bzero='$d_bzero'
12287 d_casti32='$d_casti32'
12288 d_castneg='$d_castneg'
12289 d_charvspr='$d_charvspr'
12290 d_chown='$d_chown'
12291 d_chroot='$d_chroot'
12292 d_chsize='$d_chsize'
12293 d_closedir='$d_closedir'
12294 d_const='$d_const'
12295 d_crypt='$d_crypt'
12296 d_csh='$d_csh'
12297 d_cuserid='$d_cuserid'
12298 d_dbl_dig='$d_dbl_dig'
12299 d_dbmclose64='$d_dbmclose64'
12300 d_dbminit64='$d_dbminit64'
12301 d_delete64='$d_delete64'
12302 d_difftime='$d_difftime'
12303 d_dirent64s='$d_dirent64s'
12304 d_dirnamlen='$d_dirnamlen'
12305 d_dlerror='$d_dlerror'
12306 d_dlopen='$d_dlopen'
12307 d_dlsymun='$d_dlsymun'
12308 d_dosuid='$d_dosuid'
12309 d_drand48proto='$d_drand48proto'
12310 d_dup2='$d_dup2'
12311 d_eaccess='$d_eaccess'
12312 d_endgrent='$d_endgrent'
12313 d_endhent='$d_endhent'
12314 d_endnent='$d_endnent'
12315 d_endpent='$d_endpent'
12316 d_endpwent='$d_endpwent'
12317 d_endsent='$d_endsent'
12318 d_eofnblk='$d_eofnblk'
12319 d_eunice='$d_eunice'
12320 d_fchmod='$d_fchmod'
12321 d_fchown='$d_fchown'
12322 d_fcntl='$d_fcntl'
12323 d_fd_macros='$d_fd_macros'
12324 d_fd_set='$d_fd_set'
12325 d_fds_bits='$d_fds_bits'
12326 d_fetch64='$d_fetch64'
12327 d_fgetpos64='$d_fgetpos64'
12328 d_fgetpos='$d_fgetpos'
12329 d_firstkey64='$d_firstkey64'
12330 d_flexfnam='$d_flexfnam'
12331 d_flock64s='$d_flock64s'
12332 d_flock='$d_flock'
12333 d_fopen64='$d_fopen64'
12334 d_fork='$d_fork'
12335 d_fpathconf='$d_fpathconf'
12336 d_freopen64='$d_freopen64'
12337 d_fseek64='$d_fseek64'
12338 d_fseeko64='$d_fseeko64'
12339 d_fseeko='$d_fseeko'
12340 d_fsetpos64='$d_fsetpos64'
12341 d_fsetpos='$d_fsetpos'
12342 d_fstat64='$d_fstat64'
12343 d_ftell64='$d_ftell64'
12344 d_ftello64='$d_ftello64'
12345 d_ftello='$d_ftello'
12346 d_ftime='$d_ftime'
12347 d_ftruncate64='$d_ftruncate64'
12348 d_getgrent='$d_getgrent'
12349 d_getgrps='$d_getgrps'
12350 d_gethbyaddr='$d_gethbyaddr'
12351 d_gethbyname='$d_gethbyname'
12352 d_gethent='$d_gethent'
12353 d_gethname='$d_gethname'
12354 d_gethostprotos='$d_gethostprotos'
12355 d_getlogin='$d_getlogin'
12356 d_getnbyaddr='$d_getnbyaddr'
12357 d_getnbyname='$d_getnbyname'
12358 d_getnent='$d_getnent'
12359 d_getnetprotos='$d_getnetprotos'
12360 d_getpbyname='$d_getpbyname'
12361 d_getpbynumber='$d_getpbynumber'
12362 d_getpent='$d_getpent'
12363 d_getpgid='$d_getpgid'
12364 d_getpgrp2='$d_getpgrp2'
12365 d_getpgrp='$d_getpgrp'
12366 d_getppid='$d_getppid'
12367 d_getprior='$d_getprior'
12368 d_getprotoprotos='$d_getprotoprotos'
12369 d_getpwent='$d_getpwent'
12370 d_getsbyname='$d_getsbyname'
12371 d_getsbyport='$d_getsbyport'
12372 d_getsent='$d_getsent'
12373 d_getservprotos='$d_getservprotos'
12374 d_gettimeod='$d_gettimeod'
12375 d_gnulibc='$d_gnulibc'
12376 d_grpasswd='$d_grpasswd'
12377 d_htonl='$d_htonl'
12378 d_index='$d_index'
12379 d_inetaton='$d_inetaton'
12380 d_ino64t='$d_ino64t'
12381 d_int64t='$d_int64t'
12382 d_isascii='$d_isascii'
12383 d_killpg='$d_killpg'
12384 d_lchown='$d_lchown'
12385 d_link='$d_link'
12386 d_locconv='$d_locconv'
12387 d_lockf64='$d_lockf64'
12388 d_lockf='$d_lockf'
12389 d_longdbl='$d_longdbl'
12390 d_longlong='$d_longlong'
12391 d_lseek64='$d_lseek64'
12392 d_lstat64='$d_lstat64'
12393 d_lstat='$d_lstat'
12394 d_mblen='$d_mblen'
12395 d_mbstowcs='$d_mbstowcs'
12396 d_mbtowc='$d_mbtowc'
12397 d_memcmp='$d_memcmp'
12398 d_memcpy='$d_memcpy'
12399 d_memmove='$d_memmove'
12400 d_memset='$d_memset'
12401 d_mkdir='$d_mkdir'
12402 d_mkfifo='$d_mkfifo'
12403 d_mktime='$d_mktime'
12404 d_msg='$d_msg'
12405 d_msgctl='$d_msgctl'
12406 d_msgget='$d_msgget'
12407 d_msgrcv='$d_msgrcv'
12408 d_msgsnd='$d_msgsnd'
12409 d_mymalloc='$d_mymalloc'
12410 d_nextkey64='$d_nextkey64'
12411 d_nice='$d_nice'
12412 d_off64t='$d_off64t'
12413 d_oldpthreads='$d_oldpthreads'
12414 d_oldsock='$d_oldsock'
12415 d_open3='$d_open3'
12416 d_open64='$d_open64'
12417 d_opendir64='$d_opendir64'
12418 d_pathconf='$d_pathconf'
12419 d_pause='$d_pause'
12420 d_phostname='$d_phostname'
12421 d_pipe='$d_pipe'
12422 d_poll='$d_poll'
12423 d_portable='$d_portable'
12424 d_pthread_create_joinable='$d_pthread_create_joinable'
12425 d_pthread_yield='$d_pthread_yield'
12426 d_pwage='$d_pwage'
12427 d_pwchange='$d_pwchange'
12428 d_pwclass='$d_pwclass'
12429 d_pwcomment='$d_pwcomment'
12430 d_pwexpire='$d_pwexpire'
12431 d_pwgecos='$d_pwgecos'
12432 d_pwpasswd='$d_pwpasswd'
12433 d_pwquota='$d_pwquota'
12434 d_readdir64='$d_readdir64'
12435 d_readdir='$d_readdir'
12436 d_readlink='$d_readlink'
12437 d_rename='$d_rename'
12438 d_rewinddir='$d_rewinddir'
12439 d_rmdir='$d_rmdir'
12440 d_safebcpy='$d_safebcpy'
12441 d_safemcpy='$d_safemcpy'
12442 d_sanemcmp='$d_sanemcmp'
12443 d_sched_yield='$d_sched_yield'
12444 d_seekdir64='$d_seekdir64'
12445 d_seekdir='$d_seekdir'
12446 d_select='$d_select'
12447 d_sem='$d_sem'
12448 d_semctl='$d_semctl'
12449 d_semctl_semid_ds='$d_semctl_semid_ds'
12450 d_semctl_semun='$d_semctl_semun'
12451 d_semget='$d_semget'
12452 d_semop='$d_semop'
12453 d_setegid='$d_setegid'
12454 d_seteuid='$d_seteuid'
12455 d_setgrent='$d_setgrent'
12456 d_setgrps='$d_setgrps'
12457 d_sethent='$d_sethent'
12458 d_setlinebuf='$d_setlinebuf'
12459 d_setlocale='$d_setlocale'
12460 d_setnent='$d_setnent'
12461 d_setpent='$d_setpent'
12462 d_setpgid='$d_setpgid'
12463 d_setpgrp2='$d_setpgrp2'
12464 d_setpgrp='$d_setpgrp'
12465 d_setprior='$d_setprior'
12466 d_setpwent='$d_setpwent'
12467 d_setregid='$d_setregid'
12468 d_setresgid='$d_setresgid'
12469 d_setresuid='$d_setresuid'
12470 d_setreuid='$d_setreuid'
12471 d_setrgid='$d_setrgid'
12472 d_setruid='$d_setruid'
12473 d_setsent='$d_setsent'
12474 d_setsid='$d_setsid'
12475 d_setvbuf='$d_setvbuf'
12476 d_sfio='$d_sfio'
12477 d_shm='$d_shm'
12478 d_shmat='$d_shmat'
12479 d_shmatprototype='$d_shmatprototype'
12480 d_shmctl='$d_shmctl'
12481 d_shmdt='$d_shmdt'
12482 d_shmget='$d_shmget'
12483 d_sigaction='$d_sigaction'
12484 d_sigsetjmp='$d_sigsetjmp'
12485 d_socket='$d_socket'
12486 d_sockpair='$d_sockpair'
12487 d_stat64='$d_stat64'
12488 d_statblks='$d_statblks'
12489 d_stdio_cnt_lval='$d_stdio_cnt_lval'
12490 d_stdio_ptr_lval='$d_stdio_ptr_lval'
12491 d_stdiobase='$d_stdiobase'
12492 d_stdstdio='$d_stdstdio'
12493 d_store64='$d_store64'
12494 d_strchr='$d_strchr'
12495 d_strcoll='$d_strcoll'
12496 d_strctcpy='$d_strctcpy'
12497 d_strerrm='$d_strerrm'
12498 d_strerror='$d_strerror'
12499 d_strtod='$d_strtod'
12500 d_strtol='$d_strtol'
12501 d_strtoul='$d_strtoul'
12502 d_strxfrm='$d_strxfrm'
12503 d_suidsafe='$d_suidsafe'
12504 d_symlink='$d_symlink'
12505 d_syscall='$d_syscall'
12506 d_sysconf='$d_sysconf'
12507 d_sysernlst='$d_sysernlst'
12508 d_syserrlst='$d_syserrlst'
12509 d_system='$d_system'
12510 d_tcgetpgrp='$d_tcgetpgrp'
12511 d_tcsetpgrp='$d_tcsetpgrp'
12512 d_telldir64='$d_telldir64'
12513 d_telldir='$d_telldir'
12514 d_time='$d_time'
12515 d_times='$d_times'
12516 d_tmpfile64='$d_tmpfile64'
12517 d_truncate64='$d_truncate64'
12518 d_truncate='$d_truncate'
12519 d_tzname='$d_tzname'
12520 d_umask='$d_umask'
12521 d_uname='$d_uname'
12522 d_union_semun='$d_union_semun'
12523 d_vfork='$d_vfork'
12524 d_void_closedir='$d_void_closedir'
12525 d_voidsig='$d_voidsig'
12526 d_voidtty='$d_voidtty'
12527 d_volatile='$d_volatile'
12528 d_vprintf='$d_vprintf'
12529 d_wait4='$d_wait4'
12530 d_waitpid='$d_waitpid'
12531 d_wcstombs='$d_wcstombs'
12532 d_wctomb='$d_wctomb'
12533 d_xenix='$d_xenix'
12534 date='$date'
12535 db_hashtype='$db_hashtype'
12536 db_prefixtype='$db_prefixtype'
12537 defvoidused='$defvoidused'
12538 direntrytype='$direntrytype'
12539 dlext='$dlext'
12540 dlsrc='$dlsrc'
12541 doublesize='$doublesize'
12542 drand01='$drand01'
12543 dynamic_ext='$dynamic_ext'
12544 eagain='$eagain'
12545 ebcdic='$ebcdic'
12546 echo='$echo'
12547 egrep='$egrep'
12548 emacs='$emacs'
12549 eunicefix='$eunicefix'
12550 exe_ext='$exe_ext'
12551 expr='$expr'
12552 extensions='$extensions'
12553 find='$find'
12554 firstmakefile='$firstmakefile'
12555 flex='$flex'
12556 fpostype='$fpostype'
12557 freetype='$freetype'
12558 full_csh='$full_csh'
12559 full_sed='$full_sed'
12560 gccversion='$gccversion'
12561 gidtype='$gidtype'
12562 glibpth='$glibpth'
12563 grep='$grep'
12564 groupcat='$groupcat'
12565 groupstype='$groupstype'
12566 gzip='$gzip'
12567 h_fcntl='$h_fcntl'
12568 h_sysfile='$h_sysfile'
12569 hint='$hint'
12570 hostcat='$hostcat'
12571 huge='$huge'
12572 i_arpainet='$i_arpainet'
12573 i_bsdioctl='$i_bsdioctl'
12574 i_db='$i_db'
12575 i_dbm='$i_dbm'
12576 i_dirent='$i_dirent'
12577 i_dld='$i_dld'
12578 i_dlfcn='$i_dlfcn'
12579 i_fcntl='$i_fcntl'
12580 i_float='$i_float'
12581 i_gdbm='$i_gdbm'
12582 i_grp='$i_grp'
12583 i_inttypes='$i_inttypes'
12584 i_limits='$i_limits'
12585 i_locale='$i_locale'
12586 i_machcthr='$i_machcthr'
12587 i_malloc='$i_malloc'
12588 i_math='$i_math'
12589 i_memory='$i_memory'
12590 i_ndbm='$i_ndbm'
12591 i_netdb='$i_netdb'
12592 i_neterrno='$i_neterrno'
12593 i_niin='$i_niin'
12594 i_pwd='$i_pwd'
12595 i_rpcsvcdbm='$i_rpcsvcdbm'
12596 i_sfio='$i_sfio'
12597 i_sgtty='$i_sgtty'
12598 i_stdarg='$i_stdarg'
12599 i_stddef='$i_stddef'
12600 i_stdlib='$i_stdlib'
12601 i_string='$i_string'
12602 i_sysaccess='$i_sysaccess'
12603 i_sysdir='$i_sysdir'
12604 i_sysfile='$i_sysfile'
12605 i_sysfilio='$i_sysfilio'
12606 i_sysin='$i_sysin'
12607 i_sysioctl='$i_sysioctl'
12608 i_sysndir='$i_sysndir'
12609 i_sysparam='$i_sysparam'
12610 i_sysresrc='$i_sysresrc'
12611 i_syssecrt='$i_syssecrt'
12612 i_sysselct='$i_sysselct'
12613 i_syssockio='$i_syssockio'
12614 i_sysstat='$i_sysstat'
12615 i_systime='$i_systime'
12616 i_systimek='$i_systimek'
12617 i_systimes='$i_systimes'
12618 i_systypes='$i_systypes'
12619 i_sysun='$i_sysun'
12620 i_syswait='$i_syswait'
12621 i_termio='$i_termio'
12622 i_termios='$i_termios'
12623 i_time='$i_time'
12624 i_unistd='$i_unistd'
12625 i_utime='$i_utime'
12626 i_values='$i_values'
12627 i_varargs='$i_varargs'
12628 i_varhdr='$i_varhdr'
12629 i_vfork='$i_vfork'
12630 ignore_versioned_solibs='$ignore_versioned_solibs'
12631 incpath='$incpath'
12632 inews='$inews'
12633 installarchlib='$installarchlib'
12634 installbin='$installbin'
12635 installman1dir='$installman1dir'
12636 installman3dir='$installman3dir'
12637 installprivlib='$installprivlib'
12638 installscript='$installscript'
12639 installsitearch='$installsitearch'
12640 installsitelib='$installsitelib'
12641 intsize='$intsize'
12642 known_extensions='$known_extensions'
12643 ksh='$ksh'
12644 large='$large'
12645 ld='$ld'
12646 lddlflags='$lddlflags'
12647 ldflags='$ldflags'
12648 less='$less'
12649 lib_ext='$lib_ext'
12650 libc='$libc'
12651 libperl='$libperl'
12652 libpth='$libpth'
12653 libs='$libs'
12654 libswanted='$libswanted'
12655 line='$line'
12656 lint='$lint'
12657 lkflags='$lkflags'
12658 ln='$ln'
12659 lns='$lns'
12660 locincpth='$locincpth'
12661 loclibpth='$loclibpth'
12662 longdblsize='$longdblsize'
12663 longlongsize='$longlongsize'
12664 longsize='$longsize'
12665 lp='$lp'
12666 lpr='$lpr'
12667 ls='$ls'
12668 lseeksize='$lseeksize'
12669 lseektype='$lseektype'
12670 mail='$mail'
12671 mailx='$mailx'
12672 make='$make'
12673 make_set_make='$make_set_make'
12674 mallocobj='$mallocobj'
12675 mallocsrc='$mallocsrc'
12676 malloctype='$malloctype'
12677 man1dir='$man1dir'
12678 man1direxp='$man1direxp'
12679 man1ext='$man1ext'
12680 man3dir='$man3dir'
12681 man3direxp='$man3direxp'
12682 man3ext='$man3ext'
12683 medium='$medium'
12684 mips='$mips'
12685 mips_type='$mips_type'
12686 mkdir='$mkdir'
12687 models='$models'
12688 modetype='$modetype'
12689 more='$more'
12690 mv='$mv'
12691 myarchname='$myarchname'
12692 mydomain='$mydomain'
12693 myhostname='$myhostname'
12694 myuname='$myuname'
12695 n='$n'
12696 netdb_hlen_type='$netdb_hlen_type'
12697 netdb_host_type='$netdb_host_type'
12698 netdb_name_type='$netdb_name_type'
12699 netdb_net_type='$netdb_net_type'
12700 nm='$nm'
12701 nm_opt='$nm_opt'
12702 nm_so_opt='$nm_so_opt'
12703 nonxs_ext='$nonxs_ext'
12704 nroff='$nroff'
12705 o_nonblock='$o_nonblock'
12706 obj_ext='$obj_ext'
12707 optimize='$optimize'
12708 orderlib='$orderlib'
12709 osname='$osname'
12710 osvers='$osvers'
12711 package='$package'
12712 pager='$pager'
12713 passcat='$passcat'
12714 patchlevel='$patchlevel'
12715 path_sep='$path_sep'
12716 perl='$perl'
12717 perladmin='$perladmin'
12718 perlpath='$perlpath'
12719 pg='$pg'
12720 phostname='$phostname'
12721 pidtype='$pidtype'
12722 plibpth='$plibpth'
12723 pmake='$pmake'
12724 pr='$pr'
12725 prefix='$prefix'
12726 prefixexp='$prefixexp'
12727 privlib='$privlib'
12728 privlibexp='$privlibexp'
12729 prototype='$prototype'
12730 pthread_create_joinable='$pthread_create_joinable'
12731 ptrsize='$ptrsize'
12732 randbits='$randbits'
12733 randfunc='$randfunc'
12734 randseedtype='$randseedtype'
12735 ranlib='$ranlib'
12736 rd_nodata='$rd_nodata'
12737 rm='$rm'
12738 rmail='$rmail'
12739 runnm='$runnm'
12740 sched_yield='$sched_yield'
12741 scriptdir='$scriptdir'
12742 scriptdirexp='$scriptdirexp'
12743 sed='$sed'
12744 seedfunc='$seedfunc'
12745 selectminbits='$selectminbits'
12746 selecttype='$selecttype'
12747 sendmail='$sendmail'
12748 sh='$sh'
12749 shar='$shar'
12750 sharpbang='$sharpbang'
12751 shmattype='$shmattype'
12752 shortsize='$shortsize'
12753 shrpenv='$shrpenv'
12754 shsharp='$shsharp'
12755 sig_name='$sig_name'
12756 sig_name_init='$sig_name_init'
12757 sig_num='$sig_num'
12758 sig_num_init='$sig_num_init'
12759 signal_t='$signal_t'
12760 sitearch='$sitearch'
12761 sitearchexp='$sitearchexp'
12762 sitelib='$sitelib'
12763 sitelibexp='$sitelibexp'
12764 sizetype='$sizetype'
12765 sleep='$sleep'
12766 smail='$smail'
12767 small='$small'
12768 so='$so'
12769 sockethdr='$sockethdr'
12770 socketlib='$socketlib'
12771 sort='$sort'
12772 spackage='$spackage'
12773 spitshell='$spitshell'
12774 split='$split'
12775 src='$src'
12776 ssizetype='$ssizetype'
12777 startperl='$startperl'
12778 startsh='$startsh'
12779 static_ext='$static_ext'
12780 stdchar='$stdchar'
12781 stdio_base='$stdio_base'
12782 stdio_bufsiz='$stdio_bufsiz'
12783 stdio_cnt='$stdio_cnt'
12784 stdio_filbuf='$stdio_filbuf'
12785 stdio_ptr='$stdio_ptr'
12786 strings='$strings'
12787 submit='$submit'
12788 subversion='$subversion'
12789 sysman='$sysman'
12790 tail='$tail'
12791 tar='$tar'
12792 tbl='$tbl'
12793 tee='$tee'
12794 test='$test'
12795 timeincl='$timeincl'
12796 timetype='$timetype'
12797 touch='$touch'
12798 tr='$tr'
12799 trnl='$trnl'
12800 troff='$troff'
12801 uidtype='$uidtype'
12802 uname='$uname'
12803 uniq='$uniq'
12804 use64bits='$use64bits'
12805 usedl='$usedl'
12806 usemultiplicity='$usemultiplicity'
12807 usemymalloc='$usemymalloc'
12808 usenm='$usenm'
12809 useopcode='$useopcode'
12810 useperlio='$useperlio'
12811 useposix='$useposix'
12812 usesfio='$usesfio'
12813 useshrplib='$useshrplib'
12814 usethreads='$usethreads'
12815 usevfork='$usevfork'
12816 usrinc='$usrinc'
12817 uuname='$uuname'
12818 version='$version'
12819 vi='$vi'
12820 voidflags='$voidflags'
12821 xlibpth='$xlibpth'
12822 zcat='$zcat'
12823 zip='$zip'
12824 EOT
12825
12826 : Add in command line options if available
12827 $test -f UU/cmdline.opt && $cat UU/cmdline.opt >> config.sh
12828
12829 : add special variables
12830 $test -f $src/patchlevel.h && \
12831 awk '/^#define/ {printf "%s=%s\n",$2,$3}' $src/patchlevel.h >>config.sh
12832 echo "CONFIG=true" >>config.sh
12833
12834 : propagate old symbols
12835 if $test -f UU/config.sh; then
12836         <UU/config.sh sort | uniq >UU/oldconfig.sh
12837         sed -n 's/^\([a-zA-Z_0-9]*\)=.*/\1/p' config.sh config.sh UU/oldconfig.sh |\
12838         sort | uniq -u >UU/oldsyms
12839         set X `cat UU/oldsyms`
12840         shift
12841         case $# in
12842         0) ;;
12843         *)
12844                 cat <<EOM
12845 Hmm...You had some extra variables I don't know about...I'll try to keep 'em...
12846 EOM
12847                 echo "# Variables propagated from previous config.sh file." >>config.sh
12848                 for sym in `cat UU/oldsyms`; do
12849                         echo "    Propagating $hint variable "'$'"$sym..."
12850                         eval 'tmp="$'"${sym}"'"'
12851                         echo "$tmp" | \
12852                                 sed -e "s/'/'\"'\"'/g" -e "s/^/$sym='/" -e "s/$/'/" >>config.sh
12853                 done
12854                 ;;
12855         esac
12856 fi
12857
12858 : Finish up by extracting the .SH files
12859 case "$alldone" in
12860 exit)
12861         $rm -rf UU
12862         echo "Done."
12863         exit 0
12864         ;;
12865 cont)
12866         ;;
12867 '')
12868         dflt=''
12869         nostick=true
12870         $cat <<EOM
12871
12872 If you'd like to make any changes to the config.sh file before I begin
12873 to configure things, do it as a shell escape now (e.g. !vi config.sh).
12874
12875 EOM
12876         rp="Press return or use a shell escape to edit config.sh:"
12877         . UU/myread
12878         nostick=''
12879         case "$ans" in
12880         '') ;;
12881         *) : in case they cannot read
12882                 sh 1>&4 -c "$ans";;
12883         esac
12884         ;;
12885 esac
12886
12887 : if this fails, just run all the .SH files by hand
12888 . ./config.sh
12889
12890 echo " "
12891 exec 1>&4
12892 . ./UU/extract
12893
12894 if $contains '^depend:' [Mm]akefile >/dev/null 2>&1; then
12895         dflt=y
12896         case "$silent" in
12897         true) ;;
12898         *)
12899                 $cat <<EOM
12900
12901 Now you need to generate make dependencies by running "$make depend".
12902 You might prefer to run it in background: "$make depend > makedepend.out &"
12903 It can take a while, so you might not want to run it right now.
12904
12905 EOM
12906                 ;;
12907         esac
12908         rp="Run $make depend now?"
12909         . UU/myread
12910         case "$ans" in
12911         y*)
12912                 $make depend && echo "Now you must run a $make."
12913                 ;;
12914         *)
12915                 echo "You must run '$make depend' then '$make'."
12916                 ;;
12917         esac
12918 elif test -f [Mm]akefile; then
12919         echo " "
12920         echo "Now you must run a $make."
12921 else
12922         echo "Done."
12923 fi
12924
12925 if $test -f Policy.sh; then
12926     $cat <<EOM
12927
12928 If you compile $package on a different machine or from a different object
12929 directory, copy the Policy.sh file from this object directory to the
12930 new one before you run Configure -- this will help you with most of
12931 the policy defaults.
12932
12933 EOM
12934 fi
12935 if $test -f config.msg; then
12936     echo "Hmm.  I also noted the following information while running:"
12937     echo " "
12938     $cat config.msg >&4
12939     $rm -f config.msg
12940 fi
12941 $rm -f kit*isdone ark*isdone
12942 $rm -rf UU
12943
12944 : End of Configure
12945