Phill Pafford
Phill Pafford

Reputation: 85388

How do I add multiple Perl modules to Makefile.PL?

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'
);

Upvotes: 3

Views: 1591

Answers (3)

Schwern
Schwern

Reputation: 165606

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.

Upvotes: 5

brian d foy
brian d foy

Reputation: 132914

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.

Upvotes: 3

toolic
toolic

Reputation: 62236

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.

Upvotes: 1

Related Questions