Minor Encode tweaks:
[p5sagit/p5-mst-13.2.git] / ext / Encode / EUC_JP / Makefile.PL
1 use 5.7.2;
2 use strict;
3 use ExtUtils::MakeMaker;
4
5 my %tables = (EUC_JP  => [
6                 'euc-jp.ucm',
7 #               'jis0201.enc',
8 #               'jis0212.enc',
9 #               'jis0208.enc',
10 #               'shiftjis.enc',
11               ]);
12
13
14 WriteMakefile(
15               INC               => "-I..",
16               NAME              => "Encode::EUC_JP",
17               VERSION_FROM      => 'EUC_JP.pm',
18               OBJECT            => '$(O_FILES)',
19               'dist'            => {
20                   COMPRESS      => 'gzip -9f',
21                   SUFFIX        => 'gz',
22                   DIST_DEFAULT => 'all tardist',
23               },
24               MAN3PODS  => {},
25               );
26
27 package MY;
28
29
30 sub post_initialize
31 {
32     my ($self) = @_;
33     my %o;
34     my $x = $self->{'OBJ_EXT'};
35     # Add the table O_FILES
36     foreach my $e (keys %tables)
37     {
38         $o{$e.$x} = 1;
39     }
40     $self->{'O_FILES'} = [sort keys %o];
41     my @files;
42     my %xs;
43     foreach my $table (keys %tables) {
44         $xs{"$table.xs"} = "$table.c";
45         foreach my $ext (qw($(OBJ_EXT) .xs .c .h _def.h .fnm)) {
46             push (@files,$table.$ext);
47         }
48     }
49     $self->{'XS_FILES'} = {%xs};
50     $self->{'clean'}{'FILES'} .= join(' ',@files);
51     return '';
52 }
53
54 sub postamble
55 {
56     my $self = shift;
57     my $dir  = $self->catdir($self->updir,'Encode');
58     my $str  = "# Encode\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n";
59     $str  .= 'Encode$(OBJ_EXT) :';
60     foreach my $table (keys %tables)
61     {
62         $str .= " $table.c";
63     }
64     $str .= "\n\n";
65     my $compile = $self->catfile($self->updir,'compile');
66     foreach my $table (keys %tables)
67     {
68         my $numlines = 1;
69         my $lengthsofar = length($str);
70         my $continuator = '';
71         $str .= "$table.xs : $compile Makefile.PL";
72         foreach my $file (@{$tables{$table}})
73         {
74             $str .= $continuator.' '.$self->catfile($dir,$file);
75             if ( length($str)-$lengthsofar > 128*$numlines )
76             {
77                 $continuator .= " \\\n\t";
78                 $numlines++;
79             } else {
80                 $continuator = '';
81             }
82         }
83         $str .= "\n\t\$(PERL) $compile -o \$\@ -f $table.fnm\n\n";
84         open (FILELIST, ">$table.fnm")
85             || die "Could not open $table.fnm: $!";
86         foreach my $file (@{$tables{$table}})
87         {
88             print FILELIST $self->catfile($dir,$file) . "\n";
89         }
90         close(FILELIST);
91     }
92     return $str;
93 }
94