| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
AC_FOO_IFELSE vs. AC_TRY_FOO
Since Autoconf 2.50, internal codes uses AC_PREPROC_IFELSE,
AC_COMPILE_IFELSE, AC_LINK_IFELSE, and
AC_RUN_IFELSE on the other one hand and AC_LANG_SOURCES,
and AC_LANG_PROGRAM on the other hand instead of the deprecated
AC_TRY_CPP, AC_TRY_COMPILE, AC_TRY_LINK, and
AC_TRY_RUN. The motivations where:
AC_TRY_COMPILE etc. were double
quoting their arguments;
In addition to the change of syntax, the philosphy has changed too: while emphasis was put on speed at the expense of accuracy, today's Autoconf promotes accuracy of the testing framework at, ahem..., the expense of speed.
As a perfect example of what is not to be done, here is how to
find out whether a header file contains a particular declaration, such
as a typedef, a structure, a structure member, or a function. Use
AC_EGREP_HEADER instead of running grep directly on the
header file; on some systems the symbol might be defined in another
header file that the file you are checking `#include's.
As a (bad) example, here is how you should not check for C preprocessor
symbols, either defined by header files or predefined by the C
preprocessor: using AC_EGREP_CPP:
AC_EGREP_CPP(yes, [#ifdef _AIX yes #endif ], is_aix=yes, is_aix=no) |
The above example, properly written would (i) use
AC_LANG_PROGRAM, and (ii) run the compiler:
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#if !defined _AIX
# error _AIX not defined
#endif
]])],
[is_aix=yes],
[is_aix=no])
|