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