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