3 use ExtUtils::MakeMaker;
6 my %tables = (euc_kr_t => ['euc-kr.ucm',
10 '5601_t' => ['ksc5601.ucm'],
11 johab_t => ['johab.ucm'],
14 unless ($ENV{AGGREGATE_TABLES}){
16 for my $k (keys %tables){
17 push @ucm, @{$tables{$k}};
21 for my $ucm (sort @ucm){
23 my $t = sprintf ("%s_%02d_t", substr($ucm, 0, 2), $seq++);
24 $tables{$t} = [ $ucm ];
32 NAME => 'Encode::'.$name,
33 VERSION_FROM => "$name.pm",
34 OBJECT => '$(O_FILES)',
36 COMPRESS => 'gzip -9f',
38 DIST_DEFAULT => 'all tardist',
41 # OS 390 winges about line numbers > 64K ???
42 XSOPT => '-nolinenumbers',
51 my $x = $self->{'OBJ_EXT'};
52 # Add the table O_FILES
53 foreach my $e (keys %tables)
58 $self->{'O_FILES'} = [sort keys %o];
59 my @files = ("$name.xs");
60 $self->{'C'} = ["$name.c"];
61 $self->{SOURCE} .= " $name.c"
62 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
63 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
65 foreach my $table (keys %tables) {
66 push (@{$self->{'C'}},"$table.c");
67 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
69 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
70 push (@files,$table.$ext);
72 $self->{SOURCE} .= " $table.c"
73 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
75 $self->{'XS'} = { "$name.xs" => "$name.c" };
76 $self->{'clean'}{'FILES'} .= join(' ',@files);
77 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
84 foreach my $table (sort keys %tables) {
85 print XS qq[#include "${table}.h"\n];
90 Encode_XSEncoding(pTHX_ encode_t *enc)
93 HV *stash = gv_stashpv("Encode::XS", TRUE);
94 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
100 const char *name = enc->name[i++];
101 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
104 call_pv("Encode::define_encoding",G_DISCARD);
108 MODULE = Encode::$name PACKAGE = Encode::$name
113 foreach my $table (sort keys %tables) {
114 print XS qq[#include "${table}.exh"\n];
118 return "# Built $name.xs\n\n";
124 my $dir = $self->catdir($self->updir,'ucm');
125 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
126 $str .= "$name.c : $name.xs ";
127 foreach my $table (keys %tables)
132 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
134 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
135 foreach my $table (keys %tables)
138 my $lengthsofar = length($str);
139 my $continuator = '';
140 $str .= "$table.c : $enc2xs Makefile.PL";
141 foreach my $file (@{$tables{$table}})
143 $str .= $continuator.' '.$self->catfile($dir,$file);
144 if ( length($str)-$lengthsofar > 128*$numlines )
146 $continuator .= " \\\n\t";
152 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
153 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
156 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
157 open (FILELIST, ">$table.fnm")
158 || die "Could not open $table.fnm: $!";
159 foreach my $file (@{$tables{$table}})
161 print FILELIST $self->catfile($dir,$file) . "\n";