dslinux/user/perl/lib/ExtUtils/MakeMaker Config.pm FAQ.pod Tutorial.pod bytes.pm vmsish.pm
cayenne
dslinux_cayenne at user.in-berlin.de
Mon Dec 4 18:00:36 CET 2006
Update of /cvsroot/dslinux/dslinux/user/perl/lib/ExtUtils/MakeMaker
In directory antilope:/tmp/cvs-serv17422/lib/ExtUtils/MakeMaker
Added Files:
Config.pm FAQ.pod Tutorial.pod bytes.pm vmsish.pm
Log Message:
Adding fresh perl source to HEAD to branch from
--- NEW FILE: vmsish.pm ---
package ExtUtils::MakeMaker::vmsish;
use vars qw($VERSION);
$VERSION = 0.01;
my $IsVMS = $^O eq 'VMS';
require vmsish if $IsVMS;
sub import {
return unless $IsVMS;
shift;
unshift @_, 'vmsish';
goto &vmsish::import;
}
1;
=head1 NAME
ExtUtils::MakeMaker::vmsish - Platform-agnostic vmsish.pm
=head1 SYNOPSIS
use just like vmsish.pm
=head1 DESCRIPTION
Until 5.8.0, vmsish.pm is only installed on VMS. This means any code
which has 'use vmsish' in it won't even compile outside VMS. This
makes ExtUtils::MM_VMS very hard to test.
ExtUtils::MakeMaker::vmsish is just a very thin wrapper around vmsish
which works just like it on VMS and everywhere else it does nothing.
=cut
--- NEW FILE: bytes.pm ---
package ExtUtils::MakeMaker::bytes;
use vars qw($VERSION);
$VERSION = 0.01;
my $Have_Bytes = eval q{require bytes; 1;};
sub import {
return unless $Have_Bytes;
shift;
unshift @_, 'bytes';
goto &bytes::import;
}
1;
=head1 NAME
ExtUtils::MakeMaker::bytes - Version-agnostic bytes.pm
=head1 SYNOPSIS
use just like bytes.pm
=head1 DESCRIPTION
bytes.pm was introduced with 5.6. This means any code which has 'use
bytes' in it won't even compile on 5.5.X. Since bytes is a lexical
pragma and must be used at compile time we can't simply wrap it in
a BEGIN { eval 'use bytes' } block.
ExtUtils::MakeMaker::bytes is just a very thin wrapper around bytes
which works just like it when bytes.pm exists and everywhere else it
does nothing.
=cut
--- NEW FILE: Config.pm ---
package ExtUtils::MakeMaker::Config;
$VERSION = '0.02';
use strict;
use Config ();
# Give us an overridable config.
use vars qw(%Config);
%Config = %Config::Config;
sub import {
my $caller = caller;
no strict 'refs';
*{$caller.'::Config'} = \%Config;
}
1;
=head1 NAME
ExtUtils::MakeMaker::Config - Wrapper around Config.pm
=head1 SYNOPSIS
use ExtUtils::MakeMaker::Config;
print $Config{installbin}; # or whatever
=head1 DESCRIPTION
B<FOR INTERNAL USE ONLY>
A very thin wrapper around Config.pm so MakeMaker is easier to test.
=cut
--- NEW FILE: FAQ.pod ---
package ExtUtils::MakeMaker::FAQ;
use vars qw($VERSION);
$VERSION = '1.11';
1;
__END__
=head1 NAME
ExtUtils::MakeMaker::FAQ - Frequently Asked Questions About MakeMaker
=head1 DESCRIPTION
FAQs, tricks and tips for C<ExtUtils::MakeMaker>.
=head2 Module Installation
=over 4
=item How do I keep from installing man pages?
Recent versions of MakeMaker will only install man pages on Unix like
operating systems.
For an individual module:
perl Makefile.PL INSTALLMAN1DIR=none INSTALLMAN3DIR=none
If you want to suppress man page installation for all modules you have
to reconfigure Perl and tell it 'none' when it asks where to install
man pages.
=item How do I use a module without installing it?
Two ways. One is to build the module normally...
perl Makefile.PL
make
...and then set the PERL5LIB environment variable to point at the
blib/lib and blib/arch directories.
The other is to install the module in a temporary location.
perl Makefile.PL PREFIX=~/tmp LIB=~/tmp/lib/perl
And then set PERL5LIB to F<~/tmp/lib/perl>. This works well when you have
multiple modules to work with. It also ensures that the module goes
through its full installation process which may modify it.
=back
=head2 Philosophy and History
=over 4
=item 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 and linkers they might have.
No such build tool exists. Even make itself has wildly different
dialects. So we have to build our own.
=item What is Module::Build and how does it relate to MakeMaker?
Module::Build is a project by Ken Williams to supplant MakeMaker.
Its primary advantages are:
=over 8
=item * pure perl. no make, no shell commands
=item * easier to customize
=item * cleaner internals
=item * less cruft
=back
Module::Build is the official heir apparent to MakeMaker and we
encourage people to work on M::B rather than spending time adding features
to MakeMaker.
=back
=head2 Module Writing
=over 4
=item How do I keep my $VERSION up to date without resetting it manually?
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 customize 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.
Simplest way to do it automatically is to use your version control
system's revision number (you are using version control, right?).
In CVS, RCS and SVN you use $Revision: 1.1 $ (see the documentation of your
version control system for details) writing it like so:
$VERSION = sprintf "%d.%03d", q$Revision: 1.1 $ =~ /(\d+)/g;
Every time the file is checked in the $Revision: 1.1 $ 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: 1.1 $) its a little more
complicated.
# must be all on one line or MakeMaker will get confused.
$VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
=item What's this F<META.yml> thing and how did it get in my F<MANIFEST>?!
F<META.yml> is a module meta-data file pioneered by Module::Build and
automatically generated as part of the 'distdir' target (and thus
'dist'). See L<ExtUtils::MakeMaker/"Module Meta-Data">.
To shut off its generation, pass the C<NO_META> flag to C<WriteMakefile()>.
=back
=head2 XS
=over 4
=item How to I prevent "object version X.XX does not match bootstrap 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() arguments.
depend => { '$(FIRST_MAKEFILE)' => '$(VERSION_FROM)' }
=item How do I make two or more XS files coexist in the same directory?
Sometimes you need to have two and more XS files in 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 directory.
Let's assume that we have a package C<Cool::Foo>, which includes
C<Cool::Foo> and C<Cool::Bar> modules each having a separate XS
file. First we use the following I<Makefile.PL>:
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Cool::Foo',
VERSION_FROM => 'Foo.pm',
OBJECT => q/$(O_FILES)/,
# ... other attrs ...
);
Notice the C<OBJECT> attribute. MakeMaker generates the following
variables in I<Makefile>:
# Handy lists of source code files:
XS_FILES= Bar.xs \
Foo.xs
C_FILES = Bar.c \
Foo.c
O_FILES = Bar.o \
Foo.o
Therefore we can use the C<O_FILES> variable to tell MakeMaker to use
these objects into the shared library.
That's pretty much it. Now write I<Foo.pm> and I<Foo.xs>, I<Bar.pm>
and I<Bar.xs>, where I<Foo.pm> bootstraps the shared library and
I<Bar.pm> simply loading I<Foo.pm>.
The only issue left is to how to bootstrap I<Bar.xs>. This is done
from I<Foo.xs>:
MODULE = Cool::Foo PACKAGE = Cool::Foo
BOOT:
# 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 discussed so far.
Foo.pm:
-------
package Cool::Foo;
require DynaLoader;
our @ISA = qw(DynaLoader);
our $VERSION = '0.01';
bootstrap Cool::Foo $VERSION;
1;
Bar.pm:
-------
package Cool::Bar;
use Cool::Foo; # bootstraps Bar.xs
1;
Foo.xs:
-------
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = Cool::Foo PACKAGE = Cool::Foo
BOOT:
# boot the second XS file
boot_Cool__Bar(aTHX_ cv);
MODULE = Cool::Foo PACKAGE = Cool::Foo PREFIX = cool_foo_
void
cool_foo_perl_rules()
CODE:
fprintf(stderr, "Cool::Foo says: Perl Rules\n");
Bar.xs:
-------
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = Cool::Bar PACKAGE = Cool::Bar PREFIX = cool_bar_
void
cool_bar_perl_rules()
CODE:
fprintf(stderr, "Cool::Bar says: Perl Rules\n");
And of course a very basic test:
test.pl:
--------
use Test;
BEGIN { plan tests => 1 };
use Cool::Foo;
use Cool::Bar;
Cool::Foo::perl_rules();
Cool::Bar::perl_rules();
ok 1;
This tip has been brought to you by Nick Ing-Simmons and Stas Bekman.
=back
=head1 PATCHING
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 makemaker at perl.org.
=head1 AUTHOR
The denizens of makemaker at perl.org.
=head1 SEE ALSO
L<ExtUtils::MakeMaker>
=cut
--- NEW FILE: Tutorial.pod ---
package ExtUtils::MakeMaker::Tutorial;
use vars qw($VERSION);
$VERSION = 0.02;
=head1 NAME
ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker
=head1 SYNOPSIS
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Your::Module',
VERSION_FROM => 'lib/Your/Module.pm'
);
=head1 DESCRIPTION
This is a short tutorial on writing a simple module with MakeMaker.
Its really not that hard.
=head2 The Mantra
MakeMaker modules are installed using this simple mantra
perl Makefile.PL
make
make test
make install
There are lots more commands and options, but the above will do it.
=head2 The Layout
The basic files in a module look something like this.
Makefile.PL
MANIFEST
lib/Your/Module.pm
That's all that's strictly necessary. There's additional files you might
want:
lib/Your/Other/Module.pm
t/some_test.t
t/some_other_test.t
Changes
README
INSTALL
MANIFEST.SKIP
bin/some_program
=over 4
=item Makefile.PL
When you run Makefile.PL, it makes a Makefile. That's the whole point of
MakeMaker. The Makefile.PL is a simple program which loads
ExtUtils::MakeMaker and runs the WriteMakefile() function to generate a
Makefile.
Here's an example of what you need for a simple module:
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Your::Module',
VERSION_FROM => 'lib/Your/Module.pm'
);
NAME is the top-level namespace of your module. VERSION_FROM is the file
which contains the $VERSION variable for the entire distribution. Typically
this is the same as your top-level module.
=item MANIFEST
A simple listing of all the files in your distribution.
Makefile.PL
MANIFEST
lib/Your/Module.pm
File paths in a MANIFEST always use Unix conventions (ie. /) even if you're
not on Unix.
You can write this by hand or generate it with 'make manifest'.
See L<ExtUtils::Manifest> for more details.
=item lib/
This is the directory where your .pm and .pod files you wish to have
installed go. They are layed out according to namespace. So Foo::Bar
is F<lib/Foo/Bar.pm>.
=item t/
Tests for your modules go here. Each test filename ends with a .t.
So F<t/foo.t>/ 'make test' will run these tests. The directory is flat,
you cannot, for example, have t/foo/bar.t run by 'make test'.
Tests are run from the top level of your distribution. So inside a test
you would refer to ./lib to enter the lib directory, for example.
=item Changes
A log of changes you've made to this module. The layout is free-form.
Here's an example:
1.01 Fri Apr 11 00:21:25 PDT 2003
- thing() does some stuff now
- fixed the wiggy bug in withit()
1.00 Mon Apr 7 00:57:15 PDT 2003
- "Rain of Frogs" now supported
=item README
A short description of your module, what it does, why someone would use it
and its limitations. CPAN automatically pulls your README file out of
the archive and makes it available to CPAN users, it is the first thing
they will read to decide if your module is right for them.
=item INSTALL
Instructions on how to install your module along with any dependencies.
Suggested information to include here:
any extra modules required for use
the minimum version of Perl required
if only works on certain operating systems
=item MANIFEST.SKIP
A file full of regular expressions to exclude when using 'make
manifest' to generate the MANIFEST. These regular expressions
are checked against each file path found in the distribution (so
you're matching against "t/foo.t" not "foo.t").
Here's a sample:
~$ # ignore emacs and vim backup files
.bak$ # ignore manual backups
\# # ignore CVS old revision files and emacs temp files
Since # can be used for comments, # must be escaped.
MakeMaker comes with a default MANIFEST.SKIP to avoid things like
version control directories and backup files. Specifying your own
will override this default.
=item bin/
=back
=head1 SEE ALSO
L<perlmodstyle> gives stylistic help writing a module.
L<perlnewmod> gives more information about how to write a module.
There are modules to help you through the process of writing a module:
L<ExtUtils::ModuleMaker>, L<Module::Install>, L<PAR>
=cut
1;
More information about the dslinux-commit
mailing list