autoconf: Generic Programs

1 
1 5.2.2 Generic Program and File Checks
1 -------------------------------------
1 
1 These macros are used to find programs not covered by the "particular"
1 test macros.  If you need to check the behavior of a program as well as
1 find out whether it is present, you have to write your own test for it
1 (⇒Writing Tests).  By default, these macros use the environment
1 variable `PATH'.  If you need to check for a program that might not be
1 in the user's `PATH', you can pass a modified path to use instead, like
1 this:
1 
1      AC_PATH_PROG([INETD], [inetd], [/usr/libexec/inetd],
1                   [$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl
1      [/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc])
1 
1    You are strongly encouraged to declare the VARIABLE passed to
1 `AC_CHECK_PROG' etc. as precious.  ⇒Setting Output Variables,
1 `AC_ARG_VAR', for more details.
1 
1  -- Macro: AC_CHECK_PROG (VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'], [REJECT])
1      Check whether program PROG-TO-CHECK-FOR exists in PATH.  If it is
1      found, set VARIABLE to VALUE-IF-FOUND, otherwise to
1      VALUE-IF-NOT-FOUND, if given.  Always pass over REJECT (an
1      absolute file name) even if it is the first found in the search
1      path; in that case, set VARIABLE using the absolute file name of
1      the PROG-TO-CHECK-FOR found that is not REJECT.  If VARIABLE was
1      already set, do nothing.  Calls `AC_SUBST' for VARIABLE.  The
1      result of this test can be overridden by setting the VARIABLE
1      variable or the cache variable `ac_cv_prog_VARIABLE'.
1 
1  -- Macro: AC_CHECK_PROGS (VARIABLE, PROGS-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Check for each program in the blank-separated list
1      PROGS-TO-CHECK-FOR existing in the PATH.  If one is found, set
1      VARIABLE to the name of that program.  Otherwise, continue
1      checking the next program in the list.  If none of the programs in
1      the list are found, set VARIABLE to VALUE-IF-NOT-FOUND; if
1      VALUE-IF-NOT-FOUND is not specified, the value of VARIABLE is not
1      changed.  Calls `AC_SUBST' for VARIABLE.  The result of this test
1      can be overridden by setting the VARIABLE variable or the cache
1      variable `ac_cv_prog_VARIABLE'.
1 
1  -- Macro: AC_CHECK_TARGET_TOOL (VARIABLE, PROG-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_PROG', but first looks for PROG-TO-CHECK-FOR with a
1      prefix of the target type as determined by `AC_CANONICAL_TARGET',
1      followed by a dash (⇒Canonicalizing).  If the tool cannot
1      be found with a prefix, and if the build and target types are
1      equal, then it is also searched for without a prefix.
1 
1      As noted in ⇒Specifying Target Triplets, the target is
1      rarely specified, because most of the time it is the same as the
1      host: it is the type of system for which any compiler tool in the
1      package produces code.  What this macro looks for is, for example,
1      _a tool (assembler, linker, etc.) that the compiler driver (`gcc'
1      for the GNU C Compiler) uses to produce objects, archives or
1      executables_.
1 
1  -- Macro: AC_CHECK_TOOL (VARIABLE, PROG-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_PROG', but first looks for PROG-TO-CHECK-FOR with a
1      prefix of the host type as specified by `--host', followed by a
1      dash.  For example, if the user runs `configure --build=x86_64-gnu
1      --host=i386-gnu', then this call:
1           AC_CHECK_TOOL([RANLIB], [ranlib], [:])
1      sets `RANLIB' to `i386-gnu-ranlib' if that program exists in PATH,
1      or otherwise to `ranlib' if that program exists in PATH, or to `:'
1      if neither program exists.
1 
1      When cross-compiling, this macro will issue a warning if no program
1      prefixed with the host type could be found.  For more information,
1      see ⇒Specifying Target Triplets.
1 
1  -- Macro: AC_CHECK_TARGET_TOOLS (VARIABLE, PROGS-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_TARGET_TOOL', each of the tools in the list
1      PROGS-TO-CHECK-FOR are checked with a prefix of the target type as
11      determined by `AC_CANONICAL_TARGET', followed by a dash (⇒
      Canonicalizing).  If none of the tools can be found with a
1      prefix, and if the build and target types are equal, then the
1      first one without a prefix is used.  If a tool is found, set
1      VARIABLE to the name of that program.  If none of the tools in the
1      list are found, set VARIABLE to VALUE-IF-NOT-FOUND; if
1      VALUE-IF-NOT-FOUND is not specified, the value of VARIABLE is not
1      changed.  Calls `AC_SUBST' for VARIABLE.
1 
1  -- Macro: AC_CHECK_TOOLS (VARIABLE, PROGS-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_TOOL', each of the tools in the list
1      PROGS-TO-CHECK-FOR are checked with a prefix of the host type as
11      determined by `AC_CANONICAL_HOST', followed by a dash (⇒
      Canonicalizing).  If none of the tools can be found with a
1      prefix, then the first one without a prefix is used.  If a tool is
1      found, set VARIABLE to the name of that program.  If none of the
1      tools in the list are found, set VARIABLE to VALUE-IF-NOT-FOUND; if
1      VALUE-IF-NOT-FOUND is not specified, the value of VARIABLE is not
1      changed.  Calls `AC_SUBST' for VARIABLE.
1 
1      When cross-compiling, this macro will issue a warning if no program
1      prefixed with the host type could be found.  For more information,
1      see ⇒Specifying Target Triplets.
1 
1  -- Macro: AC_PATH_PROG (VARIABLE, PROG-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_PROG', but set VARIABLE to the absolute name of
1      PROG-TO-CHECK-FOR if found.  The result of this test can be
1      overridden by setting the VARIABLE variable.  A positive result of
1      this test is cached in the `ac_cv_path_VARIABLE' variable.
1 
1  -- Macro: AC_PATH_PROGS (VARIABLE, PROGS-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_PROGS', but if any of PROGS-TO-CHECK-FOR are found,
1      set VARIABLE to the absolute name of the program found.  The
1      result of this test can be overridden by setting the VARIABLE
1      variable.  A positive result of this test is cached in the
1      `ac_cv_path_VARIABLE' variable.
1 
1  -- Macro: AC_PATH_PROGS_FEATURE_CHECK (VARIABLE, PROGS-TO-CHECK-FOR,
1           FEATURE-TEST, [ACTION-IF-NOT-FOUND], [PATH = `$PATH'])
1      This macro was introduced in Autoconf 2.62.  If VARIABLE is not
1      empty, then set the cache variable `ac_cv_path_VARIABLE' to its
1      value.  Otherwise, check for each program in the blank-separated
1      list PROGS-TO-CHECK-FOR existing in PATH.  For each program found,
1      execute FEATURE-TEST with `ac_path_VARIABLE' set to the absolute
1      name of the candidate program.  If no invocation of FEATURE-TEST
1      sets the shell variable `ac_cv_path_VARIABLE', then
1      ACTION-IF-NOT-FOUND is executed.  FEATURE-TEST will be run even
1      when `ac_cv_path_VARIABLE' is set, to provide the ability to
1      choose a better candidate found later in PATH; to accept the
1      current setting and bypass all further checks, FEATURE-TEST can
1      execute `ac_path_VARIABLE_found=:'.
1 
1      Note that this macro has some subtle differences from
1      `AC_CHECK_PROGS'.  It is designed to be run inside `AC_CACHE_VAL',
1      therefore, it should have no side effects.  In particular,
1      VARIABLE is not set to the final value of `ac_cv_path_VARIABLE',
1      nor is `AC_SUBST' automatically run.  Also, on failure, any action
1      can be performed, whereas `AC_CHECK_PROGS' only performs
1      `VARIABLE=VALUE-IF-NOT-FOUND'.
1 
1      Here is an example, similar to what Autoconf uses in its own
1      configure script.  It will search for an implementation of `m4'
1      that supports the `indir' builtin, even if it goes by the name
1      `gm4' or is not the first implementation on `PATH'.
1 
1           AC_CACHE_CHECK([for m4 that supports indir], [ac_cv_path_M4],
1             [AC_PATH_PROGS_FEATURE_CHECK([M4], [m4 gm4],
1               [[m4out=`echo 'changequote([,])indir([divnum])' | $ac_path_M4`
1                 test "x$m4out" = x0 \
1                 && ac_cv_path_M4=$ac_path_M4 ac_path_M4_found=:]],
1               [AC_MSG_ERROR([could not find m4 that supports indir])])])
1           AC_SUBST([M4], [$ac_cv_path_M4])
1 
1  -- Macro: AC_PATH_TARGET_TOOL (VARIABLE, PROG-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_TARGET_TOOL', but set VARIABLE to the absolute name
1      of the program if it is found.
1 
1  -- Macro: AC_PATH_TOOL (VARIABLE, PROG-TO-CHECK-FOR,
1           [VALUE-IF-NOT-FOUND], [PATH = `$PATH'])
1      Like `AC_CHECK_TOOL', but set VARIABLE to the absolute name of the
1      program if it is found.
1 
1      When cross-compiling, this macro will issue a warning if no program
1      prefixed with the host type could be found.  For more information,
1      see ⇒Specifying Target Triplets.
1