perl patches: fix spaces errors in patch 0001
[msysgit.git] / share / info / automake.info-1
blobea55eafc026a8aaa654f7692862132dabd63f034
1 This is automake.info, produced by makeinfo version 4.8 from
2 automake.texi.
4    This manual is for GNU Automake (version 1.10, 15 October 2006), a
5 program that creates GNU standards-compliant Makefiles from template
6 files.
8    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
9 2004, 2005, 2006 Free Software Foundation, Inc.
11      Permission is granted to copy, distribute and/or modify this
12      document under the terms of the GNU Free Documentation License,
13      Version 1.2 or any later version published by the Free Software
14      Foundation; with no Invariant Sections, with the Front-Cover texts
15      being "A GNU Manual," and with the Back-Cover Texts as in (a)
16      below.  A copy of the license is included in the section entitled
17      "GNU Free Documentation License."
19      (a) The FSF's Back-Cover Text is: "You have freedom to copy and
20      modify this GNU Manual, like GNU software.  Copies published by
21      the Free Software Foundation raise funds for GNU development."
23 INFO-DIR-SECTION Software development
24 START-INFO-DIR-ENTRY
25 * Automake: (automake).         Making GNU standards-compliant Makefiles.
26 END-INFO-DIR-ENTRY
28 INFO-DIR-SECTION Individual utilities
29 START-INFO-DIR-ENTRY
30 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4.
31 * automake: (automake)Invoking Automake.        Generating Makefile.in.
32 END-INFO-DIR-ENTRY
34 \x1f
35 File: automake.info,  Node: Top,  Next: Introduction,  Up: (dir)
37 GNU Automake
38 ************
40 This manual is for GNU Automake (version 1.10, 15 October 2006), a
41 program that creates GNU standards-compliant Makefiles from template
42 files.
44    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
45 2004, 2005, 2006 Free Software Foundation, Inc.
47      Permission is granted to copy, distribute and/or modify this
48      document under the terms of the GNU Free Documentation License,
49      Version 1.2 or any later version published by the Free Software
50      Foundation; with no Invariant Sections, with the Front-Cover texts
51      being "A GNU Manual," and with the Back-Cover Texts as in (a)
52      below.  A copy of the license is included in the section entitled
53      "GNU Free Documentation License."
55      (a) The FSF's Back-Cover Text is: "You have freedom to copy and
56      modify this GNU Manual, like GNU software.  Copies published by
57      the Free Software Foundation raise funds for GNU development."
59 * Menu:
61 * Introduction::                Automake's purpose
62 * Autotools Introduction::      An Introduction to the Autotools
63 * Generalities::                General ideas
64 * Examples::                    Some example packages
65 * Invoking Automake::           Creating a Makefile.in
66 * configure::                   Scanning configure.ac or configure.in
67 * Directories::                 Declaring subdirectories
68 * Programs::                    Building programs and libraries
69 * Other objects::               Other derived objects
70 * Other GNU Tools::             Other GNU Tools
71 * Documentation::               Building documentation
72 * Install::                     What gets installed
73 * Clean::                       What gets cleaned
74 * Dist::                        What goes in a distribution
75 * Tests::                       Support for test suites
76 * Rebuilding::                  Automatic rebuilding of Makefile
77 * Options::                     Changing Automake's behavior
78 * Miscellaneous::               Miscellaneous rules
79 * Include::                     Including extra files in an Automake template.
80 * Conditionals::                Conditionals
81 * Gnits::                       The effect of `--gnu' and `--gnits'
82 * Cygnus::                      The effect of `--cygnus'
83 * Not Enough::                  When Automake is not Enough
84 * Distributing::                Distributing the Makefile.in
85 * API versioning::              About compatibility between Automake versions
86 * Upgrading::                   Upgrading to a Newer Automake Version
87 * FAQ::                         Frequently Asked Questions
88 * History::                     Notes about the history of Automake
89 * Copying This Manual::         How to make copies of this manual
90 * Indices::                     Indices of variables, macros, and concepts
92  --- The Detailed Node Listing ---
94 An Introduction to the Autotools
96 * GNU Build System::            Introducing the GNU Build System
97 * Use Cases::                   Use Cases for the GNU Build System
98 * Why Autotools::               How Autotools Help
99 * Hello World::                 A Small Hello World Package
101 Use Cases for the GNU Build System
103 * Basic Installation::          Common installation procedure
104 * Standard Targets::            A list of standard Makefile targets
105 * Standard Directory Variables::  A list of standard directory variables
106 * Standard Configuration Variables::  Using configuration variables
107 * config.site::                 Using a config.site file
108 * VPATH Builds::                Parallel build trees
109 * Two-Part Install::            Installing data and programs separately
110 * Cross-Compilation::           Building for other architectures
111 * Renaming::                    Renaming programs at install time
112 * DESTDIR::                     Building binary packages with DESTDIR
113 * Preparing Distributions::     Rolling out tarballs
114 * Dependency Tracking::         Automatic dependency tracking
115 * Nested Packages::             The GNU Build Systems can be nested
117 A Small Hello World
119 * Creating amhello::            Create `amhello-1.0.tar.gz' from scratch
120 * amhello Explained::           `configure.ac' and `Makefile.am' explained
122 General ideas
124 * General Operation::           General operation of Automake
125 * Strictness::                  Standards conformance checking
126 * Uniform::                     The Uniform Naming Scheme
127 * Canonicalization::            How derived variables are named
128 * User Variables::              Variables reserved for the user
129 * Auxiliary Programs::          Programs automake might require
131 Some example packages
133 * Complete::                    A simple example, start to finish
134 * true::                        Building true and false
136 Scanning `configure.ac'
138 * Requirements::                Configuration requirements
139 * Optional::                    Other things Automake recognizes
140 * Invoking aclocal::            Auto-generating aclocal.m4
141 * Macros::                      Autoconf macros supplied with Automake
143 Auto-generating aclocal.m4
145 * aclocal options::             Options supported by aclocal
146 * Macro search path::           How aclocal finds .m4 files
147 * Extending aclocal::           Writing your own aclocal macros
148 * Local Macros::                Organizing local macros
149 * Serials::                     Serial lines in Autoconf macros
150 * Future of aclocal::           aclocal's scheduled death
152 Autoconf macros supplied with Automake
154 * Public macros::               Macros that you can use.
155 * Obsolete macros::             Macros that you should stop using.
156 * Private macros::              Macros that you should not use.
158 Directories
160 * Subdirectories::              Building subdirectories recursively
161 * Conditional Subdirectories::  Conditionally not building directories
162 * Alternative::                 Subdirectories without recursion
163 * Subpackages::                 Nesting packages
165 Building Programs and Libraries
167 * A Program::                   Building a program
168 * A Library::                   Building a library
169 * A Shared Library::            Building a Libtool library
170 * Program and Library Variables::  Variables controlling program and
171                                 library builds
172 * Default _SOURCES::            Default source files
173 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
174 * Program variables::           Variables used when building a program
175 * Yacc and Lex::                Yacc and Lex support
176 * C++ Support::                 Compiling C++ sources
177 * Objective C Support::         Compiling Objective C sources
178 * Unified Parallel C Support::  Compiling Unified Parallel C sources
179 * Assembly Support::            Compiling assembly sources
180 * Fortran 77 Support::          Compiling Fortran 77 sources
181 * Fortran 9x Support::          Compiling Fortran 9x sources
182 * Java Support::                Compiling Java sources
183 * Support for Other Languages::  Compiling other languages
184 * ANSI::                        Automatic de-ANSI-fication (obsolete)
185 * Dependencies::                Automatic dependency tracking
186 * EXEEXT::                      Support for executable extensions
188 Building a program
190 * Program Sources::             Defining program sources
191 * Linking::                     Linking with libraries or extra objects
192 * Conditional Sources::         Handling conditional sources
193 * Conditional Programs::        Building program conditionally
195 Building a Shared Library
197 * Libtool Concept::             Introducing Libtool
198 * Libtool Libraries::           Declaring Libtool Libraries
199 * Conditional Libtool Libraries::  Building Libtool Libraries Conditionally
200 * Conditional Libtool Sources::  Choosing Library Sources Conditionally
201 * Libtool Convenience Libraries::  Building Convenience Libtool Libraries
202 * Libtool Modules::             Building Libtool Modules
203 * Libtool Flags::               Using _LIBADD, _LDFLAGS, and _LIBTOOLFLAGS
204 * LTLIBOBJS::                   Using $(LTLIBOBJS) and $(LTALLOCA)
205 * Libtool Issues::              Common Issues Related to Libtool's Use
207 Fortran 77 Support
209 * Preprocessing Fortran 77::    Preprocessing Fortran 77 sources
210 * Compiling Fortran 77 Files::  Compiling Fortran 77 sources
211 * Mixing Fortran 77 With C and C++::  Mixing Fortran 77 With C and C++
213 Mixing Fortran 77 With C and C++
215 * How the Linker is Chosen::    Automatic linker selection
217 Fortran 9x Support
219 * Compiling Fortran 9x Files::  Compiling Fortran 9x sources
221 Other Derived Objects
223 * Scripts::                     Executable scripts
224 * Headers::                     Header files
225 * Data::                        Architecture-independent data files
226 * Sources::                     Derived sources
228 Built sources
230 * Built sources example::       Several ways to handle built sources.
232 Other GNU Tools
234 * Emacs Lisp::                  Emacs Lisp
235 * gettext::                     Gettext
236 * Libtool::                     Libtool
237 * Java::                        Java
238 * Python::                      Python
240 Building documentation
242 * Texinfo::                     Texinfo
243 * Man pages::                   Man pages
245 Miscellaneous Rules
247 * Tags::                        Interfacing to etags and mkid
248 * Suffixes::                    Handling new file extensions
249 * Multilibs::                   Support for multilibs.
251 When Automake Isn't Enough
253 * Extending::                   Adding new rules or overriding existing ones.
254 * Third-Party Makefiles::       Integrating Non-Automake `Makefile's.
256 Frequently Asked Questions about Automake
258 * CVS::                         CVS and generated files
259 * maintainer-mode::             missing and AM_MAINTAINER_MODE
260 * wildcards::                   Why doesn't Automake support wildcards?
261 * limitations on file names::   Limitations on source and installed file names
262 * distcleancheck::              Files left in build directory after distclean
263 * Flag Variables Ordering::     CFLAGS vs. AM_CFLAGS vs. mumble_CFLAGS
264 * renamed objects::             Why are object files sometimes renamed?
265 * Per-Object Flags::            How to simulate per-object flags?
266 * Multiple Outputs::            Writing rules for tools with many output files
267 * Hard-Coded Install Paths::    Installing to Hard-Coded Locations
269 History of Automake
271 * Timeline::                    The Automake story.
272 * Dependency Tracking Evolution::  Evolution of Automatic Dependency Tracking
273 * Releases::                    Statistics about Automake Releases
275 Copying This Manual
277 * GNU Free Documentation License::  License for copying this manual
279 Indices
281 * Macro Index::                 Index of Autoconf macros
282 * Variable Index::              Index of Makefile variables
283 * General Index::               General index
285 \x1f
286 File: automake.info,  Node: Introduction,  Next: Autotools Introduction,  Prev: Top,  Up: Top
288 1 Introduction
289 **************
291 Automake is a tool for automatically generating `Makefile.in's from
292 files called `Makefile.am'.  Each `Makefile.am' is basically a series
293 of `make' variable definitions(1), with rules being thrown in
294 occasionally.  The generated `Makefile.in's are compliant with the GNU
295 Makefile standards.
297    The GNU Makefile Standards Document (*note Makefile Conventions:
298 (standards)Makefile Conventions.)  is long, complicated, and subject to
299 change.  The goal of Automake is to remove the burden of Makefile
300 maintenance from the back of the individual GNU maintainer (and put it
301 on the back of the Automake maintainers).
303    The typical Automake input file is simply a series of variable
304 definitions.  Each such file is processed to create a `Makefile.in'.
305 There should generally be one `Makefile.am' per directory of a project.
307    Automake does constrain a project in certain ways; for instance, it
308 assumes that the project uses Autoconf (*note Introduction:
309 (autoconf)Top.), and enforces certain restrictions on the
310 `configure.ac' contents(2).
312    Automake requires `perl' in order to generate the `Makefile.in's.
313 However, the distributions created by Automake are fully GNU
314 standards-compliant, and do not require `perl' in order to be built.
316    Mail suggestions and bug reports for Automake to
317 <bug-automake@gnu.org>.
319    ---------- Footnotes ----------
321    (1) These variables are also called "make macros" in Make
322 terminology, however in this manual we reserve the term "macro" for
323 Autoconf's macros.
325    (2) Older Autoconf versions used `configure.in'.  Autoconf 2.50 and
326 greater promotes `configure.ac' over `configure.in'.  The rest of this
327 documentation will refer to `configure.ac', but Automake also supports
328 `configure.in' for backward compatibility.
330 \x1f
331 File: automake.info,  Node: Autotools Introduction,  Next: Generalities,  Prev: Introduction,  Up: Top
333 2 An Introduction to the Autotools
334 **********************************
336 If you are new to Automake, maybe you know that it is part of a set of
337 tools called _The Autotools_.  Maybe you've already delved into a
338 package full of files named `configure', `configure.ac', `Makefile.in',
339 `Makefile.am', `aclocal.m4', ..., some of them claiming to be
340 _generated by_ Autoconf or Automake.  But the exact purpose of these
341 files and their relations is probably fuzzy.  The goal of this chapter
342 is to introduce you to this machinery, to show you how it works and how
343 powerful it is.  If you've never installed or seen such a package, do
344 not worry: this chapter will walk you through it.
346    If you need some teaching material, more illustrations, or a less
347 `automake'-centered continuation, some slides for this introduction are
348 available in Alexandre Duret-Lutz's Autotools Tutorial
349 (http://www-src.lip6.fr/~Alexandre.Duret-Lutz/autotools.html).  This
350 chapter is the written version of the first part of his tutorial.
352 * Menu:
354 * GNU Build System::            Introducing the GNU Build System
355 * Use Cases::                   Use Cases for the GNU Build System
356 * Why Autotools::               How Autotools Help
357 * Hello World::                 A Small Hello World Package
359 \x1f
360 File: automake.info,  Node: GNU Build System,  Next: Use Cases,  Up: Autotools Introduction
362 2.1 Introducing the GNU Build System
363 ====================================
365 It is a truth universally acknowledged, that a developer in possession
366 of a new package, must be in want of a build system.
368    In the Unix world, such a build system is traditionally achieved
369 using the command `make' (*note Overview: (make)Top.).  The developer
370 expresses the recipe to build his package in a `Makefile'.  This file
371 is a set of rules to build the files in the package.  For instance the
372 program `prog' may be built by running the linker on the files
373 `main.o', `foo.o', and `bar.o'; the file `main.o' may be built by
374 running the compiler on `main.c'; etc.  Each time `make' is run, it
375 reads `Makefile', checks the existence and modification time of the
376 files mentioned, decides what files need to be built (or rebuilt), and
377 runs the associated commands.
379    When a package needs to be built on a different platform than the one
380 it was developed on, its `Makefile' usually needs to be adjusted.  For
381 instance the compiler may have another name or require more options.
382 In 1991, David J. MacKenzie got tired of customizing `Makefile' for the
383 20 platforms he had to deal with.  Instead, he handcrafted a little
384 shell script called `configure' to automatically adjust the `Makefile'
385 (*note Genesis: (autoconf)Genesis.).  Compiling his package was now as
386 simple as running `./configure && make'.
388    Today this process has been standardized in the GNU project.  The GNU
389 Coding Standards (*note The Release Process: (standards)Managing
390 Releases.) explains how each package of the GNU project should have a
391 `configure' script, and the minimal interface it should have.  The
392 `Makefile' too should follow some established conventions.  The result?
393 A unified build system that makes all packages almost
394 indistinguishable by the installer.  In its simplest scenario, all the
395 installer has to do is to unpack the package, run `./configure && make
396 && make install', and repeat with the next package to install.
398    We call this build system the "GNU Build System", since it was grown
399 out of the GNU project.  However it is used by a vast number of other
400 packages: following any existing convention has its advantages.
402    The Autotools are tools that will create a GNU Build System for your
403 package.  Autoconf mostly focuses on `configure' and Automake on
404 `Makefile's.  It is entirely possible to create a GNU Build System
405 without the help of these tools.  However it is rather burdensome and
406 error-prone.  We will discuss this again after some illustration of the
407 GNU Build System in action.
409 \x1f
410 File: automake.info,  Node: Use Cases,  Next: Why Autotools,  Prev: GNU Build System,  Up: Autotools Introduction
412 2.2 Use Cases for the GNU Build System
413 ======================================
415 In this section we explore several use cases for the GNU Build System.
416 You can replay all these examples on the `amhello-1.0.tar.gz' package
417 distributed with Automake.  If Automake is installed on your system,
418 you should find a copy of this file in
419 `PREFIX/share/doc/automake/amhello-1.0.tar.gz', where PREFIX is the
420 installation prefix specified during configuration (PREFIX defaults to
421 `/usr/local', however if Automake was installed by some GNU/Linux
422 distribution it most likely has been set to `/usr').  If you do not
423 have a copy of Automake installed, you can find a copy of this file
424 inside the `doc/' directory of the Automake package.
426    Some of the following use cases present features that are in fact
427 extensions to the GNU Build System.  Read: they are not specified by
428 the GNU Coding Standards, but they are nonetheless part of the build
429 system created by the Autotools.  To keep things simple, we do not
430 point out the difference.  Our objective is to show you many of the
431 features that the build system created by the Autotools will offer to
432 you.
434 * Menu:
436 * Basic Installation::          Common installation procedure
437 * Standard Targets::            A list of standard Makefile targets
438 * Standard Directory Variables::  A list of standard directory variables
439 * Standard Configuration Variables::  Using configuration variables
440 * config.site::                 Using a config.site file
441 * VPATH Builds::                Parallel build trees
442 * Two-Part Install::            Installing data and programs separately
443 * Cross-Compilation::           Building for other architectures
444 * Renaming::                    Renaming programs at install time
445 * DESTDIR::                     Building binary packages with DESTDIR
446 * Preparing Distributions::     Rolling out tarballs
447 * Dependency Tracking::         Automatic dependency tracking
448 * Nested Packages::             The GNU Build Systems can be nested
450 \x1f
451 File: automake.info,  Node: Basic Installation,  Next: Standard Targets,  Up: Use Cases
453 2.2.1 Basic Installation
454 ------------------------
456 The most common installation procedure looks as follows.
458      ~ % tar zxf amhello-1.0.tar.gz
459      ~ % cd amhello-1.0
460      ~/amhello-1.0 % ./configure
461      ...
462      config.status: creating Makefile
463      config.status: creating src/Makefile
464      ...
465      ~/amhello-1.0 % make
466      ...
467      ~/amhello-1.0 % make check
468      ...
469      ~/amhello-1.0 % su
470      Password:
471      /home/adl/amhello-1.0 # make install
472      ...
473      /home/adl/amhello-1.0 # exit
474      ~/amhello-1.0 % make installcheck
475      ...
477    The user first unpacks the package.  Here, and in the following
478 examples, we will use the non-portable `tar zxf' command for
479 simplicity.  On a system without GNU `tar' installed, this command
480 should read `gunzip -c amhello-1.0.tar.gz | tar xf -'.
482    The user then enters the newly created directory to run the
483 `configure' script.  This script probes the system for various
484 features, and finally creates the `Makefile's.  In this toy example
485 there are only two `Makefile's, but in real-world project there may be
486 many more, usually one `Makefile' per directory.
488    It is now possible to run `make'.  This will construct all the
489 programs, libraries, and scripts that need to be constructed for the
490 package.  In our example, this compiles the `hello' program.  All files
491 are constructed in place, in the source tree; we will see later how
492 this can be changed.
494    `make check' causes the package's tests to be run.  This step is not
495 mandatory, but it is often good to make sure the programs that have
496 been built behave as they should, before you decide to install them.
497 Our example does not contain any tests, so running `make check' is a
498 no-op.
500    After everything has been built, and maybe tested, it is time to
501 install it on the system.  That means copying the programs, libraries,
502 header files, scripts, and other data files from the source directory
503 to their final destination on the system.  The command `make install'
504 will do that.  However, by default everything will be installed in
505 subdirectories of `/usr/local': binaries will go into `/usr/local/bin',
506 libraries will end up in `/usr/local/lib', etc.  This destination is
507 usually not writable by any user, so we assume that we have to become
508 root before we can run `make install'.  In our example, running `make
509 install' will copy the program `hello' into `/usr/local/bin' and
510 `README' into `/usr/local/share/doc/amhello'.
512    A last and optional step is to run `make installcheck'.  This
513 command may run tests on the installed files.  `make check' tests the
514 files in the source tree, while `make installcheck' tests their
515 installed copies.  The tests run by the latter can be different from
516 those run by the former.  For instance, there are tests that cannot be
517 run in the source tree.  Conversely, some packages are set up so that
518 `make installcheck' will run the very same tests as `make check', only
519 on different files (non-installed vs. installed).  It can make a
520 difference, for instance when the source tree's layout is different
521 from that of the installation.  Furthermore it may help to diagnose an
522 incomplete installation.
524    Presently most packages do not have any `installcheck' tests because
525 the existence of `installcheck' is little known, and its usefulness is
526 neglected.  Our little toy package is no better: `make installcheck'
527 does nothing.
529 \x1f
530 File: automake.info,  Node: Standard Targets,  Next: Standard Directory Variables,  Prev: Basic Installation,  Up: Use Cases
532 2.2.2 Standard `Makefile' Targets
533 ---------------------------------
535 So far we have come across four ways to run `make' in the GNU Build
536 System: `make', `make check', `make install', and `make installcheck'.
537 The words `check', `install', and `installcheck', passed as arguments
538 to `make', are called "targets".  `make' is a shorthand for `make all',
539 `all' being the default target in the GNU Build System.
541    Here is a list of the most useful targets that the GNU Coding
542 Standards specify.
544 `make all'
545      Build programs, libraries, documentation, etc. (same as `make').
547 `make install'
548      Install what needs to be installed, copying the files from the
549      package's tree to system-wide directories.
551 `make install-strip'
552      Same as `make install', then strip debugging symbols.  Some users
553      like to trade space for useful bug reports....
555 `make uninstall'
556      The opposite of `make install': erase the installed files.  (This
557      needs to be run from the same build tree that was installed.)
559 `make clean'
560      Erase from the build tree the files built by `make all'.
562 `make distclean'
563      Additionally erase anything `./configure' created.
565 `make check'
566      Run the test suite, if any.
568 `make installcheck'
569      Check the installed programs or libraries, if supported.
571 `make dist'
572      Recreate `PACKAGE-VERSION.tar.gz' from all the source files.
574 \x1f
575 File: automake.info,  Node: Standard Directory Variables,  Next: Standard Configuration Variables,  Prev: Standard Targets,  Up: Use Cases
577 2.2.3 Standard Directory Variables
578 ----------------------------------
580 The GNU Coding Standards also specify a hierarchy of variables to
581 denote installation directories.  Some of these are:
583 Directory variable   Default value
584 ------------------------------------------------------- 
585 `prefix'             `/usr/local'
586   `exec_prefix'      `${prefix}'
587     `bindir'         `${exec_prefix}/bin'
588     `libdir'         `${exec_prefix}/lib'
589     ...              
590   `includedir'       `${prefix}/include'
591   `datarootdir'      `${prefix}/share'
592     `datadir'        `${datarootdir}'
593     `mandir'         `${datarootdir}/man'
594     `infodir'        `${datarootdir}/info'
595     `docdir'         `${datarootdir}/doc/${PACKAGE}'
596   ...                
598    Each of these directories has a role which is often obvious from its
599 name.  In a package, any installable file will be installed in one of
600 these directories.  For instance in `amhello-1.0', the program `hello'
601 is to be installed in BINDIR, the directory for binaries.  The default
602 value for this directory is `/usr/local/bin', but the user can supply a
603 different value when calling `configure'.  Also the file `README' will
604 be installed into DOCDIR, which defaults to
605 `/usr/local/share/doc/amhello'.
607    A user who wishes to install a package on his own account could
608 proceed as follows:
610      ~/amhello-1.0 % ./configure --prefix ~/usr
611      ...
612      ~/amhello-1.0 % make
613      ...
614      ~/amhello-1.0 % make install
615      ...
617    This would install `~/usr/bin/hello' and
618 `~/usr/share/doc/amhello/README'.
620    The list of all such directory options is shown by `./configure
621 --help'.
623 \x1f
624 File: automake.info,  Node: Standard Configuration Variables,  Next: config.site,  Prev: Standard Directory Variables,  Up: Use Cases
626 2.2.4 Standard Configuration Variables
627 --------------------------------------
629 The GNU Coding Standards also define a set of standard configuration
630 variables used during the build.  Here are some:
632 `CC'
633      C compiler command
635 `CFLAGS'
636      C compiler flags
638 `CXX'
639      C++ compiler command
641 `CXXFLAGS'
642      C++ compiler flags
644 `LDFLAGS'
645      linker flags
647 `CPPFLAGS'
648      C/C++ preprocessor flags
652    `configure' usually does a good job at setting appropriate values
653 for these variables, but there are cases where you may want to override
654 them.  For instance you may have several versions of a compiler
655 installed and would like to use another one, you may have header files
656 installed outside the default search path of the compiler, or even
657 libraries out of the way of the linker.
659    Here is how one would call `configure' to force it to use `gcc-3' as
660 C compiler, use header files from `~/usr/include' when compiling, and
661 libraries from `~/usr/lib' when linking.
663      ~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \
664      CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
666    Again, a full list of these variables appears in the output of
667 `./configure --help'.
669 \x1f
670 File: automake.info,  Node: config.site,  Next: VPATH Builds,  Prev: Standard Configuration Variables,  Up: Use Cases
672 2.2.5 Overriding Default Configuration Setting with `config.site'
673 -----------------------------------------------------------------
675 When installing several packages using the same setup, it can be
676 convenient to create a file to capture common settings.  If a file
677 named `PREFIX/share/config.site' exists, `configure' will source it at
678 the beginning of its execution.
680    Recall the command from the previous section:
682      ~/amhello-1.0 % ./configure --prefix ~/usr CC=gcc-3 \
683      CPPFLAGS=-I$HOME/usr/include LDFLAGS=-L$HOME/usr/lib
685    Assuming we are installing many package in `~/usr', and will always
686 want to use these definitions of `CC', `CPPFLAGS', and `LDFLAGS', we
687 can automate this by creating the following `~/usr/share/config.site'
688 file:
690      test -z "$CC" && CC=gcc-3
691      test -z "$CPPFLAGS" && CPPFLAGS=-I$HOME/usr/include
692      test -z "$LDFLAGS" && LDFLAGS=-L$HOME/usr/lib
694    Now, any time a `configure' script is using the `~/usr' prefix, it
695 will execute the above `config.site' and define these three variables.
697      ~/amhello-1.0 % ./configure --prefix ~/usr
698      configure: loading site script /home/adl/usr/share/config.site
699      ...
701    *Note Setting Site Defaults: (autoconf)Site Defaults, for more
702 information about this feature.
704 \x1f
705 File: automake.info,  Node: VPATH Builds,  Next: Two-Part Install,  Prev: config.site,  Up: Use Cases
707 2.2.6 Parallel Build Trees (a.k.a. VPATH Builds)
708 ------------------------------------------------
710 The GNU Build System distinguishes two trees: the source tree, and the
711 build tree.
713    The source tree is rooted in the directory containing `configure'.
714 It contains all the sources files (those that are distributed), and may
715 be arranged using several subdirectories.
717    The build tree is rooted in the directory in which `configure' was
718 run, and is populated with all object files, programs, libraries, and
719 other derived files built from the sources (and hence not distributed).
720 The build tree usually has the same subdirectory layout as the source
721 tree; its subdirectories are created automatically by the build system.
723    If `configure' is executed in its own directory, the source and
724 build trees are combined: derived files are constructed in the same
725 directories as their sources.  This was the case in our first
726 installation example (*note Basic Installation::).
728    A common request from users is that they want to confine all derived
729 files to a single directory, to keep their source directories
730 uncluttered.  Here is how we could run `configure' to build everything
731 in a subdirectory called `build/'.
733      ~ % tar zxf ~/amhello-1.0.tar.gz
734      ~ % cd amhello-1.0
735      ~/amhello-1.0 % mkdir build && cd build
736      ~/amhello-1.0/build % ../configure
737      ...
738      ~/amhello-1.0/build % make
739      ...
741    These setups, where source and build trees are different, are often
742 called "parallel builds" or "VPATH builds".  The expression _parallel
743 build_ is misleading: the word _parallel_ is a reference to the way the
744 build tree shadows the source tree, it is not about some concurrency in
745 the way build commands are run.  For this reason we refer to such
746 setups using the name _VPATH builds_ in the sequel.  _VPATH_ is the
747 name of the `make' feature used by the `Makefile's to allow these
748 builds (*note `VPATH': Search Path for All Prerequisites: (make)General
749 Search.).
751    VPATH builds have other interesting uses.  One is to build the same
752 sources with multiple configurations.  For instance:
754      ~ % tar zxf ~/amhello-1.0.tar.gz
755      ~ % cd amhello-1.0
756      ~/amhello-1.0 % mkdir debug optim && cd debug
757      ~/amhello-1.0/debug % ../configure CFLAGS='-g -O0'
758      ...
759      ~/amhello-1.0/debug % make
760      ...
761      ~/amhello-1.0/debug % cd ../optim
762      ~/amhello-1.0/optim % ../configure CFLAGS='-O3 -fomit-frame-pointer'
763      ...
764      ~/amhello-1.0/optim % make
765      ...
767    With network file systems, a similar approach can be used to build
768 the same sources on different machines.  For instance, suppose that the
769 sources are installed on a directory shared by two hosts: `HOST1' and
770 `HOST2', which may be different platforms.
772      ~ % cd /nfs/src
773      /nfs/src % tar zxf ~/amhello-1.0.tar.gz
775    On the first host, you could create a local build directory:
776      [HOST1] ~ % mkdir /tmp/amh && cd /tmp/amh
777      [HOST1] /tmp/amh % /nfs/src/amhello-1.0/configure
778      ...
779      [HOST1] /tmp/amh % make && sudo make install
780      ...
782 (Here we assume the that installer has configured `sudo' so it can
783 execute `make install' with root privileges; it is more convenient than
784 using `su' like in *Note Basic Installation::).
786    On the second host, you would do exactly the same, possibly at the
787 same time:
788      [HOST2] ~ % mkdir /tmp/amh && cd /tmp/amh
789      [HOST2] /tmp/amh % /nfs/src/amhello-1.0/configure
790      ...
791      [HOST2] /tmp/amh % make && sudo make install
792      ...
794    In this scenario, nothing forbids the `/nfs/src/amhello-1.0'
795 directory from being read-only.  In fact VPATH builds are also a means
796 of building packages from a read-only medium such as a CD-ROM.  (The
797 FSF used to sell CD-ROM with unpacked source code, before the GNU
798 project grew so big.)
800 \x1f
801 File: automake.info,  Node: Two-Part Install,  Next: Cross-Compilation,  Prev: VPATH Builds,  Up: Use Cases
803 2.2.7 Two-Part Installation
804 ---------------------------
806 In our last example (*note VPATH Builds::), a source tree was shared by
807 two hosts, but compilation and installation were done separately on
808 each host.
810    The GNU Build System also supports networked setups where part of the
811 installed files should be shared amongst multiple hosts.  It does so by
812 distinguishing architecture-dependent files from
813 architecture-independent files, and providing two `Makefile' targets to
814 install each of these classes of files.
816    These targets are `install-exec' for architecture-dependent files
817 and `install-data' for architecture-independent files.  The command we
818 used up to now, `make install', can be thought of as a shorthand for
819 `make install-exec install-data'.
821    From the GNU Build System point of view, the distinction between
822 architecture-dependent files and architecture-independent files is
823 based exclusively on the directory variable used to specify their
824 installation destination.  In the list of directory variables we
825 provided earlier (*note Standard Directory Variables::), all the
826 variables based on EXEC-PREFIX designate architecture-dependent
827 directories whose files will be installed by `make install-exec'.  The
828 others designate architecture-independent directories and will serve
829 files installed by `make install-data'.  *Note Install::, for more
830 details.
832    Here is how we could revisit our two-host installation example,
833 assuming that (1) we want to install the package directly in `/usr',
834 and (2) the directory `/usr/share' is shared by the two hosts.
836    On the first host we would run
837      [HOST1] ~ % mkdir /tmp/amh && cd /tmp/amh
838      [HOST1] /tmp/amh % /nfs/src/amhello-1.0/configure --prefix /usr
839      ...
840      [HOST1] /tmp/amh % make && sudo make install
841      ...
843    On the second host, however, we need only install the
844 architecture-specific files.
845      [HOST2] ~ % mkdir /tmp/amh && cd /tmp/amh
846      [HOST2] /tmp/amh % /nfs/src/amhello-1.0/configure --prefix /usr
847      ...
848      [HOST2] /tmp/amh % make && sudo make install-exec
849      ...
851    In packages that have installation checks, it would make sense to run
852 `make installcheck' (*note Basic Installation::) to verify that the
853 package works correctly despite the apparent partial installation.
855 \x1f
856 File: automake.info,  Node: Cross-Compilation,  Next: Renaming,  Prev: Two-Part Install,  Up: Use Cases
858 2.2.8 Cross-Compilation
859 -----------------------
861 To "cross-compile" is to build on one platform a binary that will run
862 on another platform.  When speaking of cross-compilation, it is
863 important to distinguish between the "build platform" on which the
864 compilation is performed, and the "host platform" on which the
865 resulting executable is expected to run.  The following `configure'
866 options are used to specify each of them:
868 `--build=BUILD'
869      The system on which the package is built.
871 `--host=HOST'
872      The system where built programs and libraries will run.
874    When the `--host' is used, `configure' will search for the
875 cross-compiling suite for this platform.  Cross-compilation tools
876 commonly have their target architecture as prefix of their name.  For
877 instance my cross-compiler for MinGW32 has its binaries called
878 `i586-mingw32msvc-gcc', `i586-mingw32msvc-ld', `i586-mingw32msvc-as',
879 etc.
881    Here is how we could build `amhello-1.0' for `i586-mingw32msvc' on a
882 GNU/Linux PC.
884      ~/amhello-1.0 % ./configure --build i686-pc-linux-gnu --host i586-mingw32msvc
885      checking for a BSD-compatible install... /usr/bin/install -c
886      checking whether build environment is sane... yes
887      checking for gawk... gawk
888      checking whether make sets $(MAKE)... yes
889      checking for i586-mingw32msvc-strip... i586-mingw32msvc-strip
890      checking for i586-mingw32msvc-gcc... i586-mingw32msvc-gcc
891      checking for C compiler default output file name... a.exe
892      checking whether the C compiler works... yes
893      checking whether we are cross compiling... yes
894      checking for suffix of executables... .exe
895      checking for suffix of object files... o
896      checking whether we are using the GNU C compiler... yes
897      checking whether i586-mingw32msvc-gcc accepts -g... yes
898      checking for i586-mingw32msvc-gcc option to accept ANSI C...
899      ...
900      ~/amhello-1.0 % make
901      ...
902      ~/amhello-1.0 % cd src; file hello.exe
903      hello.exe: MS Windows PE 32-bit Intel 80386 console executable not relocatable
905    The `--host' and `--build' options are usually all we need for
906 cross-compiling.  The only exception is if the package being built is
907 itself a cross-compiler: we need a third option to specify its target
908 architecture.
910 `--target=TARGET'
911      When building compiler tools: the system for which the tools will
912      create output.
914    For instance when installing GCC, the GNU Compiler Collection, we can
915 use `--target=TARGET' to specify that we want to build GCC as a
916 cross-compiler for TARGET.  Mixing `--build' and `--target', we can
917 actually cross-compile a cross-compiler; such a three-way
918 cross-compilation is known as a "Canadian cross".
920    *Note Specifying the System Type: (autoconf)Specifying Names, for
921 more information about these `configure' options.
923 \x1f
924 File: automake.info,  Node: Renaming,  Next: DESTDIR,  Prev: Cross-Compilation,  Up: Use Cases
926 2.2.9 Renaming Programs at Install Time
927 ---------------------------------------
929 The GNU Build System provides means to automatically rename executables
930 before they are installed.  This is especially convenient when
931 installing a GNU package on a system that already has a proprietary
932 implementation you do not want to overwrite.  For instance, you may
933 want to install GNU `tar' as `gtar' so you can distinguish it from your
934 vendor's `tar'.
936    This can be done using one of these three `configure' options.
938 `--program-prefix=PREFIX'
939      Prepend PREFIX to installed program names.
941 `--program-suffix=SUFFIX'
942      Append SUFFIX to installed program names.
944 `--program-transform-name=PROGRAM'
945      Run `sed PROGRAM' on installed program names.
947    The following commands would install `hello' as
948 `/usr/local/bin/test-hello', for instance.
950      ~/amhello-1.0 % ./configure --program-prefix test-
951      ...
952      ~/amhello-1.0 % make
953      ...
954      ~/amhello-1.0 % sudo make install
955      ...
957 \x1f
958 File: automake.info,  Node: DESTDIR,  Next: Preparing Distributions,  Prev: Renaming,  Up: Use Cases
960 2.2.10 Building Binary Packages Using DESTDIR
961 ---------------------------------------------
963 The GNU Build System's `make install' and `make uninstall' interface
964 does not exactly fit the needs of a system administrator who has to
965 deploy and upgrade packages on lots of hosts.  In other words, the GNU
966 Build System does not replace a package manager.
968    Such package managers usually need to know which files have been
969 installed by a package, so a mere `make install' is inappropriate.
971    The `DESTDIR' variable can be used to perform a staged installation.
972 The package should be configured as if it was going to be installed in
973 its final location (e.g., `--prefix /usr'), but when running `make
974 install' the `DESTDIR' should be set to the absolute name of a
975 directory in which all the installation will be diverted.  From this
976 directory it is easy to review which files are being installed where,
977 and finally copy them to their final location by any means.
979    For instance here is how we could create a binary package containing
980 a snapshot of all the files to be installed.
982      ~/amhello-1.0 % ./configure --prefix /usr
983      ...
984      ~/amhello-1.0 % make
985      ...
986      ~/amhello-1.0 % make DESTDIR=$HOME/inst install
987      ...
988      ~/amhello-1.0 % cd ~/inst
989      ~/inst % find . -type f -print > ../files.lst
990      ~/inst % tar zcvf ~/amhello-1.0-i686.tar.gz `cat ../file.lst`
991      ./usr/bin/hello
992      ./usr/share/doc/amhello/README
994    After this example, `amhello-1.0-i686.tar.gz' is ready to be
995 uncompressed in `/' on many hosts.  (Using ``cat ../file.lst`' instead
996 of `.' as argument for `tar' avoids entries for each subdirectory in
997 the archive: we would not like `tar' to restore the modification time
998 of `/', `/usr/', etc.)
1000    Note that when building packages for several architectures, it might
1001 be convenient to use `make install-data' and `make install-exec' (*note
1002 Two-Part Install::) to gather architecture-independent files in a
1003 single package.
1005    *Note Install::, for more information.
1007 \x1f
1008 File: automake.info,  Node: Preparing Distributions,  Next: Dependency Tracking,  Prev: DESTDIR,  Up: Use Cases
1010 2.2.11 Preparing Distributions
1011 ------------------------------
1013 We have already mentioned `make dist'.  This target collects all your
1014 source files and the necessary parts of the build system to create a
1015 tarball named `PACKAGE-VERSION.tar.gz'.
1017    Another, more useful command is `make distcheck'.  The `distcheck'
1018 target constructs `PACKAGE-VERSION.tar.gz' just as well as `dist', but
1019 it additionally ensures most of the use cases presented so far work:
1021    * It attempts a full compilation of the package (*note Basic
1022      Installation::), unpacking the newly constructed tarball, running
1023      `make', `make check', `make install', as well as `make
1024      installcheck', and even `make dist',
1026    * it tests VPATH builds with read-only source tree (*note VPATH
1027      Builds::),
1029    * it makes sure `make clean', `make distclean', and `make uninstall'
1030      do not omit any file (*note Standard Targets::),
1032    * and it checks that `DESTDIR' installations work (*note DESTDIR::).
1034    All of these actions are performed in a temporary subdirectory, so
1035 that no root privileges are required.
1037    Releasing a package that fails `make distcheck' means that one of
1038 the scenarios we presented will not work and some users will be
1039 disappointed.  Therefore it is a good practice to release a package
1040 only after a successful `make distcheck'.  This of course does not
1041 imply that the package will be flawless, but at least it will prevent
1042 some of the embarrassing errors you may find in packages released by
1043 people who have never heard about `distcheck' (like `DESTDIR' not
1044 working because of a typo, or a distributed file being erased by `make
1045 clean', or even `VPATH' builds not working).
1047    *Note Creating amhello::, to recreate `amhello-1.0.tar.gz' using
1048 `make distcheck'.  *Note Dist::, for more information about `distcheck'.
1050 \x1f
1051 File: automake.info,  Node: Dependency Tracking,  Next: Nested Packages,  Prev: Preparing Distributions,  Up: Use Cases
1053 2.2.12 Automatic Dependency Tracking
1054 ------------------------------------
1056 Dependency tracking is performed as a side-effect of compilation.  Each
1057 time the build system compiles a source file, it computes its list of
1058 dependencies (in C these are the header files included by the source
1059 being compiled).  Later, any time `make' is run and a dependency
1060 appears to have changed, the dependent files will be rebuilt.
1062    When `configure' is executed, you can see it probing each compiler
1063 for the dependency mechanism it supports (several mechanisms can be
1064 used):
1066      ~/amhello-1.0 % ./configure --prefix /usr
1067      ...
1068      checking dependency style of gcc... gcc3
1069      ...
1071    Because dependencies are only computed as a side-effect of the
1072 compilation, no dependency information exists the first time a package
1073 is built.  This is OK because all the files need to be built anyway:
1074 `make' does not have to decide which files need to be rebuilt.  In
1075 fact, dependency tracking is completely useless for one-time builds and
1076 there is a `configure' option to disable this:
1078 `--disable-dependency-tracking'
1079      Speed up one-time builds.
1081    Some compilers do not offer any practical way to derive the list of
1082 dependencies as a side-effect of the compilation, requiring a separate
1083 run (maybe of another tool) to compute these dependencies.  The
1084 performance penalty implied my these methods is important enough to
1085 disable them by default.  The option `--enable-dependency-tracking'
1086 must be passed to `configure' to activate them.
1088 `--enable-dependency-tracking'
1089      Do not reject slow dependency extractors.
1091    *Note Dependency Tracking Evolution::, for some discussion about the
1092 different dependency tracking schemes used by Automake over the years.
1094 \x1f
1095 File: automake.info,  Node: Nested Packages,  Prev: Dependency Tracking,  Up: Use Cases
1097 2.2.13 Nested Packages
1098 ----------------------
1100 Although nesting packages isn't something we would recommend to someone
1101 who is discovering the Autotools, it is a nice feature worthy of
1102 mention in this small advertising tour.
1104    Autoconfiscated packages (that means packages whose build system have
1105 been created by Autoconf and friends) can be nested to arbitrary depth.
1107    A typical setup is that a package A will distribute one of the
1108 libraries it needs in a subdirectory.  This library B is a complete
1109 package with its own GNU Build System.  The `configure' script of A will
1110 run the `configure' script of B as part of its execution, building and
1111 installing A will also build and install B.  Generating a distribution
1112 for A will also include B.
1114    It is possible to gather several package like this.  GCC is a heavy
1115 user of this feature.  This gives installers a single package to
1116 configure, build and install, while it allows developers to work on
1117 subpackages independently.
1119    When configuring nested packages, the `configure' options given to
1120 the top-level `configure' are passed recursively to nested
1121 `configure's.  A package that does not understand an option will ignore
1122 it, assuming it is meaningful to some other package.
1124    The command `configure --help=recursive' can be used to display the
1125 options supported by all the included packages.
1127    *Note Subpackages::, for an example setup.
1129 \x1f
1130 File: automake.info,  Node: Why Autotools,  Next: Hello World,  Prev: Use Cases,  Up: Autotools Introduction
1132 2.3 How Autotools Help
1133 ======================
1135 There are several reasons why you may not want to implement the GNU
1136 Build System yourself (read: write a `configure' script and `Makefile's
1137 yourself).
1139    * As we have seen, the GNU Build System has a lot of features (*note
1140      Use Cases::).  Some users may expect features you have not
1141      implemented because you did not need them.
1143    * Implementing these features portably is difficult and exhausting.
1144      Think of writing portable shell scripts, and portable `Makefile's,
1145      for systems you may not have handy.  *Note Portable Shell
1146      Programming: (autoconf)Portable Shell, to convince yourself.
1148    * You will have to upgrade your setup to follow changes to the GNU
1149      Coding Standards.
1151    The GNU Autotools take all this burden off your back and provide:
1153    * Tools to create a portable, complete, and self-contained GNU Build
1154      System, from simple instructions.  _Self-contained_ meaning the
1155      resulting build system does not require the GNU Autotools.
1157    * A central place where fixes and improvements are made: a bug-fix
1158      for a portability issue will benefit every package.
1160    Yet there also exist reasons why you may want NOT to use the
1161 Autotools.... For instance you may be already using (or used to)
1162 another incompatible build system.  Autotools will only be useful if
1163 you do accept the concepts of the GNU Build System.  People who have
1164 their own idea of how a build system should work will feel frustrated
1165 by the Autotools.
1167 \x1f
1168 File: automake.info,  Node: Hello World,  Prev: Why Autotools,  Up: Autotools Introduction
1170 2.4 A Small Hello World
1171 =======================
1173 In this section we recreate the `amhello-1.0' package from scratch.
1174 The first subsection shows how to call the Autotools to instantiate the
1175 GNU Build System, while the second explains the meaning of the
1176 `configure.ac' and `Makefile.am' files read by the Autotools.
1178 * Menu:
1180 * Creating amhello::            Create `amhello-1.0.tar.gz' from scratch
1181 * amhello Explained::           `configure.ac' and `Makefile.am' explained
1183 \x1f
1184 File: automake.info,  Node: Creating amhello,  Next: amhello Explained,  Up: Hello World
1186 2.4.1 Creating `amhello-1.0.tar.gz'
1187 -----------------------------------
1189 Here is how we can recreate `amhello-1.0.tar.gz' from scratch.  The
1190 package is simple enough so that we will only need to write 5 files.
1191 (You may copy them from the final `amhello-1.0.tar.gz' that is
1192 distributed with Automake if you do not want to write them.)
1194    Create the following files in an empty directory.
1196    * `src/main.c' is the source file for the `hello' program.  We store
1197      it in the `src/' subdirectory, because later, when the package
1198      evolves, it will ease the addition of a `man/' directory for man
1199      pages, a `data/' directory for data files, etc.
1200           ~/amhello % cat src/main.c
1201           #include <config.h>
1202           #include <stdio.h>
1204           int
1205           main (void)
1206           {
1207             puts ("Hello World!");
1208             puts ("This is " PACKAGE_STRING ".");
1209             return 0;
1210           }
1212    * `README' contains some very limited documentation for our little
1213      package.
1214           ~/amhello % cat README
1215           This is a demonstration package for GNU Automake.
1216           Type `info Automake' to read the Automake manual.
1218    * `Makefile.am' and `src/Makefile.am' contain Automake instructions
1219      for these two directories.
1221           ~/amhello % cat src/Makefile.am
1222           bin_PROGRAMS = hello
1223           hello_SOURCES = main.c
1224           ~/amhello % cat Makefile.am
1225           SUBDIRS = src
1226           dist_doc_DATA = README
1228    * Finally, `configure.ac' contains Autoconf instructions to create
1229      the `configure' script.
1231           ~/amhello % cat configure.ac
1232           AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
1233           AM_INIT_AUTOMAKE([-Wall -Werror foreign])
1234           AC_PROG_CC
1235           AC_CONFIG_HEADERS([config.h])
1236           AC_CONFIG_FILES([
1237            Makefile
1238            src/Makefile
1239           ])
1240           AC_OUTPUT
1242    Once you have these five files, it is time to run the Autotools to
1243 instantiate the build system.  Do this using the `autoreconf' command
1244 as follows:
1246      ~/amhello % autoreconf --install
1247      configure.ac: installing `./install-sh'
1248      configure.ac: installing `./missing'
1249      src/Makefile.am: installing `./depcomp'
1251    At this point the build system is complete.
1253    In addition to the three scripts mentioned in its output, you can see
1254 that `autoreconf' created four other files: `configure', `config.h.in',
1255 `Makefile.in', and `src/Makefile.in'.  The latter three files are
1256 templates that will be adapted to the system by `configure' under the
1257 names `config.h', `Makefile', and `src/Makefile'.  Let's do this:
1259      ~/amhello % ./configure
1260      checking for a BSD-compatible install... /usr/bin/install -c
1261      checking whether build environment is sane... yes
1262      checking for gawk... no
1263      checking for mawk... mawk
1264      checking whether make sets $(MAKE)... yes
1265      checking for gcc... gcc
1266      checking for C compiler default output file name... a.out
1267      checking whether the C compiler works... yes
1268      checking whether we are cross compiling... no
1269      checking for suffix of executables...
1270      checking for suffix of object files... o
1271      checking whether we are using the GNU C compiler... yes
1272      checking whether gcc accepts -g... yes
1273      checking for gcc option to accept ISO C89... none needed
1274      checking for style of include used by make... GNU
1275      checking dependency style of gcc... gcc3
1276      configure: creating ./config.status
1277      config.status: creating Makefile
1278      config.status: creating src/Makefile
1279      config.status: creating config.h
1280      config.status: executing depfiles commands
1282    You can see `Makefile', `src/Makefile', and `config.h' being created
1283 at the end after `configure' has probed the system.  It is now possible
1284 to run all the targets we wish (*note Standard Targets::).  For
1285 instance:
1287      ~/amhello % make
1288      ...
1289      ~/amhello % src/hello
1290      Hello World!
1291      This is amhello 1.0.
1292      ~/amhello % make distcheck
1293      ...
1294      =============================================
1295      amhello-1.0 archives ready for distribution:
1296      amhello-1.0.tar.gz
1297      =============================================
1299    Note that running `autoreconf' is only needed initially when the GNU
1300 Build System does not exist.  When you later change some instructions
1301 in a `Makefile.am' or `configure.ac', the relevant part of the build
1302 system will be regenerated automatically when you execute `make'.
1304    `autoreconf' is a script that calls `autoconf', `automake', and a
1305 bunch of other commands in the right order.  If you are beginning with
1306 these tools, it is not important to figure out in which order all these
1307 tools should be invoked and why.  However, because Autoconf and
1308 Automake have separate manuals, the important point to understand is
1309 that `autoconf' is in charge of creating `configure' from
1310 `configure.ac', while `automake' is in charge of creating
1311 `Makefile.in's from `Makefile.am's and `configure.ac'.  This should at
1312 least direct you to the right manual when seeking answers.
1314 \x1f
1315 File: automake.info,  Node: amhello Explained,  Prev: Creating amhello,  Up: Hello World
1317 2.4.2 `amhello-1.0' Explained
1318 -----------------------------
1320 Let us begin with the contents of `configure.ac'.
1322      AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
1323      AM_INIT_AUTOMAKE([-Wall -Werror foreign])
1324      AC_PROG_CC
1325      AC_CONFIG_HEADERS([config.h])
1326      AC_CONFIG_FILES([
1327       Makefile
1328       src/Makefile
1329      ])
1330      AC_OUTPUT
1332    This file is read by both `autoconf' (to create `configure.ac') and
1333 `automake' (to create the various `Makefile.in's).  It contains a
1334 series of M4 macros that will be expanded as shell code to finally form
1335 the `configure' script.  We will not elaborate on the syntax of this
1336 file, because the Autoconf manual has a whole section about it (*note
1337 Writing `configure.ac': (autoconf)Writing configure.ac.).
1339    The macros prefixed with `AC_' are Autoconf macros, documented in
1340 the Autoconf manual (*note Autoconf Macro Index: (autoconf)Autoconf
1341 Macro Index.).  The macros that start with `AM_' are Automake macros,
1342 documented later in this manual (*note Macro Index::).
1344    The first two lines of `configure.ac' initialize Autoconf and
1345 Automake.  `AC_INIT' takes in parameters the name of the package, its
1346 version number, and a contact address for bug-reports about the package
1347 (this address is output at the end of `./configure --help', for
1348 instance).  When adapting this setup to your own package, by all means
1349 please do not blindly copy Automake's address: use the mailing list of
1350 your package, or your own mail address.
1352    The argument to `AM_INIT_AUTOMAKE' is a list of options for
1353 `automake' (*note Options::).  `-Wall' and `-Werror' ask `automake' to
1354 turn on all warnings and report them as errors.  We are speaking of
1355 *Automake* warnings here, such as dubious instructions in
1356 `Makefile.am'.  This has absolutely nothing to do with how the compiler
1357 will be called, even though it may support options with similar names.
1358 Using `-Wall -Werror' is a safe setting when starting to work on a
1359 package: you do not want to miss any issues.  Later you may decide to
1360 relax things a bit.  The `foreign' option tells Automake that this
1361 package will not follow the GNU Standards.  GNU packages should always
1362 distribute additional files such as `ChangeLog', `AUTHORS', etc.  We do
1363 not want `automake' to complain about these missing files in our small
1364 example.
1366    The `AC_PROG_CC' line causes the `configure' script to search for a
1367 C compiler and define the variable `CC' with its name.  The
1368 `src/Makefile.in' file generated by Automake uses the variable `CC' to
1369 build `hello', so when `configure' creates `src/Makefile' from
1370 `src/Makefile.in', it will define `CC' with the value it has found.  If
1371 Automake is asked to create a `Makefile.in' that uses `CC' but
1372 `configure.ac' does not define it, it will suggest you add a call to
1373 `AC_PROG_CC'.
1375    The `AC_CONFIG_HEADERS([config.h])' invocation causes the
1376 `configure' script to create a `config.h' file gathering `#define's
1377 defined by other macros in `configure.ac'.  In our case, the `AC_INIT'
1378 macro already defined a few of them.  Here is an excerpt of `config.h'
1379 after `configure' has run:
1381      ...
1382      /* Define to the address where bug reports for this package should be sent. */
1383      #define PACKAGE_BUGREPORT "bug-automake@gnu.org"
1385      /* Define to the full name and version of this package. */
1386      #define PACKAGE_STRING "amhello 1.0"
1387      ...
1389    As you probably noticed, `src/main.c' includes `config.h' so it can
1390 use `PACKAGE_STRING'.  In a real-world project, `config.h' can grow
1391 really big, with one `#define' per feature probed on the system.
1393    The `AC_CONFIG_FILES' macro declares the list of files that
1394 `configure' should create from their `*.in' templates.  Automake also
1395 scans this list to find the `Makefile.am' files it must process.  (This
1396 is important to remember: when adding a new directory to your project,
1397 you should add its `Makefile' to this list, otherwise Automake will
1398 never process the new `Makefile.am' you wrote in that directory.)
1400    Finally, the `AC_OUTPUT' line is a closing command that actually
1401 produces the part of the script in charge of creating the files
1402 registered with `AC_CONFIG_HEADERS' and `AC_CONFIG_FILES'.
1404    When starting a new project, we suggest you start with such a simple
1405 `configure.ac', and gradually add the other tests it requires.  The
1406 command `autoscan' can also suggest a few of the tests your package may
1407 need (*note Using `autoscan' to Create `configure.ac':
1408 (autoconf)autoscan Invocation.).
1410    We now turn to `src/Makefile.am'.  This file contains Automake
1411 instructions to build and install `hello'.
1413      bin_PROGRAMS = hello
1414      hello_SOURCES = main.c
1416    A `Makefile.am' has the same syntax as an ordinary `Makefile'.  When
1417 `automake' processes a `Makefile.am' it copies the entire file into the
1418 output `Makefile.in' (that will be later turned into `Makefile' by
1419 `configure') but will react to certain variable definitions by
1420 generating some build rules and other variables.  Often `Makefile.am's
1421 contain only a list of variable definitions as above, but they can also
1422 contain other variable and rule definitions that `automake' will pass
1423 along without interpretation.
1425    Variables that end with `_PROGRAMS' are special variables that list
1426 programs that the resulting `Makefile' should build.  In Automake
1427 speak, this `_PROGRAMS' suffix is called a "primary"; Automake
1428 recognizes other primaries such as `_SCRIPTS', `_DATA', `_LIBRARIES',
1429 etc. corresponding to different types of files.
1431    The `bin' part of the `bin_PROGRAMS' tells `automake' that the
1432 resulting programs should be installed in BINDIR.  Recall that the GNU
1433 Build System uses a set of variables to denote destination directories
1434 and allow users to customize these locations (*note Standard Directory
1435 Variables::).  Any such directory variable can be put in front of a
1436 primary (omitting the `dir' suffix) to tell `automake' where to install
1437 the listed files.
1439    Programs need to be built from source files, so for each program
1440 `PROG' listed in a `_PROGRAMS' variable, `automake' will look for
1441 another variable named `PROG_SOURCES' listing its source files.  There
1442 may be more than one source file: they will all be compiled and linked
1443 together.
1445    Automake also knows that source files need to be distributed when
1446 creating a tarball (unlike built programs).  So a side-effect of this
1447 `hello_SOURCES' declaration is that `main.c' will be part of the
1448 tarball created by `make dist'.
1450    Finally here are some explanations regarding the top-level
1451 `Makefile.am'.
1453      SUBDIRS = src
1454      dist_doc_DATA = README
1456    `SUBDIRS' is a special variable listing all directories that `make'
1457 should recurse into before processing the current directory.  So this
1458 line is responsible for `make' building `src/hello' even though we run
1459 it from the top-level.  This line also causes `make install' to install
1460 `src/hello' before installing `README' (not that this order matters).
1462    The line `dist_doc_DATA = README' causes `README' to be distributed
1463 and installed in DOCDIR.  Files listed with the `_DATA' primary are not
1464 automatically part of the tarball built with `make dist', so we add the
1465 `dist_' prefix so they get distributed.  However, for `README' it would
1466 not have been necessary: `automake' automatically distributes any
1467 `README' file it encounters (the list of other files automatically
1468 distributed is presented by `automake --help').  The only important
1469 effect of this second line is therefore to install `README' during
1470 `make install'.
1472 \x1f
1473 File: automake.info,  Node: Generalities,  Next: Examples,  Prev: Autotools Introduction,  Up: Top
1475 3 General ideas
1476 ***************
1478 The following sections cover a few basic ideas that will help you
1479 understand how Automake works.
1481 * Menu:
1483 * General Operation::           General operation of Automake
1484 * Strictness::                  Standards conformance checking
1485 * Uniform::                     The Uniform Naming Scheme
1486 * Canonicalization::            How derived variables are named
1487 * User Variables::              Variables reserved for the user
1488 * Auxiliary Programs::          Programs automake might require
1490 \x1f
1491 File: automake.info,  Node: General Operation,  Next: Strictness,  Up: Generalities
1493 3.1 General Operation
1494 =====================
1496 Automake works by reading a `Makefile.am' and generating a
1497 `Makefile.in'.  Certain variables and rules defined in the
1498 `Makefile.am' instruct Automake to generate more specialized code; for
1499 instance, a `bin_PROGRAMS' variable definition will cause rules for
1500 compiling and linking programs to be generated.
1502    The variable definitions and rules in the `Makefile.am' are copied
1503 verbatim into the generated file.  This allows you to add arbitrary
1504 code into the generated `Makefile.in'.  For instance, the Automake
1505 distribution includes a non-standard rule for the `cvs-dist' target,
1506 which the Automake maintainer uses to make distributions from his
1507 source control system.
1509    Note that most GNU make extensions are not recognized by Automake.
1510 Using such extensions in a `Makefile.am' will lead to errors or
1511 confusing behavior.
1513    A special exception is that the GNU make append operator, `+=', is
1514 supported.  This operator appends its right hand argument to the
1515 variable specified on the left.  Automake will translate the operator
1516 into an ordinary `=' operator; `+=' will thus work with any make
1517 program.
1519    Automake tries to keep comments grouped with any adjoining rules or
1520 variable definitions.
1522    A rule defined in `Makefile.am' generally overrides any such rule of
1523 a similar name that would be automatically generated by `automake'.
1524 Although this is a supported feature, it is generally best to avoid
1525 making use of it, as sometimes the generated rules are very particular.
1527    Similarly, a variable defined in `Makefile.am' or `AC_SUBST'ed from
1528 `configure.ac' will override any definition of the variable that
1529 `automake' would ordinarily create.  This feature is more often useful
1530 than the ability to override a rule.  Be warned that many of the
1531 variables generated by `automake' are considered to be for internal use
1532 only, and their names might change in future releases.
1534    When examining a variable definition, Automake will recursively
1535 examine variables referenced in the definition.  For example, if
1536 Automake is looking at the content of `foo_SOURCES' in this snippet
1538      xs = a.c b.c
1539      foo_SOURCES = c.c $(xs)
1541    it would use the files `a.c', `b.c', and `c.c' as the contents of
1542 `foo_SOURCES'.
1544    Automake also allows a form of comment that is _not_ copied into the
1545 output; all lines beginning with `##' (leading spaces allowed) are
1546 completely ignored by Automake.
1548    It is customary to make the first line of `Makefile.am' read:
1550      ## Process this file with automake to produce Makefile.in
1552 \x1f
1553 File: automake.info,  Node: Strictness,  Next: Uniform,  Prev: General Operation,  Up: Generalities
1555 3.2 Strictness
1556 ==============
1558 While Automake is intended to be used by maintainers of GNU packages, it
1559 does make some effort to accommodate those who wish to use it, but do
1560 not want to use all the GNU conventions.
1562    To this end, Automake supports three levels of "strictness"--the
1563 strictness indicating how stringently Automake should check standards
1564 conformance.
1566    The valid strictness levels are:
1568 `foreign'
1569      Automake will check for only those things that are absolutely
1570      required for proper operations.  For instance, whereas GNU
1571      standards dictate the existence of a `NEWS' file, it will not be
1572      required in this mode.  The name comes from the fact that Automake
1573      is intended to be used for GNU programs; these relaxed rules are
1574      not the standard mode of operation.
1576 `gnu'
1577      Automake will check--as much as possible--for compliance to the GNU
1578      standards for packages.  This is the default.
1580 `gnits'
1581      Automake will check for compliance to the as-yet-unwritten "Gnits
1582      standards".  These are based on the GNU standards, but are even
1583      more detailed.  Unless you are a Gnits standards contributor, it is
1584      recommended that you avoid this option until such time as the Gnits
1585      standard is actually published (which may never happen).
1587    *Note Gnits::, for more information on the precise implications of
1588 the strictness level.
1590    Automake also has a special "cygnus" mode that is similar to
1591 strictness but handled differently.  This mode is useful for packages
1592 that are put into a "Cygnus" style tree (e.g., the GCC tree).  *Note
1593 Cygnus::, for more information on this mode.
1595 \x1f
1596 File: automake.info,  Node: Uniform,  Next: Canonicalization,  Prev: Strictness,  Up: Generalities
1598 3.3 The Uniform Naming Scheme
1599 =============================
1601 Automake variables generally follow a "uniform naming scheme" that
1602 makes it easy to decide how programs (and other derived objects) are
1603 built, and how they are installed.  This scheme also supports
1604 `configure' time determination of what should be built.
1606    At `make' time, certain variables are used to determine which
1607 objects are to be built.  The variable names are made of several pieces
1608 that are concatenated together.
1610    The piece that tells automake what is being built is commonly called
1611 the "primary".  For instance, the primary `PROGRAMS' holds a list of
1612 programs that are to be compiled and linked.  
1614    A different set of names is used to decide where the built objects
1615 should be installed.  These names are prefixes to the primary, and they
1616 indicate which standard directory should be used as the installation
1617 directory.  The standard directory names are given in the GNU standards
1618 (*note Directory Variables: (standards)Directory Variables.).  Automake
1619 extends this list with `pkglibdir', `pkgincludedir', and `pkgdatadir';
1620 these are the same as the non-`pkg' versions, but with `$(PACKAGE)'
1621 appended.  For instance, `pkglibdir' is defined as
1622 `$(libdir)/$(PACKAGE)'.
1624    For each primary, there is one additional variable named by
1625 prepending `EXTRA_' to the primary name.  This variable is used to list
1626 objects that may or may not be built, depending on what `configure'
1627 decides.  This variable is required because Automake must statically
1628 know the entire list of objects that may be built in order to generate
1629 a `Makefile.in' that will work in all cases.
1631    For instance, `cpio' decides at configure time which programs should
1632 be built.  Some of the programs are installed in `bindir', and some are
1633 installed in `sbindir':
1635      EXTRA_PROGRAMS = mt rmt
1636      bin_PROGRAMS = cpio pax
1637      sbin_PROGRAMS = $(MORE_PROGRAMS)
1639    Defining a primary without a prefix as a variable, e.g., `PROGRAMS',
1640 is an error.
1642    Note that the common `dir' suffix is left off when constructing the
1643 variable names; thus one writes `bin_PROGRAMS' and not
1644 `bindir_PROGRAMS'.
1646    Not every sort of object can be installed in every directory.
1647 Automake will flag those attempts it finds in error.  Automake will
1648 also diagnose obvious misspellings in directory names.
1650    Sometimes the standard directories--even as augmented by
1651 Automake--are not enough.  In particular it is sometimes useful, for
1652 clarity, to install objects in a subdirectory of some predefined
1653 directory.  To this end, Automake allows you to extend the list of
1654 possible installation directories.  A given prefix (e.g., `zar') is
1655 valid if a variable of the same name with `dir' appended is defined
1656 (e.g., `zardir').
1658    For instance, the following snippet will install `file.xml' into
1659 `$(datadir)/xml'.
1661      xmldir = $(datadir)/xml
1662      xml_DATA = file.xml
1664    The special prefix `noinst_' indicates that the objects in question
1665 should be built but not installed at all.  This is usually used for
1666 objects required to build the rest of your package, for instance static
1667 libraries (*note A Library::), or helper scripts.
1669    The special prefix `check_' indicates that the objects in question
1670 should not be built until the `make check' command is run.  Those
1671 objects are not installed either.
1673    The current primary names are `PROGRAMS', `LIBRARIES', `LISP',
1674 `PYTHON', `JAVA', `SCRIPTS', `DATA', `HEADERS', `MANS', and `TEXINFOS'.  
1676    Some primaries also allow additional prefixes that control other
1677 aspects of `automake''s behavior.  The currently defined prefixes are
1678 `dist_', `nodist_', and `nobase_'.  These prefixes are explained later
1679 (*note Program and Library Variables::).
1681 \x1f
1682 File: automake.info,  Node: Canonicalization,  Next: User Variables,  Prev: Uniform,  Up: Generalities
1684 3.4 How derived variables are named
1685 ===================================
1687 Sometimes a Makefile variable name is derived from some text the
1688 maintainer supplies.  For instance, a program name listed in
1689 `_PROGRAMS' is rewritten into the name of a `_SOURCES' variable.  In
1690 cases like this, Automake canonicalizes the text, so that program names
1691 and the like do not have to follow Makefile variable naming rules.  All
1692 characters in the name except for letters, numbers, the strudel (@),
1693 and the underscore are turned into underscores when making variable
1694 references.
1696    For example, if your program is named `sniff-glue', the derived
1697 variable name would be `sniff_glue_SOURCES', not `sniff-glue_SOURCES'.
1698 Similarly the sources for a library named `libmumble++.a' should be
1699 listed in the `libmumble___a_SOURCES' variable.
1701    The strudel is an addition, to make the use of Autoconf
1702 substitutions in variable names less obfuscating.
1704 \x1f
1705 File: automake.info,  Node: User Variables,  Next: Auxiliary Programs,  Prev: Canonicalization,  Up: Generalities
1707 3.5 Variables reserved for the user
1708 ===================================
1710 Some `Makefile' variables are reserved by the GNU Coding Standards for
1711 the use of the "user"--the person building the package.  For instance,
1712 `CFLAGS' is one such variable.
1714    Sometimes package developers are tempted to set user variables such
1715 as `CFLAGS' because it appears to make their job easier.  However, the
1716 package itself should never set a user variable, particularly not to
1717 include switches that are required for proper compilation of the
1718 package.  Since these variables are documented as being for the package
1719 builder, that person rightfully expects to be able to override any of
1720 these variables at build time.
1722    To get around this problem, Automake introduces an automake-specific
1723 shadow variable for each user flag variable.  (Shadow variables are not
1724 introduced for variables like `CC', where they would make no sense.)
1725 The shadow variable is named by prepending `AM_' to the user variable's
1726 name.  For instance, the shadow variable for `YFLAGS' is `AM_YFLAGS'.
1727 The package maintainer--that is, the author(s) of the `Makefile.am' and
1728 `configure.ac' files--may adjust these shadow variables however
1729 necessary.
1731    *Note Flag Variables Ordering::, for more discussion about these
1732 variables and how they interact with per-target variables.
1734 \x1f
1735 File: automake.info,  Node: Auxiliary Programs,  Prev: User Variables,  Up: Generalities
1737 3.6 Programs automake might require
1738 ===================================
1740 Automake sometimes requires helper programs so that the generated
1741 `Makefile' can do its work properly.  There are a fairly large number
1742 of them, and we list them here.
1744    Although all of these files are distributed and installed with
1745 Automake, a couple of them are maintained separately.  The Automake
1746 copies are updated before each release, but we mention the original
1747 source in case you need more recent versions.
1749 `ansi2knr.c'
1750 `ansi2knr.1'
1751      These two files are used by the obsolete de-ANSI-fication support
1752      (*note ANSI::).
1754 `compile'
1755      This is a wrapper for compilers that do not accept options `-c'
1756      and `-o' at the same time.  It is only used when absolutely
1757      required.  Such compilers are rare.
1759 `config.guess'
1760 `config.sub'
1761      These two programs compute the canonical triplets for the given
1762      build, host, or target architecture.  These programs are updated
1763      regularly to support new architectures and fix probes broken by
1764      changes in new kernel versions.  Each new release of Automake
1765      comes with up-to-date copies of these programs.  If your copy of
1766      Automake is getting old, you are encouraged to fetch the latest
1767      versions of these files from
1768      `http://savannah.gnu.org/cvs/?group=config' before making a
1769      release.
1771 `config-ml.in'
1772      This file is not a program, it is a `configure' fragment used for
1773      multilib support (*note Multilibs::).  This file is maintained in
1774      the GCC tree at `http://gcc.gnu.org/svn.html'.
1776 `depcomp'
1777      This program understands how to run a compiler so that it will
1778      generate not only the desired output but also dependency
1779      information that is then used by the automatic dependency tracking
1780      feature (*note Dependencies::).
1782 `elisp-comp'
1783      This program is used to byte-compile Emacs Lisp code.
1785 `install-sh'
1786      This is a replacement for the `install' program that works on
1787      platforms where `install' is unavailable or unusable.
1789 `mdate-sh'
1790      This script is used to generate a `version.texi' file.  It examines
1791      a file and prints some date information about it.
1793 `missing'
1794      This wraps a number of programs that are typically only required by
1795      maintainers.  If the program in question doesn't exist, `missing'
1796      prints an informative warning and attempts to fix things so that
1797      the build can continue.
1799 `mkinstalldirs'
1800      This script used to be a wrapper around `mkdir -p', which is not
1801      portable.  Now we prefer to use `install-sh -d' when configure
1802      finds that `mkdir -p' does not work, this makes one less script to
1803      distribute.
1805      For backward compatibility `mkinstalldirs' is still used and
1806      distributed when `automake' finds it in a package.  But it is no
1807      longer installed automatically, and it should be safe to remove it.
1809 `py-compile'
1810      This is used to byte-compile Python scripts.
1812 `symlink-tree'
1813      This program duplicates a tree of directories, using symbolic links
1814      instead of copying files.  Such operation is performed when
1815      building multilibs (*note Multilibs::).  This file is maintained
1816      in the GCC tree at `http://gcc.gnu.org/svn.html'.
1818 `texinfo.tex'
1819      Not a program, this file is required for `make dvi', `make ps' and
1820      `make pdf' to work when Texinfo sources are in the package.  The
1821      latest version can be downloaded from
1822      `http://www.gnu.org/software/texinfo/'.
1824 `ylwrap'
1825      This program wraps `lex' and `yacc' to rename their output files.
1826      It also ensures that, for instance, multiple `yacc' instances can
1827      be invoked in a single directory in parallel.
1830 \x1f
1831 File: automake.info,  Node: Examples,  Next: Invoking Automake,  Prev: Generalities,  Up: Top
1833 4 Some example packages
1834 ***********************
1836 This section contains two small examples.
1838    The first example (*note Complete::) assumes you have an existing
1839 project already using Autoconf, with handcrafted `Makefile's, and that
1840 you want to convert it to using Automake.  If you are discovering both
1841 tools, it is probably better that you look at the Hello World example
1842 presented earlier (*note Hello World::).
1844    The second example (*note true::) shows how two programs can be built
1845 from the same file, using different compilation parameters.  It
1846 contains some technical digressions that are probably best skipped on
1847 first read.
1849 * Menu:
1851 * Complete::                    A simple example, start to finish
1852 * true::                        Building true and false
1854 \x1f
1855 File: automake.info,  Node: Complete,  Next: true,  Up: Examples
1857 4.1 A simple example, start to finish
1858 =====================================
1860 Let's suppose you just finished writing `zardoz', a program to make
1861 your head float from vortex to vortex.  You've been using Autoconf to
1862 provide a portability framework, but your `Makefile.in's have been
1863 ad-hoc.  You want to make them bulletproof, so you turn to Automake.
1865    The first step is to update your `configure.ac' to include the
1866 commands that `automake' needs.  The way to do this is to add an
1867 `AM_INIT_AUTOMAKE' call just after `AC_INIT':
1869      AC_INIT([zardoz], [1.0])
1870      AM_INIT_AUTOMAKE
1871      ...
1873    Since your program doesn't have any complicating factors (e.g., it
1874 doesn't use `gettext', it doesn't want to build a shared library),
1875 you're done with this part.  That was easy!
1877    Now you must regenerate `configure'.  But to do that, you'll need to
1878 tell `autoconf' how to find the new macro you've used.  The easiest way
1879 to do this is to use the `aclocal' program to generate your
1880 `aclocal.m4' for you.  But wait... maybe you already have an
1881 `aclocal.m4', because you had to write some hairy macros for your
1882 program.  The `aclocal' program lets you put your own macros into
1883 `acinclude.m4', so simply rename and then run:
1885      mv aclocal.m4 acinclude.m4
1886      aclocal
1887      autoconf
1889    Now it is time to write your `Makefile.am' for `zardoz'.  Since
1890 `zardoz' is a user program, you want to install it where the rest of
1891 the user programs go: `bindir'.  Additionally, `zardoz' has some
1892 Texinfo documentation.  Your `configure.ac' script uses
1893 `AC_REPLACE_FUNCS', so you need to link against `$(LIBOBJS)'.  So
1894 here's what you'd write:
1896      bin_PROGRAMS = zardoz
1897      zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
1898      zardoz_LDADD = $(LIBOBJS)
1900      info_TEXINFOS = zardoz.texi
1902    Now you can run `automake --add-missing' to generate your
1903 `Makefile.in' and grab any auxiliary files you might need, and you're
1904 done!
1906 \x1f
1907 File: automake.info,  Node: true,  Prev: Complete,  Up: Examples
1909 4.2 Building true and false
1910 ===========================
1912 Here is another, trickier example.  It shows how to generate two
1913 programs (`true' and `false') from the same source file (`true.c').
1914 The difficult part is that each compilation of `true.c' requires
1915 different `cpp' flags.
1917      bin_PROGRAMS = true false
1918      false_SOURCES =
1919      false_LDADD = false.o
1921      true.o: true.c
1922              $(COMPILE) -DEXIT_CODE=0 -c true.c
1924      false.o: true.c
1925              $(COMPILE) -DEXIT_CODE=1 -o false.o -c true.c
1927    Note that there is no `true_SOURCES' definition.  Automake will
1928 implicitly assume that there is a source file named `true.c', and
1929 define rules to compile `true.o' and link `true'.  The `true.o: true.c'
1930 rule supplied by the above `Makefile.am', will override the Automake
1931 generated rule to build `true.o'.
1933    `false_SOURCES' is defined to be empty--that way no implicit value
1934 is substituted.  Because we have not listed the source of `false', we
1935 have to tell Automake how to link the program.  This is the purpose of
1936 the `false_LDADD' line.  A `false_DEPENDENCIES' variable, holding the
1937 dependencies of the `false' target will be automatically generated by
1938 Automake from the content of `false_LDADD'.
1940    The above rules won't work if your compiler doesn't accept both `-c'
1941 and `-o'.  The simplest fix for this is to introduce a bogus dependency
1942 (to avoid problems with a parallel `make'):
1944      true.o: true.c false.o
1945              $(COMPILE) -DEXIT_CODE=0 -c true.c
1947      false.o: true.c
1948              $(COMPILE) -DEXIT_CODE=1 -c true.c && mv true.o false.o
1950    Also, these explicit rules do not work if the obsolete
1951 de-ANSI-fication feature is used (*note ANSI::).  Supporting
1952 de-ANSI-fication requires a little more work:
1954      true_.o: true_.c false_.o
1955              $(COMPILE) -DEXIT_CODE=0 -c true_.c
1957      false_.o: true_.c
1958              $(COMPILE) -DEXIT_CODE=1 -c true_.c && mv true_.o false_.o
1960    As it turns out, there is also a much easier way to do this same
1961 task.  Some of the above techniques are useful enough that we've kept
1962 the example in the manual.  However if you were to build `true' and
1963 `false' in real life, you would probably use per-program compilation
1964 flags, like so:
1966      bin_PROGRAMS = false true
1968      false_SOURCES = true.c
1969      false_CPPFLAGS = -DEXIT_CODE=1
1971      true_SOURCES = true.c
1972      true_CPPFLAGS = -DEXIT_CODE=0
1974    In this case Automake will cause `true.c' to be compiled twice, with
1975 different flags.  De-ANSI-fication will work automatically.  In this
1976 instance, the names of the object files would be chosen by automake;
1977 they would be `false-true.o' and `true-true.o'.  (The name of the
1978 object files rarely matters.)
1980 \x1f
1981 File: automake.info,  Node: Invoking Automake,  Next: configure,  Prev: Examples,  Up: Top
1983 5 Creating a `Makefile.in'
1984 **************************
1986 To create all the `Makefile.in's for a package, run the `automake'
1987 program in the top level directory, with no arguments.  `automake' will
1988 automatically find each appropriate `Makefile.am' (by scanning
1989 `configure.ac'; *note configure::) and generate the corresponding
1990 `Makefile.in'.  Note that `automake' has a rather simplistic view of
1991 what constitutes a package; it assumes that a package has only one
1992 `configure.ac', at the top.  If your package has multiple
1993 `configure.ac's, then you must run `automake' in each directory holding
1994 a `configure.ac'.  (Alternatively, you may rely on Autoconf's
1995 `autoreconf', which is able to recurse your package tree and run
1996 `automake' where appropriate.)
1998    You can optionally give `automake' an argument; `.am' is appended to
1999 the argument and the result is used as the name of the input file.
2000 This feature is generally only used to automatically rebuild an
2001 out-of-date `Makefile.in'.  Note that `automake' must always be run
2002 from the topmost directory of a project, even if being used to
2003 regenerate the `Makefile.in' in some subdirectory.  This is necessary
2004 because `automake' must scan `configure.ac', and because `automake'
2005 uses the knowledge that a `Makefile.in' is in a subdirectory to change
2006 its behavior in some cases.
2008    Automake will run `autoconf' to scan `configure.ac' and its
2009 dependencies (i.e., `aclocal.m4' and any included file), therefore
2010 `autoconf' must be in your `PATH'.  If there is an `AUTOCONF' variable
2011 in your environment it will be used instead of `autoconf', this allows
2012 you to select a particular version of Autoconf.  By the way, don't
2013 misunderstand this paragraph: `automake' runs `autoconf' to *scan* your
2014 `configure.ac', this won't build `configure' and you still have to run
2015 `autoconf' yourself for this purpose.
2017    `automake' accepts the following options:
2019 `-a'
2020 `--add-missing'
2021      Automake requires certain common files to exist in certain
2022      situations; for instance, `config.guess' is required if
2023      `configure.ac' runs `AC_CANONICAL_HOST'.  Automake is distributed
2024      with several of these files (*note Auxiliary Programs::); this
2025      option will cause the missing ones to be automatically added to
2026      the package, whenever possible.  In general if Automake tells you
2027      a file is missing, try using this option.  By default Automake
2028      tries to make a symbolic link pointing to its own copy of the
2029      missing file; this can be changed with `--copy'.
2031      Many of the potentially-missing files are common scripts whose
2032      location may be specified via the `AC_CONFIG_AUX_DIR' macro.
2033      Therefore, `AC_CONFIG_AUX_DIR''s setting affects whether a file is
2034      considered missing, and where the missing file is added (*note
2035      Optional::).
2037 `--libdir=DIR'
2038      Look for Automake data files in directory DIR instead of in the
2039      installation directory.  This is typically used for debugging.
2041 `-c'
2042 `--copy'
2043      When used with `--add-missing', causes installed files to be
2044      copied.  The default is to make a symbolic link.
2046 `--cygnus'
2047      Causes the generated `Makefile.in's to follow Cygnus rules, instead
2048      of GNU or Gnits rules.  For more information, see *Note Cygnus::.
2050 `-f'
2051 `--force-missing'
2052      When used with `--add-missing', causes standard files to be
2053      reinstalled even if they already exist in the source tree.  This
2054      involves removing the file from the source tree before creating
2055      the new symlink (or, with `--copy', copying the new file).
2057 `--foreign'
2058      Set the global strictness to `foreign'.  For more information, see
2059      *Note Strictness::.
2061 `--gnits'
2062      Set the global strictness to `gnits'.  For more information, see
2063      *Note Gnits::.
2065 `--gnu'
2066      Set the global strictness to `gnu'.  For more information, see
2067      *Note Gnits::.  This is the default strictness.
2069 `--help'
2070      Print a summary of the command line options and exit.
2072 `-i'
2073 `--ignore-deps'
2074      This disables the dependency tracking feature in generated
2075      `Makefile's; see *Note Dependencies::.
2077 `--include-deps'
2078      This enables the dependency tracking feature.  This feature is
2079      enabled by default.  This option is provided for historical
2080      reasons only and probably should not be used.
2082 `--no-force'
2083      Ordinarily `automake' creates all `Makefile.in's mentioned in
2084      `configure.ac'.  This option causes it to only update those
2085      `Makefile.in's that are out of date with respect to one of their
2086      dependents.
2088 `-o DIR'
2089 `--output-dir=DIR'
2090      Put the generated `Makefile.in' in the directory DIR.  Ordinarily
2091      each `Makefile.in' is created in the directory of the
2092      corresponding `Makefile.am'.  This option is deprecated and will be
2093      removed in a future release.
2095 `-v'
2096 `--verbose'
2097      Cause Automake to print information about which files are being
2098      read or created.
2100 `--version'
2101      Print the version number of Automake and exit.
2103 `-W CATEGORY'
2105 `--warnings=CATEGORY'
2106      Output warnings falling in CATEGORY.  CATEGORY can be one of:
2107     `gnu'
2108           warnings related to the GNU Coding Standards (*note Top:
2109           (standards)Top.).
2111     `obsolete'
2112           obsolete features or constructions
2114     `override'
2115           user redefinitions of Automake rules or variables
2117     `portability'
2118           portability issues (e.g., use of `make' features that are
2119           known to be not portable)
2121     `syntax'
2122           weird syntax, unused variables, typos
2124     `unsupported'
2125           unsupported or incomplete features
2127     `all'
2128           all the warnings
2130     `none'
2131           turn off all the warnings
2133     `error'
2134           treat warnings as errors
2136      A category can be turned off by prefixing its name with `no-'.  For
2137      instance, `-Wno-syntax' will hide the warnings about unused
2138      variables.
2140      The categories output by default are `syntax' and `unsupported'.
2141      Additionally, `gnu' and `portability' are enabled in `--gnu' and
2142      `--gnits' strictness.
2144      The environment variable `WARNINGS' can contain a comma separated
2145      list of categories to enable.  It will be taken into account
2146      before the command-line switches, this way `-Wnone' will also
2147      ignore any warning category enabled by `WARNINGS'.  This variable
2148      is also used by other tools like `autoconf'; unknown categories
2149      are ignored for this reason.
2152 \x1f
2153 File: automake.info,  Node: configure,  Next: Directories,  Prev: Invoking Automake,  Up: Top
2155 6 Scanning `configure.ac'
2156 *************************
2158 Automake scans the package's `configure.ac' to determine certain
2159 information about the package.  Some `autoconf' macros are required and
2160 some variables must be defined in `configure.ac'.  Automake will also
2161 use information from `configure.ac' to further tailor its output.
2163    Automake also supplies some Autoconf macros to make the maintenance
2164 easier.  These macros can automatically be put into your `aclocal.m4'
2165 using the `aclocal' program.
2167 * Menu:
2169 * Requirements::                Configuration requirements
2170 * Optional::                    Other things Automake recognizes
2171 * Invoking aclocal::            Auto-generating aclocal.m4
2172 * Macros::                      Autoconf macros supplied with Automake
2174 \x1f
2175 File: automake.info,  Node: Requirements,  Next: Optional,  Up: configure
2177 6.1 Configuration requirements
2178 ==============================
2180 The one real requirement of Automake is that your `configure.ac' call
2181 `AM_INIT_AUTOMAKE'.  This macro does several things that are required
2182 for proper Automake operation (*note Macros::).
2184    Here are the other macros that Automake requires but which are not
2185 run by `AM_INIT_AUTOMAKE':
2187 `AC_CONFIG_FILES'
2188 `AC_OUTPUT'
2189      These two macros are usually invoked as follows near the end of
2190      `configure.ac'.
2192           ...
2193           AC_CONFIG_FILES([
2194             Makefile
2195             doc/Makefile
2196             src/Makefile
2197             src/lib/Makefile
2198             ...
2199           ])
2200           AC_OUTPUT
2202      Automake uses these to determine which files to create (*note
2203      Creating Output Files: (autoconf)Output.).  A listed file is
2204      considered to be an Automake generated `Makefile' if there exists
2205      a file with the same name and the `.am' extension appended.
2206      Typically, `AC_CONFIG_FILES([foo/Makefile])' will cause Automake to
2207      generate `foo/Makefile.in' if `foo/Makefile.am' exists.
2209      When using `AC_CONFIG_FILES' with multiple input files, as in
2211           AC_CONFIG_FILES([Makefile:top.in:Makefile.in:bot.in])
2213      `automake' will generate the first `.in' input file for which a
2214      `.am' file exists.  If no such file exists the output file is not
2215      considered to be Automake generated.
2217      Files created by `AC_CONFIG_FILES', be they Automake `Makefile's
2218      or not, are all removed by `make distclean'.  Their inputs are
2219      automatically distributed, except for inputs that turn out the be
2220      outputs of prior `AC_CONFIG_FILES' commands.  Finally, rebuild
2221      rules are generated in the Automake `Makefile' existing in the
2222      subdirectory of the output file, if there is one, or in the
2223      top-level `Makefile' otherwise.
2225      The above machinery (cleaning, distributing, and rebuilding) works
2226      fine if the `AC_CONFIG_FILES' specifications contain only
2227      literals.  If part of the specification uses shell variables,
2228      `automake' will not be able to fulfill this setup, and you will
2229      have to complete the missing bits by hand.  For instance, on
2231           file=input
2232           ...
2233           AC_CONFIG_FILES([output:$file],, [file=$file])
2235      `automake' will output rules to clean `output', and rebuild it.
2236      However the rebuild rule will not depend on `input', and this file
2237      will not be distributed either.  (You must add `EXTRA_DIST =
2238      input' to your `Makefile' if `input' is a source file.)
2240      Similarly
2242           file=output
2243           file2=out:in
2244           ...
2245           AC_CONFIG_FILES([$file:input],, [file=$file])
2246           AC_CONFIG_FILES([$file2],, [file2=$file2])
2248      will only cause `input' to be distributed.  No file will be
2249      cleaned automatically (add `DISTCLEANFILES = output out'
2250      yourself), and no rebuild rule will be output.
2252      Obviously `automake' cannot guess what value `$file' is going to
2253      hold later when `configure' is run, and it cannot use the shell
2254      variable `$file' in a `Makefile'.  However, if you make reference
2255      to `$file' as `${file}' (i.e., in a way that is compatible with
2256      `make''s syntax) and furthermore use `AC_SUBST' to ensure that
2257      `${file}' is meaningful in a `Makefile', then `automake' will be
2258      able to use `${file}' to generate all these rules.  For instance,
2259      here is how the Automake package itself generates versioned
2260      scripts for its test suite:
2262           AC_SUBST([APIVERSION], ...)
2263           ...
2264           AC_CONFIG_FILES(
2265             [tests/aclocal-${APIVERSION}:tests/aclocal.in],
2266             [chmod +x tests/aclocal-${APIVERSION}],
2267             [APIVERSION=$APIVERSION])
2268           AC_CONFIG_FILES(
2269             [tests/automake-${APIVERSION}:tests/automake.in],
2270             [chmod +x tests/automake-${APIVERSION}])
2272      Here cleaning, distributing, and rebuilding are done automatically,
2273      because `${APIVERSION}' is known at `make'-time.
2275      Note that you should not use shell variables to declare `Makefile'
2276      files for which `automake' must create `Makefile.in'.  Even
2277      `AC_SUBST' does not help here, because `automake' needs to know
2278      the file name when it runs in order to check whether `Makefile.am'
2279      exists.  (In the very hairy case that your setup requires such use
2280      of variables, you will have to tell Automake which `Makefile.in's
2281      to generate on the command-line.)
2283      To summarize:
2284         * Use literals for `Makefile's, and for other files whenever
2285           possible.
2287         * Use `$file' (or `${file}' without `AC_SUBST([file])') for
2288           files that `automake' should ignore.
2290         * Use `${file}' and `AC_SUBST([file])' for files that
2291           `automake' should not ignore.
2294 \x1f
2295 File: automake.info,  Node: Optional,  Next: Invoking aclocal,  Prev: Requirements,  Up: configure
2297 6.2 Other things Automake recognizes
2298 ====================================
2300 Every time Automake is run it calls Autoconf to trace `configure.ac'.
2301 This way it can recognize the use of certain macros and tailor the
2302 generated `Makefile.in' appropriately.  Currently recognized macros and
2303 their effects are:
2305 `AC_CANONICAL_BUILD'
2306 `AC_CANONICAL_HOST'
2307 `AC_CANONICAL_TARGET'
2308      Automake will ensure that `config.guess' and `config.sub' exist.
2309      Also, the `Makefile' variables `build_triplet', `host_triplet' and
2310      `target_triplet' are introduced.  See *Note Getting the Canonical
2311      System Type: (autoconf)Canonicalizing.
2313 `AC_CONFIG_AUX_DIR'
2314      Automake will look for various helper scripts, such as
2315      `install-sh', in the directory named in this macro invocation.
2316      (The full list of scripts is: `config.guess', `config.sub',
2317      `depcomp', `elisp-comp', `compile', `install-sh', `ltmain.sh',
2318      `mdate-sh', `missing', `mkinstalldirs', `py-compile',
2319      `texinfo.tex', and `ylwrap'.)  Not all scripts are always searched
2320      for; some scripts will only be sought if the generated
2321      `Makefile.in' requires them.
2323      If `AC_CONFIG_AUX_DIR' is not given, the scripts are looked for in
2324      their standard locations.  For `mdate-sh', `texinfo.tex', and
2325      `ylwrap', the standard location is the source directory
2326      corresponding to the current `Makefile.am'.  For the rest, the
2327      standard location is the first one of `.', `..', or `../..'
2328      (relative to the top source directory) that provides any one of
2329      the helper scripts.  *Note Finding `configure' Input:
2330      (autoconf)Input.
2332      Required files from `AC_CONFIG_AUX_DIR' are automatically
2333      distributed, even if there is no `Makefile.am' in this directory.
2335 `AC_CONFIG_LIBOBJ_DIR'
2336      Automake will require the sources file declared with
2337      `AC_LIBSOURCE' (see below) in the directory specified by this
2338      macro.
2340 `AC_CONFIG_HEADERS'
2341      Automake will generate rules to rebuild these headers.  Older
2342      versions of Automake required the use of `AM_CONFIG_HEADER' (*note
2343      Macros::); this is no longer the case today.
2345      As for `AC_CONFIG_FILES' (*note Requirements::), parts of the
2346      specification using shell variables will be ignored as far as
2347      cleaning, distributing, and rebuilding is concerned.
2349 `AC_CONFIG_LINKS'
2350      Automake will generate rules to remove `configure' generated links
2351      on `make distclean' and to distribute named source files as part
2352      of `make dist'.
2354      As for `AC_CONFIG_FILES' (*note Requirements::), parts of the
2355      specification using shell variables will be ignored as far as
2356      cleaning and distributing is concerned.  (There is no rebuild
2357      rules for links.)
2359 `AC_LIBOBJ'
2360 `AC_LIBSOURCE'
2361 `AC_LIBSOURCES'
2362      Automake will automatically distribute any file listed in
2363      `AC_LIBSOURCE' or `AC_LIBSOURCES'.
2365      Note that the `AC_LIBOBJ' macro calls `AC_LIBSOURCE'.  So if an
2366      Autoconf macro is documented to call `AC_LIBOBJ([file])', then
2367      `file.c' will be distributed automatically by Automake.  This
2368      encompasses many macros like `AC_FUNC_ALLOCA', `AC_FUNC_MEMCMP',
2369      `AC_REPLACE_FUNCS', and others.
2371      By the way, direct assignments to `LIBOBJS' are no longer
2372      supported.  You should always use `AC_LIBOBJ' for this purpose.
2373      *Note `AC_LIBOBJ' vs. `LIBOBJS': (autoconf)AC_LIBOBJ vs LIBOBJS.
2375 `AC_PROG_RANLIB'
2376      This is required if any libraries are built in the package.  *Note
2377      Particular Program Checks: (autoconf)Particular Programs.
2379 `AC_PROG_CXX'
2380      This is required if any C++ source is included.  *Note Particular
2381      Program Checks: (autoconf)Particular Programs.
2383 `AC_PROG_OBJC'
2384      This is required if any Objective C source is included.  *Note
2385      Particular Program Checks: (autoconf)Particular Programs.
2387 `AC_PROG_F77'
2388      This is required if any Fortran 77 source is included.  This macro
2389      is distributed with Autoconf version 2.13 and later.  *Note
2390      Particular Program Checks: (autoconf)Particular Programs.
2392 `AC_F77_LIBRARY_LDFLAGS'
2393      This is required for programs and shared libraries that are a
2394      mixture of languages that include Fortran 77 (*note Mixing Fortran
2395      77 With C and C++::).  *Note Autoconf macros supplied with
2396      Automake: Macros.
2398 `AC_PROG_FC'
2399      This is required if any Fortran 90/95 source is included.  This
2400      macro is distributed with Autoconf version 2.58 and later.  *Note
2401      Particular Program Checks: (autoconf)Particular Programs.
2403 `AC_PROG_LIBTOOL'
2404      Automake will turn on processing for `libtool' (*note
2405      Introduction: (libtool)Top.).
2407 `AC_PROG_YACC'
2408      If a Yacc source file is seen, then you must either use this macro
2409      or define the variable `YACC' in `configure.ac'.  The former is
2410      preferred (*note Particular Program Checks: (autoconf)Particular
2411      Programs.).
2413 `AC_PROG_LEX'
2414      If a Lex source file is seen, then this macro must be used.  *Note
2415      Particular Program Checks: (autoconf)Particular Programs.
2417 `AC_REQUIRE_AUX_FILE'
2418      `automake' will ensure each file for which this macro is called
2419      exists in the aux directory, and will complain otherwise.  It will
2420      also automatically distribute the file.  This macro should be used
2421      by third-party Autoconf macros that requires some supporting files
2422      in the aux directory specified with `AC_CONFIG_AUX_DIR' above.
2423      *Note Finding `configure' Input: (autoconf)Input.
2425 `AC_SUBST'
2426      The first argument is automatically defined as a variable in each
2427      generated `Makefile.in'.  *Note Setting Output Variables:
2428      (autoconf)Setting Output Variables.
2430      If the Autoconf manual says that a macro calls `AC_SUBST' for VAR,
2431      or defines the output variable VAR then VAR will be defined in
2432      each `Makefile.in' generated by Automake.  E.g. `AC_PATH_XTRA'
2433      defines `X_CFLAGS' and `X_LIBS', so you can use these variables in
2434      any `Makefile.am' if `AC_PATH_XTRA' is called.
2436 `AM_C_PROTOTYPES'
2437      This is required when using the obsolete de-ANSI-fication feature;
2438      see *Note ANSI::.
2440 `AM_GNU_GETTEXT'
2441      This macro is required for packages that use GNU gettext (*note
2442      gettext::).  It is distributed with gettext.  If Automake sees
2443      this macro it ensures that the package meets some of gettext's
2444      requirements.
2446 `AM_GNU_GETTEXT_INTL_SUBDIR'
2447      This macro specifies that the `intl/' subdirectory is to be built,
2448      even if the `AM_GNU_GETTEXT' macro was invoked with a first
2449      argument of `external'.
2451 `AM_MAINTAINER_MODE'
2452      This macro adds a `--enable-maintainer-mode' option to
2453      `configure'.  If this is used, `automake' will cause
2454      "maintainer-only" rules to be turned off by default in the
2455      generated `Makefile.in's.  This macro defines the
2456      `MAINTAINER_MODE' conditional, which you can use in your own
2457      `Makefile.am'.  *Note maintainer-mode::.
2459 `m4_include'
2460      Files included by `configure.ac' using this macro will be detected
2461      by Automake and automatically distributed.  They will also appear
2462      as dependencies in `Makefile' rules.
2464      `m4_include' is seldom used by `configure.ac' authors, but can
2465      appear in `aclocal.m4' when `aclocal' detects that some required
2466      macros come from files local to your package (as opposed to macros
2467      installed in a system-wide directory, *note Invoking aclocal::).
2470 \x1f
2471 File: automake.info,  Node: Invoking aclocal,  Next: Macros,  Prev: Optional,  Up: configure
2473 6.3 Auto-generating aclocal.m4
2474 ==============================
2476 Automake includes a number of Autoconf macros that can be used in your
2477 package (*note Macros::); some of them are actually required by
2478 Automake in certain situations.  These macros must be defined in your
2479 `aclocal.m4'; otherwise they will not be seen by `autoconf'.
2481    The `aclocal' program will automatically generate `aclocal.m4' files
2482 based on the contents of `configure.ac'.  This provides a convenient
2483 way to get Automake-provided macros, without having to search around.
2484 The `aclocal' mechanism allows other packages to supply their own
2485 macros (*note Extending aclocal::).  You can also use it to maintain
2486 your own set of custom macros (*note Local Macros::).
2488    At startup, `aclocal' scans all the `.m4' files it can find, looking
2489 for macro definitions (*note Macro search path::).  Then it scans
2490 `configure.ac'.  Any mention of one of the macros found in the first
2491 step causes that macro, and any macros it in turn requires, to be put
2492 into `aclocal.m4'.
2494    _Putting_ the file that contains the macro definition into
2495 `aclocal.m4' is usually done by copying the entire text of this file,
2496 including unused macro definitions as well as both `#' and `dnl'
2497 comments.  If you want to make a comment that will be completely
2498 ignored by `aclocal', use `##' as the comment leader.
2500    When a file selected by `aclocal' is located in a subdirectory
2501 specified as a relative search path with `aclocal''s `-I' argument,
2502 `aclocal' assumes the file belongs to the package and uses `m4_include'
2503 instead of copying it into `aclocal.m4'.  This makes the package
2504 smaller, eases dependency tracking, and cause the file to be
2505 distributed automatically.  (*Note Local Macros::, for an example.)
2506 Any macro that is found in a system-wide directory, or via an absolute
2507 search path will be copied.  So use `-I `pwd`/reldir' instead of `-I
2508 reldir' whenever some relative directory need to be considered outside
2509 the package.
2511    The contents of `acinclude.m4', if this file exists, are also
2512 automatically included in `aclocal.m4'.  We recommend against using
2513 `acinclude.m4' in new packages (*note Local Macros::).
2515    While computing `aclocal.m4', `aclocal' runs `autom4te' (*note Using
2516 `Autom4te': (autoconf)Using autom4te.) in order to trace the macros
2517 that are really used, and omit from `aclocal.m4' all macros that are
2518 mentioned but otherwise unexpanded (this can happen when a macro is
2519 called conditionally).  `autom4te' is expected to be in the `PATH',
2520 just as `autoconf'.  Its location can be overridden using the
2521 `AUTOM4TE' environment variable.
2523 * Menu:
2525 * aclocal options::             Options supported by aclocal
2526 * Macro search path::           How aclocal finds .m4 files
2527 * Extending aclocal::           Writing your own aclocal macros
2528 * Local Macros::                Organizing local macros
2529 * Serials::                     Serial lines in Autoconf macros
2530 * Future of aclocal::           aclocal's scheduled death
2532 \x1f
2533 File: automake.info,  Node: aclocal options,  Next: Macro search path,  Up: Invoking aclocal
2535 6.3.1 aclocal options
2536 ---------------------
2538 `aclocal' accepts the following options:
2540 `--acdir=DIR'
2541      Look for the macro files in DIR instead of the installation
2542      directory.  This is typically used for debugging.
2544 `--diff[=COMMAND]'
2545      Run COMMAND on M4 file that would be installed or overwritten by
2546      `--install'.  The default COMMAND is `diff -u'.  This option
2547      implies `--install' and `--dry-run'.
2549 `--dry-run'
2550      Do not actually overwrite (or create) `aclocal.m4' and M4 files
2551      installed by `--install'.
2553 `--help'
2554      Print a summary of the command line options and exit.
2556 `-I DIR'
2557      Add the directory DIR to the list of directories searched for
2558      `.m4' files.
2560 `--install'
2561      Install system-wide third-party macros into the first directory
2562      specified with `-I DIR' instead of copying them in the output file.
2564      When this option is used, and only when this option is used,
2565      `aclocal' will also honor `#serial NUMBER' lines that appear in
2566      macros: an M4 file is ignored if there exists another M4 file with
2567      the same basename and a greater serial number in the search path
2568      (*note Serials::).
2570 `--force'
2571      Always overwrite the output file.  The default is to overwrite the
2572      output file only when really needed, i.e., when its contents
2573      changes or if one of its dependencies is younger.
2575      This option forces the update of `aclocal.m4' (or the file
2576      specified with `--output' below) and only this file, it has
2577      absolutely no influence on files that may need to be installed by
2578      `--install'.
2580 `--output=FILE'
2581      Cause the output to be put into FILE instead of `aclocal.m4'.
2583 `--print-ac-dir'
2584      Prints the name of the directory that `aclocal' will search to
2585      find third-party `.m4' files.  When this option is given, normal
2586      processing is suppressed.  This option can be used by a package to
2587      determine where to install a macro file.
2589 `--verbose'
2590      Print the names of the files it examines.
2592 `--version'
2593      Print the version number of Automake and exit.
2595 `-W CATEGORY'
2597 `--warnings=CATEGORY'
2598      Output warnings falling in CATEGORY.  CATEGORY can be one of:
2599     `syntax'
2600           dubious syntactic constructs, underquoted macros, unused
2601           macros, etc.
2603     `unsupported'
2604           unknown macros
2606     `all'
2607           all the warnings, this is the default
2609     `none'
2610           turn off all the warnings
2612     `error'
2613           treat warnings as errors
2615      All warnings are output by default.
2617      The environment variable `WARNINGS' is honored in the same way as
2618      it is for `automake' (*note Invoking Automake::).
2621 \x1f
2622 File: automake.info,  Node: Macro search path,  Next: Extending aclocal,  Prev: aclocal options,  Up: Invoking aclocal
2624 6.3.2 Macro search path
2625 -----------------------
2627 By default, `aclocal' searches for `.m4' files in the following
2628 directories, in this order:
2630 `ACDIR-APIVERSION'
2631      This is where the `.m4' macros distributed with automake itself
2632      are stored.  APIVERSION depends on the automake release used; for
2633      automake 1.6.x, APIVERSION = `1.6'.
2635 `ACDIR'
2636      This directory is intended for third party `.m4' files, and is
2637      configured when `automake' itself is built.  This is
2638      `@datadir@/aclocal/', which typically expands to
2639      `${prefix}/share/aclocal/'.  To find the compiled-in value of
2640      ACDIR, use the `--print-ac-dir' option (*note aclocal options::).
2642    As an example, suppose that `automake-1.6.2' was configured with
2643 `--prefix=/usr/local'.  Then, the search path would be:
2645   1. `/usr/local/share/aclocal-1.6/'
2647   2. `/usr/local/share/aclocal/'
2649    As explained in (*note aclocal options::), there are several options
2650 that can be used to change or extend this search path.
2652 6.3.2.1 Modifying the macro search path: `--acdir'
2653 ..................................................
2655 The most erroneous option to modify the search path is `--acdir=DIR',
2656 which changes default directory and drops the APIVERSION directory.
2657 For example, if one specifies `--acdir=/opt/private/', then the search
2658 path becomes:
2660   1. `/opt/private/'
2662    This option, `--acdir', is intended for use by the internal automake
2663 test suite only; it is not ordinarily needed by end-users.
2665 6.3.2.2 Modifying the macro search path: `-I DIR'
2666 .................................................
2668 Any extra directories specified using `-I' options (*note aclocal
2669 options::) are _prepended_ to this search list.  Thus, `aclocal -I /foo
2670 -I /bar' results in the following search path:
2672   1. `/foo'
2674   2. `/bar'
2676   3. ACDIR-APIVERSION
2678   4. ACDIR
2680 6.3.2.3 Modifying the macro search path: `dirlist'
2681 ..................................................
2683 There is a third mechanism for customizing the search path.  If a
2684 `dirlist' file exists in ACDIR, then that file is assumed to contain a
2685 list of directory patterns, one per line.  `aclocal' expands these
2686 patterns to directory names, and adds them to the search list _after_
2687 all other directories.  `dirlist' entries may use shell wildcards such
2688 as `*', `?', or `[...]'.
2690    For example, suppose `ACDIR/dirlist' contains the following:
2692      /test1
2693      /test2
2694      /test3*
2696 and that `aclocal' was called with the `-I /foo -I /bar' options.
2697 Then, the search path would be
2699   1. `/foo'
2701   2. `/bar'
2703   3. ACDIR-APIVERSION
2705   4. ACDIR
2707   5. `/test1'
2709   6. `/test2'
2711 and all directories with path names starting with `/test3'.
2713    If the `--acdir=DIR' option is used, then `aclocal' will search for
2714 the `dirlist' file in DIR.  In the `--acdir=/opt/private/' example
2715 above, `aclocal' would look for `/opt/private/dirlist'.  Again,
2716 however, the `--acdir' option is intended for use by the internal
2717 automake test suite only; `--acdir' is not ordinarily needed by
2718 end-users.
2720    `dirlist' is useful in the following situation: suppose that
2721 `automake' version `1.6.2' is installed with `--prefix=/usr' by the
2722 system vendor.  Thus, the default search directories are
2724   1. `/usr/share/aclocal-1.6/'
2726   2. `/usr/share/aclocal/'
2728    However, suppose further that many packages have been manually
2729 installed on the system, with $prefix=/usr/local, as is typical.  In
2730 that case, many of these "extra" `.m4' files are in
2731 `/usr/local/share/aclocal'.  The only way to force `/usr/bin/aclocal'
2732 to find these "extra" `.m4' files is to always call `aclocal -I
2733 /usr/local/share/aclocal'.  This is inconvenient.  With `dirlist', one
2734 may create a file `/usr/share/aclocal/dirlist' containing only the
2735 single line
2737      /usr/local/share/aclocal
2739    Now, the "default" search path on the affected system is
2741   1. `/usr/share/aclocal-1.6/'
2743   2. `/usr/share/aclocal/'
2745   3. `/usr/local/share/aclocal/'
2747    without the need for `-I' options; `-I' options can be reserved for
2748 project-specific needs (`my-source-dir/m4/'), rather than using it to
2749 work around local system-dependent tool installation directories.
2751    Similarly, `dirlist' can be handy if you have installed a local copy
2752 Automake on your account and want `aclocal' to look for macros
2753 installed at other places on the system.
2755 \x1f
2756 File: automake.info,  Node: Extending aclocal,  Next: Local Macros,  Prev: Macro search path,  Up: Invoking aclocal
2758 6.3.3 Writing your own aclocal macros
2759 -------------------------------------
2761 The `aclocal' program doesn't have any built-in knowledge of any
2762 macros, so it is easy to extend it with your own macros.
2764    This can be used by libraries that want to supply their own Autoconf
2765 macros for use by other programs.  For instance, the `gettext' library
2766 supplies a macro `AM_GNU_GETTEXT' that should be used by any package
2767 using `gettext'.  When the library is installed, it installs this macro
2768 so that `aclocal' will find it.
2770    A macro file's name should end in `.m4'.  Such files should be
2771 installed in `$(datadir)/aclocal'.  This is as simple as writing:
2773      aclocaldir = $(datadir)/aclocal
2774      aclocal_DATA = mymacro.m4 myothermacro.m4
2776 Please do use `$(datadir)/aclocal', and not something based on the
2777 result of `aclocal --print-ac-dir'.  *Note Hard-Coded Install Paths::,
2778 for arguments.
2780    A file of macros should be a series of properly quoted `AC_DEFUN''s
2781 (*note Macro Definitions: (autoconf)Macro Definitions.).  The `aclocal'
2782 programs also understands `AC_REQUIRE' (*note Prerequisite Macros:
2783 (autoconf)Prerequisite Macros.), so it is safe to put each macro in a
2784 separate file.  Each file should have no side effects but macro
2785 definitions.  Especially, any call to `AC_PREREQ' should be done inside
2786 the defined macro, not at the beginning of the file.
2788    Starting with Automake 1.8, `aclocal' will warn about all
2789 underquoted calls to `AC_DEFUN'.  We realize this will annoy a lot of
2790 people, because `aclocal' was not so strict in the past and many third
2791 party macros are underquoted; and we have to apologize for this
2792 temporary inconvenience.  The reason we have to be stricter is that a
2793 future implementation of `aclocal' (*note Future of aclocal::) will
2794 have to temporarily include all these third party `.m4' files, maybe
2795 several times, including even files that are not actually needed.
2796 Doing so should alleviate many problems of the current implementation,
2797 however it requires a stricter style from the macro authors.  Hopefully
2798 it is easy to revise the existing macros.  For instance,
2799      # bad style
2800      AC_PREREQ(2.57)
2801      AC_DEFUN(AX_FOOBAR,
2802      [AC_REQUIRE([AX_SOMETHING])dnl
2803      AX_FOO
2804      AX_BAR
2805      ])
2806    should be rewritten as
2807      AC_DEFUN([AX_FOOBAR],
2808      [AC_PREREQ([2.57])dnl
2809      AC_REQUIRE([AX_SOMETHING])dnl
2810      AX_FOO
2811      AX_BAR
2812      ])
2814    Wrapping the `AC_PREREQ' call inside the macro ensures that Autoconf
2815 2.57 will not be required if `AX_FOOBAR' is not actually used.  Most
2816 importantly, quoting the first argument of `AC_DEFUN' allows the macro
2817 to be redefined or included twice (otherwise this first argument would
2818 be expanded during the second definition).  For consistency we like to
2819 quote even arguments such as `2.57' that do not require it.
2821    If you have been directed here by the `aclocal' diagnostic but are
2822 not the maintainer of the implicated macro, you will want to contact
2823 the maintainer of that macro.  Please make sure you have the last
2824 version of the macro and that the problem already hasn't been reported
2825 before doing so: people tend to work faster when they aren't flooded by
2826 mails.
2828    Another situation where `aclocal' is commonly used is to manage
2829 macros that are used locally by the package, *Note Local Macros::.
2831 \x1f
2832 File: automake.info,  Node: Local Macros,  Next: Serials,  Prev: Extending aclocal,  Up: Invoking aclocal
2834 6.3.4 Handling Local Macros
2835 ---------------------------
2837 Feature tests offered by Autoconf do not cover all needs.  People often
2838 have to supplement existing tests with their own macros, or with
2839 third-party macros.
2841    There are two ways to organize custom macros in a package.
2843    The first possibility (the historical practice) is to list all your
2844 macros in `acinclude.m4'.  This file will be included in `aclocal.m4'
2845 when you run `aclocal', and its macro(s) will henceforth be visible to
2846 `autoconf'.  However if it contains numerous macros, it will rapidly
2847 become difficult to maintain, and it will be almost impossible to share
2848 macros between packages.
2850    The second possibility, which we do recommend, is to write each macro
2851 in its own file and gather all these files in a directory.  This
2852 directory is usually called `m4/'.  To build `aclocal.m4', one should
2853 therefore instruct `aclocal' to scan `m4/'.  From the command line,
2854 this is done with `aclocal -I m4'.  The top-level `Makefile.am' should
2855 also be updated to define
2857      ACLOCAL_AMFLAGS = -I m4
2859    `ACLOCAL_AMFLAGS' contains options to pass to `aclocal' when
2860 `aclocal.m4' is to be rebuilt by `make'.  This line is also used by
2861 `autoreconf' (*note Using `autoreconf' to Update `configure' Scripts:
2862 (autoconf)autoreconf Invocation.) to run `aclocal' with suitable
2863 options, or by `autopoint' (*note Invoking the `autopoint' Program:
2864 (gettext)autopoint Invocation.)  and `gettextize' (*note Invoking the
2865 `gettextize' Program: (gettext)gettextize Invocation.) to locate the
2866 place where Gettext's macros should be installed.  So even if you do
2867 not really care about the rebuild rules, you should define
2868 `ACLOCAL_AMFLAGS'.
2870    When `aclocal -I m4' is run, it will build a `aclocal.m4' that
2871 `m4_include's any file from `m4/' that defines a required macro.
2872 Macros not found locally will still be searched in system-wide
2873 directories, as explained in *Note Macro search path::.
2875    Custom macros should be distributed for the same reason that
2876 `configure.ac' is: so that other people have all the sources of your
2877 package if they want to work on it.  Actually, this distribution
2878 happens automatically because all `m4_include'd files are distributed.
2880    However there is no consensus on the distribution of third-party
2881 macros that your package may use.  Many libraries install their own
2882 macro in the system-wide `aclocal' directory (*note Extending
2883 aclocal::).  For instance, Guile ships with a file called `guile.m4'
2884 that contains the macro `GUILE_FLAGS' that can be used to define setup
2885 compiler and linker flags appropriate for using Guile.  Using
2886 `GUILE_FLAGS' in `configure.ac' will cause `aclocal' to copy `guile.m4'
2887 into `aclocal.m4', but as `guile.m4' is not part of the project, it
2888 will not be distributed.  Technically, that means a user who needs to
2889 rebuild `aclocal.m4' will have to install Guile first.  This is
2890 probably OK, if Guile already is a requirement to build the package.
2891 However, if Guile is only an optional feature, or if your package might
2892 run on architectures where Guile cannot be installed, this requirement
2893 will hinder development.  An easy solution is to copy such third-party
2894 macros in your local `m4/' directory so they get distributed.
2896    Since Automake 1.10, `aclocal' offers an option to copy these
2897 system-wide third-party macros in your local macro directory, solving
2898 the above problem.  Simply use:
2900      ACLOCAL_AMFLAGS = -I m4 --install
2902 With this setup, system-wide macros will be copied to `m4/' the first
2903 time you run `autoreconf'.  Then the locally installed macros will have
2904 precedence over the system-wide installed macros each time `aclocal' is
2905 run again.
2907    One reason why you should keep `--install' in the flags even after
2908 the first run is that when you later edit `configure.ac' and depend on
2909 a new macro, this macro will be installed in your `m4/' automatically.
2910 Another one is that serial numbers (*note Serials::) can be used to
2911 update the macros in your source tree automatically when new
2912 system-wide versions are installed.  A serial number should be a single
2913 line of the form
2915      #serial NNN
2917 where NNN contains only digits and dots.  It should appear in the M4
2918 file before any macro definition.  It is a good practice to maintain a
2919 serial number for each macro you distribute, even if you do not use the
2920 `--install' option of `aclocal': this allows other people to use it.
2922 \x1f
2923 File: automake.info,  Node: Serials,  Next: Future of aclocal,  Prev: Local Macros,  Up: Invoking aclocal
2925 6.3.5 Serial Numbers
2926 --------------------
2928 Because third-party macros defined in `*.m4' files are naturally shared
2929 between multiple projects, some people like to version them.  This
2930 makes it easier to tell which of two M4 files is newer.  Since at least
2931 1996, the tradition is to use a `#serial' line for this.
2933    A serial number should be a single line of the form
2935      # serial VERSION
2937 where VERSION is a version number containing only digits and dots.
2938 Usually people use a single integer, and they increment it each time
2939 they change the macro (hence the name of "serial").  Such a line should
2940 appear in the M4 file before any macro definition.
2942    The `#' must be the first character on the line, and it is OK to
2943 have extra words after the version, as in
2945      #serial VERSION GARBAGE
2947    Normally these serial numbers are completely ignored by `aclocal'
2948 and `autoconf', like any genuine comment.  However when using
2949 `aclocal''s `--install' feature, these serial numbers will modify the
2950 way `aclocal' selects the macros to install in the package: if two
2951 files with the same basename exists in your search path, and if at
2952 least one of them use a `#serial' line, `aclocal' will ignore the file
2953 that has the older `#serial' line (or the file that has none).
2955    Note that a serial number applies to a whole M4 file, not to any
2956 macro it contains.  A file can contains multiple macros, but only one
2957 serial.
2959    Here is a use case that illustrate the use of `--install' and its
2960 interaction with serial numbers.  Let's assume we maintain a package
2961 called MyPackage, the `configure.ac' of which requires a third-party
2962 macro `AX_THIRD_PARTY' defined in `/usr/share/aclocal/thirdparty.m4' as
2963 follows:
2965      # serial 1
2966      AC_DEFUN([AX_THIRD_PARTY], [...])
2968    MyPackage uses an `m4/' directory to store local macros as explained
2969 in *Note Local Macros::, and has
2971      ACLOCAL_AMFLAGS = -I m4 --install
2973 in its top-level `Makefile.am'.
2975    Initially the `m4/' directory is empty.  The first time we run
2976 `autoreconf', it will fetch the options to pass to `aclocal' in
2977 `Makefile.am', and run `aclocal -I m4 --install'.  `aclocal' will
2978 notice that
2980    * `configure.ac' uses `AX_THIRD_PARTY'
2982    * No local macros define `AX_THIRD_PARTY'
2984    * `/usr/share/aclocal/thirdparty.m4' defines `AX_THIRD_PARTY' with
2985      serial 1.
2987 Because `/usr/share/aclocal/thirdparty.m4' is a system-wide macro and
2988 `aclocal' was given the `--install' option, it will copy this file in
2989 `m4/thirdparty.m4', and output an `aclocal.m4' that contains
2990 `m4_include([m4/thirdparty.m4])'.
2992    The next time `aclocal -I m4 --install' is run (either via
2993 `autoreconf', by hand, or from the `Makefile' rebuild rules) something
2994 different happens.  `aclocal' notices that
2996    * `configure.ac' uses `AX_THIRD_PARTY'
2998    * `m4/thirdparty.m4' defines `AX_THIRD_PARTY' with serial 1.
3000    * `/usr/share/aclocal/thirdparty.m4' defines `AX_THIRD_PARTY' with
3001      serial 1.
3003 Because both files have the same serial number, `aclocal' uses the
3004 first it found in its search path order (*note Macro search path::).
3005 `aclocal' therefore ignores `/usr/share/aclocal/thirdparty.m4' and
3006 outputs an `aclocal.m4' that contains `m4_include([m4/thirdparty.m4])'.
3008    Local directories specified with `-I' are always searched before
3009 system-wide directories, so a local file will always be preferred to
3010 the system-wide file in case of equal serial numbers.
3012    Now suppose the system-wide third-party macro is changed.  This can
3013 happen if the package installing this macro is updated.  Let's suppose
3014 the new macro has serial number 2.  The next time `aclocal -I m4
3015 --install' is run the situation is the following:
3017    * `configure.ac' uses `AX_THIRD_PARTY'
3019    * `m4/thirdparty.m4' defines `AX_THIRD_PARTY' with serial 1.
3021    * `/usr/share/aclocal/thirdparty.m4' defines `AX_THIRD_PARTY' with
3022      serial 2.
3024 When `aclocal' sees a greater serial number, it immediately forgets
3025 anything it knows from files that have the same basename and a smaller
3026 serial number.  So after it has found
3027 `/usr/share/aclocal/thirdparty.m4' with serial 2, `aclocal' will
3028 proceed as if it had never seen `m4/thirdparty.m4'.  This brings us
3029 back to a situation similar to that at the beginning of our example,
3030 where no local file defined the macro.  `aclocal' will install the new
3031 version of the macro in `m4/thirdparty.m4', in this case overriding the
3032 old version.  MyPackage just had its macro updated as a side effect of
3033 running `aclocal'.
3035    If you are leery of letting `aclocal' update your local macro, you
3036 can run `aclocal -I m4 --diff' to review the changes `aclocal -I m4
3037 --install' would perform on these macros.
3039    Finally, note that the `--force' option of `aclocal' has absolutely
3040 no effect on the files installed by `--install'.  For instance, if you
3041 have modified your local macros, do not expect `--install --force' to
3042 replace the local macros by their system-wide versions.  If you want to
3043 do so, simply erase the local macros you want to revert, and run
3044 `aclocal -I m4 --install'.
3046 \x1f
3047 File: automake.info,  Node: Future of aclocal,  Prev: Serials,  Up: Invoking aclocal
3049 6.3.6 The Future of `aclocal'
3050 -----------------------------
3052 `aclocal' is expected to disappear.  This feature really should not be
3053 offered by Automake.  Automake should focus on generating `Makefile's;
3054 dealing with M4 macros really is Autoconf's job.  That some people
3055 install Automake just to use `aclocal', but do not use `automake'
3056 otherwise is an indication of how that feature is misplaced.
3058    The new implementation will probably be done slightly differently.
3059 For instance, it could enforce the `m4/'-style layout discussed in
3060 *Note Local Macros::.
3062    We have no idea when and how this will happen.  This has been
3063 discussed several times in the past, but someone still has to commit
3064 itself to that non-trivial task.
3066    From the user point of view, `aclocal''s removal might turn out to
3067 be painful.  There is a simple precaution that you may take to make
3068 that switch more seamless: never call `aclocal' yourself.  Keep this
3069 guy under the exclusive control of `autoreconf' and Automake's rebuild
3070 rules.  Hopefully you won't need to worry about things breaking, when
3071 `aclocal' disappears, because everything will have been taken care of.
3072 If otherwise you used to call `aclocal' directly yourself or from some
3073 script, you will quickly notice the change.
3075    Many packages come with a script called `bootstrap.sh' or
3076 `autogen.sh', that will just call `aclocal', `libtoolize', `gettextize'
3077 or `autopoint', `autoconf', `autoheader', and `automake' in the right
3078 order.  Actually this is precisely what `autoreconf' can do for you.
3079 If your package has such a `bootstrap.sh' or `autogen.sh' script,
3080 consider using `autoreconf'.  That should simplify its logic a lot
3081 (less things to maintain, yum!), it's even likely you will not need the
3082 script anymore, and more to the point you will not call `aclocal'
3083 directly anymore.
3085    For the time being, third-party packages should continue to install
3086 public macros into `/usr/share/aclocal/'.  If `aclocal' is replaced by
3087 another tool it might make sense to rename the directory, but
3088 supporting `/usr/share/aclocal/' for backward compatibility should be
3089 really easy provided all macros are properly written (*note Extending
3090 aclocal::).
3092 \x1f
3093 File: automake.info,  Node: Macros,  Prev: Invoking aclocal,  Up: configure
3095 6.4 Autoconf macros supplied with Automake
3096 ==========================================
3098 Automake ships with several Autoconf macros that you can use from your
3099 `configure.ac'.  When you use one of them it will be included by
3100 `aclocal' in `aclocal.m4'.
3102 * Menu:
3104 * Public macros::               Macros that you can use.
3105 * Obsolete macros::             Macros that you should stop using.
3106 * Private macros::              Macros that you should not use.
3108 \x1f
3109 File: automake.info,  Node: Public macros,  Next: Obsolete macros,  Up: Macros
3111 6.4.1 Public macros
3112 -------------------
3114 `AM_ENABLE_MULTILIB'
3115      This is used when a "multilib" library is being built.  The first
3116      optional argument is the name of the `Makefile' being generated; it
3117      defaults to `Makefile'.  The second option argument is used to find
3118      the top source directory; it defaults to the empty string
3119      (generally this should not be used unless you are familiar with
3120      the internals).  *Note Multilibs::.
3122 `AM_INIT_AUTOMAKE([OPTIONS])'
3123 `AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])'
3124      Runs many macros required for proper operation of the generated
3125      Makefiles.
3127      This macro has two forms, the first of which is preferred.  In
3128      this form, `AM_INIT_AUTOMAKE' is called with a single argument: a
3129      space-separated list of Automake options that should be applied to
3130      every `Makefile.am' in the tree.  The effect is as if each option
3131      were listed in `AUTOMAKE_OPTIONS' (*note Options::).
3133      The second, deprecated, form of `AM_INIT_AUTOMAKE' has two required
3134      arguments: the package and the version number.  This form is
3135      obsolete because the PACKAGE and VERSION can be obtained from
3136      Autoconf's `AC_INIT' macro (which itself has an old and a new
3137      form).
3139      If your `configure.ac' has:
3141           AC_INIT([src/foo.c])
3142           AM_INIT_AUTOMAKE([mumble], [1.5])
3144      you can modernize it as follows:
3146           AC_INIT([mumble], [1.5])
3147           AC_CONFIG_SRCDIR([src/foo.c])
3148           AM_INIT_AUTOMAKE
3150      Note that if you're upgrading your `configure.ac' from an earlier
3151      version of Automake, it is not always correct to simply move the
3152      package and version arguments from `AM_INIT_AUTOMAKE' directly to
3153      `AC_INIT', as in the example above.  The first argument to
3154      `AC_INIT' should be the name of your package (e.g., `GNU
3155      Automake'), not the tarball name (e.g., `automake') that you used
3156      to pass to `AM_INIT_AUTOMAKE'.  Autoconf tries to derive a tarball
3157      name from the package name, which should work for most but not all
3158      package names.  (If it doesn't work for yours, you can use the
3159      four-argument form of `AC_INIT' to provide the tarball name
3160      explicitly).
3162      By default this macro `AC_DEFINE''s `PACKAGE' and `VERSION'.  This
3163      can be avoided by passing the `no-define' option, as in:
3164           AM_INIT_AUTOMAKE([gnits 1.5 no-define dist-bzip2])
3165      or by passing a third non-empty argument to the obsolete form.
3167 `AM_PATH_LISPDIR'
3168      Searches for the program `emacs', and, if found, sets the output
3169      variable `lispdir' to the full path to Emacs' site-lisp directory.
3171      Note that this test assumes the `emacs' found to be a version that
3172      supports Emacs Lisp (such as GNU Emacs or XEmacs).  Other emacsen
3173      can cause this test to hang (some, like old versions of
3174      MicroEmacs, start up in interactive mode, requiring `C-x C-c' to
3175      exit, which is hardly obvious for a non-emacs user).  In most
3176      cases, however, you should be able to use `C-c' to kill the test.
3177      In order to avoid problems, you can set `EMACS' to "no" in the
3178      environment, or use the `--with-lispdir' option to `configure' to
3179      explicitly set the correct path (if you're sure you have an
3180      `emacs' that supports Emacs Lisp.
3182 `AM_PROG_AS'
3183      Use this macro when you have assembly code in your project.  This
3184      will choose the assembler for you (by default the C compiler) and
3185      set `CCAS', and will also set `CCASFLAGS' if required.
3187 `AM_PROG_CC_C_O'
3188      This is like `AC_PROG_CC_C_O', but it generates its results in the
3189      manner required by automake.  You must use this instead of
3190      `AC_PROG_CC_C_O' when you need this functionality, that is, when
3191      using per-target flags or subdir-objects with C sources.
3193 `AM_PROG_LEX'
3194      Like `AC_PROG_LEX' (*note Particular Program Checks:
3195      (autoconf)Particular Programs.), but uses the `missing' script on
3196      systems that do not have `lex'.  HP-UX 10 is one such system.
3198 `AM_PROG_GCJ'
3199      This macro finds the `gcj' program or causes an error.  It sets
3200      `GCJ' and `GCJFLAGS'.  `gcj' is the Java front-end to the GNU
3201      Compiler Collection.
3203 `AM_PROG_UPC([COMPILER-SEARCH-LIST])'
3204      Find a compiler for Unified Parallel C and define the `UPC'
3205      variable.  The default COMPILER-SEARCH-LIST is `upcc upc'.  This
3206      macro will abort `configure' if no Unified Parallel C compiler is
3207      found.
3209 `AM_WITH_DMALLOC'
3210      Add support for the Dmalloc package (http://dmalloc.com/).  If the
3211      user runs `configure' with `--with-dmalloc', then define
3212      `WITH_DMALLOC' and add `-ldmalloc' to `LIBS'.
3214 `AM_WITH_REGEX'
3215      Adds `--with-regex' to the `configure' command line.  If specified
3216      (the default), then the `regex' regular expression library is
3217      used, `regex.o' is put into `LIBOBJS', and `WITH_REGEX' is
3218      defined.  If `--without-regex' is given, then the `rx' regular
3219      expression library is used, and `rx.o' is put into `LIBOBJS'.
3222 \x1f
3223 File: automake.info,  Node: Obsolete macros,  Next: Private macros,  Prev: Public macros,  Up: Macros
3225 6.4.2 Obsolete macros
3226 ---------------------
3228 Although using some of the following macros was required in past
3229 releases, you should not used any of them in new code.  Running
3230 `autoupdate' should adjust your `configure.ac' automatically (*note
3231 Using `autoupdate' to Modernize `configure.ac': (autoconf)autoupdate
3232 Invocation.).
3234 `AM_C_PROTOTYPES'
3235      Check to see if function prototypes are understood by the
3236      compiler.  If so, define `PROTOTYPES' and set the output variables
3237      `U' and `ANSI2KNR' to the empty string.  Otherwise, set `U' to `_'
3238      and `ANSI2KNR' to `./ansi2knr'.  Automake uses these values to
3239      implement the obsolete de-ANSI-fication feature.
3241 `AM_CONFIG_HEADER'
3242      Automake will generate rules to automatically regenerate the config
3243      header.  This obsolete macro is a synonym of `AC_CONFIG_HEADERS'
3244      today (*note Optional::).
3246 `AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL'
3247      If the use of `TIOCGWINSZ' requires `<sys/ioctl.h>', then define
3248      `GWINSZ_IN_SYS_IOCTL'.  Otherwise `TIOCGWINSZ' can be found in
3249      `<termios.h>'.  This macro is obsolete, you should use Autoconf's
3250      `AC_HEADER_TIOCGWINSZ' instead.
3252 `AM_PROG_MKDIR_P'
3253      From Automake 1.8 to 1.9.6 this macro used to define the output
3254      variable `mkdir_p' to one of `mkdir -p', `install-sh -d', or
3255      `mkinstalldirs'.
3257      Nowadays Autoconf provides a similar functionality with
3258      `AC_PROG_MKDIR_P' (*note Particular Program Checks:
3259      (autoconf)Particular Programs.), however this defines the output
3260      variable `MKDIR_P' instead.  Therefore `AM_PROG_MKDIR_P' has been
3261      rewritten as a thin wrapper around `AC_PROG_MKDIR_P' to define
3262      `mkdir_p' to the same value as `MKDIR_P' for backward
3263      compatibility.
3265      If you are using Automake, there is normally no reason to call this
3266      macro, because `AM_INIT_AUTOMAKE' already does so.  However, make
3267      sure that the custom rules in your `Makefile's use `$(MKDIR_P)'
3268      and not `$(mkdir_p)'.  Even if both variables still work, the
3269      latter should be considered obsolete.
3271      If you are not using Automake, please call `AC_PROG_MKDIR_P'
3272      instead of `AM_PROG_MKDIR_P'.
3274 `AM_SYS_POSIX_TERMIOS'
3275      Check to see if POSIX termios headers and functions are available
3276      on the system.  If so, set the shell variable
3277      `am_cv_sys_posix_termios' to `yes'.  If not, set the variable to
3278      `no'.  This macro is obsolete, you should use Autoconf's
3279      `AC_SYS_POSIX_TERMIOS' instead.
3282 \x1f
3283 File: automake.info,  Node: Private macros,  Prev: Obsolete macros,  Up: Macros
3285 6.4.3 Private macros
3286 --------------------
3288 The following macros are private macros you should not call directly.
3289 They are called by the other public macros when appropriate.  Do not
3290 rely on them, as they might be changed in a future version.  Consider
3291 them as implementation details; or better, do not consider them at all:
3292 skip this section!
3294 `_AM_DEPENDENCIES'
3295 `AM_SET_DEPDIR'
3296 `AM_DEP_TRACK'
3297 `AM_OUTPUT_DEPENDENCY_COMMANDS'
3298      These macros are used to implement Automake's automatic dependency
3299      tracking scheme.  They are called automatically by automake when
3300      required, and there should be no need to invoke them manually.
3302 `AM_MAKE_INCLUDE'
3303      This macro is used to discover how the user's `make' handles
3304      `include' statements.  This macro is automatically invoked when
3305      needed; there should be no need to invoke it manually.
3307 `AM_PROG_INSTALL_STRIP'
3308      This is used to find a version of `install' that can be used to
3309      strip a program at installation time.  This macro is automatically
3310      included when required.
3312 `AM_SANITY_CHECK'
3313      This checks to make sure that a file created in the build
3314      directory is newer than a file in the source directory.  This can
3315      fail on systems where the clock is set incorrectly.  This macro is
3316      automatically run from `AM_INIT_AUTOMAKE'.
3319 \x1f
3320 File: automake.info,  Node: Directories,  Next: Programs,  Prev: configure,  Up: Top
3322 7 Directories
3323 *************
3325 For simple projects that distributes all files in the same directory it
3326 is enough to have a single `Makefile.am' that builds everything in
3327 place.
3329    In larger projects it is common to organize files in different
3330 directories, in a tree.  For instance one directory per program, per
3331 library or per module.  The traditional approach is to build these
3332 subdirectory recursively: each directory contains its `Makefile'
3333 (generated from `Makefile.am'), and when `make' is run from the top
3334 level directory it enters each subdirectory in turn to build its
3335 contents.
3337 * Menu:
3339 * Subdirectories::              Building subdirectories recursively
3340 * Conditional Subdirectories::  Conditionally not building directories
3341 * Alternative::                 Subdirectories without recursion
3342 * Subpackages::                 Nesting packages
3344 \x1f
3345 File: automake.info,  Node: Subdirectories,  Next: Conditional Subdirectories,  Up: Directories
3347 7.1 Recursing subdirectories
3348 ============================
3350 In packages with subdirectories, the top level `Makefile.am' must tell
3351 Automake which subdirectories are to be built.  This is done via the
3352 `SUBDIRS' variable.  
3354    The `SUBDIRS' variable holds a list of subdirectories in which
3355 building of various sorts can occur.  The rules for many targets (e.g.,
3356 `all') in the generated `Makefile' will run commands both locally and
3357 in all specified subdirectories.  Note that the directories listed in
3358 `SUBDIRS' are not required to contain `Makefile.am's; only `Makefile's
3359 (after configuration).  This allows inclusion of libraries from
3360 packages that do not use Automake (such as `gettext'; see also *Note
3361 Third-Party Makefiles::).
3363    In packages that use subdirectories, the top-level `Makefile.am' is
3364 often very short.  For instance, here is the `Makefile.am' from the GNU
3365 Hello distribution:
3367      EXTRA_DIST = BUGS ChangeLog.O README-alpha
3368      SUBDIRS = doc intl po src tests
3370    When Automake invokes `make' in a subdirectory, it uses the value of
3371 the `MAKE' variable.  It passes the value of the variable
3372 `AM_MAKEFLAGS' to the `make' invocation; this can be set in
3373 `Makefile.am' if there are flags you must always pass to `make'.  
3375    The directories mentioned in `SUBDIRS' are usually direct children
3376 of the current directory, each subdirectory containing its own
3377 `Makefile.am' with a `SUBDIRS' pointing to deeper subdirectories.
3378 Automake can be used to construct packages of arbitrary depth this way.
3380    By default, Automake generates `Makefiles' that work depth-first in
3381 postfix order: the subdirectories are built before the current
3382 directory.  However, it is possible to change this ordering.  You can
3383 do this by putting `.' into `SUBDIRS'.  For instance, putting `.' first
3384 will cause a prefix ordering of directories.
3386    Using
3388      SUBDIRS = lib src . test
3390 will cause `lib/' to be built before `src/', then the current directory
3391 will be built, finally the `test/' directory will be built.  It is
3392 customary to arrange test directories to be built after everything else
3393 since they are meant to test what has been constructed.
3395    All `clean' rules are run in reverse order of build rules.
3397 \x1f
3398 File: automake.info,  Node: Conditional Subdirectories,  Next: Alternative,  Prev: Subdirectories,  Up: Directories
3400 7.2 Conditional Subdirectories
3401 ==============================
3403 It is possible to define the `SUBDIRS' variable conditionally if, like
3404 in the case of GNU Inetutils, you want to only build a subset of the
3405 entire package.
3407    To illustrate how this works, let's assume we have two directories
3408 `src/' and `opt/'.  `src/' should always be built, but we want to
3409 decide in `configure' whether `opt/' will be built or not.  (For this
3410 example we will assume that `opt/' should be built when the variable
3411 `$want_opt' was set to `yes'.)
3413    Running `make' should thus recurse into `src/' always, and then
3414 maybe in `opt/'.
3416    However `make dist' should always recurse into both `src/' and
3417 `opt/'.  Because `opt/' should be distributed even if it is not needed
3418 in the current configuration.  This means `opt/Makefile' should be
3419 created _unconditionally_.
3421    There are two ways to setup a project like this.  You can use
3422 Automake conditionals (*note Conditionals::) or use Autoconf `AC_SUBST'
3423 variables (*note Setting Output Variables: (autoconf)Setting Output
3424 Variables.).  Using Automake conditionals is the preferred solution.
3425 Before we illustrate these two possibility, let's introduce
3426 `DIST_SUBDIRS'.
3428 7.2.1 `SUBDIRS' vs. `DIST_SUBDIRS'
3429 ----------------------------------
3431 Automake considers two sets of directories, defined by the variables
3432 `SUBDIRS' and `DIST_SUBDIRS'.
3434    `SUBDIRS' contains the subdirectories of the current directory that
3435 must be built (*note Subdirectories::).  It must be defined manually;
3436 Automake will never guess a directory is to be built.  As we will see
3437 in the next two sections, it is possible to define it conditionally so
3438 that some directory will be omitted from the build.
3440    `DIST_SUBDIRS' is used in rules that need to recurse in all
3441 directories, even those that have been conditionally left out of the
3442 build.  Recall our example where we may not want to build subdirectory
3443 `opt/', but yet we want to distribute it?  This is where `DIST_SUBDIRS'
3444 come into play: `opt' may not appear in `SUBDIRS', but it must appear
3445 in `DIST_SUBDIRS'.
3447    Precisely, `DIST_SUBDIRS' is used by `make maintainer-clean', `make
3448 distclean' and `make dist'.  All other recursive rules use `SUBDIRS'.
3450    If `SUBDIRS' is defined conditionally using Automake conditionals,
3451 Automake will define `DIST_SUBDIRS' automatically from the possibles
3452 values of `SUBDIRS' in all conditions.
3454    If `SUBDIRS' contains `AC_SUBST' variables, `DIST_SUBDIRS' will not
3455 be defined correctly because Automake does not know the possible values
3456 of these variables.  In this case `DIST_SUBDIRS' needs to be defined
3457 manually.
3459 7.2.2 Conditional subdirectories with `AM_CONDITIONAL'
3460 ------------------------------------------------------
3462 `configure' should output the `Makefile' for each directory and define
3463 a condition into which `opt/' should be built.
3465      ...
3466      AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
3467      AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
3468      ...
3470    Then `SUBDIRS' can be defined in the top-level `Makefile.am' as
3471 follows.
3473      if COND_OPT
3474        MAYBE_OPT = opt
3475      endif
3476      SUBDIRS = src $(MAYBE_OPT)
3478    As you can see, running `make' will rightly recurse into `src/' and
3479 maybe `opt/'.
3481    As you can't see, running `make dist' will recurse into both `src/'
3482 and `opt/' directories because `make dist', unlike `make all', doesn't
3483 use the `SUBDIRS' variable.  It uses the `DIST_SUBDIRS' variable.
3485    In this case Automake will define `DIST_SUBDIRS = src opt'
3486 automatically because it knows that `MAYBE_OPT' can contain `opt' in
3487 some condition.
3489 7.2.3 Conditional Subdirectories with `AC_SUBST'
3490 ------------------------------------------------
3492 Another possibility is to define `MAYBE_OPT' from `./configure' using
3493 `AC_SUBST':
3495      ...
3496      if test "$want_opt" = yes; then
3497        MAYBE_OPT=opt
3498      else
3499        MAYBE_OPT=
3500      fi
3501      AC_SUBST([MAYBE_OPT])
3502      AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
3503      ...
3505    In this case the top-level `Makefile.am' should look as follows.
3507      SUBDIRS = src $(MAYBE_OPT)
3508      DIST_SUBDIRS = src opt
3510    The drawback is that since Automake cannot guess what the possible
3511 values of `MAYBE_OPT' are, it is necessary to define `DIST_SUBDIRS'.
3513 7.2.4 Non-configured Subdirectories
3514 -----------------------------------
3516 The semantic of `DIST_SUBDIRS' is often misunderstood by some users
3517 that try to _configure and build_ subdirectories conditionally.  Here
3518 by configuring we mean creating the `Makefile' (it might also involve
3519 running a nested `configure' script: this is a costly operation that
3520 explains why people want to do it conditionally, but only the `Makefile'
3521 is relevant to the discussion).
3523    The above examples all assume that every `Makefile' is created, even
3524 in directories that are not going to be built.  The simple reason is
3525 that we want `make dist' to distribute even the directories that are
3526 not being built (e.g., platform-dependent code), hence `make dist' must
3527 recurse into the subdirectory, hence this directory must be configured
3528 and appear in `DIST_SUBDIRS'.
3530    Building packages that do not configure every subdirectory is a
3531 tricky business, and we do not recommend it to the novice as it is easy
3532 to produce an incomplete tarball by mistake.  We will not discuss this
3533 topic in depth here, yet for the adventurous here are a few rules to
3534 remember.
3536    * `SUBDIRS' should always be a subset of `DIST_SUBDIRS'.
3538      It makes little sense to have a directory in `SUBDIRS' that is not
3539      in `DIST_SUBDIRS'.  Think of the former as a way to tell which
3540      directories listed in the latter should be built.
3542    * Any directory listed in `DIST_SUBDIRS' and `SUBDIRS' must be
3543      configured.
3545      I.e., the `Makefile' must exists or the recursive `make' rules
3546      will not be able to process the directory.
3548    * Any configured directory must be listed in `DIST_SUBDIRS'.
3550      So that the cleaning rule remove the generated `Makefile's.  It
3551      would be correct to see `DIST_SUBDIRS' as a variable that lists
3552      all the directories that have been configured.
3554    In order to prevent recursion in some non-configured directory you
3555 must therefore ensure that this directory does not appear in
3556 `DIST_SUBDIRS' (and `SUBDIRS').  For instance, if you define `SUBDIRS'
3557 conditionally using `AC_SUBST' and do not define `DIST_SUBDIRS'
3558 explicitly, it will be default to `$(SUBDIRS)'; another possibility is
3559 to force `DIST_SUBDIRS = $(SUBDIRS)'.
3561    Of course, directories that are omitted from `DIST_SUBDIRS' will not
3562 be distributed unless you make other arrangements for this to happen
3563 (for instance, always running `make dist' in a configuration where all
3564 directories are known to appear in `DIST_SUBDIRS'; or writing a
3565 `dist-hook' target to distribute these directories).
3567    In few packages, non-configured directories are not even expected to
3568 be distributed.  Although these packages do not require the
3569 aforementioned extra arrangements, there is another pitfall.  If the
3570 name of a directory appears in `SUBDIRS' or `DIST_SUBDIRS', `automake'
3571 will make sure the directory exists.  Consequently `automake' cannot be
3572 run on such a distribution when one directory has been omitted.  One
3573 way to avoid this check is to use the `AC_SUBST' method to declare
3574 conditional directories; since `automake' does not know the values of
3575 `AC_SUBST' variables it cannot ensure the corresponding directory exist.
3577 \x1f
3578 File: automake.info,  Node: Alternative,  Next: Subpackages,  Prev: Conditional Subdirectories,  Up: Directories
3580 7.3 An Alternative Approach to Subdirectories
3581 =============================================
3583 If you've ever read Peter Miller's excellent paper, Recursive Make
3584 Considered Harmful
3585 (http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html), the
3586 preceding sections on the use of subdirectories will probably come as
3587 unwelcome advice.  For those who haven't read the paper, Miller's main
3588 thesis is that recursive `make' invocations are both slow and
3589 error-prone.
3591    Automake provides sufficient cross-directory support (1) to enable
3592 you to write a single `Makefile.am' for a complex multi-directory
3593 package.
3595    By default an installable file specified in a subdirectory will have
3596 its directory name stripped before installation.  For instance, in this
3597 example, the header file will be installed as `$(includedir)/stdio.h':
3599      include_HEADERS = inc/stdio.h
3601    However, the `nobase_' prefix can be used to circumvent this path
3602 stripping.  In this example, the header file will be installed as
3603 `$(includedir)/sys/types.h':
3605      nobase_include_HEADERS = sys/types.h
3607    `nobase_' should be specified first when used in conjunction with
3608 either `dist_' or `nodist_' (*note Dist::).  For instance:
3610      nobase_dist_pkgdata_DATA = images/vortex.pgm sounds/whirl.ogg
3612    Finally, note that a variable using the `nobase_' prefix can always
3613 be replaced by several variables, one for each destination directory
3614 (*note Uniform::).  For instance, the last example could be rewritten
3615 as follows:
3617      imagesdir = $(pkgdatadir)/images
3618      soundsdir = $(pkgdatadir)/sounds
3619      dist_images_DATA = images/vortex.pgm
3620      dist_sounds_DATA = sounds/whirl.ogg
3622 This latter syntax makes it possible to change one destination
3623 directory without changing the layout of the source tree.
3625    ---------- Footnotes ----------
3627    (1) We believe.  This work is new and there are probably warts.
3628 *Note Introduction::, for information on reporting bugs.
3630 \x1f
3631 File: automake.info,  Node: Subpackages,  Prev: Alternative,  Up: Directories
3633 7.4 Nesting Packages
3634 ====================
3636 In the GNU Build System, packages can be nested to arbitrary depth.
3637 This means that a package can embedded other packages with their own
3638 `configure', `Makefile's, etc.
3640    These other packages should just appear as subdirectories of their
3641 parent package.  They must be listed in `SUBDIRS' like other ordinary
3642 directories.  However the subpackage's `Makefile's should be output by
3643 its own `configure' script, not by the parent's `configure'.  This is
3644 achieved using the `AC_CONFIG_SUBDIRS' Autoconf macro (*note
3645 AC_CONFIG_SUBDIRS: (autoconf)Subdirectories.).
3647    Here is an example package for an `arm' program that links with an
3648 `hand' library that is a nested package in subdirectory `hand/'.
3650    `arm''s `configure.ac':
3652      AC_INIT([arm], [1.0])
3653      AC_CONFIG_AUX_DIR([.])
3654      AM_INIT_AUTOMAKE
3655      AC_PROG_CC
3656      AC_CONFIG_FILES([Makefile])
3657      # Call hand's ./configure script recursively.
3658      AC_CONFIG_SUBDIRS([hand])
3659      AC_OUTPUT
3661    `arm''s `Makefile.am':
3663      # Build the library in the hand subdirectory first.
3664      SUBDIRS = hand
3666      # Include hand's header when compiling this directory.
3667      AM_CPPFLAGS = -I$(srcdir)/hand
3669      bin_PROGRAMS = arm
3670      arm_SOURCES = arm.c
3671      # link with the hand library.
3672      arm_LDADD = hand/libhand.a
3674    Now here is `hand''s `hand/configure.ac':
3676      AC_INIT([hand], [1.2])
3677      AC_CONFIG_AUX_DIR([.])
3678      AM_INIT_AUTOMAKE
3679      AC_PROG_CC
3680      AC_PROG_RANLIB
3681      AC_CONFIG_FILES([Makefile])
3682      AC_OUTPUT
3684 and its `hand/Makefile.am':
3686      lib_LIBRARIES = libhand.a
3687      libhand_a_SOURCES = hand.c
3689    When `make dist' is run from the top-level directory it will create
3690 an archive `arm-1.0.tar.gz' that contains the `arm' code as well as the
3691 `hand' subdirectory.  This package can be built and installed like any
3692 ordinary package, with the usual `./configure && make && make install'
3693 sequence (the `hand' subpackage will be built and installed by the
3694 process).
3696    When `make dist' is run from the hand directory, it will create a
3697 self-contained `hand-1.2.tar.gz' archive.  So although it appears to be
3698 embedded in another package, it can still be used separately.
3700    The purpose of the `AC_CONFIG_AUX_DIR([.])' instruction is to force
3701 Automake and Autoconf into search auxiliary script in the current
3702 directory.  For instance, this means that there will be two copies of
3703 `install-sh': one in the top-level of the `arm' package, and another
3704 one in the `hand/' subdirectory for the `hand' package.
3706    The historical default is to search these auxiliary scripts in the
3707 immediate parent and grand-parent directories.  So if the
3708 `AC_CONFIG_AUX_DIR([.])' line was removed from `hand/configure.ac',
3709 that subpackage would share the auxiliary script of the `arm' package.
3710 This may looks like a gain in size (a few kilobytes), but it is
3711 actually a loss of modularity as the `hand' subpackage is no longer
3712 self-contained (`make dist' in the subdirectory will not work anymore).
3714    Packages that do not use Automake need more work to be integrated
3715 this way.  *Note Third-Party Makefiles::.
3717 \x1f
3718 File: automake.info,  Node: Programs,  Next: Other objects,  Prev: Directories,  Up: Top
3720 8 Building Programs and Libraries
3721 *********************************
3723 A large part of Automake's functionality is dedicated to making it easy
3724 to build programs and libraries.
3726 * Menu:
3728 * A Program::                   Building a program
3729 * A Library::                   Building a library
3730 * A Shared Library::            Building a Libtool library
3731 * Program and Library Variables::  Variables controlling program and
3732                                 library builds
3733 * Default _SOURCES::            Default source files
3734 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
3735 * Program variables::           Variables used when building a program
3736 * Yacc and Lex::                Yacc and Lex support
3737 * C++ Support::                 Compiling C++ sources
3738 * Objective C Support::         Compiling Objective C sources
3739 * Unified Parallel C Support::  Compiling Unified Parallel C sources
3740 * Assembly Support::            Compiling assembly sources
3741 * Fortran 77 Support::          Compiling Fortran 77 sources
3742 * Fortran 9x Support::          Compiling Fortran 9x sources
3743 * Java Support::                Compiling Java sources
3744 * Support for Other Languages::  Compiling other languages
3745 * ANSI::                        Automatic de-ANSI-fication (obsolete)
3746 * Dependencies::                Automatic dependency tracking
3747 * EXEEXT::                      Support for executable extensions
3749 \x1f
3750 File: automake.info,  Node: A Program,  Next: A Library,  Up: Programs
3752 8.1 Building a program
3753 ======================
3755 In order to build a program, you need to tell Automake which sources
3756 are part of it, and which libraries it should be linked with.
3758    This section also covers conditional compilation of sources or
3759 programs.  Most of the comments about these also apply to libraries
3760 (*note A Library::) and libtool libraries (*note A Shared Library::).
3762 * Menu:
3764 * Program Sources::             Defining program sources
3765 * Linking::                     Linking with libraries or extra objects
3766 * Conditional Sources::         Handling conditional sources
3767 * Conditional Programs::        Building program conditionally
3769 \x1f
3770 File: automake.info,  Node: Program Sources,  Next: Linking,  Up: A Program
3772 8.1.1 Defining program sources
3773 ------------------------------
3775 In a directory containing source that gets built into a program (as
3776 opposed to a library or a script), the `PROGRAMS' primary is used.
3777 Programs can be installed in `bindir', `sbindir', `libexecdir',
3778 `pkglibdir', or not at all (`noinst_').  They can also be built only
3779 for `make check', in which case the prefix is `check_'.
3781    For instance:
3783      bin_PROGRAMS = hello
3785    In this simple case, the resulting `Makefile.in' will contain code
3786 to generate a program named `hello'.
3788    Associated with each program are several assisting variables that are
3789 named after the program.  These variables are all optional, and have
3790 reasonable defaults.  Each variable, its use, and default is spelled out
3791 below; we use the "hello" example throughout.
3793    The variable `hello_SOURCES' is used to specify which source files
3794 get built into an executable:
3796      hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
3798    This causes each mentioned `.c' file to be compiled into the
3799 corresponding `.o'.  Then all are linked to produce `hello'.
3801    If `hello_SOURCES' is not specified, then it defaults to the single
3802 file `hello.c' (*note Default _SOURCES::).  
3804    Multiple programs can be built in a single directory.  Multiple
3805 programs can share a single source file, which must be listed in each
3806 `_SOURCES' definition.
3808    Header files listed in a `_SOURCES' definition will be included in
3809 the distribution but otherwise ignored.  In case it isn't obvious, you
3810 should not include the header file generated by `configure' in a
3811 `_SOURCES' variable; this file should not be distributed.  Lex (`.l')
3812 and Yacc (`.y') files can also be listed; see *Note Yacc and Lex::.
3814 \x1f
3815 File: automake.info,  Node: Linking,  Next: Conditional Sources,  Prev: Program Sources,  Up: A Program
3817 8.1.2 Linking the program
3818 -------------------------
3820 If you need to link against libraries that are not found by
3821 `configure', you can use `LDADD' to do so.  This variable is used to
3822 specify additional objects or libraries to link with; it is
3823 inappropriate for specifying specific linker flags, you should use
3824 `AM_LDFLAGS' for this purpose.  
3826    Sometimes, multiple programs are built in one directory but do not
3827 share the same link-time requirements.  In this case, you can use the
3828 `PROG_LDADD' variable (where PROG is the name of the program as it
3829 appears in some `_PROGRAMS' variable, and usually written in lowercase)
3830 to override the global `LDADD'.  If this variable exists for a given
3831 program, then that program is not linked using `LDADD'.  
3833    For instance, in GNU cpio, `pax', `cpio' and `mt' are linked against
3834 the library `libcpio.a'.  However, `rmt' is built in the same
3835 directory, and has no such link requirement.  Also, `mt' and `rmt' are
3836 only built on certain architectures.  Here is what cpio's
3837 `src/Makefile.am' looks like (abridged):
3839      bin_PROGRAMS = cpio pax $(MT)
3840      libexec_PROGRAMS = $(RMT)
3841      EXTRA_PROGRAMS = mt rmt
3843      LDADD = ../lib/libcpio.a $(INTLLIBS)
3844      rmt_LDADD =
3846      cpio_SOURCES = ...
3847      pax_SOURCES = ...
3848      mt_SOURCES = ...
3849      rmt_SOURCES = ...
3851    `PROG_LDADD' is inappropriate for passing program-specific linker
3852 flags (except for `-l', `-L', `-dlopen' and `-dlpreopen').  So, use the
3853 `PROG_LDFLAGS' variable for this purpose.
3855    It is also occasionally useful to have a program depend on some other
3856 target that is not actually part of that program.  This can be done
3857 using the `PROG_DEPENDENCIES' variable.  Each program depends on the
3858 contents of such a variable, but no further interpretation is done.
3860    Since these dependencies are associated to the link rule used to
3861 create the programs they should normally list files used by the link
3862 command.  That is `*.$(OBJEXT)', `*.a', or `*.la' files.  In rare cases
3863 you may need to add other kinds of files such as linker scripts, but
3864 _listing a source file in `_DEPENDENCIES' is wrong_.  If some source
3865 file needs to be built before all the components of a program are
3866 built, consider using the `BUILT_SOURCES' variable instead (*note
3867 Sources::).
3869    If `PROG_DEPENDENCIES' is not supplied, it is computed by Automake.
3870 The automatically-assigned value is the contents of `PROG_LDADD', with
3871 most configure substitutions, `-l', `-L', `-dlopen' and `-dlpreopen'
3872 options removed.  The configure substitutions that are left in are only
3873 `$(LIBOBJS)' and `$(ALLOCA)'; these are left because it is known that
3874 they will not cause an invalid value for `PROG_DEPENDENCIES' to be
3875 generated.
3877    *Note Conditional Sources:: shows a situation where `_DEPENDENCIES'
3878 is useful.
3880    We recommend that you avoid using `-l' options in `LDADD' or
3881 `PROG_LDADD' when referring to libraries built by your package.
3882 Instead, write the file name of the library explicitly as in the above
3883 `cpio' example.  Use `-l' only to list third-party libraries.  If you
3884 follow this rule, the default value of `PROG_DEPENDENCIES' will list
3885 all your local libraries and omit the other ones.
3887 \x1f
3888 File: automake.info,  Node: Conditional Sources,  Next: Conditional Programs,  Prev: Linking,  Up: A Program
3890 8.1.3 Conditional compilation of sources
3891 ----------------------------------------
3893 You can't put a configure substitution (e.g., `@FOO@' or `$(FOO)' where
3894 `FOO' is defined via `AC_SUBST') into a `_SOURCES' variable.  The
3895 reason for this is a bit hard to explain, but suffice to say that it
3896 simply won't work.  Automake will give an error if you try to do this.
3898    Fortunately there are two other ways to achieve the same result.
3899 One is to use configure substitutions in `_LDADD' variables, the other
3900 is to use an Automake conditional.
3902 8.1.3.1 Conditional compilation using `_LDADD' substitutions
3903 ............................................................
3905 Automake must know all the source files that could possibly go into a
3906 program, even if not all the files are built in every circumstance.  Any
3907 files that are only conditionally built should be listed in the
3908 appropriate `EXTRA_' variable.  For instance, if `hello-linux.c' or
3909 `hello-generic.c' were conditionally included in `hello', the
3910 `Makefile.am' would contain:
3912      bin_PROGRAMS = hello
3913      hello_SOURCES = hello-common.c
3914      EXTRA_hello_SOURCES = hello-linux.c hello-generic.c
3915      hello_LDADD = $(HELLO_SYSTEM)
3916      hello_DEPENDENCIES = $(HELLO_SYSTEM)
3918 You can then setup the `$(HELLO_SYSTEM)' substitution from
3919 `configure.ac':
3921      ...
3922      case $host in
3923        *linux*) HELLO_SYSTEM='hello-linux.$(OBJEXT)' ;;
3924        *)       HELLO_SYSTEM='hello-generic.$(OBJEXT)' ;;
3925      esac
3926      AC_SUBST([HELLO_SYSTEM])
3927      ...
3929    In this case, the variable `HELLO_SYSTEM' should be replaced by
3930 either `hello-linux.o' or `hello-generic.o', and added to both
3931 `hello_DEPENDENCIES' and `hello_LDADD' in order to be built and linked
3934 8.1.3.2 Conditional compilation using Automake conditionals
3935 ...........................................................
3937 An often simpler way to compile source files conditionally is to use
3938 Automake conditionals.  For instance, you could use this `Makefile.am'
3939 construct to build the same `hello' example:
3941      bin_PROGRAMS = hello
3942      if LINUX
3943      hello_SOURCES = hello-linux.c hello-common.c
3944      else
3945      hello_SOURCES = hello-generic.c hello-common.c
3946      endif
3948    In this case, `configure.ac' should setup the `LINUX' conditional
3949 using `AM_CONDITIONAL' (*note Conditionals::).
3951    When using conditionals like this you don't need to use the `EXTRA_'
3952 variable, because Automake will examine the contents of each variable
3953 to construct the complete list of source files.
3955    If your program uses a lot of files, you will probably prefer a
3956 conditional `+='.
3958      bin_PROGRAMS = hello
3959      hello_SOURCES = hello-common.c
3960      if LINUX
3961      hello_SOURCES += hello-linux.c
3962      else
3963      hello_SOURCES += hello-generic.c
3964      endif
3966 \x1f
3967 File: automake.info,  Node: Conditional Programs,  Prev: Conditional Sources,  Up: A Program
3969 8.1.4 Conditional compilation of programs
3970 -----------------------------------------
3972 Sometimes it is useful to determine the programs that are to be built
3973 at configure time.  For instance, GNU `cpio' only builds `mt' and `rmt'
3974 under special circumstances.  The means to achieve conditional
3975 compilation of programs are the same you can use to compile source
3976 files conditionally: substitutions or conditionals.
3978 8.1.4.1 Conditional programs using `configure' substitutions
3979 ............................................................
3981 In this case, you must notify Automake of all the programs that can
3982 possibly be built, but at the same time cause the generated
3983 `Makefile.in' to use the programs specified by `configure'.  This is
3984 done by having `configure' substitute values into each `_PROGRAMS'
3985 definition, while listing all optionally built programs in
3986 `EXTRA_PROGRAMS'.
3988      bin_PROGRAMS = cpio pax $(MT)
3989      libexec_PROGRAMS = $(RMT)
3990      EXTRA_PROGRAMS = mt rmt
3992    As explained in *Note EXEEXT::, Automake will rewrite
3993 `bin_PROGRAMS', `libexec_PROGRAMS', and `EXTRA_PROGRAMS', appending
3994 `$(EXEEXT)' to each binary.  Obviously it cannot rewrite values
3995 obtained at run-time through `configure' substitutions, therefore you
3996 should take care of appending `$(EXEEXT)' yourself, as in
3997 `AC_SUBST([MT], ['mt${EXEEXT}'])'.
3999 8.1.4.2 Conditional programs using Automake conditionals
4000 ........................................................
4002 You can also use Automake conditionals (*note Conditionals::) to select
4003 programs to be built.  In this case you don't have to worry about
4004 `$(EXEEXT)' or `EXTRA_PROGRAMS'.
4006      bin_PROGRAMS = cpio pax
4007      if WANT_MT
4008        bin_PROGRAMS += mt
4009      endif
4010      if WANT_RMT
4011        libexec_PROGRAMS = rmt
4012      endif
4014 \x1f
4015 File: automake.info,  Node: A Library,  Next: A Shared Library,  Prev: A Program,  Up: Programs
4017 8.2 Building a library
4018 ======================
4020 Building a library is much like building a program.  In this case, the
4021 name of the primary is `LIBRARIES'.  Libraries can be installed in
4022 `libdir' or `pkglibdir'.
4024    *Note A Shared Library::, for information on how to build shared
4025 libraries using libtool and the `LTLIBRARIES' primary.
4027    Each `_LIBRARIES' variable is a list of the libraries to be built.
4028 For instance, to create a library named `libcpio.a', but not install
4029 it, you would write:
4031      noinst_LIBRARIES = libcpio.a
4032      libcpio_a_SOURCES = ...
4034    The sources that go into a library are determined exactly as they are
4035 for programs, via the `_SOURCES' variables.  Note that the library name
4036 is canonicalized (*note Canonicalization::), so the `_SOURCES' variable
4037 corresponding to `libcpio.a' is `libcpio_a_SOURCES', not
4038 `libcpio.a_SOURCES'.
4040    Extra objects can be added to a library using the `LIBRARY_LIBADD'
4041 variable.  This should be used for objects determined by `configure'.
4042 Again from `cpio':
4044      libcpio_a_LIBADD = $(LIBOBJS) $(ALLOCA)
4046    In addition, sources for extra objects that will not exist until
4047 configure-time must be added to the `BUILT_SOURCES' variable (*note
4048 Sources::).
4050    Building a static library is done by compiling all object files, then
4051 by invoking `$(AR) $(ARFLAGS)' followed by the name of the library and
4052 the list of objects, and finally by calling `$(RANLIB)' on that
4053 library.  You should call `AC_PROG_RANLIB' from your `configure.ac' to
4054 define `RANLIB' (Automake will complain otherwise).  `AR' and `ARFLAGS'
4055 default to `ar' and `cru' respectively; you can override these two
4056 variables my setting them in your `Makefile.am', by `AC_SUBST'ing them
4057 from your `configure.ac', or by defining a per-library `maude_AR'
4058 variable (*note Program and Library Variables::).
4060    Be careful when selecting library components conditionally.  Because
4061 building an empty library is not portable, you should ensure that any
4062 library contains always at least one object.
4064    To use a static library when building a program, add it to `LDADD'
4065 for this program.  In the following example, the program `cpio' is
4066 statically linked with the library `libcpio.a'.
4068      noinst_LIBRARIES = libcpio.a
4069      libcpio_a_SOURCES = ...
4071      bin_PROGRAMS = cpio
4072      cpio_SOURCES = cpio.c ...
4073      cpio_LDADD = libcpio.a
4075 \x1f
4076 File: automake.info,  Node: A Shared Library,  Next: Program and Library Variables,  Prev: A Library,  Up: Programs
4078 8.3 Building a Shared Library
4079 =============================
4081 Building shared libraries portably is a relatively complex matter.  For
4082 this reason, GNU Libtool (*note Introduction: (libtool)Top.) was
4083 created to help build shared libraries in a platform-independent way.
4085 * Menu:
4087 * Libtool Concept::             Introducing Libtool
4088 * Libtool Libraries::           Declaring Libtool Libraries
4089 * Conditional Libtool Libraries::  Building Libtool Libraries Conditionally
4090 * Conditional Libtool Sources::  Choosing Library Sources Conditionally
4091 * Libtool Convenience Libraries::  Building Convenience Libtool Libraries
4092 * Libtool Modules::             Building Libtool Modules
4093 * Libtool Flags::               Using _LIBADD, _LDFLAGS, and _LIBTOOLFLAGS
4094 * LTLIBOBJS::                   Using $(LTLIBOBJS) and $(LTALLOCA)
4095 * Libtool Issues::              Common Issues Related to Libtool's Use
4097 \x1f
4098 File: automake.info,  Node: Libtool Concept,  Next: Libtool Libraries,  Up: A Shared Library
4100 8.3.1 The Libtool Concept
4101 -------------------------
4103 Libtool abstracts shared and static libraries into a unified concept
4104 henceforth called "libtool libraries".  Libtool libraries are files
4105 using the `.la' suffix, and can designate a static library, a shared
4106 library, or maybe both.  Their exact nature cannot be determined until
4107 `./configure' is run: not all platforms support all kinds of libraries,
4108 and users can explicitly select which libraries should be built.
4109 (However the package's maintainers can tune the default, *note The
4110 `AC_PROG_LIBTOOL' macro: (libtool)AC_PROG_LIBTOOL.)
4112    Because object files for shared and static libraries must be compiled
4113 differently, libtool is also used during compilation.  Object files
4114 built by libtool are called "libtool objects": these are files using
4115 the `.lo' suffix.  Libtool libraries are built from these libtool
4116 objects.
4118    You should not assume anything about the structure of `.la' or `.lo'
4119 files and how libtool constructs them: this is libtool's concern, and
4120 the last thing one wants is to learn about libtool's guts.  However the
4121 existence of these files matters, because they are used as targets and
4122 dependencies in `Makefile's rules when building libtool libraries.
4123 There are situations where you may have to refer to these, for instance
4124 when expressing dependencies for building source files conditionally
4125 (*note Conditional Libtool Sources::).
4127    People considering writing a plug-in system, with dynamically loaded
4128 modules, should look into `libltdl': libtool's dlopening library (*note
4129 Using libltdl: (libtool)Using libltdl.).  This offers a portable
4130 dlopening facility to load libtool libraries dynamically, and can also
4131 achieve static linking where unavoidable.
4133    Before we discuss how to use libtool with Automake in details, it
4134 should be noted that the libtool manual also has a section about how to
4135 use Automake with libtool (*note Using Automake with Libtool:
4136 (libtool)Using Automake.).
4138 \x1f
4139 File: automake.info,  Node: Libtool Libraries,  Next: Conditional Libtool Libraries,  Prev: Libtool Concept,  Up: A Shared Library
4141 8.3.2 Building Libtool Libraries
4142 --------------------------------
4144 Automake uses libtool to build libraries declared with the
4145 `LTLIBRARIES' primary.  Each `_LTLIBRARIES' variable is a list of
4146 libtool libraries to build.  For instance, to create a libtool library
4147 named `libgettext.la', and install it in `libdir', write:
4149      lib_LTLIBRARIES = libgettext.la
4150      libgettext_la_SOURCES = gettext.c gettext.h ...
4152    Automake predefines the variable `pkglibdir', so you can use
4153 `pkglib_LTLIBRARIES' to install libraries in `$(libdir)/@PACKAGE@/'.
4155    If `gettext.h' is a public header file that needs to be installed in
4156 order for people to use the library, it should be declared using a
4157 `_HEADERS' variable, not in `libgettext_la_SOURCES'.  Headers listed in
4158 the latter should be internal headers that are not part of the public
4159 interface.
4161      lib_LTLIBRARIES = libgettext.la
4162      libgettext_la_SOURCES = gettext.c ...
4163      include_HEADERS = gettext.h ...
4165    A package can build and install such a library along with other
4166 programs that use it.  This dependency should be specified using
4167 `LDADD'.  The following example builds a program named `hello' that is
4168 linked with `libgettext.la'.
4170      lib_LTLIBRARIES = libgettext.la
4171      libgettext_la_SOURCES = gettext.c ...
4173      bin_PROGRAMS = hello
4174      hello_SOURCES = hello.c ...
4175      hello_LDADD = libgettext.la
4177 Whether `hello' is statically or dynamically linked with
4178 `libgettext.la' is not yet known: this will depend on the configuration
4179 of libtool and the capabilities of the host.
4181 \x1f
4182 File: automake.info,  Node: Conditional Libtool Libraries,  Next: Conditional Libtool Sources,  Prev: Libtool Libraries,  Up: A Shared Library
4184 8.3.3 Building Libtool Libraries Conditionally
4185 ----------------------------------------------
4187 Like conditional programs (*note Conditional Programs::), there are two
4188 main ways to build conditional libraries: using Automake conditionals
4189 or using Autoconf `AC_SUBST'itutions.
4191    The important implementation detail you have to be aware of is that
4192 the place where a library will be installed matters to libtool: it
4193 needs to be indicated _at link-time_ using the `-rpath' option.
4195    For libraries whose destination directory is known when Automake
4196 runs, Automake will automatically supply the appropriate `-rpath'
4197 option to libtool.  This is the case for libraries listed explicitly in
4198 some installable `_LTLIBRARIES' variables such as `lib_LTLIBRARIES'.
4200    However, for libraries determined at configure time (and thus
4201 mentioned in `EXTRA_LTLIBRARIES'), Automake does not know the final
4202 installation directory.  For such libraries you must add the `-rpath'
4203 option to the appropriate `_LDFLAGS' variable by hand.
4205    The examples below illustrate the differences between these two
4206 methods.
4208    Here is an example where `WANTEDLIBS' is an `AC_SUBST'ed variable
4209 set at `./configure'-time to either `libfoo.la', `libbar.la', both, or
4210 none.  Although `$(WANTEDLIBS)' appears in the `lib_LTLIBRARIES',
4211 Automake cannot guess it relates to `libfoo.la' or `libbar.la' by the
4212 time it creates the link rule for these two libraries.  Therefore the
4213 `-rpath' argument must be explicitly supplied.
4215      EXTRA_LTLIBRARIES = libfoo.la libbar.la
4216      lib_LTLIBRARIES = $(WANTEDLIBS)
4217      libfoo_la_SOURCES = foo.c ...
4218      libfoo_la_LDFLAGS = -rpath '$(libdir)'
4219      libbar_la_SOURCES = bar.c ...
4220      libbar_la_LDFLAGS = -rpath '$(libdir)'
4222    Here is how the same `Makefile.am' would look using Automake
4223 conditionals named `WANT_LIBFOO' and `WANT_LIBBAR'.  Now Automake is
4224 able to compute the `-rpath' setting itself, because it's clear that
4225 both libraries will end up in `$(libdir)' if they are installed.
4227      lib_LTLIBRARIES =
4228      if WANT_LIBFOO
4229      lib_LTLIBRARIES += libfoo.la
4230      endif
4231      if WANT_LIBBAR
4232      lib_LTLIBRARIES += libbar.la
4233      endif
4234      libfoo_la_SOURCES = foo.c ...
4235      libbar_la_SOURCES = bar.c ...
4237 \x1f
4238 File: automake.info,  Node: Conditional Libtool Sources,  Next: Libtool Convenience Libraries,  Prev: Conditional Libtool Libraries,  Up: A Shared Library
4240 8.3.4 Libtool Libraries with Conditional Sources
4241 ------------------------------------------------
4243 Conditional compilation of sources in a library can be achieved in the
4244 same way as conditional compilation of sources in a program (*note
4245 Conditional Sources::).  The only difference is that `_LIBADD' should
4246 be used instead of `_LDADD' and that it should mention libtool objects
4247 (`.lo' files).
4249    So, to mimic the `hello' example from *Note Conditional Sources::,
4250 we could build a `libhello.la' library using either `hello-linux.c' or
4251 `hello-generic.c' with the following `Makefile.am'.
4253      lib_LTLIBRARIES = libhello.la
4254      libhello_la_SOURCES = hello-common.c
4255      EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
4256      libhello_la_LIBADD = $(HELLO_SYSTEM)
4257      libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
4259 And make sure `configure' defines `HELLO_SYSTEM' as either
4260 `hello-linux.lo' or `hello-generic.lo'.
4262    Or we could simply use an Automake conditional as follows.
4264      lib_LTLIBRARIES = libhello.la
4265      libhello_la_SOURCES = hello-common.c
4266      if LINUX
4267      libhello_la_SOURCES += hello-linux.c
4268      else
4269      libhello_la_SOURCES += hello-generic.c
4270      endif
4272 \x1f
4273 File: automake.info,  Node: Libtool Convenience Libraries,  Next: Libtool Modules,  Prev: Conditional Libtool Sources,  Up: A Shared Library
4275 8.3.5 Libtool Convenience Libraries
4276 -----------------------------------
4278 Sometimes you want to build libtool libraries that should not be
4279 installed.  These are called "libtool convenience libraries" and are
4280 typically used to encapsulate many sublibraries, later gathered into
4281 one big installed library.
4283    Libtool convenience libraries are declared by directory-less
4284 variables such as `noinst_LTLIBRARIES', `check_LTLIBRARIES', or even
4285 `EXTRA_LTLIBRARIES'.  Unlike installed libtool libraries they do not
4286 need an `-rpath' flag at link time (actually this is the only
4287 difference).
4289    Convenience libraries listed in `noinst_LTLIBRARIES' are always
4290 built.  Those listed in `check_LTLIBRARIES' are built only upon `make
4291 check'.  Finally, libraries listed in `EXTRA_LTLIBRARIES' are never
4292 built explicitly: Automake outputs rules to build them, but if the
4293 library does not appear as a Makefile dependency anywhere it won't be
4294 built (this is why `EXTRA_LTLIBRARIES' is used for conditional
4295 compilation).
4297    Here is a sample setup merging libtool convenience libraries from
4298 subdirectories into one main `libtop.la' library.
4300      # -- Top-level Makefile.am --
4301      SUBDIRS = sub1 sub2 ...
4302      lib_LTLIBRARIES = libtop.la
4303      libtop_la_SOURCES =
4304      libtop_la_LIBADD = \
4305        sub1/libsub1.la \
4306        sub2/libsub2.la \
4307        ...
4309      # -- sub1/Makefile.am --
4310      noinst_LTLIBRARIES = libsub1.la
4311      libsub1_la_SOURCES = ...
4313      # -- sub2/Makefile.am --
4314      # showing nested convenience libraries
4315      SUBDIRS = sub2.1 sub2.2 ...
4316      noinst_LTLIBRARIES = libsub2.la
4317      libsub2_la_SOURCES =
4318      libsub2_la_LIBADD = \
4319        sub21/libsub21.la \
4320        sub22/libsub22.la \
4321        ...
4323    When using such setup, beware that `automake' will assume
4324 `libtop.la' is to be linked with the C linker.  This is because
4325 `libtop_la_SOURCES' is empty, so `automake' picks C as default
4326 language.  If `libtop_la_SOURCES' was not empty, `automake' would
4327 select the linker as explained in *Note How the Linker is Chosen::.
4329    If one of the sublibraries contains non-C source, it is important
4330 that the appropriate linker be chosen.  One way to achieve this is to
4331 pretend that there is such a non-C file among the sources of the
4332 library, thus forcing `automake' to select the appropriate linker.
4333 Here is the top-level `Makefile' of our example updated to force C++
4334 linking.
4336      SUBDIRS = sub1 sub2 ...
4337      lib_LTLIBRARIES = libtop.la
4338      libtop_la_SOURCES =
4339      # Dummy C++ source to cause C++ linking.
4340      nodist_EXTRA_libtop_la_SOURCES = dummy.cxx
4341      libtop_la_LIBADD = \
4342        sub1/libsub1.la \
4343        sub2/libsub2.la \
4344        ...
4346    `EXTRA_*_SOURCES' variables are used to keep track of source files
4347 that might be compiled (this is mostly useful when doing conditional
4348 compilation using `AC_SUBST', *note Conditional Libtool Sources::), and
4349 the `nodist_' prefix means the listed sources are not to be distributed
4350 (*note Program and Library Variables::).  In effect the file
4351 `dummy.cxx' does not need to exist in the source tree.  Of course if
4352 you have some real source file to list in `libtop_la_SOURCES' there is
4353 no point in cheating with `nodist_EXTRA_libtop_la_SOURCES'.
4355 \x1f
4356 File: automake.info,  Node: Libtool Modules,  Next: Libtool Flags,  Prev: Libtool Convenience Libraries,  Up: A Shared Library
4358 8.3.6 Libtool Modules
4359 ---------------------
4361 These are libtool libraries meant to be dlopened.  They are indicated
4362 to libtool by passing `-module' at link-time.
4364      pkglib_LTLIBRARIES = mymodule.la
4365      mymodule_la_SOURCES = doit.c
4366      mymodule_la_LDFLAGS = -module
4368    Ordinarily, Automake requires that a library's name starts with
4369 `lib'.  However, when building a dynamically loadable module you might
4370 wish to use a "nonstandard" name.  Automake will not complain about
4371 such nonstandard name if it knows the library being built is a libtool
4372 module, i.e., if `-module' explicitly appears in the library's
4373 `_LDFLAGS' variable (or in the common `AM_LDFLAGS' variable when no
4374 per-library `_LDFLAGS' variable is defined).
4376    As always, `AC_SUBST' variables are black boxes to Automake since
4377 their values are not yet known when `automake' is run.  Therefore if
4378 `-module' is set via such a variable, Automake cannot notice it and
4379 will proceed as if the library was an ordinary libtool library, with
4380 strict naming.
4382    If `mymodule_la_SOURCES' is not specified, then it defaults to the
4383 single file `mymodule.c' (*note Default _SOURCES::).
4385 \x1f
4386 File: automake.info,  Node: Libtool Flags,  Next: LTLIBOBJS,  Prev: Libtool Modules,  Up: A Shared Library
4388 8.3.7 `_LIBADD', `_LDFLAGS', and `_LIBTOOLFLAGS'
4389 ------------------------------------------------
4391 As shown in previous sections, the `LIBRARY_LIBADD' variable should be
4392 used to list extra libtool objects (`.lo' files) or libtool libraries
4393 (`.la') to add to LIBRARY.
4395    The `LIBRARY_LDFLAGS' variable is the place to list additional
4396 libtool linking flags, such as `-version-info', `-static', and a lot
4397 more.  *Note Link mode: (libtool)Link mode.
4399    The `libtool' command has two kinds of options: mode-specific
4400 options and generic options.  Mode-specific options such as the
4401 aforementioned linking flags should be lumped with the other flags
4402 passed to the tool invoked by `libtool' (hence the use of
4403 `LIBRARY_LDFLAGS' for libtool linking flags).  Generic options include
4404 `--tag=TAG' and `--silent' (*note Invoking `libtool': (libtool)Invoking
4405 libtool. for more options) should appear before the mode selection on
4406 the command line; in `Makefile.am's they should be listed in the
4407 `LIBRARY_LIBTOOLFLAGS' variable.
4409    If `LIBRARY_LIBTOOLFLAGS' is not defined, the global
4410 `AM_LIBTOOLFLAGS' variable is used instead.
4412    These flags are passed to libtool after the `--tag=TAG' option
4413 computed by Automake (if any), so `LIBRARY_LIBTOOLFLAGS' (or
4414 `AM_LIBTOOLFLAGS') is the good place to override or supplement the
4415 `--tag=TAG' setting.
4417    The libtool rules also use a `LIBTOOLFLAGS' variable that should not
4418 be set in `Makefile.am': this is a user variable (*note Flag Variables
4419 Ordering::.  It allows users to run `make LIBTOOLFLAGS=--silent', for
4420 instance.
4422 \x1f
4423 File: automake.info,  Node: LTLIBOBJS,  Next: Libtool Issues,  Prev: Libtool Flags,  Up: A Shared Library
4425 8.3.8 `LTLIBOBJS' and `LTALLOCA'
4426 --------------------------------
4428 Where an ordinary library might include `$(LIBOBJS)' or `$(ALLOCA)'
4429 (*note LIBOBJS::), a libtool library must use `$(LTLIBOBJS)' or
4430 `$(LTALLOCA)'.  This is required because the object files that libtool
4431 operates on do not necessarily end in `.o'.
4433    Nowadays, the computation of `LTLIBOBJS' from `LIBOBJS' is performed
4434 automatically by Autoconf (*note `AC_LIBOBJ' vs. `LIBOBJS':
4435 (autoconf)AC_LIBOBJ vs LIBOBJS.).
4437 \x1f
4438 File: automake.info,  Node: Libtool Issues,  Prev: LTLIBOBJS,  Up: A Shared Library
4440 8.3.9 Common Issues Related to Libtool's Use
4441 --------------------------------------------
4443 8.3.9.1 `required file `./ltmain.sh' not found'
4444 ...............................................
4446 Libtool comes with a tool called `libtoolize' that will install
4447 libtool's supporting files into a package.  Running this command will
4448 install `ltmain.sh'.  You should execute it before `aclocal' and
4449 `automake'.
4451    People upgrading old packages to newer autotools are likely to face
4452 this issue because older Automake versions used to call `libtoolize'.
4453 Therefore old build scripts do not call `libtoolize'.
4455    Since Automake 1.6, it has been decided that running `libtoolize'
4456 was none of Automake's business.  Instead, that functionality has been
4457 moved into the `autoreconf' command (*note Using `autoreconf':
4458 (autoconf)autoreconf Invocation.).  If you do not want to remember what
4459 to run and when, just learn the `autoreconf' command.  Hopefully,
4460 replacing existing `bootstrap.sh' or `autogen.sh' scripts by a call to
4461 `autoreconf' should also free you from any similar incompatible change
4462 in the future.
4464 8.3.9.2 Objects `created with both libtool and without'
4465 .......................................................
4467 Sometimes, the same source file is used both to build a libtool library
4468 and to build another non-libtool target (be it a program or another
4469 library).
4471    Let's consider the following `Makefile.am'.
4473      bin_PROGRAMS = prog
4474      prog_SOURCES = prog.c foo.c ...
4476      lib_LTLIBRARIES = libfoo.la
4477      libfoo_la_SOURCES = foo.c ...
4479 (In this trivial case the issue could be avoided by linking `libfoo.la'
4480 with `prog' instead of listing `foo.c' in `prog_SOURCES'.  But let's
4481 assume we really want to keep `prog' and `libfoo.la' separate.)
4483    Technically, it means that we should build `foo.$(OBJEXT)' for
4484 `prog', and `foo.lo' for `libfoo.la'.  The problem is that in the
4485 course of creating `foo.lo', libtool may erase (or replace)
4486 `foo.$(OBJEXT)', and this cannot be avoided.
4488    Therefore, when Automake detects this situation it will complain
4489 with a message such as
4490      object `foo.$(OBJEXT)' created both with libtool and without
4492    A workaround for this issue is to ensure that these two objects get
4493 different basenames.  As explained in *Note renamed objects::, this
4494 happens automatically when per-targets flags are used.
4496      bin_PROGRAMS = prog
4497      prog_SOURCES = prog.c foo.c ...
4498      prog_CFLAGS = $(AM_CFLAGS)
4500      lib_LTLIBRARIES = libfoo.la
4501      libfoo_la_SOURCES = foo.c ...
4503 Adding `prog_CFLAGS = $(AM_CFLAGS)' is almost a no-op, because when the
4504 `prog_CFLAGS' is defined, it is used instead of `AM_CFLAGS'.  However
4505 as a side effect it will cause `prog.c' and `foo.c' to be compiled as
4506 `prog-prog.$(OBJEXT)' and `prog-foo.$(OBJEXT)', which solves the issue.
4508 \x1f
4509 File: automake.info,  Node: Program and Library Variables,  Next: Default _SOURCES,  Prev: A Shared Library,  Up: Programs
4511 8.4 Program and Library Variables
4512 =================================
4514 Associated with each program are a collection of variables that can be
4515 used to modify how that program is built.  There is a similar list of
4516 such variables for each library.  The canonical name of the program (or
4517 library) is used as a base for naming these variables.
4519    In the list below, we use the name "maude" to refer to the program or
4520 library.  In your `Makefile.am' you would replace this with the
4521 canonical name of your program.  This list also refers to "maude" as a
4522 program, but in general the same rules apply for both static and dynamic
4523 libraries; the documentation below notes situations where programs and
4524 libraries differ.
4526 `maude_SOURCES'
4527      This variable, if it exists, lists all the source files that are
4528      compiled to build the program.  These files are added to the
4529      distribution by default.  When building the program, Automake will
4530      cause each source file to be compiled to a single `.o' file (or
4531      `.lo' when using libtool).  Normally these object files are named
4532      after the source file, but other factors can change this.  If a
4533      file in the `_SOURCES' variable has an unrecognized extension,
4534      Automake will do one of two things with it.  If a suffix rule
4535      exists for turning files with the unrecognized extension into `.o'
4536      files, then automake will treat this file as it will any other
4537      source file (*note Support for Other Languages::).  Otherwise, the
4538      file will be ignored as though it were a header file.
4540      The prefixes `dist_' and `nodist_' can be used to control whether
4541      files listed in a `_SOURCES' variable are distributed.  `dist_' is
4542      redundant, as sources are distributed by default, but it can be
4543      specified for clarity if desired.
4545      It is possible to have both `dist_' and `nodist_' variants of a
4546      given `_SOURCES' variable at once; this lets you easily distribute
4547      some files and not others, for instance:
4549           nodist_maude_SOURCES = nodist.c
4550           dist_maude_SOURCES = dist-me.c
4552      By default the output file (on Unix systems, the `.o' file) will
4553      be put into the current build directory.  However, if the option
4554      `subdir-objects' is in effect in the current directory then the
4555      `.o' file will be put into the subdirectory named after the source
4556      file.  For instance, with `subdir-objects' enabled,
4557      `sub/dir/file.c' will be compiled to `sub/dir/file.o'.  Some
4558      people prefer this mode of operation.  You can specify
4559      `subdir-objects' in `AUTOMAKE_OPTIONS' (*note Options::).  
4561 `EXTRA_maude_SOURCES'
4562      Automake needs to know the list of files you intend to compile
4563      _statically_.  For one thing, this is the only way Automake has of
4564      knowing what sort of language support a given `Makefile.in'
4565      requires.  (1)  This means that, for example, you can't put a
4566      configure substitution like `@my_sources@' into a `_SOURCES'
4567      variable.  If you intend to conditionally compile source files and
4568      use `configure' to substitute the appropriate object names into,
4569      e.g., `_LDADD' (see below), then you should list the corresponding
4570      source files in the `EXTRA_' variable.
4572      This variable also supports `dist_' and `nodist_' prefixes.  For
4573      instance, `nodist_EXTRA_maude_SOURCES' would list extra sources
4574      that may need to be built, but should not be distributed.
4576 `maude_AR'
4577      A static library is created by default by invoking `$(AR)
4578      $(ARFLAGS)' followed by the name of the library and then the
4579      objects being put into the library.  You can override this by
4580      setting the `_AR' variable.  This is usually used with C++; some
4581      C++ compilers require a special invocation in order to instantiate
4582      all the templates that should go into a library.  For instance,
4583      the SGI C++ compiler likes this variable set like so:
4584           libmaude_a_AR = $(CXX) -ar -o
4586 `maude_LIBADD'
4587      Extra objects can be added to a _library_ using the `_LIBADD'
4588      variable.  For instance, this should be used for objects
4589      determined by `configure' (*note A Library::).
4591      In the case of libtool libraries, `maude_LIBADD' can also refer to
4592      other libtool libraries.
4594 `maude_LDADD'
4595      Extra objects (`*.$(OBJEXT)') and libraries (`*.a', `*.la') can be
4596      added to a _program_ by listing them in the `_LDADD' variable.
4597      For instance, this should be used for objects determined by
4598      `configure' (*note Linking::).
4600      `_LDADD' and `_LIBADD' are inappropriate for passing
4601      program-specific linker flags (except for `-l', `-L', `-dlopen'
4602      and `-dlpreopen').  Use the `_LDFLAGS' variable for this purpose.
4604      For instance, if your `configure.ac' uses `AC_PATH_XTRA', you
4605      could link your program against the X libraries like so:
4607           maude_LDADD = $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS)
4609      We recommend that you use `-l' and `-L' only when referring to
4610      third-party libraries, and give the explicit file names of any
4611      library built by your package.  Doing so will ensure that
4612      `maude_DEPENDENCIES' (see below) is correctly defined by default.
4614 `maude_LDFLAGS'
4615      This variable is used to pass extra flags to the link step of a
4616      program or a shared library.  It overrides the global `AM_LDFLAGS'
4617      variable.
4619 `maude_LIBTOOLFLAGS'
4620      This variable is used to pass extra options to `libtool'.  It
4621      overrides the global `AM_LIBTOOLFLAGS' variable.  These options
4622      are output before `libtool''s `--mode=MODE' option, so they should
4623      not be mode-specific options (those belong to the compiler or
4624      linker flags).  *Note Libtool Flags::.
4626 `maude_DEPENDENCIES'
4627      It is also occasionally useful to have a target (program or
4628      library) depend on some other file that is not actually part of
4629      that target.  This can be done using the `_DEPENDENCIES' variable.
4630      Each targets depends on the contents of such a variable, but no
4631      further interpretation is done.
4633      Since these dependencies are associated to the link rule used to
4634      create the programs they should normally list files used by the
4635      link command.  That is `*.$(OBJEXT)', `*.a', or `*.la' files for
4636      programs; `*.lo' and `*.la' files for Libtool libraries; and
4637      `*.$(OBJEXT)' files for static libraries.  In rare cases you may
4638      need to add other kinds of files such as linker scripts, but
4639      _listing a source file in `_DEPENDENCIES' is wrong_.  If some
4640      source file needs to be built before all the components of a
4641      program are built, consider using the `BUILT_SOURCES' variable
4642      (*note Sources::).
4644      If `_DEPENDENCIES' is not supplied, it is computed by Automake.
4645      The automatically-assigned value is the contents of `_LDADD' or
4646      `_LIBADD', with most configure substitutions, `-l', `-L',
4647      `-dlopen' and `-dlpreopen' options removed.  The configure
4648      substitutions that are left in are only `$(LIBOBJS)' and
4649      `$(ALLOCA)'; these are left because it is known that they will not
4650      cause an invalid value for `_DEPENDENCIES' to be generated.
4652      `_DEPENDENCIES' is more likely used to perform conditional
4653      compilation using an `AC_SUBST' variable that contains a list of
4654      objects.  *Note Conditional Sources::, and *Note Conditional
4655      Libtool Sources::.
4657 `maude_LINK'
4658      You can override the linker on a per-program basis.  By default the
4659      linker is chosen according to the languages used by the program.
4660      For instance, a program that includes C++ source code would use
4661      the C++ compiler to link.  The `_LINK' variable must hold the name
4662      of a command that can be passed all the `.o' file names as
4663      arguments.  Note that the name of the underlying program is _not_
4664      passed to `_LINK'; typically one uses `$@':
4666           maude_LINK = $(CCLD) -magic -o $@
4668 `maude_CCASFLAGS'
4669 `maude_CFLAGS'
4670 `maude_CPPFLAGS'
4671 `maude_CXXFLAGS'
4672 `maude_FFLAGS'
4673 `maude_GCJFLAGS'
4674 `maude_LFLAGS'
4675 `maude_OBJCFLAGS'
4676 `maude_RFLAGS'
4677 `maude_UPCFLAGS'
4678 `maude_YFLAGS'
4679      Automake allows you to set compilation flags on a per-program (or
4680      per-library) basis.  A single source file can be included in
4681      several programs, and it will potentially be compiled with
4682      different flags for each program.  This works for any language
4683      directly supported by Automake.  These "per-target compilation
4684      flags" are `_CCASFLAGS', `_CFLAGS', `_CPPFLAGS', `_CXXFLAGS',
4685      `_FFLAGS', `_GCJFLAGS', `_LFLAGS', `_OBJCFLAGS', `_RFLAGS',
4686      `_UPCFLAGS', and `_YFLAGS'.
4688      When using a per-target compilation flag, Automake will choose a
4689      different name for the intermediate object files.  Ordinarily a
4690      file like `sample.c' will be compiled to produce `sample.o'.
4691      However, if the program's `_CFLAGS' variable is set, then the
4692      object file will be named, for instance, `maude-sample.o'.  (See
4693      also *Note renamed objects::.)  The use of per-target compilation
4694      flags with C sources requires that the macro `AM_PROG_CC_C_O' be
4695      called from `configure.ac'.
4697      In compilations with per-target flags, the ordinary `AM_' form of
4698      the flags variable is _not_ automatically included in the
4699      compilation (however, the user form of the variable _is_ included).
4700      So for instance, if you want the hypothetical `maude' compilations
4701      to also use the value of `AM_CFLAGS', you would need to write:
4703           maude_CFLAGS = ... your flags ... $(AM_CFLAGS)
4705      *Note Flag Variables Ordering::, for more discussion about the
4706      interaction between user variables, `AM_' shadow variables, and
4707      per-target variables.
4709 `maude_SHORTNAME'
4710      On some platforms the allowable file names are very short.  In
4711      order to support these systems and per-target compilation flags at
4712      the same time, Automake allows you to set a "short name" that will
4713      influence how intermediate object files are named.  For instance,
4714      in the following example,
4716           bin_PROGRAMS = maude
4717           maude_CPPFLAGS = -DSOMEFLAG
4718           maude_SHORTNAME = m
4719           maude_SOURCES = sample.c ...
4721      the object file would be named `m-sample.o' rather than
4722      `maude-sample.o'.
4724      This facility is rarely needed in practice, and we recommend
4725      avoiding it until you find it is required.
4727    ---------- Footnotes ----------
4729    (1) There are other, more obscure reasons for this limitation as
4730 well.
4732 \x1f
4733 File: automake.info,  Node: Default _SOURCES,  Next: LIBOBJS,  Prev: Program and Library Variables,  Up: Programs
4735 8.5 Default `_SOURCES'
4736 ======================
4738 `_SOURCES' variables are used to specify source files of programs
4739 (*note A Program::), libraries (*note A Library::), and Libtool
4740 libraries (*note A Shared Library::).
4742    When no such variable is specified for a target, Automake will define
4743 one itself.  The default is to compile a single C file whose base name
4744 is the name of the target itself, with any extension replaced by `.c'.
4745 (Defaulting to C is terrible but we are stuck with it for historical
4746 reasons.)
4748    For example if you have the following somewhere in your
4749 `Makefile.am' with no corresponding `libfoo_a_SOURCES':
4751      lib_LIBRARIES = libfoo.a sub/libc++.a
4753 `libfoo.a' will be built using a default source file named `libfoo.c',
4754 and `sub/libc++.a' will be built from `sub/libc++.c'.  (In older
4755 versions `sub/libc++.a' would be built from `sub_libc___a.c', i.e., the
4756 default source was the canonized name of the target, with `.c' appended.
4757 We believe the new behavior is more sensible, but for backward
4758 compatibility automake will use the old name if a file or a rule with
4759 that name exist.)
4761    Default sources are mainly useful in test suites, when building many
4762 tests programs each from a single source.  For instance, in
4764      check_PROGRAMS = test1 test2 test3
4766 `test1', `test2', and `test3' will be built from `test1.c', `test2.c',
4767 and `test3.c'.
4769    Another case where is this convenient is building many Libtool
4770 modules (`moduleN.la'), each defined in its own file (`moduleN.c').
4772      AM_LDFLAGS = -module
4773      lib_LTLIBRARIES = module1.la module2.la module3.la
4775    Finally, there is one situation where this default source computation
4776 needs to be avoided: when a target should not be built from sources.
4777 We already saw such an example in *Note true::; this happens when all
4778 the constituents of a target have already been compiled and need just
4779 to be combined using a `_LDADD' variable.  Then it is necessary to
4780 define an empty `_SOURCES' variable, so that automake does not compute
4781 a default.
4783      bin_PROGRAMS = target
4784      target_SOURCES =
4785      target_LDADD = libmain.a libmisc.a
4787 \x1f
4788 File: automake.info,  Node: LIBOBJS,  Next: Program variables,  Prev: Default _SOURCES,  Up: Programs
4790 8.6 Special handling for `LIBOBJS' and `ALLOCA'
4791 ===============================================
4793 The `$(LIBOBJS)' and `$(ALLOCA)' variables list object files that
4794 should be compiled into the project to provide an implementation for
4795 functions that are missing or broken on the host system.  They are
4796 substituted by `configure'.
4798    These variables are defined by Autoconf macros such as `AC_LIBOBJ',
4799 `AC_REPLACE_FUNCS' (*note Generic Function Checks: (autoconf)Generic
4800 Functions.), or `AC_FUNC_ALLOCA' (*note Particular Function Checks:
4801 (autoconf)Particular Functions.).  Many other Autoconf macros call
4802 `AC_LIBOBJ' or `AC_REPLACE_FUNCS' to populate `$(LIBOBJS)'.
4804    Using these variables is very similar to doing conditional
4805 compilation using `AC_SUBST' variables, as described in *Note
4806 Conditional Sources::.  That is, when building a program, `$(LIBOBJS)'
4807 and `$(ALLOCA)' should be added to the associated `*_LDADD' variable,
4808 or to the `*_LIBADD' variable when building a library.  However there
4809 is no need to list the corresponding sources in `EXTRA_*_SOURCES' nor
4810 to define `*_DEPENDENCIES'.  Automake automatically adds `$(LIBOBJS)'
4811 and `$(ALLOCA)' to the dependencies, and it will discover the list of
4812 corresponding source files automatically (by tracing the invocations of
4813 the `AC_LIBSOURCE' Autoconf macros).
4815    These variables are usually used to build a portability library that
4816 is linked with all the programs of the project.  We now review a sample
4817 setup.  First, `configure.ac' contains some checks that affect either
4818 `LIBOBJS' or `ALLOCA'.
4820      # configure.ac
4821      ...
4822      AC_CONFIG_LIBOBJ_DIR([lib])
4823      ...
4824      AC_FUNC_MALLOC             dnl May add malloc.$(OBJEXT) to LIBOBJS
4825      AC_FUNC_MEMCMP             dnl May add memcmp.$(OBJEXT) to LIBOBJS
4826      AC_REPLACE_FUNCS([strdup]) dnl May add strdup.$(OBJEXT) to LIBOBJS
4827      AC_FUNC_ALLOCA             dnl May add alloca.$(OBJEXT) to ALLOCA
4828      ...
4829      AC_CONFIG_FILES([
4830        lib/Makefile
4831        src/Makefile
4832      ])
4833      AC_OUTPUT
4835    The `AC_CONFIG_LIBOBJ_DIR' tells Autoconf that the source files of
4836 these object files are to be found in the `lib/' directory.  Automake
4837 can also use this information, otherwise it expects the source files
4838 are to be in the directory where the `$(LIBOBJS)' and `$(ALLOCA)'
4839 variables are used.
4841    The `lib/' directory should therefore contain `malloc.c',
4842 `memcmp.c', `strdup.c', `alloca.c'.  Here is its `Makefile.am':
4844      # lib/Makefile.am
4846      noinst_LIBRARIES = libcompat.a
4847      libcompat_a_SOURCES =
4848      libcompat_a_LIBADD = $(LIBOBJS) $(ALLOCA)
4850    The library can have any name, of course, and anyway it is not going
4851 to be installed: it just holds the replacement versions of the missing
4852 or broken functions so we can later link them in.  In many projects
4853 also include extra functions, specific to the project, in that library:
4854 they are simply added on the `_SOURCES' line.
4856    There is a small trap here, though: `$(LIBOBJS)' and `$(ALLOCA)'
4857 might be empty, and building an empty library is not portable.  You
4858 should ensure that there is always something to put in `libcompat.a'.
4859 Most projects will also add some utility functions in that directory,
4860 and list them in `libcompat_a_SOURCES', so in practice `libcompat.a'
4861 cannot be empty.
4863    Finally here is how this library could be used from the `src/'
4864 directory.
4866      # src/Makefile.am
4868      # Link all programs in this directory with libcompat.a
4869      LDADD = ../lib/libcompat.a
4871      bin_PROGRAMS = tool1 tool2 ...
4872      tool1_SOURCES = ...
4873      tool2_SOURCES = ...
4875    When option `subdir-objects' is not used, as in the above example,
4876 the variables `$(LIBOBJS)' or `$(ALLOCA)' can only be used in the
4877 directory where their sources lie.  E.g., here it would be wrong to use
4878 `$(LIBOBJS)' or `$(ALLOCA)' in `src/Makefile.am'.  However if both
4879 `subdir-objects' and `AC_CONFIG_LIBOBJ_DIR' are used, it is OK to use
4880 these variables in other directories.  For instance `src/Makefile.am'
4881 could be changed as follows.
4883      # src/Makefile.am
4885      AUTOMAKE_OPTIONS = subdir-objects
4886      LDADD = $(LIBOBJS) $(ALLOCA)
4888      bin_PROGRAMS = tool1 tool2 ...
4889      tool1_SOURCES = ...
4890      tool2_SOURCES = ...
4892    Because `$(LIBOBJS)' and `$(ALLOCA)' contain object file names that
4893 end with `.$(OBJEXT)', they are not suitable for Libtool libraries
4894 (where the expected object extension is `.lo'): `LTLIBOBJS' and
4895 `LTALLOCA' should be used instead.
4897    `LTLIBOBJS' is defined automatically by Autoconf and should not be
4898 defined by hand (as in the past), however at the time of writing
4899 `LTALLOCA' still needs to be defined from `ALLOCA' manually.  *Note
4900 `AC_LIBOBJ' vs. `LIBOBJS': (autoconf)AC_LIBOBJ vs LIBOBJS.
4902 \x1f
4903 File: automake.info,  Node: Program variables,  Next: Yacc and Lex,  Prev: LIBOBJS,  Up: Programs
4905 8.7 Variables used when building a program
4906 ==========================================
4908 Occasionally it is useful to know which `Makefile' variables Automake
4909 uses for compilations; for instance, you might need to do your own
4910 compilation in some special cases.
4912    Some variables are inherited from Autoconf; these are `CC',
4913 `CFLAGS', `CPPFLAGS', `DEFS', `LDFLAGS', and `LIBS'.  
4915    There are some additional variables that Automake defines on its own:
4917 `AM_CPPFLAGS'
4918      The contents of this variable are passed to every compilation that
4919      invokes the C preprocessor; it is a list of arguments to the
4920      preprocessor.  For instance, `-I' and `-D' options should be
4921      listed here.
4923      Automake already provides some `-I' options automatically.  In
4924      particular it generates `-I$(srcdir)', `-I.', and a `-I' pointing
4925      to the directory holding `config.h' (if you've used
4926      `AC_CONFIG_HEADERS' or `AM_CONFIG_HEADER').  You can disable the
4927      default `-I' options using the `nostdinc' option.
4929      `AM_CPPFLAGS' is ignored in preference to a per-executable (or
4930      per-library) `_CPPFLAGS' variable if it is defined.
4932 `INCLUDES'
4933      This does the same job as `AM_CPPFLAGS' (or any per-target
4934      `_CPPFLAGS' variable if it is used).  It is an older name for the
4935      same functionality.  This variable is deprecated; we suggest using
4936      `AM_CPPFLAGS' and per-target `_CPPFLAGS' instead.
4938 `AM_CFLAGS'
4939      This is the variable the `Makefile.am' author can use to pass in
4940      additional C compiler flags.  It is more fully documented
4941      elsewhere.  In some situations, this is not used, in preference to
4942      the per-executable (or per-library) `_CFLAGS'.
4944 `COMPILE'
4945      This is the command used to actually compile a C source file.  The
4946      file name is appended to form the complete command line.
4948 `AM_LDFLAGS'
4949      This is the variable the `Makefile.am' author can use to pass in
4950      additional linker flags.  In some situations, this is not used, in
4951      preference to the per-executable (or per-library) `_LDFLAGS'.
4953 `LINK'
4954      This is the command used to actually link a C program.  It already
4955      includes `-o $@' and the usual variable references (for instance,
4956      `CFLAGS'); it takes as "arguments" the names of the object files
4957      and libraries to link in.
4959 \x1f
4960 File: automake.info,  Node: Yacc and Lex,  Next: C++ Support,  Prev: Program variables,  Up: Programs
4962 8.8 Yacc and Lex support
4963 ========================
4965 Automake has somewhat idiosyncratic support for Yacc and Lex.
4967    Automake assumes that the `.c' file generated by `yacc' (or `lex')
4968 should be named using the basename of the input file.  That is, for a
4969 yacc source file `foo.y', Automake will cause the intermediate file to
4970 be named `foo.c' (as opposed to `y.tab.c', which is more traditional).
4972    The extension of a yacc source file is used to determine the
4973 extension of the resulting C or C++ file.  Files with the extension `.y'
4974 will be turned into `.c' files; likewise, `.yy' will become `.cc';
4975 `.y++', `c++'; `.yxx', `.cxx'; and `.ypp', `.cpp'.
4977    Likewise, lex source files can be used to generate C or C++; the
4978 extensions `.l', `.ll', `.l++', `.lxx', and `.lpp' are recognized.
4980    You should never explicitly mention the intermediate (C or C++) file
4981 in any `SOURCES' variable; only list the source file.
4983    The intermediate files generated by `yacc' (or `lex') will be
4984 included in any distribution that is made.  That way the user doesn't
4985 need to have `yacc' or `lex'.
4987    If a `yacc' source file is seen, then your `configure.ac' must
4988 define the variable `YACC'.  This is most easily done by invoking the
4989 macro `AC_PROG_YACC' (*note Particular Program Checks:
4990 (autoconf)Particular Programs.).
4992    When `yacc' is invoked, it is passed `YFLAGS' and `AM_YFLAGS'.  The
4993 former is a user variable and the latter is intended for the
4994 `Makefile.am' author.
4996    `AM_YFLAGS' is usually used to pass the `-d' option to `yacc'.
4997 Automake knows what this means and will automatically adjust its rules
4998 to update and distribute the header file built by `yacc -d'.  What
4999 Automake cannot guess, though, is where this header will be used: it is
5000 up to you to ensure the header gets built before it is first used.
5001 Typically this is necessary in order for dependency tracking to work
5002 when the header is included by another file.  The common solution is
5003 listing the header file in `BUILT_SOURCES' (*note Sources::) as follows.
5005      BUILT_SOURCES = parser.h
5006      AM_YFLAGS = -d
5007      bin_PROGRAMS = foo
5008      foo_SOURCES = ... parser.y ...
5010    If a `lex' source file is seen, then your `configure.ac' must define
5011 the variable `LEX'.  You can use `AC_PROG_LEX' to do this (*note
5012 Particular Program Checks: (autoconf)Particular Programs.), but using
5013 `AM_PROG_LEX' macro (*note Macros::) is recommended.
5015    When `lex' is invoked, it is passed `LFLAGS' and `AM_LFLAGS'.  The
5016 former is a user variable and the latter is intended for the
5017 `Makefile.am' author.
5019    When `AM_MAINTAINER_MODE' (*note maintainer-mode::) is used, the
5020 rebuild rule for distributed Yacc and Lex sources are only used when
5021 `maintainer-mode' is enabled, or when the files have been erased.
5023    When `lex' or `yacc' sources are used, `automake -i' automatically
5024 installs an auxiliary program called `ylwrap' in your package (*note
5025 Auxiliary Programs::).  This program is used by the build rules to
5026 rename the output of these tools, and makes it possible to include
5027 multiple `yacc' (or `lex') source files in a single directory.  (This
5028 is necessary because yacc's output file name is fixed, and a parallel
5029 make could conceivably invoke more than one instance of `yacc'
5030 simultaneously.)
5032    For `yacc', simply managing locking is insufficient.  The output of
5033 `yacc' always uses the same symbol names internally, so it isn't
5034 possible to link two `yacc' parsers into the same executable.
5036    We recommend using the following renaming hack used in `gdb':
5037      #define yymaxdepth c_maxdepth
5038      #define yyparse c_parse
5039      #define yylex   c_lex
5040      #define yyerror c_error
5041      #define yylval  c_lval
5042      #define yychar  c_char
5043      #define yydebug c_debug
5044      #define yypact  c_pact
5045      #define yyr1    c_r1
5046      #define yyr2    c_r2
5047      #define yydef   c_def
5048      #define yychk   c_chk
5049      #define yypgo   c_pgo
5050      #define yyact   c_act
5051      #define yyexca  c_exca
5052      #define yyerrflag c_errflag
5053      #define yynerrs c_nerrs
5054      #define yyps    c_ps
5055      #define yypv    c_pv
5056      #define yys     c_s
5057      #define yy_yys  c_yys
5058      #define yystate c_state
5059      #define yytmp   c_tmp
5060      #define yyv     c_v
5061      #define yy_yyv  c_yyv
5062      #define yyval   c_val
5063      #define yylloc  c_lloc
5064      #define yyreds  c_reds
5065      #define yytoks  c_toks
5066      #define yylhs   c_yylhs
5067      #define yylen   c_yylen
5068      #define yydefred c_yydefred
5069      #define yydgoto c_yydgoto
5070      #define yysindex c_yysindex
5071      #define yyrindex c_yyrindex
5072      #define yygindex c_yygindex
5073      #define yytable  c_yytable
5074      #define yycheck  c_yycheck
5075      #define yyname   c_yyname
5076      #define yyrule   c_yyrule
5078    For each define, replace the `c_' prefix with whatever you like.
5079 These defines work for `bison', `byacc', and traditional `yacc's.  If
5080 you find a parser generator that uses a symbol not covered here, please
5081 report the new name so it can be added to the list.
5083 \x1f
5084 File: automake.info,  Node: C++ Support,  Next: Objective C Support,  Prev: Yacc and Lex,  Up: Programs
5086 8.9 C++ Support
5087 ===============
5089 Automake includes full support for C++.
5091    Any package including C++ code must define the output variable `CXX'
5092 in `configure.ac'; the simplest way to do this is to use the
5093 `AC_PROG_CXX' macro (*note Particular Program Checks:
5094 (autoconf)Particular Programs.).
5096    A few additional variables are defined when a C++ source file is
5097 seen:
5099 `CXX'
5100      The name of the C++ compiler.
5102 `CXXFLAGS'
5103      Any flags to pass to the C++ compiler.
5105 `AM_CXXFLAGS'
5106      The maintainer's variant of `CXXFLAGS'.
5108 `CXXCOMPILE'
5109      The command used to actually compile a C++ source file.  The file
5110      name is appended to form the complete command line.
5112 `CXXLINK'
5113      The command used to actually link a C++ program.
5115 \x1f
5116 File: automake.info,  Node: Objective C Support,  Next: Unified Parallel C Support,  Prev: C++ Support,  Up: Programs
5118 8.10 Objective C Support
5119 ========================
5121 Automake includes some support for Objective C.
5123    Any package including Objective C code must define the output
5124 variable `OBJC' in `configure.ac'; the simplest way to do this is to use
5125 the `AC_PROG_OBJC' macro (*note Particular Program Checks:
5126 (autoconf)Particular Programs.).
5128    A few additional variables are defined when an Objective C source
5129 file is seen:
5131 `OBJC'
5132      The name of the Objective C compiler.
5134 `OBJCFLAGS'
5135      Any flags to pass to the Objective C compiler.
5137 `AM_OBJCFLAGS'
5138      The maintainer's variant of `OBJCFLAGS'.
5140 `OBJCCOMPILE'
5141      The command used to actually compile a Objective C source file.
5142      The file name is appended to form the complete command line.
5144 `OBJCLINK'
5145      The command used to actually link a Objective C program.
5147 \x1f
5148 File: automake.info,  Node: Unified Parallel C Support,  Next: Assembly Support,  Prev: Objective C Support,  Up: Programs
5150 8.11 Unified Parallel C Support
5151 ===============================
5153 Automake includes some support for Unified Parallel C.
5155    Any package including Unified Parallel C code must define the output
5156 variable `UPC' in `configure.ac'; the simplest way to do this is to use
5157 the `AM_PROG_UPC' macro (*note Public macros::).
5159    A few additional variables are defined when an Unified Parallel C
5160 source file is seen:
5162 `UPC'
5163      The name of the Unified Parallel C compiler.
5165 `UPCFLAGS'
5166      Any flags to pass to the Unified Parallel C compiler.
5168 `AM_UPCFLAGS'
5169      The maintainer's variant of `UPCFLAGS'.
5171 `UPCCOMPILE'
5172      The command used to actually compile a Unified Parallel C source
5173      file.  The file name is appended to form the complete command line.
5175 `UPCLINK'
5176      The command used to actually link a Unified Parallel C program.
5178 \x1f
5179 File: automake.info,  Node: Assembly Support,  Next: Fortran 77 Support,  Prev: Unified Parallel C Support,  Up: Programs
5181 8.12 Assembly Support
5182 =====================
5184 Automake includes some support for assembly code.  There are two forms
5185 of assembler files: normal (`*.s') and preprocessed by `CPP' (`*.S').
5187    The variable `CCAS' holds the name of the compiler used to build
5188 assembly code.  This compiler must work a bit like a C compiler; in
5189 particular it must accept `-c' and `-o'.  The values of `CCASFLAGS' and
5190 `AM_CCASFLAGS' (or its per-target definition) is passed to the
5191 compilation.  For preprocessed files, `DEFS', `DEFAULT_INCLUDES',
5192 `INCLUDES', `CPPFLAGS' and `AM_CPPFLAGS' are also used.
5194    The autoconf macro `AM_PROG_AS' will define `CCAS' and `CCASFLAGS'
5195 for you (unless they are already set, it simply sets `CCAS' to the C
5196 compiler and `CCASFLAGS' to the C compiler flags), but you are free to
5197 define these variables by other means.
5199    Only the suffixes `.s' and `.S' are recognized by `automake' as
5200 being files containing assembly code.
5202 \x1f
5203 File: automake.info,  Node: Fortran 77 Support,  Next: Fortran 9x Support,  Prev: Assembly Support,  Up: Programs
5205 8.13 Fortran 77 Support
5206 =======================
5208 Automake includes full support for Fortran 77.
5210    Any package including Fortran 77 code must define the output variable
5211 `F77' in `configure.ac'; the simplest way to do this is to use the
5212 `AC_PROG_F77' macro (*note Particular Program Checks:
5213 (autoconf)Particular Programs.).
5215    A few additional variables are defined when a Fortran 77 source file
5216 is seen:
5218 `F77'
5219      The name of the Fortran 77 compiler.
5221 `FFLAGS'
5222      Any flags to pass to the Fortran 77 compiler.
5224 `AM_FFLAGS'
5225      The maintainer's variant of `FFLAGS'.
5227 `RFLAGS'
5228      Any flags to pass to the Ratfor compiler.
5230 `AM_RFLAGS'
5231      The maintainer's variant of `RFLAGS'.
5233 `F77COMPILE'
5234      The command used to actually compile a Fortran 77 source file.
5235      The file name is appended to form the complete command line.
5237 `FLINK'
5238      The command used to actually link a pure Fortran 77 program or
5239      shared library.
5242    Automake can handle preprocessing Fortran 77 and Ratfor source files
5243 in addition to compiling them(1).  Automake also contains some support
5244 for creating programs and shared libraries that are a mixture of
5245 Fortran 77 and other languages (*note Mixing Fortran 77 With C and
5246 C++::).
5248    These issues are covered in the following sections.
5250 * Menu:
5252 * Preprocessing Fortran 77::    Preprocessing Fortran 77 sources
5253 * Compiling Fortran 77 Files::  Compiling Fortran 77 sources
5254 * Mixing Fortran 77 With C and C++::  Mixing Fortran 77 With C and C++
5256    ---------- Footnotes ----------
5258    (1) Much, if not most, of the information in the following sections
5259 pertaining to preprocessing Fortran 77 programs was taken almost
5260 verbatim from *Note Catalogue of Rules: (make)Catalogue of Rules.
5262 \x1f
5263 File: automake.info,  Node: Preprocessing Fortran 77,  Next: Compiling Fortran 77 Files,  Up: Fortran 77 Support
5265 8.13.1 Preprocessing Fortran 77
5266 -------------------------------
5268 `N.f' is made automatically from `N.F' or `N.r'.  This rule runs just
5269 the preprocessor to convert a preprocessable Fortran 77 or Ratfor
5270 source file into a strict Fortran 77 source file.  The precise command
5271 used is as follows:
5273 `.F'
5274      `$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
5275      $(AM_FFLAGS) $(FFLAGS)'
5277 `.r'
5278      `$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)'
5281 \x1f
5282 File: automake.info,  Node: Compiling Fortran 77 Files,  Next: Mixing Fortran 77 With C and C++,  Prev: Preprocessing Fortran 77,  Up: Fortran 77 Support
5284 8.13.2 Compiling Fortran 77 Files
5285 ---------------------------------
5287 `N.o' is made automatically from `N.f', `N.F' or `N.r' by running the
5288 Fortran 77 compiler.  The precise command used is as follows:
5290 `.f'
5291      `$(F77) -c $(AM_FFLAGS) $(FFLAGS)'
5293 `.F'
5294      `$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS)
5295      $(AM_FFLAGS) $(FFLAGS)'
5297 `.r'
5298      `$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)'
5301 \x1f
5302 File: automake.info,  Node: Mixing Fortran 77 With C and C++,  Prev: Compiling Fortran 77 Files,  Up: Fortran 77 Support
5304 8.13.3 Mixing Fortran 77 With C and C++
5305 ---------------------------------------
5307 Automake currently provides _limited_ support for creating programs and
5308 shared libraries that are a mixture of Fortran 77 and C and/or C++.
5309 However, there are many other issues related to mixing Fortran 77 with
5310 other languages that are _not_ (currently) handled by Automake, but
5311 that are handled by other packages(1).
5313    Automake can help in two ways:
5315   1. Automatic selection of the linker depending on which combinations
5316      of source code.
5318   2. Automatic selection of the appropriate linker flags (e.g., `-L' and
5319      `-l') to pass to the automatically selected linker in order to link
5320      in the appropriate Fortran 77 intrinsic and run-time libraries.
5322      These extra Fortran 77 linker flags are supplied in the output
5323      variable `FLIBS' by the `AC_F77_LIBRARY_LDFLAGS' Autoconf macro
5324      supplied with newer versions of Autoconf (Autoconf version 2.13 and
5325      later).  *Note Fortran 77 Compiler Characteristics:
5326      (autoconf)Fortran 77 Compiler Characteristics.
5328    If Automake detects that a program or shared library (as mentioned in
5329 some `_PROGRAMS' or `_LTLIBRARIES' primary) contains source code that
5330 is a mixture of Fortran 77 and C and/or C++, then it requires that the
5331 macro `AC_F77_LIBRARY_LDFLAGS' be called in `configure.ac', and that
5332 either `$(FLIBS)' appear in the appropriate `_LDADD' (for programs) or
5333 `_LIBADD' (for shared libraries) variables.  It is the responsibility
5334 of the person writing the `Makefile.am' to make sure that `$(FLIBS)'
5335 appears in the appropriate `_LDADD' or `_LIBADD' variable.
5337    For example, consider the following `Makefile.am':
5339      bin_PROGRAMS = foo
5340      foo_SOURCES  = main.cc foo.f
5341      foo_LDADD    = libfoo.la $(FLIBS)
5343      pkglib_LTLIBRARIES = libfoo.la
5344      libfoo_la_SOURCES  = bar.f baz.c zardoz.cc
5345      libfoo_la_LIBADD   = $(FLIBS)
5347    In this case, Automake will insist that `AC_F77_LIBRARY_LDFLAGS' is
5348 mentioned in `configure.ac'.  Also, if `$(FLIBS)' hadn't been mentioned
5349 in `foo_LDADD' and `libfoo_la_LIBADD', then Automake would have issued
5350 a warning.
5352 * Menu:
5354 * How the Linker is Chosen::    Automatic linker selection
5356    ---------- Footnotes ----------
5358    (1) For example, the cfortran package
5359 (http://www-zeus.desy.de/~burow/cfortran/) addresses all of these
5360 inter-language issues, and runs under nearly all Fortran 77, C and C++
5361 compilers on nearly all platforms.  However, `cfortran' is not yet Free
5362 Software, but it will be in the next major release.
5364 \x1f
5365 File: automake.info,  Node: How the Linker is Chosen,  Up: Mixing Fortran 77 With C and C++
5367 8.13.3.1 How the Linker is Chosen
5368 .................................
5370 When a program or library mixes several languages, Automake choose the
5371 linker according to the following priorities.  (The names in
5372 parentheses are the variables containing the link command.)
5374   1. Native Java (`GCJLINK')
5376   2. C++ (`CXXLINK')
5378   3. Fortran 77 (`F77LINK')
5380   4. Fortran (`FCLINK')
5382   5. Objective C (`OBJCLINK')
5384   6. Unified Parallel C (`UPCLINK')
5386   7. C (`LINK')
5388    For example, if Fortran 77, C and C++ source code is compiled into a
5389 program, then the C++ linker will be used.  In this case, if the C or
5390 Fortran 77 linkers required any special libraries that weren't included
5391 by the C++ linker, then they must be manually added to an `_LDADD' or
5392 `_LIBADD' variable by the user writing the `Makefile.am'.
5394    Automake only looks at the file names listed in `_SOURCES' variables
5395 to choose the linker, and defaults to the C linker.  Sometimes this is
5396 inconvenient because you are linking against a library written in
5397 another language and would like to set the linker more appropriately.
5398 *Note Libtool Convenience Libraries::, for a trick with
5399 `nodist_EXTRA_..._SOURCES'.
5401 \x1f
5402 File: automake.info,  Node: Fortran 9x Support,  Next: Java Support,  Prev: Fortran 77 Support,  Up: Programs
5404 8.14 Fortran 9x Support
5405 =======================
5407 Automake includes full support for Fortran 9x.
5409    Any package including Fortran 9x code must define the output variable
5410 `FC' in `configure.ac'; the simplest way to do this is to use the
5411 `AC_PROG_FC' macro (*note Particular Program Checks:
5412 (autoconf)Particular Programs.).
5414    A few additional variables are defined when a Fortran 9x source file
5415 is seen:
5417 `FC'
5418      The name of the Fortran 9x compiler.
5420 `FCFLAGS'
5421      Any flags to pass to the Fortran 9x compiler.
5423 `AM_FCFLAGS'
5424      The maintainer's variant of `FCFLAGS'.
5426 `FCCOMPILE'
5427      The command used to actually compile a Fortran 9x source file.
5428      The file name is appended to form the complete command line.
5430 `FCLINK'
5431      The command used to actually link a pure Fortran 9x program or
5432      shared library.
5435 * Menu:
5437 * Compiling Fortran 9x Files::  Compiling Fortran 9x sources
5439 \x1f
5440 File: automake.info,  Node: Compiling Fortran 9x Files,  Up: Fortran 9x Support
5442 8.14.1 Compiling Fortran 9x Files
5443 ---------------------------------
5445 `N.o' is made automatically from `N.f90' or `N.f95' by running the
5446 Fortran 9x compiler.  The precise command used is as follows:
5448 `.f9x'
5449      `$(FC) -c $(AM_FCFLAGS) $(FCFLAGS)'
5452 \x1f
5453 File: automake.info,  Node: Java Support,  Next: Support for Other Languages,  Prev: Fortran 9x Support,  Up: Programs
5455 8.15 Java Support
5456 =================
5458 Automake includes support for compiled Java, using `gcj', the Java
5459 front end to the GNU Compiler Collection.
5461    Any package including Java code to be compiled must define the output
5462 variable `GCJ' in `configure.ac'; the variable `GCJFLAGS' must also be
5463 defined somehow (either in `configure.ac' or `Makefile.am').  The
5464 simplest way to do this is to use the `AM_PROG_GCJ' macro.
5466    By default, programs including Java source files are linked with
5467 `gcj'.
5469    As always, the contents of `AM_GCJFLAGS' are passed to every
5470 compilation invoking `gcj' (in its role as an ahead-of-time compiler,
5471 when invoking it to create `.class' files, `AM_JAVACFLAGS' is used
5472 instead).  If it is necessary to pass options to `gcj' from
5473 `Makefile.am', this variable, and not the user variable `GCJFLAGS',
5474 should be used.
5476    `gcj' can be used to compile `.java', `.class', `.zip', or `.jar'
5477 files.
5479    When linking, `gcj' requires that the main class be specified using
5480 the `--main=' option.  The easiest way to do this is to use the
5481 `_LDFLAGS' variable for the program.
5483 \x1f
5484 File: automake.info,  Node: Support for Other Languages,  Next: ANSI,  Prev: Java Support,  Up: Programs
5486 8.16 Support for Other Languages
5487 ================================
5489 Automake currently only includes full support for C, C++ (*note C++
5490 Support::), Objective C (*note Objective C Support::), Fortran 77
5491 (*note Fortran 77 Support::), Fortran 9x (*note Fortran 9x Support::),
5492 and Java (*note Java Support::).  There is only rudimentary support for
5493 other languages, support for which will be improved based on user
5494 demand.
5496    Some limited support for adding your own languages is available via
5497 the suffix rule handling (*note Suffixes::).
5499 \x1f
5500 File: automake.info,  Node: ANSI,  Next: Dependencies,  Prev: Support for Other Languages,  Up: Programs
5502 8.17 Automatic de-ANSI-fication
5503 ===============================
5505 The features described in this section are obsolete; you should not
5506 used any of them in new code, and they may be withdrawn in future
5507 Automake releases.
5509    When the C language was standardized in 1989, there was a long
5510 transition period where package developers needed to worry about
5511 porting to older systems that did not support ANSI C by default.  These
5512 older systems are no longer in practical use and are no longer
5513 supported by their original suppliers, so developers need not worry
5514 about this problem any more.
5516    Automake allows you to write packages that are portable to K&R C by
5517 "de-ANSI-fying" each source file before the actual compilation takes
5518 place.
5520    If the `Makefile.am' variable `AUTOMAKE_OPTIONS' (*note Options::)
5521 contains the option `ansi2knr' then code to handle de-ANSI-fication is
5522 inserted into the generated `Makefile.in'.
5524    This causes each C source file in the directory to be treated as
5525 ANSI C.  If an ANSI C compiler is available, it is used.  If no ANSI C
5526 compiler is available, the `ansi2knr' program is used to convert the
5527 source files into K&R C, which is then compiled.
5529    The `ansi2knr' program is simple-minded.  It assumes the source code
5530 will be formatted in a particular way; see the `ansi2knr' man page for
5531 details.
5533    Support for the obsolete de-ANSI-fication feature requires the
5534 source files `ansi2knr.c' and `ansi2knr.1' to be in the same package as
5535 the ANSI C source; these files are distributed with Automake.  Also,
5536 the package `configure.ac' must call the macro `AM_C_PROTOTYPES' (*note
5537 Macros::).
5539    Automake also handles finding the `ansi2knr' support files in some
5540 other directory in the current package.  This is done by prepending the
5541 relative path to the appropriate directory to the `ansi2knr' option.
5542 For instance, suppose the package has ANSI C code in the `src' and
5543 `lib' subdirectories.  The files `ansi2knr.c' and `ansi2knr.1' appear
5544 in `lib'.  Then this could appear in `src/Makefile.am':
5546      AUTOMAKE_OPTIONS = ../lib/ansi2knr
5548    If no directory prefix is given, the files are assumed to be in the
5549 current directory.
5551    Note that automatic de-ANSI-fication will not work when the package
5552 is being built for a different host architecture.  That is because
5553 automake currently has no way to build `ansi2knr' for the build machine.
5555    Using `LIBOBJS' with source de-ANSI-fication used to require
5556 hand-crafted code in `configure' to append `$U' to basenames in
5557 `LIBOBJS'.  This is no longer true today.  Starting with version 2.54,
5558 Autoconf takes care of rewriting `LIBOBJS' and `LTLIBOBJS'.  (*note
5559 `AC_LIBOBJ' vs. `LIBOBJS': (autoconf)AC_LIBOBJ vs LIBOBJS.)
5561 \x1f
5562 File: automake.info,  Node: Dependencies,  Next: EXEEXT,  Prev: ANSI,  Up: Programs
5564 8.18 Automatic dependency tracking
5565 ==================================
5567 As a developer it is often painful to continually update the
5568 `Makefile.in' whenever the include-file dependencies change in a
5569 project.  Automake supplies a way to automatically track dependency
5570 changes (*note Dependency Tracking::).
5572    Automake always uses complete dependencies for a compilation,
5573 including system headers.  Automake's model is that dependency
5574 computation should be a side effect of the build.  To this end,
5575 dependencies are computed by running all compilations through a special
5576 wrapper program called `depcomp'.  `depcomp' understands how to coax
5577 many different C and C++ compilers into generating dependency
5578 information in the format it requires.  `automake -a' will install
5579 `depcomp' into your source tree for you.  If `depcomp' can't figure out
5580 how to properly invoke your compiler, dependency tracking will simply
5581 be disabled for your build.
5583    Experience with earlier versions of Automake (*note Dependency
5584 Tracking Evolution::) taught us that it is not reliable to generate
5585 dependencies only on the maintainer's system, as configurations vary
5586 too much.  So instead Automake implements dependency tracking at build
5587 time.
5589    Automatic dependency tracking can be suppressed by putting
5590 `no-dependencies' in the variable `AUTOMAKE_OPTIONS', or passing
5591 `no-dependencies' as an argument to `AM_INIT_AUTOMAKE' (this should be
5592 the preferred way).  Or, you can invoke `automake' with the `-i'
5593 option.  Dependency tracking is enabled by default.
5595    The person building your package also can choose to disable
5596 dependency tracking by configuring with `--disable-dependency-tracking'.
5598 \x1f
5599 File: automake.info,  Node: EXEEXT,  Prev: Dependencies,  Up: Programs
5601 8.19 Support for executable extensions
5602 ======================================
5604 On some platforms, such as Windows, executables are expected to have an
5605 extension such as `.exe'.  On these platforms, some compilers (GCC
5606 among them) will automatically generate `foo.exe' when asked to
5607 generate `foo'.
5609    Automake provides mostly-transparent support for this.  Unfortunately
5610 _mostly_ doesn't yet mean _fully_.  Until the English dictionary is
5611 revised, you will have to assist Automake if your package must support
5612 those platforms.
5614    One thing you must be aware of is that, internally, Automake rewrites
5615 something like this:
5617      bin_PROGRAMS = liver
5619    to this:
5621      bin_PROGRAMS = liver$(EXEEXT)
5623    The targets Automake generates are likewise given the `$(EXEEXT)'
5624 extension.
5626    The variable `TESTS' (*note Tests::) is also rewritten if it
5627 contains filenames that have been declared as programs in the same
5628 `Makefile'.  (This is mostly useful when some programs from
5629 `check_PROGRAMS' are listed in `TESTS'.)
5631    However, Automake cannot apply this rewriting to `configure'
5632 substitutions.  This means that if you are conditionally building a
5633 program using such a substitution, then your `configure.ac' must take
5634 care to add `$(EXEEXT)' when constructing the output variable.
5636    With Autoconf 2.13 and earlier, you must explicitly use `AC_EXEEXT'
5637 to get this support.  With Autoconf 2.50, `AC_EXEEXT' is run
5638 automatically if you configure a compiler (say, through `AC_PROG_CC').
5640    Sometimes maintainers like to write an explicit link rule for their
5641 program.  Without executable extension support, this is easy--you
5642 simply write a rule whose target is the name of the program.  However,
5643 when executable extension support is enabled, you must instead add the
5644 `$(EXEEXT)' suffix.
5646    Unfortunately, due to the change in Autoconf 2.50, this means you
5647 must always add this extension.  However, this is a problem for
5648 maintainers who know their package will never run on a platform that has
5649 executable extensions.  For those maintainers, the `no-exeext' option
5650 (*note Options::) will disable this feature.  This works in a fairly
5651 ugly way; if `no-exeext' is seen, then the presence of a rule for a
5652 target named `foo' in `Makefile.am' will override an automake-generated
5653 rule for `foo$(EXEEXT)'.  Without the `no-exeext' option, this use will
5654 give a diagnostic.
5656 \x1f
5657 File: automake.info,  Node: Other objects,  Next: Other GNU Tools,  Prev: Programs,  Up: Top
5659 9 Other Derived Objects
5660 ***********************
5662 Automake can handle derived objects that are not C programs.  Sometimes
5663 the support for actually building such objects must be explicitly
5664 supplied, but Automake will still automatically handle installation and
5665 distribution.
5667 * Menu:
5669 * Scripts::                     Executable scripts
5670 * Headers::                     Header files
5671 * Data::                        Architecture-independent data files
5672 * Sources::                     Derived sources
5674 \x1f
5675 File: automake.info,  Node: Scripts,  Next: Headers,  Up: Other objects
5677 9.1 Executable Scripts
5678 ======================
5680 It is possible to define and install programs that are scripts.  Such
5681 programs are listed using the `SCRIPTS' primary name.  When the script
5682 is distributed in its final, installable form, the `Makefile' usually
5683 looks as follows: 
5685      # Install my_script in $(bindir) and distribute it.
5686      dist_bin_SCRIPTS = my_script
5688    Script are not distributed by default; as we have just seen, those
5689 that should be distributed can be specified using a `dist_' prefix as
5690 with other primaries.
5692    Scripts can be installed in `bindir', `sbindir', `libexecdir', or
5693 `pkgdatadir'.
5695    Scripts that need not being installed can be listed in
5696 `noinst_SCRIPTS', and among them, those which are needed only by `make
5697 check' should go in `check_SCRIPTS'.
5699    When a script needs to be built, the `Makefile.am' should include
5700 the appropriate rules.  For instance the `automake' program itself is a
5701 Perl script that is generated from `automake.in'.  Here is how this is
5702 handled:
5704      bin_SCRIPTS = automake
5705      CLEANFILES = $(bin_SCRIPTS)
5706      EXTRA_DIST = automake.in
5708      do_subst = sed -e 's,[@]datadir[@],$(datadir),g' \
5709                  -e 's,[@]PERL[@],$(PERL),g' \
5710                  -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
5711                  -e 's,[@]VERSION[@],$(VERSION),g' \
5712                  ...
5714      automake: automake.in Makefile
5715              $(do_subst) < $(srcdir)/automake.in > automake
5716              chmod +x automake
5718    Such scripts for which a build rule has been supplied need to be
5719 deleted explicitly using `CLEANFILES' (*note Clean::), and their
5720 sources have to be distributed, usually with `EXTRA_DIST' (*note
5721 Dist::).
5723    Another common way to build scripts is to process them from
5724 `configure' with `AC_CONFIG_FILES'.  In this situation Automake knows
5725 which files should be cleaned and distributed, and what the rebuild
5726 rules should look like.
5728    For instance if `configure.ac' contains
5730      AC_CONFIG_FILES([src/my_script], [chmod +x src/my_script])
5732 to build `src/my_script' from `src/my_script.in', then an
5733 `src/Makefile.am' to install this script in `$(bindir)' can be as
5734 simple as
5736      bin_SCRIPTS = my_script
5737      CLEANFILES = $(bin_SCRIPTS)
5739 There is no need for `EXTRA_DIST' or any build rule: Automake infers
5740 them from `AC_CONFIG_FILES' (*note Requirements::).  `CLEANFILES' is
5741 still useful, because by default Automake will clean targets of
5742 `AC_CONFIG_FILES' in `distclean', not `clean'.
5744    Although this looks simpler, building scripts this way has one
5745 drawback: directory variables such as `$(datadir)' are not fully
5746 expanded and may refer to other directory variables.
5748 \x1f
5749 File: automake.info,  Node: Headers,  Next: Data,  Prev: Scripts,  Up: Other objects
5751 9.2 Header files
5752 ================
5754 Header files that must be installed are specified by the `HEADERS'
5755 family of variables.  Headers can be installed in `includedir',
5756 `oldincludedir', `pkgincludedir' or any other directory you may have
5757 defined (*note Uniform::).  For instance,
5759      include_HEADERS = foo.h bar/bar.h
5761 will install the two files as `$(includedir)/foo.h' and
5762 `$(includedir)/bar.h'.
5764    The `nobase_' prefix is also supported,
5766      nobase_include_HEADERS = foo.h bar/bar.h
5768 will install the two files as `$(includedir)/foo.h' and
5769 `$(includedir)/bar/bar.h' (*note Alternative::).
5771    Usually, only header files that accompany installed libraries need to
5772 be installed.  Headers used by programs or convenience libraries are
5773 not installed.  The `noinst_HEADERS' variable can be used for such
5774 headers.  However when the header actually belongs to one convenient
5775 library or program, we recommend listing it in the program's or
5776 library's `_SOURCES' variable (*note Program Sources::) instead of in
5777 `noinst_HEADERS'.  This is clearer for the `Makefile.am' reader.
5778 `noinst_HEADERS' would be the right variable to use in a directory
5779 containing only headers and no associated library or program.
5781    All header files must be listed somewhere; in a `_SOURCES' variable
5782 or in a `_HEADERS' variable.  Missing ones will not appear in the
5783 distribution.
5785    For header files that are built and must not be distributed, use the
5786 `nodist_' prefix as in `nodist_include_HEADERS' or
5787 `nodist_prog_SOURCES'.  If these generated headers are needed during
5788 the build, you must also ensure they exist before they are used (*note
5789 Sources::).
5791 \x1f
5792 File: automake.info,  Node: Data,  Next: Sources,  Prev: Headers,  Up: Other objects
5794 9.3 Architecture-independent data files
5795 =======================================
5797 Automake supports the installation of miscellaneous data files using the
5798 `DATA' family of variables.  
5800    Such data can be installed in the directories `datadir',
5801 `sysconfdir', `sharedstatedir', `localstatedir', or `pkgdatadir'.
5803    By default, data files are _not_ included in a distribution.  Of
5804 course, you can use the `dist_' prefix to change this on a per-variable
5805 basis.
5807    Here is how Automake declares its auxiliary data files:
5809      dist_pkgdata_DATA = clean-kr.am clean.am ...
5811 \x1f
5812 File: automake.info,  Node: Sources,  Prev: Data,  Up: Other objects
5814 9.4 Built sources
5815 =================
5817 Because Automake's automatic dependency tracking works as a side-effect
5818 of compilation (*note Dependencies::) there is a bootstrap issue: a
5819 target should not be compiled before its dependencies are made, but
5820 these dependencies are unknown until the target is first compiled.
5822    Ordinarily this is not a problem, because dependencies are
5823 distributed sources: they preexist and do not need to be built.
5824 Suppose that `foo.c' includes `foo.h'.  When it first compiles `foo.o',
5825 `make' only knows that `foo.o' depends on `foo.c'.  As a side-effect of
5826 this compilation `depcomp' records the `foo.h' dependency so that
5827 following invocations of `make' will honor it.  In these conditions,
5828 it's clear there is no problem: either `foo.o' doesn't exist and has to
5829 be built (regardless of the dependencies), or accurate dependencies
5830 exist and they can be used to decide whether `foo.o' should be rebuilt.
5832    It's a different story if `foo.h' doesn't exist by the first `make'
5833 run.  For instance, there might be a rule to build `foo.h'.  This time
5834 `file.o''s build will fail because the compiler can't find `foo.h'.
5835 `make' failed to trigger the rule to build `foo.h' first by lack of
5836 dependency information.
5838    The `BUILT_SOURCES' variable is a workaround for this problem.  A
5839 source file listed in `BUILT_SOURCES' is made on `make all' or `make
5840 check' (or even `make install') before other targets are processed.
5841 However, such a source file is not _compiled_ unless explicitly
5842 requested by mentioning it in some other `_SOURCES' variable.
5844    So, to conclude our introductory example, we could use
5845 `BUILT_SOURCES = foo.h' to ensure `foo.h' gets built before any other
5846 target (including `foo.o') during `make all' or `make check'.
5848    `BUILT_SOURCES' is actually a bit of a misnomer, as any file which
5849 must be created early in the build process can be listed in this
5850 variable.  Moreover, all built sources do not necessarily have to be
5851 listed in `BUILT_SOURCES'.  For instance, a generated `.c' file doesn't
5852 need to appear in `BUILT_SOURCES' (unless it is included by another
5853 source), because it's a known dependency of the associated object.
5855    It might be important to emphasize that `BUILT_SOURCES' is honored
5856 only by `make all', `make check' and `make install'.  This means you
5857 cannot build a specific target (e.g., `make foo') in a clean tree if it
5858 depends on a built source.  However it will succeed if you have run
5859 `make all' earlier, because accurate dependencies are already available.
5861    The next section illustrates and discusses the handling of built
5862 sources on a toy example.
5864 * Menu:
5866 * Built sources example::       Several ways to handle built sources.
5868 \x1f
5869 File: automake.info,  Node: Built sources example,  Up: Sources
5871 9.4.1 Built sources example
5872 ---------------------------
5874 Suppose that `foo.c' includes `bindir.h', which is
5875 installation-dependent and not distributed: it needs to be built.  Here
5876 `bindir.h' defines the preprocessor macro `bindir' to the value of the
5877 `make' variable `bindir' (inherited from `configure').
5879    We suggest several implementations below.  It's not meant to be an
5880 exhaustive listing of all ways to handle built sources, but it will give
5881 you a few ideas if you encounter this issue.
5883 First try
5884 ---------
5886 This first implementation will illustrate the bootstrap issue mentioned
5887 in the previous section (*note Sources::).
5889    Here is a tentative `Makefile.am'.
5891      # This won't work.
5892      bin_PROGRAMS = foo
5893      foo_SOURCES = foo.c
5894      nodist_foo_SOURCES = bindir.h
5895      CLEANFILES = bindir.h
5896      bindir.h: Makefile
5897              echo '#define bindir "$(bindir)"' >$@
5899    This setup doesn't work, because Automake doesn't know that `foo.c'
5900 includes `bindir.h'.  Remember, automatic dependency tracking works as
5901 a side-effect of compilation, so the dependencies of `foo.o' will be
5902 known only after `foo.o' has been compiled (*note Dependencies::).  The
5903 symptom is as follows.
5905      % make
5906      source='foo.c' object='foo.o' libtool=no \
5907      depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
5908      depmode=gcc /bin/sh ./depcomp \
5909      gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
5910      foo.c:2: bindir.h: No such file or directory
5911      make: *** [foo.o] Error 1
5913    In this example `bindir.h' is not distributed, not installed, and it
5914 is not even being built on-time.  One may wonder what the
5915 `nodist_foo_SOURCES = bindir.h' line has any use at all.  This line
5916 simply states that `bindir.h' is a source of `foo', so for instance, it
5917 should be inspected while generating tags (*note Tags::).  In other
5918 words, it does not help our present problem, and the build would fail
5919 identically without it.
5921 Using `BUILT_SOURCES'
5922 ---------------------
5924 A solution is to require `bindir.h' to be built before anything else.
5925 This is what `BUILT_SOURCES' is meant for (*note Sources::).
5927      bin_PROGRAMS = foo
5928      foo_SOURCES = foo.c
5929      nodist_foo_SOURCES = bindir.h
5930      BUILT_SOURCES = bindir.h
5931      CLEANFILES = bindir.h
5932      bindir.h: Makefile
5933              echo '#define bindir "$(bindir)"' >$@
5935    See how `bindir.h' get built first:
5937      % make
5938      echo '#define bindir "/usr/local/bin"' >bindir.h
5939      make  all-am
5940      make[1]: Entering directory `/home/adl/tmp'
5941      source='foo.c' object='foo.o' libtool=no \
5942      depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
5943      depmode=gcc /bin/sh ./depcomp \
5944      gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
5945      gcc  -g -O2   -o foo  foo.o
5946      make[1]: Leaving directory `/home/adl/tmp'
5948    However, as said earlier, `BUILT_SOURCES' applies only to the `all',
5949 `check', and `install' targets.  It still fails if you try to run `make
5950 foo' explicitly:
5952      % make clean
5953      test -z "bindir.h" || rm -f bindir.h
5954      test -z "foo" || rm -f foo
5955      rm -f *.o
5956      % : > .deps/foo.Po # Suppress previously recorded dependencies
5957      % make foo
5958      source='foo.c' object='foo.o' libtool=no \
5959      depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
5960      depmode=gcc /bin/sh ./depcomp \
5961      gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
5962      foo.c:2: bindir.h: No such file or directory
5963      make: *** [foo.o] Error 1
5965 Recording dependencies manually
5966 -------------------------------
5968 Usually people are happy enough with `BUILT_SOURCES' because they never
5969 build targets such as `make foo' before `make all', as in the previous
5970 example.  However if this matters to you, you can avoid `BUILT_SOURCES'
5971 and record such dependencies explicitly in the `Makefile.am'.
5973      bin_PROGRAMS = foo
5974      foo_SOURCES = foo.c
5975      nodist_foo_SOURCES = bindir.h
5976      foo.$(OBJEXT): bindir.h
5977      CLEANFILES = bindir.h
5978      bindir.h: Makefile
5979              echo '#define bindir "$(bindir)"' >$@
5981    You don't have to list _all_ the dependencies of `foo.o' explicitly,
5982 only those that might need to be built.  If a dependency already
5983 exists, it will not hinder the first compilation and will be recorded
5984 by the normal dependency tracking code.  (Note that after this first
5985 compilation the dependency tracking code will also have recorded the
5986 dependency between `foo.o' and `bindir.h'; so our explicit dependency
5987 is really useful to the first build only.)
5989    Adding explicit dependencies like this can be a bit dangerous if you
5990 are not careful enough.  This is due to the way Automake tries not to
5991 overwrite your rules (it assumes you know better than it).
5992 `foo.$(OBJEXT): bindir.h' supersedes any rule Automake may want to
5993 output to build `foo.$(OBJEXT)'.  It happens to work in this case
5994 because Automake doesn't have to output any `foo.$(OBJEXT):' target: it
5995 relies on a suffix rule instead (i.e., `.c.$(OBJEXT):').  Always check
5996 the generated `Makefile.in' if you do this.
5998 Build `bindir.h' from `configure'
5999 ---------------------------------
6001 It's possible to define this preprocessor macro from `configure',
6002 either in `config.h' (*note Defining Directories: (autoconf)Defining
6003 Directories.), or by processing a `bindir.h.in' file using
6004 `AC_CONFIG_FILES' (*note Configuration Actions: (autoconf)Configuration
6005 Actions.).
6007    At this point it should be clear that building `bindir.h' from
6008 `configure' work well for this example.  `bindir.h' will exist before
6009 you build any target, hence will not cause any dependency issue.
6011    The Makefile can be shrunk as follows.  We do not even have to
6012 mention `bindir.h'.
6014      bin_PROGRAMS = foo
6015      foo_SOURCES = foo.c
6017    However, it's not always possible to build sources from `configure',
6018 especially when these sources are generated by a tool that needs to be
6019 built first...
6021 Build `bindir.c', not `bindir.h'.
6022 ---------------------------------
6024 Another attractive idea is to define `bindir' as a variable or function
6025 exported from `bindir.o', and build `bindir.c' instead of `bindir.h'.
6027      noinst_PROGRAMS = foo
6028      foo_SOURCES = foo.c bindir.h
6029      nodist_foo_SOURCES = bindir.c
6030      CLEANFILES = bindir.c
6031      bindir.c: Makefile
6032              echo 'const char bindir[] = "$(bindir)";' >$@
6034    `bindir.h' contains just the variable's declaration and doesn't need
6035 to be built, so it won't cause any trouble.  `bindir.o' is always
6036 dependent on `bindir.c', so `bindir.c' will get built first.
6038 Which is best?
6039 --------------
6041 There is no panacea, of course.  Each solution has its merits and
6042 drawbacks.
6044    You cannot use `BUILT_SOURCES' if the ability to run `make foo' on a
6045 clean tree is important to you.
6047    You won't add explicit dependencies if you are leery of overriding
6048 an Automake rule by mistake.
6050    Building files from `./configure' is not always possible, neither is
6051 converting `.h' files into `.c' files.
6053 \x1f
6054 File: automake.info,  Node: Other GNU Tools,  Next: Documentation,  Prev: Other objects,  Up: Top
6056 10 Other GNU Tools
6057 ******************
6059 Since Automake is primarily intended to generate `Makefile.in's for use
6060 in GNU programs, it tries hard to interoperate with other GNU tools.
6062 * Menu:
6064 * Emacs Lisp::                  Emacs Lisp
6065 * gettext::                     Gettext
6066 * Libtool::                     Libtool
6067 * Java::                        Java
6068 * Python::                      Python
6070 \x1f
6071 File: automake.info,  Node: Emacs Lisp,  Next: gettext,  Up: Other GNU Tools
6073 10.1 Emacs Lisp
6074 ===============
6076 Automake provides some support for Emacs Lisp.  The `LISP' primary is
6077 used to hold a list of `.el' files.  Possible prefixes for this primary
6078 are `lisp_' and `noinst_'.  Note that if `lisp_LISP' is defined, then
6079 `configure.ac' must run `AM_PATH_LISPDIR' (*note Macros::).
6081    Lisp sources are not distributed by default.  You can prefix the
6082 `LISP' primary with `dist_', as in `dist_lisp_LISP' or
6083 `dist_noinst_LISP', to indicate that these files should be distributed.
6085    Automake will byte-compile all Emacs Lisp source files using the
6086 Emacs found by `AM_PATH_LISPDIR', if any was found.
6088    Byte-compiled Emacs Lisp files are not portable among all versions of
6089 Emacs, so it makes sense to turn this off if you expect sites to have
6090 more than one version of Emacs installed.  Furthermore, many packages
6091 don't actually benefit from byte-compilation.  Still, we recommend that
6092 you byte-compile your Emacs Lisp sources.  It is probably better for
6093 sites with strange setups to cope for themselves than to make the
6094 installation less nice for everybody else.
6096    There are two ways to avoid byte-compiling.  Historically, we have
6097 recommended the following construct.
6098      lisp_LISP = file1.el file2.el
6099      ELCFILES =
6100    `ELCFILES' is an internal Automake variable that normally lists all
6101 `.elc' files that must be byte-compiled.  Automake defines `ELCFILES'
6102 automatically from `lisp_LISP'.  Emptying this variable explicitly
6103 prevents byte-compilation to occur.
6105    Since Automake 1.8, we now recommend using `lisp_DATA' instead.  As
6107      lisp_DATA = file1.el file2.el
6109    Note that these two constructs are not equivalent.  `_LISP' will not
6110 install a file if Emacs is not installed, while `_DATA' will always
6111 install its files.
6113 \x1f
6114 File: automake.info,  Node: gettext,  Next: Libtool,  Prev: Emacs Lisp,  Up: Other GNU Tools
6116 10.2 Gettext
6117 ============
6119 If `AM_GNU_GETTEXT' is seen in `configure.ac', then Automake turns on
6120 support for GNU gettext, a message catalog system for
6121 internationalization (*note GNU Gettext: (gettext)GNU Gettext.).
6123    The `gettext' support in Automake requires the addition of one or
6124 two subdirectories to the package, `po' and possibly also `intl'.  The
6125 latter is needed if `AM_GNU_GETTEXT' is not invoked with the `external'
6126 argument, or if `AM_GNU_GETTEXT_INTL_SUBDIR' is used.  Automake ensures
6127 that these directories exist and are mentioned in `SUBDIRS'.
6129 \x1f
6130 File: automake.info,  Node: Libtool,  Next: Java,  Prev: gettext,  Up: Other GNU Tools
6132 10.3 Libtool
6133 ============
6135 Automake provides support for GNU Libtool (*note Introduction:
6136 (libtool)Top.) with the `LTLIBRARIES' primary.  *Note A Shared
6137 Library::.
6139 \x1f
6140 File: automake.info,  Node: Java,  Next: Python,  Prev: Libtool,  Up: Other GNU Tools
6142 10.4 Java
6143 =========
6145 Automake provides some minimal support for Java compilation with the
6146 `JAVA' primary.
6148    Any `.java' files listed in a `_JAVA' variable will be compiled with
6149 `JAVAC' at build time.  By default, `.java' files are not included in
6150 the distribution, you should use the `dist_' prefix to distribute them.
6152    Here is a typical setup for distributing `.java' files and
6153 installing the `.class' files resulting from their compilation.
6155      javadir = $(datadir)/java
6156      dist_java_JAVA = a.java b.java ...
6158    Currently Automake enforces the restriction that only one `_JAVA'
6159 primary can be used in a given `Makefile.am'.  The reason for this
6160 restriction is that, in general, it isn't possible to know which
6161 `.class' files were generated from which `.java' files, so it would be
6162 impossible to know which files to install where.  For instance, a
6163 `.java' file can define multiple classes; the resulting `.class' file
6164 names cannot be predicted without parsing the `.java' file.
6166    There are a few variables that are used when compiling Java sources:
6168 `JAVAC'
6169      The name of the Java compiler.  This defaults to `javac'.
6171 `JAVACFLAGS'
6172      The flags to pass to the compiler.  This is considered to be a user
6173      variable (*note User Variables::).
6175 `AM_JAVACFLAGS'
6176      More flags to pass to the Java compiler.  This, and not
6177      `JAVACFLAGS', should be used when it is necessary to put Java
6178      compiler flags into `Makefile.am'.
6180 `JAVAROOT'
6181      The value of this variable is passed to the `-d' option to
6182      `javac'.  It defaults to `$(top_builddir)'.
6184 `CLASSPATH_ENV'
6185      This variable is an `sh' expression that is used to set the
6186      `CLASSPATH' environment variable on the `javac' command line.  (In
6187      the future we will probably handle class path setting differently.)
6189 \x1f
6190 File: automake.info,  Node: Python,  Prev: Java,  Up: Other GNU Tools
6192 10.5 Python
6193 ===========
6195 Automake provides support for Python compilation with the `PYTHON'
6196 primary.  A typical setup is to call `AM_PATH_PYTHON' in `configure.ac'
6197 and use a line like the following in `Makefile.am':
6199      python_PYTHON = tree.py leave.py
6201    Any files listed in a `_PYTHON' variable will be byte-compiled with
6202 `py-compile' at install time.  `py-compile' actually creates both
6203 standard (`.pyc') and optimized (`.pyo') byte-compiled versions of the
6204 source files.  Note that because byte-compilation occurs at install
6205 time, any files listed in `noinst_PYTHON' will not be compiled.  Python
6206 source files are included in the distribution by default, prepend
6207 `nodist_' (as in `nodist_python_PYTHON') to omit them.
6209    Automake ships with an Autoconf macro called `AM_PATH_PYTHON' that
6210 will determine some Python-related directory variables (see below).  If
6211 you have called `AM_PATH_PYTHON' from `configure.ac', then you may use
6212 the variables `python_PYTHON' or `pkgpython_PYTHON' to list Python
6213 source files in your `Makefile.am', depending where you want your files
6214 installed (see the definitions of `pythondir' and `pkgpythondir' below).
6216  -- Macro: AM_PATH_PYTHON ([VERSION], [ACTION-IF-FOUND],
6217           [ACTION-IF-NOT-FOUND])
6218      Search a Python interpreter on the system.  This macro takes three
6219      optional arguments.  The first argument, if present, is the minimum
6220      version of Python required for this package: `AM_PATH_PYTHON' will
6221      skip any Python interpreter that is older than VERSION.  If an
6222      interpreter is found and satisfies VERSION, then ACTION-IF-FOUND
6223      is run.  Otherwise, ACTION-IF-NOT-FOUND is run.
6225      If ACTION-IF-NOT-FOUND is not specified, as in the following
6226      example, the default is to abort `configure'.
6228           AM_PATH_PYTHON([2.2])
6230      This is fine when Python is an absolute requirement for the
6231      package.  If Python >= 2.2 was only _optional_ to the package,
6232      `AM_PATH_PYTHON' could be called as follows.
6234           AM_PATH_PYTHON([2.2],, [:])
6236      `AM_PATH_PYTHON' creates the following output variables based on
6237      the Python installation found during configuration.
6239 `PYTHON'
6240      The name of the Python executable, or `:' if no suitable
6241      interpreter could be found.
6243      Assuming ACTION-IF-NOT-FOUND is used (otherwise `./configure' will
6244      abort if Python is absent), the value of `PYTHON' can be used to
6245      setup a conditional in order to disable the relevant part of a
6246      build as follows.
6248             AM_PATH_PYTHON(,, [:])
6249             AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
6251 `PYTHON_VERSION'
6252      The Python version number, in the form MAJOR.MINOR (e.g., `1.5').
6253      This is currently the value of `sys.version[:3]'.
6255 `PYTHON_PREFIX'
6256      The string `${prefix}'.  This term may be used in future work that
6257      needs the contents of Python's `sys.prefix', but general consensus
6258      is to always use the value from configure.
6260 `PYTHON_EXEC_PREFIX'
6261      The string `${exec_prefix}'.  This term may be used in future work
6262      that needs the contents of Python's `sys.exec_prefix', but general
6263      consensus is to always use the value from configure.
6265 `PYTHON_PLATFORM'
6266      The canonical name used by Python to describe the operating
6267      system, as given by `sys.platform'.  This value is sometimes
6268      needed when building Python extensions.
6270 `pythondir'
6271      The directory name for the `site-packages' subdirectory of the
6272      standard Python install tree.
6274 `pkgpythondir'
6275      This is the directory under `pythondir' that is named after the
6276      package.  That is, it is `$(pythondir)/$(PACKAGE)'.  It is provided
6277      as a convenience.
6279 `pyexecdir'
6280      This is the directory where Python extension modules (shared
6281      libraries) should be installed.  An extension module written in C
6282      could be declared as follows to Automake:
6284           pyexec_LTLIBRARIES = quaternion.la
6285           quaternion_SOURCES = quaternion.c support.c support.h
6286           quaternion_la_LDFLAGS = -avoid-version -module
6288 `pkgpyexecdir'
6289      This is a convenience variable that is defined as
6290      `$(pyexecdir)/$(PACKAGE)'.
6292    All these directory variables have values that start with either
6293 `${prefix}' or `${exec_prefix}' unexpanded.  This works fine in
6294 `Makefiles', but it makes these variables hard to use in `configure'.
6295 This is mandated by the GNU coding standards, so that the user can run
6296 `make prefix=/foo install'.  The Autoconf manual has a section with
6297 more details on this topic (*note Installation Directory Variables:
6298 (autoconf)Installation Directory Variables.).  See also *Note
6299 Hard-Coded Install Paths::.
6301 \x1f
6302 File: automake.info,  Node: Documentation,  Next: Install,  Prev: Other GNU Tools,  Up: Top
6304 11 Building documentation
6305 *************************
6307 Currently Automake provides support for Texinfo and man pages.
6309 * Menu:
6311 * Texinfo::                     Texinfo
6312 * Man pages::                   Man pages
6314 \x1f
6315 File: automake.info,  Node: Texinfo,  Next: Man pages,  Up: Documentation
6317 11.1 Texinfo
6318 ============
6320 If the current directory contains Texinfo source, you must declare it
6321 with the `TEXINFOS' primary.  Generally Texinfo files are converted
6322 into info, and thus the `info_TEXINFOS' variable is most commonly used
6323 here.  Any Texinfo source file must end in the `.texi', `.txi', or
6324 `.texinfo' extension.  We recommend `.texi' for new manuals.
6326    Automake generates rules to build `.info', `.dvi', `.ps', `.pdf' and
6327 `.html' files from your Texinfo sources.  Following the GNU Coding
6328 Standards, only the `.info' files are built by `make all' and installed
6329 by `make install' (unless you use `no-installinfo', see below).
6330 Furthermore, `.info' files are automatically distributed so that
6331 Texinfo is not a prerequisite for installing your package.
6333    Other documentation formats can be built on request by `make dvi',
6334 `make ps', `make pdf' and `make html', and they can be installed with
6335 `make install-dvi', `make install-ps', `make install-pdf' and `make
6336 install-html' explicitly.  `make uninstall' will remove everything: the
6337 Texinfo documentation installed by default as well as all the above
6338 optional formats.
6340    All these targets can be extended using `-local' rules (*note
6341 Extending::).
6343    If the `.texi' file `@include's `version.texi', then that file will
6344 be automatically generated.  The file `version.texi' defines four
6345 Texinfo flag you can reference using `@value{EDITION}',
6346 `@value{VERSION}', `@value{UPDATED}', and `@value{UPDATED-MONTH}'.
6348 `EDITION'
6349 `VERSION'
6350      Both of these flags hold the version number of your program.  They
6351      are kept separate for clarity.
6353 `UPDATED'
6354      This holds the date the primary `.texi' file was last modified.
6356 `UPDATED-MONTH'
6357      This holds the name of the month in which the primary `.texi' file
6358      was last modified.
6360    The `version.texi' support requires the `mdate-sh' script; this
6361 script is supplied with Automake and automatically included when
6362 `automake' is invoked with the `--add-missing' option.
6364    If you have multiple Texinfo files, and you want to use the
6365 `version.texi' feature, then you have to have a separate version file
6366 for each Texinfo file.  Automake will treat any include in a Texinfo
6367 file that matches `vers*.texi' just as an automatically generated
6368 version file.
6370    Sometimes an info file actually depends on more than one `.texi'
6371 file.  For instance, in GNU Hello, `hello.texi' includes the file
6372 `gpl.texi'.  You can tell Automake about these dependencies using the
6373 `TEXI_TEXINFOS' variable.  Here is how GNU Hello does it: 
6375      info_TEXINFOS = hello.texi
6376      hello_TEXINFOS = gpl.texi
6378    By default, Automake requires the file `texinfo.tex' to appear in
6379 the same directory as the Texinfo source (this can be changed using the
6380 `TEXINFO_TEX' variable, see below).  However, if you used
6381 `AC_CONFIG_AUX_DIR' in `configure.ac' (*note Finding `configure' Input:
6382 (autoconf)Input.), then `texinfo.tex' is looked for there.  Automake
6383 supplies `texinfo.tex' if `--add-missing' is given.
6385    The option `no-texinfo.tex' can be used to eliminate the requirement
6386 for the file `texinfo.tex'.  Use of the variable `TEXINFO_TEX' is
6387 preferable, however, because that allows the `dvi', `ps', and `pdf'
6388 targets to still work.
6390    Automake generates an `install-info' rule; some people apparently
6391 use this.  By default, info pages are installed by `make install', so
6392 running `make install-info' is pointless.  This can be prevented via
6393 the `no-installinfo' option.  In this case, `.info' files are not
6394 installed by default, and user must request this explicitly using `make
6395 install-info'
6397    The following variables are used by the Texinfo build rules.
6399 `MAKEINFO'
6400      The name of the program invoked to build `.info' files.  This
6401      variable is defined by Automake.  If the `makeinfo' program is
6402      found on the system then it will be used by default; otherwise
6403      `missing' will be used instead.
6405 `MAKEINFOHTML'
6406      The command invoked to build `.html' files.  Automake defines this
6407      to `$(MAKEINFO) --html'.
6409 `MAKEINFOFLAGS'
6410      User flags passed to each invocation of `$(MAKEINFO)' and
6411      `$(MAKEINFOHTML)'.  This user variable (*note User Variables::) is
6412      not expected to be defined in any `Makefile'; it can be used by
6413      users to pass extra flags to suit their needs.
6415 `AM_MAKEINFOFLAGS'
6416 `AM_MAKEINFOHTMLFLAGS'
6417      Maintainer flags passed to each `makeinfo' invocation.  Unlike
6418      `MAKEINFOFLAGS', these variables are meant to be defined by
6419      maintainers in `Makefile.am'.  `$(AM_MAKEINFOFLAGS)' is passed to
6420      `makeinfo' when building `.info' files; and
6421      `$(AM_MAKEINFOHTMLFLAGS)' is used when building `.html' files.
6423      For instance, the following setting can be used to obtain one
6424      single `.html' file per manual, without node separators.
6425           AM_MAKEINFOHTMLFLAGS = --no-headers --no-split
6427      `AM_MAKEINFOHTMLFLAGS' defaults to `$(AM_MAKEINFOFLAGS)'.  This
6428      means that defining `AM_MAKEINFOFLAGS' without defining
6429      `AM_MAKEINFOHTMLFLAGS' will impact builds of both `.info' and
6430      `.html' files.
6432 `TEXI2DVI'
6433      The name of the command that converts a `.texi' file into a `.dvi'
6434      file.  This defaults to `texi2dvi', a script that ships with the
6435      Texinfo package.
6437 `TEXI2PDF'
6438      The name of the command that translates a `.texi' file into a
6439      `.pdf' file.  This defaults to `$(TEXI2DVI) --pdf --batch'.
6441 `DVIPS'
6442      The name of the command that build a `.ps' file out of a `.dvi'
6443      file.  This defaults to `dvips'.
6445 `TEXINFO_TEX'
6446      If your package has Texinfo files in many directories, you can use
6447      the variable `TEXINFO_TEX' to tell Automake where to find the
6448      canonical `texinfo.tex' for your package.  The value of this
6449      variable should be the relative path from the current
6450      `Makefile.am' to `texinfo.tex':
6452           TEXINFO_TEX = ../doc/texinfo.tex
6454 \x1f
6455 File: automake.info,  Node: Man pages,  Prev: Texinfo,  Up: Documentation
6457 11.2 Man pages
6458 ==============
6460 A package can also include man pages (but see the GNU standards on this
6461 matter, *Note Man Pages: (standards)Man Pages.)  Man pages are declared
6462 using the `MANS' primary.  Generally the `man_MANS' variable is used.
6463 Man pages are automatically installed in the correct subdirectory of
6464 `mandir', based on the file extension.
6466    File extensions such as `.1c' are handled by looking for the valid
6467 part of the extension and using that to determine the correct
6468 subdirectory of `mandir'.  Valid section names are the digits `0'
6469 through `9', and the letters `l' and `n'.
6471    Sometimes developers prefer to name a man page something like
6472 `foo.man' in the source, and then rename it to have the correct suffix,
6473 for example `foo.1', when installing the file.  Automake also supports
6474 this mode.  For a valid section named SECTION, there is a corresponding
6475 directory named `manSECTIONdir', and a corresponding `_MANS' variable.
6476 Files listed in such a variable are installed in the indicated section.
6477 If the file already has a valid suffix, then it is installed as-is;
6478 otherwise the file suffix is changed to match the section.
6480    For instance, consider this example:
6481      man1_MANS = rename.man thesame.1 alsothesame.1c
6483    In this case, `rename.man' will be renamed to `rename.1' when
6484 installed, but the other files will keep their names.
6486    By default, man pages are installed by `make install'.  However,
6487 since the GNU project does not require man pages, many maintainers do
6488 not expend effort to keep the man pages up to date.  In these cases, the
6489 `no-installman' option will prevent the man pages from being installed
6490 by default.  The user can still explicitly install them via `make
6491 install-man'.
6493    Man pages are not currently considered to be source, because it is
6494 not uncommon for man pages to be automatically generated.  Therefore
6495 they are not automatically included in the distribution.  However, this
6496 can be changed by use of the `dist_' prefix.  For instance here is how
6497 to distribute and install the two man pages of GNU `cpio' (which
6498 includes both Texinfo documentation and man pages):
6500      dist_man_MANS = cpio.1 mt.1
6502    The `nobase_' prefix is meaningless for man pages and is disallowed.
6504 \x1f
6505 File: automake.info,  Node: Install,  Next: Clean,  Prev: Documentation,  Up: Top
6507 12 What Gets Installed
6508 **********************
6510 12.1 Basics of installation
6511 ===========================
6513 Naturally, Automake handles the details of actually installing your
6514 program once it has been built.  All files named by the various
6515 primaries are automatically installed in the appropriate places when the
6516 user runs `make install'.
6518    A file named in a primary is installed by copying the built file into
6519 the appropriate directory.  The base name of the file is used when
6520 installing.
6522      bin_PROGRAMS = hello subdir/goodbye
6524    In this example, both `hello' and `goodbye' will be installed in
6525 `$(bindir)'.
6527    Sometimes it is useful to avoid the basename step at install time.
6528 For instance, you might have a number of header files in subdirectories
6529 of the source tree that are laid out precisely how you want to install
6530 them.  In this situation you can use the `nobase_' prefix to suppress
6531 the base name step.  For example:
6533      nobase_include_HEADERS = stdio.h sys/types.h
6535    Will install `stdio.h' in `$(includedir)' and `types.h' in
6536 `$(includedir)/sys'.
6538 12.2 The two parts of install
6539 =============================
6541 Automake generates separate `install-data' and `install-exec' rules, in
6542 case the installer is installing on multiple machines that share
6543 directory structure--these targets allow the machine-independent parts
6544 to be installed only once.  `install-exec' installs platform-dependent
6545 files, and `install-data' installs platform-independent files.  The
6546 `install' target depends on both of these targets.  While Automake
6547 tries to automatically segregate objects into the correct category, the
6548 `Makefile.am' author is, in the end, responsible for making sure this
6549 is done correctly.  
6551    Variables using the standard directory prefixes `data', `info',
6552 `man', `include', `oldinclude', `pkgdata', or `pkginclude' are
6553 installed by `install-data'.
6555    Variables using the standard directory prefixes `bin', `sbin',
6556 `libexec', `sysconf', `localstate', `lib', or `pkglib' are installed by
6557 `install-exec'.
6559    For instance, `data_DATA' files are installed by `install-data',
6560 while `bin_PROGRAMS' files are installed by `install-exec'.
6562    Any variable using a user-defined directory prefix with `exec' in
6563 the name (e.g., `myexecbin_PROGRAMS') is installed by `install-exec'.
6564 All other user-defined prefixes are installed by `install-data'.
6566 12.3 Extending installation
6567 ===========================
6569 It is possible to extend this mechanism by defining an
6570 `install-exec-local' or `install-data-local' rule.  If these rules
6571 exist, they will be run at `make install' time.  These rules can do
6572 almost anything; care is required.  
6574    Automake also supports two install hooks, `install-exec-hook' and
6575 `install-data-hook'.  These hooks are run after all other install rules
6576 of the appropriate type, exec or data, have completed.  So, for
6577 instance, it is possible to perform post-installation modifications
6578 using an install hook.  *Note Extending:: gives some examples.  
6580 12.4 Staged installs
6581 ====================
6583 Automake generates support for the `DESTDIR' variable in all install
6584 rules.  `DESTDIR' is used during the `make install' step to relocate
6585 install objects into a staging area.  Each object and path is prefixed
6586 with the value of `DESTDIR' before being copied into the install area.
6587 Here is an example of typical DESTDIR usage:
6589      mkdir /tmp/staging &&
6590      make DESTDIR=/tmp/staging install
6592    The `mkdir' command avoids a security problem if the attacker
6593 creates a symbolic link from `/tmp/staging' to a victim area; then
6594 `make' places install objects in a directory tree built under
6595 `/tmp/staging'.  If `/gnu/bin/foo' and `/gnu/share/aclocal/foo.m4' are
6596 to be installed, the above command would install
6597 `/tmp/staging/gnu/bin/foo' and `/tmp/staging/gnu/share/aclocal/foo.m4'.
6599    This feature is commonly used to build install images and packages
6600 (*note DESTDIR::).
6602    Support for `DESTDIR' is implemented by coding it directly into the
6603 install rules.  If your `Makefile.am' uses a local install rule (e.g.,
6604 `install-exec-local') or an install hook, then you must write that code
6605 to respect `DESTDIR'.
6607    *Note Makefile Conventions: (standards)Makefile Conventions, for
6608 another usage example.
6610 12.5 Rules for the user
6611 =======================
6613 Automake also generates rules for targets `uninstall', `installdirs',
6614 and `install-strip'.  
6616    Automake supports `uninstall-local' and `uninstall-hook'.  There is
6617 no notion of separate uninstalls for "exec" and "data", as these
6618 features would not provide additional functionality.
6620    Note that `uninstall' is not meant as a replacement for a real
6621 packaging tool.
6623 \x1f
6624 File: automake.info,  Node: Clean,  Next: Dist,  Prev: Install,  Up: Top
6626 13 What Gets Cleaned
6627 ********************
6629 The GNU Makefile Standards specify a number of different clean rules.
6630 *Note Standard Targets for Users: (standards)Standard Targets.
6632    Generally the files that can be cleaned are determined automatically
6633 by Automake.  Of course, Automake also recognizes some variables that
6634 can be defined to specify additional files to clean.  These variables
6635 are `MOSTLYCLEANFILES', `CLEANFILES', `DISTCLEANFILES', and
6636 `MAINTAINERCLEANFILES'.  
6638    When cleaning involves more than deleting some hard-coded list of
6639 files, it is also possible to supplement the cleaning rules with your
6640 own commands.  Simply define a rule for any of the `mostlyclean-local',
6641 `clean-local', `distclean-local', or `maintainer-clean-local' targets
6642 (*note Extending::).  A common case is deleting a directory, for
6643 instance, a directory created by the test suite:
6645      clean-local:
6646              -rm -rf testSubDir
6648    As the GNU Standards aren't always explicit as to which files should
6649 be removed by which rule, we've adopted a heuristic that we believe was
6650 first formulated by Franc,ois Pinard:
6652    * If `make' built it, and it is commonly something that one would
6653      want to rebuild (for instance, a `.o' file), then `mostlyclean'
6654      should delete it.
6656    * Otherwise, if `make' built it, then `clean' should delete it.
6658    * If `configure' built it, then `distclean' should delete it.
6660    * If the maintainer built it (for instance, a `.info' file), then
6661      `maintainer-clean' should delete it.  However `maintainer-clean'
6662      should not delete anything that needs to exist in order to run
6663      `./configure && make'.
6665    We recommend that you follow this same set of heuristics in your
6666 `Makefile.am'.
6668 \x1f
6669 File: automake.info,  Node: Dist,  Next: Tests,  Prev: Clean,  Up: Top
6671 14 What Goes in a Distribution
6672 ******************************
6674 14.1 Basics of distribution
6675 ===========================
6677 The `dist' rule in the generated `Makefile.in' can be used to generate
6678 a gzipped `tar' file and other flavors of archive for distribution.
6679 The files is named based on the `PACKAGE' and `VERSION' variables
6680 defined by `AM_INIT_AUTOMAKE' (*note Macros::); more precisely the
6681 gzipped `tar' file is named `PACKAGE-VERSION.tar.gz'.  You can use the
6682 `make' variable `GZIP_ENV' to control how gzip is run.  The default
6683 setting is `--best'.
6685    For the most part, the files to distribute are automatically found by
6686 Automake: all source files are automatically included in a distribution,
6687 as are all `Makefile.am's and `Makefile.in's.  Automake also has a
6688 built-in list of commonly used files that are automatically included if
6689 they are found in the current directory (either physically, or as the
6690 target of a `Makefile.am' rule).  This list is printed by `automake
6691 --help'.  Also, files that are read by `configure' (i.e. the source
6692 files corresponding to the files specified in various Autoconf macros
6693 such as `AC_CONFIG_FILES' and siblings) are automatically distributed.
6694 Files included in `Makefile.am's (using `include') or in `configure.ac'
6695 (using `m4_include'), and helper scripts installed with `automake
6696 --add-missing' are also distributed.
6698    Still, sometimes there are files that must be distributed, but which
6699 are not covered in the automatic rules.  These files should be listed in
6700 the `EXTRA_DIST' variable.  You can mention files from subdirectories
6701 in `EXTRA_DIST'.
6703    You can also mention a directory in `EXTRA_DIST'; in this case the
6704 entire directory will be recursively copied into the distribution.
6705 Please note that this will also copy _everything_ in the directory,
6706 including CVS/RCS version control files.  We recommend against using
6707 this feature.
6709    If you define `SUBDIRS', Automake will recursively include the
6710 subdirectories in the distribution.  If `SUBDIRS' is defined
6711 conditionally (*note Conditionals::), Automake will normally include
6712 all directories that could possibly appear in `SUBDIRS' in the
6713 distribution.  If you need to specify the set of directories
6714 conditionally, you can set the variable `DIST_SUBDIRS' to the exact
6715 list of subdirectories to include in the distribution (*note
6716 Conditional Subdirectories::).
6718 14.2 Fine-grained distribution control
6719 ======================================
6721 Sometimes you need tighter control over what does _not_ go into the
6722 distribution; for instance, you might have source files that are
6723 generated and that you do not want to distribute.  In this case
6724 Automake gives fine-grained control using the `dist' and `nodist'
6725 prefixes.  Any primary or `_SOURCES' variable can be prefixed with
6726 `dist_' to add the listed files to the distribution.  Similarly,
6727 `nodist_' can be used to omit the files from the distribution.
6729    As an example, here is how you would cause some data to be
6730 distributed while leaving some source code out of the distribution:
6732      dist_data_DATA = distribute-this
6733      bin_PROGRAMS = foo
6734      nodist_foo_SOURCES = do-not-distribute.c
6736 14.3 The dist hook
6737 ==================
6739 Occasionally it is useful to be able to change the distribution before
6740 it is packaged up.  If the `dist-hook' rule exists, it is run after the
6741 distribution directory is filled, but before the actual tar (or shar)
6742 file is created.  One way to use this is for distributing files in
6743 subdirectories for which a new `Makefile.am' is overkill:
6745      dist-hook:
6746              mkdir $(distdir)/random
6747              cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
6749    Another way to to use this is for removing unnecessary files that get
6750 recursively included by specifying a directory in EXTRA_DIST:
6752      EXTRA_DIST = doc
6754      dist-hook:
6755              rm -rf `find $(distdir)/doc -name CVS`
6757    Two variables that come handy when writing `dist-hook' rules are
6758 `$(distdir)' and `$(top_distdir)'.
6760    `$(distdir)' points to the directory where the `dist' rule will copy
6761 files from the current directory before creating the tarball.  If you
6762 are at the top-level directory, then `distdir = $(PACKAGE)-$(VERSION)'.
6763 When used from subdirectory named `foo/', then `distdir =
6764 ../$(PACKAGE)-$(VERSION)/foo'.  `$(distdir)' can be a relative or
6765 absolute path, do not assume any form.
6767    `$(top_distdir)' always points to the root directory of the
6768 distributed tree.  At the top-level it's equal to `$(distdir)'.  In the
6769 `foo/' subdirectory `top_distdir = ../$(PACKAGE)-$(VERSION)'.
6770 `$(top_distdir)' too can be a relative or absolute path.
6772    Note that when packages are nested using `AC_CONFIG_SUBDIRS' (*note
6773 Subpackages::), then `$(distdir)' and `$(top_distdir)' are relative to
6774 the package where `make dist' was run, not to any sub-packages involved.
6776 14.4 Checking the distribution
6777 ==============================
6779 Automake also generates a `distcheck' rule that can be of help to
6780 ensure that a given distribution will actually work.  `distcheck' makes
6781 a distribution, then tries to do a `VPATH' build (*note VPATH
6782 Builds::), run the test suite, and finally make another tarball to
6783 ensure the distribution is self-contained.
6785    Building the package involves running `./configure'.  If you need to
6786 supply additional flags to `configure', define them in the
6787 `DISTCHECK_CONFIGURE_FLAGS' variable, either in your top-level
6788 `Makefile.am', or on the command line when invoking `make'.
6790    If the `distcheck-hook' rule is defined in your top-level
6791 `Makefile.am', then it will be invoked by `distcheck' after the new
6792 distribution has been unpacked, but before the unpacked copy is
6793 configured and built.  Your `distcheck-hook' can do almost anything,
6794 though as always caution is advised.  Generally this hook is used to
6795 check for potential distribution errors not caught by the standard
6796 mechanism.  Note that `distcheck-hook' as well as
6797 `DISTCHECK_CONFIGURE_FLAGS' are not honored in a subpackage
6798 `Makefile.am', but the `DISTCHECK_CONFIGURE_FLAGS' are passed down to
6799 the `configure' script of the subpackage.
6801    Speaking of potential distribution errors, `distcheck' also ensures
6802 that the `distclean' rule actually removes all built files.  This is
6803 done by running `make distcleancheck' at the end of the `VPATH' build.
6804 By default, `distcleancheck' will run `distclean' and then make sure
6805 the build tree has been emptied by running
6806 `$(distcleancheck_listfiles)'.  Usually this check will find generated
6807 files that you forgot to add to the `DISTCLEANFILES' variable (*note
6808 Clean::).
6810    The `distcleancheck' behavior should be OK for most packages,
6811 otherwise you have the possibility to override the definition of either
6812 the `distcleancheck' rule, or the `$(distcleancheck_listfiles)'
6813 variable.  For instance, to disable `distcleancheck' completely, add
6814 the following rule to your top-level `Makefile.am':
6816      distcleancheck:
6817              @:
6819    If you want `distcleancheck' to ignore built files that have not
6820 been cleaned because they are also part of the distribution, add the
6821 following definition instead:
6823      distcleancheck_listfiles = \
6824        find -type f -exec sh -c 'test -f $(srcdir)/{} || echo {}' ';'
6826    The above definition is not the default because it's usually an
6827 error if your Makefiles cause some distributed files to be rebuilt when
6828 the user build the package.  (Think about the user missing the tool
6829 required to build the file; or if the required tool is built by your
6830 package, consider the cross-compilation case where it can't be run.)
6831 There is a FAQ entry about this (*note distcleancheck::), make sure you
6832 read it before playing with `distcleancheck_listfiles'.
6834    `distcheck' also checks that the `uninstall' rule works properly,
6835 both for ordinary and `DESTDIR' builds.  It does this by invoking `make
6836 uninstall', and then it checks the install tree to see if any files are
6837 left over.  This check will make sure that you correctly coded your
6838 `uninstall'-related rules.
6840    By default, the checking is done by the `distuninstallcheck' rule,
6841 and the list of files in the install tree is generated by
6842 `$(distuninstallcheck_listfiles') (this is a variable whose value is a
6843 shell command to run that prints the list of files to stdout).
6845    Either of these can be overridden to modify the behavior of
6846 `distcheck'.  For instance, to disable this check completely, you would
6847 write:
6849      distuninstallcheck:
6850              @:
6852 14.5 The types of distributions
6853 ===============================
6855 Automake generates rules to provide archives of the project for
6856 distributions in various formats.  Their targets are:
6858 `dist-bzip2'
6859      Generate a bzip2 tar archive of the distribution.  bzip2 archives
6860      are frequently smaller than gzipped archives.  
6862 `dist-gzip'
6863      Generate a gzip tar archive of the distribution.  
6865 `dist-shar'
6866      Generate a shar archive of the distribution.  
6868 `dist-zip'
6869      Generate a zip archive of the distribution.  
6871 `dist-tarZ'
6872      Generate a compressed tar archive of the distribution.  
6874    The rule `dist' (and its historical synonym `dist-all') will create
6875 archives in all the enabled formats, *Note Options::.  By default, only
6876 the `dist-gzip' target is hooked to `dist'.
6878 \x1f
6879 File: automake.info,  Node: Tests,  Next: Rebuilding,  Prev: Dist,  Up: Top
6881 15 Support for test suites
6882 **************************
6884 Automake supports two forms of test suites.
6886 15.1 Simple Tests
6887 =================
6889 If the variable `TESTS' is defined, its value is taken to be a list of
6890 programs or scripts to run in order to do the testing.  Programs
6891 needing data files should look for them in `srcdir' (which is both an
6892 environment variable and a make variable) so they work when building in
6893 a separate directory (*note Build Directories: (autoconf)Build
6894 Directories.), and in particular for the `distcheck' rule (*note
6895 Dist::).
6897    The number of failures will be printed at the end of the run.  If a
6898 given test program exits with a status of 77, then its result is ignored
6899 in the final count.  This feature allows non-portable tests to be
6900 ignored in environments where they don't make sense.
6902    The variable `TESTS_ENVIRONMENT' can be used to set environment
6903 variables for the test run; the environment variable `srcdir' is set in
6904 the rule.  If all your test programs are scripts, you can also set
6905 `TESTS_ENVIRONMENT' to an invocation of the shell (e.g.  `$(SHELL) -x'
6906 can be useful for debugging the tests), or any other interpreter.  For
6907 instance the following setup is used by the Automake package to run
6908 four tests in Perl.
6909      TESTS_ENVIRONMENT = $(PERL) -Mstrict -I $(top_srcdir)/lib -w
6910      TESTS = Condition.pl DisjConditions.pl Version.pl Wrap.pl
6912    You may define the variable `XFAIL_TESTS' to a list of tests
6913 (usually a subset of `TESTS') that are expected to fail.  This will
6914 reverse the result of those tests.  
6916    Automake ensures that each file listed in `TESTS' is built before
6917 any tests are run; you can list both source and derived programs (or
6918 scripts) in `TESTS'; the generated rule will look both in `srcdir' and
6919 `.'.  For instance, you might want to run a C program as a test.  To do
6920 this you would list its name in `TESTS' and also in `check_PROGRAMS',
6921 and then specify it as you would any other program.
6923    Programs listed in `check_PROGRAMS' (and `check_LIBRARIES',
6924 `check_LTLIBRARIES'...) are only built during `make check', not during
6925 `make all'.  You should list there any program needed by your tests
6926 that does not need to be built by `make all'.  Note that
6927 `check_PROGRAMS' are _not_ automatically added to `TESTS' because
6928 `check_PROGRAMS' usually lists programs used by the tests, not the
6929 tests themselves.  Of course you can set `TESTS = $(check_PROGRAMS)' if
6930 all your programs are test cases.
6932 15.2 DejaGnu Tests
6933 ==================
6935 If `dejagnu' (ftp://ftp.gnu.org/gnu/dejagnu/) appears in
6936 `AUTOMAKE_OPTIONS', then a `dejagnu'-based test suite is assumed.  The
6937 variable `DEJATOOL' is a list of names that are passed, one at a time,
6938 as the `--tool' argument to `runtest' invocations; it defaults to the
6939 name of the package.
6941    The variable `RUNTESTDEFAULTFLAGS' holds the `--tool' and `--srcdir'
6942 flags that are passed to dejagnu by default; this can be overridden if
6943 necessary.  
6945    The variables `EXPECT' and `RUNTEST' can also be overridden to
6946 provide project-specific values.  For instance, you will need to do
6947 this if you are testing a compiler toolchain, because the default
6948 values do not take into account host and target names.  
6950    The contents of the variable `RUNTESTFLAGS' are passed to the
6951 `runtest' invocation.  This is considered a "user variable" (*note User
6952 Variables::).  If you need to set `runtest' flags in `Makefile.am', you
6953 can use `AM_RUNTESTFLAGS' instead.  
6955    Automake will generate rules to create a local `site.exp' file,
6956 defining various variables detected by `configure'.  This file is
6957 automatically read by DejaGnu.  It is OK for the user of a package to
6958 edit this file in order to tune the test suite.  However this is not
6959 the place where the test suite author should define new variables: this
6960 should be done elsewhere in the real test suite code.  Especially,
6961 `site.exp' should not be distributed.
6963    For more information regarding DejaGnu test suites, see *Note Top:
6964 (dejagnu)Top.
6966    In either case, the testing is done via `make check'.
6968 15.3 Install Tests
6969 ==================
6971 The `installcheck' target is available to the user as a way to run any
6972 tests after the package has been installed.  You can add tests to this
6973 by writing an `installcheck-local' rule.
6975 \x1f
6976 File: automake.info,  Node: Rebuilding,  Next: Options,  Prev: Tests,  Up: Top
6978 16 Rebuilding Makefiles
6979 ***********************
6981 Automake generates rules to automatically rebuild `Makefile's,
6982 `configure', and other derived files like `Makefile.in'.
6984    If you are using `AM_MAINTAINER_MODE' in `configure.ac', then these
6985 automatic rebuilding rules are only enabled in maintainer mode.
6987    Sometimes you need to run `aclocal' with an argument like `-I' to
6988 tell it where to find `.m4' files.  Since sometimes `make' will
6989 automatically run `aclocal', you need a way to specify these arguments.
6990 You can do this by defining `ACLOCAL_AMFLAGS'; this holds arguments
6991 that are passed verbatim to `aclocal'.  This variable is only useful in
6992 the top-level `Makefile.am'.
6994    Sometimes it is convenient to supplement the rebuild rules for
6995 `configure' or `config.status' with additional dependencies.  The
6996 variables `CONFIGURE_DEPENDENCIES' and `CONFIG_STATUS_DEPENDENCIES' can
6997 be used to list these extra dependencies.  These variable should be
6998 defined in all `Makefile's of the tree (because these two rebuild rules
6999 are output in all them), so it is safer and easier to `AC_SUBST' them
7000 from `configure.ac'.  For instance, the following statement will cause
7001 `configure' to be rerun each time `version.sh' is changed.
7002      AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version.sh'])
7003    Note the `$(top_srcdir)/' in the file name.  Since this variable is
7004 to be used in all `Makefile's, its value must be sensible at any level
7005 in the build hierarchy.
7007    Beware not to mistake `CONFIGURE_DEPENDENCIES' for
7008 `CONFIG_STATUS_DEPENDENCIES'.
7010    `CONFIGURE_DEPENDENCIES' adds dependencies to the `configure' rule,
7011 whose effect is to run `autoconf'.  This variable should be seldom
7012 used, because `automake' already tracks `m4_include'd files.  However
7013 it can be useful when playing tricky games with `m4_esyscmd' or similar
7014 non-recommendable macros with side effects.
7016    `CONFIG_STATUS_DEPENDENCIES' adds dependencies to the
7017 `config.status' rule, whose effect is to run `configure'.  This
7018 variable should therefore carry any non-standard source that may be
7019 read as a side effect of running configure, like `version.sh' in the
7020 example above.
7022    Speaking of `version.sh' scripts, we recommend against them today.
7023 They are mainly used when the version of a package is updated
7024 automatically by a script (e.g., in daily builds).  Here is what some
7025 old-style `configure.ac's may look like:
7026      AC_INIT
7027      . $srcdir/version.sh
7028      AM_INIT_AUTOMAKE([name], $VERSION_NUMBER)
7029      ...
7030    Here, `version.sh' is a shell fragment that sets `VERSION_NUMBER'.
7031 The problem with this example is that `automake' cannot track
7032 dependencies (listing `version.sh' in `CONFIG_STATUS_DEPENDENCIES', and
7033 distributing this file is up to the user), and that it uses the
7034 obsolete form of `AC_INIT' and `AM_INIT_AUTOMAKE'.  Upgrading to the
7035 new syntax is not straightforward, because shell variables are not
7036 allowed in `AC_INIT''s arguments.  We recommend that `version.sh' be
7037 replaced by an M4 file that is included by `configure.ac':
7038      m4_include([version.m4])
7039      AC_INIT([name], VERSION_NUMBER)
7040      AM_INIT_AUTOMAKE
7041      ...
7042    Here `version.m4' could contain something like
7043 `m4_define([VERSION_NUMBER], [1.2])'.  The advantage of this second
7044 form is that `automake' will take care of the dependencies when
7045 defining the rebuild rule, and will also distribute the file
7046 automatically.  An inconvenience is that `autoconf' will now be rerun
7047 each time the version number is bumped, when only `configure' had to be
7048 rerun in the previous setup.
7050 \x1f
7051 File: automake.info,  Node: Options,  Next: Miscellaneous,  Prev: Rebuilding,  Up: Top
7053 17 Changing Automake's Behavior
7054 *******************************
7056 Various features of Automake can be controlled by options in the
7057 `Makefile.am'.  Such options are applied on a per-`Makefile' basis when
7058 listed in a special `Makefile' variable named `AUTOMAKE_OPTIONS'.  They
7059 are applied globally to all processed `Makefiles' when listed in the
7060 first argument of `AM_INIT_AUTOMAKE' in `configure.ac'.  Currently
7061 understood options are: 
7063 `gnits'
7064 `gnu'
7065 `foreign'
7066 `cygnus'
7067      Set the strictness as appropriate.  The `gnits' option also
7068      implies options `readme-alpha' and `check-news'.
7070 `ansi2knr'
7071 `PATH/ansi2knr'
7072      Turn on the obsolete de-ANSI-fication feature.  *Note ANSI::.  If
7073      preceded by a path, the generated `Makefile.in' will look in the
7074      specified directory to find the `ansi2knr' program.  The path
7075      should be a relative path to another directory in the same
7076      distribution (Automake currently does not check this).
7078 `check-news'
7079      Cause `make dist' to fail unless the current version number appears
7080      in the first few lines of the `NEWS' file.
7082 `dejagnu'
7083      Cause `dejagnu'-specific rules to be generated.  *Note Tests::.
7085 `dist-bzip2'
7086      Hook `dist-bzip2' to `dist'.  
7088 `dist-shar'
7089      Hook `dist-shar' to `dist'.  
7091 `dist-zip'
7092      Hook `dist-zip' to `dist'.  
7094 `dist-tarZ'
7095      Hook `dist-tarZ' to `dist'.  
7097 `filename-length-max=99'
7098      Abort if file names longer than 99 characters are found during
7099      `make dist'.  Such long file names are generally considered not to
7100      be portable in tarballs.  See the `tar-v7' and `tar-ustar' options
7101      below.  This option should be used in the top-level `Makefile.am'
7102      or as an argument of `AM_INIT_AUTOMAKE' in `configure.ac', it will
7103      be ignored otherwise.  It will also be ignored in sub-packages of
7104      nested packages (*note Subpackages::).
7106 `no-define'
7107      This options is meaningful only when passed as an argument to
7108      `AM_INIT_AUTOMAKE'.  It will prevent the `PACKAGE' and `VERSION'
7109      variables to be `AC_DEFINE'd.
7111 `no-dependencies'
7112      This is similar to using `--ignore-deps' on the command line, but
7113      is useful for those situations where you don't have the necessary
7114      bits to make automatic dependency tracking work (*note
7115      Dependencies::).  In this case the effect is to effectively
7116      disable automatic dependency tracking.
7118 `no-dist'
7119      Don't emit any code related to `dist' target.  This is useful when
7120      a package has its own method for making distributions.
7122 `no-dist-gzip'
7123      Do not hook `dist-gzip' to `dist'.  
7125 `no-exeext'
7126      If your `Makefile.am' defines a rule for target `foo', it will
7127      override a rule for a target named `foo$(EXEEXT)'.  This is
7128      necessary when `EXEEXT' is found to be empty.  However, by default
7129      automake will generate an error for this use.  The `no-exeext'
7130      option will disable this error.  This is intended for use only
7131      where it is known in advance that the package will not be ported
7132      to Windows, or any other operating system using extensions on
7133      executables.
7135 `no-installinfo'
7136      The generated `Makefile.in' will not cause info pages to be built
7137      or installed by default.  However, `info' and `install-info'
7138      targets will still be available.  This option is disallowed at
7139      `gnu' strictness and above.  
7141 `no-installman'
7142      The generated `Makefile.in' will not cause man pages to be
7143      installed by default.  However, an `install-man' target will still
7144      be available for optional installation.  This option is disallowed
7145      at `gnu' strictness and above.  
7147 `nostdinc'
7148      This option can be used to disable the standard `-I' options that
7149      are ordinarily automatically provided by Automake.
7151 `no-texinfo.tex'
7152      Don't require `texinfo.tex', even if there are texinfo files in
7153      this directory.
7155 `readme-alpha'
7156      If this release is an alpha release, and the file `README-alpha'
7157      exists, then it will be added to the distribution.  If this option
7158      is given, version numbers are expected to follow one of two forms.
7159      The first form is `MAJOR.MINOR.ALPHA', where each element is a
7160      number; the final period and number should be left off for
7161      non-alpha releases.  The second form is `MAJOR.MINORALPHA', where
7162      ALPHA is a letter; it should be omitted for non-alpha releases.
7164 `std-options'
7165      Make the `installcheck' rule check that installed scripts and
7166      programs support the `--help' and `--version' options.  This also
7167      provides a basic check that the program's run-time dependencies
7168      are satisfied after installation.
7170      In a few situations, programs (or scripts) have to be exempted
7171      from this test.  For instance, `false' (from GNU sh-utils) is never
7172      successful, even for `--help' or `--version'.  You can list such
7173      programs in the variable `AM_INSTALLCHECK_STD_OPTIONS_EXEMPT'.
7174      Programs (not scripts) listed in this variable should be suffixed
7175      by `$(EXEEXT)' for the sake of Win32 or OS/2.  For instance,
7176      suppose we build `false' as a program but `true.sh' as a script,
7177      and that neither of them support `--help' or `--version':
7179           AUTOMAKE_OPTIONS = std-options
7180           bin_PROGRAMS = false ...
7181           bin_SCRIPTS = true.sh ...
7182           AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false$(EXEEXT) true.sh
7184 `subdir-objects'
7185      If this option is specified, then objects are placed into the
7186      subdirectory of the build directory corresponding to the
7187      subdirectory of the source file.  For instance, if the source file
7188      is `subdir/file.cxx', then the output file would be
7189      `subdir/file.o'.
7191      In order to use this option with C sources, you should add
7192      `AM_PROG_CC_C_O' to `configure.ac'.
7194 `tar-v7'
7195 `tar-ustar'
7196 `tar-pax'
7197      These three mutually exclusive options select the tar format to use
7198      when generating tarballs with `make dist'.  (The tar file created
7199      is then compressed according to the set of `no-dist-gzip',
7200      `dist-bzip2' and `dist-tarZ' options in use.)
7202      These options must be passed as argument to `AM_INIT_AUTOMAKE'
7203      (*note Macros::) because they can require additional configure
7204      checks.  Automake will complain if it sees such options in an
7205      `AUTOMAKE_OPTIONS' variable.
7207      `tar-v7' selects the old V7 tar format.  This is the historical
7208      default.  This antiquated format is understood by all tar
7209      implementations and supports file names with up to 99 characters.
7210      When given longer file names some tar implementations will
7211      diagnose the problem while other will generate broken tarballs or
7212      use non-portable extensions.  Furthermore, the V7 format cannot
7213      store empty directories.  When using this format, consider using
7214      the `filename-length-max=99' option to catch file names too long.
7216      `tar-ustar' selects the ustar format defined by POSIX 1003.1-1988.
7217      This format is believed to be old enough to be portable.  It
7218      fully supports empty directories.  It can store file names with up
7219      to 256 characters, provided that the file name can be split at
7220      directory separator in two parts, first of them being at most 155
7221      bytes long.  So, in most cases the maximum file name length will be
7222      shorter than 256 characters.  However you may run against broken
7223      tar implementations that incorrectly handle file names longer than
7224      99 characters (please report them to <bug-automake@gnu.org> so we
7225      can document this accurately).
7227      `tar-pax' selects the new pax interchange format defined by POSIX
7228      1003.1-2001.  It does not limit the length of file names.  However,
7229      this format is very young and should probably be restricted to
7230      packages that target only very modern platforms.  There are moves
7231      to change the pax format in an upward-compatible way, so this
7232      option may refer to a more recent version in the future.
7234      *Note Controlling the Archive Format: (tar)Formats, for further
7235      discussion about tar formats.
7237      `configure' knows several ways to construct these formats.  It
7238      will not abort if it cannot find a tool up to the task (so that the
7239      package can still be built), but `make dist' will fail.
7241 VERSION
7242      A version number (e.g., `0.30') can be specified.  If Automake is
7243      not newer than the version specified, creation of the `Makefile.in'
7244      will be suppressed.
7246 `-WCATEGORY' or `--warnings=CATEGORY'
7247      These options behave exactly like their command-line counterpart
7248      (*note Invoking Automake::).  This allows you to enable or disable
7249      some warning categories on a per-file basis.  You can also setup
7250      some warnings for your entire project; for instance, try
7251      `AM_INIT_AUTOMAKE([-Wall])' in your `configure.ac'.
7254    Unrecognized options are diagnosed by `automake'.
7256    If you want an option to apply to all the files in the tree, you can
7257 use the `AM_INIT_AUTOMAKE' macro in `configure.ac'.  *Note Macros::.
7259 \x1f
7260 File: automake.info,  Node: Miscellaneous,  Next: Include,  Prev: Options,  Up: Top
7262 18 Miscellaneous Rules
7263 **********************
7265 There are a few rules and variables that didn't fit anywhere else.
7267 * Menu:
7269 * Tags::                        Interfacing to etags and mkid
7270 * Suffixes::                    Handling new file extensions
7271 * Multilibs::                   Support for multilibs.
7273 \x1f
7274 File: automake.info,  Node: Tags,  Next: Suffixes,  Up: Miscellaneous
7276 18.1 Interfacing to `etags'
7277 ===========================
7279 Automake will generate rules to generate `TAGS' files for use with GNU
7280 Emacs under some circumstances.
7282    If any C, C++ or Fortran 77 source code or headers are present, then
7283 `tags' and `TAGS' rules will be generated for the directory.  All files
7284 listed using the `_SOURCES', `_HEADERS', and `_LISP' primaries will be
7285 used to generate tags.  Note that generated source files that are not
7286 distributed must be declared in variables like `nodist_noinst_HEADERS'
7287 or `nodist_PROG_SOURCES' or they will be ignored.
7289    A `tags' rule will be output at the topmost directory of a
7290 multi-directory package.  When run from this topmost directory, `make
7291 tags' will generate a `TAGS' file that includes by reference all `TAGS'
7292 files from subdirectories.
7294    The `tags' rule will also be generated if the variable `ETAGS_ARGS'
7295 is defined.  This variable is intended for use in directories that
7296 contain taggable source that `etags' does not understand.  The user can
7297 use the `ETAGSFLAGS' to pass additional flags to `etags';
7298 `AM_ETAGSFLAGS' is also available for use in `Makefile.am'.  
7300    Here is how Automake generates tags for its source, and for nodes in
7301 its Texinfo file:
7303      ETAGS_ARGS = automake.in --lang=none \
7304       --regex='/^@node[ \t]+\([^,]+\)/\1/' automake.texi
7306    If you add file names to `ETAGS_ARGS', you will probably also want
7307 to define `TAGS_DEPENDENCIES'.  The contents of this variable are added
7308 directly to the dependencies for the `tags' rule.  
7310    Automake also generates a `ctags' rule that can be used to build
7311 `vi'-style `tags' files.  The variable `CTAGS' is the name of the
7312 program to invoke (by default `ctags'); `CTAGSFLAGS' can be used by the
7313 user to pass additional flags, and `AM_CTAGSFLAGS' can be used by the
7314 `Makefile.am'.
7316    Automake will also generate an `ID' rule that will run `mkid' on the
7317 source.  This is only supported on a directory-by-directory basis.  
7319    Finally, Automake also emit rules to support the GNU Global Tags
7320 program (http://www.gnu.org/software/global/).  The `GTAGS' rule runs
7321 Global Tags and puts the result in the top build directory.  The
7322 variable `GTAGS_ARGS' holds arguments that are passed to `gtags'.