3 use ExtUtils::MakeMaker;
15 qw(macCentEuro.enc macCroatian.enc
16 macCyrillic.enc macDingbats.enc
17 macGreek.enc macIceland.enc
18 macRoman.enc macRumanian.enc
19 macSami.enc macThai.enc
20 macTurkish.enc macUkraine.enc),
24 opendir(ENC,'../Encode');
25 while (defined(my $file = readdir(ENC)))
27 if ($file =~ /(8859|ibm).*\.ucm/io)
29 push(@{$tables{$1."_t"}},$file) unless $file eq '8859-1.ucm';
36 NAME => 'Encode::'.$name,
37 VERSION_FROM => "$name.pm",
38 OBJECT => '$(O_FILES)',
40 COMPRESS => 'gzip -9f',
42 DIST_DEFAULT => 'all tardist',
45 # OS 390 winges about line numbers > 64K ???
46 XSOPT => '-nolinenumbers',
55 my $x = $self->{'OBJ_EXT'};
56 # Add the table O_FILES
57 foreach my $e (keys %tables)
62 $self->{'O_FILES'} = [sort keys %o];
63 my @files = ("$name.xs");
64 $self->{'C'} = ["$name.c"];
65 $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
67 foreach my $table (keys %tables) {
68 push (@{$self->{'C'}},"$table.c");
69 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
71 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) {
72 push (@files,$table.$ext);
75 $self->{'XS'} = { "$name.xs" => "$name.c" };
76 $self->{'clean'}{'FILES'} .= join(' ',@files);
77 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
83 #include "../encode.h"
85 foreach my $table (keys %tables) {
86 print XS qq[#include "${table}.h"\n];
91 Encode_XSEncoding(pTHX_ encode_t *enc)
94 HV *stash = gv_stashpv("Encode::XS", TRUE);
95 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
101 const char *name = enc->name[i++];
102 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
105 call_pv("Encode::define_encoding",G_DISCARD);
109 MODULE = Encode::$name PACKAGE = Encode::$name
114 foreach my $table (keys %tables) {
115 print XS qq[#include "${table}_def.h"\n];
119 return "# Built $name.xs\n\n";
125 my $dir = $self->catdir($self->updir,'Encode');
126 my $str = "# $name\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n";
127 $str .= "$name.c : $name.xs ";
128 foreach my $table (keys %tables)
133 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
135 my $compile = $self->catfile($self->updir,'compile');
136 foreach my $table (keys %tables)
139 my $lengthsofar = length($str);
140 my $continuator = '';
141 $str .= "$table.c : $compile Makefile.PL";
142 foreach my $file (@{$tables{$table}})
144 $str .= $continuator.' '.$self->catfile($dir,$file);
145 if ( length($str)-$lengthsofar > 128*$numlines )
147 $continuator .= " \\\n\t";
153 $str .= $^O eq 'VMS' # In VMS quote to preserve case
154 ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
155 : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
156 open (FILELIST, ">$table.fnm")
157 || die "Could not open $table.fnm: $!";
158 foreach my $file (@{$tables{$table}})
160 print FILELIST $self->catfile($dir,$file) . "\n";