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