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),
25 opendir(ENC,'../Encode');
26 while (defined(my $file = readdir(ENC)))
28 if ($file =~ /(8859|ibm).*\.ucm/io)
30 push(@{$tables{$1}},$file);
37 NAME => 'Encode::'.$name,
38 VERSION_FROM => "$name.pm",
39 OBJECT => '$(O_FILES)',
41 COMPRESS => 'gzip -9f',
43 DIST_DEFAULT => 'all tardist',
46 # OS 390 winges about line numbers > 64K ???
47 XSOPT => '-nolinenumbers',
56 my $x = $self->{'OBJ_EXT'};
57 # Add the table O_FILES
58 foreach my $e (keys %tables)
63 $self->{'O_FILES'} = [sort keys %o];
64 my @files = ("$name.xs");
65 $self->{'C'} = ["$name.c"];
66 $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
68 foreach my $table (keys %tables) {
69 push (@{$self->{'C'}},"$table.c");
70 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
72 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) {
73 push (@files,$table.$ext);
76 $self->{'XS'} = { "$name.xs" => "$name.c" };
77 $self->{'clean'}{'FILES'} .= join(' ',@files);
78 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
84 #include "../encode.h"
86 foreach my $table (keys %tables) {
87 print XS qq[#include "${table}.h"\n];
92 Encode_XSEncoding(pTHX_ encode_t *enc)
95 HV *stash = gv_stashpv("Encode::XS", TRUE);
96 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
102 const char *name = enc->name[i++];
103 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
106 call_pv("Encode::define_encoding",G_DISCARD);
110 MODULE = Encode::$name PACKAGE = Encode::$name
115 foreach my $table (keys %tables) {
116 print XS qq[#include "${table}_def.h"\n];
120 return "# Built $name.xs\n\n";
126 my $dir = $self->catdir($self->updir,'Encode');
127 my $str = "# $name\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n";
128 $str .= "$name.c : $name.xs ";
129 foreach my $table (keys %tables)
134 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
136 my $compile = $self->catfile($self->updir,'compile');
137 foreach my $table (keys %tables)
140 my $lengthsofar = length($str);
141 my $continuator = '';
142 $str .= "$table.c : $compile Makefile.PL";
143 foreach my $file (@{$tables{$table}})
145 $str .= $continuator.' '.$self->catfile($dir,$file);
146 if ( length($str)-$lengthsofar > 128*$numlines )
148 $continuator .= " \\\n\t";
154 $str .= $^O eq 'VMS' # In VMS quote to preserve case
155 ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
156 : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
157 open (FILELIST, ">$table.fnm")
158 || die "Could not open $table.fnm: $!";
159 foreach my $file (@{$tables{$table}})
161 print FILELIST $self->catfile($dir,$file) . "\n";