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