How can I make ppport.h by Module::Build?

Following code is works for me.

my $class = Module::Build->subclass(
  code => q{
    use Devel::PPPort;

    sub ACTION_build {
        my $self = shift;
        $self->depends_on('ppport_h');
        $self->SUPER::ACTION_build;
    }

    sub ACTION_ppport_h {
        my $self = shift;
        my $filepath = 'lib/HTML/ppport.h';
        unless (-e $filepath) {
            print "Writing $filepath\n";
            Devel::PPPort::WriteFile($filepath);
        }
        $self->add_to_cleanup($filepath);
    }
  },
);

Code is taken from http://cpansearch.perl.org/src/NJH/Socket-Multicast6-0.04/Build.PL, thanks.

And if you want to run the code with older perl, you need to add build_requires part.

build_requires => {
  'Devel::PPPort' => '3.20',
}

Published: 2012-10-15(Mon) 05:06