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