These macros check for particular programs—whether they exist, and in some cases whether they support certain features.
Check for
gawk,mawk,nawk, andawk, in that order, and set output variableAWKto the first one that is found. It triesgawkfirst because that is reported to be the best implementation. The result can be overridden by setting the variableAWKor the cache variableac_cv_prog_AWK.Using this macro is sufficient to avoid the pitfalls of traditional awk (see Limitations of Usual Tools).
Look for the best available
greporggrepthat accepts the longest input lines possible, and that supports multiple -e options. Set the output variableGREPto whatever is chosen. See Limitations of Usual Tools, for more information about portability problems with the grep command family. The result can be overridden by setting theGREPvariable and is cached in theac_cv_path_GREPvariable.
Check whether
$GREP -Eworks, or else look for the best availableegreporgegrepthat accepts the longest input lines possible. Set the output variableEGREPto whatever is chosen. The result can be overridden by setting theEGREPvariable and is cached in theac_cv_path_EGREPvariable.
Check whether
$GREP -Fworks, or else look for the best availablefgreporgfgrepthat accepts the longest input lines possible. Set the output variableFGREPto whatever is chosen. The result can be overridden by setting theFGREPvariable and is cached in theac_cv_path_FGREPvariable.
Set output variable
INSTALLto the name of a BSD-compatible install program, if one is found in the current PATH. Otherwise, setINSTALLto ‘dir/install-sh -c’, checking the directories specified toAC_CONFIG_AUX_DIR(or its default directories) to determine dir (see Output). Also set the variablesINSTALL_PROGRAMandINSTALL_SCRIPTto ‘${INSTALL}’ andINSTALL_DATAto ‘${INSTALL} -m 644’.‘@INSTALL@’ is special, as its value may vary for different configuration files.
This macro screens out various instances of install known not to work. It prefers to find a C program rather than a shell script, for speed. Instead of install-sh, it can also use install.sh, but that name is obsolete because some make programs have a rule that creates install from it if there is no makefile. Further, this macro requires install to be able to install multiple files into a target directory in a single invocation.
Autoconf comes with a copy of install-sh that you can use. If you use
AC_PROG_INSTALL, you must include either install-sh or install.sh in your distribution; otherwise configure produces an error message saying it can't find them—even if the system you're on has a good install program. This check is a safety measure to prevent you from accidentally leaving that file out, which would prevent your package from installing on systems that don't have a BSD-compatible install program.If you need to use your own installation program because it has features not found in standard install programs, there is no reason to use
AC_PROG_INSTALL; just put the file name of your program into your Makefile.in files.The result of the test can be overridden by setting the variable
INSTALLor the cache variableac_cv_path_install.
Set output variable
MKDIR_Pto a program that ensures that for each argument, a directory named by this argument exists, creating it and its parent directories if needed, and without race conditions when two instances of the program attempt to make the same directory at nearly the same time.This macro uses the ‘mkdir -p’ command if possible. Otherwise, it falls back on invoking install-sh with the -d option, so your package should contain install-sh as described under
AC_PROG_INSTALL. An install-sh file that predates Autoconf 2.60 or Automake 1.10 is vulnerable to race conditions, so if you want to support parallel installs from different packages into the same directory you need to make sure you have an up-to-date install-sh. In particular, be careful about using ‘autoreconf -if’ if your Automake predates Automake 1.10.This macro is related to the
AS_MKDIR_Pmacro (see Programming in M4sh), but it sets an output variable intended for use in other files, whereasAS_MKDIR_Pis intended for use in scripts like configure. Also,AS_MKDIR_Pdoes not accept options, butMKDIR_Psupports the -m option, e.g., a makefile might invoke$(MKDIR_P) -m 0 dirto create an inaccessible directory, and conversely a makefile should use$(MKDIR_P) -- $(FOO)if FOO might yield a value that begins with ‘-’. Finally,AS_MKDIR_Pdoes not check for race condition vulnerability, whereasAC_PROG_MKDIR_Pdoes.‘@MKDIR_P@’ is special, as its value may vary for different configuration files.
The result of the test can be overridden by setting the variable
MKDIR_Por the cache variableac_cv_path_mkdir.
If
flexis found, set output variableLEXto ‘flex’ andLEXLIBto -lfl, if that library is in a standard place. Otherwise setLEXto ‘lex’ andLEXLIBto -ll, if found. If neither variant is available, setLEXto ‘:’; for packages that ship the generated file.yy.c alongside the source file.l, this default allows users without a lexer generator to still build the package even if the timestamp for file.l is inadvertently changed.Define
YYTEXT_POINTERifyytextdefaults to ‘char *’ instead of to ‘char []’. Also set output variableLEX_OUTPUT_ROOTto the base of the file name that the lexer generates; usually lex.yy, but sometimes something else. These results vary according to whetherlexorflexis being used.You are encouraged to use Flex in your sources, since it is both more pleasant to use than plain Lex and the C source it produces is portable. In order to ensure portability, however, you must either provide a function
yywrapor, if you don't use it (e.g., your scanner has no ‘#include’-like feature), simply include a ‘%noyywrap’ statement in the scanner's source. Once this done, the scanner is portable (unless you felt free to use nonportable constructs) and does not depend on any library. In this case, and in this case only, it is suggested that you use this Autoconf snippet:AC_PROG_LEX if test "x$LEX" != xflex; then LEX="$SHELL $missing_dir/missing flex" AC_SUBST([LEX_OUTPUT_ROOT], [lex.yy]) AC_SUBST([LEXLIB], ['']) fiThe shell script missing can be found in the Automake distribution.
Remember that the user may have supplied an alternate location in LEX, so if Flex is required, it is better to check that the user provided something sufficient by parsing the output of ‘$LEX --version’ than by simply relying on
test "x$LEX" = xflex.To ensure backward compatibility, Automake's
AM_PROG_LEXinvokes (indirectly) this macro twice, which causes an annoying but benign “AC_PROG_LEXinvoked multiple times” warning. Future versions of Automake will fix this issue; meanwhile, just ignore this message.As part of running the test, this macro may delete any file in the configuration directory named lex.yy.c or lexyy.c.
The result of this test can be influenced by setting the variable
LEXor the cache variableac_cv_prog_LEX.
If ‘ln -s’ works on the current file system (the operating system and file system support symbolic links), set the output variable
LN_Sto ‘ln -s’; otherwise, if ‘ln’ works, setLN_Sto ‘ln’, and otherwise set it to ‘cp -pR’.If you make a link in a directory other than the current directory, its meaning depends on whether ‘ln’ or ‘ln -s’ is used. To safely create links using ‘$(LN_S)’, either find out which form is used and adjust the arguments, or always invoke
lnin the directory where the link is to be created.In other words, it does not work to do:
$(LN_S) foo /x/barInstead, do:
(cd /x && $(LN_S) foo bar)
Set output variable
RANLIBto ‘ranlib’ ifranlibis found, and otherwise to ‘:’ (do nothing).
Set output variable
SEDto a Sed implementation that conforms to Posix and does not have arbitrary length limits. Report an error if no acceptable Sed is found. See Limitations of Usual Tools, for more information about portability problems with Sed.The result of this test can be overridden by setting the
SEDvariable and is cached in theac_cv_path_SEDvariable.