This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Encode to CPAN version 2.48
[perl5.git] / cpan / Encode / Makefile.PL
1 #
2 # $Id: Makefile.PL,v 2.10 2013/02/18 02:23:56 dankogai Exp dankogai $
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 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            );
27 my @more_exe_files = qw(
28             unidump
29             );
30 my @pmlibdirs = qw(lib Encode);
31
32 $ARGV{MORE_SCRIPTS} and push @exe_files, @more_exe_files;
33 $ARGV{INSTALL_UCM}   and push @pmlibdirs, "ucm";
34
35 WriteMakefile(
36     NAME         => "Encode",
37     EXE_FILES    => \@exe_files,
38     VERSION_FROM => 'Encode.pm',
39     OBJECT       => '$(O_FILES)',
40     'dist'       => {
41         COMPRESS     => 'gzip -9f',
42         SUFFIX       => 'gz',
43         DIST_DEFAULT => 'all tardist',
44     },
45     INC         => '-I' . File::Spec->catfile( '.', 'Encode' ),
46     LICENSE     => 'perl',
47     PMLIBDIRS   => \@pmlibdirs,
48     INSTALLDIRS => ($] < 5.011 ? 'perl' : 'site'),
49 );
50
51 package MY;
52
53
54 sub post_initialize
55 {
56     my ($self) = @_;
57     my %o;
58     # Find existing O_FILES
59     foreach my $f (@{$self->{'O_FILES'}})
60     {
61     $o{$f} = 1;
62     }
63     my $x = $self->{'OBJ_EXT'};
64     # Add the table O_FILES
65     foreach my $e (keys %tables)
66     {
67     $o{$e.$x} = 1;
68     }
69     # Trick case-blind filesystems.
70     delete $o{'encode'.$x};
71     $o{'Encode'.$x} = 1;
72     # Reset the variable
73     $self->{'O_FILES'} = [sort keys %o];
74     my @files;
75     foreach my $table (keys %tables)
76     {
77     foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
78     {
79     push (@files,$table.$ext);
80     }
81     $self->{SOURCE} .= " $table.c"
82     if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
83 }
84 $self->{'clean'}{'FILES'} .= join(' ',@files);
85 return '';
86 }
87
88 sub postamble
89 {
90     my $self = shift;
91     my $dir  = $self->catdir($self->curdir,'ucm');
92     my $str  = "# Encode\$(OBJ_EXT) does not depend on .c files directly\n";
93     $str  .= "# (except Encode.c), but on .h and .exh files written by enc2xs\n";
94     $str  .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
95     $str  .= ' Encode.c';
96     foreach my $table (keys %tables)
97     {
98     $str .= " $table.c";
99     }
100     $str .= "\n\n";
101     foreach my $table (keys %tables)
102     {
103     my $numlines = 1;
104     my $lengthsofar = length($str);
105     my $continuator = '';
106     my $enc2xs = $self->catfile('bin', 'enc2xs');
107     $str .= "$table.c : $enc2xs Makefile.PL";
108     foreach my $file (@{$tables{$table}})
109     {
110         $str .= $continuator.' '.$self->catfile($dir,$file);
111         if ( length($str)-$lengthsofar > 128*$numlines )
112         {
113         $continuator .= " \\\n\t";
114         $numlines++;
115         } else {
116         $continuator = '';
117         }
118     }
119     my $plib   = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
120     $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
121     my $ucopts = '-"Q" -"O"';
122     $str .=
123         qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
124     open (FILELIST, ">$table.fnm")
125         || die "Could not open $table.fnm: $!";
126     foreach my $file (@{$tables{$table}})
127     {
128         print FILELIST $self->catfile($dir,$file) . "\n";
129     }
130     close(FILELIST);
131     }
132     return $str;
133 }