tags:

views:

128

answers:

3

Looking for some insight on how to add multiple PM files to the MakeMaker script?

I see this documentation and all the examples look like one file is added, how do I add multiple files?

use ExtUtils::MakeMaker;

WriteMakefile(
   NAME => 'Your::Module',
   VERSION_FROM => 'lib/Your/Module.pm'
);

Do I just add another set of values?

use ExtUtils::MakeMaker;

WriteMakefile(
   NAME => 'Your::Module',
   VERSION_FROM => 'lib/Your/Module.pm'

   NAME => 'Your::Module2',
   VERSION_FROM => 'lib/Your/Module2.pm'
);
A: 

Perhaps you could try to use PM. The ExtUtils::MakeMaker doc says:

Hashref of .pm files and *.pl files to be installed. e.g.

I went looking through some other modules I downloaded from CPAN for an example of its usage, and I found it in the GD Makefile.PL code:

WriteMakefile(
    'NAME'  => 'GD',
    'VERSION_FROM'  => 'GD.pm',
    'PREREQ_PM' => {
            'Math::Trig' => 0,
            },
    'PM'        => { 'GD.pm' => '$(INST_LIBDIR)/GD.pm',
                     'GD/Polyline.pm' => '$(INST_LIBDIR)/GD/Polyline.pm',
                     'GD/Polygon.pm' => '$(INST_LIBDIR)/GD/Polygon.pm',
                     'GD/Simple.pm' => '$(INST_LIBDIR)/GD/Simple.pm',
                     'GD/Image.pm' => '$(INST_LIBDIR)/GD/Image.pm',
                     'GD/Group.pm' => '$(INST_LIBDIR)/GD/Group.pm',
                     'qd.pl' => '$(INST_LIBDIR)/qd.pl'},

I doubt the code you posted would work because the hash you are passing to the WriteMakefile function has duplicate keys.

toolic
thnx that makes sense. One other question is if the new .pm file has a CPAN library dependency do I need to add that here as well?
Phill Pafford
Please ask a new question if you cannot figure it out from the documentation. http://search.cpan.org/perldoc?ExtUtils::MakeMaker#PREREQ_PM
daxim
If you structure your lib/ directory with the module name (e.g. lib/GD/Polyline.pm), you don't need to put the files in PM.
brian d foy
What brian said, PM is only necessary if MakeMaker doesn't pick them up for you. Stick your modules into `lib` and you're done.
Schwern
+2  A: 

toolic's answer already points you to the docs, but I'll answer the other part of the question (although it is also in the docs):

NAME is the string Makemaker uses for the distribution name. Although this is often the main module, it can really be anything you like.

VERSION_FROM tells Makemaker that it should take the $VERSION from a specific file and use that at the distribution version. Most often, people use the version of the main module as the distribution version, but you don't have to do that.

brian d foy
+2  A: 

The answer is: do nothing. Your original code and layout is fine. MakeMaker will find your modules in lib without you lifting a finger. Try it and see.

Explicitly writing out PM as in toolic's answer is unnecessary and brittle.

Schwern