File Coverage

Makefile.PL
Criterion Covered Total %
statement 7 74 9.4
branch 0 48 0.0
condition 0 12 0.0
subroutine 3 8 37.5
pod n/a
total 10 142 7.0


line stmt bran cond sub pod time code
1             # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2              
3 1     1   392 use strict;
  1         2  
  1         34  
4 1     1   832 use ExtUtils::MakeMaker qw(WriteMakefile);
  1         108699  
  1         1335  
5             # See lib/ExtUtils/MakeMaker.pm for details of how to influence
6             # the contents of the Makefile that is written.
7              
8             # Normalize version strings like 6.30_02 to 6.3002,
9             # so that we can do numerical comparisons on it.
10             my $eumm_version = $ExtUtils::MakeMaker::VERSION;
11             $eumm_version =~ s/_//;
12              
13             my $module = 'Win32::Wlan';
14             (my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
15             (my $distbase = $module) =~ s!::!-!g;
16             my $distlink = $distbase;
17              
18             my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
19              
20             my %module = (
21             NAME => $module,
22             AUTHOR => q{Max Maischein },
23             VERSION_FROM => $main_file,
24             ABSTRACT_FROM => $main_file,
25             META_MERGE => {
26             "meta-spec" => { version => 2 },
27             resources => {
28             repository => {
29             web => "https://github.com/Corion/$distlink",
30             url => "git://github.com/Corion/$distlink.git",
31             type => 'git',
32             },
33             bugtracker => "https://rt.cpan.org/Public/Dist/Display.html?Name=$distbase",
34             license => "https://dev.perl.org/licenses/",
35             },
36             dynamic_config => 0, # we promise to keep META.* up-to-date
37             x_static_install => 1, # we are pure Perl and don't do anything fancy
38             },
39              
40             MIN_PERL_VERSION => '5.008', # use constant;
41              
42             'LICENSE'=> 'perl',
43              
44             PL_FILES => {},
45             BUILD_REQUIRES => {
46             'ExtUtils::MakeMaker' => 0,
47             },
48              
49             PREREQ_PM => {
50             'Encode' => 0,
51             'Win32::API' => 0,
52             },
53             TEST_REQUIRES => {
54             'Test::More' => 0,
55             'Data::Dumper' => 0,
56             },
57              
58             dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
59             clean => { FILES => "$distbase-*" },
60              
61             test => { TESTS => join( ' ', @tests ) },
62             );
63              
64             # This is so that we can do
65             # require 'Makefile.PL'
66             # and then call get_module_info
67              
68 1     1   13 sub get_module_info { %module }
69              
70             if( ! caller ) {
71             # I should maybe use something like Shipwright...
72             regen_README($main_file);
73             regen_EXAMPLES() if -d 'examples';
74             WriteMakefile1(get_module_info);
75             };
76              
77             1;
78              
79             sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
80 0     0     my %params=@_;
81 0           my $eumm_version=$ExtUtils::MakeMaker::VERSION;
82 0           $eumm_version=eval $eumm_version;
83 0 0         die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
84 0 0         die "License not specified" if not exists $params{LICENSE};
85 0 0 0       if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
86             #EUMM 6.5502 has problems with BUILD_REQUIRES
87 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
  0            
  0            
88 0           delete $params{BUILD_REQUIRES};
89             }
90 0 0 0       if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
91 0 0         $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
  0            
  0            
92 0           delete $params{TEST_REQUIRES};
93             }
94 0 0         delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
95 0 0         delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
96 0 0         delete $params{META_MERGE} if $eumm_version < 6.46;
97 0 0         delete $params{META_ADD} if $eumm_version < 6.46;
98 0 0         delete $params{LICENSE} if $eumm_version < 6.31;
99 0 0         delete $params{AUTHOR} if $] < 5.005;
100 0 0         delete $params{ABSTRACT_FROM} if $] < 5.005;
101 0 0         delete $params{BINARY_LOCATION} if $] < 5.005;
102              
103 0           WriteMakefile(%params);
104             }
105              
106             sub regen_README {
107             # README is the short version that just tells people what this is
108             # and how to install it
109 0     0     eval {
110             # Get description
111 0           my $readme = join "\n",
112             pod_section($_[0], 'NAME', 'no heading' ),
113             pod_section($_[0], 'DESCRIPTION' ),
114             <
115              
116             INSTALLATION
117              
118             This is a Perl module distribution. It should be installed with whichever
119             tool you use to manage your installation of Perl, e.g. any of
120              
121             cpanm .
122             cpan .
123             cpanp -i .
124              
125             Consult https://www.cpan.org/modules/INSTALL.html for further instruction.
126             Should you wish to install this module manually, the procedure is
127              
128             perl Makefile.PL
129             make
130             make test
131             make install
132              
133             INSTALL
134             pod_section($_[0], 'REPOSITORY'),
135             pod_section($_[0], 'SUPPORT'),
136             pod_section($_[0], 'TALKS'),
137             pod_section($_[0], 'KNOWN ISSUES'),
138             pod_section($_[0], 'BUG TRACKER'),
139             pod_section($_[0], 'CONTRIBUTING'),
140             pod_section($_[0], 'SEE ALSO'),
141             pod_section($_[0], 'AUTHOR'),
142             pod_section($_[0], 'LICENSE' ),
143             pod_section($_[0], 'COPYRIGHT' ),
144             ;
145 0           update_file( 'README', $readme );
146             };
147             # README.mkdn is the documentation that will be shown as the main
148             # page of the repository on Github. Hence we recreate the POD here
149             # as Markdown
150 0           eval {
151 0           require Pod::Markdown;
152              
153 0           my $parser = Pod::Markdown->new();
154              
155             # Read POD from Module.pm and write to README
156 0           $parser->parse_from_file($_[0]);
157 0           my $readme_mkdn = <as_markdown;
158              
159             [![Travis Build Status](https://travis-ci.org/Corion/$distlink.svg?branch=master)](https://travis-ci.org/Corion/$distlink)
160             [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Corion/$distlink?branch=master&svg=true)](https://ci.appveyor.com/project/Corion/$distlink)
161              
162             STATUS
163 0           update_file( 'README.mkdn', $readme_mkdn );
164             };
165             }
166              
167             sub pod_section {
168 0     0     my( $filename, $section, $remove_heading ) = @_;
169 0 0         open my $fh, '<', $filename
170             or die "Couldn't read '$filename': $!";
171              
172             my @section =
173 0           grep { /^=head1\s+$section/.../^=/ } <$fh>;
  0            
174              
175             # Trim the section
176 0 0         if( @section ) {
177 0 0         pop @section if $section[-1] =~ /^=/;
178 0 0         shift @section if $remove_heading;
179              
180             pop @section
181 0   0       while @section and $section[-1] =~ /^\s*$/;
182             shift @section
183 0   0       while @section and $section[0] =~ /^\s*$/;
184             };
185              
186 0           @section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
  0            
  0            
187 0           return join "", @section;
188             }
189              
190             sub regen_EXAMPLES {
191 0     0     my $perl = $^X;
192 0 0         if ($perl =~/\s/) {
193 0           $perl = qq{"$perl"};
194             };
195 0           (my $example_file = $main_file) =~ s!\.pm$!/Examples.pm!;
196 0           my $examples = `$perl -w examples/gen_examples_pod.pl`;
197 0 0         if ($examples) {
198 0           warn "(Re)Creating $example_file\n";
199 0           $examples =~ s/\r\n/\n/g;
200 0           update_file( $example_file, $examples );
201             };
202             };
203              
204             sub update_file {
205 0     0     my( $filename, $new_content ) = @_;
206 0           my $content;
207 0 0         if( -f $filename ) {
208 0 0         open my $fh, '<', $filename
209             or die "Couldn't read '$filename': $!";
210 0           binmode $fh;
211 0           local $/;
212 0           $content = <$fh>;
213             };
214              
215 0 0         if( $content ne $new_content ) {
216 0 0         if( open my $fh, '>', $filename ) {
217 0           binmode $fh;
218 0           print $fh $new_content;
219             } else {
220 0           warn "Couldn't (re)write '$filename': $!";
221             };
222             };
223             }