fixes for various warnings identified by Visual C++
[p5sagit/p5-mst-13.2.git] / ext / Encode / Makefile.PL
1 use 5.007003;
2 use ExtUtils::MakeMaker;
3
4 # Just for sure :)
5 unless($ENV{PERL_CORE}) {
6     $ENV{PERL_CORE} = 1 if ($^X =~ m{\bminiperl[^/\\\]>:]*$}o);
7 }
8
9 my %tables = 
10     (
11      def_t => ['ascii.ucm',
12                '8859-1.ucm',
13                ]
14      );
15
16 my @exe_files = qw(bin/enc2xs
17                    bin/piconv
18                    );
19 my @more_exe_files = qw(
20                         unidump
21                         );
22 my @pmlibdirs = qw(lib Encode);
23 for my $arg (@ARGV){
24     if ($arg eq "MORE_SCRIPTS"){
25         push @exe_files, @more_exe_files;
26     }
27     if ($arg eq "INSTALL_UCM"){
28         push @pmlibdirs, "ucm";
29     }
30 }
31
32 WriteMakefile(
33               NAME              => "Encode",
34               EXE_FILES         => \@exe_files,
35               VERSION_FROM      => 'Encode.pm',
36               OBJECT            => '$(O_FILES)',
37               'dist'            => {
38                   COMPRESS      => 'gzip -9f',
39                   SUFFIX        => 'gz',
40                   DIST_DEFAULT => 'all tardist',
41               },
42               MAN3PODS  => {},
43               INC       => "-I./Encode",
44               PMLIBDIRS => \@pmlibdirs,
45               );
46
47 package MY;
48
49
50 sub post_initialize
51 {
52     my ($self) = @_;
53     my %o;
54     # Find existing O_FILES
55     foreach my $f (@{$self->{'O_FILES'}})
56     {
57         $o{$f} = 1;
58     }
59     my $x = $self->{'OBJ_EXT'};
60     # Add the table O_FILES
61     foreach my $e (keys %tables)
62     {
63         $o{$e.$x} = 1;
64     }
65     # Trick case-blind filesystems.
66     delete $o{'encode'.$x};
67     $o{'Encode'.$x} = 1;
68     # Reset the variable
69     $self->{'O_FILES'} = [sort keys %o];
70     my @files;
71     foreach my $table (keys %tables)
72     {
73         foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
74     {
75         push (@files,$table.$ext);
76     }
77 }
78 $self->{'clean'}{'FILES'} .= join(' ',@files);
79 return '';
80 }
81
82 sub postamble
83 {
84     my $self = shift;
85     my $dir  = $self->catdir($self->curdir,'ucm');
86     my $str  = "# Encode\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
87     $str  .= 'Encode$(OBJ_EXT) :';
88     foreach my $table (keys %tables)
89     {
90         $str .= " $table.c";
91     }
92     $str .= "\n\n";
93     foreach my $table (keys %tables)
94     {
95         my $numlines = 1;
96         my $lengthsofar = length($str);
97         my $continuator = '';
98         my $enc2xs = $self->catfile('bin', 'enc2xs');
99         $str .= "$table.c : $enc2xs Makefile.PL";
100         foreach my $file (@{$tables{$table}})
101         {
102             $str .= $continuator.' '.$self->catfile($dir,$file);
103             if ( length($str)-$lengthsofar > 128*$numlines )
104             {
105                 $continuator .= " \\\n\t";
106                 $numlines++;
107             } else {
108                 $continuator = '';
109             }
110         }
111         my $plib   = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
112         my $ucopts = '-"Q" -"O"';
113         $str .=
114             qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
115         open (FILELIST, ">$table.fnm")
116             || die "Could not open $table.fnm: $!";
117         foreach my $file (@{$tables{$table}})
118         {
119             print FILELIST $self->catfile($dir,$file) . "\n";
120         }
121         close(FILELIST);
122     }
123     return $str;
124 }