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