DeaconBlues has asked for the wisdom of the Perl Monks concerning the following question:

I need help setting up my Makefile.PL config variables. I am creating a perl module and I began with h2xs. My current variables are:

WriteMakefile( 'NAME' => 'Foo::Bar', 'VERSION_FROM' => 'Bar.pm' 'PREFIX' => '/home/deaconblues/code/lib' 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 );

I have 2 extra perl libraries I want to include when running 'make test' or 'make testdb' besides the standard perl library. When I run the testnig part of the make process the script does not find required modules in these 2 non-standard libraries. I have been editing the Make file by hand and adding -I flags to the following lines.

test_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERL) -I$(INST_ARCHLIB) -I$(INST_LIB) +-I$(PERL_A RCHLIB) -I$(PERL_LIB) $(TEST_FILE) testdb_dynamic :: pure_all PERL_DL_NONLAZY=1 $(FULLPERL) $(TESTDB_SW) -I$(INST_ARCHLIB) - +I$(INST_LI B) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(TEST_FILE)

I add the flags "-I/home/deaconblues/code/lib" and "-I/opt/cd/dv/na/bin", which work. The problem with this is that whenever I 'make clean', I have to redo my edits after I rerun 'perl Makefile.PL', because the Makefile gets deleted. I would like to setup the config variables in the MakeFile.PL script to produce the changes automatically that I have been doing by hand.

I had tried using the INC variable but it doesn't get included in above lines. Please do not tell me "Well then don't 'make clean'. :-)

Thank you for your assistance

Replies are listed 'Best First'.
Re: Help setting up Makefile.PL
by btrott (Parson) on Mar 22, 2001 at 22:56 UTC
    It seems there must be an easier way for you to handle this situation, because, as tye said, how can Perl find the libraries at your non-standard locations once you've installed this module?

    But anyway, you can change the content of the 'test' sections of the Makefile by creating a MY::test subroutine in your Makefile.PL. That routine will be passed an object (I don't know what type it is; from the docs it looks like it might be of type 'MM'). You first call the SUPER::test to get the standard 'test' section, then you can use regexps to modify it.

    For example:

    package MY; sub test { my $self = shift; my $test = $self->SUPER::test(@_); $test =~ s!(-I\$\(PERL_LIB\))!$1 -I/home/deaconblues/code/lib +-I/opt/cd/dv/na/bin!; $test; }
(tye)Re: Help setting up Makefile.PL
by tye (Sage) on Mar 22, 2001 at 21:23 UTC

    But how does Perl find those non-standard libraries after you have installed? Or are these only things that are needed during testing?

    The PERL5LIB environment variable and use lib both come to mind. I need a better understanding of your situation to see why you want to have these site-specific things written into the Makefile. Right now I'm think that is the wrong way to do it (it certainly seems difficult).

            - tye (but my friends call me "Tye")
Re: Help setting up Makefile.PL
by DeaconBlues (Monk) on Mar 22, 2001 at 22:47 UTC

    OK, Here is more information.

    This is the current development environment I work in. I have very little control over it. I am working for a firm which maintains a non-web database application written in perl.

    There are 3 perl library directories.
    /opt/perl/5.6.0/lib - standard perl library
    /opt/db/dv/na/bin - application specific perl library
    /home/deaconblues/code/lib - my installed modules

    I install perl modules in my home directory because I do not have permission to install in the other directories. I install standard modules and personal modules I have created into my home directory library. When code gets released for QA then it can be installed into the application specific library directory or the standard directory depending on which makes sense.

    When the application runs, the environment of the application's user is set to include the first 2 directories into the Unix PATH enviroment variable.

    When I test the scripts and modules not using make, I have an alias which includes the extra directories into @INC. Like this:

    alias myperl='perl -I/home/deaconblues/code/lib -I/opt/db/dv/na/bin'

    So as I develop and test new modules I need the make process to include the 2 non-standard library directories when it runs the make test script.

      Ah. Then definitely go with PERL5LIB and ditch the whole alias thing:

      setenv PERL5LIB "/home/deaconblues/code/lib:/opt/db/dv/na/bin" # or PERL5LIB="/home/deaconblues/code/lib:/opt/db/dv/na/bin" export PERL5LIB

              - tye (but my friends call me "Tye")

        Thanks,

        The quality of my work environment has been greatly improved by your PERL5LIB suggestion. It has straightened out using perl in all cases. No more -I flags anywhere, woohoo!