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