Makefile.PL

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Inline/CPP/Parser/RecDescent.pm ↑ Summary blib/lib/Inline/CPP/Config.pm »
1 use ExtUtils::MakeMaker;
2 use ExtUtils::CppGuess;
3 use strict;
4  
5 # The next line is verified via t/13version_numbers.t. Retain single quoting.
6  
7 my $DIST_VERSION = '0.75'; # DRY in Makefile.PL.
8  
9 my $CPP_Config_path = 'lib/Inline/CPP/Config.pm';
10  
11 my %PREREQ_PM = (
12 'Inline' => '0.78',
13 'Inline::C' => '0.78_003', # supports 5.8.1
14 'Parse::RecDescent' => '0',
15 'Carp' => '0',
16 'Config' => '0',
17 );
18  
19 check_prereqs(\%PREREQ_PM) or warn "!!! PREREQUISITES NOT MET !!!";
20  
21 my $guess = ExtUtils::CppGuess->new;
22 my @info = map $guess->$_,
23 qw(compiler_command linker_flags iostream_fname cpp_flavor_defs);
24  
25 $info[0] = prompt("What C++ compiler would you like to use?", $info[0]);
26  
27 $info[1]
28 = prompt("What default libraries would you like to include?", $info[1]);
29  
30 configure_distribution(@info);
31  
32 WriteMakefile(
33 NAME => 'Inline::CPP',
34 AUTHOR => 'David Oswald <davido@cpan.org>',
35 VERSION_FROM => 'lib/Inline/CPP.pm',
36 ABSTRACT_FROM => 'lib/Inline/CPP.pod',
37 LICENSE => 'artistic_2',
38 PREREQ_PM => \%PREREQ_PM,
39 TEST_REQUIRES => {
40 'Test::More' => '1.001009', # Core. Minimum version.
41 'File::Temp' => '0', # Core.
42 'FindBin' => '0', # Core.
43 },
44 CONFIGURE_REQUIRES => {
45 'ExtUtils::CppGuess' => '0.15',
46 'ExtUtils::MakeMaker' => '7.04', # Core.
47 },
48 META_MERGE => {
49 'meta-spec' => {
50 version => 2,
51 url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
52 },
53 no_index => { directory => [ 'inc' ], },
54 resources => {
55 license => 'http://dev.perl.org/licenses/artistic.html',
56 bugtracker => {web=>'http://github.com/daoswald/Inline-CPP/issues'},
57 homepage => 'http://github.com/daoswald/Inline-CPP',
58 repository => {
59 type => 'git',
60 url => 'http://github.com/daoswald/Inline-CPP.git',
61 web => 'http://github.com/daoswald/Inline-CPP',
62 },
63 },
64 provides => {
65 'Inline::CPP' => {
66 file => 'lib/Inline/CPP.pm',
67 version => $DIST_VERSION,
68 },
69 'Inline::CPP::Parser::RecDescent' => {
70 file => 'lib/Inline/CPP/Parser/RecDescent.pm',
71 version => $DIST_VERSION,
72 },
73 'Inline::CPP::Config' => {
74 file => 'lib/Inline/CPP/Config.pm',
75 version => $DIST_VERSION,
76 },
77 },
78 prereqs => {
79 develop => {
80 requires => {
81 'Test::Pod' => '1.00',
82 'Test::Perl::Critic' => 0,
83 'Test::Pod::Coverage' => '1.00',
84 'Test::Kwalitee' => 0,
85 'Test::CPAN::Changes' => 0,
86 'English' => '0',
87 },
88 },
89 },
90 },
91 MIN_PERL_VERSION => '5.008001',
92 test => {RECURSIVE_TEST_FILES => 1},
93 clean => {FILES => join q{ }, $CPP_Config_path, qw{
94 _Inline/ t/_Inline
95 t/classes/_Inline t/grammar/_Inline
96 t/namespace/_Inline Inline-CPP-*/
97 }}, # Paths can be space delimited.
98 );
99  
100 #============================================================================
101 # We'll do our own prerequisite checking, since MakeMaker does it
102 # in a way that always fails: 'use Inline::C 0.33' will never work.
103 #============================================================================
104  
105 sub check_prereqs {
106 my $prereq_pm_href = shift;
107 my $prereqs_ok = 1;
108  
109 for(sort keys %$prereq_pm_href) {
110 ## no critic (eval);
111 eval "require $_";
112  
113 # We eval version numbers to normalize _xxx dev numbering.
114 my $have = eval 'no strict q/refs/; ${"${_}::VERSION"}';
115  
116 use strict q/refs/;
117  
118 my $want = eval $prereq_pm_href->{$_};
119  
120 if($@ || $have < $want) {
121 warn "Warning: prerequisite $_ version $prereq_pm_href->{$_} not found.";
122 $prereqs_ok = 0;
123 }
124 }
125 return $prereqs_ok;
126 }
127  
128  
129 ###############################################################################
130 # Test for appropriate header style.
131 # Configure distribution defaults in Inline::CPP::Config.pm.
132 ###############################################################################
133  
134 sub to_file {
135 my ($file, @data) = @_;
136 open my $fh, '>', $file
137 or die "Makefile.PL: Couldn't open $file for output: $!\n";
138 print $fh @data or die "Makefile.PL: Couldn't write $file: $!\n";
139 close $fh or die "Makefile.PL: Couldn't close $file: $!\n";
140 }
141  
142 sub from_file {
143 my ($file) = @_;
144 local $/;
145 open my $fh, '<', $file or die "Makefile.PL: Can't read from $file: $!";
146 <$fh>;
147 }
148  
149 sub configure_distribution {
150 my( $cpp_compiler, $libs, $iostream_fname, $cpp_flavor_defs ) = @_;
151 # Apply the distribution defaults:
152 my $text = from_file("$CPP_Config_path.in");
153 to_file $CPP_Config_path, sprintf $text,
154 $DIST_VERSION,
155 $cpp_compiler,
156 $libs,
157 $iostream_fname,
158 $cpp_flavor_defs,
159 ;
160 }
« blib/lib/Inline/CPP/Parser/RecDescent.pm ↑ Summary blib/lib/Inline/CPP/Config.pm »