⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autoconf.texi

📁 这是一个自动生成MAKEFILE的工具。在LINUX工程项目里是很好的帮手。希望对大家有点帮助。
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
feature that the software package they are for might need individually.(Before each check, they print a one-line message stating what they arechecking for, so the user doesn't get too bored while waiting for thescript to finish.)  As a result, they deal well with systems that arehybrids or customized from the more common UNIX variants.  There is noneed to maintain files that list the features supported by each releaseof each variant of UNIX.For each software package that Autoconf is used with, it creates aconfiguration script from a template file that lists thesystem features that the package needs or can use.  After the shell code torecognize and respond to a system feature has been written,Autoconf allows it to be shared by many software packages that canuse (or need) that feature.  If it later turns out that the shell codeneeds adjustment for some reason, it needs to be changed in only oneplace; all of the configuration scripts can be regeneratedautomatically to take advantage of the updated code.The Metaconfig package is similar in purpose to Autoconf, butthe scripts it produces require manual user intervention, which is quiteinconvenient when configuring large source trees.  Unlike Metaconfigscripts, Autoconf scripts can support cross-compiling, if some care istaken in writing them.There are several jobs related to making portable software packagesthat Autoconf currently does not do.  Among these are automaticallycreating @file{Makefile} files with all of the standard targets, andsupplying replacements for standard library functions and header files onsystems that lack them.  Work is in progress to add those features inthe future.Autoconf imposes some restrictions on the names of macros used with@code{#ifdef} in C programs (@pxref{Preprocessor Symbol Index}).Autoconf requires GNU @code{m4} in order to generate the scripts.  Ituses features that some UNIX versions of @code{m4} do not have.  It alsooverflows internal limits of some versions of @code{m4}, including GNU@code{m4} 1.0.  You must use version 1.1 or later of GNU @code{m4}.Using version 1.3 or later will be much faster than 1.1 or 1.2.@xref{Upgrading}, for information about upgrading from version 1.@xref{History}, for the story of Autoconf's development.@xref{Questions}, for answers to some common questions about Autoconf.Mail suggestions and bug reports for Autoconf to@code{bug-gnu-utils@@prep.ai.mit.edu}.  Please include the Autoconf versionnumber, which you can get by running @samp{autoconf --version}.@node Making configure Scripts, Setup, Introduction, Top@chapter Making @code{configure} ScriptsThe configuration scripts that Autoconf produces are by conventioncalled @code{configure}.  When run, @code{configure} creates severalfiles, replacing configuration parameters in them with appropriatevalues.  The files that @code{configure} creates are:@itemize @bullet@itemone or more @file{Makefile} files, one in each subdirectory of thepackage (@pxref{Makefile Substitutions});@itemoptionally, a C header file, the name of which is configurable,containing @code{#define} directives (@pxref{Configuration Headers});@itema shell script called @file{config.status} that, when run, will recreatethe files listed above (@pxref{Invoking config.status});@itema shell script called @file{config.cache} that saves the results ofrunning many of the tests (@pxref{Cache Files});@itema file called @file{config.log} containing any messages produced bycompilers, to help debugging if @code{configure} makes a mistake.@end itemizeTo create a @code{configure} script with Autoconf, you need to write anAutoconf input file @file{configure.in} and run @code{autoconf} on it.If you write your own feature tests to supplement those that come withAutoconf, you might also write files called @file{aclocal.m4} and@file{acsite.m4}.  If you use a C header file to contain @code{#define}directives, you might also write @file{acconfig.h}, and you willdistribute the Autoconf-generated file @file{config.h.in} with thepackage.Here is a diagram showing how the files that can be used inconfiguration are produced.  Programs that are executed are suffixed by@samp{*}.  Optional files are enclosed in square brackets (@samp{[]}).@code{autoconf} and @code{autoheader} also read the installed Autoconfmacro files (by reading @file{autoconf.m4}).@noindentFiles used in preparing a software package for distribution:@example@groupyour source files --> [autoscan*] --> [configure.scan] --> configure.inconfigure.in --.   .------> autoconf* -----> configure               +---+[aclocal.m4] --+   `---.[acsite.m4] ---'       |                       +--> [autoheader*] -> [config.h.in][acconfig.h] ----.     |                 +-----'[config.h.top] --+[config.h.bot] --'Makefile.in -------------------------------> Makefile.in@end group@end example@noindentFiles used in configuring a software package:@example@group                       .-------------> config.cacheconfigure* ------------+-------------> config.log                       |[config.h.in] -.       v            .-> [config.h] -.               +--> config.status* -+               +--> make*Makefile.in ---'                    `-> Makefile ---'@end group@end example@menu* Writing configure.in::        What to put in an Autoconf input file.* Invoking autoscan::           Semi-automatic @file{configure.in} writing.* Invoking ifnames::            Listing the conditionals in source code.* Invoking autoconf::           How to create configuration scripts.* Invoking autoreconf::         Remaking multiple @code{configure} scripts.@end menu@node Writing configure.in, Invoking autoscan, Making configure Scripts, Making configure Scripts@section Writing @file{configure.in}To produce a @code{configure} script for a software package, create afile called @file{configure.in} that contains invocations of theAutoconf macros that test the system features your package needs or canuse.  Autoconf macros already exist to check for many features; see@ref{Existing Tests}, for their descriptions.  For most otherfeatures, you can use Autoconf template macros to produce custom checks;see @ref{Writing Tests}, for information about them.  For especiallytricky or specialized features, @file{configure.in} might need tocontain some hand-crafted shell commands.  The @code{autoscan}program can give you a good start in writing @file{configure.in}(@pxref{Invoking autoscan}, for more information).The order in which @file{configure.in} calls the Autoconf macrosis not important, with a few exceptions.  Every@file{configure.in} must contain a call to @code{AC_INIT} beforethe checks, and a call to @code{AC_OUTPUT} at the end(@pxref{Output}).  Additionally, some macros rely on other macroshaving been called first, because they check previously setvalues of some variables to decide what to do.  These macros arenoted in the individual descriptions (@pxref{Existing Tests}),and they also warn you when creating @code{configure} if they arecalled out of order.To encourage consistency, here is a suggested order for calling theAutoconf macros.  Generally speaking, the things near the end of thislist could depend on things earlier in it.  For example, libraryfunctions could be affected by typedefs and libraries.@display@group@code{AC_INIT(@var{file})}checks for programschecks for librarieschecks for header fileschecks for typedefschecks for structureschecks for compiler characteristicschecks for library functionschecks for system services@code{AC_OUTPUT(@r{[}@var{file@dots{}}@r{]})}@end group@end displayIt is best to put each macro call on its own line in@file{configure.in}.  Most of the macros don't add extra newlines; theyrely on the newline after the macro call to terminate the commands.This approach makes the generated @code{configure} script a littleeasier to read by not inserting lots of blank lines.  It is generallysafe to set shell variables on the same line as a macro call, becausethe shell allows assignments without intervening newlines.When calling macros that take arguments, there must not be any blankspace between the macro name and the open parenthesis.  Arguments can bemore than one line long if they are enclosed within the @code{m4} quotecharacters @samp{[} and @samp{]}.  If you have a long line such as alist of file names, you can generally use a backslash at the end of aline to continue it logically on the next line (this is implemented bythe shell, not by anything special that Autoconf does).Some macros handle two cases: what to do if the given condition is met,and what to do if the condition is not met.  In some places you mightwant to do something if a condition is true but do nothing if it'sfalse, or vice versa.  To omit the true case, pass an empty value forthe @var{action-if-found} argument to the macro.  To omit the falsecase, omit the @var{action-if-not-found} argument to the macro,including the comma before it.You can include comments in @file{configure.in} files by starting themwith the @code{m4} builtin macro @code{dnl}, which discards text upthrough the next newline.  These comments do not appear in the generated@code{configure} scripts.  For example, it is helpful to begin@file{configure.in} files with a line like this:@examplednl Process this file with autoconf to produce a configure script.@end example@node Invoking autoscan, Invoking ifnames, Writing configure.in, Making configure Scripts@section Using @code{autoscan} to Create @file{configure.in}The @code{autoscan} program can help you create a @file{configure.in}file for a software package.  @code{autoscan} examines source files inthe directory tree rooted at a directory given as a command lineargument, or the current directory if none is given.  It searches thesource files for common portability problems and creates a file@file{configure.scan} which is a preliminary @file{configure.in} forthat package.You should manually examine @file{configure.scan} before renaming it to@file{configure.in}; it will probably need some adjustments.Occasionally @code{autoscan} outputs a macro in the wrong order relativeto another macro, so that @code{autoconf} produces a warning; you needto move such macros manually.  Also, if you want the package to use aconfiguration header file, you must add a call to@code{AC_CONFIG_HEADER} (@pxref{Configuration Headers}).  You might alsohave to change or add some @code{#if} directives to your program inorder to make it work with Autoconf (@pxref{Invoking ifnames}, forinformation about a program that can help with that job).@code{autoscan} uses several data files, which are installed along with thedistributed Autoconf macro files, to determine which macros to outputwhen it finds particular symbols in a package's source files.  Thesefiles all have the same format.  Each line consists of a symbol,whitespace, and the Autoconf macro to output if that symbol isencountered.  Lines starting with @samp{#} are comments.@code{autoscan} is only installed if you already have Perl installed.@code{autoscan} accepts the following options:@table @code@item --helpPrint a summary of the command line options and exit.@item --macrodir=@var{dir}@evindex AC_MACRODIRLook for the data files in directory @var{dir} instead of the defaultinstallation directory.  You can also set the @code{AC_MACRODIR}environment variable to a directory; this option overrides theenvironment variable.@item --verbosePrint the names of the files it examines and the potentially interestingsymbols it finds in them.  This output can be voluminous.@item --versionPrint the version number of Autoconf and exit.@end table@node Invoking ifnames, Invoking autoconf, Invoking autoscan, Making configure Scripts@section Using @code{ifnames} to List Conditionals@code{ifnames} can help when writing a @file{configure.in} for asoftware package.  It prints the identifiers that the package alreadyuses in C preprocessor conditionals.  If a package has already been setup to have some portability, this program can help you figure out whatits @code{configure} needs to check for.  It may help fill in some gapsin a @file{configure.in} generated by @code{autoscan} (@pxref{Invokingautoscan}).@code{ifnames} scans all of the C source files named on the command line(or the standard input, if none are given) and writes to the standardoutput a sorted list of all the identifiers that appear in those filesin @code{#if}, @code{#elif}, @code{#ifdef}, or @code{#ifndef}directives.  It prints each identifier on a line, followed by aspace-separated list of the files in which that identifier occurs.@noindent@code{ifnames} accepts the following options:@table @code@item --help@itemx -hPrint a summary of the command line options and exit.@item --macrodir=@var{dir}@itemx -m @var{dir}@evindex AC_MACRODIRLook for the Autoconf macro files in directory @var{dir} instead of thedefault installation directory.  Only used to get the version number.You can also set the @code{AC_MACRODIR}environment variable to a directory; this option overrides theenvironment variable.@item --versionPrint the version number of Autoconf and exit.@end table@node Invoking autoconf, Invoking autoreconf, Invoking ifnames, Making configure Scripts@section Using @code{autoconf} to Create @code{configure}To create @code{configure} from @file{configure.in}, run the@code{autoconf} program with no arguments.  @code{autoconf} processes@file{configure.in} with the @code{m4} macro processor, using theAutoconf macros.  If you give @code{autoconf} an argument, it reads thatfile instead of @file{configure.in} and writes the configuration scriptto the standard output instead of to @code{configure}.  If you give@code{autoconf} the argument @samp{-}, it reads the standard inputinstead of @file{configure.in} and writes the configuration script onthe standard output.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -