ActivePerlでPPM Packageを作成する方法
ExtUtils::MM_Win32に手を加えてみた.
--- lib/ExtUtils/MM_Win32.pm~ Fri Oct 21 08:55:12 2005 +++ lib/ExtUtils/MM_Win32.pm Mon Jun 05 00:33:26 2006 @@ -526,6 +526,42 @@ return('Win32'); } +BEGIN { + splice @ExtUtils::MakeMaker::MM_Sections, -1, 0, 'ppmdist'; +} + +sub ppd { + my $self = shift; + + my $binary_location = $self->{BINARY_LOCATION}; + $self->{BINARY_LOCATION} ||= '$(DISTNAME).tar.gz'; + + my $section = $self->SUPER::ppd; + $self->{BINARY_LOCATION} = $binary_location; + + return $section; +} + +sub ppmdist { + my $self = shift; + my $archive = $self->{BINARY_LOCATION} || '$(DISTNAME).tar'; + $archive =~ s/\.gz$//; + $archive =~ s/\\/\\\\/g; + + my $section = "ppmdist: test ppd\n"; + + require File::Basename; + my $dir = File::Basename::dirname($archive); + unless (-e $dir) { + $section .= sprintf "\t\$(NOECHO) \$(MKPATH) %s\n", $dir; + $section .= sprintf "\t\$(NOECHO) \$(CHMOD) 755 %s\n", $dir; + } + + $section .= sprintf "\t\$(TAR) \$(TARFLAGS) %s blib\n", $archive; + $section .= sprintf "\t\$(COMPRESS) %s\n", $archive; + + return $section; +} 1; __END__
これで,例えばFoo-Bar-0.01の場合,以下のようにするとFoo-Bar.ppdとFoo-Bar.tar.gzを作る.
C:\Temp\Foo-Bar-0.01>perl Makefile.PL C:\Temp\Foo-Bar-0.01>nmake ppmdist
出来上がるアーカイブの場所や名前を指定したい場合は,Makefile.PLにBINARY_LOCATIONをつける.
C:\Temp\Foo-Bar-0.01>perl Makefile.PL BINARY_LOCATION=x86/Foo-Bar.tar.gz
と,ここまでやっておいて,PPM-Make同梱のmake_ppm使った方がPPDファイルのDEPENDENCYをより正確に記述してくれるっぽいな,orz.ちなみにこのPPM-Makeは浅倉さんご指摘のhttp://theoryx5.uwinnipeg.ca/ppms/メンテナであるRandy Kobes作.