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