Integrate changes #12652 and #12653 from maintperl;
[p5sagit/p5-mst-13.2.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';
8
9 # We need to pretend that DEBUGGING is in effect even if it's
10 # not but we need to remember that we pretended so we can avoid
11 # linking to things that aren't there.
12
13 if ( (($Config{'ccflags'} !~ /DEBUGGING/) && $^O ne 'VMS') || 
14      (exists($Config{'usedebugging_perl'}) && $Config{'usedebugging_perl'} ne 'Y') ) {
15   $defines .= ' -DDEBUGGING -DWAS_NOT_DEBUGGING';
16 }
17
18 WriteMakefile(
19     NAME                => 're',
20     VERSION_FROM        => 're.pm',
21     MAN3PODS            => {},  # Pods will be built by installman.
22     XSPROTOARG          => '-noprototypes',
23     OBJECT              => $object,
24     DEFINE             => $defines,
25     clean               => { FILES => '*$(OBJ_EXT) *.c ../../lib/re.pm' },
26 );
27
28 package MY;
29
30 sub upupfile {
31     File::Spec->catfile(File::Spec->updir, File::Spec->updir, $_[0]);
32 }
33
34 sub postamble {
35     my $regcomp_c = upupfile('regcomp.c');
36     my $regexec_c = upupfile('regexec.c');
37
38     <<EOF;
39 re_comp.c : $regcomp_c
40         - \$(RM_F) re_comp.c
41         \$(CP) $regcomp_c re_comp.c
42
43 re_comp\$(OBJ_EXT) : re_comp.c
44
45 re_exec.c : $regexec_c
46         - \$(RM_F) re_exec.c
47         \$(CP) $regexec_c re_exec.c
48
49 re_exec\$(OBJ_EXT) : re_exec.c
50
51 EOF
52 }
53
54 sub MY::c_o {
55     my($self) = @_;
56     package MY; # so that "SUPER" works right
57     my $inh = $self->SUPER::c_o(@_);
58     use Config;
59     if ($Config{osname} eq 'aix' && $Config{ccversion} eq '5.0.1.0') {
60         # Known buggy optimizer.
61         my $cccmd = $self->const_cccmd;
62         $cccmd =~ s/^CCCMD\s*=\s*//;
63         $cccmd =~ s/\s\$\(OPTIMIZE\)\s/ /;
64         $inh .= qq{
65
66 re_comp\$\(OBJ_EXT\): re_comp.c
67 \t$cccmd \$(CCCDLFLAGS) -I\$(PERL_INC) \$(DEFINE) \$*.c
68 };
69     }
70     $inh;
71 }