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