This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
backport of 9cf72a4efbbd7d24d3d9d7f5c9d5be6e4ef4297a
[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
53524b20 4?RCS:
edd6115f
JH
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:
302cc344
MB
13?MAKE:inc_version_list inc_version_list_init d_inc_version_list: cat sed \
14 Getfile perl5 version api_versionstring rm Myread archname \
15 prefix sitelib_stem exe_ext
edd6115f
JH
16?MAKE: -pick add $@ %<
17?Y:TOP
18?S:inc_version_list:
19?S: This variable specifies the list of subdirectories in over
20?S: which perl.c:incpush() and lib/lib.pm will automatically
cf7245dd
JH
21?S: search when adding directories to @INC. The elements in
22?S: the list are separated by spaces. This is only useful
edd6115f
JH
23?S: if you have a perl library directory tree structured like the
24?S: default one. See INSTALL for how this works. The versioned
25?S: site_perl directory was introduced in 5.005, so that is the
26?S: lowest possible value.
53524b20 27?S:
edd6115f
JH
28?S: This list includes architecture-dependent directories back to
29?S: version $api_versionstring (e.g. 5.5.640) and
30?S: architecture-independent directories all the way back to
31?S: 5.005.
32?S:.
cf7245dd
JH
33?S:inc_version_list_init:
34?S: This variable holds the same list as inc_version_list, but
53524b20 35?S: each item is enclosed in double quotes and separated by commas,
cf7245dd
JH
36?S: suitable for use in the PERL_INC_VERSION_LIST initialization.
37?S:.
302cc344
MB
38?S:d_inc_version_list:
39?S: This variable conditionally defines PERL_INC_VERSION_LIST.
40?S: It is set to undef when PERL_INC_VERSION_LIST is empty.
41?S:.
edd6115f
JH
42?C:PERL_INC_VERSION_LIST:
43?C: This variable specifies the list of subdirectories in over
44?C: which perl.c:incpush() and lib/lib.pm will automatically
45?C: search when adding directories to @INC, in a format suitable
46?C: for a C initialization string. See the inc_version_list entry
47?C: in Porting/Glossary for more details.
48?C:.
53524b20 49?H:#$d_inc_version_list PERL_INC_VERSION_LIST $inc_version_list_init /**/
edd6115f 50?H:.
41322e17 51?T:stem
edd6115f
JH
52: Determine list of previous versions to include in @INC
53$cat > getverlist <<EOPL
0fdea05a 54#!$perl5 -w
edd6115f
JH
55use File::Basename;
56\$api_versionstring = "$api_versionstring";
57\$version = "$version";
a1195863 58\$stem = "$sitelib_stem";
edd6115f
JH
59\$archname = "$archname";
60EOPL
61 $cat >> getverlist <<'EOPL'
ee1104ab
MB
62# The list found is store twice for each entry: the original name, and
63# the binary broken down version as pack "sss", so sorting is easy and
64# unambiguous. This will work for all versions that have a maximum of
65# three digit groups, separate by '.'s or '_'s. Names are extended with
66# ".0.0" to ensure at least three elements for the pack.
67# -- H.Merijn Brand (m)'06 23-10-2006
68
edd6115f
JH
69# Can't have leading @ because metaconfig interprets it as a command!
70;@inc_version_list=();
53524b20 71# XXX Redo to do opendir/readdir?
edd6115f
JH
72if (-d $stem) {
73 chdir($stem);
ee1104ab
MB
74 ;@candidates = map {
75 [ $_, pack "sss", split m/[._]/, "$_.0.0" ] } glob("5.*");
edd6115f
JH
76}
77else {
78 ;@candidates = ();
79}
80
ee1104ab
MB
81($pversion, $aversion, $vsn5005) = map {
82 pack "sss", split m/[._]/, "$_.0.0" } $version, $api_versionstring, "5.005";
edd6115f 83foreach $d (@candidates) {
ee1104ab
MB
84 if ($d->[1] lt $pversion) {
85 if ($d->[1] ge $aversion) {
86 unshift(@inc_version_list, grep { -d } $d->[0]."/$archname", $d->[0]);
edd6115f 87 }
ee1104ab
MB
88 elsif ($d->[1] ge $vsn5005) {
89 unshift(@inc_version_list, grep { -d } $d->[0]);
edd6115f
JH
90 }
91 }
92 else {
93 # Skip newer version. I.e. don't look in
94 # 5.7.0 if we're installing 5.6.1.
95 }
96}
97
98if (@inc_version_list) {
cf7245dd 99 print join(' ', @inc_version_list);
edd6115f
JH
100}
101else {
102 # Blank space to preserve value for next Configure run.
103 print " ";
104}
105EOPL
106chmod +x getverlist
107case "$inc_version_list" in
2b49ece9 108'') if test -x "$perl5$exe_ext"; then
0fdea05a 109 dflt=`$perl5 getverlist`
edd6115f 110 else
cf7245dd 111 dflt='none'
edd6115f
JH
112 fi
113 ;;
cf7245dd 114$undef) dflt='none' ;;
c29f4401
JH
115?X: Configure -Dinc_version_list='5.6.0/$archname 5.6.0' ...
116*) eval dflt=\"$inc_version_list\" ;;
edd6115f 117esac
0fdea05a
JH
118case "$dflt" in
119''|' ') dflt=none ;;
120esac
85de7615 121case "$dflt" in
5caab28d 1225.005) dflt=none ;;
85de7615 123esac
990ef7bf 124$cat <<EOM
edd6115f 125
53524b20
MB
126In order to ease the process of upgrading, this version of perl
127can be configured to use modules built and installed with earlier
edd6115f
JH
128versions of perl that were installed under $prefix. Specify here
129the list of earlier versions that this version of perl should check.
130If Configure detected no earlier versions of perl installed under
cf7245dd
JH
131$prefix, then the list will be empty. Answer 'none' to tell perl
132to not search earlier versions.
edd6115f
JH
133
134The default should almost always be sensible, so if you're not sure,
135just accept the default.
136EOM
137
cf7245dd 138rp='List of earlier versions to include in @INC?'
edd6115f 139. ./myread
cf7245dd 140case "$ans" in
7bab8e58 141[Nn]one|''|' '|$undef) inc_version_list=' ' ;;
cf7245dd
JH
142*) inc_version_list="$ans" ;;
143esac
144case "$inc_version_list" in
53524b20 145''|' ')
302cc344
MB
146 inc_version_list_init='0'
147 d_inc_version_list="$undef"
148 ;;
cf7245dd 149*) inc_version_list_init=`echo $inc_version_list |
075a0831 150 $sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
302cc344 151 d_inc_version_list="$define"
cf7245dd
JH
152 ;;
153esac
edd6115f
JH
154$rm -f getverlist
155