Upgrade to Devel::PPPort 3.08_07
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / Makefile.PL
1 ################################################################################
2 #
3 #  Makefile.PL -- generate Makefile
4 #
5 ################################################################################
6 #
7 #  $Revision: 25 $
8 #  $Author: mhx $
9 #  $Date: 2006/07/03 21:48:31 +0200 $
10 #
11 ################################################################################
12 #
13 #  Version 3.x, Copyright (C) 2004-2006, Marcus Holland-Moritz.
14 #  Version 2.x, Copyright (C) 2001, Paul Marquess.
15 #  Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
16 #
17 #  This program is free software; you can redistribute it and/or
18 #  modify it under the same terms as Perl itself.
19 #
20 ################################################################################
21
22 use ExtUtils::MakeMaker;
23 use strict;
24 require 5.003;
25
26 unless ($ENV{'PERL_CORE'}) {
27   $ENV{'PERL_CORE'} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
28 }
29
30 my %opt;
31
32 @ARGV = map { /^--with-(.*)/ && ++$opt{$1} ? () : $_ } @ARGV;
33
34 WriteMakefile(
35   NAME          => 'Devel::PPPort',
36   VERSION_FROM  => 'PPPort_pm.PL',
37   PM            => { 'PPPort.pm' => '$(INST_LIBDIR)/PPPort.pm' },
38   H             => [ qw(ppport.h) ],
39   OBJECT        => 'RealPPPort$(OBJ_EXT) $(O_FILES)',
40   XSPROTOARG    => '-noprototypes',
41   CONFIGURE     => \&configure,
42 );
43
44 sub configure
45 {
46   my @clean    = qw{ $(H_FILES) RealPPPort.xs RealPPPort.c };
47   my %depend   = ('$(OBJECT)' => '$(H_FILES)');
48   my @C_FILES  = qw{ module2.c module3.c },
49   my %PL_FILES = (
50     'ppport_h.PL'  => 'ppport.h',
51     'PPPort_pm.PL' => 'PPPort.pm',
52     'PPPort_xs.PL' => 'RealPPPort.xs',
53   );
54   my @moreopts;
55
56   if (eval $ExtUtils::MakeMaker::VERSION >= 6) {
57     push @moreopts, AUTHOR => 'Marcus Holland-Moritz <mhx@cpan.org>';
58     if (-f 'PPPort.pm') {
59       push @moreopts, ABSTRACT_FROM => 'PPPort.pm';
60     }
61   }
62
63   if (eval $ExtUtils::MakeMaker::VERSION >= 6.30_01) {
64     print "Setting license tag...\n";
65     push @moreopts, LICENSE => 'perl';
66   }
67
68   if ($ENV{'PERL_CORE'}) {
69     # Pods will be built by installman.
70     push @moreopts, MAN3PODS => {};
71     push @clean, 'PPPort.pm';
72   }
73   else {
74     # Devel::PPPort is in the core since 5.7.3
75     push @moreopts, INSTALLDIRS => ($] >= 5.007003 ? 'perl' : 'site');
76   }
77
78   if ($opt{'apicheck'}) {
79     $PL_FILES{'apicheck_c.PL'} = 'apicheck.c';
80     push @C_FILES, qw{ apicheck.c };
81     push @clean,   qw{ apicheck.c apicheck.i };
82     $depend{'apicheck.i'} = 'ppport.h';
83   }
84
85   return {
86     C        => \@C_FILES,
87     XS       => { 'RealPPPort.xs' => 'RealPPPort.c' },
88     PL_FILES => \%PL_FILES,
89     depend   => \%depend,
90     clean    => { FILES => "@clean" },
91     @moreopts,
92   };
93 }
94
95 sub MY::postamble
96 {
97   package MY;
98   my $post = shift->SUPER::postamble(@_);
99   $post .= <<'POSTAMBLE';
100
101 purge_all: realclean
102         @$(RM_F) PPPort.pm t/*.t
103
104 regen_pm:
105         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL
106
107 regen_xs:
108         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_xs.PL
109
110 regen_tests:
111         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL
112
113 regen_h:
114         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL
115
116 regen: regen_pm regen_xs regen_tests regen_h
117
118 POSTAMBLE
119   return $post;
120 }
121
122 sub MY::c_o
123 {
124   package MY;
125   my $co = shift->SUPER::c_o(@_);
126
127   $co .= <<'CO' if $::opt{'apicheck'} && $co !~ /^\.c\.i:/m;
128
129 .SUFFIXES: .i
130
131 .c.i:
132         $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i
133 CO
134
135   return $co;
136 }
137