3 use ExtUtils::MakeMaker;
4 use File::Spec::Functions;
11 # 'gsm0338.ucm', now in Encode::GSM0338
17 'koi8-f.ucm', 'koi8-r.ucm', 'koi8-u.ucm',
42 '8859-1.ucm', # default
43 qw(cp037.ucm cp1026.ucm cp1047.ucm cp500.ucm cp875.ucm), # EBCDIC
44 qw(cp932.ucm cp936.ucm cp949.ucm cp950.ucm), # CJK
47 opendir(ENC,catdir(updir(),'ucm')) or die $!;
48 while (defined(my $file = readdir(ENC)))
50 $file =~ /^(8859|cp).*\.ucm$/io or next;
51 $not_here{$file} and next;
52 push(@{$tables{byte_t}},$file);
58 NAME => 'Encode::'.$name,
59 VERSION_FROM => "$name.pm",
60 OBJECT => '$(O_FILES)',
62 COMPRESS => 'gzip -9f',
64 DIST_DEFAULT => 'all tardist',
67 # OS 390 winges about line numbers > 64K ???
68 XSOPT => '-nolinenumbers',
77 my $x = $self->{'OBJ_EXT'};
78 # Add the table O_FILES
79 foreach my $e (keys %tables)
84 $self->{'O_FILES'} = [sort keys %o];
85 my @files = ("$name.xs");
86 $self->{'C'} = ["$name.c"];
87 $self->{SOURCE} .= " $name.c"
88 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
89 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
91 foreach my $table (keys %tables) {
92 push (@{$self->{'C'}},"$table.c");
93 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
95 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
96 push (@files,$table.$ext);
98 $self->{SOURCE} .= " $table.c"
99 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
101 $self->{'XS'} = { "$name.xs" => "$name.c" };
102 $self->{'clean'}{'FILES'} .= join(' ',@files);
103 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
111 foreach my $table (keys %tables) {
112 print XS qq[#include "${table}.h"\n];
117 Encode_XSEncoding(pTHX_ encode_t *enc)
120 HV *stash = gv_stashpv("Encode::XS", TRUE);
121 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
127 const char *name = enc->name[i++];
128 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
131 call_pv("Encode::define_encoding",G_DISCARD);
135 MODULE = Encode::$name PACKAGE = Encode::$name
140 foreach my $table (keys %tables) {
141 print XS qq[#include "${table}.exh"\n];
145 return "# Built $name.xs\n\n";
151 my $dir = $self->catdir($self->updir,'ucm');
152 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
153 $str .= "$name.c : $name.xs ";
154 foreach my $table (keys %tables)
159 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
161 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
162 foreach my $table (keys %tables)
165 my $lengthsofar = length($str);
166 my $continuator = '';
167 $str .= "$table.c : $enc2xs Makefile.PL";
168 foreach my $file (@{$tables{$table}})
170 $str .= $continuator.' '.$self->catfile($dir,$file);
171 if ( length($str)-$lengthsofar > 128*$numlines )
173 $continuator .= " \\\n\t";
179 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
180 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
181 my $ucopts = '-"Q" -"O"';
183 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
184 open (FILELIST, ">$table.fnm")
185 || die "Could not open $table.fnm: $!";
186 foreach my $file (@{$tables{$table}})
188 print FILELIST $self->catfile($dir,$file) . "\n";