前: autom4te.cache, 上: FAQ
機能の調査時に覚えておくべき最も重要なガイドラインは,使いたいものをでき
るだけ真似てみるということです.残念ながら,古いバージョンの
AC_CHECK_HEADERとAC_CHECK_HEADERSはこの考えに従うと失敗し,
そして,ヘッダの調査のためコンパイラの代わりにプリプロセッサを呼び出しま
す.結果として,ヘッダ間での非互換性はコンフィグレーション時に注目されず,
管理者は結局,この問題を別の場所で処理する必要があります.
Autoconf 2.56では両方の調査を実行するので,コンパイラとプリプロセッサが
受け入れない場合,configure派手に文句を言います.プリプロセッサの
結果を利用するときは,configure.acを修正する時間が管理者に与えら
れます.しかし,将来はコンパイラだけ考慮されるでしょう.
以下の例を考えて下さい.
$ cat number.h
typedef int number;
$ cat pi.h
const number pi = 3;
$ cat configure.ac
AC_INIT
AC_CHECK_HEADERS(pi.h)
$ autoconf -Wall
$ ./configure
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking pi.h usability... no
checking pi.h presence... yes
configure: WARNING: pi.h: present but cannot be compiled
configure: WARNING: pi.h: check for missing prerequisite headers?
configure: WARNING: pi.h: proceeding with the preprocessor's result
configure: WARNING: ## ------------------------------------ ##
configure: WARNING: ## Report this to bug-autoconf@gnu.org. ##
configure: WARNING: ## ------------------------------------ ##
checking for pi.h... yes
この状況での正しい方法は,四番目の引数を使用することです(see Generic Headers).
$ cat configure.ac
AC_INIT
AC_CHECK_HEADERS(number.h pi.h,,,
[[#if HAVE_NUMBER_H
# include <number.h>
#endif
]])
$ autoconf -Wall
$ ./configure
checking for gcc... gcc
checking for C compiler default output... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for number.h... yes
checking for pi.h... yes
必要条件となるヘッダのリストはParticular Headers.