This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(perl #133326) fix and clarify handling of recurs_sv.
[perl5.git] / dist / Devel-PPPort / Makefile.PL
1 ################################################################################
2 #
3 #  Makefile.PL -- generate Makefile
4 #
5 ################################################################################
6 #
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.
10 #
11 #  This program is free software; you can redistribute it and/or
12 #  modify it under the same terms as Perl itself.
13 #
14 ################################################################################
15
16 require 5.003;
17
18 use strict;
19 use ExtUtils::MakeMaker;
20
21 use vars '%opt';  # needs to be global, and we can't use 'our'
22
23 unless ($ENV{'PERL_CORE'}) {
24   $ENV{'PERL_CORE'} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
25 }
26
27 @ARGV = map { /^--with-(apicheck)$/ && ++$opt{$1} ? () : $_ } @ARGV;
28
29 my %mf = (
30   NAME          => 'Devel::PPPort',
31   VERSION_FROM  => 'PPPort_pm.PL',
32   PM            => { 'PPPort.pm' => '$(INST_LIBDIR)/PPPort.pm' },
33   H             => [ qw(ppport.h) ],
34   OBJECT        => 'RealPPPort$(OBJ_EXT) $(O_FILES)',
35   XSPROTOARG    => '-noprototypes',
36   CONFIGURE     => \&configure,
37   META_MERGE    => {
38     'meta-spec' => {
39       version => 2,
40     },
41     resources => {
42       bugtracker => {
43         web => 'https://rt.perl.org/rt3/',
44       },
45       repository => {
46         type => 'git',
47         url  => 'git://perl5.git.perl.org/perl.git',
48         web  => 'https://perl5.git.perl.org/perl.git',
49       },
50     },
51   },
52 );
53 delete $mf{META_MERGE} unless eval { ExtUtils::MakeMaker->VERSION (6.46) };
54 WriteMakefile(%mf);
55
56 sub configure
57 {
58   my @clean    = qw{ $(H_FILES) RealPPPort.xs RealPPPort.c };
59   my %depend   = ('$(OBJECT)' => '$(H_FILES)');
60   my @C_FILES  = qw{ module2.c module3.c },
61   my %PL_FILES = (
62     'ppport_h.PL'  => 'ppport.h',
63     'PPPort_pm.PL' => 'PPPort.pm',
64     'PPPort_xs.PL' => 'RealPPPort.xs',
65   );
66   my @moreopts;
67
68   if (eval $ExtUtils::MakeMaker::VERSION >= 6) {
69     push @moreopts, AUTHOR => 'Marcus Holland-Moritz <mhx@cpan.org>';
70     if (-f 'PPPort.pm') {
71       push @moreopts, ABSTRACT_FROM => 'PPPort.pm';
72     }
73   }
74
75   if (eval $ExtUtils::MakeMaker::VERSION >= 6.30_01) {
76     print "Setting license tag...\n";
77     push @moreopts, LICENSE => 'perl';
78   }
79
80   if ($ENV{'PERL_CORE'}) {
81     # Pods will be built by installman.
82     push @clean, 'PPPort.pm';
83   }
84   else {
85     # Devel::PPPort is in the core since 5.7.3
86     # 5.11.0+ has site before perl
87     push @moreopts, INSTALLDIRS => (
88       ("$]" >= 5.007003 and "$]" < 5.011)
89         ? 'perl'
90         : 'site'
91     );
92   }
93
94   if ($opt{'apicheck'}) {
95     $PL_FILES{'apicheck_c.PL'} = 'apicheck.c';
96     push @C_FILES, qw{ apicheck.c };
97     push @clean,   qw{ apicheck.c apicheck.i };
98     $depend{'apicheck.i'} = 'ppport.h';
99   }
100
101   return {
102     C        => \@C_FILES,
103     XS       => { 'RealPPPort.xs' => 'RealPPPort.c' },
104     PL_FILES => \%PL_FILES,
105     depend   => \%depend,
106     clean    => { FILES => "@clean" },
107     @moreopts,
108   };
109 }
110
111 sub MY::postamble
112 {
113   package MY;
114   my $post = shift->SUPER::postamble(@_);
115   $post .= <<'POSTAMBLE';
116
117 purge_all: realclean
118         @$(RM_F) PPPort.pm t/*.t
119
120 regen_pm:
121         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL
122
123 regen_xs:
124         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_xs.PL
125
126 regen_tests:
127         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL
128
129 regen_h:
130         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL
131
132 regen: regen_pm regen_xs regen_tests regen_h
133
134 POSTAMBLE
135   return $post;
136 }
137
138 sub MY::c_o
139 {
140   package MY;
141   my $co = shift->SUPER::c_o(@_);
142
143   if ($::opt{'apicheck'} && $co !~ /^\.c\.i:/m) {
144     print "Adding custom rule for preprocessed apicheck file...\n";
145
146     $co .= <<'CO'
147
148 .SUFFIXES: .i
149
150 .c.i:
151         $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i
152 CO
153   }
154
155   return $co;
156 }