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->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
63 foreach my $table (keys %tables) {
64 push (@{$self->{'C'}},"$table.c");
65 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
67 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
68 push (@files,$table.$ext);
71 $self->{'XS'} = { "$name.xs" => "$name.c" };
72 $self->{'clean'}{'FILES'} .= join(' ',@files);
73 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
81 foreach my $table (keys %tables) {
82 print XS qq[#include "${table}.h"\n];
87 Encode_XSEncoding(pTHX_ encode_t *enc)
90 HV *stash = gv_stashpv("Encode::XS", TRUE);
91 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
97 const char *name = enc->name[i++];
98 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
101 call_pv("Encode::define_encoding",G_DISCARD);
105 MODULE = Encode::$name PACKAGE = Encode::$name
110 foreach my $table (keys %tables) {
111 print XS qq[#include "${table}.exh"\n];
115 return "# Built $name.xs\n\n";
121 my $dir = $self->catdir($self->updir,'ucm');
122 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
123 $str .= "$name.c : $name.xs ";
124 foreach my $table (keys %tables)
129 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
131 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
132 foreach my $table (keys %tables)
135 my $lengthsofar = length($str);
136 my $continuator = '';
137 $str .= "$table.c : $enc2xs Makefile.PL";
138 foreach my $file (@{$tables{$table}})
140 $str .= $continuator.' '.$self->catfile($dir,$file);
141 if ( length($str)-$lengthsofar > 128*$numlines )
143 $continuator .= " \\\n\t";
149 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
150 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
153 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
154 open (FILELIST, ">$table.fnm")
155 || die "Could not open $table.fnm: $!";
156 foreach my $file (@{$tables{$table}})
158 print FILELIST $self->catfile($dir,$file) . "\n";