Commit | Line | Data |
---|---|---|
a8a597b2 | 1 | use ExtUtils::MakeMaker; |
2 | use Config; | |
29fc1735 | 3 | use File::Spec; |
a8a597b2 | 4 | |
5 | my $e = $Config{'exe_ext'}; | |
6 | my $o = $Config{'obj_ext'}; | |
7 | my $exeout_flag = '-o '; | |
b7254abc | 8 | my $core = grep { $_ eq 'PERL_CORE=1' } @ARGV; |
a8a597b2 | 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( | |
51a5edaf | 19 | NAME => "B", |
20 | VERSION_FROM => "B.pm", | |
21 | PL_FILES => { 'defsubs_h.PL' => 'defsubs.h' }, | |
51a5edaf | 22 | clean => { |
23 | FILES => "perl$e *$o B.c defsubs.h *~" | |
a8a597b2 | 24 | } |
51a5edaf | 25 | ); |
a8a597b2 | 26 | |
4c1f658f | 27 | package MY; |
28 | ||
29 | sub post_constants { | |
1c74f1bd | 30 | "\nLIBS = $Config::Config{libs}\n" |
485894a1 | 31 | } |
4c1f658f | 32 | |
b7254abc | 33 | sub headerpath { |
34 | if ($core) { | |
35 | return File::Spec->catdir(File::Spec->updir, | |
36 | File::Spec->updir); | |
37 | } else { | |
38 | return File::Spec->catdir($Config::Config{archlibexp}, "CORE"); | |
39 | } | |
29fc1735 | 40 | } |
41 | ||
838c087d | 42 | sub MY::postamble { |
b7254abc | 43 | my $headerpath = headerpath(); |
44 | my @headers = map { File::Spec->catfile($headerpath, $_) } qw(op.h cop.h); | |
838c087d | 45 | my $noecho = shift->{NOECHO}; |
b7254abc | 46 | |
29fc1735 | 47 | " |
485894a1 | 48 | B\$(OBJ_EXT) : defsubs.h |
d19af0aa | 49 | |
b7254abc | 50 | defsubs.h :: @headers defsubs_h.PL |
51 | \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) defsubs_h.PL defsubs.h $headerpath | |
485894a1 | 52 | " |
a8a597b2 | 53 | } |
b7254abc | 54 | |
55 | sub MY::processPL { | |
56 | my $text = shift->SUPER::processPL(@_); | |
57 | # Append our extra parameter | |
58 | $text =~ s/^\t.*defsubs_h\.PL.*/$& . ' ' . headerpath()/me; | |
59 | $text; | |
60 | } |