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