OSDN Git Service

LaTex用に更新.
[omake-japanese/omake_trans.git] / rules.rst
1 .. 8-rules
2
3 .. index::
4    single: $*
5    single: $@
6    single: $^
7    single: $+
8    single: $<
9 .. _label8:
10
11 ビルドルール
12 ==================================
13 .. Rules are used by OMake to specify how to build files. At its simplest, a rule has the following form.
14
15 OMakeで使われているルールは、どのようにしてファイルをビルドするのかについて指定しています。最も簡単な例は以下のような形です。 ::
16
17     <target>: <dependencies>
18         <commands>
19
20 .. The <target> is the name of a file to be built. The <dependencies> are a list of files that are needed before the <target> can be built. The <commands> are a list of indented lines specifying commands to build the target. For example, the following rule specifies how to compile a file hello.c.
21
22 ``<target>`` ではビルドするファイル名を記述します。 ``<dependencies>`` では ``<target>`` をビルドする前に必要なファイルのリストを記述します。 ``<commands>`` はターゲットをビルドするためのコマンドを、インデントした状態で記述します。例えば、以下のルールではどのようにファイル ``hello.c`` をコンパイルするのかについて指定しています。 ::
23
24     hello.o: hello.c
25         $(CC) $(CFLAGS) -c -o hello.o hello.c
26
27 .. This rule states that the hello.o file depends on the hello.c file. If the hello.c file has changed, the command $(CC) $(CFLAGS) -c -o hello.o hello.c is to be executed to update the target file hello.o.
28
29 このルールでは、 ``hello.o`` ファイルは ``hello.c`` ファイルに依存しています。 ``hello.c`` ファイルが変更された場合、コマンド ``$(CC) $(CFLAGS) -c -o hello.o hello.c`` が実行されて、ターゲットファイル ``hello.o`` は更新されます。
30
31 .. A rule can have an arbitrary number of commands. The individual command lines are executed independently by the command shell. The commands do not have to begin with a tab, but they must be indented from the dependency line.
32
33 ルールの中には任意の数のコマンドを含めることができます。各々の独立したコマンドラインはコマンドシェルによって、独立した状態で実行されます。コマンドの最初にタブを含めることはできません。しかし、依存関係を指定している行からはインデントされなければなりません。
34
35 .. In addition to normal variables, the following special variables may be used in the body of a rule.
36       * $*: the target name, without a suffix.
37       * $@: the target name.
38       * $^: a list of the sources, in alphabetical order, with duplicates removed.
39       * $+: all the sources, in the original order.
40       * $<: the first source. 
41
42 通常の変数に加えて、以下の特殊変数をルールの内容で使うことができます。
43
44 * ``$*`` : 拡張子を除いたターゲットの名前
45 * ``$@`` : ターゲットの名前
46 * ``$^`` : 依存ファイルのリストをアルファベット順に並べ、かつ重複した内容を削除したもの
47 * ``$+`` : 元の順番で並んでいる依存ファイルのリスト
48 * ``$<`` : 最初の依存ファイル
49
50 .. For example, the above hello.c rule may be simplified as follows.
51
52 例えば、上の ``hello.c`` ルールは以下のように簡略化されます。 ::
53
54     hello.o: hello.c
55         $(CC) $(CFLAGS) -c -o $@ $<
56
57 .. Unlike normal values, the variables in a rule body are expanded lazily, and binding is dynamic. The following function definition illustrates some of the issues.
58
59 通常の値とは異なり、ルール中の変数は遅延評価されて、かつ動的なスコーピングが行われます。以下の関数定義はこの性質のいくつかを端的に表しています。 ::
60
61     CLibrary(name, files) =
62         OFILES = $(addsuffix .o, $(files))
63
64         $(name).a: $(OFILES)
65             $(AR) cq $@ $(OFILES)
66
67 .. This function defines a rule to build a program called $(name) from a list of .o files. The files in the argument are specified without a suffix, so the first line of the function definition defines a variable OFILES that adds the .o suffix to each of the file names. The next step defines a rule to build a target library $(name).a from the $(OFILES) files. The expression $(AR) is evaluated when the function is called, and the value of the variable AR is taken from the caller's scope (see also the section on Scoping).
68
69 この関数は ``.o`` ファイルのリストから ``$(name)`` という名前のプログラムをビルドしています。引数のファイルは拡張子なしで指定されているので、まず最初の定義では各々のファイル名に拡張子 ``.o`` を加えた配列を、変数 ``OFILES`` に束縛しています。次のステップでは ``$(OFILES)`` からターゲットライブラリ ``$(name).a`` をビルドするためのルールを定義しています。 ``$(AR)`` は関数が呼び出されて、呼び出してるスコープから変数 ``AR`` が与えられた時点で評価されます(詳細はスコーピングのセクションを参照してください)。
70
71 .. index::
72    single: ワイルドカード
73 .. _label8.1:
74
75 暗黙のルール
76 ----------------------------------
77 .. Rules may also be implicit. That is, the files may be specified by wildcard patterns. The wildcard character is %. For example, the following rule specifies a default rule for building .o files.
78
79 ルールはまた暗黙的にすることもできます。これは、ファイルがワイルドカードパターンによって指定されることを示しています。ワイルドカードとしてOMakeでは ``%`` を使用します。例えば、以下のルールでは ``.o`` ファイルをビルドするための通常のルールを指定しています。 ::
80
81     %.o: %.c
82         $(CC) $(CFLAGS) -c -o $@ $*.c
83
84 .. This rule is a template for building an arbitrary .o file from a .c file.
85
86 このルールは任意の ``.c`` ファイルから ``.o`` ファイルをビルドするためのテンプレートとなっています。
87
88 .. By default, implicit rules are only used for the targets in the current directory. However subdirectories included via the .SUBDIRS rules inherit all the implicit rules that are in scope (see also the section on Scoping).
89
90 通常、暗黙のルールはカレントディレクトリ中のターゲットのみに用いられます。しかしながら、 ``.SUBDIRS`` ルールを経由したものも含むサブディレクトリには、スコープ中にある暗黙のルールがすべて継承されます(詳細はスコーピングのセクションを参照してください)。
91
92 .. _label8.2:
93
94 束縛された暗黙のルール
95 ----------------------------------
96 .. Implicit rules may specify the set of files they apply to. The following syntax is used.
97
98 暗黙のルールのターゲットにはいくつかのファイルを指定することもできます。そのためには以下のような構文を用います。 ::
99
100     <targets>: <pattern>: <dependencies>
101         <commands>
102
103 .. For example, the following rule applies only to the files a.o and b.o.
104
105 例えば、以下のルールではファイル ``a.o`` と ``b.o`` のみにルールを適用しています。 ::
106
107    a.o b.o: %.o: %.c
108         $(CC) $(CFLAGS) -DSPECIAL -c $*.c
109
110 .. index::
111    single: section
112 .. _label8.3:
113
114 section
115 ----------------------------------
116 .. Frequently, the commands in a rule body are expressions to be evaluated by the shell. omake also allows expressions to be evaluated by omake itself.
117
118 ルールの内容に書かれているコマンドはシェルによって頻繁に評価されます。omakeはまた、omake自身も評価の対象に加えることもできます。
119
120 .. The syntax of these “computed rules” uses the section expression. The following rule uses the omake IO functions to produce the target hello.c.
121
122 これらの『ファイルを作るためのルール』を表現するためには ``section`` 表現を使います。以下のルールではターゲットの ``hello.c`` を生成するためにomakeのIO関数を用いています。 ::
123
124     hello.c:
125         section
126             FP = fopen(hello.c, w)
127             fprintln($(FP), $""#include <stdio.h> int main() { printf("Hello world\n"); }"")
128             close($(FP))
129
130 .. This example uses the quotation $""..."" (see also Section B.1.6) to quote the text being printed. These quotes are not included in the output file. The fopen, fprintln, and close functions perform file IO as discussed in the IO section.
131
132 この例では出力するテキストをクオートするために、クオーテーション ``$""...""`` を用いています(詳細はB.1.6のセクションを参照してください)。これらのクオートは出力されたファイルには含まれていません。 ``fopen`` , ``fprintln`` , ``close`` 関数はIOセクションで評価するようにファイルのIOを実行します。
133
134 .. In addition, commands that are function calls, or special expressions, are interpreted correctly. Since the fprintln function can take a file directly, the above rule can be abbreviated as follows.
135
136 加えて、関数の呼び出しや他の特殊なコマンドはその場で正しく評価されます。また、 ``fprintln`` 関数はファイルを直接出力することもできるので、上のルールは下のような形に省略できます。 ::
137
138     hello.c:
139        fprintln($@, $""#include <stdio.h> int main() { printf("Hello world\n"); }"")
140
141 .. index::
142    single: section rule
143 .. _label8.4:
144
145 section rule
146 ----------------------------------
147 .. Rules can also be computed using the section rule form, where a rule body is expected instead of an expression. In the following rule, the file a.c is copied onto the hello.c file if it exists, otherwise hello.c is created from the file default.c.
148
149 また、ターゲットの依存関係がルールの内容で記述されるような場合、 ``section rule`` を使うことで計算することができます。以下のルールでは、ファイル ``a.c`` が存在していた場合は内容を ``hello.c`` にコピーし、そうでなければ ``hello.c`` は ``default.c`` から生成されます。 ::
150
151     hello.c:
152         section rule
153            if $(target-exists a.c)
154               hello.c: a.c
155                  cat a.c > hello.c
156            else
157               hello.c: default.c
158                  cp default.c hello.c
159
160 .. _label8.5:
161
162 特別な依存関係
163 ----------------------------------
164
165 .. index::
166    single: :exists:
167 .. _label8.5.1:
168
169 \:exists:
170 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171 .. In some cases, the contents of a dependency do not matter, only whether the file exists or not. In this case, the :exists: qualifier can be used for the dependency.
172
173 時々、依存しているファイルの内容ではなく、ファイルが存在しているのかどうかが重要となる場合もあるでしょう。 ``:exists:`` 修飾子はこのような依存関係を指定したい場合に用いられます。 ::
174
175     foo.c: a.c :exists: .flag
176        if $(test -e .flag)
177            $(CP) a.c $@
178
179 .. index::
180    single: :effects:
181 .. _label8.5.2:
182
183 \:effects:
184 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
185 .. Some commands produce files by side-effect. For example, the latex(1) command produces a .aux file as a side-effect of producing a .dvi file. In this case, the :effects: qualifier can be used to list the side-effect explicitly. omake is careful to avoid simultaneously running programs that have overlapping side-effects.
186
187 コマンドの中には副産物として別のファイルを生み出すものもあるでしょう。例えば、 ``latex(1)`` コマンドは ``.dvi`` ファイルを生成する際、副産物として ``.aux`` ファイルを生成します。このような場合、 ``:effects:`` 修飾子はこのような副産物のファイルを明示的に指定したい場合に用いられます。omakeはこのファイルを上書きしないように、平行してプログラムを実行させないようにします。 ::
188
189     paper.dvi: paper.tex :effects: paper.aux
190         latex paper
191
192 .. index::
193    single: :value:
194 .. _label8.5.3:
195
196 \:value:
197 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
198 .. The :value: dependency is used to specify that the rule execution depends on the value of an expression. For example, the following rule
199
200 ``:value:`` 依存関係は、ルールの実行がある式の値に依存していることを指定するために用いられます。例えば、以下のルールを見てください。 ::
201
202     a: b c :value: $(X)
203         ...
204
205 .. specifies that “a” should be recompiled if the value of $(X) changes (X does not have to be a filename). This is intended to allow greater control over dependencies.
206
207 上のルールでは、"a"が ``$(X)`` の値が変わった場合に再コンパイルされる必要があることを指定しています(Xがファイル名である必要はありません)。これはファイルや変数の依存関係をより精密にコントロールすることを意図しています。
208
209 .. In addition, it can be used instead of other kinds of dependencies. For example, the following rule:
210
211 加えて、これは他の依存関係の代わりに用いることができます。例えば、以下のルールは、その次のルールと等価です。 ::
212
213     a: b :exists: c
214         commands
215
216 ::
217
218     a: b :value: $(target-exists c)
219         commands
220
221 .. Notes:
222       * The values are arbitrary (they are not limited to variables)
223       * The values are evaluated at rule expansion time, so expressions containing variables like $@, $^, etc are legal. 
224
225 .. note::
226   * 任意の値をとることができます(指定する変数に制限はありません)。
227   * 値はルールが展開されるときに評価されます。なので式には ``$@`` や ``#^`` のような変数も含めることができます。
228
229 .. index::
230    single: .SCANNER
231    single: digest()
232    single: digest-in-path-optional()
233 .. _label8.6:
234
235 .SCANNER ルール
236 ----------------------------------
237 .. Scanner rules define a way to specify automatic dependency scanning. A .SCANNER rule has the following form.
238
239 スキャナルールでは、自動的に依存関係の解析を行う方法について定義します。 ``.SCANNER`` ルールは以下のような形となります。 ::
240
241     .SCANNER: target: dependencies
242         commands
243
244 .. The rule is used to compute additional dependencies that might be defined in the source files for the specified target. The result of executing the scanner commands must be a sequence of dependencies in OMake format, printed to the standard output. For example, on GNU systems the gcc -MM foo.c produces dependencies for the file foo.c (based on #include information).
245
246 ルールは、指定されたターゲットのソースファイルに定義されている、追加の依存関係を計算するのに用いられます。 ``.SCANNER`` コマンドの実行結果は、OMakeのフォーマットで依存関係のシーケンスが標準の出力先に出力される必要があります。例えばGNUシステムでは、 ``gcc -MM foo.c`` はファイル ``foo.c`` の依存関係を生成するコマンドです(これは ``#include`` の情報を元にしています)。
247
248 .. We can use this to specify a scanner for C files that adds the scanned dependencies for the .o file. The following scanner specifies that dependencies for a file, say foo.o can be computed by running gcc -MM foo.c. Furthermore, foo.c is a dependency, so the scanner should be recomputed whenever the foo.c file changes.
249
250 私たちはこれを用いて、 ``.c`` ファイルから ``.o`` ファイルを生成するため、スキャンされた依存関係を既存の依存関係に追加することができます。以下のスキャナではファイルの依存関係を指定しており、仮に ``foo.o`` が指定されたとすると、 ``gcc -MM foo.c`` を実行することによって依存関係の解析が行われます。さらには、 ``foo.c`` は依存されているので、 ``foo.c`` が変更された場合はいつでもスキャナは再計算されます。 ::
251
252     .SCANNER: %.o: %.c
253         gcc -MM $<
254
255 .. Let's suppose that the command gcc -MM foo.c prints the following line.
256
257 コマンド ``gcc -MM foo.c`` は以下の行を出力するものとします。 ::
258
259     foo.o: foo.h /usr/include/stdio.h
260
261 .. The result is that the files foo.h and /usr/include/stdio.h are considered to be dependencies of foo.o—that is, foo.o should be rebuilt if either of these files changes.
262
263 以上から、ファイル ``foo.h`` と ``/usr/include/stdio.h`` は ``foo.o`` に依存しているものと考えられます。これは、もしこれらのファイルのどれか一つが変更された場合、 ``foo.o`` はリビルドされるべきであることを示しています。
264
265 .. This works, to an extent. One nice feature is that the scanner will be re-run whenever the foo.c file changes. However, one problem is that dependencies in C are recursive. That is, if the file foo.h is modified, it might include other files, establishing further dependencies. What we need is to re-run the scanner if foo.h changes too.
266
267 これはある程度ですがうまく動きます。この機能の利点の一つとしては、 ``foo.c`` が変更された場合、いつでもスキャナが再解析を行ってくれるというのが挙げられます。しかしながらこれには問題があります。Cの依存関係は *再帰的* なのです。すなわち、もしファイル ``foo.h`` が修正されたとしたら、そのファイルは他のファイルを含んでいることで、さらなる依存関係が生じているのかもしれません。必要なのは ``foo.h`` の変更に応じて、再びスキャナを実行することです。
268
269 .. We can do this with a value dependency. The variable $& is defined as the dependency results from any previous scan. We can add these as dependencies using the digest function, which computes an MD5 digest of the files.
270
271 私たちはこの問題を『依存関係を示す値(value dependency)』を用いて解決しました。変数 ``$&`` は任意の前回のスキャンから、依存関係の結果を返す変数として定義されています。私たちはこれらの依存関係を、ファイルのMD5による要約を計算して返す ``digest`` 関数を用いて追加しました。 ::
272
273     .SCANNER: %.o: %.c :value: $(digest $&)
274         gcc -MM $<
275
276 .. Now, when the file foo.h changes, its digest will also change, and the scanner will be re-run because of the value dependency (since $& will include foo.h).
277
278 これで、ファイル ``foo.h`` が変更されたときには要約も変更されているのでスキャナは再計算されます。これは依存関係を示す値( ``$&`` には ``foo.h`` がインクルードされています)によるものです。
279
280 .. This still is not quite right. The problem is that the C compiler uses a search-path for include files. There may be several versions of the file foo.h, and the one that is chosen depends on the include path. What we need is to base the dependencies on the search path.
281
282 ですが、これはまだ完全に正しいというわけではありません。Cコンパイラはインクルードファイルのために *検索パス(search-path)* を使用しているのです。ファイル ``foo.h`` には何通りものバージョンが存在しており、そのうちの選んでいる一つがインクルードパスに依存しているのかもしれません。必要なのは検索パスの依存関係も含めることです。
283
284 .. The $(digest-in-path-optional ...) function computes the digest based on a search path, giving us a solution that works.
285
286 ``$(digest-in-path-optional ...)`` 関数は検索パスを元にした要約を計算し、この問題に解決案を提示します。 ::
287
288     .SCANNER: %.o: %.c :value: $(digest-in-path-optional $(INCLUDES), $&)
289        gcc -MM $(addprefix -I, $(INCLUDES)) $<
290
291 .. The standard output of the scanner rules will be captured by OMake and is not allowed to contain any content that OMake will not be able to parse as a dependency. The output is allowed to contain dependency specifications for unrelated targets, however such dependencies will be ignored. The scanner rules are allowed to produce arbitrary output on the standard error channel — such output will be handled in the same way as the output of the ordinary rules (in other words, it will be presented to the user, when dictated by the --output-… options enabled).
292
293 スキャナルールの標準出力はOMakeによって捉えられるので、OMakeが依存関係を解析できない内容を含むことは許されません。まだ関連付けられていない依存関係について出力することは許されますが、このような依存関係は無視されます。スキャナルールでは標準エラーの出力先に任意の内容を出力することが許されています。このような出力は通常のルールの出力と同様に扱われます。(言い換えれば、これは --output-… オプションを有効にすることで、ユーザーに見せることのできる出力です。)
294
295 .. Additional examples of the .SCANNER rules can be found in Section 3.4.3.
296
297 ``.SCANNER`` ルールについての追加例は ":ref:`label3.4.3`" で見つけることができます。
298
299 .. index::
300    single: :scanner:
301 .. _label8.6.1:
302
303 スキャナの命名と :scanner: 依存関係
304 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
305 .. Sometimes it may be useful to specify explicitly which scanner should be used in a rule. For example, we might compile .c files with different options, or (heaven help us) we may be using both gcc and the Microsoft Visual C++ compiler cl. In general, the target of a .SCANNER is not tied to a particular target, and we may name it as we like.
306
307 スキャナがルール中で使われていることを明示的に指定するほうが有用である場合があります。例えば、私たちは ``.c`` ファイルを異なったオプションでコンパイルしたり、あるいは(天よ我らを助けて!) ``gcc`` と Microsoft Visual C++ コンパイラ ``cl`` の両方を使いたいとしましょう。通常、 ``.SCANNER`` のターゲットは特定のターゲットに結びついていないのですが、私たちはこれを好きなように命名することができます。 ::
308
309     .SCANNER: scan-gcc-%.c: %.c :value: $(digest-in-path-optional $(INCLUDES), $&)
310         gcc -MM $(addprefix -I, $(INCLUDES)) $<
311
312     .SCANNER: scan-cl-%.c: %.c :value: $(digest-in-path-optional $(INCLUDES), $&)
313         cl --scan-dependencies-or-something $(addprefix /I, $(INCLUDES)) $<
314
315 .. The next step is to define explicit scanner dependencies. The :scanner: dependency is used for this. In this case, the scanner dependencies are specified explicitly.
316
317 次のステップはスキャナの依存関係を明示的に定義することです。 ``:scanner:`` 依存関係はこのために用いられます。この場合、スキャナの依存関係は明示的に指定されます。 ::
318
319     $(GCC_FILES): %.o: %.c :scanner: scan-gcc-%c
320         gcc ...
321
322     $(CL_FILES): %.obj: %.c :scanner: scan-cl-%c
323         cl ...
324
325 .. Explicit :scanner: scanner specification may also be used to state that a single .SCANNER rule should be used to generate dependencies for more than one target. For example,
326
327 明示的な ``:scanner:`` スキャナの指定は、単体の ``.SCANNER`` ルールを複数のターゲットに向けて依存関係を生成することにも用いられます。例えば以下の例を見てみましょう。 ::
328
329     .SCANNER: scan-all-c: $(GCC_FILES) :value: $(digest-in-path-optional $(INCLUDES), $&)
330         gcc -MM $(addprefix -I, $(INCLUDES)) $(GCC_FILES)
331
332     $(GCC_FILES): %.o: %.c :scanner: scan-all-c
333         ...
334
335 .. The above has the advantage of only running gcc once and a disadvantage that when a single source file changes, all the files will end up being re-scanned.
336
337 上の例はgccが一回だけ呼び出されるという利点と、一つのソースファイルが変更された場合、すべてのファイルが再スキャンされてしまうという欠点の両方を持ち合わせています。
338
339 .. index::
340    single: SCANNER_MODE
341 .. _label8.6.2:
342
343 ノート
344 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
345 .. In most cases, you won't need to define scanners of your own. The standard installation includes default scanners (both explicitly and implicitly named ones) for C, OCaml, and LATEX files.
346
347 多くの場合において、あなたは自分の手でスキャナを定義する必要はありません。OMakeにはC, OCaml, LaTeXファイルのためのスキャナ(しかも暗黙的、明示的に命名されたスキャナの両方)が標準で用意されています。
348
349 .. The SCANNER_MODE variable controls the usage of implicit scanner dependencies.
350
351 ``SCANNER_MODE`` 変数は、暗黙のスキャナの依存関係の使用についてコントロールする変数です。
352
353 .. The explicit :scanner: dependencies reduce the chances of scanner mis-specifications. In large complicated projects it might be a good idea to set SCANNER_MODE to error and use only the named .SCANNER rules and explicit :scanner: specifications.
354
355 明示的に ``:scanner:`` 依存関係を指定することは、スキャナが間違って指定してしまう危険を減らします。巨大で複雑なプロジェクトでは ``SCANNER_MODE`` を ``error`` に設定することで、名前がある ``.SCANNER`` ルールと明示的な ``:scanner:`` 指定を使うようにしましょう。
356
357 .. index::
358    single: .DEFAULT
359 .. _label8.7:
360
361 .DEFAULT
362 ----------------------------------
363 .. The .DEFAULT target specifies a target to be built by default if omake is run without explicit targets. The following rule instructs omake to build the program hello by default
364
365 ``.DEFAULT`` ターゲットは、omakeが明示的にターゲットを指定していないようなデフォルトの状態でビルドされるターゲットを指定するために用いられます。以下のルールでは ``hello`` プログラムがデフォルトの状態でビルドすることを指定しています。 ::
366
367    .DEFAULT: hello
368
369 .. index::
370    single: .SUBDIRS
371 .. _label8.8:
372
373 .SUBDIRS
374 ----------------------------------
375 .. The .SUBDIRS target is used to specify a set of subdirectories that are part of the project. Each subdirectory should have its own OMakefile, which is evaluated in the context of the current environment.
376
377 ``.SUBDIRS`` ターゲットはプロジェクトの一部であるサブディレクトリの集合を指定するために用いられます。各々のサブディレクトリには、サブディレクトリの内容をその環境下で評価するための ``OMakefile`` をそれぞれ有しているべきです。 ::
378
379    .SUBDIRS: src doc tests
380
381 .. This rule specifies that the OMakefiles in each of the src, doc, and tests directories should be read.
382
383 このルールでは ``src`` , ``doc`` , ``test`` ディレクトリの中のOMakefileをそれぞれ読み込むことを指定しています。
384
385 .. In some cases, especially when the OMakefiles are very similar in a large number of subdirectories, it is inconvenient to have a separate OMakefile for each directory. If the .SUBDIRS rule has a body, the body is used instead of the OMakefile.
386
387 いくつかの場合─特に ``OMakefile`` の内容が似ている大量のサブディレクトリを持っているような場合─各々のディレクトリに分割して ``OMakefile`` を持たせるのは不便でしょう。もし ``.SUBDIRS`` ルールの中に内容を記述したとすると、その内容が ``OMakefile`` の代わりとして使われます。 ::
388
389    .SUBDIRS: src1 src2 src3
390       println(Subdirectory $(CWD))
391       .DEFAULT: lib.a
392
393 .. In this case, the src1, src2, and src3 files do not need OMakefiles. Furthermore, if one exists, it is ignored. The following includes the file if it exists.
394
395 この場合、サブディレクトリ ``src1`` , ``src2`` , ``src3`` には ``OMakefile`` が必要ありません。さらには、たとえ ``OMakefile`` が存在していた場合でも、OMakeはそれを無視します。以下の例では ``OMakefile`` が含まれていた場合、そのファイルをインクルードするよう指定しています。 ::
396
397    .SUBDIRS: src1 src2 src3
398        if $(file-exists OMakefile)
399           include OMakefile
400        .DEFAULT: lib.a
401
402 .. index::
403    single: .INCLUDE
404 .. _label8.9:
405
406 .INCLUDE
407 ----------------------------------
408 .. The .INCLUDE target is like the include directive, but it specifies a rule to build the file if it does not exist.
409
410 ``.INCLUDE`` ターゲットは ``include`` 文と似ていますが、 ``.INCLUDE`` ではたとえ指定されたファイルが存在していなくても、ビルドするためのルールを指定できます。 ::
411
412    .INCLUDE: config
413        echo "CONFIG_READ = true" > config
414
415     echo CONFIG_READ is $(CONFIG_READ)
416
417 .. You may also specify dependencies to an .INCLUDE rule.
418
419 あなたはまた ``.INCLUDE`` ルールの依存関係を指定できます。 ::
420
421    .INCLUDE: config: config.defaults
422       cp config.defaults config
423
424 .. A word of caution is in order here. The usual policy is used for determining when the rule is out-of-date. The rule is executed if any of the following hold.
425       * the target does not exist,
426       * the rule has never been executed before,
427       * any of the following have changed since the last time the rule was executed,
428             o the target,
429             o the dependencies,
430             o the commands-text. 
431
432 順番どおりにターゲットと依存関係が記述されています。通常の場合ですと、この記法はルールがいつ期限切れになったのかどうかを決定するために用いられます。 ``.INCLUDE`` 内のルールは、以下の場合のどれかに当てはまったときに実行されます。
433
434 * ターゲットが存在しない場合
435 * 以前からずっとこのルールが実行されていなかった場合
436 * ルールが実行された最後の時間から現在までの間に、以下のうちどれかが変更されていた場合
437
438   * ターゲット
439   * 依存先
440   * コマンド文
441
442 .. In some of the cases, this will mean that the rule is executed even if the target file already exists. If the target is a file that you expect to edit by hand (and therefore you don't want to overwrite it), you should make the rule evaluation conditional on whether the target already exists.
443
444 これは、たとえ既にターゲットファイルが存在していたとしても、ルールが実行される場合もあることを示しています。もしターゲットが、エディターなどで変更するような(それゆえ上書きされたくない)ファイルを指定する場合、あなたはルールの評価を、ターゲットが既に存在しているかどうかで条件分岐させるべきです。 ::
445
446    .INCLUDE: config: config.defaults
447        # わたしが注意深く手作業で変更したファイルを上書きさせません!
448        if $(not $(file-exists config))
449           cp config.defaults config
450
451 .. index::
452    single: .PHONY
453 .. _label8.10:
454
455 .PHONY
456 ----------------------------------
457 .. A “phony” target is a target that is not a real file, but exists to collect a set of dependencies. Phony targets are specified with the .PHONY rule. In the following example, the install target does not correspond to a file, but it corresponds to some commands that should be run whenever the install target is built (for example, by running omake install).
458
459 "phony" ターゲットは実際には存在しませんが、複数の依存関係を持っているようなターゲットです。Phony ターゲットは ``.PHONY`` ルールを用いて指定します。以下の例では、 ``install`` ターゲットは実際のファイルではありませんが、( ``omake install`` が実行されることによって) ``install`` ターゲットが生起された場合はいつでも、いくつかのコマンドが実行されます。 ::
460
461    .PHONY: install
462
463    install: myprogram.exe
464       cp myprogram.exe /usr/bin
465
466 .. _label8.11:
467
468 スコープ規則
469 ----------------------------------
470 .. As we have mentioned before, omake is a scoped language. This provides great flexibility—different parts of the project can define different configurations without interfering with one another (for example, one part of the project might be compiled with CFLAGS=-O3 and another with CFLAGS=-g).
471
472 以前私たちが注意したように、omakeは *スコープ化された* 言語です。これは非常に融通のきく─プロジェクトの異なるパートは別のパートを気にすることなく、異なった設定を定義することができる─ものとなっています。例えば、プロジェクトのあるパートには ``CFLAGS=-O3`` を持たせてコンパイルさせるが、別のパートには ``CFLAGS=-g`` を持たせるといった具合です。
473
474 .. But how is the scope for a target file selected? Suppose we are building a file dir/foo.o. omake uses the following rules to determine the scope.
475
476 しかし、どのようにしてターゲットファイルのスコープが選択されるのでしょうか?そこで、現在私たちはファイル ``dir/foo.o`` をビルドしているものとしましょう。omakeではスコープを決定するために、以下のルールを用います。
477
478 .. * First, if there is an explicit rule for building dir/foo.o (a rule with no wildcards), the context for that rule determines the scope for building the target.
479    * Otherwise, the directory dir/ must be part of the project. This normally means that a configuration file dir/OMakefile exists (although, see the .SUBDIRS section for another way to specify the OMakefile). In this case, the scope of the target is the scope at the end of the dir/OMakefile. 
480
481 * まず、もし ``fir/foo.o`` をビルドするための明示的なルールが指定されていた(そしてそのルールはワイルドカードを用いていない)場合、そのルールに従って、ターゲットをビルドするためのスコープが決定されます。
482 * さもなければ、ディレクトリ ``dir/`` はプロジェクトの一部であるので、普通に考えて設定ファイル ``dir/OMakefile`` が存在するはずです(あるいは、 ``OMakefile`` を ``.SUBDIRS`` セクションを用いるなどのなにか別の方法で指定しているかもしれません)。この場合、ターゲットのスコープは ``dir/OMakefile`` の終わりのスコープです。
483
484 .. To illustrate rule scoping, let's go back to the example of a “Hello world” program with two files. Here is an example OMakefile (the two definitions of CFLAGS are for illustration).
485
486 このスコープ規則を確かめるために、2つのファイルから "Hello world" プログラムを作る例へと戻ってみましょう。これは ``OMakefile`` のサンプルです。( ``CFLAGS`` の2つの定義がスコープ規則の確認に用いられます) ::
487
488     # 実行ファイルはデバッグオプションを用いてコンパイルされます
489     CFLAGS = -g
490     hello: hello_code.o hello_lib.o
491        $(CC) $(CFLAGS) -o $@ $+
492
493     # CFLAGSの再定義
494     CFLAGS += -O3
495
496 .. In this project, the target hello is explicit. The scope of the hello target is the line beginning with hello:, where the value of CFLAGS is -g. The other two targets, hello_code.o and hello_lib.o do not appear as explicit targets, so their scope is at the end of the OMakefile, where the CFLAGS variable is defined to be -g -O3. That is, hello will be linked with CFLAGS=-g and the .o files will be compiled with CFLAGS=-g -O3.
497
498 このプロジェクトでは、ターゲット ``hello`` は *明示的* です。 ``hello`` ターゲットのスコープは ``hello:`` から始まる行なので、 ``CFLAGS`` の値は ``-g`` となります。別の2つのターゲット ``hello_code.o`` と ``hello_lib.o`` は明示的にターゲットが指定されていないため、これらのスコープは ``OMakefile`` の終わりで決定しますので、 ``CFLAGS`` の値は ``-g -O3`` となります。これは、 ``hello`` が ``CFLAGS=-g`` でリンクされて、 ``.o`` ファイルが ``CFLAGS=-g -O3`` でコンパイルされることを表しています。
499
500 .. We can change this behavior for any of the targets by specifying them as explicit targets. For example, suppose we wish to compile hello_lib.o with a preprocessor variable LIBRARY.
501
502 私たちは明示的にターゲットを指定することで、任意のターゲットのふるまいを変えることができます。例えば、私たちは ``hello_lib.o`` を、プリプロセッサ変数 ``LIBRARY`` を用いてコンパイルしたいものとしましょう。 ::
503
504     # 実行ファイルはデバッグオプションを用いてコンパイルされます
505     CFLAGS = -g
506     hello: hello_code.o hello_lib.o
507        $(CC) $(CFLAGS) -o $@ $+
508
509     # hello_lib.o を CFLAGS = -g -DLIBRARY オプションでコンパイル
510     section
511         CFLAGS += -DLIBRARY
512         hello_lib.o:
513
514     # CFLAGSの再定義
515     CFLAGS += -O3
516
517 .. In this case, hello_lib.o is also mentioned as an explicit target, in a scope where CFLAGS=-g -DLIBRARY. Since no rule body is specified, it is compiled using the usual implicit rule for building .o files (in a context where CFLAGS=-g -DLIBRARY).
518
519 この場合、 ``hello_lib.o`` の暗黙のターゲットが、 ``CFLAGS=-g -DLIBRARY`` のスコープ中で指定されています。これはルールの内容が指定されていないため、 ``.o`` ファイルは、通常の暗黙のルールを使って( ``CFLAGS=-g -DLIBRARY`` のオプションで)コンパイルされます。
520
521 .. index::
522    single: 暗黙のルール
523 .. _label8.11.1:
524
525 暗黙のルールのスコーピング
526 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
527 .. Implicit rules (rules containing wildcard patterns) are not global, they follow the normal scoping convention. This allows different parts of a project to have different sets of implicit rules. If we like, we can modify the example above to provide a new implicit rule for building hello_lib.o.
528
529 暗黙のルール(ワイルドパターンを含む)は *グローバルではなく* 、通常のスコープ規則に従っています。これによって、異なるプロジェクトのパートは、異なる暗黙のルールの集合を持つことができるようになりました。もしやってみたいのであれば、私たちは上のサンプルを、以下のような新しい暗黙のルールに修正することができます。 ::
530
531     # 実行ファイルはデバッグオプションを用いてコンパイルされます
532     CFLAGS = -g
533     hello: hello_code.o hello_lib.o
534        $(CC) $(CFLAGS) -o $@ $+
535
536     # hello_lib.o を CFLAGS = -g -DLIBRARY オプションでコンパイル
537     section
538         %.o: %.c
539             $(CC) $(CFLAGS) -DLIBRARY -c $<
540         hello_lib.o:
541
542     # CFLAGSの再定義
543     CFLAGS += -O3
544
545 .. In this case, the target hello_lib.o is built in a scope with a new implicit rule for building %.o files. The implicit rule adds the -DLIBRARY option. This implicit rule is defined only for the target hello_lib.o; the target hello_code.o is built as normal.
546
547 この場合、ターゲット ``hello_lib.o`` は、 ``%.o`` をビルドするための新しい暗黙のルールがあるスコープ中でビルドされます。この暗黙のルールでは ``-DLIBRARY`` オプションを加えています。この暗黙のルールはターゲット ``hello_lib.o`` だけに定義されるため、ターゲット ``hello_code.o`` は普通にビルドされます。
548
549 .. index::
550    single: .SCANNER
551    single: :scanner:
552 .. _label8.11.2:
553
554 .SCANNER ルールのスコーピング
555 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
556 .. Scanner rules are scoped the same way as normal rules. If the .SCANNER rule is explicit (containing no wildcard patterns), then the scope of the scan target is the same as the the rule. If the .SCANNER rule is implicit, then the environment is taken from the :scanner: dependency.
557
558 スキャナルールは通常のスコープ規則と同様にスコープされます。 ``.SCANNER`` ルールが明示的に指定されていた(ワイルドカードパターンを含まない)場合、スキャンターゲットのスコープはルールと同様に扱われます。 ``.SCANNER`` ルールが暗黙的に指定されていた場合、その環境は ``:scanner:`` 依存関係によって決定されます。 ::
559
560     # 実行ファイルはデバッグオプションを用いてコンパイルされます
561     CFLAGS = -g
562     hello: hello_code.o hello_lib.o
563        $(CC) $(CFLAGS) -o $@ $+
564
565     # .c ファイルのスキャナ
566     .SCANNER: scan-c-%.c: %.c
567        $(CC) $(CFLAGS) -MM $<
568
569     # hello_lib.o を CFLAGS = -g -DLIBRARY オプションでコンパイル
570     section
571         CFLAGS += -DLIBRARY
572         hello_lib.o: hello_lib.c :scanner: scan-c-hello_lib.c
573            $(CC) $(CFLAGS) -c $<
574
575     # hello_code.c を CFLAGS = -g -O3 オプションでコンパイル
576     section
577         CFLAGS += -O3
578         hello_code.o: hello_code.c :scanner: scan-c-hello_code.c
579            $(CC) $(CFLAGS) -c $<
580
581 .. Again, this is for illustration—it is unlikely you would need to write a complicated configuration like this! In this case, the .SCANNER rule specifies that the C-compiler should be called with the -MM flag to compute dependencies. For the target hello_lib.o, the scanner is called with CFLAGS=-g -DLIBRARY, and for hello_code.o it is called with CFLAGS=-g -O3.
582
583 再びこの例が登場しましたーあなたは恐らく、このような複雑怪奇な設定を書きたいとは思っていないでしょう!この場合、 ``.SCANNER`` ルールでは、Cコンパイラが依存関係を計算するために ``-MM`` フラグを用いて呼び出すことを指定しています。ターゲット ``hello_lib.o`` には、スキャナは ``CFLAGS=-g -DLIBRARY`` が呼ばれ、 ``hello_code.o`` には、 ``CFLAGS=-g -O3`` が呼ばれます。
584
585 .. index::
586    single: .PHONY
587    single: .SUBDIRS
588 .. _label8.11.3:
589
590 .PHONY ターゲットのスコーピング
591 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
592 .. Phony targets (targets that do not correspond to files) are defined with a .PHONY: rule. Phony targets are scoped as usual. The following illustrates a common mistake, where the .PHONY target is declared after it is used.
593
594 Phonyターゲット(実際のファイルに相当しないターゲット)は ``.PHONY`` ルールを用いて定義されます。Phonyターゲットは普通にスコープされます。以下の例はよくある間違いで、 ``.PHONY`` ターゲットはそれが使われている *後で* 宣言されています。 ::
595
596     # !!この例は正常に動きません!!
597     all: hello
598
599     hello: hello_code.o hello_lib.o
600         $(CC) $(CFLAGS) -o $@ $+
601
602     .PHONY: all
603
604 .. This doesn't work as expected because the .PHONY declaration occurs too late. The proper way to write this example is to place the .PHONY declaration first.
605
606 ``.PHONY`` 宣言が非常に遅れてしまっているために、この例は期待している通りには動きません。正しくは ``.PHONY`` 宣言を最初に持っていきます。 ::
607
608     # Phonyターゲットはそれが使われる前に宣言されなければなりません
609     .PHONY: all
610
611     all: hello
612
613     hello: hello_code.o hello_lib.o
614         $(CC) $(CFLAGS) -o $@ $+
615
616 .. Phony targets are passed to subdirectories. As a practical matter, it is wise to declare all .PHONY targets in your root OMakefile, before any .SUBDIRS. This will ensure that 1) they are considered as phony targets in each of the subdirectories, and 2) you can build them from the project root.
617
618 Phonyターゲットはサブディレクトリに渡されます。実用性から、すべての ``.PHONY`` ターゲットを ``.SUBDIRS`` が表れる前に、ルートの ``OMakefile`` に宣言することは賢い判断と言えるでしょう。これは以下の点を保証してくれます。
619
620 1. 各々のサブディレクトリにPhonyターゲットが渡される
621 2. プロジェクトのルートディレクトリからビルドすることができる
622
623 ::
624
625     .PHONY: all install clean
626
627     .SUBDIRS: src lib clib
628
629 .. Note that when a .PHONY target is inherited by a subdirectory via a .SUBDIRS, a whole hierarchy of .PHONY targets (that are a part of the global one) is created, as described in Section 8.12.2 below.
630
631 .. note::
632   ``.SUBDIRS`` を経由したサブディレクトリによって ``.PHONY`` ターゲットが継承されたときに、全体の ``.PHONY`` ターゲット(これはグローバルの一部分です)の階層構造が作られます。詳細は下のセクション ":ref:`label8.12.2`" を参照してください。
633
634 .. _label8.12:
635
636 サブディレクトリからOMakeを実行
637 ----------------------------------------------
638 .. Running omake foo asks OMake to build the file foo in context of the whole project, even when running from a subdirectory of the project. Therefore, if bar/baz is a regular target (not a .PHONY one), then running omake bar/baz and running (cd bar; omake baz) are usually equivalent.
639
640 ``omake foo`` を実行した場合、 *全体* のプロジェクトの文脈から ``foo`` ファイルに関連する部分だけをビルドします。たとえそれがプロジェクトのサブディレクトリから実行したとしてもです。それゆえ、もし ``bar/baz`` が通常のターゲット( ``.PHONY`` ターゲットではない)であるとすると、 ``omake bar/baz`` を実行することは ``(cd bar; omake baz)`` を実行することと等価です。
641
642 .. There are two noteworthy exceptions to the above rule: 
643
644 上のルールには、2つの注目に値する例外が存在します。
645
646 ..    * If the subdirectory is not a part of the project (there is no .SUBDIRS) for it, then OMake will complain if you try to run it in that directory.
647       * If a subdirectory contains an OMakeroot of its own, this would designate the subdirectory as a separate project (which is usually a bad idea and is not recommended). 
648
649 * サブディレクトリがプロジェクトの一部でなかった( ``.SUBDIRS`` に存在しない)場合、あなたがそのディレクトリから実行させようとすると、OMakeは文句を言うでしょう。
650 * サブディレクトリ自身に ``OMakeroot`` が含まれている場合、OMakeはサブディレクトリを別のプロジェクトとして解釈します。これはあまり良い考えではないので推奨しません。
651
652 .. index::
653    single: .PHONY
654 .. _label8.12.1:
655
656 サブディレクトリのPhonyターゲット
657 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
658 .. Suppose you have a .PHONY: clean declared in your root OMakefile and both the root OMakefile and the OMakefile in some of the subdirectories contain clean: rules. In this case 
659
660 ``.PHONY: clean`` がルートの ``OMakefile`` で宣言されており、さらにルートの ``OMakefile`` と、サブディレクトリのいくつかの ``OMakefile`` が ``clean:`` ルールを含んでいるものとします。この場合、
661
662 ..    * Running omake clean in the root directory will execute all the rules (each in the appropriate directory);
663       * Running omake clean in the subdirectory will execute just its local one, as well as the ones from the subdirectories of the current directory. 
664
665 * ``omake clean`` をルートのディレクトリで実行したときには、(適切なディレクトリの中にある各々の)すべての ``clean:`` ルールが実行されます。
666 * ``omake clean`` をサブディレクトリで実行したときには、カレントサブディレクトリの ``clean:`` ルールだけが実行されます。
667
668 .. The above equally applies to the built-in .PHONY targets, including .DEFAULT. Namely, if OMake is executed (without argument) in the root directory of a project, all the .DEFAULT targets in the project will be built. On the other hand, when OMake is executed (without argument) in a subdirectory, only the .DEFAULT targets defined in and under that subdirectory will be built.
669
670 上のルールは ``.DEFAULT`` を含んだ、ビルドインの ``.PHONY`` ターゲットに等しく適用されます。すなわち、もしOMakeがプロジェクトのルートディレクトリで(引数なしで)実行された場合、プロジェクト中のすべての ``.DEFAULT`` がビルドされます。一方で、サブディレクトリでOMakeが(引数なしで)実行された場合、サブディレクトリ中で定義された ``.DEFAULT`` ターゲットだけがビルドされます。
671
672 .. The following Section explains the underlying semantics that gives rise to the above behavior.
673
674 以下のセクションでは上のようなふるまいをもたらしている、基本的な概念について説明します。
675
676 .. _label8.12.2:
677
678 .PHONYターゲットの階層構造
679 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
680 .. When the the root OMakefile contains a .PHONY: clean directive, it creates: 
681
682 ルートの ``OMakefile`` が ``.PHONY:clean`` を含んでいた場合、OMakeは以下を生成します。
683
684 ..    * A “global” phony target /.PHONY/clean (note the leading “/”);
685       * A “relative” phony target attached to the current directory — .PHONY/clean (note the lack of the leading “/”);
686       * A dependency /.PHONY/clean: .PHONY/clean. 
687
688 * "グローバル(global)"なPhonyターゲット ``/.PHONY/clean`` (先頭の "``/``" に注目してください)
689 * カレントディレクトリに所属している、"関連している(relative)"Phonyターゲット ``.PHONY/clean`` (先頭の "``/``" が欠けていることに注目してください)
690 * 依存関係 ``/.PHONY/clean: .PHONY/clean``
691
692 .. All the clean: ... rules in the root OMakefile following this .PHONY: clean declaration would be interpreted as rules for the .PHONY/clean target.
693
694 ルートの ``OMakefile`` では、 ``.PHONY: clean`` 宣言の後にくるすべての ``clean: ...`` ルールは、 ``.PHONY/clean`` ターゲットのルールとして解釈されます。
695
696 .. Now when OMake then comes across a .SUBDIRS: foo directive (when it is in scope of the above .PHONY: clean declaration), it does the following: 
697
698 それでは、次にOMakeは(上の ``.PHONY: clean`` 宣言のスコープ上で) ``.SUBDIRS: foo`` に遭遇したとしましょう。この場合、OMakeは以下の処理を行います。
699
700 ..    * Creates a new .PHONY/foo/clean “relative” phony target;
701       * Creates the dependency .PHONY/clean: .PHONY/foo/clean;
702       * Processes the body of the .SUBDIRS: foo directive, or reads the foo/OMakefile file, if the body is empty. While doing that, it interprets its instructions relative to the foo directory. In particular, all the clean: ... rules will be taken to apply to .PHONY/foo/clean. 
703
704 * 新しい ``.PHONY/foo/clean`` Phonyターゲットを生成します。このターゲットは"関連している"Phonyターゲットです。
705 * 依存関係 ``.PHONY/clean: .PHONY/foo/clean`` を生成します。
706 * ``.SUBDIRS: foo`` の内容を処理するか、もし内容が空であった場合は ``foo/OMakefile`` を読み込みます。処理している間、これらの指示は ``foo`` ディレクトリに関連しているものと解釈します。特に、すべての ``clean: ...`` ルールは ``.PHONY/foo/clean`` に適用されます。
707
708 .. Now when you run omake clean in the root directory of the project, it is interpreted as omake .PHONY/clean (similar to how it happens with the normal targets), so both the rules for .PHONY/clean are executed and the rules for its dependency .PHONY/foo/clean. Running (cd foo; omake clean) is, as for normal targets, equivalent to running omake .PHONY/foo/clean and only those rules that apply to .PHONY/foo/clean will be executed.
709
710 あなたが ``omake clean`` をプロジェクトのルートディレクトリで実行した場合、これは ``omake .PHONY/clean`` として解釈され(通常のターゲットに関しても同様です)、 ``.PHONY/clean`` のルールと、その依存関係 ``.PHONY/foo/clean`` のルールの両方が実行されます。また、 ``(cd foo; omake clean)`` を実行することは、 ``omake .PHONY/foo/clean`` を実行することと等価であり、 ``.PHONY/foo/clean`` のルールだけが実行されます。これもまた、通常のターゲットに関して同様です。
711
712 .. index::
713    single: absname()
714    single: --absname
715    single: OMakeFlags()
716 .. _label8.13:
717
718 ルール中でのパス名
719 ----------------------------------
720 .. In rules, the targets and dependencies are first translated to file values (as in the file function). They are then translated to strings for the command line. This can cause some unexpected behavior. In the following example, the absname function is the absolute pathname for the file a, but the rule still prints the relative pathname.
721
722 ルール中では、ターゲットと依存先は最初に"ファイル"として変換されます(詳細は ":ref:`label10.1.1`" を参照してください)。これらはコマンドライン上で文字列として変換される値です。また、これによっていくつかの期待していないふるまいを起こすことがあります。以下の例では、 ``absname`` 関数はファイル ``a`` の絶対パスを返す関数ですが、それにも関わらずこのルールでは相対パスとして出力されています。 ::
723
724     .PHONY: demo
725     demo: $(absname a)
726         echo $<
727
728     # omakeのデモ
729     a
730
731 .. There is arguably a good reason for this. On Win32 systems, the / character is viewed as an “option specifier.” The pathname separator is the \ character. OMake translates the filenames automatically so that things work as expected on both systems.
732
733 この振る舞いについては、議論の余地がある良い理由があります。Win32のシステム上では、 ``/`` という文字は『オプションの指定子』として判定されます。そして、パス名のセパレータには
734 ``\`` が用いられています。OMakeはファイル名を自動的に変換することで、両方のシステムで期待通りの動きをするようにしてくれます。 ::
735
736    demo: a/b
737        echo $<
738
739    # omakeのデモ(Unixのシステム上)
740    a/b
741    # omakeのデモ(Win32のシステム上)
742    a\b
743
744 .. Sometimes you may wish that target strings to be passed literally to the commands in the rule. One way to do this is to specify them literally.
745
746 ときどき、あなたはターゲット名を、ルール中のコマンドに文字通り渡したいと思うことがあるかもしれません。これを解決する一つの方法は、変数を指定してあげることです。 ::
747
748     SRC = a/b $(absname c/d)
749     demo: $(SRC)
750         echo $(SRC)
751
752     # omakeのデモ(Win32のシステム上)
753     a/b c:\...\c\d
754
755 .. Alternately, you might wish that filenames be automatically expanded to absolute pathnames. For example, this might be useful when parsing the OMake output to look for errors. For this, you can use the --absname option (Section A.3.20). If you call omake with the --absname option, all filenames will be expanded to absolute names.
756
757 ついでに、あなたはファイル名を自動的に絶対パスに展開してほしいと思うこともあるかもしれません。例えば、エラーを見るために、OMakeの出力を解析するような場合には有効でしょう。これを実現するために、あなたは ``--absname`` オプションを用いることができます(詳細は :ref:`labelA.3.20` を参照してください)。もしあなたが ``omake`` を ``--absname`` オプションで呼び出した場合、すべてのファイル名は絶対パスとして展開されます。 ::
758
759     # omake --absname のデモ(Unixのシステム上)
760     /home/.../a/b /home/.../c/d
761
762 .. Alternately, the --absname option is scoped. If you want to use it for only a few rules, you can use the OMakeFlags function to control how it is applied.
763
764 ついでに、 ``--absname`` オプションはスコープ化されています。もしあなたがこれを限られたルールでのみ用いたい場合は、 ``OMakeFlags`` 関数を使うことで、 ``--absname`` オプションを適用するかどうかをコントロールすることができます。 ::
765
766    section
767       OMakeFlags(--absname)
768       demo: a
769           echo $<
770
771    # omakeデモ
772    /home/.../a
773
774 .. N.B. The --absname option is currently an experimental feature.
775
776 .. warning::
777   ``--absname`` オプションは現在、実験的な機能として搭載しています。