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 variableAWK
to the first one that is found. It triesgawk
first because that is reported to be the best implementation.
Look for the best available
grep
orggrep
that accepts the longest input lines possible, and that supports multiple -e options. Set the output variableGREP
to whatever is chosen. See Limitations of Usual Tools, for more information about portability problems with the grep command family.
Check whether
$GREP -E
works, or else look for the best availableegrep
orgegrep
that accepts the longest input lines possible. Set the output variableEGREP
to whatever is chosen.
Check whether
$GREP -F
works, or else look for the best availablefgrep
orgfgrep
that accepts the longest input lines possible. Set the output variableFGREP
to whatever is chosen.
Set output variable
INSTALL
to the name of a BSD-compatible install program, if one is found in the current PATH. Otherwise, setINSTALL
to ‘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_PROGRAM
andINSTALL_SCRIPT
to ‘${INSTALL}’ andINSTALL_DATA
to ‘${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.
Set output variable
MKDIR_P
to 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_P
macro (see Programming in M4sh), but it sets an output variable intended for use in other files, whereasAS_MKDIR_P
is intended for use in scripts like configure. Also,AS_MKDIR_P
does not accept options, butMKDIR_P
supports the -m option, e.g., a makefile might invoke$(MKDIR_P) -m 0 dir
to 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_P
does not check for race condition vulnerability, whereasAC_PROG_MKDIR_P
does.‘@MKDIR_P@’ is special, as its value may vary for different configuration files.
If
flex
is found, set output variableLEX
to ‘flex’ andLEXLIB
to -lfl, if that library is in a standard place. Otherwise setLEX
to ‘lex’ andLEXLIB
to -ll, if found. If neither variant is available, setLEX
to ‘:’; 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 inadvertantly changed.Define
YYTEXT_POINTER
ifyytext
defaults to ‘char *’ instead of to ‘char []’. Also set output variableLEX_OUTPUT_ROOT
to the base of the file name that the lexer generates; usually lex.yy, but sometimes something else. These results vary according to whetherlex
orflex
is 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
yywrap
or, 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_LEX
invokes (indirectly) this macro twice, which causes an annoying but benign “AC_PROG_LEX
invoked 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.
If ‘ln -s’ works on the current file system (the operating system and file system support symbolic links), set the output variable
LN_S
to ‘ln -s’; otherwise, if ‘ln’ works, setLN_S
to ‘ln’, and otherwise set it to ‘cp -p’.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
ln
in 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
RANLIB
to ‘ranlib’ ifranlib
is found, and otherwise to ‘:’ (do nothing).
Set output variable
SED
to 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.