Tweak for 8.3 compat.
[p5sagit/p5-mst-13.2.git] / ext / Encode / Encode / Makefile_PL.e2x
CommitLineData
3ef515df 1#
2# This file is auto-generated by:
3# enc2xs version $_Version_
4# $_Now_
5#
6use 5.7.2;
7use strict;
8use ExtUtils::MakeMaker;
9
10# Please edit the following to the taste!
11my $name = '$_Name_';
12my %tables = (
13 $_Name__t => [ $_TableFiles_ ],
14 );
15
16#### DO NOT EDIT BEYOND THIS POINT!
17my $enc2xs = '$_Enc2xs_';
18WriteMakefile(
19 INC => "-I$_Inc_",
20#### END_OF_HEADER -- DO NOT EDIT THIS LINE BY HAND! ####
21 NAME => 'Encode::'.$name,
22 VERSION_FROM => "$name.pm",
23 OBJECT => '$(O_FILES)',
24 'dist' => {
25 COMPRESS => 'gzip -9f',
26 SUFFIX => 'gz',
27 DIST_DEFAULT => 'all tardist',
28 },
29 MAN3PODS => {},
30 # OS 390 winges about line numbers > 64K ???
31 XSOPT => '-nolinenumbers',
32 );
33
34package MY;
35
36sub post_initialize
37{
38 my ($self) = @_;
39 my %o;
40 my $x = $self->{'OBJ_EXT'};
41 # Add the table O_FILES
42 foreach my $e (keys %tables)
43 {
44 $o{$e.$x} = 1;
45 }
46 $o{"$name$x"} = 1;
47 $self->{'O_FILES'} = [sort keys %o];
48 my @files = ("$name.xs");
49 $self->{'C'} = ["$name.c"];
50 # $self->{'H'} = [$self->catfile($self->updir,'encode.h')];
51 my %xs;
52 foreach my $table (keys %tables) {
53 push (@{$self->{'C'}},"$table.c");
54 # Do NOT add $table.h etc. to H_FILES unless we own up as to how they
55 # get built.
e7cbefb8 56 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) {
3ef515df 57 push (@files,$table.$ext);
58 }
59 }
60 $self->{'XS'} = { "$name.xs" => "$name.c" };
61 $self->{'clean'}{'FILES'} .= join(' ',@files);
62 open(XS,">$name.xs") || die "Cannot open $name.xs:$!";
63 print XS <<'END';
64#include <EXTERN.h>
65#include <perl.h>
66#include <XSUB.h>
67#define U8 U8
68#include "encode.h"
69END
70 foreach my $table (keys %tables) {
71 print XS qq[#include "${table}.h"\n];
72 }
73 print XS <<"END";
74
75static void
76Encode_XSEncoding(pTHX_ encode_t *enc)
77{
78 dSP;
79 HV *stash = gv_stashpv("Encode::XS", TRUE);
80 SV *sv = sv_bless(newRV_noinc(newSViv(PTR2IV(enc))),stash);
81 int i = 0;
82 PUSHMARK(sp);
83 XPUSHs(sv);
84 while (enc->name[i])
85 {
86 const char *name = enc->name[i++];
87 XPUSHs(sv_2mortal(newSVpvn(name,strlen(name))));
88 }
89 PUTBACK;
90 call_pv("Encode::define_encoding",G_DISCARD);
91 SvREFCNT_dec(sv);
92}
93
94MODULE = Encode::$name PACKAGE = Encode::$name
95PROTOTYPES: DISABLE
96BOOT:
97{
98END
99 foreach my $table (keys %tables) {
e7cbefb8 100 print XS qq[#include "${table}.exh"\n];
3ef515df 101 }
102 print XS "}\n";
103 close(XS);
104 return "# Built $name.xs\n\n";
105}
106
107sub postamble
108{
109 my $self = shift;
110 my $dir = "."; # $self->catdir('Encode');
e7cbefb8 111 my $str = "# $name\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
3ef515df 112 $str .= "$name.c : $name.xs ";
113 foreach my $table (keys %tables)
114 {
115 $str .= " $table.c";
116 }
117 $str .= "\n\n";
118 $str .= "$name\$(OBJ_EXT) : $name.c\n\n";
119
120 foreach my $table (keys %tables)
121 {
122 my $numlines = 1;
123 my $lengthsofar = length($str);
124 my $continuator = '';
125 $str .= "$table.c : Makefile.PL";
126 foreach my $file (@{$tables{$table}})
127 {
128 $str .= $continuator.' '.$self->catfile($dir,$file);
129 if ( length($str)-$lengthsofar > 128*$numlines )
130 {
131 $continuator .= " \\\n\t";
132 $numlines++;
133 } else {
134 $continuator = '';
135 }
136 }
137 $str .= $^O eq 'VMS' # In VMS quote to preserve case
138 ? qq{\n\t\$(PERL) $enc2xs -"Q" -"O" -o \$\@ -f $table.fnm\n\n}
139 : qq{\n\t\$(PERL) $enc2xs -Q -O -o \$\@ -f $table.fnm\n\n};
140 open (FILELIST, ">$table.fnm")
141 || die "Could not open $table.fnm: $!";
142 foreach my $file (@{$tables{$table}})
143 {
144 print FILELIST $self->catfile($dir,$file) . "\n";
145 }
146 close(FILELIST);
147 }
148 return $str;
149}
150