Commit | Line | Data |
---|---|---|
adfe19db MHM |
1 | ################################################################################ |
2 | # | |
3 | # Makefile.PL -- generate Makefile | |
4 | # | |
5 | ################################################################################ | |
6 | # | |
b2049988 | 7 | # Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz. |
adfe19db MHM |
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 | ||
adfe19db | 16 | require 5.003; |
0a7c7f4f | 17 | |
56093a11 MHM |
18 | use strict; |
19 | use ExtUtils::MakeMaker; | |
20 | ||
21 | use vars '%opt'; # needs to be global, and we can't use 'our' | |
22 | ||
adfe19db MHM |
23 | unless ($ENV{'PERL_CORE'}) { |
24 | $ENV{'PERL_CORE'} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV; | |
9fdbfc11 | 25 | } |
adfe19db | 26 | |
56093a11 | 27 | @ARGV = map { /^--with-(apicheck)$/ && ++$opt{$1} ? () : $_ } @ARGV; |
0d0f8426 | 28 | |
0a7c7f4f | 29 | WriteMakefile( |
adfe19db MHM |
30 | NAME => 'Devel::PPPort', |
31 | VERSION_FROM => 'PPPort_pm.PL', | |
adfe19db | 32 | PM => { 'PPPort.pm' => '$(INST_LIBDIR)/PPPort.pm' }, |
adfe19db | 33 | H => [ qw(ppport.h) ], |
78b4ff79 | 34 | OBJECT => 'RealPPPort$(OBJ_EXT) $(O_FILES)', |
adfe19db | 35 | XSPROTOARG => '-noprototypes', |
236afa0a | 36 | CONFIGURE => \&configure, |
ea4b7f32 JH |
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 | }, | |
0a7c7f4f | 52 | ); |
adfe19db | 53 | |
236afa0a MHM |
54 | sub configure |
55 | { | |
78b4ff79 | 56 | my @clean = qw{ $(H_FILES) RealPPPort.xs RealPPPort.c }; |
236afa0a MHM |
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', | |
78b4ff79 | 62 | 'PPPort_xs.PL' => 'RealPPPort.xs', |
236afa0a MHM |
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. | |
236afa0a MHM |
80 | push @clean, 'PPPort.pm'; |
81 | } | |
82 | else { | |
83 | # Devel::PPPort is in the core since 5.7.3 | |
b2049988 MHM |
84 | # 5.11.0+ has site before perl |
85 | push @moreopts, INSTALLDIRS => ( | |
86 | ($] >= 5.007003 and $] < 5.011) | |
87 | ? 'perl' | |
88 | : 'site' | |
89 | ); | |
236afa0a MHM |
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, | |
78b4ff79 | 101 | XS => { 'RealPPPort.xs' => 'RealPPPort.c' }, |
236afa0a MHM |
102 | PL_FILES => \%PL_FILES, |
103 | depend => \%depend, | |
104 | clean => { FILES => "@clean" }, | |
105 | @moreopts, | |
106 | }; | |
107 | } | |
108 | ||
109 | sub MY::postamble | |
110 | { | |
adfe19db MHM |
111 | package MY; |
112 | my $post = shift->SUPER::postamble(@_); | |
113 | $post .= <<'POSTAMBLE'; | |
114 | ||
115 | purge_all: realclean | |
78b4ff79 | 116 | @$(RM_F) PPPort.pm t/*.t |
adfe19db | 117 | |
78b4ff79 | 118 | regen_pm: |
adfe19db | 119 | $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_pm.PL |
78b4ff79 MHM |
120 | |
121 | regen_xs: | |
adfe19db | 122 | $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) PPPort_xs.PL |
78b4ff79 MHM |
123 | |
124 | regen_tests: | |
adfe19db | 125 | $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) mktests.PL |
78b4ff79 MHM |
126 | |
127 | regen_h: | |
adfe19db MHM |
128 | $(PERL) -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) ppport_h.PL |
129 | ||
78b4ff79 MHM |
130 | regen: regen_pm regen_xs regen_tests regen_h |
131 | ||
adfe19db MHM |
132 | POSTAMBLE |
133 | return $post; | |
134 | } | |
135 | ||
236afa0a MHM |
136 | sub MY::c_o |
137 | { | |
ba120f6f MHM |
138 | package MY; |
139 | my $co = shift->SUPER::c_o(@_); | |
140 | ||
56093a11 MHM |
141 | if ($::opt{'apicheck'} && $co !~ /^\.c\.i:/m) { |
142 | print "Adding custom rule for preprocessed apicheck file...\n"; | |
143 | ||
144 | $co .= <<'CO' | |
ba120f6f MHM |
145 | |
146 | .SUFFIXES: .i | |
147 | ||
148 | .c.i: | |
149 | $(CCCMD) -E -I$(PERL_INC) $(DEFINE) $*.c > $*.i | |
150 | CO | |
56093a11 | 151 | } |
ba120f6f MHM |
152 | |
153 | return $co; | |
154 | } |