Integrate mainline
[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 = (
a999c27c 7 symbol_t => [qw(
8 symbol.ucm
9 dingbats.ucm
10 adobeSymbol.ucm
11 adobeZdingbat.ucm
12 macSymbol.ucm
13 macDingbats.ucm
14 )
15 ],
5129552c 16 );
17
18WriteMakefile(
67d7b5ef 19 INC => "-I../Encode",
5129552c 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 );
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 {
43 $o{$e.$x} = 1;
44 }
45 $o{"$name$x"} = 1;
46 $self->{'O_FILES'} = [sort keys %o];
47 my @files = ("$name.xs");
48 $self->{'C'} = ["$name.c"];
67d7b5ef 49 $self->{'H'} = [$self->catfile($self->updir,'Encode', 'encode.h')];
5129552c 50 my %xs;
51 foreach my $table (keys %tables) {
52 push (@{$self->{'C'}},"$table.c");
53 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
54 # get built.
e7cbefb8 55 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
5129552c 56 push (@files,$table.$ext);
57 }
58 }
59 $self->{'XS'} = { "$name.xs" => "$name.c" };
60 $self->{'clean'}{'FILES'} .= join(' ',@files);
61 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
62 print XS <<'END';
63#include <EXTERN.h>
64#include <perl.h>
65#include <XSUB.h>
66#define U8 U8
67d7b5ef 67#include "encode.h"
5129552c 68END
69 foreach my $table (keys %tables) {
70 print XS qq[#include "${table}.h"\n];
71 }
72 print XS <<"END";
73
74static void
75Encode_XSEncoding(pTHX_ encode_t *enc)
76{
77 dSP;
78 HV *stash = gv_stashpv("Encode::XS", TRUE);
79 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
80 int i = 0;
81 PUSHMARK(sp);
82 XPUSHs(sv);
83 while (enc->name[i])
84 {
85 const char *name = enc->name[i++];
86 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
87 }
88 PUTBACK;
89 call_pv("Encode::define_encoding",G_DISCARD);
90 SvREFCNT_dec(sv);
91}
92
93MODULE = Encode::$name PACKAGE = Encode::$name
94PROTOTYPES: DISABLE
95BOOT:
96{
97END
98 foreach my $table (keys %tables) {
e7cbefb8 99 print XS qq[#include "${table}.exh"\n];
5129552c 100 }
101 print XS "}\n";
102 close(XS);
103 return "# Built $name.xs\n\n";
104}
105
106sub postamble
107{
108 my $self = shift;
3ef515df 109 my $dir = $self->catdir($self->updir,'ucm');
e7cbefb8 110 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
5129552c 111 $str .= "$name.c : $name.xs ";
112 foreach my $table (keys %tables)
113 {
114 $str .= " $table.c";
115 }
116 $str .= "\n\n";
117 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
118
67d7b5ef 119 my $enc2xs = $self->catfile($self->updir,'bin', 'enc2xs');
5129552c 120 foreach my $table (keys %tables)
121 {
122 my $numlines = 1;
123 my $lengthsofar = length($str);
124 my $continuator = '';
67d7b5ef 125 $str .= "$table.c : $enc2xs Makefile.PL";
5129552c 126 foreach my $file (@{$tables{$table}})
127 {
128 $str .= $continuator.' '.$self->catfile($dir,$file);
129 if ( length($str)-$lengthsofar > 128*$numlines )
130 {
131 $continuator .= " \\\n\t";
132 $numlines++;
133 } else {
134 $continuator = '';
135 }
136 }
80a5d8e7 137 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
138 my $ucopts = '-"Q" -"O"';
a999c27c 139 $str .=
140 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
5129552c 141 open (FILELIST, ">$table.fnm")
142 || die "Could not open $table.fnm: $!";
143 foreach my $file (@{$tables{$table}})
144 {
145 print FILELIST $self->catfile($dir,$file) . "\n";
146 }
147 close(FILELIST);
148 }
149 return $str;
150}
151