Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 1325 lines (1010 sloc) 37.977 kB
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
1 package Alien::Base::ModuleBuild;
2
3 use strict;
4 use warnings;
5
3dad5d3 @plicease version 0.022_01
plicease authored
6 our $VERSION = '0.022_01';
f4322ac @jberger Added VERSION to each package. Also moved Test.pm to RepositoryTest.p…
jberger authored
7 $VERSION = eval $VERSION;
8
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
9 use parent 'Module::Build';
10
d5cde7b @jberger require C::T version 0.17 in modules
jberger authored
11 use Capture::Tiny 0.17 qw/capture tee/;
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
12 use File::chdir;
3682288 @jberger moved creation of _install to init method. This prevents new method f…
jberger authored
13 use File::Spec;
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
14 use File::Basename qw/fileparse/;
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
15 use Carp;
a4049b1 @plicease remove deprecation warnings for Archive::Extract
plicease authored
16 no warnings;
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
17 use Archive::Extract;
a4049b1 @plicease remove deprecation warnings for Archive::Extract
plicease authored
18 use warnings;
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
19 use Sort::Versions;
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
20 use List::MoreUtils qw/uniq first_index/;
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
21 use ExtUtils::Installed;
4eafd37 @plicease add property alien_isolate_dynamic
plicease authored
22 use File::Copy qw/move/;
ca979cc @plicease add alien_bin_requires
plicease authored
23 use Env qw( @PATH );
6937309 @plicease drop a config script when alien_bin_requires is used
plicease authored
24 use Shell::Guess;
25 use Shell::Config::Generate;
a80ef76 @plicease support for ExtUtils::Depends as a producer (#85)
plicease authored
26 use File::Path qw/mkpath/;
df77cb6 @plicease create a config.site file for autoconf
plicease authored
27 use Config;
28 use Text::ParseWords qw( shellwords );
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
29
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
30 use Alien::Base::PkgConfig;
2174eba @jberger Start incorporating Cabinet class into A::B::MB
jberger authored
31 use Alien::Base::ModuleBuild::Cabinet;
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
32 use Alien::Base::ModuleBuild::Repository;
e157369 @jberger Moved FTP (and HTTP) logic to A::B::MB::Repo. Overload M::B::new to c…
jberger authored
33
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
34 use Alien::Base::ModuleBuild::Repository::HTTP;
35 use Alien::Base::ModuleBuild::Repository::FTP;
36 use Alien::Base::ModuleBuild::Repository::Local;
37
38 # setup protocol specific classes
39 # Alien:: author can override these defaults using alien_repository_class property
40 my %default_repository_class = (
41 default => 'Alien::Base::ModuleBuild::Repository',
42 http => 'Alien::Base::ModuleBuild::Repository::HTTP',
3a461e9 @zmughal add support for HTTPS repositories
zmughal authored
43 https => 'Alien::Base::ModuleBuild::Repository::HTTP',
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
44 ftp => 'Alien::Base::ModuleBuild::Repository::FTP',
45 local => 'Alien::Base::ModuleBuild::Repository::Local',
46 );
e964fa6 @jberger ABMB now finds pc files, creates ABPC objects and stores in config_data
jberger authored
47
4dab278 @jberger Env variables now take precendence over package variables.
jberger authored
48 our $Verbose;
49 $Verbose = $ENV{ALIEN_VERBOSE} if defined $ENV{ALIEN_VERBOSE};
50
51 our $Force;
52 $Force = $ENV{ALIEN_FORCE} if defined $ENV{ALIEN_FORCE};
a1fbdd4 @plicease add ALIEN_INSTALL_TYPE to force system install
plicease authored
53 $Force = 1 if defined $ENV{ALIEN_INSTALL_TYPE} && $ENV{ALIEN_INSTALL_TYPE} eq 'share';
54
55 our $ForceSystem;
56 $ForceSystem = 1 if defined $ENV{ALIEN_INSTALL_TYPE} && $ENV{ALIEN_INSTALL_TYPE} eq 'system';
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
57
e7ab7bb @jberger the full path to alien_share_dir is now in ConfigData as build_share_…
jberger authored
58 ################
59 # Parameters #
60 ################
61
e6f55f7 @jberger readablility++
jberger authored
62 ## Extra parameters in A::B::MB objects (all (toplevel) should start with 'alien_')
63
b28f9c3 @plicease interface for ffi_name
plicease authored
64 # alien_name: name of library (pkg-config)
ed089da @jberger made alien_name an official property
jberger authored
65 __PACKAGE__->add_property('alien_name');
e6f55f7 @jberger readablility++
jberger authored
66
b28f9c3 @plicease interface for ffi_name
plicease authored
67 # alien_ffi_name: name of library (the "foo" in libfoo)
68 __PACKAGE__->add_property('alien_ffi_name');
69
f0b3ea9 @jberger alien_temp_dir is no longer a File::Temp->newdir object but defaults …
jberger authored
70 # alien_temp_dir: folder name for download/build
71 __PACKAGE__->add_property( alien_temp_dir => '_alien' );
e6f55f7 @jberger readablility++
jberger authored
72
e339891 @jberger alien_share_dir property is used to create the share_dir installation…
jberger authored
73 # alien_share_dir: folder name for the "install" of the library
74 # this is added (unshifted) to the @{share_dir->{dist}}
75 # N.B. is reset during constructor to be full folder name
f0d1d81 @jberger pairing down the importance of alien_share_dir
jberger authored
76 __PACKAGE__->add_property('alien_share_dir' => '_share' );
e339891 @jberger alien_share_dir property is used to create the share_dir installation…
jberger authored
77
07a1817 @jberger include cabinet->sort_files method in main_proc. also add alien_selec…
jberger authored
78 # alien_selection_method: name of method for selecting file: (todo: newest, manual)
c79d2b0 @jberger added official: alien_version_check; a "default" happens in alien_che…
jberger authored
79 # default is specified later, when this is undef (see alien_check_installed_version)
c53e319 @jberger added alien_selection_method as official, with default as 'newest'
jberger authored
80 __PACKAGE__->add_property( alien_selection_method => 'newest' );
e6f55f7 @jberger readablility++
jberger authored
81
72fb030 @jberger Improve formatting
jberger authored
82 # alien_build_commands: arrayref of commands for building
4b3c272 @jberger alien_build_commands is now official, with default now included
jberger authored
83 __PACKAGE__->add_property(
84 alien_build_commands =>
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
85 default => [ '%c --prefix=%s', 'make' ],
aa5ff91 @jberger move towards removing the library installation from the ACTION_alien
jberger authored
86 );
87
88 # alien_test_commands: arrayref of commands for testing the library
89 # note that this might be better tacked onto the build-time commands
90 __PACKAGE__->add_property(
91 alien_test_commands =>
92 default => [ ],
93 );
94
95 # alien_build_commands: arrayref of commands for installing the library
96 __PACKAGE__->add_property(
97 alien_install_commands =>
98 default => [ 'make install' ],
4b3c272 @jberger alien_build_commands is now official, with default now included
jberger authored
99 );
e6f55f7 @jberger readablility++
jberger authored
100
72fb030 @jberger Improve formatting
jberger authored
101 # alien_version_check: command to execute to check if install/version
72e2953 @plicease use helper in default
plicease authored
102 __PACKAGE__->add_property( alien_version_check => '%{pkg_config} --modversion %n' );
e6f55f7 @jberger readablility++
jberger authored
103
ec9b8e8 @jberger added alien_init_configdata and properties alien_provides_[cflags|lib…
jberger authored
104 # pkgconfig-esque info, author provides these by hand for now, will parse .pc file eventually
105 __PACKAGE__->add_property( 'alien_provides_cflags' );
106 __PACKAGE__->add_property( 'alien_provides_libs' );
107
72fb030 @jberger Improve formatting
jberger authored
108 # alien_repository: hash (or arrayref of hashes) of information about source repo on ftp
109 # |-- protocol: ftp or http
2ba8a43 @jberger added protocol_class (formerly connection_class) to api
jberger authored
110 # |-- protocol_class: holder for class type (defaults to 'Net::FTP' or 'HTTP::Tiny')
72fb030 @jberger Improve formatting
jberger authored
111 # |-- host: ftp server for source
e7fb433 @jberger rename folder property to location, allows for reuse in http class
jberger authored
112 # |-- location: ftp folder containing source, http addr to page with links
2ba8a43 @jberger added protocol_class (formerly connection_class) to api
jberger authored
113 # |-- pattern: qr regex matching acceptable files, if has capture group those are version numbers
740804f @jberger removed validation property all together, since platform contains the…
jberger authored
114 # |-- platform: src or platform, matching os_type M::B method
72fb030 @jberger Improve formatting
jberger authored
115 # |
116 # |-- (non-api) connection: holder for Net::FTP-like object (needs cwd, ls, and get methods)
5fddd65 @plicease These diagnostics would have saved me some time tonight.
plicease authored
117 __PACKAGE__->add_property( 'alien_repository' => [] );
4d44b36 @jberger official alien_repository and alien_repository_default properties.
jberger authored
118 __PACKAGE__->add_property( 'alien_repository_default' => {} );
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
119 __PACKAGE__->add_property( 'alien_repository_class' => {} );
120
4eafd37 @plicease add property alien_isolate_dynamic
plicease authored
121 # alien_isolate_dynamic
122 __PACKAGE__->add_property( 'alien_isolate_dynamic' => 0 );
6f9147f @plicease add option alien_autoconf_with_pic
plicease authored
123 __PACKAGE__->add_property( 'alien_autoconf_with_pic' => 1 );
e6f55f7 @jberger readablility++
jberger authored
124
1658354 @plicease add support for Inline's auto_include
plicease authored
125 # alien_inline_auto_include
126 __PACKAGE__->add_property( 'alien_inline_auto_include' => [] );
127
5badde3 @plicease allow for MSYS without %c
plicease authored
128 # use MSYS even if %c isn't found
129 __PACKAGE__->add_property( 'alien_msys' => 0 );
130
ca979cc @plicease add alien_bin_requires
plicease authored
131 # Alien packages that provide build dependencies
132 __PACKAGE__->add_property( 'alien_bin_requires' => {} );
133
0e42a57 @plicease make a staged install the default
plicease authored
134 # Do a staged install to blib instead of trying to install to the final location.
135 __PACKAGE__->add_property( 'alien_stage_install' => 1 );
07fe7e9 @plicease stage install to blib when building PPM files for ActiveState
plicease authored
136
a0839c4 @plicease install into arch specific directory by default
plicease authored
137 # Should modules be installed into arch specific directory?
138 # Most alien dists will have arch specific files in their share so it makes sense to install
139 # the module in the arch specific location. If you are alienizing something that isn't arch
140 # specific, like javascript source or java byte code, then you'd want to set this to 0.
1cce18d @plicease arch off by default
plicease authored
141 # For now this will default to off. See gh#119 for a discussion.
142 __PACKAGE__->add_property( 'alien_arch' => defined $ENV{ALIEN_ARCH} ? $ENV{ALIEN_ARCH} : 0 );
a0839c4 @plicease install into arch specific directory by default
plicease authored
143
e760c0e @plicease helper interface
plicease authored
144 __PACKAGE__->add_property( 'alien_helper' => {} );
145
e7ab7bb @jberger the full path to alien_share_dir is now in ConfigData as build_share_…
jberger authored
146 ################
147 # ConfigData #
148 ################
149
4a3b0c0 @jberger Updated library detection
jberger authored
150 # working_directory: full path to the extracted source or binary of the library
151 # pkgconfig: hashref of A::B::PkgConfig objects created from .pc file found in working_directory
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
152 # install_type: either system or share
153 # version: version number installed or available
c790a80 @jberger use manually entered libs/cflags if present or system-wide libs/cflag…
jberger authored
154 # Cflags: holder for cflags if manually specified
155 # Libs: same but libs
156 # name: holder for name as needed by pkg-config
0efd9c2 @jberger added a config_data named finished_installing which is set to 1 once …
jberger authored
157 # finished_installing: set to true once ACTION_install is finished, this helps testing now and real checks later
e7ab7bb @jberger the full path to alien_share_dir is now in ConfigData as build_share_…
jberger authored
158
02475cf @jberger create $builder->alien_init method which allows for creation of objec…
jberger authored
159 ############################
160 # Initialization Methods #
161 ############################
162
e157369 @jberger Moved FTP (and HTTP) logic to A::B::MB::Repo. Overload M::B::new to c…
jberger authored
163 sub new {
164 my $class = shift;
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
165 my %args = @_;
166
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
167 # merge default and user-defined repository classes
ac79862 @jberger simplified the repository class merge
jberger authored
168 $args{alien_repository_class}{$_} ||= $default_repository_class{$_}
169 for keys %default_repository_class;
d3435ce @jberger Moved Repository class selection handling to A::B::MB, this allows fo…
jberger authored
170
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
171 my $self = $class->SUPER::new(%args);
172
395a95f @plicease provide a %{pkg_cofig} by default
plicease authored
173 $self->alien_helper->{pkg_config} = 'Alien::Base::PkgConfig->pkg_config_command'
174 unless defined $self->alien_helper->{pkg_config};
175
aa5ff91 @jberger move towards removing the library installation from the ACTION_alien
jberger authored
176 # setup additional temporary directories, and yes we have to add File::ShareDir manually
177 $self->_add_prereq( 'requires', 'File::ShareDir', '1.00' );
1d13e90 @jberger fix bug with alien_cabinet, added official alien_share_dir
jberger authored
178
1658354 @plicease add support for Inline's auto_include
plicease authored
179 # this just gets passed from the Build.PL to the config so that it can
180 # be used by the auto_include method
181 $self->config_data( 'inline_auto_include' => $self->alien_inline_auto_include );
182
d50f05b @plicease Only inject alien_bin_requires and Alien::MSYS prereqs if a source co…
plicease authored
183 if($Force || !$self->alien_check_installed_version) {
6693980 @plicease allow for multiple argument do_system
plicease authored
184 if (grep /(?<!\%)\%c/, map { ref($_) ? @{$_} : $_ } @{ $self->alien_build_commands }) {
d50f05b @plicease Only inject alien_bin_requires and Alien::MSYS prereqs if a source co…
plicease authored
185 $self->config_data( 'autoconf' => 1 );
186 }
187
188 if ($^O eq 'MSWin32' && ($self->config_data( 'autoconf') || $self->alien_msys)) {
189 $self->_add_prereq( 'build_requires', 'Alien::MSYS', '0' );
190 $self->config_data( 'msys' => 1 );
191 } else {
192 $self->config_data( 'msys' => 0 );
193 }
ca979cc @plicease add alien_bin_requires
plicease authored
194
d50f05b @plicease Only inject alien_bin_requires and Alien::MSYS prereqs if a source co…
plicease authored
195 while(my($tool, $version) = each %{ $self->alien_bin_requires }) {
196 $self->_add_prereq( 'build_requires', $tool, $version );
197 }
ca979cc @plicease add alien_bin_requires
plicease authored
198 }
199
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
200
02475cf @jberger create $builder->alien_init method which allows for creation of objec…
jberger authored
201 # force newest for all automated testing
202 #TODO (this probably should be checked for "input needed" rather than blindly assigned)
203 if ($ENV{AUTOMATED_TESTING}) {
204 $self->alien_selection_method('newest');
aa5ff91 @jberger move towards removing the library installation from the ACTION_alien
jberger authored
205 }
02475cf @jberger create $builder->alien_init method which allows for creation of objec…
jberger authored
206
9096192 @jberger typo
jberger authored
207 $self->config_data( 'finished_installing' => 0 );
0efd9c2 @jberger added a config_data named finished_installing which is set to 1 once …
jberger authored
208
02475cf @jberger create $builder->alien_init method which allows for creation of objec…
jberger authored
209 return $self;
210 }
211
f0b3ea9 @jberger alien_temp_dir is no longer a File::Temp->newdir object but defaults …
jberger authored
212 sub alien_init_temp_dir {
213 my $self = shift;
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
214 my $temp_dir = $self->alien_temp_dir;
215 my $share_dir = $self->alien_share_dir;
f0b3ea9 @jberger alien_temp_dir is no longer a File::Temp->newdir object but defaults …
jberger authored
216
217 # make sure we are in base_dir
218 local $CWD = $self->base_dir;
219
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
220 unless ( -d $temp_dir ) {
221 mkdir $temp_dir or croak "Could not create temporary directory $temp_dir";
f0b3ea9 @jberger alien_temp_dir is no longer a File::Temp->newdir object but defaults …
jberger authored
222 }
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
223 $self->add_to_cleanup( $temp_dir );
3682288 @jberger moved creation of _install to init method. This prevents new method f…
jberger authored
224
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
225 unless ( -d $share_dir ) {
226 mkdir $share_dir or croak "Could not create temporary directory $share_dir";
3682288 @jberger moved creation of _install to init method. This prevents new method f…
jberger authored
227 }
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
228 $self->add_to_cleanup( $share_dir );
aa5ff91 @jberger move towards removing the library installation from the ACTION_alien
jberger authored
229
230 # add share dir to share dir list
231 my $share_dirs = $self->share_dir;
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
232 unshift @{ $share_dirs->{dist} }, $share_dir;
aa5ff91 @jberger move towards removing the library installation from the ACTION_alien
jberger authored
233 $self->share_dir( $share_dirs );
f0d1d81 @jberger pairing down the importance of alien_share_dir
jberger authored
234 {
d607b10 @jberger clean up _share by default since it will not contain built file anymore
jberger authored
235 local $CWD = $share_dir;
236 open my $fh, '>', 'README' or die "Could not open README for writing (in directory $share_dir)\n";
f0d1d81 @jberger pairing down the importance of alien_share_dir
jberger authored
237 print $fh <<'END';
238 This README file is autogenerated by Alien::Base.
239
240 Currently it exists for testing purposes, but it might eventually contain information about the file(s) installed.
241 END
242 }
f0b3ea9 @jberger alien_temp_dir is no longer a File::Temp->newdir object but defaults …
jberger authored
243 }
244
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
245 ####################
246 # ACTION methods #
247 ####################
693b82b @jberger added basic 'valid' property for repos
jberger authored
248
edf7594 @plicease as per consensus renaming alien_dry_run to alien_fakebuild
plicease authored
249 sub ACTION_alien_fakebuild {
ac14c18 @plicease ./Build alien_dry_run
plicease authored
250 my $self = shift;
251
040a25b @plicease register helpers for fakebuild too
plicease authored
252 # needed for any helpers provided by alien_bin_requires
253 $self->_alien_bin_require($_) for keys %{ $self->alien_bin_requires };
254
ac14c18 @plicease ./Build alien_dry_run
plicease authored
255 print "# Build\n";
4a6a590 @plicease dry_run: handle that commands might be list ref
plicease authored
256 foreach my $cmd (@{ $self->alien_build_commands })
ac14c18 @plicease ./Build alien_dry_run
plicease authored
257 {
4a6a590 @plicease dry_run: handle that commands might be list ref
plicease authored
258 my @cmd = map { $self->alien_interpolate($_) } ref($cmd) ? @$cmd : ($cmd);
259 print "+ @cmd\n";
ac14c18 @plicease ./Build alien_dry_run
plicease authored
260 }
261 print "# Build install\n";
4a6a590 @plicease dry_run: handle that commands might be list ref
plicease authored
262 foreach my $cmd (@{ $self->alien_install_commands })
ac14c18 @plicease ./Build alien_dry_run
plicease authored
263 {
4a6a590 @plicease dry_run: handle that commands might be list ref
plicease authored
264 my @cmd = map { $self->alien_interpolate($_) } ref($cmd) ? @$cmd : ($cmd);
265 print "+ @cmd\n";
ac14c18 @plicease ./Build alien_dry_run
plicease authored
266 }
267 }
268
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
269 sub ACTION_code {
270 my $self = shift;
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
271 $self->notes( 'alien_blib_scheme' => $self->alien_detect_blib_scheme );
272
273 # PLEASE NOTE, BOTH BRANCHES CALL SUPER::ACTION_code !!!!!!!
274 if ( $self->notes('ACTION_alien_completed') ) {
275
276 $self->SUPER::ACTION_code;
277
278 } else {
279
280 $self->depends_on('alien_code');
281 $self->SUPER::ACTION_code;
282 }
a80ef76 @plicease support for ExtUtils::Depends as a producer (#85)
plicease authored
283
284 my $module = $self->module_name;
285 my $file = File::Spec->catfile($self->blib, 'lib', split /::/, "$module\::Install::Files.pm");
286 unless (-e $file) {
287 mkpath(File::Spec->catdir($self->blib, 'lib', split /::/, "$module\::Install"), { verbose => 0 });
288 open my $fh, '>', $file;
289 print $fh <<EOF;
290 package $module\::Install::Files;
142fbd7 @plicease making ::files::install a subclass doesn't work.
plicease authored
291 require $module;
292 sub Inline { shift; $module->Inline(\@_) }
a80ef76 @plicease support for ExtUtils::Depends as a producer (#85)
plicease authored
293 1;
caf4019 @plicease just in case someone is running pod coverage over this generated file
plicease authored
294
295 =begin Pod::Coverage
296
297 Inline
298
299 =end Pod::Coverage
300
301 =cut
a80ef76 @plicease support for ExtUtils::Depends as a producer (#85)
plicease authored
302 EOF
303 close $fh;
304 }
a0839c4 @plicease install into arch specific directory by default
plicease authored
305
306 if($self->alien_arch) {
307 my @parts = split /::/, $module;
308 my $arch_dir = File::Spec->catdir($self->blib, 'arch', 'auto', @parts);
309 File::Path::mkpath($arch_dir, 0, oct(777)) unless -d $arch_dir;
310 open my $fh, '>', File::Spec->catfile($arch_dir, $parts[-1].".txt");
311 print $fh "Alien based distribution with architecture specific file in share\n";
312 close $fh;
313 }
314
315 $self->depends_on('alien_install') if $self->alien_stage_install;
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
316 }
317
86b72ba @plicease all ACTION_alien_install from process_share_dir_files when installing…
plicease authored
318 sub process_share_dir_files {
319 my $self = shift;
320 $self->SUPER::process_share_dir_files(@_);
321
322 # copy the compiled files into blib if running under blib scheme
323 $self->depends_on('alien_install') if $self->notes('alien_blib_scheme') || $self->alien_stage_install;
324 }
325
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
326 sub ACTION_alien_code {
c1fd0be @jberger added alien_main_procedure, this will be called from an overridden AC…
jberger authored
327 my $self = shift;
8f0eef0 @jberger explicitly set $| = 1 in both ACTION_alien_* methods
jberger authored
328 local $| = 1; # don't buffer stdout
329
672b1fa @jberger initialize temporary directories during ACTION_alien so they aren't c…
jberger authored
330 $self->alien_init_temp_dir;
dc49e34 @jberger rename alien_init to alien_init_repositories, since thats all it does…
jberger authored
331
9299e04 @jberger generate a _manual A::B::PC object from alien_provides_* rather than …
jberger authored
332 $self->config_data( name => $self->alien_name );
b28f9c3 @plicease interface for ffi_name
plicease authored
333 $self->config_data( ffi_name => $self->alien_ffi_name );
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
334
c790a80 @jberger use manually entered libs/cflags if present or system-wide libs/cflag…
jberger authored
335 my $version;
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
336 $version = $self->alien_check_installed_version
337 unless $Force;
338
339 if ($version) {
340 $self->config_data( install_type => 'system' );
341 $self->config_data( version => $version );
b599a8a @plicease honor alien_provides_* on system install
plicease authored
342 my %system_provides;
343 $system_provides{Cflags} = $self->alien_provides_cflags
344 if defined $self->alien_provides_cflags;
345 $system_provides{Libs} = $self->alien_provides_libs
346 if defined $self->alien_provides_libs;
347 $self->config_data( system_provides => \%system_provides );
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
348 return;
349 }
a1fbdd4 @plicease add ALIEN_INSTALL_TYPE to force system install
plicease authored
350
351 if ($ForceSystem) {
352 die "Requested system install, but system package not detected."
353 }
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
354
ca3a25e @jberger alien_init_repositories (now alien_create_repositories) returns repo …
jberger authored
355 my @repos = $self->alien_create_repositories;
02475cf @jberger create $builder->alien_init method which allows for creation of objec…
jberger authored
356
5b3d43d @jberger removed alien_cabinet property. The cabinet object now belongs to ACT…
jberger authored
357 my $cabinet = Alien::Base::ModuleBuild::Cabinet->new;
c1fd0be @jberger added alien_main_procedure, this will be called from an overridden AC…
jberger authored
358
ca3a25e @jberger alien_init_repositories (now alien_create_repositories) returns repo …
jberger authored
359 foreach my $repo (@repos) {
07a1817 @jberger include cabinet->sort_files method in main_proc. also add alien_selec…
jberger authored
360 $cabinet->add_files( $repo->probe() );
2174eba @jberger Start incorporating Cabinet class into A::B::MB
jberger authored
361 }
fa0c5d3 @jberger Forked out repo types, added repo method list_files, implemented list…
jberger authored
362
07a1817 @jberger include cabinet->sort_files method in main_proc. also add alien_selec…
jberger authored
363 $cabinet->sort_files;
fa0c5d3 @jberger Forked out repo types, added repo method list_files, implemented list…
jberger authored
364
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
365 {
02475cf @jberger create $builder->alien_init method which allows for creation of objec…
jberger authored
366 local $CWD = $self->alien_temp_dir;
12a66bf @jberger fixed ordering bug in example
jberger authored
367
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
368 my $file = $cabinet->files->[0];
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
369 $version = $file->version;
b1da1b4 @MidLifeXis Rename the config variable to be alien specific
MidLifeXis authored
370 $self->config_data( alien_version => $version ); # Temporary setting, may be overridden later
1060327 @jberger add a few progress messages
jberger authored
371
9b43b8b @jberger capture build output, output if $Verbose. added ALIEN_VERBOSE environ…
jberger authored
372 print "Downloading File: " . $file->filename . " ... ";
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
373 my $filename = $file->get;
01e3ff0 @vikasnkumar Adding SHA-1/256 sum checks on exact file downloads
vikasnkumar authored
374 croak "Error downloading file" unless $filename;
9b43b8b @jberger capture build output, output if $Verbose. added ALIEN_VERBOSE environ…
jberger authored
375 print "Done\n";
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
376
9b43b8b @jberger capture build output, output if $Verbose. added ALIEN_VERBOSE environ…
jberger authored
377 print "Extracting Archive ... ";
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
378 my $ae = Archive::Extract->new( archive => $filename );
379 $ae->extract;
9b43b8b @jberger capture build output, output if $Verbose. added ALIEN_VERBOSE environ…
jberger authored
380 print "Done\n";
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
381
557ca5e @plicease more MSWin32 path fixes
plicease authored
382 my $extract_path = _catdir($ae->extract_path);
4a3b0c0 @jberger Updated library detection
jberger authored
383 $self->config_data( working_directory => $extract_path );
1d3e866 @jberger be sure to remember the extracted path for later use (store in alien_…
jberger authored
384 $CWD = $extract_path;
385
65e09c9 @jberger don't attempt build commands unless the file is a src package
jberger authored
386 if ( $file->platform eq 'src' ) {
387 print "Building library ... ";
388 unless ($self->alien_do_commands('build')) {
389 print "Failed\n";
390 croak "Build not completed";
391 }
1e4ed50 @jberger ACTION_alien's invokation of alien_build now checks for the return st…
jberger authored
392 }
65e09c9 @jberger don't attempt build commands unless the file is a src package
jberger authored
393
9b43b8b @jberger capture build output, output if $Verbose. added ALIEN_VERBOSE environ…
jberger authored
394 print "Done\n";
395
218271b @jberger Many updates, including adding M::B tag {properties} and alien_main_p…
jberger authored
396 }
e7fb433 @jberger rename folder property to location, allows for reuse in http class
jberger authored
397
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
398 $self->config_data( install_type => 'share' );
8a5371c @plicease deal with relocatable sharedir
plicease authored
399 $self->config_data( original_prefix => $self->alien_library_destination );
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
400
401 my $pc = $self->alien_load_pkgconfig;
14f8c28 @jberger use _manual information for obtaining version info, in case of no pkg…
jberger authored
402 my $pc_version = (
403 $pc->{$self->alien_name} || $pc->{_manual}
404 )->keyword('Version');
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
405
696b1dc @plicease add alien_check_built_version method
plicease authored
406 unless (defined $version) {
407 local $CWD = $self->config_data( 'working_directory' );
408 $version = $self->alien_check_built_version
409 }
410
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
411 if (! $version and ! $pc_version) {
5fddd65 @plicease These diagnostics would have saved me some time tonight.
plicease authored
412 print STDERR "If you are the author of this Alien dist, you may need to provide a an\n";
413 print STDERR "alien_check_built_version method for your Alien::Base::ModuleBuild\n";
414 print STDERR "class. See:\n";
415 print STDERR "https://metacpan.org/pod/Alien::Base::ModuleBuild#alien_check_built_version\n";
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
416 carp "Library looks like it installed, but no version was determined";
417 $self->config_data( version => 0 );
b6ab6ca @jberger post-build version checking finished, now need to hook to that info i…
jberger authored
418 return
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
419 }
b6ab6ca @jberger post-build version checking finished, now need to hook to that info i…
jberger authored
420
421 if ( $version and $pc_version and versioncmp($version, $pc_version)) {
422 carp "Version information extracted from the file name and pkgconfig data disagree";
412c925 @jberger handle system installed, and finding versions post-install
jberger authored
423 }
424
b6ab6ca @jberger post-build version checking finished, now need to hook to that info i…
jberger authored
425 $self->config_data( version => $pc_version || $version );
d8918a1 @jberger don't rebuild library on repeated M::B::dispatch
jberger authored
426
427 # prevent building multiple times (on M::B::dispatch)
428 $self->notes( 'ACTION_alien_completed' => 1 );
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
429
b6ab6ca @jberger post-build version checking finished, now need to hook to that info i…
jberger authored
430 return;
0c94bf7 @jberger added alien_build method which runs a set of commands to build/instal…
jberger authored
431 }
432
5137e10 @jberger created ACTION_test for testing the library via defined means. This a…
jberger authored
433 sub ACTION_test {
434 my $self = shift;
435 $self->SUPER::ACTION_test;
436
4a3b0c0 @jberger Updated library detection
jberger authored
437 local $CWD = $self->config_data( 'working_directory' );
5137e10 @jberger created ACTION_test for testing the library via defined means. This a…
jberger authored
438 print "Testing library (if applicable) ... ";
439 $self->alien_do_commands('test') or die "Failed\n";
440 print "Done\n";
441 }
442
56626cf @jberger add stub ACTION_install which will house the new direct installation …
jberger authored
443 sub ACTION_install {
444 my $self = shift;
445 $self->SUPER::ACTION_install;
594dba9 @plicease relocate id in dylib files on os x
plicease authored
446 if($self->alien_stage_install) {
1600623 @plicease Another fix related to #94
plicease authored
447 $self->alien_relocation_fixup;
594dba9 @plicease relocate id in dylib files on os x
plicease authored
448 } else {
1600623 @plicease Another fix related to #94
plicease authored
449 $self->depends_on('alien_install');
594dba9 @plicease relocate id in dylib files on os x
plicease authored
450 }
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
451 }
452
453 sub ACTION_alien_install {
454 my $self = shift;
455
8f0eef0 @jberger explicitly set $| = 1 in both ACTION_alien_* methods
jberger authored
456 local $| = 1; # don't buffer stdout
457
da924b3 @jberger Don't do additional actions during install phase if using system inst…
jberger authored
458 return if $self->config_data( 'install_type' ) eq 'system';
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
459
07e8ab7 @plicease use and propagate DESTDIR as appropriate
plicease authored
460 my $destdir = $self->destdir;
4135ad1 @plicease fix destdir + staged installs
plicease authored
461 my $target = $self->alien_library_destination;
462
463 if(defined $destdir && !$self->alien_stage_install)
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
464 {
4135ad1 @plicease fix destdir + staged installs
plicease authored
465 # Note: no longer necessary when doing a staged install
10b3848 @plicease extra commentary
plicease authored
466 # prefix the target directory with $destdir so that package builds
467 # can install into a fake root
4135ad1 @plicease fix destdir + staged installs
plicease authored
468 $target = File::Spec->catdir($destdir, $target);
469 }
470
471 {
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
472 local $CWD = $target;
473
474 # The only form of introspection that exists is to see that the README file
475 # which was placed in the share_dir (default _share) exists where we expect
476 # after installation.
477 unless ( -e 'README' ) {
478 die "share_dir mismatch detected ($target)\n"
479 }
480 }
481
482 {
4a3b0c0 @jberger Updated library detection
jberger authored
483 local $CWD = $self->config_data( 'working_directory' );
9c60f65 @plicease test for DESTDIR
plicease authored
484 local $ENV{DESTDIR} = $ENV{DESTDIR};
4135ad1 @plicease fix destdir + staged installs
plicease authored
485 $ENV{DESTDIR} = $destdir if defined $destdir && !$self->alien_stage_install;
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
486 print "Installing library to $CWD ... ";
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
487 $self->alien_do_commands('install') or die "Failed\n";
488 print "Done\n";
489 }
4eafd37 @plicease add property alien_isolate_dynamic
plicease authored
490
491 if ( $self->alien_isolate_dynamic ) {
07e8ab7 @plicease use and propagate DESTDIR as appropriate
plicease authored
492 local $CWD = $target;
4eafd37 @plicease add property alien_isolate_dynamic
plicease authored
493 print "Isolating dynamic libraries ... ";
494 mkdir 'dynamic' unless -d 'dynamic';
495 foreach my $dir (qw( bin lib )) {
496 next unless -d $dir;
497 opendir(my $dh, $dir);
93f6f59 @plicease include os x .bundle file as dynamic lib
plicease authored
498 my @dlls = grep { /\.so/ || /\.(dylib|bundle|la|dll|dll\.a)$/ } grep !/^\./, readdir $dh;
4eafd37 @plicease add property alien_isolate_dynamic
plicease authored
499 closedir $dh;
500 foreach my $dll (@dlls) {
501 my $from = File::Spec->catfile($dir, $dll);
502 my $to = File::Spec->catfile('dynamic', $dll);
503 unlink $to if -e $to;
504 move($from, $to);
505 }
506 }
507 print "Done\n";
508 }
2c10b40 @jberger Refresh autogenerated pkgconfig data after installation
jberger authored
509
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
510 # refresh metadata after library installation
2c10b40 @jberger Refresh autogenerated pkgconfig data after installation
jberger authored
511 $self->alien_refresh_manual_pkgconfig( $self->alien_library_destination );
0efd9c2 @jberger added a config_data named finished_installing which is set to 1 once …
jberger authored
512 $self->config_data( 'finished_installing' => 1 );
2c10b40 @jberger Refresh autogenerated pkgconfig data after installation
jberger authored
513
1600623 @plicease Another fix related to #94
plicease authored
514 if ( $self->notes( 'alien_blib_scheme') || $self->alien_stage_install) {
96a9c68 @plicease todo note
plicease authored
515
516 ### TODO: empty if should be claned up before 0.017.
517 ### we used to call process_files_by_extension('pm')
518 ### here, but with gh#121 it is unecessary
86b72ba @plicease all ACTION_alien_install from process_share_dir_files when installing…
plicease authored
519 ## reinstall config_data to blib
520 #$self->process_files_by_extension('pm');
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
521
522 } else {
86b72ba @plicease all ACTION_alien_install from process_share_dir_files when installing…
plicease authored
523
524 # to refresh config_data
525 $self->SUPER::ACTION_config_data;
526
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
527 # reinstall config_data
528 $self->SUPER::ACTION_install;
529
530 # refresh the packlist
1600623 @plicease Another fix related to #94
plicease authored
531 $self->alien_refresh_packlist( $self->alien_library_destination );
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
532 }
56626cf @jberger add stub ACTION_install which will house the new direct installation …
jberger authored
533 }
534
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
535 #######################
536 # Pre-build Methods #
537 #######################
538
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
539 sub alien_check_installed_version {
540 my $self = shift;
0838d75 @jberger added %n as interpolation placeholder for library name. alien_version…
jberger authored
541 my $command = $self->alien_version_check;
542
52fd2d8 @jberger default to be a little noisier
jberger authored
543 my %result = $self->do_system($command, {verbose => 0});
27a981f @jberger do_system in list context captures output and returns a hash of infor…
jberger authored
544 my $version = $result{stdout} || 0;
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
545
546 return $version;
547 }
548
4ed8eb0 @jberger move alien_create_repositories to more appropriate part of the file
jberger authored
549 sub alien_create_repositories {
550 my $self = shift;
551
552 ## get repository specs
553 my $repo_default = $self->alien_repository_default;
554 my $repo_specs = $self->alien_repository;
555
556 # upconvert to arrayref if a single hashref is passed
557 if (ref $repo_specs eq 'HASH') {
558 $repo_specs = [ $repo_specs ];
559 }
5fddd65 @plicease These diagnostics would have saved me some time tonight.
plicease authored
560
561 unless(@$repo_specs)
562 {
563 print STDERR "If you are the author of this Alien dist, you need to provide at least\n";
564 print STDERR "one repository in your Build.PL. See:\n";
565 print STDERR "https://metacpan.org/pod/distribution/Alien-Base/lib/Alien/Base/ModuleBuild/API.pod#alien_repository\n";
566 croak "No repositories specified.";
567 }
4ed8eb0 @jberger move alien_create_repositories to more appropriate part of the file
jberger authored
568
569 my @repos;
570 foreach my $repo ( @$repo_specs ) {
571 #merge defaults into spec
572 foreach my $key ( keys %$repo_default ) {
573 next if defined $repo->{$key};
574 $repo->{$key} = $repo_default->{$key};
575 }
576
577 $repo->{platform} = 'src' unless defined $repo->{platform};
578 my $protocol = $repo->{protocol} || 'default';
579
580 push @repos, $self->alien_repository_class($protocol)->new( $repo );
581 }
582
583 # check validation, including c compiler for src type
584 @repos =
585 grep { $self->alien_validate_repo($_) }
586 @repos;
587
588 unless (@repos) {
589 croak "No valid repositories available";
590 }
591
592 return @repos;
593
594 }
595
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
596 sub alien_validate_repo {
f82bf0c @jberger added alien_interpolate method (for command interpolation) with tests…
jberger authored
597 my $self = shift;
efc457e @jberger remove closure validation, since M::B can't handle it
jberger authored
598 my ($repo) = @_;
599 my $platform = $repo->{platform};
f82bf0c @jberger added alien_interpolate method (for command interpolation) with tests…
jberger authored
600
efc457e @jberger remove closure validation, since M::B can't handle it
jberger authored
601 # return true if platform is undefined
602 return 1 unless defined $platform;
f82bf0c @jberger added alien_interpolate method (for command interpolation) with tests…
jberger authored
603
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
604 # if $valid is src, check for c compiler
efc457e @jberger remove closure validation, since M::B can't handle it
jberger authored
605 if ($platform eq 'src') {
50ea86f @plicease add c_compiler_required option
plicease authored
606 return !$repo->{c_compiler_required} || $self->have_c_compiler;
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
607 }
f82bf0c @jberger added alien_interpolate method (for command interpolation) with tests…
jberger authored
608
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
609 # $valid is a string (OS) to match against
efc457e @jberger remove closure validation, since M::B can't handle it
jberger authored
610 return $self->os_type eq $platform;
f82bf0c @jberger added alien_interpolate method (for command interpolation) with tests…
jberger authored
611 }
612
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
613 sub alien_library_destination {
614 my $self = shift;
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
615
616 # send the library into the blib if running under the blib scheme
617 my $lib_dir =
07fe7e9 @plicease stage install to blib when building PPM files for ActiveState
plicease authored
618 $self->notes('alien_blib_scheme') || $self->alien_stage_install
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
619 ? File::Spec->catdir( $self->base_dir, $self->blib, 'lib' )
985ddfa @plicease direct install should go to arch if alien_arch
plicease authored
620 : $self->install_destination($self->alien_arch ? 'arch' : 'lib');
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
621
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
622 my $dist_name = $self->dist_name;
557ca5e @plicease more MSWin32 path fixes
plicease authored
623 my $dest = _catdir( $lib_dir, qw/auto share dist/, $dist_name );
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
624 return $dest;
625 }
626
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
627 # CPAN testers often run tests without installing modules, but rather add
628 # blib dirs to @INC, this is a problem, so here we try to deal with it
629 sub alien_detect_blib_scheme {
630 my $self = shift;
631
d013789 @plicease minor fix for #114
plicease authored
632 return 0 if $self->alien_stage_install;
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
633 return $ENV{ALIEN_BLIB} if defined $ENV{ALIEN_BLIB};
634
635 # check to see if Alien::Base::ModuleBuild is running from blib.
636 # if so it is likely that this is the blib scheme
637
638 (undef, my $dir, undef) = File::Spec->splitpath( __FILE__ );
639 my @dirs = File::Spec->splitdir($dir);
640
641 my $index = first_index { $_ eq 'blib' } @dirs;
642 return 0 if $index == -1;
643
644 if ( $dirs[$index+1] eq 'lib' ) {
3b2830d @jberger message should have newline
jberger authored
645 print qq{'blib' scheme is detected. Setting ALIEN_BLIB=1. If this has been done in error, please set ALIEN_BLIB and restart build process to disambiguate.\n};
fb2b6b4 @jberger added handling of the 'blib scheme'
jberger authored
646 return 1;
647 }
648
649 carp q{'blib' scheme is suspected, but uncertain. Please set ALIEN_BLIB and restart build process to disambiguate. Setting ALIEN_BLIB=1 for now.};
650 return 1;
651 }
652
8c33849 @jberger Clean-up/Spruce-up
jberger authored
653 ###################
0c94bf7 @jberger added alien_build method which runs a set of commands to build/instal…
jberger authored
654 # Build Methods #
655 ###################
656
df77cb6 @plicease create a config.site file for autoconf
plicease authored
657 sub _shell_config_generate
658 {
659 my $scg = Shell::Config::Generate->new;
660 $scg->comment(
661 'this script sets the environment needed to build this package.',
662 'generated by: ' . __FILE__,
663 );
664 $scg;
665 }
666
667 sub _filter_defines
668 {
669 join ' ', grep !/^-D/, shellwords($_[0]);
670 }
671
e760c0e @plicease helper interface
plicease authored
672 sub _alien_bin_require {
673 my($self, $mod) = @_;
674
675 my $version = $self->alien_bin_requires->{$mod};
676
677 eval qq{ use $mod $version () }; # should also work for version = 0
678 die $@ if $@;
679
680 if($mod->can('alien_helper')) {
681 my $helpers = $mod->alien_helper;
682 while(my($k,$v) = each %$helpers) {
086ce33 @plicease prefer helpers in Build.PL
plicease authored
683 next if defined $self->alien_helper->{$k};
e760c0e @plicease helper interface
plicease authored
684 $self->alien_helper->{$k} = $v;
685 }
686 }
687 }
688
ca979cc @plicease add alien_bin_requires
plicease authored
689 sub _env_do_system {
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
690 my $self = shift;
691 my $command = shift;
692
ca979cc @plicease add alien_bin_requires
plicease authored
693 local $ENV{PATH} = $ENV{PATH};
694
215e76d @plicease fix bug where Alien::MSYS was being used on non windows
plicease authored
695 if ($self->config_data( 'msys' )) {
ca979cc @plicease add alien_bin_requires
plicease authored
696 $self->alien_bin_requires->{'Alien::MSYS'} ||= 0
697 }
698
df77cb6 @plicease create a config.site file for autoconf
plicease authored
699 my $config;
700
ca979cc @plicease add alien_bin_requires
plicease authored
701 foreach my $mod (keys %{ $self->alien_bin_requires }) {
e760c0e @plicease helper interface
plicease authored
702 $self->_alien_bin_require($mod);
ca979cc @plicease add alien_bin_requires
plicease authored
703
704 my %path;
705
706 if ($mod eq 'Alien::MSYS') {
707 $path{Alien::MSYS->msys_path} = 1;
708 } elsif ($mod eq 'Alien::CMake') {
709 Alien::CMake->set_path;
710 } elsif ($mod eq 'Alien::TinyCC') {
711 $path{Alien::TinyCC->path_to_tcc} = 1;
712 } elsif ($mod eq 'Alien::Autotools') {
713 $path{$_} = 1 for map { Alien::Autotools->$_ } qw( autoconf_dir automake_dir libtool_dir );
714 } elsif (eval { $mod->can('bin_dir') }) {
715 $path{$_} = 1 for $mod->bin_dir;
716 }
717
718 # remove anything already in PATH
719 delete $path{$_} for @PATH;
720 # add anything else to start of PATH
6937309 @plicease drop a config script when alien_bin_requires is used
plicease authored
721 unshift @PATH, sort keys %path;
722
df77cb6 @plicease create a config.site file for autoconf
plicease authored
723 $config ||= _shell_config_generate();
6937309 @plicease drop a config script when alien_bin_requires is used
plicease authored
724 $config->prepend_path( PATH => sort keys %path );
df77cb6 @plicease create a config.site file for autoconf
plicease authored
725 }
726
727 local $ENV{CONFIG_SITE} = $ENV{CONFIG_SITE};
728
729 # If we are using autoconf, then create a site.config file
730 # that specifies the same compiler and compiler linker flags
731 # as were used for building Perl. This is helpful for
732 # mixed 32/64bit platforms where 32bit is the default but
733 # Perl is 64bit.
734 if($self->config_data('autoconf') && !defined $ENV{CONFIG_SITE}) {
735
736 local $CWD;
737 pop @CWD;
738
dfc2cfb @plicease use -Wl,-headerpad_max_install_names flags on OS X to make dylibs rel…
plicease authored
739 my $ldflags = $Config{ldflags};
740 $ldflags .= " -Wl,-headerpad_max_install_names"
741 if $^O eq 'darwin';
742
df77cb6 @plicease create a config.site file for autoconf
plicease authored
743 open my $fh, '>', 'config.site';
f97195f @plicease also put cc in quotes
plicease authored
744 print $fh "CC='$Config{cc}'\n";
df77cb6 @plicease create a config.site file for autoconf
plicease authored
745 # -D define flags should be stripped because they are Perl
746 # specific.
747 print $fh "CFLAGS='", _filter_defines($Config{ccflags}), "'\n";
748 print $fh "CPPFLAGS='", _filter_defines($Config{cppflags}), "'\n";
749 print $fh "CXXFLAGS='", _filter_defines($Config{ccflags}), "'\n";
dfc2cfb @plicease use -Wl,-headerpad_max_install_names flags on OS X to make dylibs rel…
plicease authored
750 print $fh "LDFLAGS='$ldflags'\n";
df77cb6 @plicease create a config.site file for autoconf
plicease authored
751 close $fh;
752
753 my $config ||= _shell_config_generate();
754 my $config_site = File::Spec->catfile($CWD, 'config.site');
755 $config_site =~ s{\\}{/}g if $^O eq 'MSWin32';
756 $config->set( CONFIG_SITE => $config_site );
757 $ENV{CONFIG_SITE} = $config_site;
758 }
759
760 if($config) {
6937309 @plicease drop a config script when alien_bin_requires is used
plicease authored
761 if($^O eq 'MSWin32') {
762 local $CWD;
763 pop @CWD;
764 $config->generate_file( Shell::Guess->command_shell, 'env.bat' );
765 $config->generate_file( Shell::Guess->cmd_shell, 'env.cmd' );
766 $config->generate_file( Shell::Guess->power_shell, 'env.ps1' );
767 } else {
768 local $CWD;
769 pop @CWD;
770 $config->generate_file( Shell::Guess->bourne_shell, 'env.sh' );
771 $config->generate_file( Shell::Guess->c_shell, 'env.csh' );
772 }
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
773 }
df77cb6 @plicease create a config.site file for autoconf
plicease authored
774
6693980 @plicease allow for multiple argument do_system
plicease authored
775 $self->do_system( ref($command) ? @$command : $command );
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
776 }
777
696b1dc @plicease add alien_check_built_version method
plicease authored
778 sub alien_check_built_version {
779 return;
780 }
781
5137e10 @jberger created ACTION_test for testing the library via defined means. This a…
jberger authored
782 sub alien_do_commands {
0c94bf7 @jberger added alien_build method which runs a set of commands to build/instal…
jberger authored
783 my $self = shift;
5137e10 @jberger created ACTION_test for testing the library via defined means. This a…
jberger authored
784 my $phase = shift;
4cf30e7 @jberger implemented platform conforming local execution prefix
jberger authored
785
5137e10 @jberger created ACTION_test for testing the library via defined means. This a…
jberger authored
786 my $attr = "alien_${phase}_commands";
787 my $commands = $self->$attr();
0c94bf7 @jberger added alien_build method which runs a set of commands to build/instal…
jberger authored
788
8a56ee6 @plicease print out commands before they are executed
plicease authored
789 print "\n+ cd $CWD\n";
790
0c94bf7 @jberger added alien_build method which runs a set of commands to build/instal…
jberger authored
791 foreach my $command (@$commands) {
3294495 @jberger Include the long-awaited mac hack which should add -header-pad_max_in…
jberger authored
792
ca979cc @plicease add alien_bin_requires
plicease authored
793 my %result = $self->_env_do_system( $command );
93738e2 @jberger emit more information on failed build command
jberger authored
794 unless ($result{success}) {
52fd2d8 @jberger default to be a little noisier
jberger authored
795 carp "External command ($result{command}) failed! Error: $?\n";
0c94bf7 @jberger added alien_build method which runs a set of commands to build/instal…
jberger authored
796 return 0;
797 }
798 }
799
800 return 1;
801 }
802
eb2e5f9 @jberger created A::B::do_system which wraps M::B::do_system. This overridden …
jberger authored
803 # wrapper for M::B::do_system which interpolates alien_ vars first
b12d14a @jberger alien_check_installed_version no longer has special case $Verbose han…
jberger authored
804 # futher it either captures or tees depending on the value of $Verbose
eb2e5f9 @jberger created A::B::do_system which wraps M::B::do_system. This overridden …
jberger authored
805 sub do_system {
806 my $self = shift;
52fd2d8 @jberger default to be a little noisier
jberger authored
807 my $opts = ref $_[-1] ? pop : { verbose => 1 };
808
809 my $verbose = $Verbose || $opts->{verbose};
1676e94 @jberger explicitly restore working directory after do_system commands
jberger authored
810
811 # prevent build process from cwd-ing from underneath us
812 local $CWD;
813 my $initial_cwd = $CWD;
66f078c @jberger A::B::MB::do_system: localize $CWD to prevent global changes to worki…
jberger authored
814
eb2e5f9 @jberger created A::B::do_system which wraps M::B::do_system. This overridden …
jberger authored
815 my @args = map { $self->alien_interpolate($_) } @_;
1676e94 @jberger explicitly restore working directory after do_system commands
jberger authored
816
8a56ee6 @plicease print out commands before they are executed
plicease authored
817 print "+ @args\n";
818
012fdc0 @jberger revamp do_system capturing
jberger authored
819 my ($out, $err, $success) =
52fd2d8 @jberger default to be a little noisier
jberger authored
820 $verbose
012fdc0 @jberger revamp do_system capturing
jberger authored
821 ? tee { $self->SUPER::do_system(@args) }
822 : capture { $self->SUPER::do_system(@args) }
823 ;
824
825 my %return = (
826 stdout => $out,
827 stderr => $err,
828 success => $success,
829 command => join(' ', @args),
830 );
1676e94 @jberger explicitly restore working directory after do_system commands
jberger authored
831
832 # restore wd
833 $CWD = $initial_cwd;
012fdc0 @jberger revamp do_system capturing
jberger authored
834
8d224dc @jberger typo
jberger authored
835 return wantarray ? %return : $return{success};
eb2e5f9 @jberger created A::B::do_system which wraps M::B::do_system. This overridden …
jberger authored
836 }
837
e760c0e @plicease helper interface
plicease authored
838 sub _alien_execute_helper {
839 my($self, $helper) = @_;
840 my $code = $self->alien_helper->{$helper};
841 die "no such helper: $helper" unless defined $code;
984b62a @plicease ensure that @_ is empty for call to helper
plicease authored
842
843 if(ref($code) ne 'CODE') {
844 my $perl = $code;
845 $code = sub {
846 my $value = eval $perl;
847 die $@ if $@;
848 $value;
849 };
850 }
851
852 $code->();
e760c0e @plicease helper interface
plicease authored
853 }
854
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
855 sub alien_interpolate {
856 my $self = shift;
857 my ($string) = @_;
858
859 my $prefix = $self->alien_exec_prefix;
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
860 my $configure = $self->alien_configure;
00e431b @jberger implement alien_library_destination which is the new install target f…
jberger authored
861 my $share = $self->alien_library_destination;
709774d @preaction silence warning if no alien_name
preaction authored
862 my $name = $self->alien_name || '';
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
863
864 # substitute:
865 # install location share_dir (placeholder: %s)
866 $string =~ s/(?<!\%)\%s/$share/g;
867 # local exec prefix (ph: %p)
868 $string =~ s/(?<!\%)\%p/$prefix/g;
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
869 # correct incantation for configure on platform
870 $string =~ s/(?<!\%)\%c/$configure/g;
0838d75 @jberger added %n as interpolation placeholder for library name. alien_version…
jberger authored
871 # library name (ph: %n)
872 $string =~ s/(?<!\%)\%n/$name/g;
a6f4a4a @jberger New interpolation: %x --> $^X (current Perl interpreter)
jberger authored
873 # current interpreter ($^X) (ph: %x)
7ad95c7 @jberger use Module::Build's concept of the current interpreter rather that $^X
jberger authored
874 my $perl = $self->perl;
875 $string =~ s/(?<!\%)\%x/$perl/g;
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
876
aa81070 @MidLifeXis Implement interpolation of %v token
MidLifeXis authored
877 # Version, but only if needed. Complain if needed and not yet
878 # stored.
879 if ($string =~ /(?<!\%)\%v/) {
b1da1b4 @MidLifeXis Rename the config variable to be alien specific
MidLifeXis authored
880 my $version = $self->config_data( 'alien_version' );
aa81070 @MidLifeXis Implement interpolation of %v token
MidLifeXis authored
881 if ( ! defined( $version ) ) {
882 carp "Version substution requested but unable to identify";
883 } else {
884 $string =~ s/(?<!\%)\%v/$version/g;
885 }
886 }
887
e760c0e @plicease helper interface
plicease authored
888 $string =~ s/(?<!\%)\%\{([a-zA-Z_][a-zA-Z_0-9]+)\}/$self->_alien_execute_helper($1)/eg;
889
0bd41e4 @jberger a little reorg of code placement, no actual changes
jberger authored
890 #remove escapes (%%)
891 $string =~ s/\%(?=\%)//g;
892
893 return $string;
894 }
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
895
c1fd0be @jberger added alien_main_procedure, this will be called from an overridden AC…
jberger authored
896 sub alien_exec_prefix {
ee1d705 @jberger Fully implement validation mechanism in constructor
jberger authored
897 my $self = shift;
898 if ( $self->is_windowsish ) {
c1fd0be @jberger added alien_main_procedure, this will be called from an overridden AC…
jberger authored
899 return '';
900 } else {
901 return './';
902 }
903 }
904
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
905 sub alien_configure {
906 my $self = shift;
6f9147f @plicease add option alien_autoconf_with_pic
plicease authored
907 my $configure;
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
908 if ($self->config_data( 'msys' )) {
6f9147f @plicease add option alien_autoconf_with_pic
plicease authored
909 $configure = 'sh configure';
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
910 } else {
6f9147f @plicease add option alien_autoconf_with_pic
plicease authored
911 $configure = './configure';
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
912 }
6f9147f @plicease add option alien_autoconf_with_pic
plicease authored
913 if ($self->alien_autoconf_with_pic) {
914 $configure .= ' --with-pic';
915 }
916 $configure;
db7b46b @plicease use Alien::MSYS on windows where autoconf is needed
plicease authored
917 }
918
1b57206 @jberger libdontpanic now provides a .pc file
jberger authored
919 ########################
920 # Post-Build Methods #
921 ########################
922
923 sub alien_load_pkgconfig {
924 my $self = shift;
925
557ca5e @plicease more MSWin32 path fixes
plicease authored
926 my $dir = _catdir($self->config_data( 'working_directory' ));
e964fa6 @jberger ABMB now finds pc files, creates ABPC objects and stores in config_data
jberger authored
927 my $pc_files = $self->rscan_dir( $dir, qr/\.pc$/ );
928
2bbbf04 @jberger pkgconfig config_data now holds hashref (keys are package name) rathe…
jberger authored
929 my %pc_objects = map {
e964fa6 @jberger ABMB now finds pc files, creates ABPC objects and stores in config_data
jberger authored
930 my $pc = Alien::Base::PkgConfig->new($_);
458901a @jberger use pcfiledir rather than alien_dist_dir for future compatibiliy with…
jberger authored
931 $pc->make_abstract( pcfiledir => $dir );
2bbbf04 @jberger pkgconfig config_data now holds hashref (keys are package name) rathe…
jberger authored
932 ($pc->{package}, $pc)
e964fa6 @jberger ABMB now finds pc files, creates ABPC objects and stores in config_data
jberger authored
933 } @$pc_files;
1b57206 @jberger libdontpanic now provides a .pc file
jberger authored
934
fd95d4a @jberger remove unnecessary intermediate var
jberger authored
935 $pc_objects{_manual} = $self->alien_generate_manual_pkgconfig($dir)
7ff2ead @jberger added some warnings aimed at tracking down the missing pkgconfig prob…
jberger authored
936 or croak "Could not autogenerate pkgconfig information";
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
937
938 $self->config_data( pkgconfig => \%pc_objects );
939 return \%pc_objects;
940 }
941
2c10b40 @jberger Refresh autogenerated pkgconfig data after installation
jberger authored
942 sub alien_refresh_manual_pkgconfig {
943 my $self = shift;
944 my ($dir) = @_;
945
946 my $pc_objects = $self->config_data( 'pkgconfig' );
947 $pc_objects->{_manual} = $self->alien_generate_manual_pkgconfig($dir)
948 or croak "Could not autogenerate pkgconfig information";
949
950 $self->config_data( pkgconfig => $pc_objects );
951
952 return 1;
953 }
954
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
955 sub alien_generate_manual_pkgconfig {
956 my $self = shift;
557ca5e @plicease more MSWin32 path fixes
plicease authored
957 my ($dir) = _catdir(shift);
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
958
959 my $paths = $self->alien_find_lib_paths($dir);
960
961 my @L =
557ca5e @plicease more MSWin32 path fixes
plicease authored
962 map { "-L$_" }
963 map { _catdir( '${pcfiledir}', $_ ) }
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
964 @{$paths->{lib}};
965
966 my $provides_libs = $self->alien_provides_libs;
967
968 #if no provides_libs then generate -l list from found files
969 unless ($provides_libs) {
0ac98fb @plicease find_lib to find static lib
plicease authored
970 my @files = map { "-l$_" } @{$paths->{lib_files}};
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
971 $provides_libs = join( ' ', @files );
972 }
973
974 my $libs = join( ' ', @L, $provides_libs );
975
976 my @I =
557ca5e @plicease more MSWin32 path fixes
plicease authored
977 map { "-I$_" }
978 map { _catdir( '${pcfiledir}', $_ ) }
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
979 @{$paths->{inc}};
980
981 my $provides_cflags = $self->alien_provides_cflags;
982 push @I, $provides_cflags if $provides_cflags;
983 my $cflags = join( ' ', @I );
984
9299e04 @jberger generate a _manual A::B::PC object from alien_provides_* rather than …
jberger authored
985 my $manual_pc = Alien::Base::PkgConfig->new({
986 package => $self->alien_name,
987 vars => {
458901a @jberger use pcfiledir rather than alien_dist_dir for future compatibiliy with…
jberger authored
988 pcfiledir => $dir,
9299e04 @jberger generate a _manual A::B::PC object from alien_provides_* rather than …
jberger authored
989 },
990 keywords => {
6401cc8 @jberger Bump version for bugfix release, sorry for the noise CPAN
jberger authored
991 Cflags => $cflags || '',
992 Libs => $libs || '',
993 Version => '',
9299e04 @jberger generate a _manual A::B::PC object from alien_provides_* rather than …
jberger authored
994 },
995 });
996
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
997 return $manual_pc;
998 }
9299e04 @jberger generate a _manual A::B::PC object from alien_provides_* rather than …
jberger authored
999
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1000 sub _alien_file_pattern_dynamic {
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1001 my $self = shift;
1002 my $ext = $self->config('so'); #platform specific .so extension
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1003 return qr/\.[\d.]*(?<=\.)$ext[\d.]*(?<!\.)|(\.h|$ext)$/;
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1004 };
1005
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1006 sub _alien_file_pattern_static {
1007 my $self = shift;
1008 my $ext = quotemeta $self->config('lib_ext');
1009 return qr/(\.h|$ext)$/;
1010 }
1011
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
1012 sub alien_find_lib_paths {
1013 my $self = shift;
1014 my ($dir) = @_;
1015
1016 my $libs = $self->alien_provides_libs;
1017 my @libs;
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1018 @libs = grep { s/^-l// } split /\s+/, $libs if $libs;
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
1019
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1020 my (@lib_files, @lib_paths, @inc_paths);
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
1021
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1022 foreach my $file_pattern ($self->_alien_file_pattern_static, $self->_alien_file_pattern_dynamic) {
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1023
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1024 my @files =
1025 map { File::Spec->abs2rel( $_, $dir ) } # make relative to $dir
1026 grep { ! -d }
1027 @{ $self->_rscan_destdir( $dir, $file_pattern ) };
1d1bf93 @jberger continue to refine the find_libs logic
jberger authored
1028
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1029 for (@files) {
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
1030
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1031 my ($file, $path, $ext) = fileparse( $_, $file_pattern );
1032 next unless $ext; # just in case
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1033
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1034 $path = File::Spec->catdir($path); # remove trailing /
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1035
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1036 if ($ext eq '.h') {
1037 push @inc_paths, $path;
1038 next;
1039 }
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1040
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1041 $file =~ s/^lib//;
1042
1043 if (@libs) {
1044 next unless grep { $file eq $_ } @libs;
1045 }
1046
1047 next if grep { $file eq $_ } @lib_files;
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1048
1e24743 @plicease prefer directory with static .a files for find_lib
plicease authored
1049 push @lib_files, $file;
1050 push @lib_paths, $path;
1051 }
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1052 }
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
1053
0ac98fb @plicease find_lib to find static lib
plicease authored
1054 @lib_files = uniq @lib_files;
1055 @lib_files = sort @lib_files;
8a54f34 @jberger further refine the library detection code
jberger authored
1056
fe912c2 @jberger rework library detection code to avoid false positives when directori…
jberger authored
1057 @lib_paths = uniq @lib_paths;
1058 @inc_paths = uniq @inc_paths;
6dfe833 @jberger Major improvements to the way that the manual pkgconfig data is creat…
jberger authored
1059
0ac98fb @plicease find_lib to find static lib
plicease authored
1060 return { lib => \@lib_paths, inc => \@inc_paths, lib_files => \@lib_files };
1b57206 @jberger libdontpanic now provides a .pc file
jberger authored
1061 }
1062
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
1063 sub alien_refresh_packlist {
1064 my $self = shift;
1065 my $dir = shift || croak "Must specify a directory to include in packlist";
1066
4fd2acd @plicease don't need to update packlist if packlist is turned off
plicease authored
1067 return unless $self->create_packlist;
1068
f80423e @plicease DESTDIR support for library search and packlist
plicease authored
1069 my %installed_args;
1070 $installed_args{extra_libs} = [map { File::Spec->catdir($self->destdir, $_) } @INC]
1071 if defined $self->destdir;
1072
1073 my $inst = ExtUtils::Installed->new( %installed_args );
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
1074 my $packlist = $inst->packlist( $self->module_name );
663bcce @jberger apparently alien_refresh_packlist needs to happen last
jberger authored
1075 print "Using " . $packlist->packlist_file . "\n";
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
1076
1077 my $changed = 0;
f80423e @plicease DESTDIR support for library search and packlist
plicease authored
1078 my $files = $self->_rscan_destdir($dir);
10b3848 @plicease extra commentary
plicease authored
1079 # This is kind of strange, but MB puts the destdir paths in the
1080 # packfile, when arguably it should not. Usually you will want
1081 # to turn off packlists when you you are building an rpm anyway,
1082 # but for the sake of maximum compat with MB we add the destdir
1083 # back in after _rscan_destdir has stripped it out.
f80423e @plicease DESTDIR support for library search and packlist
plicease authored
1084 $files = [ map { File::Spec->catdir($self->destdir, $_) } @$files ]
1085 if defined $self->destdir;
7f35b9c @jberger add some diagnostics and fix one bug
jberger authored
1086 for my $file (@$files) {
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
1087 next if $packlist->{$file};
7f35b9c @jberger add some diagnostics and fix one bug
jberger authored
1088 print "Adding $file to packlist\n";
2bb314e @jberger added alien_refresh_packlist called near the end of ACTION_install
jberger authored
1089 $changed++;
1090 $packlist->{$file}++;
1091 };
1092
1093 $packlist->write if $changed;
1094 }
1095
594dba9 @plicease relocate id in dylib files on os x
plicease authored
1096 sub alien_relocation_fixup {
1097 my($self) = @_;
1098
1099 # so far relocation fixup is only needed on OS X
1100 return unless $^O eq 'darwin';
1101
1102 my $dist_name = $self->dist_name;
985ddfa @plicease direct install should go to arch if alien_arch
plicease authored
1103 my $share = _catdir( $self->install_destination($self->alien_arch ? 'arch' : 'lib'), qw/auto share dist/, $dist_name );
594dba9 @plicease relocate id in dylib files on os x
plicease authored
1104
1105 require File::Find;
1106 File::Find::find(sub {
1107 if(/\.dylib$/)
1108 {
1109 # save the original mode and make it writable
1110 my $mode = (stat $File::Find::name)[2];
1111 chmod 0755, $File::Find::name unless -w $File::Find::name;
1112
1113 my @cmd = (
1114 'install_name_tool',
1115 '-id' => $File::Find::name,
1116 $File::Find::name,
1117 );
1118 print "+ @cmd\n";
1119 system @cmd;
1120
1121 # restore the original permission mode
1122 chmod $mode, $File::Find::name;
1123 }
1124 }, $share);
1125 }
1126
f80423e @plicease DESTDIR support for library search and packlist
plicease authored
1127 sub _rscan_destdir {
1128 my($self, $dir, $pattern) = @_;
1129 my $destdir = $self->destdir;
557ca5e @plicease more MSWin32 path fixes
plicease authored
1130 $dir = _catdir($destdir, $dir) if defined $destdir;
f80423e @plicease DESTDIR support for library search and packlist
plicease authored
1131 my $files = $self->rscan_dir($dir, $pattern);
1132 $files = [ map { s/^$destdir//; $_ } @$files ] if defined $destdir;
1133 $files;
1134 }
1135
557ca5e @plicease more MSWin32 path fixes
plicease authored
1136 # File::Spec uses \ as the file separator on MSWin32, which makes sense
1137 # since it is the default "native" file separator, but in practice / is
1138 # supported everywhere that matters and is significantly less problematic
1139 # in a number of common use cases (e.g. shell quoting). This is a short
1140 # cut _catdir for this rather common pattern where you want catdir with
1141 # / as the file separator on Windows.
1142 sub _catdir {
1143 my $dir = File::Spec->catdir(@_);
1144 $dir =~ s{\\}{/}g if $^O eq 'MSWin32';
1145 $dir;
1146 }
1147
e58bcf5 @jberger Moved Module::Build subclass to Alien::Base::ModuleBuild, this allows…
jberger authored
1148 1;
1149
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1150 __END__
1151 __POD__
1152
1153 =head1 NAME
1154
1155 Alien::Base::ModuleBuild - A Module::Build subclass for building Alien:: modules and their libraries
1156
1157 =head1 SYNOPSIS
1158
94e1452 @plicease documentation improvements
plicease authored
1159 In your Build.PL:
1160
1161 use Alien::Base::ModuleBuild;
1162
1163 my $builder = Alien::Base::Module::Build->new(
1164 module_name => 'Alien::MyLibrary',
1165
1166 configure_requires => {
1167 'Alien::Base' => '0.005',
1168 'Module::Build' => '0.28'
1169 },
1170 requires => {
1171 'Alien::Base' => '0.005',
1172 },
1173
1174 alien_name => 'mylibrary', # the pkg-config name if you want
1175 # to use pkg-config to discover
1176 # system version of the mylibrary
1177
1178 alien_repository => {
1179 protocol => 'http',
1180 host => 'myhost.org',
1181 location => '/path/to/tarballs',
1182 pattern => qr{^mylibrary-([0-9\.]+)\.tar\.gz$},
1183 },
1184
1185 # this is the default:
1186 alien_build_commands => [
1187 "%c --prefix=%s", # %c is a platform independent version of ./configure
1188 "make",
1189 ],
1190
1191 # this is the default for install:
1192 alien_install_commands => [
1193 "make install",
1194 ],
1195
1196 alien_isolate_dynamic => 1,
1197 );
1198
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1199 =head1 DESCRIPTION
1200
94e1452 @plicease documentation improvements
plicease authored
1201 This is a subclass of L<Module::Build>, that with L<Alien::Base> allows
1202 for easy creation of Alien distributions. This module is used during the
1203 build step of your distribution. When properly configured it will
1204
1205 =over 4
1206
1207 =item use pkg-config to find and use the system version of the library
1208
1209 =item download, build and install the library if the system does not provide it
1210
1211 =back
1212
696b1dc @plicease add alien_check_built_version method
plicease authored
1213 =head1 METHODS
1214
1e12796 @jberger fixed typo in documentation
jberger authored
1215 =head2 alien_check_installed_version
696b1dc @plicease add alien_check_built_version method
plicease authored
1216
1217 my $version = $abmb->alien_check_installed_version;
1218
1219 This function determines if the library is already installed as part of
1220 the operating system, and returns the version as a string. If it can't
1221 be detected then it should return empty list.
1222
1223 The default implementation relies on C<pkg-config>, but you will probably
1224 want to override this with your own implementation if the package you are
1225 building does not use C<pkg-config>.
1226
1227 =head2 alien_check_built_version
1228
1229 my $version = $amb->alien_check_built_version;
1230
1231 This function determines the version of the library after it has been
1232 built from source. This function only gets called if the operating
1233 system version can not be found and the package is successfully built.
1234
1235 The default implementation relies on C<pkg-config>, and other huristics,
1236 but you will probably want to override this with your own implementation
1237 if the package you are building does not use C<pkg-config>.
1238
1239 When this method is called, the current working directory will be the
1240 build root.
1241
1242 If you see an error message like this:
1243
1244 Library looks like it installed, but no version was determined
1245
1246 After the package is built from source code then you probably need to
1247 provide an implementation for this method.
1248
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1249 =head1 GUIDE TO DOCUMENTATION
1250
1251 The documentation for C<Module::Build> is broken up into sections:
1252
1253 =over
1254
1255 =item General Usage (L<Module::Build>)
1256
1257 This is the landing document for L<Alien::Base::ModuleBuild>'s parent class.
1258 It describes basic usage and background information.
1259 Its main purpose is to assist the user who wants to learn how to invoke
1260 and control C<Module::Build> scripts at the command line.
1261
1262 It also lists the extra documentation for its use. Users and authors of Alien::
1263 modules should familiarize themselves with these documents. L<Module::Build::API>
1264 is of particular importance to authors.
1265
1266 =item Alien-Specific Usage (L<Alien::Base::ModuleBuild>)
1267
1268 This is the document you are currently reading.
1269
33b5b15 @jberger One more note on A::B::Authoring
jberger authored
1270 =item Authoring Reference (L<Alien::Base::Authoring>)
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1271
1272 This document describes the structure and organization of
1273 C<Alien::Base> based projects, beyond that contained in
1274 C<Module::Build::Authoring>, and the relevant concepts needed by authors who are
1275 writing F<Build.PL> scripts for a distribution or controlling
1276 C<Alien::Base::ModuleBuild> processes programmatically.
33b5b15 @jberger One more note on A::B::Authoring
jberger authored
1277
1278 Note that as it contains information both for the build and use phases of
1279 L<Alien::Base> projects, it is located in the upper namespace.
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1280
1281 =item API Reference (L<Alien::Base::ModuleBuild::API>)
1282
1283 This is a reference to the C<Alien::Base::ModuleBuild> API beyond that contained
1284 in C<Module::Build::API>.
1285
1286 =back
1287
1288 =head1 SEE ALSO
1289
1290 =over
1291
1292 =item *
1293
1294 L<Module::Build>
1295
1296 =item *
1297
1298 L<Alien>
1299
1300 =item *
1301
1302 L<Alien::Base>
1303
1304 =back
1305
1306 =head1 SOURCE REPOSITORY
1307
7412eae @zmughal update repo and issues URL from jberger to Perl5-Alien
zmughal authored
1308 L<http://github.com/Perl5-Alien/Alien-Base>
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1309
1310 =head1 AUTHOR
1311
f3c6dbd @plicease documentation tweaks
plicease authored
1312 Original author: Joel Berger, E<lt>joel.a.berger@gmail.comE<gt>
1313
1314 Current maintainer: Graham Ollis E<lt>plicease@cpan.orgE<gt> and the L<Alien::Base> team
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1315
1316 =head1 COPYRIGHT AND LICENSE
1317
f3c6dbd @plicease documentation tweaks
plicease authored
1318 Copyright (C) 2012-2015 by Joel Berger
4ec79a9 @jberger Added pod to A::B::MB as a landing document for the rest of the docum…
jberger authored
1319
1320 This library is free software; you can redistribute it and/or modify
1321 it under the same terms as Perl itself.
1322
1323 =cut
1324
Something went wrong with that request. Please try again.