This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Encode 2.16
[perl5.git] / ext / Encode / Makefile.PL
CommitLineData
3ef515df 1use 5.007003;
2c674647 2use ExtUtils::MakeMaker;
14a8264b 3
a999c27c 4# Just for sure :)
8676e7d3
JH
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
JH
9my %tables =
10 (
071db25d 11 def_t => ['ascii.ucm',
d1256cb1
RGS
12 '8859-1.ucm',
13 'null.ucm',
14 'ctrl.ucm',
15 ]
5d030b67 16 );
14a8264b 17
3ef515df 18my @exe_files = qw(bin/enc2xs
d1256cb1
RGS
19 bin/piconv
20 );
3ef515df 21my @more_exe_files = qw(
d1256cb1
RGS
22 unidump
23 );
3ef515df 24my @pmlibdirs = qw(lib Encode);
8676e7d3
JH
25
26$ARGV{MORE_SCRIOPTS} and push @exe_files, @more_exe_files;
27$ARGV{INSTALL_UCM} and push @pmlibdirs, "ucm";
67d7b5ef 28
2c674647 29WriteMakefile(
d1256cb1
RGS
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 );
2f2b4ff2
NIS
45
46package MY;
47
311a0942
NIS
48
49sub post_initialize
50{
18586f54
NIS
51 my ($self) = @_;
52 my %o;
53 # Find existing O_FILES
54 foreach my $f (@{$self->{'O_FILES'}})
55 {
d1256cb1 56 $o{$f} = 1;
18586f54
NIS
57 }
58 my $x = $self->{'OBJ_EXT'};
59 # Add the table O_FILES
60 foreach my $e (keys %tables)
14a8264b 61 {
d1256cb1 62 $o{$e.$x} = 1;
14a8264b 63 }
18586f54
NIS
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 {
d1256cb1 72 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
18586f54 73 {
d1256cb1 74 push (@files,$table.$ext);
18586f54 75 }
f0a41339 76 $self->{SOURCE} .= " $table.c"
d1256cb1 77 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
18586f54
NIS
78}
79$self->{'clean'}{'FILES'} .= join(' ',@files);
80return '';
311a0942
NIS
81}
82
2f2b4ff2
NIS
83sub postamble
84{
18586f54 85 my $self = shift;
3ef515df 86 my $dir = $self->catdir($self->curdir,'ucm');
8f1ed24a
MHM
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";
f0a41339 89 $str .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
8f1ed24a 90 $str .= ' Encode.c';
18586f54 91 foreach my $table (keys %tables)
14a8264b 92 {
d1256cb1 93 $str .= " $table.c";
14a8264b 94 }
18586f54
NIS
95 $str .= "\n\n";
96 foreach my $table (keys %tables)
14a8264b 97 {
d1256cb1
RGS
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);
14a8264b 126 }
18586f54 127 return $str;
2f2b4ff2 128}