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