This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Metaconfigify #5881.
[metaconfig.git] / U / installdirs / inc_version_list.U
CommitLineData
edd6115f
JH
1?RCS: $Id: inc_version_list.U,v $
2?RCS:
3?RCS: Copyright (c) 2000 Andy Dougherty
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic Licence,
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 3.0.
10?RCS:
11?RCS: $Log: inc_version_list.U,v $
12?RCS:
0fdea05a 13?MAKE:inc_version_list inc_version_list_init: cat sed Getfile perl5 \
cf7245dd 14 version api_versionstring rm Myread archname prefix sitelib
edd6115f
JH
15?MAKE: -pick add $@ %<
16?Y:TOP
17?S:inc_version_list:
18?S: This variable specifies the list of subdirectories in over
19?S: which perl.c:incpush() and lib/lib.pm will automatically
cf7245dd
JH
20?S: search when adding directories to @INC. The elements in
21?S: the list are separated by spaces. This is only useful
edd6115f
JH
22?S: if you have a perl library directory tree structured like the
23?S: default one. See INSTALL for how this works. The versioned
24?S: site_perl directory was introduced in 5.005, so that is the
25?S: lowest possible value.
26?S:
27?S: This list includes architecture-dependent directories back to
28?S: version $api_versionstring (e.g. 5.5.640) and
29?S: architecture-independent directories all the way back to
30?S: 5.005.
31?S:.
cf7245dd
JH
32?S:inc_version_list_init:
33?S: This variable holds the same list as inc_version_list, but
34?S: each item is enclosed in double quotes and separated by commas,
35?S: suitable for use in the PERL_INC_VERSION_LIST initialization.
36?S:.
edd6115f
JH
37?C:PERL_INC_VERSION_LIST:
38?C: This variable specifies the list of subdirectories in over
39?C: which perl.c:incpush() and lib/lib.pm will automatically
40?C: search when adding directories to @INC, in a format suitable
41?C: for a C initialization string. See the inc_version_list entry
42?C: in Porting/Glossary for more details.
43?C:.
cf7245dd 44?H:#define PERL_INC_VERSION_LIST $inc_version_list_init /**/
edd6115f
JH
45?H:.
46?T: stem d
47: Determine list of previous versions to include in @INC
48$cat > getverlist <<EOPL
0fdea05a 49#!$perl5 -w
edd6115f
JH
50use File::Basename;
51\$api_versionstring = "$api_versionstring";
52\$version = "$version";
53\$sitelib = "$sitelib";
54\$archname = "$archname";
55EOPL
56 $cat >> getverlist <<'EOPL'
57# Can't have leading @ because metaconfig interprets it as a command!
58;@inc_version_list=();
59$stem=dirname($sitelib);
0fdea05a 60# XXX Redo to do opendir/readdir?
edd6115f
JH
61if (-d $stem) {
62 chdir($stem);
63 ;@candidates = glob("5.*");
64}
65else {
66 ;@candidates = ();
67}
68
4b37e14a
JH
69# XXX ToDo: These comparisons must be reworked when two-digit
70# subversions come along, so that 5.7.10 compares as greater than
71# 5.7.3! By that time, hope that 5.6.x is sufficiently
72# widespread that we can use the built-in version vectors rather
73# than reinventing them here. For 5.6.0, however, we must
74# assume this script will likely be run by 5.005_0x. --AD 1/2000.
edd6115f
JH
75foreach $d (@candidates) {
76 if ($d lt $version) {
77 if ($d ge $api_versionstring) {
fcd1de66 78 unshift(@inc_version_list, grep { -d } "$d/$archname", $d);
edd6115f
JH
79 }
80 elsif ($d ge "5.005") {
fcd1de66 81 unshift(@inc_version_list, grep { -d } $d);
edd6115f
JH
82 }
83 }
84 else {
85 # Skip newer version. I.e. don't look in
86 # 5.7.0 if we're installing 5.6.1.
87 }
88}
89
90if (@inc_version_list) {
cf7245dd 91 print join(' ', @inc_version_list);
edd6115f
JH
92}
93else {
94 # Blank space to preserve value for next Configure run.
95 print " ";
96}
97EOPL
98chmod +x getverlist
99case "$inc_version_list" in
0fdea05a
JH
100'') if test -x "$perl5"; then
101 dflt=`$perl5 getverlist`
edd6115f 102 else
cf7245dd 103 dflt='none'
edd6115f
JH
104 fi
105 ;;
cf7245dd 106$undef) dflt='none' ;;
edd6115f
JH
107*) dflt="$inc_version_list" ;;
108esac
0fdea05a
JH
109case "$dflt" in
110''|' ') dflt=none ;;
111esac
edd6115f
JH
112$cat <<'EOM'
113
114In order to ease the process of upgrading, this version of perl
115can be configured to use modules built and installed with earlier
116versions of perl that were installed under $prefix. Specify here
117the list of earlier versions that this version of perl should check.
118If Configure detected no earlier versions of perl installed under
cf7245dd
JH
119$prefix, then the list will be empty. Answer 'none' to tell perl
120to not search earlier versions.
edd6115f
JH
121
122The default should almost always be sensible, so if you're not sure,
123just accept the default.
124EOM
125
cf7245dd 126rp='List of earlier versions to include in @INC?'
edd6115f 127. ./myread
cf7245dd 128case "$ans" in
0fdea05a 129[Nn]one|''|' ') inc_version_list=' ' ;;
cf7245dd
JH
130*) inc_version_list="$ans" ;;
131esac
132case "$inc_version_list" in
133''|' ')
075a0831 134 inc_version_list_init='0';;
cf7245dd 135*) inc_version_list_init=`echo $inc_version_list |
075a0831 136 $sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
cf7245dd
JH
137 ;;
138esac
edd6115f
JH
139$rm -f getverlist
140