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