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