3 use ExtUtils::MakeMaker;
14 koi8_t => [ 'koi8-f.ucm', 'koi8-r.ucm', 'koi8-u.ucm', ],
33 opendir(ENC,'../ucm');
34 while (defined(my $file = readdir(ENC)))
36 if ($file =~ /(8859|ibm).*\.ucm/io)
38 push(@{$tables{$1."_t"}},$file) unless $file eq '8859-1.ucm';
45 NAME => 'Encode::'.$name,
46 VERSION_FROM => "$name.pm",
47 OBJECT => '$(O_FILES)',
49 COMPRESS => 'gzip -9f',
51 DIST_DEFAULT => 'all tardist',
54 # OS 390 winges about line numbers > 64K ???
55 XSOPT => '-nolinenumbers',
64 my $x = $self->{'OBJ_EXT'};
65 # Add the table O_FILES
66 foreach my $e (keys %tables)
71 $self->{'O_FILES'} = [sort keys %o];
72 my @files = ("$name.xs");
73 $self->{'C'} = ["$name.c"];
74 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
76 foreach my $table (keys %tables) {
77 push (@{$self->{'C'}},"$table.c");
78 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
80 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
81 push (@files,$table.$ext);
84 $self->{'XS'} = { "$name.xs" => "$name.c" };
85 $self->{'clean'}{'FILES'} .= join(' ',@files);
86 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
94 foreach my $table (keys %tables) {
95 print XS qq[#include "${table}.h"\n];
100 Encode_XSEncoding(pTHX_ encode_t *enc)
103 HV *stash = gv_stashpv("Encode::XS", TRUE);
104 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
110 const char *name = enc->name[i++];
111 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
114 call_pv("Encode::define_encoding",G_DISCARD);
118 MODULE = Encode::$name PACKAGE = Encode::$name
123 foreach my $table (keys %tables) {
124 print XS qq[#include "${table}.exh"\n];
128 return "# Built $name.xs\n\n";
134 my $dir = $self->catdir($self->updir,'ucm');
135 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
136 $str .= "$name.c : $name.xs ";
137 foreach my $table (keys %tables)
142 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
144 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
145 foreach my $table (keys %tables)
148 my $lengthsofar = length($str);
149 my $continuator = '';
150 $str .= "$table.c : $enc2xs Makefile.PL";
151 foreach my $file (@{$tables{$table}})
153 $str .= $continuator.' '.$self->catfile($dir,$file);
154 if ( length($str)-$lengthsofar > 128*$numlines )
156 $continuator .= " \\\n\t";
162 $str .= $^O eq 'VMS' # In VMS quote to preserve case
163 ? qq{\n\t\$(PERL) $enc2xs -"Q" -o \$\@ -f $table.fnm\n\n}
164 : qq{\n\t\$(PERL) $enc2xs -Q -o \$\@ -f $table.fnm\n\n};
165 open (FILELIST, ">$table.fnm")
166 || die "Could not open $table.fnm: $!";
167 foreach my $file (@{$tables{$table}})
169 print FILELIST $self->catfile($dir,$file) . "\n";