This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
INSTALL now says that "changes in the Perl language" are usually minor
[perl5.git] / ext / re / Makefile.PL
1 use strict;
2 use warnings;
3 use ExtUtils::MakeMaker;
4 use File::Spec;
5 use Config;
6 #   [ src => @deps ]
7 our @files = (
8     # compiler files ########################################
9     ['regcomp.c'        => 'dquote.c', 'invlist_inline.h'   ],
10     ['regcomp_invlist.c' => 'invlist_inline.h'              ],
11     ['regcomp_study.c'                                      ],
12     ['regcomp_trie.c'                                       ],
13     ['regcomp_debug.c'                                      ],
14     # execution engine files ################################
15     ['regexec.c'        => 'invlist_inline.h'               ],
16     # misc files ############################################
17     ['dquote.c'                                             ],
18     ['invlist_inline.h'                                     ],
19     #########################################################
20 );
21
22 my @objects = 're$(OBJ_EXT)';
23 foreach my $tuple (@files) {
24     my $src_file = $tuple->[0];
25     if ($src_file=~s/reg/re_/ and $src_file=~s/\.c/\$(OBJ_EXT)/) {
26         push @objects, $src_file;
27     }
28 }
29
30 my $defines = '-DPERL_EXT_RE_BUILD -DPERL_EXT_RE_DEBUG -DPERL_EXT';
31
32 my @libs;
33 if ($^O eq 'cygwin' && $Config{usequadmath}) {
34     push @libs, qw(quadmath);
35 }
36 WriteMakefile(
37     NAME                => 're',
38     @libs ? ( 'LIBS' => [ join(" ", map { "-l$_" } @libs) ] ) : (),
39     VERSION_FROM        => 're.pm',
40     XSPROTOARG          => '-noprototypes',
41     OBJECT              => "@objects",
42     DEFINE             => $defines,
43     clean               => { FILES => '*$(OBJ_EXT) invlist_inline.h *.c ../../lib/re.pm' },
44 );
45
46 package MY;
47 sub upupfile {
48     File::Spec->catfile(File::Spec->updir, File::Spec->updir, $_[0]);
49 }
50
51 sub postamble {
52     my $postamble = "";
53
54     foreach my $tuple (@::files) {
55         my ($file, @deps) = @$tuple;
56         my $src_file = upupfile($file);
57         my $target = $file;
58         $target =~ s/^reg/re_/;
59         $postamble .=
60     <<EOF;
61 $target : $src_file
62         - \$(RM_F) $target
63         \$(CP) $src_file $target
64
65 EOF
66         next if $target eq $file;
67         my $base_name = $target;
68         if ($base_name=~s/\.c\z//) {
69             $postamble .= <<EOF
70 $base_name\$(OBJ_EXT) : $target @deps
71
72 EOF
73         }
74     }
75     return $postamble
76 }
77
78 sub MY::c_o {
79     my($self) = @_;
80     package MY; # so that "SUPER" works right
81     my $inh = $self->SUPER::c_o(@_);
82     use Config;
83     if ($Config{osname} eq 'aix' && $Config{ccversion} eq '5.0.1.0') {
84         # Known buggy optimizer.
85         my $cccmd = $self->const_cccmd;
86         $cccmd =~ s/^CCCMD\s*=\s*//;
87         $cccmd =~ s/\s\$\(OPTIMIZE\)\s/ /;
88         $inh .= qq{
89
90 re_comp\$\(OBJ_EXT\): re_comp.c
91 \t$cccmd \$(CCCDLFLAGS) -I\$(PERL_INC) \$(DEFINE) \$*.c
92 };
93     }
94     $inh;
95 }