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