Install Perl 5.8.8
[msysgit.git] / mingw / html / lib / ExtUtils / MakeMaker / Tutorial.html
blobd1df150a10a338aa207ba3ee0ace9f9486df9883
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:" />
8 </head>
10 <body style="background-color: white">
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="block" style="background-color: #cccccc" valign="middle">
13 <big><strong><span class="block">&nbsp;ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker</span></strong></big>
14 </td></tr>
15 </table>
17 <p><a name="__index__"></a></p>
18 <!-- INDEX BEGIN -->
20 <ul>
22 <li><a href="#name">NAME</a></li>
23 <li><a href="#synopsis">SYNOPSIS</a></li>
24 <li><a href="#description">DESCRIPTION</a></li>
25 <ul>
27 <li><a href="#the_mantra">The Mantra</a></li>
28 <li><a href="#the_layout">The Layout</a></li>
29 </ul>
31 <li><a href="#see_also">SEE ALSO</a></li>
32 </ul>
33 <!-- INDEX END -->
35 <hr />
36 <p>
37 </p>
38 <h1><a name="name">NAME</a></h1>
39 <p>ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker</p>
40 <p>
41 </p>
42 <hr />
43 <h1><a name="synopsis">SYNOPSIS</a></h1>
44 <pre>
45 use ExtUtils::MakeMaker;</pre>
46 <pre>
47 WriteMakefile(
48 NAME =&gt; 'Your::Module',
49 VERSION_FROM =&gt; 'lib/Your/Module.pm'
50 );</pre>
51 <p>
52 </p>
53 <hr />
54 <h1><a name="description">DESCRIPTION</a></h1>
55 <p>This is a short tutorial on writing a simple module with MakeMaker.
56 Its really not that hard.</p>
57 <p>
58 </p>
59 <h2><a name="the_mantra">The Mantra</a></h2>
60 <p>MakeMaker modules are installed using this simple mantra</p>
61 <pre>
62 perl Makefile.PL
63 make
64 make test
65 make install</pre>
66 <p>There are lots more commands and options, but the above will do it.</p>
67 <p>
68 </p>
69 <h2><a name="the_layout">The Layout</a></h2>
70 <p>The basic files in a module look something like this.</p>
71 <pre>
72 Makefile.PL
73 MANIFEST
74 lib/Your/Module.pm</pre>
75 <p>That's all that's strictly necessary. There's additional files you might
76 want:</p>
77 <pre>
78 lib/Your/Other/Module.pm
79 t/some_test.t
80 t/some_other_test.t
81 Changes
82 README
83 INSTALL
84 MANIFEST.SKIP
85 bin/some_program</pre>
86 <dl>
87 <dt><strong><a name="item_makefile_2epl">Makefile.PL</a></strong>
89 <dd>
90 <p>When you run Makefile.PL, it makes a Makefile. That's the whole point of
91 MakeMaker. The Makefile.PL is a simple program which loads
92 ExtUtils::MakeMaker and runs the <code>WriteMakefile()</code> function to generate a
93 Makefile.</p>
94 </dd>
95 <dd>
96 <p>Here's an example of what you need for a simple module:</p>
97 </dd>
98 <dd>
99 <pre>
100 use ExtUtils::MakeMaker;</pre>
101 </dd>
102 <dd>
103 <pre>
104 WriteMakefile(
105 NAME =&gt; 'Your::Module',
106 VERSION_FROM =&gt; 'lib/Your/Module.pm'
107 );</pre>
108 </dd>
109 <dd>
110 <p>NAME is the top-level namespace of your module. VERSION_FROM is the file
111 which contains the $VERSION variable for the entire distribution. Typically
112 this is the same as your top-level module.</p>
113 </dd>
114 </li>
115 <dt><strong><a name="item_manifest">MANIFEST</a></strong>
117 <dd>
118 <p>A simple listing of all the files in your distribution.</p>
119 </dd>
120 <dd>
121 <pre>
122 Makefile.PL
123 MANIFEST
124 lib/Your/Module.pm</pre>
125 </dd>
126 <dd>
127 <p>File paths in a MANIFEST always use Unix conventions (ie. /) even if you're
128 not on Unix.</p>
129 </dd>
130 <dd>
131 <p>You can write this by hand or generate it with 'make manifest'.</p>
132 </dd>
133 <dd>
134 <p>See <a href="file://C|\msysgit\mingw\html/lib/ExtUtils/Manifest.html">the ExtUtils::Manifest manpage</a> for more details.</p>
135 </dd>
136 </li>
137 <dt><strong><a name="item_lib_2f">lib/</a></strong>
139 <dd>
140 <p>This is the directory where your .pm and .pod files you wish to have
141 installed go. They are layed out according to namespace. So Foo::Bar
142 is <em>lib/Foo/Bar.pm</em>.</p>
143 </dd>
144 </li>
145 <dt><strong><a name="item_t_2f">t/</a></strong>
147 <dd>
148 <p>Tests for your modules go here. Each test filename ends with a .t.
149 So <em>t/foo.t</em>/ 'make test' will run these tests. The directory is flat,
150 you cannot, for example, have t/foo/bar.t run by 'make test'.</p>
151 </dd>
152 <dd>
153 <p>Tests are run from the top level of your distribution. So inside a test
154 you would refer to ./lib to enter the lib directory, for example.</p>
155 </dd>
156 </li>
157 <dt><strong><a name="item_changes">Changes</a></strong>
159 <dd>
160 <p>A log of changes you've made to this module. The layout is free-form.
161 Here's an example:</p>
162 </dd>
163 <dd>
164 <pre>
165 1.01 Fri Apr 11 00:21:25 PDT 2003
166 - thing() does some stuff now
167 - fixed the wiggy bug in withit()</pre>
168 </dd>
169 <dd>
170 <pre>
171 1.00 Mon Apr 7 00:57:15 PDT 2003
172 - &quot;Rain of Frogs&quot; now supported</pre>
173 </dd>
174 </li>
175 <dt><strong><a name="item_readme">README</a></strong>
177 <dd>
178 <p>A short description of your module, what it does, why someone would use it
179 and its limitations. CPAN automatically pulls your README file out of
180 the archive and makes it available to CPAN users, it is the first thing
181 they will read to decide if your module is right for them.</p>
182 </dd>
183 </li>
184 <dt><strong><a name="item_install">INSTALL</a></strong>
186 <dd>
187 <p>Instructions on how to install your module along with any dependencies.
188 Suggested information to include here:</p>
189 </dd>
190 <dd>
191 <pre>
192 any extra modules required for use
193 the minimum version of Perl required
194 if only works on certain operating systems</pre>
195 </dd>
196 </li>
197 <dt><strong><a name="item_manifest_2eskip">MANIFEST.SKIP</a></strong>
199 <dd>
200 <p>A file full of regular expressions to exclude when using 'make
201 manifest' to generate the MANIFEST. These regular expressions
202 are checked against each file path found in the distribution (so
203 you're matching against ``t/foo.t'' not ``foo.t'').</p>
204 </dd>
205 <dd>
206 <p>Here's a sample:</p>
207 </dd>
208 <dd>
209 <pre>
210 ~$ # ignore emacs and vim backup files
211 .bak$ # ignore manual backups
212 \# # ignore CVS old revision files and emacs temp files</pre>
213 </dd>
214 <dd>
215 <p>Since # can be used for comments, # must be escaped.</p>
216 </dd>
217 <dd>
218 <p>MakeMaker comes with a default MANIFEST.SKIP to avoid things like
219 version control directories and backup files. Specifying your own
220 will override this default.</p>
221 </dd>
222 </li>
223 <dt><strong><a name="item_bin_2f">bin/</a></strong>
225 </dl>
227 </p>
228 <hr />
229 <h1><a name="see_also">SEE ALSO</a></h1>
230 <p><a href="file://C|\msysgit\mingw\html/pod/perlmodstyle.html">the perlmodstyle manpage</a> gives stylistic help writing a module.</p>
231 <p><a href="file://C|\msysgit\mingw\html/pod/perlnewmod.html">the perlnewmod manpage</a> gives more information about how to write a module.</p>
232 <p>There are modules to help you through the process of writing a module:
233 <a href="file://C|\msysgit\mingw\html/ExtUtils/ModuleMaker.html">the ExtUtils::ModuleMaker manpage</a>, <a href="file://C|\msysgit\mingw\html/Module/Install.html">the Module::Install manpage</a>, <em>PAR</em></p>
234 <table border="0" width="100%" cellspacing="0" cellpadding="3">
235 <tr><td class="block" style="background-color: #cccccc" valign="middle">
236 <big><strong><span class="block">&nbsp;ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker</span></strong></big>
237 </td></tr>
238 </table>
240 </body>
242 </html>