1ExtUtils::MakeMaker::TutPoerrilalP(r3opgmr)ammers ReferEexntcUetiGlusi:d:eMakeMaker::Tutorial(3pm)
2
3
4

NAME

6       ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker
7

SYNOPSIS

9           use ExtUtils::MakeMaker;
10
11           WriteMakefile(
12               NAME            => 'Your::Module',
13               VERSION_FROM    => 'lib/Your/Module.pm'
14           );
15

DESCRIPTION

17       This is a short tutorial on writing a simple module with MakeMaker.
18       Its really not that hard.
19
20   The Mantra
21       MakeMaker modules are installed using this simple mantra
22
23               perl Makefile.PL
24               make
25               make test
26               make install
27
28       There are lots more commands and options, but the above will do it.
29
30   The Layout
31       The basic files in a module look something like this.
32
33               Makefile.PL
34               MANIFEST
35               lib/Your/Module.pm
36
37       That's all that's strictly necessary.  There's additional files you
38       might want:
39
40               lib/Your/Other/Module.pm
41               t/some_test.t
42               t/some_other_test.t
43               Changes
44               README
45               INSTALL
46               MANIFEST.SKIP
47               bin/some_program
48
49       Makefile.PL
50           When you run Makefile.PL, it makes a Makefile.  That's the whole
51           point of MakeMaker.  The Makefile.PL is a simple program which
52           loads ExtUtils::MakeMaker and runs the WriteMakefile() function to
53           generate a Makefile.
54
55           Here's an example of what you need for a simple module:
56
57               use ExtUtils::MakeMaker;
58
59               WriteMakefile(
60                   NAME            => 'Your::Module',
61                   VERSION_FROM    => 'lib/Your/Module.pm'
62               );
63
64           NAME is the top-level namespace of your module.  VERSION_FROM is
65           the file which contains the $VERSION variable for the entire
66           distribution.  Typically this is the same as your top-level module.
67
68       MANIFEST
69           A simple listing of all the files in your distribution.
70
71                   Makefile.PL
72                   MANIFEST
73                   lib/Your/Module.pm
74
75           File paths in a MANIFEST always use Unix conventions (ie. /) even
76           if you're not on Unix.
77
78           You can write this by hand or generate it with 'make manifest'.
79
80           See ExtUtils::Manifest for more details.
81
82       lib/
83           This is the directory where your .pm and .pod files you wish to
84           have installed go.  They are layed out according to namespace.  So
85           Foo::Bar is lib/Foo/Bar.pm.
86
87       t/  Tests for your modules go here.  Each test filename ends with a .t.
88           So t/foo.t/  'make test' will run these tests.  The directory is
89           flat, you cannot, for example, have t/foo/bar.t run by 'make test'.
90
91           Tests are run from the top level of your distribution.  So inside a
92           test you would refer to ./lib to enter the lib directory, for
93           example.
94
95       Changes
96           A log of changes you've made to this module.  The layout is free-
97           form.  Here's an example:
98
99               1.01 Fri Apr 11 00:21:25 PDT 2003
100                   - thing() does some stuff now
101                   - fixed the wiggy bug in withit()
102
103               1.00 Mon Apr  7 00:57:15 PDT 2003
104                   - "Rain of Frogs" now supported
105
106       README
107           A short description of your module, what it does, why someone would
108           use it and its limitations.  CPAN automatically pulls your README
109           file out of the archive and makes it available to CPAN users, it is
110           the first thing they will read to decide if your module is right
111           for them.
112
113       INSTALL
114           Instructions on how to install your module along with any
115           dependencies.  Suggested information to include here:
116
117               any extra modules required for use
118               the minimum version of Perl required
119               if only works on certain operating systems
120
121       MANIFEST.SKIP
122           A file full of regular expressions to exclude when using 'make
123           manifest' to generate the MANIFEST.  These regular expressions are
124           checked against each file path found in the distribution (so you're
125           matching against "t/foo.t" not "foo.t").
126
127           Here's a sample:
128
129               ~$          # ignore emacs and vim backup files
130               .bak$       # ignore manual backups
131               \#          # ignore CVS old revision files and emacs temp files
132
133           Since # can be used for comments, # must be escaped.
134
135           MakeMaker comes with a default MANIFEST.SKIP to avoid things like
136           version control directories and backup files.  Specifying your own
137           will override this default.
138
139       bin/
140

SEE ALSO

142       perlmodstyle gives stylistic help writing a module.
143
144       perlnewmod gives more information about how to write a module.
145
146       There are modules to help you through the process of writing a module:
147       ExtUtils::ModuleMaker, Module::Install, PAR
148
149
150
151perl v5.12.4                      2011-06-07ExtUtils::MakeMaker::Tutorial(3pm)
Impressum