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