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