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