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