📄 autoconf.texi
字号:
@samp{$*}, and @strong{$%}.@example@group$ @kbd{cat configure.ac}AC_DEFINE(This, is, [an[example]])$ @kbd{autoconf -t 'AC_DEFINE:@@: $@@}*: $*$: $%'@@: [This],[is],[an[example]]*: This,is,an[example]$: This:is:an [example]@end group@end example@noindentThe @var{format} gives you a lot of freedom:@example@group$ @kbd{autoconf -t 'AC_SUBST:$$ac_subst@{"$1"@} = "$f:$l";'}$ac_subst@{"ECHO_C"@} = "configure.ac:2";$ac_subst@{"ECHO_N"@} = "configure.ac:2";$ac_subst@{"ECHO_T"@} = "configure.ac:2";@i{More traces deleted}@end group@end example@noindentA long @var{separator} can be used to improve the readability of complexstructures, and to ease their parsing (for instance when no singlecharacter is suitable as a separator):@example@group$ @kbd{autoconf -t 'AM_MISSING_PROG:$@{|:::::|@}*'}ACLOCAL|:::::|aclocal|:::::|$missing_dirAUTOCONF|:::::|autoconf|:::::|$missing_dirAUTOMAKE|:::::|automake|:::::|$missing_dir@i{More traces deleted}@end group@end example@node autoreconf Invocation@section Using @command{autoreconf} to Update @command{configure} Scripts@cindex @command{autoreconf}Installing the various components of the @acronym{GNU} Build System can betedious: running @command{autopoint} for Gettext, @command{automake} for@file{Makefile.in} etc.@: in each directory. It may be needed eitherbecause some tools such as @command{automake} have been updated on yoursystem, or because some of the sources such as @file{configure.ac} havebeen updated, or finally, simply in order to install the @acronym{GNU} BuildSystem in a fresh tree.@command{autoreconf} runs @command{autoconf}, @command{autoheader},@command{aclocal}, @command{automake}, @command{libtoolize}, and@command{autopoint} (when appropriate) repeatedly to update the@acronym{GNU} Build System in the specified directories and theirsubdirectories (@pxref{Subdirectories}). By default, it only remakesthose files that are older than their sources.If you install a new version of some tool, you can make@command{autoreconf} remake @emph{all} of the files by giving it the@option{--force} option.@xref{Automatic Remaking}, for @file{Makefile} rules to automaticallyremake @command{configure} scripts when their source files change. Thatmethod handles the timestamps of configuration header templatesproperly, but does not pass @option{--autoconf-dir=@var{dir}} or@option{--localdir=@var{dir}}.@noindent@command{autoreconf} accepts the following options:@table @option@item --help@itemx -hPrint a summary of the command line options and exit.@item --version@itemx -VPrint the version number of Autoconf and exit.@item --verbosePrint the name of each directory where @command{autoreconf} runs@command{autoconf} (and @command{autoheader}, if appropriate).@item --debug@itemx -dDon't remove the temporary files.@item --force@itemx -fRemake even @file{configure} scripts and configuration headers that arenewer than their input files (@file{configure.ac} and, if present,@file{aclocal.m4}).@item --install@itemx -iInstall the missing auxiliary files in the package. By default, filesare copied; this can be changed with @option{--symlink}.This option triggers calls to @samp{automake --add-missing},@samp{libtoolize}, @samp{autopoint}, etc.@item --symlink@itemx -sWhen used with @option{--install}, install symbolic links to the missingauxiliary files instead of copying them.@item --make@itemx -mWhen the directories were configured, update the configuration byrunning @samp{./config.status --recheck && ./config.status}, and thenrun @samp{make}.@item --include=@var{dir}@itemx -I @var{dir}Append @var{dir} to the include path. Multiple invocations accumulate.@item --prepend-include=@var{dir}@item -B @var{dir}Prepend @var{dir} to the include path. Multiple invocations accumulate.@item --warnings=@var{category}@itemx -W @var{category}@evindex WARNINGSReport the warnings related to @var{category} (which can actually be acomma separated list).@table @samp@item crossrelated to cross compilation issues.@item obsoletereport the uses of obsolete constructs.@item portabilityportability issues@item syntaxdubious syntactic constructs.@item allreport all the warnings@item nonereport none@item errortreats warnings as errors@item no-@var{category}disable warnings falling into @var{category}@end tableWarnings about @samp{syntax} are enabled by default, and the environmentvariable @code{WARNINGS}, a comma separated list of categories, ishonored. Passing @samp{-W @var{category}} will actually behave as ifyou had passed @samp{--warnings=syntax,$WARNINGS,@var{category}}. Ifyou want to disable the defaults and @code{WARNINGS}, but (for example)enable the warnings about obsolete constructs, you would use @option{-Wnone,obsolete}.@end table@c ========================================= Initialization and Output Files.@node Setup@chapter Initialization and Output FilesAutoconf-generated @command{configure} scripts need some information abouthow to initialize, such as how to find the package's source files andabout the output files to produce. The following sections describe theinitialization and the creation of output files.@menu* Initializing configure:: Option processing etc.* Notices:: Copyright, version numbers in @command{configure}* Input:: Where Autoconf should find files* Output:: Outputting results from the configuration* Configuration Actions:: Preparing the output based on results* Configuration Files:: Creating output files* Makefile Substitutions:: Using output variables in @file{Makefile}s* Configuration Headers:: Creating a configuration header file* Configuration Commands:: Running arbitrary instantiation commands* Configuration Links:: Links depending on the configuration* Subdirectories:: Configuring independent packages together* Default Prefix:: Changing the default installation prefix@end menu@node Initializing configure@section Initializing @command{configure}Every @command{configure} script must call @code{AC_INIT} before doinganything else. The only other required macro is @code{AC_OUTPUT}(@pxref{Output}).@defmac AC_INIT (@var{package}, @var{version}, @ovar{bug-report}, @ovar{tarname})@acindex{INIT}Process any command-line arguments and perform various initializationsand verifications.Set the name of the @var{package} and its @var{version}. These aretypically used in @option{--version} support, including that of@command{configure}. The optional argument @var{bug-report} should bethe email to which users should send bug reports. The package@var{tarname} differs from @var{package}: the latter designates the fullpackage name (e.g., @samp{GNU Autoconf}), while the former is meant fordistribution tar ball names (e.g., @samp{autoconf}). It defaults to@var{package} with @samp{GNU } stripped, lower-cased, and all charactersother than alphanumerics and underscores are changed to @samp{-}.It is preferable that the arguments of @code{AC_INIT} be static, i.e.,there should not be any shell computation, but they can be computed byM4.The following M4 macros (e.g., @code{AC_PACKAGE_NAME}), output variables(e.g., @code{PACKAGE_NAME}), and preprocessor symbols (e.g.,@code{PACKAGE_NAME}) are defined by @code{AC_INIT}:@table @asis@item @code{AC_PACKAGE_NAME}, @code{PACKAGE_NAME}@acindex{PACKAGE_NAME}@ovindex PACKAGE_NAME@cvindex PACKAGE_NAMEExactly @var{package}.@item @code{AC_PACKAGE_TARNAME}, @code{PACKAGE_TARNAME}@acindex{PACKAGE_TARNAME}@ovindex PACKAGE_TARNAME@cvindex PACKAGE_TARNAMEExactly @var{tarname}.@item @code{AC_PACKAGE_VERSION}, @code{PACKAGE_VERSION}@acindex{PACKAGE_VERSION}@ovindex PACKAGE_VERSION@cvindex PACKAGE_VERSIONExactly @var{version}.@item @code{AC_PACKAGE_STRING}, @code{PACKAGE_STRING}@acindex{PACKAGE_STRING}@ovindex PACKAGE_STRING@cvindex PACKAGE_STRINGExactly @samp{@var{package} @var{version}}.@item @code{AC_PACKAGE_BUGREPORT}, @code{PACKAGE_BUGREPORT}@acindex{PACKAGE_BUGREPORT}@ovindex PACKAGE_BUGREPORT@cvindex PACKAGE_BUGREPORTExactly @var{bug-report}.@end table@end defmac@node Notices@section Notices in @command{configure}The following macros manage version numbers for @command{configure}scripts. Using them is optional.@c FIXME: AC_PREREQ should not be here@defmac AC_PREREQ (@var{version})@acindex{PREREQ}@cindex VersionEnsure that a recent enough version of Autoconf is being used. If theversion of Autoconf being used to create @command{configure} isearlier than @var{version}, print an error message to the standarderror output and exit with failure (exit status is 63). For example:@exampleAC_PREREQ(@value{VERSION})@end exampleThis macro is the only macro that may be used before @code{AC_INIT}, butfor consistency, you are invited not to do so.@end defmac@defmac AC_COPYRIGHT (@var{copyright-notice})@acindex{COPYRIGHT}@cindex Copyright NoticeState that, in addition to the Free Software Foundation's copyright onthe Autoconf macros, parts of your @command{configure} are covered by the@var{copyright-notice}.The @var{copyright-notice} will show up in both the head of@command{configure} and in @samp{configure --version}.@end defmac@defmac AC_REVISION (@var{revision-info})@acindex{REVISION}@cindex RevisionCopy revision stamp @var{revision-info} into the @command{configure}script, with any dollar signs or double-quotes removed. This macro letsyou put a revision stamp from @file{configure.ac} into @command{configure}without @acronym{RCS} or @acronym{CVS} changing it when you check in@command{configure}. That way, you can determine easily which revision of@file{configure.ac} a particular @command{configure} corresponds to.For example, this line in @file{configure.ac}:@c The asis prevents RCS from changing the example in the manual.@exampleAC_REVISION($@asis{Revision: 1.30 }$)@end example@noindentproduces this in @command{configure}:@example#! /bin/sh# From configure.ac Revision: 1.30@end example@end defmac@node Input@section Finding @command{configure} Input@defmac AC_CONFIG_SRCDIR (@var{unique-file-in-source-dir})@acindex{CONFIG_SRCDIR}@var{unique-file-in-source-dir} is some file that is in the package'ssource directory; @command{configure} checks for this file's existence tomake sure that the directory that it is told contains the source code infact does. Occasionally people accidentally specify the wrong directorywith @option{--srcdir}; this is a safety check. @xref{configureInvocation}, for more information.@end defmac@c FIXME: Remove definitively once --install explained.@c@c Small packages may store all their macros in @code{aclocal.m4}. As the@c set of macros grows, or for maintenance reasons, a maintainer may prefer@c to split the macros in several files. In this case, Autoconf must be@c told which files to load, and in which order.@c@c @defmac AC_INCLUDE (@var{file}@dot
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -