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