3 use ExtUtils::MakeMaker;
16 'koi8-f.ucm', 'koi8-r.ucm', 'koi8-u.ucm',
41 '8859-1.ucm', # default
42 qw(cp037.ucm cp1026.ucm cp1047.ucm cp500.ucm cp875.ucm), # EBCDIC
43 qw(cp932.ucm cp936.ucm cp949.ucm cp950.ucm), # CJK
46 opendir(ENC,'../ucm');
47 while (defined(my $file = readdir(ENC)))
49 $file =~ /^(8859|cp).*\.ucm$/io or next;
50 $not_here{$file} and next;
51 push(@{$tables{byte_t}},$file);
57 NAME => 'Encode::'.$name,
58 VERSION_FROM => "$name.pm",
59 OBJECT => '$(O_FILES)',
61 COMPRESS => 'gzip -9f',
63 DIST_DEFAULT => 'all tardist',
66 # OS 390 winges about line numbers > 64K ???
67 XSOPT => '-nolinenumbers',
76 my $x = $self->{'OBJ_EXT'};
77 # Add the table O_FILES
78 foreach my $e (keys %tables)
83 $self->{'O_FILES'} = [sort keys %o];
84 my @files = ("$name.xs");
85 $self->{'C'} = ["$name.c"];
86 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
88 foreach my $table (keys %tables) {
89 push (@{$self->{'C'}},"$table.c");
90 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
92 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
93 push (@files,$table.$ext);
96 $self->{'XS'} = { "$name.xs" => "$name.c" };
97 $self->{'clean'}{'FILES'} .= join(' ',@files);
98 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
106 foreach my $table (keys %tables) {
107 print XS qq[#include "${table}.h"\n];
112 Encode_XSEncoding(pTHX_ encode_t *enc)
115 HV *stash = gv_stashpv("Encode::XS", TRUE);
116 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
122 const char *name = enc->name[i++];
123 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
126 call_pv("Encode::define_encoding",G_DISCARD);
130 MODULE = Encode::$name PACKAGE = Encode::$name
135 foreach my $table (keys %tables) {
136 print XS qq[#include "${table}.exh"\n];
140 return "# Built $name.xs\n\n";
146 my $dir = $self->catdir($self->updir,'ucm');
147 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
148 $str .= "$name.c : $name.xs ";
149 foreach my $table (keys %tables)
154 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
156 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
157 foreach my $table (keys %tables)
160 my $lengthsofar = length($str);
161 my $continuator = '';
162 $str .= "$table.c : $enc2xs Makefile.PL";
163 foreach my $file (@{$tables{$table}})
165 $str .= $continuator.' '.$self->catfile($dir,$file);
166 if ( length($str)-$lengthsofar > 128*$numlines )
168 $continuator .= " \\\n\t";
174 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
175 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
176 my $ucopts = '-"Q" -"O"';
178 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
179 open (FILELIST, ">$table.fnm")
180 || die "Could not open $table.fnm: $!";
181 foreach my $file (@{$tables{$table}})
183 print FILELIST $self->catfile($dir,$file) . "\n";