This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: INC handlers and shutdown-time warnings
[perl5.git] / ext / B / Makefile.PL
1 use ExtUtils::MakeMaker;
2 use Config;
3 use File::Spec;
4
5 my $e = $Config{'exe_ext'};
6 my $o = $Config{'obj_ext'};
7 my $exeout_flag = '-o ';
8 my $core = grep { $_ eq 'PERL_CORE=1' } @ARGV;
9 if ($^O eq 'MSWin32') {
10     if ($Config{'cc'} =~ /^cl/i) {
11         $exeout_flag = '-Fe';
12     }
13     elsif ($Config{'cc'} =~ /^bcc/i) {
14         $exeout_flag = '-e';
15     }
16 }
17
18 WriteMakefile(
19     NAME            => "B",
20     VERSION_FROM    => "B.pm",
21     PL_FILES        => { 'defsubs_h.PL' => 'defsubs.h' },
22     MAN3PODS        => {},
23     clean           => {
24         FILES       => "perl$e *$o B.c defsubs.h *~"
25     }
26 );
27
28 package MY;
29
30 sub post_constants {
31     "\nLIBS = $Config::Config{libs}\n"
32 }
33
34 sub headerfilefile {
35     push @makefileopts, MAN3PODS => {};
36 }
37
38 sub headerpath {
39     if ($core) {
40         return File::Spec->catdir(File::Spec->updir,
41                                    File::Spec->updir);
42     } else {
43         return File::Spec->catdir($Config::Config{archlibexp}, "CORE");
44     }
45 }
46
47 sub MY::postamble {
48     my $headerpath = headerpath();
49     my @headers = map { File::Spec->catfile($headerpath, $_) } qw(op.h cop.h);
50     my $noecho = shift->{NOECHO};
51
52 "
53 B\$(OBJ_EXT) : defsubs.h
54
55 defsubs.h :: @headers defsubs_h.PL
56         \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) defsubs_h.PL defsubs.h $headerpath
57 "
58 }
59
60 sub MY::processPL {
61     my $text = shift->SUPER::processPL(@_);
62     # Append our extra parameter
63     $text =~ s/^\t.*defsubs_h\.PL.*/$& . ' ' . headerpath()/me;
64     $text;
65 }