Upgrade to Encode 1.00, 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 my @exe_files = ();
13 my @more_exe_files = qw(bin/enc2xs bin/piconv);
14
15 for my $arg (@ARGV){
16     if ($arg eq "USE_SCRIPTS"){
17         push @exe_files, @more_exe_files;
18     }
19 }
20
21 WriteMakefile(
22               NAME              => "Encode",
23               EXE_FILES         => \@exe_files,
24               VERSION_FROM      => 'Encode.pm',
25               OBJECT            => '$(O_FILES)',
26               'dist'            => {
27                   COMPRESS      => 'gzip -9f',
28                   SUFFIX        => 'gz',
29                   DIST_DEFAULT => 'all tardist',
30               },
31               MAN3PODS  => {},
32               INC       => "-I./Encode"
33               );
34
35 package MY;
36
37
38 sub post_initialize
39 {
40     my ($self) = @_;
41     my %o;
42     # Find existing O_FILES
43     foreach my $f (@{$self->{'O_FILES'}})
44     {
45         $o{$f} = 1;
46     }
47     my $x = $self->{'OBJ_EXT'};
48     # Add the table O_FILES
49     foreach my $e (keys %tables)
50     {
51         $o{$e.$x} = 1;
52     }
53     # Trick case-blind filesystems.
54     delete $o{'encode'.$x};
55     $o{'Encode'.$x} = 1;
56     # Reset the variable
57     $self->{'O_FILES'} = [sort keys %o];
58     my @files;
59     foreach my $table (keys %tables)
60     {
61         foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm))
62     {
63         push (@files,$table.$ext);
64     }
65 }
66 $self->{'clean'}{'FILES'} .= join(' ',@files);
67 return '';
68 }
69
70 sub postamble
71 {
72     my $self = shift;
73     my $dir  = $self->catdir($self->curdir,'Encode');
74     my $str  = "# Encode\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by enc2xs\n";
75     $str  .= 'Encode$(OBJ_EXT) :';
76     foreach my $table (keys %tables)
77     {
78         $str .= " $table.c";
79     }
80     $str .= "\n\n";
81     foreach my $table (keys %tables)
82     {
83         my $numlines = 1;
84         my $lengthsofar = length($str);
85         my $continuator = '';
86         my $enc2xs = $self->catfile('bin', 'enc2xs');
87         $str .= "$table.c : $enc2xs Makefile.PL";
88         foreach my $file (@{$tables{$table}})
89         {
90             $str .= $continuator.' '.$self->catfile($dir,$file);
91             if ( length($str)-$lengthsofar > 128*$numlines )
92             {
93                 $continuator .= " \\\n\t";
94                 $numlines++;
95             } else {
96                 $continuator = '';
97             }
98         }
99         $str .= $^O eq 'VMS' # In VMS quote to preserve case
100             ? qq{\n\t\$(PERL) $enc2xs -"Q" -"O" -o \$\@ -f $table.fnm\n\n}
101             : qq{\n\t\$(PERL) $enc2xs -Q -O -o \$\@ -f $table.fnm\n\n};
102         open (FILELIST, ">$table.fnm")
103             || die "Could not open $table.fnm: $!";
104         foreach my $file (@{$tables{$table}})
105         {
106             print FILELIST $self->catfile($dir,$file) . "\n";
107         }
108         close(FILELIST);
109     }
110     return $str;
111 }