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