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