]> git.vpit.fr Git - perl/modules/re-engine-Hooks.git/blob - Makefile.PL
Update VPIT::TestHelpers to 15e8aee3
[perl/modules/re-engine-Hooks.git] / Makefile.PL
1 use 5.010_001;
2
3 use strict;
4 use warnings;
5 use ExtUtils::MakeMaker;
6
7 my $dist = 're-engine-Hooks';
8
9 (my $name = $dist) =~ s{-}{::}g;
10
11 (my $file = $dist) =~ s{-}{/}g;
12 $file = "lib/$file.pm";
13
14 my %PREREQ_PM = (
15  'Carp'       => 0,
16  'DynaLoader' => 0,
17 );
18
19 my %BUILD_REQUIRES = (
20  'ExtUtils::Depends'   => 0,
21  'ExtUtils::MakeMaker' => 0,
22  'File::Spec'          => 0,
23  'POSIX'               => 0,
24  'Test::More'          => 0,
25  'blib'                => 0,
26  %PREREQ_PM,
27 );
28
29 my %META = (
30  configure_requires => {
31   'ExtUtils::Depends'   => 0,
32   'ExtUtils::MakeMaker' => 0,
33   'File::Spec'          => 0,
34  },
35  build_requires => {
36   %BUILD_REQUIRES,
37  },
38  dynamic_config => 1,
39  resources => {
40   bugtracker => "http://rt.cpan.org/Dist/Display.html?Name=$dist",
41   homepage   => "http://search.cpan.org/dist/$dist/",
42   license    => 'http://dev.perl.org/licenses/',
43   repository => "http://git.profvince.com/?p=perl%2Fmodules%2F$dist.git",
44  },
45 );
46
47 my $latest_dev_rev = 23;
48
49 sub is_outdated_dev_perl {
50  my ($rev) = "$]" =~ /^5\.([0-9]{2}[13579])/;
51
52  return unless defined $rev;
53
54  return $rev < $latest_dev_rev;
55 }
56
57 if (is_outdated_dev_perl) {
58  print STDERR <<EOF;
59      This version of perl ($]) is an outdated development release.
60      re::engine::Hooks supports all stable releases since 5.10.1, and
61      development releases after 5.$latest_dev_rev.0 only.
62      Please consider upgrading your perl to a more recent release.
63 EOF
64  exit 0;
65 }
66
67 sub versioned_file {
68  my ($file) = @_;
69
70  my $version = "$]";
71  $version    =~ s/\.//g;
72  my $len     = length $version;
73  if ($len > 7) {
74   die "Invalid perl version";
75  } else {
76   $version .= '0' x (7 - $len);
77  }
78
79  require File::Spec;
80  my $versioned_file = File::Spec->catfile('src', $version, $file);
81
82  return -e $versioned_file ? [ $file => $versioned_file ] : undef;
83 }
84
85 unless (defined versioned_file('regcomp.c')) {
86  print STDERR <<EOF;
87      This version of perl ($]) is not yet supported by this version of
88      re::engine::Hooks. If your perl has been recently released, make
89      sure there isn't a newer version of the module available on the CPAN.
90 EOF
91  exit 0;
92 }
93
94 my @DEFINES = qw<-DPERL_EXT_RE_BUILD -DPERL_EXT>;
95 @DEFINES    = (DEFINE => join ' ', @DEFINES) if @DEFINES;
96
97 use ExtUtils::Depends;
98
99 my $ed = ExtUtils::Depends->new($name);
100 $ed->add_c('regcomp.c');
101 $ed->add_c('regexec.c');
102 $ed->add_xs('Hooks.xs');
103 $ed->add_pm($file => do { local $_ = $file; s/^lib/\$(INST_LIB)/; $_ });
104 $ed->install('re_engine_hooks.h');
105 $ed->save_config('Files.pm');
106
107 my %ed_vars = $ed->get_makefile_vars;
108 $ed_vars{clean}->{FILES} .= ' ' . join ' ', (
109  "$dist-*",
110  'Files.pm',
111  qw<*.gcov *.gcda *.gcno cover_db Debian_CPANTS.txt>,
112  qw<regcomp.c regexec.c dquote_static.c inline_invlist.c>,
113 );
114
115 WriteMakefile(
116  NAME             => $name,
117  AUTHOR           => 'Vincent Pit <perl@profvince.com>',
118  LICENSE          => 'perl',
119  VERSION_FROM     => $file,
120  ABSTRACT_FROM    => $file,
121  PL_FILES         => {},
122  BUILD_REQUIRES   => \%BUILD_REQUIRES,
123  PREREQ_PM        => \%PREREQ_PM,
124  MIN_PERL_VERSION => '5.010001',
125  META_MERGE       => \%META,
126  dist             => {
127   PREOP    => "pod2text -u $file > \$(DISTVNAME)/README",
128   COMPRESS => 'gzip -9f', SUFFIX => 'gz'
129  },
130  XSPROTOARG       => '-noprototypes',
131  @DEFINES,
132  FUNCLIST         => [ qw<
133   boot_re__engine__Hooks
134   reh_register
135  > ],
136  %ed_vars,
137 );
138
139 {
140  my $args_dat = './args.dat';
141
142  open my $fh, '>', $args_dat or die "open(>$args_dat): $!";
143  for (@ARGV) {
144   my $arg = $_;
145   $arg =~ s{\s*(['"])\s*(.*)\s*\1\s*$}{$2}s;
146   $arg =~ s{([^=/.a-zA-Z0-9-])}{sprintf "[%d]", ord $1}ge;
147   print $fh "$arg\n";
148  }
149 }
150
151 package MY;
152
153 sub postamble {
154  my $regcomp_c        = main::versioned_file('regcomp.c');
155  my $regexec_c        = main::versioned_file('regexec.c');
156  my $dquote_static_c  = main::versioned_file('dquote_static.c');
157  my $inline_invlist_c = main::versioned_file('inline_invlist.c');
158
159  my @all_c          = ($regcomp_c, $regexec_c);
160  my @regcomp_c_deps = ('regcomp.c');
161  my @regexec_c_deps = ('regexec.c');
162
163  for my $extra_c ($dquote_static_c, $inline_invlist_c) {
164   next unless defined $extra_c;
165   push @all_c,           $extra_c;
166   push @regcomp_c_deps, $extra_c->[0];
167  }
168
169  my $rules;
170
171  for my $file_c (@all_c) {
172   my ($target_file, $versioned_file) = @$file_c;
173   $rules .= <<"RULE";
174 $target_file : $versioned_file
175         - \$(RM_F) $target_file
176         \$(CP) $versioned_file $target_file
177
178 RULE
179  }
180
181  $rules .= <<"RULE";
182 regcomp\$(OBJ_EXT) : @regcomp_c_deps
183
184 regexec\$(OBJ_EXT) : @regexec_c_deps
185
186 RULE
187
188  $rules .= <<'EOF';
189 configure_test.pl: args.dat
190
191 t/re-engine-Hooks-TestDist/Makefile: configure_test.pl
192         $(FULLPERLRUN) configure_test.pl
193
194 all clean:: t/re-engine-Hooks-TestDist/Makefile
195         cd t/re-engine-Hooks-TestDist && $(MAKE) $@
196
197 clean::
198         $(RM_RF) args.dat
199
200 EOF
201
202  return $rules;
203 }