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