ucmlintage.
[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 :)
8676e7d3 5my %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};
a999c27c 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);
8676e7d3 25
26$ARGV{MORE_SCRIOPTS} and push @exe_files, @more_exe_files;
27$ARGV{INSTALL_UCM} and push @pmlibdirs, "ucm";
67d7b5ef 28
2c674647 29WriteMakefile(
18586f54 30 NAME => "Encode",
67d7b5ef 31 EXE_FILES => \@exe_files,
023d8852 32 VERSION_FROM => 'Encode.pm',
18586f54 33 OBJECT => '$(O_FILES)',
34 'dist' => {
35 COMPRESS => 'gzip -9f',
36 SUFFIX => 'gz',
37 DIST_DEFAULT => 'all tardist',
38 },
39 MAN3PODS => {},
3ef515df 40 INC => "-I./Encode",
41 PMLIBDIRS => \@pmlibdirs,
f74b3917 42 INSTALLDIRS => 'perl',
18586f54 43 );
2f2b4ff2 44
45package MY;
46
311a0942 47
48sub post_initialize
49{
18586f54 50 my ($self) = @_;
51 my %o;
52 # Find existing O_FILES
53 foreach my $f (@{$self->{'O_FILES'}})
54 {
55 $o{$f} = 1;
56 }
57 my $x = $self->{'OBJ_EXT'};
58 # Add the table O_FILES
59 foreach my $e (keys %tables)
14a8264b 60 {
18586f54 61 $o{$e.$x} = 1;
14a8264b 62 }
18586f54 63 # Trick case-blind filesystems.
64 delete $o{'encode'.$x};
65 $o{'Encode'.$x} = 1;
66 # Reset the variable
67 $self->{'O_FILES'} = [sort keys %o];
68 my @files;
69 foreach my $table (keys %tables)
70 {
e7cbefb8 71 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
18586f54 72 {
73 push (@files,$table.$ext);
74 }
f0a41339 75 $self->{SOURCE} .= " $table.c"
76 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
18586f54 77}
78$self->{'clean'}{'FILES'} .= join(' ',@files);
79return '';
311a0942 80}
81
2f2b4ff2 82sub postamble
83{
18586f54 84 my $self = shift;
3ef515df 85 my $dir = $self->catdir($self->curdir,'ucm');
e7cbefb8 86 my $str = "# Encode\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n";
f0a41339 87 $str .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
18586f54 88 foreach my $table (keys %tables)
14a8264b 89 {
18586f54 90 $str .= " $table.c";
14a8264b 91 }
18586f54 92 $str .= "\n\n";
93 foreach my $table (keys %tables)
14a8264b 94 {
18586f54 95 my $numlines = 1;
96 my $lengthsofar = length($str);
97 my $continuator = '';
67d7b5ef 98 my $enc2xs = $self->catfile('bin', 'enc2xs');
99 $str .= "$table.c : $enc2xs Makefile.PL";
18586f54 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 }
46fc212f 111 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
b88803e8 112 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
46fc212f 113 my $ucopts = '-"Q" -"O"';
114 $str .=
a999c27c 115 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
18586f54 116 open (FILELIST, ">$table.fnm")
117 || die "Could not open $table.fnm: $!";
118 foreach my $file (@{$tables{$table}})
119 {
120 print FILELIST $self->catfile($dir,$file) . "\n";
121 }
122 close(FILELIST);
14a8264b 123 }
18586f54 124 return $str;
2f2b4ff2 125}