=encoding euc-jp =head1 NAME =begin original ExtUtils::MakeMaker::Tutorial - Writing a module with MakeMaker =end original ExtUtils::MakeMaker::Tutorial - MakeMaker を使ったモジュールの書き方 =head1 SYNOPSIS use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Your::Module', VERSION_FROM => 'lib/Your/Module.pm' ); =head1 DESCRIPTION =begin original This is a short tutorial on writing a simple module with MakeMaker. Its really not that hard. =end original これは簡単なモジュールを MakeMaker を使って作成する手順の簡単な紹介です。 ここでは複雑なことは抜きに読むことができます。 =head2 The Mantra (呪文) =begin original MakeMaker modules are installed using this simple mantra =end original MakeMaker を使っているモジュールは次の魔法の言葉をつかって インストールできます。 perl Makefile.PL make make test make install =begin original There are lots more commands and options, but the above will do it. =end original もっと様々なコマンドやオプションも扱えますが、通常はこれだけで十分です。 =head2 The Layout (レイアウト) =begin original The basic files in a module look something like this. =end original モジュール内の基本的なファイルは次のようなものです。 Makefile.PL MANIFEST lib/Your/Module.pm =begin original That's all that's strictly necessary. There's additional files you might want: =end original それらは厳密に必要とされています。 また、必要であれば以下のファイルを加えても良いでしょう: 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 =begin original When you run Makefile.PL, it makes a Makefile. That's the whole point of MakeMaker. The Makefile.PL is a simple module which loads ExtUtils::MakeMaker and runs the WriteMakefile() function with a few simple arguments. =end original Makefile.PL を実行すると Makefile が作成されます。 これが MakeMaker の全てです。 Makefile.PL は ExtUtils::MakeMaker をロードして WriteMakefile() 関数を わずかな引数で実行するだけの簡単なスクリプトです。 =begin original Here's an example of what you need for a simple module: =end original シンプルなモジュールでは次のようになります: use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Your::Module', VERSION_FROM => 'lib/Your/Module.pm' ); =begin original 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. =end original NAME はインストールするモジュールのトップレベルの名前空間です。 VERSION_FROM は配布パッケージのに使うバージョン番号を取得するファイルです。 指定したファイル内の $VERSION 変数の値が 配布パッケージのバージョンとして使われます。 大抵トップレベルのモジュールのファイルと同じでしょう。 =item MANIFEST =begin original A simple listing of all the files in your distribution. =end original 配布するファイルの単純なリストです。 Makefile.PL MANIFEST lib/Your/Module.pm =begin original File paths in a MANIFEST always use Unix conventions (ie. /) even if you're not on Unix. =end original MANIFEST ファイル内のファイルパスは常に(例え Unix 以外の環境で 作成していても) Unix のもの (すなわち /) を使います。 =begin original You can write this by hand or generate it with 'make manifest'. =end original このファイルは手で記述することも、'make manifest' によって 生成することもできます。 =item lib/ =begin original 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 lib/Foo/Bar.pm. =end original インストールする .pm 及び .pod ファイルを配置するディレクトリです。 各ファイルは名前空間に沿って配置します。 Foo::Base であれば lib/Foo/Bar.pm とします。 =item t/ =begin original Tests for your modules go here. Each test filename ends with a .t. So 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'. =end original モジュールのテストを行うファイルを置きます。 各テストファイルの名前は .t で終わるようにします。 つまり t/foo.t になります。 これらのファイルは 'make test' によって実行されます。 ディレクトリ内にはフラットに配置してください; 例えば、 t/foo/bar.t の様なファイルは 'make test' では実行されません。 =begin original 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. =end original テストは配布パッケージ内のトップディレクトリで実行されます。 テストスクリプト内からは、例えば lib ディレクトリは ./lib で 参照することになります。 =item Changes =begin original A log of changes you've made to this module. The layout is free-form. Here's an example: =end original モジュールに対して行われた様々な変更点。 書式は決まっていないのでお好みの形式で。 一例: 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 =begin original 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. =end original モジュールの短い説明を書きます; このモジュールが何を行う物なのか、なぜ使うべきなのか、 使用に当たっての制限などを記述しておくと良いでしょう。 CPAN では README ファイルをアーカイブから自動的に取り出して CPAN ユーザに利用できるようにするので、これが作成したモジュールが CPAN の利用者たちに見てもらう最初の文章になります。 =item INSTALL =begin original Instructions on how to install your module along with any dependencies. Suggested information to include here: =end original 何らかの依存関係を持っている場合に、どの様にインストールすればよいかの 手順書です。 このファイルに記述しておくべき情報は以下の様になります: =begin original any extra modules required for use the minimum version of Perl required if only works on certain operating systems =end original このモジュールには別の何かのモジュールを必要とします Perl が最低限必要です 特定のOSで動作します =item MANIFEST.SKIP =begin original 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"). =end original 'make manifest' を使って MANIFEST ファイルを生成するときに 対象外にするファイルを指定する完全な正規表現を記述します。 これらの正規表現はファイルパスに対して評価されます (つまり、"foo.t" ではなく "t/foo.t" に対してマッチングを 確認します)。 =begin original Here's a sample: =end original 例: ~$ # ignore emacs and vim backup files .bak$ # ignore manual backups \# # ignore CVS old revision files and emacs temp files =begin original Since # can be used for comments, # must be escaped. =end original # はコメントの始まりとして扱われるので # 自体を マッチさせたいときにはエスケープしなければなりません。 =begin original MakeMaker comes with a default MANIFEST.SKIP to avoid things like version control directories and backup files. Specifying your own will override this default. =end original MakeMaker はバージョン管理ディレクトリやバックアップファイルを 無視するデフォルトの MANIFEST.SKIP をもっています。 自分用の MANIFEST.SKIP があるとデフォルトの指定は 上書きされます。 =item bin/ =back =head1 SEE ALSO =begin original L gives stylistic help writing a module. =end original L にはモジュールを書く上での スタイル的なヘルプがあります。 =begin original L gives more information about how to write a module. =end original L にはモジュールの書き方に関するより多くの 情報があります。 =begin original There are modules to help you through the process of writing a module: L, L, L =end original モジュールを作る作業全体を通して役立つモジュールもあります: L, L, L =begin meta Translate: 山科 氷魚 (YAMASHINA Hio) (6.16) Update: SHIRAKATA Kentaro (6.17-) Status: completed =end meta =cut