1ExtUtils::MakeMaker::TuUtsoerriaClo(n3t)ributed Perl DocEuxmteUnttialtsi:o:nMakeMaker::Tutorial(3)
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       It's 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 the .pm and .pod files you wish to have
84           installed go.  They are laid 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.
89
90           Typically, the t/ test directory is flat, with all test files
91           located directly within it. However, you can nest tests within
92           subdirectories, for example:
93
94               t/foo/subdir_test.t
95
96           To do this, you need to inform "WriteMakeFile()" in your
97           Makefile.PL file in the following fashion:
98
99               test => {TESTS => 't/*.t t/*/*.t'}
100
101           That will run all tests in t/, as well as all tests in all
102           subdirectories that reside under t/. You can nest as deeply as
103           makes sense for your project.  Simply add another entry in the test
104           location string. For example, to test:
105
106               t/foo/bar/subdir_test.t
107
108           You would use the following "test" directive:
109
110               test => {TESTS => 't/*.t t/*/*/*.t'}
111
112           Note that in the above example, tests in the first subdirectory
113           will not be run. To run all tests in the intermediary subdirectory
114           preceding the one the test files are in, you need to explicitly
115           note it:
116
117               test => {TESTS => 't/*.t t/*/*.t t/*/*/*.t'}
118
119           You don't need to specify wildcards if you only want to test within
120           specific subdirectories. The following example will only run tests
121           in t/foo:
122
123               test => {TESTS => 't/foo/*.t'}
124
125           Tests are run from the top level of your distribution.  So inside a
126           test you would refer to ./lib to enter the lib directory, for
127           example.
128
129       Changes
130           A log of changes you've made to this module.  The layout is free-
131           form.  Here's an example:
132
133               1.01 Fri Apr 11 00:21:25 PDT 2003
134                   - thing() does some stuff now
135                   - fixed the wiggy bug in withit()
136
137               1.00 Mon Apr  7 00:57:15 PDT 2003
138                   - "Rain of Frogs" now supported
139
140       README
141           A short description of your module, what it does, why someone would
142           use it and its limitations.  CPAN automatically pulls your README
143           file out of the archive and makes it available to CPAN users, it is
144           the first thing they will read to decide if your module is right
145           for them.
146
147       INSTALL
148           Instructions on how to install your module along with any
149           dependencies.  Suggested information to include here:
150
151               any extra modules required for use
152               the minimum version of Perl required
153               if only works on certain operating systems
154
155       MANIFEST.SKIP
156           A file full of regular expressions to exclude when using 'make
157           manifest' to generate the MANIFEST.  These regular expressions are
158           checked against each file path found in the distribution (so you're
159           matching against "t/foo.t" not "foo.t").
160
161           Here's a sample:
162
163               ~$          # ignore emacs and vim backup files
164               .bak$       # ignore manual backups
165               \#          # ignore CVS old revision files and emacs temp files
166
167           Since # can be used for comments, # must be escaped.
168
169           MakeMaker comes with a default MANIFEST.SKIP to avoid things like
170           version control directories and backup files.  Specifying your own
171           will override this default.
172
173       bin/
174

SEE ALSO

176       perlmodstyle gives stylistic help writing a module.
177
178       perlnewmod gives more information about how to write a module.
179
180       There are modules to help you through the process of writing a module:
181       ExtUtils::ModuleMaker, Module::Install, PAR
182
183
184
185perl v5.30.0                      2019-09-11  ExtUtils::MakeMaker::Tutorial(3)
Impressum