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