Commit | Line | Data |
df1df145 |
1 | use 5.7.2; |
2 | use strict; |
2c674647 |
3 | use ExtUtils::MakeMaker; |
14a8264b |
4 | |
94b89828 |
5 | my %tables = (8859 => ['ascii.ucm', 'cp1250.ucm', 'koi8-r.ucm' ], |
e03ac092 |
6 | EBCDIC => ['cp1047.ucm','cp37.ucm','posix-bc.ucm'], |
7 | Symbols => ['symbol.ucm','dingbats.ucm'], |
df1df145 |
8 | ); |
14a8264b |
9 | |
10 | opendir(ENC,'Encode'); |
11 | while (defined(my $file = readdir(ENC))) |
df1df145 |
12 | { |
13 | if ($file =~ /8859.*\.ucm/) |
14 | { |
15 | push(@{$tables{8859}},$file); |
16 | } |
17 | } |
14a8264b |
18 | closedir(ENC); |
19 | |
311a0942 |
20 | |
2c674647 |
21 | WriteMakefile( |
df1df145 |
22 | NAME => "Encode", |
28030390 |
23 | VERSION_FROM => 'Encode.pm', |
df1df145 |
24 | OBJECT => '$(O_FILES)', |
25 | 'dist' => { |
26 | COMPRESS => 'gzip -9f', |
27 | SUFFIX => 'gz', |
28 | DIST_DEFAULT => 'all tardist', |
29 | }, |
30 | MAN3PODS => {}, |
31 | ); |
2f2b4ff2 |
32 | |
33 | package MY; |
34 | |
311a0942 |
35 | |
36 | sub post_initialize |
37 | { |
df1df145 |
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 | { |
df1df145 |
49 | $o{$e.$x} = 1; |
14a8264b |
50 | } |
df1df145 |
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 | { |
59 | foreach my $ext (qw($(OBJ_EXT) .c .h .def .fnm)) |
60 | { |
61 | push (@files,$table.$ext); |
62 | } |
63 | } |
64 | $self->{'clean'}{'FILES'} .= join(' ',@files); |
65 | return ''; |
311a0942 |
66 | } |
67 | |
2f2b4ff2 |
68 | sub postamble |
69 | { |
df1df145 |
70 | my $self = shift; |
71 | my $dir = $self->catdir($self->curdir,'Encode'); |
72 | my $str = "# Encode\$(OBJ_EXT) depends on .h and .def files not .c files - but all written by compile\n"; |
73 | $str .= 'Encode$(OBJ_EXT) :'; |
74 | foreach my $table (keys %tables) |
14a8264b |
75 | { |
df1df145 |
76 | $str .= " $table.c"; |
14a8264b |
77 | } |
df1df145 |
78 | $str .= "\n\n"; |
79 | foreach my $table (keys %tables) |
14a8264b |
80 | { |
df1df145 |
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 | } |
96 | $str .= "\n\t\$(PERL) compile -o \$\@ -f $table.fnm\n\n"; |
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 | } |
df1df145 |
105 | return $str; |
2f2b4ff2 |
106 | } |