This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Left overshift of negatives under use integer was still wrong.
[perl5.git] / cpan / Encode / Makefile.PL
1 #
2 # $Id: Makefile.PL,v 2.14 2015/06/25 00:49:23 dankogai Exp $
3 #
4 use 5.007003;
5 use strict;
6 use warnings;
7 use ExtUtils::MakeMaker;
8 use File::Spec;
9
10 # Just for sure :)
11 my %ARGV = map { my @r = split /=/,$_; defined $r[1] or $r[1]=1; @r } @ARGV;
12 $ARGV{DEBUG} and warn "$_ => $ARGV{$_}\n" for sort keys  %ARGV;
13 $ENV{PERL_CORE} ||= $ARGV{PERL_CORE} if $ARGV{PERL_CORE};
14
15 my %tables = 
16     (
17      def_t => ['ascii.ucm',
18            '8859-1.ucm',
19            'null.ucm',
20            'ctrl.ucm',
21            ]
22      );
23
24 my @exe_files = qw(bin/enc2xs
25            bin/piconv
26            bin/encguess
27            );
28 my @more_exe_files = qw(
29             unidump
30             );
31 my @pmlibdirs = qw(lib Encode);
32
33 $ARGV{MORE_SCRIPTS} and push @exe_files, @more_exe_files;
34 $ARGV{INSTALL_UCM}   and push @pmlibdirs, "ucm";
35
36 WriteMakefile(
37     NAME         => "Encode",
38     EXE_FILES    => \@exe_files,
39     VERSION_FROM => 'Encode.pm',
40     OBJECT       => '$(O_FILES)',
41     'dist'       => {
42         COMPRESS     => 'gzip -9f',
43         SUFFIX       => 'gz',
44         DIST_DEFAULT => 'all tardist',
45     },
46     INC         => '-I' . File::Spec->catfile( '.', 'Encode' ),
47     LICENSE     => 'perl',
48     PREREQ_PM   => {
49         Exporter   => '5.57',   # use Exporter 'import';
50         parent     => '0.221',  # version bundled with 5.10.1
51     },
52     PMLIBDIRS   => \@pmlibdirs,
53     INSTALLDIRS => ($] < 5.011 ? 'perl' : 'site'),
54     META_MERGE        => {
55         resources => {
56             repository  =>  'https://github.com/dankogai/p5-encode',
57         },
58     },
59 );
60
61 package MY;
62
63
64 sub post_initialize
65 {
66     my ($self) = @_;
67     my %o;
68     # Find existing O_FILES
69     foreach my $f (@{$self->{'O_FILES'}})
70     {
71     $o{$f} = 1;
72     }
73     my $x = $self->{'OBJ_EXT'};
74     # Add the table O_FILES
75     foreach my $e (keys %tables)
76     {
77     $o{$e.$x} = 1;
78     }
79     # Trick case-blind filesystems.
80     delete $o{'encode'.$x};
81     $o{'Encode'.$x} = 1;
82     # Reset the variable
83     $self->{'O_FILES'} = [sort keys %o];
84     my @files;
85     foreach my $table (sort keys %tables)
86     {
87     foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
88     {
89     push (@files,$table.$ext);
90     }
91     $self->{SOURCE} .= " $table.c"
92     if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
93 }
94 $self->{'clean'}{'FILES'} .= join(' ',@files);
95 return '';
96 }
97
98 sub postamble
99 {
100     my $self = shift;
101     my $dir  = $self->catdir($self->curdir,'ucm');
102     my $str  = "# Encode\$(OBJ_EXT) does not depend on .c files directly\n";
103     $str  .= "# (except Encode.c), but on .h and .exh files written by enc2xs\n";
104     $str  .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
105     $str  .= ' Encode.c';
106     foreach my $table (sort keys %tables)
107     {
108     $str .= " $table.c";
109     }
110     $str .= "\n\n";
111     foreach my $table (sort keys %tables)
112     {
113     my $numlines = 1;
114     my $lengthsofar = length($str);
115     my $continuator = '';
116     my $enc2xs = $self->catfile('bin', 'enc2xs');
117     $str .= "$table.c : $enc2xs Makefile.PL";
118     foreach my $file (@{$tables{$table}})
119     {
120         $str .= $continuator.' '.$self->catfile($dir,$file);
121         if ( length($str)-$lengthsofar > 128*$numlines )
122         {
123         $continuator .= " \\\n\t";
124         $numlines++;
125         } else {
126         $continuator = '';
127         }
128     }
129     my $plib   = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
130     $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
131     my $ucopts = '-"Q" -"O"';
132     $str .=
133         qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
134     open (FILELIST, ">$table.fnm")
135         || die "Could not open $table.fnm: $!";
136     foreach my $file (@{$tables{$table}})
137     {
138         print FILELIST $self->catfile($dir,$file) . "\n";
139     }
140     close(FILELIST);
141     }
142     return $str;
143 }