source: trunk/third/perl/Configure @ 10742

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