ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/staticperl/perl/ext/Encode/KR/Makefile.PL
Revision: 1.1
Committed: Thu Jun 30 14:26:47 2005 UTC (21 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: PERL-5-8-7, HEAD
Branch point for: PERL
Log Message:
*** empty log message ***

File Contents

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