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