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