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