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