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