perlmakemaker

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

Solution

  • 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.