[pm-h] TMTOWTD Makefile.PL

G. Wade Johnson gwadej at anomaly.org
Thu Dec 17 05:32:33 PST 2009


On Thu, 17 Dec 2009 00:47:39 -0600
Will Willis <will.willis at gmail.com> wrote:

> I'm writing a module. I've written plenty before, tests and all.. but
> only recently have I started paying attention to Makefile.PL as I
> consider uploading to the CPAN.
> 
> While going through a Catalyst book I got some experience with the
> inc::Module::Install convention. I'm using module-starter to create
> skeleton modules, which by default uses the ExtUtils::MakeMaker
> approach to the Makefile.PL
> 
> My main point of concern is getting the module dependency list
> included with my distribution, inc::Module::Install's approach is very
> straight forward, using the requires subroutine. MakeMaker's appears
> to go into the PREREQ_PM hash ref.
> 
> So as I feel my way through the path of module authoring I've come up
> with a few questions (and I'm sure more will follow):

I'm certainly no expert, but here's the little that I know.

> 
> 1) Is my understanding of how dependencies are defined with these 2
> modules mentioned above correct?

You are correct as far as MakeMaker's approach. I don't know much about
Module::Install, I've only begun looking at it recently.

> 2) What are the pros/cons of using one module over the other?

The author of MakeMaker (Schwern) is trying to convince people to stop
using it.<grin/> As I understand it, one of the big benefits of
Module::Install is that the installer comes bundled with your module.

This has been a major difficulty with getting Module::Build out there.
Almost everyone already has MakeMaker.

> 3) Is Build.Pl and Module::Build yet another way to accomplish the
> same task? I see that some people (on this list) provide both a
> Build.PL and Makefile.PL with their packages. Why?

Build.PL uses Module::Build. It was supposed to replace MakeMaker and
life was going to be good. (No more reliance on make). Unfortunately,
there was a bit of "chicken and egg" problem, since many people did not
have Module::Build installed. MakeMaker is part of the core, so you
could always depend on it.

I get both nowadays from using Module::Starter to create my modules.

> 4) It appears that the Makefile.PL serves a few purposes like
> providing meta data and dependencies. What else should I be aware of?

That's basically it. MakeMaker uses the data from Makefile.PL to create
an appropriate Makefile. That's where all the fun is.

> 5) regarding MakeMaker, I see some useful meta data in
> META_MERGE->{resources}, where exactly does that info get used?

I don't know this one.

> 6) I remember once scanning an electronic copy of "Writing Perl
> Modules for CPAN" many moons ago... the book is now ~7 years old. Are
> there other up-to-date resources out there for writing and deploying
> modules to CPAN? Or is this book still relevant?

I vaguely recall some good information in "Perl Best Practices", but
that might be faulty memory. I also fine-tuned my module creation
practices from some documentation around Module::Starter.

G. Wade
-- 
More good code has been written in languages denounced as "bad" than in
languages proclaimed "wonderful" -- much more.
             -- Bjarne Stroustrup, "The Design and Evolution of C++"


More information about the Houston mailing list