Re: [PATCH] Hash::Util::FieldHash
[p5sagit/p5-mst-13.2.git] / ext / Devel / PPPort / Makefile.PL
1 ################################################################################
2 #
3 #  Makefile.PL -- generate Makefile
4 #
5 ################################################################################
6 #
7 #  $Revision: 21 $
8 #  $Author: mhx $
9 #  $Date: 2006/06/23 15:55:22 +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 require 5.003;
24
25 unless ($ENV{'PERL_CORE'}) {
26   $ENV{'PERL_CORE'} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
27 }
28
29 @ARGV = map { /^--with-(.*)/ && ++$opt{$1} ? () : $_ } @ARGV;
30
31 %PL_FILES = (
32   'ppport_h.PL'  => 'ppport.h',
33   'PPPort_pm.PL' => 'PPPort.pm',
34   'PPPort_xs.PL' => 'PPPort.xs',
35 );
36
37 @C_FILES  = qw{ module2.c module3.c };
38
39 @clean    = qw{ $(H_FILES) PPPort.c };
40
41 %depend   = ( '$(OBJECT)' => '$(H_FILES)' );
42
43 if ($opt{'apicheck'}) {
44   $PL_FILES{'apicheck_c.PL'} = 'apicheck.c';
45   push @C_FILES, qw{ apicheck.c };
46   push @clean,   qw{ apicheck.c apicheck.i };
47   $depend{'apicheck.i'} = 'ppport.h';
48 }
49
50 if ($ENV{'PERL_CORE'}) {
51   # Pods will be built by installman.
52   push @moreopts, MAN3PODS => {};
53   push @clean, qw( PPPort.pm PPPort.xs );
54 }
55 else {
56   # Devel::PPPort is in the core since 5.7.3
57   push @moreopts, INSTALLDIRS => ($] >= 5.007003 ? 'perl' : 'site');
58 }
59
60 if (eval $ExtUtils::MakeMaker::VERSION >= 6) {
61   push @moreopts, AUTHOR => 'Marcus Holland-Moritz <mhx@cpan.org>';
62   if (-f 'PPPort.pm') {
63     push @moreopts, ABSTRACT_FROM => 'PPPort.pm';
64   }
65 }
66
67 if (eval $ExtUtils::MakeMaker::VERSION >= 6.30_01) {
68   print "Setting license tag...\n";
69   push @moreopts, LICENSE => 'perl';
70 }
71
72 WriteMakefile(
73   NAME          => 'Devel::PPPort',
74   VERSION_FROM  => 'PPPort_pm.PL',
75   PL_FILES      => \%PL_FILES,
76   PM            => { 'PPPort.pm' => '$(INST_LIBDIR)/PPPort.pm' },
77   C             => \@C_FILES,
78   H             => [ qw(ppport.h) ],
79   OBJECT        => '$(BASEEXT)$(OBJ_EXT) $(O_FILES)',
80   XSPROTOARG    => '-noprototypes',
81   clean         => { FILES => "@clean" },
82   depend        => \%depend,
83   @moreopts,
84 );
85
86 sub MY::postamble {
87   package MY;
88   my $post = shift->SUPER::postamble(@_);
89   $post .= <<'POSTAMBLE';
90
91 purge_all: realclean
92         @$(RM_F) PPPort.pm PPPort.xs t/*.t
93
94 regen:
95         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL
96         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_xs.PL
97         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL
98         $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL
99
100 POSTAMBLE
101   return $post;
102 }
103
104 sub MY::c_o {
105   package MY;
106   my $co = shift->SUPER::c_o(@_);
107
108   $co .= <<'CO' if $::opt{'apicheck'} && $co !~ /^\.c\.i:/m;
109
110 .SUFFIXES: .i
111
112 .c.i:
113         $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i
114 CO
115
116   return $co;
117 }
118