| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Alien::FreeImage; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 31297 | use warnings; | 
|  | 2 |  |  |  |  | 6 |  | 
|  | 2 |  |  |  |  | 66 |  | 
| 4 | 2 |  |  | 2 |  | 10 | use strict; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 37 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 2 |  |  | 2 |  | 747 | use Alien::FreeImage::ConfigData; | 
|  | 2 |  |  |  |  | 31 |  | 
|  | 2 |  |  |  |  | 77 |  | 
| 7 | 2 |  |  | 2 |  | 896 | use File::ShareDir qw(dist_dir); | 
|  | 2 |  |  |  |  | 10404 |  | 
|  | 2 |  |  |  |  | 155 |  | 
| 8 | 2 |  |  | 2 |  | 933 | use File::Spec::Functions qw(catdir); | 
|  | 2 |  |  |  |  | 1520 |  | 
|  | 2 |  |  |  |  | 391 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | =head1 NAME | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | Alien::FreeImage - Building freeimage library L | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =cut | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | our $VERSION = '1.001'; | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | This module is not a perl binding for I library; it is just a helper module that makes dev files (*.h, *.a) | 
| 21 |  |  |  |  |  |  | available for linking by other modules. | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | Alien::FreeImage installation comprise of these steps: | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =over | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =item * Build B static library (*.a) from source codes (that are bundled with this module) | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | =item * Install dev files (*.h, *.a) into I directory of Alien::FreeImage distribution | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | =back | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | Later on you can use Alien::FreeImage in your module that needs to link with I like this: | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | # Sample Makefile.PL | 
| 36 |  |  |  |  |  |  | use ExtUtils::MakeMaker; | 
| 37 |  |  |  |  |  |  | use Alien::FreeImage; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | WriteMakefile( | 
| 40 |  |  |  |  |  |  | NAME         => 'Any::FreeImage::Module', | 
| 41 |  |  |  |  |  |  | VERSION_FROM => 'lib/Any/FreeImage/Module.pm', | 
| 42 |  |  |  |  |  |  | LIBS         => Alien::FreeImage->config('LIBS'), | 
| 43 |  |  |  |  |  |  | INC          => Alien::FreeImage->config('INC'), | 
| 44 |  |  |  |  |  |  | # + additional params | 
| 45 |  |  |  |  |  |  | ); | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | =head1 METHODS | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head2 config() | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | This function is the main public interface to this module. | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | Alien::FreeImage->config('LIBS'); | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | Returns a string like: '-L/path/to/freeimage/dir -lfreeimage' | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | Alien::FreeImage->config('INC'); | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | Returns a string like: '-I/path/to/freeimage/dir' | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | Alien::FreeImage->config('PREFIX'); | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | Returns a string like: '/path/to/freeimage/dir' | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | =head1 LICENSE | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | 2014+ KMX Ekmx@cpan.orgE | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =cut | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | sub config | 
| 76 |  |  |  |  |  |  | { | 
| 77 | 8 |  |  | 8 | 1 | 610 | my ($package, $param) = @_; | 
| 78 | 8 | 50 |  |  |  | 35 | return unless ($param =~ /[a-z0-9_]*/i); | 
| 79 | 8 |  |  |  |  | 28 | my $subdir = Alien::FreeImage::ConfigData->config('share_subdir'); | 
| 80 | 8 |  |  |  |  | 25 | my $share_dir = dist_dir('Alien-FreeImage'); | 
| 81 | 8 |  |  |  |  | 653 | my $real_prefix = catdir($share_dir, $subdir); | 
| 82 | 8 |  |  |  |  | 25 | my $val = Alien::FreeImage::ConfigData->config('config')->{$param}; | 
| 83 | 8 | 50 |  |  |  | 26 | return unless $val; | 
| 84 | 8 |  |  |  |  | 34 | $val =~ s/\@PrEfIx\@/$real_prefix/g; # handle @PrEfIx@ replacement | 
| 85 | 8 |  |  |  |  | 129 | return $val; | 
| 86 |  |  |  |  |  |  | } | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | 1; |