This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update HTTP-Tiny to CPAN version 0.054
[perl5.git] / cpan / 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 WriteMakefile(
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://github.com/mhx/Devel-PPPort/issues/',
44       },
45       repository => {
46         type => 'git',
47         url  => 'git://github.com/mhx/Devel-PPPort.git',
48         web  => 'https://github.com/mhx/Devel-PPPort/',
49       },
50     },
51   },
52 );
53
54 sub configure
55 {
56   my @clean    = qw{ $(H_FILES) RealPPPort.xs RealPPPort.c };
57   my %depend   = ('$(OBJECT)' => '$(H_FILES)');
58   my @C_FILES  = qw{ module2.c module3.c },
59   my %PL_FILES = (
60     'ppport_h.PL'  => 'ppport.h',
61     'PPPort_pm.PL' => 'PPPort.pm',
62     'PPPort_xs.PL' => 'RealPPPort.xs',
63   );
64   my @moreopts;
65
66   if (eval $ExtUtils::MakeMaker::VERSION >= 6) {
67     push @moreopts, AUTHOR => 'Marcus Holland-Moritz <mhx@cpan.org>';
68     if (-f 'PPPort.pm') {
69       push @moreopts, ABSTRACT_FROM => 'PPPort.pm';
70     }
71   }
72
73   if (eval $ExtUtils::MakeMaker::VERSION >= 6.30_01) {
74     print "Setting license tag...\n";
75     push @moreopts, LICENSE => 'perl';
76   }
77
78   if ($ENV{'PERL_CORE'}) {
79     # Pods will be built by installman.
80     push @clean, 'PPPort.pm';
81   }
82   else {
83     # Devel::PPPort is in the core since 5.7.3
84     # 5.11.0+ has site before perl
85     push @moreopts, INSTALLDIRS => (
86       ($] >= 5.007003 and $] < 5.011)
87         ? 'perl'
88         : 'site'
89     );
90   }
91
92   if ($opt{'apicheck'}) {
93     $PL_FILES{'apicheck_c.PL'} = 'apicheck.c';
94     push @C_FILES, qw{ apicheck.c };
95     push @clean,   qw{ apicheck.c apicheck.i };
96     $depend{'apicheck.i'} = 'ppport.h';
97   }
98
99   return {
100     C        => \@C_FILES,
101     XS       => { 'RealPPPort.xs' => 'RealPPPort.c' },
102     PL_FILES => \%PL_FILES,
103     depend   => \%depend,
104     clean    => { FILES => "@clean" },
105     @moreopts,
106   };
107 }
108
109 sub MY::postamble
110 {
111   package MY;
112   my $post = shift->SUPER::postamble(@_);
113   $post .= <<'POSTAMBLE';
114
115 purge_all: realclean
116         @$(RM_F) PPPort.pm t/*.t
117
118 regen_pm:
119         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL
120
121 regen_xs:
122         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_xs.PL
123
124 regen_tests:
125         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL
126
127 regen_h:
128         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL
129
130 regen: regen_pm regen_xs regen_tests regen_h
131
132 POSTAMBLE
133   return $post;
134 }
135
136 sub MY::c_o
137 {
138   package MY;
139   my $co = shift->SUPER::c_o(@_);
140
141   if ($::opt{'apicheck'} && $co !~ /^\.c\.i:/m) {
142     print "Adding custom rule for preprocessed apicheck file...\n";
143
144     $co .= <<'CO'
145
146 .SUFFIXES: .i
147
148 .c.i:
149         $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i
150 CO
151   }
152
153   return $co;
154 }