Commit | Line | Data |
3ef515df |
1 | # |
2 | # This file is auto-generated by: |
3 | # enc2xs version $_Version_ |
4 | # $_Now_ |
5 | # |
6 | use 5.7.2; |
7 | use strict; |
8 | use ExtUtils::MakeMaker; |
9 | |
10 | # Please edit the following to the taste! |
11 | my $name = '$_Name_'; |
12 | my %tables = ( |
13 | $_Name__t => [ $_TableFiles_ ], |
14 | ); |
15 | |
16 | #### DO NOT EDIT BEYOND THIS POINT! |
17 | my $enc2xs = '$_Enc2xs_'; |
18 | WriteMakefile( |
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 | |
34 | package MY; |
35 | |
36 | sub 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" |
69 | END |
70 | foreach my $table (keys %tables) { |
71 | print XS qq[#include "${table}.h"\n]; |
72 | } |
73 | print XS <<"END"; |
74 | |
75 | static void |
76 | Encode_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 | |
94 | MODULE = Encode::$name PACKAGE = Encode::$name |
95 | PROTOTYPES: DISABLE |
96 | BOOT: |
97 | { |
98 | END |
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 | |
107 | sub 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 | } |
80a5d8e7 |
137 | my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : ''; |
138 | my $ucopts = '-"Q"'; |
a999c27c |
139 | $str .= |
140 | qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n}; |
3ef515df |
141 | open (FILELIST, ">$table.fnm") |
142 | || die "Could not open $table.fnm: $!"; |
143 | foreach my $file (@{$tables{$table}}) |
144 | { |
145 | print FILELIST $self->catfile($dir,$file) . "\n"; |
146 | } |
147 | close(FILELIST); |
148 | } |
149 | return $str; |
150 | } |
151 | |