This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
df610b2b3497001e1c2f2cedeb2337533f629f2d
[perl5.git] / Configure
1 #! /bin/sh
2 #
3 # If these # comments don't work, trim them. Don't worry about any other
4 # shell scripts, Configure will trim # comments from them for you.
5 #
6 # (If you are trying to port this package to a machine without sh,
7 # I would suggest you have a look at the prototypical config_h.SH file
8 # and edit it to reflect your system. Some packages may include samples
9 # of config.h for certain machines, so you might look for one of those.)
10 #
11 # Yes, you may rip this off to use in other distribution packages. This
12 # script belongs to the public domain and cannot be copyrighted.
13 #
14 # (Note: this Configure script was generated automatically. Rather than
15 # working with this copy of Configure, you may wish to get metaconfig.
16 # The dist-3.0 package (which contains metaconfig) was posted in
17 # comp.sources.misc so you may fetch it yourself from your nearest
18 # archive site. Check with Archie if you don't know where that can be.)
19 #
20
21 # $Id: Head.U,v 3.0.1.8 1995/07/25 13:40:02 ram Exp $
22 #
23 # Generated on Sat Feb  1 00:26:40 EST 1997 [metaconfig 3.0 PL60]
24
25 cat >/tmp/c1$$ <<EOF
26 ARGGGHHHH!!!!!
27
28 SCO csh still thinks true is false.  Write to SCO today and tell them that next
29 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
30
31 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
32 we'd have to do is go in and swap the && and || tokens, wherever they are.)
33
34 [End of diatribe. We now return you to your regularly scheduled programming...]
35 EOF
36 cat >/tmp/c2$$ <<EOF
37
38 OOPS!  You naughty creature!  You didn't run Configure with sh!
39 I will attempt to remedy the situation by running sh for you...
40 EOF
41
42 true || cat /tmp/c1$$ /tmp/c2$$
43 true || exec sh $0 $argv:q
44
45 (exit $?0) || cat /tmp/c2$$
46 (exit $?0) || exec sh $0 $argv:q
47 rm -f /tmp/c1$$ /tmp/c2$$
48
49 : compute my invocation name
50 me=$0
51 case "$0" in
52 */*)
53         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
54         test "$me" || me=$0
55         ;;
56 esac
57
58 : Proper PATH separator
59 p_=:
60 : On OS/2 this directory should exist if this is not floppy only system :-]
61 if test -d c:/. -a -n "$OS2_SHELL"; then
62         p_=\;
63         PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
64         OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
65 fi
66 if test -d c:/. -a -n "$DJDIR"; then
67         p_=\;
68 fi
69
70 : Proper PATH setting
71 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
72 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
73 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
74 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
75 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
76 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /usr/ccs/bin"
77 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
78 paths="$paths /sbin /usr/sbin /usr/libexec"
79
80 for p in $paths
81 do
82         case "$p_$PATH$p_" in
83         *$p_$p$p_*) ;;
84         *) test -d $p && PATH=$PATH$p_$p ;;
85         esac
86 done
87
88 PATH=.$p_$PATH
89 export PATH
90
91 : This should not matter in scripts, but apparently it does, sometimes
92 case "$CDPATH" in
93 '')     ;;
94 *)      CDPATH='' ;;
95 esac
96
97 : Sanity checks
98 if test ! -t 0; then
99         echo "Say 'sh $me', not 'sh <$me'"
100         exit 1
101 fi
102
103 : Test and see if we are running under ksh, either blatantly or in disguise.
104 if (PATH=.; alias -x) >/dev/null 2>&1; then
105     : running under ksh.  Is this a good thing?
106     if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname ; then
107         if test X`/usr/bin/uname -v` = X4 ; then
108             : on AIX 4, /bin/sh is really ksh, and it causes us problems.
109             : Avoid it
110                 cat <<'EOM'
111 (Feeding myself to /usr/bin/bsh to avoid AIX 4's /bin/sh.)
112 EOM
113                 unset ENV
114             exec /usr/bin/bsh $0 "$@"
115         fi
116     else
117         if test ! -f /hp-ux ; then
118         : Warn them if they use ksh on other systems
119                 cat <<EOM
120 (I see you are using the Korn shell.  Some ksh's blow up on $me,
121 especially on older exotic systems.  If yours does, try the Bourne 
122 shell instead.)
123 EOM
124                 unset ENV
125         fi
126     fi
127 else
128     : Not running under ksh.  Maybe we should be?
129     : On HP-UX, large Configure scripts may exercise a bug in /bin/sh
130     if test -f /hp-ux -a -f /bin/ksh; then
131         cat <<'EOM'
132 (Feeding myself to ksh to avoid nasty sh bug in "here document" expansion.)
133 EOM
134         unset ENV
135         exec /bin/ksh $0 "$@"
136     fi
137 fi
138
139 : Configure runs within the UU subdirectory
140 test -d UU || mkdir UU
141 cd UU && rm -f ./*
142
143 dynamic_ext=''
144 extensions=''
145 known_extensions=''
146 static_ext=''
147 useopcode=''
148 useposix=''
149 d_bsd=''
150 d_eunice=''
151 d_xenix=''
152 eunicefix=''
153 Mcc=''
154 awk=''
155 bash=''
156 bison=''
157 byacc=''
158 cat=''
159 chgrp=''
160 chmod=''
161 chown=''
162 comm=''
163 compress=''
164 cp=''
165 cpio=''
166 cpp=''
167 csh=''
168 date=''
169 echo=''
170 egrep=''
171 emacs=''
172 expr=''
173 find=''
174 flex=''
175 gcc=''
176 grep=''
177 gzip=''
178 inews=''
179 ksh=''
180 less=''
181 line=''
182 lint=''
183 ln=''
184 lp=''
185 lpr=''
186 ls=''
187 mail=''
188 mailx=''
189 mkdir=''
190 more=''
191 mv=''
192 nroff=''
193 perl=''
194 pg=''
195 pmake=''
196 pr=''
197 rm=''
198 rmail=''
199 sed=''
200 sendmail=''
201 shar=''
202 sleep=''
203 smail=''
204 sort=''
205 submit=''
206 tail=''
207 tar=''
208 tbl=''
209 test=''
210 touch=''
211 tr=''
212 troff=''
213 uname=''
214 uniq=''
215 usethreads=''
216 uuname=''
217 vi=''
218 zcat=''
219 zip=''
220 full_sed=''
221 libswanted=''
222 hint=''
223 myuname=''
224 osname=''
225 osvers=''
226 Author=''
227 Date=''
228 Header=''
229 Id=''
230 Locker=''
231 Log=''
232 RCSfile=''
233 Revision=''
234 Source=''
235 State=''
236 ar=''
237 archobjs=''
238 exe_ext=''
239 firstmakefile=''
240 lib_ext=''
241 obj_ext=''
242 path_sep=''
243 afs=''
244 alignbytes=''
245 archlib=''
246 archlibexp=''
247 d_archlib=''
248 installarchlib=''
249 archname=''
250 myarchname=''
251 baserev=''
252 bin=''
253 binexp=''
254 installbin=''
255 bincompat3=''
256 d_bincompat3=''
257 byteorder=''
258 cc=''
259 gccversion=''
260 ccflags=''
261 cppflags=''
262 ldflags=''
263 lkflags=''
264 locincpth=''
265 optimize=''
266 cf_email=''
267 cf_by=''
268 cf_time=''
269 contains=''
270 cpp_stuff=''
271 cpplast=''
272 cppminus=''
273 cpprun=''
274 cppstdin=''
275 d_access=''
276 d_alarm=''
277 d_attribut=''
278 d_bcmp=''
279 d_bcopy=''
280 d_bzero=''
281 d_casti32=''
282 castflags=''
283 d_castneg=''
284 d_chown=''
285 d_chroot=''
286 d_chsize=''
287 d_closedir=''
288 d_void_closedir=''
289 d_const=''
290 cryptlib=''
291 d_crypt=''
292 d_csh=''
293 full_csh=''
294 d_cuserid=''
295 d_dbl_dig=''
296 d_difftime=''
297 d_dlerror=''
298 d_dlopen=''
299 d_dlsymun=''
300 d_dosuid=''
301 d_suidsafe=''
302 d_dup2=''
303 d_fchmod=''
304 d_fchown=''
305 d_fcntl=''
306 d_fd_macros=''
307 d_fd_set=''
308 d_fds_bits=''
309 d_fgetpos=''
310 d_flexfnam=''
311 d_flock=''
312 d_fork=''
313 d_fsetpos=''
314 d_ftime=''
315 d_gettimeod=''
316 d_Gconvert=''
317 d_getgrps=''
318 d_setgrps=''
319 d_gethent=''
320 d_gethbyaddr=''
321 netdb_host_type=''
322 netdb_hlen_type=''
323 d_gethbyname=''
324 netdb_name_type=''
325 d_getnbyaddr=''
326 d_getnbyname=''
327 netdb_net_type=''
328 aphostname=''
329 d_gethname=''
330 d_getpbyname=''
331 d_getpbynumber=''
332 d_getsbyname=''
333 d_getsbyport=''
334 d_phostname=''
335 d_uname=''
336 d_getlogin=''
337 d_getpgid=''
338 d_getpgrp2=''
339 d_bsdgetpgrp=''
340 d_getpgrp=''
341 d_getppid=''
342 d_getprior=''
343 d_gnulibc=''
344 d_htonl=''
345 d_inetaton=''
346 d_isascii=''
347 d_killpg=''
348 d_link=''
349 d_locconv=''
350 d_lockf=''
351 d_lstat=''
352 d_mblen=''
353 d_mbstowcs=''
354 d_mbtowc=''
355 d_memcmp=''
356 d_memcpy=''
357 d_memmove=''
358 d_memset=''
359 d_mkdir=''
360 d_mkfifo=''
361 d_mktime=''
362 d_msg=''
363 d_msgctl=''
364 d_msgget=''
365 d_msgrcv=''
366 d_msgsnd=''
367 d_nice=''
368 d_open3=''
369 d_fpathconf=''
370 d_pathconf=''
371 d_pause=''
372 d_pipe=''
373 d_poll=''
374 d_portable=''
375 d_readdir=''
376 d_rewinddir=''
377 d_seekdir=''
378 d_telldir=''
379 d_readlink=''
380 d_rename=''
381 d_rmdir=''
382 d_safebcpy=''
383 d_safemcpy=''
384 d_sanemcmp=''
385 d_select=''
386 d_sem=''
387 d_semctl=''
388 d_semget=''
389 d_semop=''
390 d_setegid=''
391 d_seteuid=''
392 d_setlinebuf=''
393 d_setlocale=''
394 d_setpgid=''
395 d_setpgrp2=''
396 d_bsdpgrp=''
397 d_bsdsetpgrp=''
398 d_setpgrp=''
399 d_setprior=''
400 d_setregid=''
401 d_setresgid=''
402 d_setresuid=''
403 d_setreuid=''
404 d_setrgid=''
405 d_setruid=''
406 d_setsid=''
407 d_sfio=''
408 usesfio=''
409 d_shm=''
410 d_shmat=''
411 d_shmatprototype=''
412 shmattype=''
413 d_shmctl=''
414 d_shmdt=''
415 d_shmget=''
416 d_sigaction=''
417 d_sigsetjmp=''
418 d_oldsock=''
419 d_socket=''
420 d_sockpair=''
421 sockethdr=''
422 socketlib=''
423 d_statblks=''
424 d_stdio_cnt_lval=''
425 d_stdio_ptr_lval=''
426 d_stdiobase=''
427 d_stdstdio=''
428 stdio_base=''
429 stdio_bufsiz=''
430 stdio_cnt=''
431 stdio_ptr=''
432 d_index=''
433 d_strchr=''
434 d_strcoll=''
435 d_strctcpy=''
436 d_strerrm=''
437 d_strerror=''
438 d_sysernlst=''
439 d_syserrlst=''
440 d_strtod=''
441 d_strtol=''
442 d_strtoul=''
443 d_strxfrm=''
444 d_symlink=''
445 d_syscall=''
446 d_sysconf=''
447 d_system=''
448 d_tcgetpgrp=''
449 d_tcsetpgrp=''
450 d_time=''
451 timetype=''
452 clocktype=''
453 d_times=''
454 d_truncate=''
455 d_tzname=''
456 d_umask=''
457 d_vfork=''
458 usevfork=''
459 d_voidsig=''
460 signal_t=''
461 d_volatile=''
462 d_charvspr=''
463 d_vprintf=''
464 d_wait4=''
465 d_waitpid=''
466 d_wcstombs=''
467 d_wctomb=''
468 dlext=''
469 cccdlflags=''
470 ccdlflags=''
471 dlsrc=''
472 ld=''
473 lddlflags=''
474 usedl=''
475 fpostype=''
476 gidtype=''
477 groupstype=''
478 d_sched_yield=''
479 d_pthread_yield=''
480 h_fcntl=''
481 h_sysfile=''
482 db_hashtype=''
483 db_prefixtype=''
484 i_db=''
485 i_dbm=''
486 i_rpcsvcdbm=''
487 d_dirnamlen=''
488 direntrytype=''
489 i_dirent=''
490 i_dld=''
491 i_dlfcn=''
492 i_fcntl=''
493 i_float=''
494 i_gdbm=''
495 i_grp=''
496 i_limits=''
497 i_locale=''
498 i_malloc=''
499 i_math=''
500 i_memory=''
501 i_ndbm=''
502 i_netdb=''
503 i_neterrno=''
504 i_niin=''
505 i_sysin=''
506 d_pthreads_created_joinable=''
507 d_pwage=''
508 d_pwchange=''
509 d_pwclass=''
510 d_pwcomment=''
511 d_pwexpire=''
512 d_pwquota=''
513 i_pwd=''
514 i_sfio=''
515 i_stddef=''
516 i_stdlib=''
517 i_string=''
518 strings=''
519 i_sysdir=''
520 i_sysfile=''
521 d_voidtty=''
522 i_bsdioctl=''
523 i_sysfilio=''
524 i_sysioctl=''
525 i_syssockio=''
526 i_sysndir=''
527 i_sysparam=''
528 i_sysresrc=''
529 i_sysselct=''
530 i_sysstat=''
531 i_systimes=''
532 i_systypes=''
533 i_sysun=''
534 i_syswait=''
535 i_sgtty=''
536 i_termio=''
537 i_termios=''
538 i_systime=''
539 i_systimek=''
540 i_time=''
541 timeincl=''
542 i_unistd=''
543 i_utime=''
544 i_values=''
545 i_stdarg=''
546 i_varargs=''
547 i_varhdr=''
548 i_vfork=''
549 intsize=''
550 longsize=''
551 shortsize=''
552 libc=''
553 libperl=''
554 shrpenv=''
555 useshrplib=''
556 glibpth=''
557 libpth=''
558 loclibpth=''
559 plibpth=''
560 xlibpth=''
561 libs=''
562 lns=''
563 lseektype=''
564 make=''
565 make_set_make=''
566 d_mymalloc=''
567 freetype=''
568 mallocobj=''
569 mallocsrc=''
570 malloctype=''
571 usemymalloc=''
572 installman1dir=''
573 man1dir=''
574 man1direxp=''
575 man1ext=''
576 installman3dir=''
577 man3dir=''
578 man3direxp=''
579 man3ext=''
580 huge=''
581 large=''
582 medium=''
583 models=''
584 small=''
585 split=''
586 modetype=''
587 mydomain=''
588 myhostname=''
589 phostname=''
590 c=''
591 n=''
592 d_eofnblk=''
593 eagain=''
594 o_nonblock=''
595 rd_nodata=''
596 groupcat=''
597 hostcat=''
598 passcat=''
599 d_oldarchlib=''
600 oldarchlib=''
601 oldarchlibexp=''
602 orderlib=''
603 ranlib=''
604 package=''
605 spackage=''
606 pager=''
607 patchlevel=''
608 subversion=''
609 perladmin=''
610 perlpath=''
611 prefix=''
612 prefixexp=''
613 installprivlib=''
614 privlib=''
615 privlibexp=''
616 prototype=''
617 randbits=''
618 installscript=''
619 scriptdir=''
620 scriptdirexp=''
621 selecttype=''
622 sh=''
623 sig_name=''
624 sig_num=''
625 installsitearch=''
626 sitearch=''
627 sitearchexp=''
628 installsitelib=''
629 sitelib=''
630 sitelibexp=''
631 sizetype=''
632 so=''
633 sharpbang=''
634 shsharp=''
635 spitshell=''
636 ssizetype=''
637 startperl=''
638 startsh=''
639 stdchar=''
640 sysman=''
641 uidtype=''
642 nm_opt=''
643 nm_so_opt=''
644 runnm=''
645 usenm=''
646 useperlio=''
647 incpath=''
648 mips=''
649 mips_type=''
650 usrinc=''
651 defvoidused=''
652 voidflags=''
653 CONFIG=''
654
655 define='define'
656 undef='undef'
657 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
658 rmlist=''
659
660 : We must find out about Eunice early
661 eunicefix=':'
662 if test -f /etc/unixtovms; then
663         eunicefix=/etc/unixtovms
664 fi
665 if test -f /etc/unixtovms.exe; then
666         eunicefix=/etc/unixtovms.exe
667 fi
668
669 : list of known cpp symbols, sorted alphabetically
670 al="AMIX BIT_MSF BSD BSD4_3 BSD_NET2 CMU CRAY DGUX DOLPHIN DPX2"
671 al="$al GO32 GOULD_PN HP700 I386 I80960 I960 Lynx M68000 M68K MACH"
672 al="$al MIPSEB MIPSEL MSDOS MTXINU MULTIMAX MVS"
673 al="$al M_COFF M_I186 M_I286 M_I386 M_I8086 M_I86 M_I86SM"
674 al="$al M_SYS3 M_SYS5 M_SYSIII M_SYSV M_UNIX M_XENIX"
675 al="$al NeXT OCS88 OSF1 PARISC PC532 PORTAR POSIX"
676 al="$al PWB R3000 RES RISC6000 RT Sun386i SVR3 SVR4"
677 al="$al SYSTYPE_BSD SYSTYPE_SVR4 SYSTYPE_SYSV Tek4132 Tek4300"
678 al="$al UMAXV USGr4 USGr4_2 UTEK UTS UTek UnicomPBB UnicomPBD Utek"
679 al="$al VMS Xenix286"
680 al="$al _AIX _AIX32 _AIX370 _AM29000 _COFF _CRAY _CX_UX _EPI"
681 al="$al _IBMESA _IBMR2 _M88K _M88KBCS_TARGET"
682 al="$al _MIPSEB _MIPSEL _M_COFF _M_I86 _M_I86SM _M_SYS3"
683 al="$al _M_SYS5 _M_SYSIII _M_SYSV _M_UNIX _M_XENIX _NLS _PGC_ _R3000"
684 al="$al _SYSTYPE_BSD _SYSTYPE_BSD43 _SYSTYPE_SVR4"
685 al="$al _SYSTYPE_SYSV _SYSV3 _U370 _UNICOS"
686 al="$al __386BSD__ __BIG_ENDIAN __BIG_ENDIAN__ __BSD_4_4__"
687 al="$al __DGUX__ __DPX2__ __H3050R __H3050RX"
688 al="$al __LITTLE_ENDIAN __LITTLE_ENDIAN__ __MACH__"
689 al="$al __MIPSEB __MIPSEB__ __MIPSEL __MIPSEL__"
690 al="$al __Next__ __OSF1__ __PARAGON__ __PGC__ __PWB __STDC__"
691 al="$al __SVR4_2__ __UMAXV__"
692 al="$al ____386BSD____ __alpha __alpha__ __amiga"
693 al="$al __bsd4_2 __bsd4_2__ __bsdi__ __convex__"
694 al="$al __host_mips__"
695 al="$al __hp9000s200 __hp9000s300 __hp9000s400 __hp9000s500"
696 al="$al __hp9000s500 __hp9000s700 __hp9000s800"
697 al="$al __hppa __hpux __hp_osf __i286 __i286__ __i386 __i386__"
698 al="$al __i486 __i486__ __i860 __i860__ __ibmesa __ksr1__ __linux__"
699 al="$al __m68k __m68k__ __m88100__ __m88k __m88k__"
700 al="$al __mc68000 __mc68000__ __mc68020 __mc68020__"
701 al="$al __mc68030 __mc68030__ __mc68040 __mc68040__"
702 al="$al __mc88100 __mc88100__ __mips __mips__"
703 al="$al __motorola__ __osf__ __pa_risc __sparc__ __stdc__"
704 al="$al __sun __sun__ __svr3__ __svr4__ __ultrix __ultrix__"
705 al="$al __unix __unix__ __uxpm__ __uxps__ __vax __vax__"
706 al="$al _host_mips _mips _unix"
707 al="$al a29k aegis aix aixpc alliant alpha am29000 amiga ansi ardent"
708 al="$al apollo ardent att386 att3b"
709 al="$al bsd bsd43 bsd4_2 bsd4_3 bsd4_4 bsdi bull"
710 al="$al cadmus clipper concurrent convex cray ctix"
711 al="$al dmert encore gcos gcx gimpel gould"
712 al="$al hbullx20 hcx host_mips hp200 hp300 hp700 hp800"
713 al="$al hp9000 hp9000s300 hp9000s400 hp9000s500"
714 al="$al hp9000s700 hp9000s800 hp9k8 hppa hpux"
715 al="$al i186 i286 i386 i486 i8086"
716 al="$al i80960 i860 iAPX286 ibm ibm032 ibmrt interdata is68k"
717 al="$al ksr1 linux luna luna88k m68k m88100 m88k"
718 al="$al mc300 mc500 mc68000 mc68010 mc68020 mc68030"
719 al="$al mc68040 mc68060 mc68k mc68k32 mc700"
720 al="$al mc88000 mc88100 merlin mert mips mvs n16"
721 al="$al ncl_el ncl_mr"
722 al="$al news1500 news1700 news1800 news1900 news3700"
723 al="$al news700 news800 news900 ns16000 ns32000"
724 al="$al ns32016 ns32332 ns32k nsc32000 os osf"
725 al="$al parisc pc532 pdp11 plexus posix pyr"
726 al="$al riscix riscos scs sequent sgi sinix sony sony_news"
727 al="$al sonyrisc sparc sparclite spectrum stardent stratos"
728 al="$al sun sun3 sun386 svr4 sysV68 sysV88"
729 al="$al titan tower tower32 tower32_200 tower32_600 tower32_700"
730 al="$al tower32_800 tower32_850 tss u370 u3b u3b2 u3b20 u3b200"
731 al="$al u3b20d u3b5 ultrix unix unixpc unos vax venix vms"
732 al="$al xenix z8000"
733
734 groupstype=''
735 i_whoami=''
736 : default library list
737 libswanted=''
738 : set useposix=false in your hint file to disable the POSIX extension.
739 useposix=true
740 : set useopcode=false in your hint file to disable the Opcode extension.
741 useopcode=true
742 : Define several unixisms.  These can be used in hint files.
743 exe_ext='' 
744 : Extra object files, if any, needed on this platform.
745 archobjs=''
746 : Possible local include directories to search.
747 : Set locincpth to "" in a hint file to defeat local include searches.
748 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
749 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
750 :
751 : no include file wanted by default
752 inclwanted=''
753
754 : change the next line if compiling for Xenix/286 on Xenix/386
755 xlibpth='/usr/lib/386 /lib/386'
756
757 : Possible local library directories to search.
758 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
759 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
760
761 : general looking path for locating libraries
762 glibpth="/shlib /usr/shlib /usr/lib/pa1.1 /usr/lib/large"
763 glibpth="$glibpth /lib /usr/lib $xlibpth"
764 glibpth="$glibpth /lib/large /usr/lib/small /lib/small"
765 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
766
767 : Private path used by Configure to find libraries.  Its value
768 : is prepended to libpth. This variable takes care of special
769 : machines, like the mips.  Usually, it should be empty.
770 plibpth=''
771
772 : full support for void wanted by default
773 defvoidused=15
774
775 : List of libraries we want.
776 libswanted='sfio net socket inet nsl nm ndbm gdbm dbm db malloc dl'
777 libswanted="$libswanted dld ld sun m c cposix posix ndir dir crypt"
778 libswanted="$libswanted ucb bsd BSD PW x"
779 : We probably want to search /usr/shlib before most other libraries.
780 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
781 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
782 glibpth="/usr/shlib $glibpth"
783 : Do not use vfork unless overridden by a hint file.
784 usevfork=false
785
786 : Find the basic shell for Bourne shell scripts
787 case "$sh" in
788 '')
789         : SYSTYPE is for some older MIPS systems. 
790         : I do not know if it is still needed.
791         case "$SYSTYPE" in
792         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
793         *) xxx='/bin/sh';;
794         esac
795         if test -f "$xxx"; then
796                 sh="$xxx"
797         else
798                 : Build up a list and do a single loop so we can 'break' out.
799                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
800                 for xxx in sh bash ksh pdksh ash; do
801                         for p in $pth; do
802                                 try="$try ${p}/${xxx}"
803                         done
804                 done
805                 for xxx in $try; do
806                         if test -f "$xxx"; then
807                                 sh="$xxx";
808                                 echo "Your Bourne shell appears to be in $sh."
809                                 break
810                         elif test -f "$xxx.exe"; then
811                                 sh="$xxx";
812                                 echo "Hmm.  Your Bourne shell appears to be in $sh."
813                                 break
814                         fi
815                 done
816         fi
817         ;;
818 esac
819
820 case "$sh" in
821 '')     cat <<EOM >&2
822 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.  
823 Usually it's in /bin/sh.  How did you even get this far?
824 Please contact me (Chip Salzenberg) at chip@perl.com and 
825 we'll try to straigten this all out.
826 EOM
827         exit 1
828         ;;
829 esac
830
831 : see if sh knows # comments
832 if `$sh -c '#' >/dev/null 2>&1`; then
833         shsharp=true
834         spitshell=cat
835         echo " "
836         xcat=/bin/cat
837         test -f $xcat || xcat=/usr/bin/cat
838         echo "#!$xcat" >try
839         $eunicefix try
840         chmod +x try
841         ./try > today
842         if test -s today; then
843                 sharpbang='#!'
844         else
845                 echo "#! $xcat" > try
846                 $eunicefix try
847                 chmod +x try
848                 ./try > today
849                 if test -s today; then
850                         sharpbang='#! '
851                 else
852                         echo "Okay, let's see if #! works on this system..."
853                         echo "It's just a comment."
854                         sharpbang=': use '
855                 fi
856         fi
857 else
858         echo "Your $sh doesn't grok # comments--I will strip them later on."
859         shsharp=false
860         cd ..
861         echo "exec grep -v '^[  ]*#'" >spitshell
862         chmod +x spitshell
863         $eunicefix spitshell
864         spitshell=`pwd`/spitshell
865         cd UU
866         echo "I presume that if # doesn't work, #! won't work either!"
867         sharpbang=': use '
868 fi
869 rm -f try today
870
871 : figure out how to guarantee sh startup
872 case "$startsh" in
873 '') startsh=${sharpbang}${sh} ;;
874 *)
875 esac
876 cat >try <<EOSS
877 $startsh
878 set abc
879 test "$?abc" != 1
880 EOSS
881
882 chmod +x try
883 $eunicefix try
884 if ./try; then
885         : echo "Yup, it does."
886 else
887         echo "Hmm.  '$startsh' didn't work."
888         echo "You may have to fix up the shell scripts to make sure sh runs them."
889 fi
890 rm -f try
891
892 : script used to extract .SH files with variable substitutions
893 cat >extract <<EOS
894 $startsh
895 EOS
896 cat >>extract <<'EOS'
897 CONFIG=true
898 echo "Doing variable substitutions on .SH files..."
899 if test -f MANIFEST; then
900         shlist=`awk '{print $1}' <MANIFEST | grep '\.SH'`
901         : Pick up possible extension manifests.
902         for dir in ext/* ; do
903                 if test -f $dir/MANIFEST; then
904                         xxx=`awk '{print $1}' < $dir/MANIFEST | 
905                                 sed -n "/\.SH$/ s@^@$dir/@p"`
906                         shlist="$shlist $xxx"
907                 fi
908         done
909         set x $shlist
910 else
911         echo "(Looking for .SH files under the current directory.)"
912         set x `find . -name "*.SH" -print`
913 fi
914 shift
915 case $# in
916 0) set x *.SH; shift;;
917 esac
918 if test ! -f $1; then
919         shift
920 fi
921 for file in $*; do
922         case "$file" in
923         */*)
924                 dir=`expr X$file : 'X\(.*\)/'`
925                 file=`expr X$file : 'X.*/\(.*\)'`
926                 (cd $dir && . ./$file)
927                 ;;
928         *)
929                 . ./$file
930                 ;;
931         esac
932 done
933 if test -f config_h.SH; then
934         if test ! -f config.h; then
935         : oops, they left it out of MANIFEST, probably, so do it anyway.
936         . ./config_h.SH
937         fi
938 fi
939 EOS
940
941 : produce awk script to parse command line options
942 cat >options.awk <<'EOF'
943 BEGIN {
944         optstr = "dD:eEf:hKOrsSU:V";    # getopt-style specification
945
946         len = length(optstr);
947         for (i = 1; i <= len; i++) {
948                 c = substr(optstr, i, 1);
949                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
950                 if (a == ":") {
951                         arg[c] = 1;
952                         i++;
953                 }
954                 opt[c] = 1;
955         }
956 }
957 {
958         expect = 0;
959         str = $0;
960         if (substr(str, 1, 1) != "-") {
961                 printf("'%s'\n", str);
962                 next;
963         }
964         len = length($0);
965         for (i = 2; i <= len; i++) {
966                 c = substr(str, i, 1);
967                 if (!opt[c]) {
968                         printf("-%s\n", substr(str, i));
969                         next;
970                 }
971                 printf("-%s\n", c);
972                 if (arg[c]) {
973                         if (i < len)
974                                 printf("'%s'\n", substr(str, i + 1));
975                         else
976                                 expect = 1;
977                         next;
978                 }
979         }
980 }
981 END {
982         if (expect)
983                 print "?";
984 }
985 EOF
986
987 : process the command line options
988 set X `for arg in "$@"; do echo "X$arg"; done |
989         sed -e s/X// | awk -f options.awk`
990 eval "set $*"
991 shift
992 rm -f options.awk
993
994 : set up default values
995 fastread=''
996 reuseval=false
997 config_sh=''
998 alldone=''
999 error=''
1000 silent=''
1001 extractsh=''
1002 override=''
1003 knowitall=''
1004
1005 rm -f optdef.sh
1006 cat >optdef.sh <<EOS
1007 $startsh
1008 EOS
1009
1010 : option parsing
1011 while test $# -gt 0; do
1012         case "$1" in
1013         -d) shift; fastread=yes;;
1014         -e) shift; alldone=cont;;
1015         -f)
1016                 shift
1017                 cd ..
1018                 if test -r "$1"; then
1019                         config_sh="$1"
1020                 else
1021                         echo "$me: cannot read config file $1." >&2
1022                         error=true
1023                 fi
1024                 cd UU
1025                 shift;;
1026         -h) shift; error=true;;
1027         -r) shift; reuseval=true;;
1028         -s) shift; silent=true;;
1029         -E) shift; alldone=exit;;
1030         -K) shift; knowitall=true;;
1031         -O) shift; override=true;;
1032         -S) shift; extractsh=true;;
1033         -D)
1034                 shift
1035                 case "$1" in
1036                 *=)
1037                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1038                         echo "$me: ignoring -D $1" >&2
1039                         ;;
1040                 *=*) echo "$1" | \
1041                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1042                 *) echo "$1='define'" >> optdef.sh;;
1043                 esac
1044                 shift
1045                 ;;
1046         -U)
1047                 shift
1048                 case "$1" in
1049                 *=) echo "$1" >> optdef.sh;;
1050                 *=*)
1051                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1052                         echo "$me: ignoring -U $1" >&2
1053                         ;;
1054                 *) echo "$1='undef'" >> optdef.sh;;
1055                 esac
1056                 shift
1057                 ;;
1058         -V) echo "$me generated by metaconfig 3.0 PL60." >&2
1059                 exit 0;;
1060         --) break;;
1061         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1062         *) break;;
1063         esac
1064 done
1065
1066 case "$error" in
1067 true)
1068         cat >&2 <<EOM
1069 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1070                  [-U symbol] [-U symbol=]
1071   -d : use defaults for all answers.
1072   -e : go on without questioning past the production of config.sh.
1073   -f : specify an alternate default configuration file.
1074   -h : print this help message and exit (with an error status).
1075   -r : reuse C symbols value if possible (skips costly nm extraction).
1076   -s : silent mode, only echoes questions and essential information.
1077   -D : define symbol to have some value:
1078          -D symbol         symbol gets the value 'define'
1079          -D symbol=value   symbol gets the value 'value'
1080   -E : stop at the end of questions, after having produced config.sh.
1081   -K : do not use unless you know what you are doing.
1082   -O : let -D and -U override definitions from loaded configuration file.
1083   -S : perform variable substitutions on all .SH files (can mix with -f)
1084   -U : undefine symbol:
1085          -U symbol    symbol gets the value 'undef'
1086          -U symbol=   symbol gets completely empty
1087   -V : print version number and exit (with a zero status).
1088 EOM
1089         exit 1
1090         ;;
1091 esac
1092
1093 exec 4>&1
1094 case "$silent" in
1095 true) exec 1>/dev/null;;
1096 esac
1097
1098 : run the defines and the undefines, if any, but leave the file out there...
1099 touch optdef.sh
1100 . ./optdef.sh
1101
1102 case "$extractsh" in
1103 true)
1104         case "$config_sh" in
1105         '') config_sh='config.sh'; config='./config.sh';;
1106         /*) config="$config_sh";;
1107         *) config="./$config_sh";;
1108         esac
1109         echo " "
1110         echo "Fetching answers from $config_sh..."
1111         cd ..
1112         . $config
1113         test "$override" && . ./optdef.sh
1114         echo " "
1115         . ./UU/extract
1116         rm -rf UU
1117         echo "Done."
1118         exit 0
1119         ;;
1120 esac
1121
1122 : set package name
1123 package=perl5
1124 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1125 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1126 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1127 ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1128 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1129 esac
1130
1131 : Eunice requires " " instead of "", can you believe it
1132 echo " "
1133 : Here we go...
1134 echo "Beginning of configuration questions for $package."
1135
1136 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
1137
1138 : Some greps do not return status, grrr.
1139 echo "grimblepritz" >grimble
1140 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1141         contains=contains
1142 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1143         contains=grep
1144 else
1145         contains=contains
1146 fi
1147 rm -f grimble
1148 : the following should work in any shell
1149 case "$contains" in
1150 contains*)
1151         echo " "
1152         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1153         cat >contains <<'EOSS'
1154 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1155 EOSS
1156 chmod +x contains
1157 esac
1158
1159 : first determine how to suppress newline on echo command
1160 echo " "
1161 echo "Checking echo to see how to suppress newlines..."
1162 (echo "hi there\c" ; echo " ") >.echotmp
1163 if $contains c .echotmp >/dev/null 2>&1 ; then
1164         echo "...using -n."
1165         n='-n'
1166         c=''
1167 else
1168         cat <<'EOM'
1169 ...using \c
1170 EOM
1171         n=''
1172         c='\c'
1173 fi
1174 echo $n "The star should be here-->$c"
1175 echo '*'
1176 rm -f .echotmp
1177
1178 : Now test for existence of everything in MANIFEST
1179 echo " "
1180 if test -f ../MANIFEST; then
1181         echo "First let's make sure your kit is complete.  Checking..." >&4
1182         awk '$1 !~ /PACK[A-Z]+/ {print $1}' ../MANIFEST | split -50
1183         rm -f missing
1184         for filelist in x??; do
1185                 (cd ..; ls `cat UU/$filelist` >/dev/null 2>>UU/missing)
1186         done
1187         if test -s missing; then
1188                 cat missing >&4
1189                 cat >&4 <<'EOM'
1190
1191 THIS PACKAGE SEEMS TO BE INCOMPLETE.
1192
1193 You have the option of continuing the configuration process, despite the
1194 distinct possibility that your kit is damaged, by typing 'y'es.  If you
1195 do, don't blame me if something goes wrong.  I advise you to type 'n'o
1196 and contact the author (chip@perl.com).
1197
1198 EOM
1199                 echo $n "Continue? [n] $c" >&4
1200                 read ans
1201                 case "$ans" in
1202                 y*)
1203                         echo "Continuing..." >&4
1204                         rm -f missing
1205                         ;;
1206                 *)
1207                         echo "ABORTING..." >&4
1208                         kill $$
1209                         ;;
1210                 esac
1211         else
1212                 echo "Looks good..." >&4
1213         fi
1214 else
1215         echo "There is no MANIFEST file.  I hope your kit is complete !"
1216 fi
1217 rm -f missing x??
1218
1219 : compute the number of columns on the terminal for proper question formatting
1220 case "$COLUMNS" in
1221 '') COLUMNS='80';;
1222 esac
1223
1224 : set up the echo used in my read
1225 myecho="case \"\$xxxm\" in
1226 '') echo $n \"\$rp $c\" >&4;;
1227 *) case \"\$rp\" in
1228         '') echo $n \"[\$xxxm] $c\";;
1229         *)
1230                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
1231                         echo \"\$rp\" >&4
1232                         echo $n \"[\$xxxm] $c\" >&4
1233                 else
1234                         echo $n \"\$rp [\$xxxm] $c\" >&4
1235                 fi
1236                 ;;
1237         esac;;
1238 esac"
1239
1240 : now set up to do reads with possible shell escape and default assignment
1241 cat <<EOSC >myread
1242 $startsh
1243 xxxm=\$dflt
1244 $myecho
1245 ans='!'
1246 case "\$fastread" in
1247 yes) case "\$dflt" in
1248         '') ;;
1249         *) ans='';
1250                 case "\$silent-\$rp" in
1251                 true-) ;;
1252                 *) echo " " >&4;;
1253                 esac;;
1254         esac;;
1255 *) case "\$silent" in
1256         true) case "\$rp" in
1257                 '') ans='';;
1258                 esac;;
1259         esac;;
1260 esac
1261 while expr "X\$ans" : "X!" >/dev/null; do
1262         read answ
1263         set x \$xxxm
1264         shift
1265         aok=''; eval ans="\\"\$answ\\"" && aok=y
1266         case  "\$answ" in
1267         "\$ans")
1268                 case "\$ans" in
1269                 \\&*)
1270                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
1271                         shift
1272                         case "\$1" in
1273                         -d)
1274                                 fastread=yes
1275                                 echo "(OK, I'll run with -d after this question.)" >&4
1276                                 ;;
1277                         -*)
1278                                 echo "*** Sorry, \$1 not supported yet." >&4
1279                                 ;;
1280                         esac
1281                         $myecho
1282                         ans=!
1283                         ;;
1284                 "!")
1285                         sh 1>&4
1286                         echo " "
1287                         $myecho
1288                         ;;
1289                 !*)
1290                         set x \`expr "X\$ans" : "X!\(.*\)\$"\`
1291                         shift
1292                         sh 1>&4 -c "\$*"
1293                         echo " "
1294                         $myecho
1295                         ;;
1296                 esac;;
1297         *)
1298                 case "\$aok" in
1299                 y)
1300                         echo "*** Substitution done -- please confirm."
1301                         xxxm="\$ans"
1302                         ans=\`echo $n "\$ans$c" | tr '\012' ' '\`
1303                         xxxm="\$ans"
1304                         ans=!
1305                         ;;
1306                 *)
1307                         echo "*** Error -- try again."
1308                         ans=!
1309                         ;;
1310                 esac
1311                 $myecho
1312                 ;;
1313         esac
1314         case "\$ans\$xxxm\$nostick" in
1315         '')
1316                 ans=!
1317                 $myecho
1318                 ;;
1319         esac
1320 done
1321 case "\$ans" in
1322 '') ans="\$xxxm";;
1323 esac
1324 EOSC
1325
1326 : create .config dir to save info across Configure sessions
1327 test -d ../.config || mkdir ../.config
1328 cat >../.config/README <<EOF
1329 This directory created by Configure to save information that should
1330 persist across sessions.
1331
1332 You may safely delete it if you wish.
1333 EOF
1334
1335 : general instructions
1336 needman=true
1337 firsttime=true
1338 user=`(logname) 2>/dev/null`
1339 case "$user" in "")
1340         user=`whoami 2>&1` ;;
1341 esac
1342 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
1343         firsttime=false
1344         echo " "
1345         rp='Would you like to see the instructions?'
1346         dflt=n
1347         . ./myread
1348         case "$ans" in
1349         [yY]*) ;;
1350         *) needman=false;;
1351         esac
1352 fi
1353 if $needman; then
1354         cat <<EOH
1355  
1356 This installation shell script will examine your system and ask you questions
1357 to determine how the perl5 package should be installed. If you get
1358 stuck on a question, you may use a ! shell escape to start a subshell or
1359 execute a command.  Many of the questions will have default answers in square
1360 brackets; typing carriage return will give you the default.
1361
1362 On some of the questions which ask for file or directory names you are allowed
1363 to use the ~name construct to specify the login directory belonging to "name",
1364 even if you don't have a shell which knows about that.  Questions where this is
1365 allowed will be marked "(~name ok)".
1366
1367 EOH
1368         rp=''
1369         dflt='Type carriage return to continue'
1370         . ./myread
1371         cat <<'EOH'
1372
1373 The prompter used in this script allows you to use shell variables and
1374 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
1375 in the default answer, as if the default line was a set of arguments given to a
1376 script shell.  This means you may also use $* to repeat the whole default line,
1377 so you do not have to re-type everything to add something to the default.
1378
1379 Everytime there is a substitution, you will have to confirm.  If there is an
1380 error (e.g. an unmatched backtick), the default answer will remain unchanged
1381 and you will be prompted again.
1382
1383 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
1384 the questions and use the computed defaults (or the previous answers if there
1385 was already a config.sh file). Type 'Configure -h' for a list of options.
1386 You may also start interactively and then answer '& -d' at any prompt to turn
1387 on the non-interactive behavior for the remainder of the execution.
1388
1389 EOH
1390         . ./myread
1391         cat <<EOH
1392
1393 Much effort has been expended to ensure that this shell script will run on any
1394 Unix system.  If despite that it blows up on yours, your best bet is to edit
1395 Configure and run it again.  If you can't run Configure for some reason,
1396 you'll have to generate a config.sh file by hand.  Whatever problems you
1397 have, let me (chip@perl.com) know how I blew it.
1398
1399 This installation script affects things in two ways:
1400
1401 1) it may do direct variable substitutions on some of the files included
1402    in this kit.
1403 2) it builds a config.h file for inclusion in C programs.  You may edit
1404    any of these files as the need arises after running this script.
1405
1406 If you make a mistake on a question, there is no easy way to back up to it
1407 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
1408 files.  Configure will offer to let you do this before it runs the SH files.
1409
1410 EOH
1411         dflt='Type carriage return to continue'
1412         . ./myread
1413         case "$firsttime" in
1414         true) echo $user >>../.config/instruct;;
1415         esac
1416 fi
1417
1418 : find out where common programs are
1419 echo " "
1420 echo "Locating common programs..." >&4
1421 cat <<EOSC >loc
1422 $startsh
1423 case \$# in
1424 0) exit 1;;
1425 esac
1426 thing=\$1
1427 shift
1428 dflt=\$1
1429 shift
1430 for dir in \$*; do
1431         case "\$thing" in
1432         .)
1433         if test -d \$dir/\$thing; then
1434                 echo \$dir
1435                 exit 0
1436         fi
1437         ;;
1438         *)
1439         for thisthing in \$dir/\$thing; do
1440                 : just loop through to pick last item
1441         done
1442         if test -f \$thisthing; then
1443                 echo \$thisthing
1444                 exit 0
1445         elif test -f \$dir/\$thing.exe; then
1446                 : on Eunice apparently
1447                 echo \$dir/\$thing
1448                 exit 0
1449         fi
1450         ;;
1451         esac
1452 done
1453 echo \$dflt
1454 exit 1
1455 EOSC
1456 chmod +x loc
1457 $eunicefix loc
1458 loclist="
1459 awk
1460 cat
1461 comm
1462 cp
1463 echo
1464 expr
1465 find
1466 grep
1467 ls
1468 mkdir
1469 rm
1470 sed
1471 sort
1472 touch
1473 tr
1474 uniq
1475 "
1476 trylist="
1477 Mcc
1478 byacc
1479 cpp
1480 csh
1481 date
1482 egrep
1483 gzip
1484 less
1485 line
1486 ln
1487 more
1488 nroff
1489 perl
1490 pg
1491 sendmail
1492 test
1493 uname
1494 zip
1495 "
1496 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1497 pth="$pth /lib /usr/lib"
1498 for file in $loclist; do
1499         xxx=`./loc $file $file $pth`
1500         eval $file=$xxx
1501         eval _$file=$xxx
1502         case "$xxx" in
1503         /*)
1504                 echo $file is in $xxx.
1505                 ;;
1506         ?:[\\/]*)
1507                 echo $file is in $xxx.
1508                 ;;
1509         *)
1510                 echo "I don't know where '$file' is, and my life depends on it." >&4
1511                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
1512                 exit 1
1513                 ;;
1514         esac
1515 done
1516 echo " "
1517 echo "Don't worry if any of the following aren't found..."
1518 say=offhand
1519 for file in $trylist; do
1520         xxx=`./loc $file $file $pth`
1521         eval $file=$xxx
1522         eval _$file=$xxx
1523         case "$xxx" in
1524         /*)
1525                 echo $file is in $xxx.
1526                 ;;
1527         ?:[\\/]*)
1528                 echo $file is in $xxx.
1529                 ;;
1530         *)
1531                 echo "I don't see $file out there, $say."
1532                 say=either
1533                 ;;
1534         esac
1535 done
1536 case "$egrep" in
1537 egrep)
1538         echo "Substituting grep for egrep."
1539         egrep=$grep
1540         ;;
1541 esac
1542 case "$ln" in
1543 ln)
1544         echo "Substituting cp for ln."
1545         ln=$cp
1546         ;;
1547 esac
1548 case "$test" in
1549 test)
1550         echo "Hopefully test is built into your sh."
1551         ;;
1552 *)
1553         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
1554                 echo "Using the test built into your sh."
1555                 test=test
1556                 _test=test
1557         fi
1558         ;;
1559 esac
1560 case "$echo" in
1561 echo)
1562         echo "Hopefully echo is built into your sh."
1563         ;;
1564 '') ;;
1565 *)
1566         echo " "
1567 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
1568         $echo $n "hi there$c" >foo1
1569         echo $n "hi there$c" >foo2
1570         if cmp foo1 foo2 >/dev/null 2>&1; then
1571                 echo "They are compatible.  In fact, they may be identical."
1572         else
1573                 case "$n" in
1574                 '-n') n='' c='\c';;
1575                 *) n='-n' c='';;
1576                 esac
1577                 cat <<FOO
1578 They are not compatible!  You are probably running ksh on a non-USG system.
1579 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
1580 have echo built in and we may have to run some Bourne shell scripts.  That
1581 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
1582
1583 FOO
1584                 $echo $n "The star should be here-->$c"
1585                 $echo "*"
1586         fi
1587         $rm -f foo1 foo2
1588         ;;
1589 esac
1590
1591 : determine whether symbolic links are supported
1592 echo " "
1593 $touch blurfl
1594 if $ln -s blurfl sym > /dev/null 2>&1 ; then
1595         echo "Symbolic links are supported." >&4
1596         lns="$ln -s"
1597 else
1598         echo "Symbolic links are NOT supported." >&4
1599         lns="$ln"
1600 fi
1601 $rm -f blurfl sym
1602
1603 : see whether [:lower:] and [:upper:] are supported character classes
1604 echo " "
1605 up='[A-Z]'
1606 low='[a-z]'
1607 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
1608 ABYZ)
1609         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
1610         up='[:upper:]'
1611         low='[:lower:]'
1612         ;;
1613 *)
1614         echo "Your tr only supports [a-z] and [A-Z] to convert case." >&4
1615         ;;
1616 esac
1617 : set up the translation script tr, must be called with ./tr of course
1618 cat >tr <<EOSC
1619 $startsh
1620 case "\$1\$2" in
1621 '[A-Z][a-z]') exec $tr '$up' '$low';;
1622 '[a-z][A-Z]') exec $tr '$low' '$up';;
1623 esac
1624 exec $tr "\$@"
1625 EOSC
1626 chmod +x tr
1627 $eunicefix tr
1628
1629 : Try to determine whether config.sh was made on this system
1630 case "$config_sh" in
1631 '')
1632 myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
1633 myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
1634         ./tr '[A-Z]' '[a-z]' | tr '\012' ' '`
1635 newmyuname="$myuname"
1636 dflt=n
1637 case "$knowitall" in
1638 '')
1639         if test -f ../config.sh; then
1640                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
1641                         eval "`grep myuname= ../config.sh`"
1642                 fi
1643                 if test "X$myuname" = "X$newmyuname"; then
1644                         dflt=y
1645                 fi
1646         fi
1647         ;;
1648 *) dflt=y;;
1649 esac
1650
1651 : Get old answers from old config file if Configure was run on the
1652 : same system, otherwise use the hints.
1653 hint=default
1654 cd ..
1655 if test -f config.sh; then
1656         echo " "
1657         rp="I see a config.sh file.  Shall I use it to set the defaults?"
1658         . UU/myread
1659         case "$ans" in
1660         n*|N*) echo "OK, I'll ignore it."; mv config.sh config.sh.old;;
1661         *)  echo "Fetching default answers from your old config.sh file..." >&4
1662                 tmp_n="$n"
1663                 tmp_c="$c"
1664                 tmp_sh="$sh"
1665                 . ./config.sh
1666                 cp config.sh UU
1667                 n="$tmp_n"
1668                 c="$tmp_c"
1669                 : Older versions did not always set $sh.  Catch re-use of such
1670                 : an old config.sh.
1671                 case "$sh" in
1672                 '') sh="$tmp_sh" ;;
1673                 esac
1674                 hint=previous
1675                 ;;
1676         esac
1677 fi
1678 if test ! -f config.sh; then
1679         $cat <<EOM
1680
1681 First time through, eh?  I have some defaults handy for the following systems:
1682
1683 EOM
1684         cd hints; ls -C *.sh | $sed 's/\.sh/   /g' >&4
1685         dflt=''
1686         : Half the following guesses are probably wrong... If you have better
1687         : tests or hints, please send them to chip@perl.com
1688         : The metaconfig authors would also appreciate a copy...
1689         $test -f /irix && osname=irix
1690         $test -f /xenix && osname=sco_xenix
1691         $test -f /dynix && osname=dynix
1692         $test -f /dnix && osname=dnix
1693         $test -f /lynx.os && osname=lynxos
1694         $test -f /unicos && osname=unicos && osvers=`$uname -r`
1695         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
1696         $test -f /bin/mips && /bin/mips && osname=mips
1697         $test -d /NextApps && set X `hostinfo | grep 'NeXT Mach.*:' | \
1698                 $sed -e 's/://' -e 's/\./_/'` && osname=next && osvers=$4
1699         $test -d /usr/apollo/bin && osname=apollo
1700         $test -f /etc/saf/_sactab && osname=svr4
1701         $test -d /usr/include/minix && osname=minix
1702         if $test -d /MachTen; then
1703                 osname=machten 
1704                 if $test -x /sbin/version; then
1705                         osvers=`/sbin/version | $awk '{print $2}' | 
1706                         $sed -e 's/[A-Za-z]$//'`
1707                 elif $test -x /usr/etc/version; then
1708                         osvers=`/usr/etc/version | $awk '{print $2}' | 
1709                         $sed -e 's/[A-Za-z]$//'`
1710                 else
1711                         osvers="$2.$3"
1712                 fi
1713         fi
1714         if $test -f $uname; then
1715                 set X $myuname
1716                 shift
1717
1718                 case "$5" in
1719                 fps*) osname=fps ;;
1720                 mips*)
1721                         case "$4" in
1722                         umips) osname=umips ;;
1723                         *) osname=mips ;;
1724                         esac;;
1725                 [23]100) osname=mips ;;
1726                 next*) osname=next ;;
1727                 i386*)
1728                         if $test -f /etc/kconfig; then
1729                                 osname=isc
1730                                 if test "$lns" = "ln -s"; then
1731                                         osvers=4
1732                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
1733                                         osvers=3
1734                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
1735                                         osvers=2
1736                                 fi
1737                         fi
1738                         ;;
1739                 esac
1740
1741                 case "$1" in
1742                 aix) osname=aix
1743                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
1744                         case "$tmp" in
1745                         'not found') osvers="$4"."$3" ;;
1746                         '<3240'|'<>3240') osvers=3.2.0 ;;
1747                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
1748                         '=3250'|'>3250') osvers=3.2.5 ;;
1749                         *) osvers=$tmp;;
1750                         esac
1751                         ;;
1752                 *dc.osx) osname=dcosx
1753                         osvers="$3"
1754                         ;;
1755                 dnix) osname=dnix
1756                         osvers="$3"
1757                         ;;
1758                 domainos) osname=apollo
1759                         osvers="$3"
1760                         ;;
1761                 dgux) osname=dgux 
1762                         osvers="$3"
1763                         ;;
1764                 dynixptx*) osname=dynixptx
1765                         osvers="$3"
1766                         ;;
1767                 freebsd) osname=freebsd 
1768                         osvers="$3" ;;
1769                 genix) osname=genix ;;
1770                 hp*) osname=hpux 
1771                         case "$3" in
1772                         *.08.*) osvers=9 ;;
1773                         *.09.*) osvers=9 ;;
1774                         *.10.*) osvers=10 ;;
1775                         *)      osvers="$3" ;;
1776                         esac
1777                         ;;
1778                 irix*) osname=irix
1779                         case "$3" in
1780                         4*) osvers=4 ;;
1781                         5*) osvers=5 ;;
1782                         *)      osvers="$3" ;;
1783                         esac
1784                         ;;
1785                 linux) osname=linux
1786                         case "$3" in
1787                         *)      osvers="$3" ;;
1788                         esac
1789                         ;;
1790                 netbsd*) osname=netbsd 
1791                         osvers="$3"
1792                         ;;
1793                 news-os) osvers="$3"
1794                         case "$3" in
1795                         4*) osname=newsos4 ;;
1796                         *) osname=newsos ;;
1797                         esac
1798                         ;;
1799                 bsd386) osname=bsd386
1800                         osvers=`$uname -r`
1801                         ;;
1802                 powerux | power_ux | powermax_os | powermaxos | \
1803                 powerunix | power_unix) osname=powerux
1804                         osvers="$3"
1805                         ;;
1806                 next*) osname=next ;;
1807                 solaris) osname=solaris
1808                         case "$3" in
1809                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
1810                         *)      osvers="$3" ;;
1811                         esac
1812                         ;;
1813                 sunos) osname=sunos
1814                         case "$3" in
1815                         5*) osname=solaris
1816                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
1817                         *)      osvers="$3" ;;
1818                         esac
1819                         ;;
1820                 titanos) osname=titanos
1821                         case "$3" in
1822                         1*) osvers=1 ;;
1823                         2*) osvers=2 ;;
1824                         3*) osvers=3 ;;
1825                         4*) osvers=4 ;;
1826                         *)      osvers="$3" ;;
1827                         esac
1828                         ;;
1829                 ultrix) osname=ultrix
1830                         osvers="$3"
1831                         ;;
1832                 osf1|mls+)      case "$5" in
1833                                 alpha)
1834                                         osname=dec_osf
1835                                         osvers=`echo "$3" | sed 's/^[xvt]//'`
1836                                         ;;
1837                         hp*)    osname=hp_osf1  ;;
1838                         mips)   osname=mips_osf1 ;;
1839                         esac
1840                         ;;
1841                 uts) osname=uts 
1842                         osvers="$3"
1843                         ;;
1844                 qnx) osname=qnx
1845                         osvers="$4"
1846                         ;;
1847                 $2) case "$osname" in
1848                         *isc*) ;;
1849                         *freebsd*) ;;
1850                         svr*)
1851                                 : svr4.x or possibly later
1852                                 case "svr$3" in 
1853                                 ${osname}*)
1854                                         osname=svr$3
1855                                         osvers=$4
1856                                         ;;
1857                                 esac
1858                                 case "$osname" in
1859                                 svr4.0)
1860                                         : Check for ESIX
1861                                         if test -f /stand/boot ; then
1862                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
1863                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
1864                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
1865                                                         if test -n "$isesix"; then
1866                                                                 osname=esix4
1867                                                         fi
1868                                                 fi
1869                                         fi
1870                                         ;;
1871                                 esac
1872                                 ;;
1873                         *)      if test -f /etc/systemid; then
1874                                         osname=sco
1875                                         set `echo $3 | $sed 's/\./ /g'` $4
1876                                         if $test -f sco_$1_$2_$3.sh; then
1877                                                 osvers=$1.$2.$3
1878                                         elif $test -f sco_$1_$2.sh; then
1879                                                 osvers=$1.$2
1880                                         elif $test -f sco_$1.sh; then
1881                                                 osvers=$1
1882                                         fi
1883                                 else
1884                                         case "$osname" in
1885                                         '') : Still unknown.  Probably a generic Sys V.
1886                                                 osname="sysv"
1887                                                 osvers="$3"
1888                                                 ;;
1889                                         esac
1890                                 fi
1891                                 ;;
1892                         esac
1893                         ;;
1894                 *)      case "$osname" in
1895                         '') : Still unknown.  Probably a generic BSD.
1896                                 osname="$1"
1897                                 osvers="$3"
1898                                 ;;
1899                         esac
1900                         ;;
1901                 esac
1902         else
1903                 if test -f /vmunix -a -f newsos4.sh; then
1904                         (what /vmunix | ../UU/tr '[A-Z]' '[a-z]') > ../UU/kernel.what 2>&1
1905                         if $contains news-os ../UU/kernel.what >/dev/null 2>&1; then
1906                                 osname=newsos4
1907                         fi
1908                         $rm -f ../UU/kernel.what
1909                 elif test -d c:/.; then
1910                         set X $myuname
1911                         osname=os2
1912                         osvers="$5"
1913                         if test -n "$DJDIR"; then
1914                                 osname=dos
1915                                 osvers=djgpp
1916                         fi
1917                 fi
1918         fi
1919         
1920         : Now look for a hint file osname_osvers, unless one has been
1921         : specified already.
1922         case "$hintfile" in
1923         ''|' ')
1924                 file=`echo "${osname}_${osvers}" | $sed -e 's@\.@_@g' -e 's@_$@@'`
1925                 : Also try without trailing minor version numbers.
1926                 xfile=`echo $file | $sed -e 's@_[^_]*$@@'`
1927                 xxfile=`echo $xfile | $sed -e 's@_[^_]*$@@'`
1928                 xxxfile=`echo $xxfile | $sed -e 's@_[^_]*$@@'`
1929                 xxxxfile=`echo $xxxfile | $sed -e 's@_[^_]*$@@'`
1930                 case "$file" in
1931                 '') dflt=none ;;
1932                 *)  case "$osvers" in
1933                         '') dflt=$file
1934                                 ;;
1935                         *)  if $test -f $file.sh ; then
1936                                         dflt=$file
1937                                 elif $test -f $xfile.sh ; then
1938                                         dflt=$xfile
1939                                 elif $test -f $xxfile.sh ; then
1940                                         dflt=$xxfile
1941                                 elif $test -f $xxxfile.sh ; then
1942                                         dflt=$xxxfile
1943                                 elif $test -f $xxxxfile.sh ; then
1944                                         dflt=$xxxxfile
1945                                 elif $test -f "${osname}.sh" ; then
1946                                         dflt="${osname}"
1947                                 else
1948                                         dflt=none
1949                                 fi
1950                                 ;;
1951                         esac
1952                         ;;
1953                 esac
1954                 ;;
1955         *)
1956                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
1957                 ;;
1958         esac
1959
1960         $cat <<EOM
1961
1962 You may give one or more space-separated answers, or "none" if appropriate.
1963 If your OS version has no hints, DO NOT give a wrong version -- say "none".
1964
1965 EOM
1966         rp="Which of these apply, if any?"
1967         . ../UU/myread
1968         tans=$ans
1969         for file in $tans; do
1970                 if $test -f $file.sh; then
1971                         . ./$file.sh
1972                         $cat $file.sh >> ../UU/config.sh
1973                 elif $test X$tans = X -o X$tans = Xnone ; then
1974                         : nothing
1975                 else
1976                         : Give one chance to correct a possible typo.
1977                         echo "$file.sh does not exist"
1978                         dflt=$file
1979                         rp="hint to use instead?"
1980                         . ../UU/myread
1981                         for file in $ans; do
1982                                 if $test -f "$file.sh"; then
1983                                         . ./$file.sh
1984                                         $cat $file.sh >> ../UU/config.sh
1985                                 elif $test X$ans = X -o X$ans = Xnone ; then
1986                                         : nothing
1987                                 else
1988                                         echo "$file.sh does not exist -- ignored."
1989                                 fi
1990                         done
1991                 fi
1992         done
1993
1994         hint=recommended
1995         : Remember our hint file for later.
1996         if $test -f "$file.sh" ; then
1997                 hintfile="$file"
1998         else
1999                 hintfile=''
2000         fi
2001
2002         cd ..
2003 fi
2004 cd UU
2005 ;;
2006 *)
2007         echo " "
2008         echo "Fetching default answers from $config_sh..." >&4
2009         tmp_n="$n"
2010         tmp_c="$c"
2011         cd ..
2012         cp $config_sh config.sh 2>/dev/null
2013         chmod +w config.sh
2014         . ./config.sh
2015         cd UU
2016         cp ../config.sh .
2017         n="$tmp_n"
2018         c="$tmp_c"
2019         hint=previous
2020         ;;
2021 esac
2022 test "$override" && . ./optdef.sh
2023 myuname="$newmyuname"
2024
2025 : Restore computed paths
2026 for file in $loclist $trylist; do
2027         eval $file="\$_$file"
2028 done
2029
2030 cat << EOM
2031
2032 Configure uses the operating system name and version to set some defaults.
2033 The default value is probably right if the name rings a bell. Otherwise,
2034 since spelling matters for me, either accept the default or answer "none"
2035 to leave it blank.
2036
2037 EOM
2038 case "$osname" in
2039         ''|' ')
2040                 case "$hintfile" in
2041                 ''|' '|none) dflt=none ;;
2042                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
2043                 esac
2044                 ;;
2045         *) dflt="$osname" ;;
2046 esac
2047 rp="Operating system name?"
2048 . ./myread
2049 case "$ans" in
2050 none)  osname='' ;;
2051 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
2052 esac
2053 echo " "
2054 case "$osvers" in
2055         ''|' ')
2056                 case "$hintfile" in
2057                 ''|' '|none) dflt=none ;;
2058                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
2059                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
2060                         case "$dflt" in
2061                         ''|' ') dflt=none ;;
2062                         esac
2063                         ;;
2064                 esac
2065                 ;;
2066         *) dflt="$osvers" ;;
2067 esac
2068 rp="Operating system version?"
2069 . ./myread
2070 case "$ans" in
2071 none)  osvers='' ;;
2072 *) osvers="$ans" ;;
2073 esac
2074
2075
2076
2077 : who configured the system
2078 cf_time=`LC_ALL=C; export LC_ALL; $date 2>&1`
2079 cf_by=`(logname) 2>/dev/null`
2080 case "$cf_by" in "")
2081         cf_by=`(whoami) 2>/dev/null`
2082         case "$cf_by" in "")
2083                 cf_by=unknown ;;
2084         esac ;;
2085 esac
2086
2087 : determine the architecture name
2088 echo " "
2089 if xxx=`./loc arch blurfl $pth`; $test -f "$xxx"; then
2090         tarch=`arch`"-$osname"
2091 elif xxx=`./loc uname blurfl $pth`; $test -f "$xxx" ; then
2092         if uname -m > tmparch 2>&1 ; then
2093                 tarch=`$sed -e 's/ *$//' -e 's/ /_/g' \
2094                         -e 's/$/'"-$osname/" tmparch`
2095         else
2096                 tarch="$osname"
2097         fi
2098         $rm -f tmparch
2099 else
2100         tarch="$osname"
2101 fi
2102 case "$myarchname" in
2103 ''|"$tarch") ;;
2104 *)
2105         echo "(Your architecture name used to be $myarchname.)"
2106         archname=''
2107         ;;
2108 esac
2109 case "$archname" in
2110 '') dflt="$tarch";;
2111 *) dflt="$archname";;
2112 esac
2113 rp='What is your architecture name'
2114 . ./myread
2115 case "$usethreads" in
2116 $define)  echo "Threads selected." >&4
2117           case "$ans" in
2118           *-thread) echo "...and architecture name already ends in -thread." >&4
2119                     archname="$ans"
2120                     ;;
2121           *)        archname="$ans-thread"
2122                     echo "...setting architecture name to $archname." >&4
2123                     ;;
2124           esac
2125           ;;
2126 *)        archname="$ans" ;;
2127 esac
2128 myarchname="$tarch"
2129
2130 : is AFS running?
2131 echo " "
2132 case "$afs" in
2133 $define|true)   afs=true ;;
2134 $undef|false)   afs=false ;;
2135 *)      if test -d /afs; then
2136                 afs=true
2137         else
2138                 afs=false
2139         fi
2140         ;;
2141 esac
2142 if $afs; then
2143         echo "AFS may be running... I'll be extra cautious then..." >&4
2144 else
2145         echo "AFS does not seem to be running..." >&4
2146 fi
2147
2148 : decide how portable to be.  Allow command line overrides.
2149 case "$d_portable" in
2150 "$undef") ;;
2151 *)      d_portable="$define" ;;
2152 esac
2153
2154 : set up shell script to do ~ expansion
2155 cat >filexp <<EOSS
2156 $startsh
2157 : expand filename
2158 case "\$1" in
2159  ~/*|~)
2160         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
2161         ;;
2162  ~*)
2163         if $test -f /bin/csh; then
2164                 /bin/csh -f -c "glob \$1"
2165                 failed=\$?
2166                 echo ""
2167                 exit \$failed
2168         else
2169                 name=\`$expr x\$1 : '..\([^/]*\)'\`
2170                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
2171                 if $test ! -d "\$dir"; then
2172                         me=\`basename \$0\`
2173                         echo "\$me: can't locate home directory for: \$name" >&2
2174                         exit 1
2175                 fi
2176                 case "\$1" in
2177                 */*)
2178                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
2179                         ;;
2180                 *)
2181                         echo \$dir
2182                         ;;
2183                 esac
2184         fi
2185         ;;
2186 *)
2187         echo \$1
2188         ;;
2189 esac
2190 EOSS
2191 chmod +x filexp
2192 $eunicefix filexp
2193
2194 : now set up to get a file name
2195 cat <<EOS >getfile
2196 $startsh
2197 EOS
2198 cat <<'EOSC' >>getfile
2199 tilde=''
2200 fullpath=''
2201 already=''
2202 skip=''
2203 none_ok=''
2204 exp_file=''
2205 nopath_ok=''
2206 orig_rp="$rp"
2207 orig_dflt="$dflt"
2208
2209 case "$fn" in
2210 *\(*)
2211         expr $fn : '.*(\(.*\)).*' | tr ',' '\012' >getfile.ok
2212         fn=`echo $fn | sed 's/(.*)//'`
2213         ;;
2214 esac
2215
2216 case "$fn" in
2217 *:*)
2218         loc_file=`expr $fn : '.*:\(.*\)'`
2219         fn=`expr $fn : '\(.*\):.*'`
2220         ;;
2221 esac
2222
2223 case "$fn" in
2224 *~*) tilde=true;;
2225 esac
2226 case "$fn" in
2227 */*) fullpath=true;;
2228 esac
2229 case "$fn" in
2230 *+*) skip=true;;
2231 esac
2232 case "$fn" in
2233 *n*) none_ok=true;;
2234 esac
2235 case "$fn" in
2236 *e*) exp_file=true;;
2237 esac
2238 case "$fn" in
2239 *p*) nopath_ok=true;;
2240 esac
2241
2242 case "$fn" in
2243 *f*) type='File';;
2244 *d*) type='Directory';;
2245 *l*) type='Locate';;
2246 esac
2247
2248 what="$type"
2249 case "$what" in
2250 Locate) what='File';;
2251 esac
2252
2253 case "$exp_file" in
2254 '')
2255         case "$d_portable" in
2256         "$define") ;;
2257         *) exp_file=true;;
2258         esac
2259         ;;
2260 esac
2261
2262 cd ..
2263 while test "$type"; do
2264         redo=''
2265         rp="$orig_rp"
2266         dflt="$orig_dflt"
2267         case "$tilde" in
2268         true) rp="$rp (~name ok)";;
2269         esac
2270         . UU/myread
2271         if test -f UU/getfile.ok && \
2272                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
2273         then
2274                 value="$ans"
2275                 ansexp="$ans"
2276                 break
2277         fi
2278         case "$ans" in
2279         none)
2280                 value=''
2281                 ansexp=''
2282                 case "$none_ok" in
2283                 true) type='';;
2284                 esac
2285                 ;;
2286         *)
2287                 case "$tilde" in
2288                 '') value="$ans"
2289                         ansexp="$ans";;
2290                 *)
2291                         value=`UU/filexp $ans`
2292                         case $? in
2293                         0)
2294                                 if test "$ans" != "$value"; then
2295                                         echo "(That expands to $value on this system.)"
2296                                 fi
2297                                 ;;
2298                         *) value="$ans";;
2299                         esac
2300                         ansexp="$value"
2301                         case "$exp_file" in
2302                         '') value="$ans";;
2303                         esac
2304                         ;;
2305                 esac
2306                 case "$fullpath" in
2307                 true)
2308                         case "$ansexp" in
2309                         /*) value="$ansexp" ;;
2310                         *)
2311                                 redo=true
2312                                 case "$already" in
2313                                 true)
2314                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
2315                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
2316                                         ;;
2317                                 *)
2318                                 echo "Please give a full path name, starting with slash." >&4
2319                                         case "$tilde" in
2320                                         true)
2321                                 echo "Note that using ~name is ok provided it expands well." >&4
2322                                                 already=true
2323                                                 ;;
2324                                         esac
2325                                 esac
2326                                 ;;
2327                         esac
2328                         ;;
2329                 esac
2330                 case "$redo" in
2331                 '')
2332                         case "$type" in
2333                         File)
2334                                 if test -f "$ansexp"; then
2335                                         type=''
2336                                 elif test -r "$ansexp" || (test -h "$ansexp") >/dev/null 2>&1
2337                                 then
2338                                         echo "($value is not a plain file, but that's ok.)"
2339                                         type=''
2340                                 fi
2341                                 ;;
2342                         Directory)
2343                                 if test -d "$ansexp"; then
2344                                         type=''
2345                                 fi
2346                                 ;;
2347                         Locate)
2348                                 if test -d "$ansexp"; then
2349                                         echo "(Looking for $loc_file in directory $value.)"
2350                                         value="$value/$loc_file"
2351                                         ansexp="$ansexp/$loc_file"
2352                                 fi
2353                                 if test -f "$ansexp"; then
2354                                         type=''
2355                                 fi
2356                                 case "$nopath_ok" in
2357                                 true)   case "$value" in
2358                                         */*) ;;
2359                                         *)      echo "Assuming $value will be in people's path."
2360                                                 type=''
2361                                                 ;;
2362                                         esac
2363                                         ;;
2364                                 esac
2365                                 ;;
2366                         esac
2367
2368                         case "$skip" in
2369                         true) type='';
2370                         esac
2371
2372                         case "$type" in
2373                         '') ;;
2374                         *)
2375                                 if test "$fastread" = yes; then
2376                                         dflt=y
2377                                 else
2378                                         dflt=n
2379                                 fi
2380                                 rp="$what $value doesn't exist.  Use that name anyway?"
2381                                 . UU/myread
2382                                 dflt=''
2383                                 case "$ans" in
2384                                 y*) type='';;
2385                                 *) echo " ";;
2386                                 esac
2387                                 ;;
2388                         esac
2389                         ;;
2390                 esac
2391                 ;;
2392         esac
2393 done
2394 cd UU
2395 ans="$value"
2396 rp="$orig_rp"
2397 dflt="$orig_dflt"
2398 rm -f getfile.ok
2399 EOSC
2400
2401 : determine root of directory hierarchy where package will be installed.
2402 case "$prefix" in
2403 '')
2404         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
2405         ;;
2406 *)
2407         dflt="$prefix"
2408         ;;
2409 esac
2410 $cat <<EOM
2411
2412 By default, $package will be installed in $dflt/bin, manual
2413 pages under $dflt/man, etc..., i.e. with $dflt as prefix for
2414 all installation directories. Typically set to /usr/local, but you
2415 may choose /usr if you wish to install $package among your system
2416 binaries. If you wish to have binaries under /bin but manual pages
2417 under /usr/local/man, that's ok: you will be prompted separately
2418 for each of the installation directories, the prefix being only used
2419 to set the defaults.
2420
2421 EOM
2422 fn=d~
2423 rp='Installation prefix to use?'
2424 . ./getfile
2425 oldprefix=''
2426 case "$prefix" in
2427 '') ;;
2428 *)
2429         case "$ans" in
2430         "$prefix") ;;
2431         *) oldprefix="$prefix";;
2432         esac
2433         ;;
2434 esac
2435 prefix="$ans"
2436 prefixexp="$ansexp"
2437
2438 : set the prefixit variable, to compute a suitable default value
2439 prefixit='case "$3" in
2440 ""|none)
2441         case "$oldprefix" in
2442         "") eval "$1=\"\$$2\"";;
2443         *)
2444                 case "$3" in
2445                 "") eval "$1=";;
2446                 none)
2447                         eval "tp=\"\$$2\"";
2448                         case "$tp" in
2449                         ""|" ") eval "$1=\"\$$2\"";;
2450                         *) eval "$1=";;
2451                         esac;;
2452                 esac;;
2453         esac;;
2454 *)
2455         eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
2456         case "$tp" in
2457         --|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
2458         /*-$oldprefix/*|\~*-$oldprefix/*)
2459                 eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
2460         *) eval "$1=\"\$$2\"";;
2461         esac;;
2462 esac'
2463
2464 : determine where private library files go
2465 : Usual default is /usr/local/lib/perl5.  Also allow things like 
2466 : /opt/perl/lib, since /opt/perl/lib/perl5 would be redundant.
2467 case "$prefix" in
2468 *perl*) set dflt privlib lib ;;
2469 *)       set dflt privlib lib/$package ;;
2470 esac
2471 eval $prefixit
2472 $cat <<EOM
2473
2474 There are some auxiliary files for $package that need to be put into a
2475 private library directory that is accessible by everyone.
2476
2477 EOM
2478 fn=d~+
2479 rp='Pathname where the private library files will reside?'
2480 . ./getfile
2481 if $test "X$privlibexp" != "X$ansexp"; then
2482         installprivlib=''
2483 fi
2484 privlib="$ans"
2485 privlibexp="$ansexp"
2486 if $afs; then
2487         $cat <<EOM
2488
2489 Since you are running AFS, I need to distinguish the directory in which
2490 private files reside from the directory in which they are installed (and from
2491 which they are presumably copied to the former directory by occult means).
2492
2493 EOM
2494         case "$installprivlib" in
2495         '') dflt=`echo $privlibexp | sed 's#^/afs/#/afs/.#'`;;
2496         *) dflt="$installprivlib";;
2497         esac
2498         fn=de~
2499         rp='Where will private files be installed?'
2500         . ./getfile
2501         installprivlib="$ans"
2502 else
2503         installprivlib="$privlibexp"
2504 fi
2505
2506 : set the base revision
2507 baserev=5.0
2508
2509 : get the patchlevel
2510 echo " "
2511 echo "Getting the current patchlevel..." >&4
2512 if $test -r ../patchlevel.h;then
2513         patchlevel=`awk '/PATCHLEVEL/ {print $3}' ../patchlevel.h`
2514         subversion=`awk '/SUBVERSION/ {print $3}' ../patchlevel.h`
2515 else
2516         patchlevel=0
2517         subversion=0
2518 fi
2519 $echo $n "(You have $package" $c
2520 case "$package" in
2521 "*$baserev")    ;;
2522 *)              $echo $n " $baserev" $c ;;
2523 esac
2524 $echo $n " patchlevel $patchlevel" $c
2525 test 0 -eq "$subversion" || $echo $n " subversion $subversion" $c
2526 echo ".)"
2527
2528 : set the prefixup variable, to restore leading tilda escape
2529 prefixup='case "$prefixexp" in
2530 "$prefix") ;;
2531 *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
2532 esac'
2533
2534 : determine where public architecture dependent libraries go
2535 set archlib archlib
2536 eval $prefixit
2537 case "$archlib" in
2538 '')
2539     case "$privlib" in
2540     '') dflt=`./loc . "." $prefixexp/lib /usr/local/lib /usr/lib /lib`
2541         set dflt
2542         eval $prefixup
2543         ;;
2544     *)  if test 0 -eq "$subversion"; then
2545             version=`LC_ALL=C; export LC_ALL; \
2546                      echo $baserev $patchlevel | \
2547                      $awk '{ printf "%.3f\n", $1 + $2/1000.0 }'`
2548         else
2549             version=`LC_ALL=C; export LC_ALL; \
2550                      echo $baserev $patchlevel $subversion | \
2551                      $awk '{ printf "%.5f\n", $1 + $2/1000.0 + $3/100000.0 }'`
2552         fi
2553         dflt="$privlib/$archname/$version"
2554         ;;
2555     esac
2556     ;;
2557 *)
2558     dflt="$archlib"
2559     ;;
2560 esac
2561 cat <<EOM
2562
2563 $spackage contains architecture-dependent library files.  If you are
2564 sharing libraries in a heterogeneous environment, you might store
2565 these files in a separate location.  Otherwise, you can just include
2566 them with the rest of the public library files.
2567
2568 EOM
2569 fn=d+~
2570 rp='Where do you want to put the public architecture-dependent libraries?'
2571 . ./getfile
2572 archlib="$ans"
2573 archlibexp="$ansexp"
2574
2575 if $afs; then
2576         $cat <<EOM
2577
2578 Since you are running AFS, I need to distinguish the directory in
2579 which architecture-dependent library files reside from the directory
2580 in which they are installed (and from which they are presumably copied
2581 to the former directory by occult means).
2582
2583 EOM
2584         case "$installarchlib" in
2585         '') dflt=`echo $archlibexp | sed 's#^/afs/#/afs/.#'`;;
2586         *) dflt="$installarchlib";;
2587         esac
2588         fn=de~
2589         rp='Where will architecture-dependent library files be installed?'
2590         . ./getfile
2591         installarchlib="$ans"
2592 else
2593         installarchlib="$archlibexp"
2594 fi
2595 if $test X"$archlib" = X"$privlib"; then
2596         d_archlib="$undef"
2597 else
2598         d_archlib="$define"
2599 fi
2600
2601 : set up the script used to warn in case of inconsistency
2602 cat <<EOS >whoa
2603 $startsh
2604 EOS
2605 cat <<'EOSC' >>whoa
2606 dflt=y
2607 echo " "
2608 echo "*** WHOA THERE!!! ***" >&4
2609 echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
2610 rp="    Keep the $hint value?"
2611 . ./myread
2612 case "$ans" in
2613 y) td=$was; tu=$was;;
2614 esac
2615 EOSC
2616
2617 : function used to set $1 to $val
2618 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
2619 case "$val$was" in
2620 $define$undef) . ./whoa; eval "$var=\$td";;
2621 $undef$define) . ./whoa; eval "$var=\$tu";;
2622 *) eval "$var=$val";;
2623 esac'
2624
2625 : bincompat3 is no more even possible starting with 5.005
2626 d_bincompat3=$undef
2627
2628 : make some quick guesses about what we are up against
2629 echo " "
2630 $echo $n "Hmm...  $c"
2631 echo exit 1 >bsd
2632 echo exit 1 >usg
2633 echo exit 1 >v7
2634 echo exit 1 >osf1
2635 echo exit 1 >eunice
2636 echo exit 1 >xenix
2637 echo exit 1 >venix
2638 echo exit 1 >os2
2639 d_bsd="$undef"
2640 $cat /usr/include/signal.h /usr/include/sys/signal.h >foo 2>/dev/null
2641 if test -f /osf_boot || $contains 'OSF/1' /usr/include/ctype.h >/dev/null 2>&1
2642 then
2643         echo "Looks kind of like an OSF/1 system, but we'll see..."
2644         echo exit 0 >osf1
2645 elif test `echo abc | tr a-z A-Z` = Abc ; then
2646         xxx=`./loc addbib blurfl $pth`
2647         if $test -f $xxx; then
2648         echo "Looks kind of like a USG system with BSD features, but we'll see..."
2649                 echo exit 0 >bsd
2650                 echo exit 0 >usg
2651         else
2652                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
2653                         echo "Looks kind of like an extended USG system, but we'll see..."
2654                 else
2655                         echo "Looks kind of like a USG system, but we'll see..."
2656                 fi
2657                 echo exit 0 >usg
2658         fi
2659 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
2660         echo "Looks kind of like a BSD system, but we'll see..."
2661         d_bsd="$define"
2662         echo exit 0 >bsd
2663 else
2664         echo "Looks kind of like a Version 7 system, but we'll see..."
2665         echo exit 0 >v7
2666 fi
2667 case "$eunicefix" in
2668 *unixtovms*)
2669         $cat <<'EOI'
2670 There is, however, a strange, musty smell in the air that reminds me of
2671 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
2672 EOI
2673         echo exit 0 >eunice
2674         d_eunice="$define"
2675 : it so happens the Eunice I know will not run shell scripts in Unix format
2676         ;;
2677 *)
2678         echo " "
2679         echo "Congratulations.  You aren't running Eunice."
2680         d_eunice="$undef"
2681         ;;
2682 esac
2683 : Detect OS2.  The p_ variable is set above in the Head.U unit.
2684 case "$p_" in
2685 :) ;;
2686 *)
2687         $cat <<'EOI'
2688 I have the feeling something is not exactly right, however...don't tell me...
2689 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
2690 EOI
2691         echo exit 0 >os2
2692         ;;
2693 esac
2694 if test -f /xenix; then
2695         echo "Actually, this looks more like a XENIX system..."
2696         echo exit 0 >xenix
2697         d_xenix="$define"
2698 else
2699         echo " "
2700         echo "It's not Xenix..."
2701         d_xenix="$undef"
2702 fi
2703 chmod +x xenix
2704 $eunicefix xenix
2705 if test -f /venix; then
2706         echo "Actually, this looks more like a VENIX system..."
2707         echo exit 0 >venix
2708 else
2709         echo " "
2710         if ./xenix; then
2711                 : null
2712         else
2713                 echo "Nor is it Venix..."
2714         fi
2715 fi
2716 chmod +x bsd usg v7 osf1 eunice xenix venix os2
2717 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
2718 $rm -f foo
2719
2720 : see if setuid scripts can be secure
2721 $cat <<EOM
2722
2723 Some kernels have a bug that prevents setuid #! scripts from being
2724 secure.  Some sites have disabled setuid #! scripts because of this.
2725
2726 First let's decide if your kernel supports secure setuid #! scripts.
2727 (If setuid #! scripts would be secure but have been disabled anyway,
2728 don't say that they are secure if asked.)
2729
2730 EOM
2731
2732 val="$undef"
2733 if $test -d /dev/fd; then
2734         echo "#!$ls" >reflect
2735         chmod +x,u+s reflect
2736         ./reflect >flect 2>&1
2737         if $contains "/dev/fd" flect >/dev/null; then
2738                 echo "Congratulations, your kernel has secure setuid scripts!" >&4
2739                 val="$define"
2740         else
2741                 $cat <<EOM
2742 If you are not sure if they are secure, I can check but I'll need a
2743 username and password different from the one you are using right now.
2744 If you don't have such a username or don't want me to test, simply
2745 enter 'none'.
2746
2747 EOM
2748                 rp='Other username to test security of setuid scripts with?'
2749                 dflt='none'
2750                 . ./myread
2751                 case "$ans" in
2752                 n|none)
2753                         case "$d_suidsafe" in
2754                         '')     echo "I'll assume setuid scripts are *not* secure." >&4
2755                                 dflt=n;;
2756                         "$undef")
2757                                 echo "Well, the $hint value is *not* secure." >&4
2758                                 dflt=n;;
2759                         *)      echo "Well, the $hint value *is* secure." >&4
2760                                 dflt=y;;
2761                         esac
2762                         ;;
2763                 *)
2764                         $rm -f reflect flect
2765                         echo "#!$ls" >reflect
2766                         chmod +x,u+s reflect
2767                         echo >flect
2768                         chmod a+w flect
2769                         echo '"su" will (probably) prompt you for '"$ans's password."
2770                         su $ans -c './reflect >flect'
2771                         if $contains "/dev/fd" flect >/dev/null; then
2772                                 echo "Okay, it looks like setuid scripts are secure." >&4
2773                                 dflt=y
2774                         else
2775                                 echo "I don't think setuid scripts are secure." >&4
2776                                 dflt=n
2777                         fi
2778                         ;;
2779                 esac
2780                 rp='Does your kernel have *secure* setuid scripts?'
2781                 . ./myread
2782                 case "$ans" in
2783                 [yY]*)  val="$define";;
2784                 *)      val="$undef";;
2785                 esac
2786         fi
2787 else
2788         echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
2789         echo "(That's for file descriptors, not floppy disks.)"
2790         val="$undef"
2791 fi
2792 set d_suidsafe
2793 eval $setvar
2794
2795 $rm -f reflect flect
2796
2797 : now see if they want to do setuid emulation
2798 echo " "
2799 val="$undef"
2800 case "$d_suidsafe" in
2801 "$define")
2802         val="$undef"
2803         echo "No need to emulate SUID scripts since they are secure here." >& 4
2804         ;;
2805 *)
2806         $cat <<EOM
2807 Some systems have disabled setuid scripts, especially systems where
2808 setuid scripts cannot be secure.  On systems where setuid scripts have
2809 been disabled, the setuid/setgid bits on scripts are currently
2810 useless.  It is possible for $package to detect those bits and emulate
2811 setuid/setgid in a secure fashion.  This emulation will only work if
2812 setuid scripts have been disabled in your kernel.
2813
2814 EOM
2815         case "$d_dosuid" in
2816         "$define") dflt=y ;;
2817         *) dflt=n ;;
2818         esac
2819         rp="Do you want to do setuid/setgid emulation?"
2820         . ./myread
2821         case "$ans" in
2822         [yY]*)  val="$define";;
2823         *)      val="$undef";;
2824         esac
2825         ;;
2826 esac
2827 set d_dosuid
2828 eval $setvar
2829
2830 : determine where site specific libraries go.
2831 set sitelib sitelib
2832 eval $prefixit
2833 case "$sitelib" in
2834 '')     dflt="$privlib/site_perl" ;;
2835 *)      dflt="$sitelib" ;;
2836 esac
2837 $cat <<EOM
2838
2839 The installation process will also create a directory for
2840 site-specific extensions and modules.  Some users find it convenient
2841 to place all local files in this directory rather than in the main
2842 distribution directory.
2843
2844 EOM
2845 fn=d~+
2846 rp='Pathname for the site-specific library files?'
2847 . ./getfile
2848 if $test "X$sitelibexp" != "X$ansexp"; then
2849         installsitelib=''
2850 fi
2851 sitelib="$ans"
2852 sitelibexp="$ansexp"
2853 if $afs; then
2854         $cat <<EOM
2855
2856 Since you are running AFS, I need to distinguish the directory in
2857 which site-specific files reside from the directory in which they are
2858 installed (and from which they are presumably copied to the former
2859 directory by occult means).
2860
2861 EOM
2862         case "$installsitelib" in
2863         '') dflt=`echo $sitelibexp | sed 's#^/afs/#/afs/.#'`;;
2864         *) dflt="$installsitelib";;
2865         esac
2866         fn=de~
2867         rp='Where will site-specific files be installed?'
2868         . ./getfile
2869         installsitelib="$ans"
2870 else
2871         installsitelib="$sitelibexp"
2872 fi
2873
2874 : determine where site specific architecture-dependent libraries go.
2875 xxx=`echo $sitelib/$archname | sed 's!^$prefix!!'`
2876 : xxx is usuually lib/site_perl/archname.
2877 set sitearch sitearch none
2878 eval $prefixit
2879 case "$sitearch" in
2880 '')     dflt="$sitelib/$archname" ;;
2881 *)      dflt="$sitearch" ;;
2882 esac
2883 $cat <<EOM
2884
2885 The installation process will also create a directory for
2886 architecture-dependent site-specific extensions and modules.
2887
2888 EOM
2889 fn=nd~+
2890 rp='Pathname for the site-specific architecture-dependent library files?'
2891 . ./getfile
2892 if $test "X$sitearchexp" != "X$ansexp"; then
2893         installsitearch=''
2894 fi
2895 sitearch="$ans"
2896 sitearchexp="$ansexp"
2897 if $afs; then
2898         $cat <<EOM
2899
2900 Since you are running AFS, I need to distinguish the directory in
2901 which site-specific architecture-dependent library files reside from
2902 the directory in which they are installed (and from which they are
2903 presumably copied to the former directory by occult means).
2904
2905 EOM
2906         case "$installsitearch" in
2907         '') dflt=`echo $sitearchexp | sed 's#^/afs/#/afs/.#'`;;
2908         *) dflt="$installsitearch";;
2909         esac
2910         fn=de~
2911         rp='Where will site-specific architecture-dependent files be installed?'
2912         . ./getfile
2913         installsitearch="$ans"
2914 else
2915         installsitearch="$sitearchexp"
2916 fi
2917
2918 : determine where old public architecture dependent libraries might be
2919 case "$oldarchlib" in
2920 '')     case "$privlib" in
2921         '') ;;
2922         *)      dflt="$privlib/$archname"
2923                 ;;
2924         esac
2925         ;;
2926 *)      dflt="$oldarchlib" 
2927         ;;
2928 esac
2929 if $test ! -d "$dflt/auto"; then
2930         dflt=none
2931 fi
2932 cat <<EOM
2933
2934 In 5.001, Perl stored architecture-dependent library files in a directory
2935 with a name such as $privlib/$archname, 
2936 and this directory contained files from the standard extensions and 
2937 files from any additional extensions you might have added.  Starting 
2938 with version 5.002, all the architecture-dependent standard extensions 
2939 will go into a version-specific directory such as
2940 $archlib, 
2941 while locally-added extensions will go into
2942 $sitearch.
2943
2944 If you wish Perl to continue to search the old architecture-dependent
2945 library for your local extensions, give the path to that directory.
2946 If you do not wish to use your old architecture-dependent library
2947 files, answer 'none'.
2948
2949 EOM
2950 fn=dn~
2951 rp='Directory for your old 5.001 architecture-dependent libraries?'
2952 . ./getfile
2953 oldarchlib="$ans"
2954 oldarchlibexp="$ansexp"
2955 case "$oldarchlib" in
2956 ''|' ') val="$undef" ;;
2957 *) val="$define" ;;
2958 esac
2959 set d_oldarchlib
2960 eval $setvar
2961
2962 : determine where public executables go
2963 echo " "
2964 set dflt bin bin
2965 eval $prefixit
2966 fn=d~
2967 rp='Pathname where the public executables will reside?'
2968 . ./getfile
2969 if $test "X$ansexp" != "X$binexp"; then
2970         installbin=''
2971 fi
2972 bin="$ans"
2973 binexp="$ansexp"
2974 if $afs; then
2975         $cat <<EOM
2976
2977 Since you are running AFS, I need to distinguish the directory in which
2978 executables reside from the directory in which they are installed (and from
2979 which they are presumably copied to the former directory by occult means).
2980
2981 EOM
2982         case "$installbin" in
2983         '') dflt=`echo $binexp | sed 's#^/afs/#/afs/.#'`;;
2984         *) dflt="$installbin";;
2985         esac
2986         fn=de~
2987         rp='Where will public executables be installed?'
2988         . ./getfile
2989         installbin="$ans"
2990 else
2991         installbin="$binexp"
2992 fi
2993
2994 : determine where manual pages are on this system
2995 echo " "
2996 case "$sysman" in
2997 '') 
2998         syspath='/usr/man/man1 /usr/man/mann /usr/man/manl /usr/man/local/man1'
2999         syspath="$syspath /usr/man/u_man/man1 /usr/share/man/man1"
3000         syspath="$syspath /usr/catman/u_man/man1 /usr/man/l_man/man1"
3001         syspath="$syspath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
3002         syspath="$syspath /usr/man/man.L /local/man/man1 /usr/local/man/man1"
3003         sysman=`./loc . /usr/man/man1 $syspath`
3004         ;;
3005 esac
3006 if $test -d "$sysman"; then
3007         echo "System manual is in $sysman." >&4
3008 else
3009         echo "Could not find manual pages in source form." >&4
3010 fi
3011
3012 : see what memory models we can support
3013 case "$models" in
3014 '')
3015         $cat >pdp11.c <<'EOP'
3016 main() {
3017 #ifdef pdp11
3018         exit(0);
3019 #else
3020         exit(1);
3021 #endif
3022 }
3023 EOP
3024         (cc -o pdp11 pdp11.c) >/dev/null 2>&1
3025         if $test -f pdp11 && ./pdp11 2>/dev/null; then
3026                 dflt='unsplit split'
3027         else
3028                 tans=`./loc . X /lib/small /lib/large /usr/lib/small /usr/lib/large /lib/medium /usr/lib/medium /lib/huge`
3029                 case "$tans" in
3030                 X) dflt='none';;
3031                 *) if $test -d /lib/small || $test -d /usr/lib/small; then
3032                                 dflt='small'
3033                         else
3034                                 dflt=''
3035                         fi
3036                         if $test -d /lib/medium || $test -d /usr/lib/medium; then
3037                                 dflt="$dflt medium"
3038                         fi
3039                         if $test -d /lib/large || $test -d /usr/lib/large; then
3040                                 dflt="$dflt large"
3041                         fi
3042                         if $test -d /lib/huge || $test -d /usr/lib/huge; then
3043                                 dflt="$dflt huge"
3044                         fi
3045                 esac
3046         fi;;
3047 *) dflt="$models";;
3048 esac
3049 $cat <<EOM
3050  
3051 Some systems have different model sizes.  On most systems they are called
3052 small, medium, large, and huge.  On the PDP11 they are called unsplit and
3053 split.  If your system doesn't support different memory models, say "none".
3054 If you wish to force everything to one memory model, say "none" here and
3055 put the appropriate flags later when it asks you for other cc and ld flags.
3056 Venix systems may wish to put "none" and let the compiler figure things out.
3057 (In the following question multiple model names should be space separated.)
3058
3059 EOM
3060 rp="Which memory models are supported?"
3061 . ./myread
3062 models="$ans"
3063
3064 case "$models" in
3065 none)
3066         small=''
3067         medium=''
3068         large=''
3069         huge=''
3070         unsplit=''
3071         split=''
3072         ;;
3073 *split)
3074         case "$split" in
3075         '') if $contains '\-i' $sysman/ld.1 >/dev/null 2>&1 || \
3076                          $contains '\-i' $sysman/cc.1 >/dev/null 2>&1; then
3077                         dflt='-i'
3078                 else
3079                         dflt='none'
3080                 fi;;
3081         *) dflt="$split";;
3082         esac
3083         rp="What flag indicates separate I and D space?"
3084         . ./myread
3085         tans="$ans"
3086         case "$tans" in
3087         none) tans='';;
3088         esac
3089         split="$tans"
3090         unsplit='';;
3091 *large*|*small*|*medium*|*huge*)
3092         case "$models" in
3093         *large*)
3094                 case "$large" in
3095                 '') dflt='-Ml';;
3096                 *) dflt="$large";;
3097                 esac
3098         rp="What flag indicates large model?"
3099         . ./myread
3100         tans="$ans"
3101         case "$tans" in
3102         none) tans='';
3103         esac
3104         large="$tans";;
3105         *) large='';;
3106         esac
3107         case "$models" in
3108         *huge*) case "$huge" in
3109                 '') dflt='-Mh';;
3110                 *) dflt="$huge";;
3111                 esac
3112                 rp="What flag indicates huge model?"
3113                 . ./myread
3114                 tans="$ans"
3115                 case "$tans" in
3116                 none) tans='';
3117                 esac
3118                 huge="$tans";;
3119         *) huge="$large";;
3120         esac
3121         case "$models" in
3122         *medium*) case "$medium" in
3123                 '') dflt='-Mm';;
3124                 *) dflt="$medium";;
3125                 esac
3126                 rp="What flag indicates medium model?"
3127                 . ./myread
3128                 tans="$ans"
3129                 case "$tans" in
3130                 none) tans='';
3131                 esac
3132                 medium="$tans";;
3133         *) medium="$large";;
3134         esac
3135         case "$models" in
3136         *small*) case "$small" in
3137                 '') dflt='none';;
3138                 *) dflt="$small";;
3139                 esac
3140                 rp="What flag indicates small model?"
3141                 . ./myread
3142                 tans="$ans"
3143                 case "$tans" in
3144                 none) tans='';
3145                 esac
3146                 small="$tans";;
3147         *) small='';;
3148         esac
3149         ;;
3150 *)
3151         echo "Unrecognized memory models--you may have to edit Makefile.SH" >&4
3152         ;;
3153 esac
3154
3155 : see if we need a special compiler
3156 echo " "
3157 if ./usg; then
3158         case "$cc" in
3159         '') case "$Mcc" in
3160                 /*) dflt='Mcc';;
3161                 *) case "$large" in
3162                         -M*) dflt='cc';;
3163                         *)      if $contains '\-M' $sysman/cc.1 >/dev/null 2>&1 ; then
3164                                         if $contains '\-M' $sysman/cpp.1 >/dev/null 2>&1; then
3165                                                 dflt='cc'
3166                                         else
3167                                                 dflt='cc -M'
3168                                         fi
3169                                 else
3170                                         dflt='cc'
3171                                 fi;;
3172                         esac;;
3173                 esac;;
3174         *)  dflt="$cc";;
3175         esac
3176         $cat <<'EOM'
3177 On some systems the default C compiler will not resolve multiple global
3178 references that happen to have the same name.  On some such systems the "Mcc"
3179 command may be used to force these to be resolved.  On other systems a "cc -M"
3180 command is required.  (Note that the -M flag on other systems indicates a
3181 memory model to use!) If you have the Gnu C compiler, you might wish to use
3182 that instead.
3183
3184 EOM
3185         rp="What command will force resolution on this system?"
3186         . ./myread
3187         cc="$ans"
3188 else
3189         case "$cc" in
3190         '') dflt=cc;;
3191         *) dflt="$cc";;
3192         esac
3193         rp="Use which C compiler?"
3194         . ./myread
3195         cc="$ans"
3196 fi
3197 echo " "
3198 echo "Checking for GNU cc in disguise and/or its version number..." >&4
3199 $cat >gccvers.c <<EOM
3200 #include <stdio.h>
3201 int main() {
3202 #ifdef __GNUC__
3203 #ifdef __VERSION__
3204         printf("%s\n", __VERSION__);
3205 #else
3206         printf("%s\n", "1");
3207 #endif
3208 #endif
3209         exit(0);
3210 }
3211 EOM
3212 if $cc -o gccvers gccvers.c >/dev/null 2>&1; then
3213         gccversion=`./gccvers`
3214         case "$gccversion" in
3215         '') echo "You are not using GNU cc." ;;
3216         *)  echo "You are using GNU cc $gccversion." ;;
3217         esac
3218 else
3219         echo " "
3220         echo "*** WHOA THERE!!! ***" >&4
3221         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
3222         case "$knowitall" in
3223         '')
3224         echo "    You'd better start hunting for one and let me know about it." >&4
3225                 exit 1
3226                 ;;
3227         esac
3228 fi
3229 $rm -f gccvers*
3230 case "$gccversion" in
3231 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
3232 esac
3233
3234 : What should the include directory be ?
3235 echo " "
3236 $echo $n "Hmm...  $c"
3237 dflt='/usr/include'
3238 incpath=''
3239 mips_type=''
3240 if $test -f /bin/mips && /bin/mips; then
3241         echo "Looks like a MIPS system..."
3242         $cat >usr.c <<'EOCP'
3243 #ifdef SYSTYPE_BSD43
3244 /bsd43
3245 #endif
3246 EOCP
3247         if $cc -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
3248                 dflt='/bsd43/usr/include'
3249                 incpath='/bsd43'
3250                 mips_type='BSD 4.3'
3251         else
3252                 mips_type='System V'
3253         fi
3254         $rm -f usr.c usr.out
3255         echo "and you're compiling with the $mips_type compiler and libraries."
3256         xxx_prompt=y
3257         echo "exit 0" >mips
3258 else
3259         echo "Doesn't look like a MIPS system."
3260         xxx_prompt=n
3261         echo "exit 1" >mips
3262 fi
3263 chmod +x mips
3264 $eunicefix mips
3265 echo " "
3266 case "$usrinc" in
3267 '') ;;
3268 *) dflt="$usrinc";;
3269 esac
3270 case "$xxx_prompt" in
3271 y)      fn=d/
3272         rp='Where are the include files you want to use?'
3273         . ./getfile
3274         usrinc="$ans"
3275         ;;
3276 *)      usrinc="$dflt"
3277         ;;
3278 esac
3279
3280 : Set private lib path
3281 case "$plibpth" in
3282 '') if ./mips; then
3283                 plibpth="$incpath/usr/lib /usr/local/lib /usr/ccs/lib"
3284         fi;;
3285 esac
3286 case "$libpth" in
3287 ' ') dlist='';;
3288 '') dlist="$loclibpth $plibpth $glibpth";;
3289 *) dlist="$libpth";;
3290 esac
3291
3292 : Now check and see which directories actually exist, avoiding duplicates
3293 libpth=''
3294 for xxx in $dlist
3295 do
3296     if $test -d $xxx; then
3297                 case " $libpth " in
3298                 *" $xxx "*) ;;
3299                 *) libpth="$libpth $xxx";;
3300                 esac
3301     fi
3302 done
3303 $cat <<'EOM'
3304
3305 Some systems have incompatible or broken versions of libraries.  Among
3306 the directories listed in the question below, please remove any you
3307 know not to be holding relevant libraries, and add any that are needed.
3308 Say "none" for none.
3309
3310 EOM
3311 case "$libpth" in
3312 '') dflt='none';;
3313 *)
3314         set X $libpth
3315         shift
3316         dflt=${1+"$@"}
3317         ;;
3318 esac
3319 rp="Directories to use for library searches?"
3320 . ./myread
3321 case "$ans" in
3322 none) libpth=' ';;
3323 *) libpth="$ans";;
3324 esac
3325
3326 : Define several unixisms. Hints files or command line options
3327 : can be used to override them.
3328 case "$ar" in
3329 '') ar='ar';;
3330 esac
3331 case "$lib_ext" in
3332 '') lib_ext='.a';;
3333 esac
3334 case "$obj_ext" in
3335 '') obj_ext='.o';;
3336 esac
3337 case "$path_sep" in
3338 '') path_sep=':';;
3339 esac
3340 : Which makefile gets called first.  This is used by make depend.
3341 case "$firstmakefile" in
3342 '') firstmakefile='makefile';;
3343 esac
3344
3345 : compute shared library extension
3346 case "$so" in
3347 '')
3348         if xxx=`./loc libc.sl X $libpth`; $test -f "$xxx"; then
3349                 dflt='sl'
3350         else
3351                 dflt='so'
3352         fi
3353         ;;
3354 *) dflt="$so";;
3355 esac
3356 $cat <<EOM
3357
3358 On some systems, shared libraries may be available.  Answer 'none' if
3359 you want to suppress searching of shared libraries for the remaining
3360 of this configuration.
3361
3362 EOM
3363 rp='What is the file extension used for shared libraries?'
3364 . ./myread
3365 so="$ans"
3366
3367 : Looking for optional libraries
3368 echo " "
3369 echo "Checking for optional libraries..." >&4
3370 case "$libs" in
3371 ' '|'') dflt='';;
3372 *) dflt="$libs";;
3373 esac
3374 case "$libswanted" in
3375 '') libswanted='c_s';;
3376 esac
3377 for thislib in $libswanted; do
3378         
3379         if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`; $test -f "$xxx"; then
3380                 echo "Found -l$thislib (shared)."
3381                 case " $dflt " in
3382                 *"-l$thislib "*);;
3383                 *) dflt="$dflt -l$thislib";;
3384                 esac
3385         elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
3386                 echo "Found -l$thislib (shared)."
3387                 case " $dflt " in
3388                 *"-l$thislib "*);;
3389                 *) dflt="$dflt -l$thislib";;
3390                 esac
3391         elif xxx=`./loc lib$thislib$lib_ext X $libpth`; $test -f "$xxx"; then
3392                 echo "Found -l$thislib."
3393                 case " $dflt " in
3394                 *"-l$thislib "*);;
3395                 *) dflt="$dflt -l$thislib";;
3396                 esac
3397         elif xxx=`./loc $thislib$lib_ext X $libpth`; $test -f "$xxx"; then
3398                 echo "Found -l$thislib."
3399                 case " $dflt " in
3400                 *"-l$thislib "*);;
3401                 *) dflt="$dflt -l$thislib";;
3402                 esac
3403         elif xxx=`./loc lib${thislib}_s$lib_ext X $libpth`; $test -f "$xxx"; then
3404                 echo "Found -l${thislib}_s."
3405                 case " $dflt " in
3406                 *"-l$thislib "*);;
3407                 *) dflt="$dflt -l${thislib}_s";;
3408                 esac
3409         elif xxx=`./loc Slib$thislib$lib_ext X $xlibpth`; $test -f "$xxx"; then
3410                 echo "Found -l$thislib."
3411                 case " $dflt " in
3412                 *"-l$thislib "*);;
3413                 *) dflt="$dflt -l$thislib";;
3414                 esac
3415         else
3416                 echo "No -l$thislib."
3417         fi
3418 done
3419 set X $dflt
3420 shift
3421 dflt="$*"
3422 case "$libs" in
3423 '') dflt="$dflt";;
3424 *) dflt="$libs";;
3425 esac
3426 case "$dflt" in
3427 ' '|'') dflt='none';;
3428 esac
3429
3430 $cat <<EOM
3431  
3432 Some versions of Unix support shared libraries, which make executables smaller
3433 but make load time slightly longer.
3434
3435 On some systems, mostly System V Release 3's, the shared library is included
3436 by putting the option "-lc_s" as the last thing on the cc command line when
3437 linking.  Other systems use shared libraries by default.  There may be other
3438 libraries needed to compile $package on your machine as well.  If your system
3439 needs the "-lc_s" option, include it here.  Include any other special libraries
3440 here as well.  Say "none" for none.
3441 EOM
3442
3443 echo " "
3444 rp="Any additional libraries?"
3445 . ./myread
3446 case "$ans" in
3447 none) libs=' ';;
3448 *) libs="$ans";;
3449 esac
3450
3451 : see how we invoke the C preprocessor
3452 echo " "
3453 echo "Now, how can we feed standard input to your C preprocessor..." >&4
3454 cat <<'EOT' >testcpp.c
3455 #define ABC abc
3456 #define XYZ xyz
3457 ABC.XYZ
3458 EOT
3459 cd ..
3460 echo 'cat >.$$.c; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
3461 chmod 755 cppstdin
3462 wrapper=`pwd`/cppstdin
3463 ok='false'
3464 cd UU
3465
3466 if $test "X$cppstdin" != "X" && \
3467         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
3468         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3469 then
3470         echo "You used to use $cppstdin $cppminus so we'll use that again."
3471         case "$cpprun" in
3472         '') echo "But let's see if we can live without a wrapper..." ;;
3473         *)
3474                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
3475                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3476                 then
3477                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
3478                         ok='true'
3479                 else
3480                         echo "(However, $cpprun $cpplast does not work, let's see...)"
3481                 fi
3482                 ;;
3483         esac
3484 else
3485         case "$cppstdin" in
3486         '') ;;
3487         *)
3488                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
3489                 ;;
3490         esac
3491 fi
3492
3493 if $ok; then
3494         : nothing
3495 elif echo 'Maybe "'"$cc"' -E" will work...'; \
3496         $cc -E <testcpp.c >testcpp.out 2>&1; \
3497         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3498         echo "Yup, it does."
3499         x_cpp="$cc -E"
3500         x_minus='';
3501 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
3502         $cc -E - <testcpp.c >testcpp.out 2>&1; \
3503         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3504         echo "Yup, it does."
3505         x_cpp="$cc -E"
3506         x_minus='-';
3507 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
3508         $cc -P <testcpp.c >testcpp.out 2>&1; \
3509         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3510         echo "Yipee, that works!"
3511         x_cpp="$cc -P"
3512         x_minus='';
3513 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
3514         $cc -P - <testcpp.c >testcpp.out 2>&1; \
3515         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3516         echo "At long last!"
3517         x_cpp="$cc -P"
3518         x_minus='-';
3519 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
3520         $cpp <testcpp.c >testcpp.out 2>&1; \
3521         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3522         echo "It works!"
3523         x_cpp="$cpp"
3524         x_minus='';
3525 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
3526         $cpp - <testcpp.c >testcpp.out 2>&1; \
3527         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3528         echo "Hooray, it works!  I was beginning to wonder."
3529         x_cpp="$cpp"
3530         x_minus='-';
3531 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
3532         $wrapper <testcpp.c >testcpp.out 2>&1; \
3533         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3534         x_cpp="$wrapper"
3535         x_minus=''
3536         echo "Eureka!"
3537 else
3538         dflt=''
3539         rp="No dice.  I can't find a C preprocessor.  Name one:"
3540         . ./myread
3541         x_cpp="$ans"
3542         x_minus=''
3543         $x_cpp <testcpp.c >testcpp.out 2>&1
3544         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
3545                 echo "OK, that will do." >&4
3546         else
3547 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
3548                 exit 1
3549         fi
3550 fi
3551
3552 case "$ok" in
3553 false)
3554         cppstdin="$x_cpp"
3555         cppminus="$x_minus"
3556         cpprun="$x_cpp"
3557         cpplast="$x_minus"
3558         set X $x_cpp
3559         shift
3560         case "$1" in
3561         "$cpp")
3562                 echo "Perhaps can we force $cc -E using a wrapper..."
3563                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
3564                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
3565                 then
3566                         echo "Yup, we can."
3567                         cppstdin="$wrapper"
3568                         cppminus='';
3569                 else
3570                         echo "Nope, we'll have to live without it..."
3571                 fi
3572                 ;;
3573         esac
3574         case "$cpprun" in
3575         "$wrapper")
3576                 cpprun=''
3577                 cpplast=''
3578                 ;;
3579         esac
3580         ;;
3581 esac
3582
3583 case "$cppstdin" in
3584 "$wrapper") ;;
3585 *) $rm -f $wrapper;;
3586 esac
3587 $rm -f testcpp.c testcpp.out
3588
3589 : determine optimize, if desired, or use for debug flag also
3590 case "$optimize" in
3591 ' '|$undef) dflt='none';;
3592 '') dflt='-O';;
3593 *) dflt="$optimize";;
3594 esac
3595 $cat <<EOH
3596
3597 Some C compilers have problems with their optimizers.  By default, $package
3598 compiles with the -O flag to use the optimizer.  Alternately, you might want
3599 to use the symbolic debugger, which uses the -g flag (on traditional Unix
3600 systems).  Either flag can be specified here.  To use neither flag, specify
3601 the word "none".
3602
3603 EOH
3604 rp="What optimizer/debugger flag should be used?"
3605 . ./myread
3606 optimize="$ans"
3607 case "$optimize" in
3608 'none') optimize=" ";;
3609 esac
3610
3611 dflt=''
3612 : We will not override a previous value, but we might want to
3613 : augment a hint file
3614 case "$hint" in
3615 none|recommended)
3616         case "$gccversion" in
3617         1*) dflt='-fpcc-struct-return' ;;
3618         esac
3619         case "$optimize" in
3620         *-g*) dflt="$dflt -DDEBUGGING";;
3621         esac
3622         case "$gccversion" in
3623         2*) if test -d /etc/conf/kconfig.d &&
3624                         $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1
3625                 then
3626                         dflt="$dflt -posix"
3627                 fi
3628                 ;;
3629         esac
3630         ;;
3631 esac
3632
3633 case "$mips_type" in
3634 *BSD*|'') inclwanted="$locincpth $usrinc";;
3635 *) inclwanted="$locincpth $inclwanted $usrinc/bsd";;
3636 esac
3637 for thisincl in $inclwanted; do
3638         if $test -d $thisincl; then
3639                 if $test x$thisincl != x$usrinc; then
3640                         case "$dflt" in
3641                         *$thisincl*);;
3642                         *) dflt="$dflt -I$thisincl";;
3643                         esac
3644                 fi
3645         fi
3646 done
3647
3648 inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then
3649         xxx=true;
3650 elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then
3651         xxx=true;
3652 else
3653         xxx=false;
3654 fi;
3655 if $xxx; then
3656         case "$dflt" in
3657         *$2*);;
3658         *) dflt="$dflt -D$2";;
3659         esac;
3660 fi'
3661
3662 if ./osf1; then
3663         set signal.h __LANGUAGE_C__; eval $inctest
3664 else
3665         set signal.h LANGUAGE_C; eval $inctest
3666 fi
3667
3668 case "$hint" in
3669 none|recommended) dflt="$ccflags $dflt" ;;
3670 *) dflt="$ccflags";;
3671 esac
3672
3673 case "$dflt" in
3674 ''|' ') dflt=none;;
3675 esac
3676 $cat <<EOH
3677
3678 Your C compiler may want other flags.  For this question you should include
3679 -I/whatever and -DWHATEVER flags and any other flags used by the C compiler,
3680 but you should NOT include libraries or ld flags like -lwhatever.  If you
3681 want $package to honor its debug switch, you should include -DDEBUGGING here.
3682 Your C compiler might also need additional flags, such as -D_POSIX_SOURCE,
3683 -DHIDEMYMALLOC or -DCRIPPLED_CC.
3684
3685 To use no flags, specify the word "none".
3686
3687 EOH
3688 set X $dflt
3689 shift
3690 dflt=${1+"$@"}
3691 rp="Any additional cc flags?"
3692 . ./myread
3693 case "$ans" in
3694 none) ccflags='';;
3695 *) ccflags="$ans";;
3696 esac
3697
3698 : the following weeds options from ccflags that are of no interest to cpp
3699 cppflags="$ccflags"
3700 case "$gccversion" in
3701 1*) cppflags="$cppflags -D__GNUC__"
3702 esac
3703 case "$mips_type" in
3704 '');;
3705 *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";;
3706 esac
3707 case "$cppflags" in
3708 '');;
3709 *)
3710         echo " "
3711         echo "Let me guess what the preprocessor flags are..." >&4
3712         set X $cppflags
3713         shift
3714         cppflags=''
3715         $cat >cpp.c <<'EOM'
3716 #define BLURFL foo
3717
3718 BLURFL xx LFRULB
3719 EOM
3720         previous=''
3721         for flag in $*
3722         do
3723                 case "$flag" in
3724                 -*) ftry="$flag";;
3725                 *) ftry="$previous $flag";;
3726                 esac
3727                 if $cppstdin -DLFRULB=bar $cppflags $ftry $cppminus <cpp.c \
3728                         >cpp1.out 2>/dev/null && \
3729                         $cpprun -DLFRULB=bar $ftry $cpplast <cpp.c \
3730                         >cpp2.out 2>/dev/null && \
3731                         $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \
3732                         $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1
3733                 then
3734                         cppflags="$cppflags $ftry"
3735                         previous=''
3736                 else
3737                         previous="$flag"
3738                 fi
3739         done
3740         set X $cppflags
3741         shift
3742         cppflags=${1+"$@"}
3743         case "$cppflags" in
3744         *-*)  echo "They appear to be: $cppflags";;
3745         esac
3746         $rm -f cpp.c cpp?.out
3747         ;;
3748 esac
3749
3750 : flags used in final linking phase
3751
3752 case "$ldflags" in
3753 '') if ./venix; then
3754                 dflt='-i -z'
3755         else
3756                 dflt=''
3757         fi
3758         case "$ccflags" in
3759         *-posix*) dflt="$dflt -posix" ;;
3760         esac
3761         ;;
3762 *) dflt="$ldflags";;
3763 esac
3764
3765 : Try to guess additional flags to pick up local libraries.
3766 for thislibdir in $libpth; do
3767         case " $loclibpth " in
3768         *" $thislibdir "*)
3769                 case "$dflt " in 
3770                 *"-L$thislibdir "*) ;;
3771                 *)  dflt="$dflt -L$thislibdir" ;;
3772                 esac
3773                 ;;
3774         esac
3775 done
3776
3777 case "$dflt" in
3778 '') dflt='none' ;;
3779 esac
3780
3781 $cat <<EOH
3782
3783 Your C linker may need flags.  For this question you should
3784 include -L/whatever and any other flags used by the C linker, but you
3785 should NOT include libraries like -lwhatever.
3786
3787 Make sure you include the appropriate -L/path flags if your C linker
3788 does not normally search all of the directories you specified above,
3789 namely
3790         $libpth
3791 To use no flags, specify the word "none".
3792
3793 EOH
3794
3795 rp="Any additional ld flags (NOT including libraries)?"
3796 . ./myread
3797 case "$ans" in
3798 none) ldflags='';;
3799 *) ldflags="$ans";;
3800 esac
3801 rmlist="$rmlist pdp11"
3802
3803 : coherency check
3804 echo " "
3805 echo "Checking your choice of C compiler, libs, and flags for coherency..." >&4
3806 set X $cc $optimize $ccflags $ldflags -o try try.c $libs
3807 shift
3808 $cat >try.msg <<EOM
3809 I've tried to compile and run a simple program with:
3810
3811         $*
3812         ./try
3813
3814 and I got the following output:
3815
3816 EOM
3817 $cat > try.c <<'EOF'
3818 #include <stdio.h>
3819 main() { exit(0); }
3820 EOF
3821 dflt=y
3822 if sh -c "$cc $optimize $ccflags -o try try.c $ldflags $libs" >>try.msg 2>&1; then
3823         if sh -c './try' >>try.msg 2>&1; then
3824                 dflt=n
3825         else
3826                 echo "The program compiled OK, but exited with status $?." >>try.msg
3827                 rp="You have a problem.  Shall I abort Configure (and explain the problem)"
3828                 dflt=y
3829         fi
3830 else
3831         echo "I can't compile the test program." >>try.msg
3832         rp="You have a BIG problem.  Shall I abort Configure (and explain the problem)"
3833         dflt=y
3834 fi
3835 case "$dflt" in
3836 y)
3837         $cat try.msg >&4
3838         case "$knowitall" in
3839         '')
3840                 echo "(The supplied flags might be incorrect with this C compiler.)"
3841                 ;;
3842         *) dflt=n;;
3843         esac
3844         echo " "
3845         . ./myread
3846         case "$ans" in
3847         n*|N*) ;;
3848         *)      echo "Ok.  Stopping Configure." >&4
3849                 exit 1
3850                 ;;
3851         esac
3852         ;;
3853 n) echo "OK, that should do.";;
3854 esac
3855 $rm -f try try.* core
3856
3857 echo " "
3858 echo "Checking for GNU C Library..." >&4
3859 cat >gnulibc.c <<EOM
3860 int
3861 main()
3862 {
3863   return __libc_main();
3864 }
3865 EOM
3866 if $cc $ccflags $ldflags -o gnulibc gnulibc.c $libs >/dev/null 2>&1 && \
3867     ./gnulibc | $contains '^GNU C Library' >/dev/null 2>&1; then
3868         val="$define"
3869         echo "You are using the GNU C Library"
3870 else
3871         val="$undef"
3872         echo "You are not using the GNU C Library"
3873 fi
3874 $rm -f gnulibc*
3875 set d_gnulibc
3876 eval $setvar
3877
3878 : see if nm is to be used to determine whether a symbol is defined or not
3879 case "$usenm" in
3880 '')
3881         case "$d_gnulibc" in
3882         $define)
3883                 dflt=n
3884                 ;;
3885         *)
3886                 dflt=`egrep 'inlibc|csym' ../Configure | wc -l 2>/dev/null`
3887                 if $test $dflt -gt 20; then
3888                         dflt=y
3889                 else
3890                         dflt=n
3891                 fi
3892                 ;;
3893         esac
3894         ;;
3895 *)
3896         case "$usenm" in
3897         true) dflt=y;;
3898         *) dflt=n;;
3899         esac
3900         ;;
3901 esac
3902 $cat <<EOM
3903
3904 I can use 'nm' to extract the symbols from your C libraries. This is a time
3905 consuming task which may generate huge output on the disk (up to 3 megabytes)
3906 but that should make the symbols extraction faster. The alternative is to skip
3907 the 'nm' extraction part and to compile a small test program instead to
3908 determine whether each symbol is present. If you have a fast C compiler and/or
3909 if your 'nm' output cannot be parsed, this may be the best solution.
3910 You shouldn't let me use 'nm' if you have the GNU C Library.
3911
3912 EOM
3913 rp='Shall I use nm to extract C symbols from the libraries?'
3914 . ./myread
3915 case "$ans" in
3916 n|N) usenm=false;;
3917 *) usenm=true;;
3918 esac
3919
3920 runnm=$usenm
3921 case "$reuseval" in
3922 true) runnm=false;;
3923 esac
3924
3925 : nm options which may be necessary
3926 case "$nm_opt" in
3927 '') if $test -f /mach_boot; then
3928                 nm_opt=''       # Mach
3929         elif $test -d /usr/ccs/lib; then
3930                 nm_opt='-p'     # Solaris (and SunOS?)
3931         elif $test -f /dgux; then
3932                 nm_opt='-p'     # DG-UX
3933         elif $test -f /lib64/rld; then
3934                 nm_opt='-p'     # 64-bit Irix
3935         else
3936                 nm_opt=''
3937         fi;;
3938 esac
3939
3940 : nm options which may be necessary for shared libraries but illegal
3941 : for archive libraries.  Thank you, Linux.
3942 case "$nm_so_opt" in
3943 '')     case "$myuname" in
3944         *linux*)
3945                 if nm --help | $grep 'dynamic' > /dev/null 2>&1; then
3946                         nm_so_opt='--dynamic'
3947                 fi
3948                 ;;
3949         esac
3950         ;;
3951 esac
3952
3953 case "$runnm" in
3954 true)
3955 : get list of predefined functions in a handy place
3956 echo " "
3957 case "$libc" in
3958 '') libc=unknown
3959         case "$libs" in
3960         *-lc_s*) libc=`./loc libc_s$lib_ext $libc $libpth`
3961         esac
3962         ;;
3963 esac
3964 libnames='';
3965 case "$libs" in
3966 '') ;;
3967 *)  for thislib in $libs; do
3968         case "$thislib" in
3969         -lc|-lc_s)
3970                 : Handle C library specially below.
3971                 ;;
3972         -l*)
3973                 thislib=`echo $thislib | $sed -e 's/^-l//'`
3974                 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
3975                         :
3976                 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
3977                         :
3978                 elif try=`./loc lib$thislib$lib_ext X $libpth`; $test -f "$try"; then
3979                         :
3980                 elif try=`./loc $thislib$lib_ext X $libpth`; $test -f "$try"; then
3981                         :
3982                 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
3983                         :
3984                 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
3985                         :
3986                 elif try=`./loc Slib$thislib$lib_ext X $xlibpth`; $test -f "$try"; then
3987                         :
3988                 else
3989                         try=''
3990                 fi
3991                 libnames="$libnames $try"
3992                 ;;
3993         *) libnames="$libnames $thislib" ;;
3994         esac
3995         done
3996         ;;
3997 esac
3998 xxx=normal
3999 case "$libc" in
4000 unknown)
4001         set /lib/libc.$so
4002         for xxx in $libpth; do
4003                 $test -r $1 || set $xxx/libc.$so
4004                 : The messy sed command sorts on library version numbers.
4005                 $test -r $1 || \
4006                         set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
4007                                 tr ' ' '\012' | egrep -v '\.[A-Za-z]*$' | $sed -e '
4008                                 h
4009                                 s/[0-9][0-9]*/0000&/g
4010                                 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
4011                                 G
4012                                 s/\n/ /' | \
4013                         sort | $sed -e 's/^.* //'`
4014                 eval set \$$#
4015         done
4016         $test -r $1 || set /usr/ccs/lib/libc.$so
4017         $test -r $1 || set /lib/libsys_s$lib_ext
4018         ;;
4019 *)
4020         set blurfl
4021         ;;
4022 esac
4023 if $test -r "$1"; then
4024         echo "Your (shared) C library seems to be in $1."
4025         libc="$1"
4026 elif $test -r /lib/libc && $test -r /lib/clib; then
4027         echo "Your C library seems to be in both /lib/clib and /lib/libc."
4028         xxx=apollo
4029         libc='/lib/clib /lib/libc'
4030         if $test -r /lib/syslib; then
4031                 echo "(Your math library is in /lib/syslib.)"
4032                 libc="$libc /lib/syslib"
4033         fi
4034 elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4035         echo "Your C library seems to be in $libc, as you said before."
4036 elif $test -r $incpath/usr/lib/libc$lib_ext; then
4037         libc=$incpath/usr/lib/libc$lib_ext;
4038         echo "Your C library seems to be in $libc.  That's fine."
4039 elif $test -r /lib/libc$lib_ext; then
4040         libc=/lib/libc$lib_ext;
4041         echo "Your C library seems to be in $libc.  You're normal."
4042 else
4043         if tans=`./loc libc$lib_ext blurfl/dyick $libpth`; $test -r "$tans"; then
4044                 :
4045         elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
4046                 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
4047         elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
4048                 :
4049         elif tans=`./loc Slibc$lib_ext blurfl/dyick $xlibpth`; $test -r "$tans"; then
4050                 :
4051         elif tans=`./loc Mlibc$lib_ext blurfl/dyick $xlibpth`; $test -r "$tans"; then
4052                 :
4053         else
4054                 tans=`./loc Llibc$lib_ext blurfl/dyick $xlibpth`
4055         fi
4056         if $test -r "$tans"; then
4057                 echo "Your C library seems to be in $tans, of all places."
4058                 libc=$tans
4059         else
4060                 libc='blurfl'
4061         fi
4062 fi
4063 if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
4064         dflt="$libc"
4065         cat <<EOM
4066
4067 If the guess above is wrong (which it might be if you're using a strange
4068 compiler, or your machine supports multiple models), you can override it here.
4069
4070 EOM
4071 else
4072         dflt=''
4073         echo $libpth | tr ' ' '\012' | sort | uniq > libpath
4074         cat >&4 <<EOM
4075 I can't seem to find your C library.  I've looked in the following places:
4076
4077 EOM
4078         $sed 's/^/      /' libpath
4079         cat <<EOM
4080
4081 None of these seems to contain your C library. I need to get its name...
4082
4083 EOM
4084 fi
4085 fn=f
4086 rp='Where is your C library?'
4087 . ./getfile
4088 libc="$ans"
4089
4090 echo " "
4091 echo $libc $libnames | tr ' ' '\012' | sort | uniq > libnames
4092 set X `cat libnames`
4093 shift
4094 xxx=files
4095 case $# in 1) xxx=file; esac
4096 echo "Extracting names from the following $xxx for later perusal:" >&4
4097 echo " "
4098 $sed 's/^/      /' libnames >&4
4099 echo " "
4100 $echo $n "This may take a while...$c" >&4
4101
4102 : Linux may need the special Dynamic option to nm for shared libraries.
4103 : In general, this is stored in the nm_so_opt variable.
4104 : Unfortunately, that option may be fatal on non-shared libraries.
4105 for nm_libs_ext in $*; do
4106     case $nm_libs_ext in
4107         *$so*)  nm $nm_so_opt $nm_opt $nm_libs_ext 2>/dev/null ;;
4108         *)              nm $nm_opt $nm_libs_ext 2>/dev/null ;;
4109         esac
4110 done > libc.tmp
4111
4112 $echo $n ".$c"
4113 $grep fprintf libc.tmp > libc.ptf
4114 xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
4115 xrun='eval "<libc.tmp $com >libc.list"; echo "done" >&4'
4116 xxx='[ADTSIW]'
4117 if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx  *_[_.]*//p' -e 's/^.* $xxx  *//p'";\
4118         eval $xscan;\
4119         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4120                 eval $xrun
4121 elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
4122         eval $xscan;\
4123         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4124                 eval $xrun
4125 elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
4126         eval $xscan;\
4127         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4128                 eval $xrun
4129 elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
4130         eval $xscan;\
4131         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4132                 eval $xrun
4133 elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
4134         eval $xscan;\
4135         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4136                 eval $xrun
4137 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
4138         eval $xscan;\
4139         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4140                 eval $xrun
4141 elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
4142                                 -e '/ file/d' -e 's/^\([^       ]*\).*/\1/p'";\
4143         eval $xscan;\
4144         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4145                 eval $xrun
4146 elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
4147         eval $xscan;\
4148         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4149                 eval $xrun
4150 elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
4151         eval $xscan;\
4152         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4153                 eval $xrun
4154 elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
4155         eval $xscan;\
4156         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4157                 eval $xrun
4158 elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
4159         eval $xscan;\
4160         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4161                 eval $xrun
4162 elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
4163         eval $xscan;\
4164         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4165                 eval $xrun
4166 elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
4167         eval $xscan;\
4168         $contains '^fprintf$' libc.list >/dev/null 2>&1; then
4169                 eval $xrun
4170 else
4171         nm -p $* 2>/dev/null >libc.tmp
4172         $grep fprintf libc.tmp > libc.ptf
4173         if com="$sed -n -e 's/^.* [ADTSIW]  *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
4174                 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
4175         then
4176                 nm_opt='-p'
4177                 eval $xrun
4178         else
4179                 echo " "
4180                 echo "nm didn't seem to work right. Trying ar instead..." >&4
4181                 com=''
4182                 if ar t $libc > libc.tmp; then
4183                         for thisname in $libnames; do
4184                                 ar t $thisname >>libc.tmp
4185                         done
4186                         $sed -e 's/\.o$//' < libc.tmp > libc.list
4187                         echo "Ok." >&4
4188                 else
4189                         echo "ar didn't seem to work right." >&4
4190                         echo "Maybe this is a Cray...trying bld instead..." >&4
4191                         if bld t $libc | $sed -e 's/.*\///' -e 's/\.o:.*$//' > libc.list
4192                         then
4193                                 for thisname in $libnames; do
4194                                         bld t $libnames | \
4195                                         $sed -e 's/.*\///' -e 's/\.o:.*$//' >>libc.list
4196                                         ar t $thisname >>libc.tmp
4197                                 done
4198                                 echo "Ok." >&4
4199                         else
4200                                 echo "That didn't work either.  Giving up." >&4
4201                                 exit 1
4202                         fi
4203                 fi
4204         fi
4205 fi
4206 nm_extract="$com"
4207 if $test -f /lib/syscalls.exp; then
4208         echo " "
4209         echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
4210         $sed -n 's/^\([^        ]*\)[   ]*syscall$/\1/p' /lib/syscalls.exp >>libc.list
4211 fi
4212 ;;
4213 esac
4214 $rm -f libnames libpath
4215
4216 : determine filename position in cpp output
4217 echo " "
4218 echo "Computing filename position in cpp output for #include directives..." >&4
4219 echo '#include <stdio.h>' > foo.c
4220 $cat >fieldn <<EOF
4221 $startsh
4222 $cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
4223 $grep '^[       ]*#.*stdio\.h' | \
4224 while read cline; do
4225         pos=1
4226         set \$cline
4227         while $test \$# -gt 0; do
4228                 if $test -r \`echo \$1 | $tr -d '"'\`; then
4229                         echo "\$pos"
4230                         exit 0
4231                 fi
4232                 shift
4233                 pos=\`expr \$pos + 1\`
4234         done
4235 done
4236 EOF
4237 chmod +x fieldn
4238 fieldn=`./fieldn`
4239 $rm -f foo.c fieldn
4240 case $fieldn in
4241 '') pos='???';;
4242 1) pos=first;;
4243 2) pos=second;;
4244 3) pos=third;;
4245 *) pos="${fieldn}th";;
4246 esac
4247 echo "Your cpp writes the filename in the $pos field of the line."
4248
4249 : locate header file
4250 $cat >findhdr <<EOF
4251 $startsh
4252 wanted=\$1
4253 name=''
4254 if test -f $usrinc/\$wanted; then
4255         echo "$usrinc/\$wanted"
4256         exit 0
4257 fi
4258 awkprg='{ print \$$fieldn }'
4259 echo "#include <\$wanted>" > foo\$\$.c
4260 $cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
4261 $grep "^[       ]*#.*\$wanted" | \
4262 while read cline; do
4263         name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
4264         case "\$name" in
4265         */\$wanted) echo "\$name"; exit 0;;
4266         *) name='';;
4267         esac;
4268 done;
4269 $rm -f foo\$\$.c;
4270 case "\$name" in
4271 '') exit 1;;
4272 esac
4273 EOF
4274 chmod +x findhdr
4275
4276 : define an alternate in-header-list? function
4277 inhdr='echo " "; td=$define; tu=$undef; yyy=$@;
4278 cont=true; xxf="echo \"<\$1> found.\" >&4";
4279 case $# in 2) xxnf="echo \"<\$1> NOT found.\" >&4";;
4280 *) xxnf="echo \"<\$1> NOT found, ...\" >&4";;
4281 esac;
4282 case $# in 4) instead=instead;; *) instead="at last";; esac;
4283 while $test "$cont"; do
4284         xxx=`./findhdr $1`
4285         var=$2; eval "was=\$$2";
4286         if $test "$xxx" && $test -r "$xxx";
4287         then eval $xxf;
4288         eval "case \"\$$var\" in $undef) . ./whoa; esac"; eval "$var=\$td";
4289                 cont="";
4290         else eval $xxnf;
4291         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu"; fi;
4292         set $yyy; shift; shift; yyy=$@;
4293         case $# in 0) cont="";;
4294         2) xxf="echo \"but I found <\$1> $instead.\" >&4";
4295                 xxnf="echo \"and I did not find <\$1> either.\" >&4";;
4296         *) xxf="echo \"but I found <\$1\> instead.\" >&4";
4297                 xxnf="echo \"there is no <\$1>, ...\" >&4";;
4298         esac;
4299 done;
4300 while $test "$yyy";
4301 do set $yyy; var=$2; eval "was=\$$2";
4302         eval "case \"\$$var\" in $define) . ./whoa; esac"; eval "$var=\$tu";
4303         set $yyy; shift; shift; yyy=$@;
4304 done'
4305
4306 : see if dld is available
4307 set dld.h i_dld
4308 eval $inhdr
4309
4310 : is a C symbol defined?
4311 csym='tlook=$1;
4312 case "$3" in
4313 -v) tf=libc.tmp; tc=""; tdc="";;
4314 -a) tf=libc.tmp; tc="[0]"; tdc="[]";;
4315 *) tlook="^$1\$"; tf=libc.list; tc="()"; tdc="()";;
4316 esac;
4317 tx=yes;
4318 case "$reuseval-$4" in
4319 true-) ;;
4320 true-*) tx=no; eval "tval=\$$4"; case "$tval" in "") tx=yes;; esac;;
4321 esac;
4322 case "$tx" in
4323 yes)
4324         case "$runnm" in
4325         true)
4326                 if $contains $tlook $tf >/dev/null 2>&1;
4327                 then tval=true;
4328                 else tval=false;
4329                 fi;;
4330         *)
4331                 echo "main() { extern short $1$tdc; printf(\"%hd\", $1$tc); }" > t.c;
4332                 if $cc $ccflags $ldflags -o t t.c $libs >/dev/null 2>&1;
4333                 then tval=true;
4334                 else tval=false;
4335                 fi;
4336                 $rm -f t t.c;;
4337         esac;;
4338 *)
4339         case "$tval" in
4340         $define) tval=true;;
4341         *) tval=false;;
4342         esac;;
4343 esac;
4344 eval "$2=$tval"'
4345
4346 : define an is-in-libc? function
4347 inlibc='echo " "; td=$define; tu=$undef;
4348 sym=$1; var=$2; eval "was=\$$2";
4349 tx=yes;
4350 case "$reuseval$was" in
4351 true) ;;
4352 true*) tx=no;;
4353 esac;
4354 case "$tx" in
4355 yes)
4356         set $sym tres -f;
4357         eval $csym;
4358         case "$tres" in
4359         true)
4360                 echo "$sym() found." >&4;
4361                 case "$was" in $undef) . ./whoa; esac; eval "$var=\$td";;
4362         *)
4363                 echo "$sym() NOT found." >&4;
4364                 case "$was" in $define) . ./whoa; esac; eval "$var=\$tu";;
4365         esac;;
4366 *)
4367         case "$was" in
4368         $define) echo "$sym() found." >&4;;
4369         *) echo "$sym() NOT found." >&4;;
4370         esac;;
4371 esac'
4372
4373 : see if dlopen exists
4374 xxx_runnm="$runnm"
4375 runnm=false
4376 set dlopen d_dlopen
4377 eval $inlibc
4378 runnm="$xxx_runnm"
4379
4380 : determine which dynamic loading, if any, to compile in
4381 echo " "
4382 dldir="ext/DynaLoader"
4383 case "$usedl" in
4384 $define|y|true)
4385         dflt='y'
4386         usedl="$define"
4387         ;;
4388 $undef|n|false)
4389         dflt='n'
4390         usedl="$undef"
4391         ;;
4392 *) 
4393         dflt='n'
4394         case "$d_dlopen" in
4395             $define) dflt='y' ;;
4396         esac
4397         case "$i_dld" in
4398             $define) dflt='y' ;;
4399         esac
4400         : Does a dl_xxx.xs file exist for this operating system
4401         $test -f ../$dldir/dl_${osname}.xs && dflt='y'
4402         ;;
4403 esac
4404 rp="Do you wish to use dynamic loading?"
4405 . ./myread
4406 usedl="$ans"
4407 case "$ans" in
4408 y*) usedl="$define"
4409         case "$dlsrc" in
4410         '')
4411                 if $test -f ../$dldir/dl_${osname}.xs ; then
4412                         dflt="$dldir/dl_${osname}.xs"
4413                 elif $test "$d_dlopen" = "$define" ; then
4414                         dflt="$dldir/dl_dlopen.xs"
4415                 elif $test "$i_dld" = "$define" ; then
4416                         dflt="$dldir/dl_dld.xs"
4417                 else
4418                         dflt=''
4419                 fi
4420                 ;;
4421         *)      dflt="$dldir/$dlsrc"
4422                 ;;
4423         esac
4424     echo "The following dynamic loading files are available:"
4425         : Can not go over to $dldir because getfile has path hard-coded in.
4426     cd ..; ls -C $dldir/dl*.xs; cd UU
4427     rp="Source file to use for dynamic loading"
4428     fn="fne"
4429     . ./getfile
4430         usedl="$define"
4431         : emulate basename
4432         dlsrc=`echo $ans | $sed -e 's@.*/\([^/]*\)$@\1@'`
4433
4434     $cat << EOM
4435
4436 Some systems may require passing special flags to $cc -c to
4437 compile modules that will be used to create a shared library.
4438 To use no flags, say "none".
4439
4440 EOM
4441     case "$cccdlflags" in
4442     '') case "$gccversion" in
4443                 '') case "$osname" in
4444                         hpux)   dflt='+z' ;;
4445                         next)   dflt='none' ;;
4446                         svr4*|esix*)    dflt='-Kpic' ;;
4447                         irix*)  dflt='-KPIC' ;;
4448                         solaris) case "$ccflags" in
4449                                 *-DDEBUGGING*)  dflt='-KPIC' ;;
4450                                 *)              dflt='-Kpic' ;;
4451                                 esac ;;
4452                         sunos)  dflt='-pic' ;;
4453                         *)      dflt='none' ;;
4454                     esac ;;
4455                 *)  case "$osname/$ccflags" in
4456                         solaris/*-DDEBUGGING*)  dflt='-fPIC' ;;
4457                         *)                      dflt='-fpic' ;;
4458                     esac ;;
4459             esac ;;
4460     *)  dflt="$cccdlflags" ;;
4461     esac
4462     rp="Any special flags to pass to $cc -c to compile shared library modules?"
4463     . ./myread
4464     case "$ans" in
4465     none) cccdlflags=' ' ;;
4466     *) cccdlflags="$ans" ;;
4467     esac
4468
4469     cat << EOM
4470
4471 Some systems use ld to create libraries that can be dynamically loaded,
4472 while other systems (such as those using ELF) use $cc.
4473
4474 EOM
4475         case "$ld" in
4476         '')     $cat >try.c <<'EOM'
4477 /* Test for whether ELF binaries are produced */
4478 #include <fcntl.h>
4479 #include <stdlib.h>
4480 main() {
4481         char b[4];
4482         int i = open("a.out",O_RDONLY);
4483         if(i == -1) 
4484                 exit(1); /* fail */
4485         if(read(i,b,4)==4 && b[0]==127 && b[1]=='E' && b[2]=='L' && b[3]=='F')
4486                 exit(0); /* succeed (yes, it's ELF) */
4487         else
4488                 exit(1); /* fail */
4489 }
4490 EOM
4491                 if $cc $ccflags try.c >/dev/null 2>&1 && ./a.out; then
4492                         cat <<EOM
4493 You appear to have ELF support.  I'll use $cc to build dynamic libraries.
4494 EOM
4495                         dflt="$cc"
4496                 else
4497                         echo "I'll use ld to build dynamic libraries."
4498                         dflt='ld'
4499                 fi
4500                 rm -f try.c a.out
4501                 ;;
4502         *)      dflt="$ld"
4503                 ;;
4504         esac
4505
4506     rp="What command should be used to create dynamic libraries?"
4507     . ./myread
4508         ld="$ans"
4509
4510     cat << EOM
4511
4512 Some systems may require passing special flags to $ld to create a
4513 library that can be dynamically loaded.  If your ld flags include
4514 -L/other/path options to locate libraries outside your loader's normal
4515 search path, you may need to specify those -L options here as well.  To
4516 use no flags, say "none".
4517
4518 EOM
4519     case "$lddlflags" in
4520     '') case "$osname" in
4521                         hpux)  dflt='-b' ;;
4522                         linux|irix*)    dflt='-shared' ;;
4523                         next)  dflt='none' ;;
4524                         solaris) dflt='-G' ;;
4525                         sunos) dflt='-assert nodefinitions' ;;
4526                         svr4*|esix*) dflt="-G $ldflags" ;;
4527                 *)     dflt='none' ;;
4528                         esac
4529                         ;;
4530     *) dflt="$lddlflags" ;;
4531     esac
4532
4533 : Try to guess additional flags to pick up local libraries.
4534 for thisflag in $ldflags; do
4535         case "$thisflag" in
4536         -L*)
4537                 case " $dflt " in
4538                 *" $thisflag "*) ;;
4539                 *) dflt="$dflt $thisflag" ;;
4540                 esac
4541                 ;;
4542         esac
4543 done
4544
4545 case "$dflt" in
4546 '') dflt='none' ;;
4547 esac
4548
4549     rp="Any special flags to pass to $ld to create a dynamically loaded library?"
4550     . ./myread
4551     case "$ans" in
4552     none) lddlflags=' ' ;;
4553     *) lddlflags="$ans" ;;
4554     esac
4555
4556         cat <<EOM
4557
4558 Some systems may require passing special flags to $cc to indicate that
4559 the resulting executable will use dynamic linking.  To use no flags,
4560 say "none".
4561
4562 EOM
4563     case "$ccdlflags" in
4564     '') case "$osname" in
4565                 hpux)   dflt='-Wl,-E' ;;
4566                 linux)  dflt='-rdynamic' ;;
4567                 next)   dflt='none' ;;
4568                 sunos)  dflt='none' ;;
4569                 *)      dflt='none' ;;
4570             esac ;;
4571     *)  dflt="$ccdlflags" ;;
4572     esac
4573     rp="Any special flags to pass to $cc to use dynamic loading?"
4574     . ./myread
4575     case "$ans" in
4576     none) ccdlflags=' ' ;;
4577     *) ccdlflags="$ans" ;;
4578     esac
4579     ;;
4580 *)  usedl="$undef"
4581         ld='ld'
4582     dlsrc='dl_none.xs'
4583     lddlflags=''
4584     ccdlflags=''
4585     ;;
4586 esac
4587
4588 also=''
4589 case "$usedl" in
4590 $undef)
4591         # No dynamic loading being used, so don't bother even to prompt.
4592         useshrplib='false'
4593         ;;
4594 *)      case "$useshrplib" in
4595         '')     case "$osname" in
4596                 svr4*|dgux|dynixptx|esix|powerux)
4597                         dflt=y
4598                         also='Building a shared libperl is required for dynamic loading to work on your system.'
4599                         ;;
4600                 next*)
4601                         case "$osvers" in
4602                         4*)     dflt=y
4603                                 also='Building a shared libperl is needed for MAB support.'
4604                                 ;;
4605                         *)      dflt=n
4606                                 ;;
4607                         esac
4608                         ;;
4609                 sunos)
4610                         dflt=n
4611                         also='Building a shared libperl will definitely not work on SunOS 4.'
4612                         ;;
4613                 *)      dflt=n
4614                         ;;
4615                 esac
4616                 ;;
4617         $define|true|[Yy]*)
4618                 dflt=y
4619                 ;;
4620         *)      dflt=n
4621                 ;;
4622         esac
4623         $cat << EOM
4624
4625 The perl executable is normally obtained by linking perlmain.c with
4626 libperl${lib_ext}, any static extensions (usually just DynaLoader), and
4627 any other libraries needed on this system (such as -lm, etc.).  Since
4628 your system supports dynamic loading, it is probably possible to build
4629 a shared libperl.$so.  If you will have more than one executable linked
4630 to libperl.$so, this will significantly reduce the size of each
4631 executable, but it may have a noticeable affect on performance.  The
4632 default is probably sensible for your system.
4633 $also
4634
4635 EOM
4636         rp="Build a shared libperl.$so (y/n)"
4637         . ./myread
4638         case "$ans" in
4639         true|$define|[Yy]*)
4640                 useshrplib='true'
4641                 # Why does next4 have to be so different?
4642                 case "${osname}${osvers}" in
4643                 next4*) xxx='DYLD_LIBRARY_PATH' ;;
4644                 *)              xxx='LD_LIBRARY_PATH' ;;
4645                 esac
4646                 $cat <<EOM >&4
4647
4648 To build perl, you must add the current working directory to your
4649 $xxx environtment variable before running make.  You can do
4650 this with
4651    $xxx=\`pwd\`; export $xxx
4652 for Bourne-style shells, or
4653    setenv $xxx \`pwd\`
4654 for Csh-style shells.  You *MUST* do this before running make.
4655
4656 EOM
4657                 ;;
4658         *)      useshrplib='false' ;;
4659         esac
4660         ;;
4661 esac
4662
4663 case "$useshrplib" in
4664 true)
4665         case "$libperl" in
4666         '')
4667                 # Figure out a good name for libperl.so.  Since it gets stored in
4668                 # a version-specific architecture-dependent library, the version
4669                 # number isn't really that important, except for making cc/ld happy.
4670                 #
4671                 # A name such as libperl.so.3.1
4672                 majmin="libperl.$so.$patchlevel.$subversion"
4673                 # A name such as libperl.so.301
4674                 majonly=`echo $patchlevel $subversion |
4675                         $awk '{printf "%d%02d", $1, $2}'`
4676                 majonly=libperl.$so.$majonly
4677                 # I'd prefer to keep the os-specific stuff here to a minimum, and
4678                 # rely on figuring it out from the naming of libc.
4679                 case "${osname}${osvers}" in
4680                 next4*)
4681                         dflt=libperl.5.$so
4682                         # XXX How handle the --version stuff for MAB?
4683                         ;;
4684                 linux*)  # ld won't link with a bare -lperl otherwise.
4685                         dflt=libperl.$so
4686                         ;;
4687                 *)      # Try to guess based on whether libc has major.minor.
4688                         case "$libc" in
4689                         *libc.$so.[0-9]*.[0-9]*) dflt=$majmin ;;
4690                         *libc.$so.[0-9]*) dflt=$majonly ;;
4691                         *)      dflt=libperl.$so ;;
4692                         esac
4693                         ;;
4694                 esac
4695                 ;;
4696         *)      dflt=$libperl
4697            &nb