3 use ExtUtils::MakeMaker;
5 my %tables = (EUC_CN => ['euc-cn.enc'],
6 GB2312 => ['gb2312.enc'],
7 GB12345 => ['gb12345.enc'],
8 CP936 => ['cp936.enc'],
9 'ISO_IR_165' => ['iso-ir-165.enc'],
16 NAME => 'Encode::'.$name,
17 VERSION_FROM => "$name.pm",
18 OBJECT => '$(O_FILES)',
20 COMPRESS => 'gzip -9f',
22 DIST_DEFAULT => 'all tardist',
25 # OS 390 winges about line numbers > 64K ???
26 XSOPT => '-nolinenumbers',
27 XSPROTOARG => '-noprototypes',
36 my $x = $self->{'OBJ_EXT'};
37 # Add the table O_FILES
38 foreach my $e (keys %tables)
43 $self->{'O_FILES'} = [sort keys %o];
44 my @files = ("$name.xs");
45 $self->{'C'} = ["$name.c"];
46 $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
48 foreach my $table (keys %tables) {
49 push (@{$self->{'C'}},"$table.c");
50 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
52 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) {
53 push (@files,$table.$ext);
56 $self->{'XS'} = { "$name.xs" => "$name.c" };
57 $self->{'clean'}{'FILES'} .= join(' ',@files);
58 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
64 #include "../encode.h"
66 foreach my $table (keys %tables) {
67 print XS qq[#include "${table}.h"\n];
72 Encode_XSEncoding(pTHX_ encode_t *enc)
75 HV *stash = gv_stashpv("Encode::XS", TRUE);
76 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
82 const char *name = enc->name[i++];
83 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
86 call_pv("Encode::define_encoding",G_DISCARD);
90 MODULE = Encode::$name PACKAGE = Encode::$name
95 foreach my $table (keys %tables) {
96 print XS qq[#include "${table}_def.h"\n];
100 return "# Built $name.xs\n\n";
106 my $dir = $self->catdir($self->updir,'Encode');
107 my $str = "# $name\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n";
108 $str .= "$name.c : $name.xs ";
109 foreach my $table (keys %tables)
114 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
116 my $compile = $self->catfile($self->updir,'compile');
117 foreach my $table (keys %tables)
120 my $lengthsofar = length($str);
121 my $continuator = '';
122 $str .= "$table.c : $compile Makefile.PL";
123 foreach my $file (@{$tables{$table}})
125 $str .= $continuator.' '.$self->catfile($dir,$file);
126 if ( length($str)-$lengthsofar > 128*$numlines )
128 $continuator .= " \\\n\t";
134 $str .= $^O eq 'VMS' # In VMS quote to preserve case
135 ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
136 : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
137 open (FILELIST, ">$table.fnm")
138 || die "Could not open $table.fnm: $!";
139 foreach my $file (@{$tables{$table}})
141 print FILELIST $self->catfile($dir,$file) . "\n";