Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 122 lines (108 sloc) 3.859 kB
4441d2c first commit
Tobias Leich authored
1 use strict;
2 use warnings;
3
4 use lib "inc";
5 use File::Spec::Functions qw(catdir catfile);
6 use My::Utility qw(check_config_script check_prebuilt_binaries check_src_build);
7
8 #### we need the platform-specific module
9 my %platforms =(
10 # Unix = default, thus not listing all UNIX like systems
11 MSWin32 => 'Windows',
12 );
13 my $package = 'My::Builder::' . ($platforms{$^O} || 'Unix');
14 print "Gonna use '$package' class ...\n";
15 eval "require $package" or die "Require '$package' failed: $@\n";
16
17 #### Stadard Module::Builder stuff
18 my $build = $package->new(
19 module_name => 'Alien::PNG',
20 all_from => 'lib/Alien/PNG.pm',
21 dist_abstract => 'Get, Build and Use PNG libraries',
22 dist_author => 'Tobias Leich <FROGGS@cpan.org>',
23 license => 'perl',
24 requires => {
25 'File::Spec' => '0',
26 'File::Temp' => '0',
27 'File::ShareDir' => '0',
28 'ExtUtils::CBuilder' => '0',
29 },
30 build_requires => { #need to have for running: ./Build (install|test)
31 'File::Spec' => '0',
32 'File::Temp' => '0',
33 'File::ShareDir' => '0',
34 'ExtUtils::CBuilder' => '0',
35 'File::Path' => '2.07',
36 'File::Fetch' => '0',
37 'File::Find' => '0',
38 'Digest::SHA' => '0',
39 'Archive::Extract' => '0',
40 'Archive::Tar' => '0',
41 'Archive::Zip' => '0',
42 'Module::Build' => '0.36',
43 },
44 configure_requires => { #need to have for running: perl Buil.PL
45 'File::Spec' => '0',
46 'File::Path' => '2.07',
47 'File::Fetch' => '0',
48 'File::Find' => '0',
49 'Digest::SHA' => '0',
50 'Archive::Extract' => '0',
51 'Module::Build' => '0.36',
52 },
53 meta_merge => {
54 resources => {
55 bugtracker => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=Alien-PNG',
20f25c6 fixed repo url
Tobias Leich authored
56 repository => 'http://github.com/FROGGS/Alien_PNG'
4441d2c first commit
Tobias Leich authored
57 }
58 },
59 create_readme => 1,
60 share_dir => 'sharedir',
61 # sharedir is used for storing compiled/prebuilt binaries of PNG lib + related libraries
62 # avoid using 'share' name as M::B doe not handle well paths like /xx/yy/share/zz/ww/share/xx
63 );
64 $build->create_build_script();
65
66 #### clean build_done stamp; force rebuild when running 'Build'
67 $build->clean_build_done_marker;
68
69 print "\nWelcome to Alien::PNG module installation";
70 print "\n-----------------------------------------\n\n";
71
72 #### check what options we have for our platform
73 my $rv; my @candidates = ();
74
75 if(defined($ENV{PNG_INST_DIR})) {
76 print "Gonna use PNG_INST_DIR environment variable...\n";
77 print "(PNG_INST_DIR=$ENV{PNG_INST_DIR})\n";
78 if (-d $ENV{PNG_INST_DIR}) {
79 my @pnginst = File::Spec->splitdir($ENV{PNG_INST_DIR});
80 if($rv=check_config_script(File::Spec->catdir(@pnginst, 'bin', 'libpng-config'))) {
81 push @candidates, $rv;
82 }
83 elsif($rv=check_config_script(File::Spec->catdir(@pnginst, 'libpng-config'))) {
84 push @candidates, $rv;
85 }
86 }
87 else {
88 warn "###WARN### Non-existing directory '$ENV{PNG_INST_DIR}' - skipping";
89 }
90 }
91
92 if($rv=check_config_script("libpng-config")) {
93 push @candidates, $rv;
94 };
95
96 if($rv=check_prebuilt_binaries($build->os_type)) {
97 push @candidates, @{$rv};
98 };
99
100 if(($rv=check_src_build($build->os_type)) && $build->can_build_binaries_from_sources()) {
101 push @candidates, @{$rv};
102 };
103
104 push @candidates, { title => 'Quit installation' };
105
106 #### ask user what way to go
107 my $i = 1;
108 my $prompt_string = "\nYou have the following options:\n";
109 foreach my $c (@candidates) {
110 $prompt_string .= "[" . $i++ . "] " . $c->{title} . "\n"
111 }
112 $prompt_string .= "\nWhat way do you wanna go?";
113 my $ans = $build->prompt($prompt_string, 1);
114
115 #### store build params into 'notes'
116 if(($ans>0) && ($ans<scalar(@candidates))) {
117 $build->notes('build_params', $candidates[$ans-1]);
118 }
119 else {
120 $build->notes('build_params', undef); # just to be sure
121 }
Something went wrong with that request. Please try again.