This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
For the sake or robustness, avoid reproducing Perl guts in test file
[perl5.git] / ext / re / Makefile.PL
1 use ExtUtils::MakeMaker;
2 use File::Spec;
3 use Config;
4
5 my $object = 're_exec$(OBJ_EXT) re_comp$(OBJ_EXT) re$(OBJ_EXT)';
6
7 my $defines = '-DPERL_EXT_RE_BUILD -DPERL_EXT_RE_DEBUG -DPERL_EXT';
8
9 WriteMakefile(
10     NAME                => 're',
11     VERSION_FROM        => 're.pm',
12     XSPROTOARG          => '-noprototypes',
13     OBJECT              => $object,
14     DEFINE             => $defines,
15     clean               => { FILES => '*$(OBJ_EXT) *.c ../../lib/re.pm' },
16 );
17
18 package MY;
19
20 sub upupfile {
21     File::Spec->catfile(File::Spec->updir, File::Spec->updir, $_[0]);
22 }
23
24 sub postamble {
25     my $regcomp_c = upupfile('regcomp.c');
26     my $regexec_c = upupfile('regexec.c');
27     my $dquote_static_c = upupfile('dquote_static.c');
28
29     <<EOF;
30 re_comp.c : $regcomp_c
31         - \$(RM_F) re_comp.c
32         \$(CP) $regcomp_c re_comp.c
33
34 re_comp\$(OBJ_EXT) : re_comp.c dquote_static.c
35
36 re_exec.c : $regexec_c
37         - \$(RM_F) re_exec.c
38         \$(CP) $regexec_c re_exec.c
39
40 re_exec\$(OBJ_EXT) : re_exec.c
41
42 dquote_static.c : $dquote_static_c
43         - \$(RM_F) dquote_static.c
44         \$(CP) $dquote_static_c dquote_static.c
45
46 EOF
47 }
48
49 sub MY::c_o {
50     my($self) = @_;
51     package MY; # so that "SUPER" works right
52     my $inh = $self->SUPER::c_o(@_);
53     use Config;
54     if ($Config{osname} eq 'aix' && $Config{ccversion} eq '5.0.1.0') {
55         # Known buggy optimizer.
56         my $cccmd = $self->const_cccmd;
57         $cccmd =~ s/^CCCMD\s*=\s*//;
58         $cccmd =~ s/\s\$\(OPTIMIZE\)\s/ /;
59         $inh .= qq{
60
61 re_comp\$\(OBJ_EXT\): re_comp.c
62 \t$cccmd \$(CCCDLFLAGS) -I\$(PERL_INC) \$(DEFINE) \$*.c
63 };
64     }
65     $inh;
66 }