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