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