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