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