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 ################################################################################
21 use ExtUtils::MakeMaker;
24 use vars '%opt'; # needs to be global, and we can't use 'our'
26 unless ($ENV{'PERL_CORE'}) {
27 $ENV{'PERL_CORE'} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
30 @ARGV = map { /^--with-(apicheck)$/ && ++$opt{$1} ? () : $_ } @ARGV;
33 NAME => 'Devel::PPPort',
34 VERSION_FROM => 'PPPort_pm.PL',
35 PM => { 'PPPort.pm' => '$(INST_LIBDIR)/PPPort.pm' },
36 H => [ qw(ppport.h) ],
37 OBJECT => 'RealPPPort$(OBJ_EXT) $(O_FILES)',
38 XSPROTOARG => '-noprototypes',
39 CONFIGURE => \&configure,
45 my @clean = qw{ $(H_FILES) RealPPPort.xs RealPPPort.c PPPort.pm };
46 my %depend = ('$(OBJECT)' => '$(H_FILES)');
47 my @C_FILES = qw{ module2.c module3.c },
49 'ppport_h.PL' => 'ppport.h',
50 'PPPort_pm.PL' => 'PPPort.pm',
51 'RealPPPort_xs.PL' => 'RealPPPort.xs',
52 'mktests.PL' => 't/01_test.t',
56 if (eval $ExtUtils::MakeMaker::VERSION >= 6) {
57 push @moreopts, AUTHOR => 'Marcus Holland-Moritz <mhx@cpan.org>';
58 push @moreopts, ABSTRACT_FROM => 'PPPort_pm.PL';
61 if (eval $ExtUtils::MakeMaker::VERSION >= 6.30_01) {
62 print "Setting license tag...\n";
63 push @moreopts, LICENSE => 'perl';
66 if (eval { ExtUtils::MakeMaker->VERSION (6.46) }) {
67 open FH, '<PPPort_pm.PL' or die "cannot open PPPort_pm.PL for reading: $!";
69 while (my $line = <FH>) {
70 ($version) = $line =~ /^\$VERSION = '([\d.]+)';$/ and last;
72 die 'failed to extract $VERSION from PPPort_pm.PL' if not $version;
74 print "Adding META_MERGE...\n";
75 push @moreopts, META_MERGE => {
76 'meta-spec' => { version => 2 },
79 file => 'PPPort_pm.PL',
85 web => 'https://rt.perl.org/rt3/',
89 url => 'git://perl5.git.perl.org/perl.git',
90 web => 'https://perl5.git.perl.org/perl.git',
96 if (not $ENV{'PERL_CORE'}) {
97 # Devel::PPPort is in the core since 5.7.3
98 # 5.11.0+ has site before perl
99 push @moreopts, INSTALLDIRS => (
100 ("$]" >= 5.007003 and "$]" < 5.011)
106 if ($opt{'apicheck'}) {
107 $PL_FILES{'apicheck_c.PL'} = 'apicheck.c';
108 push @C_FILES, qw{ apicheck.c };
109 push @clean, qw{ apicheck.c apicheck.i };
110 $depend{'apicheck.i'} = 'ppport.h';
113 if ($Config{gccversion}) {
114 my $define = '-W -Wall';
115 $define .= ' -Wdeclaration-after-statement' if $Config{gccversion} =~ /^(\d+\.\d+)\./ && $1 >= 3.4;
116 push @moreopts, DEFINE => $define;
121 XS => { 'RealPPPort.xs' => 'RealPPPort.c' },
122 PL_FILES => \%PL_FILES,
124 clean => { FILES => "@clean" },
132 my $post = shift->SUPER::postamble(@_);
133 $post .= <<'POSTAMBLE';
136 @$(RM_F) PPPort.pm t/*.t
139 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL
142 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) RealPPPort_xs.PL
145 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL
148 $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL
150 regen: regen_pm regen_xs regen_tests regen_h
159 my $original = shift->SUPER::processPL(@_);
161 require "./parts/ppptools.pl";
162 my $includes = join ' ', all_files_in_dir('parts/inc');
165 my @rules = split( m{^\s*$}m, $original );
166 foreach my $rule ( @rules ) {
167 if ( $rule =~ m{^\s*^PPPort\.pm\s+:}m ) {
168 $rule =~ s{^(\s*^PPPort\.pm\s+:.*)}{$1 $includes}m; # PPPort.pm depends on all files from parts/inc
169 $rule =~ s{pm_to_blib}{}m; # PPPort.pm must not depend on built PPPort.pm in blib/
170 } elsif ( $rule =~ m{^\s*^ppport\.h\s+:}m ) {
171 $rule =~ s{^(\s*^ppport\.h\s+:.*)}{$1 PPPort.pm}m; # ppport.h depends on PPPort.pm
172 $rule =~ s{pm_to_blib}{}m; # ppport.h is used to build RealPPPort.xs so cannot depend on built PPPort in blib/
173 } elsif ( $rule =~ m{^\s*^RealPPPort\.xs\s+:}m ) {
174 $rule =~ s{^(\s*^RealPPPort\.xs\s+:.*)}{$1 ppport.h}m; # RealPPPort.xs depends on ppport.h
175 $rule =~ s{pm_to_blib}{}m; # RealPPPort.xs is used to build PPPort binary, so it cannot depend on it
176 } elsif ( $rule =~ m{^\s*\S+\b01_test\.t\s+:}m ) {
177 $rule =~ s{^(\s*^\S+\b01_test\.t\s+:.*)}{$1 $includes}m; # all tests in t/ depends on all files from parts/inc
178 $rule =~ s{pm_to_blib}{}m; # Generating test files does not depend on built PPPort in blib/
189 my $dist = shift->SUPER::dist_core(@_);
192 my @rules = split( m{^\s*$}m, $dist );
193 foreach my $rule ( @rules ) {
194 if ( $rule =~ m{^\s*^dist\s+:}m ) {
195 $rule =~ s{:}{: manifest}; # make sure we regenerate the manifest
196 $rule .= qq[\t].q[$(NOECHO) $(ECHO) "Warning: Please check '__MAX_PERL__' value in PPPort_pm.PL"].qq[\n];
208 my $co = shift->SUPER::c_o(@_);
210 if ($::opt{'apicheck'} && $co !~ /^\.c\.i:/m) {
211 print "Adding custom rule for preprocessed apicheck file...\n";
218 $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i