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