开发者

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 => 'You开发者_StackOverflow中文版r::Module2',
   VERSION_FROM => 'lib/Your/Module2.pm'
);


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜