OSDN Git Service

syntaxは文法よりも構文のほうがより適切であるため、修正.
[omake-japanese/omake_trans.git] / autoconf.rst
1 .. 14-autoconf
2
3 .. _label14:
4
5 14. 自動設定用の変数と関数
6 ========================================
7 .. OMake standard library provides a number of functions and variables intended to help one write build specifications that need to be capable of autoconfiguring itself to adjust to different build environments.
8
9 OMakeの標準ライブラリでは、異なったビルド環境下でのビルドを調整するための、自動設定(autoconfiguring)用のコードを書くことを手助けする、数多くの関数や変数を提供しています。
10
11 .. _label14.1:
12
13 14.1 汎用的な自動設定関数
14 ----------------------------------
15 .. The following general-purpose functions can be used to discover the properties of your build environment in a fashion similar to the one used by GNU autoconf tool you may be familiar with. It is recommended that these function be used from an appropriate static. block (see Section 4.14 for more information).
16
17 以下にリストしてある汎用的な関数では、あなたの『ビルド環境(the properties of your build environment)』について調べることができます。これらの関数の中には、恐らくあなたがよく知っているであろうGNU autoconfツールによく似ているものも含まれています。また、これらの関数は適切な ``static.`` ブロックで使うことを推奨しています(詳細は ":ref:`label4.14`" を参照してください)。
18
19 .. In order to use the following general-purpose functions, you need to have the line included in your OMakefile or OMakeroot. 
20
21 以下の汎用的な関数を使うためには、まずあなたの ``OMakeroot`` あるいは ``OMakefile`` ファイルに、以下の一行を追加してください。 ::
22
23   open configure/Configure
24
25 .. index::
26    single: ConfMsgChecking()
27    single: ConfMsgResult()
28 .. _label14.1.1:
29
30 14.1.1 ConfMsgChecking, ConfMsgResult
31 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32 ::
33
34   ConfMsgChecking(<msg>)
35   ...
36   ConfMsgResult(<msg>)
37
38 .. The ConfMsgChecking function output message of the form --- Checking <msg>... without any trailing newline. After the test advertized by ConfMsgChecking is performed, the ConfMsgResult function should be used to output the result.
39
40 ``ConfMsgChecking`` 関数は ``--- Checking <msg>...`` のような形のメッセージを *改行なしで* 出力します。 ``ConfMsgChecking`` が実行されて、後にテストが終わったときには、 ``ConfMsgResult`` 関数を使って結果を出力すべきです。
41
42 .. In certain cases users may want to redefine these function — for example, to use a different output formatting and/or to copy the messages to a log file.
43
44 これらの関数を再定義したいという場合があるかもしれません。例えば、出力の形式を異なったものにしたいという場合や、メッセージをログファイルにコピーしたいというような場合です。
45
46 例::
47
48   static. =
49      ConfMsgChecking(which foo to use)
50      foo = ...
51      ConfMsgResult($(foo))
52
53 .. index::
54    single: ConfMsgWarn()
55    single: ConfMsgError()
56 .. _label14.1.2:
57
58 14.1.2 ConfMsgWarn, ConfMsgError
59 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60 ::
61
62   ConfMsgWarn(<msg>)
63   ConfMsgError(<msg>)
64
65 .. Print a warning or an error message respectively. ConfMsgError would then abort OMake. 
66
67 警告やエラーメッセージをそれぞれ表示します。 ``ConfMsgError`` はOMakeを中断させます。
68
69 .. index::
70    single: ConfMsgYesNo()
71    single: ConfMsgFound()
72 .. _label14.1.3:
73
74 14.1.3 ConfMsgYesNo, ConfMsgFound
75 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76 ::
77
78   flag = $(ConfMsgYesNo <bool expr>)
79   flag = $(ConfMsgFound <bool expr>)
80
81 .. The ConfMsgFound function expects to receive a boolean flag describing whether a test previously announced using the ConfMsgChecking function found what it was looking for. ConfMsgFound will output the appropriate result (“found” or “NOT found”) using the ConfMsgResult function and return its argument back.
82
83 ``ConfMsgFound`` 関数を使う前にまず ``ConfMsgChecking`` 関数を用いて「コマンドが使用できるかどうか調べます」ということをユーザに伝えます。その後、その結果を真偽値で ``ConfMsgFound`` 関数に渡します。 ``ConfMsgFound`` は結果を適切な形("found"あるいは"NOT found")に直し、 ``ConfMsgResult`` 関数を使って出力します。また引数として渡された結果を、加工しないでそのまま返します。
84
85 .. The ConfMsgYesNo function is similar, outputting a simple (“yes” or “NO”). 
86
87 ``ConfMsgYesNo`` 関数は ``ConfMsgFound`` と似ていますが、出力がシンプルです("yes"あるいは"NO")。
88
89 .. index::
90    single: TryConpileC()
91    single: TryLinkC()
92    single: TryRunC()
93 .. _label14.1.4:
94
95 14.1.4 TryCompileC, TryLinkC, TryRunC
96 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
97 ::
98
99   success = $(TryCompileC <prog_text>)
100   success = $(TryLinkC <prog_text>)
101   success = $(TryRunC <prog_text>)
102
103 .. Given the text of a C program, the TryCompileC, TryLinkC, and TryRunC functions would try to compile / compile and link / compile, link, and run, the given program and return a boolean flag indicating whether the attempt was successful.
104
105 Cプログラムの *コード* を引数として渡します。 ``TryCompileC`` , ``TryLinkC`` , ``TryRunC`` 関数は与えられた引数を『コンパイル/コンパイルとリンク/コンパイルとリンクと実行』できるかどうか試します。テストが成功した場合、この関数は真を返します。一方で、失敗した場合は偽を返します。
106
107 .. TryCompileC will use the CC, CFLAGS and INCLUDES variables to run the C compiler. TryLinkC and TryRunC will also use the LDFLAGS variable to run the C compiler and linker. However, the flags like /WX, -Werror and -warn-error will be not be passed to the compiler, even if they occur in CFLAGS.
108
109 ``TryCompileC`` はCコンパイラを実行するときに ``CC`` , ``CFLAGS`` , ``INCLUDES`` 変数を使用します。 ``TryLinkC`` と ``TryRunC`` はそれに加えて ``LDFLAGS`` 変数を、Cコンパイラとリンカを実行するときに使用します。しかし、 ``/WX`` , ``-Werror`` , ``-warn-error`` のようなフラグは、たとえ ``CFLAGS`` 変数に含まれていたとしても、コンパイラに渡されることはありません。
110
111 .. These functions are silent and should normally be used with an appropriate ConfMsgChecking … ConfMsgResult. 
112
113 これらの関数は結果を表示しません。また、通常の場合は適切な ``ConfMsgChecking`` ~ ``ConfMsgResult`` 間で使用すべきです。
114
115 .. index::
116    single: RunCProg()
117 .. _label14.1.5:
118
119 14.1.5 RunCProg
120 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121 ::
122
123   output = $(RunCProg <prog>)
124
125 .. RunCProg is similar to the RunCProg function, except that it returns the output of the function (will return false if the program fails to compile or run). 
126
127 ``RunCProg`` 関数は ``TryRunC`` 関数と似ていますが、この関数はプログラムの出力を返します(プログラムのコンパイルや実行に失敗した場合は ``false`` が返されます)。
128
129 (訳注: 原文では "RunCProg is similar to the RunCProg function, ..." となっていましたが、恐らくこれはTryRunCの間違いではないかと思われます)
130
131 .. index::
132    single: CheckCHeader()
133    single: VerboseCheckCHeader()
134 .. _label14.1.6:
135
136 14.1.6 CheckCHeader, VerboseCheckCHeader
137 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138 ::
139
140   success = $(CheckCHeader <files>)
141   success = $(VerboseCheckCHeader <files>)
142
143 .. Use the TryCompileC function to check whether your C compiler can locate and process the specified headers files. Will incude <stdio.h> before including the header files.
144
145 ``TryCompileC`` 関数を用いることで、あなたのCコンパイラが指定したヘッダファイルの位置をつきとめ、さらに処理できるかどうか調べることができます。 ``TryCompileC`` 関数はヘッダファイルをインクルードする前に ``<stdio.h>`` をインクルードします。
146
147 .. Both functions return a boolean value. The CheckCHeader function is silent; the VerboseCheckCHeader function will use the ConfMsgChecking and ConfMsgResult functions to describe the test and the outcome.
148
149 両方の関数は真偽値を返します。 ``CheckCHeader`` 関数は結果を表示しません。 ``VerboseCheckCHeader`` 関数はテストと結果を表示するのに ``ConfMsgChecking`` と ``ConfMsgResult`` 関数を使います。
150
151 例::
152
153   static. =
154      NCURSES_H_AVAILABLE = $(VerboseCheckCHeader ncurses.h)
155
156 .. index::
157    single: CheckCLib()
158    single: VerboseCheckCLib()
159 .. _label14.1.7:
160
161 14.1.7 CheckCLib, VerboseCheckCLib
162 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
163 ::
164
165   success = $(CheckCLib <libs>, <functions>)
166   success = $(VerboseCheckCLib <libs>, <functions>)
167
168 .. Use the TryLinkC function to check whether your C compiler and linker can find the named functions when linking with the named libraries. Will pass the <libs> to the compiler using the -l flag.
169
170 ``TryLinkC`` 関数を用いることで、与えられたライブラリのリンク時に、あなたのCコンパイラとリンカが、与えられた関数を見つけられるかどうか調べることができます。 ``TryLinkC`` 関数は ``-l`` フラグを使ってコンパイラに ``<libs>`` を渡します。
171
172 .. Both functions return a boolean value. The CheckCLib function is silent; the VerboseCheckCHeader function will use the ConfMsgChecking and ConfMsgResult functions to describe the test and the outcome.
173
174 両方の関数は真偽値を返します。 ``CheckCLib`` 関数は結果を表示しません。 ``VerboseCheckCLib`` 関数はテストと結果を表示するのに ``ConfMsgChecking`` と ``ConfMsgResult`` 関数を使います。
175
176 例::
177
178   static. =
179       NCURSES_LIB_AVAILABLE = $(VerboseCheckCLib ncurses, initscr setupterm tigetstr)
180
181 .. index::
182    single: CheckProg()
183 .. _label14.1.8:
184
185 14.1.8 CheckProg
186 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187 ::
188
189   success = $(CheckProg <prog>)
190
191 .. Checks whether the program <prog> exists in your path. Will use the ConfMsgChecking and ConfMsgResult functions to describe the test and the outcome.
192
193 あなたのパス中に ``<prog>`` が存在しているかどうかを調べます。この関数はテストと結果を表示するのに ``ConfMsgChecking`` と ``ConfMsgResult`` 関数を使います。
194
195 .. index::
196    single: AC_MSG_CHECKING
197    single: AC_MSG_RESULT
198    single: AC_MSG_WARN
199    single: AC_MSG_ERROR
200    single: AC_TRY_COMPILE
201    single: AC_TRY_LINK
202    single: AC_TRY_RUN
203 .. _label14.2:
204
205 14.2 ``autoconf`` スクリプトをOMake用に翻訳する
206 --------------------------------------------------
207 .. Some of the functions described above are very similar to the ones present in autoconf. Below is a brief translation table for such functions. 
208
209 上の関数のいくつかは、 ``autoconf`` に存在しているものと非常に似ています。以下はそのような関数のための簡単な翻訳テーブルです。
210
211 .. AC_MSG_CHECKING is very similar to ConfMsgChecking function. 
212    AC_MSG_RESULT is very similar to ConfMsgResult function. 
213    AC_MSG_WARN is very similar to ConfMsgWarn function. 
214    AC_MSG_ERROR is very similar to ConfMsgError function. 
215    AC_TRY_COMPILE is somewhat similar to TryCompileC function, except the TryCompileC function returns a boolean value and only works for C. Similarly,
216    AC_TRY_LINK is approximated by TryLinkC function, and 
217    AC_TRY_RUN is approximated by TryRunC function. 
218
219 * ``AC_MSG_CHECKING`` は ``ConfMsgChecking`` 関数と非常に似ています。
220 * ``AC_MSG_RESULT`` は ``ConfMsgResult`` 関数と非常に似ています。
221 * ``AC_MSG_WARN`` は ``ConfMsgWarn`` 関数と非常に似ています。
222 * ``AC_MSG_ERROR`` は ``COnfMsgError`` 関数と非常に似ています。
223 * ``AC_TRY_COMPILE`` は ``TryCompileC`` 関数をいくらか似ています。ただし、 ``TryCompileC`` 関数は真偽値を返し、 ``C`` 言語のみに機能するという点が異なります。
224 * ``AC_TRY_LINK`` は ``TryLinkC`` 関数と似ています。
225 * ``AC_TRY_RUN`` は ``TryRunC`` 関数と似ています。
226
227 .. _label14.3:
228
229 14.3 事前に用意された設定テスト
230 ------------------------------------------
231 .. A number of configuration tests are already included in the standard library. In order to use them in your project, simply open (see Section 4.7) the corresponding build file in your OMakefile and the tests will run the first time OMake is executed. Note that it is not a problem to open these files from more than one place in your project — if you do that, the test will still run only once. 
232
233 OMakeでは数多くの設定テスト(configuration tests)が標準ライブラリに含まれています。あなたのプロジェクトでこれらを使うためには、単純に対象の ``OMakefile`` に、設定テストを記述したビルドファイルを『 ``open`` (詳細は ":ref:`label4.7`" を参照してください)』するだけです。そうすれば、OMakeを初めて実行した時点で設定テストが実行されます。これは、あなたのプロジェクト上で二回以上設定テストが ``open`` されるわけではない点に注意してください。たとえ二回以上呼び出したとしても、このテストは一回だけしか実行されません。
234
235 .. index::
236    single: NCURSES_AVAILABLE
237    single: NCURSES_TERMH_IN_NCURSES
238    single: NCURSES_CFLAGS
239    single: NCURSES_CLIBS
240 .. _label14.3.1:
241
242 14.3.1 NCursesライブラリの設定
243 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
244 .. Add open configure/ncurses line to your OMakefile to get access to the following autoconfiguration variables. 
245
246 あなたの ``OMakefile`` に ``open configure/ncurses`` を加えることで、以下の自動設定変数を利用できます。
247
248 * **NCURSES_AVAILABLE**
249   
250   .. A boolean flag that would be set when both the curses.h header, the term.h header, and the ncurses library very found.
251   
252   ``curses.h`` , ``term.h`` ヘッダファイルと ``ncurses`` ライブラリが見つかった場合に真となる真偽値
253
254 * **NCURSES_TERMH_IN_NCURSES**
255   
256   .. A boolean flag that would be set when term.h has to be included as <ncurses/term.h> instead of <term.h>.
257   
258   ``term.h`` が ``<term.h>`` の代わりに ``<ncurses/term.h>`` としてインクルードされていた場合に真となる真偽値
259
260 * **NCURSES_CFLAGS**
261   
262   .. The CFLAGS to use when compiling ncurses code. Will include -DNCURSES and -DTERMH_IN_NCURSES, respectively when NCURSES_AVAILABLE and NCURSES_TERMH_IN_NCURSES are true.
263   
264   ncursesコードをコンパイルする際に用いる ``CFLAGS`` の値。 ``NCURSES_AVAILABLE`` と ``NCURSES_TERMH_IN_NCURSES`` がそれぞれ真である場合には ``-DNCURSES`` と ``-DTERMH_IN_NCURSES`` が含まれます。
265
266 * **NCURSES_CLIBS**
267   
268   .. The LDFLAGS to use when linking ncurses code. Will normally contain -lncurses when ncurses is found and remain empty otherwise. 
269   
270   ncursesコードをリンクする際に用いる ``LDFLAGS`` の値。ncursesが見つかって、それ以外が空のままである場合には通常 ``-lncurses`` が含まれます。
271
272 .. index::
273    single: READLINE_AVAILABLE
274    single: READLINE_GNU
275    single: READLINE_CFLAGS
276    single: READLINE_CLIBS
277 .. _label14.3.2:
278
279 14.3.2 ReadLineライブラリの設定
280 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
281 .. Add open configure/readline line to your OMakefile to get access to the following autoconfiguration variables. 
282
283 あなたの ``OMakefile`` に ``open configure/readline`` を加えることで、以下の自動設定変数を利用できます。
284
285 * **READLINE_AVAILABLE**
286   
287   .. A boolean flag that would be set when both the readline/readline.h header, the readline/history.h header, and the readline library very found.
288   
289   ``readline/readline.h`` , ``readline/history.h`` ヘッダと ``readline`` ライブラリが見つかった場合に真となる真偽値
290
291 * **READLINE_GNU**
292   
293   .. A boolean flag that would be set when the GNU version of the readline library is found (as opposed to the BSD one).
294   
295   readlineライブラリのGNUバージョン(BSDバージョンではなく)が見つかった場合に真となる真偽値
296
297 * **READLINE_CFLAGS**
298   
299   .. The CFLAGS to use when compiling readline code. Will include -DREADLINE_ENABLED and -DREADLINE_GNU, respectively when READLINE_AVAILABLE and READLINE_GNU are true.
300   
301   readlineコードをコンパイルする際に用いる ``CFLAGS`` の値。 ``READLINE_AVAILABLE`` と ``READLINE_GNU`` がそれぞれ真である場合には ``-DREADLINE_ENABLED`` と ``-DREADLINE_GNU`` が含まれます。
302
303 * **READLINE_CLIBS**
304   
305   .. The LDFLAGS to use when linking readline code. Will normally contain -lncurses -lreadline when readline is found and remain empty otherwise. 
306   
307   readlineコードをリンクする際に用いる ``LDFLAGS`` の値。readlineが見つかって、それ以外が空である場合には通常 ``-lncurses -lreadline`` が含まれます。
308
309 .. index::
310    single: SNPRINTF_AVAILABLE
311 .. _label14.3.3:
312
313 14.3.3 Snprintfの設定
314 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
315 .. Add open configure/snprintf line to your OMakefile to get access to the following autoconfiguration variables.
316
317 あなたの ``OMakefile`` に ``open configure/snprintf`` を加えることで、以下の自動設定変数を利用できます。
318
319 * **SNPRINTF_AVAILABLE**
320   
321   .. A boolean flag telling whether the snprintf function is available in the standard C library.
322   
323   標準Cライブラリでsnprintf関数が利用可能であるかどうかを示す真偽値