root/lang/perl/Encode-JP-Mobile/trunk/Makefile.PL @ 3722

Revision 3722, 4.6 kB (checked in by tokuhirom, 5 years ago)

Encode-JP-Mobile: merge to trunk

Line 
1#
2# This file is auto-generated by:
3# enc2xs version 2.01
4# Wed Jun 22 12:01:25 2005
5#
6use 5.008_001;
7use strict;
8use ExtUtils::MakeMaker;
9use Config;
10
11# Please edit the following to the taste!
12my $name = 'Mobile';
13my $modname = 'JP::Mobile';
14
15my @ucms = qw( imode kddi kddi-auto softbank-auto );
16my %tables = (
17             Mobile_t   => [ map "ucm/x-sjis-$_.ucm", @ucms ],
18             );
19
20#### DO NOT EDIT BEYOND THIS POINT!
21require File::Spec;
22my ($enc2xs, $encode_h) = ();
23PATHLOOP:
24for my $d (@Config{qw/bin sitebin vendorbin/},
25           (split /$Config{path_sep}/o, $ENV{PATH})){
26    for my $f (qw/enc2xs enc2xs5.7.3/){
27        my $path = File::Spec->catfile($d, $f);
28        -r $path and $enc2xs = $path and last PATHLOOP;
29    }
30}
31$enc2xs or die "enc2xs not found!";
32print "enc2xs is $enc2xs\n";
33my %encode_h = ();
34for my $d (@INC){
35    my $dir = File::Spec->catfile($d, "Encode");
36    my $file =  File::Spec->catfile($dir, "encode.h");
37    -f $file and $encode_h{$dir} = -M $file;
38}
39%encode_h or die "encode.h not found!";
40# find the latest one
41($encode_h) = sort {$encode_h{$b} <=> $encode_h{$a}} keys %encode_h;
42print "encode.h is at $encode_h\n";
43
44WriteMakefile(
45              INC               => "-I$encode_h",
46              NAME              => "Encode::JP::Mobile",
47              VERSION_FROM      => "lib/Encode/JP/Mobile.pm",
48              OBJECT            => '$(O_FILES)',
49              'dist'            => {
50                  COMPRESS      => 'gzip -9f',
51                  SUFFIX        => 'gz',
52                  DIST_DEFAULT => 'all tardist',
53              },
54              MAN3PODS  => {},
55              PREREQ_PM => {
56                            'Encode'     => "1.41",
57                           },
58              # OS 390 winges about line numbers > 64K ???
59              XSOPT => '-nolinenumbers',
60              );
61
62package MY;
63
64sub post_initialize
65{
66    my ($self) = @_;
67    my %o;
68    my $x = $self->{'OBJ_EXT'};
69    # Add the table O_FILES
70    foreach my $e (keys %tables)
71    {
72        $o{$e.$x} = 1;
73    }
74    $o{"$name$x"} = 1;
75    $self->{'O_FILES'} = [sort keys %o];
76    my @files = ("$name.xs");
77    $self->{'C'} = ["$name.c"];
78    # The next two lines to make MacPerl Happy -- dankogai via pudge
79    $self->{SOURCE} .= " $name.c"
80        if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$name\.c\b/;
81    # $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
82    my %xs;
83    foreach my $table (keys %tables) {
84        push (@{$self->{'C'}},"$table.c");
85        # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
86        # get built.
87        foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
88            push (@files,$table.$ext);
89        }
90    }
91    $self->{'XS'} = { "$name.xs" => "$name.c" };
92    $self->{'clean'}{'FILES'} .= join(' ',@files);
93    open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
94    print XS <<'END';
95#include <EXTERN.h>
96#include <perl.h>
97#include <XSUB.h>
98#define U8 U8
99#include "encode.h"
100END
101    foreach my $table (keys %tables) {
102        print XS qq[#include "${table}.h"\n];
103    }
104    print XS <<"END";
105
106static void
107Encode_XSEncoding(pTHX_ encode_t *enc)
108{
109 dSP;
110 HV *stash = gv_stashpv("Encode::XS", TRUE);
111 SV *sv    = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
112 int i = 0;
113 PUSHMARK(sp);
114 XPUSHs(sv);
115 while (enc->name[i])
116  {
117   const char *name = enc->name[i++];
118   XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
119  }
120 PUTBACK;
121 call_pv("Encode::define_encoding",G_DISCARD);
122 SvREFCNT_dec(sv);
123}
124
125MODULE = Encode::$modname       PACKAGE = Encode::$modname
126PROTOTYPES: DISABLE
127BOOT:
128{
129END
130    foreach my $table (keys %tables) {
131        print XS qq[#include "${table}.exh"\n];
132    }
133    print XS "}\n";
134    close(XS);
135    return "# Built $name.xs\n\n";
136}
137
138sub postamble
139{
140    my $self = shift;
141    my $dir  = "."; # $self->catdir('Encode');
142    my $str  = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
143    $str    .= "$name.c : $name.xs ";
144    foreach my $table (keys %tables)
145    {
146        $str .= " $table.c";
147    }
148    $str .= "\n\n";
149    $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
150
151    foreach my $table (keys %tables)
152    {
153        my $numlines = 1;
154        my $lengthsofar = length($str);
155        my $continuator = '';
156        $str .= "$table.c : Makefile.PL";
157        foreach my $file (@{$tables{$table}})
158        {
159            $str .= $continuator.' '.$self->catfile($dir,$file);
160            if ( length($str)-$lengthsofar > 128*$numlines )
161            {
162                $continuator .= " \\\n\t";
163                $numlines++;
164            } else {
165                $continuator = '';
166            }
167        }
168        my $plib   = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
169        my $ucopts = '-"Q"';
170        $str .= 
171            qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
172        open (FILELIST, ">$table.fnm")
173            || die "Could not open $table.fnm: $!";
174        foreach my $file (@{$tables{$table}})
175        {
176            print FILELIST $self->catfile($dir,$file) . "\n";
177        }
178        close(FILELIST);
179    }
180
181    $str .= <<"...";
182config ::
183\t\$(NOECHO) \$(MOD_INSTALL) \\
184\t\t"dat" \$(INST_AUTODIR)
185...
186
187    return $str;
188}
189
Note: See TracBrowser for help on using the browser.