Re: [PATCH pp_ctl.c] [ID 20020301.011] Core dump in 'leavetry' in 5.7.2
[p5sagit/p5-mst-13.2.git] / ext / Encode / Makefile.PL
CommitLineData
3ef515df 1use 5.007003;
2c674647 2use ExtUtils::MakeMaker;
14a8264b 3
5d030b67 4my %tables =
5 (
071db25d 6 def_t => ['ascii.ucm',
7 '8859-1.ucm',
8 ]
5d030b67 9 );
14a8264b 10
3ef515df 11my @exe_files = qw(bin/enc2xs
12 bin/piconv
13 );
14my @more_exe_files = qw(
15 ucm2table
16 );
17my @pmlibdirs = qw(lib Encode);
67d7b5ef 18for my $arg (@ARGV){
037b88d6 19 if ($arg eq "MORE_SCRIPTS"){
67d7b5ef 20 push @exe_files, @more_exe_files;
21 }
3ef515df 22 if ($arg eq "INSTALL_UCM"){
23 push @pmlibdirs, "ucm";
24 }
67d7b5ef 25}
26
2c674647 27WriteMakefile(
18586f54 28 NAME => "Encode",
67d7b5ef 29 EXE_FILES => \@exe_files,
023d8852 30 VERSION_FROM => 'Encode.pm',
18586f54 31 OBJECT => '$(O_FILES)',
32 'dist' => {
33 COMPRESS => 'gzip -9f',
34 SUFFIX => 'gz',
35 DIST_DEFAULT => 'all tardist',
36 },
37 MAN3PODS => {},
3ef515df 38 INC => "-I./Encode",
39 PMLIBDIRS => \@pmlibdirs,
18586f54 40 );
2f2b4ff2 41
42package MY;
43
311a0942 44
45sub post_initialize
46{
18586f54 47 my ($self) = @_;
48 my %o;
49 # Find existing O_FILES
50 foreach my $f (@{$self->{'O_FILES'}})
51 {
52 $o{$f} = 1;
53 }
54 my $x = $self->{'OBJ_EXT'};
55 # Add the table O_FILES
56 foreach my $e (keys %tables)
14a8264b 57 {
18586f54 58 $o{$e.$x} = 1;
14a8264b 59 }
18586f54 60 # Trick case-blind filesystems.
61 delete $o{'encode'.$x};
62 $o{'Encode'.$x} = 1;
63 # Reset the variable
64 $self->{'O_FILES'} = [sort keys %o];
65 my @files;
66 foreach my $table (keys %tables)
67 {
023d8852 68 foreach my $ext (qw($(OBJ_EXT) .c .h _def.h .fnm))
18586f54 69 {
70 push (@files,$table.$ext);
71 }
72}
73$self->{'clean'}{'FILES'} .= join(' ',@files);
74return '';
311a0942 75}
76
2f2b4ff2 77sub postamble
78{
18586f54 79 my $self = shift;
3ef515df 80 my $dir = $self->catdir($self->curdir,'ucm');
67d7b5ef 81 my $str = "# Encode\$(OBJ_EXT) depends on .h and _def.h files not .c files - but all written by enc2xs\n";
18586f54 82 $str .= 'Encode$(OBJ_EXT) :';
83 foreach my $table (keys %tables)
14a8264b 84 {
18586f54 85 $str .= " $table.c";
14a8264b 86 }
18586f54 87 $str .= "\n\n";
88 foreach my $table (keys %tables)
14a8264b 89 {
18586f54 90 my $numlines = 1;
91 my $lengthsofar = length($str);
92 my $continuator = '';
67d7b5ef 93 my $enc2xs = $self->catfile('bin', 'enc2xs');
94 $str .= "$table.c : $enc2xs Makefile.PL";
18586f54 95 foreach my $file (@{$tables{$table}})
96 {
97 $str .= $continuator.' '.$self->catfile($dir,$file);
98 if ( length($str)-$lengthsofar > 128*$numlines )
99 {
100 $continuator .= " \\\n\t";
101 $numlines++;
102 } else {
103 $continuator = '';
104 }
105 }
3964a085 106 $str .= $^O eq 'VMS' # In VMS quote to preserve case
67d7b5ef 107 ? qq{\n\t\$(PERL) $enc2xs -"Q" -"O" -o \$\@ -f $table.fnm\n\n}
108 : qq{\n\t\$(PERL) $enc2xs -Q -O -o \$\@ -f $table.fnm\n\n};
18586f54 109 open (FILELIST, ">$table.fnm")
110 || die "Could not open $table.fnm: $!";
111 foreach my $file (@{$tables{$table}})
112 {
113 print FILELIST $self->catfile($dir,$file) . "\n";
114 }
115 close(FILELIST);
14a8264b 116 }
18586f54 117 return $str;
2f2b4ff2 118}