3 use ExtUtils::MakeMaker;
5 my %tables = (EUC_JP => ['euc-jp.enc'],
6 SHIFTJIS => ['shiftjis.enc'],
7 MACJAPAN => ['macJapan.enc'],
8 CP932 => ['cp932.enc'],
15 NAME => 'Encode::'.$name,
16 VERSION_FROM => "$name.pm",
17 OBJECT => '$(O_FILES)',
19 COMPRESS => 'gzip -9f',
21 DIST_DEFAULT => 'all tardist',
24 # OS 390 winges about line numbers > 64K ???
25 XSOPT => '-nolinenumbers',
34 my $x = $self->{'OBJ_EXT'};
35 # Add the table O_FILES
36 foreach my $e (keys %tables)
41 $self->{'O_FILES'} = [sort keys %o];
42 my @files = ("$name.xs");
43 $self->{'C'} = ["$name.c"];
44 $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
46 foreach my $table (keys %tables) {
47 push (@{$self->{'C'}},"$table.c");
48 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
50 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) {
51 push (@files,$table.$ext);
54 $self->{'XS'} = { "$name.xs" => "$name.c" };
55 $self->{'clean'}{'FILES'} .= join(' ',@files);
56 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
62 #include "../encode.h"
64 foreach my $table (keys %tables) {
65 print XS qq[#include "${table}.h"\n];
70 Encode_XSEncoding(pTHX_ encode_t *enc)
73 HV *stash = gv_stashpv("Encode::XS", TRUE);
74 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
80 const char *name = enc->name[i++];
81 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
84 call_pv("Encode::define_encoding",G_DISCARD);
88 MODULE = Encode::$name PACKAGE = Encode::$name
92 foreach my $table (keys %tables) {
93 print XS qq[#include "${table}_def.h"\n];
97 return "# Built $name.xs\n\n";
103 my $dir = $self->catdir($self->updir,'Encode');
104 my $str = "# $name\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n";
105 $str .= "$name.c : $name.xs ";
106 foreach my $table (keys %tables)
111 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
113 my $compile = $self->catfile($self->updir,'compile');
114 foreach my $table (keys %tables)
117 my $lengthsofar = length($str);
118 my $continuator = '';
119 $str .= "$table.c : $compile Makefile.PL";
120 foreach my $file (@{$tables{$table}})
122 $str .= $continuator.' '.$self->catfile($dir,$file);
123 if ( length($str)-$lengthsofar > 128*$numlines )
125 $continuator .= " \\\n\t";
131 $str .= $^O eq 'VMS' # In VMS quote to preserve case
132 ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
133 : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
134 open (FILELIST, ">$table.fnm")
135 || die "Could not open $table.fnm: $!";
136 foreach my $file (@{$tables{$table}})
138 print FILELIST $self->catfile($dir,$file) . "\n";