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