This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport #27632, part 1
[metaconfig.git] / U / installdirs / inc_version_list.U
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:
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
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
21 ?S:     search when adding directories to @INC.  The elements in
22 ?S:     the list are separated by spaces.  This is only useful
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.
27 ?S:     
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:.
33 ?S:inc_version_list_init:
34 ?S:     This variable holds the same list as inc_version_list, but
35 ?S:     each item is enclosed in double quotes and separated by commas, 
36 ?S:     suitable for use in the PERL_INC_VERSION_LIST initialization.
37 ?S:.
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:.
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:.
49 ?H:#define PERL_INC_VERSION_LIST $inc_version_list_init         /**/
50 ?H:.
51 ?T: stem d
52 : Determine list of previous versions to include in @INC
53 $cat > getverlist <<EOPL
54 #!$perl5 -w
55 use File::Basename;
56 \$api_versionstring = "$api_versionstring";
57 \$version = "$version";
58 \$stem = "$sitelib_stem";
59 \$archname = "$archname";
60 EOPL
61         $cat >> getverlist <<'EOPL'
62 # Can't have leading @ because metaconfig interprets it as a command!
63 ;@inc_version_list=();
64 # XXX Redo to do opendir/readdir? 
65 if (-d $stem) {
66     chdir($stem);
67     ;@candidates = glob("5.*");
68 }
69 else {
70     ;@candidates = ();
71 }
72
73 # XXX ToDo:  These comparisons must be reworked when two-digit
74 # subversions come along, so that 5.7.10 compares as greater than
75 # 5.7.3!  By that time, hope that 5.6.x is sufficiently
76 # widespread that we can use the built-in version vectors rather
77 # than reinventing them here.  For 5.6.0, however, we must
78 # assume this script will likely be run by 5.005_0x.  --AD 1/2000.
79 foreach $d (@candidates) {
80     if ($d lt $version) {
81         if ($d ge $api_versionstring) {
82             unshift(@inc_version_list, grep { -d } "$d/$archname", $d);
83         }
84         elsif ($d ge "5.005") {
85             unshift(@inc_version_list, grep { -d } $d);
86         }
87     }
88     else {
89         # Skip newer version.  I.e. don't look in
90         # 5.7.0 if we're installing 5.6.1.
91     }
92 }
93
94 if (@inc_version_list) {
95     print join(' ', @inc_version_list);
96 }
97 else {
98     # Blank space to preserve value for next Configure run.
99     print " ";
100 }
101 EOPL
102 chmod +x getverlist
103 case "$inc_version_list" in
104 '')     if test -x "$perl5$exe_ext"; then
105                 dflt=`$perl5 getverlist`
106         else
107                 dflt='none'
108         fi
109         ;;
110 $undef) dflt='none' ;;
111 ?X:     Configure -Dinc_version_list='5.6.0/$archname 5.6.0' ...
112 *)  eval dflt=\"$inc_version_list\" ;;
113 esac
114 case "$dflt" in
115 ''|' ') dflt=none ;;
116 esac
117 case "$dflt" in
118 5.005) dflt=none ;;
119 esac
120 $cat <<EOM
121
122 In order to ease the process of upgrading, this version of perl 
123 can be configured to use modules built and installed with earlier 
124 versions of perl that were installed under $prefix.  Specify here
125 the list of earlier versions that this version of perl should check.
126 If Configure detected no earlier versions of perl installed under
127 $prefix, then the list will be empty.  Answer 'none' to tell perl
128 to not search earlier versions.
129
130 The default should almost always be sensible, so if you're not sure,
131 just accept the default.
132 EOM
133
134 rp='List of earlier versions to include in @INC?'
135 . ./myread
136 case "$ans" in
137 [Nn]one|''|' '|$undef) inc_version_list=' ' ;;
138 *) inc_version_list="$ans" ;;
139 esac
140 case "$inc_version_list" in
141 ''|' ') 
142         inc_version_list_init='0'
143         d_inc_version_list="$undef"
144         ;;
145 *)      inc_version_list_init=`echo $inc_version_list |
146                 $sed -e 's/^/"/' -e 's/ /","/g' -e 's/$/",0/'`
147         d_inc_version_list="$define"
148         ;;
149 esac
150 $rm -f getverlist
151