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