in reply to Perl Module Make Format Conversion.

The two modules performing the chores of module installation are ExtUtils::MakeMaker (classic) and Module::Build (new).

Both have a different set of problems - ExtUtils::MakeMaker is a veteran module, tried and proven on many platforms, but if you want to do anything special in the build process, you're left with ugly manual parsing of the generated Makefile. Module::Build is new and has problems with older versions of CPAN, but it allows you more easily to extend the build process.

I have done a similar yet different preprocessing step for one of my modules, the generation of Perl code from an abstract grammar, and used Module::Build for that. Here is my Module::Build script, adapted somewhat to your needs:

use strict; use Module::Build; use Config; my $build = Module::Build->new ( module_name => 'Swordkeeper::Speechengine', license => 'perl', requires => { # 'perl' => '5.6.1', }, create_makefile_pl => 'passthrough' ); $build->do_system('swig','-perl5','say.i'); $build->do_system('gcc',qw(say.c say_warp.c -fpic -c -I/usr/local/incl +ude/flite -L/usr/local/lib/ -I/usr/lib/perl5/5.8.0/i386-linux/CORE)); $build->do_system('ld', qw(-G say.o say_wrap.o -lflite_cmu_us_kal -lfl +ite_usenglish -lfliste_cmulex -lflite -lm -o say.so)); $build->create_build_script;

The above script plainly recreates your shell script, but this will not be very portable if anyone is using it with a differen version of Perl or a Perl compiled with a different compiler - for that, you should use the values provided in Config.pm, replacing gcc with $Config{cc} and so on, see perldoc Config.

After you've written your Build.PL script, you need to add Module::Build in your prerequisites and include Build.PL and Makefile.PL in your module distribution (this is the passthrough Makefile.PL I stole from Autrijus):

#!/usr/bin/perl # $File: //member/autrijus/XML-RSS-Aggregate/Makefile.PL $ # $Revision: 1.6 $ $Change: 2920 $ $DateTime: 2002/12/25 14:43:18 $ # This Makefile.PL creates a pass-through Makefile that simply calls # the equivalent Module::Build methods for each make target. See the # documentation for Module::Build::Compat for more information. unless (eval "use Module::Build::Compat 0.02; 1" ) { require Cwd; require File::Spec; require ExtUtils::MakeMaker; my $yn = ''; # Check if we're likely to have permission to install Module::Buil +d if (-w $INC{'ExtUtils/MakeMaker.pm'}) { # Check if we're under the non-reentrant CPAN.pm require CPAN; CPAN::Config->load; my $cwd = File::Spec->canonpath(Cwd::cwd()); my $cpan = File::Spec->canonpath($CPAN::Config->{cpan_home}); if (index($cwd, $cpan) == -1) { print "This module requires Module::Build to install itsel +f.\n"; $yn = ExtUtils::MakeMaker::prompt( ' Install Module::Build from CPAN?', 'y' ); } } if ($yn =~ /^y/i) { # Save this 'cause CPAN will chdir all over the place. my $cwd = Cwd::cwd(); my $makefile = File::Spec->rel2abs($0); if (eval { require CPANPLUS::Backend; 1 }) { CPANPLUS::Backend->new->install( modules => [ 'Module::Build' ] ); } else { require CPAN; CPAN::Shell->install('Module::Build::Compat'); } chdir $cwd or die "Cannot chdir() back to $cwd: $!"; exec $^X, $makefile, @ARGV; # Redo now that we have Module::B +uild } else { warn << '.'; This module requires Module::Build to install itself. Please re-run Makefile.PL with root privilege to install it automatically from CPAN, or manually download it from: http://search.cpan.org/author/KWILLIAMS/Module-Build/ . # Leave hints for CPAN.pm and CPANPLUS.pm ExtUtils::MakeMaker::WriteMakefile( PREREQ_PM => { 'Module::Build' => 0.11 } ); exit(0); } } Module::Build::Compat->run_build_pl(args => \@ARGV); Module::Build::Compat->write_makefile(); __END__ # Local variables: # c-indentation-style: bsd # c-basic-offset: 4 # indent-tabs-mode: nil # End: # vim: expandtab shiftwidth=4:

Replies are listed 'Best First'.
Re: Re: Perl Module Make Format Conversion.
by Swordkeeper (Novice) on Mar 08, 2004 at 09:45 UTC
    Thank you so much, I had no idea the newer one even existed until now; much thanks.