| 1 |
#!/usr/bin/perl |
| 2 |
# Copyright 2022 Jeffrey Kegler |
| 3 |
# This file is part of Marpa::R2. Marpa::R2 is free software: you can |
| 4 |
# redistribute it and/or modify it under the terms of the GNU Lesser |
| 5 |
# General Public License as published by the Free Software Foundation, |
| 6 |
# either version 3 of the License, or (at your option) any later version. |
| 7 |
# |
| 8 |
# Marpa::R2 is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
# Lesser General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU Lesser |
| 14 |
# General Public License along with Marpa::R2. If not, see |
| 15 |
# http://www.gnu.org/licenses/. |
| 16 |
|
| 17 |
use 5.010001; |
| 18 |
use strict; |
| 19 |
use warnings; |
| 20 |
use Fatal qw(open close mkdir chdir); |
| 21 |
use File::Spec 0.82; |
| 22 |
use IPC::Cmd; |
| 23 |
use English qw( -no_match_vars ); |
| 24 |
|
| 25 |
use Config; |
| 26 |
use Module::Build; |
| 27 |
|
| 28 |
use lib File::Spec->catdir('inc'); |
| 29 |
use Marpa::R2::Build_Me; |
| 30 |
use Marpa::R2::Config; |
| 31 |
|
| 32 |
my @packages_for_perl_autoconf = qw( Config::AutoConf ); |
| 33 |
my @always_required = qw( |
| 34 |
Carp |
| 35 |
Cwd |
| 36 |
Data::Dumper |
| 37 |
DynaLoader |
| 38 |
English |
| 39 |
Exporter |
| 40 |
ExtUtils::CBuilder |
| 41 |
ExtUtils::MakeMaker |
| 42 |
ExtUtils::Manifest |
| 43 |
ExtUtils::Mkbootstrap |
| 44 |
Fatal |
| 45 |
File::Copy |
| 46 |
File::Spec |
| 47 |
IPC::Cmd |
| 48 |
List::Util |
| 49 |
PPI |
| 50 |
Scalar::Util |
| 51 |
Test::More |
| 52 |
Time::Piece |
| 53 |
XSLoader |
| 54 |
); |
| 55 |
|
| 56 |
my %configure_requires = |
| 57 |
map { ( $_, $Marpa::R2::VERSION_FOR_CONFIG{$_} ) } |
| 58 |
qw( CPAN::Meta::Converter Module::Build ), |
| 59 |
@always_required, |
| 60 |
@packages_for_perl_autoconf; |
| 61 |
$configure_requires{perl} = '5.010001'; |
| 62 |
|
| 63 |
my %requires = |
| 64 |
map { ( $_, $Marpa::R2::VERSION_FOR_CONFIG{$_} ) } |
| 65 |
qw( HTML::Entities HTML::Parser ), |
| 66 |
@always_required; |
| 67 |
$requires{perl} = '5.010001'; |
| 68 |
|
| 69 |
my %recommends = |
| 70 |
map { ( $_, $Marpa::R2::VERSION_FOR_CONFIG{$_} ) } |
| 71 |
( @packages_for_perl_autoconf, qw( PPI ) ); |
| 72 |
|
| 73 |
my %pod_files = (); |
| 74 |
{ |
| 75 |
local $RS = undef; |
| 76 |
open my $manifest_fh, q{<}, 'MANIFEST'; |
| 77 |
my @pod_files = split /\n/xms, $manifest_fh->getline(); |
| 78 |
close $manifest_fh; |
| 79 |
LINE: for my $pod_file (@pod_files) { |
| 80 |
$pod_file =~ s/ \s* [#] .* \z //xms; |
| 81 |
next LINE if not $pod_file =~ / [.] pod \z /xms; |
| 82 |
next LINE if $pod_file =~ m{ libmarpa [/] dev [/] old_pod [/] }xms; |
| 83 |
if ( ( my $destfile = $pod_file ) |
| 84 |
=~ s{ \A pod [/] }{lib/Marpa/R2/}xms ) |
| 85 |
{ |
| 86 |
$pod_files{$pod_file} = $destfile; |
| 87 |
next LINE; |
| 88 |
} ## end if ( ( my $destfile = $pod_file ) =~ ...) |
| 89 |
if ( ( my $destfile = $pod_file ) |
| 90 |
=~ s{ \A html [/] pod [/] }{lib/Marpa/R2/}xms ) |
| 91 |
{ |
| 92 |
$pod_files{$pod_file} = $destfile; |
| 93 |
next LINE; |
| 94 |
} ## end if ( ( my $destfile = $pod_file ) =~ ...) |
| 95 |
die "Failed to rename POD file: $pod_file"; |
| 96 |
} ## end LINE: for my $pod_file (@pod_files) |
| 97 |
} |
| 98 |
$pod_files{'pod/Marpa_R2.pod'} = 'lib/Marpa/R2.pod'; |
| 99 |
$pod_files{'html/pod/HTML.pod'} = 'lib/Marpa/R2/HTML.pod'; |
| 100 |
|
| 101 |
my %pm_files = (); |
| 102 |
File::Find::find( |
| 103 |
sub { |
| 104 |
return if not m/[.]pm \z/xms; |
| 105 |
$pm_files{$File::Find::name} = $File::Find::name; |
| 106 |
}, |
| 107 |
'lib' |
| 108 |
); |
| 109 |
File::Find::find( |
| 110 |
sub { |
| 111 |
return if not m/[.]pm \z/xms; |
| 112 |
my ( $vol, $dirs, $file ) = File::Spec->splitpath($File::Find::name); |
| 113 |
my @dirs = File::Spec->splitdir($dirs); |
| 114 |
my $dest_dirs = File::Spec->catdir( @dirs[ 1 .. $#dirs ] ); |
| 115 |
my $dest_name = File::Spec->catpath( $vol, $dest_dirs, $file ); |
| 116 |
$pm_files{$File::Find::name} = $dest_name; |
| 117 |
}, |
| 118 |
'html/lib' |
| 119 |
); |
| 120 |
for my $pm_file (qw(Version.pm Installed.pm)) { |
| 121 |
my $pm_fullname = 'lib/Marpa/R2/' . $pm_file; |
| 122 |
$pm_files{$pm_fullname} = $pm_fullname; |
| 123 |
} |
| 124 |
|
| 125 |
my @no_index_namespace_inclusive = qw( |
| 126 |
Marpa::R2::HTML |
| 127 |
Marpa::R2::Value |
| 128 |
Marpa::R2::Perl |
| 129 |
Marpa::R2::Test |
| 130 |
Marpa::R2::Display |
| 131 |
Marpa::R2::Inner |
| 132 |
Marpa::R2::Internal |
| 133 |
Marpa::R2::MetaAST |
| 134 |
Marpa::R2::MetaG |
| 135 |
Marpa::R2::Stuifzand |
| 136 |
); |
| 137 |
|
| 138 |
my @files_to_cleanup = ( |
| 139 |
'lib/Marpa/R2/Version.pm', 'pperl/Marpa/R2/Perl/Version.pm', |
| 140 |
'lib/Marpa/R2/Installed.pm', 'pperl/Marpa/R2/Perl/Installed.pm', |
| 141 |
'lib/Marpa/R2.o', 'libmarpa_build' |
| 142 |
); |
| 143 |
|
| 144 |
my $build = Marpa::R2::Build_Me->new( |
| 145 |
add_to_cleanup => \@files_to_cleanup, |
| 146 |
module_name => 'Marpa::R2', |
| 147 |
dist_author => 'Jeffrey Kegler', |
| 148 |
dist_abstract => 'Release 2 of Marpa', |
| 149 |
recommends => \%recommends, |
| 150 |
requires => \%requires, |
| 151 |
configure_requires => \%configure_requires, |
| 152 |
dynamic_config => 1, |
| 153 |
PL_files => {}, |
| 154 |
pm_files => \%pm_files, |
| 155 |
script_files => [ |
| 156 |
'html/script/marpa_r2_html_fmt', |
| 157 |
'html/script/marpa_r2_html_score', |
| 158 |
], |
| 159 |
xs_files => { 'xs/R2.xs' => 'lib/Marpa/R2.xs' }, |
| 160 |
meta_add => { |
| 161 |
no_index => { |
| 162 |
directory => [ |
| 163 |
qw( pperl tool libmarpa author.t |
| 164 |
html/etc html/sandbox html/script html/t |
| 165 |
) |
| 166 |
], |
| 167 |
namespace => [ |
| 168 |
'Marpa::R2::Recognizer', 'Marpa::R2::Grammar', |
| 169 |
@no_index_namespace_inclusive |
| 170 |
], |
| 171 |
package => |
| 172 |
[ @no_index_namespace_inclusive, 'Marpa::R2::Thin::Trace' ], |
| 173 |
} |
| 174 |
}, |
| 175 |
meta_merge => { |
| 176 |
resources => { |
| 177 |
homepage => 'http://savage.net.au/Marpa.html', |
| 178 |
repository => 'git://github.com/jeffreykegler/Marpa--R2.git', |
| 179 |
IRC => 'irc://irc.freenode.net/#marpa', |
| 180 |
x_IRC => { |
| 181 |
irc => 'irc://irc.freenode.net/#marpa', |
| 182 |
web => 'http://webchat.freenode.net/?channels=%23marpa&uio=d4' |
| 183 |
}, |
| 184 |
}, |
| 185 |
}, |
| 186 |
pod_files => \%pod_files, |
| 187 |
license => 'lgpl3', |
| 188 |
create_readme => 0, |
| 189 |
|
| 190 |
test_files => [ map { glob $_ } qw(t/*.t html/t/*.t) ], |
| 191 |
getoptions => { Dev => {}, 'Marpa-debug' => {} }, |
| 192 |
); |
| 193 |
|
| 194 |
$build->create_build_script; |
| 195 |
|
| 196 |
# vim: expandtab shiftwidth=4: |