OSDN Git Service

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