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