This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Win32 0.34
[perl5.git] / ext / Encode / Makefile.PL
1 #
2 # $Id: Makefile.PL,v 2.5 2007/05/29 18:15:32 dankogai Exp dankogai $
3 #
4 use 5.007003;
5 use strict;
6 use warnings;
7 use ExtUtils::MakeMaker;
8
9 # Just for sure :)
10 my %ARGV = map { my @r = split /=/,$_; defined $r[1] or $r[1]=1; @r } @ARGV;
11 $ARGV{DEBUG} and warn "$_ => $ARGV{$_}\n" for keys  %ARGV;
12 $ENV{PERL_CORE} ||= $ARGV{PERL_CORE} if $ARGV{PERL_CORE};
13
14 my %tables = 
15     (
16      def_t => ['ascii.ucm',
17            '8859-1.ucm',
18            'null.ucm',
19            'ctrl.ucm',
20            ]
21      );
22
23 my @exe_files = qw(bin/enc2xs
24            bin/piconv
25            );
26 my @more_exe_files = qw(
27             unidump
28             );
29 my @pmlibdirs = qw(lib Encode);
30
31 $ARGV{MORE_SCRIOPTS} and push @exe_files, @more_exe_files;
32 $ARGV{INSTALL_UCM}   and push @pmlibdirs, "ucm";
33 my @man =  ();
34 @man = ( MAN1PODS => {}, MAN3PODS => {} ) if $ENV{PERL_CORE};
35
36 WriteMakefile(
37           NAME          => "Encode",
38           EXE_FILES         => \@exe_files,
39           VERSION_FROM  => 'Encode.pm',
40           OBJECT                => '$(O_FILES)',
41           'dist'                => {
42           COMPRESS      => 'gzip -9f',
43           SUFFIX        => 'gz',
44           DIST_DEFAULT => 'all tardist',
45           },
46           @man,
47           INC       => "-I./Encode",
48           PMLIBDIRS => \@pmlibdirs,
49           INSTALLDIRS => 'perl',
50           );
51
52 package MY;
53
54
55 sub post_initialize
56 {
57     my ($self) = @_;
58     my %o;
59     # Find existing O_FILES
60     foreach my $f (@{$self->{'O_FILES'}})
61     {
62     $o{$f} = 1;
63     }
64     my $x = $self->{'OBJ_EXT'};
65     # Add the table O_FILES
66     foreach my $e (keys %tables)
67     {
68     $o{$e.$x} = 1;
69     }
70     # Trick case-blind filesystems.
71     delete $o{'encode'.$x};
72     $o{'Encode'.$x} = 1;
73     # Reset the variable
74     $self->{'O_FILES'} = [sort keys %o];
75     my @files;
76     foreach my $table (keys %tables)
77     {
78     foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
79     {
80     push (@files,$table.$ext);
81     }
82     $self->{SOURCE} .= " $table.c"
83     if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
84 }
85 $self->{'clean'}{'FILES'} .= join(' ',@files);
86 return '';
87 }
88
89 sub postamble
90 {
91     my $self = shift;
92     my $dir  = $self->catdir($self->curdir,'ucm');
93     my $str  = "# Encode\$(OBJ_EXT) does not depend on .c files directly\n";
94     $str  .= "# (except Encode.c), but on .h and .exh files written by enc2xs\n";
95     $str  .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
96     $str  .= ' Encode.c';
97     foreach my $table (keys %tables)
98     {
99     $str .= " $table.c";
100     }
101     $str .= "\n\n";
102     foreach my $table (keys %tables)
103     {
104     my $numlines = 1;
105     my $lengthsofar = length($str);
106     my $continuator = '';
107     my $enc2xs = $self->catfile('bin', 'enc2xs');
108     $str .= "$table.c : $enc2xs Makefile.PL";
109     foreach my $file (@{$tables{$table}})
110     {
111         $str .= $continuator.' '.$self->catfile($dir,$file);
112         if ( length($str)-$lengthsofar > 128*$numlines )
113         {
114         $continuator .= " \\\n\t";
115         $numlines++;
116         } else {
117         $continuator = '';
118         }
119     }
120     my $plib   = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
121     $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
122     my $ucopts = '-"Q" -"O"';
123     $str .=
124         qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
125     open (FILELIST, ">$table.fnm")
126         || die "Could not open $table.fnm: $!";
127     foreach my $file (@{$tables{$table}})
128     {
129         print FILELIST $self->catfile($dir,$file) . "\n";
130     }
131     close(FILELIST);
132     }
133     return $str;
134 }