Download - Auto Tools
![Page 1: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/1.jpg)
Foreword
Foreword (1/2)
This presentation targets developers familiar with Unix development tools(shell, make, compiler) that want to learn Autotools.
The latest version of this document can be retrieved fromhttp://www.lrde.epita.fr/∼adl/autotools.html
Please mail me corrections and suggestions about this document [email protected].
Do not send me any general question about the Autotools. Use theappropriate mailing list instead ([email protected], [email protected]).
A. Duret-Lutz Using GNU Autotools February 21, 2008 1 / 162
![Page 2: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/2.jpg)
Tool Versions
Foreword (2/2)
This document was updated for the following releases of the Autotools:
GNU Autoconf 2.61 (November 2006)GNU Automake 1.10.1 (January 2008)GNU Libtool 1.5.26 (February 2008)GNU Gettext 0.17 (November 2007)
These were the last releases at the time of writing.
The usage of these tools has improved a lot over the last years.
Some syntaxes used here will not work with older tools.
This a deliberate choice:
New users should learn today’s recommended usages.Make sure you have up-to-date tools and do not bother with oldreleases.
A. Duret-Lutz Using GNU Autotools February 21, 2008 2 / 162
![Page 3: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/3.jpg)
Title Page
Using GNU Autotools
Alexandre [email protected]
February 21, 2008
Copyright c© 2008 Alexandre Duret-Lutzhttp://creativecommons.org/licenses/by-sa/2.0/
Trivial source code examples displayed in this tutorial (such asthe C files, Makefile.ams, and configure.acs of all the ‘amhello’projects) can be reused as if they were in the public domain.
A. Duret-Lutz Using GNU Autotools February 21, 2008 3 / 162
![Page 4: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/4.jpg)
Part I
The GNU Build System
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 4 / 162
![Page 5: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/5.jpg)
Goals Portable Packages
Portable Packages
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 5 / 162
![Page 6: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/6.jpg)
Goals Portable Packages
Sources of Non-Portability in C
Consider C functions...
that do not exist everywhere (e.g., strtod())
that have different names (e.g., strchr() vs. index())
that have varying prototypes(e.g., int setpgrp(void); vs. int setpgrp(int, int);)
that can behave differently (e.g., malloc(0);)
that might require other libraries(is pow() in libm.so or in libc.so?)
that can be defined in different headers(string.h vs. strings.h vs. memory.h)
How should a package deal with those?
A. Duret-Lutz Using GNU Autotools February 21, 2008 6 / 162
![Page 7: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/7.jpg)
Goals Portable Packages
Possible Solutions
Slice the code with lots of #if/#else
Create substitution macros
Create substitution functions
The latter two are to be preferred.
A. Duret-Lutz Using GNU Autotools February 21, 2008 7 / 162
![Page 8: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/8.jpg)
Goals Portable Packages
Possible Solutions
Slice the code with lots of #if/#else
Create substitution macros
Create substitution functions
The latter two are to be preferred.
A. Duret-Lutz Using GNU Autotools February 21, 2008 7 / 162
![Page 9: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/9.jpg)
Goals Portable Packages
Code Cluttered with #if/#else
Excerpt of ffcall-1.10’s alloc trampoline()
#i f ! d e f i n e d (CODE EXECUTABLE)s t a t i c long p a g e s i z e = 0 ;
#i f d e f i n e d (EXECUTABLE VIA MMAP DEVZERO)s t a t i c i n t z e r o f d ;
#end i fi f ( ! p a g e s i z e ) {
#i f d e f i n e d (HAVE MACH VM)pag e s i z e = vm page s i z e ;
#e l s ep a g e s i z e = g e t p a g e s i z e ( ) ;
#end i f#i f d e f i n e d (EXECUTABLE VIA MMAP DEVZERO)
z e r o f d = open ( ”/dev/ z e r o ” , O RDONLY, 0 6 4 4 ) ;i f ( z e r o f d < 0) {
f p r i n t f ( s t d e r r , ” t r ampo l i n e : Cannot open /dev/ ze r o !\ n” ) ;abo r t ( ) ;
}#end i f
}#end i f
A. Duret-Lutz Using GNU Autotools February 21, 2008 8 / 162
![Page 10: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/10.jpg)
Goals Portable Packages
Substitution macros
Excerpt of coreutils-5.2.1’s system.h
#i f ! HAVE FSEEKO && ! d e f i n e d f s e e k o# def ine f s e e k o ( s , o , w) ( ( o ) == ( long ) ( o ) \
? f s e e k ( s , o , w) \: ( e r r n o = EOVERFLOW, −1))
#end i f
Then use fseeko() whether it exists or not.
A. Duret-Lutz Using GNU Autotools February 21, 2008 9 / 162
![Page 11: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/11.jpg)
Goals Portable Packages
Substitution functions
If strdup() does not exist, link your program with a replacementdefinition such as
strdup.c (from the GNU C library)
char ∗s t r dup ( const char ∗ s ){
s i z e t l e n = s t r l e n ( s ) + 1 ;void ∗new = ma l l o c ( l e n ) ;i f ( new == NULL)
return NULL ;return ( char ∗) memcpy (new , s , l e n ) ;
}
A. Duret-Lutz Using GNU Autotools February 21, 2008 10 / 162
![Page 12: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/12.jpg)
Goals Uniform Builds
Uniform Builds
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 11 / 162
![Page 13: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/13.jpg)
Goals Uniform Builds
Need for Automatic Configuration
Maintaining a collection of #define for each system by hand iscumbersome.
Requiring users to add the necessary -D, -I, and -l compilationoptions to Makefile is burdensome.
Complicated builds hinder the acceptance of free software.
In 1991 people started to write shell scripts to guess these settingsfor some GNU packages.
Since then the configure script is mandatory in any package of theGNU project.
A. Duret-Lutz Using GNU Autotools February 21, 2008 12 / 162
![Page 14: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/14.jpg)
Goals Uniform Builds
Need for Automatic Configuration
Maintaining a collection of #define for each system by hand iscumbersome.
Requiring users to add the necessary -D, -I, and -l compilationoptions to Makefile is burdensome.
Complicated builds hinder the acceptance of free software.
In 1991 people started to write shell scripts to guess these settingsfor some GNU packages.
Since then the configure script is mandatory in any package of theGNU project.
A. Duret-Lutz Using GNU Autotools February 21, 2008 12 / 162
![Page 15: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/15.jpg)
Goals Uniform Builds
configure’s Purpose
configure
config.hMakefile src/Makefile
configure probes the systems for required functions, libraries, andtools
then it generates a config.h file with all #defines
as well as Makefiles to build the package
A. Duret-Lutz Using GNU Autotools February 21, 2008 13 / 162
![Page 16: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/16.jpg)
Goals Uniform Builds
configure’s Purpose
configure
config.h
Makefile src/Makefile
configure probes the systems for required functions, libraries, andtools
then it generates a config.h file with all #defines
as well as Makefiles to build the package
A. Duret-Lutz Using GNU Autotools February 21, 2008 13 / 162
![Page 17: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/17.jpg)
Goals Uniform Builds
configure’s Purpose
configure
config.hMakefile src/Makefile
configure probes the systems for required functions, libraries, andtools
then it generates a config.h file with all #defines
as well as Makefiles to build the package
A. Duret-Lutz Using GNU Autotools February 21, 2008 13 / 162
![Page 18: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/18.jpg)
Goals Uniform Builds
GNU Coding Standards
http://www.gnu.org/prep/standards/
Practices that packages of the GNU project should follow:
program behavior
how to report errors,standard command line options,etc.
coding style
configuration
Makefile conventions
etc.
A. Duret-Lutz Using GNU Autotools February 21, 2008 14 / 162
![Page 19: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/19.jpg)
Goals Uniform Builds
GNU Coding Standards
http://www.gnu.org/prep/standards/
Practices that packages of the GNU project should follow:
program behavior
how to report errors,standard command line options,etc.
coding style
configuration
Makefile conventions
etc.
A. Duret-Lutz Using GNU Autotools February 21, 2008 14 / 162
![Page 20: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/20.jpg)
Goals Uniform Builds
GNU Coding Standards
http://www.gnu.org/prep/standards/
Practices that packages of the GNU project should follow:
program behavior
how to report errors,standard command line options,etc.
coding style
configuration
Makefile conventions
etc.
A. Duret-Lutz Using GNU Autotools February 21, 2008 14 / 162
![Page 21: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/21.jpg)
Goals Uniform Builds
GNU Coding Standards
http://www.gnu.org/prep/standards/
Practices that packages of the GNU project should follow:
program behavior
how to report errors,standard command line options,etc.
coding style
configuration
Makefile conventions
etc.
A. Duret-Lutz Using GNU Autotools February 21, 2008 14 / 162
![Page 22: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/22.jpg)
Goals Uniform Builds
GNU Coding Standards
http://www.gnu.org/prep/standards/
Practices that packages of the GNU project should follow:
program behavior
how to report errors,standard command line options,etc.
coding style
configuration
Makefile conventions
etc.
A. Duret-Lutz Using GNU Autotools February 21, 2008 14 / 162
![Page 23: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/23.jpg)
Package Use Cases The User Point of View
The User Point of View
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 15 / 162
![Page 24: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/24.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 25: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/25.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 26: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/26.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...
~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 27: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/27.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...
~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 28: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/28.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...
~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 29: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/29.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:
/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 30: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/30.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
...
/home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 31: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/31.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 32: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/32.jpg)
Package Use Cases The User Point of View
Standard Installation Procedure
~ % tar zxf amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % ./configure
...~/amhello-1.0 % make
...~/amhello-1.0 % make check
...~/amhello-1.0 % su
Password:/home/adl/amhello-1.0 # make install
.../home/adl/amhello-1.0 # exit
~/amhello-1.0 % make installcheck
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 16 / 162
![Page 33: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/33.jpg)
Package Use Cases The User Point of View
Standard Makefile Targets
‘make all’ Build programs, libraries, documentation, etc.(Same as ‘make’.)
‘make install’ Install what needs to be installed.
‘make install-strip’ Same as ‘make install’, then strip debuggingsymbols.
‘make uninstall’ The opposite of ‘make install’.
‘make clean’ Erase what has been built (the opposite of ‘makeall’).
‘make distclean’ Additionally erase anything ‘./configure’created.
‘make check’ Run the test suite, if any.
‘make installcheck’ Check the installed programs or libraries, ifsupported.
‘make dist’ Create PACKAGE-VERSION.tar.gz .
A. Duret-Lutz Using GNU Autotools February 21, 2008 17 / 162
![Page 34: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/34.jpg)
Package Use Cases The User Point of View
Standard File System Hierarchy
Directory variable Default valueprefix /usr/ local
exec-prefix prefixbindir exec-prefix/binlibdir exec-prefix/lib...
includedir prefix/includedatarootdir prefix/share
datadir datarootdirmandir datarootdir/maninfodir datarootdir/info
...
~/amhello-1.0 %
./configure --prefix ~/usr
~/amhello-1.0 % make
~/amhello-1.0 % make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 18 / 162
![Page 35: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/35.jpg)
Package Use Cases The User Point of View
Standard File System Hierarchy
Directory variable Default valueprefix /usr/ local
exec-prefix prefixbindir exec-prefix/binlibdir exec-prefix/lib...
includedir prefix/includedatarootdir prefix/share
datadir datarootdirmandir datarootdir/maninfodir datarootdir/info
...
~/amhello-1.0 % ./configure --prefix ~/usr
~/amhello-1.0 % make
~/amhello-1.0 % make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 18 / 162
![Page 36: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/36.jpg)
Package Use Cases The User Point of View
Standard File System Hierarchy
Directory variable Default valueprefix /usr/ local
exec-prefix prefixbindir exec-prefix/binlibdir exec-prefix/lib...
includedir prefix/includedatarootdir prefix/share
datadir datarootdirmandir datarootdir/maninfodir datarootdir/info
...
~/amhello-1.0 % ./configure --prefix ~/usr
~/amhello-1.0 % make
~/amhello-1.0 % make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 18 / 162
![Page 37: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/37.jpg)
Package Use Cases The User Point of View
Standard File System Hierarchy
Directory variable Default valueprefix /usr/ local
exec-prefix prefixbindir exec-prefix/binlibdir exec-prefix/lib...
includedir prefix/includedatarootdir prefix/share
datadir datarootdirmandir datarootdir/maninfodir datarootdir/info
...
~/amhello-1.0 % ./configure --prefix ~/usr
~/amhello-1.0 % make
~/amhello-1.0 % make installA. Duret-Lutz Using GNU Autotools February 21, 2008 18 / 162
![Page 38: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/38.jpg)
Package Use Cases The User Point of View
Standard Configuration Variables
‘./configure’ automatically detects many settings.You can force some of them using configuration variables.
CC C compiler command
CFLAGS C compiler flags
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LDFLAGS linker flags
CPPFLAGS C/C++ preprocessor flags
... See ‘./configure --help’ for a full list.
~/amhello-1.0 %
./configure --prefix ~/usr CC=gcc-3 \CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
A. Duret-Lutz Using GNU Autotools February 21, 2008 19 / 162
![Page 39: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/39.jpg)
Package Use Cases The User Point of View
Standard Configuration Variables
‘./configure’ automatically detects many settings.You can force some of them using configuration variables.
CC C compiler command
CFLAGS C compiler flags
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LDFLAGS linker flags
CPPFLAGS C/C++ preprocessor flags
... See ‘./configure --help’ for a full list.
~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
A. Duret-Lutz Using GNU Autotools February 21, 2008 19 / 162
![Page 40: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/40.jpg)
Package Use Cases The Power User Point of View
The Power User Point of View
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 20 / 162
![Page 41: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/41.jpg)
Package Use Cases The Power User Point of View
Overriding Default Configuration Settings with config.site
Recall that old command
~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
Common configuration settings can be put in prefix/share/config.site
~/amhello-1.0 % cat ~/usr/share/config.site
test -z "$CC" && CC=gcc-3test -z "$CPPFLAGS" && CPPFLAGS=-I$HOME/usr/includetest -z "$LDFLAGS" && LDFLAGS=-L$HOME/usr/lib
Reducing the command to...
~/amhello-1.0 % ./configure --prefix ~/usrconfigure: loading site script /home/adl/usr/share/config.site...
A. Duret-Lutz Using GNU Autotools February 21, 2008 21 / 162
![Page 42: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/42.jpg)
Package Use Cases The Power User Point of View
Overriding Default Configuration Settings with config.site
Recall that old command
~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
Common configuration settings can be put in prefix/share/config.site
~/amhello-1.0 % cat ~/usr/share/config.site
test -z "$CC" && CC=gcc-3test -z "$CPPFLAGS" && CPPFLAGS=-I$HOME/usr/includetest -z "$LDFLAGS" && LDFLAGS=-L$HOME/usr/lib
Reducing the command to...
~/amhello-1.0 % ./configure --prefix ~/usrconfigure: loading site script /home/adl/usr/share/config.site...
A. Duret-Lutz Using GNU Autotools February 21, 2008 21 / 162
![Page 43: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/43.jpg)
Package Use Cases The Power User Point of View
Overriding Default Configuration Settings with config.site
Recall that old command
~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
Common configuration settings can be put in prefix/share/config.site
~/amhello-1.0 % cat ~/usr/share/config.site
test -z "$CC" && CC=gcc-3test -z "$CPPFLAGS" && CPPFLAGS=-I$HOME/usr/includetest -z "$LDFLAGS" && LDFLAGS=-L$HOME/usr/lib
Reducing the command to...
~/amhello-1.0 % ./configure --prefix ~/usrconfigure: loading site script /home/adl/usr/share/config.site...
A. Duret-Lutz Using GNU Autotools February 21, 2008 21 / 162
![Page 44: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/44.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 22 / 162
![Page 45: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/45.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 22 / 162
![Page 46: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/46.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 22 / 162
![Page 47: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/47.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 22 / 162
![Page 48: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/48.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 22 / 162
![Page 49: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/49.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 22 / 162
![Page 50: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/50.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees for Multiple Architectures
Builds for multiple architectures can share the same source tree.
Have the source on a (possibly read-only) shared directory
~ % cd /nfs/src
/nfs/src % tar zxf ~/amhello-1.0.tar.gz
Compilation on first host
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
Compilation on second host
, assuming shared data
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 23 / 162
![Page 51: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/51.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees for Multiple Architectures
Builds for multiple architectures can share the same source tree.
Have the source on a (possibly read-only) shared directory
~ % cd /nfs/src
/nfs/src % tar zxf ~/amhello-1.0.tar.gz
Compilation on first host
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
Compilation on second host
, assuming shared data
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 23 / 162
![Page 52: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/52.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees for Multiple Architectures
Builds for multiple architectures can share the same source tree.
Have the source on a (possibly read-only) shared directory
~ % cd /nfs/src
/nfs/src % tar zxf ~/amhello-1.0.tar.gz
Compilation on first host
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
Compilation on second host
, assuming shared data
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 23 / 162
![Page 53: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/53.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees for Multiple Architectures
Builds for multiple architectures can share the same source tree.
Have the source on a (possibly read-only) shared directory
~ % cd /nfs/src
/nfs/src % tar zxf ~/amhello-1.0.tar.gz
Compilation on first host
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
Compilation on second host
, assuming shared data
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 23 / 162
![Page 54: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/54.jpg)
Package Use Cases The Power User Point of View
Parallel Build Trees for Multiple Architectures
Builds for multiple architectures can share the same source tree.
Have the source on a (possibly read-only) shared directory
~ % cd /nfs/src
/nfs/src % tar zxf ~/amhello-1.0.tar.gz
Compilation on first host
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install
Compilation on second host, assuming shared data
~ % mkdir /tmp/amh && cd /tmp/amh
/tmp/amh % /nfs/src/amhello-1.0/configure
/tmp/amh % make && sudo make install-exec
A. Duret-Lutz Using GNU Autotools February 21, 2008 23 / 162
![Page 55: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/55.jpg)
Package Use Cases The Power User Point of View
Two Part Installation
‘make install’=
‘make install-exec’
install platform-dependent files
+‘make install-data’
install platform-independent files(can be shared among multiple machines)
A. Duret-Lutz Using GNU Autotools February 21, 2008 24 / 162
![Page 56: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/56.jpg)
Package Use Cases The Power User Point of View
Two Part Installation
‘make install’=
‘make install-exec’ install platform-dependent files+
‘make install-data’
install platform-independent files(can be shared among multiple machines)
A. Duret-Lutz Using GNU Autotools February 21, 2008 24 / 162
![Page 57: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/57.jpg)
Package Use Cases The Power User Point of View
Two Part Installation
‘make install’=
‘make install-exec’ install platform-dependent files+
‘make install-data’ install platform-independent files(can be shared among multiple machines)
A. Duret-Lutz Using GNU Autotools February 21, 2008 24 / 162
![Page 58: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/58.jpg)
Package Use Cases The Power User Point of View
Cross-Compilation
~/amhello-1.0 % ./configurechecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for gcc... gccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yeschecking whether we are cross compiling... nochecking for suffix of executables...checking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ANSI C......
Of course you need a cross-compiler installed first.
Cross-compilation configure options:
‘--build=BUILD’ The system on which the package is built.‘--host=HOST’ The system where built programs & libraries will
run.‘--target=TARGET’ Only when building compiler tools: the system for
which the tools will create output.
For simple cross-compilation, only ‘--host=HOST’ is needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 25 / 162
![Page 59: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/59.jpg)
Package Use Cases The Power User Point of View
Cross-Compilation
~/amhello-1.0 % ./configurechecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for gcc... gccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yeschecking whether we are cross compiling... nochecking for suffix of executables...checking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether gcc accepts -g... yeschecking for gcc option to accept ANSI C......
Of course you need a cross-compiler installed first.
Cross-compilation configure options:
‘--build=BUILD’ The system on which the package is built.‘--host=HOST’ The system where built programs & libraries will
run.‘--target=TARGET’ Only when building compiler tools: the system for
which the tools will create output.
For simple cross-compilation, only ‘--host=HOST’ is needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 25 / 162
![Page 60: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/60.jpg)
Package Use Cases The Power User Point of View
Cross-Compilation
~/amhello-1.0 % ./configure --build i686-pc-linux-gnu \
--host i586-mingw32msvcchecking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for i586-mingw32msvc-strip... i586-mingw32msvc-stripchecking for i586-mingw32msvc-gcc... i586-mingw32msvc-gccchecking for C compiler default output file name... a.exechecking whether the C compiler works... yeschecking whether we are cross compiling... yeschecking for suffix of executables... .exechecking for suffix of object files... ochecking whether we are using the GNU C compiler... yeschecking whether i586-mingw32msvc-gcc accepts -g... yeschecking for i586-mingw32msvc-gcc option to accept ANSI C......
Of course you need a cross-compiler installed first.
Cross-compilation configure options:
‘--build=BUILD’ The system on which the package is built.‘--host=HOST’ The system where built programs & libraries will
run.‘--target=TARGET’ Only when building compiler tools: the system for
which the tools will create output.
For simple cross-compilation, only ‘--host=HOST’ is needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 25 / 162
![Page 61: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/61.jpg)
Package Use Cases The Power User Point of View
Cross-Compilation
~/amhello-1.0 % ./configure --build i686-pc-linux-gnu \
--host i586-mingw32msvc
...~/amhello-1.0 % make
...
~/amhello-1.0 % cd src; file hello.exehello.exe: MS Windows PE 32-bit Intel 80386 console executable not relocatable
Of course you need a cross-compiler installed first.
Cross-compilation configure options:
‘--build=BUILD’ The system on which the package is built.
‘--host=HOST’ The system where built programs & libraries willrun.
‘--target=TARGET’ Only when building compiler tools: the system forwhich the tools will create output.
For simple cross-compilation, only ‘--host=HOST’ is needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 25 / 162
![Page 62: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/62.jpg)
Package Use Cases The Power User Point of View
Cross-Compilation
~/amhello-1.0 % ./configure --build i686-pc-linux-gnu \
--host i586-mingw32msvc
...~/amhello-1.0 % make
...~/amhello-1.0 % cd src; file hello.exehello.exe: MS Windows PE 32-bit Intel 80386 console executable not relocatable
Of course you need a cross-compiler installed first.
Cross-compilation configure options:
‘--build=BUILD’ The system on which the package is built.
‘--host=HOST’ The system where built programs & libraries willrun.
‘--target=TARGET’ Only when building compiler tools: the system forwhich the tools will create output.
For simple cross-compilation, only ‘--host=HOST’ is needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 25 / 162
![Page 63: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/63.jpg)
Package Use Cases The Power User Point of View
Cross-Compilation
~/amhello-1.0 % ./configure --build i686-pc-linux-gnu \
--host i586-mingw32msvc
...~/amhello-1.0 % make
...~/amhello-1.0 % cd src; file hello.exehello.exe: MS Windows PE 32-bit Intel 80386 console executable not relocatable
Of course you need a cross-compiler installed first.
Cross-compilation configure options:
‘--build=BUILD’ The system on which the package is built.
‘--host=HOST’ The system where built programs & libraries willrun.
‘--target=TARGET’ Only when building compiler tools: the system forwhich the tools will create output.
For simple cross-compilation, only ‘--host=HOST’ is needed.A. Duret-Lutz Using GNU Autotools February 21, 2008 25 / 162
![Page 64: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/64.jpg)
Package Use Cases The Power User Point of View
Renaming Programs at Install Time
Maybe hello is already a command on this host?
‘--program-prefix=PREFIX’prepend PREFIX to installed program names,
‘--program-suffix=SUFFIX’append SUFFIX to installed program names,
‘--program-transform-name=PROGRAM’run ‘sed PROGRAM’ on installed program names.
~/amhello-1.0 % ./configure --program-prefix test-
~/amhello-1.0 % make
~/amhello-1.0 % sudo make install
Will install hello as /usr/ local/bin/ test-hello
.
A. Duret-Lutz Using GNU Autotools February 21, 2008 26 / 162
![Page 65: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/65.jpg)
Package Use Cases The Power User Point of View
Renaming Programs at Install Time
Maybe hello is already a command on this host?
‘--program-prefix=PREFIX’prepend PREFIX to installed program names,
‘--program-suffix=SUFFIX’append SUFFIX to installed program names,
‘--program-transform-name=PROGRAM’run ‘sed PROGRAM’ on installed program names.
~/amhello-1.0 % ./configure --program-prefix test-
~/amhello-1.0 % make
~/amhello-1.0 % sudo make install
Will install hello as /usr/ local/bin/ test-hello
.
A. Duret-Lutz Using GNU Autotools February 21, 2008 26 / 162
![Page 66: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/66.jpg)
Package Use Cases The Power User Point of View
Renaming Programs at Install Time
Maybe hello is already a command on this host?
‘--program-prefix=PREFIX’prepend PREFIX to installed program names,
‘--program-suffix=SUFFIX’append SUFFIX to installed program names,
‘--program-transform-name=PROGRAM’run ‘sed PROGRAM’ on installed program names.
~/amhello-1.0 % ./configure --program-prefix test-
~/amhello-1.0 % make
~/amhello-1.0 % sudo make install
Will install hello as /usr/ local/bin/ test-hello.
A. Duret-Lutz Using GNU Autotools February 21, 2008 26 / 162
![Page 67: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/67.jpg)
Package Use Cases The Packager Point of View
The Packager Point of View
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 27 / 162
![Page 68: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/68.jpg)
Package Use Cases The Packager Point of View
Building Binary Packages Using DESTDIR
DESTDIR is used to relocate a package at install time.
~/amhello-1.0 % ./configure --prefix /usr
...
~/amhello-1.0 % make
...~/amhello-1.0 % make DESTDIR=$HOME/inst install
...~/amhello-1.0 % cd ~/inst
~/inst % tar zcvf ~/amhello-1.0-i686.tar.gz .
./
./usr/
./usr/bin/
./usr/bin/hello
... and ∼/amhello-1.0-i686.tar.gz is ready to be uncompressed in / onmany hosts.
A. Duret-Lutz Using GNU Autotools February 21, 2008 28 / 162
![Page 69: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/69.jpg)
Package Use Cases The Packager Point of View
Building Binary Packages Using DESTDIR
DESTDIR is used to relocate a package at install time.
~/amhello-1.0 % ./configure --prefix /usr
...~/amhello-1.0 % make
...
~/amhello-1.0 % make DESTDIR=$HOME/inst install
...~/amhello-1.0 % cd ~/inst
~/inst % tar zcvf ~/amhello-1.0-i686.tar.gz .
./
./usr/
./usr/bin/
./usr/bin/hello
... and ∼/amhello-1.0-i686.tar.gz is ready to be uncompressed in / onmany hosts.
A. Duret-Lutz Using GNU Autotools February 21, 2008 28 / 162
![Page 70: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/70.jpg)
Package Use Cases The Packager Point of View
Building Binary Packages Using DESTDIR
DESTDIR is used to relocate a package at install time.
~/amhello-1.0 % ./configure --prefix /usr
...~/amhello-1.0 % make
...~/amhello-1.0 % make DESTDIR=$HOME/inst install
...
~/amhello-1.0 % cd ~/inst
~/inst % tar zcvf ~/amhello-1.0-i686.tar.gz .
./
./usr/
./usr/bin/
./usr/bin/hello
... and ∼/amhello-1.0-i686.tar.gz is ready to be uncompressed in / onmany hosts.
A. Duret-Lutz Using GNU Autotools February 21, 2008 28 / 162
![Page 71: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/71.jpg)
Package Use Cases The Packager Point of View
Building Binary Packages Using DESTDIR
DESTDIR is used to relocate a package at install time.
~/amhello-1.0 % ./configure --prefix /usr
...~/amhello-1.0 % make
...~/amhello-1.0 % make DESTDIR=$HOME/inst install
...~/amhello-1.0 % cd ~/inst
~/inst % tar zcvf ~/amhello-1.0-i686.tar.gz .
./
./usr/
./usr/bin/
./usr/bin/hello
... and ∼/amhello-1.0-i686.tar.gz is ready to be uncompressed in / onmany hosts.
A. Duret-Lutz Using GNU Autotools February 21, 2008 28 / 162
![Page 72: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/72.jpg)
Package Use Cases The Maintainer Point of View
The Maintainer Point of View
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 29 / 162
![Page 73: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/73.jpg)
Package Use Cases The Maintainer Point of View
Preparing Distributions
‘make dist’ Create PACKAGE-VERSION.tar.gz .
‘make distcheck’ Likewise, with many sanity checks. Prefer this one!
‘make distcheck’ ensures most of the use cases presented so far work.
It tests VPATH builds (with read-only source tree)
It ensures ‘make clean’, ‘make distclean’, and ‘make uninstall’do not omit files,
It checks that DESTDIR installations work,
It runs the test suite (both ‘make check’ and ‘makeinstallcheck’).
Releasing a package that fails ‘make distcheck’ means releasing apackage that will disappoint many users.
A. Duret-Lutz Using GNU Autotools February 21, 2008 30 / 162
![Page 74: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/74.jpg)
Package Use Cases The Maintainer Point of View
Preparing Distributions
‘make dist’ Create PACKAGE-VERSION.tar.gz .
‘make distcheck’ Likewise, with many sanity checks. Prefer this one!
‘make distcheck’ ensures most of the use cases presented so far work.
It tests VPATH builds (with read-only source tree)
It ensures ‘make clean’, ‘make distclean’, and ‘make uninstall’do not omit files,
It checks that DESTDIR installations work,
It runs the test suite (both ‘make check’ and ‘makeinstallcheck’).
Releasing a package that fails ‘make distcheck’ means releasing apackage that will disappoint many users.
A. Duret-Lutz Using GNU Autotools February 21, 2008 30 / 162
![Page 75: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/75.jpg)
Package Use Cases The Maintainer Point of View
Automatic Dependency Tracking
~/amhello-1.0 % ./configure --prefix /usr
...checking dependency style of gcc... gcc3...
Dependency tracking is performed as a side-effect of compilation.Several methods are supported, and checked for by configure.(The gcc3 method above is the fastest.)
Dependency tracking is only needed when the source files change;it can be safely disabled for throw-away installation builds.Slow methods must be enabled explicitly.
‘--disable-dependency-tracking’ speed up one-time builds
‘--enable-dependency-tracking’ do not reject slow dependencyextractors
A. Duret-Lutz Using GNU Autotools February 21, 2008 31 / 162
![Page 76: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/76.jpg)
Package Use Cases The Maintainer Point of View
Automatic Dependency Tracking
~/amhello-1.0 % ./configure --prefix /usr
...checking dependency style of gcc... gcc3...
Dependency tracking is performed as a side-effect of compilation.Several methods are supported, and checked for by configure.(The gcc3 method above is the fastest.)
Dependency tracking is only needed when the source files change;it can be safely disabled for throw-away installation builds.Slow methods must be enabled explicitly.
‘--disable-dependency-tracking’ speed up one-time builds
‘--enable-dependency-tracking’ do not reject slow dependencyextractors
A. Duret-Lutz Using GNU Autotools February 21, 2008 31 / 162
![Page 77: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/77.jpg)
Package Use Cases The Maintainer Point of View
Nested Packages
Autoconfiscated packages can be nested to arbitrary depth.
A package can distribute a third-party library it uses in a subdirectory.It’s possible to gather many packages this way to distribute a set oftools.
For installers:
A single package to configure, build, and install.‘configure’ options are passed recursively to sub-packages.‘configure --help=recursive’ shows the help of all sub-packages.
For maintainers:
Easier integration.The sub-package is autonomous.
A. Duret-Lutz Using GNU Autotools February 21, 2008 32 / 162
![Page 78: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/78.jpg)
Package Use Cases The Maintainer Point of View
Nested Packages
Autoconfiscated packages can be nested to arbitrary depth.
A package can distribute a third-party library it uses in a subdirectory.It’s possible to gather many packages this way to distribute a set oftools.
For installers:
A single package to configure, build, and install.‘configure’ options are passed recursively to sub-packages.‘configure --help=recursive’ shows the help of all sub-packages.
For maintainers:
Easier integration.The sub-package is autonomous.
A. Duret-Lutz Using GNU Autotools February 21, 2008 32 / 162
![Page 79: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/79.jpg)
Package Use Cases The Maintainer Point of View
Nested Packages
Autoconfiscated packages can be nested to arbitrary depth.
A package can distribute a third-party library it uses in a subdirectory.It’s possible to gather many packages this way to distribute a set oftools.
For installers:
A single package to configure, build, and install.‘configure’ options are passed recursively to sub-packages.‘configure --help=recursive’ shows the help of all sub-packages.
For maintainers:
Easier integration.The sub-package is autonomous.
A. Duret-Lutz Using GNU Autotools February 21, 2008 32 / 162
![Page 80: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/80.jpg)
The configure Process
The configure Process
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 33 / 162
![Page 81: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/81.jpg)
The configure Process
The (simplified) configure process
Makefile.in src/Makefile.in config.h.in
configure
Makefile src/Makefile config.h
*.in files are configuration templates
from which configure generates the configuration files to use for building
A. Duret-Lutz Using GNU Autotools February 21, 2008 34 / 162
![Page 82: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/82.jpg)
The configure Process
The (simplified) configure process
Makefile.in src/Makefile.in config.h.in
configure
Makefile src/Makefile config.h
*.in files are configuration templatesfrom which configure generates the configuration files to use for building
A. Duret-Lutz Using GNU Autotools February 21, 2008 34 / 162
![Page 83: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/83.jpg)
The configure Process
The (real) configure process
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
configreconfiguration
A. Duret-Lutz Using GNU Autotools February 21, 2008 35 / 162
![Page 84: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/84.jpg)
The configure Process
The (real) configure process
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
config.log contains a trace of the configurationreconfiguration
A. Duret-Lutz Using GNU Autotools February 21, 2008 35 / 162
![Page 85: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/85.jpg)
The configure Process
The (real) configure process
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
config.status will actually process the templatesreconfiguration
A. Duret-Lutz Using GNU Autotools February 21, 2008 35 / 162
![Page 86: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/86.jpg)
The configure Process
The (real) configure process
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
config.status will actually process the templatesreconfiguration
A. Duret-Lutz Using GNU Autotools February 21, 2008 35 / 162
![Page 87: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/87.jpg)
The configure Process
The (real) configure process
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
‘configure -C’ caches results in config.cache to speed upreconfigurations
A. Duret-Lutz Using GNU Autotools February 21, 2008 35 / 162
![Page 88: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/88.jpg)
Why We Need Tools
Why We Need Tools
1 GoalsPortable PackagesUniform Builds
2 Package Use CasesThe User Point of ViewThe Power User Point of ViewThe Packager Point of ViewThe Maintainer Point of View
3 The configure Process
4 Why We Need Tools
A. Duret-Lutz Using GNU Autotools February 21, 2008 36 / 162
![Page 89: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/89.jpg)
Why We Need Tools
Why We Need Tools
If you try to mimic this build system by hand, you’ll discover that
The GNU Build System has a lot of features.Some users may expect features you do not use.
Implementing them portably is difficult, and exhausting.(Think portable shell scripts, portable Makefiles, on systems you maynot have handy.)
You will have to upgrade your setup to follow changes of the GNUCoding Standards.
GNU Autotools provide:
Tools to create the GNU Build System from simple instructions.
A central place where fixes and improvements are made.(A bug-fix for a portability issue benefits every package.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 37 / 162
![Page 90: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/90.jpg)
Why We Need Tools
Why We Need Tools
If you try to mimic this build system by hand, you’ll discover that
The GNU Build System has a lot of features.Some users may expect features you do not use.
Implementing them portably is difficult, and exhausting.(Think portable shell scripts, portable Makefiles, on systems you maynot have handy.)
You will have to upgrade your setup to follow changes of the GNUCoding Standards.
GNU Autotools provide:
Tools to create the GNU Build System from simple instructions.
A central place where fixes and improvements are made.(A bug-fix for a portability issue benefits every package.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 37 / 162
![Page 91: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/91.jpg)
Why We Need Tools
Why We Need Tools
If you try to mimic this build system by hand, you’ll discover that
The GNU Build System has a lot of features.Some users may expect features you do not use.
Implementing them portably is difficult, and exhausting.(Think portable shell scripts, portable Makefiles, on systems you maynot have handy.)
You will have to upgrade your setup to follow changes of the GNUCoding Standards.
GNU Autotools provide:
Tools to create the GNU Build System from simple instructions.
A central place where fixes and improvements are made.(A bug-fix for a portability issue benefits every package.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 37 / 162
![Page 92: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/92.jpg)
Why We Need Tools
Why We Need Tools
If you try to mimic this build system by hand, you’ll discover that
The GNU Build System has a lot of features.Some users may expect features you do not use.
Implementing them portably is difficult, and exhausting.(Think portable shell scripts, portable Makefiles, on systems you maynot have handy.)
You will have to upgrade your setup to follow changes of the GNUCoding Standards.
GNU Autotools provide:
Tools to create the GNU Build System from simple instructions.
A central place where fixes and improvements are made.(A bug-fix for a portability issue benefits every package.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 37 / 162
![Page 93: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/93.jpg)
Why We Need Tools
Why We Need Tools
If you try to mimic this build system by hand, you’ll discover that
The GNU Build System has a lot of features.Some users may expect features you do not use.
Implementing them portably is difficult, and exhausting.(Think portable shell scripts, portable Makefiles, on systems you maynot have handy.)
You will have to upgrade your setup to follow changes of the GNUCoding Standards.
GNU Autotools provide:
Tools to create the GNU Build System from simple instructions.
A central place where fixes and improvements are made.(A bug-fix for a portability issue benefits every package.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 37 / 162
![Page 94: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/94.jpg)
Why We Need Tools
Why We Need Tools
If you try to mimic this build system by hand, you’ll discover that
The GNU Build System has a lot of features.Some users may expect features you do not use.
Implementing them portably is difficult, and exhausting.(Think portable shell scripts, portable Makefiles, on systems you maynot have handy.)
You will have to upgrade your setup to follow changes of the GNUCoding Standards.
GNU Autotools provide:
Tools to create the GNU Build System from simple instructions.
A central place where fixes and improvements are made.(A bug-fix for a portability issue benefits every package.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 37 / 162
![Page 95: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/95.jpg)
Part II
GNU Autotools
5 Hello World
6 Introducing Core Autotools
7 Hello World Explained
8 Using Autoconf
9 Using Automake
A. Duret-Lutz Using GNU Autotools February 21, 2008 38 / 162
![Page 96: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/96.jpg)
Hello World
Hello World
5 Hello World
6 Introducing Core Autotools
7 Hello World Explained
8 Using Autoconf
9 Using Automake
A. Duret-Lutz Using GNU Autotools February 21, 2008 39 / 162
![Page 97: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/97.jpg)
Hello World
src/main.c for Hello World
src/main.c
#inc lude <c o n f i g . h>#inc lude <s t d i o . h>
i n tmain ( void ){
put s ( ” He l l o World ! ” ) ;put s ( ”Thi s i s ” PACKAGE STRING ” . ” ) ;return 0 ;
}
A. Duret-Lutz Using GNU Autotools February 21, 2008 40 / 162
![Page 98: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/98.jpg)
Hello World
Generating All Template Files
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
A. Duret-Lutz Using GNU Autotools February 21, 2008 41 / 162
![Page 99: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/99.jpg)
Hello World
Generating All Template Files
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
A. Duret-Lutz Using GNU Autotools February 21, 2008 41 / 162
![Page 100: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/100.jpg)
Hello World
Generating All Template Files
Makefile.in src/Makefile.in config.h.in
configure
‘autoreconf’
configure.ac Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 41 / 162
![Page 101: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/101.jpg)
Hello World
Generating All Template Files
Makefile.in src/Makefile.in config.h.in
configure
‘autoreconf’
configure.ac
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 41 / 162
![Page 102: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/102.jpg)
Hello World
Generating All Template Files
Makefile.in src/Makefile.in config.h.in
configure
‘autoreconf’
configure.ac Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 41 / 162
![Page 103: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/103.jpg)
Hello World
Autotools Inputs
configure.ac
AC INIT ( [ amhe l l o ] , [ 1 . 0 ] ,[ bug−r e p o r t@add r e s s ] )
AM INIT AUTOMAKE ( [−Wall −Werror f o r e i g n ] )
AC PROG CCAC CONFIG HEADERS ( [ c o n f i g . h ] )AC CONFIG FILES ( [
Make f i l es r c / Make f i l e
] )AC OUTPUT
Makefile.am
SUBDIRS = s r c
src/Makefile.am
bin PROGRAMS = h e l l ohello SOURCES = main . c
A. Duret-Lutz Using GNU Autotools February 21, 2008 42 / 162
![Page 104: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/104.jpg)
Hello World
Autotools Inputs
configure.ac
AC INIT ( [ amhe l l o ] , [ 1 . 0 ] ,[ bug−r e p o r t@add r e s s ] )
AM INIT AUTOMAKE ( [−Wall −Werror f o r e i g n ] )
AC PROG CCAC CONFIG HEADERS ( [ c o n f i g . h ] )AC CONFIG FILES ( [
Make f i l es r c / Make f i l e
] )AC OUTPUT
Makefile.am
SUBDIRS = s r c
src/Makefile.am
bin PROGRAMS = h e l l ohello SOURCES = main . c
A. Duret-Lutz Using GNU Autotools February 21, 2008 42 / 162
![Page 105: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/105.jpg)
Hello World
Autotools Inputs
configure.ac
AC INIT ( [ amhe l l o ] , [ 1 . 0 ] ,[ bug−r e p o r t@add r e s s ] )
AM INIT AUTOMAKE ( [−Wall −Werror f o r e i g n ] )
AC PROG CCAC CONFIG HEADERS ( [ c o n f i g . h ] )AC CONFIG FILES ( [
Make f i l es r c / Make f i l e
] )AC OUTPUT
Makefile.am
SUBDIRS = s r c
src/Makefile.am
bin PROGRAMS = h e l l ohello SOURCES = main . c
A. Duret-Lutz Using GNU Autotools February 21, 2008 42 / 162
![Page 106: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/106.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.ac src/
./src:Makefile.am main.c~/amhello %
autoreconf --install
configure.ac:4: installing ‘./install-sh’configure.ac:4: installing ‘./missing’src/Makefile.am: installing ‘./depcomp’~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 107: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/107.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.ac src/
./src:Makefile.am main.c~/amhello % autoreconf --install
configure.ac:4: installing ‘./install-sh’configure.ac:4: installing ‘./missing’src/Makefile.am: installing ‘./depcomp’~/amhello %
ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 108: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/108.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.ac src/
./src:Makefile.am main.c~/amhello % autoreconf --install
configure.ac:4: installing ‘./install-sh’configure.ac:4: installing ‘./missing’src/Makefile.am: installing ‘./depcomp’~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 109: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/109.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 110: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/110.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
expected configuration templates
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 111: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/111.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
definitions for third-party macrosused in configure.ac
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 112: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/112.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
auxiliary toolsused during the build
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 113: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/113.jpg)
Hello World
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
Autotools cache files
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 114: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/114.jpg)
Hello World
Preparing the Package
~/amhello % ./configure
checking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for gcc... gcc...checking dependency style of gcc... gcc3configure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating src/Makefileconfig.status: creating config.hconfig.status: executing depfiles commands~/amhello %
make
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 115: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/115.jpg)
Hello World
Preparing the Package
~/amhello % ./configure
checking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for gcc... gcc...checking dependency style of gcc... gcc3configure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating src/Makefileconfig.status: creating config.hconfig.status: executing depfiles commands~/amhello %
make
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 116: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/116.jpg)
Hello World
Preparing the Package
~/amhello % ./configure
checking for a BSD-compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking for gawk... gawkchecking whether make sets $(MAKE)... yeschecking for gcc... gcc...checking dependency style of gcc... gcc3configure: creating ./config.statusconfig.status: creating Makefileconfig.status: creating src/Makefileconfig.status: creating config.hconfig.status: executing depfiles commands~/amhello % make
...
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 117: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/117.jpg)
Hello World
Preparing the Package
~/amhello % src/hello
Hello World!This is amhello 1.0.~/amhello %
make distcheck
...========================================amhello archives ready for distribution:amhello-1.0.tar.gz========================================~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 118: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/118.jpg)
Hello World
Preparing the Package
~/amhello % src/hello
Hello World!This is amhello 1.0.~/amhello % make distcheck
...========================================amhello archives ready for distribution:amhello-1.0.tar.gz========================================~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 119: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/119.jpg)
Hello World
Preparing the Package
~/amhello % tar ztf amhello-1.0.tar.gz
amhello-1.0/amhello-1.0/Makefile.amamhello-1.0/Makefile.inamhello-1.0/aclocal.m4amhello-1.0/config.h.inamhello-1.0/configureamhello-1.0/configure.acamhello-1.0/depcompamhello-1.0/install-shamhello-1.0/missingamhello-1.0/src/amhello-1.0/src/Makefile.amamhello-1.0/src/Makefile.inamhello-1.0/src/main.c~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 43 / 162
![Page 120: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/120.jpg)
Introducing Core Autotools
Introducing Core Autotools
5 Hello World
6 Introducing Core Autotools
7 Hello World Explained
8 Using Autoconf
9 Using Automake
A. Duret-Lutz Using GNU Autotools February 21, 2008 44 / 162
![Page 121: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/121.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 122: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/122.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 123: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/123.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 124: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/124.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 125: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/125.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 126: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/126.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 127: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/127.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 128: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/128.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 129: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/129.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 130: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/130.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 131: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/131.jpg)
Introducing Core Autotools
Two Core Packages
GNU Autoconf
‘autoconf’ Create configure from configure.ac .
‘autoheader’ Create config.h.in from configure.ac .
‘autoreconf’ Run all tools in the right order.
‘autoscan’ Scan sources for common portability problems,and related macros missing from configure.ac .
‘autoupdate’ Update obsolete macros in configure.ac .
‘ifnames’ Gather identifiers from all #if/#ifdef/... directives.
‘autom4te’ The heart of Autoconf. It drives M4 and implements thefeatures used by most of the above tools. Useful forcreating more than just configure files.
GNU Automake
‘automake’ Create Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scan configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
A. Duret-Lutz Using GNU Autotools February 21, 2008 45 / 162
![Page 132: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/132.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 133: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/133.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 134: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/134.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 135: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/135.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 136: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/136.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 137: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/137.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 138: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/138.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 139: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/139.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 140: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/140.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 141: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/141.jpg)
Introducing Core Autotools
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 46 / 162
![Page 142: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/142.jpg)
Introducing Core Autotools
‘autoreconf’ is Your Friend
In practice,
You do not have to remember the interaction of all tools.
Use ‘autoreconf --install’ to setup the package initially.
Rely on the rebuild rules (output in Makefiles) to rerun the rightautotool when you change some input file.
You only need a rough idea of the purpose of each tool to understanderrors. (What tool complains and about what?)
‘autoconf’ Creates configure from configure.ac .
‘autoheader’ Creates config.h.in from configure.ac .
‘automake’ Creates Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scans configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
‘autom4te’ Autoconf driver for M4. All tools that process configure.acdo so through ‘autom4te’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 47 / 162
![Page 143: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/143.jpg)
Introducing Core Autotools
‘autoreconf’ is Your Friend
In practice,
You do not have to remember the interaction of all tools.
Use ‘autoreconf --install’ to setup the package initially.
Rely on the rebuild rules (output in Makefiles) to rerun the rightautotool when you change some input file.
You only need a rough idea of the purpose of each tool to understanderrors. (What tool complains and about what?)
‘autoconf’ Creates configure from configure.ac .
‘autoheader’ Creates config.h.in from configure.ac .
‘automake’ Creates Makefile.ins from Makefile.ams and configure.ac .
‘aclocal’ Scans configure.ac for uses of third-party macros, andgather definitions in aclocal.m4 .
‘autom4te’ Autoconf driver for M4. All tools that process configure.acdo so through ‘autom4te’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 47 / 162
![Page 144: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/144.jpg)
Hello World Explained
Hello World Explained
5 Hello World
6 Introducing Core Autotools
7 Hello World Explained
8 Using Autoconf
9 Using Automake
A. Duret-Lutz Using GNU Autotools February 21, 2008 48 / 162
![Page 145: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/145.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.Check for a C compiler.Declare config.h as output header.Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 49 / 162
![Page 146: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/146.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.
Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.Check for a C compiler.Declare config.h as output header.Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 49 / 162
![Page 147: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/147.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.
Check for a C compiler.Declare config.h as output header.Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 49 / 162
![Page 148: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/148.jpg)
Hello World Explained
foreign Ignores some GNU Coding Standards
configure.ac...AM_INIT_AUTOMAKE([-Wall -Werror foreign])...
~/amhello % autoreconf --install
configure.ac:2: installing ‘./install-sh’configure.ac:2: installing ‘./missing’src/Makefile.am: installing ‘./depcomp’
Makefile.am: installing ‘./INSTALL’Makefile.am: required file ‘./NEWS’ not foundMakefile.am: required file ‘./README’ not foundMakefile.am: required file ‘./AUTHORS’ not foundMakefile.am: required file ‘./ChangeLog’ not foundMakefile.am: installing ‘./COPYING’autoreconf: automake failed with exit status: 1
A. Duret-Lutz Using GNU Autotools February 21, 2008 50 / 162
![Page 149: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/149.jpg)
Hello World Explained
foreign Ignores some GNU Coding Standards
configure.ac without the foreign option...AM_INIT_AUTOMAKE([-Wall -Werror])...
~/amhello % autoreconf --install
configure.ac:2: installing ‘./install-sh’configure.ac:2: installing ‘./missing’src/Makefile.am: installing ‘./depcomp’Makefile.am: installing ‘./INSTALL’Makefile.am: required file ‘./NEWS’ not foundMakefile.am: required file ‘./README’ not foundMakefile.am: required file ‘./AUTHORS’ not foundMakefile.am: required file ‘./ChangeLog’ not foundMakefile.am: installing ‘./COPYING’autoreconf: automake failed with exit status: 1
A. Duret-Lutz Using GNU Autotools February 21, 2008 50 / 162
![Page 150: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/150.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.
Check for a C compiler.Declare config.h as output header.Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 51 / 162
![Page 151: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/151.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.Check for a C compiler.
Declare config.h as output header.Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 51 / 162
![Page 152: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/152.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.Check for a C compiler.Declare config.h as output header.
Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 51 / 162
![Page 153: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/153.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.Check for a C compiler.Declare config.h as output header.Declare Makefile and src/Makefile as output files.
Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 51 / 162
![Page 154: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/154.jpg)
Hello World Explained
amhello’s configure.ac explained
configure.ac
AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Initialize Autoconf. Specify package’s name, version number, andbug-report address.Initialize Automake. Turn on all Automake warnings and report themas errors. This is a foreign package.Check for a C compiler.Declare config.h as output header.Declare Makefile and src/Makefile as output files.Actually output all declared files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 51 / 162
![Page 155: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/155.jpg)
Hello World Explained
amhello’s Makefile.am explained
Makefile.amSUBDIRS = src
Build recursively in src/ .
Nothing else is declared for the current directory.(The top-level Makefile.am is usually short.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 52 / 162
![Page 156: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/156.jpg)
Hello World Explained
amhello’s Makefile.am explained
Makefile.amSUBDIRS = src
Build recursively in src/ .
Nothing else is declared for the current directory.(The top-level Makefile.am is usually short.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 52 / 162
![Page 157: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/157.jpg)
Hello World Explained
amhello’s src/Makefile.am explained
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c
We are building some programs.
These programs will be installed in bindir.
There is only one program to build: hello.
To create hello, just compile main.c .
A. Duret-Lutz Using GNU Autotools February 21, 2008 53 / 162
![Page 158: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/158.jpg)
Hello World Explained
amhello’s src/Makefile.am explained
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c
We are building some programs.
These programs will be installed in bindir.
There is only one program to build: hello.
To create hello, just compile main.c .
A. Duret-Lutz Using GNU Autotools February 21, 2008 53 / 162
![Page 159: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/159.jpg)
Hello World Explained
Standard File System Hierarchy
Directory variable Default valueprefix /usr/ local
exec-prefix prefixbindir exec-prefix/binlibdir exec-prefix/lib...
includedir prefix/includedatarootdir prefix/share
datadir datarootdirmandir datarootdir/maninfodir datarootdir/info
...
~/amhello-1.0 % ./configure --prefix ~/usr
~/amhello-1.0 % make
~/amhello-1.0 % make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 54 / 162
![Page 160: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/160.jpg)
Hello World Explained
amhello’s src/Makefile.am explained
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c
We are building some programs.
These programs will be installed in bindir.
There is only one program to build: hello.
To create hello, just compile main.c .
A. Duret-Lutz Using GNU Autotools February 21, 2008 55 / 162
![Page 161: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/161.jpg)
Hello World Explained
amhello’s src/Makefile.am explained
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c
We are building some programs.
These programs will be installed in bindir.
There is only one program to build: hello.
To create hello, just compile main.c .
A. Duret-Lutz Using GNU Autotools February 21, 2008 55 / 162
![Page 162: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/162.jpg)
Hello World Explained
amhello’s src/Makefile.am explained
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c
We are building some programs.
These programs will be installed in bindir.
There is only one program to build: hello.
To create hello, just compile main.c .
A. Duret-Lutz Using GNU Autotools February 21, 2008 55 / 162
![Page 163: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/163.jpg)
Using Autoconf
Using Autoconf
5 Hello World
6 Introducing Core Autotools
7 Hello World Explained
8 Using Autoconf
9 Using Automake
A. Duret-Lutz Using GNU Autotools February 21, 2008 56 / 162
![Page 164: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/164.jpg)
Using Autoconf
From configure.ac to configure and config.h.in
‘autoconf’ is a macro processor.
It converts configure.ac , which is a shell script using macroinstructions, into configure, a full-fledged shell script.
Autoconf offers many macros to perform common configurationchecks.
It is not uncommon to have a configure.ac without shell constructs,using only macros.
While processing configure.ac it is also possible to trace theoccurrences of macros. This is how ‘autoheader’ creates config.h.in.It just looks for the macros that #define symbols.
The real macro processor actually is GNU M4. Autoconf offers someinfrastructure on top of that, plus the pool of macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 57 / 162
![Page 165: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/165.jpg)
Using Autoconf
From configure.ac to configure and config.h.in
‘autoconf’ is a macro processor.
It converts configure.ac , which is a shell script using macroinstructions, into configure, a full-fledged shell script.
Autoconf offers many macros to perform common configurationchecks.
It is not uncommon to have a configure.ac without shell constructs,using only macros.
While processing configure.ac it is also possible to trace theoccurrences of macros. This is how ‘autoheader’ creates config.h.in.It just looks for the macros that #define symbols.
The real macro processor actually is GNU M4. Autoconf offers someinfrastructure on top of that, plus the pool of macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 57 / 162
![Page 166: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/166.jpg)
Using Autoconf
From configure.ac to configure and config.h.in
‘autoconf’ is a macro processor.
It converts configure.ac , which is a shell script using macroinstructions, into configure, a full-fledged shell script.
Autoconf offers many macros to perform common configurationchecks.
It is not uncommon to have a configure.ac without shell constructs,using only macros.
While processing configure.ac it is also possible to trace theoccurrences of macros. This is how ‘autoheader’ creates config.h.in.It just looks for the macros that #define symbols.
The real macro processor actually is GNU M4. Autoconf offers someinfrastructure on top of that, plus the pool of macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 57 / 162
![Page 167: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/167.jpg)
Using Autoconf
From configure.ac to configure and config.h.in
‘autoconf’ is a macro processor.
It converts configure.ac , which is a shell script using macroinstructions, into configure, a full-fledged shell script.
Autoconf offers many macros to perform common configurationchecks.
It is not uncommon to have a configure.ac without shell constructs,using only macros.
While processing configure.ac it is also possible to trace theoccurrences of macros. This is how ‘autoheader’ creates config.h.in.It just looks for the macros that #define symbols.
The real macro processor actually is GNU M4. Autoconf offers someinfrastructure on top of that, plus the pool of macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 57 / 162
![Page 168: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/168.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ %
m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 169: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/169.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 170: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/170.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 171: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/171.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 172: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/172.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 173: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/173.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 174: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/174.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 175: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/175.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 176: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/176.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 177: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/177.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 178: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/178.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 179: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/179.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 180: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/180.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 181: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/181.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(NAME1, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 182: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/182.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 183: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/183.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 184: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/184.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, NAME2)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 185: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/185.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Sally)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 186: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/186.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Sally)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 187: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/187.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Sally)
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 188: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/188.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Sally
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 189: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/189.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Sally
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 190: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/190.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Sally
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 191: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/191.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Sally
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 192: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/192.jpg)
Using Autoconf
Discovering M4
example.m4
m4_define(NAME1, Harry)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Sally
~ % m4 -P example.m4
Harry met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 58 / 162
![Page 193: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/193.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 194: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/194.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 195: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/195.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 196: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/196.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 197: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/197.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 198: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/198.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 199: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/199.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 200: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/200.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 201: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/201.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 202: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/202.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 203: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/203.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 204: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/204.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(NAME2, Sally)m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 205: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/205.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 206: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/206.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 207: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/207.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 208: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/208.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 209: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/209.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 210: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/210.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(NAME1, NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 211: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/211.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 212: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/212.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 213: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/213.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 214: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/214.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., NAME2)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 215: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/215.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., Sally)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 216: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/216.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., Sally)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 217: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/217.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(Harry, Jr., Sally)
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 218: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/218.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Jr.
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 219: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/219.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Jr.
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 220: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/220.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Jr.
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 221: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/221.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Jr.
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 222: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/222.jpg)
Using Autoconf
M4 Quoting
The macro’s arguments are processed
Then the macro is expanded
Finally the output of the macro is processed too
A string can be protected from processing using quotes.
This is a source of many mistakes for the unwary.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry met Jr.
Can you guess the output of the above?
A. Duret-Lutz Using GNU Autotools February 21, 2008 59 / 162
![Page 223: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/223.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 224: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/224.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 225: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/225.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 226: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/226.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 227: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/227.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 228: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/228.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 229: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/229.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 230: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/230.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(NAME2, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 231: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/231.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)
m4_define(NAME2, Sally)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 232: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/232.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 233: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/233.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 234: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/234.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)
m4_define(MET, $1 met $2)MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 235: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/235.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(‘NAME1’, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 236: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/236.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(NAME1, ‘NAME2’)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 237: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/237.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
MET(NAME1, NAME2)
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 238: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/238.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
NAME1 met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 239: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/239.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
NAME1 met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 240: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/240.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 241: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/241.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 242: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/242.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 243: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/243.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 244: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/244.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met NAME2
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 245: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/245.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 246: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/246.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 247: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/247.jpg)
Using Autoconf
M4 Quoting Rule of the Thumb
Quote each macro argument once.
So it is processed only after it has been output.
example.m4
m4_define(NAME1, Harry, Jr.)m4_define(NAME2, Sally)m4_define(MET, $1 met $2)
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 60 / 162
![Page 248: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/248.jpg)
Using Autoconf
Spacing Matters
The parenthesis must stick to the macro name.
Spaces after or inside quotes are part of the arguments.
Spaces before quotes are ignored.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘NAME1’, ‘NAME2’)
~ % m4 -P example.m4
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 61 / 162
![Page 249: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/249.jpg)
Using Autoconf
Spacing Matters
The parenthesis must stick to the macro name.
Spaces after or inside quotes are part of the arguments.
Spaces before quotes are ignored.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET (‘NAME1’, ‘NAME2’)
~ % m4 -P example.m4
met (NAME1, NAME2)
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 61 / 162
![Page 250: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/250.jpg)
Using Autoconf
Spacing Matters
The parenthesis must stick to the macro name.
Spaces after or inside quotes are part of the arguments.
Spaces before quotes are ignored.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET(‘ NAME1 ’ , ‘NAME2’)
~ % m4 -P example.m4
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 61 / 162
![Page 251: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/251.jpg)
Using Autoconf
Spacing Matters
The parenthesis must stick to the macro name.
Spaces after or inside quotes are part of the arguments.
Spaces before quotes are ignored.
example.m4
m4_define(‘NAME1’, ‘Harry, Jr.’)m4_define(‘NAME2’, ‘Sally’)m4_define(‘MET’, ‘$1 met $2’)MET( ‘NAME1’, ‘NAME2’)
~ % m4 -P example.m4
Harry, Jr. met Sally
A. Duret-Lutz Using GNU Autotools February 21, 2008 61 / 162
![Page 252: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/252.jpg)
Using Autoconf
Autoconf on Top of M4
Autoconf = M4 with more machinery, and many predefined macros.
The quotes are [ and ] (instead of ‘ and ’).
For this reason we use the test command instead of [ in shellfragments:
if [ "$x" = "$y" ]; then ...
Macros are defined with AC DEFUN.
AC_DEFUN([NAME1], [Harry, Jr.])AC_DEFUN([NAME2], [Sally])AC_DEFUN([MET], [$1 met $2])MET([NAME1], [NAME2])
A. Duret-Lutz Using GNU Autotools February 21, 2008 62 / 162
![Page 253: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/253.jpg)
Using Autoconf
Autoconf on Top of M4
Autoconf = M4 with more machinery, and many predefined macros.
The quotes are [ and ] (instead of ‘ and ’).
For this reason we use the test command instead of [ in shellfragments:
if [ "$x" = "$y" ]; then ...
Macros are defined with AC DEFUN.
AC_DEFUN([NAME1], [Harry, Jr.])AC_DEFUN([NAME2], [Sally])AC_DEFUN([MET], [$1 met $2])MET([NAME1], [NAME2])
A. Duret-Lutz Using GNU Autotools February 21, 2008 62 / 162
![Page 254: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/254.jpg)
Using Autoconf
Autoconf on Top of M4
Autoconf = M4 with more machinery, and many predefined macros.
The quotes are [ and ] (instead of ‘ and ’).
For this reason we use the test command instead of [ in shellfragments:
if [ "$x" = "$y" ]; then ...
Macros are defined with AC DEFUN.
AC_DEFUN([NAME1], [Harry, Jr.])AC_DEFUN([NAME2], [Sally])AC_DEFUN([MET], [$1 met $2])MET([NAME1], [NAME2])
A. Duret-Lutz Using GNU Autotools February 21, 2008 62 / 162
![Page 255: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/255.jpg)
Using Autoconf
Autoconf on Top of M4
Autoconf = M4 with more machinery, and many predefined macros.
The quotes are [ and ] (instead of ‘ and ’).
For this reason we use the test command instead of [ in shellfragments:
if test "$x" = "$y"; then ...
Macros are defined with AC DEFUN.
AC_DEFUN([NAME1], [Harry, Jr.])AC_DEFUN([NAME2], [Sally])AC_DEFUN([MET], [$1 met $2])MET([NAME1], [NAME2])
A. Duret-Lutz Using GNU Autotools February 21, 2008 62 / 162
![Page 256: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/256.jpg)
Using Autoconf
Autoconf on Top of M4
Autoconf = M4 with more machinery, and many predefined macros.
The quotes are [ and ] (instead of ‘ and ’).
For this reason we use the test command instead of [ in shellfragments:
if test "$x" = "$y"; then ...
Macros are defined with AC DEFUN.
AC_DEFUN([NAME1], [Harry, Jr.])AC_DEFUN([NAME2], [Sally])AC_DEFUN([MET], [$1 met $2])MET([NAME1], [NAME2])
A. Duret-Lutz Using GNU Autotools February 21, 2008 62 / 162
![Page 257: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/257.jpg)
Using Autoconf
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([PACKAGE], [VERSION], [BUG-REPORT-ADDRESS])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([FILES])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 63 / 162
![Page 258: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/258.jpg)
Using Autoconf
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([amhello], [1.0], [bug-report@address])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([FILES])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 63 / 162
![Page 259: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/259.jpg)
Using Autoconf
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])# Checks for programs.
AC_PROG_CC
# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([FILES])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 63 / 162
![Page 260: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/260.jpg)
Using Autoconf
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])# Checks for programs.AC_PROG_CC# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([FILES])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 63 / 162
![Page 261: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/261.jpg)
Using Autoconf
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])# Checks for programs.AC_PROG_CC# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 63 / 162
![Page 262: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/262.jpg)
Using Autoconf
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])# Checks for programs.AC_PROG_CC# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.AC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 63 / 162
![Page 263: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/263.jpg)
Using Autoconf
Useful Autoconf Macros for Prelude
AC INIT(PACKAGE, VERSION, BUG-REPORT-ADDRESS)Mandatory Autoconf initialization.
AC PREREQ(VERSION)Require a minimum Autoconf version. E.g. AC PREREQ([2.61])
AC CONFIG SRCDIR(FILE)A safety check. FILE should be a distributed source file, and thismakes sure that ‘configure’ is not run from outer space. E.g.AC CONFIG SRCDIR([src/main.c]).
AC CONFIG AUX DIR(DIRECTORY)Auxiliary scripts such as install-sh and depcomp should be inDIRECTORY. E.g. AC CONFIG AUX DIR([build-aux]).
A. Duret-Lutz Using GNU Autotools February 21, 2008 64 / 162
![Page 264: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/264.jpg)
Using Autoconf
Useful Autoconf Macros for Prelude
AC INIT(PACKAGE, VERSION, BUG-REPORT-ADDRESS)Mandatory Autoconf initialization.
AC PREREQ(VERSION)Require a minimum Autoconf version. E.g. AC PREREQ([2.61])
AC CONFIG SRCDIR(FILE)A safety check. FILE should be a distributed source file, and thismakes sure that ‘configure’ is not run from outer space. E.g.AC CONFIG SRCDIR([src/main.c]).
AC CONFIG AUX DIR(DIRECTORY)Auxiliary scripts such as install-sh and depcomp should be inDIRECTORY. E.g. AC CONFIG AUX DIR([build-aux]).
A. Duret-Lutz Using GNU Autotools February 21, 2008 64 / 162
![Page 265: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/265.jpg)
Using Autoconf
Useful Autoconf Macros for Prelude
AC INIT(PACKAGE, VERSION, BUG-REPORT-ADDRESS)Mandatory Autoconf initialization.
AC PREREQ(VERSION)Require a minimum Autoconf version. E.g. AC PREREQ([2.61])
AC CONFIG SRCDIR(FILE)A safety check. FILE should be a distributed source file, and thismakes sure that ‘configure’ is not run from outer space. E.g.AC CONFIG SRCDIR([src/main.c]).
AC CONFIG AUX DIR(DIRECTORY)Auxiliary scripts such as install-sh and depcomp should be inDIRECTORY. E.g. AC CONFIG AUX DIR([build-aux]).
A. Duret-Lutz Using GNU Autotools February 21, 2008 64 / 162
![Page 266: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/266.jpg)
Using Autoconf
Useful Autoconf Macros for Prelude
AC INIT(PACKAGE, VERSION, BUG-REPORT-ADDRESS)Mandatory Autoconf initialization.
AC PREREQ(VERSION)Require a minimum Autoconf version. E.g. AC PREREQ([2.61])
AC CONFIG SRCDIR(FILE)A safety check. FILE should be a distributed source file, and thismakes sure that ‘configure’ is not run from outer space. E.g.AC CONFIG SRCDIR([src/main.c]).
AC CONFIG AUX DIR(DIRECTORY)Auxiliary scripts such as install-sh and depcomp should be inDIRECTORY. E.g. AC CONFIG AUX DIR([build-aux]).
A. Duret-Lutz Using GNU Autotools February 21, 2008 64 / 162
![Page 267: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/267.jpg)
Using Autoconf
Preparing the Package
~/amhello % ls -R
.:Makefile.am configure.acMakefile.in depcomp*aclocal.m4 install-sh*autom4te.cache/ missing*config.h.in src/configure*
./autom4te.cache:output.0 requests traces.1output.1 traces.0
./src:Makefile.am Makefile.in main.c
auxiliary toolsused during the build
A. Duret-Lutz Using GNU Autotools February 21, 2008 65 / 162
![Page 268: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/268.jpg)
Using Autoconf
AC CONFIG AUX DIR Example
configure.ac
AC_INIT([amhello], [1.1], [bug-report@address])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
% autoreconf --install
configure.ac:3: installing ‘missing’configure.ac:3: installing ‘install-sh’src/Makefile.am: installing ‘depcomp’
A. Duret-Lutz Using GNU Autotools February 21, 2008 66 / 162
![Page 269: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/269.jpg)
Using Autoconf
AC CONFIG AUX DIR Example
configure.ac
AC_INIT([amhello], [1.1], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
% autoreconf --install
configure.ac:3: installing ‘build-aux/missing’configure.ac:3: installing ‘build-aux/install-sh’src/Makefile.am: installing ‘build-aux/depcomp’
A. Duret-Lutz Using GNU Autotools February 21, 2008 66 / 162
![Page 270: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/270.jpg)
Using Autoconf
Useful Program Checks
AC PROG CC, AC PROG CXX, AC PROG F77, ...Compiler checks. (Handle search cross-compilers if needed.)
AC PROG SED, AC PROG YACC, AC PROG LEX, ...Find good implementations and set $SED, $YACC, $LEX, etc.
AC CHECK PROGS(VAR, PROGS, [VAL-IF-NOT-FOUND])Define VAR to the first PROGS found, or to VAL-IF-NOT-FOUNDotherwise.
AC_CHECK_PROGS([TAR], [tar gtar], [:])if test "$TAR" = :; thenAC_MSG_ERROR([This package needs tar.])
fi
... and many more
A. Duret-Lutz Using GNU Autotools February 21, 2008 67 / 162
![Page 271: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/271.jpg)
Using Autoconf
Useful Program Checks
AC PROG CC, AC PROG CXX, AC PROG F77, ...Compiler checks. (Handle search cross-compilers if needed.)
AC PROG SED, AC PROG YACC, AC PROG LEX, ...Find good implementations and set $SED, $YACC, $LEX, etc.
AC CHECK PROGS(VAR, PROGS, [VAL-IF-NOT-FOUND])Define VAR to the first PROGS found, or to VAL-IF-NOT-FOUNDotherwise.
AC_CHECK_PROGS([TAR], [tar gtar], [:])if test "$TAR" = :; thenAC_MSG_ERROR([This package needs tar.])
fi
... and many more
A. Duret-Lutz Using GNU Autotools February 21, 2008 67 / 162
![Page 272: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/272.jpg)
Using Autoconf
Useful Program Checks
AC PROG CC, AC PROG CXX, AC PROG F77, ...Compiler checks. (Handle search cross-compilers if needed.)
AC PROG SED, AC PROG YACC, AC PROG LEX, ...Find good implementations and set $SED, $YACC, $LEX, etc.
AC CHECK PROGS(VAR, PROGS, [VAL-IF-NOT-FOUND])Define VAR to the first PROGS found, or to VAL-IF-NOT-FOUNDotherwise.
AC_CHECK_PROGS([TAR], [tar gtar], [:])if test "$TAR" = :; thenAC_MSG_ERROR([This package needs tar.])
fi
... and many more
A. Duret-Lutz Using GNU Autotools February 21, 2008 67 / 162
![Page 273: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/273.jpg)
Using Autoconf
Useful Program Checks
AC PROG CC, AC PROG CXX, AC PROG F77, ...Compiler checks. (Handle search cross-compilers if needed.)
AC PROG SED, AC PROG YACC, AC PROG LEX, ...Find good implementations and set $SED, $YACC, $LEX, etc.
AC CHECK PROGS(VAR, PROGS, [VAL-IF-NOT-FOUND])Define VAR to the first PROGS found, or to VAL-IF-NOT-FOUNDotherwise.
AC_CHECK_PROGS([TAR], [tar gtar], [:])if test "$TAR" = :; thenAC_MSG_ERROR([This package needs tar.])
fi
... and many more
A. Duret-Lutz Using GNU Autotools February 21, 2008 67 / 162
![Page 274: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/274.jpg)
Using Autoconf
Useful Autoconf Action Macros
AC MSG ERROR(ERROR-DESCRIPTION, [EXIT-STATUS])Print ERROR-DESCRIPTION (also to config.log) and abort‘configure’.
AC MSG WARN(ERROR-DESCRIPTION)Likewise, but don’t abort.
AC DEFINE(VARIABLE, VALUE, DESCRIPTION)Output the following to config.h.
/* DESCRIPTION */#define VARIABLE VALUE
AC SUBST(VARIABLE, [VALUE])Define $(VARIABLE) as VALUE in Makefile.
AC_SUBST([FOO], [foo])FOO=fooAC_SUBST([FOO])
AC_SUBST([FOO])FOO=foo
All equivalent.
A. Duret-Lutz Using GNU Autotools February 21, 2008 68 / 162
![Page 275: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/275.jpg)
Using Autoconf
Useful Autoconf Action Macros
AC MSG ERROR(ERROR-DESCRIPTION, [EXIT-STATUS])Print ERROR-DESCRIPTION (also to config.log) and abort‘configure’.
AC MSG WARN(ERROR-DESCRIPTION)Likewise, but don’t abort.
AC DEFINE(VARIABLE, VALUE, DESCRIPTION)Output the following to config.h.
/* DESCRIPTION */#define VARIABLE VALUE
AC SUBST(VARIABLE, [VALUE])Define $(VARIABLE) as VALUE in Makefile.
AC_SUBST([FOO], [foo])FOO=fooAC_SUBST([FOO])
AC_SUBST([FOO])FOO=foo
All equivalent.
A. Duret-Lutz Using GNU Autotools February 21, 2008 68 / 162
![Page 276: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/276.jpg)
Using Autoconf
Useful Autoconf Action Macros
AC MSG ERROR(ERROR-DESCRIPTION, [EXIT-STATUS])Print ERROR-DESCRIPTION (also to config.log) and abort‘configure’.
AC MSG WARN(ERROR-DESCRIPTION)Likewise, but don’t abort.
AC DEFINE(VARIABLE, VALUE, DESCRIPTION)Output the following to config.h.
/* DESCRIPTION */#define VARIABLE VALUE
AC SUBST(VARIABLE, [VALUE])Define $(VARIABLE) as VALUE in Makefile.
AC_SUBST([FOO], [foo])FOO=fooAC_SUBST([FOO])
AC_SUBST([FOO])FOO=foo
All equivalent.
A. Duret-Lutz Using GNU Autotools February 21, 2008 68 / 162
![Page 277: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/277.jpg)
Using Autoconf
Checking for Libraries
AC CHECK LIB(LIBRARY, FUNCT, [ACT-IF-FOUND], [ACT-IF-NOT])
Check whether LIBRARY exists and contains FUNCT.Execute ACT-IF-FOUND if it does, ACT-IF-NOT otherwise.
AC_CHECK_LIB([efence], [malloc], [EFENCELIB=-lefence])AC_SUBST([EFENCELIB])
... we would later use $(EFENCELIB) in the link rule.
If ACT-IF-FOUND is not set and the library is found, AC CHECK LIBwill do LIBS="-lLIBRARY $LIBS" and #define HAVE LIBLIBRARY.(Automake uses $LIBS for linking everything.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 69 / 162
![Page 278: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/278.jpg)
Using Autoconf
Checking for Libraries
AC CHECK LIB(LIBRARY, FUNCT, [ACT-IF-FOUND], [ACT-IF-NOT])
Check whether LIBRARY exists and contains FUNCT.Execute ACT-IF-FOUND if it does, ACT-IF-NOT otherwise.
AC_CHECK_LIB([efence], [malloc], [EFENCELIB=-lefence])AC_SUBST([EFENCELIB])
... we would later use $(EFENCELIB) in the link rule.
If ACT-IF-FOUND is not set and the library is found, AC CHECK LIBwill do LIBS="-lLIBRARY $LIBS" and #define HAVE LIBLIBRARY.(Automake uses $LIBS for linking everything.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 69 / 162
![Page 279: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/279.jpg)
Using Autoconf
Checking for Libraries
AC CHECK LIB(LIBRARY, FUNCT, [ACT-IF-FOUND], [ACT-IF-NOT])
Check whether LIBRARY exists and contains FUNCT.Execute ACT-IF-FOUND if it does, ACT-IF-NOT otherwise.
AC_CHECK_LIB([efence], [malloc], [EFENCELIB=-lefence])AC_SUBST([EFENCELIB])
... we would later use $(EFENCELIB) in the link rule.
If ACT-IF-FOUND is not set and the library is found, AC CHECK LIBwill do LIBS="-lLIBRARY $LIBS" and #define HAVE LIBLIBRARY.(Automake uses $LIBS for linking everything.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 69 / 162
![Page 280: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/280.jpg)
Using Autoconf
Checking for Headers
AC CHECK HEADERS(HEADERS...)Check for HEADERS and #define HAVE HEADER H for each headerfound.
AC_CHECK_HEADERS([sys/param.h unistd.h])AC_CHECK_HEADERS([wchar.h])
Might #define HAVE SYS PARAM H, HAVE UNISTD H, andHAVE WCHAR H.
#i f HAVE UNISTD H# inc lude <un i s t d . h>#end i f
AC CHECK HEADER(HEADER, [ACT-IF-FOUND], [ACT-IF-NOT])Check only one header.
A. Duret-Lutz Using GNU Autotools February 21, 2008 70 / 162
![Page 281: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/281.jpg)
Using Autoconf
Checking for Headers
AC CHECK HEADERS(HEADERS...)Check for HEADERS and #define HAVE HEADER H for each headerfound.
AC_CHECK_HEADERS([sys/param.h unistd.h])AC_CHECK_HEADERS([wchar.h])
Might #define HAVE SYS PARAM H, HAVE UNISTD H, andHAVE WCHAR H.
#i f HAVE UNISTD H# inc lude <un i s t d . h>#end i f
AC CHECK HEADER(HEADER, [ACT-IF-FOUND], [ACT-IF-NOT])Check only one header.
A. Duret-Lutz Using GNU Autotools February 21, 2008 70 / 162
![Page 282: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/282.jpg)
Using Autoconf
Checking for Headers
AC CHECK HEADERS(HEADERS...)Check for HEADERS and #define HAVE HEADER H for each headerfound.
AC_CHECK_HEADERS([sys/param.h unistd.h])AC_CHECK_HEADERS([wchar.h])
Might #define HAVE SYS PARAM H, HAVE UNISTD H, andHAVE WCHAR H.
#i f HAVE UNISTD H# inc lude <un i s t d . h>#end i f
AC CHECK HEADER(HEADER, [ACT-IF-FOUND], [ACT-IF-NOT])Check only one header.
A. Duret-Lutz Using GNU Autotools February 21, 2008 70 / 162
![Page 283: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/283.jpg)
Using Autoconf
Checking for Headers
AC CHECK HEADERS(HEADERS...)Check for HEADERS and #define HAVE HEADER H for each headerfound.
AC_CHECK_HEADERS([sys/param.h unistd.h])AC_CHECK_HEADERS([wchar.h])
Might #define HAVE SYS PARAM H, HAVE UNISTD H, andHAVE WCHAR H.
#i f HAVE UNISTD H# inc lude <un i s t d . h>#end i f
AC CHECK HEADER(HEADER, [ACT-IF-FOUND], [ACT-IF-NOT])Check only one header.
A. Duret-Lutz Using GNU Autotools February 21, 2008 70 / 162
![Page 284: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/284.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h])
Will create config.h from config.h.in
(DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 285: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/285.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h])
Will create config.h from config.h.in
(DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 286: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/286.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h:config.hin])
Will create config.h from config.hin (DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 287: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/287.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h:config.hin])
Will create config.h from config.hin (DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 288: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/288.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h:config.hin])
Will create config.h from config.hin (DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 289: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/289.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h:config.hin])
Will create config.h from config.hin (DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.
It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 290: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/290.jpg)
Using Autoconf
Output Commands
AC CONFIG HEADERS(HEADERS...)Create HEADER for all HEADER.in. Use only one such header unlessyou know what you are doing (‘autoheader’ creates HEADER.in onlyfor the first HEADER).HEADERS contain definitions made with AC DEFINE.
AC_CONFIG_HEADERS([config.h:config.hin])
Will create config.h from config.hin (DJGPP supports only 1 dot).
AC CONFIG FILES(FILES...)Create FILE for all FILE.in.FILES contain definitions made with AC SUBST.
AC_CONFIG_FILES([Makefile sub/Makefile script.sh:script.in])
Automake creates FILE.in for each FILE that has a FILE.am.It’s legitimate to process non-Makefiles too.
A. Duret-Lutz Using GNU Autotools February 21, 2008 71 / 162
![Page 291: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/291.jpg)
Using Autoconf
AC CONFIG FILES([script.sh:script.in]) Example
script.in
#!/bin/shSED=’@SED@’TAR=’@TAR@’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
script.sh
#!/bin/shSED=’/usr/xpg4/bin/sed’TAR=’/usr/bin/tar’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
.in files are templates
where @XYZ@ are placeholders forAC SUBST([XYZ]) definitions. ‘config.status’ substitutes them.
Makefile.ins also use @XYZ@ as placeholders but Automake makes allXYZ=@XYZ@ definitions and you may simply use $(XYZ) as needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 72 / 162
![Page 292: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/292.jpg)
Using Autoconf
AC CONFIG FILES([script.sh:script.in]) Example
script.in
#!/bin/shSED=’@SED@’TAR=’@TAR@’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
script.sh
#!/bin/shSED=’/usr/xpg4/bin/sed’TAR=’/usr/bin/tar’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
.in files are templates where @XYZ@ are placeholders forAC SUBST([XYZ]) definitions.
‘config.status’ substitutes them.
Makefile.ins also use @XYZ@ as placeholders but Automake makes allXYZ=@XYZ@ definitions and you may simply use $(XYZ) as needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 72 / 162
![Page 293: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/293.jpg)
Using Autoconf
AC CONFIG FILES([script.sh:script.in]) Example
script.in
#!/bin/shSED=’@SED@’TAR=’@TAR@’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
script.sh
#!/bin/shSED=’/usr/xpg4/bin/sed’TAR=’/usr/bin/tar’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
.in files are templates where @XYZ@ are placeholders forAC SUBST([XYZ]) definitions. ‘config.status’ substitutes them.
Makefile.ins also use @XYZ@ as placeholders but Automake makes allXYZ=@XYZ@ definitions and you may simply use $(XYZ) as needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 72 / 162
![Page 294: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/294.jpg)
Using Autoconf
AC CONFIG FILES([script.sh:script.in]) Example
script.in
#!/bin/shSED=’@SED@’TAR=’@TAR@’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
script.sh
#!/bin/shSED=’/usr/xpg4/bin/sed’TAR=’/usr/bin/tar’d=$1; shift; mkdir "$d"for f; do"$SED" ’s/#.*//’ "$f" \>"$d/$f"
done"$TAR" cf "$d.tar" "$d"
.in files are templates where @XYZ@ are placeholders forAC SUBST([XYZ]) definitions. ‘config.status’ substitutes them.
Makefile.ins also use @XYZ@ as placeholders but Automake makes allXYZ=@XYZ@ definitions and you may simply use $(XYZ) as needed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 72 / 162
![Page 295: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/295.jpg)
Using Automake
Using Automake
5 Hello World
6 Introducing Core Autotools
7 Hello World Explained
8 Using Autoconf
9 Using Automake
A. Duret-Lutz Using GNU Autotools February 21, 2008 73 / 162
![Page 296: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/296.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 297: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/297.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)
Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 298: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/298.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 299: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/299.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 300: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/300.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 301: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/301.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 302: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/302.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.
It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 303: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/303.jpg)
Using Automake
Automake Principles
Automake helps creating portable and GNU-standard compliantMakefiles.
You may be used to other kinds of build systems.(E.g., no VPATH builds, but all objects go into obj/ .)Do not use Automake if you do not like the GNU Build System:Automake will get in your way if you don’t fit the mold.
‘automake’ creates complex Makefile.ins from simple Makefile.ams.
Consider Makefile.ins as internal details.
Makefile.ams follow roughly the same syntax as Makefiles howeverthey usually contains only variable definitions.
‘automake’ creates build rules from these definitions.It’s OK to add extra Makefile rules in Makefile.am:‘automake’ will preserve them in the output.
A. Duret-Lutz Using GNU Autotools February 21, 2008 74 / 162
![Page 304: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/304.jpg)
Using Automake
Declaring Automake in configure.ac
AM INIT AUTOMAKE([OPTIONS...])Check for tools needed by ‘automake’-generated Makefiles.
Useful options:
-Wall Turn all warnings on.-Werror Report warnings as errors.foreign Relax some GNU standard requirements.1.10.1 Require a minimum version of ‘automake’.
dist-bzip2 Also create tar.bz2 archives during ‘make dist’ and‘make distcheck’.
tar-ustar Create tar archives using the ustar format.
AC CONFIG FILES(FILES...)Automake creates FILE.in for each FILE that has a FILE.am.
AC_CONFIG_FILES([Makefile sub/Makefile])
... and write Makefile.am and sub/Makefile.am.
A. Duret-Lutz Using GNU Autotools February 21, 2008 75 / 162
![Page 305: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/305.jpg)
Using Automake
The Structure of a configure.ac
configure.ac
# Prelude.AC_INIT([amhello], [1.0], [bug-report@address])AM_INIT_AUTOMAKE([-Wall -Werror foreign])# Checks for programs.
AC_PROG_CC
# Checks for libraries.# Checks for header files.# Checks for typedefs, structures, and compiler characteristics.# Checks for library functions.# Output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([FILES])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 76 / 162
![Page 306: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/306.jpg)
Using Automake
Declaring Automake in configure.ac
AM INIT AUTOMAKE([OPTIONS...])Check for tools needed by ‘automake’-generated Makefiles.Useful options:
-Wall Turn all warnings on.-Werror Report warnings as errors.foreign Relax some GNU standard requirements.1.10.1 Require a minimum version of ‘automake’.
dist-bzip2 Also create tar.bz2 archives during ‘make dist’ and‘make distcheck’.
tar-ustar Create tar archives using the ustar format.
AC CONFIG FILES(FILES...)Automake creates FILE.in for each FILE that has a FILE.am.
AC_CONFIG_FILES([Makefile sub/Makefile])
... and write Makefile.am and sub/Makefile.am.
A. Duret-Lutz Using GNU Autotools February 21, 2008 77 / 162
![Page 307: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/307.jpg)
Using Automake
Declaring Automake in configure.ac
AM INIT AUTOMAKE([OPTIONS...])Check for tools needed by ‘automake’-generated Makefiles.Useful options:
-Wall Turn all warnings on.-Werror Report warnings as errors.foreign Relax some GNU standard requirements.1.10.1 Require a minimum version of ‘automake’.
dist-bzip2 Also create tar.bz2 archives during ‘make dist’ and‘make distcheck’.
tar-ustar Create tar archives using the ustar format.
AC CONFIG FILES(FILES...)Automake creates FILE.in for each FILE that has a FILE.am.
AC_CONFIG_FILES([Makefile sub/Makefile])
... and write Makefile.am and sub/Makefile.am.
A. Duret-Lutz Using GNU Autotools February 21, 2008 77 / 162
![Page 308: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/308.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 78 / 162
![Page 309: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/309.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 78 / 162
![Page 310: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/310.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 78 / 162
![Page 311: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/311.jpg)
Using Automake
Standard File System Hierarchy
Directory variable Default valueprefix /usr/ local
exec-prefix prefixbindir exec-prefix/binlibdir exec-prefix/lib...
includedir prefix/includedatarootdir prefix/share
datadir datarootdirmandir datarootdir/maninfodir datarootdir/info
...
~/amhello-1.0 % ./configure --prefix ~/usr
~/amhello-1.0 % make
~/amhello-1.0 % make install
A. Duret-Lutz Using GNU Autotools February 21, 2008 79 / 162
![Page 312: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/312.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 80 / 162
![Page 313: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/313.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 80 / 162
![Page 314: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/314.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 80 / 162
![Page 315: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/315.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.am
option_
where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.
A. Duret-Lutz Using GNU Autotools February 21, 2008 80 / 162
![Page 316: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/316.jpg)
Using Automake
where PRIMARY Convention for Declaring Targets
Makefile.amoption_where_PRIMARY = targets ...
targets should be installed in...
bin $(bindir)
lib $(libdir)
...
custom $(customdir )You define customdir.
noinst Not installed.
check Built by ‘make check’.
targets should be built as...
PROGRAMS
LIBRARIES
LTLIBRARIES (Libtool libraries)
HEADERS
SCRIPTS
DATA
Optionally: dist Distribute targets (if not the default)
nodist Don’t.A. Duret-Lutz Using GNU Autotools February 21, 2008 80 / 162
![Page 317: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/317.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 318: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/318.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 319: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/319.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 320: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/320.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 321: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/321.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 322: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/322.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 323: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/323.jpg)
Using Automake
Declaring Sources
Makefile.ambin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
These programs will be installed in $(bindir).
The sources of each program go into programs SOURCES.
Non-alphanumeric characters are mapped to ‘ ’.
Automake automatically computes the list of objects to build and linkfrom these files.
Header files are not compiled. We list them only so they getdistributed (Automake does not distribute files it does not knowabout).
It’s OK to use the same source for two programs.
Compiler and linker are inferred from the extensions.
A. Duret-Lutz Using GNU Autotools February 21, 2008 81 / 162
![Page 324: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/324.jpg)
Using Automake
(Static) Libraries
Add AC PROG RANLIB to configure.ac .
Makefile.amlib_LIBRARIES = libfoo.a libbar.alibfoo_a_SOURCES = foo.c privfoo.hlibbar_a_SOURCES = bar.c privbar.hinclude_HEADERS = foo.h bar.h
These libraries will be installed in $(libdir).
Library names must match lib*.a.
Public headers will be installed in $(includedir).
Private headers are not installed, like ordinary sources files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 82 / 162
![Page 325: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/325.jpg)
Using Automake
(Static) Libraries
Add AC PROG RANLIB to configure.ac .
Makefile.amlib_LIBRARIES = libfoo.a libbar.alibfoo_a_SOURCES = foo.c privfoo.hlibbar_a_SOURCES = bar.c privbar.hinclude_HEADERS = foo.h bar.h
These libraries will be installed in $(libdir).
Library names must match lib*.a.
Public headers will be installed in $(includedir).
Private headers are not installed, like ordinary sources files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 82 / 162
![Page 326: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/326.jpg)
Using Automake
(Static) Libraries
Add AC PROG RANLIB to configure.ac .
Makefile.amlib_LIBRARIES = libfoo.a libbar.alibfoo_a_SOURCES = foo.c privfoo.hlibbar_a_SOURCES = bar.c privbar.hinclude_HEADERS = foo.h bar.h
These libraries will be installed in $(libdir).
Library names must match lib*.a.
Public headers will be installed in $(includedir).
Private headers are not installed, like ordinary sources files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 82 / 162
![Page 327: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/327.jpg)
Using Automake
(Static) Libraries
Add AC PROG RANLIB to configure.ac .
Makefile.amlib_LIBRARIES = libfoo.a libbar.alibfoo_a_SOURCES = foo.c privfoo.hlibbar_a_SOURCES = bar.c privbar.hinclude_HEADERS = foo.h bar.h
These libraries will be installed in $(libdir).
Library names must match lib*.a.
Public headers will be installed in $(includedir).
Private headers are not installed, like ordinary sources files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 82 / 162
![Page 328: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/328.jpg)
Using Automake
(Static) Libraries
Add AC PROG RANLIB to configure.ac .
Makefile.amlib_LIBRARIES = libfoo.a libbar.alibfoo_a_SOURCES = foo.c privfoo.hlibbar_a_SOURCES = bar.c privbar.hinclude_HEADERS = foo.h bar.h
These libraries will be installed in $(libdir).
Library names must match lib*.a.
Public headers will be installed in $(includedir).
Private headers are not installed, like ordinary sources files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 82 / 162
![Page 329: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/329.jpg)
Using Automake
(Static) Libraries
Add AC PROG RANLIB to configure.ac .
Makefile.amlib_LIBRARIES = libfoo.a libbar.alibfoo_a_SOURCES = foo.c privfoo.hlibbar_a_SOURCES = bar.c privbar.hinclude_HEADERS = foo.h bar.h
These libraries will be installed in $(libdir).
Library names must match lib*.a.
Public headers will be installed in $(includedir).
Private headers are not installed, like ordinary sources files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 82 / 162
![Page 330: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/330.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 331: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/331.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 332: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/332.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 333: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/333.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 334: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/334.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 335: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/335.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira dirb .
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 336: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/336.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = dira . dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 337: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/337.jpg)
Using Automake
Directory Layout
You may have one Makefile (hence one Makefile.am) per directory.
They must all be declared in configure.ac .
configure.ac
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefilesrc/dira/Makefile src/dirb/Makefile])
‘make’ is run at the top-level.
Makefile.ams should fix the order in which to recurse directories usingthe SUBDIRS variable.
Makefile.amSUBDIRS = lib src
src/Makefile.am
SUBDIRS = . dira dirb
The current directory is implicitly built after subdirectories.
You can put ‘.’ where you want to override this.
A. Duret-Lutz Using GNU Autotools February 21, 2008 83 / 162
![Page 338: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/338.jpg)
Using Automake
$(srcdir) and VPATH Builds
Remember VPATH builds: a source file is not necessary in the currentdirectory.
There are two twin trees: the build tree, and the source tree.Makefile and objects files are in the build tree.Makefile.in, Makefile.am, and source files are in the source tree.If ‘./configure’ is run in the current directory, the two trees are one.
In each Makefile, ‘config.status’ will define $(srcdir): the path tothe matching source directory.
When referring to sources files or targets in Automake variables, youdo not have to worry about source vs. build, because ‘make’ willcheck both directories.
You may need $(srcdir) when specifying flags for tools, or writingcustom commands. E.g., to tell the compiler to include headers fromdir/ , you should write -I$(srcdir)/dir, not -Idir. (-Idir wouldfetch headers from the build tree.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 84 / 162
![Page 339: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/339.jpg)
Using Automake
Parallel Build Trees (a.k.a. VPATH Builds)
Objects files, programs, and libraries are built where configure was run.
~ % tar zxf ~/amhello-1.0.tar.gz
~ % cd amhello-1.0
~/amhello-1.0 % mkdir build && cd build
~/amhello-1.0/build % ../configure
~/amhello-1.0/build % make
...
Sources files are in ∼/amhello-1.0/ ,built files are all in ∼/amhello-1.0/build/ .
A. Duret-Lutz Using GNU Autotools February 21, 2008 85 / 162
![Page 340: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/340.jpg)
Using Automake
$(srcdir) and VPATH Builds
Remember VPATH builds: a source file is not necessary in the currentdirectory.
There are two twin trees: the build tree, and the source tree.Makefile and objects files are in the build tree.Makefile.in, Makefile.am, and source files are in the source tree.If ‘./configure’ is run in the current directory, the two trees are one.
In each Makefile, ‘config.status’ will define $(srcdir): the path tothe matching source directory.
When referring to sources files or targets in Automake variables, youdo not have to worry about source vs. build, because ‘make’ willcheck both directories.
You may need $(srcdir) when specifying flags for tools, or writingcustom commands. E.g., to tell the compiler to include headers fromdir/ , you should write -I$(srcdir)/dir, not -Idir. (-Idir wouldfetch headers from the build tree.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 86 / 162
![Page 341: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/341.jpg)
Using Automake
$(srcdir) and VPATH Builds
Remember VPATH builds: a source file is not necessary in the currentdirectory.
There are two twin trees: the build tree, and the source tree.Makefile and objects files are in the build tree.Makefile.in, Makefile.am, and source files are in the source tree.If ‘./configure’ is run in the current directory, the two trees are one.
In each Makefile, ‘config.status’ will define $(srcdir): the path tothe matching source directory.
When referring to sources files or targets in Automake variables, youdo not have to worry about source vs. build, because ‘make’ willcheck both directories.
You may need $(srcdir) when specifying flags for tools, or writingcustom commands. E.g., to tell the compiler to include headers fromdir/ , you should write -I$(srcdir)/dir, not -Idir. (-Idir wouldfetch headers from the build tree.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 86 / 162
![Page 342: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/342.jpg)
Using Automake
$(srcdir) and VPATH Builds
Remember VPATH builds: a source file is not necessary in the currentdirectory.
There are two twin trees: the build tree, and the source tree.Makefile and objects files are in the build tree.Makefile.in, Makefile.am, and source files are in the source tree.If ‘./configure’ is run in the current directory, the two trees are one.
In each Makefile, ‘config.status’ will define $(srcdir): the path tothe matching source directory.
When referring to sources files or targets in Automake variables, youdo not have to worry about source vs. build, because ‘make’ willcheck both directories.
You may need $(srcdir) when specifying flags for tools, or writingcustom commands. E.g., to tell the compiler to include headers fromdir/ , you should write -I$(srcdir)/dir, not -Idir. (-Idir wouldfetch headers from the build tree.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 86 / 162
![Page 343: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/343.jpg)
Using Automake
$(srcdir) and VPATH Builds
Remember VPATH builds: a source file is not necessary in the currentdirectory.
There are two twin trees: the build tree, and the source tree.Makefile and objects files are in the build tree.Makefile.in, Makefile.am, and source files are in the source tree.If ‘./configure’ is run in the current directory, the two trees are one.
In each Makefile, ‘config.status’ will define $(srcdir): the path tothe matching source directory.
When referring to sources files or targets in Automake variables, youdo not have to worry about source vs. build, because ‘make’ willcheck both directories.
You may need $(srcdir) when specifying flags for tools, or writingcustom commands. E.g., to tell the compiler to include headers fromdir/ , you should write -I$(srcdir)/dir, not -Idir. (-Idir wouldfetch headers from the build tree.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 86 / 162
![Page 344: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/344.jpg)
Using Automake
Convenience Libraries
lib/Makefile.am
noinst_LIBRARIES = libcompat.alibcompat_a_SOURCES = xalloc.c xalloc.h
This is a convenience library, used only when building the package.
src/Makefile.am
LDADD = ../lib/libcompat.aAM_CPPFLAGS = -I$(srcdir)/../libbin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
LDADD is added when linking all programs.
AM CPPFLAGS contains additional preprocessor flags.
You can use per-target variables: they apply to a single program.
A. Duret-Lutz Using GNU Autotools February 21, 2008 87 / 162
![Page 345: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/345.jpg)
Using Automake
Convenience Libraries
lib/Makefile.am
noinst_LIBRARIES = libcompat.alibcompat_a_SOURCES = xalloc.c xalloc.h
This is a convenience library, used only when building the package.
src/Makefile.am
LDADD = ../lib/libcompat.aAM_CPPFLAGS = -I$(srcdir)/../libbin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
LDADD is added when linking all programs.
AM CPPFLAGS contains additional preprocessor flags.
You can use per-target variables: they apply to a single program.
A. Duret-Lutz Using GNU Autotools February 21, 2008 87 / 162
![Page 346: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/346.jpg)
Using Automake
Convenience Libraries
lib/Makefile.am
noinst_LIBRARIES = libcompat.alibcompat_a_SOURCES = xalloc.c xalloc.h
This is a convenience library, used only when building the package.
src/Makefile.am
LDADD = ../lib/libcompat.aAM_CPPFLAGS = -I$(srcdir)/../libbin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
LDADD is added when linking all programs.
AM CPPFLAGS contains additional preprocessor flags.
You can use per-target variables: they apply to a single program.
A. Duret-Lutz Using GNU Autotools February 21, 2008 87 / 162
![Page 347: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/347.jpg)
Using Automake
Convenience Libraries
lib/Makefile.am
noinst_LIBRARIES = libcompat.alibcompat_a_SOURCES = xalloc.c xalloc.h
This is a convenience library, used only when building the package.
src/Makefile.am
LDADD = ../lib/libcompat.aAM_CPPFLAGS = -I$(srcdir)/../libbin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
LDADD is added when linking all programs.
AM CPPFLAGS contains additional preprocessor flags.
You can use per-target variables: they apply to a single program.
A. Duret-Lutz Using GNU Autotools February 21, 2008 87 / 162
![Page 348: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/348.jpg)
Using Automake
Convenience Libraries
lib/Makefile.am
noinst_LIBRARIES = libcompat.alibcompat_a_SOURCES = xalloc.c xalloc.h
This is a convenience library, used only when building the package.
src/Makefile.am
LDADD = ../lib/libcompat.aAM_CPPFLAGS = -I$(srcdir)/../libbin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.c
LDADD is added when linking all programs.
AM CPPFLAGS contains additional preprocessor flags.
You can use per-target variables: they apply to a single program.
A. Duret-Lutz Using GNU Autotools February 21, 2008 87 / 162
![Page 349: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/349.jpg)
Using Automake
Convenience Libraries
lib/Makefile.am
noinst_LIBRARIES = libcompat.alibcompat_a_SOURCES = xalloc.c xalloc.h
This is a convenience library, used only when building the package.
src/Makefile.am
bin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.crun_me_LDADD = ../lib/libcompat.arun_me_CPPFLAGS = -I$(srcdir)/../lib
LDADD is added when linking all programs.
AM CPPFLAGS contains additional preprocessor flags.
You can use per-target variables: they apply to a single program.
A. Duret-Lutz Using GNU Autotools February 21, 2008 87 / 162
![Page 350: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/350.jpg)
Using Automake
Per-Target Flags
Assuming foo is a program or library:
foo CFLAGS Additional C compiler flagsfoo CPPFLAGS Additional preprocessor flags (-Is and -Ds)
foo LDADD Additional link objects, -ls and -Ls (if foo is a program)foo LIBADD Additional link objects, -ls and -Ls (if foo is a library)
foo LDFLAGS Additional linker flags
The default value for foo XXXFLAGS is $(AM XXXFLAGS).
Use plain file names to refer to libraries inside your package (keep -ls and-Ls for external libraries only).
src/Makefile.am
bin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.crun_me_CPPFLAGS = -I$(srcdir)/../librun_me_LDADD = ../lib/libcompat.a
$(EFENCELIB)
A. Duret-Lutz Using GNU Autotools February 21, 2008 88 / 162
![Page 351: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/351.jpg)
Using Automake
Per-Target Flags
Assuming foo is a program or library:
foo CFLAGS Additional C compiler flagsfoo CPPFLAGS Additional preprocessor flags (-Is and -Ds)
foo LDADD Additional link objects, -ls and -Ls (if foo is a program)foo LIBADD Additional link objects, -ls and -Ls (if foo is a library)
foo LDFLAGS Additional linker flags
The default value for foo XXXFLAGS is $(AM XXXFLAGS).
Use plain file names to refer to libraries inside your package (keep -ls and-Ls for external libraries only).
src/Makefile.am
bin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.crun_me_CPPFLAGS = -I$(srcdir)/../librun_me_LDADD = ../lib/libcompat.a
$(EFENCELIB)
A. Duret-Lutz Using GNU Autotools February 21, 2008 88 / 162
![Page 352: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/352.jpg)
Using Automake
Per-Target Flags
Assuming foo is a program or library:
foo CFLAGS Additional C compiler flagsfoo CPPFLAGS Additional preprocessor flags (-Is and -Ds)
foo LDADD Additional link objects, -ls and -Ls (if foo is a program)foo LIBADD Additional link objects, -ls and -Ls (if foo is a library)
foo LDFLAGS Additional linker flags
The default value for foo XXXFLAGS is $(AM XXXFLAGS).Use plain file names to refer to libraries inside your package (keep -ls and-Ls for external libraries only).
src/Makefile.am
bin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.crun_me_CPPFLAGS = -I$(srcdir)/../librun_me_LDADD = ../lib/libcompat.a
$(EFENCELIB)
A. Duret-Lutz Using GNU Autotools February 21, 2008 88 / 162
![Page 353: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/353.jpg)
Using Automake
Checking for Libraries
AC CHECK LIB(LIBRARY, FUNCT, [ACT-IF-FOUND], [ACT-IF-NOT])
Check whether LIBRARY exists and contains FUNCT.Execute ACT-IF-FOUND if it does, ACT-IF-NOT otherwise.
AC_CHECK_LIB([efence], [malloc], [EFENCELIB=-lefence])AC_SUBST([EFENCELIB])
... we would later use $(EFENCELIB) in the link rule.
If ACT-IF-FOUND is not set and the library is found, AC CHECK LIBwill do LIBS="-lLIBRARY $LIBS" and #define HAVE LIBLIBRARY.(Automake uses $LIBS for linking everything.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 89 / 162
![Page 354: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/354.jpg)
Using Automake
Per-Target Flags
Assuming foo is a program or library:
foo CFLAGS Additional C compiler flagsfoo CPPFLAGS Additional preprocessor flags (-Is and -Ds)
foo LDADD Additional link objects, -ls and -Ls (if foo is a program)foo LIBADD Additional link objects, -ls and -Ls (if foo is a library)
foo LDFLAGS Additional linker flags
The default value for foo XXXFLAGS is $(AM XXXFLAGS).Use plain file names to refer to libraries inside your package (keep -ls and-Ls for external libraries only).
src/Makefile.am
bin_PROGRAMS = foo run-mefoo_SOURCES = foo.c foo.h print.c print.hrun_me_SOURCES = run.c run.h print.crun_me_CPPFLAGS = -I$(srcdir)/../librun_me_LDADD = ../lib/libcompat.a $(EFENCELIB)
A. Duret-Lutz Using GNU Autotools February 21, 2008 90 / 162
![Page 355: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/355.jpg)
Using Automake
What Gets Distributed
‘make dist’ and ‘make distcheck’ create a tarball containing:
All sources declared using ... SOURCES
All headers declared using ... HEADERS
All scripts declared with dist ... SCRIPTS
All data files declared with dist ... DATA
...
Common files such as ChangeLog , NEWS , etc.See ‘automake --help’ for a list of those files.
Extra files or directories listed into EXTRA DIST.
Makefile.amSUBDIRS = lib srcEXTRA_DIST = HACKING
... will additionally distribute HACKING .
A. Duret-Lutz Using GNU Autotools February 21, 2008 91 / 162
![Page 356: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/356.jpg)
Using Automake
What Gets Distributed
‘make dist’ and ‘make distcheck’ create a tarball containing:
All sources declared using ... SOURCES
All headers declared using ... HEADERS
All scripts declared with dist ... SCRIPTS
All data files declared with dist ... DATA
...
Common files such as ChangeLog , NEWS , etc.See ‘automake --help’ for a list of those files.
Extra files or directories listed into EXTRA DIST.
Makefile.amSUBDIRS = lib srcEXTRA_DIST = HACKING
... will additionally distribute HACKING .
A. Duret-Lutz Using GNU Autotools February 21, 2008 91 / 162
![Page 357: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/357.jpg)
Using Automake
What Gets Distributed
‘make dist’ and ‘make distcheck’ create a tarball containing:
All sources declared using ... SOURCES
All headers declared using ... HEADERS
All scripts declared with dist ... SCRIPTS
All data files declared with dist ... DATA
...
Common files such as ChangeLog , NEWS , etc.See ‘automake --help’ for a list of those files.
Extra files or directories listed into EXTRA DIST.
Makefile.amSUBDIRS = lib srcEXTRA_DIST = HACKING
... will additionally distribute HACKING .
A. Duret-Lutz Using GNU Autotools February 21, 2008 91 / 162
![Page 358: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/358.jpg)
Using Automake
What Gets Distributed
‘make dist’ and ‘make distcheck’ create a tarball containing:
All sources declared using ... SOURCES
All headers declared using ... HEADERS
All scripts declared with dist ... SCRIPTS
All data files declared with dist ... DATA
...
Common files such as ChangeLog , NEWS , etc.See ‘automake --help’ for a list of those files.
Extra files or directories listed into EXTRA DIST.
Makefile.amSUBDIRS = lib srcEXTRA_DIST = HACKING
... will additionally distribute HACKING .
A. Duret-Lutz Using GNU Autotools February 21, 2008 91 / 162
![Page 359: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/359.jpg)
Using Automake
What Gets Distributed
‘make dist’ and ‘make distcheck’ create a tarball containing:
All sources declared using ... SOURCES
All headers declared using ... HEADERS
All scripts declared with dist ... SCRIPTS
All data files declared with dist ... DATA
...
Common files such as ChangeLog , NEWS , etc.See ‘automake --help’ for a list of those files.
Extra files or directories listed into EXTRA DIST.
Makefile.amSUBDIRS = lib srcEXTRA_DIST = HACKING
... will additionally distribute HACKING .
A. Duret-Lutz Using GNU Autotools February 21, 2008 91 / 162
![Page 360: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/360.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 361: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/361.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 362: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/362.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 363: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/363.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.
bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 364: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/364.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.
In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 365: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/365.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.
This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 366: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/366.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.
WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 367: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/367.jpg)
Using Automake
Conditionals: Usage
Conditionals allow for conditional builds and unconditionaldistribution.
Conditional Programs
bin_PROGRAMS = fooif WANT_BARbin_PROGRAMS += bar
endiffoo_SOURCES = foo.cbar_SOURCES = bar.c
Conditional Sourcesbin_PROGRAMS = foofoo_SOURCES = foo.cif WANT_BARfoo_SOURCES += bar.c
endif
bar is built iff WANT BAR is true.bar.o is linked in foo iff WANT BAR is true.In all cases foo.c and bar.c are distributed regardless of WANT BAR.This is portable. ‘config.status’ will comment rules of Makefile.inthat must be disabled.WANT BAR must be declared and valued in configure.ac .
A. Duret-Lutz Using GNU Autotools February 21, 2008 92 / 162
![Page 368: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/368.jpg)
Using Automake
Conditionals: Declaration
AM CONDITIONAL(NAME, CONDITION)Declare conditional NAME. CONDITION should be a shell instructionthat succeeds iff NAME should be enabled.
configure.ac
AC_CHECK_HEADER([bar.h], [use_bar=yes])AM_CONDITIONAL([WANT_BAR], [test "$use_bar" = yes])
Will enable WANT BAR only if bar.h is present on the system.
A. Duret-Lutz Using GNU Autotools February 21, 2008 93 / 162
![Page 369: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/369.jpg)
Using Automake
Conditionals: Declaration
AM CONDITIONAL(NAME, CONDITION)Declare conditional NAME. CONDITION should be a shell instructionthat succeeds iff NAME should be enabled.
configure.ac
AC_CHECK_HEADER([bar.h], [use_bar=yes])AM_CONDITIONAL([WANT_BAR], [test "$use_bar" = yes])
Will enable WANT BAR only if bar.h is present on the system.
A. Duret-Lutz Using GNU Autotools February 21, 2008 93 / 162
![Page 370: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/370.jpg)
Using Automake
Extending Automake Rules
The contents of Makefile.am is copied almost verbatim to Makefile.in.
‘automake’ adds new rules and variables in Makefile.in, to achieve thesemantics of the special variables you have defined.
Some minor rewriting is done to handle constructs like conditionals or+= portably.
It’s OK to define your own rules in Makefile.am.
Helpful maintenance targets (‘make style-check’)Build idiosyncratic files (generate a FAQ from some random source)...
It’s OK to define variables that are meaningless to Automake.
For use in custom rules.
Beware of conflicts: your definitions (of variables or rules) willoverride those of Automake.
-Wall will diagnose these.
A. Duret-Lutz Using GNU Autotools February 21, 2008 94 / 162
![Page 371: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/371.jpg)
Using Automake
Extending Automake Rules
The contents of Makefile.am is copied almost verbatim to Makefile.in.
‘automake’ adds new rules and variables in Makefile.in, to achieve thesemantics of the special variables you have defined.
Some minor rewriting is done to handle constructs like conditionals or+= portably.
It’s OK to define your own rules in Makefile.am.
Helpful maintenance targets (‘make style-check’)Build idiosyncratic files (generate a FAQ from some random source)...
It’s OK to define variables that are meaningless to Automake.
For use in custom rules.
Beware of conflicts: your definitions (of variables or rules) willoverride those of Automake.
-Wall will diagnose these.
A. Duret-Lutz Using GNU Autotools February 21, 2008 94 / 162
![Page 372: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/372.jpg)
Using Automake
Extending Automake Rules
The contents of Makefile.am is copied almost verbatim to Makefile.in.
‘automake’ adds new rules and variables in Makefile.in, to achieve thesemantics of the special variables you have defined.
Some minor rewriting is done to handle constructs like conditionals or+= portably.
It’s OK to define your own rules in Makefile.am.Helpful maintenance targets (‘make style-check’)Build idiosyncratic files (generate a FAQ from some random source)...
It’s OK to define variables that are meaningless to Automake.
For use in custom rules.
Beware of conflicts: your definitions (of variables or rules) willoverride those of Automake.
-Wall will diagnose these.
A. Duret-Lutz Using GNU Autotools February 21, 2008 94 / 162
![Page 373: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/373.jpg)
Using Automake
Extending Automake Rules
The contents of Makefile.am is copied almost verbatim to Makefile.in.
‘automake’ adds new rules and variables in Makefile.in, to achieve thesemantics of the special variables you have defined.
Some minor rewriting is done to handle constructs like conditionals or+= portably.
It’s OK to define your own rules in Makefile.am.Helpful maintenance targets (‘make style-check’)Build idiosyncratic files (generate a FAQ from some random source)...
It’s OK to define variables that are meaningless to Automake.For use in custom rules.
Beware of conflicts: your definitions (of variables or rules) willoverride those of Automake.
-Wall will diagnose these.
A. Duret-Lutz Using GNU Autotools February 21, 2008 94 / 162
![Page 374: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/374.jpg)
Using Automake
Extending Automake Rules
The contents of Makefile.am is copied almost verbatim to Makefile.in.
‘automake’ adds new rules and variables in Makefile.in, to achieve thesemantics of the special variables you have defined.
Some minor rewriting is done to handle constructs like conditionals or+= portably.
It’s OK to define your own rules in Makefile.am.Helpful maintenance targets (‘make style-check’)Build idiosyncratic files (generate a FAQ from some random source)...
It’s OK to define variables that are meaningless to Automake.For use in custom rules.
Beware of conflicts: your definitions (of variables or rules) willoverride those of Automake.
-Wall will diagnose these.
A. Duret-Lutz Using GNU Autotools February 21, 2008 94 / 162
![Page 375: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/375.jpg)
Using Automake
Recommendations
Use -Wall -Werror.
Keep Your Setup Simple (KYSS!).
You will spend a large part of time debugging your cunning tricks if youtry to automatize too much.
Do not lie to Automake.
Automake can be annoying, but when you lie it gets worse!
A. Duret-Lutz Using GNU Autotools February 21, 2008 95 / 162
![Page 376: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/376.jpg)
Using Automake
Recommendations
Use -Wall -Werror.
Keep Your Setup Simple (KYSS!).
You will spend a large part of time debugging your cunning tricks if youtry to automatize too much.
Do not lie to Automake.
Automake can be annoying, but when you lie it gets worse!
A. Duret-Lutz Using GNU Autotools February 21, 2008 95 / 162
![Page 377: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/377.jpg)
Using Automake
Recommendations
Use -Wall -Werror.
Keep Your Setup Simple (KYSS!).
You will spend a large part of time debugging your cunning tricks if youtry to automatize too much.
Do not lie to Automake.
Automake can be annoying, but when you lie it gets worse!
A. Duret-Lutz Using GNU Autotools February 21, 2008 95 / 162
![Page 378: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/378.jpg)
Using Automake
Lost? ‘autoreconf’ is Still Your Friend
If ‘make’ fails to rebuild configuration files, run ‘autoreconf’ manually.
~/amhello % autoreconf --install
If this does not help, try harder.
~/amhello % autoreconf --install --force
If this still does not help, try even harder.
~/amhello % make -k maintainer-clean
~/amhello % autoreconf --install --force
Do this only when necessary. Each of these commands will cause yourpackage to take longer to reconfigure and recompile.
A. Duret-Lutz Using GNU Autotools February 21, 2008 96 / 162
![Page 379: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/379.jpg)
Using Automake
Lost? ‘autoreconf’ is Still Your Friend
If ‘make’ fails to rebuild configuration files, run ‘autoreconf’ manually.
~/amhello % autoreconf --install
If this does not help, try harder.
~/amhello % autoreconf --install --force
If this still does not help, try even harder.
~/amhello % make -k maintainer-clean
~/amhello % autoreconf --install --force
Do this only when necessary. Each of these commands will cause yourpackage to take longer to reconfigure and recompile.
A. Duret-Lutz Using GNU Autotools February 21, 2008 96 / 162
![Page 380: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/380.jpg)
Using Automake
Lost? ‘autoreconf’ is Still Your Friend
If ‘make’ fails to rebuild configuration files, run ‘autoreconf’ manually.
~/amhello % autoreconf --install
If this does not help, try harder.
~/amhello % autoreconf --install --force
If this still does not help, try even harder.
~/amhello % make -k maintainer-clean
~/amhello % autoreconf --install --force
Do this only when necessary. Each of these commands will cause yourpackage to take longer to reconfigure and recompile.
A. Duret-Lutz Using GNU Autotools February 21, 2008 96 / 162
![Page 381: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/381.jpg)
Part III
More Autotools
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 97 / 162
![Page 382: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/382.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing Autoconf Macros
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 98 / 162
![Page 383: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/383.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing an Autoconf Macro? Why? How?
Two fundamentally different types of new macros:
Macros that factor related tests in a single reusable entity.
High-level.Combination of existing lower-level macros.May not use shell code at all.
Macros that implements new tests.
Low-level.Actually code the check.Need to bother with caching values.
A. Duret-Lutz Using GNU Autotools February 21, 2008 99 / 162
![Page 384: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/384.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing an Autoconf Macro? Why? How?
Two fundamentally different types of new macros:
Macros that factor related tests in a single reusable entity.
High-level.Combination of existing lower-level macros.May not use shell code at all.
Macros that implements new tests.
Low-level.Actually code the check.Need to bother with caching values.
A. Duret-Lutz Using GNU Autotools February 21, 2008 99 / 162
![Page 385: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/385.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing an Autoconf Macro? Why? How?
Two fundamentally different types of new macros:
Macros that factor related tests in a single reusable entity.
High-level.Combination of existing lower-level macros.May not use shell code at all.
Macros that implements new tests.
Low-level.Actually code the check.Need to bother with caching values.
A. Duret-Lutz Using GNU Autotools February 21, 2008 99 / 162
![Page 386: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/386.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Defining Macros
AC DEFUN(MACRO-NAME, MACRO-BODY)Define MACRO-NAME as MACRO-BODY.
Avoid names that may conflict.
Macro name spaces:
m4 Original M4 macros, plus M4sugar macros.
AS M4sh macros (macroized shell constructs)
AH Autoheader macros
AC Autoconf macros (written on top of the above layers)
AC CHECK Generic checks.AC FUNC Specific function checks.
AC HEADER Specific header checks.AC PROG Specific program checks.
...
AM Automake macros
AT Autotest macros
A. Duret-Lutz Using GNU Autotools February 21, 2008 100 / 162
![Page 387: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/387.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Defining Macros
AC DEFUN(MACRO-NAME, MACRO-BODY)Define MACRO-NAME as MACRO-BODY.
Avoid names that may conflict. Macro name spaces:
m4 Original M4 macros, plus M4sugar macros.
AS M4sh macros (macroized shell constructs)
AH Autoheader macros
AC Autoconf macros (written on top of the above layers)
AC CHECK Generic checks.AC FUNC Specific function checks.
AC HEADER Specific header checks.AC PROG Specific program checks.
...
AM Automake macros
AT Autotest macrosA. Duret-Lutz Using GNU Autotools February 21, 2008 100 / 162
![Page 388: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/388.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Defining Macros
AC DEFUN(MACRO-NAME, MACRO-BODY)Define MACRO-NAME as MACRO-BODY.
Avoid names that may conflict. Macro name spaces:
m4 Original M4 macros, plus M4sugar macros.
AS M4sh macros (macroized shell constructs)
AH Autoheader macros
AC Autoconf macros (written on top of the above layers)
AC CHECK Generic checks.AC FUNC Specific function checks.
AC HEADER Specific header checks.AC PROG Specific program checks.
...
AM Automake macros
AT Autotest macrosA. Duret-Lutz Using GNU Autotools February 21, 2008 100 / 162
![Page 389: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/389.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
mkdir() Example
POSIX systems define mkdir() with two arguments.
On Mingw32 (at least), mkdir() takes only one argument.
On Win32 (at least), the name is mkdir() with one argument.
#if HAVE_MKDIR# if MKDIR_ONE_ARG# define mkdir(a,b) mkdir(a)# endif#else# if HAVE__MKDIR# define mkdir(a,b) _mkdir(a)# else# error "Don’t know how to create a directory."# endif#endif
Let’s write an Autoconf macro to define these C macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 101 / 162
![Page 390: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/390.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
mkdir() Example
POSIX systems define mkdir() with two arguments.
On Mingw32 (at least), mkdir() takes only one argument.
On Win32 (at least), the name is mkdir() with one argument.
#if HAVE_MKDIR# if MKDIR_ONE_ARG# define mkdir(a,b) mkdir(a)# endif#else# if HAVE__MKDIR# define mkdir(a,b) _mkdir(a)# else# error "Don’t know how to create a directory."# endif#endif
Let’s write an Autoconf macro to define these C macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 101 / 162
![Page 391: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/391.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
mkdir() Example
POSIX systems define mkdir() with two arguments.
On Mingw32 (at least), mkdir() takes only one argument.
On Win32 (at least), the name is mkdir() with one argument.
#if HAVE_MKDIR# if MKDIR_ONE_ARG# define mkdir(a,b) mkdir(a)# endif#else# if HAVE__MKDIR# define mkdir(a,b) _mkdir(a)# else# error "Don’t know how to create a directory."# endif#endif
Let’s write an Autoconf macro to define these C macros.A. Duret-Lutz Using GNU Autotools February 21, 2008 101 / 162
![Page 392: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/392.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a High-Level Macro: AX FUNC MKDIR
AC_DEFUN([AX_FUNC_MKDIR],[AC_CHECK_FUNCS([mkdir _mkdir])AC_CHECK_HEADERS([io.h])AX_FUNC_MKDIR_ONE_ARG])
Suggested name space for extension macros.
Use same convention as Autoconf for categorizing macros.
Defines HAVE MKDIR and HAVE MKDIR.
Defines HAVE IO H if io.h exists.(mkdir() may also be defined there, and sys/ stat.h and unistd.h arealways tested by AC PROG CC)
Will define MKDIR ONE ARG... once written.
A. Duret-Lutz Using GNU Autotools February 21, 2008 102 / 162
![Page 393: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/393.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a High-Level Macro: AX FUNC MKDIR
AC_DEFUN([AX_FUNC_MKDIR],[AC_CHECK_FUNCS([mkdir _mkdir])AC_CHECK_HEADERS([io.h])AX_FUNC_MKDIR_ONE_ARG])
Suggested name space for extension macros.
Use same convention as Autoconf for categorizing macros.
Defines HAVE MKDIR and HAVE MKDIR.
Defines HAVE IO H if io.h exists.(mkdir() may also be defined there, and sys/ stat.h and unistd.h arealways tested by AC PROG CC)
Will define MKDIR ONE ARG... once written.
A. Duret-Lutz Using GNU Autotools February 21, 2008 102 / 162
![Page 394: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/394.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a High-Level Macro: AX FUNC MKDIR
AC_DEFUN([AX_FUNC_MKDIR],[AC_CHECK_FUNCS([mkdir _mkdir])AC_CHECK_HEADERS([io.h])AX_FUNC_MKDIR_ONE_ARG])
Suggested name space for extension macros.
Use same convention as Autoconf for categorizing macros.
Defines HAVE MKDIR and HAVE MKDIR.
Defines HAVE IO H if io.h exists.(mkdir() may also be defined there, and sys/ stat.h and unistd.h arealways tested by AC PROG CC)
Will define MKDIR ONE ARG... once written.
A. Duret-Lutz Using GNU Autotools February 21, 2008 102 / 162
![Page 395: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/395.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a High-Level Macro: AX FUNC MKDIR
AC_DEFUN([AX_FUNC_MKDIR],[AC_CHECK_FUNCS([mkdir _mkdir])AC_CHECK_HEADERS([io.h])AX_FUNC_MKDIR_ONE_ARG])
Suggested name space for extension macros.
Use same convention as Autoconf for categorizing macros.
Defines HAVE MKDIR and HAVE MKDIR.
Defines HAVE IO H if io.h exists.(mkdir() may also be defined there, and sys/ stat.h and unistd.h arealways tested by AC PROG CC)
Will define MKDIR ONE ARG... once written.
A. Duret-Lutz Using GNU Autotools February 21, 2008 102 / 162
![Page 396: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/396.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a High-Level Macro: AX FUNC MKDIR
AC_DEFUN([AX_FUNC_MKDIR],[AC_CHECK_FUNCS([mkdir _mkdir])AC_CHECK_HEADERS([io.h])AX_FUNC_MKDIR_ONE_ARG])
Suggested name space for extension macros.
Use same convention as Autoconf for categorizing macros.
Defines HAVE MKDIR and HAVE MKDIR.
Defines HAVE IO H if io.h exists.(mkdir() may also be defined there, and sys/ stat.h and unistd.h arealways tested by AC PROG CC)
Will define MKDIR ONE ARG... once written.
A. Duret-Lutz Using GNU Autotools February 21, 2008 102 / 162
![Page 397: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/397.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a High-Level Macro: AX FUNC MKDIR
AC_DEFUN([AX_FUNC_MKDIR],[AC_CHECK_FUNCS([mkdir _mkdir])AC_CHECK_HEADERS([io.h])AX_FUNC_MKDIR_ONE_ARG])
Suggested name space for extension macros.
Use same convention as Autoconf for categorizing macros.
Defines HAVE MKDIR and HAVE MKDIR.
Defines HAVE IO H if io.h exists.(mkdir() may also be defined there, and sys/ stat.h and unistd.h arealways tested by AC PROG CC)
Will define MKDIR ONE ARG... once written.
A. Duret-Lutz Using GNU Autotools February 21, 2008 102 / 162
![Page 398: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/398.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Checking mkdir()’s number of arguments
# _AX_FUNC_MKDIR_ONE_ARG(IF-ONE-ARG, IF-TWO-ARGS)# -----------------------------------------------# Execute IF-TWO-ARGS if mkdir() accepts two# arguments; execute IF-ONE-ARG otherwise.AC_DEFUN([_AX_FUNC_MKDIR_ONE_ARG],[AC_TRY_COMPILE([#include <sys/stat.h>#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_IO_H# include <io.h>#endif], [mkdir (".", 0700);], [$2], [$1])])
Wait! That’s not enough for an Autoconf check: we should also addsome checking whether... message on top of this.We use the AX prefix for helper macros not meant to be used directly.
A. Duret-Lutz Using GNU Autotools February 21, 2008 103 / 162
![Page 399: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/399.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Checking mkdir()’s number of arguments
# _AX_FUNC_MKDIR_ONE_ARG(IF-ONE-ARG, IF-TWO-ARGS)# -----------------------------------------------# Execute IF-TWO-ARGS if mkdir() accepts two# arguments; execute IF-ONE-ARG otherwise.AC_DEFUN([_AX_FUNC_MKDIR_ONE_ARG],[AC_TRY_COMPILE([#include <sys/stat.h>#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_IO_H# include <io.h>#endif], [mkdir (".", 0700);], [$2], [$1])])
Wait! That’s not enough for an Autoconf check: we should also addsome checking whether... message on top of this.We use the AX prefix for helper macros not meant to be used directly.
Comments
Showcase of the traditional style used todocument autoconf macros.
A. Duret-Lutz Using GNU Autotools February 21, 2008 103 / 162
![Page 400: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/400.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Checking mkdir()’s number of arguments
# _AX_FUNC_MKDIR_ONE_ARG(IF-ONE-ARG, IF-TWO-ARGS)# -----------------------------------------------# Execute IF-TWO-ARGS if mkdir() accepts two# arguments; execute IF-ONE-ARG otherwise.AC_DEFUN([_AX_FUNC_MKDIR_ONE_ARG],[AC_TRY_COMPILE([#include <sys/stat.h>#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_IO_H# include <io.h>#endif], [mkdir (".", 0700);], [$2], [$1])])
Wait! That’s not enough for an Autoconf check: we should also addsome checking whether... message on top of this.We use the AX prefix for helper macros not meant to be used directly.
AC TRY COMPILE
Creates a small program and attempt tocompile it. In our case it will execute one ofthe AX FUNC MKDIR ONE ARG argumentsdepending on whether the program compiledor not.
A. Duret-Lutz Using GNU Autotools February 21, 2008 103 / 162
![Page 401: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/401.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Checking mkdir()’s number of arguments
# _AX_FUNC_MKDIR_ONE_ARG(IF-ONE-ARG, IF-TWO-ARGS)# -----------------------------------------------# Execute IF-TWO-ARGS if mkdir() accepts two# arguments; execute IF-ONE-ARG otherwise.AC_DEFUN([_AX_FUNC_MKDIR_ONE_ARG],[AC_TRY_COMPILE([#include <sys/stat.h>#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_IO_H# include <io.h>#endif], [mkdir (".", 0700);], [$2], [$1])])
Wait! That’s not enough for an Autoconf check: we should also addsome checking whether... message on top of this.
We use the AX prefix for helper macros not meant to be used directly.
A. Duret-Lutz Using GNU Autotools February 21, 2008 103 / 162
![Page 402: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/402.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Checking mkdir()’s number of arguments
# _AX_FUNC_MKDIR_ONE_ARG(IF-ONE-ARG, IF-TWO-ARGS)# -----------------------------------------------# Execute IF-TWO-ARGS if mkdir() accepts two# arguments; execute IF-ONE-ARG otherwise.AC_DEFUN([_AX_FUNC_MKDIR_ONE_ARG],[AC_TRY_COMPILE([#include <sys/stat.h>#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_IO_H# include <io.h>#endif], [mkdir (".", 0700);], [$2], [$1])])
Wait! That’s not enough for an Autoconf check: we should also addsome checking whether... message on top of this.We use the AX prefix for helper macros not meant to be used directly.
A. Duret-Lutz Using GNU Autotools February 21, 2008 103 / 162
![Page 403: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/403.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a Low-Level Macro
Low-level macros need to
print a checking whether... messagedo the actual checkcache the result of the check
Most of this is achieved via the AC CACHE CHECK macro.
AC_DEFUN(MACRO-NAME,[AC_CACHE_CHECK(WHETHER-MESSAGE,
CACHE-VARIABLE,CODE-TO-SET-CACHE-VARIABLE)
CODE-USING-CACHE-VARIABLE])
The CACHE-VARIABLE should match * cv *.CODE-TO-SET-CACHE-VARIABLE should contain the check. It willbe skipped when the cache is used.CODE-USING-CACHE-VARIABLE is always executed, use AC SUBSTand AC DEFINE here.
A. Duret-Lutz Using GNU Autotools February 21, 2008 104 / 162
![Page 404: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/404.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
The (real) configure process
Makefile.in src/Makefile.in config.h.in
configure
config.log
config.status
Makefile src/Makefile config.h
config.cache
‘configure -C’ caches results in config.cache to speed upreconfigurations
A. Duret-Lutz Using GNU Autotools February 21, 2008 105 / 162
![Page 405: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/405.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a Low-Level Macro
Low-level macros need to
print a checking whether... messagedo the actual checkcache the result of the check
Most of this is achieved via the AC CACHE CHECK macro.
AC_DEFUN(MACRO-NAME,[AC_CACHE_CHECK(WHETHER-MESSAGE,
CACHE-VARIABLE,CODE-TO-SET-CACHE-VARIABLE)
CODE-USING-CACHE-VARIABLE])
The CACHE-VARIABLE should match * cv *.CODE-TO-SET-CACHE-VARIABLE should contain the check. It willbe skipped when the cache is used.CODE-USING-CACHE-VARIABLE is always executed, use AC SUBSTand AC DEFINE here.
A. Duret-Lutz Using GNU Autotools February 21, 2008 106 / 162
![Page 406: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/406.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a Low-Level Macro
Low-level macros need to
print a checking whether... messagedo the actual checkcache the result of the check
Most of this is achieved via the AC CACHE CHECK macro.
AC_DEFUN(MACRO-NAME,[AC_CACHE_CHECK(WHETHER-MESSAGE,
CACHE-VARIABLE,CODE-TO-SET-CACHE-VARIABLE)
CODE-USING-CACHE-VARIABLE])
The CACHE-VARIABLE should match * cv *.
CODE-TO-SET-CACHE-VARIABLE should contain the check. It willbe skipped when the cache is used.CODE-USING-CACHE-VARIABLE is always executed, use AC SUBSTand AC DEFINE here.
A. Duret-Lutz Using GNU Autotools February 21, 2008 106 / 162
![Page 407: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/407.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a Low-Level Macro
Low-level macros need to
print a checking whether... messagedo the actual checkcache the result of the check
Most of this is achieved via the AC CACHE CHECK macro.
AC_DEFUN(MACRO-NAME,[AC_CACHE_CHECK(WHETHER-MESSAGE,
CACHE-VARIABLE,CODE-TO-SET-CACHE-VARIABLE)
CODE-USING-CACHE-VARIABLE])
The CACHE-VARIABLE should match * cv *.CODE-TO-SET-CACHE-VARIABLE should contain the check. It willbe skipped when the cache is used.
CODE-USING-CACHE-VARIABLE is always executed, use AC SUBSTand AC DEFINE here.
A. Duret-Lutz Using GNU Autotools February 21, 2008 106 / 162
![Page 408: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/408.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Writing a Low-Level Macro
Low-level macros need to
print a checking whether... messagedo the actual checkcache the result of the check
Most of this is achieved via the AC CACHE CHECK macro.
AC_DEFUN(MACRO-NAME,[AC_CACHE_CHECK(WHETHER-MESSAGE,
CACHE-VARIABLE,CODE-TO-SET-CACHE-VARIABLE)
CODE-USING-CACHE-VARIABLE])
The CACHE-VARIABLE should match * cv *.CODE-TO-SET-CACHE-VARIABLE should contain the check. It willbe skipped when the cache is used.CODE-USING-CACHE-VARIABLE is always executed, use AC SUBSTand AC DEFINE here.
A. Duret-Lutz Using GNU Autotools February 21, 2008 106 / 162
![Page 409: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/409.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
A Low-Level Macro: AX FUNC MKDIR ONE ARG
AC_DEFUN([AX_FUNC_MKDIR_ONE_ARG],[AC_CACHE_CHECK([whether mkdir takes one argument],
[ax_cv_mkdir_one_arg],[_AX_FUNC_MKDIR_ONE_ARG([ax_cv_mkdir_one_arg=yes],
[ax_cv_mkdir_one_arg=no])])if test x"$ax_cv_mkdir_one_arg" = xyes; thenAC_DEFINE([MKDIR_ONE_ARG], 1,
[Define if mkdir takes only one argument.])fi]) # AX_FUNC_MKDIR_ONE_ARG
AC CACHE CHECKprints checking whether mkdir...does the check (unless already done)cache the result in ax cv mkdir one arg
Keep configuration actions outside AC CACHE CHECK: they have to beexecuted whether the check is run or cached.
A. Duret-Lutz Using GNU Autotools February 21, 2008 107 / 162
![Page 410: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/410.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
A Low-Level Macro: AX FUNC MKDIR ONE ARG
AC_DEFUN([AX_FUNC_MKDIR_ONE_ARG],[AC_CACHE_CHECK([whether mkdir takes one argument],
[ax_cv_mkdir_one_arg],[_AX_FUNC_MKDIR_ONE_ARG([ax_cv_mkdir_one_arg=yes],
[ax_cv_mkdir_one_arg=no])])if test x"$ax_cv_mkdir_one_arg" = xyes; thenAC_DEFINE([MKDIR_ONE_ARG], 1,
[Define if mkdir takes only one argument.])fi]) # AX_FUNC_MKDIR_ONE_ARG
AC CACHE CHECKprints checking whether mkdir...does the check (unless already done)cache the result in ax cv mkdir one arg
Keep configuration actions outside AC CACHE CHECK: they have to beexecuted whether the check is run or cached.
A. Duret-Lutz Using GNU Autotools February 21, 2008 107 / 162
![Page 411: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/411.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
A Low-Level Macro: AX FUNC MKDIR ONE ARG
AC_DEFUN([AX_FUNC_MKDIR_ONE_ARG],[AC_CACHE_CHECK([whether mkdir takes one argument],
[ax_cv_mkdir_one_arg],[_AX_FUNC_MKDIR_ONE_ARG([ax_cv_mkdir_one_arg=yes],
[ax_cv_mkdir_one_arg=no])])if test x"$ax_cv_mkdir_one_arg" = xyes; thenAC_DEFINE([MKDIR_ONE_ARG], 1,
[Define if mkdir takes only one argument.])fi]) # AX_FUNC_MKDIR_ONE_ARG
AC CACHE CHECKprints checking whether mkdir...does the check (unless already done)cache the result in ax cv mkdir one arg
Keep configuration actions outside AC CACHE CHECK: they have to beexecuted whether the check is run or cached.
A. Duret-Lutz Using GNU Autotools February 21, 2008 107 / 162
![Page 412: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/412.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Recommendations for Writing Autoconf Macros
Test for features, not for systems.E.g., check whether mkdir() takes one argument, not whether you arecompiling for Win32.Your package will be more likely to adapt to untested systems.
Avoid writing tests that are conditional on previous tests.Have unconditional tests, with conditional actions.E.g., check for mkdir() even if mkdir() exists.
Do not reinvent the wheel.Autoconf comes with a lot of well-tested macros. Use them.
Remember to [quote].
Read the Portable Shell section of the Autoconf manual, beforewriting shell code.Test your macros on different systems.
Check test results in config.log .Get accounts on foreign systems:http://www.testdrive.hp.com/http://sourceforge.net/docs/E02/
A. Duret-Lutz Using GNU Autotools February 21, 2008 108 / 162
![Page 413: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/413.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Recommendations for Writing Autoconf Macros
Test for features, not for systems.E.g., check whether mkdir() takes one argument, not whether you arecompiling for Win32.Your package will be more likely to adapt to untested systems.
Avoid writing tests that are conditional on previous tests.Have unconditional tests, with conditional actions.E.g., check for mkdir() even if mkdir() exists.
Do not reinvent the wheel.Autoconf comes with a lot of well-tested macros. Use them.
Remember to [quote].
Read the Portable Shell section of the Autoconf manual, beforewriting shell code.Test your macros on different systems.
Check test results in config.log .Get accounts on foreign systems:http://www.testdrive.hp.com/http://sourceforge.net/docs/E02/
A. Duret-Lutz Using GNU Autotools February 21, 2008 108 / 162
![Page 414: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/414.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Recommendations for Writing Autoconf Macros
Test for features, not for systems.E.g., check whether mkdir() takes one argument, not whether you arecompiling for Win32.Your package will be more likely to adapt to untested systems.
Avoid writing tests that are conditional on previous tests.Have unconditional tests, with conditional actions.E.g., check for mkdir() even if mkdir() exists.
Do not reinvent the wheel.Autoconf comes with a lot of well-tested macros. Use them.
Remember to [quote].
Read the Portable Shell section of the Autoconf manual, beforewriting shell code.Test your macros on different systems.
Check test results in config.log .Get accounts on foreign systems:http://www.testdrive.hp.com/http://sourceforge.net/docs/E02/
A. Duret-Lutz Using GNU Autotools February 21, 2008 108 / 162
![Page 415: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/415.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Recommendations for Writing Autoconf Macros
Test for features, not for systems.E.g., check whether mkdir() takes one argument, not whether you arecompiling for Win32.Your package will be more likely to adapt to untested systems.
Avoid writing tests that are conditional on previous tests.Have unconditional tests, with conditional actions.E.g., check for mkdir() even if mkdir() exists.
Do not reinvent the wheel.Autoconf comes with a lot of well-tested macros. Use them.
Remember to [quote].
Read the Portable Shell section of the Autoconf manual, beforewriting shell code.
Test your macros on different systems.Check test results in config.log .Get accounts on foreign systems:http://www.testdrive.hp.com/http://sourceforge.net/docs/E02/
A. Duret-Lutz Using GNU Autotools February 21, 2008 108 / 162
![Page 416: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/416.jpg)
Writing and Managing Custom Macros Writing Autoconf Macros
Recommendations for Writing Autoconf Macros
Test for features, not for systems.E.g., check whether mkdir() takes one argument, not whether you arecompiling for Win32.Your package will be more likely to adapt to untested systems.
Avoid writing tests that are conditional on previous tests.Have unconditional tests, with conditional actions.E.g., check for mkdir() even if mkdir() exists.
Do not reinvent the wheel.Autoconf comes with a lot of well-tested macros. Use them.
Remember to [quote].
Read the Portable Shell section of the Autoconf manual, beforewriting shell code.Test your macros on different systems.
Check test results in config.log .Get accounts on foreign systems:http://www.testdrive.hp.com/http://sourceforge.net/docs/E02/
A. Duret-Lutz Using GNU Autotools February 21, 2008 108 / 162
![Page 417: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/417.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
Managing Custom Macros with ‘aclocal’
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 109 / 162
![Page 418: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/418.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
aclocal.m4 and Third-Party Macros
‘autoconf’ knows only the macros it provides.(m4 *, AS *, AH *, AC *, AT *).
‘autoconf’ knows nothing about macro supplied by third-party tools(e.g., Automake’s AM * macros).
‘autoconf’ reads aclocal.m4 in addition to configure.ac .
aclocal.m4 should define the extra macros required by configure.ac .
‘aclocal’ automates the construction of aclocal.m4 from varioussources.
‘aclocal’ searches macros in
directories specified with -I options
a system-wide directory (usually /usr/ share/aclocal/ ) wherethird-party packages may install their macros
Automake’s own private macro directory
A. Duret-Lutz Using GNU Autotools February 21, 2008 110 / 162
![Page 419: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/419.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
aclocal.m4 and Third-Party Macros
‘autoconf’ knows only the macros it provides.(m4 *, AS *, AH *, AC *, AT *).
‘autoconf’ knows nothing about macro supplied by third-party tools(e.g., Automake’s AM * macros).
‘autoconf’ reads aclocal.m4 in addition to configure.ac .
aclocal.m4 should define the extra macros required by configure.ac .
‘aclocal’ automates the construction of aclocal.m4 from varioussources.
‘aclocal’ searches macros in
directories specified with -I options
a system-wide directory (usually /usr/ share/aclocal/ ) wherethird-party packages may install their macros
Automake’s own private macro directory
A. Duret-Lutz Using GNU Autotools February 21, 2008 110 / 162
![Page 420: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/420.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
aclocal.m4 and Third-Party Macros
‘autoconf’ knows only the macros it provides.(m4 *, AS *, AH *, AC *, AT *).
‘autoconf’ knows nothing about macro supplied by third-party tools(e.g., Automake’s AM * macros).
‘autoconf’ reads aclocal.m4 in addition to configure.ac .
aclocal.m4 should define the extra macros required by configure.ac .
‘aclocal’ automates the construction of aclocal.m4 from varioussources.
‘aclocal’ searches macros in
directories specified with -I options
a system-wide directory (usually /usr/ share/aclocal/ ) wherethird-party packages may install their macros
Automake’s own private macro directory
A. Duret-Lutz Using GNU Autotools February 21, 2008 110 / 162
![Page 421: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/421.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
Behind ‘autoreconf’
configure config.h.in Makefile.in src/Makefile.in
‘autoreconf’
‘aclocal’
‘autoconf’
‘autoheader’
‘automake’
configure.ac
aclocal.m4
Makefile.am src/Makefile.am
A. Duret-Lutz Using GNU Autotools February 21, 2008 111 / 162
![Page 422: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/422.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
aclocal.m4 and Third-Party Macros
‘autoconf’ knows only the macros it provides.(m4 *, AS *, AH *, AC *, AT *).
‘autoconf’ knows nothing about macro supplied by third-party tools(e.g., Automake’s AM * macros).
‘autoconf’ reads aclocal.m4 in addition to configure.ac .
aclocal.m4 should define the extra macros required by configure.ac .
‘aclocal’ automates the construction of aclocal.m4 from varioussources.
‘aclocal’ searches macros in
directories specified with -I options
a system-wide directory (usually /usr/ share/aclocal/ ) wherethird-party packages may install their macros
Automake’s own private macro directory
A. Duret-Lutz Using GNU Autotools February 21, 2008 112 / 162
![Page 423: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/423.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
Managing Custom Macros in Your Package
Create a m4/ subdirectory.
Put your macros there.E.g., define AX FUNC MKDIR and AX FUNC MKDIR ONE ARG inm4/mkdir.m4 .(The extension must be *.m4)
Add ACLOCAL AMFLAGS = -I m4 to the top-level Makefile.am.
Add AC CONFIG MACRO DIR([m4]) to configure.ac . (This is notstrictly needed yet, but let’s be future-proof.)
Use your macros in configure.ac .
The ACLOCAL AMFLAGS are used by ‘autoreconf’ and by the Makefilerebuild rule when they need to run ‘aclocal’.Local macros that are used are automatically distributed. (Those that arenot used are simply ignored.)You need such a setup to use Gettext, and the upcoming Libtool 2.0.
A. Duret-Lutz Using GNU Autotools February 21, 2008 113 / 162
![Page 424: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/424.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
Managing Custom Macros in Your Package
Create a m4/ subdirectory.
Put your macros there.E.g., define AX FUNC MKDIR and AX FUNC MKDIR ONE ARG inm4/mkdir.m4 .(The extension must be *.m4)
Add ACLOCAL AMFLAGS = -I m4 to the top-level Makefile.am.
Add AC CONFIG MACRO DIR([m4]) to configure.ac . (This is notstrictly needed yet, but let’s be future-proof.)
Use your macros in configure.ac .
The ACLOCAL AMFLAGS are used by ‘autoreconf’ and by the Makefilerebuild rule when they need to run ‘aclocal’.
Local macros that are used are automatically distributed. (Those that arenot used are simply ignored.)You need such a setup to use Gettext, and the upcoming Libtool 2.0.
A. Duret-Lutz Using GNU Autotools February 21, 2008 113 / 162
![Page 425: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/425.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
Managing Custom Macros in Your Package
Create a m4/ subdirectory.
Put your macros there.E.g., define AX FUNC MKDIR and AX FUNC MKDIR ONE ARG inm4/mkdir.m4 .(The extension must be *.m4)
Add ACLOCAL AMFLAGS = -I m4 to the top-level Makefile.am.
Add AC CONFIG MACRO DIR([m4]) to configure.ac . (This is notstrictly needed yet, but let’s be future-proof.)
Use your macros in configure.ac .
The ACLOCAL AMFLAGS are used by ‘autoreconf’ and by the Makefilerebuild rule when they need to run ‘aclocal’.Local macros that are used are automatically distributed. (Those that arenot used are simply ignored.)
You need such a setup to use Gettext, and the upcoming Libtool 2.0.
A. Duret-Lutz Using GNU Autotools February 21, 2008 113 / 162
![Page 426: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/426.jpg)
Writing and Managing Custom Macros Managing Custom Macros with ‘aclocal’
Managing Custom Macros in Your Package
Create a m4/ subdirectory.
Put your macros there.E.g., define AX FUNC MKDIR and AX FUNC MKDIR ONE ARG inm4/mkdir.m4 .(The extension must be *.m4)
Add ACLOCAL AMFLAGS = -I m4 to the top-level Makefile.am.
Add AC CONFIG MACRO DIR([m4]) to configure.ac . (This is notstrictly needed yet, but let’s be future-proof.)
Use your macros in configure.ac .
The ACLOCAL AMFLAGS are used by ‘autoreconf’ and by the Makefilerebuild rule when they need to run ‘aclocal’.Local macros that are used are automatically distributed. (Those that arenot used are simply ignored.)You need such a setup to use Gettext, and the upcoming Libtool 2.0.
A. Duret-Lutz Using GNU Autotools February 21, 2008 113 / 162
![Page 427: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/427.jpg)
Libtool
Libtool
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 114 / 162
![Page 428: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/428.jpg)
Libtool
Shared Libraries: A Portability Hell
Almost each system has its own format of shared library
libhello.solibhello.dlllibhello.sllibhello.dylib...
Building will require different flags
-fPIC, -shared-KPIC, -G-bM:SRE...
Linking against the library may also require specific flags.
There is no way for a developer to keep track of all these details.
Quiz: match each of the above example with its OS.
Not all systems support shared libraries.
A. Duret-Lutz Using GNU Autotools February 21, 2008 115 / 162
![Page 429: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/429.jpg)
Libtool
Shared Libraries: A Portability Hell
Almost each system has its own format of shared library
libhello.solibhello.dlllibhello.sllibhello.dylib...
Building will require different flags
-fPIC, -shared-KPIC, -G-bM:SRE...
Linking against the library may also require specific flags.
There is no way for a developer to keep track of all these details.
Quiz: match each of the above example with its OS.
Not all systems support shared libraries.
A. Duret-Lutz Using GNU Autotools February 21, 2008 115 / 162
![Page 430: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/430.jpg)
Libtool
Shared Libraries: A Portability Hell
Almost each system has its own format of shared library
libhello.solibhello.dlllibhello.sllibhello.dylib...
Building will require different flags
-fPIC, -shared-KPIC, -G-bM:SRE...
Linking against the library may also require specific flags.
There is no way for a developer to keep track of all these details.
Quiz: match each of the above example with its OS.
Not all systems support shared libraries.
A. Duret-Lutz Using GNU Autotools February 21, 2008 115 / 162
![Page 431: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/431.jpg)
Libtool
Shared Libraries: A Portability Hell
Almost each system has its own format of shared library
libhello.solibhello.dlllibhello.sllibhello.dylib...
Building will require different flags
-fPIC, -shared-KPIC, -G-bM:SRE...
Linking against the library may also require specific flags.
There is no way for a developer to keep track of all these details.
Quiz: match each of the above example with its OS.
Not all systems support shared libraries.
A. Duret-Lutz Using GNU Autotools February 21, 2008 115 / 162
![Page 432: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/432.jpg)
Libtool
Shared Libraries: A Portability Hell
Almost each system has its own format of shared library
libhello.solibhello.dlllibhello.sllibhello.dylib...
Building will require different flags
-fPIC, -shared-KPIC, -G-bM:SRE...
Linking against the library may also require specific flags.
There is no way for a developer to keep track of all these details.
Quiz: match each of the above example with its OS.
Not all systems support shared libraries.
A. Duret-Lutz Using GNU Autotools February 21, 2008 115 / 162
![Page 433: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/433.jpg)
Libtool
Shared Libraries: Libtool’s Solution
A new library format that abstracts all the others
libhello.la (libtool archive)
A wrapper script for the compiler and linker
translates operations involving libhello.la into the correct operation forthe current system using the real library
In a Makefile.am, you simply create and link against *.la files.
These operations are translated appropriately.
A. Duret-Lutz Using GNU Autotools February 21, 2008 116 / 162
![Page 434: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/434.jpg)
Libtool
Shared Libraries: Libtool’s Solution
A new library format that abstracts all the others
libhello.la (libtool archive)
A wrapper script for the compiler and linker
translates operations involving libhello.la into the correct operation forthe current system using the real library
In a Makefile.am, you simply create and link against *.la files.
These operations are translated appropriately.
A. Duret-Lutz Using GNU Autotools February 21, 2008 116 / 162
![Page 435: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/435.jpg)
Libtool
Shared Libraries: Libtool’s Solution
A new library format that abstracts all the others
libhello.la (libtool archive)
A wrapper script for the compiler and linker
translates operations involving libhello.la into the correct operation forthe current system using the real library
In a Makefile.am, you simply create and link against *.la files.
These operations are translated appropriately.
A. Duret-Lutz Using GNU Autotools February 21, 2008 116 / 162
![Page 436: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/436.jpg)
Libtool
Setting Up Libtool: Roadmap
Call AC PROG LIBTOOL in configure.ac .
Use LTLIBRARIES to declare libtool archives in Makefile.am
Use LDADD to link against local libtool archives.
Makefile.amlib_LTLIBRARIES = libfoo.lalibfoo_la_SOURCES = foo.c foo.h etc.c
bin_PROGRAMS = runmerunme_SOURCES = main.crunme_LDADD = libfoo.la
A. Duret-Lutz Using GNU Autotools February 21, 2008 117 / 162
![Page 437: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/437.jpg)
Libtool
Setting Up Libtool: Roadmap
Call AC PROG LIBTOOL in configure.ac .
Use LTLIBRARIES to declare libtool archives in Makefile.am
Use LDADD to link against local libtool archives.
Makefile.amlib_LTLIBRARIES = libfoo.lalibfoo_la_SOURCES = foo.c foo.h etc.c
bin_PROGRAMS = runmerunme_SOURCES = main.crunme_LDADD = libfoo.la
A. Duret-Lutz Using GNU Autotools February 21, 2008 117 / 162
![Page 438: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/438.jpg)
Libtool
Setting Up Libtool: Roadmap
Call AC PROG LIBTOOL in configure.ac .
Use LTLIBRARIES to declare libtool archives in Makefile.am
Use LDADD to link against local libtool archives.
Makefile.amlib_LTLIBRARIES = libfoo.lalibfoo_la_SOURCES = foo.c foo.h etc.c
bin_PROGRAMS = runmerunme_SOURCES = main.crunme_LDADD = libfoo.la
A. Duret-Lutz Using GNU Autotools February 21, 2008 117 / 162
![Page 439: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/439.jpg)
Libtool
Hello World Using Libtool: C Files
lib/ say.c
#include <config.h>#include <stdio.h>
void say_hello (void){puts ("Hello World!");puts ("This is " PACKAGE_STRING ".");
}
lib/ say.h
void say_hello (void);
src/main.c
#include "say.h"
int main (void){say_hello ();return 0;
}
A. Duret-Lutz Using GNU Autotools February 21, 2008 118 / 162
![Page 440: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/440.jpg)
Libtool
Hello World Using Libtool: Makefile.ams
lib/Makefile.am
lib_LTLIBRARIES = libhello.lalibhello_la_SOURCES = say.c say.h
src/Makefile.am
AM_CPPFLAGS = -I$(srcdir)/../libbin_PROGRAMS = hellohello_SOURCES = main.chello_LDADD = ../lib/libhello.la
Makefile.amSUBDIRS = lib src
A. Duret-Lutz Using GNU Autotools February 21, 2008 119 / 162
![Page 441: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/441.jpg)
Libtool
Hello World Using Libtool: configure.ac
configure.ac
AC_INIT([amhello], [2.0], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_LIBTOOLAC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile])AC_OUTPUT
A. Duret-Lutz Using GNU Autotools February 21, 2008 120 / 162
![Page 442: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/442.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % ls -R
.:Makefile.am configure.ac lib/ src/
./lib:Makefile.am say.c say.h
./src:Makefile.am main.c
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 443: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/443.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % ls -R
.:Makefile.am configure.ac lib/ src/
./lib:Makefile.am say.c say.h
./src:Makefile.am main.c
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 444: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/444.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % autoreconf --install
Putting files in AC_CONFIG_AUX_DIR, ‘build-aux’.configure.ac: installing ‘build-aux/install-sh’configure.ac: installing ‘build-aux/missing’lib/Makefile.am: installing ‘build-aux/depcomp’~/amhello % ./configure --prefix ~/test
...~/amhello % make && make install
...~/amhello % ~/test/bin/hello
Hello World!This is amhello 2.0.~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 445: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/445.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % autoreconf --install
Putting files in AC_CONFIG_AUX_DIR, ‘build-aux’.configure.ac: installing ‘build-aux/install-sh’configure.ac: installing ‘build-aux/missing’lib/Makefile.am: installing ‘build-aux/depcomp’~/amhello %
./configure --prefix ~/test
...~/amhello % make && make install
...~/amhello % ~/test/bin/hello
Hello World!This is amhello 2.0.~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 446: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/446.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % autoreconf --install
Putting files in AC_CONFIG_AUX_DIR, ‘build-aux’.configure.ac: installing ‘build-aux/install-sh’configure.ac: installing ‘build-aux/missing’lib/Makefile.am: installing ‘build-aux/depcomp’~/amhello % ./configure --prefix ~/test
...~/amhello %
make && make install
...~/amhello % ~/test/bin/hello
Hello World!This is amhello 2.0.~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 447: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/447.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % autoreconf --install
Putting files in AC_CONFIG_AUX_DIR, ‘build-aux’.configure.ac: installing ‘build-aux/install-sh’configure.ac: installing ‘build-aux/missing’lib/Makefile.am: installing ‘build-aux/depcomp’~/amhello % ./configure --prefix ~/test
...~/amhello % make && make install
...~/amhello %
~/test/bin/hello
Hello World!This is amhello 2.0.~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 448: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/448.jpg)
Libtool
Hello World Using Libtool: ‘autoreconf’
~/amhello % autoreconf --install
Putting files in AC_CONFIG_AUX_DIR, ‘build-aux’.configure.ac: installing ‘build-aux/install-sh’configure.ac: installing ‘build-aux/missing’lib/Makefile.am: installing ‘build-aux/depcomp’~/amhello % ./configure --prefix ~/test
...~/amhello % make && make install
...~/amhello % ~/test/bin/hello
Hello World!This is amhello 2.0.~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 121 / 162
![Page 449: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/449.jpg)
Libtool
What Was Built and Installed
~/amhello % ls -R ~/test
/home/adl/test:bin/ lib//home/adl/test/bin:hello*/home/adl/test/lib:libhello.a libhello.so@ libhello.so.0.0.0*libhello.la* libhello.so.0@~/amhello %
ldd ~/test/bin/hello
libhello.so.0 => /home/adl/test/lib/libhello.so.0 (0xb7fe7000)libc.so.6 => /lib/tls/libc.so.6 (0xb7e9c000)lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)~/amhello % ldd src/hello
not a dynamic executable~/amhello % file src/hello
src/hello: Bourne shell script text executable~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 122 / 162
![Page 450: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/450.jpg)
Libtool
What Was Built and Installed
~/amhello % ls -R ~/test
/home/adl/test:bin/ lib//home/adl/test/bin:hello*/home/adl/test/lib:libhello.a libhello.so@ libhello.so.0.0.0*libhello.la* libhello.so.0@~/amhello % ldd ~/test/bin/hello
libhello.so.0 => /home/adl/test/lib/libhello.so.0 (0xb7fe7000)libc.so.6 => /lib/tls/libc.so.6 (0xb7e9c000)lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)~/amhello %
ldd src/hello
not a dynamic executable~/amhello % file src/hello
src/hello: Bourne shell script text executable~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 122 / 162
![Page 451: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/451.jpg)
Libtool
What Was Built and Installed
~/amhello % ls -R ~/test
/home/adl/test:bin/ lib//home/adl/test/bin:hello*/home/adl/test/lib:libhello.a libhello.so@ libhello.so.0.0.0*libhello.la* libhello.so.0@~/amhello % ldd ~/test/bin/hello
libhello.so.0 => /home/adl/test/lib/libhello.so.0 (0xb7fe7000)libc.so.6 => /lib/tls/libc.so.6 (0xb7e9c000)lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)~/amhello % ldd src/hello
not a dynamic executable~/amhello %
file src/hello
src/hello: Bourne shell script text executable~/amhello %
A. Duret-Lutz Using GNU Autotools February 21, 2008 122 / 162
![Page 452: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/452.jpg)
Libtool
What Was Built and Installed
~/amhello % ls -R ~/test
/home/adl/test:bin/ lib//home/adl/test/bin:hello*/home/adl/test/lib:libhello.a libhello.so@ libhello.so.0.0.0*libhello.la* libhello.so.0@~/amhello % ldd ~/test/bin/hello
libhello.so.0 => /home/adl/test/lib/libhello.so.0 (0xb7fe7000)libc.so.6 => /lib/tls/libc.so.6 (0xb7e9c000)lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0xb7fea000)~/amhello % ldd src/hello
not a dynamic executable~/amhello % file src/hello
src/hello: Bourne shell script text executable~/amhello %A. Duret-Lutz Using GNU Autotools February 21, 2008 122 / 162
![Page 453: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/453.jpg)
Libtool
Building Shared or Static Libraries
By default, both static and shared libraries are built.
This default can be changed in a package using two macros:
AC DISABLE SHARED do not build shared libraries by defaultAC DISABLE STATIC do not build static libraries by default
The installer can override these settings using configure options.
--enable-shared build shared libraries--disable-shared don’t--enable-static build static libraries--disable-static don’t
At least one flavor is built, always.
Some systems don’t leave any choice.
A. Duret-Lutz Using GNU Autotools February 21, 2008 123 / 162
![Page 454: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/454.jpg)
Libtool
Building Shared or Static Libraries
By default, both static and shared libraries are built.
This default can be changed in a package using two macros:
AC DISABLE SHARED do not build shared libraries by defaultAC DISABLE STATIC do not build static libraries by default
The installer can override these settings using configure options.
--enable-shared build shared libraries--disable-shared don’t--enable-static build static libraries--disable-static don’t
At least one flavor is built, always.
Some systems don’t leave any choice.
A. Duret-Lutz Using GNU Autotools February 21, 2008 123 / 162
![Page 455: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/455.jpg)
Libtool
Building Shared or Static Libraries
By default, both static and shared libraries are built.
This default can be changed in a package using two macros:
AC DISABLE SHARED do not build shared libraries by defaultAC DISABLE STATIC do not build static libraries by default
The installer can override these settings using configure options.
--enable-shared build shared libraries--disable-shared don’t--enable-static build static libraries--disable-static don’t
At least one flavor is built, always.
Some systems don’t leave any choice.
A. Duret-Lutz Using GNU Autotools February 21, 2008 123 / 162
![Page 456: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/456.jpg)
Libtool
The src/hello Wrapper Script
src/hello can be a wrapper scriptDepending on Libtool’s configuration.
The real binary has been built elsewhereLibtool hides it in the build tree (don’t bother about it)
This wrapper script runs the real binary, and arranges so it finds thenot-yet-installed libraries
This way src/hello can be run, for instance in a test suite
Do not debug the shell script!
~/amhello % gdb -q src/hello
"src/hello": not in executable format: File format not recognized
(gdb)
Prefix such commands with libtool --mode=execute
~/amhello % libtool --mode=execute gdb -q src/hello
A. Duret-Lutz Using GNU Autotools February 21, 2008 124 / 162
![Page 457: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/457.jpg)
Libtool
The src/hello Wrapper Script
src/hello can be a wrapper scriptDepending on Libtool’s configuration.
The real binary has been built elsewhereLibtool hides it in the build tree (don’t bother about it)
This wrapper script runs the real binary, and arranges so it finds thenot-yet-installed libraries
This way src/hello can be run, for instance in a test suite
Do not debug the shell script!
~/amhello % gdb -q src/hello
"src/hello": not in executable format: File format not recognized
(gdb)
Prefix such commands with libtool --mode=execute
~/amhello % libtool --mode=execute gdb -q src/hello
A. Duret-Lutz Using GNU Autotools February 21, 2008 124 / 162
![Page 458: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/458.jpg)
Libtool
The src/hello Wrapper Script
src/hello can be a wrapper scriptDepending on Libtool’s configuration.
The real binary has been built elsewhereLibtool hides it in the build tree (don’t bother about it)
This wrapper script runs the real binary, and arranges so it finds thenot-yet-installed libraries
This way src/hello can be run, for instance in a test suite
Do not debug the shell script!
~/amhello % gdb -q src/hello
"src/hello": not in executable format: File format not recognized
(gdb)
Prefix such commands with libtool --mode=execute
~/amhello % libtool --mode=execute gdb -q src/hello
A. Duret-Lutz Using GNU Autotools February 21, 2008 124 / 162
![Page 459: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/459.jpg)
Libtool
The src/hello Wrapper Script
src/hello can be a wrapper scriptDepending on Libtool’s configuration.
The real binary has been built elsewhereLibtool hides it in the build tree (don’t bother about it)
This wrapper script runs the real binary, and arranges so it finds thenot-yet-installed libraries
This way src/hello can be run, for instance in a test suite
Do not debug the shell script!
~/amhello % gdb -q src/hello
"src/hello": not in executable format: File format not recognized
(gdb)
Prefix such commands with libtool --mode=execute
~/amhello % libtool --mode=execute gdb -q src/hello
A. Duret-Lutz Using GNU Autotools February 21, 2008 124 / 162
![Page 460: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/460.jpg)
Libtool
The src/hello Wrapper Script
src/hello can be a wrapper scriptDepending on Libtool’s configuration.
The real binary has been built elsewhereLibtool hides it in the build tree (don’t bother about it)
This wrapper script runs the real binary, and arranges so it finds thenot-yet-installed libraries
This way src/hello can be run, for instance in a test suite
Do not debug the shell script!
~/amhello % gdb -q src/hello
"src/hello": not in executable format: File format not recognized
(gdb)
Prefix such commands with libtool --mode=execute
~/amhello % libtool --mode=execute gdb -q src/hello
A. Duret-Lutz Using GNU Autotools February 21, 2008 124 / 162
![Page 461: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/461.jpg)
Libtool
Versioning Libtool Libraries: Interfaces
Versioning libraries allow several versions to coexist.
It ensures programs use the library that implements the interface theyrequire.
Interface = public variables and functions, I/O, formats, protocols, ...
Interfaces are identified using integers.
A program remembers the interface numbers of the libraries it waslinked against.
A library can implement several interfaces.
E.g., adding new functions changes the interface, but does not breakold interfaces.
Hence libtool’s versioning format encodes a range of supportedinterfaces.
Interface numbers are not release numbers.
A. Duret-Lutz Using GNU Autotools February 21, 2008 125 / 162
![Page 462: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/462.jpg)
Libtool
Versioning Libtool Libraries: Interfaces
Versioning libraries allow several versions to coexist.
It ensures programs use the library that implements the interface theyrequire.
Interface = public variables and functions, I/O, formats, protocols, ...
Interfaces are identified using integers.
A program remembers the interface numbers of the libraries it waslinked against.
A library can implement several interfaces.
E.g., adding new functions changes the interface, but does not breakold interfaces.
Hence libtool’s versioning format encodes a range of supportedinterfaces.
Interface numbers are not release numbers.
A. Duret-Lutz Using GNU Autotools February 21, 2008 125 / 162
![Page 463: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/463.jpg)
Libtool
Versioning Libtool Libraries: Interfaces
Versioning libraries allow several versions to coexist.
It ensures programs use the library that implements the interface theyrequire.
Interface = public variables and functions, I/O, formats, protocols, ...
Interfaces are identified using integers.
A program remembers the interface numbers of the libraries it waslinked against.
A library can implement several interfaces.
E.g., adding new functions changes the interface, but does not breakold interfaces.
Hence libtool’s versioning format encodes a range of supportedinterfaces.
Interface numbers are not release numbers.
A. Duret-Lutz Using GNU Autotools February 21, 2008 125 / 162
![Page 464: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/464.jpg)
Libtool
Versioning Libtool Libraries: Interfaces
Versioning libraries allow several versions to coexist.
It ensures programs use the library that implements the interface theyrequire.
Interface = public variables and functions, I/O, formats, protocols, ...
Interfaces are identified using integers.
A program remembers the interface numbers of the libraries it waslinked against.
A library can implement several interfaces.
E.g., adding new functions changes the interface, but does not breakold interfaces.
Hence libtool’s versioning format encodes a range of supportedinterfaces.
Interface numbers are not release numbers.
A. Duret-Lutz Using GNU Autotools February 21, 2008 125 / 162
![Page 465: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/465.jpg)
Libtool
Versioning Libtool Libraries: Version Triplets
CURRENT The latest interface implemented.
REVISION The implementation number of CURRENT(read: number of bugs fixed...)
AGE The number of interfaces implemented, minus one.The library supports all interfaces between CURRENT − AGEand CURRENT.
These numbers should be specified using -version-info.
lib/Makefile.am
lib_LTLIBRARIES = libhello.lalibhello_la_SOURCES = say.c say.hlibhello_la_LDFLAGS = -version-info CURRENT:REVISION:AGE
The default version is 0:0:0. It’s also a good initial version.
A. Duret-Lutz Using GNU Autotools February 21, 2008 126 / 162
![Page 466: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/466.jpg)
Libtool
Versioning Libtool Libraries: Version Triplets
CURRENT The latest interface implemented.
REVISION The implementation number of CURRENT(read: number of bugs fixed...)
AGE The number of interfaces implemented, minus one.The library supports all interfaces between CURRENT − AGEand CURRENT.
These numbers should be specified using -version-info.
lib/Makefile.am
lib_LTLIBRARIES = libhello.lalibhello_la_SOURCES = say.c say.hlibhello_la_LDFLAGS = -version-info CURRENT:REVISION:AGE
The default version is 0:0:0. It’s also a good initial version.
A. Duret-Lutz Using GNU Autotools February 21, 2008 126 / 162
![Page 467: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/467.jpg)
Libtool
Versioning Libtool Libraries: Version Triplets
CURRENT The latest interface implemented.
REVISION The implementation number of CURRENT(read: number of bugs fixed...)
AGE The number of interfaces implemented, minus one.The library supports all interfaces between CURRENT − AGEand CURRENT.
These numbers should be specified using -version-info.
lib/Makefile.am
lib_LTLIBRARIES = libhello.lalibhello_la_SOURCES = say.c say.hlibhello_la_LDFLAGS = -version-info 0:0:0
The default version is 0:0:0. It’s also a good initial version.
A. Duret-Lutz Using GNU Autotools February 21, 2008 126 / 162
![Page 468: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/468.jpg)
Libtool
Versioning Libtool Libraries: Bumping Versions
Remember to bump library versions before a release.Suppose the old version was CURRENT:REVISION:AGE.
If you have bump the version to
not changed the interface CURRENT : REVISION+1 : AGE(bug fixes)
augmented the interface CURRENT+1 : 0 : AGE+1(new functions)
broken old interface CURRENT+1 : 0 : 0(e.g. removed functions)
A. Duret-Lutz Using GNU Autotools February 21, 2008 127 / 162
![Page 469: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/469.jpg)
Gettext Introducing Gettext
Introducing Gettext
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 128 / 162
![Page 470: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/470.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization
= I18nChanging a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization
= L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 471: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/471.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization
= I18n
Changing a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization
= L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 472: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/472.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization
= I18n
Changing a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization
= L10n
Providing an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 473: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/473.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization = I18nChanging a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization = L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 474: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/474.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization = I18nChanging a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization = L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 475: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/475.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization = I18nChanging a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization = L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 476: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/476.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization = I18nChanging a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization = L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.
A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 477: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/477.jpg)
Gettext Introducing Gettext
Introducing Gettext
Internationalization = I18nChanging a program to support for multiple languages and culturalhabits.
Character handling (unicode...)Locale awareness (date formats, currencies, numbers, time zones, etc.)Localizability
Isolate localizable items (messages, pictures, etc.)Implement infrastructure necessary for localizing above items.
The programmer’s work.
Localization = L10nProviding an internationalized package the necessary bits to supportone’s native language and cultural habits.
Translate localizable items (messages, pictures, etc.) for one language.
The translator’s work.
Gettext = complete toolset for translating messages output by programs.A. Duret-Lutz Using GNU Autotools February 21, 2008 129 / 162
![Page 478: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/478.jpg)
Gettext Introducing Gettext
Translating Messages Made Easy
#include <config.h>#include <stdio.h>
#include "gettext.h"#define _(string) gettext (string)
void say_hello (void){puts ("Hello World!");puts ("This is " PACKAGE_STRING ".");
}
The program is written in English.
Messages that must be translated are marked with (...).‘xgettext’ builds catalogs of translatable messages from such strings.Translators will provide translated catalogs for their locale.
gettext looks up the translation of the English message in thecurrent locale’s catalog.
A. Duret-Lutz Using GNU Autotools February 21, 2008 130 / 162
![Page 479: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/479.jpg)
Gettext Introducing Gettext
Translating Messages Made Easy
#include <config.h>#include <stdio.h>#include "gettext.h"#define _(string) gettext (string)void say_hello (void){puts (_("Hello World!"));printf (_("This is %s.\n"), PACKAGE_STRING);
}
The program is written in English.Messages that must be translated are marked with (...).
‘xgettext’ builds catalogs of translatable messages from such strings.Translators will provide translated catalogs for their locale.
gettext looks up the translation of the English message in thecurrent locale’s catalog.
A. Duret-Lutz Using GNU Autotools February 21, 2008 130 / 162
![Page 480: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/480.jpg)
Gettext Introducing Gettext
Translating Messages Made Easy
#include <config.h>#include <stdio.h>#include "gettext.h"#define _(string) gettext (string)void say_hello (void){puts (_("Hello World!"));printf (_("This is %s.\n"), PACKAGE_STRING);
}
The program is written in English.Messages that must be translated are marked with (...).
‘xgettext’ builds catalogs of translatable messages from such strings.Translators will provide translated catalogs for their locale.
gettext looks up the translation of the English message in thecurrent locale’s catalog.
A. Duret-Lutz Using GNU Autotools February 21, 2008 130 / 162
![Page 481: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/481.jpg)
Gettext Internationalizing a Package, Start to Finish
Internationalizing a Package, Start to Finish
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 131 / 162
![Page 482: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/482.jpg)
Gettext Internationalizing a Package, Start to Finish
Internationalizing a Package, Start to Finish
Roadmap:
1 Start with a non-internationalized Hello World.
2 Invoke AM GNU GETTEXT from configure.ac
3 Run ‘gettextize’ to provide the basic infrastructure.
4 Fill in the configuration files left by ‘gettextize’.
5 Update src/Makefile.am to link hello with the necessary library.6 Update the code:
Initialize Gettext in main()Mark translatable strings.
7 Generate messages catalogs automatically.
We’ll talk about localization once this is done.
A. Duret-Lutz Using GNU Autotools February 21, 2008 132 / 162
![Page 483: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/483.jpg)
Gettext Internationalizing a Package, Start to Finish
Non Internationalized Hello World (1/2)
src/main.c
#include "say.h"
intmain (void){say_hello ();return 0;
}
src/ say.h
#ifndef AMHELLO_SAY_H# define AMHELLO_SAY_Hvoid say_hello (void);#endif
src/ say.c
#include <config.h>#include <stdio.h>
void say_hello (void){puts ("Hello World!");puts ("This is " PACKAGE_STRING ".");
}
A. Duret-Lutz Using GNU Autotools February 21, 2008 133 / 162
![Page 484: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/484.jpg)
Gettext Internationalizing a Package, Start to Finish
Non Internationalized Hello World (2/2)
configure.ac
AC_INIT([amhello], [3.0], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
Makefile.amSUBDIRS = src
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h
A. Duret-Lutz Using GNU Autotools February 21, 2008 134 / 162
![Page 485: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/485.jpg)
Gettext Internationalizing a Package, Start to Finish
Update configure.ac for Gettext
configure.ac
AC_INIT([amhello], [3.0], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AM_GNU_GETTEXT_VERSION([0.17])AM_GNU_GETTEXT([external])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
AM GNU GETTEXT VERSION = exactly which Gettext version to use.AM GNU GETTEXT([external])
the GNU libc or an external (= not distributed) Gettext library will beused if foundNLS (Native Language System) will be disabled otherwise
A. Duret-Lutz Using GNU Autotools February 21, 2008 135 / 162
![Page 486: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/486.jpg)
Gettext Internationalizing a Package, Start to Finish
Update configure.ac for Gettext
configure.ac
AC_INIT([amhello], [3.0], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AM_GNU_GETTEXT_VERSION([0.17])AM_GNU_GETTEXT([external])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
AM GNU GETTEXT VERSION = exactly which Gettext version to use.
AM GNU GETTEXT([external])the GNU libc or an external (= not distributed) Gettext library will beused if foundNLS (Native Language System) will be disabled otherwise
A. Duret-Lutz Using GNU Autotools February 21, 2008 135 / 162
![Page 487: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/487.jpg)
Gettext Internationalizing a Package, Start to Finish
Update configure.ac for Gettext
configure.ac
AC_INIT([amhello], [3.0], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AM_GNU_GETTEXT_VERSION([0.17])AM_GNU_GETTEXT([external])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile])AC_OUTPUT
AM GNU GETTEXT VERSION = exactly which Gettext version to use.AM GNU GETTEXT([external])
the GNU libc or an external (= not distributed) Gettext library will beused if foundNLS (Native Language System) will be disabled otherwise
A. Duret-Lutz Using GNU Autotools February 21, 2008 135 / 162
![Page 488: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/488.jpg)
Gettext Internationalizing a Package, Start to Finish
Running ‘gettextize’
You should run ‘gettextize’:
A first time, to install the Gettext infrastructure in your package.
Each time you upgrade Gettext to a new version.
~/amhello %
gettextize --copy --no-changelog
[...]~/amhello % cp /usr/share/gettext/gettext.h src
Install most of the Gettext infrastructure.
Copy gettext.h in the source tree, it will be distributed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 136 / 162
![Page 489: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/489.jpg)
Gettext Internationalizing a Package, Start to Finish
Running ‘gettextize’
You should run ‘gettextize’:
A first time, to install the Gettext infrastructure in your package.
Each time you upgrade Gettext to a new version.
~/amhello % gettextize --copy --no-changelog
[...]~/amhello %
cp /usr/share/gettext/gettext.h src
Install most of the Gettext infrastructure.
Copy gettext.h in the source tree, it will be distributed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 136 / 162
![Page 490: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/490.jpg)
Gettext Internationalizing a Package, Start to Finish
Running ‘gettextize’
You should run ‘gettextize’:
A first time, to install the Gettext infrastructure in your package.
Each time you upgrade Gettext to a new version.
~/amhello % gettextize --copy --no-changelog
[...]~/amhello % cp /usr/share/gettext/gettext.h src
Install most of the Gettext infrastructure.
Copy gettext.h in the source tree, it will be distributed.
A. Duret-Lutz Using GNU Autotools February 21, 2008 136 / 162
![Page 491: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/491.jpg)
Gettext Internationalizing a Package, Start to Finish
Gettextize Updated Some Files
configure.ac
AC_INIT([amhello], [3.0], [bug-report@address])AC_CONFIG_AUX_DIR([build-aux])AM_GNU_GETTEXT_VERSION([0.17])AM_GNU_GETTEXT([external])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_HEADERS([config.h])AC_CONFIG_FILES([Makefile src/Makefile po/Makefile.in])AC_OUTPUT
Makefile.amSUBDIRS = po srcACLOCAL_AMFLAGS = -I m4EXTRA_DIST = ...
src/Makefile.am
bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h
A. Duret-Lutz Using GNU Autotools February 21, 2008 137 / 162
![Page 492: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/492.jpg)
Gettext Internationalizing a Package, Start to Finish
po/Makevars and po/POTFILES.in
Fill po/Makevars.template and rename it as po/Makevars:
po/Makevars
DOMAIN = $(PACKAGE)subdir = potop_builddir = ..XGETTEXT_OPTIONS = --keyword=_ --keyword=N_COPYRIGHT_HOLDER = Your Name or Your EmployerMSGID_BUGS_ADDRESS = $(PACKAGE BUGREPORT)EXTRA_LOCALE_CATEGORIES =
List sources files that (may) contain translatable strings in POTFILES.in.
po/POTFILES.in
src/main.csrc/say.c
$(PACKAGE BUGREPORT) is thethird argument of AC INIT. Some
packages use a mailing listdedicated to translation issues
instead.
A. Duret-Lutz Using GNU Autotools February 21, 2008 138 / 162
![Page 493: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/493.jpg)
Gettext Internationalizing a Package, Start to Finish
po/Makevars and po/POTFILES.in
Fill po/Makevars.template and rename it as po/Makevars:
po/Makevars
DOMAIN = $(PACKAGE)subdir = potop_builddir = ..XGETTEXT_OPTIONS = --keyword=_ --keyword=N_COPYRIGHT_HOLDER = Your Name or Your EmployerMSGID_BUGS_ADDRESS = $(PACKAGE BUGREPORT)EXTRA_LOCALE_CATEGORIES =
List sources files that (may) contain translatable strings in POTFILES.in.
po/POTFILES.in
src/main.csrc/say.c
$(PACKAGE BUGREPORT) is thethird argument of AC INIT. Some
packages use a mailing listdedicated to translation issues
instead.
A. Duret-Lutz Using GNU Autotools February 21, 2008 138 / 162
![Page 494: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/494.jpg)
Gettext Internationalizing a Package, Start to Finish
po/Makevars and po/POTFILES.in
Fill po/Makevars.template and rename it as po/Makevars:
po/Makevars
DOMAIN = $(PACKAGE)subdir = potop_builddir = ..XGETTEXT_OPTIONS = --keyword=_ --keyword=N_COPYRIGHT_HOLDER = Your Name or Your EmployerMSGID_BUGS_ADDRESS = $(PACKAGE BUGREPORT)EXTRA_LOCALE_CATEGORIES =
List sources files that (may) contain translatable strings in POTFILES.in.
po/POTFILES.in
src/main.csrc/say.c
$(PACKAGE BUGREPORT) is thethird argument of AC INIT. Some
packages use a mailing listdedicated to translation issues
instead.
A. Duret-Lutz Using GNU Autotools February 21, 2008 138 / 162
![Page 495: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/495.jpg)
Gettext Internationalizing a Package, Start to Finish
What’s Next?
Done:
1 Start with a non-internationalized Hello World.
2 Invoke AM GNU GETTEXT from configure.ac
3 Run ‘gettextize’ to provide the basic infrastructure.
4 Fill in the configuration files left by ‘gettextize’.
Now, ‘autoreconf --install; ./configure; make’ should work.
To do:
5 Update src/Makefile.am to link hello with the necessary library.6 Update the code:
Initialize Gettext in main()Mark translatable strings.
7 Generate messages catalogs automatically.
A. Duret-Lutz Using GNU Autotools February 21, 2008 139 / 162
![Page 496: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/496.jpg)
Gettext Internationalizing a Package, Start to Finish
What’s Next?
Done:
1 Start with a non-internationalized Hello World.
2 Invoke AM GNU GETTEXT from configure.ac
3 Run ‘gettextize’ to provide the basic infrastructure.
4 Fill in the configuration files left by ‘gettextize’.
Now, ‘autoreconf --install; ./configure; make’ should work.
To do:
5 Update src/Makefile.am to link hello with the necessary library.6 Update the code:
Initialize Gettext in main()Mark translatable strings.
7 Generate messages catalogs automatically.
A. Duret-Lutz Using GNU Autotools February 21, 2008 139 / 162
![Page 497: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/497.jpg)
Gettext Internationalizing a Package, Start to Finish
Updating src/Makefile.am
src/Makefile.am
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h
gettext.hhello_LDADD = $(LIBINTL)
$(LIBINTL) lists the libraries any internationalized program shouldbe linked against.
We can strip the leading hello and use the global LDADD instead.
Mention gettext.h (we will use it shortly) so it is distributed.
$(LOCALEDIR) is the place where message catalogs are installed.This is needed during initialization.
A. Duret-Lutz Using GNU Autotools February 21, 2008 140 / 162
![Page 498: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/498.jpg)
Gettext Internationalizing a Package, Start to Finish
Updating src/Makefile.am
src/Makefile.am
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h
gettext.h
hello_LDADD = $(LIBINTL)
$(LIBINTL) lists the libraries any internationalized program shouldbe linked against.
We can strip the leading hello and use the global LDADD instead.
Mention gettext.h (we will use it shortly) so it is distributed.
$(LOCALEDIR) is the place where message catalogs are installed.This is needed during initialization.
A. Duret-Lutz Using GNU Autotools February 21, 2008 140 / 162
![Page 499: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/499.jpg)
Gettext Internationalizing a Package, Start to Finish
Updating src/Makefile.am
src/Makefile.am
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h
gettext.h
LDADD = $(LIBINTL)
$(LIBINTL) lists the libraries any internationalized program shouldbe linked against.
We can strip the leading hello and use the global LDADD instead.
Mention gettext.h (we will use it shortly) so it is distributed.
$(LOCALEDIR) is the place where message catalogs are installed.This is needed during initialization.
A. Duret-Lutz Using GNU Autotools February 21, 2008 140 / 162
![Page 500: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/500.jpg)
Gettext Internationalizing a Package, Start to Finish
Updating src/Makefile.am
src/Makefile.am
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"
bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h gettext.hLDADD = $(LIBINTL)
$(LIBINTL) lists the libraries any internationalized program shouldbe linked against.
We can strip the leading hello and use the global LDADD instead.
Mention gettext.h (we will use it shortly) so it is distributed.
$(LOCALEDIR) is the place where message catalogs are installed.This is needed during initialization.
A. Duret-Lutz Using GNU Autotools February 21, 2008 140 / 162
![Page 501: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/501.jpg)
Gettext Internationalizing a Package, Start to Finish
Updating src/Makefile.am
src/Makefile.am
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"bin_PROGRAMS = hellohello_SOURCES = main.c say.c say.h gettext.hLDADD = $(LIBINTL)
$(LIBINTL) lists the libraries any internationalized program shouldbe linked against.
We can strip the leading hello and use the global LDADD instead.
Mention gettext.h (we will use it shortly) so it is distributed.
$(LOCALEDIR) is the place where message catalogs are installed.This is needed during initialization.
A. Duret-Lutz Using GNU Autotools February 21, 2008 140 / 162
![Page 502: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/502.jpg)
Gettext Internationalizing a Package, Start to Finish
Initializing Gettext
src/main.c
#include <config.h>#include <locale.h>#include "gettext.h"
#include "say.h"intmain (void){
setlocale (LC_ALL, "");bindtextdomain (PACKAGE,
LOCALEDIR);textdomain (PACKAGE);
say_hello();return 0;
}
Initialize the locale asspecified in theenvironment.(E.g., the user setsLANG=fr FR in theenvironment to getFrench messages.)
Tell Gettext where tofind message catalogs forthis program.(All programs in thesame package usuallyshare the same messagecatalog.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 141 / 162
![Page 503: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/503.jpg)
Gettext Internationalizing a Package, Start to Finish
Initializing Gettext
src/main.c
#include <config.h>
#include <locale.h>
#include "gettext.h"
#include "say.h"intmain (void){setlocale (LC_ALL, "");
bindtextdomain (PACKAGE,LOCALEDIR);
textdomain (PACKAGE);
say_hello();return 0;
}
Initialize the locale asspecified in theenvironment.(E.g., the user setsLANG=fr FR in theenvironment to getFrench messages.)
Tell Gettext where tofind message catalogs forthis program.(All programs in thesame package usuallyshare the same messagecatalog.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 141 / 162
![Page 504: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/504.jpg)
Gettext Internationalizing a Package, Start to Finish
Initializing Gettext
src/main.c
#include <config.h>#include <locale.h>#include "gettext.h"#include "say.h"intmain (void){setlocale (LC_ALL, "");bindtextdomain (PACKAGE,
LOCALEDIR);textdomain (PACKAGE);say_hello();return 0;
}
Initialize the locale asspecified in theenvironment.(E.g., the user setsLANG=fr FR in theenvironment to getFrench messages.)
Tell Gettext where tofind message catalogs forthis program.(All programs in thesame package usuallyshare the same messagecatalog.)
A. Duret-Lutz Using GNU Autotools February 21, 2008 141 / 162
![Page 505: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/505.jpg)
Gettext Internationalizing a Package, Start to Finish
Marking Strings for Translation
src/ say.c
#include <config.h>#include <stdio.h>
#include "gettext.h"#define _(string) gettext (string)
void say_hello (void){puts ("Hello World!");puts ("This is " PACKAGE_STRING ".");
}
Messages that must be translated are marked with (...).NLS (Native Language System) can be disabled.
Explicitly with ‘./configure --disable-nls’Implicitly if no gettext implementation is installed.
Then gettext.h defines gettext(), textdomain(), . . . , as no-ops.
A. Duret-Lutz Using GNU Autotools February 21, 2008 142 / 162
![Page 506: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/506.jpg)
Gettext Internationalizing a Package, Start to Finish
Marking Strings for Translation
src/ say.c
#include <config.h>#include <stdio.h>#include "gettext.h"#define _(string) gettext (string)void say_hello (void){puts (_("Hello World!"));printf (_("This is %s.\n"), PACKAGE_STRING);
}
Messages that must be translated are marked with (...).
NLS (Native Language System) can be disabled.Explicitly with ‘./configure --disable-nls’Implicitly if no gettext implementation is installed.
Then gettext.h defines gettext(), textdomain(), . . . , as no-ops.
A. Duret-Lutz Using GNU Autotools February 21, 2008 142 / 162
![Page 507: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/507.jpg)
Gettext Internationalizing a Package, Start to Finish
Marking Strings for Translation
src/ say.c
#include <config.h>#include <stdio.h>#include "gettext.h"#define _(string) gettext (string)void say_hello (void){puts (_("Hello World!"));printf (_("This is %s.\n"), PACKAGE_STRING);
}
Messages that must be translated are marked with (...).NLS (Native Language System) can be disabled.
Explicitly with ‘./configure --disable-nls’Implicitly if no gettext implementation is installed.
Then gettext.h defines gettext(), textdomain(), . . . , as no-ops.A. Duret-Lutz Using GNU Autotools February 21, 2008 142 / 162
![Page 508: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/508.jpg)
Gettext Internationalizing a Package, Start to Finish
Building the Whole Shebang
Our Hello World is now internationalized.
~/amhello % autoreconf --install
...~/amhello % ./configure
...~/amhello % make
...
Making all in pomake amhello.pot-update...
The po/ directory contains messages catalogs.po/amhello.pot is the template message catalog.
Updating po/amhello.pot is costly and occurs only before releases (e.g.,during ‘make distcheck’) or if the file did not exist (our case above).It can be updated explicitly with ‘cd po; make update-po’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 143 / 162
![Page 509: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/509.jpg)
Gettext Internationalizing a Package, Start to Finish
Building the Whole Shebang
Our Hello World is now internationalized.
~/amhello % autoreconf --install
...~/amhello % ./configure
...~/amhello % make
...Making all in pomake amhello.pot-update...
The po/ directory contains messages catalogs.po/amhello.pot is the template message catalog.
Updating po/amhello.pot is costly and occurs only before releases (e.g.,during ‘make distcheck’) or if the file did not exist (our case above).It can be updated explicitly with ‘cd po; make update-po’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 143 / 162
![Page 510: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/510.jpg)
Gettext Localizing a Package
Localizing a Package
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 144 / 162
![Page 511: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/511.jpg)
Gettext Localizing a Package
po/amhello.pot: The PO Template File
# ... COMMENTS ...
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: bug-report@address\n"
"POT-Creation-Date: 2005-03-05 00:27+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/say.c:9
msgid "Hello World!"
msgstr ""
#: src/say.c:10
#, c-format
msgid "This is %s.\n"
msgstr ""
A. Duret-Lutz Using GNU Autotools February 21, 2008 145 / 162
![Page 512: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/512.jpg)
Gettext Localizing a Package
po/amhello.pot: The PO Template File
# ... COMMENTS ...
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: bug-report@address\n"
"POT-Creation-Date: 2005-03-05 00:27+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/say.c:9
msgid "Hello World!"
msgstr ""
#: src/say.c:10
#, c-format
msgid "This is %s.\n"
msgstr ""
A. Duret-Lutz Using GNU Autotools February 21, 2008 145 / 162
![Page 513: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/513.jpg)
Gettext Localizing a Package
po/amhello.pot: List of Messages
#: src/say.c:9msgid "Hello World!"msgstr ""
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr ""
msgids identify all strings in the package
empty msgstrs are placeholders for translations
the location of each string is shown,so the translator can check the context if needed
additional flags can be used
A. Duret-Lutz Using GNU Autotools February 21, 2008 146 / 162
![Page 514: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/514.jpg)
Gettext Localizing a Package
po/amhello.pot: List of Messages
#: src/say.c:9msgid "Hello World!"msgstr ""
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr ""
msgids identify all strings in the package
empty msgstrs are placeholders for translations
the location of each string is shown,so the translator can check the context if needed
additional flags can be used
A. Duret-Lutz Using GNU Autotools February 21, 2008 146 / 162
![Page 515: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/515.jpg)
Gettext Localizing a Package
po/amhello.pot: List of Messages
#: src/say.c:9msgid "Hello World!"msgstr ""
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr ""
msgids identify all strings in the package
empty msgstrs are placeholders for translations
the location of each string is shown,so the translator can check the context if needed
additional flags can be used
A. Duret-Lutz Using GNU Autotools February 21, 2008 146 / 162
![Page 516: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/516.jpg)
Gettext Localizing a Package
po/amhello.pot: List of Messages
#: src/say.c:9msgid "Hello World!"msgstr ""
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr ""
msgids identify all strings in the package
empty msgstrs are placeholders for translations
the location of each string is shown,so the translator can check the context if needed
additional flags can be used
A. Duret-Lutz Using GNU Autotools February 21, 2008 146 / 162
![Page 517: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/517.jpg)
Gettext Localizing a Package
po/amhello.pot: List of Messages
#: src/say.c:9msgid "Hello World!"msgstr ""
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr ""
msgids identify all strings in the package
empty msgstrs are placeholders for translations
the location of each string is shown,so the translator can check the context if needed
additional flags can be used
A. Duret-Lutz Using GNU Autotools February 21, 2008 146 / 162
![Page 518: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/518.jpg)
Gettext Localizing a Package
po/amhello.pot: The PO Template File
# ... COMMENTS ...
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: bug-report@address\n"
"POT-Creation-Date: 2005-03-05 00:27+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/say.c:9
msgid "Hello World!"
msgstr ""
#: src/say.c:10
#, c-format
msgid "This is %s.\n"
msgstr ""
A. Duret-Lutz Using GNU Autotools February 21, 2008 147 / 162
![Page 519: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/519.jpg)
Gettext Localizing a Package
po/amhello.pot: The PO Template File
# ... COMMENTS ...
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: bug-report@address\n"
"POT-Creation-Date: 2005-03-05 00:27+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/say.c:9
msgid "Hello World!"
msgstr ""
#: src/say.c:10
#, c-format
msgid "This is %s.\n"
msgstr ""
A. Duret-Lutz Using GNU Autotools February 21, 2008 147 / 162
![Page 520: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/520.jpg)
Gettext Localizing a Package
po/amhello.pot: The Header Entry
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: bug-report@address\n""POT-Creation-Date: 2005-03-05 00:27+0100\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <[email protected]>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=CHARSET\n""Content-Transfer-Encoding: 8bit\n"
The translation of the empty string is a special entry that will be filledwith administrative information.
A. Duret-Lutz Using GNU Autotools February 21, 2008 148 / 162
![Page 521: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/521.jpg)
Gettext Localizing a Package
How to Add a New Language?
1 Initialize po/LL.po or po/LL CC.po from po/amhello.pot, using‘msginit’.LL is your language code, and CC is your country code
pt is Portuguesept BR is Brazilian Portuguese
(The annexes of the Gettext manual show lists of LLs and CCs.)
2 Fill in po/LL.po (or po/LL CC.po)
3 List the new translation in po/LINGUAS
Let’s add a French translation for amhello.
A. Duret-Lutz Using GNU Autotools February 21, 2008 149 / 162
![Page 522: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/522.jpg)
Gettext Localizing a Package
How to Add a New Language?
1 Initialize po/LL.po or po/LL CC.po from po/amhello.pot, using‘msginit’.LL is your language code, and CC is your country code
pt is Portuguesept BR is Brazilian Portuguese
(The annexes of the Gettext manual show lists of LLs and CCs.)
2 Fill in po/LL.po (or po/LL CC.po)
3 List the new translation in po/LINGUAS
Let’s add a French translation for amhello.
A. Duret-Lutz Using GNU Autotools February 21, 2008 149 / 162
![Page 523: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/523.jpg)
Gettext Localizing a Package
Preparing po/ fr.po
~/amhello % cd po
~/amhello/po % msginit -l fr
...~/amhello/po % emacs fr.po &
The PO mode of ‘emacs’ (〈M-x〉 po-mode):
The buffer is modified only indirectly.
〈Enter〉 on a message will open a buffer to edit the translation.
Use 〈C-c〉〈C-c〉 after you have completed the translation, to get back tothe updated amhello.pot buffer.
Once all strings are translated, use 〈V〉 to save and check the file.
Use 〈Tab〉 to remove fuzzy attributes.
A. Duret-Lutz Using GNU Autotools February 21, 2008 150 / 162
![Page 524: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/524.jpg)
Gettext Localizing a Package
Preparing po/ fr.po
~/amhello % cd po
~/amhello/po % msginit -l fr
...~/amhello/po % emacs fr.po &
The PO mode of ‘emacs’ (〈M-x〉 po-mode):
The buffer is modified only indirectly.
〈Enter〉 on a message will open a buffer to edit the translation.
Use 〈C-c〉〈C-c〉 after you have completed the translation, to get back tothe updated amhello.pot buffer.
Once all strings are translated, use 〈V〉 to save and check the file.
Use 〈Tab〉 to remove fuzzy attributes.
A. Duret-Lutz Using GNU Autotools February 21, 2008 150 / 162
![Page 525: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/525.jpg)
Gettext Localizing a Package
po/ fr.po: Message Translations
#: src/say.c:9msgid "Hello World!"msgstr ""
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr ""
A. Duret-Lutz Using GNU Autotools February 21, 2008 151 / 162
![Page 526: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/526.jpg)
Gettext Localizing a Package
po/ fr.po: Message Translations
#: src/say.c:9msgid "Hello World!"msgstr "Bonjour Monde !"
#: src/say.c:10#, c-formatmsgid "This is %s.\n"msgstr "Ceci est %s.\n"
A. Duret-Lutz Using GNU Autotools February 21, 2008 151 / 162
![Page 527: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/527.jpg)
Gettext Localizing a Package
po/ fr.po: Header
msgid ""msgstr """Project-Id-Version: amhello 3.0\n""Report-Msgid-Bugs-To: bug-report@address\n""POT-Creation-Date: 2005-03-05 00:27+0100\n""PO-Revision-Date: 2005-03-15 20:54+0100\n""Last-Translator: Alexandre Duret-Lutz <[email protected]>\n""Language-Team: French\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=ASCII\n""Content-Transfer-Encoding: 8bit\n""Plural-Forms: nplurals=2; plural=(n > 1);\n"
‘msginit’ filled these fields.
You may have to customize it a bit.The revision date will also be updated on save.
A. Duret-Lutz Using GNU Autotools February 21, 2008 152 / 162
![Page 528: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/528.jpg)
Gettext Localizing a Package
po/ fr.po: Header
msgid ""msgstr """Project-Id-Version: amhello 3.0\n""Report-Msgid-Bugs-To: bug-report@address\n""POT-Creation-Date: 2005-03-05 00:27+0100\n""PO-Revision-Date: 2005-03-15 20:54+0100\n""Last-Translator: Alexandre Duret-Lutz <[email protected]>\n""Language-Team: French\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=ASCII\n""Content-Transfer-Encoding: 8bit\n""Plural-Forms: nplurals=2; plural=(n > 1);\n"
‘msginit’ filled these fields.
You may have to customize it a bit.The revision date will also be updated on save.
A. Duret-Lutz Using GNU Autotools February 21, 2008 152 / 162
![Page 529: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/529.jpg)
Gettext Localizing a Package
po/ fr.po: Header
msgid ""msgstr """Project-Id-Version: amhello 3.0\n""Report-Msgid-Bugs-To: bug-report@address\n""POT-Creation-Date: 2005-03-05 00:27+0100\n""PO-Revision-Date: 2005-03-15 20:54+0100\n""Last-Translator: Alexandre Duret-Lutz <[email protected]>\n""Language-Team: French\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=iso-8859-1\n""Content-Transfer-Encoding: 8bit\n""Plural-Forms: nplurals=2; plural=(n > 1);\n"
‘msginit’ filled these fields.You may have to customize it a bit.
The revision date will also be updated on save.
A. Duret-Lutz Using GNU Autotools February 21, 2008 152 / 162
![Page 530: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/530.jpg)
Gettext Localizing a Package
po/ fr.po: Header
msgid ""msgstr """Project-Id-Version: amhello 3.0\n""Report-Msgid-Bugs-To: bug-report@address\n""POT-Creation-Date: 2005-03-05 00:27+0100\n""PO-Revision-Date: 2005-03-15 20:54+0100\n""Last-Translator: Alexandre Duret-Lutz <[email protected]>\n""Language-Team: French\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=iso-8859-1\n""Content-Transfer-Encoding: 8bit\n""Plural-Forms: nplurals=2; plural=(n > 1);\n"
‘msginit’ filled these fields.You may have to customize it a bit.The revision date will also be updated on save.
A. Duret-Lutz Using GNU Autotools February 21, 2008 152 / 162
![Page 531: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/531.jpg)
Gettext Localizing a Package
po/ fr.po: Validation and Addition
Once po/ fr.po is completed, hit 〈V〉. This will:
1 Update the revision date
2 Save the file
3 Run ‘msgfmt --statistics --check’ on po/ fr.po, to validate it.
We can now register the language.
~/amhello/po % echo fr >> LINGUAS
A. Duret-Lutz Using GNU Autotools February 21, 2008 153 / 162
![Page 532: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/532.jpg)
Gettext Localizing a Package
po/ fr.po: Validation and Addition
Once po/ fr.po is completed, hit 〈V〉. This will:
1 Update the revision date
2 Save the file
3 Run ‘msgfmt --statistics --check’ on po/ fr.po, to validate it.
We can now register the language.
~/amhello/po % echo fr >> LINGUAS
A. Duret-Lutz Using GNU Autotools February 21, 2008 153 / 162
![Page 533: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/533.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello %
make
~/amhello % cd po
~/amhello/po % make update-po
~/amhello/po % cd ..
~/amhello % make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 534: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/534.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello %
cd po
~/amhello/po % make update-po
~/amhello/po % cd ..
~/amhello % make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 535: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/535.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello % cd po
~/amhello/po %
make update-po
~/amhello/po % cd ..
~/amhello % make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 536: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/536.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello % cd po
~/amhello/po % make update-po
~/amhello/po %
cd ..
~/amhello % make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 537: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/537.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello % cd po
~/amhello/po % make update-po
~/amhello/po % cd ..
~/amhello %
make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 538: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/538.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello % cd po
~/amhello/po % make update-po
~/amhello/po % cd ..
~/amhello % make install
~/amhello %
~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 539: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/539.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello % cd po
~/amhello/po % make update-po
~/amhello/po % cd ..
~/amhello % make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello %
LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 540: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/540.jpg)
Gettext Localizing a Package
hello now Speaks French!
~/amhello % ./configure --prefix ~/test
~/amhello % make
~/amhello % cd po
~/amhello/po % make update-po
~/amhello/po % cd ..
~/amhello % make install
~/amhello % ~/test/bin/hello
Hello World!This is amhello 3.0.~/amhello % LANG=fr_FR ~/test/bin/hello
Bonjour Monde !Ceci est amhello 3.0.
update-po
This step is needed because wejust created fr.po, and it has to
be compiled. This happensautomatically during ‘make dist’.
A. Duret-Lutz Using GNU Autotools February 21, 2008 154 / 162
![Page 541: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/541.jpg)
Gettext Localizing a Package
Updating Message Catalogs
Because maintainers can change the strings marked for translation, themessages catalogs are varying, and are not always up-to-date.
Varying messages. update-po modify *.po file:
New messages are added with a blank translation.Obsolete translations, not used anymore, are commented.Messages with tiny changes keep their translation, but aremarked fuzzy.Translators remove fuzzy attributes (〈Tab〉) after verification.
Not up-to-date. gettext copes with incomplete translations as follows.
Untranslated messages are output untranslated.Fuzzy messages are also output untranslated. (Better output theoriginal sentence, rather than an inappropriate translation.)
Good practice: the string freeze. Two weeks before a release, run‘make update-po’ and send the *.pot file to translators. Don’t change oradd strings from this point on. Let translators send you updated *.po files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 155 / 162
![Page 542: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/542.jpg)
Gettext Localizing a Package
Updating Message Catalogs
Because maintainers can change the strings marked for translation, themessages catalogs are varying, and are not always up-to-date.
Varying messages. update-po modify *.po file:
New messages are added with a blank translation.Obsolete translations, not used anymore, are commented.Messages with tiny changes keep their translation, but aremarked fuzzy.Translators remove fuzzy attributes (〈Tab〉) after verification.
Not up-to-date. gettext copes with incomplete translations as follows.
Untranslated messages are output untranslated.Fuzzy messages are also output untranslated. (Better output theoriginal sentence, rather than an inappropriate translation.)
Good practice: the string freeze. Two weeks before a release, run‘make update-po’ and send the *.pot file to translators. Don’t change oradd strings from this point on. Let translators send you updated *.po files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 155 / 162
![Page 543: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/543.jpg)
Gettext Localizing a Package
Updating Message Catalogs
Because maintainers can change the strings marked for translation, themessages catalogs are varying, and are not always up-to-date.
Varying messages. update-po modify *.po file:
New messages are added with a blank translation.Obsolete translations, not used anymore, are commented.Messages with tiny changes keep their translation, but aremarked fuzzy.Translators remove fuzzy attributes (〈Tab〉) after verification.
Not up-to-date. gettext copes with incomplete translations as follows.
Untranslated messages are output untranslated.Fuzzy messages are also output untranslated. (Better output theoriginal sentence, rather than an inappropriate translation.)
Good practice: the string freeze. Two weeks before a release, run‘make update-po’ and send the *.pot file to translators. Don’t change oradd strings from this point on. Let translators send you updated *.po files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 155 / 162
![Page 544: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/544.jpg)
Gettext Localizing a Package
Updating Message Catalogs
Because maintainers can change the strings marked for translation, themessages catalogs are varying, and are not always up-to-date.
Varying messages. update-po modify *.po file:
New messages are added with a blank translation.Obsolete translations, not used anymore, are commented.Messages with tiny changes keep their translation, but aremarked fuzzy.Translators remove fuzzy attributes (〈Tab〉) after verification.
Not up-to-date. gettext copes with incomplete translations as follows.
Untranslated messages are output untranslated.Fuzzy messages are also output untranslated. (Better output theoriginal sentence, rather than an inappropriate translation.)
Good practice: the string freeze. Two weeks before a release, run‘make update-po’ and send the *.pot file to translators. Don’t change oradd strings from this point on. Let translators send you updated *.po files.
A. Duret-Lutz Using GNU Autotools February 21, 2008 155 / 162
![Page 545: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/545.jpg)
Gettext Localizing a Package
Language Teams & The Translation Project
http://www.iro.umontreal.ca/translation/
The Translation Project provides an infrastructure for package maintainersand translators to exchange messages catalogs.
Translators gather in Language Teams (consider joining the team ofyour own language) to discuss issues.
Maintainer submit *.pot files and are notified when *.po files areupdated.
Pages in The Translation Project will show where work is needed(consider adopting an orphan *.po file.)
This is only one way of getting a project translated. A lot of packageshave dedicated translators and deal with them directly.
A. Duret-Lutz Using GNU Autotools February 21, 2008 156 / 162
![Page 546: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/546.jpg)
Gettext Localizing a Package
Language Teams & The Translation Project
http://www.iro.umontreal.ca/translation/
The Translation Project provides an infrastructure for package maintainersand translators to exchange messages catalogs.
Translators gather in Language Teams (consider joining the team ofyour own language) to discuss issues.
Maintainer submit *.pot files and are notified when *.po files areupdated.
Pages in The Translation Project will show where work is needed(consider adopting an orphan *.po file.)
This is only one way of getting a project translated. A lot of packageshave dedicated translators and deal with them directly.
A. Duret-Lutz Using GNU Autotools February 21, 2008 156 / 162
![Page 547: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/547.jpg)
Gettext Localizing a Package
Language Teams & The Translation Project
http://www.iro.umontreal.ca/translation/
The Translation Project provides an infrastructure for package maintainersand translators to exchange messages catalogs.
Translators gather in Language Teams (consider joining the team ofyour own language) to discuss issues.
Maintainer submit *.pot files and are notified when *.po files areupdated.
Pages in The Translation Project will show where work is needed(consider adopting an orphan *.po file.)
This is only one way of getting a project translated. A lot of packageshave dedicated translators and deal with them directly.
A. Duret-Lutz Using GNU Autotools February 21, 2008 156 / 162
![Page 548: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/548.jpg)
Nested Packages
Nested Packages
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 157 / 162
![Page 549: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/549.jpg)
Nested Packages
Nested Packages
Autoconfiscated packages can be nested to arbitrary depth.
A package can distribute a third-party library it uses in a subdirectory.It’s possible to gather many packages this way to distribute a set oftools.
For installers:
A single package to configure, build, and install.‘configure’ options are passed recursively to sub-packages.‘configure --help=recursive’ shows the help of all sub-packages.
For maintainers:
Easier integration.The sub-package is autonomous.
A. Duret-Lutz Using GNU Autotools February 21, 2008 158 / 162
![Page 550: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/550.jpg)
Nested Packages
Setting Up Nested Packages
A sub-package should appear as an ordinary directory.
In Makefile.am, this directory must appear in SUBDIRS so ‘make’recurses into it.
configure.ac should also declare this directory
AC_CONFIG_SUBDIRS([subdir])
so ‘configure’ calls subdir/ configure recursively.
A. Duret-Lutz Using GNU Autotools February 21, 2008 159 / 162
![Page 551: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/551.jpg)
Nested Packages
Setting Up Nested Packages
A sub-package should appear as an ordinary directory.
In Makefile.am, this directory must appear in SUBDIRS so ‘make’recurses into it.
configure.ac should also declare this directory
AC_CONFIG_SUBDIRS([subdir])
so ‘configure’ calls subdir/ configure recursively.
A. Duret-Lutz Using GNU Autotools February 21, 2008 159 / 162
![Page 552: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/552.jpg)
Nested Packages
Setting Up Nested Packages
A sub-package should appear as an ordinary directory.
In Makefile.am, this directory must appear in SUBDIRS so ‘make’recurses into it.
configure.ac should also declare this directory
AC_CONFIG_SUBDIRS([subdir])
so ‘configure’ calls subdir/ configure recursively.
A. Duret-Lutz Using GNU Autotools February 21, 2008 159 / 162
![Page 553: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/553.jpg)
Nested Packages
Nested Packages Example
The arm program links with an hand library, a nested package in hand/ .
arm’s configure.ac
AC_INIT([arm], [1.0])AM_INIT_AUTOMAKE([-Wall -Werror foreign])AC_PROG_CCAC_CONFIG_FILES([Makefile src/Makefile])AC_CONFIG_SUBDIRS([hand])AC_OUTPUT
arm’s Makefile.amSUBDIRS = hand src
arm’s src/Makefile.am
AM_CPPFLAGS = -I$(top_srcdir)/handbin_PROGRAMS = armarm_SOURCES = arm.carm_LDADD = ../hand/libhand.a
A. Duret-Lutz Using GNU Autotools February 21, 2008 160 / 162
![Page 554: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/554.jpg)
The End
The End
10 Writing and Managing Custom MacrosWriting Autoconf MacrosManaging Custom Macros with ‘aclocal’
11 Libtool
12 GettextIntroducing GettextInternationalizing a Package, Start to FinishLocalizing a Package
13 Nested Packages
14 The End
A. Duret-Lutz Using GNU Autotools February 21, 2008 161 / 162
![Page 555: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/555.jpg)
The End
Where to go Now?
Locate the reference manuals in your preferred format.
Autoconf, Automake, Libtool, and Gettext all install reference manualsin the Info format. (Try ‘info Autoconf’, ‘info Automake’, etc.)The web pages of these tools also have .html or .pdf versions.These manuals may not be easy introductions to the tools, but theymake good and up-to-date references.
Subscribe to these tools’ mailing lists, to see other people’s uses ofthe tools.
Pick a package that uses these tools and dissect its setup.
Try picking something written by somebody who isn’t just anotherneophyte!I recommend looking at GNU Coreutils.
A. Duret-Lutz Using GNU Autotools February 21, 2008 162 / 162
![Page 556: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/556.jpg)
The End
Where to go Now?
Locate the reference manuals in your preferred format.
Autoconf, Automake, Libtool, and Gettext all install reference manualsin the Info format. (Try ‘info Autoconf’, ‘info Automake’, etc.)The web pages of these tools also have .html or .pdf versions.These manuals may not be easy introductions to the tools, but theymake good and up-to-date references.
Subscribe to these tools’ mailing lists, to see other people’s uses ofthe tools.
Pick a package that uses these tools and dissect its setup.
Try picking something written by somebody who isn’t just anotherneophyte!I recommend looking at GNU Coreutils.
A. Duret-Lutz Using GNU Autotools February 21, 2008 162 / 162
![Page 557: Auto Tools](https://reader034.vdocuments.us/reader034/viewer/2022051513/547633ddb4af9f16608b4589/html5/thumbnails/557.jpg)
The End
Where to go Now?
Locate the reference manuals in your preferred format.
Autoconf, Automake, Libtool, and Gettext all install reference manualsin the Info format. (Try ‘info Autoconf’, ‘info Automake’, etc.)The web pages of these tools also have .html or .pdf versions.These manuals may not be easy introductions to the tools, but theymake good and up-to-date references.
Subscribe to these tools’ mailing lists, to see other people’s uses ofthe tools.
Pick a package that uses these tools and dissect its setup.
Try picking something written by somebody who isn’t just anotherneophyte!I recommend looking at GNU Coreutils.
A. Duret-Lutz Using GNU Autotools February 21, 2008 162 / 162