DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(automk14.info.gz) Conditionals

Info Catalog (automk14.info.gz) Include (automk14.info.gz) Top (automk14.info.gz) Gnits
 
 18 Conditionals
 ***************
 
 Automake supports a simple type of conditionals.
 
    Before using a conditional, you must define it by using
 `AM_CONDITIONAL' in the `configure.in' file ( Macros).  The
 `AM_CONDITIONAL' macro takes two arguments.
 
    The first argument to `AM_CONDITIONAL' is the name of the
 conditional.  This should be a simple string starting with a letter and
 containing only letters, digits, and underscores.
 
    The second argument to `AM_CONDITIONAL' is a shell condition,
 suitable for use in a shell `if' statement.  The condition is evaluated
 when `configure' is run.
 
    Conditionals typically depend upon options which the user provides to
 the `configure' script.  Here is an example of how to write a
 conditional which is true if the user uses the `--enable-debug' option.
 
      AC_ARG_ENABLE(debug,
      [  --enable-debug    Turn on debugging],
      [case "${enableval}" in
        yes) debug=true ;;
        no)  debug=false ;;
        *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
      esac],[debug=false])
      AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
 
    Here is an example of how to use that conditional in `Makefile.am':
 
      if DEBUG
      DBG = debug
      else
      DBG =
      endif
      noinst_PROGRAMS = $(DBG)
 
    This trivial example could also be handled using EXTRA_PROGRAMS
 ( A Program).
 
    You may only test a single variable in an `if' statement.  The
 `else' statement may be omitted.  Conditionals may be nested to any
 depth.
 
    Note that conditionals in Automake are not the same as conditionals
 in GNU Make.  Automake conditionals are checked at configure time by the
 `configure' script, and affect the translation from `Makefile.in' to
 `Makefile'.  They are based on options passed to `configure' and on
 results that `configure' has discovered about the host system.  GNU
 Make conditionals are checked at `make' time, and are based on
 variables passed to the make program or defined in the `Makefile'.
 
    Automake conditionals will work with any make program.
 
Info Catalog (automk14.info.gz) Include (automk14.info.gz) Top (automk14.info.gz) Gnits
automatically generated byinfo2html