make ext/re play nice with DEBUGGING override
[p5sagit/p5-mst-13.2.git] / ext / re / Makefile.PL
CommitLineData
56953603 1use ExtUtils::MakeMaker;
472390e1 2use File::Spec;
8d4151d3 3use Config;
4
5my $object = 're_exec$(OBJ_EXT) re_comp$(OBJ_EXT) re$(OBJ_EXT)';
6
fd3cca25 7my $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
13if ($Config{'usedebugging_perl'} ne 'Y') {
14 $defines .= ' -DDEBUGGING -DWAS_NOT_DEBUGGING';
15}
16
56953603 17WriteMakefile(
18 NAME => 're',
19 VERSION_FROM => 're.pm',
69158f75 20 MAN3PODS => {}, # Pods will be built by installman.
56953603 21 XSPROTOARG => '-noprototypes',
8d4151d3 22 OBJECT => $object,
fd3cca25 23 DEFINE => $defines,
782f0963 24 clean => { FILES => '*$(OBJ_EXT) *.c ../../lib/re.pm' },
56953603 25);
26
472390e1 27package MY;
778ddebd 28
472390e1 29sub upupfile {
30 File::Spec->catfile(File::Spec->updir, File::Spec->updir, $_[0]);
31}
778ddebd 32
472390e1 33sub postamble {
34 my $regcomp_c = upupfile('regcomp.c');
35 my $regexec_c = upupfile('regexec.c');
778ddebd 36
472390e1 37 <<EOF;
38re_comp.c : $regcomp_c
39 - \$(RM_F) re_comp.c
40 \$(CP) $regcomp_c re_comp.c
778ddebd 41
472390e1 42re_comp\$(OBJ_EXT) : re_comp.c
778ddebd 43
472390e1 44re_exec.c : $regexec_c
45 - \$(RM_F) re_exec.c
46 \$(CP) $regexec_c re_exec.c
56953603 47
472390e1 48re_exec\$(OBJ_EXT) : re_exec.c
56953603 49
50EOF
51}
b7a20417 52
53sub MY::c_o {
54 my($self) = @_;
55 package MY; # so that "SUPER" works right
56 my $inh = $self->SUPER::c_o(@_);
57 use Config;
58 if ($Config{osname} eq 'aix' && $Config{ccversion} eq '5.0.1.0') {
59 # Known buggy optimizer.
60 my $cccmd = $self->const_cccmd;
61 $cccmd =~ s/^CCCMD\s*=\s*//;
62 $cccmd =~ s/\s\$\(OPTIMIZE\)\s/ /;
63 $inh .= qq{
64
65re_comp\$\(OBJ_EXT\): re_comp.c
66\t$cccmd \$(CCCDLFLAGS) -I\$(PERL_INC) \$(DEFINE) \$*.c
67};
68 }
69 $inh;
70}