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