Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (OpenBSD-3.6)
Apropos / Subsearch:
optional field

ExtUtils::MakeMakPerlFProgrammers RefExtUtils::MakeMaker::FAQ(3p)

       ExtUtils::MakeMaker::FAQ - Frequently Asked Questions
       About MakeMaker

       FAQs, tricks and tips for "ExtUtils::MakeMaker".

       Philosophy and History

       Why not just use <insert other build config tool here>?
           Why did MakeMaker reinvent the build configuration
           wheel?  Why not just use autoconf or automake or ppm
           or Ant or ...

           There are many reasons, but the major one is cross-
           platform compatibility.

           Perl is one of the most ported pieces of software
           ever.  It works on operating systems I've never even
           heard of (see perlport for details).  It needs a build
           tool that can work on all those platforms and with any
           wacky C compilers they might have.

           No such build tool existed at the time and I only know
           of one now (Module::Build).

       What's Module::Build and how does it relate to MakeMaker?
           Module::Build is a project by Ken Williams to supplant
           MakeMaker.  Its primary advantages are:

           * pure perl.  no make, no shell commands
           * easier to customize
           * cleaner internals
           * less cruft

           Module::Build is the official heir apparent to Make-
           Maker and we encourage people to work on M::B rather
           than spending time improving MakeMaker.

       Module Writing

       How do I keep my $VERSION up to date without resetting it
       manu- ally?
           Often you want to manually set the $VERSION in the
           main module distribution because this is the version
           that everybody sees on CPAN and maybe you want to cus-
           tomize it a bit.  But for all the other modules in
           your dist, $VERSION is really just bookkeeping and all
           that's important is it goes up every time the module
           is changed.  Doing this by hand is a pain and you
           often forget.

perl v5.8.5                 2002-11-06                          1

ExtUtils::MakeMakPerlFProgrammers RefExtUtils::MakeMaker::FAQ(3p)

           Simplest way to do it automatically is to use your
           version control system's revision number (you are
           using version control, right?).

           In CVS and RCS you use $Revision$ writing it like so:

               $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)/g;

           Every time the file is checked in the $Revision$ will
           be updated, updating your $VERSION.

           In CVS version 1.9 is followed by 1.10.  Since CPAN
           compares version numbers numerically we use a
           sprintf() to convert 1.9 to 1.009 and 1.10 to 1.010
           which compare properly.

           If branches are involved (ie. $Revision: its
           a little more complicated.

               # must be all on one line or MakeMaker will get confused.
               $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };

       What's this META.yml thing and how did it get in my MANI-
           META.yml is a module meta-data file pioneered by Mod-
           ule::Build and automatically generated as part of the
           'distdir' target (and thus 'dist').  See "Module
           Meta-Data" in ExtUtils::MakeMaker.

           To shut off its generation, pass the "NO_META" flag to


       How to I prevent "object version X.XX does not match boot-
       strap parameter Y.YY" errors?
           XS code is very sensitive to the module version number
           and will complain if the version number in your Perl
           module doesn't match.  If you change your module's
           version # without reruning Makefile.PL the old version
           number will remain in the Makefile causing the XS code
           to be built with the wrong number.

           To avoid this, you can force the Makefile to be
           rebuilt whenever you change the module containing the
           version number by adding this to your WriteMakefile()

               depend => { '$(FIRST_MAKEFILE)' => '$(VERSION_FROM)' }

       How do I make two or more XS files coexist in the same
           Sometimes you need to have two and more XS files in

perl v5.8.5                 2002-11-06                          2

ExtUtils::MakeMakPerlFProgrammers RefExtUtils::MakeMaker::FAQ(3p)

           the same package.  One way to go is to put them into
           separate directories, but sometimes this is not the
           most suitable solution. The following technique allows
           you to put two (and more) XS files in the same direc-

           Let's assume that we have a package "Cool::Foo", which
           includes "Cool::Foo" and "Cool::Bar" modules each hav-
           ing a separate XS file. First we use the following

             use ExtUtils::MakeMaker;

                 NAME              => 'Cool::Foo',
                 VERSION_FROM      => 'Foo.pm',
                 OBJECT              => q/$(O_FILES)/,
                 # ... other attrs ...

           Notice the "OBJECT" attribute. MakeMaker generates the
           following variables in Makefile:

             # Handy lists of source code files:
             XS_FILES= Bar.xs \
             C_FILES = Bar.c \
             O_FILES = Bar.o \

           Therefore we can use the "O_FILES" variable to tell
           MakeMaker to use these objects into the shared

           That's pretty much it. Now write Foo.pm and Foo.xs,
           Bar.pm and Bar.xs, where Foo.pm bootstraps the shared
           library and Bar.pm simply loading Foo.pm.

           The only issue left is to how to bootstrap Bar.xs.
           This is done from Foo.xs:

             MODULE = Cool::Foo PACKAGE = Cool::Foo

             # boot the second XS file
             boot_Cool__Bar(aTHX_ cv);

           If you have more than two files, this is the place
           where you should boot extra XS files from.

           The following four files sum up all the details dis-
           cussed so far.

perl v5.8.5                 2002-11-06                          3

ExtUtils::MakeMakPerlFProgrammers RefExtUtils::MakeMaker::FAQ(3p)

             package Cool::Foo;

             require DynaLoader;

             our @ISA = qw(DynaLoader);
             our $VERSION = '0.01';
             bootstrap Cool::Foo $VERSION;


             package Cool::Bar;

             use Cool::Foo; # bootstraps Bar.xs


             #include "EXTERN.h"
             #include "perl.h"
             #include "XSUB.h"

             MODULE = Cool::Foo  PACKAGE = Cool::Foo

             # boot the second XS file
             boot_Cool__Bar(aTHX_ cv);

             MODULE = Cool::Foo  PACKAGE = Cool::Foo  PREFIX = cool_foo_


                 fprintf(stderr, "Cool::Foo says: Perl Rules\n");

             #include "EXTERN.h"
             #include "perl.h"
             #include "XSUB.h"

             MODULE = Cool::Bar  PACKAGE = Cool::Bar PREFIX = cool_bar_


                 fprintf(stderr, "Cool::Bar says: Perl Rules\n");

perl v5.8.5                 2002-11-06                          4

ExtUtils::MakeMakPerlFProgrammers RefExtUtils::MakeMaker::FAQ(3p)

           And of course a very basic test:

             use Test;
             BEGIN { plan tests => 1 };
             use Cool::Foo;
             use Cool::Bar;
             ok 1;

           This tip has been brought to you by Nick Ing-Simmons
           and Stas Bekman.

       If you have a question you'd like to see added to the FAQ
       (whether or not you have the answer) please send it to

       The denizens of makemakerATperl.org.


perl v5.8.5                 2002-11-06                          5