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