| 1 | 1 | ▶ | use alienfile; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use Path::Tiny qw( path ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | # Because bzip2 does not come with a pkg-config compatible .pc file | ||
| 5 | # we use the CBuilder plugin to guess the appropriate flags | ||
| 6 | # (usually just libs=-lbz2): | ||
| 7 | 1 | plugin 'Probe::CBuilder' => ( | |
| 8 | libs => '-lbz2', | ||
| 9 | |||
| 10 | # The version regex here will attempt to parse out the | ||
| 11 | # bzip2 version number from the output of the test program below. | ||
| 12 | version => qr/version = '(.*?)[,']/, | ||
| 13 | |||
| 14 | # Both the test program and the version regex are optional, but | ||
| 15 | # if you do not provide them, then you should provide a | ||
| 16 | # sys { gather } declaration for how to obtain the version number. | ||
| 17 | # assuming the version number matters. | ||
| 18 | program => q{ | ||
| 19 | #include <stdio.h> | ||
| 20 | #include <bzlib.h> | ||
| 21 | |||
| 22 | int main(int argc, char *argv[]) | ||
| 23 | { | ||
| 24 | printf("version = '%s'\n", BZ2_bzlibVersion()); | ||
| 25 | return 0; | ||
| 26 | } | ||
| 27 | }, | ||
| 28 | ); | ||
| 29 | |||
| 30 | # in addition to the library, we require that the bzip2 command | ||
| 31 | # is also available. | ||
| 32 | 1 | plugin 'Probe::CommandLine' => ( | |
| 33 | command => 'bzip2', | ||
| 34 | secondary => 1, | ||
| 35 | ); | ||
| 36 | |||
| 37 | 1 | ▶ | share { |
|
Subroutine
__ANON__: called CC=1 SCAR=2.0
| |||
| 38 | |||
| 39 | # items in the share block relate to building the package | ||
| 40 | # from source. It is called share because it will be | ||
| 41 | # installed into a dist level share directory in your | ||
| 42 | # perl lib. | ||
| 43 | |||
| 44 | # The Build::MSYS plugin just makes sure that Alien::MSYS | ||
| 45 | # is used to provide the necessary tools on Windows. It | ||
| 46 | # doesn't do anything on other platforms. | ||
| 47 | 1 | plugin 'Build::MSYS'; | |
| 48 | |||
| 49 | # The Download negotiator picks the best method for | ||
| 50 | # downloading the package. | ||
| 51 | 1 | plugin 'Download' => ( | |
| 52 | url => 'https://sourceforge.net/projects/bzip2/files/latest/download', | ||
| 53 | ); | ||
| 54 | |||
| 55 | # The Extract negotiator picks the best method for | ||
| 56 | # extracting from the tarball. We give it a hint | ||
| 57 | # here that we expect the tarball to be .gz compressed | ||
| 58 | # in case it needs to load extra modules to | ||
| 59 | # decompress. | ||
| 60 | 1 | plugin Extract => 'tar.gz'; | |
| 61 | |||
| 62 | # The build stage here is specified as a series of commands. | ||
| 63 | # bzip2 uses make to build and install. It is vital that we | ||
| 64 | # include cccdlflags in the compiler flags, because this will | ||
| 65 | # include any flags necessary for making the library relocatable | ||
| 66 | # which we need to link into a Perl XS .so file. | ||
| 67 | # We also use CC=$Config{cc} to make sure that we use the | ||
| 68 | # same compiler as was used to build Perl. | ||
| 69 | build [ | ||
| 70 | [ '%{make}', 'all', "CC=%{perl.config.cc}", "CFLAGS=%{perl.config.cccdlflags} %{perl.config.optimize}", ], | ||
| 71 | [ '%{make}', 'install', 'PREFIX=%{.install.prefix}', ], | ||
| 72 | |||
| 73 | # we can use a code ref here to determine the version number of | ||
| 74 | # bzip2 from the directory that is extracted from the tarball. | ||
| 75 | # Usually this is something like bzip2-1.0.6 and we just parse | ||
| 76 | # off the bit that looks like a version number. | ||
| 77 | 0 | ▶ | sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 78 | 0 | my($build) = @_; | |
| 79 | 0 | my($version) = path(".")->absolute->basename =~ /([0-9\.]+)$/; | |
| 80 | 0 | $build->runtime_prop->{version} = $version; | |
| 81 | }, | ||
| 82 | 1 | ]; | |
| 83 | |||
| 84 | # This package doesn't build a dynamic library by default, but if | ||
| 85 | # it did this would make sure that it wasn't used with XS. | ||
| 86 | # (See Alien::Build::Manual::AlienAuthor for details). | ||
| 87 | 1 | plugin 'Gather::IsolateDynamic'; | |
| 88 | |||
| 89 | # The gather stage determines the appropriate cflags and libs for | ||
| 90 | # using the library that we just built. | ||
| 91 | 0 | ▶ | gather sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 92 | 0 | my($build) =@_; | |
| 93 | 0 | my $prefix = $build->runtime_prop->{prefix}; | |
| 94 | 0 | $build->runtime_prop->{cflags} = "-I$prefix/include"; | |
| 95 | 0 | $build->runtime_prop->{cflags_static} = "-I$prefix/include"; | |
| 96 | 0 | $build->runtime_prop->{libs} = "-L$prefix/lib -lbz2"; | |
| 97 | 0 | $build->runtime_prop->{libs_static} = "-L$prefix/lib -lbz2"; | |
| 98 | 1 | }; | |
| 99 | |||
| 100 | 1 | }; | |