source: for-distributions/trunk/bin/windows/perl/lib/Encode/Makefile_PL.e2x@ 14489

Last change on this file since 14489 was 14489, checked in by oranfry, 17 years ago

upgrading to perl 5.8

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