1 ################################################################################
3 # Makefile.PL -- generate Makefile
5 ################################################################################
7 # Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz.
8 # Version 2.x, Copyright (C) 2001, Paul Marquess.
9 # Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the same terms as Perl itself.
14 ################################################################################
19 use ExtUtils::MakeMaker;
22 use vars '%opt'; # needs to be global, and we can't use 'our'
24 unless ($ENV{'PERL_CORE'}) {
25 $ENV{'PERL_CORE'} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
28 @ARGV = map { /^--with-(apicheck)$/ && ++$opt{$1} ? () : $_ } @ARGV;
31 NAME => 'Devel::PPPort',
32 VERSION_FROM => 'PPPort_pm.PL',
33 PM => { 'PPPort.pm' => '$(INST_LIBDIR)/PPPort.pm' },
34 H => [ qw(ppport.h) ],
35 OBJECT => 'RealPPPort$(OBJ_EXT) $(O_FILES)',
36 XSPROTOARG => '-noprototypes',
37 CONFIGURE => \&configure,
39 delete $mf{META_MERGE} unless eval { ExtUtils::MakeMaker->VERSION (6.46) };
44 my @clean = qw{ $(H_FILES) RealPPPort.xs RealPPPort.c PPPort.pm };
45 my %depend = ('$(OBJECT)' => '$(H_FILES)');
46 my @C_FILES = qw{ module2.c module3.c },
48 'ppport_h.PL' => 'ppport.h',
49 'PPPort_pm.PL' => 'PPPort.pm',
50 'RealPPPort_xs.PL' => 'RealPPPort.xs',
51 'mktests.PL' => 't/01_test.t',
55 if (eval $ExtUtils::MakeMaker::VERSION >= 6) {
56 push @moreopts, AUTHOR => 'Marcus Holland-Moritz <mhx@cpan.org>';
57 push @moreopts, ABSTRACT_FROM => 'PPPort_pm.PL';
60 if (eval $ExtUtils::MakeMaker::VERSION >= 6.30_01) {
61 print "Setting license tag...\n";
62 push @moreopts, LICENSE => 'perl';
65 if (not $ENV{'PERL_CORE'}) {
66 # Devel::PPPort is in the core since 5.7.3
67 # 5.11.0+ has site before perl
68 push @moreopts, INSTALLDIRS => (
69 ("$]" >= 5.007003 and "$]" < 5.011)
75 if ($opt{'apicheck'}) {
76 $PL_FILES{'apicheck_c.PL'} = 'apicheck.c';
77 push @C_FILES, qw{ apicheck.c };
78 push @clean, qw{ apicheck.c apicheck.i };
79 $depend{'apicheck.i'} = 'ppport.h';
82 open FH, '<PPPort_pm.PL' or die "cannot open PPPort_pm.PL for reading: $!";
84 while (my $line = <FH>) {
85 ($version) = $line =~ /^\$VERSION = '([\d.]+)';$/ and last;
87 die 'failed to extract $VERSION from PPPort_pm.PL' if not $version;
90 if ($Config{gccversion}) {
91 my $define = '-W -Wall';
92 $define .= ' -Wdeclaration-after-statement' if $Config{gccversion} =~ /^(\d+\.\d+)\./ && $1 >= 3.4;
93 push @moreopts, DEFINE => $define;
98 XS => { 'RealPPPort.xs' => 'RealPPPort.c' },
99 PL_FILES => \%PL_FILES,
101 clean => { FILES => "@clean" },
103 'meta-spec' => { version => 2 },
106 file => 'PPPort_pm.PL',
112 web => 'https://rt.perl.org/rt3/',
116 url => 'git://perl5.git.perl.org/perl.git',
117 web => 'https://perl5.git.perl.org/perl.git',
128 my $post = shift->SUPER::postamble(@_);
129 $post .= <<'POSTAMBLE';
132 @$(RM_F) PPPort.pm t/*.t
135 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL
138 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) RealPPPort_xs.PL
141 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL
144 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL
146 regen: regen_pm regen_xs regen_tests regen_h
155 my $original = shift->SUPER::processPL(@_);
157 require "./parts/ppptools.pl";
158 my $includes = join ' ', all_files_in_dir('parts/inc');
161 my @rules = split( m{^\s*$}m, $original );
162 foreach my $rule ( @rules ) {
163 if ( $rule =~ m{^\s*^PPPort\.pm\s+:}m ) {
164 $rule =~ s{^(\s*^PPPort\.pm\s+:.*)}{$1 $includes}m; # PPPort.pm depends on all files from parts/inc
165 $rule =~ s{pm_to_blib}{}m; # PPPort.pm must not depend on built PPPort.pm in blib/
166 } elsif ( $rule =~ m{^\s*^ppport\.h\s+:}m ) {
167 $rule =~ s{^(\s*^ppport\.h\s+:.*)}{$1 PPPort.pm}m; # ppport.h depends on PPPort.pm
168 $rule =~ s{pm_to_blib}{}m; # ppport.h is used to build RealPPPort.xs so cannot depend on built PPPort in blib/
169 } elsif ( $rule =~ m{^\s*^RealPPPort\.xs\s+:}m ) {
170 $rule =~ s{^(\s*^RealPPPort\.xs\s+:.*)}{$1 ppport.h}m; # RealPPPort.xs depends on ppport.h
171 $rule =~ s{pm_to_blib}{}m; # RealPPPort.xs is used to build PPPort binary, so it cannot depend on it
172 } elsif ( $rule =~ m{^\s*\S+\b01_test\.t\s+:}m ) {
173 $rule =~ s{^(\s*^\S+\b01_test\.t\s+:.*)}{$1 $includes}m; # all tests in t/ depends on all files from parts/inc
174 $rule =~ s{pm_to_blib}{}m; # Generating test files does not depend on built PPPort in blib/
185 my $dist = shift->SUPER::dist_core(@_);
188 my @rules = split( m{^\s*$}m, $dist );
189 foreach my $rule ( @rules ) {
190 if ( $rule =~ m{^\s*^dist\s+:}m ) {
191 $rule =~ s{:}{: manifest}; # make sure we regenerate the manifest
192 $rule .= qq[\t].q[$(NOECHO) $(ECHO) "Warning: Please check '__MAX_PERL__' value in PPPort_pm.PL"].qq[\n];
204 my $co = shift->SUPER::c_o(@_);
206 if ($::opt{'apicheck'} && $co !~ /^\.c\.i:/m) {
207 print "Adding custom rule for preprocessed apicheck file...\n";
214 $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i