Create a perl5130delta.pod
[p5sagit/p5-mst-13.2.git] / cpan / Encode / JP / Makefile.PL
CommitLineData
d811239c 1use 5.7.2;
2use strict;
3use ExtUtils::MakeMaker;
af1f55d9 4use strict;
d811239c 5
ee981de6 6my %tables = (
d1256cb1 7 euc_jp_t => ['euc-jp.ucm'],
64ffdd5e 8 sjis_t => ['shiftjis.ucm',
d1256cb1 9 'macJapanese.ucm',
10 'cp932.ucm'],
11 raw_t => [
12 qw(jis0201.ucm jis0208.ucm jis0212.ucm)
13 ],
3de3d21f 14 );
d811239c 15
af1f55d9 16unless ($ENV{AGGREGATE_TABLES}){
17 my @ucm;
18 for my $k (keys %tables){
d1256cb1 19 push @ucm, @{$tables{$k}};
af1f55d9 20 }
21 %tables = ();
22 my $seq = 0;
23 for my $ucm (sort @ucm){
d1256cb1 24 # 8.3 compliance !
25 my $t = sprintf ("%s_%02d_t", substr($ucm, 0, 2), $seq++);
26 $tables{$t} = [ $ucm ];
af1f55d9 27 }
28}
29
0e567a6c 30my $name = 'JP';
d811239c 31
32WriteMakefile(
67d7b5ef 33 INC => "-I../Encode",
d1256cb1 34 NAME => 'Encode::'.$name,
35 VERSION_FROM => "$name.pm",
36 OBJECT => '$(O_FILES)',
37 'dist' => {
38 COMPRESS => 'gzip -9f',
39 SUFFIX => 'gz',
40 DIST_DEFAULT => 'all tardist',
41 },
42 MAN3PODS => {},
43 # OS 390 winges about line numbers > 64K ???
44 XSOPT => '-nolinenumbers',
45 );
d811239c 46
47package MY;
48
d811239c 49sub post_initialize
50{
51 my ($self) = @_;
52 my %o;
53 my $x = $self->{'OBJ_EXT'};
54 # Add the table O_FILES
55 foreach my $e (keys %tables)
56 {
d1256cb1 57 $o{$e.$x} = 1;
d811239c 58 }
6d4ed59b 59 $o{"$name$x"} = 1;
d811239c 60 $self->{'O_FILES'} = [sort keys %o];
6d4ed59b 61 my @files = ("$name.xs");
62 $self->{'C'} = ["$name.c"];
f0a41339 63 $self->{SOURCE} .= " $name.c"
64 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
67d7b5ef 65 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
d811239c 66 my %xs;
67 foreach my $table (keys %tables) {
d1256cb1 68 push (@{$self->{'C'}},"$table.c");
69 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
70 # get built.
71 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
72 push (@files,$table.$ext);
73 }
74 $self->{SOURCE} .= " $table.c"
75 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
d811239c 76 }
6d4ed59b 77 $self->{'XS'} = { "$name.xs" => "$name.c" };
d811239c 78 $self->{'clean'}{'FILES'} .= join(' ',@files);
6d4ed59b 79 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
b90c9a30 80 print XS <<'END';
81#include <EXTERN.h>
82#include <perl.h>
83#include <XSUB.h>
84#define U8 U8
67d7b5ef 85#include "encode.h"
b90c9a30 86END
87 foreach my $table (keys %tables) {
d1256cb1 88 print XS qq[#include "${table}.h"\n];
b90c9a30 89 }
6d4ed59b 90 print XS <<"END";
b90c9a30 91
92static void
93Encode_XSEncoding(pTHX_ encode_t *enc)
94{
95 dSP;
96 HV *stash = gv_stashpv("Encode::XS", TRUE);
97 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
98 int i = 0;
99 PUSHMARK(sp);
100 XPUSHs(sv);
101 while (enc->name[i])
102 {
103 const char *name = enc->name[i++];
104 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
105 }
106 PUTBACK;
107 call_pv("Encode::define_encoding",G_DISCARD);
108 SvREFCNT_dec(sv);
109}
110
6d4ed59b 111MODULE = Encode::$name PACKAGE = Encode::$name
1aebe30a 112PROTOTYPES: DISABLE
b90c9a30 113BOOT:
114{
115END
116 foreach my $table (keys %tables) {
d1256cb1 117 print XS qq[#include "${table}.exh"\n];
b90c9a30 118 }
119 print XS "}\n";
120 close(XS);
6d4ed59b 121 return "# Built $name.xs\n\n";
d811239c 122}
123
124sub postamble
125{
126 my $self = shift;
3ef515df 127 my $dir = $self->catdir($self->updir,'ucm');
e7cbefb8 128 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
6d4ed59b 129 $str .= "$name.c : $name.xs ";
d811239c 130 foreach my $table (keys %tables)
131 {
d1256cb1 132 $str .= " $table.c";
d811239c 133 }
134 $str .= "\n\n";
6d4ed59b 135 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
136
67d7b5ef 137 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
d811239c 138 foreach my $table (keys %tables)
139 {
d1256cb1 140 my $numlines = 1;
141 my $lengthsofar = length($str);
142 my $continuator = '';
143 $str .= "$table.c : $enc2xs Makefile.PL";
144 foreach my $file (@{$tables{$table}})
145 {
146 $str .= $continuator.' '.$self->catfile($dir,$file);
147 if ( length($str)-$lengthsofar > 128*$numlines )
148 {
149 $continuator .= " \\\n\t";
150 $numlines++;
151 } else {
152 $continuator = '';
153 }
154 }
155 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
156 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
157 my $ucopts = '-"Q"';
158 $str .=
159 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
160 open (FILELIST, ">$table.fnm")
161 || die "Could not open $table.fnm: $!";
162 foreach my $file (@{$tables{$table}})
163 {
164 print FILELIST $self->catfile($dir,$file) . "\n";
165 }
166 close(FILELIST);
d811239c 167 }
168 return $str;
169}
170