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

SEE ALSO

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