Update Changes.
[p5sagit/p5-mst-13.2.git] / ext / Encode / Makefile.PL
CommitLineData
3ef515df 1use 5.007003;
2c674647 2use ExtUtils::MakeMaker;
14a8264b 3
a999c27c 4# Just for sure :)
5unless($ENV{PERL_CORE}) {
6 $ENV{PERL_CORE} = 1 if ($^X =~ m{\bminiperl[^/\\\]>:]*$}o);
7}
8
5d030b67 9my %tables =
10 (
071db25d 11 def_t => ['ascii.ucm',
12 '8859-1.ucm',
f0a41339 13 'null.ucm',
14 'ctrl.ucm',
071db25d 15 ]
5d030b67 16 );
14a8264b 17
3ef515df 18my @exe_files = qw(bin/enc2xs
19 bin/piconv
20 );
21my @more_exe_files = qw(
a999c27c 22 unidump
3ef515df 23 );
24my @pmlibdirs = qw(lib Encode);
67d7b5ef 25for my $arg (@ARGV){
037b88d6 26 if ($arg eq "MORE_SCRIPTS"){
67d7b5ef 27 push @exe_files, @more_exe_files;
28 }
3ef515df 29 if ($arg eq "INSTALL_UCM"){
30 push @pmlibdirs, "ucm";
31 }
67d7b5ef 32}
33
2c674647 34WriteMakefile(
18586f54 35 NAME => "Encode",
67d7b5ef 36 EXE_FILES => \@exe_files,
023d8852 37 VERSION_FROM => 'Encode.pm',
18586f54 38 OBJECT => '$(O_FILES)',
39 'dist' => {
40 COMPRESS => 'gzip -9f',
41 SUFFIX => 'gz',
42 DIST_DEFAULT => 'all tardist',
43 },
44 MAN3PODS => {},
3ef515df 45 INC => "-I./Encode",
46 PMLIBDIRS => \@pmlibdirs,
f74b3917 47 INSTALLDIRS => 'perl',
18586f54 48 );
2f2b4ff2 49
50package MY;
51
311a0942 52
53sub post_initialize
54{
18586f54 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)
14a8264b 65 {
18586f54 66 $o{$e.$x} = 1;
14a8264b 67 }
18586f54 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 {
e7cbefb8 76 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
18586f54 77 {
78 push (@files,$table.$ext);
79 }
f0a41339 80 $self->{SOURCE} .= " $table.c"
81 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
18586f54 82}
83$self->{'clean'}{'FILES'} .= join(' ',@files);
84return '';
311a0942 85}
86
2f2b4ff2 87sub postamble
88{
18586f54 89 my $self = shift;
3ef515df 90 my $dir = $self->catdir($self->curdir,'ucm');
e7cbefb8 91 my $str = "# Encode\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
f0a41339 92 $str .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
18586f54 93 foreach my $table (keys %tables)
14a8264b 94 {
18586f54 95 $str .= " $table.c";
14a8264b 96 }
18586f54 97 $str .= "\n\n";
98 foreach my $table (keys %tables)
14a8264b 99 {
18586f54 100 my $numlines = 1;
101 my $lengthsofar = length($str);
102 my $continuator = '';
67d7b5ef 103 my $enc2xs = $self->catfile('bin', 'enc2xs');
104 $str .= "$table.c : $enc2xs Makefile.PL";
18586f54 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 }
46fc212f 116 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
b88803e8 117 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
46fc212f 118 my $ucopts = '-"Q" -"O"';
119 $str .=
a999c27c 120 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
18586f54 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);
14a8264b 128 }
18586f54 129 return $str;
2f2b4ff2 130}