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