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