Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.”
3 Automake的设计理念
本节主要讲讲Automake是如何工作的。
3.1 一般操作
Automake 读取Makefile.am 并生成文件Makefile.in。
Makefile.am定义的变量和规则会指导Automake生成相关的代码。
比如bin_PROGRAMS 变量定义了如何编译连接的规则。
Makefile.am 大部分定义的变量和规则会拷贝到生成的文件。
GNU make支持追加操作符 +=。
Automake在解析时并不是特别聪明,所以最好不要编写一些奇形怪状的语句。
特别是最好不要使用 <TAB> ,如果使用很多复杂的宏也会引起诸多问题:
% cat Makefile.am
$(FOO:=x): bar
% automake
Makefile.am:1: bad characters in variable name '$(FOO'
Makefile.am:1: ':='-style assignments are not portable
Some Makefile variables are reserved by the GNU Coding Standards for the use of the “user”—the person building the package. For instance, CFLAGS is one such variable.
Sometimes package developers are tempted to set user variables such as CFLAGS because it appears to make their job easier. However, the package itself should never set a user variable, particularly not to include switches that are required for proper compilation of the package. Since these variables are documented as being for the package builder, that person rightfully expects to be able to override any of these variables at build time.
To get around this problem, Automake introduces an automake-specific shadow variable for each user flag variable. (Shadow variables are not introduced for variables like CC, where they would make no sense.) The shadow variable is named by prepending AM_ to the user variable’s name. For instance, the shadow variable for YFLAGS is AM_YFLAGS. The package maintainer—that is, the author(s) of the Makefile.am and configure.ac files—may adjust these shadow variables however necessary.
config.guess config.sub These two programs compute the canonical triplets for the given build, host, or target architecture. These programs are updated regularly to support new architectures and fix probes broken by changes in new kernel versions. Each new release of Automake comes with up-to-date copies of these programs. If your copy of Automake is getting old, you are encouraged to fetch the latest versions of these files from https://savannah.gnu.org/git/?group=config before making a release.
depcomp This program understands how to run a compiler so that it will generate not only the desired output but also dependency information that is then used by the automatic dependency tracking feature
install-sh This is a replacement for the install program that works on platforms where install is unavailable or unusable.
mdate-sh This script is used to generate a version.texi file. It examines a file and prints some date information about it.
missing This wraps a number of programs that are typically only required by maintainers. If the program in question does not exist, or seems to old, missing will print an informative warning before failing out, to provide the user with more context and information.
mkinstalldirs This script used to be a wrapper around mkdir -p, which is not portable. Now we prefer to use install-sh -d when configure finds that mkdir -p does not work, this makes one less script to distribute. For backward compatibility mkinstalldirs is still used and distributed when automake finds it in a package. But it is no longer installed automatically, and it should be safe to remove it.
py-compile This is used to byte-compile Python scripts.
test-driver This implements the default test driver offered by the parallel testsuite harness.
texinfo.tex Not a program, this file is required for make dvi, make ps and make pdf to work when Texinfo sources are in the package. The latest version can be downloaded from https://www.gnu.org/software/texinfo/.
ylwrap This program wraps lex and yacc to rename their output files. It also ensures that, for instance, multiple yacc instances can be invoked in a single directory in parallel.