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