Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / 5.8.0 / sun4-solaris / lib.pm
CommitLineData
86530b38
AT
1package lib;
2
3# THIS FILE IS AUTOMATICALLY GENERATED FROM lib_pm.PL.
4# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN BY THE NEXT PERL BUILD.
5
6use Config;
7
8use strict;
9
10my $archname = $Config{archname};
11my $version = $Config{version};
12my @inc_version_list = reverse split / /, $Config{inc_version_list};
13
14
15our @ORIG_INC = @INC; # take a handy copy of 'original' value
16our $VERSION = '0.5564';
17my $Is_MacOS = $^O eq 'MacOS';
18my $Mac_FS;
19if ($Is_MacOS) {
20 require File::Spec;
21 $Mac_FS = eval { require Mac::FileSpec::Unixish };
22}
23
24sub import {
25 shift;
26
27 my %names;
28 foreach (reverse @_) {
29 if ($_ eq '') {
30 require Carp;
31 Carp::carp("Empty compile time value given to use lib");
32 }
33
34 local $_ = _nativize($_);
35
36 if (-e && ! -d _) {
37 require Carp;
38 Carp::carp("Parameter to use lib must be directory, not file");
39 }
40 unshift(@INC, $_);
41 # Add any previous version directories we found at configure time
42 foreach my $incver (@inc_version_list)
43 {
44 my $dir = $Is_MacOS
45 ? File::Spec->catdir( $_, $incver )
46 : "$_/$incver";
47 unshift(@INC, $dir) if -d $dir;
48 }
49 # Put a corresponding archlib directory in front of $_ if it
50 # looks like $_ has an archlib directory below it.
51 my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
52 = _get_dirs($_);
53 unshift(@INC, $arch_dir) if -d $arch_auto_dir;
54 unshift(@INC, $version_dir) if -d $version_dir;
55 unshift(@INC, $version_arch_dir) if -d $version_arch_dir;
56 }
57
58 # remove trailing duplicates
59 @INC = grep { ++$names{$_} == 1 } @INC;
60 return;
61}
62
63
64sub unimport {
65 shift;
66
67 my %names;
68 foreach (@_) {
69 local $_ = _nativize($_);
70
71 my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir)
72 = _get_dirs($_);
73 ++$names{$_};
74 ++$names{$arch_dir} if -d $arch_auto_dir;
75 ++$names{$version_dir} if -d $version_dir;
76 ++$names{$version_arch_dir} if -d $version_arch_dir;
77 }
78
79 # Remove ALL instances of each named directory.
80 @INC = grep { !exists $names{$_} } @INC;
81 return;
82}
83
84sub _get_dirs {
85 my($dir) = @_;
86 my($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir);
87
88 # we could use this for all platforms in the future, but leave it
89 # Mac-only for now, until there is more time for testing it.
90 if ($Is_MacOS) {
91 $arch_auto_dir = File::Spec->catdir( $_, $archname, 'auto' );
92 $arch_dir = File::Spec->catdir( $_, $archname, );
93 $version_dir = File::Spec->catdir( $_, $version );
94 $version_arch_dir = File::Spec->catdir( $_, $version, $archname );
95 } else {
96 $arch_auto_dir = "$_/$archname/auto";
97 $arch_dir = "$_/$archname";
98 $version_dir = "$_/$version";
99 $version_arch_dir = "$_/$version/$archname";
100 }
101 return($arch_auto_dir, $arch_dir, $version_dir, $version_arch_dir);
102}
103
104sub _nativize {
105 my($dir) = @_;
106
107 if ($Is_MacOS && $Mac_FS && ! -d $dir) {
108 $dir = Mac::FileSpec::Unixish::nativize($dir);
109 $dir .= ":" unless $dir =~ /:$/;
110 }
111
112 return $dir;
113}
114
1151;
116__END__
117
118=head1 NAME
119
120lib - manipulate @INC at compile time
121
122=head1 SYNOPSIS
123
124 use lib LIST;
125
126 no lib LIST;
127
128=head1 DESCRIPTION
129
130This is a small simple module which simplifies the manipulation of @INC
131at compile time.
132
133It is typically used to add extra directories to perl's search path so
134that later C<use> or C<require> statements will find modules which are
135not located on perl's default search path.
136
137=head2 Adding directories to @INC
138
139The parameters to C<use lib> are added to the start of the perl search
140path. Saying
141
142 use lib LIST;
143
144is I<almost> the same as saying
145
146 BEGIN { unshift(@INC, LIST) }
147
148For each directory in LIST (called $dir here) the lib module also
149checks to see if a directory called $dir/$archname/auto exists.
150If so the $dir/$archname directory is assumed to be a corresponding
151architecture specific directory and is added to @INC in front of $dir.
152
153To avoid memory leaks, all trailing duplicate entries in @INC are
154removed.
155
156=head2 Deleting directories from @INC
157
158You should normally only add directories to @INC. If you need to
159delete directories from @INC take care to only delete those which you
160added yourself or which you are certain are not needed by other modules
161in your script. Other modules may have added directories which they
162need for correct operation.
163
164The C<no lib> statement deletes all instances of each named directory
165from @INC.
166
167For each directory in LIST (called $dir here) the lib module also
168checks to see if a directory called $dir/$archname/auto exists.
169If so the $dir/$archname directory is assumed to be a corresponding
170architecture specific directory and is also deleted from @INC.
171
172=head2 Restoring original @INC
173
174When the lib module is first loaded it records the current value of @INC
175in an array C<@lib::ORIG_INC>. To restore @INC to that value you
176can say
177
178 @INC = @lib::ORIG_INC;
179
180=head1 CAVEATS
181
182In order to keep lib.pm small and simple, it only works with Unix
183filepaths. This doesn't mean it only works on Unix, but non-Unix
184users must first translate their file paths to Unix conventions.
185
186 # VMS users wanting to put [.stuff.moo] into
187 # their @INC would write
188 use lib 'stuff/moo';
189
190=head1 NOTES
191
192In the future, this module will likely use File::Spec for determining
193paths, as it does now for Mac OS (where Unix-style or Mac-style paths
194work, and Unix-style paths are converted properly to Mac-style paths
195before being added to @INC).
196
197=head1 SEE ALSO
198
199FindBin - optional module which deals with paths relative to the source file.
200
201=head1 AUTHOR
202
203Tim Bunce, 2nd June 1995.
204
205=cut