* doc/automake.texi (Flag Variables Ordering): New section.
[automake.git] / doc / automake.texi
blobf08867ed9ef8d5e3d435f1cfa4f74d04a0c5740a
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename automake.info
4 @settitle automake
5 @setchapternewpage off
6 @c %**end of header
8 @include version.texi
10 @copying
12 This manual is for @acronym{GNU} Automake (version @value{VERSION},
13 @value{UPDATED}), a program which creates GNU standards-compliant
14 Makefiles from template files.
16 Copyright @copyright{} 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
17 2003, 2004 Free Software Foundation, Inc.
19 @quotation
20 Permission is granted to copy, distribute and/or modify this document
21 under the terms of the @acronym{GNU} Free Documentation License,
22 Version 1.1 or any later version published by the Free Software
23 Foundation; with no Invariant Sections, with the Front-Cover texts
24 being ``A @acronym{GNU} Manual,'' and with the Back-Cover Texts as in
25 (a) below.  A copy of the license is included in the section entitled
26 ``@acronym{GNU} Free Documentation License.''
28 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and
29 modify this @acronym{GNU} Manual, like @acronym{GNU} software.  Copies
30 published by the Free Software Foundation raise funds for
31 @acronym{GNU} development.''
32 @end quotation
33 @end copying
35 @dircategory Software development
36 @direntry
37 * automake: (automake).         Making Makefile.in's.
38 @end direntry
40 @dircategory Individual utilities
41 @direntry
42 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4.
43 @end direntry
45 @titlepage
46 @title GNU Automake
47 @subtitle For version @value{VERSION}, @value{UPDATED}
48 @author David MacKenzie
49 @author Tom Tromey
50 @author Alexandre Duret-Lutz
51 @page
52 @vskip 0pt plus 1filll
53 @insertcopying
54 @end titlepage
56 @c Define an index of configure output variables.
57 @defcodeindex ov
58 @c Define an index of configure variables.
59 @defcodeindex cv
60 @c Define an index of options.
61 @defcodeindex op
62 @c Define an index of targets.
63 @defcodeindex tr
64 @c Define an index of commands.
65 @defcodeindex cm
67 @c Put the macros and variables into their own index.
68 @c @syncodeindex fn cp
69 @syncodeindex ov vr
70 @syncodeindex cv vr
71 @syncodeindex fn vr
73 @c Put everything else into one index (arbitrarily chosen to be the concept index).
74 @syncodeindex op cp
75 @syncodeindex tr cp
76 @syncodeindex cm cp
78 @ifnottex
79 @node Top
80 @comment  node-name,  next,  previous,  up
81 @top GNU Automake
83 @insertcopying
85 @menu
86 * Introduction::                Automake's purpose
87 * Generalities::                General ideas
88 * Examples::                    Some example packages
89 * Invoking Automake::           Creating a Makefile.in
90 * configure::                   Scanning configure.ac or configure.in
91 * Directories::                 Declaring subdirectories
92 * Programs::                    Building programs and libraries
93 * Other objects::               Other derived objects
94 * Other GNU Tools::             Other GNU Tools
95 * Documentation::               Building documentation
96 * Install::                     What gets installed
97 * Clean::                       What gets cleaned
98 * Dist::                        What goes in a distribution
99 * Tests::                       Support for test suites
100 * Rebuilding::                  Automatic rebuilding of Makefile
101 * Options::                     Changing Automake's behavior
102 * Miscellaneous::               Miscellaneous rules
103 * Include::                     Including extra files in an Automake template.
104 * Conditionals::                Conditionals
105 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
106 * Cygnus::                      The effect of @code{--cygnus}
107 * Not Enough::                  When Automake is not Enough
108 * Distributing::                Distributing the Makefile.in
109 * API versioning::              About compatibility between Automake versions
110 * Upgrading::                   Upgrading to a Newer Automake Version
111 * FAQ::                         Frequently Asked Questions
112 * History::                     Notes about the history of Automake
113 * Copying This Manual::         How to make copies of this manual
114 * Indices::                     Indices of variables, macros, and concepts
116 @detailmenu
117  --- The Detailed Node Listing ---
119 General ideas
121 * General Operation::           General operation of Automake
122 * Strictness::                  Standards conformance checking
123 * Uniform::                     The Uniform Naming Scheme
124 * Canonicalization::            How derived variables are named
125 * User Variables::              Variables reserved for the user
126 * Auxiliary Programs::          Programs automake might require
128 Some example packages
130 * Complete::                    A simple example, start to finish
131 * Hello::                       A classic program
132 * true::                        Building true and false
134 Scanning @file{configure.ac}
136 * Requirements::                Configuration requirements
137 * Optional::                    Other things Automake recognizes
138 * Invoking aclocal::            Auto-generating aclocal.m4
139 * aclocal options::             aclocal command line arguments
140 * Macro search path::           Modifying aclocal's search path
141 * Macros::                      Autoconf macros supplied with Automake
142 * Extending aclocal::           Writing your own aclocal macros
143 * Local Macros::                Organizing local macros
144 * Future of aclocal::           aclocal's scheduled death
146 Auto-generating aclocal.m4
148 * aclocal options::             Options supported by aclocal
149 * Macro search path::           How aclocal finds .m4 files
151 Autoconf macros supplied with Automake
153 * Public macros::               Macros that you can use.
154 * Private macros::              Macros that you should not use.
156 Directories
158 * Subdirectories::              Building subdirectories recursively
159 * Conditional Subdirectories::  Conditionally not building directories
160 * Alternative::                 Subdirectories without recursion
161 * Subpackages::                 Nesting packages
163 Building Programs and Libraries
165 * A Program::                   Building a program
166 * A Library::                   Building a library
167 * A Shared Library::            Building a Libtool library
168 * Program and Library Variables::  Variables controlling program and
169                                 library builds
170 * Default _SOURCES::            Default source files
171 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
172 * Program variables::           Variables used when building a program
173 * Yacc and Lex::                Yacc and Lex support
174 * C++ Support::                 Compiling C++ sources
175 * Assembly Support::            Compiling assembly sources
176 * Fortran 77 Support::          Compiling Fortran 77 sources
177 * Fortran 9x Support::          Compiling Fortran 9x sources
178 * Java Support::                Compiling Java sources
179 * Support for Other Languages::  Compiling other languages
180 * ANSI::                        Automatic de-ANSI-fication
181 * Dependencies::                Automatic dependency tracking
182 * EXEEXT::                      Support for executable extensions
184 Building a program
186 * Program Sources::             Defining program sources
187 * Linking::                     Linking with libraries or extra objects
188 * Conditional Sources::         Handling conditional sources
189 * Conditional Programs::        Building program conditionally
191 Building a Shared Library
193 * Libtool Concept::             Introducing Libtool
194 * Libtool Libraries::           Declaring Libtool Libraries
195 * Conditional Libtool Libraries::  Building Libtool Libraries Conditionally
196 * Conditional Libtool Sources::  Choosing Library Sources Conditionally
197 * Libtool Convenience Libraries::  Building Convenience Libtool Libraries
198 * Libtool Modules::             Building Libtool Modules
199 * Libtool Flags::               Using _LIBADD and _LDFLAGS
200 * LTLIBOBJS::                   Using $(LTLIBOBJS) and $(LTALLOCA)
201 * Libtool Issues::              Common Issues Related to Libtool's Use
203 Fortran 77 Support
205 * Preprocessing Fortran 77::    Preprocessing Fortran 77 sources
206 * Compiling Fortran 77 Files::  Compiling Fortran 77 sources
207 * Mixing Fortran 77 With C and C++::  Mixing Fortran 77 With C and C++
209 Mixing Fortran 77 With C and C++
211 * How the Linker is Chosen::    Automatic linker selection
213 Fortran 9x Support
215 * Compiling Fortran 9x Files::  Compiling Fortran 9x sources
217 Other Derived Objects
219 * Scripts::                     Executable scripts
220 * Headers::                     Header files
221 * Data::                        Architecture-independent data files
222 * Sources::                     Derived sources
224 Built sources
226 * Built sources example::       Several ways to handle built sources.
228 Other GNU Tools
230 * Emacs Lisp::                  Emacs Lisp
231 * gettext::                     Gettext
232 * Libtool::                     Libtool
233 * Java::                        Java
234 * Python::                      Python
236 Building documentation
238 * Texinfo::                     Texinfo
239 * Man pages::                   Man pages
241 Miscellaneous Rules
243 * Tags::                        Interfacing to etags and mkid
244 * Suffixes::                    Handling new file extensions
245 * Multilibs::                   Support for multilibs.
247 When Automake Isn't Enough
249 * Extending::                   Adding new rules or overriding existing ones.
250 * Third-Party Makefiles::       Integrating Non-Automake @file{Makefile}s.
252 Frequently Asked Questions about Automake
254 * CVS::                         CVS and generated files
255 * maintainer-mode::             missing and AM_MAINTAINER_MODE
256 * wildcards::                   Why doesn't Automake support wildcards?
257 * distcleancheck::              Files left in build directory after distclean
258 * Flag Variables Ordering::     CFLAGS vs. AM_CFLAGS vs. mumble_CFLAGS
259 * renamed objects::             Why are object files sometimes renamed?
260 * Multiple Outputs::            Writing rules for tools with many output files
262 History of Automake
264 * Timeline::                    The Automake story.
265 * Dependency Tracking Evolution::  Evolution of Automatic Dependency Tracking
266 * Releases::                    Statistics about Automake Releases
268 Copying This Manual
270 * GNU Free Documentation License::  License for copying this manual
272 Indices
274 * Macro and Variable Index::    Index of Autoconf macros and Automake variables
275 * General Index::               General index
277 @end detailmenu
278 @end menu
280 @end ifnottex
283 @node Introduction
284 @chapter Introduction
286 Automake is a tool for automatically generating @file{Makefile.in}s from
287 files called @file{Makefile.am}.  Each @file{Makefile.am} is basically a
288 series of @code{make} variable definitions@footnote{These variables are
289 also called @dfn{make macros} in Make terminology, however in this
290 manual we reserve the term @dfn{macro} for Autoconf's macros.}, with
291 rules being thrown in occasionally.  The generated @file{Makefile.in}s
292 are compliant with the GNU Makefile standards.
294 @cindex GNU Makefile standards
296 The GNU Makefile Standards Document
297 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
298 is long, complicated, and subject to change.  The goal of Automake is to
299 remove the burden of Makefile maintenance from the back of the
300 individual GNU maintainer (and put it on the back of the Automake
301 maintainer).
303 The typical Automake input file is simply a series of variable definitions.
304 Each such file is processed to create a @file{Makefile.in}.  There
305 should generally be one @file{Makefile.am} per directory of a project.
307 @cindex Constraints of Automake
308 @cindex Automake constraints
310 Automake does constrain a project in certain ways; for instance it
311 assumes that the project uses Autoconf (@pxref{Top, , Introduction,
312 autoconf, The Autoconf Manual}), and enforces certain restrictions on
313 the @file{configure.ac} contents@footnote{Older Autoconf versions used
314 @file{configure.in}.  Autoconf 2.50 and greater promotes
315 @file{configure.ac} over @file{configure.in}.  The rest of this
316 documentation will refer to @file{configure.ac}, but Automake also
317 supports @file{configure.in} for backward compatibility.}.
319 @cindex Automake requirements
320 @cindex Requirements, Automake
322 Automake requires @code{perl} in order to generate the
323 @file{Makefile.in}s.  However, the distributions created by Automake are
324 fully GNU standards-compliant, and do not require @code{perl} in order
325 to be built.
327 @cindex BUGS, reporting
328 @cindex Reporting BUGS
329 @cindex E-mail, bug reports
331 Mail suggestions and bug reports for Automake to
332 @email{bug-automake@@gnu.org}.
335 @node Generalities
336 @chapter General ideas
338 The following sections cover a few basic ideas that will help you
339 understand how Automake works.
341 @menu
342 * General Operation::           General operation of Automake
343 * Strictness::                  Standards conformance checking
344 * Uniform::                     The Uniform Naming Scheme
345 * Canonicalization::            How derived variables are named
346 * User Variables::              Variables reserved for the user
347 * Auxiliary Programs::          Programs automake might require
348 @end menu
351 @node General Operation
352 @section General Operation
354 Automake works by reading a @file{Makefile.am} and generating a
355 @file{Makefile.in}.  Certain variables and rules defined in the
356 @file{Makefile.am} instruct Automake to generate more specialized code;
357 for instance, a @samp{bin_PROGRAMS} variable definition will cause rules
358 for compiling and linking programs to be generated.
360 @cindex Non-standard targets
361 @cindex cvs-dist, non-standard example
362 @trindex cvs-dist
364 The variable definitions and rules in the @file{Makefile.am} are
365 copied verbatim into the generated file.  This allows you to add
366 arbitrary code into the generated @file{Makefile.in}.  For instance
367 the Automake distribution includes a non-standard rule for the
368 @code{cvs-dist} target, which the Automake maintainer uses to make
369 distributions from his source control system.
371 @cindex GNU make extensions
373 Note that most GNU make extensions are not recognized by Automake.  Using
374 such extensions in a @file{Makefile.am} will lead to errors or confusing
375 behavior.
377 @cindex Append operator
378 A special exception is that the GNU make append operator, @samp{+=}, is
379 supported.  This operator appends its right hand argument to the variable
380 specified on the left.  Automake will translate the operator into
381 an ordinary @samp{=} operator; @samp{+=} will thus work with any make program.
383 Automake tries to keep comments grouped with any adjoining rules or
384 variable definitions.
386 @cindex Make targets, overriding
387 @cindex Make rules, overriding
388 @cindex Overriding make rules
389 @cindex Overriding make targets
391 A rule defined in @file{Makefile.am} generally overrides any such
392 rule of a similar name that would be automatically generated by
393 @code{automake}.  Although this is a supported feature, it is generally
394 best to avoid making use of it, as sometimes the generated rules are
395 very particular.
397 @cindex Variables, overriding
398 @cindex Overriding make variables
400 Similarly, a variable defined in @file{Makefile.am} or
401 @code{AC_SUBST}'ed from @file{configure.ac} will override any
402 definition of the variable that @code{automake} would ordinarily
403 create.  This feature is more often useful than the ability to
404 override a rule.  Be warned that many of the variables generated by
405 @code{automake} are considered to be for internal use only, and their
406 names might change in future releases.
408 @cindex Recursive operation of Automake
409 @cindex Automake, recursive operation
410 @cindex Example of recursive operation
412 When examining a variable definition, Automake will recursively examine
413 variables referenced in the definition.  For example, if Automake is
414 looking at the content of @code{foo_SOURCES} in this snippet
416 @example
417 xs = a.c b.c
418 foo_SOURCES = c.c $(xs)
419 @end example
421 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
422 contents of @code{foo_SOURCES}.
424 @cindex ## (special Automake comment)
425 @cindex Special Automake comment
426 @cindex Comment, special to Automake
428 Automake also allows a form of comment which is @emph{not} copied into
429 the output; all lines beginning with @samp{##} (leading spaces allowed)
430 are completely ignored by Automake.
432 It is customary to make the first line of @file{Makefile.am} read:
434 @cindex Makefile.am, first line
435 @cindex First line of Makefile.am
437 @example
438 ## Process this file with automake to produce Makefile.in
439 @end example
441 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
442 @c I don't know quite what to say.
444 @c FIXME document customary ordering of Makefile.am here!
447 @node Strictness
448 @section Strictness
450 @cindex Non-GNU packages
452 While Automake is intended to be used by maintainers of GNU packages, it
453 does make some effort to accommodate those who wish to use it, but do
454 not want to use all the GNU conventions.
456 @cindex Strictness, defined
457 @cindex Strictness, foreign
458 @cindex foreign strictness
459 @cindex Strictness, gnu
460 @cindex gnu strictness
461 @cindex Strictness, gnits
462 @cindex gnits strictness
464 To this end, Automake supports three levels of @dfn{strictness}---the
465 strictness indicating how stringently Automake should check standards
466 conformance.
468 The valid strictness levels are:
470 @table @samp
471 @item foreign
472 Automake will check for only those things which are absolutely
473 required for proper operations.  For instance, whereas GNU standards
474 dictate the existence of a @file{NEWS} file, it will not be required in
475 this mode.  The name comes from the fact that Automake is intended to be
476 used for GNU programs; these relaxed rules are not the standard mode of
477 operation.
479 @item gnu
480 Automake will check---as much as possible---for compliance to the GNU
481 standards for packages.  This is the default.
483 @item gnits
484 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
485 standards}.  These are based on the GNU standards, but are even more
486 detailed.  Unless you are a Gnits standards contributor, it is
487 recommended that you avoid this option until such time as the Gnits
488 standard is actually published (which may never happen).
489 @end table
491 For more information on the precise implications of the strictness
492 level, see @ref{Gnits}.
494 Automake also has a special ``cygnus'' mode which is similar to
495 strictness but handled differently.  This mode is useful for packages
496 which are put into a ``Cygnus'' style tree (e.g., the GCC tree).  For
497 more information on this mode, see @ref{Cygnus}.
500 @node Uniform
501 @section The Uniform Naming Scheme
503 @cindex Uniform naming scheme
505 Automake variables generally follow a @dfn{uniform naming scheme} that
506 makes it easy to decide how programs (and other derived objects) are
507 built, and how they are installed.  This scheme also supports
508 @code{configure} time determination of what should be built.
510 @cindex _PROGRAMS primary variable
511 @cindex PROGRAMS primary variable
512 @cindex Primary variable, PROGRAMS
513 @cindex Primary variable, defined
515 At @code{make} time, certain variables are used to determine which
516 objects are to be built.  The variable names are made of several pieces
517 which are concatenated together.
519 The piece which tells automake what is being built is commonly called
520 the @dfn{primary}.  For instance, the primary @code{PROGRAMS} holds a
521 list of programs which are to be compiled and linked.
522 @vindex PROGRAMS
524 @cindex pkglibdir, defined
525 @cindex pkgincludedir, defined
526 @cindex pkgdatadir, defined
528 @vindex pkglibdir
529 @vindex pkgincludedir
530 @vindex pkgdatadir
532 A different set of names is used to decide where the built objects
533 should be installed.  These names are prefixes to the primary which
534 indicate which standard directory should be used as the installation
535 directory.  The standard directory names are given in the GNU standards
536 (@pxref{Directory Variables, , , standards, The GNU Coding Standards}).
537 Automake extends this list with @code{pkglibdir}, @code{pkgincludedir},
538 and @code{pkgdatadir}; these are the same as the non-@samp{pkg}
539 versions, but with @samp{$(PACKAGE)} appended.  For instance,
540 @code{pkglibdir} is defined as @code{$(libdir)/$(PACKAGE)}.
541 @cvindex PACKAGE, directory
543 @cindex EXTRA_, prepending
545 For each primary, there is one additional variable named by prepending
546 @samp{EXTRA_} to the primary name.  This variable is used to list
547 objects which may or may not be built, depending on what
548 @code{configure} decides.  This variable is required because Automake
549 must statically know the entire list of objects that may be built in
550 order to generate a @file{Makefile.in} that will work in all cases.
552 @cindex EXTRA_PROGRAMS, defined
553 @cindex Example, EXTRA_PROGRAMS
554 @cindex cpio example
556 For instance, @code{cpio} decides at configure time which programs are
557 built.  Some of the programs are installed in @code{bindir}, and some
558 are installed in @code{sbindir}:
560 @example
561 EXTRA_PROGRAMS = mt rmt
562 bin_PROGRAMS = cpio pax
563 sbin_PROGRAMS = $(MORE_PROGRAMS)
564 @end example
566 Defining a primary without a prefix as a variable, e.g.,
567 @code{PROGRAMS}, is an error.
569 Note that the common @samp{dir} suffix is left off when constructing the
570 variable names; thus one writes @samp{bin_PROGRAMS} and not
571 @samp{bindir_PROGRAMS}.
573 Not every sort of object can be installed in every directory.  Automake
574 will flag those attempts it finds in error.
575 Automake will also diagnose obvious misspellings in directory names.
577 @cindex Extending list of installation directories
578 @cindex Installation directories, extending list
580 Sometimes the standard directories---even as augmented by Automake---
581 are not enough.  In particular it is sometimes useful, for clarity, to
582 install objects in a subdirectory of some predefined directory.  To this
583 end, Automake allows you to extend the list of possible installation
584 directories.  A given prefix (e.g. @samp{zar}) is valid if a variable of
585 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
587 @cindex HTML installation, example
589 For instance, installation of HTML files is part of Automake, you could
590 use this to install raw HTML documentation:
592 @example
593 htmldir = $(prefix)/html
594 html_DATA = automake.html
595 @end example
597 @cindex noinst primary prefix, definition
599 The special prefix @samp{noinst} indicates that the objects in question
600 should be built but not installed at all.  This is usually used for
601 objects required to build the rest of your package, for instance static
602 libraries (@pxref{A Library}), or helper scripts.
604 @cindex check primary prefix, definition
606 The special prefix @samp{check} indicates that the objects in question
607 should not be built until the @code{make check} command is run.  Those
608 objects are not installed either.
610 The current primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
611 @samp{LISP}, @samp{PYTHON}, @samp{JAVA}, @samp{SCRIPTS}, @samp{DATA},
612 @samp{HEADERS}, @samp{MANS}, and @samp{TEXINFOS}.
613 @vindex PROGRAMS
614 @vindex LIBRARIES
615 @vindex LISP
616 @vindex PYTHON
617 @vindex JAVA
618 @vindex SCRIPTS
619 @vindex DATA
620 @vindex HEADERS
621 @vindex MANS
622 @vindex TEXINFOS
624 Some primaries also allow additional prefixes which control other
625 aspects of @code{automake}'s behavior.  The currently defined prefixes
626 are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
627 are explained later (@pxref{Program and Library Variables}).
630 @node Canonicalization
631 @section How derived variables are named
633 @cindex canonicalizing Automake variables
635 Sometimes a Makefile variable name is derived from some text the
636 maintainer supplies.  For instance, a program name listed in
637 @samp{_PROGRAMS} is rewritten into the name of a @samp{_SOURCES}
638 variable.  In cases like this, Automake canonicalizes the text, so that
639 program names and the like do not have to follow Makefile variable naming
640 rules.  All characters in the name except for letters, numbers, the
641 strudel (@@), and the underscore are turned into underscores when making
642 variable references.
644 For example, if your program is named @code{sniff-glue}, the derived
645 variable name would be @code{sniff_glue_SOURCES}, not
646 @code{sniff-glue_SOURCES}.  Similarly the sources for a library named
647 @code{libmumble++.a} should be listed in the
648 @code{libmumble___a_SOURCES} variable.
650 The strudel is an addition, to make the use of Autoconf substitutions in
651 variable names less obfuscating.
654 @node User Variables
655 @section Variables reserved for the user
657 @cindex variables, reserved for the user
658 @cindex user variables
660 Some @code{Makefile} variables are reserved by the GNU Coding Standards
661 for the use of the ``user'' -- the person building the package.  For
662 instance, @code{CFLAGS} is one such variable.
664 Sometimes package developers are tempted to set user variables such as
665 @code{CFLAGS} because it appears to make their job easier.  However,
666 the package itself should never set a user variable, particularly not
667 to include switches which are required for proper compilation of the
668 package.  Since these variables are documented as being for the
669 package builder, that person rightfully expects to be able to override
670 any of these variables at build time.
672 To get around this problem, automake introduces an automake-specific
673 shadow variable for each user flag variable.  (Shadow variables are not
674 introduced for variables like @code{CC}, where they would make no
675 sense.)  The shadow variable is named by prepending @samp{AM_} to the
676 user variable's name.  For instance, the shadow variable for
677 @code{YFLAGS} is @code{AM_YFLAGS}.
679 @xref{Flag Variables Ordering}, for more discussion about these
680 variables and how they interact with per-target variables.
682 @node Auxiliary Programs
683 @section Programs automake might require
685 @cindex Programs, auxiliary
686 @cindex Auxiliary programs
688 Automake sometimes requires helper programs so that the generated
689 @file{Makefile} can do its work properly.  There are a fairly large
690 number of them, and we list them here.
692 @table @code
693 @item ansi2knr.c
694 @itemx ansi2knr.1
695 These two files are used by the automatic de-ANSI-fication support
696 (@pxref{ANSI}).
698 @item compile
699 This is a wrapper for compilers which don't accept both @samp{-c} and
700 @samp{-o} at the same time.  It is only used when absolutely required.
701 Such compilers are rare.
703 @item config.guess
704 @itemx config.sub
705 These programs compute the canonical triplets for the given build, host,
706 or target architecture.  These programs are updated regularly to support
707 new architectures and fix probes broken by changes in new kernel
708 versions.  You are encouraged to fetch the latest versions of these
709 files from @url{ftp://ftp.gnu.org/gnu/config/} before making a release.
711 @item depcomp
712 This program understands how to run a compiler so that it will generate
713 not only the desired output but also dependency information which is
714 then used by the automatic dependency tracking feature.
716 @item elisp-comp
717 This program is used to byte-compile Emacs Lisp code.
719 @item install-sh
720 This is a replacement for the @code{install} program which works on
721 platforms where @code{install} is unavailable or unusable.
723 @item mdate-sh
724 This script is used to generate a @file{version.texi} file.  It examines
725 a file and prints some date information about it.
727 @item missing
728 This wraps a number of programs which are typically only required by
729 maintainers.  If the program in question doesn't exist, @code{missing}
730 prints an informative warning and attempts to fix things so that the
731 build can continue.
733 @item mkinstalldirs
734 This script used to be a wrapper around @code{mkdir -p}, which is not
735 portable.  Now we use prefer to use @code{install-sh -d} when configure
736 finds that @code{mkdir -p} does not work, this makes one less script to
737 distribute.
739 For backward compatibility @code{mkinstalldirs} is still used and
740 distributed when @code{automake} finds it in a package.  But it is no
741 longer installed automatically, and it should be safe to remove it.
743 @item py-compile
744 This is used to byte-compile Python scripts.
746 @item texinfo.tex
747 Not a program, this file is required for @code{make dvi}, @code{make ps}
748 and @code{make pdf} to work when Texinfo sources are in the package.
750 @item ylwrap
751 This program wraps @code{lex} and @code{yacc} and ensures that, for
752 instance, multiple @code{yacc} instances can be invoked in a single
753 directory in parallel.
755 @end table
758 @node Examples
759 @chapter Some example packages
761 @menu
762 * Complete::                    A simple example, start to finish
763 * Hello::                       A classic program
764 * true::                        Building true and false
765 @end menu
768 @node Complete
769 @section A simple example, start to finish
771 @cindex Complete example
773 Let's suppose you just finished writing @code{zardoz}, a program to make
774 your head float from vortex to vortex.  You've been using Autoconf to
775 provide a portability framework, but your @file{Makefile.in}s have been
776 ad-hoc.  You want to make them bulletproof, so you turn to Automake.
778 @cindex AM_INIT_AUTOMAKE, example use
780 The first step is to update your @file{configure.ac} to include the
781 commands that @code{automake} needs.  The way to do this is to add an
782 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
784 @example
785 AC_INIT(zardoz, 1.0)
786 AM_INIT_AUTOMAKE
787 @dots{}
788 @end example
790 Since your program doesn't have any complicating factors (e.g., it
791 doesn't use @code{gettext}, it doesn't want to build a shared library),
792 you're done with this part.  That was easy!
794 @cindex aclocal program, introduction
795 @cindex aclocal.m4, preexisting
796 @cindex acinclude.m4, defined
798 Now you must regenerate @file{configure}.  But to do that, you'll need
799 to tell @code{autoconf} how to find the new macro you've used.  The
800 easiest way to do this is to use the @code{aclocal} program to generate
801 your @file{aclocal.m4} for you.  But wait@dots{} maybe you already have an
802 @file{aclocal.m4}, because you had to write some hairy macros for your
803 program.  The @code{aclocal} program lets you put your own macros into
804 @file{acinclude.m4}, so simply rename and then run:
806 @example
807 mv aclocal.m4 acinclude.m4
808 aclocal
809 autoconf
810 @end example
812 @cindex zardoz example
814 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
815 Since @code{zardoz} is a user program, you want to install it where the
816 rest of the user programs go: @code{bindir}.  Additionally,
817 @code{zardoz} has some Texinfo documentation.  Your @file{configure.ac}
818 script uses @code{AC_REPLACE_FUNCS}, so you need to link against
819 @samp{$(LIBOBJS)}.  So here's what you'd write:
821 @example
822 bin_PROGRAMS = zardoz
823 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
824 zardoz_LDADD = $(LIBOBJS)
826 info_TEXINFOS = zardoz.texi
827 @end example
829 Now you can run @code{automake --add-missing} to generate your
830 @file{Makefile.in} and grab any auxiliary files you might need, and
831 you're done!
834 @node Hello
835 @section A classic program
837 @cindex Example, GNU Hello
838 @cindex Hello example
839 @cindex GNU Hello, example
841 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
842 renowned for its classic simplicity and versatility.  This section shows
843 how Automake could be used with the GNU Hello package.  The examples
844 below are from the latest beta version of GNU Hello, but with all of the
845 maintainer-only code stripped out, as well as all copyright comments.
847 Of course, GNU Hello is somewhat more featureful than your traditional
848 two-liner.  GNU Hello is internationalized, does option processing, and
849 has a manual and a test suite.
851 @cindex configure.ac, from GNU Hello
852 @cindex GNU Hello, configure.ac
853 @cindex Hello, configure.ac
855 Here is the @file{configure.ac} from GNU Hello.
856 @strong{Please note:} The calls to @code{AC_INIT} and @code{AM_INIT_AUTOMAKE}
857 in this example use a deprecated syntax.  For the current approach,
858 see the description of @code{AM_INIT_AUTOMAKE} in @ref{Public macros}.
860 @c FIXME: This definitely requires an update, e.g. to GNU Hello 2.1.1.
862 @example
863 dnl Process this file with autoconf to produce a configure script.
864 AC_INIT(src/hello.c)
865 AM_INIT_AUTOMAKE(hello, 1.3.11)
866 AM_CONFIG_HEADER(config.h)
868 dnl Set of available languages.
869 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
871 dnl Checks for programs.
872 AC_PROG_CC
873 AC_ISC_POSIX
875 dnl Checks for libraries.
877 dnl Checks for header files.
878 AC_STDC_HEADERS
879 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
881 dnl Checks for library functions.
882 AC_FUNC_ALLOCA
884 dnl Check for st_blksize in struct stat
885 AC_ST_BLKSIZE
887 dnl internationalization macros
888 AM_GNU_GETTEXT
889 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
890            src/Makefile tests/Makefile tests/hello],
891    [chmod +x tests/hello])
892 @end example
894 The @samp{AM_} macros are provided by Automake (or the Gettext library);
895 the rest are standard Autoconf macros.
898 The top-level @file{Makefile.am}:
900 @example
901 EXTRA_DIST = BUGS ChangeLog.O
902 SUBDIRS = doc intl po src tests
903 @end example
905 As you can see, all the work here is really done in subdirectories.
907 The @file{po} and @file{intl} directories are automatically generated
908 using @code{gettextize}; they will not be discussed here.
910 @cindex Texinfo file handling example
911 @cindex Example, handling Texinfo files
913 In @file{doc/Makefile.am} we see:
915 @example
916 info_TEXINFOS = hello.texi
917 hello_TEXINFOS = gpl.texi
918 @end example
920 This is sufficient to build, install, and distribute the GNU Hello
921 manual.
923 @cindex Regression test example
924 @cindex Example, regression test
926 Here is @file{tests/Makefile.am}:
928 @example
929 TESTS = hello
930 EXTRA_DIST = hello.in testdata
931 @end example
933 The script @file{hello} is generated by @code{configure}, and is the
934 only test case.  @code{make check} will run this test.
936 @cindex INCLUDES, example usage
938 Last we have @file{src/Makefile.am}, where all the real work is done:
939 @c FIXME: As all the Hello World excerpts in this manual, this
940 @c shows deprecated features (here: $(INCLUDES)).
942 @example
943 bin_PROGRAMS = hello
944 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
945 hello_LDADD = $(INTLLIBS) $(ALLOCA)
946 localedir = $(datadir)/locale
947 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
948 @end example
951 @node true
952 @section Building true and false
954 @cindex Example, false and true
955 @cindex false Example
956 @cindex true Example
958 Here is another, trickier example.  It shows how to generate two
959 programs (@code{true} and @code{false}) from the same source file
960 (@file{true.c}).  The difficult part is that each compilation of
961 @file{true.c} requires different @code{cpp} flags.
963 @example
964 bin_PROGRAMS = true false
965 false_SOURCES =
966 false_LDADD = false.o
968 true.o: true.c
969         $(COMPILE) -DEXIT_CODE=0 -c true.c
971 false.o: true.c
972         $(COMPILE) -DEXIT_CODE=1 -o false.o -c true.c
973 @end example
975 Note that there is no @code{true_SOURCES} definition.  Automake will
976 implicitly assume that there is a source file named @file{true.c}, and
977 define rules to compile @file{true.o} and link @file{true}.  The
978 @code{true.o: true.c} rule supplied by the above @file{Makefile.am},
979 will override the Automake generated rule to build @file{true.o}.
981 @code{false_SOURCES} is defined to be empty---that way no implicit value
982 is substituted.  Because we have not listed the source of
983 @file{false}, we have to tell Automake how to link the program.  This is
984 the purpose of the @code{false_LDADD} line.  A @code{false_DEPENDENCIES}
985 variable, holding the dependencies of the @file{false} target will be
986 automatically generated by Automake from the content of
987 @code{false_LDADD}.
989 The above rules won't work if your compiler doesn't accept both
990 @samp{-c} and @samp{-o}.  The simplest fix for this is to introduce a
991 bogus dependency (to avoid problems with a parallel @code{make}):
993 @example
994 true.o: true.c false.o
995         $(COMPILE) -DEXIT_CODE=0 -c true.c
997 false.o: true.c
998         $(COMPILE) -DEXIT_CODE=1 -c true.c && mv true.o false.o
999 @end example
1001 Also, these explicit rules do not work if the de-ANSI-fication feature
1002 is used (@pxref{ANSI}).  Supporting de-ANSI-fication requires a little
1003 more work:
1005 @example
1006 true_.o: true_.c false_.o
1007         $(COMPILE) -DEXIT_CODE=0 -c true_.c
1009 false_.o: true_.c
1010         $(COMPILE) -DEXIT_CODE=1 -c true_.c && mv true_.o false_.o
1011 @end example
1013 As it turns out, there is also a much easier way to do this same task.
1014 Some of the above techniques are useful enough that we've kept the
1015 example in the manual.  However if you were to build @code{true} and
1016 @code{false} in real life, you would probably use per-program
1017 compilation flags, like so:
1019 @example
1020 bin_PROGRAMS = false true
1022 false_SOURCES = true.c
1023 false_CPPFLAGS = -DEXIT_CODE=1
1025 true_SOURCES = true.c
1026 true_CPPFLAGS = -DEXIT_CODE=0
1027 @end example
1029 In this case Automake will cause @file{true.c} to be compiled twice,
1030 with different flags.  De-ANSI-fication will work automatically.  In
1031 this instance, the names of the object files would be chosen by
1032 automake; they would be @file{false-true.o} and @file{true-true.o}.
1033 (The name of the object files rarely matters.)
1036 @node Invoking Automake
1037 @chapter Creating a @file{Makefile.in}
1039 @cindex Multiple configure.ac files
1040 @cindex Invoking Automake
1041 @cindex Automake, invoking
1043 To create all the @file{Makefile.in}s for a package, run the
1044 @code{automake} program in the top level directory, with no arguments.
1045 @code{automake} will automatically find each appropriate
1046 @file{Makefile.am} (by scanning @file{configure.ac}; @pxref{configure})
1047 and generate the corresponding @file{Makefile.in}.  Note that
1048 @code{automake} has a rather simplistic view of what constitutes a
1049 package; it assumes that a package has only one @file{configure.ac}, at
1050 the top.  If your package has multiple @file{configure.ac}s, then you
1051 must run @code{automake} in each directory holding a
1052 @file{configure.ac}.  (Alternatively, you may rely on Autoconf's
1053 @code{autoreconf}, which is able to recurse your package tree and run
1054 @code{automake} where appropriate.)
1056 You can optionally give @code{automake} an argument; @file{.am} is
1057 appended to the argument and the result is used as the name of the input
1058 file.  This feature is generally only used to automatically rebuild an
1059 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
1060 be run from the topmost directory of a project, even if being used to
1061 regenerate the @file{Makefile.in} in some subdirectory.  This is
1062 necessary because @code{automake} must scan @file{configure.ac}, and
1063 because @code{automake} uses the knowledge that a @file{Makefile.in} is
1064 in a subdirectory to change its behavior in some cases.
1066 @vindex AUTOCONF
1067 Automake will run @code{autoconf} to scan @file{configure.ac} and its
1068 dependencies (@file{aclocal.m4}), therefore @code{autoconf} must be in
1069 your @code{PATH}.  If there is an @code{AUTOCONF} variable in your
1070 environment it will be used instead of @code{autoconf}, this allows you
1071 to select a particular version of Autoconf.  By the way, don't
1072 misunderstand this paragraph: Automake runs @code{autoconf} to
1073 @strong{scan} your @file{configure.ac}, this won't build
1074 @file{configure} and you still have to run @code{autoconf} yourself for
1075 this purpose.
1077 @cindex Automake options
1078 @cindex Options, Automake
1079 @cindex Strictness, command line
1081 @code{automake} accepts the following options:
1083 @cindex Extra files distributed with Automake
1084 @cindex Files distributed with Automake
1085 @cindex config.guess
1087 @table @samp
1088 @item -a
1089 @itemx --add-missing
1090 @opindex -a
1091 @opindex --add-missing
1092 Automake requires certain common files to exist in certain situations;
1093 for instance @file{config.guess} is required if @file{configure.ac} runs
1094 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
1095 files (@pxref{Auxiliary Programs}); this option will cause the missing
1096 ones to be automatically added to the package, whenever possible.  In
1097 general if Automake tells you a file is missing, try using this option.
1098 By default Automake tries to make a symbolic link pointing to its own
1099 copy of the missing file; this can be changed with @code{--copy}.
1101 Many of the potentially-missing files are common scripts whose
1102 location may be specified via the @code{AC_CONFIG_AUX_DIR} macro.
1103 Therefore, @code{AC_CONFIG_AUX_DIR}'s setting affects whether a
1104 file is considered missing, and where the missing file is added
1105 (@pxref{Optional}).
1107 @item --libdir=@var{dir}
1108 @opindex --libdir
1109 Look for Automake data files in directory @var{dir} instead of in the
1110 installation directory.  This is typically used for debugging.
1112 @item -c
1113 @opindex -c
1114 @itemx --copy
1115 @opindex --copy
1116 When used with @code{--add-missing}, causes installed files to be
1117 copied.  The default is to make a symbolic link.
1119 @item --cygnus
1120 @opindex --cygnus
1121 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
1122 of GNU or Gnits rules.  For more information, see @ref{Cygnus}.
1124 @item -f
1125 @opindex -f
1126 @itemx --force-missing
1127 @opindex --force-missing
1128 When used with @code{--add-missing}, causes standard files to be reinstalled
1129 even if they already exist in the source tree.  This involves removing
1130 the file from the source tree before creating the new symlink (or, with
1131 @code{--copy}, copying the new file).
1133 @item --foreign
1134 @opindex --foreign
1135 Set the global strictness to @samp{foreign}.  For more information, see
1136 @ref{Strictness}.
1138 @item --gnits
1139 @opindex --gnits
1140 Set the global strictness to @samp{gnits}.  For more information, see
1141 @ref{Gnits}.
1143 @item --gnu
1144 @opindex --gnu
1145 Set the global strictness to @samp{gnu}.  For more information, see
1146 @ref{Gnits}.  This is the default strictness.
1148 @item --help
1149 @opindex --help
1150 Print a summary of the command line options and exit.
1152 @item -i
1153 @itemx --ignore-deps
1154 @opindex -i
1155 This disables the dependency tracking feature in generated
1156 @file{Makefile}s; see @ref{Dependencies}.
1158 @item --include-deps
1159 @opindex --include-deps
1160 This enables the dependency tracking feature.  This feature is enabled
1161 by default.  This option is provided for historical reasons only and
1162 probably should not be used.
1164 @item --no-force
1165 @opindex --no-force
1166 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
1167 @file{configure.ac}.  This option causes it to only update those
1168 @file{Makefile.in}s which are out of date with respect to one of their
1169 dependents.
1171 @item -o @var{dir}
1172 @itemx --output-dir=@var{dir}
1173 @opindex -o
1174 @opindex --output-dir
1175 Put the generated @file{Makefile.in} in the directory @var{dir}.
1176 Ordinarily each @file{Makefile.in} is created in the directory of the
1177 corresponding @file{Makefile.am}.  This option is deprecated and will be
1178 removed in a future release.
1180 @item -v
1181 @itemx --verbose
1182 @opindex -v
1183 @opindex --verbose
1184 Cause Automake to print information about which files are being read or
1185 created.
1187 @item --version
1188 @opindex --version
1189 Print the version number of Automake and exit.
1191 @item -W CATEGORY
1192 @item --warnings=@var{category}
1193 @opindex -W
1194 @opindex --warnings
1195 Output warnings falling in @var{category}.  @var{category} can be
1196 one of:
1197 @table @samp
1198 @item gnu
1199 warnings related to the GNU Coding Standards
1200 (@pxref{Top, , , standards, The GNU Coding Standards}).
1201 @item obsolete
1202 obsolete features or constructions
1203 @item override
1204 user redefinitions of Automake rules or variables
1205 @item portability
1206 portability issues (e.g., use of Make features which are known not portable)
1207 @item syntax
1208 weird syntax, unused variables, typos
1209 @item unsupported
1210 unsupported or incomplete features
1211 @item all
1212 all the warnings
1213 @item none
1214 turn off all the warnings
1215 @item error
1216 treat warnings as errors
1217 @end table
1219 A category can be turned off by prefixing its name with @samp{no-}.  For
1220 instance @samp{-Wno-syntax} will hide the warnings about unused
1221 variables.
1223 The categories output by default are @samp{syntax} and
1224 @samp{unsupported}.  Additionally, @samp{gnu} is enabled in @samp{--gnu} and
1225 @samp{--gnits} strictness.
1227 @samp{portability} warnings are currently disabled by default, but they
1228 will be enabled in @samp{--gnu} and @samp{--gnits} strictness in a
1229 future release.
1231 @vindex WARNINGS
1232 The environment variable @samp{WARNINGS} can contain a comma separated
1233 list of categories to enable.  It will be taken into account before the
1234 command-line switches, this way @samp{-Wnone} will also ignore any
1235 warning category enabled by @samp{WARNINGS}.  This variable is also used
1236 by other tools like @command{autoconf}; unknown categories are ignored
1237 for this reason.
1239 @end table
1242 @node configure
1243 @chapter Scanning @file{configure.ac}
1245 @cindex configure.ac, scanning
1246 @cindex Scanning configure.ac
1248 Automake scans the package's @file{configure.ac} to determine certain
1249 information about the package.  Some @code{autoconf} macros are required
1250 and some variables must be defined in @file{configure.ac}.  Automake
1251 will also use information from @file{configure.ac} to further tailor its
1252 output.
1254 Automake also supplies some Autoconf macros to make the maintenance
1255 easier.  These macros can automatically be put into your
1256 @file{aclocal.m4} using the @code{aclocal} program.
1258 @menu
1259 * Requirements::                Configuration requirements
1260 * Optional::                    Other things Automake recognizes
1261 * Invoking aclocal::            Auto-generating aclocal.m4
1262 * aclocal options::             aclocal command line arguments
1263 * Macro search path::           Modifying aclocal's search path
1264 * Macros::                      Autoconf macros supplied with Automake
1265 * Extending aclocal::           Writing your own aclocal macros
1266 * Local Macros::                Organizing local macros
1267 * Future of aclocal::           aclocal's scheduled death
1268 @end menu
1271 @node Requirements
1272 @section Configuration requirements
1274 @cindex Automake requirements
1275 @cindex Requirements of Automake
1277 The one real requirement of Automake is that your @file{configure.ac}
1278 call @code{AM_INIT_AUTOMAKE}.  This macro does several things which are
1279 required for proper Automake operation (@pxref{Macros}).
1280 @cvindex AM_INIT_AUTOMAKE
1282 Here are the other macros which Automake requires but which are not run
1283 by @code{AM_INIT_AUTOMAKE}:
1285 @table @code
1286 @item AC_CONFIG_FILES
1287 @itemx AC_OUTPUT
1288 Automake uses these to determine which files to create (@pxref{Output, ,
1289 Creating Output Files, autoconf, The Autoconf Manual}).  A listed file
1290 is considered to be an Automake generated @file{Makefile} if there
1291 exists a file with the same name and the @file{.am} extension appended.
1292 Typically, @code{AC_CONFIG_FILES([foo/Makefile])} will cause Automake to
1293 generate @file{foo/Makefile.in} if @file{foo/Makefile.am} exists.
1295 When using @code{AC_CONFIG_FILES} with multiple input files, as in
1296 @code{AC_CONFIG_FILES([Makefile:top.in:Makefile.in:bot.in])}, Automake
1297 will generate the first @file{.in} input file for which a @file{.am}
1298 file exists.  If no such file exists the output file is not considered
1299 to be Automake generated.
1301 Files created by @code{AC_CONFIG_FILES} are removed by @code{make distclean}.
1302 @cvindex AC_CONFIG_FILES
1303 @cvindex AC_OUTPUT
1304 @end table
1307 @node Optional
1308 @section Other things Automake recognizes
1310 @cindex Macros Automake recognizes
1311 @cindex Recognized macros by Automake
1313 Every time Automake is run it calls Autoconf to trace
1314 @file{configure.ac}.  This way it can recognize the use of certain
1315 macros and tailor the generated @file{Makefile.in} appropriately.
1316 Currently recognized macros and their effects are:
1318 @table @code
1319 @item AC_CONFIG_HEADERS
1320 Automake will generate rules to rebuild these headers.  Older versions
1321 of Automake required the use of @code{AM_CONFIG_HEADER}
1322 (@pxref{Macros}); this is no longer the case today.
1323 @cvindex AC_CONFIG_HEADERS
1325 @item AC_CONFIG_LINKS
1326 Automake will generate rules to remove @file{configure} generated links on
1327 @code{make distclean} and to distribute named source files as part of
1328 @code{make dist}.
1329 @cvindex AC_CONFIG_LINKS
1331 @item AC_CONFIG_AUX_DIR
1332 Automake will look for various helper scripts, such as
1333 @file{install-sh}, in the directory named in this macro invocation.
1334 @c This list is accurate relative to version 1.8
1335 (The full list of scripts is: @file{config.guess}, @file{config.sub},
1336 @file{depcomp}, @file{elisp-comp}, @file{compile}, @file{install-sh},
1337 @file{ltmain.sh}, @file{mdate-sh}, @file{missing}, @file{mkinstalldirs},
1338 @file{py-compile}, @file{texinfo.tex}, and @file{ylwrap}.)  Not all
1339 scripts are always searched for; some scripts will only be sought if the
1340 generated @file{Makefile.in} requires them.
1341 @cvindex AC_CONFIG_AUX_DIR
1343 If @code{AC_CONFIG_AUX_DIR} is not given, the scripts are looked for in
1344 their @samp{standard} locations.  For @file{mdate-sh},
1345 @file{texinfo.tex}, and @file{ylwrap}, the standard location is the
1346 source directory corresponding to the current @file{Makefile.am}.  For
1347 the rest, the standard location is the first one of @file{.}, @file{..},
1348 or @file{../..} (relative to the top source directory) that provides any
1349 one of the helper scripts.  @xref{Input, , Finding `configure' Input,
1350 autoconf, The Autoconf Manual}.
1352 Required files from @code{AC_CONFIG_AUX_DIR} are automatically
1353 distributed, even if there is no @file{Makefile.am} in this directory.
1355 @item AC_CANONICAL_BUILD
1356 @itemx AC_CANONICAL_HOST
1357 @itemx AC_CANONICAL_TARGET
1358 Automake will ensure that @file{config.guess} and @file{config.sub}
1359 exist.  Also, the @file{Makefile} variables @samp{build_triplet},
1360 @samp{host_triplet} and @samp{target_triplet} are introduced.  See
1361 @ref{Canonicalizing, , Getting the Canonical System Type, autoconf,
1362 The Autoconf Manual}.
1363 @cvindex AC_CANONICAL_BUILD
1364 @cvindex AC_CANONICAL_HOST
1365 @cvindex AC_CANONICAL_TARGET
1366 @vindex build_triplet
1367 @vindex host_triplet
1368 @vindex target_triplet
1370 @item AC_LIBSOURCE
1371 @itemx AC_LIBSOURCES
1372 @itemx AC_LIBOBJ
1373 Automake will automatically distribute any file listed in
1374 @code{AC_LIBSOURCE} or @code{AC_LIBSOURCES}.
1376 Note that the @code{AC_LIBOBJ} macro calls @code{AC_LIBSOURCE}.  So if
1377 an Autoconf macro is documented to call @code{AC_LIBOBJ([file])}, then
1378 @file{file.c} will be distributed automatically by Automake.  This
1379 encompasses many macros like @code{AC_FUNC_ALLOCA},
1380 @code{AC_FUNC_MEMCMP}, @code{AC_REPLACE_FUNCS}, and others.
1381 @cvindex AC_LIBOBJ
1382 @cvindex AC_LIBSOURCE
1383 @cvindex AC_LIBSOURCES
1385 By the way, direct assignments to @code{LIBOBJS} are no longer
1386 supported.  You should always use @code{AC_LIBOBJ} for this purpose.
1387 @xref{AC_LIBOBJ vs LIBOBJS, , @code{AC_LIBOBJ} vs. @code{LIBOBJS},
1388 autoconf, The Autoconf Manual}.
1389 @cvindex LIBOBJS
1391 @item AC_PROG_RANLIB
1392 This is required if any libraries are built in the package.
1393 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1394 Autoconf Manual}.
1395 @cvindex AC_PROG_RANLIB
1397 @item AC_PROG_CXX
1398 This is required if any C++ source is included.  @xref{Particular
1399 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1400 @cvindex AC_PROG_CXX
1402 @item AC_PROG_F77
1403 This is required if any Fortran 77 source is included.  This macro is
1404 distributed with Autoconf version 2.13 and later.  @xref{Particular
1405 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1406 @cvindex AC_PROG_F77
1408 @item AC_F77_LIBRARY_LDFLAGS
1409 This is required for programs and shared libraries that are a mixture of
1410 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1411 C++}).  @xref{Macros, , Autoconf macros supplied with Automake}.
1412 @cvindex AC_F77_LIBRARY_LDFLAGS
1414 @item AC_PROG_FC
1415 This is required if any Fortran 90/95 source is included.  This macro is
1416 distributed with Autoconf version 2.58 and later.  @xref{Particular
1417 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1418 @cvindex AC_PROG_FC
1420 @item AC_PROG_LIBTOOL
1421 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1422 Introduction, libtool, The Libtool Manual}).
1423 @cvindex AC_PROG_LIBTOOL
1425 @item AC_PROG_YACC
1426 If a Yacc source file is seen, then you must either use this macro or
1427 define the variable @samp{YACC} in @file{configure.ac}.  The former is
1428 preferred (@pxref{Particular Programs, , Particular Program Checks,
1429 autoconf, The Autoconf Manual}).
1430 @cvindex AC_PROG_YACC
1431 @cvindex YACC
1433 @item AC_PROG_LEX
1434 If a Lex source file is seen, then this macro must be used.
1435 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1436 Autoconf Manual}.
1437 @cvindex AC_PROG_LEX
1439 @item AC_REQUIRE_AUX_FILE
1440 @cvindex AC_REQUIRE_AUX_FILE
1441 @command{automake} will ensure each file for which this macro is
1442 called exists in the aux directory, and will complain otherwise.  It
1443 will also automatically distribute the file.  This macro should be
1444 used by third-party Autoconf macros that requires some supporting
1445 files in the aux directory specified with @code{AC_CONFIG_AUX_DIR}
1446 above.  @xref{Input, , Finding @command{configure} Input, autoconf,
1447 The Autoconf Manual}.
1449 @item AC_SUBST
1450 @cvindex AC_SUBST
1451 The first argument is automatically defined as a variable in each
1452 generated @file{Makefile.in}.  @xref{Setting Output Variables, , Setting
1453 Output Variables, autoconf, The Autoconf Manual}.
1455 If the Autoconf manual says that a macro calls @code{AC_SUBST} for
1456 @var{var}, or defines the output variable @var{var} then @var{var} will
1457 be defined in each @file{Makefile.in} generated by Automake.
1458 E.g. @code{AC_PATH_XTRA} defines @code{X_CFLAGS} and @code{X_LIBS}, so
1459 you can use these variables in any @file{Makefile.am} if
1460 @code{AC_PATH_XTRA} is called.
1462 @item AM_C_PROTOTYPES
1463 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1464 @cvindex AM_C_PROTOTYPES
1466 @item AM_GNU_GETTEXT
1467 This macro is required for packages which use GNU gettext
1468 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
1469 this macro it ensures that the package meets some of gettext's
1470 requirements.
1471 @cvindex AM_GNU_GETTEXT
1473 @item AM_MAINTAINER_MODE
1474 @opindex --enable-maintainer-mode
1475 This macro adds a @samp{--enable-maintainer-mode} option to
1476 @code{configure}.  If this is used, @code{automake} will cause
1477 @samp{maintainer-only} rules to be turned off by default in the
1478 generated @file{Makefile.in}s. This macro defines the
1479 @samp{MAINTAINER_MODE} conditional, which you can use in your own
1480 @file{Makefile.am}.
1481 @cvindex AM_MAINTAINER_MODE
1483 @item m4_include
1484 @cvindex m4_include
1485 Files included by @file{configure.ac} using this macro will be
1486 detected by Automake and automatically distributed.  They will also
1487 appear as dependencies in @file{Makefile} rules.
1489 @code{m4_include} is seldom used by @file{configure.ac} authors, but
1490 can appear in @file{aclocal.m4} when @command{aclocal} detects that
1491 some required macros come from files local to your package (as
1492 opposed to macros installed in a system-wide directory, see
1493 @ref{Invoking aclocal}).
1495 @end table
1498 @node Invoking aclocal
1499 @section Auto-generating aclocal.m4
1501 @cindex Invoking aclocal
1502 @cindex aclocal, Invoking
1504 Automake includes a number of Autoconf macros which can be used in
1505 your package (@pxref{Macros}); some of them are actually required by
1506 Automake in certain situations.  These macros must be defined in your
1507 @file{aclocal.m4}; otherwise they will not be seen by
1508 @command{autoconf}.
1510 The @command{aclocal} program will automatically generate
1511 @file{aclocal.m4} files based on the contents of @file{configure.ac}.
1512 This provides a convenient way to get Automake-provided macros,
1513 without having to search around.  The @command{aclocal} mechanism
1514 allows other packages to supply their own macros (@pxref{Extending
1515 aclocal}).  You can also use it to maintain your own set of custom
1516 macros (@pxref{Local Macros}).
1518 At startup, @command{aclocal} scans all the @file{.m4} files it can
1519 find, looking for macro definitions (@pxref{Macro search path}).  Then
1520 it scans @file{configure.ac}.  Any mention of one of the macros found
1521 in the first step causes that macro, and any macros it in turn
1522 requires, to be put into @file{aclocal.m4}.
1524 @emph{Putting} the file that contains the macro definition into
1525 @file{aclocal.m4} is usually done by copying the entire text of this
1526 file, including unused macro definitions as well as both @samp{#} and
1527 @samp{dnl} comments.  If you want to make a comment which will be
1528 completely ignored by @command{aclocal}, use @samp{##} as the comment
1529 leader.
1531 When a file selected by @command{aclocal} is located in a subdirectory
1532 specified as a relative search path with @command{aclocal}'s @code{-I}
1533 argument, @command{aclocal} assumes the file belongs to the package
1534 and uses @code{m4_include} instead of copying it into
1535 @file{aclocal.m4}.  This makes the package smaller, eases dependency
1536 tracking, and cause the file to be distributed automatically.
1537 (@pxref{Local Macros} for an example.)  Any macro which is found in a
1538 system-wide directory, or via an absolute search path will be copied.
1539 So use @code{-I `pwd`/reldir} instead of @code{-I reldir} whenever
1540 some relative directory need to be considered outside the package.
1542 The contents of @file{acinclude.m4}, if this file exists, are also
1543 automatically included in @file{aclocal.m4}.  We recommend against
1544 using @file{acinclude.m4} in new packages (@pxref{Local Macros}).
1546 @vindex AUTOM4TE
1547 While computing @file{aclocal.m4}, @code{aclocal} runs @code{autom4te}
1548 (@pxref{Using autom4te, , Using @code{Autom4te}, autoconf, The
1549 Autoconf Manual}) in order to trace the macros which are really used,
1550 and omit from @file{aclocal.m4} all macros which are mentioned but
1551 otherwise unexpanded (this can happen when a macro is called
1552 conditionally).  @code{autom4te} is expected to be in the @code{PATH},
1553 just as @code{autoconf}.  Its location can be overridden using the
1554 @code{AUTOM4TE} environment variable.
1556 @menu
1557 * aclocal options::             Options supported by aclocal
1558 * Macro search path::           How aclocal finds .m4 files
1559 @end menu
1561 @node aclocal options
1562 @section aclocal options
1564 @cindex aclocal, Options
1565 @cindex Options, aclocal
1567 @code{aclocal} accepts the following options:
1569 @table @code
1570 @item --acdir=@var{dir}
1571 @opindex --acdir
1572 Look for the macro files in @var{dir} instead of the installation
1573 directory.  This is typically used for debugging.
1575 @item --help
1576 @opindex --help
1577 Print a summary of the command line options and exit.
1579 @item -I @var{dir}
1580 @opindex -I
1581 Add the directory @var{dir} to the list of directories searched for
1582 @file{.m4} files.
1584 @item --force
1585 @opindex --force
1586 Always overwrite the output file.  The default is to overwrite the output
1587 file only when really needed, i.e., when its contents changes or if one
1588 of its dependencies is younger.
1590 @item --output=@var{file}
1591 @opindex --output
1592 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1594 @item --print-ac-dir
1595 @opindex --print-ac-dir
1596 Prints the name of the directory which @code{aclocal} will search to
1597 find third-party @file{.m4} files.  When this option is given, normal
1598 processing is suppressed.  This option can be used by a package to
1599 determine where to install a macro file.
1601 @item --verbose
1602 @opindex --verbose
1603 Print the names of the files it examines.
1605 @item --version
1606 @opindex --version
1607 Print the version number of Automake and exit.
1609 @item -W CATEGORY
1610 @item --warnings=@var{category}
1611 @opindex -W
1612 @opindex --warnings
1613 Output warnings falling in @var{category}.  @var{category} can be
1614 one of:
1615 @table @samp
1616 @item syntax
1617 dubious syntactic constructs, underquoted macros, unused macros, etc.
1618 @item unsupported
1619 unknown macros
1620 @item all
1621 all the warnings, this is the default
1622 @item none
1623 turn off all the warnings
1624 @item error
1625 treat warnings as errors
1626 @end table
1628 All warnings are output by default.
1630 @vindex WARNINGS
1631 The environment variable @samp{WARNINGS} is honored in the same
1632 way as it is for @command{automake} (@pxref{Invoking Automake}).
1634 @end table
1636 @node Macro search path
1637 @section Macro search path
1639 @cindex Macro search path
1640 @cindex aclocal search path
1642 By default, @command{aclocal} searches for @file{.m4} files in the following
1643 directories, in this order:
1645 @table @code
1646 @item @var{acdir-APIVERSION}
1647 This is where the @file{.m4} macros distributed with automake itself
1648 are stored.  @var{APIVERSION} depends on the automake release used;
1649 for automake 1.6.x, @var{APIVERSION} = @code{1.6}.
1651 @item @var{acdir}
1652 This directory is intended for third party @file{.m4} files, and is
1653 configured when @command{automake} itself is built.  This is
1654 @file{@@datadir@@/aclocal/}, which typically
1655 expands to @file{$@{prefix@}/share/aclocal/}.  To find the compiled-in
1656 value of @var{acdir}, use the @code{--print-ac-dir} option
1657 (@pxref{aclocal options}).
1658 @end table
1660 As an example, suppose that automake-1.6.2 was configured with
1661 @code{--prefix=/usr/local}.  Then, the search path would be:
1663 @enumerate
1664 @item @file{/usr/local/share/aclocal-1.6/}
1665 @item @file{/usr/local/share/aclocal/}
1666 @end enumerate
1668 As explained in (@pxref{aclocal options}), there are several options that
1669 can be used to change or extend this search path.
1671 @subsection Modifying the macro search path: @code{--acdir}
1673 The most obvious option to modify the search path is
1674 @code{--acdir=@var{dir}}, which changes default directory and
1675 drops the @var{APIVERSION} directory.  For example, if one specifies
1676 @code{--acdir=/opt/private/}, then the search path becomes:
1678 @enumerate
1679 @item @file{/opt/private/}
1680 @end enumerate
1682 Note that this option, @code{--acdir}, is intended for use
1683 by the internal automake test suite only; it is not ordinarily
1684 needed by end-users.
1686 @subsection Modifying the macro search path: @code{-I @var{dir}}
1688 Any extra directories specified using @code{-I} options
1689 (@pxref{aclocal options}) are @emph{prepended} to this search list.  Thus,
1690 @code{aclocal -I /foo -I /bar} results in the following search path:
1692 @enumerate
1693 @item @file{/foo}
1694 @item @file{/bar}
1695 @item @var{acdir}-@var{APIVERSION}
1696 @item @var{acdir}
1697 @end enumerate
1699 @subsection Modifying the macro search path: @file{dirlist}
1700 @cindex @file{dirlist}
1702 There is a third mechanism for customizing the search path.  If a
1703 @file{dirlist} file exists in @var{acdir}, then that file is assumed to
1704 contain a list of directories, one per line, to be added to the search
1705 list.  These directories are searched @emph{after} all other
1706 directories.
1708 For example, suppose
1709 @file{@var{acdir}/dirlist} contains the following:
1711 @example
1712 /test1
1713 /test2
1714 @end example
1716 @noindent
1717 and that @code{aclocal} was called with the @code{-I /foo -I /bar} options.
1718 Then, the search path would be
1720 @enumerate
1721 @item @file{/foo}
1722 @item @file{/bar}
1723 @item @var{acdir}-@var{APIVERSION}
1724 @item @var{acdir}
1725 @item @file{/test1}
1726 @item @file{/test2}
1727 @end enumerate
1729 If the @code{--acdir=@var{dir}} option is used, then @command{aclocal}
1730 will search for the @file{dirlist} file in @var{dir}.  In the
1731 @code{--acdir=/opt/private/} example above, @command{aclocal} would look
1732 for @file{/opt/private/dirlist}.  Again, however, the @code{--acdir}
1733 option is intended for use by the internal automake test suite only;
1734 @code{--acdir} is not ordinarily needed by end-users.
1736 @file{dirlist} is useful in the following situation: suppose that
1737 @code{automake} version @code{1.6.2} is installed with
1738 $prefix=/usr by the system vendor. Thus, the default search
1739 directories are
1741 @enumerate
1742 @item @file{/usr/share/aclocal-1.6/}
1743 @item @file{/usr/share/aclocal/}
1744 @end enumerate
1746 However, suppose further that many packages have been manually
1747 installed on the system, with $prefix=/usr/local, as is typical.
1748 In that case, many of these ``extra'' @file{.m4} files are in
1749 @file{/usr/local/share/aclocal}.  The only way to force
1750 @file{/usr/bin/aclocal} to find these ``extra'' @file{.m4} files
1751 is to always call @code{aclocal -I /usr/local/share/aclocal}.
1752 This is inconvenient.  With @file{dirlist}, one may create the file
1754 @file{/usr/share/aclocal/dirlist}
1756 @noindent
1757 which contains only the single line
1759 @file{/usr/local/share/aclocal}
1761 Now, the ``default'' search path on the affected system is
1763 @enumerate
1764 @item @file{/usr/share/aclocal-1.6/}
1765 @item @file{/usr/share/aclocal/}
1766 @item @file{/usr/local/share/aclocal/}
1767 @end enumerate
1769 without the need for @code{-I} options; @code{-I} options can be reserved
1770 for project-specific needs (@file{my-source-dir/m4/}), rather than
1771 using it to work around local system-dependent tool installation
1772 directories.
1774 Similarly, @file{dirlist} can be handy if you have installed a local
1775 copy Automake on your account and want @command{aclocal} to look for
1776 macros installed at other places on the system.
1779 @node Macros
1780 @section Autoconf macros supplied with Automake
1782 Automake ships with several Autoconf macros that you can use from your
1783 @file{configure.ac}.  When you use one of them it will be included by
1784 @code{aclocal} in @file{aclocal.m4}.
1786 @menu
1787 * Public macros::               Macros that you can use.
1788 * Private macros::              Macros that you should not use.
1789 @end menu
1791 @c consider generating the following subsections automatically from m4 files.
1793 @node Public macros
1794 @subsection Public macros
1796 @table @code
1797 @item AM_CONFIG_HEADER
1798 Automake will generate rules to automatically regenerate the config
1799 header.  This obsolete macro is a synonym of @code{AC_CONFIG_HEADERS}
1800 today (@pxref{Optional}).
1801 @cvindex AM_CONFIG_HEADER
1803 @item AM_ENABLE_MULTILIB
1804 This is used when a ``multilib'' library is being built.  The first
1805 optional argument is the name of the @file{Makefile} being generated; it
1806 defaults to @samp{Makefile}.  The second option argument is used to find
1807 the top source directory; it defaults to the empty string (generally
1808 this should not be used unless you are familiar with the internals).
1809 @xref{Multilibs}.
1811 @item AM_C_PROTOTYPES
1812 Check to see if function prototypes are understood by the compiler.  If
1813 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1814 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
1815 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
1816 values to implement automatic de-ANSI-fication.
1817 @cvindex AM_C_PROTOTYPES
1819 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1820 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1821 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
1822 found in @file{<termios.h>}.
1823 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1825 @item AM_INIT_AUTOMAKE([OPTIONS])
1826 @itemx AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
1827 Runs many macros required for proper operation of the generated Makefiles.
1829 This macro has two forms, the first of which is preferred.
1830 In this form, @code{AM_INIT_AUTOMAKE} is called with a
1831 single argument --- a space-separated list of Automake options which should
1832 be applied to every @file{Makefile.am} in the tree.  The effect is as if
1833 each option were listed in @code{AUTOMAKE_OPTIONS}.
1835 The second, deprecated, form of @code{AM_INIT_AUTOMAKE} has two required
1836 arguments: the package and the version number.  This form is
1837 obsolete because the @var{package} and @var{version} can be obtained
1838 from Autoconf's @code{AC_INIT} macro (which itself has an old and a new
1839 form).
1841 If your @file{configure.ac} has:
1842 @example
1843 AC_INIT(src/foo.c)
1844 AM_INIT_AUTOMAKE(mumble, 1.5)
1845 @end example
1846 you can modernize it as follows:
1847 @example
1848 AC_INIT(mumble, 1.5)
1849 AC_CONFIG_SRCDIR(src/foo.c)
1850 AM_INIT_AUTOMAKE
1851 @end example
1853 Note that if you're upgrading your @file{configure.ac} from an earlier
1854 version of Automake, it is not always correct to simply move the package
1855 and version arguments from @code{AM_INIT_AUTOMAKE} directly to
1856 @code{AC_INIT}, as in the example above.  The first argument to
1857 @code{AC_INIT} should be the name of your package (e.g. @samp{GNU Automake}),
1858 not the tarball name (e.g. @samp{automake}) that you used to pass to
1859 @code{AM_INIT_AUTOMAKE}.  Autoconf tries to derive a tarball name from
1860 the package name, which should work for most but not all package names.
1861 (If it doesn't work for yours, you can use the
1862 four-argument form of @code{AC_INIT} --- supported in Autoconf versions
1863 greater than 2.52g --- to provide the tarball name explicitly).
1865 By default this macro @code{AC_DEFINE}'s @samp{PACKAGE} and
1866 @samp{VERSION}.  This can be avoided by passing the @samp{no-define}
1867 option, as in:
1868 @example
1869 AM_INIT_AUTOMAKE([gnits 1.5 no-define dist-bzip2])
1870 @end example
1871 or by passing a third non-empty argument to the obsolete form.
1873 @cvindex PACKAGE, prevent definition
1874 @cvindex VERSION, prevent definition
1876 @item AM_PATH_LISPDIR
1877 Searches for the program @code{emacs}, and, if found, sets the output
1878 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1880 Note that this test assumes the @code{emacs} found to be a version that
1881 supports Emacs Lisp (such as @sc{gnu} Emacs or XEmacs).  Other emacsen
1882 can cause this test to hang (some, like old versions of MicroEmacs,
1883 start up in interactive mode, requiring @samp{C-x C-c} to exit, which
1884 is hardly obvious for a non-emacs user).  In most cases, however, you
1885 should be able to use @samp{C-c} to kill the test.  In order to avoid
1886 problems, you can set @code{EMACS} to ``no'' in the environment, or
1887 use the @samp{--with-lispdir} option to @command{configure} to
1888 explicitly set the correct path (if you're sure you have an @code{emacs}
1889 that supports Emacs Lisp.
1890 @cvindex AM_PATH_LISPDIR
1892 @item AM_PROG_AS
1893 Use this macro when you have assembly code in your project.  This will
1894 choose the assembler for you (by default the C compiler) and set
1895 @code{CCAS}, and will also set @code{CCASFLAGS} if required.
1897 @item AM_PROG_CC_C_O
1898 This is like @code{AC_PROG_CC_C_O}, but it generates its results in
1899 the manner required by automake.  You must use this instead of
1900 @code{AC_PROG_CC_C_O} when you need this functionality, that is, when
1901 using per-target flags or subdir-objects with C sources.
1903 @item AM_PROG_LEX
1904 @cindex HP-UX 10, lex problems
1905 @cindex lex problems with HP-UX 10
1906 Like @code{AC_PROG_LEX} (@pxref{Particular Programs, , Particular
1907 Program Checks, autoconf, The Autoconf Manual}), but uses the
1908 @code{missing} script on systems that do not have @code{lex}.
1909 @samp{HP-UX 10} is one such system.
1911 @item AM_PROG_GCJ
1912 This macro finds the @code{gcj} program or causes an error.  It sets
1913 @samp{GCJ} and @samp{GCJFLAGS}.  @code{gcj} is the Java front-end to the
1914 GNU Compiler Collection.
1915 @cvindex AM_PROG_GCJ
1917 @item AM_SYS_POSIX_TERMIOS
1918 @cvindex am_cv_sys_posix_termios
1919 @cindex POSIX termios headers
1920 @cindex termios POSIX headers
1921 Check to see if POSIX termios headers and functions are available on the
1922 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1923 @samp{yes}.  If not, set the variable to @samp{no}.
1925 @item AM_WITH_DMALLOC
1926 @cvindex WITH_DMALLOC
1927 @cindex dmalloc, support for
1928 @opindex --with-dmalloc
1929 Add support for the
1930 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1931 package.  If the user configures with @samp{--with-dmalloc}, then define
1932 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1934 @item AM_WITH_REGEX
1935 @cvindex WITH_REGEX
1936 @opindex --with-regex
1937 @cindex regex package
1938 @cindex rx package
1939 Adds @samp{--with-regex} to the @code{configure} command line.  If
1940 specified (the default), then the @samp{regex} regular expression
1941 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1942 @samp{WITH_REGEX} is defined.  If @samp{--without-regex} is given, then
1943 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1944 into @samp{LIBOBJS}.
1946 @end table
1948 @node Private macros
1949 @subsection Private macros
1951 The following macros are private macros you should not call directly.
1952 They are called by the other public macros when appropriate.  Do not
1953 rely on them, as they might be changed in a future version.  Consider
1954 them as implementation details; or better, do not consider them at all:
1955 skip this section!
1957 @table @code
1958 @item _AM_DEPENDENCIES
1959 @itemx AM_SET_DEPDIR
1960 @itemx AM_DEP_TRACK
1961 @itemx AM_OUTPUT_DEPENDENCY_COMMANDS
1962 These macros are used to implement Automake's automatic dependency
1963 tracking scheme.  They are called automatically by automake when
1964 required, and there should be no need to invoke them manually.
1966 @item AM_MAKE_INCLUDE
1967 This macro is used to discover how the user's @code{make} handles
1968 @code{include} statements.  This macro is automatically invoked when
1969 needed; there should be no need to invoke it manually.
1971 @item AM_PROG_INSTALL_STRIP
1972 This is used to find a version of @code{install} which can be used to
1973 @code{strip} a program at installation time.  This macro is
1974 automatically included when required.
1976 @item AM_SANITY_CHECK
1977 This checks to make sure that a file created in the build directory is
1978 newer than a file in the source directory.  This can fail on systems
1979 where the clock is set incorrectly.  This macro is automatically run
1980 from @code{AM_INIT_AUTOMAKE}.
1982 @end table
1985 @node Extending aclocal
1986 @section Writing your own aclocal macros
1988 @cindex aclocal, extending
1989 @cindex Extending aclocal
1991 The @command{aclocal} program doesn't have any built-in knowledge of any
1992 macros, so it is easy to extend it with your own macros.
1994 This can be used by libraries which want to supply their own Autoconf
1995 macros for use by other programs.  For instance the @command{gettext}
1996 library supplies a macro @code{AM_GNU_GETTEXT} which should be used by
1997 any package using @command{gettext}.  When the library is installed, it
1998 installs this macro so that @command{aclocal} will find it.
2000 A macro file's name should end in @file{.m4}.  Such files should be
2001 installed in @file{$(datadir)/aclocal}.  This is as simple as writing:
2003 @example
2004 aclocaldir = $(datadir)/aclocal
2005 aclocal_DATA = mymacro.m4 myothermacro.m4
2006 @end example
2008 A file of macros should be a series of properly quoted
2009 @code{AC_DEFUN}'s (@pxref{Macro Definitions, , , autoconf, The
2010 Autoconf Manual}).  The @command{aclocal} programs also understands
2011 @code{AC_REQUIRE} (@pxref{Prerequisite Macros, , , autoconf, The
2012 Autoconf Manual}), so it is safe to put each macro in a separate file.
2013 Each file should have no side effects but macro definitions.
2014 Especially, any call to @code{AC_PREREQ} should be done inside the
2015 defined macro, not at the beginning of the file.
2017 @cindex underquoted AC_DEFUN
2018 @cvindex AC_DEFUN
2019 @cvindex AC_PREREQ
2021 Starting with Automake 1.8, @command{aclocal} will warn about all
2022 underquoted calls to @code{AC_DEFUN}.  We realize this will annoy a
2023 lot of people, because @command{aclocal} was not so strict in the past
2024 and many third party macros are underquoted; and we have to apologize
2025 for this temporary inconvenience.  The reason we have to be stricter
2026 is that a future implementation of @command{aclocal} (@pxref{Future of
2027 aclocal}) will have to temporary include all these third party
2028 @file{.m4} files, maybe several times, even those which are not
2029 actually needed.  Doing so should alleviate many problem of the
2030 current implementation, however it requires a stricter style from the
2031 macro authors.  Hopefully it is easy to revise the existing macros.
2032 For instance
2033 @example
2034 # bad style
2035 AC_PREREQ(2.57)
2036 AC_DEFUN(AX_FOOBAR,
2037 [AC_REQUIRE([AX_SOMETHING])dnl
2038 AX_FOO
2039 AX_BAR
2041 @end example
2042 @noindent
2043 should be rewritten as
2044 @example
2045 AC_DEFUN([AX_FOOBAR],
2046 [AC_PREREQ(2.57)dnl
2047 AC_REQUIRE([AX_SOMETHING])dnl
2048 AX_FOO
2049 AX_BAR
2051 @end example
2053 Wrapping the @code{AC_PREREQ} call inside the macro ensures that
2054 Autoconf 2.57 will not be required if @code{AX_FOOBAR} is not actually
2055 used.  Most importantly, quoting the first argument of @code{AC_DEFUN}
2056 allows the macro to be redefined or included twice (otherwise this
2057 first argument would be expansed during the second definition).
2059 If you have been directed here by the @command{aclocal} diagnostic but
2060 are not the maintainer of the implicated macro, you will want to
2061 contact the maintainer of that macro.  Please make sure you have the
2062 last version of the macro and that the problem already hasn't been
2063 reported before doing so: people tend to work faster when they aren't
2064 flooded by mails.
2066 Another situation where @command{aclocal} is commonly used is to
2067 manage macros which are used locally by the package, @ref{Local
2068 Macros}.
2070 @node Local Macros
2071 @section Handling Local Macros
2073 Feature tests offered by Autoconf do not cover all needs.  People
2074 often have to supplement existing tests with their own macros, or
2075 with third-party macros.
2077 There are two ways to organize custom macros in a package.
2079 The first possibility (the historical practice) is to list all your
2080 macros in @file{acinclude.m4}.  This file will be included in
2081 @file{aclocal.m4} when you run @command{aclocal}, and its macro(s) will
2082 henceforth be visible to @command{autoconf}.  However if it contains
2083 numerous macros, it will rapidly become difficult to maintain, and it
2084 will be almost impossible to share macros between packages.
2086 @vindex ACLOCAL_AMFLAGS
2087 The second possibility, which we do recommend, is to write each macro
2088 in its own file and gather all these files in a directory.  This
2089 directory is usually called @file{m4/}.  To build @file{aclocal.m4},
2090 one should therefore instruct @command{aclocal} to scan @file{m4/}.
2091 From the command line, this is done with @code{aclocal -I m4}.  The
2092 top-level @file{Makefile.am} should also be updated to define
2094 @example
2095  ACLOCAL_AMFLAGS = -I m4
2096 @end example
2098 @code{ACLOCAL_AMFLAGS} contains options to pass to @command{aclocal}
2099 when @file{aclocal.m4} is to be rebuilt by @code{make}.  This line is
2100 also used by @command{autoreconf} (@pxref{autoreconf Invocation, ,
2101 Using @command{autoreconf} to Update @file{configure} Scripts,
2102 autoconf, The Autoconf Manual}) to run @command{aclocal} with suitable
2103 options, or by @command{autopoint} (@pxref{autopoint Invocation, ,
2104 Invoking the @command{autopoint} Program, gettext, GNU gettext tools})
2105 and @command{gettextize} (@pxref{gettextize Invocation, , Invoking the
2106 @command{gettextize} Program, gettext, GNU gettext tools}) to locate
2107 the place where Gettext's macros should be installed.  So even if you
2108 do not really care about the rebuild rules, you should define
2109 @code{ACLOCAL_AMFLAGS}.
2111 When @code{aclocal -I m4} is run, it will build a @code{aclocal.m4}
2112 that @code{m4_include}s any file from @file{m4/} that defines a
2113 required macro.  Macros not found locally will still be searched in
2114 system-wide directories, as explained in @ref{Macro search path}.
2116 Custom macros should be distributed for the same reason that
2117 @file{configure.ac} is: so that other people have all the sources of
2118 your package if they want to work on it.  Actually, this distribution
2119 happens automatically because all @code{m4_include}d files are
2120 distributed.
2122 However there is no consensus on the distribution of third-party
2123 macros that your package may use.  Many libraries install their own
2124 macro in the system-wide @command{aclocal} directory (@pxref{Extending
2125 aclocal}).  For instance Guile ships with a file called
2126 @file{guile.m4} that contains the macro @code{GUILE_FLAGS} which can
2127 be used to define setup compiler and linker flags appropriate for
2128 using Guile.  Using @code{GUILE_FLAGS} in @file{configure.ac} will
2129 cause @command{aclocal} to copy @file{guile.m4} into
2130 @file{aclocal.m4}, but as @file{guile.m4} is not part of the project,
2131 it will not be distributed.  Technically, that means a user which
2132 needs to rebuild @file{aclocal.m4} will have to install Guile first.
2133 This is probably OK, if Guile already is a requirement to build the
2134 package.  However, if Guile is only an optional feature, or if your
2135 package might run on architectures where Guile cannot be installed,
2136 this requirement will hinder development.  An easy solution is to copy
2137 such third-party macros in your local @file{m4/} directory so they get
2138 distributed.
2140 @node Future of aclocal
2141 @section The Future of @command{aclocal}
2142 @cindex aclocal's scheduled death
2144 @command{aclocal} is expected to disappear.  This feature really
2145 should not be offered by Automake.  Automake should focus on generating
2146 @file{Makefile}s; dealing with M4 macros really is Autoconf's job.
2147 That some people install Automake just to use @command{aclocal}, but
2148 do not use @command{automake} otherwise is an indication of how that
2149 feature is misplaced.
2151 The new implementation will probably be done slightly differently.
2152 For instance it could enforce the @file{m4/}-style layout discussed in
2153 @ref{Local Macros}, and take care of copying (and even updating)
2154 third-party macros from @file{/usr/share/aclocal/} into the local
2155 @file{m4/} directory.
2157 We have no idea when and how this will happen.  This has been
2158 discussed several times in the past, but someone still has to commit
2159 itself to that non-trivial task.
2161 From the user point of view, @command{aclocal}'s removal might turn
2162 out to be painful.  There is a simple precaution that you may take to
2163 make that switch more seamless: never call @command{aclocal} yourself.
2164 Keep this guy under the exclusive control of @command{autoreconf} and
2165 Automake's rebuild rules.  Hopefully you won't need to worry about
2166 things breaking, when @command{aclocal} disappears, because everything
2167 will have been taken care of.  If otherwise you used to call
2168 @command{aclocal} directly yourself or from some script, you will
2169 quickly notice the change.
2171 Many packages come with a script called @file{bootstrap.sh} or
2172 @file{autogen.sh}, that will just call @command{aclocal},
2173 @command{libtoolize}, @command{gettextize} or @command{autopoint},
2174 @command{autoconf}, @command{autoheader}, and @command{automake} in
2175 the right order.  Actually this is precisely what @command{autoreconf}
2176 can do for you.  If your package has such a @file{bootstrap.sh} or
2177 @file{autogen.sh} script, consider using @command{autoreconf}.  That
2178 should simplify its logic a lot (less things to maintain, yum!), it's
2179 even likely you will not need the script anymore, and more to the point
2180 you will not call @command{aclocal} directly anymore.
2182 For the time being, third-party packages should continue to install
2183 public macros into @code{/usr/share/aclocal/}.  If @command{aclocal}
2184 is replaced by another tool it might make sense to rename the
2185 directory, but supporting @code{/usr/share/aclocal/} for backward
2186 compatibility should be really easy provided all macros are properly
2187 written (@pxref{Extending aclocal}).
2191 @node Directories
2192 @chapter Directories
2194 For simple projects that distributes all files in the same directory
2195 it is enough to have a single @file{Makefile.am} that builds
2196 everything in place.
2198 In larger projects it is common to organize files in different
2199 directories, in a tree.  For instance one directory per program, per
2200 library or per module.  The traditional approach is to build these
2201 subdirectory recursively: each directory contains its @file{Makefile}
2202 (generated from @file{Makefile.am}), and when @command{make} is run
2203 from the top level directory it enters each subdirectory in turn to
2204 build its contents.
2206 @menu
2207 * Subdirectories::              Building subdirectories recursively
2208 * Conditional Subdirectories::  Conditionally not building directories
2209 * Alternative::                 Subdirectories without recursion
2210 * Subpackages::                 Nesting packages
2211 @end menu
2213 @node Subdirectories
2214 @section Recursing subdirectories
2216 @cindex SUBDIRS, explained
2218 In packages with subdirectories, the top level @file{Makefile.am} must
2219 tell Automake which subdirectories are to be built.  This is done via
2220 the @code{SUBDIRS} variable.
2221 @vindex SUBDIRS
2223 The @code{SUBDIRS} variable holds a list of subdirectories in which
2224 building of various sorts can occur.  The rules for many targets
2225 (e.g. @code{all}) in the generated @file{Makefile} will run commands
2226 both locally and in all specified subdirectories.  Note that the
2227 directories listed in @code{SUBDIRS} are not required to contain
2228 @file{Makefile.am}s; only @file{Makefile}s (after configuration).
2229 This allows inclusion of libraries from packages which do not use
2230 Automake (such as @code{gettext}; see also @ref{Third-Party
2231 Makefiles}).
2233 In packages that use subdirectories, the top-level @file{Makefile.am} is
2234 often very short.  For instance, here is the @file{Makefile.am} from the
2235 GNU Hello distribution:
2237 @example
2238 EXTRA_DIST = BUGS ChangeLog.O README-alpha
2239 SUBDIRS = doc intl po src tests
2240 @end example
2242 When Automake invokes @code{make} in a subdirectory, it uses the value
2243 of the @code{MAKE} variable.  It passes the value of the variable
2244 @code{AM_MAKEFLAGS} to the @code{make} invocation; this can be set in
2245 @file{Makefile.am} if there are flags you must always pass to
2246 @code{make}.
2247 @vindex MAKE
2248 @vindex AM_MAKEFLAGS
2250 The directories mentioned in @code{SUBDIRS} are usually direct
2251 children of the current directory, each subdirectory containing its
2252 own @file{Makefile.am} with a @code{SUBDIRS} pointing to deeper
2253 subdirectories.  Automake can be used to construct packages of
2254 arbitrary depth this way.
2256 By default, Automake generates @file{Makefiles} which work depth-first
2257 in postfix order: the subdirectories are built before the current
2258 directory.  However, it is possible to change this ordering.  You can
2259 do this by putting @samp{.} into @code{SUBDIRS}.  For instance,
2260 putting @samp{.}  first will cause a @samp{prefix} ordering of
2261 directories.
2263 Using
2265 @example
2266 SUBDIRS = lib src . test
2267 @end example
2269 @noindent
2270 will cause @file{lib/} to be built before @file{src/}, then the
2271 current directory will be built, finally the @file{test/} directory
2272 will be built.  It is customary to arrange test directories to be
2273 built after everything else since they are meant to test what has
2274 been constructed.
2276 All @samp{clean} rules are run in reverse order of build rules.
2278 @node Conditional Subdirectories
2279 @section Conditional Subdirectories
2280 @cindex Subdirectories, building conditionally
2281 @cindex Conditional subdirectories
2282 @cindex @code{SUBDIRS}, conditional
2283 @cindex Conditional @code{SUBDIRS}
2285 It is possible to define the @code{SUBDIRS} variable conditionally if,
2286 like in the case of GNU @code{Inetutils}, you want to only build a
2287 subset of the entire package.
2289 To illustrate how this works, let's assume we have two directories
2290 @file{src/} and @file{opt/}.  @file{src/} should always be built, but we
2291 want to decide in @code{./configure} whether @file{opt/} will be built
2292 or not.  (For this example we will assume that @file{opt/} should be
2293 built when the variable @code{$want_opt} was set to @code{yes}.)
2295 Running @code{make} should thus recurse into @file{src/} always, and
2296 then maybe in @file{opt/}.
2298 However @code{make dist} should always recurse into both @file{src/}
2299 and @file{opt/}.  Because @file{opt/} should be distributed even if it
2300 is not needed in the current configuration. This means
2301 @file{opt/Makefile} should be created @emph{unconditionally}.
2303 There are two ways to setup a project like this.  You can use Automake
2304 conditionals (@pxref{Conditionals}) or use Autoconf @code{AC_SUBST}
2305 variables (@pxref{Setting Output Variables, , Setting Output
2306 Variables, autoconf, The Autoconf Manual}).  Using Automake
2307 conditionals is the preferred solution.  Before we illustrate these
2308 two possibility, let's introduce @code{DIST_SUBDIRS}.
2310 @subsection @code{SUBDIRS} vs. @code{DIST_SUBDIRS}
2311 @cindex @code{DIST_SUBDIRS}, explained
2313 Automake considers two sets of directories, defined by the variables
2314 @code{SUBDIRS} and @code{DIST_SUBDIRS}.
2316 @code{SUBDIRS} contains the subdirectories of the current directory
2317 that must be built (@pxref{Subdirectories}).  It must be defined
2318 manually; Automake will never guess a directory is to be built.  As we
2319 will see in the next two sections, it is possible to define it
2320 conditionally so that some directory will be omitted from the build.
2322 @code{DIST_SUBDIRS} is used in rules that need to recurse in all
2323 directories, even those which have been conditionally left out of the
2324 build.  Recall our example where we may not want to build subdirectory
2325 @file{opt/}, but yet we want to distribute it?  This is where
2326 @code{DIST_SUBDIRS} come into play: @code{opt} may not appear in
2327 @code{SUBDIRS}, but it must appear in @code{DIST_SUBDIRS}.
2329 Precisely, @code{DIST_SUBDIRS} is used by @code{make dist}, @code{make
2330 distclean}, and @code{make maintainer-clean}.  All other recursive
2331 rules use @code{SUBDIRS}.
2333 If @code{SUBDIRS} is defined conditionally using Automake
2334 conditionals, Automake will define @code{DIST_SUBDIRS} automatically
2335 from the possibles values of @code{SUBDIRS} in all conditions.
2337 If @code{SUBDIRS} contains @code{AC_SUBST} variables,
2338 @code{DIST_SUBDIRS} will not be defined correctly because Automake
2339 does not know the possible values of these variables.  In this case
2340 @code{DIST_SUBDIRS} needs to be defined manually.
2342 @subsection Conditional subdirectories with @code{AM_CONDITIONAL}
2343 @cindex @code{SUBDIRS} and @code{AM_CONDITIONAL}
2344 @cindex @code{AM_CONDITIONAL} and @code{SUBDIRS}
2346 @c The test case for the setup described here is
2347 @c     test/subdircond2.test
2348 @c Try to keep it in sync.
2350 @file{configure} should output the @file{Makefile} for each directory
2351 and define a condition into which @file{opt/} should be built.
2353 @example
2354 @dots{}
2355 AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
2356 AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
2357 @dots{}
2358 @end example
2360 Then @code{SUBDIRS} can be defined in the top-level @file{Makefile.am}
2361 as follows.
2363 @example
2364 if COND_OPT
2365   MAYBE_OPT = opt
2366 endif
2367 SUBDIRS = src $(MAYBE_OPT)
2368 @end example
2370 As you can see, running @code{make} will rightly recurse into
2371 @file{src/} and maybe @file{opt/}.
2373 @vindex DIST_SUBDIRS
2374 As you can't see, running @code{make dist} will recurse into both
2375 @file{src/} and @file{opt/} directories because @code{make dist}, unlike
2376 @code{make all}, doesn't use the @code{SUBDIRS} variable.  It uses the
2377 @code{DIST_SUBDIRS} variable.
2379 In this case Automake will define @code{DIST_SUBDIRS = src opt}
2380 automatically because it knows that @code{MAYBE_OPT} can contain
2381 @code{opt} in some condition.
2383 @subsection Conditional Subdirectories with @code{AC_SUBST}
2384 @cindex @code{SUBDIRS} and @code{AC_SUBST}
2385 @cindex @code{AC_SUBST} and @code{SUBDIRS}
2387 @c The test case for the setup described here is
2388 @c     test/subdircond3.test
2389 @c Try to keep it in sync.
2391 Another possibility is to define @code{MAYBE_OPT} from
2392 @file{./configure} using @code{AC_SUBST}:
2394 @example
2395 @dots{}
2396 if test "$want_opt" = yes; then
2397   MAYBE_OPT=opt
2398 else
2399   MAYBE_OPT=
2401 AC_SUBST([MAYBE_OPT])
2402 AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
2403 @dots{}
2404 @end example
2406 In this case the top-level @file{Makefile.am} should look as follows.
2408 @example
2409 SUBDIRS = src $(MAYBE_OPT)
2410 DIST_SUBDIRS = src opt
2411 @end example
2413 The drawback is that since Automake cannot guess what the possible
2414 values of @code{MAYBE_OPT} are, it is necessary to define
2415 @code{DIST_SUBDIRS}.
2417 @subsection Non-configured Subdirectories
2418 @cindex Subdirectories, configured conditionally
2420 The semantic of @code{DIST_SUBDIRS} is often misunderstood by some
2421 users that try to @emph{configure and build} subdirectories
2422 conditionally.  Here by configuring we mean creating the
2423 @file{Makefile} (it might also involve running a nested
2424 @command{configure} script: this is a costly operation that explains
2425 why people want to do it conditionally, but only the @file{Makefile}
2426 is relevant to the discussion).
2428 The above examples all assume that every @file{Makefile} is created,
2429 even in directories that are not going to be built.  The simple reason
2430 is that we want @code{make dist} to distribute even the directories
2431 that are not being built (e.g. platform-dependent code), hence
2432 @file{make dist} must recurse into the subdirectory, hence this
2433 directory must be configured and appear in @code{DIST_SUBDIRS}.
2435 Building packages that do not configure every subdirectory is a tricky
2436 business, and we do not recommend it to the novice as it is easy to
2437 produce an incomplete tarball by mistake.  We will not discuss this
2438 topic in depth here, yet for the adventurous here are a few rules to
2439 remember.
2441 @cartouche
2442 @itemize
2443 @item @code{SUBDIRS} should always be a subset of @code{DIST_SUBDIRS}.
2445 It makes little sense to have a directory in @code{SUBDIRS} that
2446 is not in @code{DIST_SUBDIRS}.  Think of the former as a way to tell
2447 which directories listed in the latter should be built.
2448 @item Any directory listed in @code{DIST_SUBDIRS} and @code{SUBDIRS}
2449 must be configured.
2451 I.e., the @file{Makefile} must exists or the recursive @code{make}
2452 rules will not be able to process the directory.
2453 @item Any configured directory must be listed in @code{DIST_SUBDIRS}.
2455 So that the cleaning rule remove the generated @file{Makefile}s.
2456 It would be correct to see @code{DIST_SUBDIRS} as a variable that
2457 lists all the directories that have been configured.
2458 @end itemize
2459 @end cartouche
2461 In order to prevent recursion in some non-configured directory you
2462 must therefore ensure that this directory does not appear in
2463 @code{DIST_SUBDIRS} (and @code{SUBDIRS}).  For instance if you define
2464 @code{SUBDIRS} conditionally using @code{AC_SUBST} and do not define
2465 @code{DIST_SUBDIRS} explicitly, it will be default to
2466 @code{$(SUBDIRS)}; another possibility is to force @code{DIST_SUBDIRS
2467 = $(SUBDIRS)}.
2469 Of course, directories which are omitted from @code{DIST_SUBDIRS} will
2470 not be distributed unless you make other arrangements for this to
2471 happen (for instance always running @code{make dist} in a
2472 configuration where all directories are known to appear in
2473 @code{DIST_SUBDIRS}; or writing a @code{dist-hook} target to
2474 distribute these directories).
2476 @cindex Subdirectories, not distributed
2477 In few packages, non-configured directories are not even expected to
2478 be distributed.  Although these packages do not require the
2479 aforementioned extra arrangements, there is another pitfall.  If the
2480 name of a directory appears in @code{SUBDIRS} or @code{DIST_SUBDIRS},
2481 @command{automake} will make sure the directory exists.  Consequently
2482 @command{automake} cannot be run on such a distribution when one
2483 directory has been omitted.  One way to avoid this check is to use the
2484 @code{AC_SUBST} method to declare conditional directories; since
2485 @command{automake} does not know the values of @code{AC_SUBST}
2486 variables it cannot ensure the corresponding directory exist.
2488 @node Alternative
2489 @section An Alternative Approach to Subdirectories
2491 If you've ever read Peter Miller's excellent paper,
2492 @uref{http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html,
2493 Recursive Make Considered Harmful}, the preceding sections on the use of
2494 subdirectories will probably come as unwelcome advice.  For those who
2495 haven't read the paper, Miller's main thesis is that recursive
2496 @code{make} invocations are both slow and error-prone.
2498 Automake provides sufficient cross-directory support @footnote{We
2499 believe.  This work is new and there are probably warts.
2500 @xref{Introduction}, for information on reporting bugs.} to enable you
2501 to write a single @file{Makefile.am} for a complex multi-directory
2502 package.
2505 By default an installable file specified in a subdirectory will have its
2506 directory name stripped before installation.  For instance, in this
2507 example, the header file will be installed as
2508 @file{$(includedir)/stdio.h}:
2510 @example
2511 include_HEADERS = inc/stdio.h
2512 @end example
2514 @cindex nobase_
2515 @cindex Path stripping, avoiding
2516 @cindex Avoiding path stripping
2518 However, the @samp{nobase_} prefix can be used to circumvent this path
2519 stripping.  In this example, the header file will be installed as
2520 @file{$(includedir)/sys/types.h}:
2522 @example
2523 nobase_include_HEADERS = sys/types.h
2524 @end example
2526 @cindex nobase_ and dist_ or nodist_
2527 @cindex dist_ and nobase_
2528 @cindex nodist_ and nobase_
2530 @samp{nobase_} should be specified first when used in conjunction with
2531 either @samp{dist_} or @samp{nodist_} (@pxref{Dist}).  For instance:
2533 @example
2534 nobase_dist_pkgdata_DATA = images/vortex.pgm
2535 @end example
2538 @node Subpackages
2539 @section Nesting Packages
2540 @cindex Nesting packages
2541 @cindex Subpackages
2542 @cvindex AC_CONFIG_SUBDIRS
2543 @cvindex AC_CONFIG_AUX_DIR
2546 In the GNU Build System, packages can be nested to arbitrary depth.
2547 This means that a package can embedded other packages with their own
2548 @file{configure}, @file{Makefile}s, etc.
2550 These other packages should just appear as subdirectories of their
2551 parent package.  They must be listed in @code{SUBDIRS} like other
2552 ordinary directories.  However the subpackage's @file{Makefile}s
2553 should be output by its own @file{configure} script, not by the
2554 parent's @file{configure}.  This is achieved using the
2555 @code{AC_CONFIG_SUBDIRS} Autoconf macro (@pxref{Subdirectories,
2556 AC_CONFIG_SUBDIRS, Configuring Other Packages in Subdirectories,
2557 autoconf, The Autoconf Manual}).
2559 Here is an example package for an @code{arm} program that links with
2560 an @code{hand} library that is a nested package in subdirectory
2561 @file{hand/}.
2563 @code{arm}'s @file{configure.ac}:
2565 @example
2566 AC_INIT([arm], [1.0])
2567 AC_CONFIG_AUX_DIR([.])
2568 AM_INIT_AUTOMAKE
2569 AC_PROG_CC
2570 AC_CONFIG_FILES([Makefile])
2571 # Call hand's ./configure script recursively.
2572 AC_CONFIG_SUBDIRS([hand])
2573 AC_OUTPUT
2574 @end example
2576 @code{arm}'s @file{Makefile.am}:
2578 @example
2579 # Build the library in the hand subdirectory first.
2580 SUBDIRS = hand
2582 # Include hand's header when compiling this directory.
2583 AM_CPPFLAGS = -I$(srcdir)/hand
2585 bin_PROGRAMS = arm
2586 arm_SOURCES = arm.c
2587 # link with the hand library.
2588 arm_LDADD = hand/libhand.a
2589 @end example
2591 Now here is @code{hand}'s @file{hand/configure.ac}:
2593 @example
2594 AC_INIT([hand], [1.2])
2595 AC_CONFIG_AUX_DIR([.])
2596 AM_INIT_AUTOMAKE
2597 AC_PROG_CC
2598 AC_PROG_RANLIB
2599 AC_CONFIG_FILES([Makefile])
2600 AC_OUTPUT
2601 @end example
2603 @noindent
2604 and its @file{hand/Makefile.am}:
2606 @example
2607 lib_LIBRARIES = libhand.a
2608 libhand_a_SOURCES = hand.c
2609 @end example
2611 When @code{make dist} is run from the top-level directory it will
2612 create an archive @file{arm-1.0.tar.gz} that contains the @code{arm}
2613 code as well as the @file{hand} subdirectory.  This package can be
2614 built and installed like any ordinary package, with the usual
2615 @code{./configure && make && make install} sequence (the @code{hand}
2616 subpackage will be built and installed by the process).
2618 When @code{make dist} is run from the hand directory, it will create a
2619 self-contained @file{hand-1.2.tar.gz} archive.  So although it appears
2620 to be embedded in another package, it can still be used separately.
2622 The purpose of the @code{AC_CONFIG_AUX_DIR([.])} instruction is to
2623 force Automake and Autoconf into search auxiliary script in the
2624 current directory.  For instance this means that there will be two
2625 copies of @file{install-sh}: one in the top-level of the @code{arm}
2626 package, and another one in the @file{hand/} subdirectory for the
2627 @code{hand} package.
2629 The historical default is to search these auxiliary scripts in the
2630 immediate parent and grand-parent directories.  So if the
2631 @code{AC_CONFIG_AUX_DIR([.])} line was removed from
2632 @file{hand/configure.ac}, that subpackage would share the auxiliary
2633 script of the @code{arm} package.  This may looks like a gain in size
2634 (a few kilobytes), but it is actually a loss of modularity as the
2635 @code{hand} subpackage is no longer self-contained (@code{make dist}
2636 in the subdirectory will not work anymore).
2638 Packages that do not use Automake need more work to be integrated this
2639 way.  @xref{Third-Party Makefiles}.
2641 @node Programs
2642 @chapter Building Programs and Libraries
2644 A large part of Automake's functionality is dedicated to making it easy
2645 to build programs and libraries.
2647 @menu
2648 * A Program::                   Building a program
2649 * A Library::                   Building a library
2650 * A Shared Library::            Building a Libtool library
2651 * Program and Library Variables::  Variables controlling program and
2652                                 library builds
2653 * Default _SOURCES::            Default source files
2654 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
2655 * Program variables::           Variables used when building a program
2656 * Yacc and Lex::                Yacc and Lex support
2657 * C++ Support::                 Compiling C++ sources
2658 * Assembly Support::            Compiling assembly sources
2659 * Fortran 77 Support::          Compiling Fortran 77 sources
2660 * Fortran 9x Support::          Compiling Fortran 9x sources
2661 * Java Support::                Compiling Java sources
2662 * Support for Other Languages::  Compiling other languages
2663 * ANSI::                        Automatic de-ANSI-fication
2664 * Dependencies::                Automatic dependency tracking
2665 * EXEEXT::                      Support for executable extensions
2666 @end menu
2669 @node A Program
2670 @section Building a program
2672 In order to build a program, you need to tell Automake which sources
2673 are part of it, and which libraries it should be linked with.
2675 This section also covers conditional compilation of sources or
2676 programs.  Most of the comments about these also apply to libraries
2677 (@pxref{A Library}) and libtool libraries (@pxref{A Shared Library}).
2679 @menu
2680 * Program Sources::             Defining program sources
2681 * Linking::                     Linking with libraries or extra objects
2682 * Conditional Sources::         Handling conditional sources
2683 * Conditional Programs::        Building program conditionally
2684 @end menu
2686 @node Program Sources
2687 @subsection Defining program sources
2689 @cindex PROGRAMS, bindir
2690 @vindex bin_PROGRAMS
2691 @vindex sbin_PROGRAMS
2692 @vindex libexec_PROGRAMS
2693 @vindex pkglib_PROGRAMS
2694 @vindex noinst_PROGRAMS
2695 @vindex check_PROGRAMS
2697 In a directory containing source that gets built into a program (as
2698 opposed to a library or a script), the @samp{PROGRAMS} primary is used.
2699 Programs can be installed in @code{bindir}, @code{sbindir},
2700 @code{libexecdir}, @code{pkglibdir}, or not at all (@samp{noinst}).
2701 They can also be built only for @code{make check}, in which case the
2702 prefix is @samp{check}.
2704 For instance:
2706 @example
2707 bin_PROGRAMS = hello
2708 @end example
2710 In this simple case, the resulting @file{Makefile.in} will contain code
2711 to generate a program named @code{hello}.
2713 Associated with each program are several assisting variables which are
2714 named after the program.  These variables are all optional, and have
2715 reasonable defaults.  Each variable, its use, and default is spelled out
2716 below; we use the ``hello'' example throughout.
2718 The variable @code{hello_SOURCES} is used to specify which source files
2719 get built into an executable:
2721 @example
2722 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
2723 @end example
2725 This causes each mentioned @samp{.c} file to be compiled into the
2726 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
2728 @cindex _SOURCES primary, defined
2729 @cindex SOURCES primary, defined
2730 @cindex Primary variable, SOURCES
2732 If @samp{hello_SOURCES} is not specified, then it defaults to the single
2733 file @file{hello.c} (@pxref{Default _SOURCES}).
2734 @vindex _SOURCES
2735 @vindex SOURCES
2737 Multiple programs can be built in a single directory.  Multiple programs
2738 can share a single source file, which must be listed in each
2739 @samp{_SOURCES} definition.
2741 @cindex Header files in _SOURCES
2742 @cindex _SOURCES and header files
2744 Header files listed in a @samp{_SOURCES} definition will be included in
2745 the distribution but otherwise ignored.  In case it isn't obvious, you
2746 should not include the header file generated by @file{configure} in a
2747 @samp{_SOURCES} variable; this file should not be distributed.  Lex
2748 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
2749 and Lex}.
2752 @node Linking
2753 @subsection Linking the program
2755 If you need to link against libraries that are not found by
2756 @code{configure}, you can use @code{LDADD} to do so.  This variable is
2757 used to specify additional objects or libraries to link with; it is
2758 inappropriate for specifying specific linker flags, you should use
2759 @code{AM_LDFLAGS} for this purpose.
2760 @vindex LDADD
2761 @vindex AM_LDFLAGS
2763 @cindex prog_LDADD, defined
2765 Sometimes, multiple programs are built in one directory but do not share
2766 the same link-time requirements.  In this case, you can use the
2767 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
2768 program as it appears in some @samp{_PROGRAMS} variable, and usually
2769 written in lowercase) to override the global @code{LDADD}.  If this
2770 variable exists for a given program, then that program is not linked
2771 using @code{LDADD}.
2772 @vindex _LDADD
2774 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
2775 linked against the library @file{libcpio.a}.  However, @code{rmt} is
2776 built in the same directory, and has no such link requirement.  Also,
2777 @code{mt} and @code{rmt} are only built on certain architectures.  Here
2778 is what cpio's @file{src/Makefile.am} looks like (abridged):
2780 @example
2781 bin_PROGRAMS = cpio pax $(MT)
2782 libexec_PROGRAMS = $(RMT)
2783 EXTRA_PROGRAMS = mt rmt
2785 LDADD = ../lib/libcpio.a $(INTLLIBS)
2786 rmt_LDADD =
2788 cpio_SOURCES = @dots{}
2789 pax_SOURCES = @dots{}
2790 mt_SOURCES = @dots{}
2791 rmt_SOURCES = @dots{}
2792 @end example
2794 @cindex _LDFLAGS, defined
2796 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
2797 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
2798 @samp{-dlpreopen}).  So, use the @samp{@var{prog}_LDFLAGS} variable for
2799 this purpose.
2800 @vindex _LDFLAGS
2802 @cindex _DEPENDENCIES, defined
2804 It is also occasionally useful to have a program depend on some other
2805 target which is not actually part of that program.  This can be done
2806 using the @samp{@var{prog}_DEPENDENCIES} variable.  Each program depends
2807 on the contents of such a variable, but no further interpretation is
2808 done.
2810 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
2811 Automake.  The automatically-assigned value is the contents of
2812 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
2813 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed.  The
2814 configure substitutions that are left in are only @samp{$(LIBOBJS)} and
2815 @samp{$(ALLOCA)}; these are left because it is known that they will not
2816 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
2817 generated.
2820 @node Conditional Sources
2821 @subsection Conditional compilation of sources
2823 You can't put a configure substitution (e.g., @samp{@@FOO@@} or
2824 @samp{$(FOO)} where @code{FOO} is defined via @code{AC_SUBST}) into a
2825 @samp{_SOURCES} variable.  The reason for this is a bit hard to
2826 explain, but suffice to say that it simply won't work.  Automake will
2827 give an error if you try to do this.
2829 Fortunately there are two other ways to achieve the same result.  One is
2830 to use configure substitutions in @code{_LDADD} variables, the other is
2831 to use an Automake conditional.
2833 @subsubsection Conditional compilation using @code{_LDADD} substitutions
2835 @cindex EXTRA_prog_SOURCES, defined
2837 Automake must know all the source files that could possibly go into a
2838 program, even if not all the files are built in every circumstance.  Any
2839 files which are only conditionally built should be listed in the
2840 appropriate @samp{EXTRA_} variable.  For instance, if
2841 @file{hello-linux.c} or @file{hello-generic.c} were conditionally included
2842 in @code{hello}, the @file{Makefile.am} would contain:
2844 @example
2845 bin_PROGRAMS = hello
2846 hello_SOURCES = hello-common.c
2847 EXTRA_hello_SOURCES = hello-linux.c hello-generic.c
2848 hello_LDADD = $(HELLO_SYSTEM)
2849 hello_DEPENDENCIES = $(HELLO_SYSTEM)
2850 @end example
2852 @noindent
2853 You can then setup the @code{$(HELLO_SYSTEM)} substitution from
2854 @file{configure.ac}:
2856 @example
2857 @dots{}
2858 case $host in
2859   *linux*) HELLO_SYSTEM='hello-linux.$(OBJEXT)' ;;
2860   *)       HELLO_SYSTEM='hello-generic.$(OBJEXT)' ;;
2861 esac
2862 AC_SUBST([HELLO_SYSTEM])
2863 @dots{}
2864 @end example
2866 In this case, @code{HELLO_SYSTEM} should be replaced by
2867 @file{hello-linux.o} or @file{hello-generic.o}, and added to
2868 @code{hello_DEPENDENCIES} and @code{hello_LDADD} in order to be built
2869 and linked in.
2871 @subsubsection Conditional compilation using Automake conditionals
2873 An often simpler way to compile source files conditionally is to use
2874 Automake conditionals.  For instance, you could use this
2875 @file{Makefile.am} construct to build the same @file{hello} example:
2877 @example
2878 bin_PROGRAMS = hello
2879 if LINUX
2880 hello_SOURCES = hello-linux.c hello-common.c
2881 else
2882 hello_SOURCES = hello-generic.c hello-common.c
2883 endif
2884 @end example
2886 In this case, your @file{configure.ac} should setup the @code{LINUX}
2887 conditional using @code{AM_CONDITIONAL} (@pxref{Conditionals}).
2889 When using conditionals like this you don't need to use the
2890 @samp{EXTRA_} variable, because Automake will examine the contents of
2891 each variable to construct the complete list of source files.
2893 If your program uses a lot of files, you will probably prefer a
2894 conditional @code{+=}.
2896 @example
2897 bin_PROGRAMS = hello
2898 hello_SOURCES = hello-common.c
2899 if LINUX
2900 hello_SOURCES += hello-linux.c
2901 else
2902 hello_SOURCES += hello-generic.c
2903 endif
2904 @end example
2906 @node Conditional Programs
2907 @subsection Conditional compilation of programs
2908 @cindex Conditional programs
2909 @cindex Programs, conditional
2911 Sometimes it is useful to determine the programs that are to be built
2912 at configure time.  For instance, GNU @code{cpio} only builds
2913 @code{mt} and @code{rmt} under special circumstances.  The means to
2914 achieve conditional compilation of programs are the same you can use
2915 to compile source files conditionally: substitutions or conditionals.
2917 @subsubsection Conditional programs using @code{configure} substitutions
2919 In this case, you must notify Automake of all the programs that can
2920 possibly be built, but at the same time cause the generated
2921 @file{Makefile.in} to use the programs specified by @code{configure}.
2922 This is done by having @code{configure} substitute values into each
2923 @samp{_PROGRAMS} definition, while listing all optionally built programs
2924 in @code{EXTRA_PROGRAMS}.
2925 @vindex EXTRA_PROGRAMS
2926 @cindex EXTRA_PROGRAMS, defined
2928 @example
2929 bin_PROGRAMS = cpio pax $(MT)
2930 libexec_PROGRAMS = $(RMT)
2931 EXTRA_PROGRAMS = mt rmt
2932 @end example
2934 As explained in @ref{EXEEXT}, Automake will rewrite
2935 @code{bin_PROGRAMS}, @code{libexec_PROGRAMS}, and
2936 @code{EXTRA_PROGRAMS}, appending @code{$(EXEEXT)} to each binary.
2937 Obviously it cannot rewrite values obtained at run-time through
2938 @code{configure} substitutions, therefore you should take care of
2939 appending @code{$(EXEEXT)} yourself, as in @code{AC_SUBST([MT],
2940 ['mt$@{EXEEXT@}'])}.
2942 @subsubsection Conditional programs using Automake conditionals
2944 You can also use Automake conditionals (@pxref{Conditionals}) to
2945 select programs to be built.  In this case you don't have to worry
2946 about @code{$(EXEEXT)} or @code{EXTRA_PROGRAMS}.
2948 @example
2949 bin_PROGRAMS = cpio pax
2950 if WANT_MT
2951   bin_PROGRAMS += mt
2952 endif
2953 if WANT_RMT
2954   libexec_PROGRAMS = rmt
2955 endif
2956 @end example
2959 @node A Library
2960 @section Building a library
2962 @cindex _LIBRARIES primary, defined
2963 @cindex LIBRARIES primary, defined
2964 @cindex Primary variable, LIBRARIES
2966 @vindex lib_LIBRARIES
2967 @vindex pkglib_LIBRARIES
2968 @vindex noinst_LIBRARIES
2970 Building a library is much like building a program.  In this case, the
2971 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
2972 @code{libdir} or @code{pkglibdir}.
2974 @xref{A Shared Library}, for information on how to build shared
2975 libraries using libtool and the @samp{LTLIBRARIES} primary.
2977 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
2978 For instance to create a library named @file{libcpio.a}, but not install
2979 it, you would write:
2981 @example
2982 noinst_LIBRARIES = libcpio.a
2983 @end example
2985 The sources that go into a library are determined exactly as they are
2986 for programs, via the @samp{_SOURCES} variables.  Note that the library
2987 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
2988 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
2989 not @samp{liblob.a_SOURCES}.
2991 @cindex _LIBADD primary, defined
2992 @cindex LIBADD primary, defined
2993 @cindex Primary variable, LIBADD
2995 Extra objects can be added to a library using the
2996 @samp{@var{library}_LIBADD} variable.  This should be used for objects
2997 determined by @code{configure}.  Again from @code{cpio}:
2998 @vindex _LIBADD
2999 @vindex LIBADD
3001 @example
3002 libcpio_a_LIBADD = $(LIBOBJS) $(ALLOCA)
3003 @end example
3005 In addition, sources for extra objects that will not exist until
3006 configure-time must be added to the @code{BUILT_SOURCES} variable
3007 (@pxref{Sources}).
3009 Building a static library is done by compiling all object files, then
3010 by invoking @code{$(AR) $(ARFLAGS)} followed by the name of the
3011 library and the list of objects, and finally by calling
3012 @code{$(RANLIB)} on that library.  You should call
3013 @code{AC_PROG_RANLIB} from your @file{configure.ac} to define
3014 @code{RANLIB} (Automake will complain otherwise).  @code{AR} and
3015 @code{ARFLAGS} default to @code{ar} and @code{cru} respectively; you
3016 can override these two variables my setting them in your
3017 @file{Makefile.am}, by @code{AC_SUBST}ing them from your
3018 @file{configure.ac}, or by defining a per-library @code{maude_AR}
3019 variable (@pxref{Program and Library Variables}).
3021 @node A Shared Library
3022 @section Building a Shared Library
3024 @cindex Shared libraries, support for
3026 Building shared libraries portably is a relatively complex matter.
3027 For this reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
3028 Libtool Manual}) was created to help build shared libraries in a
3029 platform-independent way.
3031 @menu
3032 * Libtool Concept::             Introducing Libtool
3033 * Libtool Libraries::           Declaring Libtool Libraries
3034 * Conditional Libtool Libraries::  Building Libtool Libraries Conditionally
3035 * Conditional Libtool Sources::  Choosing Library Sources Conditionally
3036 * Libtool Convenience Libraries::  Building Convenience Libtool Libraries
3037 * Libtool Modules::             Building Libtool Modules
3038 * Libtool Flags::               Using _LIBADD and _LDFLAGS
3039 * LTLIBOBJS::                   Using $(LTLIBOBJS) and $(LTALLOCA)
3040 * Libtool Issues::              Common Issues Related to Libtool's Use
3041 @end menu
3043 @node Libtool Concept
3044 @subsection The Libtool Concept
3046 @cindex libtool, introduction
3047 @cindex libtool library, definition
3048 @cindex suffix .la, defined
3049 @cindex .la suffix, defined
3051 Libtool abstracts shared and static libraries into a unified
3052 concept henceforth called @dfn{libtool libraries}.  Libtool libraries
3053 are files using the @file{.la} suffix, and can designate a static
3054 library, a shared library, or maybe both.  Their exact nature cannot
3055 be determined until @file{./configure} is run: not all platforms
3056 support all kinds of libraries, and users can explicitly select which
3057 libraries should be built.  (However the package's maintainers can
3058 tune the default, @xref{AC_PROG_LIBTOOL, , The @code{AC_PROG_LIBTOOL}
3059 macro, libtool, The Libtool Manual}.)
3061 @cindex suffix .lo, defined
3062 Because object files for shared and static libraries must be compiled
3063 differently, libtool is also used during compilation.  Object files
3064 built by libtool are called @dfn{libtool objects}: these are files
3065 using the @file{.lo} suffix.  Libtool libraries are built from these
3066 libtool objects.
3068 You should not assume anything about the structure of @file{.la} or
3069 @file{.lo} files and how libtool constructs them: this is libtool's
3070 concern, and the last thing one wants is to learn about libtool's
3071 guts.  However the existence of these files matters, because they are
3072 used as targets and dependencies in @file{Makefile}s rules when
3073 building libtool libraries.  There are situations where you may have
3074 to refer to these, for instance when expressing dependencies for
3075 building source files conditionally (@pxref{Conditional Libtool
3076 Sources}).
3078 @cindex libltdl, introduction
3080 People considering writing a plug-in system, with dynamically loaded
3081 modules, should look into @file{libltdl}: libtool's dlopening library
3082 (@pxref{Using libltdl, , Using libltdl, libtool, The Libtool Manual}).
3083 This offers a portable dlopening facility to load libtool libraries
3084 dynamically, and can also achieve static linking where unavoidable.
3086 Before we discuss how to use libtool with Automake in details, it
3087 should be noted that the libtool manual also has a section about how
3088 to use Automake with libtool (@pxref{Using Automake, , Using Automake
3089 with Libtool, libtool, The Libtool Manual}).
3091 @node Libtool Libraries
3092 @subsection Building Libtool Libraries
3094 @cindex _LTLIBRARIES primary, defined
3095 @cindex LTLIBRARIES primary, defined
3096 @cindex Primary variable, LTLIBRARIES
3097 @cindex Example of shared libraries
3098 @vindex lib_LTLIBRARIES
3099 @vindex pkglib_LTLIBRARIES
3101 Automake uses libtool to build libraries declared with the
3102 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a
3103 list of libtool libraries to build.  For instance, to create a libtool
3104 library named @file{libgettext.la}, and install it in @samp{libdir},
3105 write:
3107 @example
3108 lib_LTLIBRARIES = libgettext.la
3109 libgettext_la_SOURCES = gettext.c gettext.h @dots{}
3110 @end example
3112 Automake predefines the variable @samp{pkglibdir}, so you can use
3113 @code{pkglib_LTLIBRARIES} to install libraries in
3114 @code{$(libdir)/@@PACKAGE@@/}.
3116 @node Conditional Libtool Libraries
3117 @subsection Building Libtool Libraries Conditionally
3118 @cindex libtool libraries, conditional
3119 @cindex conditional libtool libraries
3121 Like conditional programs (@pxref{Conditional Programs}), there are
3122 two main ways to build conditional libraries: using Automake
3123 conditionals or using Autoconf @code{AC_SUBST}itutions.
3125 The important implementation detail you have to be aware of is that
3126 the place where a library will be installed matters to libtool: it
3127 needs to be indicated @emph{at link-time} using the @code{-rpath}
3128 option.
3130 For libraries whose destination directory is known when Automake runs,
3131 Automake will automatically supply the appropriate @samp{-rpath}
3132 option to libtool. This is the case for libraries listed explicitly in
3133 some installable @code{_LTLIBRARIES} variables such as
3134 @code{lib_LTLIBRARIES}.
3136 However, for libraries determined at configure time (and thus
3137 mentioned in @code{EXTRA_LTLIBRARIES}), Automake does not know the
3138 final installation directory.  For such libraries you must add the
3139 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
3140 hand.
3142 The examples below illustrate the differences between these two methods.
3144 Here is an example where @code{$(WANTEDLIBS)} is an @code{AC_SUBST}ed
3145 variable set at @file{./configure}-time to either @file{libfoo.la},
3146 @file{libbar.la}, both, or none.  Although @code{$(WANTEDLIBS)}
3147 appears in the @code{lib_LTLIBRARIES}, Automake cannot guess it
3148 relates to @file{libfoo.la} or @file{libbar.la} by the time it creates
3149 the link rule for these two libraries.  Therefore the @code{-rpath}
3150 argument must be explicitly supplied.
3152 @example
3153 EXTRA_LTLIBRARIES = libfoo.la libbar.la
3154 lib_LTLIBRARIES = $(WANTEDLIBS)
3155 libfoo_la_SOURCES = foo.c @dots{}
3156 libfoo_la_LDFLAGS = -rpath '$(libdir)'
3157 libbar_la_SOURCES = bar.c @dots{}
3158 libbar_la_LDFLAGS = -rpath '$(libdir)'
3159 @end example
3161 Here is how the same @file{Makefile.am} would look using Automake
3162 conditionals named @code{WANT_LIBFOO} and @code{WANT_LIBBAR}.  Now
3163 Automake is able to compute the @code{-rpath} setting itself, because
3164 it's clear that both libraries will end up in @code{$(libdir)} if they
3165 are installed.
3167 @example
3168 lib_LTLIBRARIES =
3169 if WANT_LIBFOO
3170 lib_LTLIBRARIES += libfoo.la
3171 endif
3172 if WANT_LIBBAR
3173 lib_LTLIBRARIES += libbar.la
3174 endif
3175 libfoo_la_SOURCES = foo.c @dots{}
3176 libbar_la_SOURCES = bar.c @dots{}
3177 @end example
3179 @node Conditional Libtool Sources
3180 @subsection Libtool Libraries with Conditional Sources
3182 Conditional compilation of sources in a library can be achieved in the
3183 same way as conditional compilation of sources in a program
3184 (@pxref{Conditional Sources}).  The only difference is that
3185 @code{_LIBADD} should be used instead of @code{_LDADD} and that it
3186 should mention libtool objects (@file{.lo} files).
3188 So, to mimic the @file{hello} example from @ref{Conditional Sources},
3189 we could build a @file{libhello.la} library using either
3190 @file{hello-linux.c} or @file{hello-generic.c} with the following
3191 @file{Makefile.am}.
3193 @example
3194 lib_LTLIBRARIES = libhello.la
3195 libhello_la_SOURCES = hello-common.c
3196 EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
3197 libhello_la_LIBADD = $(HELLO_SYSTEM)
3198 libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
3199 @end example
3201 @noindent
3202 And make sure @code{$(HELLO_SYSTEM)} is set to either
3203 @file{hello-linux.lo} or @file{hello-generic.lo} in
3204 @file{./configure}.
3206 Or we could simply use an Automake conditional as follows.
3208 @example
3209 lib_LTLIBRARIES = libhello.la
3210 libhello_la_SOURCES = hello-common.c
3211 if LINUX
3212 libhello_la_SOURCES += hello-linux.c
3213 else
3214 libhello_la_SOURCES += hello-generic.c
3215 endif
3216 @end example
3218 @node Libtool Convenience Libraries
3219 @subsection Libtool Convenience Libraries
3220 @cindex convenience libraries, libtool
3221 @cindex libtool convenience libraries
3222 @vindex noinst_LTLIBRARIES
3223 @vindex check_LTLIBRARIES
3225 Sometimes you want to build libtool libraries which should not be
3226 installed.  These are called @dfn{libtool convenience libraries} and
3227 are typically used to encapsulate many sublibraries, later gathered
3228 into one big installed library.
3230 Libtool convenience libraries are declared by
3231 @code{noinst_LTLIBRARIES}, @code{check_LTLIBRARIES}, or even
3232 @code{EXTRA_LTLIBRARIES}.  Unlike installed libtool libraries they do
3233 not need an @code{-rpath} flag at link time (actually this is the only
3234 difference).
3236 Convenience libraries listed in @code{noinst_LTLIBRARIES} are always
3237 built.  Those listed in @code{check_LTLIBRARIES} are built only upon
3238 @code{make check}.  Finally, libraries listed in
3239 @code{EXTRA_LTLIBRARIES} are never built explicitly: Automake outputs
3240 rules to build them, but if the library does not appear as a Makefile
3241 dependency anywhere it won't be built (this is why
3242 @code{EXTRA_LTLIBRARIES} is used for conditional compilation).
3244 Here is a sample setup merging libtool convenience libraries from
3245 subdirectories into one main @file{libtop.la} library.
3247 @example
3248 # -- Top-level Makefile.am --
3249 SUBDIRS = sub1 sub2 @dots{}
3250 lib_LTLIBRARIES = libtop.la
3251 libtop_la_SOURCES =
3252 libtop_la_LIBADD = \
3253   sub1/libsub1.la \
3254   sub2/libsub2.la \
3255   @dots{}
3257 # -- sub1/Makefile.am --
3258 noinst_LTLIBRARIES = libsub1.la
3259 libsub1_la_SOURCES = @dots{}
3261 # -- sub2/Makefile.am --
3262 # showing nested convenience libraries
3263 SUBDIRS = sub2.1 sub2.2 @dots{}
3264 noinst_LTLIBRARIES = libsub2.la
3265 libsub2_la_SOURCES =
3266 libsub2_la_LIBADD = \
3267   sub21/libsub21.la \
3268   sub22/libsub22.la \
3269   @dots{}
3270 @end example
3272 When using such setup, beware that @command{automake} will assume
3273 @file{libtop.la} is to be linked with the C linker.  This is because
3274 @code{libtop_la_SOURCES} is empty, so @command{automake} picks C as
3275 default language.  If @code{libtop_la_SOURCES} was not empty,
3276 @command{automake} would select the linker as explained in @ref{How
3277 the Linker is Chosen}.
3279 If one of the sublibraries contains non-C source, it is important that
3280 the appropriate linker be chosen.  One way to achieve this is to
3281 pretend that there is such a non-C file among the sources of the
3282 library, thus forcing @command{automake} to select the appropriate
3283 linker.  Here is the top-level @file{Makefile} of our example updated
3284 to force C++ linking.
3286 @example
3287 SUBDIRS = sub1 sub2 @dots{}
3288 lib_LTLIBRARIES = libtop.la
3289 libtop_la_SOURCES =
3290 # Dummy C++ source to cause C++ linking.
3291 nodist_EXTRA_libtop_la_SOURCES = dummy.cxx
3292 libtop_la_LIBADD = \
3293   sub1/libsub1.la \
3294   sub2/libsub2.la \
3295   @dots{}
3296 @end example
3298 @code{EXTRA_*_SOURCES} variables are used to keep track of source
3299 files that might be compiled (this is mostly useful when doing
3300 conditional compilation using @code{AC_SUBST}, see @ref{Conditional
3301 Libtool Sources}), and the @code{nodist_} prefix means the listed
3302 sources are not to be distributed (@pxref{Program and Library
3303 Variables}).  In effect the file @file{dummy.cxx} does not need to
3304 exist in the source tree.  Of course if you have some real source file
3305 to list in @code{libtop_la_SOURCES} there is no point in cheating with
3306 @code{nodist_EXTRA_libtop_la_SOURCES}.
3309 @node Libtool Modules
3310 @subsection Libtool Modules
3311 @cindex modules, libtool
3312 @cindex libtool modules
3313 @cindex -module, libtool
3315 These are libtool libraries meant to be dlopened.  They are
3316 indicated to libtool by passing @code{-module} at link-time.
3318 @example
3319 pkglib_LTLIBRARIES = mymodule.la
3320 mymodule_la_SOURCES = doit.c
3321 mymodule_la_LDFLAGS = -module
3322 @end example
3324 Ordinarily, Automake requires that a library's name starts with
3325 @samp{lib}.  However, when building a dynamically loadable module you
3326 might wish to use a "nonstandard" name.  Automake will not complain
3327 about such nonstandard name if it knows the library being built is a
3328 libtool module, i.e., if @samp{-module} explicitly appears in the
3329 library's @code{_LDFLAGS} variable (or in the common @code{AM_LDFLAGS}
3330 variable when no per-library @code{_LDFLAGS} variable is defined).
3332 As always, @code{AC_SUBST} variables are black boxes to Automake since
3333 their values are not yet known when @command{automake} is run.
3334 Therefore if @code{-module} is set via such a variable, Automake
3335 cannot notice it and will proceed as if the library was an ordinary
3336 libtool library, with strict naming.
3338 If @samp{mymodule_la_SOURCES} is not specified, then it defaults to
3339 the single file @file{mymodule.c} (@pxref{Default _SOURCES}).
3341 @node Libtool Flags
3342 @subsection _LIBADD and _LDFLAGS
3343 @cindex _LIBADD, libtool
3344 @cindex _LDFLAGS, libtool
3346 As shown in previous sections, the @samp{@var{library}_LIBADD}
3347 variable should be used to list extra libtool objects (@file{.lo}
3348 files) or libtool libraries (@file{.la}) to add to @var{library}.
3350 The @samp{@var{library}_LDFLAGS} variable is the place to list
3351 additional libtool flags, such as @samp{-version-info},
3352 @samp{-static}, and a lot more.  See @xref{Link mode, , Using libltdl,
3353 libtool, The Libtool Manual}.
3355 @node LTLIBOBJS, Libtool Issues, Libtool Flags, A Shared Library
3356 @subsection @code{LTLIBOBJS} and @code{LTALLOCA}
3357 @cindex @code{LTLIBOBJS}, special handling
3358 @cindex @code{LIBOBJS}, and Libtool
3359 @cindex @code{LTALLOCA}, special handling
3360 @cindex @code{ALLOCA}, and Libtool
3361 @vindex LTLIBOBJS
3362 @vindex LIBOBJS
3363 @vindex LTALLOCA
3364 @vindex ALLOCA
3365 @cvindex AC_LIBOBJ
3367 Where an ordinary library might include @code{$(LIBOBJS)} or
3368 @code{$(ALLOCA)} (@pxref{LIBOBJS}), a libtool library must use
3369 @code{$(LTLIBOBJS)} or @code{$(LTALLOCA)}.  This is required because
3370 the object files that libtool operates on do not necessarily end in
3371 @file{.o}.
3373 Nowadays, the computation of @code{LTLIBOBJS} from @code{LIBOBJS} is
3374 performed automatically by Autoconf (@pxref{AC_LIBOBJ vs LIBOBJS, ,
3375 @code{AC_LIBOBJ} vs. @code{LIBOBJS}, autoconf, The Autoconf Manual}).
3377 @node Libtool Issues
3378 @subsection Common Issues Related to Libtool's Use
3380 @subsubsection @code{required file `./ltmain.sh' not found}
3381 @cindex ltmain.sh not found
3382 @cindex libtoolize, no longer run by Automake
3383 @cindex libtoolize and autoreconf
3384 @cindex autoreconf and libtoolize
3385 @cindex bootstrap.sh and autoreconf
3386 @cindex autogen.sh and autoreconf
3388 Libtool comes with a tool called @command{libtoolize} that will
3389 install libtool's supporting files into a package.  Running this
3390 command will install @file{ltmain.sh}.  You should execute it before
3391 @command{aclocal} and @command{automake}.
3393 People upgrading old packages to newer autotools are likely to face
3394 this issue because older Automake versions used to call
3395 @command{libtoolize}.  Therefore old build scripts do not call
3396 @command{libtoolize}.
3398 Since Automake 1.6, it has been decided that running
3399 @command{libtoolize} was none of Automake's business.  Instead, that
3400 functionality has been moved into the @command{autoreconf} command
3401 (@pxref{autoreconf Invocation, , Using @command{autoreconf}, autoconf,
3402 The Autoconf Manual}).  If you do not want to remember what to run and
3403 when, just learn the @command{autoreconf} command.  Hopefully,
3404 replacing existing @file{bootstrap.sh} or @file{autogen.sh} scripts by
3405 a call to @command{autoreconf} should also free you from any similar
3406 incompatible change in the future.
3408 @subsubsection Objects @code{created with both libtool and without}
3410 Sometimes, the same source file is used both to build a libtool
3411 library and to build another non-libtool target (be it a program or
3412 another library).
3414 Let's consider the following @file{Makefile.am}.
3416 @example
3417 bin_PROGRAMS = prog
3418 prog_SOURCES = prog.c foo.c @dots{}
3420 lib_LTLIBRARIES = libfoo.la
3421 libfoo_la_SOURCES = foo.c @dots{}
3422 @end example
3424 @noindent
3425 (In this trivial case the issue could be avoided by linking
3426 @file{libfoo.la} with @file{prog} instead of listing @file{foo.c} in
3427 @code{prog_SOURCES}.  But let's assume we really want to keep
3428 @file{prog} and @file{libfoo.la} separate.)
3430 Technically, it means that we should build @file{foo.$(OBJEXT)} for
3431 @file{prog}, and @file{foo.lo} for @file{libfoo.la}.  The problem is
3432 that in the course of creating @file{foo.lo}, libtool may erase (or
3433 replace) @file{foo.$(OBJEXT)} -- and this cannot be avoided.
3435 Therefore, when Automake detects this situation it will complain
3436 with a message such as
3437 @example
3438 object `foo.$(OBJEXT)' created both with libtool and without
3439 @end example
3441 A workaround for this issue is to ensure that these two objects get
3442 different basenames.  As explained in @ref{renamed objects}, this
3443 happens automatically when per-targets flags are used.
3445 @example
3446 bin_PROGRAMS = prog
3447 prog_SOURCES = prog.c foo.c @dots{}
3448 prog_CFLAGS = $(AM_CFLAGS)
3450 lib_LTLIBRARIES = libfoo.la
3451 libfoo_la_SOURCES = foo.c @dots{}
3452 @end example
3454 @noindent
3455 Adding @code{prog_CFLAGS = $(AM_CFLAGS)} is almost a no-op, because
3456 when the @code{prog_CFLAGS} is defined, it is used instead of
3457 @code{AM_CFLAGS}.  However as a side effect it will cause
3458 @file{prog.c} and @file{foo.c} to be compiled as
3459 @file{prog-prog.$(OBJEXT)} and @file{prog-foo.$(OBJEXT)} which solves
3460 the issue.
3462 @node Program and Library Variables
3463 @section Program and Library Variables
3465 Associated with each program are a collection of variables which can be
3466 used to modify how that program is built.  There is a similar list of
3467 such variables for each library.  The canonical name of the program (or
3468 library) is used as a base for naming these variables.
3470 In the list below, we use the name ``maude'' to refer to the program or
3471 library.  In your @file{Makefile.am} you would replace this with the
3472 canonical name of your program.  This list also refers to ``maude'' as a
3473 program, but in general the same rules apply for both static and dynamic
3474 libraries; the documentation below notes situations where programs and
3475 libraries differ.
3477 @table @samp
3478 @item maude_SOURCES
3479 This variable, if it exists, lists all the source files which are
3480 compiled to build the program.  These files are added to the
3481 distribution by default.  When building the program, Automake will cause
3482 each source file to be compiled to a single @file{.o} file (or
3483 @file{.lo} when using libtool).  Normally these object files are named
3484 after the source file, but other factors can change this.  If a file in
3485 the @samp{_SOURCES} variable has an unrecognized extension, Automake
3486 will do one of two things with it.  If a suffix rule exists for turning
3487 files with the unrecognized extension into @file{.o} files, then
3488 automake will treat this file as it will any other source file
3489 (@pxref{Support for Other Languages}).  Otherwise, the file will be
3490 ignored as though it were a header file.
3492 The prefixes @samp{dist_} and @samp{nodist_} can be used to control
3493 whether files listed in a @samp{_SOURCES} variable are distributed.
3494 @samp{dist_} is redundant, as sources are distributed by default, but it
3495 can be specified for clarity if desired.
3497 It is possible to have both @samp{dist_} and @samp{nodist_} variants of
3498 a given @samp{_SOURCES} variable at once; this lets you easily
3499 distribute some files and not others, for instance:
3501 @example
3502 nodist_maude_SOURCES = nodist.c
3503 dist_maude_SOURCES = dist-me.c
3504 @end example
3506 By default the output file (on Unix systems, the @file{.o} file) will be
3507 put into the current build directory.  However, if the option
3508 @code{subdir-objects} is in effect in the current directory then the
3509 @file{.o} file will be put into the subdirectory named after the source
3510 file.  For instance, with @code{subdir-objects} enabled,
3511 @file{sub/dir/file.c} will be compiled to @file{sub/dir/file.o}.  Some
3512 people prefer this mode of operation.  You can specify
3513 @code{subdir-objects} in @code{AUTOMAKE_OPTIONS} (@pxref{Options}).
3514 @cindex Subdirectory, objects in
3515 @cindex Objects in subdirectory
3518 @item EXTRA_maude_SOURCES
3519 Automake needs to know the list of files you intend to compile
3520 @emph{statically}.  For one thing, this is the only way Automake has of
3521 knowing what sort of language support a given @file{Makefile.in}
3522 requires.  @footnote{There are other, more obscure reasons for
3523 this limitation as well.}  This means that, for example, you can't put a
3524 configure substitution like @samp{@@my_sources@@} into a @samp{_SOURCES}
3525 variable.  If you intend to conditionally compile source files and use
3526 @file{configure} to substitute the appropriate object names into, e.g.,
3527 @samp{_LDADD} (see below), then you should list the corresponding source
3528 files in the @samp{EXTRA_} variable.
3530 This variable also supports @samp{dist_} and @samp{nodist_} prefixes,
3531 e.g., @samp{nodist_EXTRA_maude_SOURCES}.
3533 @item maude_AR
3534 A static library is created by default by invoking @code{$(AR)
3535 $(ARFLAGS)} followed by the name of the library and then the objects
3536 being put into the library.  You can override this by setting the
3537 @samp{_AR} variable.  This is usually used with C++; some C++
3538 compilers require a special invocation in order to instantiate all the
3539 templates which should go into a library.  For instance, the SGI C++
3540 compiler likes this variable set like so:
3541 @example
3542 libmaude_a_AR = $(CXX) -ar -o
3543 @end example
3545 @item maude_LIBADD
3546 Extra objects can be added to a @emph{library} using the @samp{_LIBADD}
3547 variable.  For instance this should be used for objects determined by
3548 @code{configure} (@pxref{A Library}).
3550 @item maude_LDADD
3551 Extra objects can be added to a @emph{program} by listing them in the
3552 @samp{_LDADD} variable.  For instance this should be used for objects
3553 determined by @code{configure} (@pxref{Linking}).
3555 @samp{_LDADD} and @samp{_LIBADD} are inappropriate for passing
3556 program-specific linker flags (except for @samp{-l}, @samp{-L},
3557 @samp{-dlopen} and @samp{-dlpreopen}).  Use the @samp{_LDFLAGS} variable
3558 for this purpose.
3560 For instance, if your @file{configure.ac} uses @code{AC_PATH_XTRA}, you
3561 could link your program against the X libraries like so:
3563 @example
3564 maude_LDADD = $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS)
3565 @end example
3567 @item maude_LDFLAGS
3568 This variable is used to pass extra flags to the link step of a program
3569 or a shared library.
3571 @item maude_DEPENDENCIES
3572 It is also occasionally useful to have a program depend on some other
3573 target which is not actually part of that program.  This can be done
3574 using the @samp{_DEPENDENCIES} variable.  Each program depends on the
3575 contents of such a variable, but no further interpretation is done.
3577 If @samp{_DEPENDENCIES} is not supplied, it is computed by Automake.
3578 The automatically-assigned value is the contents of @samp{_LDADD} or
3579 @samp{_LIBADD}, with most configure substitutions, @samp{-l}, @samp{-L},
3580 @samp{-dlopen} and @samp{-dlpreopen} options removed.  The configure
3581 substitutions that are left in are only @samp{$(LIBOBJS)} and
3582 @samp{$(ALLOCA)}; these are left because it is known that they will not
3583 cause an invalid value for @samp{_DEPENDENCIES} to be generated.
3585 @item maude_LINK
3586 You can override the linker on a per-program basis.  By default the
3587 linker is chosen according to the languages used by the program.  For
3588 instance, a program that includes C++ source code would use the C++
3589 compiler to link.  The @samp{_LINK} variable must hold the name of a
3590 command which can be passed all the @file{.o} file names as arguments.
3591 Note that the name of the underlying program is @emph{not} passed to
3592 @samp{_LINK}; typically one uses @samp{$@@}:
3594 @example
3595 maude_LINK = $(CCLD) -magic -o $@@
3596 @end example
3598 @item maude_CCASFLAGS
3599 @itemx maude_CFLAGS
3600 @itemx maude_CPPFLAGS
3601 @itemx maude_CXXFLAGS
3602 @itemx maude_FFLAGS
3603 @itemx maude_GCJFLAGS
3604 @itemx maude_LFLAGS
3605 @itemx maude_OBJCFLAGS
3606 @itemx maude_RFLAGS
3607 @itemx maude_YFLAGS
3608 @cindex per-target compilation flags, defined
3609 Automake allows you to set compilation flags on a per-program (or
3610 per-library) basis.  A single source file can be included in several
3611 programs, and it will potentially be compiled with different flags for
3612 each program.  This works for any language directly supported by
3613 Automake.  These @dfn{per-target compilation flags} are
3614 @samp{_CCASFLAGS},
3615 @samp{_CFLAGS},
3616 @samp{_CPPFLAGS},
3617 @samp{_CXXFLAGS},
3618 @samp{_FFLAGS},
3619 @samp{_GCJFLAGS},
3620 @samp{_LFLAGS},
3621 @samp{_OBJCFLAGS},
3622 @samp{_RFLAGS}, and
3623 @samp{_YFLAGS}.
3625 When using a per-target compilation flag, Automake will choose a
3626 different name for the intermediate object files.  Ordinarily a file
3627 like @file{sample.c} will be compiled to produce @file{sample.o}.
3628 However, if the program's @samp{_CFLAGS} variable is set, then the
3629 object file will be named, for instance, @file{maude-sample.o}.  (See
3630 also @ref{renamed objects}.)  The use of per-target compilation flags
3631 with C sources requires that the macro @code{AM_PROG_CC_C_O} be called
3632 from @file{configure.ac}.
3634 In compilations with per-target flags, the ordinary @samp{AM_} form of
3635 the flags variable is @emph{not} automatically included in the
3636 compilation (however, the user form of the variable @emph{is} included).
3637 So for instance, if you want the hypothetical @file{maude} compilations
3638 to also use the value of @samp{AM_CFLAGS}, you would need to write:
3640 @example
3641 maude_CFLAGS = @dots{} your flags @dots{} $(AM_CFLAGS)
3642 @end example
3644 @xref{Flag Variables Ordering}, for more discussion about the
3645 interaction between user variables, @code{AM_} shadow variables, and
3646 per-target variables.
3648 @item maude_SHORTNAME
3649 On some platforms the allowable file names are very short.  In order to
3650 support these systems and per-target compilation flags at the same
3651 time, Automake allows you to set a ``short name'' which will influence
3652 how intermediate object files are named.  For instance, in the following
3653 example,
3655 @example
3656 bin_PROGRAMS = maude
3657 maude_CPPFLAGS = -DSOMEFLAG
3658 maude_SHORTNAME = m
3659 maude_SOURCES = sample.c @dots{}
3660 @end example
3662 @noindent
3663 the object file would be named @file{m-sample.o} rather than
3664 @file{maude-sample.o}.
3666 This facility is rarely needed in practice,
3667 and we recommend avoiding it until you find it is required.
3668 @end table
3670 @node Default _SOURCES
3671 @section Default @code{_SOURCES}
3673 @vindex _SOURCES
3674 @vindex SOURCES
3675 @cindex @code{_SOURCES}, default
3676 @cindex default @code{_SOURCES}
3678 @code{_SOURCES} variables are used to specify source files of programs
3679 (@pxref{A Program}), libraries (@pxref{A Library}), and Libtool
3680 libraries (@pxref{A Shared Library}).
3682 When no such variable is specified for a target, Automake will define
3683 one itself.  The default is to compile a single C file whose base name
3684 is the name of the target itself, with any extension replaced by
3685 @file{.c}.  (Defaulting to C is terrible but we are stuck with it for
3686 historical reasons.)
3688 For example if you have the following somewhere in your
3689 @file{Makefile.am} with no corresponding @samp{libfoo_a_SOURCES}:
3691 @example
3692 lib_LIBRARIES = libfoo.a sub/libc++.a
3693 @end example
3695 @noindent
3696 @file{libfoo.a} will be built using a default source file named
3697 @file{libfoo.c}, and @file{sub/libc++.a} will be built from
3698 @file{sub/libc++.c}.  (In older versions @file{sub/libc++.a}
3699 would be built from @file{sub_libc___a.c}, i.e., the default source
3700 was the canonized name of the target, with @file{.c} appended.
3701 We believe the new behavior is more sensible, but for backward
3702 compatibility automake will use the old name if a file or a rule
3703 with that name exist.)
3705 @cindex @code{check_PROGRAMS} example
3706 @vindex check_PROGRAMS
3707 Default sources are mainly useful in test suites, when building many
3708 tests programs each from a single source.  For instance in
3710 @example
3711 check_PROGRAMS = test1 test2 test3
3712 @end example
3714 @noindent
3715 @file{test1}, @file{test2}, and @file{test3} will be built
3716 from @file{test1.c}, @file{test2.c}, and @file{test3.c}.
3718 @cindex Libtool modules, default source example
3719 @cindex default source, Libtool modules example
3720 Another case where is this convenient is building many Libtool modules
3721 (@file{moduleN.la}), each defined in its own file (@file{moduleN.c}).
3723 @example
3724 AM_LDFLAGS = -module
3725 lib_LTLIBRARIES = module1.la module2.la module3.la
3726 @end example
3728 @cindex empty @code{_SOURCES}
3729 @cindex @code{_SOURCES}, empty
3730 Finally, there is one situation where this default source computation
3731 needs to be avoided: when a target should not be built from sources.
3732 We already saw such an example in @ref{true}; this happens when all
3733 the constituents of a target have already been compiled and need just
3734 to be combined using a @code{_LDADD} variable.  Then it is necessary
3735 to define an empty @code{_SOURCES} variable, so that automake does not
3736 compute a default.
3738 @example
3739 bin_PROGRAMS = target
3740 target_SOURCES =
3741 target_LDADD = libmain.a libmisc.a
3742 @end example
3744 @node LIBOBJS
3745 @section Special handling for LIBOBJS and ALLOCA
3747 @cindex @code{LIBOBJS}, example
3748 @cindex @code{ALLOCA}, example
3749 @cindex @code{LIBOBJS}, special handling
3750 @cindex @code{ALLOCA}, special handling
3751 @vindex LTLIBOBJS
3752 @vindex LIBOBJS
3753 @vindex LTALLOCA
3754 @vindex ALLOCA
3756 The @code{$(LIBOBJS)} and @code{$(ALLOCA)} variables list object
3757 files that should be compiled into the project to provide an
3758 implementation for functions that are missing or broken on the host
3759 system.  They are substituted by @file{configure}.
3761 @cvindex AC_LIBOBJ
3763 These variables are defined by Autoconf macros such as
3764 @code{AC_LIBOBJ}, @code{AC_REPLACE_FUNCS} (@pxref{Generic Functions, ,
3765 Generic Function Checks, autoconf, The Autoconf Manual}), or
3766 @code{AC_FUNC_ALLOCA} (@pxref{Particular Functions, , Particular
3767 Function Checks, autoconf, The Autoconf Manual}).  Many other Autoconf
3768 macros call @code{AC_LIBOBJ} or @code{AC_REPLACE_FUNCS} to
3769 populate @code{$(LIBOBJS)}.
3771 @cvindex AC_LIBSOURCE
3773 Using these variables is very similar to doing conditional compilation
3774 using @code{AC_SUBST} variables, as described in @ref{Conditional
3775 Sources}.  That is, when building a program, @code{$(LIBOBJS)} and
3776 @code{$(ALLOCA)} should be added to the associated @samp{*_LDADD}
3777 variable, or to the @samp{*_LIBADD} variable when building a library.
3778 However there is no need to list the corresponding sources in
3779 @code{EXTRA_*_SOURCES} nor to define @code{*_DEPENDENCIES}.  Automake
3780 automatically adds @code{$(LIBOBJS)} and @code{$(ALLOCA)} to the
3781 dependencies, and it will discover the list of corresponding source
3782 files automatically (by tracing the invocations of the
3783 @code{AC_LIBSOURCE} Autoconf macros).
3785 These variables are usually used to build a portability library that
3786 is linked with all the programs of the project.  We now review a
3787 sample setup.  First, @file{configure.ac} contains some checks that
3788 affect either @code{LIBOBJS} or @code{ALLOCA}.
3790 @example
3791 # configure.ac
3792 @dots{}
3793 AC_CONFIG_LIBOBJ_DIR([lib])
3794 @dots{}
3795 AC_FUNC_MALLOC             dnl May add malloc.$(OBJEXT) to LIBOBJS
3796 AC_FUNC_MEMCMP             dnl May add memcmp.$(OBJEXT) to LIBOBJS
3797 AC_REPLACE_FUNCS([strdup]) dnl May add strdup.$(OBJEXT) to LIBOBJS
3798 AC_FUNC_ALLOCA             dnl May add alloca.$(OBJEXT) to ALLOCA
3799 @dots{}
3800 AC_CONFIG_FILES([
3801   lib/Makefile
3802   src/Makefile
3804 AC_OUTPUT
3805 @end example
3807 @cvindex AC_CONFIG_LIBOBJ_DIR
3809 The @code{AC_CONFIG_LIBOBJ_DIR} tells Autoconf that the source files
3810 of these object files are to be found in the @file{lib/} directory.
3811 Automake does not yet use this information; it knows the source files
3812 are expected to be in the directory where the @code{$(LIBOBJS)} and
3813 @code{$(ALLOCA)} variables are used.
3815 The @file{lib/} directory should therefore contain @file{malloc.c},
3816 @file{memcmp.c}, @file{strdup.c}, @file{alloca.c}.  Here is its
3817 @file{Makefile.am}:
3819 @example
3820 # lib/Makefile.am
3822 noinst_LIBRARIES = libcompat.a
3823 libcompat_a_SOURCES =
3824 libcompat_a_LIBADD = $(LIBOBJS) $(ALLOCA)
3825 @end example
3827 Nothing else is required.  The library can have any name, of course,
3828 and anyway it is not going to be installed: it just holds the
3829 replacement versions of the missing or broken functions so we can
3830 later link them in.  In many projects also include extra functions,
3831 specific to the project, in that library: they are simply added on
3832 the @code{_SOURCES} line.
3834 Finally here is how this library could be used from the @file{src/}
3835 directory.
3837 @example
3838 # src/Makefile.am
3840 # Link all programs in this directory with libcompat.a
3841 LDADD = ../lib/libcompat.a
3843 bin_PROGRAMS = tool1 tool2 @dots{}
3844 tool1_SOURCES = @dots{}
3845 tool2_SOURCES = @dots{}
3846 @end example
3848 Please note it would be wrong to use the @code{$(LIBOBJS)} or
3849 @code{$(ALLOCA)} in @file{src/Makefile.am}, because these variables
3850 contains unprefixed object names, and for instance
3851 @file{malloc.$(OBJEXT)} is not buildable in the @file{src/} directory.
3852 (Actually if you try using @code{$(LIBOBJS)} in @file{src/}, Automake
3853 will require a copy of @file{malloc.c}, @file{memcmp.c},
3854 @file{strdup.c}, @file{alloca.c} in @file{src/} too.)
3856 Because @code{$(LIBOBJS)} and @code{$(ALLOCA)} contain object
3857 filenames that end with @code{.$(OBJEXT)}, they are not suitable for
3858 Libtool libraries (where the expected object extension is @file{.lo}):
3859 @code{LTLIBOBJS} and @code{LTALLOCA} should be used instead.
3861 @code{LTLIBOBJS} is defined automatically by Autoconf and should not
3862 be defined by hand (as in the past), however at the time of writing
3863 @code{LTALLOCA} still needs to be defined from @code{ALLOCA} manually.
3864 See @ref{AC_LIBOBJ vs LIBOBJS, , @code{AC_LIBOBJ} vs. @code{LIBOBJS},
3865 autoconf, The Autoconf Manual}.
3868 @node Program variables
3869 @section Variables used when building a program
3871 Occasionally it is useful to know which @file{Makefile} variables
3872 Automake uses for compilations; for instance you might need to do your
3873 own compilation in some special cases.
3875 Some variables are inherited from Autoconf; these are @code{CC},
3876 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
3877 @code{LIBS}.
3878 @vindex CC
3879 @vindex CFLAGS
3880 @vindex CPPFLAGS
3881 @vindex DEFS
3882 @vindex LDFLAGS
3883 @vindex LIBS
3885 There are some additional variables which Automake itself defines:
3887 @vtable @code
3888 @item AM_CPPFLAGS
3889 The contents of this variable are passed to every compilation which invokes
3890 the C preprocessor; it is a list of arguments to the preprocessor.  For
3891 instance, @samp{-I} and @samp{-D} options should be listed here.
3893 Automake already provides some @samp{-I} options automatically.  In
3894 particular it generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I}
3895 pointing to the directory holding @file{config.h} (if you've used
3896 @code{AC_CONFIG_HEADERS} or @code{AM_CONFIG_HEADER}).  You can disable
3897 the default @samp{-I} options using the @samp{nostdinc} option.
3899 @code{AM_CPPFLAGS} is ignored in preference to a per-executable (or
3900 per-library) @code{_CPPFLAGS} variable if it is defined.
3902 @item INCLUDES
3903 This does the same job as @samp{AM_CPPFLAGS} (or any per-target
3904 @samp{_CPPFLAGS} variable if it is used).  It is an older name for the
3905 same functionality.  This variable is deprecated; we suggest using
3906 @samp{AM_CPPFLAGS} and per-target @samp{_CPPFLAGS} instead.
3908 @item AM_CFLAGS
3909 This is the variable which the @file{Makefile.am} author can use to pass
3910 in additional C compiler flags.  It is more fully documented elsewhere.
3911 In some situations, this is not used, in preference to the
3912 per-executable (or per-library) @code{_CFLAGS}.
3914 @item COMPILE
3915 This is the command used to actually compile a C source file.  The
3916 filename is appended to form the complete command line.
3918 @item AM_LDFLAGS
3919 This is the variable which the @file{Makefile.am} author can use to pass
3920 in additional linker flags.  In some situations, this is not used, in
3921 preference to the per-executable (or per-library) @code{_LDFLAGS}.
3923 @item LINK
3924 This is the command used to actually link a C program.  It already
3925 includes @samp{-o $@@} and the usual variable references (for instance,
3926 @code{CFLAGS}); it takes as ``arguments'' the names of the object files
3927 and libraries to link in.
3928 @end vtable
3931 @node Yacc and Lex
3932 @section Yacc and Lex support
3934 Automake has somewhat idiosyncratic support for Yacc and Lex.
3936 Automake assumes that the @file{.c} file generated by @code{yacc} (or
3937 @code{lex}) should be named using the basename of the input file.  That
3938 is, for a yacc source file @file{foo.y}, Automake will cause the
3939 intermediate file to be named @file{foo.c} (as opposed to
3940 @file{y.tab.c}, which is more traditional).
3942 The extension of a yacc source file is used to determine the extension
3943 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
3944 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
3945 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
3946 @samp{.cxx}.
3948 Likewise, lex source files can be used to generate @samp{C} or
3949 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
3950 @samp{.lxx} are recognized.
3952 You should never explicitly mention the intermediate (@samp{C} or
3953 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
3954 file.
3956 The intermediate files generated by @code{yacc} (or @code{lex}) will be
3957 included in any distribution that is made.  That way the user doesn't
3958 need to have @code{yacc} or @code{lex}.
3960 If a @code{yacc} source file is seen, then your @file{configure.ac} must
3961 define the variable @samp{YACC}.  This is most easily done by invoking
3962 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
3963 Program Checks, autoconf, The Autoconf Manual}).
3965 When @code{yacc} is invoked, it is passed @samp{YFLAGS} and
3966 @samp{AM_YFLAGS}.  The former is a user variable and the latter is
3967 intended for the @file{Makefile.am} author.
3969 @samp{AM_YFLAGS} is usually used to pass the @code{-d} option to
3970 @code{yacc}.  Automake knows what this means and will automatically
3971 adjust its rules to update and distribute the header file built by
3972 @code{yacc -d}.  What Automake cannot guess, though, is where this
3973 header will be used: it is up to you to ensure the header gets built
3974 before it is first used.  Typically this is necessary in order for
3975 dependency tracking to work when the header is included by another
3976 file.  The common solution is listing the header file in
3977 @code{BUILT_SOURCES} (@pxref{Sources}) as follows.
3979 @example
3980 BUILT_SOURCES = parser.h
3981 AM_YFLAGS = -d
3982 bin_PROGRAMS = foo
3983 foo_SOURCES = @dots{} parser.y @dots{}
3984 @end example
3986 If a @code{lex} source file is seen, then your @file{configure.ac}
3987 must define the variable @samp{LEX}.  You can use @samp{AC_PROG_LEX}
3988 to do this (@pxref{Particular Programs, , Particular Program Checks,
3989 autoconf, The Autoconf Manual}), but using @code{AM_PROG_LEX} macro
3990 (@pxref{Macros}) is recommended.
3992 When @code{lex} is invoked, it is passed @samp{LFLAGS} and
3993 @samp{AM_LFLAGS}.  The former is a user variable and the latter is
3994 intended for the @file{Makefile.am} author.
3996 When @code{AM_MAINTAINER_MODE} (@pxref{maintainer-mode}) is used, the
3997 rebuild rule for distributed Yacc and Lex sources are only used when
3998 @code{maintainer-mode} is enabled, or when the files have been erased.
4001 @cindex ylwrap
4002 @cindex yacc, multiple parsers
4003 @cindex Multiple yacc parsers
4004 @cindex Multiple lex lexers
4005 @cindex lex, multiple lexers
4008 Automake makes it possible to include multiple @code{yacc} (or
4009 @code{lex}) source files in a single program.  When there is more than
4010 one distinct @code{yacc} (or @code{lex}) source file in a directory,
4011 Automake uses a small program called @code{ylwrap} to run @code{yacc}
4012 (or @code{lex}) in a subdirectory.  This is necessary because yacc's
4013 output filename is fixed, and a parallel make could conceivably invoke
4014 more than one instance of @code{yacc} simultaneously.  The
4015 @code{ylwrap} program is distributed with Automake.  It should appear
4016 in the directory specified by @samp{AC_CONFIG_AUX_DIR}, or one of its
4017 default locations (@pxref{Input, , Finding `configure' Input,
4018 autoconf, The Autoconf Manual}).
4020 For @code{yacc}, simply managing locking is insufficient.  The output of
4021 @code{yacc} always uses the same symbol names internally, so it isn't
4022 possible to link two @code{yacc} parsers into the same executable.
4024 We recommend using the following renaming hack used in @code{gdb}:
4025 @example
4026 #define yymaxdepth c_maxdepth
4027 #define yyparse c_parse
4028 #define yylex   c_lex
4029 #define yyerror c_error
4030 #define yylval  c_lval
4031 #define yychar  c_char
4032 #define yydebug c_debug
4033 #define yypact  c_pact
4034 #define yyr1    c_r1
4035 #define yyr2    c_r2
4036 #define yydef   c_def
4037 #define yychk   c_chk
4038 #define yypgo   c_pgo
4039 #define yyact   c_act
4040 #define yyexca  c_exca
4041 #define yyerrflag c_errflag
4042 #define yynerrs c_nerrs
4043 #define yyps    c_ps
4044 #define yypv    c_pv
4045 #define yys     c_s
4046 #define yy_yys  c_yys
4047 #define yystate c_state
4048 #define yytmp   c_tmp
4049 #define yyv     c_v
4050 #define yy_yyv  c_yyv
4051 #define yyval   c_val
4052 #define yylloc  c_lloc
4053 #define yyreds  c_reds
4054 #define yytoks  c_toks
4055 #define yylhs   c_yylhs
4056 #define yylen   c_yylen
4057 #define yydefred c_yydefred
4058 #define yydgoto c_yydgoto
4059 #define yysindex c_yysindex
4060 #define yyrindex c_yyrindex
4061 #define yygindex c_yygindex
4062 #define yytable  c_yytable
4063 #define yycheck  c_yycheck
4064 #define yyname   c_yyname
4065 #define yyrule   c_yyrule
4066 @end example
4068 For each define, replace the @samp{c_} prefix with whatever you like.
4069 These defines work for @code{bison}, @code{byacc}, and traditional
4070 @code{yacc}s.  If you find a parser generator that uses a symbol not
4071 covered here, please report the new name so it can be added to the list.
4074 @node C++ Support
4075 @section C++ Support
4077 @cindex C++ support
4078 @cindex Support for C++
4080 Automake includes full support for C++.
4082 Any package including C++ code must define the output variable
4083 @samp{CXX} in @file{configure.ac}; the simplest way to do this is to use
4084 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
4085 Program Checks, autoconf, The Autoconf Manual}).
4087 A few additional variables are defined when a C++ source file is seen:
4089 @vtable @code
4090 @item CXX
4091 The name of the C++ compiler.
4093 @item CXXFLAGS
4094 Any flags to pass to the C++ compiler.
4096 @item AM_CXXFLAGS
4097 The maintainer's variant of @code{CXXFLAGS}.
4099 @item CXXCOMPILE
4100 The command used to actually compile a C++ source file.  The file name
4101 is appended to form the complete command line.
4103 @item CXXLINK
4104 The command used to actually link a C++ program.
4105 @end vtable
4108 @node Assembly Support
4109 @section Assembly Support
4111 Automake includes some support for assembly code.  There are two forms
4112 of assembler files: normal (@file{*.s}) and preprocessed by @code{CPP}
4113 (@file{*.S}).
4115 The variable @code{CCAS} holds the name of the compiler used to build
4116 assembly code.  This compiler must work a bit like a C compiler; in
4117 particular it must accept @samp{-c} and @samp{-o}.  The value of
4118 @code{CCASFLAGS} (and @code{CPPFLAGS} for preprocessed files) is passed
4119 to the compilation.
4120 @vindex CCAS
4121 @vindex CCASFLAGS
4122 @vindex CPPFLAGS
4124 You are required to set @code{CCAS} and @code{CCASFLAGS} via
4125 @file{configure.ac}.  The autoconf macro @code{AM_PROG_AS} will do this
4126 for you.  Unless they are already set, it simply sets @code{CCAS} to the
4127 C compiler and @code{CCASFLAGS} to the C compiler flags.
4129 Only the suffixes @file{.s} and @file{.S} are recognized by
4130 @code{automake} as being files containing assembly code.
4133 @node Fortran 77 Support
4134 @comment  node-name,  next,  previous,  up
4135 @section Fortran 77 Support
4137 @cindex Fortran 77 support
4138 @cindex Support for Fortran 77
4140 Automake includes full support for Fortran 77.
4142 Any package including Fortran 77 code must define the output variable
4143 @samp{F77} in @file{configure.ac}; the simplest way to do this is to use
4144 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
4145 Program Checks, autoconf, The Autoconf Manual}).
4147 A few additional variables are defined when a Fortran 77 source file is
4148 seen:
4150 @vtable @code
4152 @item F77
4153 The name of the Fortran 77 compiler.
4155 @item FFLAGS
4156 Any flags to pass to the Fortran 77 compiler.
4158 @item AM_FFLAGS
4159 The maintainer's variant of @code{FFLAGS}.
4161 @item RFLAGS
4162 Any flags to pass to the Ratfor compiler.
4164 @item AM_RFLAGS
4165 The maintainer's variant of @code{RFLAGS}.
4167 @item F77COMPILE
4168 The command used to actually compile a Fortran 77 source file.  The file
4169 name is appended to form the complete command line.
4171 @item FLINK
4172 The command used to actually link a pure Fortran 77 program or shared
4173 library.
4175 @end vtable
4177 Automake can handle preprocessing Fortran 77 and Ratfor source files in
4178 addition to compiling them@footnote{Much, if not most, of the
4179 information in the following sections pertaining to preprocessing
4180 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
4181 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}.  Automake
4182 also contains some support for creating programs and shared libraries
4183 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
4184 Fortran 77 With C and C++}).
4186 These issues are covered in the following sections.
4188 @menu
4189 * Preprocessing Fortran 77::    Preprocessing Fortran 77 sources
4190 * Compiling Fortran 77 Files::  Compiling Fortran 77 sources
4191 * Mixing Fortran 77 With C and C++::  Mixing Fortran 77 With C and C++
4192 @end menu
4195 @node Preprocessing Fortran 77
4196 @comment  node-name,  next,  previous,  up
4197 @subsection Preprocessing Fortran 77
4199 @cindex Preprocessing Fortran 77
4200 @cindex Fortran 77, Preprocessing
4201 @cindex Ratfor programs
4203 @file{N.f} is made automatically from @file{N.F} or @file{N.r}.  This
4204 rule runs just the preprocessor to convert a preprocessable Fortran 77
4205 or Ratfor source file into a strict Fortran 77 source file.  The precise
4206 command used is as follows:
4208 @table @file
4210 @item .F
4211 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
4213 @item .r
4214 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
4216 @end table
4219 @node Compiling Fortran 77 Files
4220 @comment  node-name,  next,  previous,  up
4221 @subsection Compiling Fortran 77 Files
4223 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
4224 @file{N.r} by running the Fortran 77 compiler.  The precise command used
4225 is as follows:
4227 @table @file
4229 @item .f
4230 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
4232 @item .F
4233 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
4235 @item .r
4236 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
4238 @end table
4241 @node Mixing Fortran 77 With C and C++
4242 @comment  node-name,  next,  previous,  up
4243 @subsection Mixing Fortran 77 With C and C++
4245 @cindex Fortran 77, mixing with C and C++
4246 @cindex Mixing Fortran 77 with C and C++
4247 @cindex Linking Fortran 77 with C and C++
4248 @cindex cfortran
4249 @cindex Mixing Fortran 77 with C and/or C++
4251 Automake currently provides @emph{limited} support for creating programs
4252 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
4253 However, there are many other issues related to mixing Fortran 77 with
4254 other languages that are @emph{not} (currently) handled by Automake, but
4255 that are handled by other packages@footnote{For example,
4256 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
4257 addresses all of these inter-language issues, and runs under nearly all
4258 Fortran 77, C and C++ compilers on nearly all platforms.  However,
4259 @code{cfortran} is not yet Free Software, but it will be in the next
4260 major release.}.
4262 @page
4263 Automake can help in two ways:
4265 @enumerate
4266 @item
4267 Automatic selection of the linker depending on which combinations of
4268 source code.
4270 @item
4271 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
4272 @samp{-l}) to pass to the automatically selected linker in order to link
4273 in the appropriate Fortran 77 intrinsic and run-time libraries.
4275 @cindex FLIBS, defined
4276 These extra Fortran 77 linker flags are supplied in the output variable
4277 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
4278 supplied with newer versions of Autoconf (Autoconf version 2.13 and
4279 later).  @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
4280 Autoconf}.
4281 @end enumerate
4283 If Automake detects that a program or shared library (as mentioned in
4284 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
4285 code that is a mixture of Fortran 77 and C and/or C++, then it requires
4286 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
4287 @file{configure.ac}, and that either @code{$(FLIBS)}
4288 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
4289 (for shared libraries) variables.  It is the responsibility of the
4290 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
4291 appears in the appropriate @code{_LDADD} or
4292 @code{_LIBADD} variable.
4294 @cindex Mixed language example
4295 @cindex Example, mixed language
4297 For example, consider the following @file{Makefile.am}:
4299 @example
4300 bin_PROGRAMS = foo
4301 foo_SOURCES  = main.cc foo.f
4302 foo_LDADD    = libfoo.la $(FLIBS)
4304 pkglib_LTLIBRARIES = libfoo.la
4305 libfoo_la_SOURCES  = bar.f baz.c zardoz.cc
4306 libfoo_la_LIBADD   = $(FLIBS)
4307 @end example
4309 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
4310 is mentioned in @file{configure.ac}.  Also, if @code{$(FLIBS)} hadn't
4311 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
4312 Automake would have issued a warning.
4315 @page
4316 @menu
4317 * How the Linker is Chosen::    Automatic linker selection
4318 @end menu
4320 @node How the Linker is Chosen
4321 @comment  node-name,  next,  previous,  up
4322 @subsubsection How the Linker is Chosen
4324 @cindex Automatic linker selection
4325 @cindex Selecting the linker automatically
4327 The following diagram demonstrates under what conditions a particular
4328 linker is chosen by Automake.
4330 For example, if Fortran 77, C and C++ source code were to be compiled
4331 into a program, then the C++ linker will be used.  In this case, if the
4332 C or Fortran 77 linkers required any special libraries that weren't
4333 included by the C++ linker, then they must be manually added to an
4334 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
4335 @file{Makefile.am}.
4337 @example
4338                      \              Linker
4339           source      \
4340            code        \     C        C++     Fortran
4341      -----------------  +---------+---------+---------+
4342                         |         |         |         |
4343      C                  |    x    |         |         |
4344                         |         |         |         |
4345                         +---------+---------+---------+
4346                         |         |         |         |
4347          C++            |         |    x    |         |
4348                         |         |         |         |
4349                         +---------+---------+---------+
4350                         |         |         |         |
4351                Fortran  |         |         |    x    |
4352                         |         |         |         |
4353                         +---------+---------+---------+
4354                         |         |         |         |
4355      C + C++            |         |    x    |         |
4356                         |         |         |         |
4357                         +---------+---------+---------+
4358                         |         |         |         |
4359      C +       Fortran  |         |         |    x    |
4360                         |         |         |         |
4361                         +---------+---------+---------+
4362                         |         |         |         |
4363          C++ + Fortran  |         |    x    |         |
4364                         |         |         |         |
4365                         +---------+---------+---------+
4366                         |         |         |         |
4367      C + C++ + Fortran  |         |    x    |         |
4368                         |         |         |         |
4369                         +---------+---------+---------+
4370 @end example
4372 @node Fortran 9x Support
4373 @comment  node-name,  next,  previous,  up
4374 @section Fortran 9x Support
4376 @cindex Fortran 9x support
4377 @cindex Support for Fortran 9x
4379 Automake includes full support for Fortran 9x.
4381 Any package including Fortran 9x code must define the output variable
4382 @samp{FC} in @file{configure.ac}; the simplest way to do this is to use
4383 the @code{AC_PROG_FC} macro (@pxref{Particular Programs, , Particular
4384 Program Checks, autoconf, The Autoconf Manual}).
4386 A few additional variables are defined when a Fortran 9x source file is
4387 seen:
4389 @vtable @code
4391 @item FC
4392 The name of the Fortran 9x compiler.
4394 @item FCFLAGS
4395 Any flags to pass to the Fortran 9x compiler.
4397 @item AM_FCFLAGS
4398 The maintainer's variant of @code{FCFLAGS}.
4400 @item FCCOMPILE
4401 The command used to actually compile a Fortran 9x source file.  The file
4402 name is appended to form the complete command line.
4404 @item FCLINK
4405 The command used to actually link a pure Fortran 9x program or shared
4406 library.
4408 @end vtable
4410 @menu
4411 * Compiling Fortran 9x Files::  Compiling Fortran 9x sources
4412 @end menu
4414 @node Compiling Fortran 9x Files
4415 @comment  node-name,  next,  previous,  up
4416 @subsection Compiling Fortran 9x Files
4418 @file{N.o} is made automatically from @file{N.f90} or @file{N.f95}
4419 by running the Fortran 9x compiler.  The precise command used
4420 is as follows:
4422 @table @file
4424 @item .f9x
4425 @code{$(FC) -c $(AM_FCFLAGS) $(FCFLAGS)}
4427 @end table
4429 @node Java Support
4430 @comment  node-name,  next,  previous,  up
4431 @section Java Support
4433 @cindex Java support
4434 @cindex Support for Java
4436 Automake includes support for compiled Java, using @code{gcj}, the Java
4437 front end to the GNU Compiler Collection.
4439 Any package including Java code to be compiled must define the output
4440 variable @samp{GCJ} in @file{configure.ac}; the variable @samp{GCJFLAGS}
4441 must also be defined somehow (either in @file{configure.ac} or
4442 @file{Makefile.am}).  The simplest way to do this is to use the
4443 @code{AM_PROG_GCJ} macro.
4445 @vindex GCJFLAGS
4447 By default, programs including Java source files are linked with
4448 @code{gcj}.
4450 As always, the contents of @samp{AM_GCJFLAGS} are passed to every
4451 compilation invoking @code{gcj} (in its role as an ahead-of-time
4452 compiler -- when invoking it to create @file{.class} files,
4453 @samp{AM_JAVACFLAGS} is used instead).  If it is necessary to pass
4454 options to @code{gcj} from @file{Makefile.am}, this variable, and not
4455 the user variable @samp{GCJFLAGS}, should be used.
4457 @vindex AM_GCJFLAGS
4459 @code{gcj} can be used to compile @file{.java}, @file{.class},
4460 @file{.zip}, or @file{.jar} files.
4462 When linking, @code{gcj} requires that the main class be specified
4463 using the @samp{--main=} option.  The easiest way to do this is to use
4464 the @code{_LDFLAGS} variable for the program.
4467 @node Support for Other Languages
4468 @comment  node-name,  next,  previous,  up
4469 @section Support for Other Languages
4471 Automake currently only includes full support for C, C++ (@pxref{C++
4472 Support}), Fortran 77 (@pxref{Fortran 77 Support}),
4473 Fortran 9x (@pxref{Fortran 9x Support}),
4474 and Java (@pxref{Java Support}).  There is only rudimentary support for other
4475 languages, support for which will be improved based on user demand.
4477 Some limited support for adding your own languages is available via the
4478 suffix rule handling; see @ref{Suffixes}.
4481 @node ANSI
4482 @section Automatic de-ANSI-fication
4484 @cindex de-ANSI-fication, defined
4486 Although the GNU standards allow the use of ANSI C, this can have the
4487 effect of limiting portability of a package to some older compilers
4488 (notably the SunOS C compiler).
4490 Automake allows you to work around this problem on such machines by
4491 @dfn{de-ANSI-fying} each source file before the actual compilation takes
4492 place.
4494 @vindex AUTOMAKE_OPTIONS
4495 @opindex ansi2knr
4497 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
4498 (@pxref{Options}) contains the option @code{ansi2knr} then code to
4499 handle de-ANSI-fication is inserted into the generated
4500 @file{Makefile.in}.
4502 This causes each C source file in the directory to be treated as ANSI C@.
4503 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
4504 is available, the @code{ansi2knr} program is used to convert the source
4505 files into K&R C, which is then compiled.
4507 The @code{ansi2knr} program is simple-minded.  It assumes the source
4508 code will be formatted in a particular way; see the @code{ansi2knr} man
4509 page for details.
4511 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
4512 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
4513 these files are distributed with Automake.  Also, the package
4514 @file{configure.ac} must call the macro @code{AM_C_PROTOTYPES}
4515 (@pxref{Macros}).
4516 @cvindex AM_C_PROTOTYPES
4518 Automake also handles finding the @code{ansi2knr} support files in some
4519 other directory in the current package.  This is done by prepending the
4520 relative path to the appropriate directory to the @code{ansi2knr}
4521 option.  For instance, suppose the package has ANSI C code in the
4522 @file{src} and @file{lib} subdirectories.  The files @file{ansi2knr.c} and
4523 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
4524 @file{src/Makefile.am}:
4526 @example
4527 AUTOMAKE_OPTIONS = ../lib/ansi2knr
4528 @end example
4530 If no directory prefix is given, the files are assumed to be in the
4531 current directory.
4533 Note that automatic de-ANSI-fication will not work when the package is
4534 being built for a different host architecture.  That is because automake
4535 currently has no way to build @code{ansi2knr} for the build machine.
4537 @c FIXME: this paragraph might be better moved to an `upgrading' section.
4538 @cindex @code{LTLIBOBJS} and @code{ansi2knr}
4539 @cindex @code{LIBOBJS} and @code{ansi2knr}
4540 @cindex @code{ansi2knr} and @code{LTLIBOBJS}
4541 @cindex @code{ansi2knr} and @code{LIBOBJS}
4542 Using @code{LIBOBJS} with source de-ANSI-fication used to require
4543 hand-crafted code in @file{configure} to append @code{$U} to basenames
4544 in @code{LIBOBJS}.  This is no longer true today.  Starting with version
4545 2.54, Autoconf takes care of rewriting @code{LIBOBJS} and
4546 @code{LTLIBOBJS}.  (@pxref{AC_LIBOBJ vs LIBOBJS, , @code{AC_LIBOBJ}
4547 vs. @code{LIBOBJS}, autoconf, The Autoconf Manual})
4549 @node Dependencies
4550 @section Automatic dependency tracking
4552 As a developer it is often painful to continually update the
4553 @file{Makefile.in} whenever the include-file dependencies change in a
4554 project.  Automake supplies a way to automatically track dependency
4555 changes.
4557 @cindex Dependency tracking
4558 @cindex Automatic dependency tracking
4560 Automake always uses complete dependencies for a compilation, including
4561 system headers.  Automake's model is that dependency computation should
4562 be a side effect of the build.  To this end, dependencies are computed
4563 by running all compilations through a special wrapper program called
4564 @code{depcomp}.  @code{depcomp} understands how to coax many different C
4565 and C++ compilers into generating dependency information in the format
4566 it requires.  @code{automake -a} will install @code{depcomp} into your
4567 source tree for you.  If @code{depcomp} can't figure out how to properly
4568 invoke your compiler, dependency tracking will simply be disabled for
4569 your build.
4571 @cindex depcomp
4573 Experience with earlier versions of Automake (@pxref{Dependency
4574 Tracking Evolution}) taught us that it is not reliable to generate
4575 dependencies only on the maintainer's system, as configurations vary
4576 too much.  So instead Automake implements dependency tracking at build
4577 time.
4579 Automatic dependency tracking can be suppressed by putting
4580 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}, or
4581 passing @code{no-dependencies} as an argument to @code{AM_INIT_AUTOMAKE}
4582 (this should be the preferred way).  Or, you can invoke @code{automake}
4583 with the @code{-i} option.  Dependency tracking is enabled by default.
4585 @vindex AUTOMAKE_OPTIONS
4586 @opindex no-dependencies
4588 The person building your package also can choose to disable dependency
4589 tracking by configuring with @code{--disable-dependency-tracking}.
4591 @cindex Disabling dependency tracking
4592 @cindex Dependency tracking, disabling
4595 @node EXEEXT
4596 @section Support for executable extensions
4598 @cindex Executable extension
4599 @cindex Extension, executable
4600 @cindex Windows
4602 On some platforms, such as Windows, executables are expected to have an
4603 extension such as @samp{.exe}.  On these platforms, some compilers (GCC
4604 among them) will automatically generate @file{foo.exe} when asked to
4605 generate @file{foo}.
4607 Automake provides mostly-transparent support for this.  Unfortunately
4608 @emph{mostly} doesn't yet mean @emph{fully}.  Until the English
4609 dictionary is revised, you will have to assist Automake if your package
4610 must support those platforms.
4612 One thing you must be aware of is that, internally, Automake rewrites
4613 something like this:
4615 @example
4616 bin_PROGRAMS = liver
4617 @end example
4619 to this:
4621 @example
4622 bin_PROGRAMS = liver$(EXEEXT)
4623 @end example
4625 The targets Automake generates are likewise given the @samp{$(EXEEXT)}
4626 extension.  @code{EXEEXT}
4628 However, Automake cannot apply this rewriting to @code{configure}
4629 substitutions.  This means that if you are conditionally building a
4630 program using such a substitution, then your @file{configure.ac} must
4631 take care to add @samp{$(EXEEXT)} when constructing the output variable.
4633 With Autoconf 2.13 and earlier, you must explicitly use @code{AC_EXEEXT}
4634 to get this support.  With Autoconf 2.50, @code{AC_EXEEXT} is run
4635 automatically if you configure a compiler (say, through
4636 @code{AC_PROG_CC}).
4638 Sometimes maintainers like to write an explicit link rule for their
4639 program.  Without executable extension support, this is easy---you
4640 simply write a rule whose target is the name of the program.  However,
4641 when executable extension support is enabled, you must instead add the
4642 @samp{$(EXEEXT)} suffix.
4644 Unfortunately, due to the change in Autoconf 2.50, this means you must
4645 always add this extension.  However, this is a problem for maintainers
4646 who know their package will never run on a platform that has
4647 executable extensions.  For those maintainers, the @code{no-exeext}
4648 option (@pxref{Options}) will disable this feature.  This works in a
4649 fairly ugly way; if @code{no-exeext} is seen, then the presence of a
4650 rule for a target named @code{foo} in @file{Makefile.am} will override
4651 an automake-generated rule for @code{foo$(EXEEXT)}.  Without
4652 the @code{no-exeext} option, this use will give a diagnostic.
4655 @node Other objects
4656 @chapter Other Derived Objects
4658 Automake can handle derived objects which are not C programs.  Sometimes
4659 the support for actually building such objects must be explicitly
4660 supplied, but Automake will still automatically handle installation and
4661 distribution.
4663 @menu
4664 * Scripts::                     Executable scripts
4665 * Headers::                     Header files
4666 * Data::                        Architecture-independent data files
4667 * Sources::                     Derived sources
4668 @end menu
4671 @node Scripts
4672 @section Executable Scripts
4674 @cindex _SCRIPTS primary, defined
4675 @cindex SCRIPTS primary, defined
4676 @cindex Primary variable, SCRIPTS
4678 It is possible to define and install programs which are scripts.  Such
4679 programs are listed using the @samp{SCRIPTS} primary name.  Automake
4680 doesn't define any dependencies for scripts; the @file{Makefile.am}
4681 should include the appropriate rules.
4682 @vindex SCRIPTS
4684 Automake does not assume that scripts are derived objects; such objects
4685 must be deleted by hand (@pxref{Clean}).
4687 The @code{automake} program itself is a Perl script that is generated
4688 from @file{automake.in}.  Here is how this is handled:
4690 @example
4691 bin_SCRIPTS = automake
4692 CLEANFILES = $(bin_SCRIPTS)
4694 do_subst = sed -e 's,[@@]datadir[@@],$(datadir),g' \
4695             -e 's,[@@]PERL[@@],$(PERL),g' \
4696             -e 's,[@@]PACKAGE[@@],$(PACKAGE),g' \
4697             -e 's,[@@]VERSION[@@],$(VERSION),g' \
4698             @dots{}
4700 automake: automake.in Makefile
4701         $(do_subst) < $(srcdir)/automake.in > automake
4702         chmod +x automake
4703 @end example
4705 Because---as we have just seen---scripts can be built, they are not
4706 distributed by default.  Scripts that should be distributed can be
4707 specified using a @code{dist_} prefix as in other primaries.  For
4708 instance the following @file{Makefile.am} declares that
4709 @file{my_script} should be distributed and installed in
4710 @code{$(sbindir)}.
4712 @example
4713 dist_sbin_SCRIPTS = my_script
4714 @end example
4716 @cindex SCRIPTS, installation directories
4717 @cindex Installing scripts
4719 @vindex bin_SCRIPTS
4720 @vindex sbin_SCRIPTS
4721 @vindex libexec_SCRIPTS
4722 @vindex pkgdata_SCRIPTS
4723 @vindex noinst_SCRIPTS
4724 @vindex check_SCRIPTS
4726 Script objects can be installed in @code{bindir}, @code{sbindir},
4727 @code{libexecdir}, or @code{pkgdatadir}.
4729 Scripts that need not being installed can be listed in
4730 @code{noinst_SCRIPTS}, and among them, those which are needed only by
4731 @code{make check} should go in @code{check_SCRIPTS}.
4734 @node Headers
4735 @section Header files
4737 @cindex _HEADERS primary, defined
4738 @cindex HEADERS primary, defined
4739 @cindex Primary variable, HEADERS
4741 @vindex noinst_HEADERS
4742 @cindex HEADERS, installation directories
4743 @cindex Installing headers
4744 @vindex include_HEADERS
4745 @vindex oldinclude_HEADERS
4746 @vindex pkginclude_HEADERS
4749 Header files that must be installed are specified by the
4750 @samp{HEADERS} family of variables.  Headers can be installed in
4751 @code{includedir}, @code{oldincludedir}, @code{pkgincludedir} or any
4752 other directory you may have defined (@pxref{Uniform}).  For instance
4754 @example
4755 include_HEADERS = foo.h bar/bar.h
4756 @end example
4758 @noindent
4759 will install the two files as @file{$(includedir)/foo.h} and
4760 @file{$(includedir)/bar.h}.
4762 The @samp{nobase_} prefix is also supported,
4764 @example
4765 nobase_include_HEADERS = foo.h bar/bar.h
4766 @end example
4768 @noindent
4769 will install the two files as @file{$(includedir)/foo.h} and
4770 @file{$(includedir)/bar/bar.h} (@pxref{Alternative}).
4772 @vindex noinst_HEADERS
4773 Usually, only header files that accompany installed libraries need to
4774 be installed.  Headers used by programs or convenience libraries are
4775 not installed.  The @code{noinst_HEADERS} variable can be used for
4776 such headers.  However when the header actually belongs to one
4777 convenient library or program, we recommend listing it in the
4778 program's or library's @samp{_SOURCES} variable (@pxref{Program
4779 Sources}) instead of in @code{noinst_HEADERS}.  This is clearer for
4780 the @file{Makefile.am} reader.  @code{noinst_HEADERS} would be the
4781 right variable to use in a directory containing only headers and no
4782 associated library or program.
4784 All header files must be listed somewhere; in a @samp{_SOURCES}
4785 variable or in a @samp{_HEADERS} variable.  Missing ones will not
4786 appear in the distribution.
4788 For header files that are built and must not be distributed, use the
4789 @samp{nodist_} prefix as in @code{nodist_include_HEADERS} or
4790 @code{nodist_prog_SOURCES}.  If these generated headers are needed
4791 during the build, you must also ensure they exist before they are
4792 used, see @xref{Sources}.
4795 @node Data
4796 @section Architecture-independent data files
4798 @cindex _DATA primary, defined
4799 @cindex DATA primary, defined
4800 @cindex Primary variable, DATA
4802 Automake supports the installation of miscellaneous data files using the
4803 @samp{DATA} family of variables.
4804 @vindex DATA
4806 @vindex data_DATA
4807 @vindex sysconf_DATA
4808 @vindex sharedstate_DATA
4809 @vindex localstate_DATA
4810 @vindex pkgdata_DATA
4812 Such data can be installed in the directories @code{datadir},
4813 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
4814 @code{pkgdatadir}.
4816 By default, data files are @emph{not} included in a distribution.  Of
4817 course, you can use the @samp{dist_} prefix to change this on a
4818 per-variable basis.
4820 Here is how Automake declares its auxiliary data files:
4822 @example
4823 dist_pkgdata_DATA = clean-kr.am clean.am @dots{}
4824 @end example
4827 @node Sources
4828 @section Built sources
4830 Because Automake's automatic dependency tracking works as a side-effect
4831 of compilation (@pxref{Dependencies}) there is a bootstrap issue: a
4832 target should not be compiled before its dependencies are made, but
4833 these dependencies are unknown until the target is first compiled.
4835 Ordinarily this is not a problem, because dependencies are distributed
4836 sources: they preexist and do not need to be built.  Suppose that
4837 @file{foo.c} includes @file{foo.h}.  When it first compiles
4838 @file{foo.o}, @command{make} only knows that @file{foo.o} depends on
4839 @file{foo.c}.  As a side-effect of this compilation @code{depcomp}
4840 records the @file{foo.h} dependency so that following invocations of
4841 @command{make} will honor it.  In these conditions, it's clear there is
4842 no problem: either @file{foo.o} doesn't exist and has to be built
4843 (regardless of the dependencies), or accurate dependencies exist and
4844 they can be used to decide whether @file{foo.o} should be rebuilt.
4846 It's a different story if @file{foo.h} doesn't exist by the first
4847 @command{make} run.  For instance there might be a rule to build
4848 @file{foo.h}.  This time @file{file.o}'s build will fail because the
4849 compiler can't find @file{foo.h}. @command{make} failed to trigger the
4850 rule to build @file{foo.h} first by lack of dependency information.
4852 @vindex BUILT_SOURCES
4853 @cindex BUILT_SOURCES, defined
4855 The @code{BUILT_SOURCES} variable is a workaround for this problem.  A
4856 source file listed in @code{BUILT_SOURCES} is made on @code{make all}
4857 or @code{make check} (or even @code{make install}) before other
4858 targets are processed.  However, such a source file is not
4859 @emph{compiled} unless explicitly requested by mentioning it in some
4860 other @samp{_SOURCES} variable.
4862 So, to conclude our introductory example, we could use
4863 @code{BUILT_SOURCES = foo.h} to ensure @file{foo.h} gets built before
4864 any other target (including @file{foo.o}) during @code{make all} or
4865 @code{make check}.
4867 @code{BUILT_SOURCES} is actually a bit of a misnomer, as any file which
4868 must be created early in the build process can be listed in this
4869 variable.  Moreover, all built sources do not necessarily have to be
4870 listed in @code{BUILT_SOURCES}.  For instance a generated @file{.c} file
4871 doesn't need to appear in @code{BUILT_SOURCES} (unless it is included by
4872 another source), because it's a known dependency of the associated
4873 object.
4875 It might be important to emphasize that @code{BUILT_SOURCES} is
4876 honored only by @code{make all}, @code{make check} and @code{make
4877 install}.  This means you cannot build a specific target (e.g.,
4878 @code{make foo}) in a clean tree if it depends on a built source.
4879 However it will succeed if you have run @code{make all} earlier,
4880 because accurate dependencies are already available.
4882 The next section illustrates and discusses the handling of built sources
4883 on a toy example.
4885 @menu
4886 * Built sources example::       Several ways to handle built sources.
4887 @end menu
4889 @node Built sources example
4890 @subsection Built sources example
4892 Suppose that @file{foo.c} includes @file{bindir.h}, which is
4893 installation-dependent and not distributed: it needs to be built.  Here
4894 @file{bindir.h} defines the preprocessor macro @code{bindir} to the
4895 value of the @command{make} variable @code{bindir} (inherited from
4896 @file{configure}).
4898 We suggest several implementations below.  It's not meant to be an
4899 exhaustive listing of all ways to handle built sources, but it will give
4900 you a few ideas if you encounter this issue.
4902 @unnumberedsubsec First try
4904 This first implementation will illustrate the bootstrap issue mentioned
4905 in the previous section (@pxref{Sources}).
4907 Here is a tentative @file{Makefile.am}.
4909 @example
4910 # This won't work.
4911 bin_PROGRAMS = foo
4912 foo_SOURCES = foo.c
4913 nodist_foo_SOURCES = bindir.h
4914 CLEANFILES = bindir.h
4915 bindir.h: Makefile
4916         echo '#define bindir "$(bindir)"' >$@@
4917 @end example
4919 This setup doesn't work, because Automake doesn't know that @file{foo.c}
4920 includes @file{bindir.h}.  Remember, automatic dependency tracking works
4921 as a side-effect of compilation, so the dependencies of @file{foo.o} will
4922 be known only after @file{foo.o} has been compiled (@pxref{Dependencies}).
4923 The symptom is as follows.
4925 @example
4926 % make
4927 source='foo.c' object='foo.o' libtool=no \
4928 depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
4929 depmode=gcc /bin/sh ./depcomp \
4930 gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
4931 foo.c:2: bindir.h: No such file or directory
4932 make: *** [foo.o] Error 1
4933 @end example
4935 In this example @file{bindir.h} is not distributed, not installed, and
4936 it is not even being built on-time.  One may wonder what the
4937 @code{nodist_foo_SOURCES = bindir.h} line has any use at all.  This
4938 line simply states that @file{bindir.h} is a source of @code{foo}, so
4939 for instance it should be inspected while generating tags
4940 (@pxref{Tags}).  In other words, it does not help our present problem,
4941 and the build would fail identically without it.
4943 @unnumberedsubsec Using @code{BUILT_SOURCES}
4945 A solution is to require @file{bindir.h} to be built before anything
4946 else.  This is what @code{BUILT_SOURCES} is meant for (@pxref{Sources}).
4948 @example
4949 bin_PROGRAMS = foo
4950 foo_SOURCES = foo.c
4951 nodist_foo_SOURCES = bindir.h
4952 BUILT_SOURCES = bindir.h
4953 CLEANFILES = bindir.h
4954 bindir.h: Makefile
4955         echo '#define bindir "$(bindir)"' >$@@
4956 @end example
4958 See how @file{bindir.h} get built first:
4960 @example
4961 % make
4962 echo '#define bindir "/usr/local/bin"' >bindir.h
4963 make  all-am
4964 make[1]: Entering directory `/home/adl/tmp'
4965 source='foo.c' object='foo.o' libtool=no \
4966 depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
4967 depmode=gcc /bin/sh ./depcomp \
4968 gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
4969 gcc  -g -O2   -o foo  foo.o
4970 make[1]: Leaving directory `/home/adl/tmp'
4971 @end example
4973 However, as said earlier, @code{BUILT_SOURCES} applies only to the
4974 @code{all}, @code{check}, and @code{install} targets.  It still fails
4975 if you try to run @code{make foo} explicitly:
4977 @example
4978 % make clean
4979 test -z "bindir.h" || rm -f bindir.h
4980 test -z "foo" || rm -f foo
4981 rm -f *.o
4982 % : > .deps/foo.Po # Suppress previously recorded dependencies
4983 % make foo
4984 source='foo.c' object='foo.o' libtool=no \
4985 depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
4986 depmode=gcc /bin/sh ./depcomp \
4987 gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
4988 foo.c:2: bindir.h: No such file or directory
4989 make: *** [foo.o] Error 1
4990 @end example
4992 @unnumberedsubsec Recording dependencies manually
4994 Usually people are happy enough with @code{BUILT_SOURCES} because they
4995 never build targets such as @code{make foo} before @code{make all}, as
4996 in the previous example.  However if this matters to you, you can
4997 avoid @code{BUILT_SOURCES} and record such dependencies explicitly in
4998 the @file{Makefile.am}.
5000 @example
5001 bin_PROGRAMS = foo
5002 foo_SOURCES = foo.c
5003 nodist_foo_SOURCES = bindir.h
5004 foo.$(OBJEXT): bindir.h
5005 CLEANFILES = bindir.h
5006 bindir.h: Makefile
5007         echo '#define bindir "$(bindir)"' >$@@
5008 @end example
5010 You don't have to list @emph{all} the dependencies of @code{foo.o}
5011 explicitly, only those which might need to be built.  If a dependency
5012 already exists, it will not hinder the first compilation and will be
5013 recorded by the normal dependency tracking code.  (Note that after this
5014 first compilation the dependency tracking code will also have recorded
5015 the dependency between @code{foo.o} and @code{bindir.h}; so our explicit
5016 dependency is really useful to the first build only.)
5018 Adding explicit dependencies like this can be a bit dangerous if you are
5019 not careful enough.  This is due to the way Automake tries not to
5020 overwrite your rules (it assumes you know better than it).
5021 @code{foo.$(OBJEXT): bindir.h} supersedes any rule Automake may want to
5022 output to build @code{foo.$(OBJEXT)}.  It happens to work in this case
5023 because Automake doesn't have to output any @code{foo.$(OBJEXT):}
5024 target: it relies on a suffix rule instead (i.e., @code{.c.$(OBJEXT):}).
5025 Always check the generated @file{Makefile.in} if you do this.
5027 @unnumberedsubsec Build @file{bindir.h} from @file{configure}
5029 It's possible to define this preprocessor macro from @file{configure},
5030 either in @file{config.h} (@pxref{Defining Directories, , Defining
5031 Directories, autoconf, The Autoconf Manual}), or by processing a
5032 @file{bindir.h.in} file using @code{AC_CONFIG_FILES}
5033 (@pxref{Configuration Actions, ,Configuration Actions, autoconf, The
5034 Autoconf Manual}).
5036 At this point it should be clear that building @file{bindir.h} from
5037 @file{configure} work well for this example.  @file{bindir.h} will exist
5038 before you build any target, hence will not cause any dependency issue.
5040 The Makefile can be shrunk as follows.  We do not even have to mention
5041 @file{bindir.h}.
5043 @example
5044 bin_PROGRAMS = foo
5045 foo_SOURCES = foo.c
5046 @end example
5048 However, it's not always possible to build sources from
5049 @file{configure}, especially when these sources are generated by a tool
5050 that needs to be built first...
5052 @unnumberedsubsec Build @file{bindir.c}, not @file{bindir.h}.
5054 Another attractive idea is to define @code{bindir} as a variable or
5055 function exported from @file{bindir.o}, and build @file{bindir.c}
5056 instead of @file{bindir.h}.
5058 @example
5059 noinst_PROGRAMS = foo
5060 foo_SOURCES = foo.c bindir.h
5061 nodist_foo_SOURCES = bindir.c
5062 CLEANFILES = bindir.c
5063 bindir.c: Makefile
5064         echo 'const char bindir[] = "$(bindir)";' >$@@
5065 @end example
5067 @file{bindir.h} contains just the variable's declaration and doesn't
5068 need to be built, so it won't cause any trouble.  @file{bindir.o} is
5069 always dependent on @file{bindir.c}, so @file{bindir.c} will get built
5070 first.
5072 @unnumberedsubsec Which is best?
5074 There is no panacea, of course.  Each solution has its merits and
5075 drawbacks.
5077 You cannot use @code{BUILT_SOURCES} if the ability to run @code{make
5078 foo} on a clean tree is important to you.
5080 You won't add explicit dependencies if you are leery of overriding
5081 an Automake rule by mistake.
5083 Building files from @file{./configure} is not always possible, neither
5084 is converting @file{.h} files into @file{.c} files.
5087 @node Other GNU Tools
5088 @chapter Other GNU Tools
5090 Since Automake is primarily intended to generate @file{Makefile.in}s for
5091 use in GNU programs, it tries hard to interoperate with other GNU tools.
5093 @menu
5094 * Emacs Lisp::                  Emacs Lisp
5095 * gettext::                     Gettext
5096 * Libtool::                     Libtool
5097 * Java::                        Java
5098 * Python::                      Python
5099 @end menu
5102 @node Emacs Lisp
5103 @section Emacs Lisp
5105 @cindex _LISP primary, defined
5106 @cindex LISP primary, defined
5107 @cindex Primary variable, LISP
5109 @vindex LISP
5110 @vindex lisp_LISP
5111 @vindex noinst_LISP
5113 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
5114 is used to hold a list of @file{.el} files.  Possible prefixes for this
5115 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
5116 @code{lisp_LISP} is defined, then @file{configure.ac} must run
5117 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
5119 Automake will byte-compile all Emacs Lisp source files using the Emacs
5120 found by @code{AM_PATH_LISPDIR}, if any was found.
5122 Byte-compiled Emacs Lisp files are not portable among all versions of
5123 Emacs, so it makes sense to turn this off if you expect sites to have
5124 more than one version of Emacs installed.  Furthermore, many packages
5125 don't actually benefit from byte-compilation.  Still, we recommend
5126 that you byte-compile your Emacs Lisp sources.  It is probably better
5127 for sites with strange setups to cope for themselves than to make the
5128 installation less nice for everybody else.
5130 There are two ways to avoid byte-compiling.  Historically, we have
5131 recommended the following construct.
5132 @example
5133 lisp_LISP = file1.el file2.el
5134 ELCFILES =
5135 @end example
5136 @noindent
5137 @code{ELCFILES} is an internal Automake variable that normally lists
5138 all @file{.elc} files that must be byte-compiled.  Automake defines
5139 @code{ELCFILES} automatically from @code{lisp_LISP}.  Emptying this
5140 variable explicitly prevents byte-compilation to occur.
5142 Since Automake 1.8, we now recommend using @code{lisp_DATA} instead.  As
5144 @example
5145 lisp_DATA = file1.el file2.el
5146 @end example
5148 Note that these two constructs are not equivalent.  @code{_LISP} will
5149 not install a file if Emacs is not installed, while @code{_DATA} will
5150 always install its files.
5152 @node gettext
5153 @section Gettext
5155 @cindex GNU Gettext support
5156 @cindex Gettext support
5157 @cindex Support for GNU Gettext
5159 If @code{AM_GNU_GETTEXT} is seen in @file{configure.ac}, then Automake
5160 turns on support for GNU gettext, a message catalog system for
5161 internationalization
5162 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
5164 The @code{gettext} support in Automake requires the addition of two
5165 subdirectories to the package, @file{intl} and @file{po}.  Automake
5166 insures that these directories exist and are mentioned in
5167 @code{SUBDIRS}.
5169 @vindex dist_lisp_LISP
5170 @vindex dist_noinst_LISP
5171 Lisp sources are not distributed by default.  You can prefix the
5172 @code{LISP} primary with @code{dist_}, as in @code{dist_lisp_LISP} or
5173 @code{dist_noinst_LISP}, to indicate that these files should be
5174 distributed.
5176 @node Libtool
5177 @section Libtool
5179 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
5180 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
5181 @xref{A Shared Library}.
5184 @node Java
5185 @section Java
5187 @cindex _JAVA primary, defined
5188 @cindex JAVA primary, defined
5189 @cindex Primary variable, JAVA
5191 Automake provides some minimal support for Java compilation with the
5192 @samp{JAVA} primary.
5194 Any @file{.java} files listed in a @samp{_JAVA} variable will be
5195 compiled with @code{JAVAC} at build time.  By default, @file{.class}
5196 files are not included in the distribution.
5198 @cindex JAVA restrictions
5199 @cindex Restrictions for JAVA
5201 Currently Automake enforces the restriction that only one @samp{_JAVA}
5202 primary can be used in a given @file{Makefile.am}.  The reason for this
5203 restriction is that, in general, it isn't possible to know which
5204 @file{.class} files were generated from which @file{.java} files -- so
5205 it would be impossible to know which files to install where.  For
5206 instance, a @file{.java} file can define multiple classes; the resulting
5207 @file{.class} file names cannot be predicted without parsing the
5208 @file{.java} file.
5210 There are a few variables which are used when compiling Java sources:
5212 @vtable @code
5213 @item JAVAC
5214 The name of the Java compiler.  This defaults to @samp{javac}.
5216 @item JAVACFLAGS
5217 The flags to pass to the compiler.  This is considered to be a user
5218 variable (@pxref{User Variables}).
5220 @item AM_JAVACFLAGS
5221 More flags to pass to the Java compiler.  This, and not
5222 @code{JAVACFLAGS}, should be used when it is necessary to put Java
5223 compiler flags into @file{Makefile.am}.
5225 @item JAVAROOT
5226 The value of this variable is passed to the @samp{-d} option to
5227 @code{javac}.  It defaults to @samp{$(top_builddir)}.
5229 @item CLASSPATH_ENV
5230 This variable is an @code{sh} expression which is used to set the
5231 @code{CLASSPATH} environment variable on the @code{javac} command line.
5232 (In the future we will probably handle class path setting differently.)
5233 @end vtable
5236 @node Python
5237 @section Python
5239 @cindex _PYTHON primary, defined
5240 @cindex PYTHON primary, defined
5241 @cindex Primary variable, PYTHON
5244 Automake provides support for Python compilation with the @samp{PYTHON}
5245 primary.
5247 Any files listed in a @samp{_PYTHON} variable will be byte-compiled with
5248 @code{py-compile} at install time.  @code{py-compile} actually creates
5249 both standard (@file{.pyc}) and byte-compiled (@file{.pyo}) versions of
5250 the source files.  Note that because byte-compilation occurs at install
5251 time, any files listed in @samp{noinst_PYTHON} will not be compiled.
5252 Python source files are included in the distribution by default.
5254 Automake ships with an Autoconf macro called @code{AM_PATH_PYTHON} which
5255 will determine some Python-related directory variables (see below).  If
5256 you have called @code{AM_PATH_PYTHON} from @file{configure.ac}, then you
5257 may use the following variables to list you Python source files in your
5258 variables: @samp{python_PYTHON}, @samp{pkgpython_PYTHON},
5259 @samp{pyexecdir_PYTHON}, @samp{pkgpyexecdir_PYTHON}, depending where you
5260 want your files installed.
5262 @code{AM_PATH_PYTHON([@var{VERSION}], [@var{ACTION-IF-FOUND}],
5263 [@var{ACTION-IF-NOT-FOUND}])} takes three optional arguments.  It will
5264 search a Python interpreter on the system.  The first argument, if
5265 present, is the minimum version of Python required for this package:
5266 @code{AM_PATH_PYTHON} will skip any Python interpreter which is older
5267 than @var{VERSION}.  If an interpreter is found and satisfies
5268 @var{VERSION}, then @var{ACTION-IF-FOUND} is run.  Otherwise,
5269 @var{ACTION-IF-NOT-FOUND} is run.
5271 If @var{ACTION-IF-NOT-FOUND} is not specified, the default is to abort
5272 configure.  This is fine when Python is an absolute requirement for the
5273 package.  Therefore if Python >= 2.2 is only @emph{optional} to the
5274 package, @code{AM_PATH_PYTHON} could be called as follows.
5276 @example
5277   AM_PATH_PYTHON(2.2,, :)
5278 @end example
5280 @code{AM_PATH_PYTHON} creates several output variables based on the
5281 Python installation found during configuration.
5283 @vtable @code
5284 @item PYTHON
5285 The name of the Python executable, or @code{:} if no suitable
5286 interpreter could be found.
5288 Assuming @var{ACTION-IF-NOT-FOUND} is used (otherwise @file{./configure}
5289 will abort if Python is absent), the value of @code{PYTHON} can be used
5290 to setup a conditional in order to disable the relevant part of a build
5291 as follows.
5293 @example
5294   AM_PATH_PYTHON(,, :)
5295   AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
5296 @end example
5299 If the @var{ACTION-IF-NOT-FOUND}
5300 is specified
5302 @item PYTHON_VERSION
5303 The Python version number, in the form @var{major}.@var{minor}
5304 (e.g. @samp{1.5}).  This is currently the value of
5305 @code{sys.version[:3]}.
5307 @item PYTHON_PREFIX
5308 The string @code{$@{prefix@}}.  This term may be used in future work
5309 which needs the contents of Python's @code{sys.prefix}, but general
5310 consensus is to always use the value from configure.
5312 @item PYTHON_EXEC_PREFIX
5313 The string @code{$@{exec_prefix@}}.  This term may be used in future work
5314 which needs the contents of Python's @code{sys.exec_prefix}, but general
5315 consensus is to always use the value from configure.
5317 @item PYTHON_PLATFORM
5318 The canonical name used by Python to describe the operating system, as
5319 given by @code{sys.platform}.  This value is sometimes needed when
5320 building Python extensions.
5322 @item pythondir
5323 The directory name for the @file{site-packages} subdirectory of the
5324 standard Python install tree.
5326 @item pkgpythondir
5327 This is is the directory under @code{pythondir} which is named after the
5328 package.  That is, it is @samp{$(pythondir)/$(PACKAGE)}.  It is provided
5329 as a convenience.
5331 @item pyexecdir
5332 This is the directory where Python extension modules (shared libraries)
5333 should be installed.
5335 @item pkgpyexecdir
5336 This is a convenience variable which is defined as
5337 @samp{$(pyexecdir)/$(PACKAGE)}.
5338 @end vtable
5340 All these directory variables have values that start with either
5341 @code{$@{prefix@}} or @code{$@{exec_prefix@}} unexpanded.  This works
5342 fine in @file{Makefiles}, but it makes these variables hard to use in
5343 @file{configure}.  This is mandated by the GNU coding standards, so
5344 that the user can run @code{make prefix=/foo install}.  The Autoconf
5345 manual has a section with more details on this topic
5346 (@pxref{Installation Directory Variables, , Installation Directory
5347 Variables, autoconf, The Autoconf Manual}).
5350 @node Documentation
5351 @chapter Building documentation
5353 Currently Automake provides support for Texinfo and man pages.
5355 @menu
5356 * Texinfo::                     Texinfo
5357 * Man pages::                   Man pages
5358 @end menu
5361 @node Texinfo
5362 @section Texinfo
5364 @cindex _TEXINFOS primary, defined
5365 @cindex TEXINFOS primary, defined
5366 @cindex Primary variable, TEXINFOS
5367 @cindex HTML output using Texinfo
5368 @cindex PDF output using Texinfo
5369 @cindex PS output using Texinfo
5370 @cindex DVI output using Texinfo
5372 If the current directory contains Texinfo source, you must declare it
5373 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
5374 into info, and thus the @code{info_TEXINFOS} variable is most commonly used
5375 here.  Any Texinfo source file must end in the @file{.texi},
5376 @file{.txi}, or @file{.texinfo} extension.  We recommend @file{.texi}
5377 for new manuals.
5378 @vindex TEXINFOS
5379 @vindex info_TEXINFOS
5381 Automake generates rules to build @file{.info}, @file{.dvi}, @file{.ps},
5382 @file{.pdf} and @file{.html} files from your Texinfo sources.
5383 The @file{.info} files are built by @code{make all} and installed
5384 by @code{make install} (unless you use @code{no-installinfo}, see below).
5385 The other files can be built on request by @code{make dvi}, @code{make ps},
5386 @code{make pdf} and @code{make html}.
5388 @cindex Texinfo flag, VERSION
5389 @cindex Texinfo flag, UPDATED
5390 @cindex Texinfo flag, EDITION
5391 @cindex Texinfo flag, UPDATED-MONTH
5393 @cindex VERSION Texinfo flag
5394 @cindex UPDATED Texinfo flag
5395 @cindex EDITION Texinfo flag
5396 @cindex UPDATED-MONTH Texinfo flag
5398 @cindex mdate-sh
5400 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
5401 that file will be automatically generated.  The file @file{version.texi}
5402 defines four Texinfo flag you can reference using
5403 @code{@@value@{EDITION@}}, @code{@@value@{VERSION@}},
5404 @code{@@value@{UPDATED@}}, and @code{@@value@{UPDATED-MONTH@}}.
5406 @table @code
5407 @item EDITION
5408 @itemx VERSION
5409 Both of these flags hold the version number of your program.  They are
5410 kept separate for clarity.
5412 @item UPDATED
5413 This holds the date the primary @file{.texi} file was last modified.
5415 @item UPDATED-MONTH
5416 This holds the name of the month in which the primary @file{.texi} file
5417 was last modified.
5418 @end table
5420 The @file{version.texi} support requires the @code{mdate-sh} program;
5421 this program is supplied with Automake and automatically included when
5422 @code{automake} is invoked with the @code{--add-missing} option.
5424 If you have multiple Texinfo files, and you want to use the
5425 @file{version.texi} feature, then you have to have a separate version
5426 file for each Texinfo file.  Automake will treat any include in a
5427 Texinfo file that matches @samp{vers*.texi} just as an automatically
5428 generated version file.
5430 Sometimes an info file actually depends on more than one @file{.texi}
5431 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
5432 @file{gpl.texi}.  You can tell Automake about these dependencies using
5433 the @code{@var{texi}_TEXINFOS} variable.  Here is how GNU Hello does it:
5434 @vindex TEXINFOS
5435 @vindex _TEXINFOS
5437 @example
5438 info_TEXINFOS = hello.texi
5439 hello_TEXINFOS = gpl.texi
5440 @end example
5442 @cindex texinfo.tex
5444 By default, Automake requires the file @file{texinfo.tex} to appear in
5445 the same directory as the Texinfo source (this can be changed using the
5446 @code{TEXINFO_TEX} variable, see below).  However, if you used
5447 @code{AC_CONFIG_AUX_DIR} in @file{configure.ac} (@pxref{Input, , Finding
5448 `configure' Input, autoconf, The Autoconf Manual}), then
5449 @file{texinfo.tex} is looked for there.  Automake supplies
5450 @file{texinfo.tex} if @samp{--add-missing} is given.
5452 @opindex no-texinfo.tex
5454 The option @samp{no-texinfo.tex} can be used to eliminate the
5455 requirement for @file{texinfo.tex}.  Use of the variable
5456 @code{TEXINFO_TEX} is preferable, however, because that allows the
5457 @code{dvi}, @code{ps}, and @code{pdf} targets to still work.
5459 @cindex Rule, install-info
5460 @cindex Rule, noinstall-info
5461 @cindex Target, install-info
5462 @cindex Target, noinstall-info
5463 @cindex install-info target
5464 @cindex noinstall-info target
5466 @opindex no-installinfo
5467 @trindex install-info
5469 Automake generates an @code{install-info} rule; some people apparently
5470 use this.  By default, info pages are installed by @samp{make install}.
5471 This can be prevented via the @code{no-installinfo} option.
5473 The following variables are used by the Texinfo build rules.
5475 @vtable @code
5476 @item MAKEINFO
5477 The name of the program invoked to build @file{.info} files.  This
5478 variable is defined by Automake.  If the @code{makeinfo} program is
5479 found on the system then it will be used by default; otherwise
5480 @code{missing} will be used instead.
5482 @item MAKEINFOHTML
5483 The command invoked to build @file{.html} files.  Automake
5484 defines this to @code{$(MAKEINFO) --html}.
5486 @item MAKEINFOFLAGS
5487 User flags passed to each invocation of @code{$(MAKEINFO)} and
5488 @code{$(MAKEINFOHTML)}.  This user variable (@pxref{User Variables}) is
5489 not expected to be defined in any @file{Makefile}; it can be used by
5490 users to pass extra flags to suit their needs.
5492 @item AM_MAKEINFOFLAGS
5493 @itemx AM_MAKEINFOHTMLFLAGS
5494 Maintainer flags passed to each @code{makeinfo} invocation.  These
5495 are maintainer variables that can be overridden in @file{Makefile.am}.
5496 @code{$(AM_MAKEINFOFLAGS)} is passed to @code{makeinfo} when building
5497 @file{.info} files; and @code{$(AM_MAKEINFOHTMLFLAGS)} is used when
5498 building @file{.html} files.
5500 For instance the following setting can be used to obtain one single
5501 @file{.html} file per manual, without node separators.
5502 @example
5503 AM_MAKEINFOHTMLFLAGS = --no-headers --no-split
5504 @end example
5506 By default, @code{$(AM_MAKEINFOHTMLFLAGS)} is set to
5507 @code{$(AM_MAKEINFOFLAGS)}.  This means that defining
5508 @code{$(AM_MAKEINFOFLAGS)} without defining
5509 @code{$(AM_MAKEINFOHTMLFLAGS)} will impact builds of both @file{.info}
5510 and @file{.html} files.
5512 @item TEXI2DVI
5513 The name of the command that converts a @file{.texi} file into a
5514 @file{.dvi} file.  This defaults to @code{texi2dvi}, a script that ships
5515 with the Texinfo package.
5517 @item TEXI2PDF
5518 The name of the command that translates a @file{.texi} file into a
5519 @file{.pdf} file.  This defaults to @code{$(TEXI2DVI) --pdf --batch}.
5521 @item DVIPS
5522 The name of the command that build a @file{.ps} file out of a
5523 @file{.dvi} file.  This defaults to @code{dvips}.
5525 @item TEXINFO_TEX
5527 If your package has Texinfo files in many directories, you can use the
5528 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
5529 @file{texinfo.tex} for your package.  The value of this variable should
5530 be the relative path from the current @file{Makefile.am} to
5531 @file{texinfo.tex}:
5533 @example
5534 TEXINFO_TEX = ../doc/texinfo.tex
5535 @end example
5536 @end vtable
5539 @node Man pages
5540 @section Man pages
5542 @cindex _MANS primary, defined
5543 @cindex MANS primary, defined
5544 @cindex Primary variable, MANS
5546 A package can also include man pages (but see the GNU standards on this
5547 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.)  Man
5548 pages are declared using the @samp{MANS} primary.  Generally the
5549 @code{man_MANS} variable is used.  Man pages are automatically installed in
5550 the correct subdirectory of @code{mandir}, based on the file extension.
5551 @vindex MANS
5552 @vindex man_MANS
5554 File extensions such as @samp{.1c} are handled by looking for the valid
5555 part of the extension and using that to determine the correct
5556 subdirectory of @code{mandir}.  Valid section names are the digits
5557 @samp{0} through @samp{9}, and the letters @samp{l} and @samp{n}.
5559 Sometimes developers prefer to name a man page something like
5560 @file{foo.man} in the source, and then rename it to have the correct
5561 suffix, e.g. @file{foo.1}, when installing the file.  Automake also
5562 supports this mode.  For a valid section named @var{SECTION}, there is a
5563 corresponding directory named @samp{man@var{SECTION}dir}, and a
5564 corresponding @samp{_MANS} variable.  Files listed in such a variable
5565 are installed in the indicated section.  If the file already has a
5566 valid suffix, then it is installed as-is; otherwise the file suffix is
5567 changed to match the section.
5569 For instance, consider this example:
5570 @example
5571 man1_MANS = rename.man thesame.1 alsothesame.1c
5572 @end example
5574 In this case, @file{rename.man} will be renamed to @file{rename.1} when
5575 installed, but the other files will keep their names.
5577 @cindex Rule, install-man
5578 @cindex Rule, noinstall-man
5579 @cindex Target, install-man
5580 @cindex Target, noinstall-man
5581 @cindex install-man target
5582 @cindex noinstall-man target
5584 @c Use @samp{make install} per documentation: (texi)code.
5585 By default, man pages are installed by @samp{make install}.  However,
5586 since the GNU project does not require man pages, many maintainers do
5587 not expend effort to keep the man pages up to date.  In these cases, the
5588 @code{no-installman} option will prevent the man pages from being
5589 installed by default.  The user can still explicitly install them via
5590 @samp{make install-man}.
5591 @opindex no-installman
5592 @trindex install-man
5594 Here is how the man pages are handled in GNU @code{cpio} (which includes
5595 both Texinfo documentation and man pages):
5597 @example
5598 man_MANS = cpio.1 mt.1
5599 EXTRA_DIST = $(man_MANS)
5600 @end example
5602 Man pages are not currently considered to be source, because it is not
5603 uncommon for man pages to be automatically generated.  Therefore they
5604 are not automatically included in the distribution.  However, this can
5605 be changed by use of the @samp{dist_} prefix.
5607 The @samp{nobase_} prefix is meaningless for man pages and is
5608 disallowed.
5611 @node Install
5612 @chapter What Gets Installed
5614 @cindex Installation support
5615 @cindex make install support
5617 @section Basics of installation
5619 Naturally, Automake handles the details of actually installing your
5620 program once it has been built.  All files named by the various
5621 primaries are automatically installed in the appropriate places when the
5622 user runs @code{make install}.
5624 A file named in a primary is installed by copying the built file into
5625 the appropriate directory.  The base name of the file is used when
5626 installing.
5628 @example
5629 bin_PROGRAMS = hello subdir/goodbye
5630 @end example
5632 In this example, both @samp{hello} and @samp{goodbye} will be installed
5633 in @code{$(bindir)}.
5635 Sometimes it is useful to avoid the basename step at install time.  For
5636 instance, you might have a number of header files in subdirectories of
5637 the source tree which are laid out precisely how you want to install
5638 them.  In this situation you can use the @samp{nobase_} prefix to
5639 suppress the base name step.  For example:
5641 @example
5642 nobase_include_HEADERS = stdio.h sys/types.h
5643 @end example
5645 Will install @file{stdio.h} in @code{$(includedir)} and @file{types.h}
5646 in @code{$(includedir)/sys}.
5648 @section The two parts of install
5650 Automake generates separate @code{install-data} and @code{install-exec}
5651 rules, in case the installer is installing on multiple machines which
5652 share directory structure---these targets allow the machine-independent
5653 parts to be installed only once.  @code{install-exec} installs
5654 platform-dependent files, and @code{install-data} installs
5655 platform-independent files.  The @code{install} target depends on both
5656 of these targets.  While Automake tries to automatically segregate
5657 objects into the correct category, the @file{Makefile.am} author is, in
5658 the end, responsible for making sure this is done correctly.
5659 @trindex install-data
5660 @trindex install-exec
5661 @trindex install
5662 @cindex Install, two parts of
5664 Variables using the standard directory prefixes @samp{data},
5665 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
5666 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
5667 installed by @samp{install-data}.
5669 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
5670 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
5671 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
5672 @samp{install-exec}.
5674 Any variable using a user-defined directory prefix with @samp{exec} in
5675 the name (e.g. @samp{myexecbin_PROGRAMS}) is installed by
5676 @samp{install-exec}.  All other user-defined prefixes are installed by
5677 @samp{install-data}.
5679 @section Extending installation
5681 It is possible to extend this mechanism by defining an
5682 @code{install-exec-local} or @code{install-data-local} rule.  If these
5683 rules exist, they will be run at @samp{make install} time.  These
5684 rules can do almost anything; care is required.
5685 @trindex install-exec-local
5686 @trindex install-data-local
5688 Automake also supports two install hooks, @code{install-exec-hook} and
5689 @code{install-data-hook}.  These hooks are run after all other install
5690 rules of the appropriate type, exec or data, have completed.  So, for
5691 instance, it is possible to perform post-installation modifications
5692 using an install hook.  @ref{Extending} gives some examples.
5693 @cindex Install hook
5695 @section Staged installs
5697 @vindex DESTDIR
5698 Automake generates support for the @samp{DESTDIR} variable in all
5699 install rules.  @samp{DESTDIR} is used during the @samp{make install}
5700 step to relocate install objects into a staging area.  Each object and
5701 path is prefixed with the value of @samp{DESTDIR} before being copied
5702 into the install area.  Here is an example of typical DESTDIR usage:
5704 @example
5705 mkdir /tmp/staging &&
5706 make DESTDIR=/tmp/staging install
5707 @end example
5709 The @command{mkdir} command avoids a security problem if the attacker
5710 creates a symbolic link from @file{/tmp/staging} to a victim area;
5711 then @command{make} places install objects in a directory tree built under
5712 @file{/tmp/staging}.  If @file{/gnu/bin/foo} and
5713 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
5714 would install @file{/tmp/staging/gnu/bin/foo} and
5715 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
5717 This feature is commonly used to build install images and packages.  For
5718 more information, see @ref{Makefile Conventions, , , standards, The GNU
5719 Coding Standards}.
5721 Support for @samp{DESTDIR} is implemented by coding it directly into the
5722 install rules.  If your @file{Makefile.am} uses a local install rule
5723 (e.g., @code{install-exec-local}) or an install hook, then you must
5724 write that code to respect @samp{DESTDIR}.
5726 @section Rules for the user
5728 Automake also generates rules for targets @code{uninstall},
5729 @code{installdirs}, and @code{install-strip}.
5730 @trindex uninstall
5731 @trindex installdirs
5732 @trindex install-strip
5734 Automake supports @code{uninstall-local} and @code{uninstall-hook}.
5735 There is no notion of separate uninstalls for ``exec'' and ``data'', as
5736 these features would not provide additional functionality.
5738 Note that @code{uninstall} is not meant as a replacement for a real
5739 packaging tool.
5742 @node Clean
5743 @chapter What Gets Cleaned
5745 @cindex make clean support
5747 The GNU Makefile Standards specify a number of different clean rules.
5748 See @xref{Standard Targets, , Standard Targets for Users, standards,
5749 The GNU Coding Standards}.
5751 Generally the files that can be cleaned are determined automatically by
5752 Automake.  Of course, Automake also recognizes some variables that can
5753 be defined to specify additional files to clean.  These variables are
5754 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
5755 @code{MAINTAINERCLEANFILES}.
5756 @vindex MOSTLYCLEANFILES
5757 @vindex CLEANFILES
5758 @vindex DISTCLEANFILES
5759 @vindex MAINTAINERCLEANFILES
5761 @trindex mostlyclean-local
5762 @trindex clean-local
5763 @trindex distclean-local
5764 @trindex maintainerclean-local
5765 When cleaning involves more than deleting some hard-coded list of
5766 files, it is also possible to supplement the cleaning rules with your
5767 own commands.  Simply define a rule for any of the
5768 @code{mostlyclean-local}, @code{clean-local}, @code{distclean-local},
5769 or @code{maintainerclean-local} targets (@pxref{Extending}).  A common
5770 case is deleting a directory, for instance a directory created by the
5771 test suite:
5773 @example
5774 clean-local:
5775         -rm -rf testSubDir
5776 @end example
5778 As the GNU Standards aren't always explicit as to which files should
5779 be removed by which rule, we've adopted a heuristic which we believe
5780 was first formulated by Fran@,{c}ois Pinard:
5782 @itemize @bullet
5783 @item
5784 If @code{make} built it, and it is commonly something that one would
5785 want to rebuild (for instance, a @file{.o} file), then
5786 @code{mostlyclean} should delete it.
5788 @item
5789 Otherwise, if @code{make} built it, then @code{clean} should delete it.
5791 @item
5792 If @code{configure} built it, then @code{distclean} should delete it.
5794 @item
5795 If the maintainer built it (for instance, a @file{.info} file), then
5796 @code{maintainer-clean} should delete it.  However
5797 @code{maintainer-clean} should not delete anything that needs to exist
5798 in order to run @code{./configure && make}.
5799 @end itemize
5801 We recommend that you follow this same set of heuristics in your
5802 @file{Makefile.am}.
5805 @node Dist
5806 @chapter What Goes in a Distribution
5808 @section Basics of distribution
5810 @cindex make dist
5812 The @code{dist} rule in the generated @file{Makefile.in} can be used
5813 to generate a gzip'd @code{tar} file and other flavors of archive for
5814 distribution.  The files is named based on the @samp{PACKAGE} and
5815 @samp{VERSION} variables defined by @code{AM_INIT_AUTOMAKE}
5816 (@pxref{Macros}); more precisely the gzip'd @code{tar} file is named
5817 @samp{@var{package}-@var{version}.tar.gz}.
5818 @cvindex PACKAGE
5819 @cvindex VERSION
5820 @trindex dist
5821 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
5822 is run.  The default setting is @samp{--best}.
5824 For the most part, the files to distribute are automatically found by
5825 Automake: all source files are automatically included in a distribution,
5826 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
5827 has a built-in list of commonly used files which are automatically
5828 included if they are found in the current directory (either physically,
5829 or as the target of a @file{Makefile.am} rule).  This list is printed by
5830 @samp{automake --help}.  Also, files which are read by @code{configure}
5831 (i.e. the source files corresponding to the files specified in various
5832 Autoconf macros such as @code{AC_CONFIG_FILES} and siblings) are
5833 automatically distributed.  Files included in @file{Makefile.am}s (using
5834 @code{include}) or in @file{configure.ac} (using @code{m4_include}), and
5835 helper scripts installed with @samp{automake --add-missing} are also
5836 distributed.
5838 @cvindex m4_include, distribution
5840 Still, sometimes there are files which must be distributed, but which
5841 are not covered in the automatic rules.  These files should be listed in
5842 the @code{EXTRA_DIST} variable.  You can mention files from
5843 subdirectories in @code{EXTRA_DIST}.
5845 You can also mention a directory in @code{EXTRA_DIST}; in this case the
5846 entire directory will be recursively copied into the distribution.
5847 Please note that this will also copy @emph{everything} in the directory,
5848 including CVS/RCS version control files.  We recommend against using
5849 this feature.
5850 @vindex EXTRA_DIST
5852 If you define @code{SUBDIRS}, Automake will recursively include the
5853 subdirectories in the distribution.  If @code{SUBDIRS} is defined
5854 conditionally (@pxref{Conditionals}), Automake will normally include
5855 all directories that could possibly appear in @code{SUBDIRS} in the
5856 distribution.  If you need to specify the set of directories
5857 conditionally, you can set the variable @code{DIST_SUBDIRS} to the
5858 exact list of subdirectories to include in the distribution
5859 (@pxref{Conditional Subdirectories}).
5860 @vindex DIST_SUBDIRS
5863 @section Fine-grained distribution control
5865 Sometimes you need tighter control over what does @emph{not} go into the
5866 distribution; for instance you might have source files which are
5867 generated and which you do not want to distribute.  In this case
5868 Automake gives fine-grained control using the @samp{dist} and
5869 @samp{nodist} prefixes.  Any primary or @samp{_SOURCES} variable can be
5870 prefixed with @samp{dist_} to add the listed files to the distribution.
5871 Similarly, @samp{nodist_} can be used to omit the files from the
5872 distribution.
5873 @vindex dist_
5874 @vindex nodist_
5876 As an example, here is how you would cause some data to be distributed
5877 while leaving some source code out of the distribution:
5879 @example
5880 dist_data_DATA = distribute-this
5881 bin_PROGRAMS = foo
5882 nodist_foo_SOURCES = do-not-distribute.c
5883 @end example
5885 @section The dist hook
5887 @trindex dist-hook
5889 Occasionally it is useful to be able to change the distribution before
5890 it is packaged up.  If the @code{dist-hook} rule exists, it is run
5891 after the distribution directory is filled, but before the actual tar
5892 (or shar) file is created.  One way to use this is for distributing
5893 files in subdirectories for which a new @file{Makefile.am} is overkill:
5895 @example
5896 dist-hook:
5897         mkdir $(distdir)/random
5898         cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
5899 @end example
5901 Another way to to use this is for removing unnecessary files that get
5902 recursively included by specifying a directory in EXTRA_DIST:
5904 @example
5905 EXTRA_DIST = doc
5907 dist-hook:
5908         rm -rf `find $(distdir)/doc -name CVS`
5909 @end example
5911 @vindex distdir
5912 @vindex top_distdir
5913 Two variables that come handy when writing @code{dist-hook} rules are
5914 @code{$(distdir)} and @code{$(top_distdir)}.
5916 @code{$(distdir)} points to the directory where the @code{dist} rule
5917 will copy files from the current directory before creating the
5918 tarball.  If you are at the top-level directory, then @code{distdir =
5919 $(PACKAGE)-$(VERSION)}.  When used from subdirectory named
5920 @file{foo/}, then @code{distdir = ../$(PACKAGE)-$(VERSION)/foo}.
5921 @code{$(distdir)} can be a relative or absolute path, do not assume
5922 any form.
5924 @code{$(top_distdir)} always points to the root directory of the
5925 distributed tree.  At the top-level it's equal to @code{$(distdir)}.
5926 In the @file{foo/} subdirectory
5927 @code{top_distdir = ../$(PACKAGE)-$(VERSION)}.
5928 @code{$(top_distdir)} too can be a relative or absolute path.
5930 Note that when packages are nested using @code{AC_CONFIG_SUBDIRS}
5931 (@pxref{Subpackages}), then @code{$(distdir)} and
5932 @code{$(top_distdir)} are relative to the package where @code{make
5933 dist} was run, not to any sub-packages involved.
5935 @section Checking the distribution
5937 @cindex make distcheck
5938 @cindex make distcleancheck
5939 @vindex distcleancheck_listfiles
5940 @cindex make distuninstallcheck
5941 @vindex distuninstallcheck_listfiles
5943 Automake also generates a @code{distcheck} rule which can be of help
5944 to ensure that a given distribution will actually work.
5945 @code{distcheck} makes a distribution, then tries to do a @code{VPATH}
5946 build, run the test suite, and finally make another tarfile to ensure the
5947 distribution is self-contained.
5948 @trindex distcheck
5950 Building the package involves running @code{./configure}.  If you need
5951 to supply additional flags to @code{configure}, define them in the
5952 @code{DISTCHECK_CONFIGURE_FLAGS} variable, either in your top-level
5953 @file{Makefile.am}, or on the command line when invoking @code{make}.
5954 @vindex DISTCHECK_CONFIGURE_FLAGS
5956 If the @code{distcheck-hook} rule is defined in your top-level
5957 @file{Makefile.am}, then it will be invoked by @code{distcheck} after
5958 the new distribution has been unpacked, but before the unpacked copy
5959 is configured and built.  Your @code{distcheck-hook} can do almost
5960 anything, though as always caution is advised.  Generally this hook is
5961 used to check for potential distribution errors not caught by the
5962 standard mechanism.  Note that @code{distcheck-hook} as well as
5963 @code{DISTCHECK_CONFIGURE_FLAGS} are not honored in a subpackage
5964 @file{Makefile.am}, but the @code{DISTCHECK_CONFIGURE_FLAGS} are
5965 passed down to the @code{configure} script of the subpackage.
5968 Speaking about potential distribution errors, @code{distcheck} will also
5969 ensure that the @code{distclean} rule actually removes all built
5970 files.  This is done by running @code{make distcleancheck} at the end of
5971 the @code{VPATH} build.  By default, @code{distcleancheck} will run
5972 @code{distclean} and then make sure the build tree has been emptied by
5973 running @code{$(distcleancheck_listfiles)}.  Usually this check will
5974 find generated files that you forgot to add to the @code{DISTCLEANFILES}
5975 variable (@pxref{Clean}).
5976 @trindex distcleancheck
5978 The @code{distcleancheck} behavior should be OK for most packages,
5979 otherwise you have the possibility to override the definition of
5980 either the @code{distcleancheck} rule, or the
5981 @code{$(distcleancheck_listfiles)} variable.  For instance to disable
5982 @code{distcleancheck} completely, add the following rule to your
5983 top-level @file{Makefile.am}:
5984 @vindex distcleancheck_listfiles
5986 @example
5987 distcleancheck:
5988         @@:
5989 @end example
5991 If you want @code{distcleancheck} to ignore built files which have not
5992 been cleaned because they are also part of the distribution, add the
5993 following definition instead:
5995 @example
5996 distcleancheck_listfiles = \
5997   find -type f -exec sh -c 'test -f $(srcdir)/@{@} || echo @{@}' ';'
5998 @end example
6000 The above definition is not the default because it's usually an error if
6001 your Makefiles cause some distributed files to be rebuilt when the user
6002 build the package.  (Think about the user missing the tool required to
6003 build the file; or if the required tool is built by your package,
6004 consider the cross-compilation case where it can't be run.)  There is
6005 a FAQ entry about this (@pxref{distcleancheck}), make sure you read it
6006 before playing with @code{distcleancheck_listfiles}.
6008 @code{distcheck} also checks that the @code{uninstall} rule works
6009 properly, both for ordinary and @samp{DESTDIR} builds.  It does this
6010 by invoking @code{make uninstall}, and then it checks the install tree
6011 to see if any files are left over.  This check will make sure that you
6012 correctly coded your @code{uninstall}-related rules.
6014 By default, the checking is done by the @code{distuninstallcheck} rule,
6015 and the list of files in the install tree is generated by
6016 @code{$(distuninstallcheck_listfiles}) (this is a variable whose value is
6017 a shell command to run that prints the list of files to stdout).
6019 Either of these can be overridden to modify the behavior of
6020 @code{distcheck}.  For instance, to disable this check completely, you
6021 would write:
6023 @example
6024 distuninstallcheck:
6025         @@:
6026 @end example
6028 @section The types of distributions
6030 Automake generates rules to provide archives of the project for
6031 distributions in various formats.  Their targets are:
6033 @table @asis
6034 @item @code{dist-bzip2}
6035 Generate a bzip2 tar archive of the distribution.  bzip2 archives are
6036 frequently smaller than gzipped archives.
6037 @trindex dist-bzip2
6039 @item @code{dist-gzip}
6040 Generate a gzip tar archive of the distribution.
6041 @trindex dist-gzip
6043 @item @code{dist-shar}
6044 Generate a shar archive of the distribution.
6045 @trindex dist-shar
6047 @item @code{dist-zip}
6048 Generate a zip archive of the distribution.
6049 @trindex dist-zip
6051 @item @code{dist-tarZ}
6052 Generate a compressed tar archive of
6053 the distribution.
6054 @trindex dist-tarZ
6055 @end table
6057 The rule @code{dist} (and its historical synonym @code{dist-all}) will
6058 create archives in all the enabled formats, @ref{Options}.  By
6059 default, only the @code{dist-gzip} target is hooked to @code{dist}.
6062 @node Tests
6063 @chapter Support for test suites
6065 @cindex Test suites
6066 @cindex make check
6068 Automake supports two forms of test suites.
6070 @section Simple Tests
6072 If the variable @code{TESTS} is defined, its value is taken to be a list
6073 of programs to run in order to do the testing.  The programs can either
6074 be derived objects or source objects; the generated rule will look both
6075 in @code{srcdir} and @file{.}.  Programs needing data files should look
6076 for them in @code{srcdir} (which is both an environment variable and a
6077 make variable) so they work when building in a separate directory
6078 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
6079 Manual}), and in particular for the @code{distcheck} rule
6080 (@pxref{Dist}).
6082 @cindex Exit status 77, special interpretation
6084 The number of failures will be printed at the end of the run.  If a
6085 given test program exits with a status of 77, then its result is ignored
6086 in the final count.  This feature allows non-portable tests to be
6087 ignored in environments where they don't make sense.
6089 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
6090 variables for the test run; the environment variable @code{srcdir} is
6091 set in the rule.  If all your test programs are scripts, you can also
6092 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
6093 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
6094 @vindex TESTS
6095 @vindex TESTS_ENVIRONMENT
6097 @cindex Tests, expected failure
6098 @cindex Expected test failure
6100 You may define the variable @code{XFAIL_TESTS} to a list of tests
6101 (usually a subset of @code{TESTS}) that are expected to fail.  This will
6102 reverse the result of those tests.
6103 @vindex XFAIL_TESTS
6105 Automake ensures that each program listed in @code{TESTS} is built
6106 before any tests are run; you can list both source and derived programs
6107 in @code{TESTS}.  For instance, you might want to run a C program as a
6108 test.  To do this you would list its name in @code{TESTS} and also in
6109 @code{check_PROGRAMS}, and then specify it as you would any other
6110 program.
6112 @section DejaGnu Tests
6114 If @uref{ftp://ftp.gnu.org/gnu/dejagnu/, @samp{dejagnu}} appears in
6115 @code{AUTOMAKE_OPTIONS}, then a @code{dejagnu}-based test suite is
6116 assumed.  The variable @code{DEJATOOL} is a list of names which are
6117 passed, one at a time, as the @code{--tool} argument to @code{runtest}
6118 invocations; it defaults to the name of the package.
6120 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
6121 @code{--srcdir} flags that are passed to dejagnu by default; this can be
6122 overridden if necessary.
6123 @vindex RUNTESTDEFAULTFLAGS
6125 The variables @code{EXPECT} and @code{RUNTEST} can
6126 also be overridden to provide project-specific values.  For instance,
6127 you will need to do this if you are testing a compiler toolchain,
6128 because the default values do not take into account host and target
6129 names.
6130 @opindex dejagnu
6131 @vindex DEJATOOL
6132 @vindex EXPECT
6133 @vindex RUNTEST
6135 The contents of the variable @code{RUNTESTFLAGS} are passed to the
6136 @code{runtest} invocation.  This is considered a ``user variable''
6137 (@pxref{User Variables}).  If you need to set @code{runtest} flags in
6138 @file{Makefile.am}, you can use @code{AM_RUNTESTFLAGS} instead.
6139 @vindex RUNTESTFLAGS
6140 @vindex AM_RUNTESTFLAGS
6142 @cindex @file{site.exp}
6143 Automake will generate rules to create a local @file{site.exp} file,
6144 defining various variables detected by @code{./configure}.  This file
6145 is automatically read by DejaGnu.  It is OK for the user of a package
6146 to edit this file in order to tune the test suite.  However this is
6147 not the place where the test suite author should define new variables:
6148 this should be done elsewhere in the real test suite code.
6149 Especially, @file{site.exp} should not be distributed.
6151 For more information regarding DejaGnu test suites, see @xref{Top, , ,
6152 dejagnu, The DejaGnu Manual}.
6154 In either case, the testing is done via @samp{make check}.
6156 @section Install Tests
6158 The @code{installcheck} target is available to the user as a way to
6159 run any tests after the package has been installed.  You can add tests
6160 to this by writing an @code{installcheck-local} rule.
6163 @node Rebuilding
6164 @chapter Rebuilding Makefiles
6165 @cindex rebuild rules
6167 Automake generates rules to automatically rebuild @file{Makefile}s,
6168 @file{configure}, and other derived files like @file{Makefile.in}.
6170 @cvindex AM_MAINTAINER_MODE
6171 If you are using @code{AM_MAINTAINER_MODE} in @file{configure.ac}, then
6172 these automatic rebuilding rules are only enabled in maintainer mode.
6174 @vindex ACLOCAL_AMFLAGS
6175 Sometimes you need to run @code{aclocal} with an argument like @code{-I}
6176 to tell it where to find @file{.m4} files.  Since sometimes @code{make}
6177 will automatically run @code{aclocal}, you need a way to specify these
6178 arguments.  You can do this by defining @code{ACLOCAL_AMFLAGS}; this
6179 holds arguments which are passed verbatim to @code{aclocal}.  This variable
6180 is only useful in the top-level @file{Makefile.am}.
6182 @vindex CONFIG_STATUS_DEPENDENCIES
6183 @vindex CONFIGURE_DEPENDENCIES
6184 @cindex @file{version.sh}, example
6185 @cindex @file{version.m4}, example
6187 Sometimes it is convenient to supplement the rebuild rules for
6188 @file{configure} or @file{config.status} with additional dependencies.
6189 The variables @code{CONFIGURE_DEPENDENCIES} and
6190 @code{CONFIG_STATUS_DEPENDENCIES} can be used to list these extra
6191 dependencies.  These variable should be defined in all
6192 @file{Makefile}s of the tree (because these two rebuild rules are
6193 output in all them), so it is safer and easier to @code{AC_SUBST} them
6194 from @file{configure.ac}.  For instance the following statement will
6195 cause @file{configure} to be rerun each time @file{version.sh} is
6196 changed.
6197 @example
6198 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version.sh'])
6199 @end example
6200 @noindent
6201 Note the @code{$(top_srcdir)/} in the filename.  Since this variable
6202 is to be used in all @file{Makefile}s, its value must be sensible at
6203 any level in the build hierarchy.
6205 Beware not to mistake @code{CONFIGURE_DEPENDENCIES} for
6206 @code{CONFIG_STATUS_DEPENDENCIES}.
6208 @code{CONFIGURE_DEPENDENCIES} adds dependencies to the
6209 @file{configure} rule, whose effect is to run @code{autoconf}.  This
6210 variable should be seldom used, because @code{automake} already tracks
6211 @code{m4_include}d files.  However it can be useful when playing
6212 tricky games with @code{m4_esyscmd} or similar non-recommendable
6213 macros with side effects.
6215 @code{CONFIG_STATUS_DEPENDENCIES} adds dependencies to the
6216 @file{config.status} rule, whose effect is to run @file{configure}.
6217 This variable should therefore carry any non-standard source that may
6218 be read as a side effect of running configure, like @file{version.sh}
6219 in the example above.
6221 Speaking of @file{version.sh} scripts, we recommend against them
6222 today.  They are mainly used when the version of a package is updated
6223 automatically by a script (e.g., in daily builds).  Here is what some
6224 old-style @file{configure.ac}s may look like:
6225 @example
6226 AC_INIT
6227 . $srcdir/version.sh
6228 AM_INIT_AUTOMAKE([name], $VERSION_NUMBER)
6229 @dots{}
6230 @end example
6231 @noindent
6232 Here, @file{version.sh} is a shell fragment that sets
6233 @code{VERSION_NUMBER}.  The problem with this example is that
6234 @code{automake} cannot track dependencies (listing @file{version.sh}
6235 in @code{CONFIG_STATUS_DEPENDENCIES}, and distributing this file is up
6236 to the user), and that it uses the obsolete form of @code{AC_INIT} and
6237 @code{AM_INIT_AUTOMAKE}.  Upgrading to the new syntax is not
6238 straightforward, because shell variables are not allowed in
6239 @code{AC_INIT}'s arguments.  We recommend that @file{version.sh} be
6240 replaced by an M4 file that is included by @file{configure.ac}:
6241 @example
6242 m4_include([version.m4])
6243 AC_INIT([name], VERSION_NUMBER)
6244 AM_INIT_AUTOMAKE
6245 @dots{}
6246 @end example
6247 @noindent
6248 Here @file{version.m4} could contain something like
6249 @code{m4_define([VERSION_NUMBER], [1.2])}.  The advantage of this
6250 second form is that @code{automake} will take care of the dependencies
6251 when defining the rebuild rule, and will also distribute the file
6252 automatically.  An inconvenience is that @code{autoconf} will now be
6253 rerun each time the version number is bumped, when only
6254 @file{configure} had to be rerun in the previous setup.
6257 @node Options
6258 @chapter Changing Automake's Behavior
6260 Various features of Automake can be controlled by options in the
6261 @file{Makefile.am}.  Such options are applied on a per-@file{Makefile}
6262 basis when listed in a special @file{Makefile} variable named
6263 @code{AUTOMAKE_OPTIONS}.  They are applied globally to all processed
6264 @file{Makefiles} when listed in the first argument of
6265 @code{AM_INIT_AUTOMAKE} in @file{configure.ac}.  Currently understood
6266 options are:
6267 @vindex AUTOMAKE_OPTIONS
6269 @table @asis
6270 @item @code{gnits}
6271 @itemx @code{gnu}
6272 @itemx @code{foreign}
6273 @itemx @code{cygnus}
6274 @cindex Option, gnits
6275 @cindex Option, gnu
6276 @cindex Option, foreign
6277 @cindex Option, cygnus
6279 Set the strictness as appropriate.  The @code{gnits} option also implies
6280 @code{readme-alpha} and @code{check-news}.
6282 @item @code{ansi2knr}
6283 @itemx @code{@var{path}/ansi2knr}
6284 @cindex Option, ansi2knr
6285 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceded by a
6286 path, the generated @file{Makefile.in} will look in the specified
6287 directory to find the @file{ansi2knr} program.  The path should be a
6288 relative path to another directory in the same distribution (Automake
6289 currently does not check this).
6291 @item @code{check-news}
6292 @cindex Option, check-news
6293 Cause @code{make dist} to fail unless the current version number appears
6294 in the first few lines of the @file{NEWS} file.
6296 @item @code{dejagnu}
6297 @cindex Option, dejagnu
6298 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
6300 @item @code{dist-bzip2}
6301 @cindex Option, dist-bzip2
6302 Hook @code{dist-bzip2} to @code{dist}.
6303 @trindex dist-bzip2
6305 @item @code{dist-shar}
6306 @cindex Option, dist-shar
6307 Hook @code{dist-shar} to @code{dist}.
6308 @trindex dist-shar
6310 @item @code{dist-zip}
6311 @cindex Option, dist-zip
6312 Hook @code{dist-zip} to @code{dist}.
6313 @trindex dist-zip
6315 @item @code{dist-tarZ}
6316 @cindex Option, dist-tarZ
6317 Hook @code{dist-tarZ} to @code{dist}.
6318 @trindex dist-tarZ
6320 @item @code{filename-length-max=99}
6321 @cindex Option, filename-length-max=99
6322 @trindex filename-length-max=99
6323 Abort if filenames longer than 99 characters are found during
6324 @code{make dist}.  Such long filenames are generally considered not to
6325 be portable in tarballs.  See the @code{tar-v7} and @code{tar-ustar}
6326 options below.  This option should be used in the top-level
6327 @file{Makefile.am} or as an argument of @code{AM_INIT_AUTOMAKE} in
6328 @file{configure.ac}, it will be ignored otherwise.
6330 @item @code{no-define}
6331 @cindex Option, no-define
6332 This options is meaningful only when passed as an argument to
6333 @code{AM_INIT_AUTOMAKE}.  It will prevent the @code{PACKAGE} and
6334 @code{VERSION} variables to be @code{AC_DEFINE}d.
6336 @item @code{no-dependencies}
6337 @cindex Option, no-dependencies
6338 This is similar to using @samp{--include-deps} on the command line, but
6339 is useful for those situations where you don't have the necessary bits
6340 to make automatic dependency tracking work @xref{Dependencies}.  In this
6341 case the effect is to effectively disable automatic dependency tracking.
6343 @item @code{no-dist}
6344 @cindex Option, no-dist
6345 Don't emit any code related to @code{dist} target.  This is useful
6346 when a package has its own method for making distributions.
6348 @item @code{no-dist-gzip}
6349 @cindex Option, no-dist-gzip
6350 Do not hook @code{dist-gzip} to @code{dist}.
6351 @trindex no-dist-gzip
6353 @item @code{no-exeext}
6354 @cindex Option, no-exeext
6355 If your @file{Makefile.am} defines a rule for target @samp{foo}, it
6356 will override a rule for a target named @samp{foo$(EXEEXT)}.  This is
6357 necessary when @code{EXEEXT} is found to be empty.  However, by
6358 default automake will generate an error for this use.  The
6359 @code{no-exeext} option will disable this error.  This is intended for
6360 use only where it is known in advance that the package will not be
6361 ported to Windows, or any other operating system using extensions on
6362 executables.
6364 @item @code{no-installinfo}
6365 @cindex Option, no-installinfo
6366 The generated @file{Makefile.in} will not cause info pages to be built
6367 or installed by default.  However, @code{info} and @code{install-info}
6368 targets will still be available.  This option is disallowed at
6369 @samp{GNU} strictness and above.
6370 @trindex info
6371 @trindex install-info
6373 @item @code{no-installman}
6374 @cindex Option, no-installman
6375 The generated @file{Makefile.in} will not cause man pages to be
6376 installed by default.  However, an @code{install-man} target will still
6377 be available for optional installation.  This option is disallowed at
6378 @samp{GNU} strictness and above.
6379 @trindex install-man
6381 @item @code{nostdinc}
6382 @cindex Option, nostdinc
6383 This option can be used to disable the standard @samp{-I} options which
6384 are ordinarily automatically provided by Automake.
6386 @item @code{no-texinfo.tex}
6387 @cindex Option, no-texinfo
6388 Don't require @file{texinfo.tex}, even if there are texinfo files in
6389 this directory.
6391 @item @code{readme-alpha}
6392 @cindex Option, readme-alpha
6393 If this release is an alpha release, and the file @file{README-alpha}
6394 exists, then it will be added to the distribution.  If this option is
6395 given, version numbers are expected to follow one of two forms.  The
6396 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
6397 element is a number; the final period and number should be left off for
6398 non-alpha releases.  The second form is
6399 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
6400 letter; it should be omitted for non-alpha releases.
6402 @item @code{std-options}
6403 @cindex Options, std-options
6404 @cindex make installcheck
6405 Make the @code{installcheck} rule check that installed scripts and
6406 programs support the @code{--help} and @code{--version} options.
6407 This also provides a basic check that the program's
6408 run-time dependencies are satisfied after installation.
6410 @vindex AM_INSTALLCHECK_STD_OPTIONS_EXEMPT
6411 In a few situations, programs (or scripts) have to be exempted from this
6412 test.  For instance @command{false} (from GNU sh-utils) is never
6413 successful, even for @code{--help} or @code{--version}.  You can list
6414 such programs in the variable @code{AM_INSTALLCHECK_STD_OPTIONS_EXEMPT}.
6415 Programs (not scripts) listed in this variable should be suffixed by
6416 @code{$(EXEEXT)} for the sake of Win32 or OS/2.  For instance suppose we
6417 build @code{false} as a program but @code{true.sh} as a script, and that
6418 neither of them support @code{--help} or @code{--version}:
6420 @example
6421 AUTOMAKE_OPTIONS = std-options
6422 bin_PROGRAMS = false ...
6423 bin_SCRIPTS = true.sh ...
6424 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false$(EXEEXT) true.sh
6425 @end example
6427 @item @code{subdir-objects}
6428 If this option is specified, then objects are placed into the
6429 subdirectory of the build directory corresponding to the subdirectory of
6430 the source file.  For instance if the source file is
6431 @file{subdir/file.cxx}, then the output file would be
6432 @file{subdir/file.o}.
6434 In order to use this option with C sources, you should add
6435 @code{AM_PROG_CC_C_O} to @file{configure.ac}.
6437 @item @code{tar-v7}
6438 @itemx @code{tar-ustar}
6439 @itemx @code{tar-pax}
6440 @cindex Option, tar-v7
6441 @cindex Option, tar-ustar
6442 @cindex Option, tar-pax
6443 @cindex tar formats
6444 @cindex v7 tar format
6445 @cindex ustar format
6446 @cindex pax format
6447 @trindex tar-v7
6448 @trindex tar-ustar
6449 @trindex tar-pax
6451 These three mutually exclusive options select the tar format to use
6452 when generating tarballs with @code{make dist}.  (The tar file created
6453 is then compressed according to the set of @code{no-dist-gzip},
6454 @code{dist-bzip2} and @code{dist-tarZ} options in use.)
6456 These options must be passed as argument to @code{AM_INIT_AUTOMAKE}
6457 (@pxref{Macros}) because they can causes new configure check to be
6458 performed.  Automake will complain if it sees such option in a
6459 @code{AUTOMAKE_OPTIONS} variable.
6461 @code{tar-v7} selects the old V7 tar format.  This is the historical
6462 default.  This antiquated format is understood by all tar
6463 implementations and supports filenames with up to 99 characters. When
6464 given longer filenames some tar implementations will diagnose the
6465 problem while other will generate broken tarballs or use non-portable
6466 extensions.  Furthermore, the V7 format cannot store empty
6467 directories.  When using this format, consider using the
6468 @code{filename-length-max=99} option to catch filenames too long.
6470 @code{tar-ustar} selects the ustar format defined by POSIX
6471 1003.1-1988.  This format is believed to be old enough to be portable.
6472 It fully supports empty directories.  It can stores filenames with up
6473 to 256 characters, provided that the filename can be split at
6474 directory separator in two parts, first of them being at most 155
6475 bytes long. So, in most cases the maximum file name length will be
6476 shorter than 256 characters.  However you may run against broken tar
6477 implementations that incorrectly handle filenames longer than 99
6478 characters (please report them to @email{bug-automake@@gnu.org} so we
6479 can document this accurately).
6481 @code{tar-pax} selects the new pax interchange format defined by POSIX
6482 1003.1-2001.  It does not limit the length of filenames.  However,
6483 this format is very young and should probably be restricted to
6484 packages which target only very modern platforms.  There are moves to
6485 change the pax format in an upward-compatible way, so this option may
6486 refer to a more recent version in the future.
6488 @xref{Formats, , Controlling the Archive Format, tar, GNU Tar}, for
6489 further discussion about tar formats.
6491 @code{configure} knows several ways to construct these formats.  It
6492 will not abort if it cannot find a tool up to the task (so that the
6493 package can still be built), but @code{make dist} will fail.
6495 @item @var{version}
6496 @cindex Option, version
6497 A version number (e.g. @samp{0.30}) can be specified.  If Automake is not
6498 newer than the version specified, creation of the @file{Makefile.in}
6499 will be suppressed.
6501 @item @code{-W@var{category}} or @code{--warnings=@var{category}}
6502 @cindex Option, warnings
6503 These options behave exactly like their command-line counterpart
6504 (@pxref{Invoking Automake}).  This allows you to enable or disable some
6505 warning categories on a per-file basis.  You can also setup some warnings
6506 for your entire project; for instance try @code{AM_INIT_AUTOMAKE([-Wall])}
6507 in your @file{configure.ac}.
6509 @end table
6511 Unrecognized options are diagnosed by @code{automake}.
6513 If you want an option to apply to all the files in the tree, you can use
6514 the @code{AM_INIT_AUTOMAKE} macro in @file{configure.ac}.
6515 @xref{Macros}.
6518 @node Miscellaneous
6519 @chapter Miscellaneous Rules
6521 There are a few rules and variables that didn't fit anywhere else.
6523 @menu
6524 * Tags::                        Interfacing to etags and mkid
6525 * Suffixes::                    Handling new file extensions
6526 * Multilibs::                   Support for multilibs.
6527 @end menu
6530 @node Tags
6531 @section Interfacing to @code{etags}
6533 @cindex TAGS support
6535 Automake will generate rules to generate @file{TAGS} files for use with
6536 GNU Emacs under some circumstances.
6538 @trindex tags
6539 If any C, C++ or Fortran 77 source code or headers are present, then
6540 @code{tags} and @code{TAGS} rules will be generated for the directory.
6541 All files listed using the @code{_SOURCES}, @code{_HEADERS}, and
6542 @code{_LISP} primaries will be used to generate tags.  Note that
6543 generated source files that are not distributed must be declared in
6544 variables like @code{nodist_noinst_HEADERS} or
6545 @code{nodist_@var{prog}_SOURCES} or they will be ignored.
6547 At the topmost directory of a multi-directory package, a @code{tags}
6548 rule will be output which, when run, will generate a @file{TAGS} file
6549 that includes by reference all @file{TAGS} files from subdirectories.
6551 The @code{tags} rule will also be generated if the variable
6552 @code{ETAGS_ARGS} is defined.  This variable is intended for use in
6553 directories which contain taggable source that @code{etags} does not
6554 understand.  The user can use the @code{ETAGSFLAGS} to pass additional
6555 flags to @code{etags}; @code{AM_ETAGSFLAGS} is also available for use
6556 in @file{Makefile.am}.
6557 @vindex ETAGS_ARGS
6558 @vindex ETAGSFLAGS
6559 @vindex AM_ETAGSFLAGS
6561 Here is how Automake generates tags for its source, and for nodes in its
6562 Texinfo file:
6564 @example
6565 ETAGS_ARGS = automake.in --lang=none \
6566  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
6567 @end example
6569 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
6570 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
6571 are added directly to the dependencies for the @code{tags} rule.
6572 @vindex TAGS_DEPENDENCIES
6574 Automake also generates a @code{ctags} rule which can be used to
6575 build @command{vi}-style @file{tags} files.  The variable @code{CTAGS}
6576 is the name of the program to invoke (by default @samp{ctags});
6577 @code{CTAGSFLAGS} can be used by the user to pass additional flags,
6578 and @code{AM_CTAGSFLAGS} can be used by the @file{Makefile.am}.
6580 Automake will also generate an @code{ID} rule which will run
6581 @code{mkid} on the source.  This is only supported on a
6582 directory-by-directory basis.
6583 @trindex id
6585 Automake also supports the @uref{http://www.gnu.org/software/global/,
6586 GNU Global Tags program}.  The @code{GTAGS} rule runs Global Tags
6587 automatically and puts the result in the top build directory.  The
6588 variable @code{GTAGS_ARGS} holds arguments which are passed to
6589 @code{gtags}.
6590 @vindex GTAGS_ARGS
6593 @node Suffixes
6594 @section Handling new file extensions
6596 @cindex Adding new SUFFIXES
6597 @cindex SUFFIXES, adding
6598 @vindex SUFFIXES
6600 It is sometimes useful to introduce a new implicit rule to handle a file
6601 type that Automake does not know about.
6603 For instance, suppose you had a compiler which could compile @samp{.foo}
6604 files to @samp{.o} files.  You would simply define an suffix rule for
6605 your language:
6607 @example
6608 .foo.o:
6609         foocc -c -o $@@ $<
6610 @end example
6612 Then you could directly use a @samp{.foo} file in a @samp{_SOURCES}
6613 variable and expect the correct results:
6615 @example
6616 bin_PROGRAMS = doit
6617 doit_SOURCES = doit.foo
6618 @end example
6620 This was the simpler and more common case.  In other cases, you will
6621 have to help Automake to figure which extensions you are defining your
6622 suffix rule for.  This usually happens when your extensions does not
6623 start with a dot.  Then, all you have to do is to put a list of new
6624 suffixes in the @code{SUFFIXES} variable @strong{before} you define your
6625 implicit rule.
6627 For instance the following definition prevents Automake to misinterpret
6628 @samp{.idlC.cpp:} as an attempt to transform @samp{.idlC} into
6629 @samp{.cpp}.
6631 @example
6632 SUFFIXES = .idl C.cpp
6633 .idlC.cpp:
6634         # whatever
6635 @end example
6637 As you may have noted, the @code{SUFFIXES} variable behaves like the
6638 @code{.SUFFIXES} special target of @code{make}.  You should not touch
6639 @code{.SUFFIXES} yourself, but use @code{SUFFIXES} instead and let
6640 Automake generate the suffix list for @code{.SUFFIXES}.  Any given
6641 @code{SUFFIXES} go at the start of the generated suffixes list, followed
6642 by Automake generated suffixes not already in the list.
6644 @node Multilibs
6645 @section Support for Multilibs
6647 Automake has support for an obscure feature called multilibs.  A
6648 @dfn{multilib} is a library which is built for multiple different ABIs
6649 at a single time; each time the library is built with a different target
6650 flag combination.  This is only useful when the library is intended to
6651 be cross-compiled, and it is almost exclusively used for compiler
6652 support libraries.
6654 The multilib support is still experimental.  Only use it if you are
6655 familiar with multilibs and can debug problems you might encounter.
6658 @node Include
6659 @chapter Include
6661 @cmindex include
6662 @cindex Including Makefile fragment
6663 @cindex Makefile fragment, including
6665 Automake supports an @code{include} directive which can be used to
6666 include other @file{Makefile} fragments when @code{automake} is run.
6667 Note that these fragments are read and interpreted by @code{automake},
6668 not by @code{make}.  As with conditionals, @code{make} has no idea that
6669 @code{include} is in use.
6671 There are two forms of @code{include}:
6673 @table @code
6674 @item include $(srcdir)/file
6675 Include a fragment which is found relative to the current source
6676 directory.
6678 @item include $(top_srcdir)/file
6679 Include a fragment which is found relative to the top source directory.
6680 @end table
6682 Note that if a fragment is included inside a conditional, then the
6683 condition applies to the entire contents of that fragment.
6685 Makefile fragments included this way are always distributed because
6686 there are needed to rebuild @file{Makefile.in}.
6688 @node Conditionals
6689 @chapter Conditionals
6691 @cindex Conditionals
6693 Automake supports a simple type of conditionals.
6695 @cvindex AM_CONDITIONAL
6696 Before using a conditional, you must define it by using
6697 @code{AM_CONDITIONAL} in the @code{configure.ac} file (@pxref{Macros}).
6699 @defmac AM_CONDITIONAL (@var{conditional}, @var{condition})
6700 The conditional name, @var{conditional}, should be a simple string
6701 starting with a letter and containing only letters, digits, and
6702 underscores.  It must be different from @samp{TRUE} and @samp{FALSE}
6703 which are reserved by Automake.
6705 The shell @var{condition} (suitable for use in a shell @code{if}
6706 statement) is evaluated when @code{configure} is run.  Note that you
6707 must arrange for @emph{every} @code{AM_CONDITIONAL} to be invoked every
6708 time @code{configure} is run -- if @code{AM_CONDITIONAL} is run
6709 conditionally (e.g., in a shell @code{if} statement), then the result
6710 will confuse automake.
6711 @end defmac
6713 @cindex --enable-debug, example
6714 @cindex Example conditional --enable-debug
6715 @cindex Conditional example,  --enable-debug
6717 Conditionals typically depend upon options which the user provides to
6718 the @code{configure} script.  Here is an example of how to write a
6719 conditional which is true if the user uses the @samp{--enable-debug}
6720 option.
6722 @example
6723 AC_ARG_ENABLE(debug,
6724 [  --enable-debug    Turn on debugging],
6725 [case "$@{enableval@}" in
6726   yes) debug=true ;;
6727   no)  debug=false ;;
6728   *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
6729 esac],[debug=false])
6730 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
6731 @end example
6733 Here is an example of how to use that conditional in @file{Makefile.am}:
6735 @cmindex if
6736 @cmindex endif
6737 @cmindex else
6739 @example
6740 if DEBUG
6741 DBG = debug
6742 else
6743 DBG =
6744 endif
6745 noinst_PROGRAMS = $(DBG)
6746 @end example
6748 This trivial example could also be handled using EXTRA_PROGRAMS
6749 (@pxref{Conditional Programs}).
6751 You may only test a single variable in an @code{if} statement, possibly
6752 negated using @samp{!}.  The @code{else} statement may be omitted.
6753 Conditionals may be nested to any depth.  You may specify an argument to
6754 @code{else} in which case it must be the negation of the condition used
6755 for the current @code{if}.  Similarly you may specify the condition
6756 which is closed by an @code{end}:
6758 @example
6759 if DEBUG
6760 DBG = debug
6761 else !DEBUG
6762 DBG =
6763 endif !DEBUG
6764 @end example
6766 @noindent
6767 Unbalanced conditions are errors.
6769 Note that conditionals in Automake are not the same as conditionals in
6770 GNU Make.  Automake conditionals are checked at configure time by the
6771 @file{configure} script, and affect the translation from
6772 @file{Makefile.in} to @file{Makefile}.  They are based on options passed
6773 to @file{configure} and on results that @file{configure} has discovered
6774 about the host system.  GNU Make conditionals are checked at @code{make}
6775 time, and are based on variables passed to the make program or defined
6776 in the @file{Makefile}.
6778 Automake conditionals will work with any make program.
6781 @node Gnits
6782 @chapter The effect of @code{--gnu} and @code{--gnits}
6784 @cindex --gnu, required files
6785 @cindex --gnu, complete description
6787 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
6788 variable) causes @code{automake} to check the following:
6790 @itemize @bullet
6791 @item
6792 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{AUTHORS},
6793 and @file{ChangeLog}, plus one of @file{COPYING.LIB}, @file{COPYING.LESSER}
6794 or @file{COPYING}, are required at the topmost directory of the package.
6796 @item
6797 The options @samp{no-installman} and @samp{no-installinfo} are
6798 prohibited.
6799 @end itemize
6801 Note that this option will be extended in the future to do even more
6802 checking; it is advisable to be familiar with the precise requirements
6803 of the GNU standards.  Also, @samp{--gnu} can require certain
6804 non-standard GNU programs to exist for use by various maintainer-only
6805 rules; for instance in the future @code{pathchk} might be required for
6806 @samp{make dist}.
6808 @cindex --gnits, complete description
6810 The @samp{--gnits} option does everything that @samp{--gnu} does, and
6811 checks the following as well:
6813 @itemize @bullet
6814 @item
6815 @samp{make installcheck} will check to make sure that the @code{--help}
6816 and @code{--version} really print a usage message and a version string,
6817 respectively.  This is the @code{std-options} option (@pxref{Options}).
6819 @item
6820 @samp{make dist} will check to make sure the @file{NEWS} file has been
6821 updated to the current version.
6823 @item
6824 @samp{VERSION} is checked to make sure its format complies with Gnits
6825 standards.
6826 @c FIXME xref when standards are finished
6828 @item
6829 @cindex README-alpha
6830 If @samp{VERSION} indicates that this is an alpha release, and the file
6831 @file{README-alpha} appears in the topmost directory of a package, then
6832 it is included in the distribution.  This is done in @samp{--gnits}
6833 mode, and no other, because this mode is the only one where version
6834 number formats are constrained, and hence the only mode where Automake
6835 can automatically determine whether @file{README-alpha} should be
6836 included.
6838 @item
6839 The file @file{THANKS} is required.
6840 @end itemize
6843 @node Cygnus
6844 @chapter The effect of @code{--cygnus}
6846 @cindex Cygnus strictness
6848 Some packages, notably GNU GCC and GNU gdb, have a build environment
6849 originally written at Cygnus Support (subsequently renamed Cygnus
6850 Solutions, and then later purchased by Red Hat).  Packages with this
6851 ancestry are sometimes referred to as ``Cygnus'' trees.
6853 A Cygnus tree has slightly different rules for how a @file{Makefile.in}
6854 is to be constructed.  Passing @samp{--cygnus} to @code{automake} will
6855 cause any generated @file{Makefile.in} to comply with Cygnus rules.
6857 Here are the precise effects of @samp{--cygnus}:
6859 @itemize @bullet
6860 @item
6861 Info files are always created in the build directory, and not in the
6862 source directory.
6864 @item
6865 @file{texinfo.tex} is not required if a Texinfo source file is
6866 specified.  The assumption is that the file will be supplied, but in a
6867 place that Automake cannot find.  This assumption is an artifact of how
6868 Cygnus packages are typically bundled.
6870 @item
6871 @samp{make dist} is not supported, and the rules for it are not
6872 generated.  Cygnus-style trees use their own distribution mechanism.
6874 @item
6875 Certain tools will be searched for in the build tree as well as in the
6876 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
6877 @code{makeinfo} and @code{texi2dvi}.
6879 @item
6880 @code{--foreign} is implied.
6882 @item
6883 The options @samp{no-installinfo} and @samp{no-dependencies} are
6884 implied.
6886 @item
6887 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
6888 required.
6890 @item
6891 The @code{check} target doesn't depend on @code{all}.
6892 @end itemize
6894 GNU maintainers are advised to use @samp{gnu} strictness in preference
6895 to the special Cygnus mode.  Some day, perhaps, the differences between
6896 Cygnus trees and GNU trees will disappear (for instance, as GCC is made
6897 more standards compliant).  At that time the special Cygnus mode will be
6898 removed.
6901 @node Not Enough
6902 @chapter When Automake Isn't Enough
6904 In some situations, where Automake is not up to one task, one has to
6905 resort to handwritten rules or even handwritten @file{Makefile}s.
6907 @menu
6908 * Extending::                   Adding new rules or overriding existing ones.
6909 * Third-Party Makefiles::       Integrating Non-Automake @file{Makefile}s.
6910 @end menu
6912 @node Extending
6913 @section Extending Automake Rules
6915 With some minor exceptions (like @code{_PROGRAMS} variables being
6916 rewritten to append @code{$(EXEEXT)}), the contents of a
6917 @file{Makefile.am} is copied to @file{Makefile.in} verbatim.
6919 @cindex copying semantics
6921 These copying semantics means that many problems can be worked around
6922 by simply adding some @code{make} variables and rules to
6923 @file{Makefile.am}.  Automake will ignore these additions.
6925 @cindex conflicting definitions
6926 @cindex rules, conflicting
6927 @cindex variables, conflicting
6928 @cindex definitions, conflicts
6930 Since a @file{Makefile.in} is built from data gathered from three
6931 different places (@file{Makefile.am}, @file{configure.ac}, and
6932 @command{automake} itself), it is possible to have conflicting
6933 definitions of rules or variables.  When building @file{Makefile.in}
6934 the following priorities are respected by @command{automake} to ensure
6935 the user always have the last word.  User defined variables in
6936 @file{Makefile.am} have priority over variables @code{AC_SUBST}ed from
6937 @file{configure.ac}, and @code{AC_SUBST}ed variables have priority
6938 over @command{automake}-defined variables.  As far rules are
6939 concerned, a user-defined rule overrides any
6940 @command{automake}-defined rule for the same target.
6942 @cindex overriding rules
6943 @cindex overriding semantics
6944 @cindex rules, overriding
6946 These overriding semantics make it possible to fine tune some default
6947 settings of Automake, or replace some of its rules.  Overriding
6948 Automake rules is often inadvisable, particularly in the topmost
6949 directory of a package with subdirectories.  The @code{-Woverride}
6950 option (@pxref{Invoking Automake}) comes handy to catch overridden
6951 definitions.
6953 Note that Automake does not make any difference between rules with
6954 commands and rules that only specify dependencies.  So it is not
6955 possible to append new dependencies to an @code{automake}-defined
6956 target without redefining the entire rule.
6958 @cindex -local targets
6959 @cindex local targets
6961 However, various useful targets have a @samp{-local} version you can
6962 specify in your @file{Makefile.am}.  Automake will supplement the
6963 standard target with these user-supplied targets.
6965 @trindex  all
6966 @trindex  all-local
6967 @trindex  info
6968 @trindex  info-local
6969 @trindex  dvi
6970 @trindex  dvi-local
6971 @trindex  ps
6972 @trindex  ps-local
6973 @trindex  pdf
6974 @trindex  pdf-local
6975 @trindex  html
6976 @trindex  html-local
6977 @trindex  check
6978 @trindex  check-local
6979 @trindex  install
6980 @trindex  install-data-local
6981 @trindex  install-exec
6982 @trindex  install-exec-local
6983 @trindex  uninstall
6984 @trindex  uninstall-local
6985 @trindex  mostlyclean
6986 @trindex  mostlyclean-local
6987 @trindex  clean
6988 @trindex  clean-local
6989 @trindex  distclean
6990 @trindex  distclean-local
6991 @trindex  installdirs
6992 @trindex  installdirs-local
6993 @trindex  installcheck
6994 @trindex  installcheck-local
6996 The targets that support a local version are @code{all}, @code{info},
6997 @code{dvi}, @code{ps}, @code{pdf}, @code{html}, @code{check},
6998 @code{install-data}, @code{install-exec}, @code{uninstall},
6999 @code{installdirs}, @code{installcheck} and the various @code{clean} targets
7000 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
7001 @code{maintainer-clean}).  Note that there are no
7002 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
7003 use @code{uninstall-local}.  It doesn't make sense to uninstall just
7004 data or just executables.
7006 For instance, here is one way to install a file in @file{/etc}:
7008 @example
7009 install-data-local:
7010         $(INSTALL_DATA) $(srcdir)/afile $(DESTDIR)/etc/afile
7011 @end example
7013 @cindex -hook targets
7014 @cindex hook targets
7016 Some rule also have a way to run another rule, called a @dfn{hook},
7017 after their work is done.  The hook is named after the principal target,
7018 with @samp{-hook} appended.  The targets allowing hooks are
7019 @code{install-data}, @code{install-exec}, @code{uninstall}, @code{dist},
7020 and @code{distcheck}.
7021 @trindex install-data-hook
7022 @trindex install-exec-hook
7023 @trindex uninstall-hook
7024 @trindex dist-hook
7026 For instance, here is how to create a hard link to an installed program:
7028 @example
7029 install-exec-hook:
7030         ln $(DESTDIR)$(bindir)/program$(EXEEXT) \
7031            $(DESTDIR)$(bindir)/proglink$(EXEEXT)
7032 @end example
7034 Although cheaper and more portable than symbolic links, hard links
7035 will not work everywhere (for instance OS/2 does not have
7036 @command{ln}).  Ideally you should fall back to @code{cp -p} when
7037 @code{ln} does not work.  An easy way, if symbolic links are
7038 acceptable to you, is to add @code{AC_PROG_LN_S} to
7039 @file{configure.ac} (@pxref{Particular Programs, , Particular Program
7040 Checks, autoconf, The Autoconf Manual}) and use @code{$(LN_S)} in
7041 @file{Makefile.am}.
7043 @cindex versioned binaries, installing
7044 @cindex installing versioned binaries
7045 @cindex LN_S example
7046 For instance, here is how you could install a versioned copy of a
7047 program using @code{$(LN_S)}:
7049 @example
7050 install-exec-hook:
7051         cd $(DESTDIR)$(bindir) && \
7052           mv -f prog$(EXEEXT) prog-$(VERSION)$(EXEEXT) && \
7053           $(LN_S) prog-$(VERSION)$(EXEEXT) prog$(EXEEXT)
7054 @end example
7056 Note that we rename the program so that a new version will erase the
7057 symbolic link, not the real binary.  Also we @code{cd} into the
7058 destination directory in order to create relative links.
7060 When writing @code{install-exec-hook} or @code{install-data-hook},
7061 please bear in mind that the exec/data distinction is based on the
7062 installation directory, not on the primary used (@pxref{Install}).  So
7063 a @code{foo_SCRIPTS} will be installed by @code{install-data}, and a
7064 @code{barexec_SCRIPTS} will be installed by @code{install-exec}.  You
7065 should define your hooks consequently.
7067 @c FIXME should include discussion of variables you can use in these
7068 @c rules
7070 @node Third-Party Makefiles
7071 @section Third-Party @file{Makefile}s
7073 @cindex Third-party packages, interfacing with
7074 @cindex Interfacing with third-party packages
7076 In most projects all @file{Makefile}s are generated by Automake.  In
7077 some cases, however, projects need to embed subdirectories with
7078 handwritten @file{Makefile}s.  For instance one subdirectory could be
7079 a third-party project with its own build system, not using Automake.
7081 It is possible to list arbitrary directories in @code{SUBDIRS} or
7082 @code{DIST_SUBDIRS} provided each of these directories has a
7083 @file{Makefile} that recognizes all the following recursive targets.
7085 @cindex recursive targets and third-party @file{Makefile}s
7086 When a user runs one of these targets, that target is run recursively
7087 in all subdirectories.  This is why it is important that even
7088 third-party @file{Makefile}s support them.
7090 @table @code
7091 @item all
7092 Compile the entire package.  This is the default target in
7093 Automake-generated @file{Makefile}s, but it does not need to be the
7094 default in third-party @file{Makefile}s.
7096 @item distdir
7097 @trindex distdir
7098 @vindex distdir
7099 @vindex top_distdir
7100 Copy files to distribute into @code{$(distdir)}, before a tarball is
7101 constructed.  Of course this target is not required if the
7102 @code{no-dist} option (@pxref{Options}) is used.
7104 The variables @code{$(top_distdir)} and @code{$(distdir)}
7105 (@pxref{Dist}) will be passed from the outer package to the subpackage
7106 when the @code{distdir} target is invoked.  These two variables have
7107 been adjusted for the directory which is being recursed into, so they
7108 are ready to use.
7110 @item install
7111 @itemx install-data
7112 @itemx install-exec
7113 @itemx uninstall
7114 Install or uninstall files (@pxref{Install}).
7116 @item install-info
7117 Install only the Texinfo documentation (@pxref{Texinfo}).
7119 @item installdirs
7120 Create install directories, but do not install any files.
7122 @item check
7123 @itemx installcheck
7124 Check the package (@pxref{Tests}).
7126 @item mostlyclean
7127 @itemx clean
7128 @itemx distclean
7129 @itemx maintainer-clean
7130 Cleaning rules (@pxref{Clean}).
7132 @item dvi
7133 @itemx pdf
7134 @itemx ps
7135 @itemx info
7136 @itemx html
7137 Build the documentation in various formats (@pxref{Texinfo}).
7139 @item tags
7140 @itemx ctags
7141 Build @code{TAGS} and @code{CTAGS} (@pxref{Tags}).
7142 @end table
7144 If you have ever used Gettext in a project, this is a good example of
7145 how third-party @file{Makefile}s can be used with Automake.  The
7146 @file{Makefile}s @command{gettextize} puts in the @file{po/} and
7147 @file{intl/} directories are handwritten @file{Makefile}s that
7148 implement all these targets.  That way they can be added to
7149 @code{SUBDIRS} in Automake packages.
7151 Directories which are only listed in @code{DIST_SUBDIRS} but not in
7152 @code{SUBDIRS} need only the @code{distclean},
7153 @code{maintainer-clean}, and @code{distdir} rules (@pxref{Conditional
7154 Subdirectories}).
7156 Usually, many of these rules are irrelevant to the third-party
7157 subproject, but they are required for the whole package to work.  It's
7158 OK to have a rule that does nothing, so if you are integrating a
7159 third-party project with no documentation or tag support, you could
7160 simply augment its @file{Makefile} as follows:
7162 @example
7163 EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags
7164 .PHONY: $(EMPTY_AUTOMAKE_TARGETS)
7165 $(EMPTY_AUTOMAKE_TARGETS):
7166 @end example
7168 Another aspect of integrating third-party build systems is whether
7169 they support VPATH builds.  Obviously if the subpackage does not
7170 support VPATH builds the whole package will not support VPATH builds.
7171 This in turns means that @code{make distcheck} will not work, because
7172 it relies on VPATH builds.  Some people can live without this
7173 (actually, many Automake users have never heard of @code{make
7174 distcheck}).  Other people may prefer to revamp the existing
7175 @file{Makefile}s to support VPATH.  Doing so does not necessarily
7176 require Automake, only Autoconf is needed (@pxref{Build Directories, ,
7177 Build Directories, autoconf, The Autoconf Manual}).  The necessary
7178 substitutions: @code{@@scrdir@@}, @code{@@top_srcdir@@}, and
7179 @code{@@top_builddir@@} are defined by @file{configure} when it
7180 processes a @file{Makefile} (@pxref{Preset Output Variables, , Preset
7181 Output Variables, autoconf, The Autoconf Manual}), they are not
7182 computed by the Makefile like the aforementioned @code{$(distdir)} and
7183 @code{$(top_distdir)} variables..
7185 It is sometimes inconvenient to modify a third-party @file{Makefile}
7186 to introduce the above required targets.  For instance one may want to
7187 keep the third-party sources untouched to ease upgrades to new
7188 versions.
7190 @cindex @file{GNUmakefile} including @file{Makefile}
7191 Here are two other ideas.  If GNU make is assumed, one possibility is
7192 to add to that subdirectory a @file{GNUmakefile} that defines the
7193 required targets and include the third-party @file{Makefile}.  For
7194 this to work in VPATH builds, @file{GNUmakefile} must lie in the build
7195 directory; the easiest way to do this is to write a
7196 @file{GNUmakefile.in} instead, and have it processed with
7197 @code{AC_CONFIG_FILES} from the outer package.  For example if we
7198 assume @file{Makefile} defines all targets except the documentation
7199 targets, and that the @code{check} target is actually called
7200 @code{test}, we could write @file{GNUmakefile} (or
7201 @file{GNUmakefile.in}) like this:
7203 @example
7204 # First, include the real Makefile
7205 include Makefile
7206 # Then, define the other targets needed by Automake Makefiles.
7207 .PHONY: dvi pdf ps info html check
7208 dvi pdf ps info html:
7209 check: test
7210 @end example
7212 @cindex Proxy @file{Makefile} for third-party packages
7213 A similar idea that does not use @code{include} is to write a proxy
7214 @file{Makefile} that dispatches rules to the real @file{Makefile},
7215 either with @code{$(MAKE) -f Makefile.real $(AM_MAKEFLAGS) target} (if
7216 it's OK to rename the original @file{Makefile}) or with @code{cd
7217 subdir && $(MAKE) $(AM_MAKEFLAGS) target} (if it's OK to store the
7218 subdirectory project one directory deeper).  The good news is that
7219 this proxy @file{Makefile} can be generated with Automake.  All we
7220 need are -local targets (@pxref{Extending}) that perform the dispatch.
7221 Of course the other Automake features are available, so you could
7222 decide to let Automake perform distribution or installation.  Here is
7223 a possible @file{Makefile.am}:
7225 @example
7226 all-local:
7227         cd subdir && $(MAKE) $(AM_MAKEFLAGS) all
7228 check-local:
7229         cd subdir && $(MAKE) $(AM_MAKEFLAGS) test
7230 clean-local:
7231         cd subdir && $(MAKE) $(AM_MAKEFLAGS) clean
7233 # Assuming the package knows how to install itself
7234 install-data-local:
7235         cd subdir && $(MAKE) $(AM_MAKEFLAGS) install-data
7236 install-exec-local:
7237         cd subdir && $(MAKE) $(AM_MAKEFLAGS) install-exec
7238 uninstall-local:
7239         cd subdir && $(MAKE) $(AM_MAKEFLAGS) uninstall
7241 # Distribute files from here.
7242 EXTRA_DIST = subdir/Makefile subdir/program.c ...
7243 @end example
7245 Pushing this idea to the extreme, it is also possible to ignore the
7246 subproject build system and build everything from this proxy
7247 @file{Makefile.am}.  This might sounds very sensible if you need VPATH
7248 builds but the subproject does not support them.
7250 @node Distributing
7251 @chapter Distributing @file{Makefile.in}s
7253 Automake places no restrictions on the distribution of the resulting
7254 @file{Makefile.in}s.  We still encourage software authors to
7255 distribute their work under terms like those of the GPL, but doing so
7256 is not required to use Automake.
7258 Some of the files that can be automatically installed via the
7259 @code{--add-missing} switch do fall under the GPL@.  However, these also
7260 have a special exception allowing you to distribute them with your
7261 package, regardless of the licensing you choose.
7264 @node API versioning
7265 @chapter Automake API versioning
7267 New Automake releases usually include bug fixes and new features.
7268 Unfortunately they may also introduce new bugs and incompatibilities.
7269 This makes four reasons why a package may require a particular Automake
7270 version.
7272 Things get worse when maintaining a large tree of packages, each one
7273 requiring a different version of Automake.  In the past, this meant that
7274 any developer (and sometime users) had to install several versions of
7275 Automake in different places, and switch @samp{$PATH} appropriately for
7276 each package.
7278 Starting with version 1.6, Automake installs versioned binaries.  This
7279 means you can install several versions of Automake in the same
7280 @samp{$prefix}, and can select an arbitrary Automake version by running
7281 @samp{automake-1.6} or @samp{automake-1.7} without juggling with
7282 @samp{$PATH}.  Furthermore, @file{Makefile}'s generated by Automake 1.6
7283 will use @samp{automake-1.6} explicitly in their rebuild rules.
7285 The number @samp{1.6} in @samp{automake-1.6} is Automake's API version,
7286 not Automake's version.  If a bug fix release is made, for instance
7287 Automake 1.6.1, the API version will remain 1.6.  This means that a
7288 package which work with Automake 1.6 should also work with 1.6.1; after
7289 all, this is what people expect from bug fix releases.
7291 If your package relies on a feature or a bug fix introduced in
7292 a release, you can pass this version as an option to Automake to ensure
7293 older releases will not be used.  For instance, use this in your
7294 @file{configure.ac}:
7296 @example
7297   AM_INIT_AUTOMAKE(1.6.1)    dnl Require Automake 1.6.1 or better.
7298 @end example
7299 @noindent
7300 or, in a particular @file{Makefile.am}:
7302 @example
7303   AUTOMAKE_OPTIONS = 1.6.1   # Require Automake 1.6.1 or better.
7304 @end example
7305 @noindent
7306 Automake will print an error message if its version is
7307 older than the requested version.
7310 @heading What is in the API
7312 Automake's programming interface is not easy to define.  Basically it
7313 should include at least all @strong{documented} variables and targets
7314 that a @samp{Makefile.am} author can use, any behavior associated with
7315 them (e.g. the places where @samp{-hook}'s are run), the command line
7316 interface of @samp{automake} and @samp{aclocal}, @dots{}
7318 @heading What is not in the API
7320 Every undocumented variable, target, or command line option, is not part
7321 of the API@.  You should avoid using them, as they could change from one
7322 version to the other (even in bug fix releases, if this helps to fix a
7323 bug).
7325 If it turns out you need to use such a undocumented feature, contact
7326 @email{automake@@gnu.org} and try to get it documented and exercised by
7327 the test-suite.
7329 @node Upgrading
7330 @chapter Upgrading a Package to a Newer Automake Version
7332 Automake maintains three kind of files in a package.
7334 @itemize
7335 @item @file{aclocal.m4}
7336 @item @file{Makefile.in}s
7337 @item auxiliary tools like @file{install-sh} or @file{py-compile}
7338 @end itemize
7340 @file{aclocal.m4} is generated by @command{aclocal} and contains some
7341 Automake-supplied M4 macros.  Auxiliary tools are installed by
7342 @samp{automake --add-missing} when needed.  @file{Makefile.in}s are
7343 built from @file{Makefile.am} by @command{automake}, and rely on the
7344 definitions of the M4 macros put in @file{aclocal.m4} as well as the
7345 behavior of the auxiliary tools installed.
7347 Because all these files are closely related, it is important to
7348 regenerate all of them when upgrading to a newer Automake release.
7349 The usual way to do that is
7351 @example
7352 aclocal # with any option needed (such a -I m4)
7353 autoconf
7354 automake --add-missing --force-missing
7355 @end example
7357 @noindent
7358 or more conveniently:
7360 @example
7361 autoreconf -vfi
7362 @end example
7364 The use of @code{--force-missing} ensures that auxiliary tools will be
7365 overridden by new versions (@pxref{Invoking Automake}).
7367 It is important to regenerate all these files each time Automake is
7368 upgraded, even between bug fixes releases.  For instance it is not
7369 unusual for a bug fix to involve changes to both the rules generated
7370 in @file{Makefile.in} and the supporting M4 macros copied to
7371 @file{aclocal.m4}.
7373 Presently @command{automake} is able to diagnose situations where
7374 @file{aclocal.m4} has been generated with another version of
7375 @command{aclocal}.  However it never checks whether auxiliary scripts
7376 are up-to-date.  In other words, @command{automake} will tell you when
7377 @command{aclocal} needs to be rerun, but it will never diagnose a
7378 missing @code{--force-missing}.
7380 Before upgrading to a new major release, it is a good idea to read the
7381 file @file{NEWS}.  This file lists all changes between releases: new
7382 features, obsolete constructs, known incompatibilities, and
7383 workarounds.
7385 @node FAQ
7386 @chapter Frequently Asked Questions about Automake
7388 This chapter covers some questions that often come up on the mailing
7389 lists.
7391 @menu
7392 * CVS::                         CVS and generated files
7393 * maintainer-mode::             missing and AM_MAINTAINER_MODE
7394 * wildcards::                   Why doesn't Automake support wildcards?
7395 * distcleancheck::              Files left in build directory after distclean
7396 * Flag Variables Ordering::     CFLAGS vs. AM_CFLAGS vs. mumble_CFLAGS
7397 * renamed objects::             Why are object files sometimes renamed?
7398 * Multiple Outputs::            Writing rules for tools with many output files
7399 @end menu
7401 @node CVS
7402 @section CVS and generated files
7404 @subsection Background: distributed generated files
7405 @cindex generated files, distributed
7406 @cindex rebuild rules
7408 Packages made with Autoconf and Automake ship with some generated
7409 files like @file{configure} or @file{Makefile.in}.  These files were
7410 generated on the developer's host and are distributed so that
7411 end-users do not have to install the maintainer tools required to
7412 rebuild them.  Other generated files like Lex scanners, Yacc parsers,
7413 or Info documentation, are usually distributed on similar grounds.
7415 Automake outputs rules in @file{Makefile}s to rebuild these files.  For
7416 instance @command{make} will run @command{autoconf} to rebuild
7417 @file{configure} whenever @file{configure.ac} is changed.  This makes
7418 development safer by ensuring a @file{configure} is never out-of-date
7419 with respect to @file{configure.ac}.
7421 As generated files shipped in packages are up-to-date, and because
7422 @command{tar} preserves times-tamps, these rebuild rules are not
7423 triggered when a user unpacks and builds a package.
7425 @subsection Background: CVS and timestamps
7426 @cindex timestamps and CVS
7427 @cindex CVS and timestamps
7429 Unless you use CVS keywords (in which case files must be updated at
7430 commit time), CVS preserves timestamp during @code{cvs commit} and
7431 @code{cvs import -d} operations.
7433 When you check out a file using @code{cvs checkout} its timestamp is
7434 set to that of the revision which is being checked out.
7436 However, during @command{cvs update}, files will have the date of the
7437 update, not the original timestamp of this revision.  This is meant to
7438 make sure that @command{make} notices sources files have been updated.
7440 This times tamp shift is troublesome when both sources and generated
7441 files are kept under CVS.  Because CVS processes files in alphabetical
7442 order, @file{configure.ac} will appear older than @file{configure}
7443 after a @command{cvs update} that updates both files, even if
7444 @file{configure} was newer than @file{configure.ac} when it was
7445 checked in.  Calling @code{make} will then trigger a spurious rebuild
7446 of @file{configure}.
7448 @subsection Living with CVS in Autoconfiscated projects
7449 @cindex CVS and generated files
7450 @cindex generated files and CVS
7452 There are basically two clans amongst maintainers: those who keep all
7453 distributed files under CVS, including generated files, and those who
7454 keep generated files @emph{out} of CVS.
7456 @subsubheading All files in CVS
7458 @itemize @bullet
7459 @item
7460 The CVS repository contains all distributed files so you know exactly
7461 what is distributed, and you can checkout any prior version entirely.
7463 @item
7464 Maintainers can see how generated files evolve (for instance you can
7465 see what happens to your @file{Makefile.in}s when you upgrade Automake
7466 and make sure they look OK).
7468 @item
7469 Users do not need the autotools to build a checkout of the project, it
7470 works just like a released tarball.
7472 @item
7473 If users use @command{cvs update} to update their copy, instead of
7474 @command{cvs checkout} to fetch a fresh one, timestamps will be
7475 inaccurate.  Some rebuild rules will be triggered and attempt to
7476 run developer tools such as @command{autoconf} or @command{automake}.
7478 Actually, calls to such tools are all wrapped into a call to the
7479 @command{missing} script discussed later (@pxref{maintainer-mode}).
7480 @command{missing} will take care of fixing the timestamps when these
7481 tools are not installed, so that the build can continue.
7483 @item
7484 In distributed development, developers are likely to have different
7485 version of the maintainer tools installed.  In this case rebuilds
7486 triggered by timestamp lossage will lead to spurious changes
7487 to generated files.  There are several solutions to this:
7489 @itemize
7490 @item
7491 All developers should use the same versions, so that the rebuilt files
7492 are identical to files in CVS.  (This starts to be difficult when each
7493 project you work on uses different versions.)
7494 @item
7495 Or people use a script to fix the timestamp after a checkout (the GCC
7496 folks have such a script).
7497 @item
7498 Or @file{configure.ac} uses @code{AM_MAINTAINER_MODE}, which will
7499 disable all these rebuild rules by default.  This is further discussed
7500 in @ref{maintainer-mode}.
7501 @end itemize
7503 @item
7504 Although we focused on spurious rebuilds, the converse can also
7505 happen.  CVS's timestamp handling can also let you think an
7506 out-of-date file is up-to-date.
7508 For instance, suppose a developer has modified @file{Makefile.am} and
7509 rebuilt @file{Makefile.in}, and then decide to do a last-minute change
7510 to @file{Makefile.am} right before checking in both files (without
7511 rebuilding @file{Makefile.in} to account for the change).
7513 This last change to @file{Makefile.am} make the copy of
7514 @file{Makefile.in} out-of-date.  Since CVS processes files
7515 alphabetically, when another developer @code{cvs update} his or her
7516 tree, @file{Makefile.in} will happen to be newer than
7517 @file{Makefile.am}.  This other developer will not see
7518 @file{Makefile.in} is out-of-date.
7520 @end itemize
7522 @subsubheading Generated files out of CVS
7524 One way to get CVS and @code{make} working peacefully is to never
7525 store generated files in CVS, i.e., do not CVS-control files which
7526 are @code{Makefile} targets (also called @emph{derived} files).
7528 This way developers are not annoyed by changes to generated files.  It
7529 does not matter if they all have different versions (assuming they are
7530 compatible, of course).  And finally, timestamps are not lost, changes
7531 to sources files can't be missed as in the
7532 @file{Makefile.am}/@file{Makefile.in} example discussed earlier.
7534 The drawback is that the CVS repository is not an exact copy of what
7535 is distributed and that users now need to install various development
7536 tools (maybe even specific versions) before they can build a checkout.
7537 But, after all, CVS's job is versioning, not distribution.
7539 Allowing developers to use different versions of their tools can also
7540 hide bugs during distributed development.  Indeed, developers will be
7541 using (hence testing) their own generated files, instead of the
7542 generated files that will be released actually.  The developer who
7543 prepares the tarball might be using a version of the tool that
7544 produces bogus output (for instance a non-portable C file), something
7545 other developers could have noticed if they weren't using their own
7546 versions of this tool.
7548 @subsection Third-party files
7549 @cindex CVS and third-party files
7550 @cindex third-party files and CVS
7552 Another class of files not discussed here (because they do not cause
7553 timestamp issues) are files which are shipped with a package, but
7554 maintained elsewhere.  For instance tools like @command{gettextize}
7555 and @command{autopoint} (from Gettext) or @command{libtoolize} (from
7556 Libtool), will install or update files in your package.
7558 These files, whether they are kept under CVS or not, raise similar
7559 concerns about version mismatch between developers' tools.  The
7560 Gettext manual has a section about this, see @ref{CVS Issues, CVS
7561 Issues, Integrating with CVS, gettext, GNU gettext tools}.
7563 @node maintainer-mode
7564 @section @command{missing} and @code{AM_MAINTAINER_MODE}
7566 @subsection @command{missing}
7567 @cindex missing, purpose
7569 The @command{missing} script is a wrapper around several maintainer
7570 tools, designed to warn users if a maintainer tool is required but
7571 missing.  Typical maintainer tools are @command{autoconf},
7572 @command{automake}, @command{bison}, etc.  Because file generated by
7573 these tools are shipped with the other sources of a package, these
7574 tools shouldn't be required during a user build and they are not
7575 checked for in @file{configure}.
7577 However, if for some reason a rebuild rule is triggered and involves a
7578 missing tool, @command{missing} will notice it and warn the user.
7579 Besides the warning, when a tool is missing, @command{missing} will
7580 attempt to fix timestamps in a way which allow the build to continue.
7581 For instance @command{missing} will touch @file{configure} if
7582 @command{autoconf} is not installed.  When all distributed files are
7583 kept under CVS, this feature of @command{missing} allows user
7584 @emph{with no maintainer tools} to build a package off CVS, bypassing
7585 any timestamp inconsistency implied by @code{cvs update}.
7587 If the required tool is installed, @command{missing} will run it and
7588 won't attempt to continue after failures.  This is correct during
7589 development: developers love fixing failures.  However, users with
7590 wrong versions of maintainer tools may get an error when the rebuild
7591 rule is spuriously triggered, halting the build.  This failure to let
7592 the build continue is one of the arguments of the
7593 @code{AM_MAINTAINER_MODE} advocates.
7595 @subsection @code{AM_MAINTAINER_MODE}
7596 @cindex AM_MAINTAINER_MODE, purpose
7597 @cvindex AM_MAINTAINER_MODE
7599 @code{AM_MAINTAINER_MODE} disables the so called "rebuild rules" by
7600 default.  If you have @code{AM_MAINTAINER_MODE} in
7601 @file{configure.ac}, and run @code{./configure && make}, then
7602 @command{make} will *never* attempt to rebuilt @file{configure},
7603 @file{Makefile.in}s, Lex or Yacc outputs, etc.  I.e., this disables
7604 build rules for files which are usually distributed and that users
7605 should normally not have to update.
7607 If you run @code{./configure --enable-maintainer-mode}, then these
7608 rebuild rules will be active.
7610 People use @code{AM_MAINTAINER_MODE} either because they do want their
7611 users (or themselves) annoyed by timestamps lossage (@pxref{CVS}), or
7612 because they simply can't stand the rebuild rules and prefer running
7613 maintainer tools explicitly.
7615 @code{AM_MAINTAINER_MODE} also allows you to disable some custom build
7616 rules conditionally.  Some developers use this feature to disable
7617 rules that need exotic tools that users may not have available.
7619 Several years ago Fran@,{c}ois Pinard pointed out several arguments
7620 against @code{AM_MAINTAINER_MODE}.  Most of them relate to insecurity.
7621 By removing dependencies you get non-dependable builds: change to
7622 sources files can have no effect on generated files and this can be
7623 very confusing when unnoticed.  He adds that security shouldn't be
7624 reserved to maintainers (what @code{--enable-maintainer-mode}
7625 suggests), on the contrary.  If one user has to modify a
7626 @file{Makefile.am}, then either @file{Makefile.in} should be updated
7627 or a warning should be output (this is what Automake uses
7628 @code{missing} for) but the last thing you want is that nothing
7629 happens and the user doesn't notice it (this is what happens when
7630 rebuild rules are disabled by @code{AM_MAINTAINER_MODE}).
7632 Jim Meyering, the inventor of the @code{AM_MAINTAINER_MODE} macro was
7633 swayed by Fran@,{c}ois's arguments, and got rid of
7634 @code{AM_MAINTAINER_MODE} in all of his packages.
7636 Still many people continue to use @code{AM_MAINTAINER_MODE}, because
7637 it helps them working on projects where all files are kept under CVS,
7638 and because @command{missing} isn't enough if you have the wrong
7639 version of the tools.
7642 @node wildcards
7643 @section Why doesn't Automake support wildcards?
7644 @cindex wildcards
7646 Developers are lazy.  They often would like to use wildcards in
7647 @file{Makefile.am}s, so they don't need to remember they have to
7648 update @file{Makefile.am}s every time they add, delete, or rename a
7649 file.
7651 There are several objections to this:
7652 @itemize
7653 @item
7654 When using CVS (or similar) developers need to remember they have to
7655 run @code{cvs add} or @code{cvs rm} anyway.  Updating
7656 @file{Makefile.am} accordingly quickly becomes a reflex.
7658 Conversely, if your application doesn't compile
7659 because you forgot to add a file in @file{Makefile.am}, it will help
7660 you remember to @code{cvs add} it.
7662 @item
7663 Using wildcards makes easy to distribute files by mistake.  For
7664 instance some code a developer is experimenting with (a test case,
7665 say) but which should not be part of the distribution.
7667 @item
7668 Using wildcards it's easy to omit some files by mistake.  For
7669 instance one developer creates a new file, uses it at many places,
7670 but forget to commit it.  Another developer then checkout the
7671 incomplete project and is able to run `make dist' successfully,
7672 even though a file is missing.
7674 @item
7675 Listing files, you control *exactly* what you distribute.
7676 If some file that should be distributed is missing from your
7677 tree, @code{make dist} will complain.  Besides, you don't distribute
7678 more than what you listed.
7680 @item
7681 Finally it's really hard to @file{forget} adding a file to
7682 @file{Makefile.am}, because if you don't add it, it doesn't get
7683 compiled nor installed, so you can't even test it.
7684 @end itemize
7686 Still, these are philosophical objections, and as such you may disagree,
7687 or find enough value in wildcards to dismiss all of them.  Before you
7688 start writing a patch against Automake to teach it about wildcards,
7689 let's see the main technical issue: portability.
7691 Although @code{$(wildcard ...)} works with GNU @command{make}, it is
7692 not portable to other @command{make} implementations.
7694 The only way Automake could support @command{$(wildcard ...)} is by
7695 expending @command{$(wildcard ...)} when @command{automake} is run.
7696 Resulting @file{Makefile.in}s would be portable since they would
7697 list all files and not use @code{$(wildcard ...)}.  However that
7698 means developers need to remember they must run @code{automake} each
7699 time they add, delete, or rename files.
7701 Compared to editing @file{Makefile.am}, this is really little win.  Sure,
7702 it's easier and faster to type @code{automake; make} than to type
7703 @code{emacs Makefile.am; make}.  But nobody bothered enough to write a
7704 patch add support for this syntax.  Some people use scripts to
7705 generated file lists in @file{Makefile.am} or in separate
7706 @file{Makefile} fragments.
7708 Even if you don't care about portability, and are tempted to use
7709 @code{$(wildcard ...)} anyway because you target only GNU Make, you
7710 should know there are many places where Automake need to know exactly
7711 which files should be processed.  As Automake doesn't know how to
7712 expand @code{$(wildcard ...)}, you cannot use it in these places.
7713 @code{$(wildcard ...)} is a black box comparable to @code{AC_SUBST}ed
7714 variables as far Automake is concerned.
7716 You can get warnings about @code{$(wildcard ...}) constructs using the
7717 @code{-Wportability} flag.
7719 @node distcleancheck
7720 @section Files left in build directory after distclean
7721 @cindex distclean, diagnostic
7722 @cindex dependencies and distributed files
7723 @trindex distclean
7724 @trindex distcleancheck
7726 This is a diagnostic you might encounter while running @code{make
7727 distcheck}.
7729 As explained in @ref{Dist}, @code{make distcheck} attempts to build
7730 and check your package for errors like this one.
7732 @code{make distcheck} will perform a @code{VPATH} build of your
7733 package, and then call @code{make distclean}.  Files left in the build
7734 directory after @code{make distclean} has run are listed after this
7735 error.
7737 This diagnostic really covers two kinds of errors:
7739 @itemize @bullet
7740 @item
7741 files that are forgotten by distclean;
7742 @item
7743 distributed files that are erroneously rebuilt.
7744 @end itemize
7746 The former left-over files are not distributed, so the fix is to mark
7747 them for cleaning (@pxref{Clean}), this is obvious and doesn't deserve
7748 more explanations.
7750 The latter bug is not always easy to understand and fix, so let's
7751 proceed with an example.  Suppose our package contains a program for
7752 which we want to build a man page using @command{help2man}.  GNU
7753 @command{help2man} produces simple manual pages from the @code{--help}
7754 and @code{--version} output of other commands (@pxref{Top, , Overview,
7755 help2man, The Help2man Manual}).  Because we don't to force want our
7756 users to install @command{help2man}, we decide to distribute the
7757 generated man page using the following setup.
7759 @example
7760 # This Makefile.am is bogus.
7761 bin_PROGRAMS = foo
7762 foo_SOURCES = foo.c
7763 dist_man_MANS = foo.1
7765 foo.1: foo$(EXEEXT)
7766         help2man --output=foo.1 ./foo$(EXEEXT)
7767 @end example
7769 This will effectively distribute the man page.  However,
7770 @code{make distcheck} will fail with:
7772 @example
7773 ERROR: files left in build directory after distclean:
7774 ./foo.1
7775 @end example
7777 Why was @file{foo.1} rebuilt?  Because although distributed,
7778 @file{foo.1} depends on a non-distributed built file:
7779 @file{foo$(EXEEXT)}.  @file{foo$(EXEEXT)} is built by the user, so it
7780 will always appear to be newer than the distributed @file{foo.1}.
7782 @code{make distcheck} caught an inconsistency in our package.  Our
7783 intent was to distribute @file{foo.1} so users do not need installing
7784 @command{help2man}, however since this our rule causes this file to be
7785 always rebuilt, users @emph{do} need @command{help2man}.  Either we
7786 should ensure that @file{foo.1} is not rebuilt by users, or there is
7787 no point in distributing @file{foo.1}.
7789 More generally, the rule is that distributed files should never depend
7790 on non-distributed built files.  If you distribute something
7791 generated, distribute its sources.
7793 One way to fix the above example, while still distributing
7794 @file{foo.1} is to not depend on @file{foo$(EXEEXT)}.  For instance,
7795 assuming @command{foo --version} and @command{foo --help} do not
7796 change unless @file{foo.c} or @file{configure.ac} change, we could
7797 write the following @file{Makefile.am}:
7799 @example
7800 bin_PROGRAMS = foo
7801 foo_SOURCES = foo.c
7802 dist_man_MANS = foo.1
7804 foo.1: foo.c $(top_srcdir)/configure.ac
7805         $(MAKE) $(AM_MAKEFLAGS) foo$(EXEEXT)
7806         help2man --output=foo.1 ./foo$(EXEEXT)
7807 @end example
7809 This way, @file{foo.1} will not get rebuilt every time
7810 @file{foo$(EXEEXT)} changes.  The @command{make} call makes sure
7811 @file{foo$(EXEEXT)} is up-to-date before @command{help2man}.  Another
7812 way to ensure this would be to use separate directories for binaries
7813 and man pages, and set @code{SUBDIRS} so that binaries are built
7814 before man pages.
7816 We could also decide not to distribute @file{foo.1}.  In
7817 this case it's fine to have @file{foo.1} dependent upon
7818 @file{foo$(EXEEXT)}, since both will have to be rebuilt.
7819 However it would be impossible to build the package in a
7820 cross-compilation, because building @file{foo.1} involves
7821 an @emph{execution} of @file{foo$(EXEEXT)}.
7823 Another context where such errors are common is when distributed files
7824 are built by tools which are built by the package.  The pattern is similar:
7826 @example
7827 distributed-file: built-tools distributed-sources
7828         build-command
7829 @end example
7831 @noindent
7832 should be changed to
7834 @example
7835 distributed-file: distributed-sources
7836         $(MAKE) $(AM_MAKEFLAGS) built-tools
7837         build-command
7838 @end example
7840 @noindent
7841 or you could choose not to distribute @file{distributed-file}, if
7842 cross-compilation does not matter.
7844 The points made through these examples are worth a summary:
7846 @cartouche
7847 @itemize
7848 @item
7849 Distributed files should never depend upon non-distributed built
7850 files.
7851 @item
7852 Distributed files should be distributed will all their dependencies.
7853 @item
7854 If a file is @emph{intended} be rebuilt by users, there is no point in
7855 distributing it.
7856 @end itemize
7857 @end cartouche
7859 @vrindex distcleancheck_listfiles
7860 For desperate cases, it's always possible to disable this check by
7861 setting @code{distcleancheck_listfiles} as documented in @ref{Dist}.
7862 Make sure you do understand the reason why @code{make distcheck}
7863 complains before you do this.  @code{distcleancheck_listfiles} is a
7864 way to @emph{hide} errors, not to fix them.  You can always do better.
7866 @node Flag Variables Ordering
7867 @section Flag Variables Ordering
7868 @cindex Ordering flag variables
7869 @cindex Flag variables, ordering
7871 @display
7872 What is the difference between @code{AM_CFLAGS}, @code{CFLAGS}, and
7873 @code{mumble_CFLAGS}?
7874 @end display
7876 @display
7877 Why does @command{automake} output @code{CPPFLAGS} after
7878 @code{AM_CPPFLAGS} on compile lines?  Shouldn't it be the converse?
7879 @end display
7881 @display
7882 My @file{configure} adds some warning flags into @code{CXXFLAGS}.  In
7883 one @file{Makefile.am} I would like to append a new flag, however if I
7884 put the flag into @code{AM_CXXFLAGS} it is prepended to the other
7885 flags, not appended.
7886 @end display
7888 @subsection Compile Flag Variables
7889 @cindex @code{AM_CCASFLAGS} and @code{CCASFLAGS}
7890 @cindex @code{AM_CFLAGS} and @code{CFLAGS}
7891 @cindex @code{AM_CPPFLAGS} and @code{CPPFLAGS}
7892 @cindex @code{AM_CXXFLAGS} and @code{CXXFLAGS}
7893 @cindex @code{AM_FCFLAGS} and @code{FCFLAGS}
7894 @cindex @code{AM_FFLAGS} and @code{FFLAGS}
7895 @cindex @code{AM_GCJFLAGS} and @code{GCJFLAGS}
7896 @cindex @code{AM_LDFLAGS} and @code{LDFLAGS}
7897 @cindex @code{AM_LFLAGS} and @code{LFLAGS}
7898 @cindex @code{AM_OBJCFLAGS} and @code{OBJCFLAGS}
7899 @cindex @code{AM_RFLAGS} and @code{RFLAGS}
7900 @cindex @code{AM_YFLAGS} and @code{YFLAGS}
7901 @cindex @code{CCASFLAGS} and @code{AM_CCASFLAGS}
7902 @cindex @code{CFLAGS} and @code{AM_CFLAGS}
7903 @cindex @code{CPPFLAGS} and @code{AM_CPPFLAGS}
7904 @cindex @code{CXXFLAGS} and @code{AM_CXXFLAGS}
7905 @cindex @code{FCFLAGS} and @code{AM_FCFLAGS}
7906 @cindex @code{FFLAGS} and @code{AM_FFLAGS}
7907 @cindex @code{GCJFLAGS} and @code{AM_GCJFLAGS}
7908 @cindex @code{LDFLAGS} and @code{AM_LDFLAGS}
7909 @cindex @code{LFLAGS} and @code{AM_LFLAGS}
7910 @cindex @code{OBJCFLAGS} and @code{AM_OBJCFLAGS}
7911 @cindex @code{RFLAGS} and @code{AM_RFLAGS}
7912 @cindex @code{YFLAGS} and @code{AM_YFLAGS}
7914 This section attempts to answer all the above questions.  We will
7915 mostly discuss @code{CPPFLAGS} in our examples, but actually the
7916 answer holds for all the compile flags used in Automake:
7917 @code{CCASFLAGS}, @code{CFLAGS}, @code{CPPFLAGS}, @code{CXXFLAGS},
7918 @code{FCFLAGS}, @code{FFLAGS}, @code{GCJFLAGS}, @code{LDFLAGS},
7919 @code{LFLAGS}, @code{OBJCFLAGS}, @code{RFLAGS}, and @code{YFLAGS}.
7921 @code{CPPFLAGS}, @code{AM_CPPFLAGS}, and @code{mumble_CPPFLAGS} are
7922 three variables that can be used to pass flags to the C preprocessor
7923 (actually these variables are also used for other languages like C++
7924 or preprocessed Fortran).  @code{CPPFLAGS} is the user variable
7925 (@pxref{User Variables}), @code{AM_CPPFLAGS} is the Automake variable,
7926 and @code{mumble_CPPFLAGS} is the variable specific to the
7927 @code{mumble} target (we call this a per-target variable,
7928 see @ref{Program and Library Variables}).
7930 Automake always uses two of these variables when compiling C sources
7931 files.  When compiling an object file for the @code{mumble} target,
7932 the first variable will be @code{mumble_CPPFLAGS} if it is defined, or
7933 @code{AM_CPPFLAGS} otherwise.  The second variable is always
7934 @code{CPPFLAGS}.
7936 In the following example,
7938 @example
7939 bin_PROGRAMS = foo bar
7940 foo_SOURCES = xyz.c
7941 bar_SOURCES = main.c
7942 foo_CPPFLAGS = -DFOO
7943 AM_CPPFLAGS = -DBAZ
7944 @end example
7946 @noindent
7947 @file{xyz.o} will be compiled with @code{$(foo_CPPFLAGS) $(CPPFLAGS)},
7948 (because @file{xyz.o} is part of the @code{foo} target), while
7949 @file{main.o} will be compiled with @code{$(AM_CPPFLAGS) $(CPPFLAGS)}
7950 (because there is no per-target variable for target @code{bar}).
7952 The difference between @code{mumble_CPPFLAGS} and @code{AM_CPPFLAGS}
7953 being clear enough, let's focus on @code{CPPFLAGS}.  @code{CPPFLAGS}
7954 is a user variable, i.e., a variable that users are entitled to modify
7955 in order to compile the package.  This variable, like many others,
7956 is documented at the end of the output of @code{configure --help}.
7958 For instance, someone who needs to add @file{/home/my/usr/include} to
7959 the C compiler's search path would configure a package with
7961 @example
7962 ./configure CPPFLAGS='-I /home/my/usr/include'
7963 @end example
7965 @noindent
7966 and this flag would be propagated to the compile rules of all
7967 @file{Makefile}s.
7969 It is also not uncommon to override a user variable at
7970 @command{make}-time.  Many installers do this with @code{prefix}, but
7971 this can be useful with compiler flags too.  For instance if, while
7972 debugging a C++ project, you need to disable optimization in one
7973 specific object file, you can run something like
7975 @example
7976 rm file.o
7977 make CXXFLAGS=-O0 file.o
7978 make
7979 @end example
7981 The reason @code{$(CPPFLAGS)} appears after @code{$(AM_CPPFLAGS)} or
7982 @code{$(mumble_CPPFLAGS)} in the compile command is that users
7983 should always have the last say.  It probably makes more sense if you
7984 think about it while looking at the @code{CXXFLAGS=-O0} above, which
7985 should supersede any other switch from @code{AM_CXXFLAGS} or
7986 @code{mumble_CXXFLAGS} (and this of course replaces the previous value
7987 of @code{CXXFLAGS}).
7989 You should never redefine a user variable such as @code{CPPFLAGS} in
7990 @file{Makefile.am}.  Use @code{automake -Woverride} to diagnose such
7991 mistakes.  Even something like
7993 @example
7994 CPPFLAGS = -DDATADIR=\"$(datadir)\" @@CPPFLAGS@@
7995 @end example
7997 @noindent
7998 is erroneous.  Although this preserves @file{configure}'s value of
7999 @code{CPPFLAGS}, the definition of @code{DATADIR} will disappear if a
8000 user attempts to override @code{CPPFLAGS} from the @command{make}
8001 command line.
8003 @example
8004 AM_CPPFLAGS = -DDATADIR=\"$(datadir)\"
8005 @end example
8007 @noindent
8008 is all what is needed here if no per-target flags are used.
8010 You should not add options to these variables from inside
8011 @file{configure} either, for the same reason.  Occasionally you need
8012 to modify these variables to perform a test, but you should reset
8013 their value afterwards.
8015 What we recommend is that you define extra flags in separate
8016 variables.  For instance you may write an Autoconf macro that computes
8017 a set of warning options for the C compiler, and @code{AC_SUBST} them
8018 in @code{WARNINGCFLAGS}; you may also have an Autoconf macro that
8019 determines which compiler and which linker flags should be used to
8020 link with library @file{libfoo}, and @code{AC_SUBST} these in
8021 @code{LIBFOOCFLAGS} and @code{LIBFOOLDFLAGS}.  Then, a
8022 @file{Makefile.am} could use these variables as follows:
8024 @example
8025 AM_CFLAGS = $(WARNINGCFLAGS)
8026 bin_PROGRAMS = prog1 prog2
8027 prog1_SOURCES = @dots{}
8028 prog2_SOURCES = @dots{}
8029 prog2_CFLAGS = $(LIBFOOCFLAGS) $(AM_CFLAGS)
8030 prog2_LDFLAGS = $(LIBFOOLDFLAGS)
8031 @end example
8033 In this example both programs will be compiled with the flags
8034 substituted into @code{$(WARNINGCFLAGS)}, and @code{prog2} will
8035 additionally be compiled with the flags required to link with
8036 @file{libfoo}.
8038 Note that listing @code{AM_CFLAGS} in a per-target @code{CFLAGS}
8039 variable is a common idiom to ensure that @code{AM_CFLAGS} applies to
8040 every target in a @file{Makefile.in}.
8042 Using variables like this gives you full control over the ordering of
8043 the flags.  For instance if there is a flag in $(WARNINGCFLAGS) that
8044 you want to negate for a particular target, you can use something like
8045 @code{prog1_CFLAGS = $(AM_CFLAGS) -no-flag}.  If all these flags had
8046 been forcefully appended to @code{CFLAGS}, there would be no way to
8047 disable one flag.  Yet another reason to leave user variables to
8048 users.
8050 Finally, we have avoided naming the variable of the example
8051 @code{LIBFOO_LDFLAGS} (with an underscore) because that would cause
8052 Automake to think that this is actually a per-target variable (like
8053 @code{mumble_LDFLAGS}) for some non-declared @code{LIBFOO} target.
8055 @subsection Other Variables
8057 There are other variables in Automake that follow similar principles
8058 to allow user options.  For instance Texinfo rules (@pxref{Texinfo})
8059 uses @code{MAKEINFOFLAGS} and @code{AM_MAKEINFOFLAGS}.  Similarly,
8060 DejaGnu tests @pxref{Tests} use @code{RUNTESTDEFAULTFLAGS} and
8061 @code{AM_RUNTESTDEFAULTFLAGS}.  The tags and ctags rules
8062 (@pxref{Tags}) use @code{ETAGSFLAGS}, @code{AM_ETAGSFLAGS},
8063 @code{CTAGSFLAGS}, and @code{AM_CTAGSFLAGS}.  Java rules
8064 (@pxref{Java}) use @code{JAVACFLAGS} and @code{AM_JAVACFLAGS}.  None
8065 of these rules do support per-target flags (yet).
8067 To some extent, even @code{AM_MAKEFLAGS} (@pxref{Subdirectories})
8068 obeys this naming scheme.  The slight difference is that
8069 @code{MAKEFLAGS} is passed to sub-@command{make}s implicitly by
8070 @command{make} itself.
8072 However you should not think that all variables ending with
8073 @code{FLAGS} follow this convention.  For instance
8074 @code{DISTCHECK_CONFIGURE_FLAGS} (@pxref{Dist}),
8075 @code{ACLOCAL_AMFLAGS} (@pxref{Rebuilding} and @ref{Local Macros}),
8076 are two variables that are only useful to the maintainer and have no
8077 user counterpart.
8079 @code{ARFLAGS} (@pxref{A Library}) is usually defined by Automake and
8080 has neither @code{AM_} nor per-target cousin.
8082 Finally you should not think either that the existence of a per-target
8083 variable implies that of an @code{AM_} variable or that of a user
8084 variable.  For instance the @code{mumble_LDADD} per-target variable
8085 overrides the global @code{LDADD} variable (which is not a user
8086 variable), and @code{mumble_LIBADD} exists only as a per-target
8087 variable.  (@pxref{Program and Library Variables}.)
8089 @node renamed objects
8090 @section Why are object files sometimes renamed?
8092 This happens when per-target compilation flags are used.  Object
8093 files need to be renamed just in case they would clash with object
8094 files compiled from the same sources, but with different flags.
8095 Consider the following example.
8097 @example
8098 bin_PROGRAMS = true false
8099 true_SOURCES = generic.c
8100 true_CPPFLAGS = -DEXIT_CODE=0
8101 false_SOURCES = generic.c
8102 false_CPPFLAGS = -DEXIT_CODE=1
8103 @end example
8104 @noindent
8105 Obviously the two programs are built from the same source, but it
8106 would be bad if they shared the same object, because @file{generic.o}
8107 cannot be built with both @code{-DEXIT_CODE=0} *and*
8108 @code{-DEXIT_CODE=1}.  Therefore @command{automake} outputs rules to
8109 build two different objects: @file{true-generic.o} and
8110 @file{false-generic.o}.
8112 @command{automake} doesn't actually look whether sources files are
8113 shared to decide if it must rename objects.  It will just rename all
8114 objects of a target as soon as it sees per-target compilation flags
8115 are used.
8117 It's OK to share object files when per-target compilation flags are not
8118 used.  For instance @file{true} and @file{false} will both use
8119 @file{version.o} in the following example.
8121 @example
8122 AM_CPPFLAGS = -DVERSION=1.0
8123 bin_PROGRAMS = true false
8124 true_SOURCES = true.c version.c
8125 false_SOURCES = false.c version.c
8126 @end example
8128 Note that the renaming of objects is also affected by the
8129 @code{_SHORTNAME} variable (@pxref{Program and Library Variables}).
8132 @node Multiple Outputs
8133 @section Handling Tools that Produce Many Outputs
8134 @cindex multiple outputs, rules with
8135 @cindex many outputs, rules with
8136 @cindex rules with multiple outputs
8138 This section describes a @command{make} idiom that can be used when a
8139 tool produces multiple output files.  It is not specific to Automake
8140 and can be used in ordinary @file{Makefile}s.
8142 Suppose we have a program called @command{foo} that will read one file
8143 called @file{data.foo} and produce two files named @file{data.c} and
8144 @file{data.h}.  We want to write a @file{Makefile} rule that captures
8145 this one-to-two dependency.
8147 The naive rule is incorrect:
8149 @example
8150 # This is incorrect.
8151 data.c data.h: data.foo
8152         foo data.foo
8153 @end example
8155 @noindent
8156 What the above rule really says is that @file{data.c} and
8157 @file{data.h} each depend on @file{data.foo}, and can each be built by
8158 running @code{foo data.foo}.  In other words it is equivalent to:
8160 @example
8161 # We do not want this.
8162 data.c: data.foo
8163         foo data.foo
8164 data.h: data.foo
8165         foo data.foo
8166 @end example
8168 @noindent
8169 which means that @command{foo} can be run twice.  Usually it will not
8170 be run twice, because @command{make} implementations are smart enough
8171 to check for the existence of the second file after the first one has
8172 been built; they will therefore detect that it already exists.
8173 However there are a few situations where it can run twice anyway:
8175 @itemize
8176 @item
8177 The most worrying case is when running a parallel @command{make}.  If
8178 @file{data.c} and @file{data.h} are built in parallel, two @code{foo
8179 data.foo} commands will run concurrently.  This is harmful.
8180 @item
8181 Another case is when the dependency (here @code{data.foo}) is
8182 (or depends upon) a phony target.
8183 @end itemize
8185 A solution that works with parallel @command{make} but not with
8186 phony dependencies is the following:
8188 @example
8189 data.c data.h: data.foo
8190         foo data.foo
8191 data.h: data.c
8192 @end example
8194 @noindent
8195 The above rules are equivalent to
8197 @example
8198 data.c: data.foo
8199         foo data.foo
8200 data.h: data.foo data.c
8201         foo data.foo
8202 @end example
8203 @noindent
8204 therefore a parallel @command{make} will have to serialize the builds
8205 of @file{data.c} and @file{data.h}, and will detect that the second is
8206 no longer needed once the first is over.
8208 Using this pattern is probably enough for most cases.  However it does
8209 not scale easily to more output files (in this scheme all output files
8210 must be totally ordered by the dependency relation), so we will
8211 explore a more complicated solution.
8213 Another idea is to write the following:
8215 @example
8216 # There is still a problem with this one.
8217 data.c: data.foo
8218         foo data.foo
8219 data.h: data.c
8220 @end example
8222 @noindent
8223 The idea is that @code{foo data.foo} is run only when @file{data.c}
8224 needs to be updated, but we further state that @file{data.h} depends
8225 upon @file{data.c}.  That way, if @file{data.h} is required and
8226 @file{data.foo} is out of date, the dependency on @file{data.c} will
8227 trigger the build.
8229 This is almost perfect, but suppose we have built @file{data.h} and
8230 @file{data.c}, and then we erase @file{data.h}.  Then, running
8231 @code{make data.h} will not rebuild @file{data.h}.  The above rules
8232 just state that @file{data.c} must be up-to-date with respect to
8233 @file{data.foo}, and this is already the case.
8235 What we need is a rule that forces a rebuild when @file{data.h} is
8236 missing.  Here it is:
8238 @example
8239 data.c: data.foo
8240         foo data.foo
8241 data.h: data.c
8242         @@if test -f $@@; then :; else \
8243           rm -f data.c; \
8244           $(MAKE) $(AM_MAKEFLAGS) data.c; \
8245         fi
8246 @end example
8248 The above scales easily to more outputs and more inputs.  One of the
8249 output is picked up to serve as a witness of the run of the command,
8250 it depends upon all inputs, and all other outputs depend upon it.  For
8251 instance if @command{foo} should additionally read @file{data.bar} and
8252 also produce @file{data.w} and @file{data.x}, we would write:
8254 @example
8255 data.c: data.foo data.bar
8256         foo data.foo data.bar
8257 data.h data.w data.x: data.c
8258         @@if test -f $@@; then :; else \
8259           rm -f data.c; \
8260           $(MAKE) $(AM_MAKEFLAGS) data.c; \
8261         fi
8262 @end example
8264 There is still a minor problem with this setup.  @command{foo} outputs
8265 four files, but we do not know in which order these files are created.
8266 Suppose that @file{data.h} is created before @file{data.c}.  Then we
8267 have a weird situation.  The next time @command{make} is run,
8268 @file{data.h} will appear older than @file{data.c}, the second rule
8269 will be triggered, a shell will be started to execute the
8270 @code{if...fi} command, but actually it will just execute the
8271 @code{then} branch, that is: nothing.  In other words, because the
8272 witness we selected is not the first file created by @command{foo},
8273 @command{make} will start a shell to do nothing each time it is run.
8275 A simple riposte is to fix the timestamps when this happens.
8277 @example
8278 data.c: data.foo data.bar
8279         foo data.foo data.bar
8280 data.h data.w data.x: data.c
8281         @@if test -f $@@; then \
8282           touch $@@; \
8283         else \
8284           rm -f data.c; \
8285           $(MAKE) $(AM_MAKEFLAGS) data.c; \
8286         fi
8287 @end example
8289 Another solution, not incompatible with the previous one, is to use a
8290 different and dedicated file as witness, rather than using any of
8291 @command{foo}'s outputs.
8293 @example
8294 data.stamp: data.foo data.bar
8295         @@rm -f data.tmp
8296         @@touch data.tmp
8297         foo data.foo data.bar
8298         @@mv -f data.tmp $@@
8299 data.c data.h data.w data.x: data.stamp
8300         @@if test -f $@@; then \
8301           touch $@@; \
8302         else \
8303           rm -f data.stamp; \
8304           $(MAKE) $(AM_MAKEFLAGS) data.stamp; \
8305         fi
8306 @end example
8308 @file{data.tmp} is created before @command{foo} is run, so it has a
8309 timestamp older than output files output by @command{foo}.  It is then
8310 renamed to @file{data.stamp} after @command{foo} has run, because we
8311 do not want to update @file{data.stamp} if @command{foo} fails.
8313 Using a dedicated witness like this is very handy when the list of
8314 output files is not known beforehand.  As an illustration, consider
8315 the following rules to compile many @file{*.el} files into
8316 @file{*.elc} files in a single command.  It does not matter how
8317 @code{ELFILES} is defined (as long as it is not empty: empty targets
8318 are not accepted by POSIX).
8320 @example
8321 ELFILES = one.el two.el three.el @dots{}
8322 ELCFILES = $(ELFILES:=c)
8324 elc-stamp: $(ELFILES)
8325         @@rm -f elc-temp
8326         @@touch elc-temp
8327         $(elisp_comp) $(ELFILES)
8328         @@mv -f elc-temp $@@
8330 $(ELCFILES): elc-stamp
8331         @@if test -f $@@; then \
8332           touch $@@; \
8333         else \
8334           rm -f elc-stamp; \
8335           $(MAKE) $(AM_MAKEFLAGS) elc-stamp; \
8336         fi
8337 @end example
8339 For completeness it should be noted that GNU @command{make} is able to
8340 express rules with multiple output files using pattern rules
8341 (@pxref{Pattern Examples, , Pattern Rule Examples, make, The GNU Make
8342 Manual}).  We do not discuss pattern rules here because they are not
8343 portable, but they can be convenient in packages that assume GNU
8344 @command{make}.
8346 @node History
8347 @chapter History of Automake
8349 This chapter presents various aspects of the history of Automake.  The
8350 exhausted reader can safely skip it; this will be more of interest to
8351 nostalgic people, or to those curious to learn about the evolution of
8352 Automake.
8354 @menu
8355 * Timeline::                    The Automake story.
8356 * Dependency Tracking Evolution::  Evolution of Automatic Dependency Tracking
8357 * Releases::                    Statistics about Automake Releases
8358 @end menu
8360 @node Timeline
8361 @section Timeline
8363 @table @asis
8364 @item 1994-09-19 First CVS commit.
8366 If we can trust the CVS repository, David J. MacKenzie (djm) started
8367 working on Automake (or AutoMake, as it was spelt then) this Monday.
8369 The first version of the @command{automake} script looks as follows.
8371 @example
8372 #!/bin/sh
8374 status=0
8376 for makefile
8378   if test ! -f $@{makefile@}.am; then
8379     echo "automake: $@{makefile@}.am: No such honkin' file"
8380     status=1
8381     continue
8382   fi
8384   exec 4> $@{makefile@}.in
8386 done
8387 @end example
8389 From this you can already see that Automake will be about reading
8390 @file{*.am} file and producing @file{*.in} files.  You cannot see
8391 anything else, but if you also know that David is the one who created
8392 Autoconf two years before you can guess the rest.
8394 Several commits follow, and by the end of the day Automake is
8395 reported to work for GNU fileutils and GNU m4.
8397 The modus operandi is the one that is still used today: variables
8398 assignments in @file{Makefile.am} files trigger injections of
8399 precanned @file{Makefile} fragments into the generated
8400 @file{Makefile.in}.  The use of @file{Makefile} fragments was inspired
8401 by the 4.4BSD @command{make} and include files, however Automake aims
8402 to be portable and to conform to the GNU standards for @file{Makefile}
8403 variables and targets.
8405 At this point, the most recent release of Autoconf is version 1.11,
8406 and David is preparing to release Autoconf 2.0 in late October.  As a
8407 matter of fact, he will barely touch Automake after September.
8409 @item 1994-11-05 David MacKenzie's last commit.
8411 At this point Automake is a 200 line portable shell script, plus 332
8412 lines of @file{Makefile} fragments.  In the @file{README}, David
8413 states his ambivalence between ``portable shell'' and ``more
8414 appropriate language'':
8416 @quotation
8417 I wrote it keeping in mind the possibility of it becoming an Autoconf
8418 macro, so it would run at configure-time.  That would slow
8419 configuration down a bit, but allow users to modify the Makefile.am
8420 without needing to fetch the AutoMake package.  And, the Makefile.in
8421 files wouldn't need to be distributed.  But all of AutoMake would.  So
8422 I might reimplement AutoMake in Perl, m4, or some other more
8423 appropriate language.
8424 @end quotation
8426 Automake is described as ``an experimental Makefile generator''.
8427 There is no documentation.  Adventurous users are referred to the
8428 examples and patches needed to use Automake with GNU m4 1.3, fileutils
8429 3.9, time 1.6, and development versions of find and indent.
8431 These examples seem to have been lost.  However at the time of writing
8432 (10 years later in September, 2004) the FSF still distributes a
8433 package that uses this version of Automake: check out GNU termutils
8434 2.0.
8436 @item 1995-11-12 Tom Tromey's first commit.
8438 After one year of inactivity, Tom Tromey takes over the package.
8439 Tom was working on GNU cpio back then, and doing this just for fun,
8440 having trouble finding a project to contribute to.  So while hacking
8441 he wanted to bring the @file{Makefile.in} up to GNU standards.  This
8442 was hard, and one day he saw Automake on @url{ftp://alpha.gnu.org/},
8443 grabbed it and tried it out.
8445 Tom didn't talk to djm about it until later, just to make sure he
8446 didn't mind if he made a release.  He did a bunch of early releases to
8447 the Gnits folks.
8449 Gnits was (and still is) totally informal, just a few GNU friends who
8450 Fran@,cois Pinard knew, who were all interested in making a common
8451 infrastructure for GNU projects, and shared a similar outlook on how
8452 to do it.  So they were able to make some progress.  It came along
8453 with Autoconf and extensions thereof, and then Automake from David and
8454 Tom (who were both gnitsians).  One of their ideas was to write a
8455 document paralleling the GNU standards, that was more strict in some
8456 ways and more detailed.  They never finished the GNITS standards, but
8457 the ideas mostly made their way into Automake.
8459 @item 1995-11-23 Automake 0.20
8461 Besides introducing automatic dependency tracking (@pxref{Dependency
8462 Tracking Evolution}), this version also supplies a 9-page manual.
8464 At this time @command{aclocal} and @code{AM_INIT_AUTOMAKE} did not
8465 exist, so many things had to be done by hand.  For instance here is
8466 what a configure.in (this is the former name of the
8467 @file{configure.ac} we use today) must contain in order to use
8468 Automake 0.20:
8470 @example
8471 PACKAGE=cpio
8472 VERSION=2.3.911
8473 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
8474 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
8475 AC_SUBST(PACKAGE)
8476 AC_SUBST(VERSION)
8477 AC_ARG_PROGRAM
8478 AC_PROG_INSTALL
8479 @end example
8481 (Today all of the above is achieved by @code{AC_INIT} and
8482 @code{AM_INIT_AUTOMAKE}.)
8484 Here is how programs are specified in @file{Makefile.am}:
8486 @example
8487 PROGRAMS = hello
8488 hello_SOURCES = hello.c
8489 @end example
8491 This looks pretty much like what we do today, except the
8492 @code{PROGRAMS} variable has no directory prefix specifying where
8493 @file{hello} should be installed: all programs are installed in
8494 @code{$(bindir)}.  @code{LIBPROGRAMS} can be used to specify programs
8495 that must be built but not installed (it is called
8496 @code{noinst_PROGRAMS} nowadays).
8498 Programs can be built conditionally using @code{AC_SUBST}itutions:
8500 @example
8501 PROGRAMS = @@progs@@
8502 AM_PROGRAMS = foo bar baz
8503 @end example
8505 (@code{AM_PROGRAMS} has since then been renamed to
8506 @code{EXTRA_PROGRAMS}.)
8508 Similarly scripts, static libraries, and data can built and installed
8509 using the @code{LIBRARIES}, @code{SCRIPTS}, and @code{DATA} variables.
8510 However @code{LIBRARIES} were treated a bit specially in that Automake
8511 did automatically supply the @file{lib} and @file{.a} prefixes.
8512 Therefore to build @file{libcpio.a}, one had to write
8514 @example
8515 LIBRARIES = cpio
8516 cpio_SOURCES = ...
8517 @end example
8519 Extra files to distribute must be listed in @code{DIST_OTHER} (the
8520 ancestor of @code{EXTRA_DIST}).  Also extra directories that are to be
8521 distributed should appear in @code{DIST_SUBDIRS}, but the manual
8522 describes this as a temporary ugly hack (today extra directories should
8523 also be listed in @code{EXTRA_DIST}, and @code{DIST_SUBDIRS} is used
8524 for another purpose, see @ref{Conditional Subdirectories}).
8526 @item 1995-11-26 Automake 0.21
8528 In less time that it takes to cook a frozen pizza, Tom rewrites
8529 Automake using Perl.  At this time Perl 5 is only one year old, and
8530 Perl 4.036 is in use at many sites.  Supporting several Perl versions
8531 has been a source of problems through the whole history of Automake.
8533 If you never used Perl 4, imagine Perl 5 without objects, without
8534 @code{my} variables (only dynamically scoped @code{local} variables),
8535 without function prototypes, with function calls that needs to be
8536 prefixed with @code{&}, etc.  Traces of this old style can still be
8537 found in today's @command{automake}.
8539 @item 1995-11-28 Automake 0.22
8540 @itemx 1995-11-29 Automake 0.23
8542 Bug fixes.
8544 @item 1995-12-08 Automake 0.24
8545 @itemx 1995-12-10 Automake 0.25
8547 Releases are raining.  0.24 introduces the uniform naming scheme we
8548 use today, i.e., @code{bin_PROGRAMS} instead of @code{PROGRAMS},
8549 @code{noinst_LIBRARIES} instead of @code{LIBLIBRARIES}, etc.  (However
8550 @code{EXTRA_PROGRAMS} does not exist yet, @code{AM_PROGRAMS} is still
8551 in use; and @code{TEXINFOS} and @code{MANS} still have no directory
8552 prefixes.)  Adding support for prefixes like that was one of the major
8553 ideas in automake; it has lasted pretty well.
8555 AutoMake is renamed to Automake (Tom seems to recall it was Fran@,cois
8556 Pinard's doing).
8558 0.25 fixes a Perl 4 portability bug.
8560 @item 1995-12-18 Jim Meyering starts using Automake in GNU Textutils.
8561 @item 1995-12-31 Fran@,cois Pinard starts using Automake in GNU tar.
8563 @item 1996-01-03 Automake 0.26
8564 @itemx 1996-01-03 Automake 0.27
8566 Of the many change and suggestions sent by Fran@,cois Pinard and
8567 included in 0.26, the most important is perhaps the advise that to
8568 ease customization a user rule or variable definition should always
8569 override an Automake rule or definition.
8571 Gordon Matzigkeit and Jim Meyering are two other early contributors
8572 that have been sending fixes.
8574 0.27 fixes yet another Perl 4 portability bug.
8576 @item 1996-01-13 Automake 0.28
8578 Automake starts scanning @file{configure.in} for @code{LIBOBJS}
8579 support.  This is an important step because until this version
8580 Automake did only know about the @file{Makefile.am}s it processed.
8581 @file{configure.in} was Autoconf's world and the link between Autoconf
8582 and Automake had to be done by the @file{Makefile.am} author.  For
8583 instance if @file{config.h} was generated by @file{configure}, it was the
8584 package maintainer's responsibility to define the @code{CONFIG_HEADER}
8585 variable in each @file{Makefile.am}.
8587 Succeeding releases will rely more and more on scanning
8588 @file{configure.in} to better automate the Autoconf integration.
8590 0.28 also introduces the @code{AUTOMAKE_OPTIONS} variable and the
8591 @code{--gnu} and @code{--gnits} options, the latter being stricter.
8593 @item 1996-02-07 Automake 0.29
8595 Thanks to @file{configure.in} scanning, @code{CONFIG_HEADER} is gone,
8596 and rebuild rules for @file{configure}-generated file are
8597 automatically output.
8599 @code{TEXINFOS} and @code{MANS} converted to the uniform naming
8600 scheme.
8602 @item 1996-02-24 Automake 0.30
8604 The test suite is born.  It contains 9 tests.  From now on test cases
8605 will be added pretty regularly (@pxref{Releases}), and this proved to
8606 be really helpful later on.
8608 @code{EXTRA_PROGRAMS} finally replaces @code{AM_PROGRAMS}.
8610 All the third-party Autoconf macros, written mostly by Fran@,cois
8611 Pinard (and later Jim Meyering), are distributed in Automake's
8612 hand-written @file{aclocal.m4} file.  Package maintainers are expected
8613 to extract the necessary macros from this file.  (In previous version
8614 you had to copy and paste them from the manual...)
8616 @item 1996-03-11 Automake 0.31
8618 The test suite in 0.30 was run via a long @code{check-local} rule.  Upon
8619 Ulrich Drepper's suggestion, 0.31 makes it an Automake rule output
8620 whenever the @code{TESTS} variable is defined.
8622 @code{DIST_OTHER} is renamed to @code{EXTRA_DIST}, and the @code{check_}
8623 prefix is introduced.  The syntax is now the same as today.
8625 @item 1996-03-15 Gordon Matzigkeit starts writing libtool.
8627 @item 1996-04-27 Automake 0.32
8629 @code{-hook} targets are introduced; an idea from Dieter Baron.
8631 @file{*.info} files, which were output in the build directory are
8632 now built in the source directory, because they are distributed.  It
8633 seems these files like to move back and forth as that will happen
8634 again in future versions.
8636 @item 1996-05-18 Automake 0.33
8638 Gord Matzigkeit's main two contributions:
8640 @itemize
8641 @item very preliminary libtool support
8642 @item the distcheck rule
8643 @end itemize
8645 Although they were very basic at this point, these are probably
8646 among the top features for Automake today.
8648 Jim Meyering also provides the infamous @code{jm_MAINTAINER_MODE},
8649 since then renamed to @code{AM_MAINTAINER_MODE} and abandoned by its
8650 author (@pxref{maintainer-mode}).
8652 @item 1996-05-28 Automake 1.0
8654 After only six months of heavy development, the automake script is
8655 3134 lines long, plus 973 lines of @file{Makefile} fragments.  The
8656 package has 30 pages of documentation, and 38 test cases.
8657 @file{aclocal.m4} contains 4 macros.
8659 From now on and until version 1.4, new releases will occur at a rate
8660 of about one a year.  1.1 did not exist, actually 1.1b to 1.1p have
8661 been the name of beta releases for 1.2.  This is the first time
8662 Automake uses suffix letters to designate beta releases, an habit that
8663 lasts.
8665 @item 1996-10-10 Kevin Dalley packages Automake 1.0 for Debian GNU/Linux.
8667 @item 1996-11-26 David J. MacKenzie releases Autoconf 2.12.
8669 Between June and October, the Autoconf development is almost staled.
8670 Roland McGrath has been working at the beginning of the year.  David
8671 comes back in November to release 2.12, but he won't touch Autoconf
8672 anymore after this year, and Autoconf then really stagnates.  The
8673 desolate Autoconf @file{ChangeLog} for 1997 lists only 7 commits.
8675 @item 1997-02-28 @email{automake@@gnu.ai.mit.edu} list alive
8677 The mailing list is announced as follows:
8678 @example
8679 I've created the "automake" mailing list.  It is
8680 "automake@@gnu.ai.mit.edu".  Administrivia, as always, to
8681 automake-request@@gnu.ai.mit.edu.
8683 The charter of this list is discussion of automake, autoconf, and
8684 other configuration/portability tools (eg libtool).  It is expected
8685 that discussion will range from pleas for help all the way up to
8686 patches.
8688 This list is archived on the FSF machines.  Offhand I don't know if
8689 you can get the archive without an account there.
8691 This list is open to anybody who wants to join.  Tell all your
8692 friends!
8693 -- Tom Tromey
8694 @end example
8696 Before that people were discussing Automake privately, on the Gnits
8697 mailing list (which is not public either), and less frequently on
8698 @code{gnu.misc.discuss}.
8700 @code{gnu.ai.mit.edu} is now @code{gnu.org}, in case you never
8701 noticed.  The archives of the early years of the
8702 @code{automake@@gnu.org} list have been lost, so today it is almost
8703 impossible to find traces of discussions that occurred before 1999.
8704 This has been annoying more than once, as such discussions can be
8705 useful to understand the rationale behind a piece of uncommented code
8706 that was introduced back then.
8708 @item 1997-06-22 Automake 1.2
8710 Automake developments continues, and more and more new Autoconf macros
8711 are required.  Distributing them in @file{aclocal.m4} and requiring
8712 people to browse this file to extract the relevant macros becomes
8713 uncomfortable.  Ideally, some of them should be contributed to
8714 Autoconf so that they can be used directly, however Autoconf is
8715 currently inactive.  Automake 1.2 consequently introduces
8716 @command{aclocal} (@command{aclocal} was actually started on
8717 1996-07-28), a tool that automatically constructs an @file{aclocal.m4}
8718 file from a repository of third-party macros.  Because Autoconf has
8719 stalled, Automake also becomes a kind of repository for such
8720 third-party macros, even macros completely unrelated to Automake (for
8721 instance macros that fixes broken Autoconf macros).
8723 The 1.2 release contains 20 macros, among which the
8724 @code{AM_INIT_AUTOMAKE} macro that simplifies the creation of
8725 @file{configure.in}.
8727 Libtool is fully supported using @code{*_LTLIBRARIES}.
8729 The missing script is introduced by Fran@,cois Pinard; it is meant to be
8730 a better solution than @code{AM_MAINTAINER_MODE}
8731 (@pxref{maintainer-mode}).
8733 Conditionals support was implemented by Ian Lance Taylor.  At the
8734 time, Tom and Ian were working on an internal project at Cygnus.  They
8735 were using ILU, which is pretty similar to CORBA.  They wanted to
8736 integrate ILU into their build, which was all @file{configure}-based,
8737 and Ian thought that adding conditionals to @command{automake} was
8738 simpler than doing all the work in @file{configure} (which was the
8739 standard at the time).  So this was actually funded by Cygnus.
8741 This very useful but tricky feature will take a lot of time to
8742 stabilize.  (At the time this text is written, there are still
8743 primaries that have not been updated to support conditional
8744 definitions in Automake 1.9.)
8746 The @command{automake} script has almost doubled: 6089 lines of Perl,
8747 plus 1294 lines of @file{Makefile} fragments.
8749 @item 1997-07-08 Gordon Matzigkeit releases Libtool 1.0.
8751 @item 1998-04-05 Automake 1.3
8753 This is a small advance compared to 1.2.
8754 It add support for assembly, and preliminary support for Java.
8756 Perl 5.004_04 is out, but fixes to support Perl 4 are still
8757 regularly submitted whenever Automake breaks it.
8759 @item 1998-09-06 @code{sourceware.cygnus.com} is on-line.
8761 Sourceware was setup by Jason Molenda to host open source projects.
8763 @item 1998-09-19  Automake CVS repository moved to @code{sourceware.cygnus.com}
8764 @itemx 1998-10-26  @code{sourceware.cygnus.com} announces it hosts Automake
8765 Automake is now hosted on @code{sourceware.cygnus.com}.  It has a
8766 publicly accessible CVS repository.  This CVS repository is a copy of
8767 the one Tom was using on his machine, which in turn is based on
8768 a copy of the CVS repository of David MacKenzie.  This is why we still
8769 have to full source history.  (Automake is still on Sourceware today,
8770 but the host has been renamed to @code{sources.redhat.com}.)
8772 The oldest file in the administrative directory of the CVS repository
8773 that was created on Sourceware is dated 1998-09-19, while the
8774 announcement that @code{automake} and @code{autoconf} had joined
8775 @code{sourceware} was made on 1998-10-26.  They were among the first
8776 projects to be hosted there.
8778 The heedful reader will have noticed Automake was exactly 4-year-old
8779 on 1998-09-19.
8781 @item 1999-01-05 Ben Elliston releases Autoconf 2.13.
8783 @item 1999-01-14 Automake 1.4
8785 This release adds support for Fortran 77 and for the @code{include}
8786 statement.  Also, @code{+=} assignments are introduced, but it is
8787 still quite easy to fool Automake when mixing this with conditionals.
8789 These two releases, Automake 1.4 and Autoconf 2.13 makes a duo that
8790 will be used together for years.
8792 @command{automake} is 7228 lines, plus 1591 lines of Makefile
8793 fragment, 20 macros (some 1.3 macros were finally contributed back to
8794 Autoconf), 197 test cases, and 51 pages of documentation.
8796 @item 1999-03-27 The @code{user-dep-branch} is created on the CVS repository.
8798 This implements a new dependency tracking schemed that should be
8799 able to handle automatic dependency tracking using any compiler (not
8800 just gcc) and any make (not just GNU @command{make}).  In addition,
8801 the new scheme should be more reliable than the old one, as
8802 dependencies are generated on the end user's machine. Alexandre Oliva
8803 creates depcomp for this purpose.
8805 @xref{Dependency Tracking Evolution}, for more details about the
8806 evolution of automatic dependency tracking in Automake.
8808 @item 1999-11-21 The @code{user-dep-branch} is merged into the main trunk.
8810 This was a huge problem since we also had patches going in on the
8811 trunk.  The merge took a long time and was very painful.
8813 @item 2000-05-10
8815 Since September 1999 and until 2003, Akim Demaille will be zealously
8816 revamping Autoconf.
8818 @quotation
8819 I think the next release should be called "3.0".@*
8820 Let's face it: you've basically rewritten autoconf.@*
8821 Every weekend there are 30 new patches.@*
8822 I don't see how we could call this "2.15" with a straight face.@*
8823 -- Tom Tromey on @email{autoconf@@gnu.org}
8824 @end quotation
8826 Actually Akim works like a submarine: he will pile up patches while he
8827 works off-line during the weekend, and flush them in batch when he
8828 resurfaces on Monday.
8830 @item 2001-01-24
8832 On this Wednesday, Autoconf 2.49c, the last beta before Autoconf 2.50
8833 is out, and Akim has to find something to do during his week-end :)
8835 @item 2001-01-28
8837 Akim sends a batch of 14 patches to @email{automake@@gnu.org}.
8839 @quotation
8840 Aiieeee!  I was dreading the day that the Demaillator turned his
8841 sights on automake... and now it has arrived! -- Tom Tromey
8842 @end quotation
8844 It's only the beginning: in two months he will send 192 patches.  Then
8845 he would slow down so Tom can catch up and review all this.  Initially
8846 Tom actually read all these patches, then he probably trustingly
8847 answered OK to most of them, and finally gave up and let Akim apply
8848 whatever he wanted.  There was no way to keep up with that patch rate.
8850 @quotation
8851 Anyway the patch below won't apply since it predates Akim's
8852 sourcequake; I have yet to figure where the relevant passage has
8853 been moved :) -- Alexandre Duret-Lutz
8854 @end quotation
8856 All these patches were sent to and discussed on
8857 @email{automake@@gnu.org}, so subscribed users were literally drown in
8858 technical mails.  Eventually, the @email{automake-patches@@gnu.org}
8859 mailing list was created in May.
8861 Year after year, Automake had drifted away from its initial design:
8862 construct @file{Makefile.in} by assembling various @file{Makefile}
8863 fragments.  In 1.4, lots of @file{Makefile} rules are being emitted at
8864 various places in the @command{automake} script itself; this does not
8865 help ensuring a consistent treatment of these rules (for instance
8866 making sure that user-defined rules override Automake's own rules).
8867 One of Akim's goal was moving all these hard-coded rules to separate
8868 @file{Makefile} fragments, so the logic could be centralized in a
8869 @file{Makefile} fragment processor.
8871 Another significant contribution of Akim is the interface with the
8872 ``trace'' feature of Autoconf.  The way to scan @file{configure.in} at
8873 this time was to read the file and grep the various macro of interest
8874 to Automake.  Doing so could break in many unexpected ways; automake
8875 could miss some definition (for instance @code{AC_SUBST([$1], [$2])}
8876 where the arguments are known only when M4 is run), or conversely it
8877 could detect some macro that was not expanded (because it is called
8878 conditionally).  In the CVS version of Autoconf, Akim had implemented
8879 the @code{--trace} option, which provides accurate information about
8880 where macros are actually called and with what arguments.  Akim will
8881 equip Automake with a second @file{configure.in} scanner that uses
8882 this @code{--trace} interface.  Since it was not sensible to drop the
8883 Autoconf 2.13 compatibility yet, this experimental scanner was only
8884 used when an environment variable was set, the traditional
8885 grep-scanner being still the default.
8887 @item 2001-04-25 Gary V. Vaughan releases Libtool 1.4
8889 It has been more than two years since Automake 1.4, CVS Automake has
8890 suffered lot's of heavy changes and still is not ready for release.
8891 Libtool 1.4 had to be distributed with a patch against Automake 1.4.
8893 @item 2001-05-08 Automake 1.4-p1
8894 @itemx 2001-05-24 Automake 1.4-p2
8896 Gary V. Vaughan, the principal Libtool maintainer, makes a ``patch
8897 release'' of Automake:
8899 @quotation
8900 The main purpose of this release is to have a stable automake
8901 which is compatible with the latest stable libtool.
8902 @end quotation
8904 The release also contains obvious fixes for bugs in Automake 1.4,
8905 some of which were reported almost monthly.
8907 @item 2001-05-21 Akim Demaille releases Autoconf 2.50
8909 @item 2001-06-07 Automake 1.4-p3
8910 @itemx 2001-06-10 Automake 1.4-p4
8911 @itemx 2001-07-15 Automake 1.4-p5
8913 Gary continues his patch-release series.  These also add support for
8914 some new Autoconf 2.50 idioms.  Essentially, Autoconf now advocates
8915 @file{configure.ac} over @file{configure.in}, and it introduces a new
8916 syntax for @code{AC_OUTPUT}ing files.
8918 @item 2001-08-23 Automake 1.5
8920 A major and long-awaited release, that comes more than two years after
8921 1.4.  It brings many changes, among which:
8922 @itemize
8923 @item The new dependency tracking scheme that uses @command{depcomp}.
8924 Aside from the improvement on the dependency tracking itself
8925 (@pxref{Dependency Tracking Evolution}), this also streamlines the use
8926 of automake generated @file{Makefile.in}s as the @file{Makefile.in}s
8927 used during development are now the same as those used in
8928 distributions.  Before that the @file{Makefile.in}s generated for
8929 maintainers required GNU @command{make} and GCC, they were different
8930 from the portable @file{Makefile} generated for distribution; this was
8931 causing some confusion.
8933 @item Support for per-target compilation flags.
8935 @item Support for reference to files in subdirectories in most
8936 @file{Makefile.am} variables.
8938 @item Introduction of the @code{dist_}, @code{nodist_}, and @code{nobase_}
8939 prefixes.
8940 @item Perl 4 support is finally dropped.
8941 @end itemize
8943 1.5 did broke several packages that worked with 1.4.  Enough so that
8944 Linux distributions could not easily install the new Automake version
8945 without breaking many of the packages for which they had to run
8946 @command{automake}.
8948 Some of these breakages were effectively bugs that would eventually be
8949 fixed in the next release.  However, a lot of damage was caused by
8950 some changes made deliberately to render Automake stricter on some
8951 setup we did consider bogus.  For instance @code{make distcheck} was
8952 improved to check that @code{make uninstall} did remove all the files
8953 @code{make install} installed, that @code{make distclean} did not omit
8954 some file, and that a VPATH build would work even if the source
8955 directory was read-only.  Similarly, Automake now rejects multiple
8956 definitions of the same variable (because that would mix very badly
8957 with conditionals), and @code{+=} assignments with no previous
8958 definition.  Because these changes all occurred suddenly after 1.4 had
8959 been established for more that two years, it hurt users.
8961 To make matter worse, meanwhile Autoconf (now at version 2.52) was
8962 facing similar troubles, for similar reasons.
8964 @item 2002-03-05 Automake 1.6
8966 This release introduced versioned installation (@pxref{API
8967 versioning}).  This was mainly pushed by Havoc Pennington, taking the
8968 GNOME source tree as motive: due to incompatibilities between the
8969 autotools it's impossible for the GNOME packages to switch to Autoconf
8970 2.53 and Automake 1.5 all at once, so they are currently stuck with
8971 Autoconf 2.13 and Automake 1.4.
8973 The idea was to call this version @file{automake-1.6}, call all its
8974 bug-fix versions identically, and switch to @file{automake-1.7} for
8975 the next release that adds new features or changes some rules.  This
8976 scheme implies maintaining a bug-fix branch in addition to the
8977 development trunk, which means more work from the maintainer, but
8978 providing regular bug-fix releases proved to be really worthwhile.
8980 Like 1.5, 1.6 also introduced a bunch of incompatibilities, meant or
8981 not.  Perhaps the more annoying was the dependence on the newly
8982 released Autoconf 2.53.  Autoconf seemed to have stabilized enough
8983 since its explosive 2.50 release, and included changes required to fix
8984 some bugs in Automake.  In order to upgrade to Automake 1.6, people
8985 now had to upgrade Autoconf too; for some packages it was no picnic.
8987 While versioned installation helped people to upgrade, it also
8988 unfortunately allowed people not to upgrade.  At the time of writing,
8989 some Linux distributions are shipping packages for Automake 1.4, 1.5,
8990 1.6, 1.7, 1.8, and 1.9.  Most of these still install 1.4 by default.
8991 Some distribution also call 1.4 the ``stable'' version, and present
8992 ``1.9'' as the development version; this does not really makes sense
8993 since 1.9 is way more solid than 1.4.  All this does not help the
8994 newcomer.
8996 @item 2002-04-11 Automake 1.6.1
8998 1.6, and the upcoming 1.4-p6 release were the last release by Tom.
8999 This one and those following will be handled by Alexandre
9000 Duret-Lutz.  Tom is still around, and will be there until about 1.7,
9001 but his interest into Automake is drifting away towards projects like
9002 @command{gcj}.
9004 Alexandre has been using Automake since 2000, and started to
9005 contribute mostly on Akim's incitement (Akim and Alexandre have been
9006 working in the same room from 1999 to 2002).  In 2001 and 2002 he had
9007 a lot of free time to enjoy hacking Automake.
9009 @item 2002-06-14 Automake 1.6.2
9011 @item 2002-07-28 Automake 1.6.3
9012 @itemx 2002-07-28 Automake 1.4-p6
9014 Two releases on the same day.  1.6.3 is a bug-fix release.
9016 Tom Tromey backported the versioned installation mechanism on the 1.4
9017 branch, so that Automake 1.6.x and Automake 1.4-p6 could be installed
9018 side by side.  Another request from the GNOME folks.
9020 @item 2002-09-25 Automake 1.7
9022 This release switches to the new @file{configure.ac} scanner Akim
9023 was experimenting in 1.5.
9025 @item 2002-10-16 Automake 1.7.1
9026 @itemx 2002-12-06 Automake 1.7.2
9027 @itemx 2003-02-20 Automake 1.7.3
9028 @itemx 2003-04-23 Automake 1.7.4
9029 @itemx 2003-05-18 Automake 1.7.5
9030 @itemx 2003-07-10 Automake 1.7.6
9031 @itemx 2003-09-07 Automake 1.7.7
9032 @itemx 2003-10-07 Automake 1.7.8
9034 Many bug-fix releases.  1.7 lasted because the development version
9035 (upcoming 1.8) was suffering some major internal revamping.
9037 @item 2003-10-26 Automake on screen
9039 Episode 49, `Repercussions', in the third season of the `Alias' TV
9040 show is first aired.
9042 Marshall, one of the character, is working on a computer virus that he
9043 has to modify before it gets into the wrong hands or something like
9044 that.  The screenshots you see do not show any program code, they show
9045 a @file{Makefile.in} @code{generated by automake}...
9047 @item 2003-11-09 Automake 1.7.9
9049 @item 2003-12-10 Automake 1.8
9051 The most striking update is probably that of @command{aclocal}.
9053 @command{aclocal} now uses @code{m4_include} in the produced
9054 @code{aclocal.m4} when the included macros are already distributed
9055 with the package (an idiom used in many packages), which reduces code
9056 duplication.  Many people liked that, but in fact this change was
9057 really introduced to fix a bug in rebuild rules: @file{Makefile.in}
9058 must be rebuilt whenever a dependency of @file{configure} changes, but
9059 all the @file{m4} files included in @file{aclocal.m4} where unknown
9060 from @command{automake}.  Now @command{automake} can just trace the
9061 @code{m4_include}s to discover the dependencies.
9063 @command{aclocal} also starts using the @code{--trace} Autoconf option
9064 in order to discover used macros more accurately.  This will turn out
9065 to be very tricky (later releases will improve this) as people had
9066 devised many ways to cope with the limitation of previous
9067 @command{aclocal} versions, notably using handwritten
9068 @code{m4_include}s: @command{aclocal} must make sure not to redefine a
9069 rule which is already included by such statement.
9071 Automake also has seen its guts rewritten.  Although this rewriting
9072 took a lot of efforts, it is only apparent to the users in that some
9073 constructions previously disallowed by the implementation now work
9074 nicely.  Conditionals, Locations, Variable and Rule definitions,
9075 Options: these items on which Automake works have been rewritten as
9076 separate Perl modules, and documented.
9078 @itemx 2004-01-11 Automake 1.8.1
9079 @itemx 2004-01-12 Automake 1.8.2
9080 @itemx 2004-03-07 Automake 1.8.3
9081 @itemx 2004-04-25 Automake 1.8.4
9082 @itemx 2004-05-16 Automake 1.8.5
9084 @item 2004-07-28 Automake 1.9
9086 This release tries to simplify the compilation rules it outputs to
9087 reduce the size of the Makefile.  The complaint initially come from
9088 the libgcj developers.  Their @file{Makefile.in} generated with
9089 Automake 1.4 and custom build rules (1.4 did not support compiled
9090 Java) is 250KB.  The one generated by 1.8 was over 9MB!  1.9 gets it
9091 down to 1.2MB.
9093 Aside from this it contains mainly minor changes and bug-fixes.
9095 @itemx 2004-08-11 Automake 1.9.1
9096 @itemx 2004-09-19 Automake 1.9.2
9098 Automake has ten years.  This chapter of the manual was initially
9099 written for this occasion.
9101 @end table
9103 @node Dependency Tracking Evolution
9104 @section Dependency Tracking in Automake
9106 Over the years Automake has deployed three different dependency
9107 tracking methods.  Each method, including the current one, has had
9108 flaws of various sorts.  Here we lay out the different dependency
9109 tracking methods, their flaws, and their fixes.  We conclude with
9110 recommendations for tool writers, and by indicating future directions
9111 for dependency tracking work in Automake.
9113 @subsection First Take
9114 @unnumberedsubsubsec Description
9116 Our first attempt at automatic dependency tracking was based on the
9117 method recommended by GNU @command{make}.  (@pxref{Automatic
9118 Prerequisites, , Generating Prerequisites Automatically, make, The GNU
9119 make Manual})
9121 This version worked by precomputing dependencies ahead of time.  For
9122 each source file, it had a special @file{.P} file which held the
9123 dependencies.  There was a rule to generate a @file{.P} file by
9124 invoking the compiler appropriately.  All such @file{.P} files were
9125 included by the @file{Makefile}, thus implicitly becoming dependencies
9126 of @file{Makefile}.
9128 @unnumberedsubsubsec Bugs
9130 This approach had several critical bugs.
9132 @itemize
9133 @item
9134 The code to generate the @file{.P} file relied on @code{gcc}.
9135 (A limitation, not technically a bug.)
9136 @item
9137 The dependency tracking mechanism itself relied on GNU @command{make}.
9138 (A limitation, not technically a bug.)
9139 @item
9140 Because each @file{.P} file was a dependency of @file{Makefile}, this
9141 meant that dependency tracking was done eagerly by @command{make}.
9142 For instance, @code{make clean} would cause all the dependency files
9143 to be updated, and then immediately removed.  This eagerness also
9144 caused problems with some configurations; if a certain source file
9145 could not be compiled on a given architecture for some reason,
9146 dependency tracking would fail, aborting the entire build.
9147 @item
9148 As dependency tracking was done as a pre-pass, compile times were
9149 doubled--the compiler had to be run twice per source file.
9150 @item
9151 @code{make dist} re-ran @command{automake} to generate a
9152 @file{Makefile} which did not have automatic dependency tracking (and
9153 which was thus portable to any version of @command{make}).  In order to
9154 do this portably, Automake had to scan the dependency files and remove
9155 any reference which was to a source file not in the distribution.
9156 This process was error-prone.  Also, if @code{make dist} was run in an
9157 environment where some object file had a dependency on a source file
9158 which was only conditionally created, Automake would generate a
9159 @file{Makefile} which referred to a file which might not appear in the
9160 end user's build.  A special, hacky mechanism was required to work
9161 around this.
9162 @end itemize
9164 @unnumberedsubsubsec Historical Note
9166 The code generated by Automake is often inspired by the
9167 @file{Makefile} style of a particular author. In the case of the first
9168 implementation of dependency tracking, I believe the impetus and
9169 inspiration was Jim Meyering.  (I could be mistaken.  If you know
9170 otherwise feel free to correct me.)
9172 @subsection Dependencies As Side Effects
9173 @unnumberedsubsubsec Description
9175 The next refinement of Automake's automatic dependency tracking scheme
9176 was to implement dependencies as side effects of the compilation.
9177 This was aimed at solving the most commonly reported problems with the
9178 first approach.  In particular we were most concerned with eliminating
9179 the weird rebuilding effect associated with make clean.
9181 In this approach, the @file{.P} files were included using the
9182 @code{-include} command, which let us create these files lazily.  This
9183 avoided the @code{make clean} problem.
9185 We only computed dependencies when a file was actually compiled.  This
9186 avoided the performance penalty associated with scanning each file
9187 twice.  It also let us avoid the other problems associated with the
9188 first, eager, implementation.  For instance, dependencies would never
9189 be generated for a source file which was not compilable on a given
9190 architecture (because it in fact would never be compiled).
9192 @unnumberedsubsubsec Bugs
9194 @itemize
9195 @item
9196 This approach also relied on the existence of @command{gcc} and GNU
9197 @command{make}. (A limitation, not technically a bug.)
9198 @item
9199 Dependency tracking was still done by the developer, so the problems
9200 from the first implementation relating to massaging of dependencies by
9201 @code{make dist} were still in effect.
9202 @item
9203 This implementation suffered from the ``deleted header file'' problem.
9204 Suppose a lazily-created @file{.P} file includes a dependency on a
9205 given header file, like this:
9207 @example
9208 maude.o: maude.c something.h
9209 @end example
9211 Now suppose that the developer removes @file{something.h} and updates
9212 @file{maude.c} so that this include is no longer needed.  If he runs
9213 @command{make}, he will get an error because there is no way to create
9214 @file{something.h}.
9216 We fixed this problem in a later release by further massaging the
9217 output of @command{gcc} to include a dummy dependency for each header
9218 file.
9219 @end itemize
9221 @subsection Dependencies for the User
9222 @unnumberedsubsubsec Description
9224 The bugs associated with @code{make dist}, over time, became a real
9225 problem.  Packages using Automake were being built on a large number
9226 of platforms, and were becoming increasingly complex.  Broken
9227 dependencies were distributed in ``portable'' @file{Makefile.in}s,
9228 leading to user complaints.  Also, the requirement for @command{gcc}
9229 and GNU @command{make} was a constant source of bug reports.  The next
9230 implementation of dependency tracking aimed to remove these problems.
9232 We realized that the only truly reliable way to automatically track
9233 dependencies was to do it when the package itself was built.  This
9234 meant discovering a method portable to any version of make and any
9235 compiler.  Also, we wanted to preserve what we saw as the best point
9236 of the second implementation: dependency computation as a side effect
9237 of compilation.
9239 In the end we found that most modern make implementations support some
9240 form of include directive.  Also, we wrote a wrapper script which let
9241 us abstract away differences between dependency tracking methods for
9242 compilers.  For instance, some compilers cannot generate dependencies
9243 as a side effect of compilation.  In this case we simply have the
9244 script run the compiler twice.  Currently our wrapper script
9245 (@command{depcomp}) knows about twelve different compilers (including
9246 a "compiler" which simply invokes @command{makedepend} and then the
9247 real compiler, which is assumed to be a standard Unix-like C compiler
9248 with no way to do dependency tracking).
9250 @unnumberedsubsubsec Bugs
9252 @itemize
9253 @item
9254 Running a wrapper script for each compilation slows down the build.
9255 @item
9256 Many users don't really care about precise dependencies.
9257 @item
9258 This implementation, like every other automatic dependency tracking
9259 scheme in common use today (indeed, every one we've ever heard of),
9260 suffers from the ``duplicated new header'' bug.
9262 This bug occurs because dependency tracking tools, such as the
9263 compiler, only generate dependencies on the successful opening of a
9264 file, and not on every probe.
9266 Suppose for instance that the compiler searches three directories for
9267 a given header, and that the header is found in the third directory.
9268 If the programmer erroneously adds a header file with the same name to
9269 the first directory, then a clean rebuild from scratch could fail
9270 (suppose the new header file is buggy), whereas an incremental rebuild
9271 will succeed.
9273 What has happened here is that people have a misunderstanding of what
9274 a dependency is.  Tool writers think a dependency encodes information
9275 about which files were read by the compiler.  However, a dependency
9276 must actually encode information about what the compiler tried to do.
9278 This problem is not serious in practice.  Programmers typically do not
9279 use the same name for a header file twice in a given project.  (At
9280 least, not in C or C++.  This problem may be more troublesome in
9281 Java.)  This problem is easy to fix, by modifying dependency
9282 generators to record every probe, instead of every successful open.
9284 @item
9285 Since automake generates dependencies as a side effect of compilation,
9286 there is a bootstrapping problem when header files are generated by
9287 running a program.  The problem is that, the first time the build is
9288 done, there is no way by default to know that the headers are
9289 required, so make might try to run a compilation for which the headers
9290 have not yet been built.
9292 This was also a problem in the previous dependency tracking implementation.
9294 The current fix is to use @code{BUILT_SOURCES} to list built headers
9295 (@pxref{Sources}).  This causes them to be built before any other
9296 other build rules are run.  This is unsatisfactory as a general
9297 solution, however in practice it seems sufficient for most actual
9298 programs.
9299 @end itemize
9301 This code is used since Automake 1.5.
9303 In GCC 3.0, we managed to convince the maintainers to add special
9304 command-line options to help Automake more efficiently do its job.  We
9305 hoped this would let us avoid the use of a wrapper script when
9306 Automake's automatic dependency tracking was used with @command{gcc}.
9308 Unfortunately, this code doesn't quite do what we want.  In
9309 particular, it removes the dependency file if the compilation fails;
9310 we'd prefer that it instead only touch the file in any way if the
9311 compilation succeeds.
9313 Nevertheless, since Automake 1.7, when a recent @command{gcc} is
9314 detected at @command{configure} time, we inline the
9315 dependency-generation code and do not use the @command{depcomp}
9316 wrapper script.  This makes compilations faster for those using this
9317 compiler (probably our primary user base).  The counterpart is that
9318 because we have to encode two compilation rules in @file{Makefile}
9319 (with or without @command{depcomp}), the produced @file{Makefile}s are
9320 larger.
9322 @subsection Techniques for Computing Dependencies
9324 There are actually several ways for a build tool like Automake to
9325 cause tools to generate dependencies.
9327 @table @asis
9328 @item @command{makedepend}
9329 This was a commonly-used method in the past.  The idea is to run a
9330 special program over the source and have it generate dependency
9331 information.  Traditional implementations of @command{makedepend} ere
9332 not completely precise; ordinarily they were conservative and
9333 discovered too many dependencies.
9334 @item The tool
9335 An obvious way to generate dependencies is to simply write the tool so
9336 that it can generate the information needed by the build tool.  This is
9337 also the most portable method.  Many compilers have an option to
9338 generate dependencies.  Unfortunately, not all tools provide such an
9339 option.
9340 @item The file system
9341 It is possible to write a special file system that tracks opens,
9342 reads, writes, etc, and then feed this information back to the build
9343 tool.  @command{clearmake} does this.  This is a very powerful
9344 technique, as it doesn't require cooperation from the
9345 tool.  Unfortunately it is also very difficult to implement and also
9346 not practical in the general case.
9347 @item @code{LD_PRELOAD}
9348 Rather than use the file system, one could write a special library to
9349 intercept @code{open} and other syscalls.  This technique is also quite
9350 powerful, but unfortunately it is not portable enough for use in
9351 @command{automake}.
9352 @end table
9354 @subsection Recommendations for Tool Writers
9356 We think that every compilation tool ought to be able to generate
9357 dependencies as a side effect of compilation.  Furthermore, at least
9358 while @command{make}-based tools are nearly universally in use (at
9359 least in the free software community), the tool itself should generate
9360 dummy dependencies for header files, to avoid the deleted header file
9361 bug.  Finally, the tool should generate a dependency for each probe,
9362 instead of each successful file open, in order to avoid the duplicated
9363 new header bug.
9365 @subsection Future Directions for Automake's Dependency Tracking
9367 Currently, only languages and compilers understood by Automake can
9368 have dependency tracking enabled.  We would like to see if it is
9369 practical (and worthwhile) to let this support be extended by the user
9370 to languages unknown to Automake.
9372 @node Releases
9373 @section Release Statistics
9375 The following table (inspired by @code{perlhist(1)}) quantifies the
9376 evolution of Automake using these metrics:
9378 @table @asis
9379 @item Date, Rel
9380 The date and version of the release.
9381 @item am
9382 The number of lines of the @command{automake} script.
9383 @item acl
9384 The number of lines of the @command{aclocal} script.
9385 @item pm
9386 The number of lines of the @command{Perl} supporting modules.
9387 @item @file{*.am}
9388 The number of lines of the @file{Makefile} fragments.  The number in parenthesis
9389 is the number of files.
9390 @item m4
9391 The number of lines (and files) of Autoconf macros.
9392 @item doc
9393 The number of pages of the documentation (the Postscript version).
9394 @item t
9395 The number of test cases in the test suite.
9396 @end table
9398 @multitable {8888-88-88} {8.8-p8} {8888} {888} {8888} {8888 (88)} {8888 (88)} {888} {888}
9399 @headitem Date   @tab Rel @tab am @tab acl @tab pm @tab @file{*.am} @tab m4 @tab doc @tab t
9400 @item 1994-09-19 @tab CVS    @tab  141 @tab     @tab      @tab  299 (24) @tab           @tab     @tab
9401 @item 1994-11-05 @tab CVS    @tab  208 @tab     @tab      @tab  332 (28) @tab           @tab     @tab
9402 @item 1995-11-23 @tab 0.20   @tab  533 @tab     @tab      @tab  458 (35) @tab           @tab   9 @tab
9403 @item 1995-11-26 @tab 0.21   @tab  613 @tab     @tab      @tab  480 (36) @tab           @tab  11 @tab
9404 @item 1995-11-28 @tab 0.22   @tab 1116 @tab     @tab      @tab  539 (38) @tab           @tab  12 @tab
9405 @item 1995-11-29 @tab 0.23   @tab 1240 @tab     @tab      @tab  541 (38) @tab           @tab  12 @tab
9406 @item 1995-12-08 @tab 0.24   @tab 1462 @tab     @tab      @tab  504 (33) @tab           @tab  14 @tab
9407 @item 1995-12-10 @tab 0.25   @tab 1513 @tab     @tab      @tab  511 (37) @tab           @tab  15 @tab
9408 @item 1996-01-03 @tab 0.26   @tab 1706 @tab     @tab      @tab  438 (36) @tab           @tab  16 @tab
9409 @item 1996-01-03 @tab 0.27   @tab 1706 @tab     @tab      @tab  438 (36) @tab           @tab  16 @tab
9410 @item 1996-01-13 @tab 0.28   @tab 1964 @tab     @tab      @tab  934 (33) @tab           @tab  16 @tab
9411 @item 1996-02-07 @tab 0.29   @tab 2299 @tab     @tab      @tab  936 (33) @tab           @tab  17 @tab
9412 @item 1996-02-24 @tab 0.30   @tab 2544 @tab     @tab      @tab  919 (32) @tab   85 (1)  @tab  20 @tab 9
9413 @item 1996-03-11 @tab 0.31   @tab 2877 @tab     @tab      @tab  919 (32) @tab   85 (1)  @tab  29 @tab 17
9414 @item 1996-04-27 @tab 0.32   @tab 3058 @tab     @tab      @tab  921 (31) @tab   85 (1)  @tab  30 @tab 26
9415 @item 1996-05-18 @tab 0.33   @tab 3110 @tab     @tab      @tab  926 (31) @tab  105 (1)  @tab  30 @tab 35
9416 @item 1996-05-28 @tab 1.0    @tab 3134 @tab     @tab      @tab  973 (32) @tab  105 (1)  @tab  30 @tab 38
9417 @item 1997-06-22 @tab 1.2    @tab 6089 @tab 385 @tab      @tab 1294 (36) @tab  592 (23) @tab  37 @tab 126
9418 @item 1998-04-05 @tab 1.3    @tab 6415 @tab 422 @tab      @tab 1470 (39) @tab  741 (26) @tab  39 @tab 156
9419 @item 1999-01-14 @tab 1.4    @tab 7240 @tab 426 @tab      @tab 1591 (40) @tab  734 (23) @tab  51 @tab 197
9420 @item 2001-05-08 @tab 1.4-p1 @tab 7251 @tab 426 @tab      @tab 1591 (40) @tab  734 (23) @tab  51 @tab 197
9421 @item 2001-05-24 @tab 1.4-p2 @tab 7268 @tab 439 @tab      @tab 1591 (40) @tab  734 (23) @tab  49 @tab 197
9422 @item 2001-06-07 @tab 1.4-p3 @tab 7312 @tab 439 @tab      @tab 1591 (40) @tab  734 (23) @tab  49 @tab 197
9423 @item 2001-06-10 @tab 1.4-p4 @tab 7321 @tab 439 @tab      @tab 1591 (40) @tab  734 (23) @tab  49 @tab 198
9424 @item 2001-07-15 @tab 1.4-p5 @tab 7228 @tab 426 @tab      @tab 1596 (40) @tab  734 (23) @tab  51 @tab 198
9425 @item 2001-08-23 @tab 1.5    @tab 8016 @tab 475 @tab  600 @tab 2654 (39) @tab 1166 (32) @tab  63 @tab 327
9426 @item 2002-03-05 @tab 1.6    @tab 8465 @tab 475 @tab 1136 @tab 2732 (39) @tab 1603 (31) @tab  66 @tab 365
9427 @item 2002-04-11 @tab 1.6.1  @tab 8544 @tab 475 @tab 1136 @tab 2741 (39) @tab 1603 (31) @tab  66 @tab 372
9428 @item 2002-06-14 @tab 1.6.2  @tab 8575 @tab 475 @tab 1136 @tab 2800 (39) @tab 1609 (31) @tab  67 @tab 386
9429 @item 2002-07-28 @tab 1.6.3  @tab 8600 @tab 475 @tab 1153 @tab 2809 (39) @tab 1609 (31) @tab  67 @tab 391
9430 @item 2002-07-28 @tab 1.4-p6 @tab 7332 @tab 455 @tab      @tab 1596 (40) @tab  735 (24) @tab  49 @tab 197
9431 @item 2002-09-25 @tab 1.7    @tab 9189 @tab 471 @tab 1790 @tab 2965 (39) @tab 1606 (33) @tab  73 @tab 430
9432 @item 2002-10-16 @tab 1.7.1  @tab 9229 @tab 475 @tab 1790 @tab 2977 (39) @tab 1606 (33) @tab  73 @tab 437
9433 @item 2002-12-06 @tab 1.7.2  @tab 9334 @tab 475 @tab 1790 @tab 2988 (39) @tab 1606 (33) @tab  77 @tab 445
9434 @item 2003-02-20 @tab 1.7.3  @tab 9389 @tab 475 @tab 1790 @tab 3023 (39) @tab 1651 (34) @tab  84 @tab 448
9435 @item 2003-04-23 @tab 1.7.4  @tab 9429 @tab 475 @tab 1790 @tab 3031 (39) @tab 1644 (34) @tab  85 @tab 458
9436 @item 2003-05-18 @tab 1.7.5  @tab 9429 @tab 475 @tab 1790 @tab 3033 (39) @tab 1645 (34) @tab  85 @tab 459
9437 @item 2003-07-10 @tab 1.7.6  @tab 9442 @tab 475 @tab 1790 @tab 3033 (39) @tab 1660 (34) @tab  85 @tab 461
9438 @item 2003-09-07 @tab 1.7.7  @tab 9443 @tab 475 @tab 1790 @tab 3041 (39) @tab 1660 (34) @tab  90 @tab 467
9439 @item 2003-10-07 @tab 1.7.8  @tab 9444 @tab 475 @tab 1790 @tab 3041 (39) @tab 1660 (34) @tab  90 @tab 468
9440 @item 2003-11-09 @tab 1.7.9  @tab 9444 @tab 475 @tab 1790 @tab 3048 (39) @tab 1660 (34) @tab  90 @tab 468
9441 @item 2003-12-10 @tab 1.8    @tab 7171 @tab 585 @tab 7730 @tab 3236 (39) @tab 1666 (36) @tab 104 @tab 521
9442 @item 2004-01-11 @tab 1.8.1  @tab 7217 @tab 663 @tab 7726 @tab 3287 (39) @tab 1686 (36) @tab 104 @tab 525
9443 @item 2004-01-12 @tab 1.8.2  @tab 7217 @tab 663 @tab 7726 @tab 3288 (39) @tab 1686 (36) @tab 104 @tab 526
9444 @item 2004-03-07 @tab 1.8.3  @tab 7214 @tab 686 @tab 7735 @tab 3303 (39) @tab 1695 (36) @tab 111 @tab 530
9445 @item 2004-04-25 @tab 1.8.4  @tab 7214 @tab 686 @tab 7736 @tab 3310 (39) @tab 1701 (36) @tab 112 @tab 531
9446 @item 2004-05-16 @tab 1.8.5  @tab 7240 @tab 686 @tab 7736 @tab 3299 (39) @tab 1701 (36) @tab 112 @tab 533
9447 @item 2004-07-28 @tab 1.9    @tab 7508 @tab 715 @tab 7794 @tab 3352 (40) @tab 1812 (37) @tab 115 @tab 551
9448 @item 2004-08-11 @tab 1.9.1  @tab 7512 @tab 715 @tab 7794 @tab 3354 (40) @tab 1812 (37) @tab 115 @tab 552
9449 @item 2004-09-19 @tab 1.9.2  @tab 7512 @tab 715 @tab 7794 @tab 3354 (40) @tab 1812 (37) @tab 132 @tab 554
9450 @end multitable
9453 @c ========================================================== Appendices
9455 @page
9456 @node Copying This Manual
9457 @appendix Copying This Manual
9459 @menu
9460 * GNU Free Documentation License::  License for copying this manual
9461 @end menu
9463 @include fdl.texi
9465 @page
9466 @node Indices
9467 @appendix Indices
9469 @menu
9470 * Macro and Variable Index::    Index of Autoconf macros and Automake variables
9471 * General Index::               General index
9472 @end menu
9474 @node Macro and Variable Index
9475 @appendixsec Macro and Variable Index
9477 @printindex vr
9479 @node General Index
9480 @appendixsec General Index
9482 @printindex cp
9485 @page
9486 @contents
9487 @bye
9489 @c  LocalWords:  texinfo setfilename settitle setchapternewpage texi direntry
9490 @c  LocalWords:  dircategory in's aclocal ifinfo titlepage Tromey vskip pt sp
9491 @c  LocalWords:  filll defcodeindex ov cv op tr syncodeindex fn cp vr ifnottex
9492 @c  LocalWords:  dir Automake's ac Dist Gnits gnits cygnus dfn Autoconf's pxref
9493 @c  LocalWords:  cindex Autoconf autoconf perl samp cvs dist trindex SUBST foo
9494 @c  LocalWords:  xs emph FIXME ref vindex pkglibdir pkgincludedir pkgdatadir mt
9495 @c  LocalWords:  pkg libdir cvindex cpio bindir sbindir rmt pax sbin zar zardir
9496 @c  LocalWords:  HTML htmldir html noinst TEXINFOS nodist nobase strudel CFLAGS
9497 @c  LocalWords:  libmumble CC YFLAGS ansi knr itemx de fication config url comp
9498 @c  LocalWords:  depcomp elisp sh mdate mkinstalldirs mkdir py tex dvi ps pdf
9499 @c  LocalWords:  ylwrap zardoz INIT gettext acinclude mv FUNCS LIBOBJS LDADD fr
9500 @c  LocalWords:  uref featureful dnl src LINGUAS es ko nl pl sl sv PROG ISC doc
9501 @c  LocalWords:  POSIX STDC fcntl FUNC ALLOCA blksize struct stat intl po chmod
9502 @c  LocalWords:  ChangeLog SUBDIRS gettextize gpl testdata getopt INTLLIBS cpp
9503 @c  LocalWords:  localedir datadir DLOCALEDIR DEXIT CPPFLAGS autoreconf opindex
9504 @c  LocalWords:  AUX var symlink deps Wno Wnone package's aclocal's distclean
9505 @c  LocalWords:  ltmain xref LIBSOURCE LIBSOURCES LIBOBJ MEMCMP vs RANLIB CXX
9506 @c  LocalWords:  LDFLAGS LIBTOOL libtool XTRA LIBS gettext's acdir APIVERSION
9507 @c  LocalWords:  dirlist noindent usr MULTILIB multilib Multilibs TIOCGWINSZ sc
9508 @c  LocalWords:  GWINSZ termios SRCDIR tarball bzip LISPDIR lispdir XEmacs CCAS
9509 @c  LocalWords:  emacsen MicroEmacs CCASFLAGS UX GCJ gcj GCJFLAGS posix DMALLOC
9510 @c  LocalWords:  dmalloc ldmalloc REGEX regex rx DEPDIR DEP DEFUN aclocaldir fi
9511 @c  LocalWords:  mymacro myothermacro AMFLAGS autopoint autogen libtoolize yum
9512 @c  LocalWords:  autoheader README MAKEFLAGS subdir Inetutils sync COND endif
9513 @c  LocalWords:  Miller's installable includedir inc pkgdata EXEEXT libexec bsd
9514 @c  LocalWords:  pkglib libexecdir prog libcpio cpio's dlopen dlpreopen linux
9515 @c  LocalWords:  subsubsection OBJEXT esac lib LTLIBRARIES liblob LIBADD AR ar
9516 @c  LocalWords:  ARFLAGS cru ing maude libgettext lo LTLIBOBJS rpath SGI PRE yy
9517 @c  LocalWords:  libmaude CCLD CXXFLAGS FFLAGS LFLAGS OBJCFLAGS RFLAGS DEFS cc
9518 @c  LocalWords:  SHORTNAME vtable srcdir nostdinc basename yxx cxx ll lxx gdb
9519 @c  LocalWords:  lexers yymaxdepth maxdepth yyparse yylex yyerror yylval lval
9520 @c  LocalWords:  yychar yydebug yypact yyr yydef def yychk chk yypgo pgo yyact
9521 @c  LocalWords:  yyexca exca yyerrflag errflag yynerrs nerrs yyps yypv pv yys
9522 @c  LocalWords:  yystate yytmp tmp yyv yyval val yylloc lloc yyreds yytoks toks
9523 @c  LocalWords:  yylhs yylen yydefred yydgoto yysindex yyrindex yygindex yyname
9524 @c  LocalWords:  yytable yycheck yyrule byacc CXXCOMPILE CXXLINK FLINK cfortran
9525 @c  LocalWords:  Catalogue preprocessable FLIBS libfoo baz JAVACFLAGS java exe
9526 @c  LocalWords:  SunOS fying basenames exeext uninstalled oldinclude kr FSF's
9527 @c  LocalWords:  pkginclude oldincludedir sysconf sharedstate localstate gcc rm
9528 @c  LocalWords:  sysconfdir sharedstatedir localstatedir preexist CLEANFILES gz
9529 @c  LocalWords:  unnumberedsubsec depfile tmpdepfile depmode const interoperate
9530 @c  LocalWords:  JAVAC javac JAVAROOT builddir CLASSPATH ENV pyc pyo pkgpython
9531 @c  LocalWords:  pyexecdir pkgpyexecdir Python's pythondir pkgpythondir txi ois
9532 @c  LocalWords:  installinfo vers MAKEINFO makeinfo MAKEINFOFLAGS noinstall rf
9533 @c  LocalWords:  mandir thesame alsothesame installman myexecbin DESTDIR Pinard
9534 @c  LocalWords:  uninstall installdirs uninstalls MOSTLYCLEANFILES mostlyclean
9535 @c  LocalWords:  DISTCLEANFILES MAINTAINERCLEANFILES gzip'd GZIP gzip shar exp
9536 @c  LocalWords:  distdir distcheck distcleancheck listfiles distuninstallcheck
9537 @c  LocalWords:  VPATH tarfile stdout XFAIL DejaGnu dejagnu DEJATOOL runtest ln
9538 @c  LocalWords:  RUNTESTDEFAULTFLAGS toolchain RUNTESTFLAGS asis readme DVIPS
9539 @c  LocalWords:  installcheck gzipped tarZ std utils etags mkid multilibbing cd
9540 @c  LocalWords:  ARGS taggable ETAGSFLAGS lang ctags CTAGSFLAGS GTAGS gtags idl
9541 @c  LocalWords:  foocc doit idlC multilibs ABIs cmindex defmac ARG enableval FC
9542 @c  LocalWords:  MSG xtrue DBG pathchk CYGWIN afile proglink versioned CVS's TE
9543 @c  LocalWords:  wildcards Autoconfiscated subsubheading autotools Meyering API
9544 @c  LocalWords:  ois's wildcard Wportability cartouche vrindex printindex Duret
9545 @c  LocalWords:  DSOMEFLAG DVERSION automake Lutz insertcopying versioning FAQ
9546 @c  LocalWords:  LTLIBOBJ Libtool's libtool's libltdl dlopening itutions libbar
9547 @c  LocalWords:  WANTEDLIBS libhello sublibraries libtop libsub dlopened Ratfor
9548 @c  LocalWords:  mymodule timestamps timestamp underquoted MAKEINFOHTMLFLAGS te
9549 @c  LocalWords:  GNUmakefile buildir Subpackages subpackage's subpackages aux
9550 @c  LocalWords:  detailmenu Timeline pwd reldir AUTOM autom PREREQ FOOBAR libc
9551 @c  LocalWords:  libhand subpackage moduleN libmain libmisc FCFLAGS FCCOMPILE
9552 @c  LocalWords:  FCLINK subst sed ELCFILES elc MAKEINFOHTML dvips esyscmd ustar
9553 @c  LocalWords:  tarballs Woverride scrdir vfi ELFILES djm AutoMake honkin FSF
9554 @c  LocalWords:  fileutils precanned MacKenzie's reimplement termutils Tromey's
9555 @c  LocalWords:  cois gnitsians LIBPROGRAMS progs LIBLIBRARIES Textutils Ulrich
9556 @c  LocalWords:  Matzigkeit Drepper's Gord Matzigkeit's jm Dalley Debian eg org
9557 @c  LocalWords:  Administrivia ILU CORBA Sourceware Molenda sourceware Elliston
9558 @c  LocalWords:  dep Oliva Akim Demaille Aiieeee Demaillator Akim's sourcequake
9559 @c  LocalWords:  grep backported screenshots libgcj KB unnumberedsubsubsec pre
9560 @c  LocalWords:  precomputing hacky makedepend inline clearmake LD PRELOAD Rel
9561 @c  LocalWords:  syscalls perlhist acl pm multitable headitem fdl appendixsec
9562 @c  LocalWords:  LTALLOCA MALLOC malloc memcmp strdup alloca libcompat xyz DFOO
9563 @c  LocalWords:  unprefixed buildable preprocessed DBAZ DDATADIR WARNINGCFLAGS
9564 @c  LocalWords:  LIBFOOCFLAGS LIBFOOLDFLAGS