[admin] set up .gitignore files
[p5sagit/p5-mst-13.2.git] / ext / Encode / Makefile.PL
CommitLineData
370462a2 1#
2fd0906e 2# $Id: Makefile.PL,v 2.7 2008/07/01 20:56:17 dankogai Exp dankogai $
370462a2 3#
3ef515df 4use 5.007003;
370462a2 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 15my %tables =
16 (
071db25d 17 def_t => ['ascii.ucm',
d1256cb1 18 '8859-1.ucm',
19 'null.ucm',
20 'ctrl.ucm',
21 ]
5d030b67 22 );
14a8264b 23
3ef515df 24my @exe_files = qw(bin/enc2xs
d1256cb1 25 bin/piconv
26 );
3ef515df 27my @more_exe_files = qw(
d1256cb1 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";
370462a2 34my @man = ();
35@man = ( MAN1PODS => {}, MAN3PODS => {} ) if $ENV{PERL_CORE};
67d7b5ef 36
2c674647 37WriteMakefile(
2fd0906e 38 NAME => "Encode",
39 EXE_FILES => \@exe_files,
40 VERSION_FROM => 'Encode.pm',
41 OBJECT => '$(O_FILES)',
42 'dist' => {
43 COMPRESS => 'gzip -9f',
44 SUFFIX => 'gz',
45 DIST_DEFAULT => 'all tardist',
46 },
47 @man,
48 INC => '-I' . File::Spec->catfile( '.', 'Encode' ),
49 PMLIBDIRS => \@pmlibdirs,
50 INSTALLDIRS => 'perl',
51);
2f2b4ff2 52
53package MY;
54
311a0942 55
56sub post_initialize
57{
18586f54 58 my ($self) = @_;
59 my %o;
60 # Find existing O_FILES
61 foreach my $f (@{$self->{'O_FILES'}})
62 {
d1256cb1 63 $o{$f} = 1;
18586f54 64 }
65 my $x = $self->{'OBJ_EXT'};
66 # Add the table O_FILES
67 foreach my $e (keys %tables)
14a8264b 68 {
d1256cb1 69 $o{$e.$x} = 1;
14a8264b 70 }
18586f54 71 # Trick case-blind filesystems.
72 delete $o{'encode'.$x};
73 $o{'Encode'.$x} = 1;
74 # Reset the variable
75 $self->{'O_FILES'} = [sort keys %o];
76 my @files;
77 foreach my $table (keys %tables)
78 {
d1256cb1 79 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm))
18586f54 80 {
d1256cb1 81 push (@files,$table.$ext);
18586f54 82 }
f0a41339 83 $self->{SOURCE} .= " $table.c"
d1256cb1 84 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/;
18586f54 85}
86$self->{'clean'}{'FILES'} .= join(' ',@files);
87return '';
311a0942 88}
89
2f2b4ff2 90sub postamble
91{
18586f54 92 my $self = shift;
3ef515df 93 my $dir = $self->catdir($self->curdir,'ucm');
8f1ed24a 94 my $str = "# Encode\$(OBJ_EXT) does not depend on .c files directly\n";
95 $str .= "# (except Encode.c), but on .h and .exh files written by enc2xs\n";
f0a41339 96 $str .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :';
8f1ed24a 97 $str .= ' Encode.c';
18586f54 98 foreach my $table (keys %tables)
14a8264b 99 {
d1256cb1 100 $str .= " $table.c";
14a8264b 101 }
18586f54 102 $str .= "\n\n";
103 foreach my $table (keys %tables)
14a8264b 104 {
d1256cb1 105 my $numlines = 1;
106 my $lengthsofar = length($str);
107 my $continuator = '';
108 my $enc2xs = $self->catfile('bin', 'enc2xs');
109 $str .= "$table.c : $enc2xs Makefile.PL";
110 foreach my $file (@{$tables{$table}})
111 {
112 $str .= $continuator.' '.$self->catfile($dir,$file);
113 if ( length($str)-$lengthsofar > 128*$numlines )
114 {
115 $continuator .= " \\\n\t";
116 $numlines++;
117 } else {
118 $continuator = '';
119 }
120 }
121 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : '';
122 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform;
123 my $ucopts = '-"Q" -"O"';
124 $str .=
125 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n};
126 open (FILELIST, ">$table.fnm")
127 || die "Could not open $table.fnm: $!";
128 foreach my $file (@{$tables{$table}})
129 {
130 print FILELIST $self->catfile($dir,$file) . "\n";
131 }
132 close(FILELIST);
14a8264b 133 }
18586f54 134 return $str;
2f2b4ff2 135}