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