3 use ExtUtils::MakeMaker;
6 my %tables = (big5_t => ['big5-eten.ucm',
12 unless ($ENV{AGGREGATE_TABLES}){
14 for my $k (keys %tables){
15 push @ucm, @{$tables{$k}};
19 for my $ucm (sort @ucm){
21 my $t = sprintf ("%s_%02d_t", substr($ucm, 0, 2), $seq++);
22 $tables{$t} = [ $ucm ];
30 NAME => 'Encode::'.$name,
31 VERSION_FROM => "$name.pm",
32 OBJECT => '$(O_FILES)',
34 COMPRESS => 'gzip -9f',
36 DIST_DEFAULT => 'all tardist',
39 # OS 390 winges about line numbers > 64K ???
40 XSOPT => '-nolinenumbers',
49 my $x = $self->{'OBJ_EXT'};
50 # Add the table O_FILES
51 foreach my $e (keys %tables)
56 $self->{'O_FILES'} = [sort keys %o];
57 my @files = ("$name.xs");
58 $self->{'C'} = ["$name.c"];
59 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
61 foreach my $table (keys %tables) {
62 push (@{$self->{'C'}},"$table.c");
63 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
65 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
66 push (@files,$table.$ext);
69 $self->{'XS'} = { "$name.xs" => "$name.c" };
70 $self->{'clean'}{'FILES'} .= join(' ',@files);
71 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
79 foreach my $table (keys %tables) {
80 print XS qq[#include "${table}.h"\n];
85 Encode_XSEncoding(pTHX_ encode_t *enc)
88 HV *stash = gv_stashpv("Encode::XS", TRUE);
89 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
95 const char *name = enc->name[i++];
96 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
99 call_pv("Encode::define_encoding",G_DISCARD);
103 MODULE = Encode::$name PACKAGE = Encode::$name
108 foreach my $table (keys %tables) {
109 print XS qq[#include "${table}.exh"\n];
113 return "# Built $name.xs\n\n";
119 my $dir = $self->catdir($self->updir,'ucm');
120 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
121 $str .= "$name.c : $name.xs ";
122 foreach my $table (keys %tables)
127 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
129 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
130 foreach my $table (keys %tables)
133 my $lengthsofar = length($str);
134 my $continuator = '';
135 $str .= "$table.c : $enc2xs Makefile.PL";
136 foreach my $file (@{$tables{$table}})
138 $str .= $continuator.' '.$self->catfile($dir,$file);
139 if ( length($str)-$lengthsofar > 128*$numlines )
141 $continuator .= " \\\n\t";
147 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
148 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
151 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
152 open (FILELIST, ">$table.fnm")
153 || die "Could not open $table.fnm: $!";
154 foreach my $file (@{$tables{$table}})
156 print FILELIST $self->catfile($dir,$file) . "\n";