3 use ExtUtils::MakeMaker;
5 my %tables = (euc_kr_t => ['euc-kr.enc'],
6 '5601_t' => ['ksc5601.enc'],
7 cp_kr_t => ['cp949.enc'],
14 NAME => 'Encode::'.$name,
15 VERSION_FROM => "$name.pm",
16 OBJECT => '$(O_FILES)',
18 COMPRESS => 'gzip -9f',
20 DIST_DEFAULT => 'all tardist',
23 # OS 390 winges about line numbers > 64K ???
24 XSOPT => '-nolinenumbers',
33 my $x = $self->{'OBJ_EXT'};
34 # Add the table O_FILES
35 foreach my $e (keys %tables)
40 $self->{'O_FILES'} = [sort keys %o];
41 my @files = ("$name.xs");
42 $self->{'C'} = ["$name.c"];
43 $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
45 foreach my $table (keys %tables) {
46 push (@{$self->{'C'}},"$table.c");
47 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
49 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) {
50 push (@files,$table.$ext);
53 $self->{'XS'} = { "$name.xs" => "$name.c" };
54 $self->{'clean'}{'FILES'} .= join(' ',@files);
55 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
61 #include "../encode.h"
63 foreach my $table (keys %tables) {
64 print XS qq[#include "${table}.h"\n];
69 Encode_XSEncoding(pTHX_ encode_t *enc)
72 HV *stash = gv_stashpv("Encode::XS", TRUE);
73 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
79 const char *name = enc->name[i++];
80 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
83 call_pv("Encode::define_encoding",G_DISCARD);
87 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";