1# 2# $Id: Makefile.PL,v 2.25 2022/06/25 01:58:57 dankogai Exp $ 3# 4use 5.007003; 5use strict; 6use warnings; 7use utf8; 8use ExtUtils::MakeMaker; 9use File::Spec; 10use Config; 11 12# Just for sure :) 13my %ARGV = map { my @r = split /=/,$_; defined $r[1] or $r[1]=1; @r } @ARGV; 14$ARGV{DEBUG} and warn "$_ => $ARGV{$_}\n" for sort keys %ARGV; 15$ENV{PERL_CORE} ||= $ARGV{PERL_CORE} if $ARGV{PERL_CORE}; 16# similar strictness as in core 17my $ccflags = $Config{ccflags}; 18if (!$ENV{PERL_CORE}) { 19 if (my $gccver = $Config{gccversion}) { 20 # no more 'Argument "Apple" isn't numeric in addition (+)' 21 no warnings 'numeric'; 22 $gccver =~ s/\.//g; $gccver =~ s/ .*//; 23 $gccver .= "0" while length $gccver < 3; 24 $gccver = 0+$gccver; 25 $ccflags .= ' -Werror=declaration-after-statement' if $gccver > 412 and $] < 5.035005; 26 $ccflags .= ' -Wpointer-sign' if !$Config{d_cplusplus} and $gccver > 400; 27 $ccflags .= ' -fpermissive' if $Config{d_cplusplus}; 28 } 29} 30 31my %tables = 32 ( 33 def_t => [ 34 'ascii.ucm', 35 '8859-1.ucm', 36 'cp1252.ucm', 37 'null.ucm', 38 'ctrl.ucm', 39 ] 40 ); 41 42my @exe_files = qw(bin/enc2xs 43 bin/piconv 44 bin/encguess 45 ); 46my @more_exe_files = qw( 47 unidump 48 ); 49my @pmlibdirs = qw(lib Encode); 50 51$ARGV{MORE_SCRIPTS} and push @exe_files, @more_exe_files; 52$ARGV{INSTALL_UCM} and push @pmlibdirs, "ucm"; 53 54WriteMakefile( 55 NAME => "Encode", 56 EXE_FILES => \@exe_files, 57 VERSION_FROM => 'Encode.pm', 58 ABSTRACT_FROM=> 'Encode.pm', 59 AUTHOR => 'Dan Kogai <dankogai@dan.co.jp>', 60 OBJECT => '$(O_FILES)', 61 'dist' => { 62 COMPRESS => 'gzip -9f', 63 SUFFIX => 'gz', 64 DIST_DEFAULT => 'all tardist', 65 }, 66 CCFLAGS => $ccflags, 67 INC => '-I' . File::Spec->catfile( '.', 'Encode' ), 68 LICENSE => 'perl', 69 PREREQ_PM => { 70 Exporter => '5.57', # use Exporter 'import'; 71 parent => '0.221', # version bundled with 5.10.1 72 Storable => '0', # bundled with Perl 5.7.3 73 }, 74 TEST_REQUIRES => { 75 'Test::More' => '0.92', 76 }, 77 PMLIBDIRS => \@pmlibdirs, 78 INSTALLDIRS => ($] < 5.011 ? 'perl' : 'site'), 79 META_MERGE => { 80 resources => { 81 repository => 'https://github.com/dankogai/p5-encode', 82 }, 83 x_contributors => [ 84 'Alex Davies <alex.davies@talktalk.net>', 85 'Alex Kapranoff <alex@kapranoff.ru>', 86 'Alex Vandiver <alex@chmrr.net>', 87 'Andreas J. Koenig <andreas.koenig@anima.de>', 88 'Andrew Pennebaker <andrew.pennebaker@networkedinsights.com>', 89 'Andy Grundman <andyg@activestate.com>', 90 'Anton Tagunov <tagunov@motor.ru>', 91 'Autrijus Tang <autrijus@autrijus.org>', 92 'Benjamin Goldberg <goldbb2@earthlink.net>', 93 'Bjoern Hoehrmann <derhoermi@gmx.net>', 94 'Bjoern Jacke <debianbugs@j3e.de>', 95 'bulk88 <bulk88@hotmail.com>', 96 'Craig A. Berry <craigberry@mac.com>', 97 'Curtis Jewell <csjewell@cpan.org>', 98 'Dan Kogai <dankogai@dan.co.jp>', 99 'Dave Evans <dave@rudolf.org.uk>', 100 'David Golden <dagolden@cpan.org>', 101 'David Steinbrunner <dsteinbrunner@pobox.com>', 102 'Deng Liu <dengliu@ntu.edu.tw>', 103 'Dominic Dunlop <domo@computer.org>', 104 'drry', 105 'Elizabeth Mattijsen <liz@dijkmat.nl>', 106 'Flavio Poletti <flavio@polettix.it>', 107 'Gerrit P. Haase <gp@familiehaase.de>', 108 'Gisle Aas <gisle@ActiveState.com>', 109 'Graham Barr <gbarr@pobox.com>', 110 'Graham Knop <haarg@haarg.org>', 111 'Graham Ollis <perl@wdlabs.com>', 112 'Gurusamy Sarathy <gsar@activestate.com>', 113 'H.Merijn Brand <h.m.brand@xs4all.nl>', 114 'Hugo van der Sanden <hv@crypt.org>', 115 'chansen <chansen@cpan.org>', 116 'Chris Nandor <pudge@pobox.com>', 117 'Inaba Hiroto <inaba@st.rim.or.jp>', 118 'Jarkko Hietaniemi <jhi@iki.fi>', 119 'Jesse Vincent <jesse@fsck.com>', 120 'Jungshik Shin <jshin@mailaps.org>', 121 'Karen Etheridge <ether@cpan.org>', 122 'Karl Williamson <khw@cpan.org>', 123 'Kenichi Ishigaki <ishigaki@cpan.org>', 124 'KONNO Hiroharu <hiroharu.konno@bowneglobal.co.jp>', 125 'Laszlo Molnar <ml1050@freemail.hu>', 126 'Makamaka <makamaka@donzoko.net>', 127 'Mark-Jason Dominus <mjd@plover.com>', 128 'Masahiro Iuchi <masahiro.iuchi@gmail.com>', 129 'MATSUNO Tokuhiro <tokuhirom+cpan@gmail.com>', 130 'Mattia Barbon <mbarbon@dsi.unive.it>', 131 'Michael G Schwern <schwern@pobox.com>', 132 'Michael LaGrasta <michael@lagrasta.com>', 133 'Miron Cuperman <miron@hyper.to>', 134 'Moritz Lenz <moritz@faui2k3.org>', 135 'MORIYAMA Masayuki <msyk@mtg.biglobe.ne.jp>', 136 'Nick Ing-Simmons <nick@ing-simmons.net>', 137 'Nicholas Clark <nick@ccl4.org>', 138 'Olivier Mengué <dolmen@cpan.org>', 139 'otsune', 140 'Pali <pali@cpan.org>', 141 'Paul Marquess <paul_marquess@yahoo.co.uk>', 142 'Peter Prymmer <pvhp@best.com>', 143 'Peter Rabbitson <ribasushi@cpan.org>', 144 'Philip Newton <pne@cpan.org>', 145 'Piotr Fusik <pfusik@op.pl>', 146 'Rafael Garcia-Suarez <rgarciasuarez@mandriva.com>', 147 'Randy Stauner <randy@magnificent-tears.com>', 148 'Reini Urban <rurban@cpan.org>', 149 'Robin Barker <rmb1@cise.npl.co.uk>', 150 'SADAHIRO Tomoyuki <SADAHIRO@cpan.org>', 151 'Simon Cozens <simon@netthink.co.uk>', 152 'Slaven Rezic <SREZIC@cpan.org>', 153 'Spider Boardman <spider@web.zk3.dec.com>', 154 'Steve Hay <steve.m.hay@googlemail.com>', 155 'Steve Peters <steve@fisharerojo.org>', 156 'SUGAWARA Hajime <sugawara@hdt.co.jp>', 157 'SUZUKI Norio <ZAP00217@nifty.com>', 158 'szr8 <blz.marcel@gmail.com>', 159 'Tatsuhiko Miyagawa <miyagawa@bulknews.net>', 160 'Tels <perl_dummy@bloodgate.com>', 161 'Tony Cook <tony@develop-help.com>', 162 'Vadim Konovalov <vkonovalov@peterstar.ru>', 163 'Victor <victor@vsespb.ru>', 164 'Ville Skyttä <ville.skytta@iki.fi>', 165 'Vincent van Dam <vvandam@sandvine.com>', 166 'Yitzchak Scott-Thoennes <sthoenna@efn.org>', 167 ], 168 }, 169); 170 171package MY; 172 173 174sub post_initialize 175{ 176 my ($self) = @_; 177 my %o; 178 # Find existing O_FILES 179 foreach my $f (@{$self->{'O_FILES'}}) 180 { 181 $o{$f} = 1; 182 } 183 my $x = $self->{'OBJ_EXT'}; 184 # Add the table O_FILES 185 foreach my $e (keys %tables) 186 { 187 $o{$e.$x} = 1; 188 } 189 # Trick case-blind filesystems. 190 delete $o{'encode'.$x}; 191 $o{'Encode'.$x} = 1; 192 # Reset the variable 193 $self->{'O_FILES'} = [sort keys %o]; 194 my @files; 195 foreach my $table (sort keys %tables) 196 { 197 foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) 198 { 199 push (@files,$table.$ext); 200 } 201 $self->{SOURCE} .= " $table.c" 202 if $^O eq 'MacOS' && $self->{SOURCE} !~ /\b$table\.c\b/; 203} 204$self->{'clean'}{'FILES'} .= join(' ',@files); 205return ''; 206} 207 208sub postamble 209{ 210 my $self = shift; 211 my $dir = $self->catdir($self->curdir,'ucm'); 212 my $str = "# Encode\$(OBJ_EXT) does not depend on .c files directly\n"; 213 $str .= "# (except Encode.c), but on .h and .exh files written by enc2xs\n"; 214 $str .= $^O eq 'MacOS' ? 'Encode.c.{$(MACPERL_BUILD_EXT_STATIC)}.o :' : 'Encode$(OBJ_EXT) :'; 215 $str .= ' Encode.c'; 216 foreach my $table (sort keys %tables) 217 { 218 $str .= " $table.c"; 219 } 220 $str .= "\n\n"; 221 foreach my $table (sort keys %tables) 222 { 223 my $numlines = 1; 224 my $lengthsofar = length($str); 225 my $continuator = ''; 226 my $enc2xs = $self->catfile('bin', 'enc2xs'); 227 $str .= "$table.c : $enc2xs Makefile.PL"; 228 foreach my $file (@{$tables{$table}}) 229 { 230 $str .= $continuator.' '.$self->catfile($dir,$file); 231 if ( length($str)-$lengthsofar > 128*$numlines ) 232 { 233 $continuator .= " \\\n\t"; 234 $numlines++; 235 } else { 236 $continuator = ''; 237 } 238 } 239 my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : ''; 240 $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform; 241 my $ucopts = '-"Q" -"O"'; 242 $str .= 243 qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n}; 244 open (FILELIST, ">$table.fnm") 245 || die "Could not open $table.fnm: $!"; 246 foreach my $file (@{$tables{$table}}) 247 { 248 print FILELIST $self->catfile($dir,$file) . "\n"; 249 } 250 close(FILELIST); 251 } 252 return $str; 253} 254