📄 autoconf.texi
字号:
Alternately, if your code tests for configuration options using@code{#ifdef} instead of @code{#if}, a default value can be to@code{#undef} the variable instead of to define it to a value. Onsystems that have @file{unistd.h}, @code{configure} will change thesecond line to read @samp{#define HAVE_UNISTD_H 1}. On other systems,it will comment that line out (in case the system predefines thatsymbol).@example@group/* Define if you have unistd.h. */#undef HAVE_UNISTD_H@end group@end example@node Invoking autoheader, , Header Templates, Configuration Headers@subsection Using @code{autoheader} to Create @file{config.h.in}The @code{autoheader} program can create a template file of C@samp{#define} statements for @code{configure} to use. If@file{configure.in} invokes @code{AC_CONFIG_HEADER(@var{file})},@code{autoheader} creates @file{@var{file}.in}; if multiple filearguments are given, the first one is used. Otherwise,@code{autoheader} creates @file{config.h.in}.If you give @code{autoheader} an argument, it uses that file instead of@file{configure.in} and writes the header file to the standard outputinstead of to @file{config.h.in}. If you give @code{autoheader} anargument of @samp{-}, it reads the standard input instead of@file{configure.in} and writes the header file to the standard output.@code{autoheader} scans @file{configure.in} and figures out which Cpreprocessor symbols it might define. It copies comments and@code{#define} and @code{#undef} statements from a file called@file{acconfig.h}, which comes with and is installed with Autoconf. Italso uses a file called @file{acconfig.h} in the current directory, ifpresent. If you @code{AC_DEFINE} any additional symbols, you mustcreate that file with entries for them. For symbols defined by@code{AC_CHECK_HEADERS}, @code{AC_CHECK_FUNCS}, @code{AC_CHECK_SIZEOF},or @code{AC_CHECK_LIB}, @code{autoheader} generates comments and@code{#undef} statements itself rather than copying them from a file,since the possible symbols are effectively limitless.The file that @code{autoheader} creates contains mainly @code{#define}and @code{#undef} statements and their accompanying comments. If@file{./acconfig.h} contains the string @samp{@@TOP@@},@code{autoheader} copies the lines before the line containing@samp{@@TOP@@} into the top of the file that it generates. Similarly,if @file{./acconfig.h} contains the string @samp{@@BOTTOM@@},@code{autoheader} copies the lines after that line to the end of thefile it generates. Either or both of those strings may be omitted.An alternate way to produce the same effect is to create the files@file{@var{file}.top} (typically @file{config.h.top}) and/or@file{@var{file}.bot} in the current directory. If they exist,@code{autoheader} copies them to the beginning and end, respectively, ofits output. Their use is discouraged because they have file names thatcontain two periods, and so can not be stored on MS-DOS; also, they aretwo more files to clutter up the directory. But if you use the@samp{--localdir=@var{dir}} option to use an @file{acconfig.h} in anotherdirectory, they give you a way to put custom boilerplate in eachindividual @file{config.h.in}.@code{autoheader} accepts the following options:@table @code@item --help@itemx -hPrint a summary of the command line options and exit.@item --localdir=@var{dir}@itemx -l @var{dir}Look for the package files @file{aclocal.m4} and @file{acconfig.h} (butnot @file{@var{file}.top} and @file{@var{file}.bot}) in directory@var{dir} instead of in the current directory.@item --macrodir=@var{dir}@itemx -m @var{dir}@evindex AC_MACRODIRLook for the installed macro files and @file{acconfig.h} in directory@var{dir}. You can also set the @code{AC_MACRODIR} environment variableto a directory; this option overrides the environment variable.@item --versionPrint the version number of Autoconf and exit.@end table@node Subdirectories, Default Prefix, Configuration Headers, Setup@section Configuring Other Packages in SubdirectoriesIn most situations, calling @code{AC_OUTPUT} is sufficient to produce@file{Makefile}s in subdirectories. However, @code{configure} scriptsthat control more than one independent package can use@code{AC_CONFIG_SUBDIRS} to run @code{configure} scripts for otherpackages in subdirectories.@defmac AC_CONFIG_SUBDIRS (@var{dir} @dots{})@maindex CONFIG_SUBDIRS@ovindex subdirsMake @code{AC_OUTPUT} run @code{configure} in each subdirectory@var{dir} in the given whitespace-separated list. If a given @var{dir}is not found, no error is reported, so a @code{configure} script canconfigure whichever parts of a large source tree are present. If agiven @var{dir} contains @file{configure.in} but no @code{configure},the Cygnus @code{configure} script found by @code{AC_CONFIG_AUXDIR} isused.The subdirectory @code{configure} scripts are given the samecommand line options that were given to this @code{configure} script,with minor changes if needed (e.g., to adjust a relative path for thecache file or source directory). This macro also sets the outputvariable @code{subdirs} to the list of directories @samp{@var{dir}@dots{}}. @file{Makefile} rules can use this variable to determinewhich subdirectories to recurse into. This macro may be called multipletimes.@end defmac@node Default Prefix, Versions, Subdirectories, Setup@section Default PrefixBy default, @code{configure} sets the prefix for files it installs to@file{/usr/local}. The user of @code{configure} can select a differentprefix using the @samp{--prefix} and @samp{--exec-prefix} options.There are two ways to change the default: when creating@code{configure}, and when running it.Some software packages might want to install in a directory besides@file{/usr/local} by default. To accomplish that, use the@code{AC_PREFIX_DEFAULT} macro.@defmac AC_PREFIX_DEFAULT (@var{prefix})Set the default installation prefix to @var{prefix} instead of @file{/usr/local}.@end defmacIt may be convenient for users to have @code{configure} guess theinstallation prefix from the location of a related program that theyhave already installed. If you wish to do that, you can call@code{AC_PREFIX_PROGRAM}.@defmac AC_PREFIX_PROGRAM (@var{program})@maindex PREFIX_PROGRAMIf the user did not specify an installation prefix (using the@samp{--prefix} option), guess a value for it by looking for@var{program} in @code{PATH}, the way the shell does. If @var{program}is found, set the prefix to the parent of the directory containing@var{program}; otherwise leave the prefix specified in@file{Makefile.in} unchanged. For example, if @var{program} is@code{gcc} and the @code{PATH} contains @file{/usr/local/gnu/bin/gcc},set the prefix to @file{/usr/local/gnu}.@end defmac@node Versions, , Default Prefix, Setup@section Version Numbers in @code{configure}The following macros manage version numbers for @code{configure}scripts. Using them is optional.@defmac AC_PREREQ (@var{version})@maindex PREREQEnsure that a recent enough version of Autoconf is being used. If theversion of Autoconf being used to create @code{configure} is earlierthan @var{version}, print an error message on the standard error outputand do not create @code{configure}. For example:@exampleAC_PREREQ(1.8)@end exampleThis macro is useful if your @file{configure.in} relies on non-obviousbehavior that changed between Autoconf releases. If it merely needsrecently added macros, then @code{AC_PREREQ} is less useful, because the@code{autoconf} program already tells the user which macros are notfound. The same thing happens if @file{configure.in} is processed by aversion of Autoconf older than when @code{AC_PREREQ} was added.@end defmac@defmac AC_REVISION (@var{revision-info})@maindex REVISIONCopy revision stamp @var{revision-info} into the @code{configure}script, with any dollar signs or double-quotes removed. This macro letsyou put a revision stamp from @file{configure.in} into @code{configure}without RCS or CVS changing it when you check in @code{configure}. Thatway, you can determine easily which revision of @file{configure.in} aparticular @code{configure} corresponds to.It is a good idea to call this macro before @code{AC_INIT} so that therevision number is near the top of both @file{configure.in} and@code{configure}. To support doing that, the @code{AC_REVISION} outputbegins with @samp{#! /bin/sh}, like the normal start of a@code{configure} script does.For example, this line in @file{configure.in}:@c The asis prevents RCS from changing the example in the manual.@exampleAC_REVISION($@asis{Revision: 1.30 }$)dnl@end example@noindentproduces this in @code{configure}:@example#! /bin/sh# From configure.in Revision: 1.30@end example@end defmac@node Existing Tests, Writing Tests, Setup, Top@chapter Existing TestsThese macros test for particular system features that packagesmight need or want to use. If you need to test for a kind of featurethat none of these macros check for, you can probably do it by callingprimitive test macros with appropriate arguments (@pxref{Writing Tests}).These tests print messages telling the user which feature they'rechecking for, and what they find. They cache their results for future@code{configure} runs (@pxref{Caching Results}).Some of these macros set output variables. @xref{MakefileSubstitutions}, for how to get their values. The phrase ``define@var{name}'' is used below as a shorthand to mean ``define Cpreprocessor symbol @var{name} to the value 1''. @xref{DefiningSymbols}, for how to get those symbol definitions into your program.@menu* Alternative Programs:: Selecting between alternative programs.* Libraries:: Library archives that might be missing.* Library Functions:: C library functions that might be missing.* Header Files:: Header files that might be missing.* Structures:: Structures or members that might be missing.* Typedefs:: @code{typedef}s that might be missing.* C Compiler Characteristics:: * Fortran 77 Compiler Characteristics:: * System Services:: Operating system services.* UNIX Variants:: Special kludges for specific UNIX variants.@end menu@node Alternative Programs, Libraries, Existing Tests, Existing Tests@section Alternative ProgramsThese macros check for the presence or behavior of particular programs.They are used to choose between several alternative programs and todecide what to do once one has been chosen.If there is no macro specifically defined to check for a program you need,and you don't need to check for any special properties ofit, then you can use one of the general program check macros.@menu* Particular Programs:: Special handling to find certain programs.* Generic Programs:: How to find other programs.@end menu@node Particular Programs, Generic Programs, Alternative Programs, Alternative Programs@subsection Particular Program ChecksThese macros check for particular programs---whether they exist, andin some cases whether they support certain features.@defmac AC_DECL_YYTEXT@maindex DECL_YYTEXT@cvindex YYTEXT_POINTER@ovindex LEX_OUTPUT_ROOTDefine @code{YYTEXT_POINTER} if @code{yytext} is a @samp{char *} insteadof a @samp{char []}. Also set output variable @code{LEX_OUTPUT_ROOT} tothe base of the file name that the lexer generates; usually@file{lex.yy}, but sometimes something else. These results varyaccording to whether @code{lex} or @code{flex} is being used.@end defmac@defmac AC_PROG_AWK@maindex PROG_AWK@ovindex AWKCheck for @code{mawk}, @code{gawk}, @code{nawk}, and @code{awk}, in thatorder, and set output variable @code{AWK} to the first one that itfinds. It tries @code{mawk} first because that is reported to be thefastest implementation.@end defmac@defmac AC_PROG_CC@maindex PROG_CC@ovindex CC@ovindex CFLAGSDetermine a C compiler to use. If @code{CC} is not already set in theenvironment, check for @code{gcc}, and use @code{cc} if that's not found.Set output variable @code{CC} to the name of the compiler found.If using the GNU C compiler, set shell variable @code{GCC} to@samp{yes}, empty otherwise. If output variable @code{CFLAGS} wasnot already set, set it to @samp{-g -O2} for the GNU C compiler(@samp{-O2} on systems where GCC does not accept @samp{-g}), or @samp{-g}for other compilers.If the C compiler being used does not produce executables that can runon the system where @code{configure} is being run, set the shellvariable @code{cross_compiling} to @samp{yes}, otherwise @samp{no}.In other words, this tests whether the build system type is differentfrom the host system type (the target system type is irrelevant to thistest). @xref{Manual Configuration}, for more on support for cross compiling.@end defmac@defmac AC_PROG_CC_C_O@maindex PROG_CC_C_O@cvindex NO_MINUS_C_MINUS_OIf the C compiler does not accept the @samp{-c} and @samp{-o} optionssimultaneously, define @code{NO_MINUS_C_MINUS_O}.@end defmac@defmac AC_PROG_CPP@maindex PROG_CPP@ovindex CPPSet output variable @code{CPP} to a command that runs theC preprocessor. If @samp{$CC -E} doesn't
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -