1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License, Version 1.0 only 6# (the "License"). You may not use this file except in compliance 7# with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22use 5.007003; 23use ExtUtils::MakeMaker; 24 25# Just for sure :) 26my %ARGV = map { split /=/; defined $_[1] or $_[1]=1; @_ } @ARGV; 27$ARGV{DEBUG} and warn "$_ => $ARGV{$_}\n" for keys %ARGV; 28$ENV{PERL_CORE} ||= $ARGV{PERL_CORE}; 29 30my %tables = 31 ( 32 def_t => ['ascii.ucm', 33 '8859-1.ucm', 34 'null.ucm', 35 'ctrl.ucm', 36 ] 37 ); 38 39my @exe_files = qw(bin/enc2xs 40 bin/piconv 41 ); 42my @more_exe_files = qw( 43 unidump 44 ); 45my @pmlibdirs = qw(lib Encode); 46 47$ARGV{MORE_SCRIOPTS} and push @exe_files, @more_exe_files; 48$ARGV{INSTALL_UCM} and push @pmlibdirs, "ucm"; 49 50WriteMakefile( 51 NAME => "Encode", 52 EXE_FILES => \@exe_files, 53 VERSION_FROM => 'Encode.pm', 54 OBJECT => '$(O_FILES)', 55 'dist' => { 56 COMPRESS => 'gzip -9f', 57 SUFFIX => 'gz', 58 DIST_DEFAULT => 'all tardist', 59 }, 60 MAN3PODS => {}, 61 INC => "-I./Encode", 62 PMLIBDIRS => \@pmlibdirs, 63 INSTALLDIRS => 'perl', 64 ); 65 66package MY; 67 68 69sub post_initialize 70{ 71 my ($self) = @_; 72 my %o; 73 # Find existing O_FILES 74 foreach my $f (@{$self->{'O_FILES'}}) 75 { 76 $o{$f} = 1; 77 } 78 my $x = $self->{'OBJ_EXT'}; 79 # Add the table O_FILES 80 foreach my $e (keys %tables) 81 { 82 $o{$e.$x} = 1; 83 } 84 # Trick case-blind filesystems. 85 delete $o{'encode'.$x}; 86 $o{'Encode'.$x} = 1; 87 # Reset the variable 88 $self->{'O_FILES'} = [sort keys %o]; 89 my @files; 90 foreach my $table (keys %tables) 91 { 92 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) 93 { 94 push (@files,$table.$ext); 95 } 96 $self->{SOURCE} .= " $table.c" 97 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/; 98} 99$self->{'clean'}{'FILES'} .= join(' ',@files); 100return ''; 101} 102 103sub postamble 104{ 105 my $self = shift; 106 my $dir = $self->catdir($self->curdir,'ucm'); 107 my $str = "# Encode\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n"; 108 $str .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :'; 109 foreach my $table (keys %tables) 110 { 111 $str .= " $table.c"; 112 } 113 $str .= "\n\n"; 114 foreach my $table (keys %tables) 115 { 116 my $numlines = 1; 117 my $lengthsofar = length($str); 118 my $continuator = ''; 119 my $enc2xs = $self->catfile('bin', 'enc2xs'); 120 $str .= "$table.c : $enc2xs Makefile.PL"; 121 foreach my $file (@{$tables{$table}}) 122 { 123 $str .= $continuator.' '.$self->catfile($dir,$file); 124 if ( length($str)-$lengthsofar > 128*$numlines ) 125 { 126 $continuator .= " \\\n\t"; 127 $numlines++; 128 } else { 129 $continuator = ''; 130 } 131 } 132 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : ''; 133 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform; 134 my $ucopts = '-"Q" -"O"'; 135 $str .= 136 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n}; 137 open (FILELIST, ">$table.fnm") 138 || die "Could not open $table.fnm: $!"; 139 foreach my $file (@{$tables{$table}}) 140 { 141 print FILELIST $self->catfile($dir,$file) . "\n"; 142 } 143 close(FILELIST); 144 } 145 return $str; 146} 147