This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Configure might miss old directories when prefix must be
[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";
a1195863 53\$stem = "$sitelib_stem";
edd6115f
JH
54\$archname = "$archname";
55EOPL
56 $cat >> getverlist <<'EOPL'
57# Can't have leading @ because metaconfig interprets it as a command!
58;@inc_version_list=();
0fdea05a 59# XXX Redo to do opendir/readdir?
edd6115f
JH
60if (-d $stem) {
61 chdir($stem);
62 ;@candidates = glob("5.*");
63}
64else {
65 ;@candidates = ();
66}
67
4b37e14a
JH
68# XXX ToDo: These comparisons must be reworked when two-digit
69# subversions come along, so that 5.7.10 compares as greater than
70# 5.7.3! By that time, hope that 5.6.x is sufficiently
71# widespread that we can use the built-in version vectors rather
72# than reinventing them here. For 5.6.0, however, we must
73# assume this script will likely be run by 5.005_0x. --AD 1/2000.
edd6115f
JH
74foreach $d (@candidates) {
75 if ($d lt $version) {
76 if ($d ge $api_versionstring) {
fcd1de66 77 unshift(@inc_version_list, grep { -d } "$d/$archname", $d);
edd6115f
JH
78 }
79 elsif ($d ge "5.005") {
fcd1de66 80 unshift(@inc_version_list, grep { -d } $d);
edd6115f
JH
81 }
82 }
83 else {
84 # Skip newer version. I.e. don't look in
85 # 5.7.0 if we're installing 5.6.1.
86 }
87}
88
89if (@inc_version_list) {
cf7245dd 90 print join(' ', @inc_version_list);
edd6115f
JH
91}
92else {
93 # Blank space to preserve value for next Configure run.
94 print " ";
95}
96EOPL
97chmod +x getverlist
98case "$inc_version_list" in
0fdea05a
JH
99'') if test -x "$perl5"; then
100 dflt=`$perl5 getverlist`
edd6115f 101 else
cf7245dd 102 dflt='none'
edd6115f
JH
103 fi
104 ;;
cf7245dd 105$undef) dflt='none' ;;
edd6115f
JH
106*) dflt="$inc_version_list" ;;
107esac
0fdea05a
JH
108case "$dflt" in
109''|' ') dflt=none ;;
110esac
edd6115f
JH
111$cat <<'EOM'
112
113In order to ease the process of upgrading, this version of perl
114can be configured to use modules built and installed with earlier
115versions of perl that were installed under $prefix. Specify here
116the list of earlier versions that this version of perl should check.
117If Configure detected no earlier versions of perl installed under
cf7245dd
JH
118$prefix, then the list will be empty. Answer 'none' to tell perl
119to not search earlier versions.
edd6115f
JH
120
121The default should almost always be sensible, so if you're not sure,
122just accept the default.
123EOM
124
cf7245dd 125rp='List of earlier versions to include in @INC?'
edd6115f 126. ./myread
cf7245dd 127case "$ans" in
0fdea05a 128[Nn]one|''|' ') inc_version_list=' ' ;;
cf7245dd
JH
129*) inc_version_list="$ans" ;;
130esac
131case "$inc_version_list" in
132''|' ')
075a0831 133 inc_version_list_init='0';;
cf7245dd 134*) inc_version_list_init=`echo $inc_version_list |
075a0831 135 $sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
cf7245dd
JH
136 ;;
137esac
edd6115f
JH
138$rm -f getverlist
139