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