This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add Configure probe for querylocale()
[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 by the tool
15 # called "metaconfig". Rather than working with this copy of Configure,
16 # you may wish to get metaconfig. Perl uses a modified version of this
17 # tool, available in the "dist" folder in the checkout of the git repo
18 #    $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
19 # The original dist package (including metaconfig) is available via SVN:
20 #    $ svn co https://svn.code.sf.net/p/dist/code/trunk/dist
21 #
22 # Though this script was generated by metaconfig from metaunits, it is
23 # OK to send patches against Configure itself. It's up to the Configure
24 # pumpkin to backport the patch to the metaunits if it is accepted.
25 # For more information on patching Configure, see pod/perlhack.pod
26 #
27 # The metaunits are also available from the public git repository:
28 #     http://perl5.git.perl.org/metaconfig.git/ or
29 #     $ git clone git://perl5.git.perl.org/metaconfig.git metaconfig
30 #
31 # See Porting/pumpkin.pod for more information on metaconfig.
32
33 # Generated using [metaconfig 3.5 PL0]
34 # (with additional metaconfig patches by perlbug@perl.org)
35
36 cat >c1$$ <<EOF
37 ARGGGHHHH!!!!!
38
39 SCO csh still thinks true is false.  Write to SCO today and tell them that next
40 year Configure ought to "rm /bin/csh" unless they fix their blasted shell. :-)
41
42 (Actually, Configure ought to just patch csh in place.  Hmm.  Hmmmmm.  All
43 we'd have to do is go in and swap the && and || tokens, wherever they are.)
44
45 [End of diatribe. We now return you to your regularly scheduled programming...]
46 EOF
47 cat >c2$$ <<EOF
48
49 OOPS!  You naughty creature!  You didn't run Configure with sh!
50 I will attempt to remedy the situation by running sh for you...
51 EOF
52
53 true || cat c1$$ c2$$
54 true || exec sh $0 $argv:q
55
56 (exit $?0) || cat c2$$
57 (exit $?0) || exec sh $0 $argv:q
58 rm -f c1$$ c2$$
59
60 if test -f /dev/cputype -a -f /dev/drivers -a -f /dev/osversion; then
61         cat <<EOF
62 ***
63 *** I'm sorry but this system looks like Plan 9 and Plan 9 doesn't do
64 *** Configure that well.  (Plan 9 is close to UNIX but not close enough.)
65 *** Please read the README.plan9 for further instructions.
66 *** Cannot continue, aborting.
67 ***
68 EOF
69         exit 1
70 fi
71
72 if test -f /sys/utilities/MultiView ; then
73         # AmigaOS, test -c for /dev/null is not useful
74         :
75 elif test ! -c /dev/null ; then
76         cat <<EOF
77 ***
78 *** I'm sorry, but /dev/null appears to be a file rather than a device.
79 *** Please consult your operating sytem's notes for making a device
80 *** in /dev.
81 *** Cannot continue, aborting.
82 ***
83 EOF
84         exit 1
85 fi
86
87 : compute my invocation name
88 me=$0
89 case "$0" in
90 */*)
91         me=`echo $0 | sed -e 's!.*/\(.*\)!\1!' 2>/dev/null`
92         test "$me" || me=$0
93         ;;
94 esac
95
96 : Proper separator for the PATH environment variable
97 p_=:
98 : On OS/2 this directory should exist if this is not floppy only system ":-]"
99 if test -d c:/. || ( uname -a | grep -i 'os\(/\|\)2' 2>&1 ) 2>&1 >/dev/null ; then
100         if test -n "$OS2_SHELL"; then
101                 p_=\;
102                 PATH=`cmd /c "echo %PATH%" | tr '\\\\' / `
103                 OS2_SHELL=`cmd /c "echo %OS2_SHELL%" | tr '\\\\' / | tr '[A-Z]' '[a-z]'`
104                 is_os2=yes
105         elif test -n "$DJGPP"; then
106                 case "X${MACHTYPE:-nonesuchmach}" in
107                 *cygwin|*msys) ;;
108                 *) p_=\; ;;
109                 esac
110         fi
111 fi
112
113 : Proper PATH setting
114 paths='/bin /usr/bin /usr/local/bin /usr/ucb /usr/local /usr/lbin'
115 paths="$paths /opt/bin /opt/local/bin /opt/local /opt/lbin"
116 paths="$paths /usr/5bin /etc /usr/gnu/bin /usr/new /usr/new/bin /usr/nbin"
117 paths="$paths /opt/gnu/bin /opt/new /opt/new/bin /opt/nbin"
118 paths="$paths /sys5.3/bin /sys5.3/usr/bin /bsd4.3/bin /bsd4.3/usr/ucb"
119 paths="$paths /bsd4.3/usr/bin /usr/bsd /bsd43/bin /opt/ansic/bin /usr/ccs/bin"
120 paths="$paths /etc /usr/lib /usr/ucblib /lib /usr/ccs/lib"
121 paths="$paths /sbin /usr/sbin /usr/libexec"
122 paths="$paths /system/gnu_library/bin"
123
124 for p in $paths
125 do
126         case "$p_$PATH$p_" in
127         *$p_$p$p_*) ;;
128         *) test -d $p && PATH=$PATH$p_$p ;;
129         esac
130 done
131
132 PATH=.$p_$PATH
133 export PATH
134
135 : shall we be using ksh?
136 inksh=''
137 needksh=''
138 avoidksh=''
139 newsh=/bin/ksh
140 changesh=''
141 if (PATH=.; alias -x) >/dev/null 2>&1; then
142                 inksh=true
143 fi
144 if test -f /hp-ux -a -f /bin/ksh; then
145         needksh='to avoid sh bug in "here document" expansion'
146 fi
147 if test -d /usr/lpp -a -f /usr/bin/bsh -a -f /usr/bin/uname; then
148         if test X`/usr/bin/uname -v` = X4; then
149                 avoidksh="to avoid AIX 4's /bin/sh"
150                 newsh=/usr/bin/bsh
151         fi
152 fi
153 if test -f /osf_boot -a -f /usr/sbin/setld; then
154         if test X`/usr/bin/uname -s` = XOSF1; then
155                 avoidksh="to avoid Digital UNIX' ksh"
156                 newsh=/bin/sh
157                 unset BIN_SH
158         fi
159 fi
160 case "$inksh/$needksh" in
161 /[a-z]*)
162                 ENV=''
163                 changesh=true
164                 reason="$needksh"
165         ;;
166 esac
167 case "$inksh/$avoidksh" in
168 true/[a-z]*)
169         changesh=true
170         reason="$avoidksh"
171         ;;
172 esac
173 case "$inksh/$needksh-$avoidksh-" in
174 true/--)
175                 cat <<EOM
176 (I see you are using the Korn shell.  Some ksh's blow up on $me,
177 mainly on older exotic systems.  If yours does, try the Bourne shell instead.)
178 EOM
179         ;;
180 esac
181 case "$changesh" in
182 true)
183         export newsh
184         echo "(Feeding myself to $newsh $reason.)"
185         case "$0" in
186         Configure|*/Configure) exec $newsh $0 "$@";;
187         *) exec $newsh Configure "$@";;
188         esac
189         ;;
190 esac
191 test -x "${newsh}" || unset newsh
192
193 : if needed, set CDPATH to a harmless value that is not chatty
194 : avoid bash 2.02 problems with empty CDPATH.
195 case "$CDPATH" in
196 '')     ;;
197 *)      case "$SHELL" in
198         *bash*) CDPATH='.' ;;
199         *) CDPATH='' ;;
200         esac
201         ;;
202 esac
203
204 : Configure runs within the UU subdirectory
205 test -d UU || mkdir UU
206 cd UU && rm -f ./*
207
208 ccname=''
209 ccversion=''
210 ccsymbols=''
211 cppccsymbols=''
212 cppsymbols=''
213 from=''
214 hostgenerate=''
215 hostosname=''
216 hostperl=''
217 run=''
218 targetarch=''
219 targetdir=''
220 targetenv=''
221 targethost=''
222 targetmkdir=''
223 targetport=''
224 to=''
225 usecrosscompile=''
226 extern_C=''
227 mistrustnm=''
228 usedevel=''
229 perllibs=''
230 dynamic_ext=''
231 extensions=''
232 known_extensions=''
233 nonxs_ext=''
234 static_ext=''
235 useopcode=''
236 useposix=''
237 extras=''
238 d_bsd=''
239 d_eunice=''
240 d_xenix=''
241 eunicefix=''
242 ar=''
243 awk=''
244 bash=''
245 bison=''
246 byacc=''
247 cat=''
248 chgrp=''
249 chmod=''
250 chown=''
251 comm=''
252 compress=''
253 cp=''
254 cpio=''
255 cpp=''
256 csh=''
257 date=''
258 echo=''
259 egrep=''
260 emacs=''
261 expr=''
262 find=''
263 flex=''
264 gmake=''
265 grep=''
266 gzip=''
267 inews=''
268 ksh=''
269 less=''
270 line=''
271 lint=''
272 ln=''
273 lp=''
274 lpr=''
275 ls=''
276 mail=''
277 mailx=''
278 make=''
279 mkdir=''
280 more=''
281 mv=''
282 nm=''
283 nroff=''
284 perl=''
285 pg=''
286 pmake=''
287 pr=''
288 rm=''
289 rmail=''
290 sed=''
291 sendmail=''
292 shar=''
293 sleep=''
294 smail=''
295 sort=''
296 submit=''
297 tail=''
298 tar=''
299 tbl=''
300 tee=''
301 test=''
302 touch=''
303 tr=''
304 troff=''
305 uname=''
306 uniq=''
307 uuname=''
308 vi=''
309 zcat=''
310 zip=''
311 full_ar=''
312 full_sed=''
313 libswanted=''
314 hint=''
315 myuname=''
316 osname=''
317 osvers=''
318 Author=''
319 Date=''
320 Header=''
321 Id=''
322 Locker=''
323 Log=''
324 RCSfile=''
325 Revision=''
326 Source=''
327 State=''
328 sysroot=''
329 _a=''
330 _exe=''
331 _o=''
332 archobjs=''
333 exe_ext=''
334 firstmakefile=''
335 lib_ext=''
336 obj_ext=''
337 path_sep=''
338 rm_try=''
339 afs=''
340 afsroot=''
341 alignbytes=''
342 ansi2knr=''
343 archlib=''
344 archlibexp=''
345 d_archlib=''
346 installarchlib=''
347 archname=''
348 myarchname=''
349 useversionedarchname=''
350 d_atolf=''
351 d_atoll=''
352 baserev=''
353 bin=''
354 binexp=''
355 initialinstalllocation=''
356 installbin=''
357 userelocatableinc=''
358 byteorder=''
359 cc=''
360 ccflags=''
361 cppflags=''
362 ldflags=''
363 lkflags=''
364 locincpth=''
365 optimize=''
366 cf_email=''
367 cf_by=''
368 cf_time=''
369 charbits=''
370 charsize=''
371 contains=''
372 cpp_stuff=''
373 cpplast=''
374 cppminus=''
375 cpprun=''
376 cppstdin=''
377 d__fwalk=''
378 d_access=''
379 d_accessx=''
380 d_acosh=''
381 d_aintl=''
382 d_alarm=''
383 asctime_r_proto=''
384 d_asctime_r=''
385 d_asinh=''
386 d_atanh=''
387 d_attribute_deprecated=''
388 d_attribute_format=''
389 d_attribute_malloc=''
390 d_attribute_nonnull=''
391 d_attribute_noreturn=''
392 d_attribute_pure=''
393 d_attribute_unused=''
394 d_attribute_warn_unused_result=''
395 d_printf_format_null=''
396 d_backtrace=''
397 d_bcmp=''
398 d_bcopy=''
399 d_builtin_choose_expr=''
400 d_builtin_expect=''
401 d_bzero=''
402 d_c99_variadic_macros=''
403 d_casti32=''
404 castflags=''
405 d_castneg=''
406 d_cbrt=''
407 d_chown=''
408 d_chroot=''
409 d_chsize=''
410 d_class=''
411 d_clearenv=''
412 d_closedir=''
413 d_void_closedir=''
414 d_cmsghdr_s=''
415 d_const=''
416 d_copysign=''
417 d_copysignl=''
418 d_cplusplus=''
419 cryptlib=''
420 d_crypt=''
421 crypt_r_proto=''
422 d_crypt_r=''
423 d_csh=''
424 full_csh=''
425 d_ctermid=''
426 ctermid_r_proto=''
427 d_ctermid_r=''
428 ctime_r_proto=''
429 d_ctime_r=''
430 d_cuserid=''
431 d_dbl_dig=''
432 d_dbminitproto=''
433 d_difftime=''
434 d_dir_dd_fd=''
435 d_dirfd=''
436 d_dladdr=''
437 d_dlerror=''
438 d_dlopen=''
439 d_dlsymun=''
440 d_dosuid=''
441 d_suidsafe=''
442 d_drand48_r=''
443 drand48_r_proto=''
444 d_drand48proto=''
445 d_dup2=''
446 d_eaccess=''
447 d_endgrent=''
448 d_endgrent_r=''
449 endgrent_r_proto=''
450 d_endhent=''
451 d_endhostent_r=''
452 endhostent_r_proto=''
453 d_endnent=''
454 d_endnetent_r=''
455 endnetent_r_proto=''
456 d_endpent=''
457 d_endprotoent_r=''
458 endprotoent_r_proto=''
459 d_endpwent=''
460 d_endpwent_r=''
461 endpwent_r_proto=''
462 d_endsent=''
463 d_endservent_r=''
464 endservent_r_proto=''
465 d_erf=''
466 d_erfc=''
467 d_exp2=''
468 d_expm1=''
469 d_faststdio=''
470 d_fchdir=''
471 d_fchmod=''
472 d_fchown=''
473 d_fcntl=''
474 d_fcntl_can_lock=''
475 d_fd_macros=''
476 d_fd_set=''
477 d_fds_bits=''
478 d_fdclose=''
479 d_fdim=''
480 d_fegetround=''
481 d_fgetpos=''
482 d_finite=''
483 d_finitel=''
484 d_flexfnam=''
485 d_flock=''
486 d_flockproto=''
487 d_fma=''
488 d_fmax=''
489 d_fmin=''
490 d_fork=''
491 d_fp_class=''
492 d_fp_classl=''
493 d_fpclass=''
494 d_fp_classify=''
495 d_fpclassify=''
496 d_fpclassl=''
497 d_fpgetround=''
498 d_fpos64_t=''
499 d_frexpl=''
500 d_fs_data_s=''
501 d_fseeko=''
502 d_fsetpos=''
503 d_fstatfs=''
504 d_fsync=''
505 d_ftello=''
506 d_ftime=''
507 d_gettimeod=''
508 d_futimes=''
509 d_Gconvert=''
510 d_getaddrinfo=''
511 d_getcwd=''
512 d_getespwnam=''
513 d_getfsstat=''
514 d_getgrent=''
515 d_getgrent_r=''
516 getgrent_r_proto=''
517 d_getgrgid_r=''
518 getgrgid_r_proto=''
519 d_getgrnam_r=''
520 getgrnam_r_proto=''
521 d_getgrps=''
522 d_gethbyaddr=''
523 d_gethbyname=''
524 d_gethent=''
525 aphostname=''
526 d_gethname=''
527 d_phostname=''
528 d_uname=''
529 d_gethostbyaddr_r=''
530 gethostbyaddr_r_proto=''
531 d_gethostbyname_r=''
532 gethostbyname_r_proto=''
533 d_gethostent_r=''
534 gethostent_r_proto=''
535 d_gethostprotos=''
536 d_getitimer=''
537 d_getlogin=''
538 d_getlogin_r=''
539 getlogin_r_proto=''
540 d_getmnt=''
541 d_getmntent=''
542 d_getnameinfo=''
543 d_getnbyaddr=''
544 d_getnbyname=''
545 d_getnent=''
546 d_getnetbyaddr_r=''
547 getnetbyaddr_r_proto=''
548 d_getnetbyname_r=''
549 getnetbyname_r_proto=''
550 d_getnetent_r=''
551 getnetent_r_proto=''
552 d_getnetprotos=''
553 d_getpagsz=''
554 d_getpent=''
555 d_getpgid=''
556 d_getpgrp2=''
557 d_bsdgetpgrp=''
558 d_getpgrp=''
559 d_getppid=''
560 d_getprior=''
561 d_getpbyname=''
562 d_getpbynumber=''
563 d_getprotobyname_r=''
564 getprotobyname_r_proto=''
565 d_getprotobynumber_r=''
566 getprotobynumber_r_proto=''
567 d_getprotoent_r=''
568 getprotoent_r_proto=''
569 d_getprotoprotos=''
570 d_getprpwnam=''
571 d_getpwent=''
572 d_getpwent_r=''
573 getpwent_r_proto=''
574 d_getpwnam_r=''
575 getpwnam_r_proto=''
576 d_getpwuid_r=''
577 getpwuid_r_proto=''
578 d_getsent=''
579 d_getservbyname_r=''
580 getservbyname_r_proto=''
581 d_getservbyport_r=''
582 getservbyport_r_proto=''
583 d_getservent_r=''
584 getservent_r_proto=''
585 d_getservprotos=''
586 d_getspnam=''
587 d_getspnam_r=''
588 getspnam_r_proto=''
589 d_getsbyname=''
590 d_getsbyport=''
591 d_gmtime_r=''
592 gmtime_r_proto=''
593 d_gnulibc=''
594 gnulibc_version=''
595 d_hasmntopt=''
596 d_htonl=''
597 d_hypot=''
598 d_ilogb=''
599 d_ilogbl=''
600 d_inetaton=''
601 d_inetntop=''
602 d_inetpton=''
603 d_int64_t=''
604 d_isascii=''
605 d_isblank=''
606 d_isfinite=''
607 d_isfinitel=''
608 d_isinf=''
609 d_isinfl=''
610 d_isless=''
611 d_isnan=''
612 d_isnanl=''
613 d_isnormal=''
614 d_j0=''
615 d_j0l=''
616 d_killpg=''
617 d_lc_monetary_2008=''
618 d_lchown=''
619 d_ldbl_dig=''
620 d_lgamma=''
621 d_lgamma_r=''
622 d_libm_lib_version=''
623 d_link=''
624 d_llrint=''
625 d_llrintl=''
626 d_llround=''
627 d_llroundl=''
628 d_localtime_r=''
629 d_localtime_r_needs_tzset=''
630 localtime_r_proto=''
631 d_locconv=''
632 d_lockf=''
633 d_log1p=''
634 d_log2=''
635 d_logb=''
636 d_ldexpl=''
637 d_longdbl=''
638 longdblkind=''
639 longdblsize=''
640 d_longlong=''
641 longlongsize=''
642 d_lrint=''
643 d_lrintl=''
644 d_lround=''
645 d_lroundl=''
646 d_lseekproto=''
647 d_lstat=''
648 d_madvise=''
649 d_malloc_good_size=''
650 d_malloc_size=''
651 d_mblen=''
652 d_mbstowcs=''
653 d_mbtowc=''
654 d_memchr=''
655 d_memcmp=''
656 d_memcpy=''
657 d_memmem=''
658 d_memmove=''
659 d_memset=''
660 d_mkdir=''
661 d_mkdtemp=''
662 d_mkfifo=''
663 d_mkstemp=''
664 d_mkstemps=''
665 d_mktime=''
666 d_mmap=''
667 mmaptype=''
668 d_modfl=''
669 d_modflproto=''
670 d_mprotect=''
671 d_msg=''
672 d_msgctl=''
673 d_msgget=''
674 d_msghdr_s=''
675 d_msgrcv=''
676 d_msgsnd=''
677 d_msync=''
678 d_munmap=''
679 d_nan=''
680 d_nearbyint=''
681 d_duplocale=''
682 d_freelocale=''
683 d_newlocale=''
684 d_querylocale=''
685 d_uselocale=''
686 i_xlocale=''
687 d_nextafter=''
688 d_nexttoward=''
689 d_nice=''
690 d_nl_langinfo=''
691 d_off64_t=''
692 d_open3=''
693 d_fpathconf=''
694 d_pathconf=''
695 d_pause=''
696 d_pipe=''
697 d_poll=''
698 d_portable=''
699 d_prctl=''
700 d_prctl_set_name=''
701 d_procselfexe=''
702 procselfexe=''
703 d_old_pthread_create_joinable=''
704 old_pthread_create_joinable=''
705 d_pthread_atfork=''
706 d_pthread_attr_setscope=''
707 d_pthread_yield=''
708 d_sched_yield=''
709 sched_yield=''
710 d_ptrdiff_t=''
711 d_qgcvt=''
712 d_random_r=''
713 random_r_proto=''
714 d_readdir64_r=''
715 readdir64_r_proto=''
716 d_readdir=''
717 d_rewinddir=''
718 d_seekdir=''
719 d_telldir=''
720 d_readdir_r=''
721 readdir_r_proto=''
722 d_readlink=''
723 d_readv=''
724 d_recvmsg=''
725 d_re_comp=''
726 d_regcmp=''
727 d_regcomp=''
728 d_remainder=''
729 d_remquo=''
730 d_rename=''
731 d_rint=''
732 d_rmdir=''
733 d_round=''
734 d_safebcpy=''
735 d_safemcpy=''
736 d_sanemcmp=''
737 d_sbrkproto=''
738 d_scalbn=''
739 d_scalbnl=''
740 d_select=''
741 d_sem=''
742 d_semctl=''
743 d_semget=''
744 d_semop=''
745 d_sendmsg=''
746 d_setegid=''
747 d_seteuid=''
748 d_setgrent=''
749 d_setgrent_r=''
750 setgrent_r_proto=''
751 d_setgrps=''
752 d_sethent=''
753 d_sethostent_r=''
754 sethostent_r_proto=''
755 d_setitimer=''
756 d_setlinebuf=''
757 d_setlocale=''
758 d_setlocale_r=''
759 setlocale_r_proto=''
760 d_setnent=''
761 d_setnetent_r=''
762 setnetent_r_proto=''
763 d_setpent=''
764 d_setpgid=''
765 d_setpgrp2=''
766 d_bsdsetpgrp=''
767 d_setpgrp=''
768 d_setprior=''
769 d_setproctitle=''
770 d_setprotoent_r=''
771 setprotoent_r_proto=''
772 d_setpwent=''
773 d_setpwent_r=''
774 setpwent_r_proto=''
775 d_setregid=''
776 d_setresgid=''
777 d_setresuid=''
778 d_setreuid=''
779 d_setrgid=''
780 d_setruid=''
781 d_setsent=''
782 d_setservent_r=''
783 setservent_r_proto=''
784 d_setsid=''
785 d_setvbuf=''
786 d_shm=''
787 d_shmat=''
788 d_shmatprototype=''
789 shmattype=''
790 d_shmctl=''
791 d_shmdt=''
792 d_shmget=''
793 d_sigaction=''
794 d_siginfo_si_addr=''
795 d_siginfo_si_band=''
796 d_siginfo_si_errno=''
797 d_siginfo_si_fd=''
798 d_siginfo_si_pid=''
799 d_siginfo_si_status=''
800 d_siginfo_si_uid=''
801 d_siginfo_si_value=''
802 d_signbit=''
803 d_sigprocmask=''
804 d_sigsetjmp=''
805 usesitecustomize=''
806 d_snprintf=''
807 d_vsnprintf=''
808 d_sockatmark=''
809 d_sockatmarkproto=''
810 d_ip_mreq=''
811 d_ip_mreq_source=''
812 d_ipv6_mreq=''
813 d_ipv6_mreq_source=''
814 d_msg_ctrunc=''
815 d_msg_dontroute=''
816 d_msg_oob=''
817 d_msg_peek=''
818 d_msg_proxy=''
819 d_oldsock=''
820 d_scm_rights=''
821 d_sin6_scope_id=''
822 d_sockaddr_in6=''
823 d_sockaddr_sa_len=''
824 d_socket=''
825 d_sockpair=''
826 sockethdr=''
827 socketlib=''
828 d_socklen_t=''
829 d_socks5_init=''
830 d_sprintf_returns_strlen=''
831 d_sqrtl=''
832 d_srand48_r=''
833 srand48_r_proto=''
834 d_srandom_r=''
835 srandom_r_proto=''
836 d_sresgproto=''
837 d_sresuproto=''
838 d_stat=''
839 d_statblks=''
840 d_statfs_f_flags=''
841 d_statfs_s=''
842 d_static_inline=''
843 perl_static_inline=''
844 d_fstatvfs=''
845 d_statvfs=''
846 d_stdio_cnt_lval=''
847 d_stdio_ptr_lval=''
848 d_stdio_ptr_lval_nochange_cnt=''
849 d_stdio_ptr_lval_sets_cnt=''
850 d_stdiobase=''
851 d_stdstdio=''
852 stdio_base=''
853 stdio_bufsiz=''
854 stdio_cnt=''
855 stdio_filbuf=''
856 stdio_ptr=''
857 d_index=''
858 d_strchr=''
859 d_strcoll=''
860 d_strctcpy=''
861 d_strerrm=''
862 d_strerror=''
863 d_sysernlst=''
864 d_syserrlst=''
865 d_strerror_r=''
866 strerror_r_proto=''
867 d_strftime=''
868 d_strlcat=''
869 d_strlcpy=''
870 d_strtod=''
871 d_strtol=''
872 d_strtold=''
873 d_strtoll=''
874 d_strtoq=''
875 d_strtoul=''
876 d_strtoull=''
877 d_strtouq=''
878 d_strxfrm=''
879 d_symlink=''
880 d_syscall=''
881 d_syscallproto=''
882 d_sysconf=''
883 d_system=''
884 d_tcgetpgrp=''
885 d_tcsetpgrp=''
886 d_telldirproto=''
887 d_tgamma=''
888 d_time=''
889 timetype=''
890 d_asctime64=''
891 d_ctime64=''
892 d_difftime64=''
893 d_gmtime64=''
894 d_localtime64=''
895 d_mktime64=''
896 d_timegm=''
897 clocktype=''
898 d_times=''
899 d_tmpnam_r=''
900 tmpnam_r_proto=''
901 d_trunc=''
902 d_truncate=''
903 d_truncl=''
904 d_ttyname_r=''
905 ttyname_r_proto=''
906 d_tzname=''
907 d_u32align=''
908 d_ualarm=''
909 d_umask=''
910 d_semctl_semid_ds=''
911 d_semctl_semun=''
912 d_union_semun=''
913 d_unordered=''
914 d_unsetenv=''
915 d_usleep=''
916 d_usleepproto=''
917 d_ustat=''
918 d_pseudofork=''
919 d_vfork=''
920 usevfork=''
921 d_voidsig=''
922 signal_t=''
923 d_volatile=''
924 d_charvspr=''
925 d_vprintf=''
926 d_wait4=''
927 d_waitpid=''
928 d_wcscmp=''
929 d_wcstombs=''
930 d_wcsxfrm=''
931 d_wctomb=''
932 d_writev=''
933 dlext=''
934 bin_ELF=''
935 cccdlflags=''
936 ccdlflags=''
937 dlsrc=''
938 ld=''
939 ld_can_script=''
940 lddlflags=''
941 usedl=''
942 doublesize=''
943 dtraceobject=''
944 ebcdic=''
945 fflushNULL=''
946 fflushall=''
947 fpossize=''
948 fpostype=''
949 gccansipedantic=''
950 gccosandvers=''
951 gccversion=''
952 gidformat=''
953 gidsign=''
954 gidsize=''
955 gidtype=''
956 groupstype=''
957 h_fcntl=''
958 h_sysfile=''
959 html1dir=''
960 html1direxp=''
961 installhtml1dir=''
962 html3dir=''
963 html3direxp=''
964 installhtml3dir=''
965 i_arpainet=''
966 i_assert=''
967 i_bfd=''
968 i_crypt=''
969 db_hashtype=''
970 db_prefixtype=''
971 db_version_major=''
972 db_version_minor=''
973 db_version_patch=''
974 i_db=''
975 i_dbm=''
976 i_rpcsvcdbm=''
977 d_dirnamlen=''
978 direntrytype=''
979 i_dirent=''
980 i_dlfcn=''
981 i_execinfo=''
982 i_fcntl=''
983 i_fenv=''
984 i_float=''
985 i_fp=''
986 i_fp_class=''
987 i_gdbm=''
988 d_grpasswd=''
989 i_grp=''
990 i_ieeefp=''
991 i_inttypes=''
992 i_langinfo=''
993 i_libutil=''
994 i_limits=''
995 i_locale=''
996 i_machcthr=''
997 i_malloc=''
998 i_mallocmalloc=''
999 i_math=''
1000 i_memory=''
1001 i_mntent=''
1002 d_gdbm_ndbm_h_uses_prototypes=''
1003 d_gdbmndbm_h_uses_prototypes=''
1004 d_ndbm=''
1005 d_ndbm_h_uses_prototypes=''
1006 i_gdbm_ndbm=''
1007 i_gdbmndbm=''
1008 i_ndbm=''
1009 i_netdb=''
1010 i_neterrno=''
1011 i_netinettcp=''
1012 i_niin=''
1013 i_sysin=''
1014 i_poll=''
1015 i_prot=''
1016 i_pthread=''
1017 d_pwage=''
1018 d_pwchange=''
1019 d_pwclass=''
1020 d_pwcomment=''
1021 d_pwexpire=''
1022 d_pwgecos=''
1023 d_pwpasswd=''
1024 d_pwquota=''
1025 i_pwd=''
1026 i_quadmath=''
1027 i_shadow=''
1028 i_socks=''
1029 i_stdbool=''
1030 i_stddef=''
1031 i_stdint=''
1032 i_stdlib=''
1033 i_string=''
1034 strings=''
1035 i_sunmath=''
1036 i_sysaccess=''
1037 i_sysdir=''
1038 i_sysfile=''
1039 d_voidtty=''
1040 i_bsdioctl=''
1041 i_sysfilio=''
1042 i_sysioctl=''
1043 i_syssockio=''
1044 i_syslog=''
1045 i_sysmman=''
1046 i_sysmode=''
1047 i_sysmount=''
1048 i_sysndir=''
1049 i_sysparam=''
1050 i_syspoll=''
1051 i_sysresrc=''
1052 i_syssecrt=''
1053 i_sysselct=''
1054 i_sysstat=''
1055 i_sysstatfs=''
1056 i_sysstatvfs=''
1057 i_systimes=''
1058 i_systypes=''
1059 i_sysuio=''
1060 i_sysun=''
1061 i_sysutsname=''
1062 i_sysvfs=''
1063 i_syswait=''
1064 i_sgtty=''
1065 i_termio=''
1066 i_termios=''
1067 d_tm_tm_gmtoff=''
1068 d_tm_tm_zone=''
1069 i_systime=''
1070 i_systimek=''
1071 i_time=''
1072 timeincl=''
1073 i_unistd=''
1074 i_ustat=''
1075 i_utime=''
1076 i_values=''
1077 i_stdarg=''
1078 i_varargs=''
1079 i_varhdr=''
1080 i_vfork=''
1081 d_inc_version_list=''
1082 inc_version_list=''
1083 inc_version_list_init=''
1084 doubleinfbytes=''
1085 doublenanbytes=''
1086 longdblinfbytes=''
1087 longdblnanbytes=''
1088 installprefix=''
1089 installprefixexp=''
1090 installstyle=''
1091 installusrbinperl=''
1092 intsize=''
1093 longsize=''
1094 shortsize=''
1095 issymlink=''
1096 libc=''
1097 ldlibpthname=''
1098 libperl=''
1099 shrpenv=''
1100 useshrplib=''
1101 glibpth=''
1102 incpth=''
1103 libpth=''
1104 loclibpth=''
1105 plibpth=''
1106 xlibpth=''
1107 ignore_versioned_solibs=''
1108 libs=''
1109 libsdirs=''
1110 libsfiles=''
1111 libsfound=''
1112 libspath=''
1113 lns=''
1114 d_PRIEUldbl=''
1115 d_PRIFUldbl=''
1116 d_PRIGUldbl=''
1117 d_PRIeldbl=''
1118 d_PRIfldbl=''
1119 d_PRIgldbl=''
1120 d_SCNfldbl=''
1121 doublekind=''
1122 sPRIEUldbl=''
1123 sPRIFUldbl=''
1124 sPRIGUldbl=''
1125 sPRIeldbl=''
1126 sPRIfldbl=''
1127 sPRIgldbl=''
1128 sSCNfldbl=''
1129 lseeksize=''
1130 lseektype=''
1131 make_set_make=''
1132 d_mymalloc=''
1133 freetype=''
1134 mallocobj=''
1135 mallocsrc=''
1136 malloctype=''
1137 usemallocwrap=''
1138 usemymalloc=''
1139 installman1dir=''
1140 man1dir=''
1141 man1direxp=''
1142 man1ext=''
1143 installman3dir=''
1144 man3dir=''
1145 man3direxp=''
1146 man3ext=''
1147 doublemantbits=''
1148 longdblmantbits=''
1149 nvmantbits=''
1150 modetype=''
1151 multiarch=''
1152 mydomain=''
1153 myhostname=''
1154 phostname=''
1155 c=''
1156 n=''
1157 d_eofnblk=''
1158 eagain=''
1159 o_nonblock=''
1160 rd_nodata=''
1161 need_va_copy=''
1162 netdb_hlen_type=''
1163 netdb_host_type=''
1164 netdb_name_type=''
1165 netdb_net_type=''
1166 groupcat=''
1167 hostcat=''
1168 passcat=''
1169 orderlib=''
1170 ranlib=''
1171 d_perl_otherlibdirs=''
1172 otherlibdirs=''
1173 package=''
1174 spackage=''
1175 pager=''
1176 api_revision=''
1177 api_subversion=''
1178 api_version=''
1179 api_versionstring=''
1180 patchlevel=''
1181 perl_patchlevel=''
1182 revision=''
1183 subversion=''
1184 version=''
1185 version_patchlevel_string=''
1186 perl5=''
1187 perladmin=''
1188 perlpath=''
1189 d_nv_preserves_uv=''
1190 d_nv_zero_is_allbits_zero=''
1191 i16size=''
1192 i16type=''
1193 i32size=''
1194 i32type=''
1195 i64size=''
1196 i64type=''
1197 i8size=''
1198 i8type=''
1199 ivsize=''
1200 ivtype=''
1201 nv_overflows_integers_at=''
1202 nv_preserves_uv_bits=''
1203 nvsize=''
1204 nvtype=''
1205 u16size=''
1206 u16type=''
1207 u32size=''
1208 u32type=''
1209 u64size=''
1210 u64type=''
1211 u8size=''
1212 u8type=''
1213 uvsize=''
1214 uvtype=''
1215 ivdformat=''
1216 nvEUformat=''
1217 nvFUformat=''
1218 nvGUformat=''
1219 nveformat=''
1220 nvfformat=''
1221 nvgformat=''
1222 uvXUformat=''
1223 uvoformat=''
1224 uvuformat=''
1225 uvxformat=''
1226 pidtype=''
1227 prefix=''
1228 prefixexp=''
1229 installprivlib=''
1230 privlib=''
1231 privlibexp=''
1232 prototype=''
1233 ptrsize=''
1234 d_PRIXU64=''
1235 d_PRId64=''
1236 d_PRIi64=''
1237 d_PRIo64=''
1238 d_PRIu64=''
1239 d_PRIx64=''
1240 sPRIXU64=''
1241 sPRId64=''
1242 sPRIi64=''
1243 sPRIo64=''
1244 sPRIu64=''
1245 sPRIx64=''
1246 d_quad=''
1247 quadkind=''
1248 quadtype=''
1249 uquadtype=''
1250 drand01=''
1251 randbits=''
1252 randfunc=''
1253 randseedtype=''
1254 seedfunc=''
1255 installscript=''
1256 scriptdir=''
1257 scriptdirexp=''
1258 selectminbits=''
1259 selecttype=''
1260 sh=''
1261 targetsh=''
1262 sig_count=''
1263 sig_name=''
1264 sig_name_init=''
1265 sig_num=''
1266 sig_num_init=''
1267 sig_size=''
1268 d_sitearch=''
1269 installsitearch=''
1270 sitearch=''
1271 sitearchexp=''
1272 installsitebin=''
1273 sitebin=''
1274 sitebinexp=''
1275 installsitehtml1dir=''
1276 sitehtml1dir=''
1277 sitehtml1direxp=''
1278 installsitehtml3dir=''
1279 sitehtml3dir=''
1280 sitehtml3direxp=''
1281 installsitelib=''
1282 sitelib=''
1283 sitelib_stem=''
1284 sitelibexp=''
1285 installsiteman1dir=''
1286 siteman1dir=''
1287 siteman1direxp=''
1288 installsiteman3dir=''
1289 siteman3dir=''
1290 siteman3direxp=''
1291 siteprefix=''
1292 siteprefixexp=''
1293 installsitescript=''
1294 sitescript=''
1295 sitescriptexp=''
1296 sizesize=''
1297 sizetype=''
1298 d_libname_unique=''
1299 so=''
1300 socksizetype=''
1301 sharpbang=''
1302 shsharp=''
1303 spitshell=''
1304 src=''
1305 ssizetype=''
1306 st_ino_sign=''
1307 st_ino_size=''
1308 startperl=''
1309 startsh=''
1310 stdchar=''
1311 d_stdio_stream_array=''
1312 stdio_stream_array=''
1313 sysman=''
1314 sGMTIME_max=''
1315 sGMTIME_min=''
1316 sLOCALTIME_max=''
1317 sLOCALTIME_min=''
1318 trnl=''
1319 uidformat=''
1320 uidsign=''
1321 uidsize=''
1322 uidtype=''
1323 archname64=''
1324 use64bitall=''
1325 use64bitint=''
1326 usecbacktrace=''
1327 dtrace=''
1328 usedtrace=''
1329 usefaststdio=''
1330 usekernprocpathname=''
1331 ccflags_uselargefiles=''
1332 ldflags_uselargefiles=''
1333 libswanted_uselargefiles=''
1334 uselargefiles=''
1335 uselongdouble=''
1336 usemorebits=''
1337 usemultiplicity=''
1338 nm_opt=''
1339 nm_so_opt=''
1340 runnm=''
1341 usenm=''
1342 usensgetexecutablepath=''
1343 useperlio=''
1344 usequadmath=''
1345 usesocks=''
1346 d_oldpthreads=''
1347 use5005threads=''
1348 useithreads=''
1349 usereentrant=''
1350 usethreads=''
1351 incpath=''
1352 mips_type=''
1353 usrinc=''
1354 vaproto=''
1355 d_vendorarch=''
1356 installvendorarch=''
1357 vendorarch=''
1358 vendorarchexp=''
1359 d_vendorbin=''
1360 installvendorbin=''
1361 vendorbin=''
1362 vendorbinexp=''
1363 installvendorhtml1dir=''
1364 vendorhtml1dir=''
1365 vendorhtml1direxp=''
1366 installvendorhtml3dir=''
1367 vendorhtml3dir=''
1368 vendorhtml3direxp=''
1369 d_vendorlib=''
1370 installvendorlib=''
1371 vendorlib=''
1372 vendorlib_stem=''
1373 vendorlibexp=''
1374 installvendorman1dir=''
1375 vendorman1dir=''
1376 vendorman1direxp=''
1377 installvendorman3dir=''
1378 vendorman3dir=''
1379 vendorman3direxp=''
1380 usevendorprefix=''
1381 vendorprefix=''
1382 vendorprefixexp=''
1383 d_vendorscript=''
1384 installvendorscript=''
1385 vendorscript=''
1386 vendorscriptexp=''
1387 versiononly=''
1388 yacc=''
1389 yaccflags=''
1390 CONFIG=''
1391
1392 : Detect odd OSs
1393 define='define'
1394 undef='undef'
1395 smallmach='pdp11 i8086 z8000 i80286 iAPX286'
1396 rmlist=''
1397
1398 : We must find out about Eunice early
1399 eunicefix=':'
1400 if test -f /etc/unixtovms; then
1401         eunicefix=/etc/unixtovms
1402 fi
1403 if test -f /etc/unixtovms.exe; then
1404         eunicefix=/etc/unixtovms.exe
1405 fi
1406
1407 : Set executable suffix now -- needed before hints available
1408 if test -f "/libs/version.library"; then
1409 : Amiga OS
1410     _exe=""
1411 elif test -f "/system/gnu_library/bin/ar.pm"; then
1412 : Stratus VOS
1413     _exe=".pm"
1414 elif test -n "$DJGPP"; then
1415 : DOS DJGPP
1416     _exe=".exe"
1417 elif test -f /kern/cookiejar; then
1418 : MiNT
1419     _exe=""
1420 elif test -d c:/. -o -n "$is_os2" ; then
1421 : OS/2 or cygwin
1422     _exe=".exe"
1423 fi
1424
1425 groupstype=''
1426 i_whoami=''
1427 : Possible local include directories to search.
1428 : Set locincpth to "" in a hint file to defeat local include searches.
1429 locincpth="/usr/local/include /opt/local/include /usr/gnu/include"
1430 locincpth="$locincpth /opt/gnu/include /usr/GNU/include /opt/GNU/include"
1431 :
1432 : no include file wanted by default
1433 inclwanted=''
1434
1435 : Enable -DEBUGGING and -DDEBUGGING from the command line
1436 EBUGGING=''
1437 DEBUGGING=''
1438
1439 : Trailing extension.  Override this in a hint file, if needed.
1440 : Extra object files, if any, needed on this platform.
1441 archobjs=''
1442 libnames=''
1443 : change the next line if compiling for Xenix/286 on Xenix/386
1444 xlibpth='/usr/lib/386 /lib/386'
1445 : Possible local library directories to search.
1446 loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
1447 loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
1448
1449 : general looking path for locating libraries
1450 glibpth="/lib /usr/lib $xlibpth"
1451 glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
1452 test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
1453 test -f /shlib/libc.so     && glibpth="/shlib $glibpth"
1454 test -d /usr/lib64         && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
1455
1456 : Private path used by Configure to find libraries.  Its value
1457 : is prepended to libpth. This variable takes care of special
1458 : machines, like the mips.  Usually, it should be empty.
1459 plibpth=''
1460
1461 : default library list
1462 libswanted=''
1463 : some systems want to use only the non-versioned libso:s
1464 ignore_versioned_solibs=''
1465 ccname=''
1466 ccversion=''
1467 perllibs=''
1468 : set useposix=false in your hint file to disable the POSIX extension.
1469 useposix=true
1470 : set useopcode=false in your hint file to disable the Opcode extension.
1471 useopcode=true
1472 archname64=''
1473 ccflags_uselargefiles=''
1474 ldflags_uselargefiles=''
1475 libswanted_uselargefiles=''
1476 : set usemultiplicity on the Configure command line to enable multiplicity.
1477 : set usesocks on the Configure command line to enable socks.
1478 archname=''
1479 : set usethreads on the Configure command line to enable threads.
1480 usereentrant='undef'
1481 : List of libraries we want.
1482 : If anyone needs extra -lxxx, put those in a hint file.
1483 libswanted="cl pthread socket bind inet nsl ndbm gdbm dbm db malloc dl ld"
1484 libswanted="$libswanted sun m crypt sec util c cposix posix ucb bsd BSD"
1485 : We probably want to search /usr/shlib before most other libraries.
1486 : This is only used by the lib/ExtUtils/MakeMaker.pm routine extliblist.
1487 glibpth=`echo " $glibpth " | sed -e 's! /usr/shlib ! !'`
1488 glibpth="/usr/shlib $glibpth"
1489 : Do not use vfork unless overridden by a hint file.
1490 usevfork=false
1491
1492 : Find the basic shell for Bourne shell scripts
1493 case "$sh" in
1494 '')
1495         case "$SYSTYPE" in
1496         *bsd*|sys5*) xxx="/$SYSTYPE/bin/sh";;
1497         *) xxx='/bin/sh';;
1498         esac
1499         if test -f "$xxx"; then
1500                 sh="$xxx"
1501         else
1502                 : Build up a list and do a single loop so we can 'break' out.
1503                 pth=`echo $PATH | sed -e "s/$p_/ /g"`
1504                 for xxx in sh bash ksh pdksh ash; do
1505                         for p in $pth; do
1506                                 try="$try ${p}/${xxx}"
1507                         done
1508                 done
1509                 for xxx in $try; do
1510                         if test -f "$xxx"; then
1511                                 sh="$xxx";
1512                                 break
1513                         elif test "X$_exe" != X -a -f "$xxx$_exe"; then
1514                                 sh="$xxx";
1515                                 break
1516                         elif test -f "$xxx.exe"; then
1517                                 sh="$xxx";
1518                                 break
1519                         fi
1520                 done
1521         fi
1522         ;;
1523 esac
1524
1525 case "$sh" in
1526 '')     cat >&2 <<EOM
1527 $me:  Fatal Error:  I can't find a Bourne Shell anywhere.
1528
1529 Usually it's in /bin/sh.  How did you even get this far?
1530 Please contact me (Perl Maintainers) at perlbug@perl.org and
1531 we'll try to straighten this all out.
1532 EOM
1533         exit 1
1534         ;;
1535 esac
1536
1537 : When cross-compiling we need to separate the sh-to-run-Configure-with from the sh-to-use-in-Perl
1538 : default both to the same thing, cross-compilers can then set targetsh differently if they like
1539 targetsh=$sh
1540
1541 : see if sh knows # comments
1542 if `$sh -c '#' >/dev/null 2>&1`; then
1543         shsharp=true
1544         spitshell=cat
1545         xcat=/bin/cat
1546         test -f $xcat$_exe || xcat=/usr/bin/cat
1547         if test ! -f $xcat$_exe; then
1548                 for p in `echo $PATH | sed -e "s/$p_/ /g"` $paths; do
1549                         if test -f $p/cat$_exe; then
1550                                 xcat=$p/cat
1551                                 break
1552                         fi
1553                 done
1554                 if test ! -f $xcat$_exe; then
1555                         echo "Can't find cat anywhere!"
1556                         exit 1
1557                 fi
1558         fi
1559         echo "#!$xcat" >sharp
1560         $eunicefix sharp
1561         chmod +x sharp
1562         ./sharp > today 2>/dev/null
1563         if test -s today; then
1564                 sharpbang='#!'
1565         else
1566                 echo "#! $xcat" > sharp
1567                 $eunicefix sharp
1568                 chmod +x sharp
1569                 ./sharp > today 2>/dev/null
1570                 if test -s today; then
1571                         sharpbang='#! '
1572                 else
1573                         sharpbang=': use '
1574                 fi
1575         fi
1576 else
1577         echo " "
1578         echo "Your $sh doesn't grok # comments--I will strip them later on."
1579         shsharp=false
1580         cd ..
1581         echo "exec grep -v '^[  ]*#'" >spitshell
1582         chmod +x spitshell
1583         $eunicefix spitshell
1584         spitshell=`pwd`/spitshell
1585         cd UU
1586         echo "I presume that if # doesn't work, #! won't work either!"
1587         sharpbang=': use '
1588 fi
1589 rm -f sharp today
1590
1591 : figure out how to guarantee sh startup
1592 case "$startsh" in
1593 '') startsh=${sharpbang}${sh} ;;
1594 *)
1595 esac
1596 cat >sharp <<EOSS
1597 $startsh
1598 set abc
1599 test "$?abc" != 1
1600 EOSS
1601
1602 chmod +x sharp
1603 $eunicefix sharp
1604 if ./sharp; then
1605         : echo "Yup, it does."
1606 else
1607         echo "Hmm... '$startsh' does not guarantee sh startup..."
1608         echo "You may have to fix up the shell scripts to make sure $sh runs them."
1609 fi
1610 rm -f sharp
1611
1612 : Save command line options in file UU/cmdline.opt for later use in
1613 : generating config.sh.
1614 cat > cmdline.opt <<EOSH
1615 : Configure command line arguments.
1616 config_arg0='$0'
1617 config_args='$*'
1618 config_argc=$#
1619 EOSH
1620 argn=1
1621 args_exp=''
1622 args_sep=''
1623 for arg in "$@"; do
1624         cat >>cmdline.opt <<EOSH
1625 config_arg$argn='$arg'
1626 EOSH
1627         cat <<EOC | sed -e "s/'/'"'"'"'"'"'"'/g" > cmdl.opt
1628 $arg
1629 EOC
1630         arg_exp=`cat cmdl.opt`
1631         args_exp="$args_exp$args_sep'$arg_exp'"
1632         argn=`expr $argn + 1`
1633         args_sep=' '
1634 done
1635 rm -f cmdl.opt
1636
1637 : produce awk script to parse command line options
1638 cat >options.awk <<'EOF'
1639 BEGIN {
1640         optstr = "A:dD:eEf:hKOrsSU:V";  # getopt-style specification
1641
1642         len = length(optstr);
1643         for (i = 1; i <= len; i++) {
1644                 c = substr(optstr, i, 1);
1645                 if (i < len) a = substr(optstr, i + 1, 1); else a = "";
1646                 if (a == ":") {
1647                         arg[c] = 1;
1648                         i++;
1649                 }
1650                 opt[c] = 1;
1651         }
1652 }
1653 {
1654         expect = 0;
1655         str = $0;
1656         if (substr(str, 1, 1) != "-") {
1657                 printf("'%s'\n", str);
1658                 next;
1659         }
1660         len = length($0);
1661         for (i = 2; i <= len; i++) {
1662                 c = substr(str, i, 1);
1663                 if (!opt[c]) {
1664                         printf("-%s\n", substr(str, i));
1665                         next;
1666                 }
1667                 printf("-%s\n", c);
1668                 if (arg[c]) {
1669                         if (i < len)
1670                                 printf("'%s'\n", substr(str, i + 1));
1671                         else
1672                                 expect = 1;
1673                         next;
1674                 }
1675         }
1676 }
1677 END {
1678         if (expect)
1679                 print "?";
1680 }
1681 EOF
1682
1683 : process the command line options
1684 set X `for arg in "$@"; do echo "X$arg"; done |
1685         sed -e s/X// | awk -f options.awk`
1686 eval "set $*"
1687 shift
1688 rm -f options.awk
1689
1690 : set up default values
1691 fastread=''
1692 reuseval=false
1693 config_sh=''
1694 alldone=''
1695 error=''
1696 silent=''
1697 extractsh=''
1698 knowitall=''
1699 rm -f optdef.sh posthint.sh
1700 cat >optdef.sh <<EOS
1701 $startsh
1702 EOS
1703
1704
1705 : option parsing
1706 while test $# -gt 0; do
1707         case "$1" in
1708         -d) shift; fastread=yes;;
1709         -e) shift; alldone=cont;;
1710         -f)
1711                 shift
1712                 cd ..
1713                 if test -r "$1"; then
1714                         config_sh="$1"
1715                 else
1716                         echo "$me: cannot read config file $1." >&2
1717                         error=true
1718                 fi
1719                 cd UU
1720                 shift;;
1721         --help|\
1722         -h) shift; error=true;;
1723         -r) shift; reuseval=true;;
1724         -s) shift; silent=true; realsilent=true;;
1725         -E) shift; alldone=exit;;
1726         -K) shift; knowitall=true;;
1727         -O) shift;;
1728         -S) shift; silent=true; extractsh=true;;
1729         -D)
1730                 shift
1731                 case "$1" in
1732                 *=)
1733                         echo "$me: use '-U symbol=', not '-D symbol='." >&2
1734                         echo "$me: ignoring -D $1" >&2
1735                         ;;
1736                 *=*) echo "$1" | \
1737                                 sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
1738                 *) echo "$1='define'" >> optdef.sh;;
1739                 esac
1740                 shift
1741                 ;;
1742         -U)
1743                 shift
1744                 case "$1" in
1745                 *=) echo "$1" >> optdef.sh;;
1746                 *=*)
1747                         echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
1748                         echo "$me: ignoring -U $1" >&2
1749                         ;;
1750                 *) echo "$1='undef'" >> optdef.sh;;
1751                 esac
1752                 shift
1753                 ;;
1754         -A)
1755             shift
1756             xxx=''
1757             yyy="$1"
1758             zzz=''
1759             uuu=undef
1760             case "$yyy" in
1761             *=*) zzz=`echo "$yyy"|sed 's!=.*!!'`
1762                  case "$zzz" in
1763                  *:*) zzz='' ;;
1764                  *)   xxx=append
1765                       zzz=" "`echo "$yyy"|sed 's!^[^=]*=!!'`
1766                       yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1767                  esac
1768                  ;;
1769             esac
1770             case "$xxx" in
1771             '')  case "$yyy" in
1772                  *:*) xxx=`echo "$yyy"|sed 's!:.*!!'`
1773                       yyy=`echo "$yyy"|sed 's!^[^:]*:!!'`
1774                       zzz=`echo "$yyy"|sed 's!^[^=]*=!!'`
1775                       yyy=`echo "$yyy"|sed 's!=.*!!'` ;;
1776                  *)   xxx=`echo "$yyy"|sed 's!:.*!!'`
1777                       yyy=`echo "$yyy"|sed 's!^[^:]*:!!'` ;;
1778                  esac
1779                  ;;
1780             esac
1781             case "$xxx" in
1782             append)
1783                 echo "$yyy=\"\${$yyy}$zzz\""    >> posthint.sh ;;
1784             clear)
1785                 echo "$yyy=''"                  >> posthint.sh ;;
1786             define)
1787                 case "$zzz" in
1788                 '') zzz=define ;;
1789                 esac
1790                 echo "$yyy='$zzz'"              >> posthint.sh ;;
1791             eval)
1792                 echo "eval \"$yyy=$zzz\""       >> posthint.sh ;;
1793             prepend)
1794                 echo "$yyy=\"$zzz\${$yyy}\""    >> posthint.sh ;;
1795             undef)
1796                 case "$zzz" in
1797                 '') zzz="$uuu" ;;
1798                 esac
1799                 echo "$yyy=$zzz"                >> posthint.sh ;;
1800             *)  echo "$me: unknown -A command '$xxx', ignoring -A $1" >&2 ;;
1801             esac
1802             shift
1803             ;;
1804         -V) echo "$me generated by metaconfig 3.5 PL0." >&2
1805             exit 0;;
1806         --) break;;
1807         -*) echo "$me: unknown option $1" >&2; shift; error=true;;
1808         *) break;;
1809         esac
1810 done
1811
1812 case "$error" in
1813 true)
1814         cat >&2 <<EOM
1815 Usage: $me [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value]
1816                  [-U symbol] [-U symbol=] [-A command:symbol...]
1817   -d : use defaults for all answers.
1818   -e : go on without questioning past the production of config.sh.
1819   -f : specify an alternate default configuration file.
1820   -h : print this help message and exit (with an error status).
1821   -r : reuse C symbols value if possible (skips costly nm extraction).
1822   -s : silent mode, only echoes questions and essential information.
1823   -D : define symbol to have some value:
1824          -D symbol         symbol gets the value 'define'
1825          -D symbol=value   symbol gets the value 'value'
1826        common used examples (see INSTALL for more info):
1827          -Duse64bitint            use 64bit integers
1828          -Duse64bitall            use 64bit integers and pointers
1829          -Dusethreads             use thread support
1830          -Dinc_version_list=none  do not include older perl trees in @INC
1831          -DEBUGGING=none          DEBUGGING options
1832          -Dcc=gcc                 choose your compiler
1833          -Dprefix=/opt/perl5      choose your destination
1834   -E : stop at the end of questions, after having produced config.sh.
1835   -K : do not use unless you know what you are doing.
1836   -O : ignored for backward compatibility
1837   -S : perform variable substitutions on all .SH files (can mix with -f)
1838   -U : undefine symbol:
1839          -U symbol    symbol gets the value 'undef'
1840          -U symbol=   symbol gets completely empty
1841        e.g.:  -Uversiononly
1842   -A : manipulate symbol after the platform specific hints have been applied:
1843          -A append:symbol=value   append value to symbol
1844          -A symbol=value          like append:, but with a separating space
1845          -A define:symbol=value   define symbol to have value
1846          -A clear:symbol          define symbol to be ''
1847          -A define:symbol         define symbol to be 'define'
1848          -A eval:symbol=value     define symbol to be eval of value
1849          -A prepend:symbol=value  prepend value to symbol
1850          -A undef:symbol          define symbol to be 'undef'
1851          -A undef:symbol=         define symbol to be ''
1852        e.g.:  -A prepend:libswanted='cl pthread '
1853               -A ccflags=-DSOME_MACRO
1854   -V : print version number and exit (with a zero status).
1855 EOM
1856         exit 1
1857         ;;
1858 esac
1859
1860 : Sanity checks
1861 case "$fastread$alldone" in
1862 yescont|yesexit) ;;
1863 *)
1864         case "$extractsh" in
1865         true) ;;
1866         *)
1867                 if test ! -t 0; then
1868                         echo "Say 'sh Configure', not 'sh <Configure'"
1869                         exit 1
1870                 fi
1871                 ;;
1872         esac
1873         ;;
1874 esac
1875
1876 exec 4>&1
1877 case "$silent" in
1878 true) exec 1>/dev/null;;
1879 esac
1880
1881 : run the defines and the undefines, if any, but leave the file out there...
1882 touch optdef.sh
1883 grep '\\' optdef.sh >/dev/null 2>&1
1884 if test $? = 0; then
1885     echo "Configure does not support \\ in -D arguments"
1886     exit 1
1887 fi
1888 . ./optdef.sh
1889 : create the posthint manipulation script and leave the file out there...
1890 touch posthint.sh
1891
1892 : set package name
1893 package='perl5'
1894 first=`echo $package | sed -e 's/^\(.\).*/\1/'`
1895 last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
1896 case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
1897 ABYZ-abyz) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
1898 *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
1899 esac
1900
1901 : Some greps do not return status, grrr.
1902 echo "grimblepritz" >grimble
1903 if grep blurfldyick grimble >/dev/null 2>&1 ; then
1904         contains=contains
1905 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
1906         contains=grep
1907 else
1908         contains=contains
1909 fi
1910 rm -f grimble
1911 : the following should work in any shell
1912 case "$contains" in
1913 contains*)
1914         echo " "
1915         echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
1916         cat >contains <<'EOSS'
1917 grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
1918 EOSS
1919 chmod +x contains
1920 esac
1921
1922 : Find the path to the source tree
1923 case "$src" in
1924 '') case "$0" in
1925     */*) src=`echo $0 | sed -e 's%/[^/][^/]*$%%'`
1926          case "$src" in
1927          /*)    ;;
1928          .)     ;;
1929          *)     src=`cd ../$src && pwd` ;;
1930          esac
1931          ;;
1932     *)   src='.';;
1933     esac;;
1934 esac
1935 case "$src" in
1936 '')     src=/
1937         rsrc=/
1938         ;;
1939 /*)     rsrc="$src";;
1940 *)      rsrc="../$src";;
1941 esac
1942 if test -f $rsrc/Configure && \
1943         $contains "^package='$package'\$" $rsrc/Configure >/dev/null 2>&1
1944 then
1945    : found it, so we are ok.
1946 else
1947         rsrc=''
1948         for src in . .. ../.. ../../.. ../../../..; do
1949                 if test -f ../$src/Configure && \
1950                         $contains "^package=$package$" ../$src/Configure >/dev/null 2>&1
1951                 then
1952                         rsrc=../$src
1953                         break
1954                 fi
1955         done
1956 fi
1957 case "$rsrc" in
1958 '')
1959         cat <<EOM >&4
1960
1961 Sorry, I can't seem to locate the source dir for $package.  Please start
1962 Configure with an explicit path -- i.e. /some/path/Configure.
1963
1964 EOM
1965         exit 1
1966         ;;
1967 ../.)   rsrc='..';;
1968 *)
1969         echo " "
1970         echo "Sources for $package found in \"$src\"." >&4
1971         ;;
1972 esac
1973
1974 : script used to extract .SH files with variable substitutions
1975 cat >extract <<'EOS'
1976 PERL_CONFIG_SH=true
1977 echo "Doing variable substitutions on .SH files..."
1978 if test -f MANIFEST; then
1979         set x `awk '{print $1}' < MANIFEST | grep '\.SH$'`
1980 else
1981         echo "(Looking for .SH files under the source directory.)"
1982         set x `(cd "$src"; find . -name "*.SH" -print)`
1983 fi
1984 shift
1985 case $# in
1986 0) set x `(cd "$src"; echo *.SH)`; shift;;
1987 esac
1988 if test ! -f "$src/$1"; then
1989         shift
1990 fi
1991 mkdir_p='
1992 name=$1;
1993 create="";
1994 while test $name; do
1995         if test ! -d "$name"; then
1996                 create="$name $create";
1997                 name=`echo $name | sed -e "s|^[^/]*$||"`;
1998                 name=`echo $name | sed -e "s|\(.*\)/.*|\1|"`;
1999         else
2000                 name="";
2001         fi;
2002 done;
2003 for file in $create; do
2004         mkdir $file;
2005 done
2006 '
2007 for file in $*; do
2008         case "$src" in
2009         ".")
2010                 case "$file" in
2011                 */*)
2012                         dir=`expr X$file : 'X\(.*\)/'`
2013                         file=`expr X$file : 'X.*/\(.*\)'`
2014                         (cd "$dir" && . ./$file)
2015                         ;;
2016                 *)
2017                         . ./$file
2018                         ;;
2019                 esac
2020                 ;;
2021         *)
2022                 case "$file" in
2023                 */*)
2024                         dir=`expr X$file : 'X\(.*\)/'`
2025                         file=`expr X$file : 'X.*/\(.*\)'`
2026                         (set x $dir; shift; eval $mkdir_p)
2027                         sh <"$src/$dir/$file"
2028                         ;;
2029                 *)
2030                         sh <"$src/$file"
2031                         ;;
2032                 esac
2033                 ;;
2034         esac
2035 done
2036 if test -f "$src/config_h.SH"; then
2037         if test ! -f config.h; then
2038         : oops, they left it out of MANIFEST, probably, so do it anyway.
2039         . "$src/config_h.SH"
2040         fi
2041 fi
2042 EOS
2043
2044 : extract files and exit if asked to do so
2045 case "$extractsh" in
2046 true)
2047         case "$realsilent" in
2048         true) ;;
2049         *) exec 1>&4;;
2050         esac
2051         case "$config_sh" in
2052         '') config_sh='config.sh';;
2053         esac
2054         echo " "
2055         echo "Fetching answers from $config_sh..."
2056         cd ..
2057         . $config_sh
2058         . UU/optdef.sh
2059         echo " "
2060         . UU/extract
2061         rm -rf UU
2062         echo "Extraction done."
2063         exit 0
2064         ;;
2065 esac
2066
2067 : Eunice requires " " instead of "", can you believe it
2068 echo " "
2069 : Here we go...
2070 echo "Beginning of configuration questions for $package."
2071
2072 trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
2073
2074 : first determine how to suppress newline on echo command
2075 echo " "
2076 echo "Checking echo to see how to suppress newlines..."
2077 (echo "hi there\c" ; echo " ") >.echotmp
2078 if $contains c .echotmp >/dev/null 2>&1 ; then
2079         echo "...using -n."
2080         n='-n'
2081         c=''
2082 else
2083         cat <<'EOM'
2084 ...using \c
2085 EOM
2086         n=''
2087         c='\c'
2088 fi
2089 echo $n "The star should be here-->$c"
2090 echo '*'
2091 rm -f .echotmp
2092
2093 : Now test for existence of everything in MANIFEST
2094 echo " "
2095 if test -f "$rsrc/MANIFEST"; then
2096         echo "First let's make sure your kit is complete.  Checking..." >&4
2097         awk '$1 !~ /PACK[A-Z]+/ {print $1}' "$rsrc/MANIFEST" | \
2098                 (split -l 50 2>/dev/null || split -50)
2099         rm -f missing
2100         tmppwd=`pwd`
2101         for filelist in x??; do
2102                 (cd "$rsrc"; ls `cat "$tmppwd/$filelist"` \
2103                         >/dev/null 2>>"$tmppwd/missing")
2104         done
2105         if test -s missing; then
2106                 cat missing >&4
2107                 cat >&4 <<'EOM'
2108
2109 THIS PACKAGE SEEMS TO BE INCOMPLETE.
2110
2111 You have the option of continuing the configuration process, despite the
2112 distinct possibility that your kit is damaged, by typing 'y'es.  If you
2113 do, don't blame me if something goes wrong.  I advise you to type 'n'o
2114 and contact the author (perlbug@perl.org).
2115
2116 EOM
2117                 echo $n "Continue? [n] $c" >&4
2118                 read ans
2119                 case "$ans" in
2120                 y*)
2121                         echo "Continuing..." >&4
2122                         rm -f missing
2123                         ;;
2124                 *)
2125                         echo "ABORTING..." >&4
2126                         kill $$
2127                         ;;
2128                 esac
2129         else
2130                 echo "Looks good..."
2131         fi
2132 else
2133         echo "There is no MANIFEST file.  I hope your kit is complete !"
2134 fi
2135 rm -f missing x??
2136
2137 : Find the appropriate value for a newline for tr
2138 if test -n "$DJGPP"; then
2139        trnl='\012'
2140 fi
2141 if test X"$trnl" = X; then
2142         case "`echo foo | tr '\n' x 2>/dev/null`" in
2143         foox) trnl='\n' ;;
2144         esac
2145 fi
2146 if test X"$trnl" = X; then
2147         case "`echo foo | tr '\012' x 2>/dev/null`" in
2148         foox) trnl='\012' ;;
2149         esac
2150 fi
2151 if test X"$trnl" = X; then
2152        case "`echo foo | tr '\r\n' xy 2>/dev/null`" in
2153        fooxy) trnl='\n\r' ;;
2154        esac
2155 fi
2156 if test X"$trnl" = X; then
2157         cat <<EOM >&2
2158
2159 $me: Fatal Error: cannot figure out how to translate newlines with 'tr'.
2160
2161 EOM
2162         exit 1
2163 fi
2164
2165 : compute the number of columns on the terminal for proper question formatting
2166 case "$COLUMNS" in
2167 '') COLUMNS='80';;
2168 esac
2169
2170 : set up the echo used in my read
2171 myecho="case \"\$xxxm\" in
2172 '') echo $n \"\$rp $c\" >&4;;
2173 *) case \"\$rp\" in
2174         '') echo $n \"[\$xxxm] $c\";;
2175         *)
2176                 if test \`echo \"\$rp [\$xxxm]  \" | wc -c\` -ge $COLUMNS; then
2177                         echo \"\$rp\" >&4
2178                         echo $n \"[\$xxxm] $c\" >&4
2179                 else
2180                         echo $n \"\$rp [\$xxxm] $c\" >&4
2181                 fi
2182                 ;;
2183         esac;;
2184 esac"
2185
2186 : now set up to do reads with possible shell escape and default assignment
2187 cat <<EOSC >myread
2188 $startsh
2189 xxxm=\$dflt
2190 $myecho
2191 ans='!'
2192 case "\$fastread" in
2193 yes) case "\$dflt" in
2194         '') ;;
2195         *) ans='';
2196                 case "\$silent-\$rp" in
2197                 true-) ;;
2198                 *) echo " " >&4;;
2199                 esac;;
2200         esac;;
2201 *) case "\$silent" in
2202         true) case "\$rp" in
2203                 '') ans='';;
2204                 esac;;
2205         esac;;
2206 esac
2207 while expr "X\$ans" : "X!" >/dev/null; do
2208         read answ
2209         set x \$xxxm
2210         shift
2211         aok=''; eval "ans=\\"\$answ\\"" && aok=y
2212         case  "\$answ" in
2213         "!")
2214                 sh 1>&4
2215                 echo " "
2216                 $myecho
2217                 ;;
2218         !*)
2219                 set x \`expr "X\$ans" : "X!\(.*\)\$"\`
2220                 shift
2221                 sh 1>&4 -c "\$*"
2222                 echo " "
2223                 $myecho
2224                 ;;
2225         "\$ans")
2226                 case "\$ans" in
2227                 \\&*)
2228                         set x \`expr "X\$ans" : "X&\(.*\)\$"\`
2229                         shift
2230                         case "\$1" in
2231                         -d)
2232                                 fastread=yes
2233                                 echo "(OK, I'll run with -d after this question.)" >&4
2234                                 ;;
2235                         -*)
2236                                 echo "*** Sorry, \$1 not supported yet." >&4
2237                                 ;;
2238                         esac
2239                         $myecho
2240                         ans=!
2241                         ;;
2242                 esac;;
2243         *)
2244                 case "\$aok" in
2245                 y)
2246                         echo "*** Substitution done -- please confirm."
2247                         xxxm="\$ans"
2248                         ans=\`echo $n "\$ans$c" | tr '$trnl' ' '\`
2249                         xxxm="\$ans"
2250                         ans=!
2251                         ;;
2252                 *)
2253                         echo "*** Error -- try again."
2254                         ans=!
2255                         ;;
2256                 esac
2257                 $myecho
2258                 ;;
2259         esac
2260         case "\$ans\$xxxm\$nostick" in
2261         '')
2262                 ans=!
2263                 $myecho
2264                 ;;
2265         esac
2266 done
2267 case "\$ans" in
2268 '') ans="\$xxxm";;
2269 esac
2270 EOSC
2271
2272 : create .config dir to save info across Configure sessions
2273 test -d ../.config || mkdir ../.config
2274 cat >../.config/README <<EOF
2275 This directory created by Configure to save information that should
2276 persist across sessions for $package.
2277
2278 You may safely delete it if you wish.
2279 EOF
2280
2281 : See if we are using a devel version and want that
2282 xversion=`awk '/define[         ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
2283 case "$usedevel" in
2284 $define|true|[yY]*)
2285     usedevel="$define" ;;
2286 *) case "$xversion" in
2287    *[13579])
2288         cat >&4 <<EOH
2289 *** WHOA THERE!!! ***
2290
2291     This is an UNSTABLE DEVELOPMENT release.
2292     The version of this $package distribution is $xversion, that is, odd,
2293     (as opposed to even) and that signifies a development release.
2294     If you want a maintenance release, you want an even-numbered version.
2295
2296     Do ***NOT*** install this into production use.
2297     Data corruption and crashes are possible.
2298
2299     It is most seriously suggested that you do not continue any further
2300     unless you want to help in developing and debugging Perl.
2301
2302     If you *still* want to build perl, you can answer 'y' now,
2303     or pass -Dusedevel to Configure.
2304
2305 EOH
2306         rp='Do you really want to continue?'
2307         dflt='n'
2308         . ./myread
2309         case "$ans" in
2310         [yY]) echo >&4 "Okay, continuing."
2311               usedevel="$define" ;;
2312         *) echo >&4 "Okay, bye."
2313            exit 1
2314            ;;
2315         esac
2316         ;;
2317     esac
2318     usedevel="$undef"
2319     ;;
2320 esac
2321 case "$usedevel" in
2322 $define|true|[yY]*)
2323         case "$versiononly" in
2324         '') versiononly="$define" ;;
2325         esac
2326         case "$installusrbinperl" in
2327         '') installusrbinperl="$undef" ;;
2328         esac
2329         ;;
2330 esac
2331
2332 : general instructions
2333 needman=true
2334 firsttime=true
2335 user=`(logname) 2>/dev/null`
2336 case "$user" in
2337 '') user=`whoami 2>&1`;;
2338 esac
2339 if $contains "^$user\$" ../.config/instruct >/dev/null 2>&1; then
2340         firsttime=false
2341         echo " "
2342         rp='Would you like to see the instructions?'
2343         dflt=n
2344         . ./myread
2345         case "$ans" in
2346         [yY]*) ;;
2347         *) needman=false;;
2348         esac
2349 fi
2350 if $needman; then
2351         cat <<EOH
2352
2353 This installation shell script will examine your system and ask you questions
2354 to determine how the perl5 package should be installed. If you get
2355 stuck on a question, you may use a ! shell escape to start a subshell or
2356 execute a command.  Many of the questions will have default answers in square
2357 brackets; typing carriage return will give you the default.
2358
2359 On some of the questions which ask for file or directory names you are allowed
2360 to use the ~name construct to specify the login directory belonging to "name",
2361 even if you don't have a shell which knows about that.  Questions where this is
2362 allowed will be marked "(~name ok)".
2363
2364 EOH
2365         rp=''
2366         dflt='Type carriage return to continue'
2367         . ./myread
2368         cat <<'EOH'
2369
2370 The prompter used in this script allows you to use shell variables and
2371 backticks in your answers.  You may use $1, $2, etc...  to refer to the words
2372 in the default answer, as if the default line was a set of arguments given to a
2373 script shell.  This means you may also use $* to repeat the whole default line,
2374 so you do not have to re-type everything to add something to the default.
2375
2376 Every time there is a substitution, you will have to confirm.  If there is an
2377 error (e.g. an unmatched backtick), the default answer will remain unchanged
2378 and you will be prompted again.
2379
2380 If you are in a hurry, you may run 'Configure -d'.  This will bypass nearly all
2381 the questions and use the computed defaults (or the previous answers if there
2382 was already a config.sh file). Type 'Configure -h' for a list of options.
2383 You may also start interactively and then answer '& -d' at any prompt to turn
2384 on the non-interactive behaviour for the remainder of the execution.
2385
2386 EOH
2387         . ./myread
2388         cat <<EOH
2389
2390 Much effort has been expended to ensure that this shell script will run on any
2391 Unix system.  If despite that it blows up on yours, your best bet is to edit
2392 Configure and run it again.  If you can't run Configure for some reason,
2393 you'll have to generate a config.sh file by hand.  Whatever problems you
2394 have, let me (perlbug@perl.org) know how I blew it.
2395
2396 This installation script affects things in two ways:
2397
2398 1) it may do direct variable substitutions on some of the files included
2399    in this kit.
2400 2) it builds a config.h file for inclusion in C programs.  You may edit
2401    any of these files as the need arises after running this script.
2402
2403 If you make a mistake on a question, there is no easy way to back up to it
2404 currently.  The easiest thing to do is to edit config.sh and rerun all the SH
2405 files.  Configure will offer to let you do this before it runs the SH files.
2406
2407 EOH
2408         dflt='Type carriage return to continue'
2409         . ./myread
2410         case "$firsttime" in
2411         true) echo $user >>../.config/instruct;;
2412         esac
2413 fi
2414
2415 : Set 'sysroot' to change the logical root directory to your headers and libraries see man gcc
2416 : This is primarily meant for cross-compile environments, and may fail to be useful in other cases
2417 if test "X$sysroot" = X; then
2418     sysroot=""
2419 else
2420     case "$cc" in
2421         *gcc*|*g++*)
2422             echo "Using $sysroot to find your headers and libraries, adding to ccflags"
2423             # _sysroot is used in places where we need --sysroot=foo
2424             # but using the rest of the flags could cause issues.
2425             _sysroot="--sysroot=$sysroot";
2426             case "$ccflags" in
2427                 *sysroot*) ;;
2428                 'undef'|*)
2429                 ccflags="$ccflags $_sysroot"
2430             esac
2431             case "$ldflags" in
2432                 *sysroot*) ;;
2433                 'undef'|*)
2434                 ldflags="$ldflags $_sysroot"
2435             esac
2436             case "$cppflags" in
2437                 *sysroot*) ;;
2438                 'undef'|*)
2439                 cppflags="$cppflags $_sysroot"
2440             esac
2441             # lddlflags updated below in lddlflags section;
2442             # same with cccdlflags
2443             ;;
2444     esac
2445
2446     # Adjust some defaults to also use $sysroot
2447     for var in xlibpth loclibpth locincpth glibpth; do
2448         eval xxx=\$$var
2449         eval $var=''
2450         for path in $xxx; do
2451             eval $var=\"\$$var $sysroot$path\"
2452         done
2453     done
2454
2455 fi
2456
2457 : find out where common programs are
2458 echo " "
2459 echo "Locating common programs..." >&4
2460 cat <<EOSC >loc
2461 $startsh
2462 case \$# in
2463 0) exit 1;;
2464 esac
2465 thing=\$1
2466 shift
2467 dflt=\$1
2468 shift
2469 for dir in \$*; do
2470         case "\$thing" in
2471         .)
2472         if test -d \$dir/\$thing; then
2473                 echo \$dir
2474                 exit 0
2475         fi
2476         ;;
2477         *)
2478         for thisthing in \$dir/\$thing; do
2479                 : just loop through to pick last item
2480         done
2481         if test -f \$thisthing; then
2482                 echo \$thisthing
2483                 exit 0
2484         elif test "X$_exe" != X -a -f \$thisthing$_exe; then
2485                 echo \$thisthing
2486                 exit 0
2487         elif test -f \$dir/\$thing.exe; then
2488                 if test -n "$DJGPP"; then
2489                         echo \$dir/\$thing.exe
2490                 elif test "$eunicefix" != ":"; then
2491                         : on Eunice apparently
2492                         echo \$dir/\$thing
2493                 fi
2494                 exit 0
2495         fi
2496         ;;
2497         esac
2498 done
2499 echo \$dflt
2500 exit 1
2501 EOSC
2502 chmod +x loc
2503 $eunicefix loc
2504 loclist="
2505 awk
2506 cat
2507 chmod
2508 comm
2509 cp
2510 echo
2511 expr
2512 grep
2513 ls
2514 mkdir
2515 rm
2516 sed
2517 sort
2518 touch
2519 tr
2520 uniq
2521 "
2522 trylist="
2523 ar
2524 bison
2525 byacc
2526 cpp
2527 csh
2528 date
2529 egrep
2530 gmake
2531 gzip
2532 less
2533 ln
2534 make
2535 more
2536 nm
2537 nroff
2538 perl
2539 pg
2540 test
2541 uname
2542 zip
2543 "
2544 pth=`echo $PATH | sed -e "s/$p_/ /g"`
2545 pth="$pth $sysroot/lib $sysroot/usr/lib"
2546 for file in $loclist; do
2547         eval xxx=\$$file
2548         case "$xxx" in
2549         /*|?:[\\/]*)
2550                 if test -f "$xxx"; then
2551                         : ok
2552                 else
2553                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2554                         xxx=`./loc $file $file $pth`
2555                 fi
2556                 ;;
2557         '') xxx=`./loc $file $file $pth`;;
2558         *) xxx=`./loc $xxx $xxx $pth`;;
2559         esac
2560         eval $file=$xxx$_exe
2561         eval _$file=$xxx
2562         case "$xxx" in
2563         /*)
2564                 echo $file is in $xxx.
2565                 ;;
2566         ?:[\\/]*)
2567                 echo $file is in $xxx.
2568                 ;;
2569         *)
2570                 echo "I don't know where '$file' is, and my life depends on it." >&4
2571                 echo "Go find a public domain implementation or fix your PATH setting!" >&4
2572                 exit 1
2573                 ;;
2574         esac
2575 done
2576 echo " "
2577 echo "Don't worry if any of the following aren't found..."
2578 say=offhand
2579 for file in $trylist; do
2580         eval xxx=\$$file
2581         case "$xxx" in
2582         /*|?:[\\/]*)
2583                 if test -f "$xxx"; then
2584                         : ok
2585                 else
2586                         echo "WARNING: no $xxx -- ignoring your setting for $file." >&4
2587                         xxx=`./loc $file $file $pth`
2588                 fi
2589                 ;;
2590         '') xxx=`./loc $file $file $pth`;;
2591         *) xxx=`./loc $xxx $xxx $pth`;;
2592         esac
2593         eval $file=$xxx$_exe
2594         eval _$file=$xxx
2595         case "$xxx" in
2596         /*)
2597                 echo $file is in $xxx.
2598                 ;;
2599         ?:[\\/]*)
2600                 echo $file is in $xxx.
2601                 ;;
2602         *)
2603                 echo "I don't see $file out there, $say."
2604                 say=either
2605                 ;;
2606         esac
2607 done
2608 case "$egrep" in
2609 egrep)
2610         echo "Substituting grep for egrep."
2611         egrep=$grep
2612         _egrep=$grep
2613         ;;
2614 esac
2615 case "$less" in
2616 '')     ;;
2617 *)      if $less -R </dev/null >/dev/null 2>&1; then
2618                echo "Substituting less -R for less."
2619                less="$less -R"
2620                _less=$less
2621         fi
2622         ;;
2623 esac
2624 case "$ln" in
2625 ln)
2626         echo "Substituting cp for ln."
2627         ln=$cp
2628         _ln=$cp
2629         ;;
2630 esac
2631 case "$make" in
2632 make)
2633         case "$gmake" in
2634         gmake)
2635         echo "I can't find make or gmake, and my life depends on it." >&4
2636         echo "Go find a public domain implementation or fix your PATH setting!" >&4
2637         exit 1
2638         ;;
2639         esac
2640         ;;
2641 esac
2642 case "$gmake" in
2643 gmake)  ;;
2644 *)      # We can't have osname yet.
2645         if test -f "/system/gnu_library/bin/ar.pm"; then # Stratus VOS
2646                 # Assume that gmake, if found, is definitely GNU make
2647                 # and prefer it over the system make.
2648                 echo "Substituting gmake for make."
2649                 make=$gmake
2650                 _make=$gmake
2651         fi
2652         ;;
2653 esac
2654 case "$test" in
2655 test)
2656         echo "Hopefully test is built into your sh."
2657         ;;
2658 *)
2659         if `sh -c "PATH= test true" >/dev/null 2>&1`; then
2660                 echo "Using the test built into your sh."
2661                 test=test
2662                 _test=test
2663         fi
2664         ;;
2665 esac
2666 case "$echo" in
2667 echo)
2668         echo "Hopefully echo is built into your sh."
2669         ;;
2670 '') ;;
2671 *)
2672         echo " "
2673 echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
2674         $echo $n "hi there$c" >foo1
2675         echo $n "hi there$c" >foo2
2676         if cmp foo1 foo2 >/dev/null 2>&1; then
2677                 echo "They are compatible.  In fact, they may be identical."
2678         else
2679                 case "$n" in
2680                 '-n') n='' c='\c';;
2681                 *) n='-n' c='';;
2682                 esac
2683                 cat <<FOO
2684 They are not compatible!  You are probably running ksh on a non-USG system.
2685 I'll have to use $echo instead of the builtin, since Bourne shell doesn't
2686 have echo built in and we may have to run some Bourne shell scripts.  That
2687 means I'll have to use '$n$c' to suppress newlines now.  Life is ridiculous.
2688
2689 FOO
2690                 $echo $n "The star should be here-->$c"
2691                 $echo "*"
2692         fi
2693         $rm -f foo1 foo2
2694         ;;
2695 esac
2696
2697 # This question was auctioned at YAPC::Europe-2007 in Vienna
2698 # I never promised you could answer it. I only auctioned the question.
2699 cat <<FOO
2700 The following message is sponsored by
2701
2702   Dresden.pm<--The stars should be here.
2703
2704 Dear Perl user, system administrator or package
2705 maintainer, the Perl community sends greetings to
2706 you. Do you (emblematical) greet back [Y/n]? n
2707
2708 FOO
2709
2710 : Check what type of C compiler we use
2711 cat <<EOS >trygcc
2712 $startsh
2713 EOS
2714 cat <<'EOSC' >>trygcc
2715 case "$cc" in
2716 '') ;;
2717 *)  $rm -f try try.*
2718     $cat >try.c <<EOM
2719 int main(int argc, char *argv[]) {
2720   return 0;
2721 }
2722 EOM
2723     if $cc -o try $ccflags $ldflags try.c; then
2724        :
2725     else
2726         echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2727         despair=yes
2728         trygcc=yes
2729         case "$cc" in
2730         *gcc*) trygcc=no ;;
2731         esac
2732         # Skip this test because it gives a false match on output like:
2733         #    ./trygcc: line 23: cc: command not found
2734         # case "`$cc -v -c try.c 2>&1`" in
2735         # *gcc*) trygcc=no ;;
2736         # esac
2737         if $test X"$trygcc" = Xyes; then
2738             if gcc -o try -c try.c; then
2739                 echo " "
2740                 echo "You seem to have a working gcc, though." >&4
2741                 # Switching compilers may undo the work of hints files.
2742                 # The most common problem is -D_REENTRANT for threads.
2743                 # This heuristic catches that case, but gets false positives
2744                 # if -Dusethreads was not actually specified.  Better to
2745                 # bail out here with a useful message than fail
2746                 # mysteriously later. Should we perhaps just try to
2747                 # re-invoke Configure -Dcc=gcc config_args ?
2748                 if $test -f usethreads.cbu; then
2749                         $cat >&4 <<EOM
2750
2751 *** However, any setting of the C compiler flags (e.g. for thread support)
2752 *** will be lost.  It may be necessary for you to restart Configure and
2753 *** add -Dcc=gcc to your Configure command line.
2754
2755 EOM
2756                         rp="Would you like to go ahead and try gcc anyway?"
2757                         dflt=n
2758                 else
2759                         rp="Would you like to use it?"
2760                         dflt=y
2761                 fi
2762                 if $test -f myread; then
2763                     . ./myread
2764                 else
2765                     if $test -f UU/myread; then
2766                         . ./UU/myread
2767                     else
2768                         echo "Cannot find myread, sorry.  Aborting." >&2
2769                         exit 1
2770                     fi
2771                 fi
2772                 case "$ans" in
2773                 [yY]*) cc=gcc; ccname=gcc; ccflags=''; despair=no;
2774                 esac
2775             fi
2776         fi
2777     fi
2778     $rm -f try try.*
2779     ;;
2780 esac
2781 EOSC
2782
2783 cat <<EOS >checkcc
2784 $startsh
2785 EOS
2786 cat <<'EOSC' >>checkcc
2787 case "$cc" in
2788 '') ;;
2789 *)  $rm -f try try.*
2790     $cat >try.c <<EOM
2791 int main(int argc, char *argv[]) {
2792   return 0;
2793 }
2794 EOM
2795     if $cc -o try $ccflags $ldflags try.c; then
2796        :
2797     else
2798         if $test X"$despair" = Xyes; then
2799            echo "Uh-oh, the C compiler '$cc' doesn't seem to be working." >&4
2800         fi
2801         $cat >&4 <<EOM
2802 You need to find a working C compiler.
2803 Either (purchase and) install the C compiler supplied by your OS vendor,
2804 or for a free C compiler try http://gcc.gnu.org/
2805 I cannot continue any further, aborting.
2806 EOM
2807         exit 1
2808     fi
2809     $rm -f try try.*
2810     ;;
2811 esac
2812 EOSC
2813
2814 : determine whether symbolic links are supported
2815 echo " "
2816 $touch blurfl
2817 if $ln -s blurfl sym > /dev/null 2>&1 ; then
2818         echo "Symbolic links are supported." >&4
2819         lns="$ln -s"
2820 else
2821         echo "Symbolic links are NOT supported." >&4
2822         lns="$ln"
2823 fi
2824 $rm -f blurfl sym
2825
2826 : determine whether symbolic links are supported
2827 echo " "
2828 case "$lns" in
2829 *"ln"*" -s")
2830         echo "Checking how to test for symbolic links..." >&4
2831         $lns blurfl sym
2832         if $test "X$issymlink" = X; then
2833                 case "$newsh" in
2834                 '') sh     -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2835                 *)  $newsh -c "PATH= test -h sym" >/dev/null 2>&1 ;;
2836                 esac
2837                 if test $? = 0; then
2838                         issymlink="test -h"
2839                 else
2840                         echo "Your builtin 'test -h' may be broken." >&4
2841                         case "$test" in
2842                         /*)     ;;
2843                         *)      pth=`echo $PATH | sed -e "s/$p_/ /g"`
2844                                 for p in $pth
2845                                 do
2846                                         if test -f "$p/$test"; then
2847                                                 test="$p/$test"
2848                                                 break
2849                                         fi
2850                                 done
2851                                 ;;
2852                         esac
2853                         case "$test" in
2854                         /*)
2855                                 echo "Trying external '$test -h'." >&4
2856                                 issymlink="$test -h"
2857                                 if $test ! -h sym >/dev/null 2>&1; then
2858                                         echo "External '$test -h' is broken, too." >&4
2859                                         issymlink=''
2860                                 fi
2861                                 ;;
2862                         *)      issymlink='' ;;
2863                         esac
2864                 fi
2865         fi
2866         if $test "X$issymlink" = X; then
2867                 if $test -L sym 2>/dev/null; then
2868                         issymlink="$test -L"
2869                         echo "The builtin '$test -L' worked." >&4
2870                 fi
2871         fi
2872         if $test "X$issymlink" != X; then
2873                 echo "You can test for symbolic links with '$issymlink'." >&4
2874         else
2875                 echo "I do not know how you can test for symbolic links." >&4
2876         fi
2877         $rm -f blurfl sym
2878         ;;
2879 *)      echo "No symbolic links, so not testing for their testing..." >&4
2880         ;;
2881 esac
2882 echo " "
2883
2884 : Make symlinks util
2885 case "$mksymlinks" in
2886 $define|true|[yY]*)
2887         case "$src" in
2888         ''|'.') echo "Cannot create symlinks in the original directory." >&4
2889                 exit 1
2890                 ;;
2891         *)      case "$lns:$issymlink" in
2892                 *"ln"*" -s:"*"test -"?)
2893                         echo "Creating the symbolic links..." >&4
2894                         cd ..
2895                         awk '{print $1}' $src/MANIFEST | sed -e 's:/\([^/]*\)$: \1:' |
2896                         awk 'NF == 1 {
2897                                 dir=".";
2898                                 file=$1 "";
2899                              }
2900                              NF == 2 {
2901                                 dir=$1 "";
2902                                 file=$2 "";
2903                              }
2904                              {
2905                                  print "# dir = ", dir, "file = ", file
2906                                  mf[dir] = mf[dir]" "source"/"dir"/"file;
2907                              } END {
2908                                  for (d in mf) {
2909                                      if (d != ".") { print("mkdir -p "d) }
2910                                      print("ln -sf "mf[d]" "d);
2911                                  }
2912                              }' source="$src" > UU/mksymlinks.$$
2913                         sh UU/mksymlinks.$$
2914                         rm UU/mksymlinks.$$
2915                         # Sanity check 1.
2916                         if test ! -d t/base; then
2917                                 echo "Failed to create the subdirectories.  Aborting." >&4
2918                                 exit 1
2919                         fi
2920                         # Sanity check 2.
2921                         if test ! -f t/base/lex.t; then
2922                                 echo "Failed to create the symlinks (t/base/lex.t missing).  Aborting." >&4
2923                                 exit 1
2924                         fi
2925                         if test ! -f win32/win32.c; then
2926                                 echo "Failed to create the symlinks (win32/win32.c missing).  Aborting." >&4
2927                                 exit 1
2928                         fi
2929                         cd UU
2930                         ;;
2931                 *)      echo "(I cannot figure out how to do symbolic links, ignoring mksymlinks)." >&4
2932                         ;;
2933                 esac
2934                 ;;
2935         esac
2936         ;;
2937 esac
2938
2939 : Check for Cross-Compilation
2940 if $test "X$targethost" = "X"; then
2941     targethost=""
2942 fi
2943 if $test "X$targetenv" = "X"; then
2944     targetenv=""
2945 fi
2946 case "$usecrosscompile" in
2947 $define|true|[yY]*)
2948         $echo "Cross-compiling..."
2949         croak=''
2950         case "$cc" in
2951         *-gcc*|*-g++*) # A cross-compiling gcc, probably.
2952             # arm-linux-androideabi-gcc  -> arm-linux-androideabi
2953             # x86_64-w64-mingw32-gcc.exe -> x86_64-w64-mingw32
2954             targetarch=`$echo $cc|$sed 's/-g[c\+][c\+].*$//'`
2955             ar=`$echo $cc|$sed 's/-g[c\+][c\+]/-ar/'`
2956             # leave out ld, choosing it is more complex
2957             nm=`$echo $cc|$sed 's/-g[c\+][c\+]/-nm/'`
2958             ranlib=`$echo $cc|$sed 's/-g[c\+][c\+]/-ranlib/'`
2959             # We are in a weird spot. Just before us, some values
2960             # were 'saved', to be restored after the hints are
2961             # run.  This means that the changes we made to ar,
2962             # nm and ranlib will get reverted.
2963             # To avoid that, we hijack the saving mechanism and
2964             # have it save our new values.
2965             for file in ar nm ranlib; do
2966                 eval xxx=\$$file
2967                 eval $file=$xxx$_exe
2968                 eval _$file=$xxx
2969             done
2970         ;;
2971         esac
2972         case "$targetarch" in
2973         '') echo "Targetarch not defined." >&4; croak=y ;;
2974         *)  echo "Using targetarch $targetarch." >&4 ;;
2975         esac
2976         case "$targethost" in
2977         '') echo "Targethost not defined." >&4; croak=n ;;
2978         *)  echo "Using targethost $targethost." >&4
2979         esac
2980         locincpth=' '
2981         loclibpth=' '
2982         case "$croak" in
2983         y) echo "Cannot continue, aborting." >&4; exit 1 ;;
2984         esac
2985     : compile a host miniperl and generate_uudmap, unless we got passed them
2986     if $test "X$hostperl" = X; then
2987       echo "Building host miniperl and generate_uudmap binaries" >&4
2988       before_host=`pwd`
2989       cd ..
2990       cd $src
2991       src=`pwd`
2992       rm -rf $src/host
2993       mkdir $src/host
2994       cd $src/host
2995       $src/Configure -des -Dusedevel -Dmksymlinks
2996       $make miniperl
2997       case "$hostgenerate" in
2998       '') $make generate_uudmap
2999           hostgenerate=$src/host/generate_uudmap
3000           ;;
3001        "$undef") hostgenerate=''
3002           ;;
3003       esac
3004       hostperl=$src/host/miniperl
3005       cd $before_host
3006     fi
3007     hostosname=`$hostperl -le 'print $^O'`
3008     ;;
3009 *)
3010     usecrosscompile="$undef"
3011     ;;
3012 esac
3013
3014 : Define -Dtargethost=somecomputer to run compiled tests on another machine
3015 case "$targethost" in
3016     '') echo "Checking for cross-compile" >&4
3017     case "$usecrosscompile$multiarch" in
3018        *$define*) echo "Skipping the try tests in the rest of Configure as no targethost was defined when cross-compiling" >&4
3019          if [ -f Makefile ]; then
3020            echo " "
3021            echo "Now you must ensure config.sh, config.h and the generated headers exist and run a $make."
3022          else
3023            echo "Configure done."
3024          fi
3025        exit 0
3026        ;;
3027      *) echo "No targethost for running compiler tests against defined, running locally" >&4
3028         run=''
3029         to=:
3030         from=:
3031         ;;
3032     esac
3033     ;;
3034     *) echo "Using targethost $targethost." >&4
3035         case "$src" in
3036         /*) run=$src/Cross/run
3037             targetmkdir=$src/Cross/mkdir
3038             to=$src/Cross/to
3039             from=$src/Cross/from
3040             ;;
3041         *)  pwd=`$test -f ../Configure & cd ..; pwd`
3042             run=$pwd/Cross/run
3043             targetmkdir=$pwd/Cross/mkdir
3044             to=$pwd/Cross/to
3045             from=$pwd/Cross/from
3046             ;;
3047         esac
3048         case "$targetrun" in
3049         '') targetrun=ssh ;;
3050         esac
3051         case "$targetto" in
3052         '') targetto=scp ;;
3053         esac
3054         case "$targetfrom" in
3055         '') targetfrom=scp ;;
3056         esac
3057         run=$run-$targetrun
3058         to=$to-$targetto
3059         from=$from-$targetfrom
3060         case "$targetdir" in
3061         '')  targetdir=/tmp
3062              echo "Guessing targetdir $targetdir." >&4
3063              ;;
3064         esac
3065         case "$targetuser" in
3066         '')  targetuser=root
3067              echo "Guessing targetuser $targetuser." >&4
3068              ;;
3069         esac
3070         case "$targetport" in
3071         '')  targetport=22
3072              echo "Guessing targetport $targetport." >&4
3073              ;;
3074         esac
3075         case "$targetfrom" in
3076         scp)    q=-q ;;
3077         *)      q='' ;;
3078         esac
3079         case "$targetrun" in
3080         ssh|rsh)
3081             cat >$run <<EOF
3082 #!/bin/sh
3083 env=''
3084 case "\$1" in
3085 -cwd)
3086   shift
3087   cwd=\$1
3088   shift
3089   ;;
3090 esac
3091 case "\$1" in
3092 -env)
3093   shift
3094   env=\$1
3095   shift
3096   ;;
3097 esac
3098 case "\$cwd" in
3099 '') cwd=$targetdir ;;
3100 esac
3101 exe=\$1
3102 shift
3103 $to \$exe
3104 $targetrun -p $targetport -l $targetuser $targethost "cd \$cwd && \$env \$exe \$@"
3105 EOF
3106             ;;
3107         adb)
3108             $touch $run
3109             ;;
3110         *)  echo "Unknown targetrun '$targetrun'" >&4
3111             exit 1
3112             ;;
3113         esac
3114         case "$targetmkdir" in
3115         */Cross/mkdir)
3116             cat >$targetmkdir <<EOF
3117 #!/bin/sh
3118 $targetrun -p $targetport -l $targetuser $targethost "mkdir -p \$@"
3119 EOF
3120             $chmod a+rx $targetmkdir
3121             ;;
3122         *)  echo "Unknown targetmkdir '$targetmkdir'" >&4
3123             exit 1
3124             ;;
3125         esac
3126         case "$targetto" in
3127         scp|rcp)
3128             cat >$to <<EOF
3129 #!/bin/sh
3130 for f in \$@
3131 do
3132   case "\$f" in
3133   /*)
3134     $targetmkdir \`dirname \$f\`
3135     $targetto -P $targetport -r $q \$f $targetuser@$targethost:\$f           2>/dev/null  || exit 1
3136     ;;
3137   *)
3138     $targetmkdir $targetdir/\`dirname \$f\`
3139     $targetto -P $targetport -r $q \$f $targetuser@$targethost:$targetdir/\$f 2>/dev/null || exit 1
3140     ;;
3141   esac
3142 done
3143 exit 0
3144 EOF
3145             ;;
3146         cp) cat >$to <<EOF
3147 #!/bin/sh
3148 for f in \$@
3149 do
3150   case "\$f" in
3151   /*)
3152     $mkdir -p $targetdir/\`dirname \$f\`
3153     $cp \$f $targetdir/\$f || exit 1
3154     ;;
3155   *)
3156     $targetmkdir $targetdir/\`dirname \$f\`
3157     $cp \$f $targetdir/\$f || exit 1
3158     ;;
3159   esac
3160 done
3161 exit 0
3162 EOF
3163             ;;
3164         *)  echo "Unknown targetto '$targetto'" >&4
3165             exit 1
3166             ;;
3167         esac
3168         case "$targetfrom" in
3169         scp|rcp)
3170           cat >$from <<EOF
3171 #!/bin/sh
3172 for f in \$@
3173 do
3174   $rm -f \$f
3175   $targetfrom -P $targetport $q $targetuser@$targethost:$targetdir/\$f . || exit 1
3176 done
3177 exit 0
3178 EOF
3179             ;;
3180         cp) cat >$from <<EOF
3181 #!/bin/sh
3182 for f in \$@
3183 do
3184   $rm -f \$f
3185   cp $targetdir/\$f . || exit 1
3186 done
3187 exit 0
3188 EOF
3189             ;;
3190         *)  echo "Unknown targetfrom '$targetfrom'" >&4
3191             exit 1
3192             ;;
3193         esac
3194         if $test ! -f $run; then
3195             echo "Target 'run' script '$run' not found." >&4
3196         else
3197             $chmod a+rx $run
3198         fi
3199         if $test ! -f $to; then
3200             echo "Target 'to' script '$to' not found." >&4
3201         else
3202             $chmod a+rx $to
3203         fi
3204         if $test ! -f $from; then
3205             echo "Target 'from' script '$from' not found." >&4
3206         else
3207             $chmod a+rx $from
3208         fi
3209         if $test ! -f $run -o ! -f $to -o ! -f $from; then
3210             exit 1
3211         fi
3212         cat >&4 <<EOF
3213 Using '$run' for remote execution,
3214 and '$from' and '$to'
3215 for remote file transfer.
3216 EOF
3217         ;;
3218 *)      run=''
3219         to=:
3220         from=:
3221         usecrosscompile="$undef"
3222         targetarch=''
3223         ;;
3224 esac
3225
3226 : see whether [:lower:] and [:upper:] are supported character classes
3227 echo " "
3228 case "`echo AbyZ | $tr '[:lower:]' '[:upper:]' 2>/dev/null`"-"`echo AbyZ | $tr '[:upper:]' '[:lower:]' 2>/dev/null`" in
3229 ABYZ-abyz)
3230         echo "Good, your tr supports [:lower:] and [:upper:] to convert case." >&4
3231         up='[:upper:]'
3232         low='[:lower:]'
3233         ;;
3234 *)      # There is a discontinuity in EBCDIC between 'R' and 'S'
3235         # (0xd9 and 0xe2), therefore that is a nice testing point.
3236         if test "X$up" = X -o "X$low" = X; then
3237             case "`echo RS | $tr '[R-S]' '[r-s]' 2>/dev/null`" in
3238             rs) up='[A-Z]'
3239                 low='[a-z]'
3240                 ;;
3241             esac
3242         fi
3243         if test "X$up" = X -o "X$low" = X; then
3244             case "`echo RS | $tr R-S r-s 2>/dev/null`" in
3245             rs) up='A-Z'
3246                 low='a-z'
3247                 ;;
3248             esac
3249         fi
3250         if test "X$up" = X -o "X$low" = X; then
3251             case "`echo RS | od -x 2>/dev/null`" in
3252             *D9E2*|*d9e2*)
3253                 echo "Hey, this might be EBCDIC." >&4
3254                 if test "X$up" = X -o "X$low" = X; then
3255                     case "`echo RS | $tr '[A-IJ-RS-Z]' '[a-ij-rs-z]' 2>/dev/null`" in
3256                     rs) up='[A-IJ-RS-Z]'
3257                         low='[a-ij-rs-z]'
3258                         ;;
3259                     esac
3260                 fi
3261                 if test "X$up" = X -o "X$low" = X; then
3262                     case "`echo RS | $tr A-IJ-RS-Z a-ij-rs-z 2>/dev/null`" in
3263                     rs) up='A-IJ-RS-Z'
3264                         low='a-ij-rs-z'
3265                         ;;
3266                     esac
3267                 fi
3268                 ;;
3269             esac
3270         fi
3271 esac
3272 case "`echo RS | $tr \"$up\" \"$low\" 2>/dev/null`" in
3273 rs)
3274     echo "Using $up and $low to convert case." >&4
3275     ;;
3276 *)
3277     echo "I don't know how to translate letters from upper to lower case." >&4
3278     echo "Your tr is not acting any way I know of." >&4
3279     exit 1
3280     ;;
3281 esac
3282 : set up the translation script tr, must be called with ./tr of course
3283 cat >tr <<EOSC
3284 $startsh
3285 case "\$1\$2" in
3286 '[A-Z][a-z]') exec $tr '$up' '$low';;
3287 '[a-z][A-Z]') exec $tr '$low' '$up';;
3288 esac
3289 exec $tr "\$@"
3290 EOSC
3291 chmod +x tr
3292 $eunicefix tr
3293
3294 : Try to determine whether config.sh was made on this system
3295 case "$config_sh" in
3296 '')
3297 myuname=`$uname -a 2>/dev/null`
3298 $test -z "$myuname" && myuname=`hostname 2>/dev/null`
3299 # Downcase everything to avoid ambiguity.
3300 # Remove slashes and single quotes so we can use parts of this in
3301 # directory and file names.
3302 # Remove newlines so myuname is sane to use elsewhere.
3303 # tr '[A-Z]' '[a-z]' would not work in EBCDIC
3304 # because the A-Z/a-z are not consecutive.
3305 myuname=`echo $myuname | $sed -e "s,['/],,g" | \
3306         ./tr '[A-Z]' '[a-z]' | $tr $trnl ' '`
3307 newmyuname="$myuname"
3308 dflt=n
3309 case "$knowitall" in
3310 '')
3311         if test -f ../config.sh; then
3312                 if $contains myuname= ../config.sh >/dev/null 2>&1; then
3313                         eval "`grep myuname= ../config.sh`"
3314                 fi
3315                 if test "X$myuname" = "X$newmyuname"; then
3316                         dflt=y
3317                 fi
3318         fi
3319         ;;
3320 *) dflt=y;;
3321 esac
3322
3323 : Get old answers from old config file if Configure was run on the
3324 : same system, otherwise use the hints.
3325 hint=default
3326 cd ..
3327 if test -f config.sh; then
3328         echo " "
3329         rp="I see a config.sh file.  Shall I use it to set the defaults?"
3330         . UU/myread
3331         case "$ans" in
3332         n*|N*) echo "OK, I'll ignore it."
3333                 mv config.sh config.sh.old
3334                 myuname="$newmyuname"
3335                 ;;
3336         *)  echo "Fetching default answers from your old config.sh file..." >&4
3337                 tmp_n="$n"
3338                 tmp_c="$c"
3339                 tmp_sh="$sh"
3340                 . ./config.sh
3341                 cp config.sh UU
3342                 n="$tmp_n"
3343                 c="$tmp_c"
3344                 : Older versions did not always set $sh.  Catch re-use of such
3345                 : an old config.sh.
3346                 case "$sh" in
3347                 '') sh="$tmp_sh" ;;
3348                 esac
3349                 hint=previous
3350                 ;;
3351         esac
3352 fi
3353 . ./UU/checkcc
3354 if test ! -f config.sh; then
3355         $cat <<EOM
3356
3357 First time through, eh?  I have some defaults handy for some systems
3358 that need some extra help getting the Configure answers right:
3359
3360 EOM
3361         (cd $src/hints; ls -C *.sh) | $sed 's/\.sh/   /g' >&4
3362         dflt=''
3363         : Half the following guesses are probably wrong... If you have better
3364         : tests or hints, please send them to perlbug@perl.org
3365         : The metaconfig authors would also appreciate a copy...
3366         $test -f /irix && osname=irix
3367         $test -f /xenix && osname=sco_xenix
3368         $test -f /dynix && osname=dynix
3369         $test -f /dnix && osname=dnix
3370         $test -f /lynx.os && osname=lynxos
3371         $test -f /unicos && osname=unicos && osvers=`$uname -r`
3372         $test -f /unicosmk && osname=unicosmk && osvers=`$uname -r`
3373         $test -f /unicosmk.ar && osname=unicosmk && osvers=`$uname -r`
3374         $test -f /bin/mips && /bin/mips && osname=mips
3375         $test -d /usr/apollo/bin && osname=apollo
3376         $test -f /etc/saf/_sactab && osname=svr4
3377         $test -d /usr/include/minix && osname=minix && osvers=`$uname -r`
3378         $test -f /system/gnu_library/bin/ar.pm && osname=vos
3379         $test -f /sys/utilities/MultiView && osname=amigaos
3380         if $test -d /MachTen -o -d /MachTen_Folder; then
3381                 osname=machten
3382                 if $test -x /sbin/version; then
3383                         osvers=`/sbin/version | $awk '{print $2}' |
3384                         $sed -e 's/[A-Za-z]$//'`
3385                 elif $test -x /usr/etc/version; then
3386                         osvers=`/usr/etc/version | $awk '{print $2}' |
3387                         $sed -e 's/[A-Za-z]$//'`
3388                 else
3389                         osvers="$2.$3"
3390                 fi
3391         fi
3392
3393         $test -f /sys/posix.dll &&
3394                 $test -f /usr/bin/what &&
3395                 set X `/usr/bin/what /sys/posix.dll` &&
3396                 $test "$3" = UWIN &&
3397                 osname=uwin &&
3398                 osvers="$5"
3399
3400         if $test -f $uname; then
3401                 set X $myuname
3402                 shift
3403
3404                 case "$5" in
3405                 fps*) osname=fps ;;
3406                 mips*)
3407                         case "$4" in
3408                         umips) osname=umips ;;
3409                         *) osname=mips ;;
3410                         esac;;
3411                 [23]100) osname=mips ;;
3412                 i386*)
3413                         tmp=`/bin/uname -X 2>/dev/null|awk '/3\.2v[45]/{ print $(NF) }'`
3414                         if $test "$tmp" != "" -a "$3" = "3.2" -a -f '/etc/systemid'; then
3415                                 osname='sco'
3416                                 osvers=$tmp
3417                         elif $test -f /etc/kconfig; then
3418                                 osname=isc
3419                                 if test "$lns" = "$ln -s"; then
3420                                         osvers=4
3421                                 elif $contains _SYSV3 /usr/include/stdio.h > /dev/null 2>&1 ; then
3422                                         osvers=3
3423                                 elif $contains _POSIX_SOURCE /usr/include/stdio.h > /dev/null 2>&1 ; then
3424                                         osvers=2
3425                                 fi
3426                         fi
3427                         tmp=''
3428                         ;;
3429                 pc*)
3430                         if test -n "$DJGPP"; then
3431                                 osname=dos
3432                                 osvers=djgpp
3433                         fi
3434                         ;;
3435                 esac
3436
3437                 case "$1" in
3438                 aix) osname=aix
3439                         tmp=`( (oslevel) 2>/dev/null || echo "not found") 2>&1`
3440                         case "$tmp" in
3441                         # oslevel can fail with:
3442                         # oslevel: Unable to acquire lock.
3443                         *not\ found) osvers="$4"."$3" ;;
3444                         '<3240'|'<>3240') osvers=3.2.0 ;;
3445                         '=3240'|'>3240'|'<3250'|'<>3250') osvers=3.2.4 ;;
3446                         '=3250'|'>3250') osvers=3.2.5 ;;
3447                         *) osvers=$tmp;;
3448                         esac
3449                         ;;
3450                 bitrig) osname=bitrig
3451                         osvers="$3"
3452                         ;;
3453                 bsd386) osname=bsd386
3454                         osvers=`$uname -r`
3455                         ;;
3456                 cygwin*) osname=cygwin
3457                         osvers="$3"
3458                         ;;
3459                 *dc.osx) osname=dcosx
3460                         osvers="$3"
3461                         ;;
3462                 dnix) osname=dnix
3463                         osvers="$3"
3464                         ;;
3465                 domainos) osname=apollo
3466                         osvers="$3"
3467                         ;;
3468                 dgux)   osname=dgux
3469                         osvers="$3"
3470                         ;;
3471                 dragonfly) osname=dragonfly
3472                         osvers="$3"
3473                         ;;
3474                 dynixptx*) osname=dynixptx
3475                         osvers=`echo "$4"|sed 's/^v//'`
3476                         ;;
3477                 freebsd) osname=freebsd
3478                         osvers="$3" ;;
3479                 genix)  osname=genix ;;
3480                 gnu)    osname=gnu
3481                         osvers="$3" ;;
3482                 hp*)    osname=hpux
3483                         osvers=`echo "$3" | $sed 's,.*\.\([0-9]*\.[0-9]*\),\1,'`
3484                         ;;
3485                 irix*)  osname=irix
3486                         case "$3" in
3487                         4*) osvers=4 ;;
3488                         5*) osvers=5 ;;
3489                         *)      osvers="$3" ;;
3490                         esac
3491                         ;;
3492                 linux)  osname=linux
3493                         case "$3" in
3494                         *)      osvers="$3" ;;
3495                         esac
3496                         $test -f /system/lib/libandroid.so && osname=linux-android
3497                         ;;
3498                 MiNT)   osname=mint
3499                         ;;
3500                 netbsd*) osname=netbsd
3501                         osvers="$3"
3502                         ;;
3503                 news-os) osvers="$3"
3504                         case "$3" in
3505                         4*) osname=newsos4 ;;
3506                         *) osname=newsos ;;
3507                         esac
3508                         ;;
3509                 nonstop-ux) osname=nonstopux ;;
3510                 openbsd) osname=openbsd
3511                         osvers="$3"
3512                         ;;
3513                 os2)    osname=os2
3514                         osvers="$4"
3515                         ;;
3516                 POSIX-BC | posix-bc ) osname=posix-bc
3517                         osvers="$3"
3518                         ;;
3519                 powerux | power_ux | powermax_os | powermaxos | \
3520                 powerunix | power_unix) osname=powerux
3521                         osvers="$3"
3522                         ;;
3523                 qnx) osname=qnx
3524                         osvers="$4"
3525                         ;;
3526                 solaris) osname=solaris
3527                         case "$3" in
3528                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3529                         *)      osvers="$3" ;;
3530                         esac
3531                         ;;
3532                 sunos) osname=sunos
3533                         case "$3" in
3534                         5*) osname=solaris
3535                                 osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3536                         *)      osvers="$3" ;;
3537                         esac
3538                         ;;
3539                 titanos) osname=titanos
3540                         case "$3" in
3541                         1*) osvers=1 ;;
3542                         2*) osvers=2 ;;
3543                         3*) osvers=3 ;;
3544                         4*) osvers=4 ;;
3545                         *)      osvers="$3" ;;
3546                         esac
3547                         ;;
3548                 ultrix) osname=ultrix
3549                         osvers="$3"
3550                         ;;
3551                 osf1|mls+)      case "$5" in
3552                                 alpha)
3553                                         osname=dec_osf
3554                                         osvers=`sizer -v | awk -FUNIX '{print $2}' | awk '{print $1}' |  tr '[A-Z]' '[a-z]' | sed 's/^[xvt]//'`
3555                                         case "$osvers" in
3556                                         [1-9].[0-9]*) ;;
3557                                         *) osvers=`echo "$3" | sed 's/^[xvt]//'` ;;
3558                                         esac
3559                                         ;;
3560                         hp*)    osname=hp_osf1  ;;
3561                         mips)   osname=mips_osf1 ;;
3562                         esac
3563                         ;;
3564                 # UnixWare 7.1.2 is known as Open UNIX 8
3565                 openunix|unixware) osname=svr5
3566                         osvers="$4"
3567                         ;;
3568                 uts)    osname=uts
3569                         osvers="$3"
3570                         ;;
3571                 vos) osvers="$3"
3572                         ;;
3573                 $2) case "$osname" in
3574                         *isc*) ;;
3575                         *freebsd*) ;;
3576                         svr*)
3577                                 : svr4.x or possibly later
3578                                 case "svr$3" in
3579                                 ${osname}*)
3580                                         osname=svr$3
3581                                         osvers=$4
3582                                         ;;
3583                                 esac
3584                                 case "$osname" in
3585                                 svr4.0)
3586                                         : Check for ESIX
3587                                         if test -f /stand/boot ; then
3588                                                 eval `grep '^INITPROG=[a-z/0-9]*$' /stand/boot`
3589                                                 if test -n "$INITPROG" -a -f "$INITPROG"; then
3590                         isesix=`strings -a $INITPROG|grep 'ESIX SYSTEM V/386 Release 4.0'`
3591                                                         if test -n "$isesix"; then
3592                                                                 osname=esix4
3593                                                         fi
3594                                                 fi
3595                                         fi
3596                                         ;;
3597                                 esac
3598                                 ;;
3599                         *)      if test -f /etc/systemid; then
3600                                         osname=sco
3601                                         set `echo $3 | $sed 's/\./ /g'` $4
3602                                         if $test -f $src/hints/sco_$1_$2_$3.sh; then
3603                                                 osvers=$1.$2.$3
3604                                         elif $test -f $src/hints/sco_$1_$2.sh; then
3605                                                 osvers=$1.$2
3606                                         elif $test -f $src/hints/sco_$1.sh; then
3607                                                 osvers=$1
3608                                         fi
3609                                 else
3610                                         case "$osname" in
3611                                         '') : Still unknown.  Probably a generic Sys V.
3612                                                 osname="sysv"
3613                                                 osvers="$3"
3614                                                 ;;
3615                                         esac
3616                                 fi
3617                                 ;;
3618                         esac
3619                         ;;
3620                 *)      case "$osname" in
3621                         '') : Still unknown.  Probably a generic BSD.
3622                                 osname="$1"
3623                                 osvers="$3"
3624                                 ;;
3625                         esac
3626                         ;;
3627                 esac
3628         else
3629                 if test -f /vmunix -a -f $src/hints/news_os.sh; then
3630                         (what /vmunix | UU/tr '[A-Z]' '[a-z]') > UU/kernel.what 2>&1
3631                         if $contains news-os UU/kernel.what >/dev/null 2>&1; then
3632                                 osname=news_os
3633                         fi
3634                         $rm -f UU/kernel.what
3635                 elif test -d c:/. -o -n "$is_os2" ; then
3636                         set X $myuname
3637                         osname=os2
3638                         osvers="$5"
3639                 fi
3640         fi
3641
3642         case "$targetarch" in
3643         '') ;;
3644         *)  hostarch=$osname
3645             case "$targetarch" in
3646                 nto*|*-nto-*)
3647                     # Will load qnx.sh, which should change osname to nto
3648                     osname=qnx
3649                     osvers=''
3650                     ;;
3651                 *linux-android*)
3652                     # Catch arm-linux-androideabi, mipsel-linux-android,
3653                     # and i686-linux-android
3654                     osname=linux-android
3655                     osvers=''
3656                     ;;
3657                 *linux*)
3658                     # Something like arm-linux-gnueabihf is really just
3659                     # plain linux.
3660                     osname=linux
3661                     osvers=''
3662                     ;;
3663                 *solaris*|*sunos*)
3664                     osname=solaris
3665                     # XXX perhaps we should just assume
3666                     # osvers to be 2, or maybe take the value
3667                     # from targetarch. Using $run before the
3668                     # hints are run is somewhat icky.
3669                     set X `$run $uname -a 2>/dev/null`
3670                     shift
3671                     case "$3" in
3672                         5*) osvers=`echo $3 | $sed 's/^5/2/g'` ;;
3673                         *)  osvers="$3" ;;
3674                     esac
3675                     ;;
3676                 *)
3677                     osname=`echo $targetarch|sed 's,^[^-]*-,,'`
3678                     osvers=''
3679                 ;;
3680             esac
3681             ;;
3682         esac
3683
3684         : Now look for a hint file osname_osvers, unless one has been
3685         : specified already.
3686         case "$hintfile" in
3687         ''|' ')
3688                 file=`echo "${osname}_${osvers}" | $sed -e 's%\.%_%g' -e 's%_$%%'`
3689                 : Also try without trailing minor version numbers.
3690                 xfile=`echo $file | $sed -e 's%_[^_]*$%%'`
3691                 xxfile=`echo $xfile | $sed -e 's%_[^_]*$%%'`
3692                 xxxfile=`echo $xxfile | $sed -e 's%_[^_]*$%%'`
3693                 xxxxfile=`echo $xxxfile | $sed -e 's%_[^_]*$%%'`
3694                 case "$file" in
3695                 '') dflt=none ;;
3696                 *)  case "$osvers" in
3697                         '') dflt=$file
3698                                 ;;
3699                         *)  if $test -f $src/hints/$file.sh ; then
3700                                         dflt=$file
3701                                 elif $test -f $src/hints/$xfile.sh ; then
3702                                         dflt=$xfile
3703                                 elif $test -f $src/hints/$xxfile.sh ; then
3704                                         dflt=$xxfile
3705                                 elif $test -f $src/hints/$xxxfile.sh ; then
3706                                         dflt=$xxxfile
3707                                 elif $test -f $src/hints/$xxxxfile.sh ; then
3708                                         dflt=$xxxxfile
3709                                 elif $test -f "$src/hints/${osname}.sh" ; then
3710                                         dflt="${osname}"
3711                                 else
3712                                         dflt=none
3713                                 fi
3714                                 ;;
3715                         esac
3716                         ;;
3717                 esac
3718                 if $test -f Policy.sh ; then
3719                         case "$dflt" in
3720                         *Policy*) ;;
3721                         none) dflt="Policy" ;;
3722                         *) dflt="Policy $dflt" ;;
3723                         esac
3724                 fi
3725                 ;;
3726         *)
3727                 dflt=`echo $hintfile | $sed 's/\.sh$//'`
3728                 ;;
3729         esac
3730
3731         if $test -f Policy.sh ; then
3732                 $cat <<EOM
3733
3734 There's also a Policy hint file available, which should make the
3735 site-specific (policy) questions easier to answer.
3736 EOM
3737
3738         fi
3739
3740         $cat <<EOM
3741
3742 You may give one or more space-separated answers, or "none" if appropriate.
3743 If you have a handcrafted Policy.sh file or a Policy.sh file generated by a
3744 previous run of Configure, you may specify it as well as or instead of
3745 OS-specific hints.  If hints are provided for your OS, you should use them:
3746 although Perl can probably be built without hints on many platforms, using
3747 hints often improve performance and may enable features that Configure can't
3748 set up on its own. If there are no hints that match your OS, specify "none";
3749 DO NOT give a wrong version or a wrong OS.
3750
3751 EOM
3752
3753         rp="Which of these apply, if any?"
3754         . UU/myread
3755         tans=$ans
3756         for file in $tans; do
3757                 if $test X$file = XPolicy -a -f Policy.sh; then
3758                         . Policy.sh
3759                         $cat Policy.sh >> UU/config.sh
3760                 elif $test -f $src/hints/$file.sh; then
3761                         . $src/hints/$file.sh
3762                         $cat $src/hints/$file.sh >> UU/config.sh
3763                 elif $test X"$tans" = X -o X"$tans" = Xnone ; then
3764                         : nothing
3765                 else
3766                         : Give one chance to correct a possible typo.
3767                         echo "$file.sh does not exist"
3768                         dflt=$file
3769                         rp="hint to use instead?"
3770                         . UU/myread
3771                         for file in $ans; do
3772                                 if $test -f "$src/hints/$file.sh"; then
3773                                         . $src/hints/$file.sh
3774                                         $cat $src/hints/$file.sh >> UU/config.sh
3775                                 elif $test X$ans = X -o X$ans = Xnone ; then
3776                                         : nothing
3777                                 else
3778                                         echo "$file.sh does not exist -- ignored."
3779                                 fi
3780                         done
3781                 fi
3782         done
3783
3784         hint=recommended
3785         : Remember our hint file for later.
3786         if $test -f "$src/hints/$file.sh" ; then
3787                 hintfile="$file"
3788         else
3789                 hintfile=''
3790         fi
3791 fi
3792 cd UU
3793 ;;
3794 *)
3795         echo " "
3796         echo "Fetching default answers from $config_sh..." >&4
3797         tmp_n="$n"
3798         tmp_c="$c"
3799         cd ..
3800         cp $config_sh config.sh 2>/dev/null
3801         chmod +w config.sh
3802         . ./config.sh
3803         cd UU
3804         cp ../config.sh .
3805         n="$tmp_n"
3806         c="$tmp_c"
3807         hint=previous
3808         ;;
3809 esac
3810 . ./optdef.sh
3811
3812 : Restore computed paths
3813 for file in $loclist $trylist; do
3814         eval $file="\$_$file"
3815 done
3816
3817 cat << EOM
3818
3819 Configure uses the operating system name and version to set some defaults.
3820 The default value is probably right if the name rings a bell. Otherwise,
3821 since spelling matters for me, either accept the default or answer "none"
3822 to leave it blank.
3823
3824 EOM
3825 case "$osname" in
3826         ''|' ')
3827                 case "$hintfile" in
3828                 ''|' '|none) dflt=none ;;
3829                 *)  dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/_.*$//'` ;;
3830                 esac
3831                 ;;
3832         *) dflt="$osname" ;;
3833 esac
3834 rp="Operating system name?"
3835 . ./myread
3836 case "$ans" in
3837 none)  osname='' ;;
3838 *) osname=`echo "$ans" | $sed -e 's/[   ][      ]*/_/g' | ./tr '[A-Z]' '[a-z]'`;;
3839 esac
3840 echo " "
3841 case "$osvers" in
3842         ''|' ')
3843                 case "$hintfile" in
3844                 ''|' '|none) dflt=none ;;
3845                 *)      dflt=`echo $hintfile | $sed -e 's/\.sh$//' -e 's/^[^_]*//'`
3846                         dflt=`echo $dflt | $sed -e 's/^_//' -e 's/_/./g'`
3847                         case "$dflt" in
3848                         ''|' ') dflt=none ;;
3849                         esac
3850                         ;;
3851                 esac
3852                 ;;
3853         *) dflt="$osvers" ;;
3854 esac
3855 rp="Operating system version?"
3856 . ./myread
3857 case "$ans" in
3858 none)  osvers='' ;;
3859 *) osvers="$ans" ;;
3860 esac
3861
3862
3863 . ./posthint.sh
3864
3865 : who configured the system
3866 cf_time=`LC_ALL=C; LANGUAGE=C; export LC_ALL; export LANGUAGE; $date 2>&1`
3867 case "$cf_by" in
3868 "")
3869         cf_by=`(logname) 2>/dev/null`
3870         case "$cf_by" in
3871         "")
3872                 cf_by=`(whoami) 2>/dev/null`
3873                 case "$cf_by" in
3874                 "") cf_by=unknown ;;
3875                 esac ;;
3876         esac ;;
3877 esac
3878
3879 : decide how portable to be.  Allow command line overrides.
3880 case "$d_portable" in
3881 "$undef") ;;
3882 *)      d_portable="$define" ;;
3883 esac
3884
3885 : set up shell script to do ~ expansion
3886 cat >filexp <<EOSS
3887 $startsh
3888 : expand filename
3889 case "\$1" in
3890  \~/*|\~)
3891         echo \$1 | $sed "s|~|\${HOME-\$LOGDIR}|"
3892         ;;
3893  \~*)
3894         if $test -f /bin/csh; then
3895                 /bin/csh -f -c "glob \$1"
3896                 failed=\$?
3897                 echo ""
3898                 exit \$failed
3899         else
3900                 name=\`$expr x\$1 : '..\([^/]*\)'\`
3901                 dir=\`$sed -n -e "/^\${name}:/{s/^[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:]*\).*"'\$'"/\1/" -e p -e q -e '}' </etc/passwd\`
3902                 if $test ! -d "\$dir"; then
3903                         me=\`basename \$0\`
3904                         echo "\$me: can't locate home directory for: \$name" >&2
3905                         exit 1
3906                 fi
3907                 case "\$1" in
3908                 */*)
3909                         echo \$dir/\`$expr x\$1 : '..[^/]*/\(.*\)'\`
3910                         ;;
3911                 *)
3912                         echo \$dir
3913                         ;;
3914                 esac
3915         fi
3916         ;;
3917 *)
3918         echo \$1
3919         ;;
3920 esac
3921 EOSS
3922 chmod +x filexp
3923 $eunicefix filexp
3924
3925 : now set up to get a file name
3926 cat <<EOS >getfile
3927 $startsh
3928 EOS
3929 cat <<'EOSC' >>getfile
3930 tilde=''
3931 fullpath=''
3932 already=''
3933 skip=''
3934 none_ok=''
3935 exp_file=''
3936 nopath_ok=''
3937 orig_rp="$rp"
3938 orig_dflt="$dflt"
3939 case "$gfpth" in
3940 '') gfpth='.' ;;
3941 esac
3942
3943 case "$fn" in
3944 *\(*)
3945         : getfile will accept an answer from the comma-separated list
3946         : enclosed in parentheses even if it does not meet other criteria.
3947         expr "$fn" : '.*(\(.*\)).*' | $tr ',' $trnl >getfile.ok
3948         fn=`echo $fn | sed 's/(.*)//'`
3949         ;;
3950 esac
3951
3952 case "$fn" in
3953 *:*)
3954         loc_file=`expr $fn : '.*:\(.*\)'`
3955         fn=`expr $fn : '\(.*\):.*'`
3956         ;;
3957 esac
3958
3959 case "$fn" in
3960 *~*) tilde=true;;
3961 esac
3962 case "$fn" in
3963 */*) fullpath=true;;
3964 esac
3965 case "$fn" in
3966 *+*) skip=true;;
3967 esac
3968 case "$fn" in
3969 *n*) none_ok=true;;
3970 esac
3971 case "$fn" in
3972 *e*) exp_file=true;;
3973 esac
3974 case "$fn" in
3975 *p*) nopath_ok=true;;
3976 esac
3977
3978 case "$fn" in
3979 *f*) type='File';;
3980 *d*) type='Directory';;
3981 *l*) type='Locate';;
3982 esac
3983
3984 what="$type"
3985 case "$what" in
3986 Locate) what='File';;
3987 esac
3988
3989 case "$exp_file" in
3990 '')
3991         case "$d_portable" in
3992         "$define") ;;
3993         *) exp_file=true;;
3994         esac
3995         ;;
3996 esac
3997
3998 cd ..
3999 while test "$type"; do
4000         redo=''
4001         rp="$orig_rp"
4002         dflt="$orig_dflt"
4003         case "$tilde" in
4004         true) rp="$rp (~name ok)";;
4005         esac
4006         . UU/myread
4007         if test -f UU/getfile.ok && \
4008                 $contains "^$ans\$" UU/getfile.ok >/dev/null 2>&1
4009         then
4010                 value="$ans"
4011                 ansexp="$ans"
4012                 break
4013         fi
4014         case "$ans" in
4015         none)
4016                 value=''
4017                 ansexp=''
4018                 case "$none_ok" in
4019                 true) type='';;
4020                 esac
4021                 ;;
4022         *)
4023                 case "$tilde" in
4024                 '') value="$ans"
4025                         ansexp="$ans";;
4026                 *)
4027                         value=`UU/filexp $ans`
4028                         case $? in
4029                         0)
4030                                 if test "$ans" != "$value"; then
4031                                         echo "(That expands to $value on this system.)"
4032                                 fi
4033                                 ;;
4034                         *) value="$ans";;
4035                         esac
4036                         ansexp="$value"
4037                         case "$exp_file" in
4038                         '') value="$ans";;
4039                         esac
4040                         ;;
4041                 esac
4042                 case "$fullpath" in
4043                 true)
4044                         case "$ansexp" in
4045                         /*) value="$ansexp" ;;
4046                         [a-zA-Z]:/*) value="$ansexp" ;;
4047                         *)
4048                                 redo=true
4049                                 case "$already" in
4050                                 true)
4051                                 echo "I shall only accept a full path name, as in /bin/ls." >&4
4052                                 echo "Use a ! shell escape if you wish to check pathnames." >&4
4053                                         ;;
4054                                 *)
4055                                 echo "Please give a full path name, starting with slash." >&4
4056                                         case "$tilde" in
4057                                         true)
4058                                 echo "Note that using ~name is ok provided it expands well." >&4
4059                                                 already=true
4060                                                 ;;
4061                                         esac
4062                                 esac
4063                                 ;;
4064                         esac
4065                         ;;
4066                 esac
4067                 case "$redo" in
4068                 '')
4069                         case "$type" in
4070                         File)
4071                                 for fp in $gfpth; do
4072                                         if test "X$fp" = X.; then
4073                                             pf="$ansexp"
4074                                         else    
4075                                             pf="$fp/$ansexp"
4076                                         fi
4077                                         if test -f "$pf"; then
4078                                                 type=''
4079                                         elif test -r "$pf" || (test -h "$pf") >/dev/null 2>&1
4080                                         then
4081                                                 echo "($value is not a plain file, but that's ok.)"
4082                                                 type=''
4083                                         fi
4084                                         if test X"$type" = X; then
4085                                             value="$pf"
4086                                             break
4087                                         fi
4088                                 done
4089                                 ;;
4090                         Directory)
4091                                 for fp in $gfpth; do
4092                                         if test "X$fp" = X.; then
4093                                             dir="$ans"
4094                                             direxp="$ansexp"
4095                                         else    
4096                                             dir="$fp/$ansexp"
4097                                             direxp="$fp/$ansexp"
4098                                         fi
4099                                         if test -d "$direxp"; then
4100                                                 type=''
4101                                                 value="$dir"
4102                                                 break
4103                                         fi
4104                                 done
4105                                 ;;
4106                         Locate)
4107                                 if test -d "$ansexp"; then
4108                                         echo "(Looking for $loc_file in directory $value.)"
4109                                         value="$value/$loc_file"
4110                                         ansexp="$ansexp/$loc_file"
4111                                 fi
4112                                 if test -f "$ansexp"; then
4113                                         type=''
4114                                 fi
4115                                 case "$nopath_ok" in
4116                                 true)   case "$value" in
4117                                         */*) ;;
4118                                         *)      echo "Assuming $value will be in people's path."
4119                                                 type=''
4120                                                 ;;
4121                                         esac
4122                                         ;;
4123                                 esac
4124                                 ;;
4125                         esac
4126
4127                         case "$skip" in
4128                         true) type='';
4129                         esac
4130
4131                         case "$type" in
4132                         '') ;;
4133                         *)
4134                                 if test "$fastread" = yes; then
4135                                         dflt=y
4136                                 else
4137                                         dflt=n
4138                                 fi
4139                                 rp="$what $value doesn't exist.  Use that name anyway?"
4140                                 . UU/myread
4141                                 dflt=''
4142                                 case "$ans" in
4143                                 y*) type='';;
4144                                 *) echo " ";;
4145                                 esac
4146                                 ;;
4147                         esac
4148                         ;;
4149                 esac
4150                 ;;
4151         esac
4152 done
4153 cd UU
4154 ans="$value"
4155 rp="$orig_rp"
4156 dflt="$orig_dflt"
4157 rm -f getfile.ok
4158 test "X$gfpthkeep" != Xy && gfpth=""
4159 EOSC
4160
4161 : determine root of directory hierarchy where package will be installed.
4162 case "$prefix" in
4163 '')
4164         dflt=`./loc . /usr/local /usr/local /local /opt /usr`
4165         ;;
4166 *?/)
4167         dflt=`echo "$prefix" | sed 's/.$//'`
4168         ;;
4169 *)
4170         dflt="$prefix"
4171         ;;
4172 esac
4173 $cat <<EOM
4174
4175 By default, $package will be installed in $dflt/bin, manual pages
4176 under $dflt/man, etc..., i.e. with $dflt as prefix for all
4177 installation directories. Typically this is something like /usr/local.
4178 If you wish to have binaries under /usr/bin but other parts of the
4179 installation under /usr/local, that's ok: you will be prompted
4180 separately for each of the installation directories, the prefix being
4181 only used to set the defaults.
4182
4183 EOM
4184 fn=d~
4185 rp='Installation prefix to use?'
4186 . ./getfile
4187 oldprefix=''
4188 case "$prefix" in
4189 '') ;;
4190 *)
4191         case "$ans" in
4192         "$prefix") ;;
4193         *) oldprefix="$prefix";;
4194         esac
4195         ;;
4196 esac
4197 prefix="$ans"
4198 prefixexp="$ansexp"
4199
4200 : allow them to override the AFS root
4201 case "$afsroot" in
4202 '')     afsroot=/afs ;;
4203 *)      afsroot=$afsroot ;;
4204 esac
4205
4206 : is AFS running?
4207 echo " "
4208 case "$afs" in
4209 $define|true)   afs=true ;;
4210 $undef|false)   afs=false ;;
4211 *)      if $test -d $afsroot; then
4212                 afs=true
4213         else
4214                 afs=false
4215         fi
4216         ;;
4217 esac
4218 if $afs; then
4219         echo "AFS may be running... I'll be extra cautious then..." >&4
4220 else
4221         echo "AFS does not seem to be running..." >&4
4222 fi
4223
4224 : determine installation prefix for where package is to be installed.
4225 if $afs; then
4226 $cat <<EOM
4227
4228 Since you are running AFS, I need to distinguish the directory in which
4229 files will reside from the directory in which they are installed (and from
4230 which they are presumably copied to the former directory by occult means).
4231
4232 EOM
4233         case "$installprefix" in
4234         '') dflt=`echo $prefix | sed 's#^/afs/#/afs/.#'`;;
4235         *) dflt="$installprefix";;
4236         esac
4237 else
4238 $cat <<EOM
4239
4240 In some special cases, particularly when building $package for distribution,
4241 it is convenient to distinguish the directory in which files should be
4242 installed from the directory ($prefix) in which they will
4243 eventually reside.  For most users, these two directories are the same.
4244
4245 EOM
4246         case "$installprefix" in
4247         '') dflt=$prefix ;;
4248         *) dflt=$installprefix;;
4249         esac
4250 fi
4251 fn=d~
4252 rp='What installation prefix should I use for installing files?'
4253 . ./getfile
4254 installprefix="$ans"
4255 installprefixexp="$ansexp"
4256
4257 : Perform the prefixexp/installprefixexp correction if necessary
4258 cat <<EOS >installprefix
4259 $startsh
4260 EOS
4261 cat <<'EOSC' >>installprefix
4262 : Change installation prefix, if necessary.
4263 if $test X"$prefix" != X"$installprefix"; then
4264     eval "install${prefixvar}=\`echo \$${prefixvar}exp | sed \"s#^\$prefixexp#\$installprefixexp#\"\`"
4265 else
4266     eval "install${prefixvar}=\"\$${prefixvar}exp\""
4267 fi
4268 EOSC
4269 chmod +x installprefix
4270 $eunicefix installprefix
4271
4272 : Set variables such as privlib and privlibexp from the output of ./getfile
4273 : performing the prefixexp/installprefixexp correction if necessary.
4274 cat <<EOS >setprefixvar
4275 $startsh
4276 EOS
4277 cat <<'EOSC' >>setprefixvar
4278 eval "${prefixvar}=\"\$ans\""
4279 eval "${prefixvar}exp=\"\$ansexp\""
4280 . ./installprefix
4281 EOSC
4282 chmod +x setprefixvar
4283 $eunicefix setprefixvar
4284
4285 : set up the script used to warn in case of inconsistency
4286 cat <<EOS >whoa
4287 $startsh
4288 EOS
4289 cat <<'EOSC' >>whoa
4290 dflt=y
4291 case "$hint" in
4292     recommended)
4293         case "$hintfile" in
4294         '')     echo "The $hint value for \$$var on this machine was \"$was\"!" >&4
4295                 ;;
4296         *)      echo "Hmm.  Based on the hints in hints/$hintfile.sh, " >&4
4297                 echo "the $hint value for \$$var on this machine was \"$was\"!" >&4
4298                 ;;
4299         esac
4300         ;;
4301     *)  echo " "
4302         echo "*** WHOA THERE!!! ***" >&4
4303         echo "    The $hint value for \$$var on this machine was \"$was\"!" >&4
4304         ;;
4305 esac
4306 rp="    Keep the $hint value?"
4307 . ./myread
4308 case "$ans" in
4309 y) td=$was; tu=$was;;
4310 esac
4311 EOSC
4312
4313 : function used to set '$1' to '$val'
4314 setvar='var=$1; eval "was=\$$1"; td=$define; tu=$undef;
4315 case "$val$was" in
4316 $define$undef) . ./whoa; eval "$var=\$td";;
4317 $undef$define) . ./whoa; eval "$var=\$tu";;
4318 *) eval "$var=$val";;
4319 esac'
4320
4321 : get the patchlevel
4322 echo " "
4323 echo "Getting the current patchlevel..." >&4
4324 if $test -r $rsrc/patchlevel.h;then
4325         revision=`awk '/define[         ]+PERL_REVISION/ {print $3}' $rsrc/patchlevel.h`
4326         patchlevel=`awk '/define[       ]+PERL_VERSION/ {print $3}' $rsrc/patchlevel.h`
4327         subversion=`awk '/define[       ]+PERL_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
4328         api_revision=`awk '/define[     ]+PERL_API_REVISION/ {print $3}' $rsrc/patchlevel.h`
4329         api_version=`awk '/define[      ]+PERL_API_VERSION/ {print $3}' $rsrc/patchlevel.h`
4330         api_subversion=`awk '/define[   ]+PERL_API_SUBVERSION/ {print $3}' $rsrc/patchlevel.h`
4331         perl_patchlevel=`egrep ',"(MAINT|SMOKE)[0-9][0-9]*"' $rsrc/patchlevel.h|tail -1|sed 's/[^0-9]//g'`
4332 else
4333         revision=0
4334         patchlevel=0
4335         subversion=0
4336         api_revision=0
4337         api_version=0
4338         api_subversion=0
4339         perl_patchlevel=0
4340         $echo "(You do not have patchlevel.h.  Eek.)"
4341 fi
4342 : Define a handy string here to avoid duplication in myconfig.SH and configpm.
4343 version_patchlevel_string="version $patchlevel subversion $subversion"
4344 case "$perl_patchlevel" in
4345 0|'') ;;
4346 *)  perl_patchlevel=`echo $perl_patchlevel | sed 's/.* //'`
4347     version_patchlevel_string="$version_patchlevel_string patch $perl_patchlevel"
4348     ;;
4349 esac
4350
4351 $echo "(You have $package $version_patchlevel_string.)"
4352
4353 case "$osname" in
4354 dos|vms)
4355         : XXX Should be a Configure test for double-dots in filenames.
4356         version=`echo $revision $patchlevel $subversion | \
4357                  $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
4358         api_versionstring=`echo $api_revision $api_version $api_subversion | \
4359                  $awk '{ printf "%d_%d_%d", $1, $2, $3 }'`
4360         ;;
4361 *)
4362         version=`echo $revision $patchlevel $subversion | \
4363                  $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
4364         api_versionstring=`echo $api_revision $api_version $api_subversion | \
4365                  $awk '{ printf "%d.%d.%d", $1, $2, $3 }'`
4366         ;;
4367 esac
4368 : Special case the 5.005_xx maintenance series, which used 5.005
4369 : without any subversion label as a subdirectory in $sitelib
4370 if test "${api_revision}${api_version}${api_subversion}" = "550"; then
4371         api_versionstring='5.005'
4372 fi
4373
4374 : Do we want threads support and if so, what type
4375 case "$usethreads" in
4376 $define|true|[yY]*)     dflt='y';;
4377 *)     # Catch case where user specified ithreads or 5005threads but
4378        # forgot -Dusethreads (A.D. 4/2002)
4379        case "$useithreads$use5005threads" in
4380        *$define*)       dflt='y';;
4381        *)               dflt='n';;
4382        esac
4383        ;;
4384 esac
4385 cat <<EOM
4386
4387 Perl can be built to offer a form of threading support on some systems
4388 To do so, Configure can be run with -Dusethreads.
4389
4390 Note that Perl built with threading support runs slightly slower
4391 and uses slightly more memory than plain Perl.
4392
4393 If this doesn't make any sense to you, just accept the default '$dflt'.
4394 EOM
4395 rp='Build a threading Perl?'
4396 . ./myread
4397 case "$ans" in
4398 y|Y)    val="$define" ;;
4399 *)      val="$undef" ;;
4400 esac
4401 set usethreads
4402 eval $setvar
4403
4404 if $test $patchlevel -lt 9; then
4405     case "$usethreads" in
4406     $define)
4407         : Default to ithreads unless overridden on command line or with
4408         : old config.sh
4409         dflt='y'
4410         case "$use5005threads" in
4411                 $define|true|[yY]*)
4412                         echo "5.005 threads are no longer supported"
4413                         exit 1
4414                 ;;
4415         esac
4416         case "$useithreads" in
4417                 $undef|false|[nN]*) dflt='n';;
4418         esac
4419         rp='Use the newer interpreter-based ithreads?'
4420         . ./myread
4421         case "$ans" in
4422         y|Y)    val="$define" ;;
4423         *)      val="$undef" ;;
4424         esac
4425         set useithreads
4426         eval $setvar
4427         : Now set use5005threads to the opposite value.
4428         case "$useithreads" in
4429         $define) val="$undef" ;;
4430         *) val="$define" ;;
4431         esac
4432         set use5005threads
4433         eval $setvar
4434         ;;
4435     *)
4436         useithreads="$undef"
4437         use5005threads="$undef"
4438         ;;
4439     esac
4440
4441     case "$useithreads$use5005threads" in
4442     "$define$define")
4443         $cat >&4 <<EOM
4444
4445 You cannot have both the ithreads and the 5.005 threads enabled
4446 at the same time.  Disabling the 5.005 threads since they are
4447 much less stable than the ithreads.
4448
4449 EOM
4450         use5005threads="$undef"
4451         ;;
4452     esac
4453
4454 else
4455 : perl-5.9.x and later
4456
4457     if test X"$usethreads" = "X$define"; then
4458         case "$use5005threads" in
4459             $define|true|[yY]*)
4460                 $cat >&4 <<EOM
4461
4462 5.005 threads has been removed for 5.10.  Perl will be built using ithreads.
4463
4464 EOM
4465             ;;
4466         esac
4467     fi
4468
4469     use5005threads="$undef"
4470     useithreads="$usethreads"
4471 fi
4472
4473 case "$d_oldpthreads" in
4474 '')     : Configure tests would be welcome here.  For now, assume undef.
4475         val="$undef" ;;
4476 *)      val="$d_oldpthreads" ;;
4477 esac
4478 set d_oldpthreads
4479 eval $setvar
4480
4481
4482 : Look for a hint-file generated 'call-back-unit'.  If the
4483 : user has specified that a threading perl is to be built,
4484 : we may need to set or change some other defaults.
4485 if $test -f usethreads.cbu; then
4486     echo "Your platform has some specific hints regarding threaded builds, using them..."
4487     . ./usethreads.cbu
4488 else
4489     case "$usethreads" in
4490         "$define"|true|[yY]*)
4491                 $cat <<EOM
4492 (Your platform does not have any specific hints for threaded builds.
4493  Assuming POSIX threads, then.)
4494 EOM
4495         ;;
4496     esac
4497 fi
4498
4499 : Check if multiplicity is required
4500 cat <<EOM
4501
4502 Perl can be built so that multiple Perl interpreters can coexist
4503 within the same Perl executable.
4504 EOM
4505
4506 case "$useithreads" in
4507 $define)
4508         cat <<EOM
4509 This multiple interpreter support is required for interpreter-based threads.
4510 EOM
4511         val="$define"
4512         ;;
4513 *)      case "$usemultiplicity" in
4514         $define|true|[yY]*)     dflt='y';;
4515         *) dflt='n';;
4516         esac
4517         echo " "
4518         echo "If this doesn't make any sense to you, just accept the default '$dflt'."
4519         rp='Build Perl for multiplicity?'
4520         . ./myread
4521         case "$ans" in
4522         y|Y)    val="$define" ;;
4523         *)      val="$undef" ;;
4524         esac
4525         ;;
4526 esac
4527 set usemultiplicity
4528 eval $setvar
4529
4530 : Check if morebits is requested
4531 case "$usemorebits" in
4532 "$define"|true|[yY]*)
4533         use64bitint="$define"
4534         uselongdouble="$define"
4535         usemorebits="$define"
4536         ;;
4537 *)      usemorebits="$undef"
4538         ;;
4539 esac
4540
4541 : Determine the C compiler to be used
4542 echo " "
4543 case "$cc" in
4544 '') dflt=cc;;
4545 *) dflt="$cc";;
4546 esac
4547 rp="Use which C compiler?"
4548 . ./myread
4549 cc="$ans"
4550
4551 : See whether they have no cc but they do have gcc
4552 . ./trygcc
4553 if $test -f cc.cbu; then
4554     . ./cc.cbu
4555 fi
4556 . ./checkcc
4557
4558 : make some quick guesses about what we are up against
4559 echo " "
4560 $echo $n "Hmm...  $c"
4561 echo exit 1 >bsd
4562 echo exit 1 >usg
4563 echo exit 1 >v7
4564 echo exit 1 >osf1
4565 echo exit 1 >eunice
4566 echo exit 1 >xenix
4567 echo exit 1 >venix
4568 echo exit 1 >os2
4569 d_bsd="$undef"
4570 $cat $sysroot/usr/include/signal.h $sysroot/usr/include/sys/signal.h >foo 2>/dev/null
4571 if test -f /osf_boot || $contains 'OSF/1' $sysroot/usr/include/ctype.h >/dev/null 2>&1
4572 then
4573         echo "Looks kind of like an OSF/1 system, but we'll see..."
4574         echo exit 0 >osf1
4575 elif test `echo abc | $tr a-z A-Z` = Abc ; then
4576         xxx=`./loc addbib blurfl $pth`
4577         if $test -f $xxx; then
4578         echo "Looks kind of like a USG system with BSD features, but we'll see..."
4579                 echo exit 0 >bsd
4580                 echo exit 0 >usg
4581         else
4582                 if $contains SIGTSTP foo >/dev/null 2>&1 ; then
4583                         echo "Looks kind of like an extended USG system, but we'll see..."
4584                 else
4585                         echo "Looks kind of like a USG system, but we'll see..."
4586                 fi
4587                 echo exit 0 >usg
4588         fi
4589 elif $contains SIGTSTP foo >/dev/null 2>&1 ; then
4590         echo "Looks kind of like a BSD system, but we'll see..."
4591         d_bsd="$define"
4592         echo exit 0 >bsd
4593 else
4594         echo "Looks kind of like a Version 7 system, but we'll see..."
4595         echo exit 0 >v7
4596 fi
4597 case "$eunicefix" in
4598 *unixtovms*)
4599         $cat <<'EOI'
4600 There is, however, a strange, musty smell in the air that reminds me of
4601 something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
4602 EOI
4603         echo exit 0 >eunice
4604         d_eunice="$define"
4605 : it so happens the Eunice I know will not run shell scripts in Unix format
4606         ;;
4607 *)
4608         echo " "
4609         echo "Congratulations.  You aren't running Eunice."
4610         d_eunice="$undef"
4611         ;;
4612 esac
4613 : Detect OS2.  The p_ variable is set above in the Head.U unit.
4614 : Note that this also -- wrongly -- detects e.g. dos-djgpp, which also uses
4615 : semicolon as a patch separator
4616 case "$p_" in
4617 :) ;;
4618 *)
4619         $cat <<'EOI'
4620 I have the feeling something is not exactly right, however...don't tell me...
4621 lemme think...does HAL ring a bell?...no, of course, you're only running OS/2!
4622 (Or you may be running DOS with DJGPP.)
4623 EOI
4624         echo exit 0 >os2
4625         ;;
4626 esac
4627 if test -f /xenix; then
4628         echo "Actually, this looks more like a XENIX system..."
4629         echo exit 0 >xenix
4630         d_xenix="$define"
4631 else
4632         echo " "
4633         echo "It's not Xenix..."
4634         d_xenix="$undef"
4635 fi
4636 chmod +x xenix
4637 $eunicefix xenix
4638 if test -f /venix; then
4639         echo "Actually, this looks more like a VENIX system..."
4640         echo exit 0 >venix
4641 else
4642         echo " "
4643         if ./xenix; then
4644                 : null
4645         else
4646                 echo "Nor is it Venix..."
4647         fi
4648 fi
4649 chmod +x bsd usg v7 osf1 eunice xenix venix os2
4650 $eunicefix bsd usg v7 osf1 eunice xenix venix os2
4651 $rm -f foo
4652
4653 : Check if we are using GNU gcc and what its version is
4654 echo " "
4655 echo "Checking for GNU cc in disguise and/or its version number..." >&4
4656 $cat >try.c <<EOM
4657 #include <stdio.h>
4658 int main() {
4659 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
4660 #ifdef __VERSION__
4661         printf("%s\n", __VERSION__);
4662 #else
4663         printf("%s\n", "1");
4664 #endif
4665 #endif
4666         return(0);
4667 }
4668 EOM
4669 if $cc -o try $ccflags $ldflags try.c; then
4670         gccversion=`$run ./try`
4671         case "$gccversion" in
4672         '') echo "You are not using GNU cc." ;;
4673         *)  echo "You are using GNU cc $gccversion."
4674             ccname=gcc
4675             ;;
4676         esac
4677 else
4678         echo " "
4679         echo "*** WHOA THERE!!! ***" >&4
4680         echo "    Your C compiler \"$cc\" doesn't seem to be working!" >&4
4681         case "$knowitall" in
4682         '')
4683         echo "    You'd better start hunting for one and let me know about it." >&4
4684                 exit 1
4685                 ;;
4686         esac
4687 fi
4688 $rm -f try try.*
4689 case "$gccversion" in
4690 1*) cpp=`./loc gcc-cpp $cpp $pth` ;;
4691 esac
4692 case "$gccversion" in
4693 '') gccosandvers='' ;;
4694 *) gccshortvers=`echo "$gccversion"|sed 's/ .*//'`
4695    gccosandvers=`$cc -v 2>&1|grep '/specs$'|sed "s!.*/[^-/]*-[^-/]*-\([^-/]*\)/$gccshortvers/specs!\1!"`
4696    gccshortvers=''
4697    case "$gccosandvers" in
4698    $osname) gccosandvers='' ;; # linux gccs seem to have no linux osvers, grr
4699    $osname$osvers) ;; # looking good
4700    $osname*) cat <<EOM >&4
4701
4702 *** WHOA THERE!!! ***
4703
4704     Your gcc has not been compiled for the exact release of
4705     your operating system ($gccosandvers versus $osname$osvers).
4706
4707     In general it is a good idea to keep gcc synchronized with
4708     the operating system because otherwise serious problems
4709     may ensue when trying to compile software, like Perl.
4710
4711     I'm trying to be optimistic here, though, and will continue.
4712     If later during the configuration and build icky compilation
4713     problems appear (headerfile conflicts being the most common
4714     manifestation), I suggest reinstalling the gcc to match
4715     your operating system release.
4716
4717 EOM
4718       ;;
4719    *) gccosandvers='' ;; # failed to parse, better be silent
4720    esac
4721    ;;
4722 esac
4723 case "$ccname" in
4724 '') ccname="$cc" ;;
4725 esac
4726
4727 # gcc 3.* complain about adding -Idirectories that they already know about,
4728 # so we will take those off from locincpth.
4729 case "$gccversion" in
4730 3*)
4731     echo "main(){}">try.c
4732     for incdir in $locincpth; do
4733        warn=`$cc $ccflags -I$incdir -c try.c 2>&1 | \
4734              grep '^c[cp]p*[01]: warning: changing search order '`
4735        if test "X$warn" != X; then
4736            locincpth=`echo " $locincpth " | sed "s! $incdir ! !"`
4737        fi
4738     done
4739     $rm -f try try.*
4740 esac
4741
4742 # gcc 4.9 by default does some optimizations that break perl.
4743 # see ticket 121505.
4744 #
4745 # The -fwrapv disables those optimizations (and probably others,) so
4746 # for gcc 4.9 (and later, since the optimizations probably won't go
4747 # away), add -fwrapv unless the user requests -fno-wrapv, which
4748 # disables -fwrapv, or if the user requests -fsanitize=undefined,
4749 # which turns the overflows -fwrapv ignores into runtime errors.
4750 case "$gccversion" in
4751 4.[3-9].*|4.[1-9][0-9]*|[5-9].*|[1-9][0-9]*)
4752     case "$ccflags" in
4753     *-fno-wrapv*|*-fsanitize=undefined*|*-fwrapv*) ;;
4754     *) ccflags="$ccflags -fwrapv" ;;
4755     esac
4756 esac
4757
4758 : What should the include directory be ?
4759 : Use sysroot if set, so findhdr looks in the right place.
4760 echo " "
4761 $echo $n "Hmm...  $c"
4762 dflt="$sysroot/usr/include"
4763 incpath=''
4764 mips_type=''
4765 if $test -f /bin/mips && /bin/mips; then
4766         echo "Looks like a MIPS system..."
4767         $cat >usr.c <<'EOCP'
4768 #ifdef SYSTYPE_BSD43
4769 /bsd43
4770 #endif
4771 EOCP
4772         if $cc $cppflags -E usr.c > usr.out && $contains / usr.out >/dev/null 2>&1; then
4773                 dflt='/bsd43/usr/include'
4774                 incpath='/bsd43'
4775                 mips_type='BSD 4.3'
4776         else
4777                 mips_type='System V'
4778         fi
4779         $rm -f usr.c usr.out
4780         echo "and you're compiling with the $mips_type compiler and libraries."
4781         xxx_prompt=y
4782         echo "exit 0" >mips
4783 else
4784         echo "Doesn't look like a MIPS system."
4785         xxx_prompt=n
4786         echo "exit 1" >mips
4787 fi
4788 chmod +x mips
4789 $eunicefix mips
4790 case "$usrinc" in
4791 '') ;;
4792 *) dflt="$usrinc";;
4793 esac
4794 case "$xxx_prompt" in
4795 y)      fn=d/
4796         echo " "
4797         rp='Where are the include files you want to use?'
4798         . ./getfile
4799         usrinc="$ans"
4800         ;;
4801 *)      usrinc="$dflt"
4802         ;;
4803 esac
4804
4805 : see how we invoke the C preprocessor
4806 echo " "
4807 echo "Now, how can we feed standard input to your C preprocessor..." >&4
4808 cat <<'EOT' >testcpp.c
4809 #define ABC abc
4810 #define XYZ xyz
4811 ABC.XYZ
4812 EOT
4813 cd ..
4814 if test ! -f cppstdin; then
4815         if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
4816                 # AIX cc -E doesn't show the absolute headerfile
4817                 # locations but we'll cheat by using the -M flag.
4818                 echo 'cat >.$$.c; rm -f .$$.u; '"$cc"' ${1+"$@"} -M -c .$$.c 2>/dev/null; test -s .$$.u && awk '"'"'$2 ~ /\.h$/ { print "# 0 \""$2"\"" }'"'"' .$$.u; rm -f .$$.o .$$.u; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' > cppstdin
4819         else
4820                 echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
4821         fi
4822 else
4823         echo "Keeping your $hint cppstdin wrapper."
4824 fi
4825 chmod 755 cppstdin
4826 wrapper=`pwd`/cppstdin
4827 ok='false'
4828 cd UU
4829
4830 if $test "X$cppstdin" != "X" && \
4831         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
4832         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4833 then
4834         echo "You used to use $cppstdin $cppminus so we'll use that again."
4835         case "$cpprun" in
4836         '') echo "But let's see if we can live without a wrapper..." ;;
4837         *)
4838                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
4839                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
4840                 then
4841                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
4842                         ok='true'
4843                 else
4844                         echo "(However, $cpprun $cpplast does not work, let's see...)"
4845                 fi
4846                 ;;
4847         esac
4848 else
4849         case "$cppstdin" in
4850   &n