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