This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH @15001] ISO-IR-165 --> ISO_IR_165
[perl5.git] / ext / Encode / TW / Makefile.PL
CommitLineData
d811239c
NIS
1use 5.7.2;
2use strict;
3use ExtUtils::MakeMaker;
4
f500e210 5my %tables = ('BIG5' => ['big5.enc'],
8de3d090 6 'BIG5_HKSCS' => ['big5-hkscs.enc'],
f500e210 7 'CP950' => ['cp950.enc'],
3de3d21f 8 );
d811239c 9
0e567a6c 10my $name = 'TW';
d811239c
NIS
11
12WriteMakefile(
13 INC => "-I..",
6d4ed59b
NIS
14 NAME => 'Encode::'.$name,
15 VERSION_FROM => "$name.pm",
d811239c
NIS
16 OBJECT => '$(O_FILES)',
17 'dist' => {
18 COMPRESS => 'gzip -9f',
19 SUFFIX => 'gz',
20 DIST_DEFAULT => 'all tardist',
21 },
22 MAN3PODS => {},
1604a540
NIS
23 # OS 390 winges about line numbers > 64K ???
24 XSOPT => '-nolinenumbers',
d811239c
NIS
25 );
26
27package MY;
28
d811239c
NIS
29sub post_initialize
30{
31 my ($self) = @_;
32 my %o;
33 my $x = $self->{'OBJ_EXT'};
34 # Add the table O_FILES
35 foreach my $e (keys %tables)
36 {
37 $o{$e.$x} = 1;
38 }
6d4ed59b 39 $o{"$name$x"} = 1;
d811239c 40 $self->{'O_FILES'} = [sort keys %o];
6d4ed59b
NIS
41 my @files = ("$name.xs");
42 $self->{'C'} = ["$name.c"];
43 $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
d811239c
NIS
44 my %xs;
45 foreach my $table (keys %tables) {
6d4ed59b
NIS
46 push (@{$self->{'C'}},"$table.c");
47 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
48 # get built.
b90c9a30 49 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm)) {
d811239c
NIS
50 push (@files,$table.$ext);
51 }
52 }
6d4ed59b 53 $self->{'XS'} = { "$name.xs" => "$name.c" };
d811239c 54 $self->{'clean'}{'FILES'} .= join(' ',@files);
6d4ed59b 55 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
b90c9a30
NIS
56 print XS <<'END';
57#include <EXTERN.h>
58#include <perl.h>
59#include <XSUB.h>
60#define U8 U8
61#include "../encode.h"
62END
63 foreach my $table (keys %tables) {
64 print XS qq[#include "${table}.h"\n];
65 }
6d4ed59b 66 print XS <<"END";
b90c9a30
NIS
67
68static void
69Encode_XSEncoding(pTHX_ encode_t *enc)
70{
71 dSP;
72 HV *stash = gv_stashpv("Encode::XS", TRUE);
73 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
74 int i = 0;
75 PUSHMARK(sp);
76 XPUSHs(sv);
77 while (enc->name[i])
78 {
79 const char *name = enc->name[i++];
80 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
81 }
82 PUTBACK;
83 call_pv("Encode::define_encoding",G_DISCARD);
84 SvREFCNT_dec(sv);
85}
86
6d4ed59b 87MODULE = Encode::$name PACKAGE = Encode::$name
b90c9a30
NIS
88BOOT:
89{
90END
91 foreach my $table (keys %tables) {
92 print XS qq[#include "${table}_def.h"\n];
93 }
94 print XS "}\n";
95 close(XS);
6d4ed59b 96 return "# Built $name.xs\n\n";
d811239c
NIS
97}
98
99sub postamble
100{
101 my $self = shift;
102 my $dir = $self->catdir($self->updir,'Encode');
6d4ed59b
NIS
103 my $str = "# $name\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by compile\n";
104 $str .= "$name.c : $name.xs ";
d811239c
NIS
105 foreach my $table (keys %tables)
106 {
107 $str .= " $table.c";
108 }
109 $str .= "\n\n";
6d4ed59b
NIS
110 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
111
d811239c
NIS
112 my $compile = $self->catfile($self->updir,'compile');
113 foreach my $table (keys %tables)
114 {
115 my $numlines = 1;
116 my $lengthsofar = length($str);
117 my $continuator = '';
b90c9a30 118 $str .= "$table.c : $compile Makefile.PL";
d811239c
NIS
119 foreach my $file (@{$tables{$table}})
120 {
121 $str .= $continuator.' '.$self->catfile($dir,$file);
122 if ( length($str)-$lengthsofar > 128*$numlines )
123 {
124 $continuator .= " \\\n\t";
125 $numlines++;
126 } else {
127 $continuator = '';
128 }
129 }
3964a085
NC
130 $str .= $^O eq 'VMS' # In VMS quote to preserve case
131 ? qq{\n\t\$(PERL) $compile -"Q" -o \$\@ -f $table.fnm\n\n}
132 : qq{\n\t\$(PERL) $compile -Q -o \$\@ -f $table.fnm\n\n};
d811239c
NIS
133 open (FILELIST, ">$table.fnm")
134 || die "Could not open $table.fnm: $!";
135 foreach my $file (@{$tables{$table}})
136 {
137 print FILELIST $self->catfile($dir,$file) . "\n";
138 }
139 close(FILELIST);
140 }
141 return $str;
142}
143