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