in reply to Varying module build options

Although it might not be perfect, here is what I do for XML::Twig. Note that none of the modules I check are needed, so just display messages if I don't find them, but I would think that dying should stop the installation process.

The Makefile.PL file includes a line that runs this code:

#!/bin/perl -w # $Id: check_optional_modules,v 1.2 2003/09/24 13:35:07 mrodrigu Exp $ use strict; exit if( $] >= 5.008); # Encode is there, so is Scalar::Util if( $] >= 5.0060) { unless( eval 'require Scalar::Util' or eval 'require WeakRef' ) { warn "Neither Scalar::Util nor WeakRef is installed. ", "Installing one of these modules would improve ", "XML::Twig memory management and eliminate memory ", "leaks when re-using twigs.\n"; } else { warn "weaken is available\n"; } } unless( eval 'require Text::Iconv') { my $version= `iconv -V` || ''; if($version) { warn "The iconv library was found on your system ", "but the Text::Iconv module is not installed. ", "Installing Text::Iconv would make character ", "encoding translations fast and efficient.\n"; } else { warn "Did not find iconv\n"; } } else { warn "Text::Iconv is installed\n"; }

I also run a script that creates the real .pm file from the file I maintain. Amongst other things, this script turns qr// constructs into plain strings for (very!) old versions of Perl. You could probably use such a trick to turn no warnings 'once'; into local $^W = 0;.

Replies are listed 'Best First'.
Re: Re: Varying module build options
by liz (Monsignor) on Nov 18, 2003 at 22:37 UTC
    I also run a script that creates the real .pm file from the file I maintain.

    I use a similar approach with forks, but that script is integrated into the build process. The XS file is needed for 5.6.X is different from the one that is needed with 5.8.X. When you execute Makefile.PL, it creates the version of the XS file that is needed for that version of Perl. I assume a similar approach could be used for your Perl module.

    Liz