home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _27384d558babbaf78f7786814ba15c6a < prev    next >
Text File  |  2004-06-01  |  5KB  |  181 lines

  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. use Config;
  10.  
  11. # Please edit the following to the taste!
  12. my $name = '$_Name_';
  13. my %tables = (
  14.          $_Name__t   => [ $_TableFiles_ ],
  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. #### 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.  
  60. package MY;
  61.  
  62. sub 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"
  98. END
  99.     foreach my $table (keys %tables) {
  100.     print XS qq[#include "${table}.h"\n];
  101.     }
  102.     print XS <<"END";
  103.  
  104. static void
  105. Encode_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.  
  123. MODULE = Encode::$name    PACKAGE = Encode::$name
  124. PROTOTYPES: DISABLE
  125. BOOT:
  126. {
  127. END
  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.  
  136. sub 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.  
  181.