Commit | Line | Data |
5129552c |
1 | use 5.7.2; |
2 | use strict; |
3 | use ExtUtils::MakeMaker; |
4 | |
5 | my $name = 'Symbol'; |
6 | my %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 | |
18 | WriteMakefile( |
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 | |
33 | package MY; |
34 | |
35 | sub 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"]; |
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) { |
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. |
e7cbefb8 |
57 | foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) { |
5129552c |
58 | push (@files,$table.$ext); |
59 | } |
f0a41339 |
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 |
72 | END |
73 | foreach my $table (keys %tables) { |
74 | print XS qq[#include "${table}.h"\n]; |
75 | } |
76 | print XS <<"END"; |
77 | |
78 | static void |
79 | Encode_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 | |
97 | MODULE = Encode::$name PACKAGE = Encode::$name |
98 | PROTOTYPES: DISABLE |
99 | BOOT: |
100 | { |
101 | END |
102 | foreach my $table (keys %tables) { |
e7cbefb8 |
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 | |
110 | sub 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 | { |
118 | $str .= " $table.c"; |
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 | { |
126 | my $numlines = 1; |
127 | my $lengthsofar = length($str); |
128 | my $continuator = ''; |
67d7b5ef |
129 | $str .= "$table.c : $enc2xs Makefile.PL"; |
5129552c |
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 | } |
46fc212f |
141 | my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : ''; |
fefd7080 |
142 | $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform; |
46fc212f |
143 | my $ucopts = '-"Q" -"O"'; |
a999c27c |
144 | $str .= |
145 | qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n}; |
5129552c |
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); |
153 | } |
154 | return $str; |
155 | } |
156 | |