(autoconf.info)AC_FOO_IFELSE vs AC_TRY_FOO

Prev: AC_LIBOBJ vs LIBOBJS Up: Autoconf 2.13

17.6.5 `AC_FOO_IFELSE' vs. `AC_TRY_FOO'

Since Autoconf 2.50, internal codes uses `AC_PREPROC_IFELSE',
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:
   - a more consistent interface: `AC_TRY_COMPILE' etc. were double
     quoting their arguments;

   - the combinatoric explosion is solved by decomposing on the one
     hand the generation of sources, and on the other hand executing
     the program;

   - this scheme helps supporting more languages than plain C and C++.

   In addition to the change of syntax, the philosophy 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 includes.

   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':

     [#ifdef _AIX
     ], is_aix=yes, is_aix=no)

   The above example, properly written would (i) use `AC_LANG_PROGRAM',
and (ii) run the compiler:

     [[#ifndef _AIX
      error: This isn't AIX!

automatically generated by info2www