1 \input texinfo @c -*-texinfo-*-
3 @setfilename automake.info
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.
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.''
35 @dircategory Software development
37 * automake: (automake). Making Makefile.in's.
40 @dircategory Individual utilities
42 * aclocal: (automake)Invoking aclocal. Generating aclocal.m4.
47 @subtitle For version @value{VERSION}, @value{UPDATED}
48 @author David MacKenzie
50 @author Alexandre Duret-Lutz
52 @vskip 0pt plus 1filll
56 @c Define an index of configure output variables.
58 @c Define an index of configure variables.
60 @c Define an index of options.
62 @c Define an index of targets.
64 @c Define an index of commands.
67 @c Put the macros and variables into their own index.
68 @c @syncodeindex fn cp
73 @c Put everything else into one index (arbitrarily chosen to be the concept index).
80 @comment node-name, next, previous, up
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 * Top level:: The top-level Makefile.am
92 * Alternative:: An alternative approach to subdirectories
93 * Programs:: Building programs and libraries
94 * Other objects:: Other derived objects
95 * Other GNU Tools:: Other GNU Tools
96 * Documentation:: Building documentation
97 * Install:: What gets installed
98 * Clean:: What gets cleaned
99 * Dist:: What goes in a distribution
100 * Tests:: Support for test suites
101 * Rebuilding:: Automatic rebuilding of Makefile
102 * Options:: Changing Automake's behavior
103 * Miscellaneous:: Miscellaneous rules
104 * Include:: Including extra files in an Automake template.
105 * Conditionals:: Conditionals
106 * Gnits:: The effect of @code{--gnu} and @code{--gnits}
107 * Cygnus:: The effect of @code{--cygnus}
108 * Not Enough:: When Automake is not Enough
109 * Distributing:: Distributing the Makefile.in
110 * API versioning:: About compatibility between Automake versions
111 * Upgrading:: Upgrading to a Newer Automake Version
112 * FAQ:: Frequently Asked Questions
113 * Copying This Manual:: How to make copies of this manual
114 * Indices:: Indices of variables, macros, and concepts
117 --- The Detailed Node Listing ---
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 Building Programs and Libraries
158 * A Program:: Building a program
159 * A Library:: Building a library
160 * A Shared Library:: Building a Libtool library
161 * Program and Library Variables:: Variables controlling program and
163 * Default _SOURCES:: Default source files
164 * LIBOBJS:: Special handling for LIBOBJS and ALLOCA
165 * Program variables:: Variables used when building a program
166 * Yacc and Lex:: Yacc and Lex support
167 * C++ Support:: Compiling C++ sources
168 * Assembly Support:: Compiling assembly sources
169 * Fortran 77 Support:: Compiling Fortran 77 sources
170 * Java Support:: Compiling Java sources
171 * Support for Other Languages:: Compiling other languages
172 * ANSI:: Automatic de-ANSI-fication
173 * Dependencies:: Automatic dependency tracking
174 * EXEEXT:: Support for executable extensions
178 * Program Sources:: Defining program sources
179 * Linking:: Linking with libraries or extra objects
180 * Conditional Sources:: Handling conditional sources
181 * Conditional Programs:: Building program conditionally
183 Building a Shared Library
185 * Libtool Concept:: Introducing Libtool
186 * Libtool Libraries:: Declaring Libtool Libraries
187 * Conditional Libtool Libraries:: Building Libtool Libraries Conditionally
188 * Conditional Libtool Sources:: Choosing Library Sources Conditionally
189 * Libtool Convenience Libraries:: Building Convenience Libtool Libraries
190 * Libtool Modules:: Building Libtool Modules
191 * Libtool Flags:: Using _LIBADD and _LDFLAGS
192 * LTLIBOBJ:: Using $(LTLIBOBJ)
193 * Libtool Issues:: Common Issues Related to Libtool's Use
197 * Preprocessing Fortran 77:: Preprocessing Fortran 77 sources
198 * Compiling Fortran 77 Files:: Compiling Fortran 77 sources
199 * Mixing Fortran 77 With C and C++:: Mixing Fortran 77 With C and C++
201 Mixing Fortran 77 With C and C++
203 * How the Linker is Chosen:: Automatic linker selection
205 Other Derived Objects
207 * Scripts:: Executable scripts
208 * Headers:: Header files
209 * Data:: Architecture-independent data files
210 * Sources:: Derived sources
214 * Built sources example:: Several ways to handle built sources.
218 * Emacs Lisp:: Emacs Lisp
224 Building documentation
227 * Man pages:: Man pages
231 * Tags:: Interfacing to etags and mkid
232 * Suffixes:: Handling new file extensions
233 * Multilibs:: Support for multilibs.
235 When Automake Isn't Enough
237 * Extending:: Adding new rules or overriding existing ones.
238 * Third-Party Makefiles:: Integrating Non-Automake @file{Makefile}s.
240 Frequently Asked Questions about Automake
242 * CVS:: CVS and generated files
243 * maintainer-mode:: missing and AM_MAINTAINER_MODE
244 * wildcards:: Why doesn't Automake support wildcards?
245 * distcleancheck:: Files left in build directory after distclean
246 * renamed objects:: Why are object files sometimes renamed?
247 * Multiple Outputs:: Writing rules for tools with many output files
251 * GNU Free Documentation License:: License for copying this manual
255 * Macro and Variable Index:: Index of Autoconf macros and Automake variables
256 * General Index:: General index
265 @chapter Introduction
267 Automake is a tool for automatically generating @file{Makefile.in}s from
268 files called @file{Makefile.am}. Each @file{Makefile.am} is basically a
269 series of @code{make} variable definitions@footnote{These variables are
270 also called @dfn{make macros} in Make terminology, however in this
271 manual we reserve the term @dfn{macro} for Autoconf's macros.}, with
272 rules being thrown in occasionally. The generated @file{Makefile.in}s
273 are compliant with the GNU Makefile standards.
275 @cindex GNU Makefile standards
277 The GNU Makefile Standards Document
278 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
279 is long, complicated, and subject to change. The goal of Automake is to
280 remove the burden of Makefile maintenance from the back of the
281 individual GNU maintainer (and put it on the back of the Automake
284 The typical Automake input file is simply a series of variable definitions.
285 Each such file is processed to create a @file{Makefile.in}. There
286 should generally be one @file{Makefile.am} per directory of a project.
288 @cindex Constraints of Automake
289 @cindex Automake constraints
291 Automake does constrain a project in certain ways; for instance it
292 assumes that the project uses Autoconf (@pxref{Top, , Introduction,
293 autoconf, The Autoconf Manual}), and enforces certain restrictions on
294 the @file{configure.ac} contents@footnote{Older Autoconf versions used
295 @file{configure.in}. Autoconf 2.50 and greater promotes
296 @file{configure.ac} over @file{configure.in}. The rest of this
297 documentation will refer to @file{configure.ac}, but Automake also
298 supports @file{configure.in} for backward compatibility.}.
300 @cindex Automake requirements
301 @cindex Requirements, Automake
303 Automake requires @code{perl} in order to generate the
304 @file{Makefile.in}s. However, the distributions created by Automake are
305 fully GNU standards-compliant, and do not require @code{perl} in order
308 @cindex BUGS, reporting
309 @cindex Reporting BUGS
310 @cindex E-mail, bug reports
312 Mail suggestions and bug reports for Automake to
313 @email{bug-automake@@gnu.org}.
317 @chapter General ideas
319 The following sections cover a few basic ideas that will help you
320 understand how Automake works.
323 * General Operation:: General operation of Automake
324 * Strictness:: Standards conformance checking
325 * Uniform:: The Uniform Naming Scheme
326 * Canonicalization:: How derived variables are named
327 * User Variables:: Variables reserved for the user
328 * Auxiliary Programs:: Programs automake might require
332 @node General Operation
333 @section General Operation
335 Automake works by reading a @file{Makefile.am} and generating a
336 @file{Makefile.in}. Certain variables and rules defined in the
337 @file{Makefile.am} instruct Automake to generate more specialized code;
338 for instance, a @samp{bin_PROGRAMS} variable definition will cause rules
339 for compiling and linking programs to be generated.
341 @cindex Non-standard targets
342 @cindex cvs-dist, non-standard example
345 The variable definitions and rules in the @file{Makefile.am} are
346 copied verbatim into the generated file. This allows you to add
347 arbitrary code into the generated @file{Makefile.in}. For instance
348 the Automake distribution includes a non-standard rule for the
349 @code{cvs-dist} target, which the Automake maintainer uses to make
350 distributions from his source control system.
352 @cindex GNU make extensions
354 Note that most GNU make extensions are not recognized by Automake. Using
355 such extensions in a @file{Makefile.am} will lead to errors or confusing
358 @cindex Append operator
359 A special exception is that the GNU make append operator, @samp{+=}, is
360 supported. This operator appends its right hand argument to the variable
361 specified on the left. Automake will translate the operator into
362 an ordinary @samp{=} operator; @samp{+=} will thus work with any make program.
364 Automake tries to keep comments grouped with any adjoining rules or
365 variable definitions.
367 @cindex Make targets, overriding
368 @cindex Make rules, overriding
369 @cindex Overriding make rules
370 @cindex Overriding make targets
372 A rule defined in @file{Makefile.am} generally overrides any such
373 rule of a similar name that would be automatically generated by
374 @code{automake}. Although this is a supported feature, it is generally
375 best to avoid making use of it, as sometimes the generated rules are
378 @cindex Variables, overriding
379 @cindex Overriding make variables
381 Similarly, a variable defined in @file{Makefile.am} or
382 @code{AC_SUBST}'ed from @file{configure.ac} will override any
383 definition of the variable that @code{automake} would ordinarily
384 create. This feature is more often useful than the ability to
385 override a rule. Be warned that many of the variables generated by
386 @code{automake} are considered to be for internal use only, and their
387 names might change in future releases.
389 @cindex Recursive operation of Automake
390 @cindex Automake, recursive operation
391 @cindex Example of recursive operation
393 When examining a variable definition, Automake will recursively examine
394 variables referenced in the definition. For example, if Automake is
395 looking at the content of @code{foo_SOURCES} in this snippet
399 foo_SOURCES = c.c $(xs)
402 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
403 contents of @code{foo_SOURCES}.
405 @cindex ## (special Automake comment)
406 @cindex Special Automake comment
407 @cindex Comment, special to Automake
409 Automake also allows a form of comment which is @emph{not} copied into
410 the output; all lines beginning with @samp{##} (leading spaces allowed)
411 are completely ignored by Automake.
413 It is customary to make the first line of @file{Makefile.am} read:
415 @cindex Makefile.am, first line
416 @cindex First line of Makefile.am
419 ## Process this file with automake to produce Makefile.in
422 @c FIXME discuss putting a copyright into Makefile.am here? I would but
423 @c I don't know quite what to say.
425 @c FIXME document customary ordering of Makefile.am here!
431 @cindex Non-GNU packages
433 While Automake is intended to be used by maintainers of GNU packages, it
434 does make some effort to accommodate those who wish to use it, but do
435 not want to use all the GNU conventions.
437 @cindex Strictness, defined
438 @cindex Strictness, foreign
439 @cindex foreign strictness
440 @cindex Strictness, gnu
441 @cindex gnu strictness
442 @cindex Strictness, gnits
443 @cindex gnits strictness
445 To this end, Automake supports three levels of @dfn{strictness}---the
446 strictness indicating how stringently Automake should check standards
449 The valid strictness levels are:
453 Automake will check for only those things which are absolutely
454 required for proper operations. For instance, whereas GNU standards
455 dictate the existence of a @file{NEWS} file, it will not be required in
456 this mode. The name comes from the fact that Automake is intended to be
457 used for GNU programs; these relaxed rules are not the standard mode of
461 Automake will check---as much as possible---for compliance to the GNU
462 standards for packages. This is the default.
465 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
466 standards}. These are based on the GNU standards, but are even more
467 detailed. Unless you are a Gnits standards contributor, it is
468 recommended that you avoid this option until such time as the Gnits
469 standard is actually published (which may never happen).
472 For more information on the precise implications of the strictness
473 level, see @ref{Gnits}.
475 Automake also has a special ``cygnus'' mode which is similar to
476 strictness but handled differently. This mode is useful for packages
477 which are put into a ``Cygnus'' style tree (e.g., the GCC tree). For
478 more information on this mode, see @ref{Cygnus}.
482 @section The Uniform Naming Scheme
484 @cindex Uniform naming scheme
486 Automake variables generally follow a @dfn{uniform naming scheme} that
487 makes it easy to decide how programs (and other derived objects) are
488 built, and how they are installed. This scheme also supports
489 @code{configure} time determination of what should be built.
491 @cindex _PROGRAMS primary variable
492 @cindex PROGRAMS primary variable
493 @cindex Primary variable, PROGRAMS
494 @cindex Primary variable, defined
496 At @code{make} time, certain variables are used to determine which
497 objects are to be built. The variable names are made of several pieces
498 which are concatenated together.
500 The piece which tells automake what is being built is commonly called
501 the @dfn{primary}. For instance, the primary @code{PROGRAMS} holds a
502 list of programs which are to be compiled and linked.
505 @cindex pkglibdir, defined
506 @cindex pkgincludedir, defined
507 @cindex pkgdatadir, defined
510 @vindex pkgincludedir
513 A different set of names is used to decide where the built objects
514 should be installed. These names are prefixes to the primary which
515 indicate which standard directory should be used as the installation
516 directory. The standard directory names are given in the GNU standards
517 (@pxref{Directory Variables, , , standards, The GNU Coding Standards}).
518 Automake extends this list with @code{pkglibdir}, @code{pkgincludedir},
519 and @code{pkgdatadir}; these are the same as the non-@samp{pkg}
520 versions, but with @samp{$(PACKAGE)} appended. For instance,
521 @code{pkglibdir} is defined as @code{$(libdir)/$(PACKAGE)}.
522 @cvindex PACKAGE, directory
524 @cindex EXTRA_, prepending
526 For each primary, there is one additional variable named by prepending
527 @samp{EXTRA_} to the primary name. This variable is used to list
528 objects which may or may not be built, depending on what
529 @code{configure} decides. This variable is required because Automake
530 must statically know the entire list of objects that may be built in
531 order to generate a @file{Makefile.in} that will work in all cases.
533 @cindex EXTRA_PROGRAMS, defined
534 @cindex Example, EXTRA_PROGRAMS
537 For instance, @code{cpio} decides at configure time which programs are
538 built. Some of the programs are installed in @code{bindir}, and some
539 are installed in @code{sbindir}:
542 EXTRA_PROGRAMS = mt rmt
543 bin_PROGRAMS = cpio pax
544 sbin_PROGRAMS = $(MORE_PROGRAMS)
547 Defining a primary without a prefix as a variable, e.g.,
548 @code{PROGRAMS}, is an error.
550 Note that the common @samp{dir} suffix is left off when constructing the
551 variable names; thus one writes @samp{bin_PROGRAMS} and not
552 @samp{bindir_PROGRAMS}.
554 Not every sort of object can be installed in every directory. Automake
555 will flag those attempts it finds in error.
556 Automake will also diagnose obvious misspellings in directory names.
558 @cindex Extending list of installation directories
559 @cindex Installation directories, extending list
561 Sometimes the standard directories---even as augmented by Automake---
562 are not enough. In particular it is sometimes useful, for clarity, to
563 install objects in a subdirectory of some predefined directory. To this
564 end, Automake allows you to extend the list of possible installation
565 directories. A given prefix (e.g. @samp{zar}) is valid if a variable of
566 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
568 @cindex HTML installation, example
570 For instance, installation of HTML files is part of Automake, you could
571 use this to install raw HTML documentation:
574 htmldir = $(prefix)/html
575 html_DATA = automake.html
578 @cindex noinst primary prefix, definition
580 The special prefix @samp{noinst} indicates that the objects in question
581 should be built but not installed at all. This is usually used for
582 objects required to build the rest of your package, for instance static
583 libraries (@pxref{A Library}), or helper scripts.
585 @cindex check primary prefix, definition
587 The special prefix @samp{check} indicates that the objects in question
588 should not be built until the @code{make check} command is run. Those
589 objects are not installed either.
591 The current primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
592 @samp{LISP}, @samp{PYTHON}, @samp{JAVA}, @samp{SCRIPTS}, @samp{DATA},
593 @samp{HEADERS}, @samp{MANS}, and @samp{TEXINFOS}.
605 Some primaries also allow additional prefixes which control other
606 aspects of @code{automake}'s behavior. The currently defined prefixes
607 are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}. These prefixes
608 are explained later (@pxref{Program and Library Variables}).
611 @node Canonicalization
612 @section How derived variables are named
614 @cindex canonicalizing Automake variables
616 Sometimes a Makefile variable name is derived from some text the
617 maintainer supplies. For instance, a program name listed in
618 @samp{_PROGRAMS} is rewritten into the name of a @samp{_SOURCES}
619 variable. In cases like this, Automake canonicalizes the text, so that
620 program names and the like do not have to follow Makefile variable naming
621 rules. All characters in the name except for letters, numbers, the
622 strudel (@@), and the underscore are turned into underscores when making
625 For example, if your program is named @code{sniff-glue}, the derived
626 variable name would be @code{sniff_glue_SOURCES}, not
627 @code{sniff-glue_SOURCES}. Similarly the sources for a library named
628 @code{libmumble++.a} should be listed in the
629 @code{libmumble___a_SOURCES} variable.
631 The strudel is an addition, to make the use of Autoconf substitutions in
632 variable names less obfuscating.
636 @section Variables reserved for the user
638 @cindex variables, reserved for the user
639 @cindex user variables
641 Some @code{Makefile} variables are reserved by the GNU Coding Standards
642 for the use of the ``user'' -- the person building the package. For
643 instance, @code{CFLAGS} is one such variable.
645 Sometimes package developers are tempted to set user variables such as
646 @code{CFLAGS} because it appears to make their job easier. However,
647 the package itself should never set a user variable, particularly not
648 to include switches which are required for proper compilation of the
649 package. Since these variables are documented as being for the
650 package builder, that person rightfully expects to be able to override
651 any of these variables at build time.
653 To get around this problem, automake introduces an automake-specific
654 shadow variable for each user flag variable. (Shadow variables are not
655 introduced for variables like @code{CC}, where they would make no
656 sense.) The shadow variable is named by prepending @samp{AM_} to the
657 user variable's name. For instance, the shadow variable for
658 @code{YFLAGS} is @code{AM_YFLAGS}.
661 @node Auxiliary Programs
662 @section Programs automake might require
664 @cindex Programs, auxiliary
665 @cindex Auxiliary programs
667 Automake sometimes requires helper programs so that the generated
668 @file{Makefile} can do its work properly. There are a fairly large
669 number of them, and we list them here.
674 These two files are used by the automatic de-ANSI-fication support
678 This is a wrapper for compilers which don't accept both @samp{-c} and
679 @samp{-o} at the same time. It is only used when absolutely required.
680 Such compilers are rare.
684 These programs compute the canonical triplets for the given build, host,
685 or target architecture. These programs are updated regularly to support
686 new architectures and fix probes broken by changes in new kernel
687 versions. You are encouraged to fetch the latest versions of these
688 files from @url{ftp://ftp.gnu.org/gnu/config/} before making a release.
691 This program understands how to run a compiler so that it will generate
692 not only the desired output but also dependency information which is
693 then used by the automatic dependency tracking feature.
696 This program is used to byte-compile Emacs Lisp code.
699 This is a replacement for the @code{install} program which works on
700 platforms where @code{install} is unavailable or unusable.
703 This script is used to generate a @file{version.texi} file. It examines
704 a file and prints some date information about it.
707 This wraps a number of programs which are typically only required by
708 maintainers. If the program in question doesn't exist, @code{missing}
709 prints an informative warning and attempts to fix things so that the
713 This script used to be a wrapper around @code{mkdir -p}, which is not
714 portable. Now we use prefer to use @code{install-sh -d} when configure
715 finds that @code{mkdir -p} does not work, this makes one less script to
718 For backward compatibility @code{mkinstalldirs} is still used and
719 distributed when @code{automake} finds it in a package. But it is no
720 longer installed automatically, and it should be safe to remove it.
723 This is used to byte-compile Python scripts.
726 Not a program, this file is required for @code{make dvi}, @code{make ps}
727 and @code{make pdf} to work when Texinfo sources are in the package.
730 This program wraps @code{lex} and @code{yacc} and ensures that, for
731 instance, multiple @code{yacc} instances can be invoked in a single
732 directory in parallel.
738 @chapter Some example packages
741 * Complete:: A simple example, start to finish
742 * Hello:: A classic program
743 * true:: Building true and false
748 @section A simple example, start to finish
750 @cindex Complete example
752 Let's suppose you just finished writing @code{zardoz}, a program to make
753 your head float from vortex to vortex. You've been using Autoconf to
754 provide a portability framework, but your @file{Makefile.in}s have been
755 ad-hoc. You want to make them bulletproof, so you turn to Automake.
757 @cindex AM_INIT_AUTOMAKE, example use
759 The first step is to update your @file{configure.ac} to include the
760 commands that @code{automake} needs. The way to do this is to add an
761 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
769 Since your program doesn't have any complicating factors (e.g., it
770 doesn't use @code{gettext}, it doesn't want to build a shared library),
771 you're done with this part. That was easy!
773 @cindex aclocal program, introduction
774 @cindex aclocal.m4, preexisting
775 @cindex acinclude.m4, defined
777 Now you must regenerate @file{configure}. But to do that, you'll need
778 to tell @code{autoconf} how to find the new macro you've used. The
779 easiest way to do this is to use the @code{aclocal} program to generate
780 your @file{aclocal.m4} for you. But wait@dots{} maybe you already have an
781 @file{aclocal.m4}, because you had to write some hairy macros for your
782 program. The @code{aclocal} program lets you put your own macros into
783 @file{acinclude.m4}, so simply rename and then run:
786 mv aclocal.m4 acinclude.m4
791 @cindex zardoz example
793 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
794 Since @code{zardoz} is a user program, you want to install it where the
795 rest of the user programs go: @code{bindir}. Additionally,
796 @code{zardoz} has some Texinfo documentation. Your @file{configure.ac}
797 script uses @code{AC_REPLACE_FUNCS}, so you need to link against
798 @samp{$(LIBOBJS)}. So here's what you'd write:
801 bin_PROGRAMS = zardoz
802 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
803 zardoz_LDADD = $(LIBOBJS)
805 info_TEXINFOS = zardoz.texi
808 Now you can run @code{automake --add-missing} to generate your
809 @file{Makefile.in} and grab any auxiliary files you might need, and
814 @section A classic program
816 @cindex Example, GNU Hello
817 @cindex Hello example
818 @cindex GNU Hello, example
820 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
821 renowned for its classic simplicity and versatility. This section shows
822 how Automake could be used with the GNU Hello package. The examples
823 below are from the latest beta version of GNU Hello, but with all of the
824 maintainer-only code stripped out, as well as all copyright comments.
826 Of course, GNU Hello is somewhat more featureful than your traditional
827 two-liner. GNU Hello is internationalized, does option processing, and
828 has a manual and a test suite.
830 @cindex configure.ac, from GNU Hello
831 @cindex GNU Hello, configure.ac
832 @cindex Hello, configure.ac
834 Here is the @file{configure.ac} from GNU Hello.
835 @strong{Please note:} The calls to @code{AC_INIT} and @code{AM_INIT_AUTOMAKE}
836 in this example use a deprecated syntax. For the current approach,
837 see the description of @code{AM_INIT_AUTOMAKE} in @ref{Public macros}.
839 @c FIXME: This definitely requires an update, e.g. to GNU Hello 2.1.1.
842 dnl Process this file with autoconf to produce a configure script.
844 AM_INIT_AUTOMAKE(hello, 1.3.11)
845 AM_CONFIG_HEADER(config.h)
847 dnl Set of available languages.
848 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
850 dnl Checks for programs.
854 dnl Checks for libraries.
856 dnl Checks for header files.
858 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
860 dnl Checks for library functions.
863 dnl Check for st_blksize in struct stat
866 dnl internationalization macros
868 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
869 src/Makefile tests/Makefile tests/hello],
870 [chmod +x tests/hello])
873 The @samp{AM_} macros are provided by Automake (or the Gettext library);
874 the rest are standard Autoconf macros.
877 The top-level @file{Makefile.am}:
880 EXTRA_DIST = BUGS ChangeLog.O
881 SUBDIRS = doc intl po src tests
884 As you can see, all the work here is really done in subdirectories.
886 The @file{po} and @file{intl} directories are automatically generated
887 using @code{gettextize}; they will not be discussed here.
889 @cindex Texinfo file handling example
890 @cindex Example, handling Texinfo files
892 In @file{doc/Makefile.am} we see:
895 info_TEXINFOS = hello.texi
896 hello_TEXINFOS = gpl.texi
899 This is sufficient to build, install, and distribute the GNU Hello
902 @cindex Regression test example
903 @cindex Example, regression test
905 Here is @file{tests/Makefile.am}:
909 EXTRA_DIST = hello.in testdata
912 The script @file{hello} is generated by @code{configure}, and is the
913 only test case. @code{make check} will run this test.
915 @cindex INCLUDES, example usage
917 Last we have @file{src/Makefile.am}, where all the real work is done:
918 @c FIXME: As all the Hello World excerpts in this manual, this
919 @c shows deprecated features (here: $(INCLUDES)).
923 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
924 hello_LDADD = $(INTLLIBS) $(ALLOCA)
925 localedir = $(datadir)/locale
926 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
931 @section Building true and false
933 @cindex Example, false and true
934 @cindex false Example
937 Here is another, trickier example. It shows how to generate two
938 programs (@code{true} and @code{false}) from the same source file
939 (@file{true.c}). The difficult part is that each compilation of
940 @file{true.c} requires different @code{cpp} flags.
943 bin_PROGRAMS = true false
945 false_LDADD = false.o
948 $(COMPILE) -DEXIT_CODE=0 -c true.c
951 $(COMPILE) -DEXIT_CODE=1 -o false.o -c true.c
954 Note that there is no @code{true_SOURCES} definition. Automake will
955 implicitly assume that there is a source file named @file{true.c}, and
956 define rules to compile @file{true.o} and link @file{true}. The
957 @code{true.o: true.c} rule supplied by the above @file{Makefile.am},
958 will override the Automake generated rule to build @file{true.o}.
960 @code{false_SOURCES} is defined to be empty---that way no implicit value
961 is substituted. Because we have not listed the source of
962 @file{false}, we have to tell Automake how to link the program. This is
963 the purpose of the @code{false_LDADD} line. A @code{false_DEPENDENCIES}
964 variable, holding the dependencies of the @file{false} target will be
965 automatically generated by Automake from the content of
968 The above rules won't work if your compiler doesn't accept both
969 @samp{-c} and @samp{-o}. The simplest fix for this is to introduce a
970 bogus dependency (to avoid problems with a parallel @code{make}):
973 true.o: true.c false.o
974 $(COMPILE) -DEXIT_CODE=0 -c true.c
977 $(COMPILE) -DEXIT_CODE=1 -c true.c && mv true.o false.o
980 Also, these explicit rules do not work if the de-ANSI-fication feature
981 is used (@pxref{ANSI}). Supporting de-ANSI-fication requires a little
985 true._o: true._c false.o
986 $(COMPILE) -DEXIT_CODE=0 -c true.c
989 $(COMPILE) -DEXIT_CODE=1 -c true.c && mv true._o false.o
992 As it turns out, there is also a much easier way to do this same task.
993 Some of the above techniques are useful enough that we've kept the
994 example in the manual. However if you were to build @code{true} and
995 @code{false} in real life, you would probably use per-program
996 compilation flags, like so:
999 bin_PROGRAMS = false true
1001 false_SOURCES = true.c
1002 false_CPPFLAGS = -DEXIT_CODE=1
1004 true_SOURCES = true.c
1005 true_CPPFLAGS = -DEXIT_CODE=0
1008 In this case Automake will cause @file{true.c} to be compiled twice,
1009 with different flags. De-ANSI-fication will work automatically. In
1010 this instance, the names of the object files would be chosen by
1011 automake; they would be @file{false-true.o} and @file{true-true.o}.
1012 (The name of the object files rarely matters.)
1015 @node Invoking Automake
1016 @chapter Creating a @file{Makefile.in}
1018 @cindex Multiple configure.ac files
1019 @cindex Invoking Automake
1020 @cindex Automake, invoking
1022 To create all the @file{Makefile.in}s for a package, run the
1023 @code{automake} program in the top level directory, with no arguments.
1024 @code{automake} will automatically find each appropriate
1025 @file{Makefile.am} (by scanning @file{configure.ac}; @pxref{configure})
1026 and generate the corresponding @file{Makefile.in}. Note that
1027 @code{automake} has a rather simplistic view of what constitutes a
1028 package; it assumes that a package has only one @file{configure.ac}, at
1029 the top. If your package has multiple @file{configure.ac}s, then you
1030 must run @code{automake} in each directory holding a
1031 @file{configure.ac}. (Alternatively, you may rely on Autoconf's
1032 @code{autoreconf}, which is able to recurse your package tree and run
1033 @code{automake} where appropriate.)
1035 You can optionally give @code{automake} an argument; @file{.am} is
1036 appended to the argument and the result is used as the name of the input
1037 file. This feature is generally only used to automatically rebuild an
1038 out-of-date @file{Makefile.in}. Note that @code{automake} must always
1039 be run from the topmost directory of a project, even if being used to
1040 regenerate the @file{Makefile.in} in some subdirectory. This is
1041 necessary because @code{automake} must scan @file{configure.ac}, and
1042 because @code{automake} uses the knowledge that a @file{Makefile.in} is
1043 in a subdirectory to change its behavior in some cases.
1046 Automake will run @code{autoconf} to scan @file{configure.ac} and its
1047 dependencies (@file{aclocal.m4}), therefore @code{autoconf} must be in
1048 your @code{PATH}. If there is an @code{AUTOCONF} variable in your
1049 environment it will be used instead of @code{autoconf}, this allows you
1050 to select a particular version of Autoconf. By the way, don't
1051 misunderstand this paragraph: Automake runs @code{autoconf} to
1052 @strong{scan} your @file{configure.ac}, this won't build
1053 @file{configure} and you still have to run @code{autoconf} yourself for
1056 @cindex Automake options
1057 @cindex Options, Automake
1058 @cindex Strictness, command line
1060 @code{automake} accepts the following options:
1062 @cindex Extra files distributed with Automake
1063 @cindex Files distributed with Automake
1064 @cindex config.guess
1068 @itemx --add-missing
1070 @opindex --add-missing
1071 Automake requires certain common files to exist in certain situations;
1072 for instance @file{config.guess} is required if @file{configure.ac} runs
1073 @code{AC_CANONICAL_HOST}. Automake is distributed with several of these
1074 files (@pxref{Auxiliary Programs}); this option will cause the missing
1075 ones to be automatically added to the package, whenever possible. In
1076 general if Automake tells you a file is missing, try using this option.
1077 By default Automake tries to make a symbolic link pointing to its own
1078 copy of the missing file; this can be changed with @code{--copy}.
1080 Many of the potentially-missing files are common scripts whose
1081 location may be specified via the @code{AC_CONFIG_AUX_DIR} macro.
1082 Therefore, @code{AC_CONFIG_AUX_DIR}'s setting affects whether a
1083 file is considered missing, and where the missing file is added
1086 @item --libdir=@var{dir}
1088 Look for Automake data files in directory @var{dir} instead of in the
1089 installation directory. This is typically used for debugging.
1095 When used with @code{--add-missing}, causes installed files to be
1096 copied. The default is to make a symbolic link.
1100 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
1101 of GNU or Gnits rules. For more information, see @ref{Cygnus}.
1105 @itemx --force-missing
1106 @opindex --force-missing
1107 When used with @code{--add-missing}, causes standard files to be reinstalled
1108 even if they already exist in the source tree. This involves removing
1109 the file from the source tree before creating the new symlink (or, with
1110 @code{--copy}, copying the new file).
1114 Set the global strictness to @samp{foreign}. For more information, see
1119 Set the global strictness to @samp{gnits}. For more information, see
1124 Set the global strictness to @samp{gnu}. For more information, see
1125 @ref{Gnits}. This is the default strictness.
1129 Print a summary of the command line options and exit.
1132 @itemx --ignore-deps
1134 This disables the dependency tracking feature in generated
1135 @file{Makefile}s; see @ref{Dependencies}.
1137 @item --include-deps
1138 @opindex --include-deps
1139 This enables the dependency tracking feature. This feature is enabled
1140 by default. This option is provided for historical reasons only and
1141 probably should not be used.
1145 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
1146 @file{configure.ac}. This option causes it to only update those
1147 @file{Makefile.in}s which are out of date with respect to one of their
1151 @itemx --output-dir=@var{dir}
1153 @opindex --output-dir
1154 Put the generated @file{Makefile.in} in the directory @var{dir}.
1155 Ordinarily each @file{Makefile.in} is created in the directory of the
1156 corresponding @file{Makefile.am}. This option is deprecated and will be
1157 removed in a future release.
1163 Cause Automake to print information about which files are being read or
1168 Print the version number of Automake and exit.
1171 @item --warnings=@var{category}
1174 Output warnings falling in @var{category}. @var{category} can be
1178 warnings related to the GNU Coding Standards
1179 (@pxref{Top, , , standards, The GNU Coding Standards}).
1181 obsolete features or constructions
1183 user redefinitions of Automake rules or variables
1185 portability issues (e.g., use of Make features which are known not portable)
1187 weird syntax, unused variables, typos
1189 unsupported or incomplete features
1193 turn off all the warnings
1195 treat warnings as errors
1198 A category can be turned off by prefixing its name with @samp{no-}. For
1199 instance @samp{-Wno-syntax} will hide the warnings about unused
1202 The categories output by default are @samp{syntax} and
1203 @samp{unsupported}. Additionally, @samp{gnu} is enabled in @samp{--gnu} and
1204 @samp{--gnits} strictness.
1206 @samp{portability} warnings are currently disabled by default, but they
1207 will be enabled in @samp{--gnu} and @samp{--gnits} strictness in a
1211 The environment variable @samp{WARNINGS} can contain a comma separated
1212 list of categories to enable. It will be taken into account before the
1213 command-line switches, this way @samp{-Wnone} will also ignore any
1214 warning category enabled by @samp{WARNINGS}. This variable is also used
1215 by other tools like @command{autoconf}; unknown categories are ignored
1222 @chapter Scanning @file{configure.ac}
1224 @cindex configure.ac, scanning
1225 @cindex Scanning configure.ac
1227 Automake scans the package's @file{configure.ac} to determine certain
1228 information about the package. Some @code{autoconf} macros are required
1229 and some variables must be defined in @file{configure.ac}. Automake
1230 will also use information from @file{configure.ac} to further tailor its
1233 Automake also supplies some Autoconf macros to make the maintenance
1234 easier. These macros can automatically be put into your
1235 @file{aclocal.m4} using the @code{aclocal} program.
1238 * Requirements:: Configuration requirements
1239 * Optional:: Other things Automake recognizes
1240 * Invoking aclocal:: Auto-generating aclocal.m4
1241 * aclocal options:: aclocal command line arguments
1242 * Macro search path:: Modifying aclocal's search path
1243 * Macros:: Autoconf macros supplied with Automake
1244 * Extending aclocal:: Writing your own aclocal macros
1245 * Local Macros:: Organizing local macros
1246 * Future of aclocal:: aclocal's scheduled death
1251 @section Configuration requirements
1253 @cindex Automake requirements
1254 @cindex Requirements of Automake
1256 The one real requirement of Automake is that your @file{configure.ac}
1257 call @code{AM_INIT_AUTOMAKE}. This macro does several things which are
1258 required for proper Automake operation (@pxref{Macros}).
1259 @cvindex AM_INIT_AUTOMAKE
1261 Here are the other macros which Automake requires but which are not run
1262 by @code{AM_INIT_AUTOMAKE}:
1265 @item AC_CONFIG_FILES
1267 Automake uses these to determine which files to create (@pxref{Output, ,
1268 Creating Output Files, autoconf, The Autoconf Manual}). A listed file
1269 is considered to be an Automake generated @file{Makefile} if there
1270 exists a file with the same name and the @file{.am} extension appended.
1271 Typically, @code{AC_CONFIG_FILES([foo/Makefile])} will cause Automake to
1272 generate @file{foo/Makefile.in} if @file{foo/Makefile.am} exists.
1274 When using @code{AC_CONFIG_FILES} with multiple input files, as in
1275 @code{AC_CONFIG_FILES([Makefile:top.in:Makefile.in:bot.in])}, Automake
1276 will generate the first @file{.in} input file for which a @file{.am}
1277 file exists. If no such file exists the output file is not considered
1278 to be Automake generated.
1280 Files created by @code{AC_CONFIG_FILES} are removed by @code{make distclean}.
1281 @cvindex AC_CONFIG_FILES
1287 @section Other things Automake recognizes
1289 @cindex Macros Automake recognizes
1290 @cindex Recognized macros by Automake
1292 Every time Automake is run it calls Autoconf to trace
1293 @file{configure.ac}. This way it can recognize the use of certain
1294 macros and tailor the generated @file{Makefile.in} appropriately.
1295 Currently recognized macros and their effects are:
1298 @item AC_CONFIG_HEADERS
1299 Automake will generate rules to rebuild these headers. Older versions
1300 of Automake required the use of @code{AM_CONFIG_HEADER}
1301 (@pxref{Macros}); this is no longer the case today.
1302 @cvindex AC_CONFIG_HEADERS
1304 @item AC_CONFIG_LINKS
1305 Automake will generate rules to remove @file{configure} generated links on
1306 @code{make distclean} and to distribute named source files as part of
1308 @cvindex AC_CONFIG_LINKS
1310 @item AC_CONFIG_AUX_DIR
1311 Automake will look for various helper scripts, such as
1312 @file{install-sh}, in the directory named in this macro invocation.
1313 @c This list is accurate relative to version 1.8
1314 (The full list of scripts is: @file{config.guess}, @file{config.sub},
1315 @file{depcomp}, @file{elisp-comp}, @file{compile}, @file{install-sh},
1316 @file{ltmain.sh}, @file{mdate-sh}, @file{missing}, @file{mkinstalldirs},
1317 @file{py-compile}, @file{texinfo.tex}, and @file{ylwrap}.) Not all
1318 scripts are always searched for; some scripts will only be sought if the
1319 generated @file{Makefile.in} requires them.
1320 @cvindex AC_CONFIG_AUX_DIR
1322 If @code{AC_CONFIG_AUX_DIR} is not given, the scripts are looked for in
1323 their @samp{standard} locations. For @file{mdate-sh},
1324 @file{texinfo.tex}, and @file{ylwrap}, the standard location is the
1325 source directory corresponding to the current @file{Makefile.am}. For
1326 the rest, the standard location is the first one of @file{.}, @file{..},
1327 or @file{../..} (relative to the top source directory) that provides any
1328 one of the helper scripts. @xref{Input, , Finding `configure' Input,
1329 autoconf, The Autoconf Manual}.
1331 Required files from @code{AC_CONFIG_AUX_DIR} are automatically
1332 distributed, even if there is no @file{Makefile.am} in this directory.
1334 @item AC_CANONICAL_HOST
1335 Automake will ensure that @file{config.guess} and @file{config.sub}
1336 exist. Also, the @file{Makefile} variables @samp{host_alias} and
1337 @samp{host_triplet} are introduced. See @ref{Canonicalizing, ,
1338 Getting the Canonical System Type, autoconf, The Autoconf Manual}.
1339 @cvindex AC_CANONICAL_HOST
1341 @vindex host_triplet
1343 @item AC_CANONICAL_SYSTEM
1344 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
1345 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
1346 @xref{Canonicalizing, , Getting the Canonical System Type, autoconf, The
1348 @cvindex AC_CANONICAL_SYSTEM
1350 @vindex target_alias
1353 @itemx AC_LIBSOURCES
1355 Automake will automatically distribute any file listed in
1356 @code{AC_LIBSOURCE} or @code{AC_LIBSOURCES}.
1358 Note that the @code{AC_LIBOBJ} macro calls @code{AC_LIBSOURCE}. So if
1359 an Autoconf macro is documented to call @code{AC_LIBOBJ([file])}, then
1360 @file{file.c} will be distributed automatically by Automake. This
1361 encompasses many macros like @code{AC_FUNC_ALLOCA},
1362 @code{AC_FUNC_MEMCMP}, @code{AC_REPLACE_FUNCS}, and others.
1364 @cvindex AC_LIBSOURCE
1365 @cvindex AC_LIBSOURCES
1367 By the way, direct assignments to @code{LIBOBJS} are no longer
1368 supported. You should always use @code{AC_LIBOBJ} for this purpose.
1369 @xref{AC_LIBOBJ vs LIBOBJS, , @code{AC_LIBOBJ} vs. @code{LIBOBJS},
1370 autoconf, The Autoconf Manual}.
1373 @item AC_PROG_RANLIB
1374 This is required if any libraries are built in the package.
1375 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1377 @cvindex AC_PROG_RANLIB
1380 This is required if any C++ source is included. @xref{Particular
1381 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1382 @cvindex AC_PROG_CXX
1385 This is required if any Fortran 77 source is included. This macro is
1386 distributed with Autoconf version 2.13 and later. @xref{Particular
1387 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1388 @cvindex AC_PROG_F77
1390 @item AC_F77_LIBRARY_LDFLAGS
1391 This is required for programs and shared libraries that are a mixture of
1392 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1393 C++}). @xref{Macros, , Autoconf macros supplied with Automake}.
1394 @cvindex AC_F77_LIBRARY_LDFLAGS
1396 @item AC_PROG_LIBTOOL
1397 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1398 Introduction, libtool, The Libtool Manual}).
1399 @cvindex AC_PROG_LIBTOOL
1402 If a Yacc source file is seen, then you must either use this macro or
1403 define the variable @samp{YACC} in @file{configure.ac}. The former is
1404 preferred (@pxref{Particular Programs, , Particular Program Checks,
1405 autoconf, The Autoconf Manual}).
1406 @cvindex AC_PROG_YACC
1410 If a Lex source file is seen, then this macro must be used.
1411 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1413 @cvindex AC_PROG_LEX
1417 The first argument is automatically defined as a variable in each
1418 generated @file{Makefile.in}. @xref{Setting Output Variables, , Setting
1419 Output Variables, autoconf, The Autoconf Manual}.
1421 If the Autoconf manual says that a macro calls @code{AC_SUBST} for
1422 @var{var}, or defines the output variable @var{var} then @var{var} will
1423 be defined in each @file{Makefile.in} generated by Automake.
1424 E.g. @code{AC_PATH_XTRA} defines @code{X_CFLAGS} and @code{X_LIBS}, so
1425 you can use these variables in any @file{Makefile.am} if
1426 @code{AC_PATH_XTRA} is called.
1428 @item AM_C_PROTOTYPES
1429 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1430 @cvindex AM_C_PROTOTYPES
1432 @item AM_GNU_GETTEXT
1433 This macro is required for packages which use GNU gettext
1434 (@pxref{gettext}). It is distributed with gettext. If Automake sees
1435 this macro it ensures that the package meets some of gettext's
1437 @cvindex AM_GNU_GETTEXT
1439 @item AM_MAINTAINER_MODE
1440 @opindex --enable-maintainer-mode
1441 This macro adds a @samp{--enable-maintainer-mode} option to
1442 @code{configure}. If this is used, @code{automake} will cause
1443 @samp{maintainer-only} rules to be turned off by default in the
1444 generated @file{Makefile.in}s. This macro defines the
1445 @samp{MAINTAINER_MODE} conditional, which you can use in your own
1447 @cvindex AM_MAINTAINER_MODE
1451 Files included by @file{configure.ac} using this macro will be
1452 detected by Automake and automatically distributed. They will also
1453 appear as dependencies in @file{Makefile} rules.
1455 @code{m4_include} is seldom used by @file{configure.ac} authors, but
1456 can appear in @file{aclocal.m4} when @command{aclocal} detects that
1457 some required macros come from files local to your package (as
1458 opposed to macros installed in a system-wide directory, see
1459 @ref{Invoking aclocal}).
1464 @node Invoking aclocal
1465 @section Auto-generating aclocal.m4
1467 @cindex Invoking aclocal
1468 @cindex aclocal, Invoking
1470 Automake includes a number of Autoconf macros which can be used in
1471 your package (@pxref{Macros}); some of them are actually required by
1472 Automake in certain situations. These macros must be defined in your
1473 @file{aclocal.m4}; otherwise they will not be seen by
1476 The @command{aclocal} program will automatically generate
1477 @file{aclocal.m4} files based on the contents of @file{configure.ac}.
1478 This provides a convenient way to get Automake-provided macros,
1479 without having to search around. The @command{aclocal} mechanism
1480 allows other packages to supply their own macros (@pxref{Extending
1481 aclocal}). You can also use it to maintain your own set of custom
1482 macros (@pxref{Local Macros}).
1484 At startup, @command{aclocal} scans all the @file{.m4} files it can
1485 find, looking for macro definitions (@pxref{Macro search path}). Then
1486 it scans @file{configure.ac}. Any mention of one of the macros found
1487 in the first step causes that macro, and any macros it in turn
1488 requires, to be put into @file{aclocal.m4}.
1490 @emph{Putting} the file that contains the macro definition into
1491 @file{aclocal.m4} is usually done by copying the entire text of this
1492 file, including unused macro definitions as well as both @samp{#} and
1493 @samp{dnl} comments. If you want to make a comment which will be
1494 completely ignored by @command{aclocal}, use @samp{##} as the comment
1497 When @command{aclocal} detects that the file containing the macro
1498 definition is in a subdirectory of your package, it will use
1499 @code{m4_include} instead of copying it; this makes the package
1500 smaller and eases dependency tracking. This only works if the
1501 subdirectory containing the macro was specified as a relative search
1502 path with @command{aclocal}'s @code{-I} argument. (@pxref{Local
1503 Macros} for an example.) Any macro which is found in a system-wide
1504 directory, or via an absolute search path will be copied.
1506 The contents of @file{acinclude.m4}, if it exists, are also
1507 automatically included in @file{aclocal.m4}. We recommend against
1508 using @file{acinclude.m4} in new packages (@pxref{Local Macros}).
1511 While computing @file{aclocal.m4}, @code{aclocal} runs @code{autom4te}
1512 (@pxref{Using autom4te, , Using @code{Autom4te}, autoconf, The
1513 Autoconf Manual}) in order to trace the macros which are really used,
1514 and omit from @file{aclocal.m4} all macros which are mentioned but
1515 otherwise unexpanded (this can happen when a macro is called
1516 conditionally). @code{autom4te} is expected to be in the @code{PATH},
1517 just as @code{autoconf}. Its location can be overridden using the
1518 @code{AUTOM4TE} environment variable.
1521 * aclocal options:: Options supported by aclocal
1522 * Macro search path:: How aclocal finds .m4 files
1525 @node aclocal options
1526 @section aclocal options
1528 @cindex aclocal, Options
1529 @cindex Options, aclocal
1531 @code{aclocal} accepts the following options:
1534 @item --acdir=@var{dir}
1536 Look for the macro files in @var{dir} instead of the installation
1537 directory. This is typically used for debugging.
1541 Print a summary of the command line options and exit.
1545 Add the directory @var{dir} to the list of directories searched for
1550 Always overwrite the output file. The default is to overwrite the output
1551 file only when really needed, i.e., when its contents changes or if one
1552 of its dependencies is younger.
1554 @item --output=@var{file}
1556 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1558 @item --print-ac-dir
1559 @opindex --print-ac-dir
1560 Prints the name of the directory which @code{aclocal} will search to
1561 find third-party @file{.m4} files. When this option is given, normal
1562 processing is suppressed. This option can be used by a package to
1563 determine where to install a macro file.
1567 Print the names of the files it examines.
1571 Print the version number of Automake and exit.
1574 @node Macro search path
1575 @section Macro search path
1577 @cindex Macro search path
1578 @cindex aclocal search path
1580 By default, @command{aclocal} searches for @file{.m4} files in the following
1581 directories, in this order:
1584 @item @var{acdir-APIVERSION}
1585 This is where the @file{.m4} macros distributed with automake itself
1586 are stored. @var{APIVERSION} depends on the automake release used;
1587 for automake 1.6.x, @var{APIVERSION} = @code{1.6}.
1590 This directory is intended for third party @file{.m4} files, and is
1591 configured when @command{automake} itself is built. This is
1592 @file{@@datadir@@/aclocal/}, which typically
1593 expands to @file{$@{prefix@}/share/aclocal/}. To find the compiled-in
1594 value of @var{acdir}, use the @code{--print-ac-dir} option
1595 (@pxref{aclocal options}).
1598 As an example, suppose that automake-1.6.2 was configured with
1599 @code{--prefix=/usr/local}. Then, the search path would be:
1602 @item @file{/usr/local/share/aclocal-1.6/}
1603 @item @file{/usr/local/share/aclocal/}
1606 As explained in (@pxref{aclocal options}), there are several options that
1607 can be used to change or extend this search path.
1609 @subsection Modifying the macro search path: @code{--acdir}
1611 The most obvious option to modify the search path is
1612 @code{--acdir=@var{dir}}, which changes default directory and
1613 drops the @var{APIVERSION} directory. For example, if one specifies
1614 @code{--acdir=/opt/private/}, then the search path becomes:
1617 @item @file{/opt/private/}
1620 Note that this option, @code{--acdir}, is intended for use
1621 by the internal automake test suite only; it is not ordinarily
1622 needed by end-users.
1624 @subsection Modifying the macro search path: @code{-I @var{dir}}
1626 Any extra directories specified using @code{-I} options
1627 (@pxref{aclocal options}) are @emph{prepended} to this search list. Thus,
1628 @code{aclocal -I /foo -I /bar} results in the following search path:
1633 @item @var{acdir}-@var{APIVERSION}
1637 @subsection Modifying the macro search path: @file{dirlist}
1638 @cindex @file{dirlist}
1640 There is a third mechanism for customizing the search path. If a
1641 @file{dirlist} file exists in @var{acdir}, then that file is assumed to
1642 contain a list of directories, one per line, to be added to the search
1643 list. These directories are searched @emph{after} all other
1646 For example, suppose
1647 @file{@var{acdir}/dirlist} contains the following:
1655 and that @code{aclocal} was called with the @code{-I /foo -I /bar} options.
1656 Then, the search path would be
1661 @item @var{acdir}-@var{APIVERSION}
1667 If the @code{--acdir=@var{dir}} option is used, then @command{aclocal}
1668 will search for the @file{dirlist} file in @var{dir}. In the
1669 @code{--acdir=/opt/private/} example above, @command{aclocal} would look
1670 for @file{/opt/private/dirlist}. Again, however, the @code{--acdir}
1671 option is intended for use by the internal automake test suite only;
1672 @code{--acdir} is not ordinarily needed by end-users.
1674 @file{dirlist} is useful in the following situation: suppose that
1675 @code{automake} version @code{1.6.2} is installed with
1676 $prefix=/usr by the system vendor. Thus, the default search
1680 @item @file{/usr/share/aclocal-1.6/}
1681 @item @file{/usr/share/aclocal/}
1684 However, suppose further that many packages have been manually
1685 installed on the system, with $prefix=/usr/local, as is typical.
1686 In that case, many of these ``extra'' @file{.m4} files are in
1687 @file{/usr/local/share/aclocal}. The only way to force
1688 @file{/usr/bin/aclocal} to find these ``extra'' @file{.m4} files
1689 is to always call @code{aclocal -I /usr/local/share/aclocal}.
1690 This is inconvenient. With @file{dirlist}, one may create the file
1692 @file{/usr/share/aclocal/dirlist}
1695 which contains only the single line
1697 @file{/usr/local/share/aclocal}
1699 Now, the ``default'' search path on the affected system is
1702 @item @file{/usr/share/aclocal-1.6/}
1703 @item @file{/usr/share/aclocal/}
1704 @item @file{/usr/local/share/aclocal/}
1707 without the need for @code{-I} options; @code{-I} options can be reserved
1708 for project-specific needs (@file{my-source-dir/m4/}), rather than
1709 using it to work around local system-dependent tool installation
1712 Similarly, @file{dirlist} can be handy if you have installed a local
1713 copy Automake on your account and want @command{aclocal} to look for
1714 macros installed at other places on the system.
1718 @section Autoconf macros supplied with Automake
1720 Automake ships with several Autoconf macros that you can use from your
1721 @file{configure.ac}. When you use one of them it will be included by
1722 @code{aclocal} in @file{aclocal.m4}.
1725 * Public macros:: Macros that you can use.
1726 * Private macros:: Macros that you should not use.
1729 @c consider generating the following subsections automatically from m4 files.
1732 @subsection Public macros
1735 @item AM_CONFIG_HEADER
1736 Automake will generate rules to automatically regenerate the config
1737 header. This obsolete macro is a synonym of @code{AC_CONFIG_HEADERS}
1738 today (@pxref{Optional}).
1739 @cvindex AM_CONFIG_HEADER
1741 @item AM_ENABLE_MULTILIB
1742 This is used when a ``multilib'' library is being built. The first
1743 optional argument is the name of the @file{Makefile} being generated; it
1744 defaults to @samp{Makefile}. The second option argument is used to find
1745 the top source directory; it defaults to the empty string (generally
1746 this should not be used unless you are familiar with the internals).
1749 @item AM_C_PROTOTYPES
1750 Check to see if function prototypes are understood by the compiler. If
1751 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1752 @samp{ANSI2KNR} to the empty string. Otherwise, set @samp{U} to
1753 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}. Automake uses these
1754 values to implement automatic de-ANSI-fication.
1755 @cvindex AM_C_PROTOTYPES
1757 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1758 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1759 define @code{GWINSZ_IN_SYS_IOCTL}. Otherwise @code{TIOCGWINSZ} can be
1760 found in @file{<termios.h>}.
1761 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1763 @item AM_INIT_AUTOMAKE([OPTIONS])
1764 @itemx AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
1765 Runs many macros required for proper operation of the generated Makefiles.
1767 This macro has two forms, the first of which is preferred.
1768 In this form, @code{AM_INIT_AUTOMAKE} is called with a
1769 single argument --- a space-separated list of Automake options which should
1770 be applied to every @file{Makefile.am} in the tree. The effect is as if
1771 each option were listed in @code{AUTOMAKE_OPTIONS}.
1773 The second, deprecated, form of @code{AM_INIT_AUTOMAKE} has two required
1774 arguments: the package and the version number. This form is
1775 obsolete because the @var{package} and @var{version} can be obtained
1776 from Autoconf's @code{AC_INIT} macro (which itself has an old and a new
1779 If your @file{configure.ac} has:
1782 AM_INIT_AUTOMAKE(mumble, 1.5)
1784 you can modernize it as follows:
1786 AC_INIT(mumble, 1.5)
1787 AC_CONFIG_SRCDIR(src/foo.c)
1791 Note that if you're upgrading your @file{configure.ac} from an earlier
1792 version of Automake, it is not always correct to simply move the package
1793 and version arguments from @code{AM_INIT_AUTOMAKE} directly to
1794 @code{AC_INIT}, as in the example above. The first argument to
1795 @code{AC_INIT} should be the name of your package (e.g. @samp{GNU Automake}),
1796 not the tarball name (e.g. @samp{automake}) that you used to pass to
1797 @code{AM_INIT_AUTOMAKE}. Autoconf tries to derive a tarball name from
1798 the package name, which should work for most but not all package names.
1799 (If it doesn't work for yours, you can use the
1800 four-argument form of @code{AC_INIT} --- supported in Autoconf versions
1801 greater than 2.52g --- to provide the tarball name explicitly).
1803 By default this macro @code{AC_DEFINE}'s @samp{PACKAGE} and
1804 @samp{VERSION}. This can be avoided by passing the @samp{no-define}
1807 AM_INIT_AUTOMAKE([gnits 1.5 no-define dist-bzip2])
1809 or by passing a third non-empty argument to the obsolete form.
1811 @cvindex PACKAGE, prevent definition
1812 @cvindex VERSION, prevent definition
1815 @item AM_PATH_LISPDIR
1816 Searches for the program @code{emacs}, and, if found, sets the output
1817 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1819 Note that this test assumes the @code{emacs} found to be a version that
1820 supports Emacs Lisp (such as @sc{gnu} Emacs or XEmacs). Other emacsen
1821 can cause this test to hang (some, like old versions of MicroEmacs,
1822 start up in interactive mode, requiring @samp{C-x C-c} to exit, which
1823 is hardly obvious for a non-emacs user). In most cases, however, you
1824 should be able to use @samp{C-c} to kill the test. In order to avoid
1825 problems, you can set @code{EMACS} to ``no'' in the environment, or
1826 use the @samp{--with-lispdir} option to @command{configure} to
1827 explicitly set the correct path (if you're sure you have an @code{emacs}
1828 that supports Emacs Lisp.
1829 @cvindex AM_PATH_LISPDIR
1832 Use this macro when you have assembly code in your project. This will
1833 choose the assembler for you (by default the C compiler) and set
1834 @code{CCAS}, and will also set @code{CCASFLAGS} if required.
1836 @item AM_PROG_CC_C_O
1837 This is like @code{AC_PROG_CC_C_O}, but it generates its results in the
1838 manner required by automake. You must use this instead of
1839 @code{AC_PROG_CC_C_O} when you need this functionality.
1842 @cindex HP-UX 10, lex problems
1843 @cindex lex problems with HP-UX 10
1844 Like @code{AC_PROG_LEX} (@pxref{Particular Programs, , Particular
1845 Program Checks, autoconf, The Autoconf Manual}), but uses the
1846 @code{missing} script on systems that do not have @code{lex}.
1847 @samp{HP-UX 10} is one such system.
1850 This macro finds the @code{gcj} program or causes an error. It sets
1851 @samp{GCJ} and @samp{GCJFLAGS}. @code{gcj} is the Java front-end to the
1852 GNU Compiler Collection.
1853 @cvindex AM_PROG_GCJ
1855 @item AM_SYS_POSIX_TERMIOS
1856 @cvindex am_cv_sys_posix_termios
1857 @cindex POSIX termios headers
1858 @cindex termios POSIX headers
1859 Check to see if POSIX termios headers and functions are available on the
1860 system. If so, set the shell variable @code{am_cv_sys_posix_termios} to
1861 @samp{yes}. If not, set the variable to @samp{no}.
1863 @item AM_WITH_DMALLOC
1864 @cvindex WITH_DMALLOC
1865 @cindex dmalloc, support for
1866 @opindex --with-dmalloc
1868 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1869 package. If the user configures with @samp{--with-dmalloc}, then define
1870 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1874 @opindex --with-regex
1875 @cindex regex package
1877 Adds @samp{--with-regex} to the @code{configure} command line. If
1878 specified (the default), then the @samp{regex} regular expression
1879 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1880 @samp{WITH_REGEX} is defined. If @samp{--without-regex} is given, then
1881 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1882 into @samp{LIBOBJS}.
1886 @node Private macros
1887 @subsection Private macros
1889 The following macros are private macros you should not call directly.
1890 They are called by the other public macros when appropriate. Do not
1891 rely on them, as they might be changed in a future version. Consider
1892 them as implementation details; or better, do not consider them at all:
1896 @item _AM_DEPENDENCIES
1897 @itemx AM_SET_DEPDIR
1899 @itemx AM_OUTPUT_DEPENDENCY_COMMANDS
1900 These macros are used to implement Automake's automatic dependency
1901 tracking scheme. They are called automatically by automake when
1902 required, and there should be no need to invoke them manually.
1904 @item AM_MAKE_INCLUDE
1905 This macro is used to discover how the user's @code{make} handles
1906 @code{include} statements. This macro is automatically invoked when
1907 needed; there should be no need to invoke it manually.
1909 @item AM_PROG_INSTALL_STRIP
1910 This is used to find a version of @code{install} which can be used to
1911 @code{strip} a program at installation time. This macro is
1912 automatically included when required.
1914 @item AM_SANITY_CHECK
1915 This checks to make sure that a file created in the build directory is
1916 newer than a file in the source directory. This can fail on systems
1917 where the clock is set incorrectly. This macro is automatically run
1918 from @code{AM_INIT_AUTOMAKE}.
1923 @node Extending aclocal
1924 @section Writing your own aclocal macros
1926 @cindex aclocal, extending
1927 @cindex Extending aclocal
1929 The @command{aclocal} program doesn't have any built-in knowledge of any
1930 macros, so it is easy to extend it with your own macros.
1932 This can be used by libraries which want to supply their own Autoconf
1933 macros for use by other programs. For instance the @command{gettext}
1934 library supplies a macro @code{AM_GNU_GETTEXT} which should be used by
1935 any package using @command{gettext}. When the library is installed, it
1936 installs this macro so that @command{aclocal} will find it.
1938 A macro file's name should end in @file{.m4}. Such files should be
1939 installed in @file{$(datadir)/aclocal}. This is as simple as writing:
1942 aclocaldir = $(datadir)/aclocal
1943 aclocal_DATA = mymacro.m4 myothermacro.m4
1946 A file of macros should be a series of properly quoted
1947 @code{AC_DEFUN}'s (@pxref{Macro Definitions, , , autoconf, The
1948 Autoconf Manual}). The @command{aclocal} programs also understands
1949 @code{AC_REQUIRE} (@pxref{Prerequisite Macros, , , autoconf, The
1950 Autoconf Manual}), so it is safe to put each macro in a separate file.
1951 Each file should have no side effects but macro definitions.
1952 Especially, any call to @code{AC_PREREQ} should be done inside the
1953 defined macro, not at the beginning of the file.
1955 @cindex underquoted AC_DEFUN
1959 Starting with Automake 1.8, @command{aclocal} will warn about all
1960 underquoted calls to @code{AC_DEFUN}. We realize this will annoy a
1961 lot of people, because @command{aclocal} was not so strict in the past
1962 and many third party macros are underquoted; and we have to apologize
1963 for this temporary inconvenience. The reason we have to be stricter
1964 is that a future implementation of @command{aclocal} (@pxref{Future of
1965 aclocal}) will have to temporary include all these third party
1966 @file{.m4} files, maybe several times, even those which are not
1967 actually needed. Doing so should alleviate many problem of the
1968 current implementation, however it requires a stricter style from the
1969 macro authors. Hopefully it is easy to revise the existing macros.
1975 [AC_REQUIRE([AX_SOMETHING])dnl
1981 should be rewritten as
1983 AC_DEFUN([AX_FOOBAR],
1985 AC_REQUIRE([AX_SOMETHING])dnl
1991 Wrapping the @code{AC_PREREQ} call inside the macro ensures that
1992 Autoconf 2.57 will not be required if @code{AX_FOOBAR} is not actually
1993 used. Most importantly, quoting the first argument of @code{AC_DEFUN}
1994 allows the macro to be redefined or included twice (otherwise this
1995 first argument would be expansed during the second definition).
1997 If you have been directed here by the @command{aclocal} diagnostic but
1998 are not the maintainer of the implicated macro, you will want to
1999 contact the maintainer of that macro. Please make sure you have the
2000 last version of the macro and that the problem already hasn't been
2001 reported before doing so: people tend to work faster when they aren't
2004 Another situation where @command{aclocal} is commonly used is to
2005 manage macros which are used locally by the package, @ref{Local
2009 @section Handling Local Macros
2011 Feature tests offered by Autoconf do not cover all needs. People
2012 often have to supplement existing tests with their own macros, or
2013 with third-party macros.
2015 There are two ways to organize custom macros in a package.
2017 The first possibility (the historical practice) is to list all your
2018 macros in @file{acinclude.m4}. This file will be included in
2019 @file{aclocal.m4} when you run @command{aclocal}, and its macro(s) will
2020 henceforth be visible to @command{autoconf}. However if it contains
2021 numerous macros, it will rapidly become difficult to maintain, and it
2022 will be almost impossible to share macros between packages.
2024 @vindex ACLOCAL_AMFLAGS
2025 The second possibility, which we do recommend, is to write each macro
2026 in its own file and gather all these files in a directory. This
2027 directory is usually called @file{m4/}. To build @file{aclocal.m4},
2028 one should therefore instruct @command{aclocal} to scan @file{m4/}.
2029 From the command line, this is done with @code{aclocal -I m4}. The
2030 top-level @file{Makefile.am} should also be updated to define
2033 ACLOCAL_AMFLAGS = -I m4
2036 @code{ACLOCAL_AMFLAGS} contains options to pass to @command{aclocal}
2037 when @file{aclocal.m4} is to be rebuilt by @code{make}. This line is
2038 also used by @command{autoreconf} (@pxref{autoreconf Invocation, ,
2039 Using @command{autoreconf} to Update @file{configure} Scripts,
2040 autoconf, The Autoconf Manual}) to run @command{aclocal} with suitable
2041 options, or by @command{autopoint} (@pxref{autopoint Invocation, ,
2042 Invoking the @command{autopoint} Program, gettext, GNU gettext tools})
2043 and @command{gettextize} (@pxref{gettextize Invocation, , Invoking the
2044 @command{gettextize} Program, gettext, GNU gettext tools}) to locate
2045 the place where Gettext's macros should be installed. So even if you
2046 do not really care about the rebuild rules, you should define
2047 @code{ACLOCAL_AMFLAGS}.
2049 When @code{aclocal -I m4} is run, it will build a @code{aclocal.m4}
2050 that @code{m4_include}s any file from @file{m4/} that defines a
2051 required macro. Macros not found locally will still be searched in
2052 system-wide directories, as explained in @ref{Macro search path}.
2054 Custom macros should be distributed for the same reason that
2055 @file{configure.ac} is: so that other people have all the sources of
2056 your package if they want to work on it. Actually, this distribution
2057 happens automatically because all @code{m4_include}d files are
2060 However there is no consensus on the distribution of third-party
2061 macros that your package may use. Many libraries install their own
2062 macro in the system-wide @command{aclocal} directory (@pxref{Extending
2063 aclocal}). For instance Guile ships with a file called
2064 @file{guile.m4} that contains the macro @code{GUILE_FLAGS} which can
2065 be used to define setup compiler and linker flags appropriate for
2066 using Guile. Using @code{GUILE_FLAGS} in @file{configure.ac} will
2067 cause @command{aclocal} to copy @file{guile.m4} into
2068 @file{aclocal.m4}, but as @file{guile.m4} is not part of the project,
2069 it will not be distributed. Technically, that means a user which
2070 needs to rebuild @file{aclocal.m4} will have to install Guile first.
2071 This is probably OK, if Guile already is a requirement to build the
2072 package. However, if Guile is only an optional feature, or if your
2073 package might run on architectures where Guile cannot be installed,
2074 this requirement will hinder development. An easy solution is to copy
2075 such third-party macros in your local @file{m4/} directory so they get
2078 @node Future of aclocal
2079 @section The Future of @command{aclocal}
2080 @cindex aclocal's scheduled death
2082 @command{aclocal} is expected to disappear. This feature really
2083 should not be offered by Automake. Automake should focus on generating
2084 @file{Makefile}s; dealing with M4 macros really is Autoconf's job.
2085 That some people install Automake just to use @command{aclocal}, but
2086 do not use @command{automake} otherwise is an indication of how that
2087 feature is misplaced.
2089 The new implementation will probably be done slightly differently.
2090 For instance it could enforce the @file{m4/}-style layout discussed in
2091 @ref{Local Macros}, and take care of copying (and even updating)
2092 third-party macros from @file{/usr/share/aclocal/} into the local
2093 @file{m4/} directory.
2095 We have no idea when and how this will happen. This has been
2096 discussed several times in the past, but someone still has to commit
2097 itself to that non-trivial task.
2099 From the user point of view, @command{aclocal}'s removal might turn
2100 out to be painful. There is a simple precaution that you may take to
2101 make that switch more seamless: never call @command{aclocal} yourself.
2102 Keep this guy under the exclusive control of @command{autoreconf} and
2103 Automake's rebuild rules. Hopefully you won't need to worry about
2104 things breaking, when @command{aclocal} disappears, because everything
2105 will have been taken care of. If otherwise you used to call
2106 @command{aclocal} directly yourself or from some script, you will
2107 quickly notice the change.
2109 Many packages come with a script called @file{bootstrap.sh} or
2110 @file{autogen.sh}, that will just call @command{aclocal},
2111 @command{libtoolize}, @command{gettextize} or @command{autopoint},
2112 @command{autoconf}, @command{autoheader}, and @command{automake} in
2113 the right order. Actually this is precisely what @command{autoreconf}
2114 can do for you. If your package has such a @file{bootstrap.sh} or
2115 @file{autogen.sh} script, consider using @command{autoreconf}. That
2116 should simplify its logic a lot (less things to maintain, yum!), it's
2117 even likely you will not need the script anymore, and more to the point
2118 you will not call @command{aclocal} directly anymore.
2120 For the time being, third-party packages should continue to install
2121 public macros into @code{/usr/share/aclocal/}. If @command{aclocal}
2122 is replaced by another tool it might make sense to rename the
2123 directory, but supporting @code{/usr/share/aclocal/} for backward
2124 compatibility should be really easy provided all macros are properly
2125 written (@pxref{Extending aclocal}).
2129 @chapter The top-level @file{Makefile.am}
2131 @section Recursing subdirectories
2133 @cindex SUBDIRS, explained
2135 In packages with subdirectories, the top level @file{Makefile.am} must
2136 tell Automake which subdirectories are to be built. This is done via
2137 the @code{SUBDIRS} variable.
2140 The @code{SUBDIRS} variable holds a list of subdirectories in which
2141 building of various sorts can occur. The rules for many targets
2142 (e.g. @code{all}) in the generated @file{Makefile} will run commands
2143 both locally and in all specified subdirectories. Note that the
2144 directories listed in @code{SUBDIRS} are not required to contain
2145 @file{Makefile.am}s; only @file{Makefile}s (after configuration).
2146 This allows inclusion of libraries from packages which do not use
2147 Automake (such as @code{gettext}).
2149 In packages that use subdirectories, the top-level @file{Makefile.am} is
2150 often very short. For instance, here is the @file{Makefile.am} from the
2151 GNU Hello distribution:
2154 EXTRA_DIST = BUGS ChangeLog.O README-alpha
2155 SUBDIRS = doc intl po src tests
2158 When Automake invokes @code{make} in a subdirectory, it uses the value
2159 of the @code{MAKE} variable. It passes the value of the variable
2160 @code{AM_MAKEFLAGS} to the @code{make} invocation; this can be set in
2161 @file{Makefile.am} if there are flags you must always pass to
2166 The directories mentioned in @code{SUBDIRS} must be direct children of
2167 the current directory. For instance, you cannot put @samp{src/subdir}
2168 into @code{SUBDIRS}. Instead you should put @code{SUBDIRS = subdir}
2169 into @file{src/Makefile.am}. Automake can be used to construct packages
2170 of arbitrary depth this way.
2172 By default, Automake generates @file{Makefiles} which work depth-first
2173 (@samp{postfix}). However, it is possible to change this ordering.
2174 You can do this by putting @samp{.} into @code{SUBDIRS}. For
2175 instance, putting @samp{.} first will cause a @samp{prefix} ordering
2176 of directories. All @samp{clean} rules are run in reverse
2177 order of build rules.
2179 @section Conditional subdirectories
2180 @cindex Subdirectories, building conditionally
2181 @cindex Conditional subdirectories
2182 @cindex @code{SUBDIRS}, conditional
2183 @cindex Conditional @code{SUBDIRS}
2185 It is possible to define the @code{SUBDIRS} variable conditionally if,
2186 like in the case of GNU @code{Inetutils}, you want to only build a
2187 subset of the entire package.
2189 To illustrate how this works, let's assume we have two directories
2190 @file{src/} and @file{opt/}. @file{src/} should always be built, but we
2191 want to decide in @code{./configure} whether @file{opt/} will be built
2192 or not. (For this example we will assume that @file{opt/} should be
2193 built when the variable @code{$want_opt} was set to @code{yes}.)
2195 Running @code{make} should thus recurse into @file{src/} always, and
2196 then maybe in @file{opt/}.
2198 However @code{make dist} should always recurse into both @file{src/} and
2199 @file{opt/}. Because @file{opt/} should be distributed even if it is
2200 not needed in the current configuration. This means @file{opt/Makefile}
2201 should be created unconditionally. @footnote{Don't try seeking a
2202 solution where @file{opt/Makefile} is created conditionally, this is a
2203 lot trickier than the solutions presented here.}
2205 There are two ways to setup a project like this. You can use Automake
2206 conditionals (@pxref{Conditionals}) or use Autoconf @code{AC_SUBST}
2207 variables (@pxref{Setting Output Variables, , Setting Output Variables,
2208 autoconf, The Autoconf Manual}). Using Automake conditionals is the
2211 @subsection Conditional subdirectories with @code{AM_CONDITIONAL}
2212 @cindex @code{SUBDIRS} and @code{AM_CONDITIONAL}
2213 @cindex @code{AM_CONDITIONAL} and @code{SUBDIRS}
2215 @c The test case for the setup described here is
2216 @c test/subdircond2.test
2217 @c Try to keep it in sync.
2219 @file{configure} should output the @file{Makefile} for each directory
2220 and define a condition into which @file{opt/} should be built.
2224 AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
2225 AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
2229 Then @code{SUBDIRS} can be defined in the top-level @file{Makefile.am}
2236 SUBDIRS = src $(MAYBE_OPT)
2239 As you can see, running @code{make} will rightly recurse into
2240 @file{src/} and maybe @file{opt/}.
2242 @vindex DIST_SUBDIRS
2243 As you can't see, running @code{make dist} will recurse into both
2244 @file{src/} and @file{opt/} directories because @code{make dist}, unlike
2245 @code{make all}, doesn't use the @code{SUBDIRS} variable. It uses the
2246 @code{DIST_SUBDIRS} variable.
2248 In this case Automake will define @code{DIST_SUBDIRS = src opt}
2249 automatically because it knows that @code{MAYBE_OPT} can contain
2250 @code{opt} in some condition.
2252 @subsection Conditional subdirectories with @code{AC_SUBST}
2253 @cindex @code{SUBDIRS} and @code{AC_SUBST}
2254 @cindex @code{AC_SUBST} and @code{SUBDIRS}
2256 @c The test case for the setup described here is
2257 @c test/subdircond3.test
2258 @c Try to keep it in sync.
2260 Another idea is to define @code{MAYBE_OPT} from @file{./configure} using
2265 if test "$want_opt" = yes; then
2270 AC_SUBST([MAYBE_OPT])
2271 AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
2275 In this case the top-level @file{Makefile.am} should look as follows.
2278 SUBDIRS = src $(MAYBE_OPT)
2279 DIST_SUBDIRS = src opt
2282 The drawback is that since Automake cannot guess what the possible
2283 values of @code{MAYBE_OPT} are, it is necessary to define
2284 @code{DIST_SUBDIRS}.
2286 @subsection How @code{DIST_SUBDIRS} is used
2287 @cindex @code{DIST_SUBDIRS}, explained
2289 As shown in the above examples, @code{DIST_SUBDIRS} is used in rules
2290 that need to recurse in all directories, even those which have been
2291 conditionally left out of the build.
2293 Precisely, @code{DIST_SUBDIRS} is used by @code{make dist}, @code{make
2294 distclean}, and @code{make maintainer-clean}. All other recursive
2295 rules use @code{SUBDIRS}.
2297 Automake will define @code{DIST_SUBDIRS} automatically from the
2298 possibles values of @code{SUBDIRS} in all conditions.
2300 If @code{SUBDIRS} contains @code{AC_SUBST} variables,
2301 @code{DIST_SUBDIRS} will not be defined correctly because Automake
2302 doesn't know the possible values of these variables. In this case
2303 @code{DIST_SUBDIRS} needs to be defined manually.
2307 @chapter An Alternative Approach to Subdirectories
2309 If you've ever read Peter Miller's excellent paper,
2310 @uref{http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html,
2311 Recursive Make Considered Harmful}, the preceding section on the use of
2312 subdirectories will probably come as unwelcome advice. For those who
2313 haven't read the paper, Miller's main thesis is that recursive
2314 @code{make} invocations are both slow and error-prone.
2316 Automake provides sufficient cross-directory support @footnote{We
2317 believe. This work is new and there are probably warts.
2318 @xref{Introduction}, for information on reporting bugs.} to enable you
2319 to write a single @file{Makefile.am} for a complex multi-directory
2323 By default an installable file specified in a subdirectory will have its
2324 directory name stripped before installation. For instance, in this
2325 example, the header file will be installed as
2326 @file{$(includedir)/stdio.h}:
2329 include_HEADERS = inc/stdio.h
2333 @cindex Path stripping, avoiding
2334 @cindex Avoiding path stripping
2336 However, the @samp{nobase_} prefix can be used to circumvent this path
2337 stripping. In this example, the header file will be installed as
2338 @file{$(includedir)/sys/types.h}:
2341 nobase_include_HEADERS = sys/types.h
2344 @cindex nobase_ and dist_ or nodist_
2345 @cindex dist_ and nobase_
2346 @cindex nodist_ and nobase_
2348 @samp{nobase_} should be specified first when used in conjunction with
2349 either @samp{dist_} or @samp{nodist_} (@pxref{Dist}). For instance:
2352 nobase_dist_pkgdata_DATA = images/vortex.pgm
2356 @chapter Building Programs and Libraries
2358 A large part of Automake's functionality is dedicated to making it easy
2359 to build programs and libraries.
2362 * A Program:: Building a program
2363 * A Library:: Building a library
2364 * A Shared Library:: Building a Libtool library
2365 * Program and Library Variables:: Variables controlling program and
2367 * Default _SOURCES:: Default source files
2368 * LIBOBJS:: Special handling for LIBOBJS and ALLOCA
2369 * Program variables:: Variables used when building a program
2370 * Yacc and Lex:: Yacc and Lex support
2371 * C++ Support:: Compiling C++ sources
2372 * Assembly Support:: Compiling assembly sources
2373 * Fortran 77 Support:: Compiling Fortran 77 sources
2374 * Java Support:: Compiling Java sources
2375 * Support for Other Languages:: Compiling other languages
2376 * ANSI:: Automatic de-ANSI-fication
2377 * Dependencies:: Automatic dependency tracking
2378 * EXEEXT:: Support for executable extensions
2383 @section Building a program
2385 In order to build a program, you need to tell Automake which sources
2386 are part of it, and which libraries it should be linked with.
2388 This section also covers conditional compilation of sources or
2389 programs. Most of the comments about these also apply to libraries
2390 (@pxref{A Library}) and libtool libraries (@pxref{A Shared Library}).
2393 * Program Sources:: Defining program sources
2394 * Linking:: Linking with libraries or extra objects
2395 * Conditional Sources:: Handling conditional sources
2396 * Conditional Programs:: Building program conditionally
2399 @node Program Sources
2400 @subsection Defining program sources
2402 @cindex PROGRAMS, bindir
2403 @vindex bin_PROGRAMS
2404 @vindex sbin_PROGRAMS
2405 @vindex libexec_PROGRAMS
2406 @vindex pkglib_PROGRAMS
2407 @vindex noinst_PROGRAMS
2408 @vindex check_PROGRAMS
2410 In a directory containing source that gets built into a program (as
2411 opposed to a library or a script), the @samp{PROGRAMS} primary is used.
2412 Programs can be installed in @code{bindir}, @code{sbindir},
2413 @code{libexecdir}, @code{pkglibdir}, or not at all (@samp{noinst}).
2414 They can also be built only for @code{make check}, in which case the
2415 prefix is @samp{check}.
2420 bin_PROGRAMS = hello
2423 In this simple case, the resulting @file{Makefile.in} will contain code
2424 to generate a program named @code{hello}.
2426 Associated with each program are several assisting variables which are
2427 named after the program. These variables are all optional, and have
2428 reasonable defaults. Each variable, its use, and default is spelled out
2429 below; we use the ``hello'' example throughout.
2431 The variable @code{hello_SOURCES} is used to specify which source files
2432 get built into an executable:
2435 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
2438 This causes each mentioned @samp{.c} file to be compiled into the
2439 corresponding @samp{.o}. Then all are linked to produce @file{hello}.
2441 @cindex _SOURCES primary, defined
2442 @cindex SOURCES primary, defined
2443 @cindex Primary variable, SOURCES
2445 If @samp{hello_SOURCES} is not specified, then it defaults to the single
2446 file @file{hello.c} (@pxref{Default _SOURCES}).
2450 Multiple programs can be built in a single directory. Multiple programs
2451 can share a single source file, which must be listed in each
2452 @samp{_SOURCES} definition.
2454 @cindex Header files in _SOURCES
2455 @cindex _SOURCES and header files
2457 Header files listed in a @samp{_SOURCES} definition will be included in
2458 the distribution but otherwise ignored. In case it isn't obvious, you
2459 should not include the header file generated by @file{configure} in a
2460 @samp{_SOURCES} variable; this file should not be distributed. Lex
2461 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
2466 @subsection Linking the program
2468 If you need to link against libraries that are not found by
2469 @code{configure}, you can use @code{LDADD} to do so. This variable is
2470 used to specify additional objects or libraries to link with; it is
2471 inappropriate for specifying specific linker flags, you should use
2472 @code{AM_LDFLAGS} for this purpose.
2476 @cindex prog_LDADD, defined
2478 Sometimes, multiple programs are built in one directory but do not share
2479 the same link-time requirements. In this case, you can use the
2480 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
2481 program as it appears in some @samp{_PROGRAMS} variable, and usually
2482 written in lowercase) to override the global @code{LDADD}. If this
2483 variable exists for a given program, then that program is not linked
2487 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
2488 linked against the library @file{libcpio.a}. However, @code{rmt} is
2489 built in the same directory, and has no such link requirement. Also,
2490 @code{mt} and @code{rmt} are only built on certain architectures. Here
2491 is what cpio's @file{src/Makefile.am} looks like (abridged):
2494 bin_PROGRAMS = cpio pax $(MT)
2495 libexec_PROGRAMS = $(RMT)
2496 EXTRA_PROGRAMS = mt rmt
2498 LDADD = ../lib/libcpio.a $(INTLLIBS)
2501 cpio_SOURCES = @dots{}
2502 pax_SOURCES = @dots{}
2503 mt_SOURCES = @dots{}
2504 rmt_SOURCES = @dots{}
2507 @cindex _LDFLAGS, defined
2509 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
2510 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
2511 @samp{-dlpreopen}). So, use the @samp{@var{prog}_LDFLAGS} variable for
2515 @cindex _DEPENDENCIES, defined
2517 It is also occasionally useful to have a program depend on some other
2518 target which is not actually part of that program. This can be done
2519 using the @samp{@var{prog}_DEPENDENCIES} variable. Each program depends
2520 on the contents of such a variable, but no further interpretation is
2523 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
2524 Automake. The automatically-assigned value is the contents of
2525 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
2526 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed. The
2527 configure substitutions that are left in are only @samp{$(LIBOBJS)} and
2528 @samp{$(ALLOCA)}; these are left because it is known that they will not
2529 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
2533 @node Conditional Sources
2534 @subsection Conditional compilation of sources
2536 You can't put a configure substitution (e.g., @samp{@@FOO@@} or
2537 @samp{$(FOO)} where @code{FOO} is defined via @code{AC_SUBST}) into a
2538 @samp{_SOURCES} variable. The reason for this is a bit hard to
2539 explain, but suffice to say that it simply won't work. Automake will
2540 give an error if you try to do this.
2542 Fortunately there are two other ways to achieve the same result. One is
2543 to use configure substitutions in @code{_LDADD} variables, the other is
2544 to use an Automake conditional.
2546 @subsubsection Conditional compilation using @code{_LDADD} substitutions
2548 @cindex EXTRA_prog_SOURCES, defined
2550 Automake must know all the source files that could possibly go into a
2551 program, even if not all the files are built in every circumstance. Any
2552 files which are only conditionally built should be listed in the
2553 appropriate @samp{EXTRA_} variable. For instance, if
2554 @file{hello-linux.c} or @file{hello-generic.c} were conditionally included
2555 in @code{hello}, the @file{Makefile.am} would contain:
2558 bin_PROGRAMS = hello
2559 hello_SOURCES = hello-common.c
2560 EXTRA_hello_SOURCES = hello-linux.c hello-generic.c
2561 hello_LDADD = $(HELLO_SYSTEM)
2562 hello_DEPENDENCIES = $(HELLO_SYSTEM)
2566 You can then setup the @code{$(HELLO_SYSTEM)} substitution from
2567 @file{configure.ac}:
2572 *linux*) HELLO_SYSTEM='hello-linux.$(OBJEXT)' ;;
2573 *) HELLO_SYSTEM='hello-generic.$(OBJEXT)' ;;
2575 AC_SUBST([HELLO_SYSTEM])
2579 In this case, @code{HELLO_SYSTEM} should be replaced by
2580 @file{hello-linux.o} or @file{hello-generic.o}, and added to
2581 @code{hello_DEPENDENCIES} and @code{hello_LDADD} in order to be built
2584 @subsubsection Conditional compilation using Automake conditionals
2586 An often simpler way to compile source files conditionally is to use
2587 Automake conditionals. For instance, you could use this
2588 @file{Makefile.am} construct to build the same @file{hello} example:
2591 bin_PROGRAMS = hello
2593 hello_SOURCES = hello-linux.c hello-common.c
2595 hello_SOURCES = hello-generic.c hello-common.c
2599 In this case, your @file{configure.ac} should setup the @code{LINUX}
2600 conditional using @code{AM_CONDITIONAL} (@pxref{Conditionals}).
2602 When using conditionals like this you don't need to use the
2603 @samp{EXTRA_} variable, because Automake will examine the contents of
2604 each variable to construct the complete list of source files.
2606 If your program uses a lot of files, you will probably prefer a
2607 conditional @code{+=}.
2610 bin_PROGRAMS = hello
2611 hello_SOURCES = hello-common.c
2613 hello_SOURCES += hello-linux.c
2615 hello_SOURCES += hello-generic.c
2619 @node Conditional Programs
2620 @subsection Conditional compilation of programs
2621 @cindex Conditional programs
2622 @cindex Programs, conditional
2624 Sometimes it is useful to determine the programs that are to be built
2625 at configure time. For instance, GNU @code{cpio} only builds
2626 @code{mt} and @code{rmt} under special circumstances. The means to
2627 achieve conditional compilation of programs are the same you can use
2628 to compile source files conditionally: substitutions or conditionals.
2630 @subsubsection Conditional programs using @code{configure} substitutions
2632 In this case, you must notify Automake of all the programs that can
2633 possibly be built, but at the same time cause the generated
2634 @file{Makefile.in} to use the programs specified by @code{configure}.
2635 This is done by having @code{configure} substitute values into each
2636 @samp{_PROGRAMS} definition, while listing all optionally built programs
2637 in @code{EXTRA_PROGRAMS}.
2638 @vindex EXTRA_PROGRAMS
2639 @cindex EXTRA_PROGRAMS, defined
2642 bin_PROGRAMS = cpio pax $(MT)
2643 libexec_PROGRAMS = $(RMT)
2644 EXTRA_PROGRAMS = mt rmt
2647 As explained in @ref{EXEEXT}, Automake will rewrite
2648 @code{bin_PROGRAMS}, @code{libexec_PROGRAMS}, and
2649 @code{EXTRA_PROGRAMS}, appending @code{$(EXEEXT)} to each binary.
2650 Obviously it cannot rewrite values obtained at run-time through
2651 @code{configure} substitutions, therefore you should take care of
2652 appending @code{$(EXEEXT)} yourself, as in @code{AC_SUBST([MT],
2653 ['mt$@{EXEEXT@}'])}.
2655 @subsubsection Conditional programs using Automake conditionals
2657 You can also use Automake conditionals (@pxref{Conditionals}) to
2658 select programs to be built. In this case you don't have to worry
2659 about @code{$(EXEEXT)} or @code{EXTRA_PROGRAMS}.
2662 bin_PROGRAMS = cpio pax
2667 libexec_PROGRAMS = rmt
2673 @section Building a library
2675 @cindex _LIBRARIES primary, defined
2676 @cindex LIBRARIES primary, defined
2677 @cindex Primary variable, LIBRARIES
2679 @vindex lib_LIBRARIES
2680 @vindex pkglib_LIBRARIES
2681 @vindex noinst_LIBRARIES
2683 Building a library is much like building a program. In this case, the
2684 name of the primary is @samp{LIBRARIES}. Libraries can be installed in
2685 @code{libdir} or @code{pkglibdir}.
2687 @xref{A Shared Library}, for information on how to build shared
2688 libraries using libtool and the @samp{LTLIBRARIES} primary.
2690 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
2691 For instance to create a library named @file{libcpio.a}, but not install
2692 it, you would write:
2695 noinst_LIBRARIES = libcpio.a
2698 The sources that go into a library are determined exactly as they are
2699 for programs, via the @samp{_SOURCES} variables. Note that the library
2700 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
2701 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
2702 not @samp{liblob.a_SOURCES}.
2704 @cindex _LIBADD primary, defined
2705 @cindex LIBADD primary, defined
2706 @cindex Primary variable, LIBADD
2708 Extra objects can be added to a library using the
2709 @samp{@var{library}_LIBADD} variable. This should be used for objects
2710 determined by @code{configure}. Again from @code{cpio}:
2715 libcpio_a_LIBADD = $(LIBOBJS) $(ALLOCA)
2718 In addition, sources for extra objects that will not exist until
2719 configure-time must be added to the @code{BUILT_SOURCES} variable
2722 Building a static library is done by compiling all object files, then
2723 by invoking @code{$(AR) $(ARFLAGS)} followed by the name of the
2724 library and the list of objects, and finally by calling
2725 @code{$(RANLIB)} on that library. You should call
2726 @code{AC_PROG_RANLIB} from your @file{configure.ac} to define
2727 @code{RANLIB} (Automake will complain otherwise). @code{AR} and
2728 @code{ARFLAGS} default to @code{ar} and @code{cru} respectively; you
2729 can override these two variables my setting them in your
2730 @file{Makefile.am}, by @code{AC_SUBST}ing them from your
2731 @file{configure.ac}, or by defining a per-library @code{maude_AR}
2732 variable (@pxref{Program and Library Variables}).
2734 @node A Shared Library
2735 @section Building a Shared Library
2737 @cindex Shared libraries, support for
2739 Building shared libraries portably is a relatively complex matter.
2740 For this reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
2741 Libtool Manual}) was created to help build shared libraries in a
2742 platform-independent way.
2745 * Libtool Concept:: Introducing Libtool
2746 * Libtool Libraries:: Declaring Libtool Libraries
2747 * Conditional Libtool Libraries:: Building Libtool Libraries Conditionally
2748 * Conditional Libtool Sources:: Choosing Library Sources Conditionally
2749 * Libtool Convenience Libraries:: Building Convenience Libtool Libraries
2750 * Libtool Modules:: Building Libtool Modules
2751 * Libtool Flags:: Using _LIBADD and _LDFLAGS
2752 * LTLIBOBJ:: Using $(LTLIBOBJ)
2753 * Libtool Issues:: Common Issues Related to Libtool's Use
2756 @node Libtool Concept
2757 @subsection The Libtool Concept
2759 @cindex libtool, introduction
2760 @cindex libtool library, definition
2761 @cindex suffix .la, defined
2762 @cindex .la suffix, defined
2764 Libtool abstracts shared and static libraries into a unified
2765 concept henceforth called @dfn{libtool libraries}. Libtool libraries
2766 are files using the @file{.la} suffix, and can designate a static
2767 library, a shared library, or maybe both. Their exact nature cannot
2768 be determined until @file{./configure} is run: not all platforms
2769 support all kinds of libraries, and users can explicitly select which
2770 libraries should be built. (However the package's maintainers can
2771 tune the default, @xref{AC_PROG_LIBTOOL, , The @code{AC_PROG_LIBTOOL}
2772 macro, libtool, The Libtool Manual}.)
2774 @cindex suffix .lo, defined
2775 Because object files for shared and static libraries must be compiled
2776 differently, libtool is also used during compilation. Object files
2777 built by libtool are called @dfn{libtool objects}: these are files
2778 using the @file{.lo} suffix. Libtool libraries are built from these
2781 You should not assume anything about the structure of @file{.la} or
2782 @file{.lo} files and how libtool constructs them: this is libtool's
2783 concern, and the last thing one wants is to learn about libtool's
2784 guts. However the existence of these files matters, because they are
2785 used as targets and dependencies in @file{Makefile}s rules when
2786 building libtool libraries. There are situations where you may have
2787 to refer to these, for instance when expressing dependencies for
2788 building source files conditionally (@pxref{Conditional Libtool
2791 @cindex libltdl, introduction
2793 People considering writing a plug-in system, with dynamically loaded
2794 modules, should look into @file{libltdl}: libtool's dlopening library
2795 (@pxref{Using libltdl, , Using libltdl, libtool, The Libtool Manual}).
2796 This offers a portable dlopening facility to load libtool libraries
2797 dynamically, and can also achieve static linking where unavoidable.
2799 Before we discuss how to use libtool with Automake in details, it
2800 should be noted that the libtool manual also has a section about how
2801 to use Automake with libtool (@pxref{Using Automake, , Using Automake
2802 with Libtool, libtool, The Libtool Manual}).
2804 @node Libtool Libraries
2805 @subsection Building Libtool Libraries
2807 @cindex _LTLIBRARIES primary, defined
2808 @cindex LTLIBRARIES primary, defined
2809 @cindex Primary variable, LTLIBRARIES
2810 @cindex Example of shared libraries
2811 @vindex lib_LTLIBRARIES
2812 @vindex pkglib_LTLIBRARIES
2814 Automake uses libtool to build libraries declared with the
2815 @samp{LTLIBRARIES} primary. Each @samp{_LTLIBRARIES} variable is a
2816 list of libtool libraries to build. For instance, to create a libtool
2817 library named @file{libgettext.la}, and install it in @samp{libdir},
2821 lib_LTLIBRARIES = libgettext.la
2822 libgettext_la_SOURCES = gettext.c gettext.h @dots{}
2825 Automake predefines the variable @samp{pkglibdir}, so you can use
2826 @code{pkglib_LTLIBRARIES} to install libraries in
2827 @code{$(libdir)/@@PACKAGE@@/}.
2829 @node Conditional Libtool Libraries
2830 @subsection Building Libtool Libraries Conditionally
2831 @cindex libtool libraries, conditional
2832 @cindex conditional libtool libraries
2834 Like conditional programs (@pxref{Conditional Programs}), there are
2835 two main ways to build conditional libraries: using Automake
2836 conditionals or using Autoconf @code{AC_SUBST}itutions.
2838 The important implementation detail you have to be aware of is that
2839 the place where a library will be installed matters to libtool: it
2840 needs to be indicated @emph{at link-time} using the @code{-rpath}
2843 For libraries whose destination directory is known when Automake runs,
2844 Automake will automatically supply the appropriate @samp{-rpath}
2845 option to libtool. This is the case for libraries listed explicitly in
2846 some installable @code{_LTLIBRARIES} variables such as
2847 @code{lib_LTLIBRARIES}.
2849 However, for libraries determined at configure time (and thus
2850 mentioned in @code{EXTRA_LTLIBRARIES}), Automake does not know the
2851 final installation directory. For such libraries you must add the
2852 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
2855 The examples below illustrate the differences between these two methods.
2857 Here is an example where @code{$(WANTEDLIBS)} is an @code{AC_SUBST}ed
2858 variable set at @file{./configure}-time to either @file{libfoo.la},
2859 @file{libbar.la}, both, or none. Although @code{$(WANTEDLIBS)}
2860 appears in the @code{lib_LTLIBRARIES}, Automake cannot guess it
2861 relates to @file{libfoo.la} or @file{libbar.la} by the time it creates
2862 the link rule for these two libraries. Therefore the @code{-rpath}
2863 argument must be explicitly supplied.
2866 EXTRA_LTLIBRARIES = libfoo.la libbar.la
2867 lib_LTLIBRARIES = $(WANTEDLIBS)
2868 libfoo_la_SOURCES = foo.c @dots{}
2869 libfoo_la_LDFLAGS = -rpath '$(libdir)'
2870 libbar_la_SOURCES = bar.c @dots{}
2871 libbar_la_LDFLAGS = -rpath '$(libdir)'
2874 Here is how the same @file{Makefile.am} would look using Automake
2875 conditionals named @code{WANT_LIBFOO} and @code{WANT_LIBBAR}. Now
2876 Automake is able to compute the @code{-rpath} setting itself, because
2877 it's clear that both libraries will end up in @code{$(libdir)} if they
2883 lib_LTLIBRARIES += libfoo.la
2886 lib_LTLIBRARIES += libbar.la
2888 libfoo_la_SOURCES = foo.c @dots{}
2889 libbar_la_SOURCES = bar.c @dots{}
2892 @node Conditional Libtool Sources
2893 @subsection Libtool Libraries with Conditional Sources
2895 Conditional compilation of sources in a library can be achieved in the
2896 same way as conditional compilation of sources in a program
2897 (@pxref{Conditional Sources}). The only difference is that
2898 @code{_LIBADD} should be used instead of @code{_LDADD} and that it
2899 should mention libtool objects (@file{.lo} files).
2901 So, to mimic the @file{hello} example from @ref{Conditional Sources},
2902 we could build a @file{libhello.la} library using either
2903 @file{hello-linux.c} or @file{hello-generic.c} with the following
2907 lib_LTLIBRARIES = libhello.la
2908 libhello_la_SOURCES = hello-common.c
2909 EXTRA_libhello_la_SOURCES = hello-linux.c hello-generic.c
2910 libhello_la_LIBADD = $(HELLO_SYSTEM)
2911 libhello_la_DEPENDENCIES = $(HELLO_SYSTEM)
2915 And make sure @code{$(HELLO_SYSTEM)} is set to either
2916 @file{hello-linux.lo} or @file{hello-generic.lo} in
2919 Or we could simply use an Automake conditional as follows.
2922 lib_LTLIBRARIES = libhello.la
2923 libhello_la_SOURCES = hello-common.c
2925 libhello_la_SOURCES += hello-linux.c
2927 libhello_la_SOURCES += hello-generic.c
2931 @node Libtool Convenience Libraries
2932 @subsection Libtool Convenience Libraries
2933 @cindex convenience libraries, libtool
2934 @cindex libtool convenience libraries
2935 @vindex noinst_LTLIBRARIES
2936 @vindex check_LTLIBRARIES
2938 Sometimes you want to build libtool libraries which should not be
2939 installed. These are called @dfn{libtool convenience libraries} and
2940 are typically used to encapsulate many sublibraries, later gathered
2941 into one big installed library.
2943 Libtool convenience libraries are declared by
2944 @code{noinst_LTLIBRARIES}, @code{check_LTLIBRARIES}, or even
2945 @code{EXTRA_LTLIBRARIES}. Unlike installed libtool libraries they do
2946 not need an @code{-rpath} flag at link time (actually this is the only
2949 Convenience libraries listed in @code{noinst_LTLIBRARIES} are always
2950 built. Those listed in @code{check_LTLIBRARIES} are built only upon
2951 @code{make check}. Finally, libraries listed in
2952 @code{EXTRA_LTLIBRARIES} are never built explicitly: Automake outputs
2953 rules to build them, but if the library does not appear as a Makefile
2954 dependency anywhere it won't be built (this is why
2955 @code{EXTRA_LTLIBRARIES} is used for conditional compilation).
2957 Here is a sample setup merging libtool convenience libraries from
2958 subdirectories into one main @file{libtop.la} library.
2961 # -- Top-level Makefile.am --
2962 SUBDIRS = sub1 sub2 @dots{}
2963 lib_LTLIBRARIES = libtop.la
2965 libtop_la_LIBADD = \
2970 # -- sub1/Makefile.am --
2971 noinst_LTLIBRARIES = libsub1.la
2972 libsub1_la_SOURCES = @dots{}
2974 # -- sub2/Makefile.am --
2975 # showing nested convenience libraries
2976 SUBDIRS = sub2.1 sub2.2 @dots{}
2977 noinst_LTLIBRARIES = libsub2.la
2978 libsub2_la_SOURCES =
2979 libsub2_la_LIBADD = \
2985 @node Libtool Modules
2986 @subsection Libtool Modules
2987 @cindex modules, libtool
2988 @cindex libtool modules
2989 @cindex -module, libtool
2991 These are libtool libraries meant to be dlopened. They are
2992 indicated to libtool by passing @code{-module} at link-time.
2995 pkglib_LTLIBRARIES = mymodule.la
2996 mymodule_la_SOURCES = doit.c
2997 mymodule_LDFLAGS = -module
3000 Ordinarily, Automake requires that a Library's name starts with
3001 @samp{lib}. However, when building a dynamically loadable module you
3002 might wish to use a "nonstandard" name.
3004 If @samp{mymodule_la_SOURCES} is not specified, then it defaults to the single
3005 file @file{mymodule.c} (@pxref{Default _SOURCES}).
3008 @subsection _LIBADD and _LDFLAGS
3009 @cindex _LIBADD, libtool
3010 @cindex _LDFLAGS, libtool
3012 As shown in previous sections, the @samp{@var{library}_LIBADD}
3013 variable should be used to list extra libtool objects (@file{.lo}
3014 files) or libtool libraries (@file{.la}) to add to @var{library}.
3016 The @samp{@var{library}_LDFLAGS} variable is the place to list
3017 additional libtool flags, such as @samp{-version-info},
3018 @samp{-static}, and a lot more. See @xref{Link mode, , Using libltdl,
3019 libtool, The Libtool Manual}.
3021 @node LTLIBOBJ, Libtool Issues, Libtool Flags, A Shared Library
3022 @subsection @code{LTLIBOBJS}
3023 @cindex @code{LTLIBOBJS}, special handling
3028 Where an ordinary library might include @code{$(LIBOBJS)}, a libtool
3029 library must use @code{$(LTLIBOBJS)}. This is required because the
3030 object files that libtool operates on do not necessarily end in
3033 Nowadays, the computation of @code{LTLIBOBJS} from @code{LIBOBJS} is
3034 performed automatically by Autoconf (@pxref{AC_LIBOBJ vs LIBOBJS, ,
3035 @code{AC_LIBOBJ} vs. @code{LIBOBJS}, autoconf, The Autoconf Manual}).
3037 @node Libtool Issues
3038 @subsection Common Issues Related to Libtool's Use
3040 @subsubsection @code{required file `./ltmain.sh' not found}
3041 @cindex ltmain.sh not found
3042 @cindex libtoolize, no longer run by Automake
3043 @cindex libtoolize and autoreconf
3044 @cindex autoreconf and libtoolize
3045 @cindex bootstrap.sh and autoreconf
3046 @cindex autogen.sh and autoreconf
3048 Libtool comes with a tool called @command{libtoolize} that will
3049 install libtool's supporting files into a package. Running this
3050 command will install @file{ltmain.sh}. You should execute it before
3051 @command{aclocal} and @command{automake}.
3053 People upgrading old packages to newer autotools are likely to face
3054 this issue because older Automake versions used to call
3055 @command{libtoolize}. Therefore old build scripts do not call
3056 @command{libtoolize}.
3058 Since Automake 1.6, it has been decided that running
3059 @command{libtoolize} was none of Automake's business. Instead, that
3060 functionality has been moved into the @command{autoreconf} command
3061 (@pxref{autoreconf Invocation, , Using @command{autoreconf}, autoconf,
3062 The Autoconf Manual}). If you do not want to remember what to run and
3063 when, just learn the @command{autoreconf} command. Hopefully,
3064 replacing existing @file{bootstrap.sh} or @file{autogen.sh} scripts by
3065 a call to @command{autoreconf} should also free you from any similar
3066 incompatible change in the future.
3068 @subsubsection Objects @code{created with both libtool and without}
3070 Sometimes, the same source file is used both to build a libtool
3071 library and to build another non-libtool target (be it a program or
3074 Let's consider the following @file{Makefile.am}.
3078 prog_SOURCES = prog.c foo.c @dots{}
3080 lib_LTLIBRARIES = libfoo.la
3081 libfoo_la_SOURCES = foo.c @dots{}
3085 (In this trivial case the issue could be avoided by linking
3086 @file{libfoo.la} with @file{prog} instead of listing @file{foo.c} in
3087 @code{prog_SOURCES}. But let's assume we really want to keep
3088 @file{prog} and @file{libfoo.la} separate.)
3090 Technically, it means that we should build @file{foo.$(OBJEXT)} for
3091 @file{prog}, and @file{foo.lo} for @file{libfoo.la}. The problem is
3092 that in the course of creating @file{foo.lo}, libtool may erase (or
3093 replace) @file{foo.$(OBJEXT)} -- and this cannot be avoided.
3095 Therefore, when Automake detects this situation it will complain
3096 with a message such as
3098 object `foo.$(OBJEXT)' created both with libtool and without
3101 A workaround for this issue is to ensure that these two objects get
3102 different basenames. As explained in @ref{renamed objects}, this
3103 happens automatically when per-targets flags are used.
3107 prog_SOURCES = prog.c foo.c @dots{}
3108 prog_CFLAGS = $(AM_CFLAGS)
3110 lib_LTLIBRARIES = libfoo.la
3111 libfoo_la_SOURCES = foo.c @dots{}
3115 Adding @code{prog_CFLAGS = $(AM_CFLAGS)} is almost a no-op, because
3116 when the @code{prog_CFLAGS} is defined, it is used instead of
3117 @code{AM_CFLAGS}. However as a side effect it will cause
3118 @file{prog.c} and @file{foo.c} to be compiled as
3119 @file{prog-prog.$(OBJEXT)} and @file{prog-foo.$(OBJEXT)} which solves
3122 @node Program and Library Variables
3123 @section Program and Library Variables
3125 Associated with each program are a collection of variables which can be
3126 used to modify how that program is built. There is a similar list of
3127 such variables for each library. The canonical name of the program (or
3128 library) is used as a base for naming these variables.
3130 In the list below, we use the name ``maude'' to refer to the program or
3131 library. In your @file{Makefile.am} you would replace this with the
3132 canonical name of your program. This list also refers to ``maude'' as a
3133 program, but in general the same rules apply for both static and dynamic
3134 libraries; the documentation below notes situations where programs and
3139 This variable, if it exists, lists all the source files which are
3140 compiled to build the program. These files are added to the
3141 distribution by default. When building the program, Automake will cause
3142 each source file to be compiled to a single @file{.o} file (or
3143 @file{.lo} when using libtool). Normally these object files are named
3144 after the source file, but other factors can change this. If a file in
3145 the @samp{_SOURCES} variable has an unrecognized extension, Automake
3146 will do one of two things with it. If a suffix rule exists for turning
3147 files with the unrecognized extension into @file{.o} files, then
3148 automake will treat this file as it will any other source file
3149 (@pxref{Support for Other Languages}). Otherwise, the file will be
3150 ignored as though it were a header file.
3152 The prefixes @samp{dist_} and @samp{nodist_} can be used to control
3153 whether files listed in a @samp{_SOURCES} variable are distributed.
3154 @samp{dist_} is redundant, as sources are distributed by default, but it
3155 can be specified for clarity if desired.
3157 It is possible to have both @samp{dist_} and @samp{nodist_} variants of
3158 a given @samp{_SOURCES} variable at once; this lets you easily
3159 distribute some files and not others, for instance:
3162 nodist_maude_SOURCES = nodist.c
3163 dist_maude_SOURCES = dist-me.c
3166 By default the output file (on Unix systems, the @file{.o} file) will be
3167 put into the current build directory. However, if the option
3168 @code{subdir-objects} is in effect in the current directory then the
3169 @file{.o} file will be put into the subdirectory named after the source
3170 file. For instance, with @code{subdir-objects} enabled,
3171 @file{sub/dir/file.c} will be compiled to @file{sub/dir/file.o}. Some
3172 people prefer this mode of operation. You can specify
3173 @code{subdir-objects} in @code{AUTOMAKE_OPTIONS} (@pxref{Options}).
3174 @cindex Subdirectory, objects in
3175 @cindex Objects in subdirectory
3178 @item EXTRA_maude_SOURCES
3179 Automake needs to know the list of files you intend to compile
3180 @emph{statically}. For one thing, this is the only way Automake has of
3181 knowing what sort of language support a given @file{Makefile.in}
3182 requires. @footnote{There are other, more obscure reasons reasons for
3183 this limitation as well.} This means that, for example, you can't put a
3184 configure substitution like @samp{@@my_sources@@} into a @samp{_SOURCES}
3185 variable. If you intend to conditionally compile source files and use
3186 @file{configure} to substitute the appropriate object names into, e.g.,
3187 @samp{_LDADD} (see below), then you should list the corresponding source
3188 files in the @samp{EXTRA_} variable.
3190 This variable also supports @samp{dist_} and @samp{nodist_} prefixes,
3191 e.g., @samp{nodist_EXTRA_maude_SOURCES}.
3194 A static library is created by default by invoking @code{$(AR)
3195 $(ARFLAGS)} followed by the name of the library and then the objects
3196 being put into the library. You can override this by setting the
3197 @samp{_AR} variable. This is usually used with C++; some C++
3198 compilers require a special invocation in order to instantiate all the
3199 templates which should go into a library. For instance, the SGI C++
3200 compiler likes this variable set like so:
3202 libmaude_a_AR = $(CXX) -ar -o
3206 Extra objects can be added to a @emph{library} using the @samp{_LIBADD}
3207 variable. For instance this should be used for objects determined by
3208 @code{configure} (@pxref{A Library}).
3211 Extra objects can be added to a @emph{program} by listing them in the
3212 @samp{_LDADD} variable. For instance this should be used for objects
3213 determined by @code{configure} (@pxref{Linking}).
3215 @samp{_LDADD} and @samp{_LIBADD} are inappropriate for passing
3216 program-specific linker flags (except for @samp{-l}, @samp{-L},
3217 @samp{-dlopen} and @samp{-dlpreopen}). Use the @samp{_LDFLAGS} variable
3220 For instance, if your @file{configure.ac} uses @code{AC_PATH_XTRA}, you
3221 could link your program against the X libraries like so:
3224 maude_LDADD = $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS)
3228 This variable is used to pass extra flags to the link step of a program
3229 or a shared library.
3231 @item maude_DEPENDENCIES
3232 It is also occasionally useful to have a program depend on some other
3233 target which is not actually part of that program. This can be done
3234 using the @samp{_DEPENDENCIES} variable. Each program depends on the
3235 contents of such a variable, but no further interpretation is done.
3237 If @samp{_DEPENDENCIES} is not supplied, it is computed by Automake.
3238 The automatically-assigned value is the contents of @samp{_LDADD} or
3239 @samp{_LIBADD}, with most configure substitutions, @samp{-l}, @samp{-L},
3240 @samp{-dlopen} and @samp{-dlpreopen} options removed. The configure
3241 substitutions that are left in are only @samp{$(LIBOBJS)} and
3242 @samp{$(ALLOCA)}; these are left because it is known that they will not
3243 cause an invalid value for @samp{_DEPENDENCIES} to be generated.
3246 You can override the linker on a per-program basis. By default the
3247 linker is chosen according to the languages used by the program. For
3248 instance, a program that includes C++ source code would use the C++
3249 compiler to link. The @samp{_LINK} variable must hold the name of a
3250 command which can be passed all the @file{.o} file names as arguments.
3251 Note that the name of the underlying program is @emph{not} passed to
3252 @samp{_LINK}; typically one uses @samp{$@@}:
3255 maude_LINK = $(CCLD) -magic -o $@@
3258 @item maude_CCASFLAGS
3260 @itemx maude_CPPFLAGS
3261 @itemx maude_CXXFLAGS
3263 @itemx maude_GCJFLAGS
3265 @itemx maude_OBJCFLAGS
3268 @cindex per-target compilation flags, defined
3269 Automake allows you to set compilation flags on a per-program (or
3270 per-library) basis. A single source file can be included in several
3271 programs, and it will potentially be compiled with different flags for
3272 each program. This works for any language directly supported by
3273 Automake. These @dfn{per-target compilation flags} are
3285 When using a per-target compilation flag, Automake will choose a
3286 different name for the intermediate object files. Ordinarily a file
3287 like @file{sample.c} will be compiled to produce @file{sample.o}.
3288 However, if the program's @samp{_CFLAGS} variable is set, then the
3289 object file will be named, for instance, @file{maude-sample.o}.
3290 (See also @ref{renamed objects}.)
3292 In compilations with per-target flags, the ordinary @samp{AM_} form of
3293 the flags variable is @emph{not} automatically included in the
3294 compilation (however, the user form of the variable @emph{is} included).
3295 So for instance, if you want the hypothetical @file{maude} compilations
3296 to also use the value of @samp{AM_CFLAGS}, you would need to write:
3299 maude_CFLAGS = @dots{} your flags @dots{} $(AM_CFLAGS)
3303 @item maude_SHORTNAME
3304 On some platforms the allowable file names are very short. In order to
3305 support these systems and per-target compilation flags at the same
3306 time, Automake allows you to set a ``short name'' which will influence
3307 how intermediate object files are named. For instance, in the following
3311 bin_PROGRAMS = maude
3312 maude_CPPFLAGS = -DSOMEFLAG
3314 maude_SOURCES = sample.c @dots{}
3318 the object file would be named @file{m-sample.o} rather than
3319 @file{maude-sample.o}.
3321 This facility is rarely needed in practice,
3322 and we recommend avoiding it until you find it is required.
3325 @node Default _SOURCES
3326 @section Default @code{_SOURCES}
3330 @cindex @code{_SOURCES}, default
3331 @cindex default @code{_SOURCES}
3333 @code{_SOURCES} variables are used to specify source files of programs
3334 (@pxref{A Program}), libraries (@pxref{A Library}), and Libtool
3335 libraries (@pxref{A Shared Library}).
3337 When no such variable is specified for a target, Automake will define
3338 one itself. The default is to compile a single C file whose base name
3339 is the name of the target itself, with any extension replaced by
3340 @file{.c}. (Defaulting to C is terrible but we are stuck with it for
3341 historical reasons.)
3343 For example if you have the following somewhere in your
3344 @file{Makefile.am} with no corresponding @samp{libfoo_a_SOURCES}:
3347 lib_LIBRARIES = libfoo.a sub/libc++.a
3351 @file{libfoo.a} will be built using a default source file named
3352 @file{libfoo.c}, and @file{sub/libc++.a} will be built from
3353 @file{sub/libc++.c}. (In older versions @file{sub/libc++.a}
3354 would be built from @file{sub_libc___a.c}, i.e., the default source
3355 was the canonized name of the target, with @file{.c} appended.
3356 Be believe the new behavior is more sensible, but for backward
3357 compatibility automake will use the old name if a file or a rule
3358 with that name exist.)
3360 @cindex @code{check_PROGRAMS} example
3361 @vindex check_PROGRAMS
3362 Default sources are mainly useful in test suites, when building many
3363 tests programs each from a single source. For instance in
3366 check_PROGRAMS = test1 test2 test3
3370 @file{test1}, @file{test2}, and @file{test3} will be built
3371 from @file{test1.c}, @file{test2.c}, and @file{test3.c}.
3373 @cindex Libtool modules, default source example
3374 @cindex default source, Libtool modules example
3375 Another case where is this convenient is building many Libtool modules
3376 (@file{moduleN.la}), each defined in its own file (@file{moduleN.c}).
3379 AM_LDFLAGS = -module
3380 lib_LTLIBRARIES = module1.la module2.la module3.la
3383 @cindex empty @code{_SOURCES}
3384 @cindex @code{_SOURCES}, empty
3385 Finally, there is one situation where this default source computation
3386 needs to be avoided: when a target should not be built from sources.
3387 We already saw such an example in @ref{true}; this happens when all
3388 the constituents of a target have already been compiled and need just
3389 to be combined using a @code{_LDADD} variable. Then it is necessary
3390 to define an empty @code{_SOURCES} variable, so that automake does not
3394 bin_PROGRAMS = target
3396 target_LDADD = libmain.a libmisc.a
3400 @section Special handling for LIBOBJS and ALLOCA
3402 @cindex @code{LIBOBJS}, special handling
3403 @cindex @code{ALLOCA}, special handling
3405 Automake explicitly recognizes the use of @code{$(LIBOBJS)} and
3406 @code{$(ALLOCA)}, and uses this information, plus the list of
3407 @code{LIBOBJS} files derived from @file{configure.ac} to automatically
3408 include the appropriate source files in the distribution (@pxref{Dist}).
3409 These source files are also automatically handled in the
3410 dependency-tracking scheme; see @xref{Dependencies}.
3412 @code{$(LIBOBJS)} and @code{$(ALLOCA)} are specially recognized in any
3413 @samp{_LDADD} or @samp{_LIBADD} variable.
3416 @node Program variables
3417 @section Variables used when building a program
3419 Occasionally it is useful to know which @file{Makefile} variables
3420 Automake uses for compilations; for instance you might need to do your
3421 own compilation in some special cases.
3423 Some variables are inherited from Autoconf; these are @code{CC},
3424 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
3433 There are some additional variables which Automake itself defines:
3437 The contents of this variable are passed to every compilation which invokes
3438 the C preprocessor; it is a list of arguments to the preprocessor. For
3439 instance, @samp{-I} and @samp{-D} options should be listed here.
3441 Automake already provides some @samp{-I} options automatically. In
3442 particular it generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I}
3443 pointing to the directory holding @file{config.h} (if you've used
3444 @code{AC_CONFIG_HEADERS} or @code{AM_CONFIG_HEADER}). You can disable
3445 the default @samp{-I} options using the @samp{nostdinc} option.
3447 @code{AM_CPPFLAGS} is ignored in preference to a per-executable (or
3448 per-library) @code{_CPPFLAGS} variable if it is defined.
3451 This does the same job as @samp{AM_CPPFLAGS} (or any per-target
3452 @samp{_CPPFLAGS} variable if it is used). It is an older name for the
3453 same functionality. This variable is deprecated; we suggest using
3454 @samp{AM_CPPFLAGS} and per-target @samp{_CPPFLAGS} instead.
3457 This is the variable which the @file{Makefile.am} author can use to pass
3458 in additional C compiler flags. It is more fully documented elsewhere.
3459 In some situations, this is not used, in preference to the
3460 per-executable (or per-library) @code{_CFLAGS}.
3463 This is the command used to actually compile a C source file. The
3464 filename is appended to form the complete command line.
3467 This is the variable which the @file{Makefile.am} author can use to pass
3468 in additional linker flags. In some situations, this is not used, in
3469 preference to the per-executable (or per-library) @code{_LDFLAGS}.
3472 This is the command used to actually link a C program. It already
3473 includes @samp{-o $@@} and the usual variable references (for instance,
3474 @code{CFLAGS}); it takes as ``arguments'' the names of the object files
3475 and libraries to link in.
3480 @section Yacc and Lex support
3482 Automake has somewhat idiosyncratic support for Yacc and Lex.
3484 Automake assumes that the @file{.c} file generated by @code{yacc} (or
3485 @code{lex}) should be named using the basename of the input file. That
3486 is, for a yacc source file @file{foo.y}, Automake will cause the
3487 intermediate file to be named @file{foo.c} (as opposed to
3488 @file{y.tab.c}, which is more traditional).
3490 The extension of a yacc source file is used to determine the extension
3491 of the resulting @samp{C} or @samp{C++} file. Files with the extension
3492 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
3493 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
3496 Likewise, lex source files can be used to generate @samp{C} or
3497 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
3498 @samp{.lxx} are recognized.
3500 You should never explicitly mention the intermediate (@samp{C} or
3501 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
3504 The intermediate files generated by @code{yacc} (or @code{lex}) will be
3505 included in any distribution that is made. That way the user doesn't
3506 need to have @code{yacc} or @code{lex}.
3508 If a @code{yacc} source file is seen, then your @file{configure.ac} must
3509 define the variable @samp{YACC}. This is most easily done by invoking
3510 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
3511 Program Checks, autoconf, The Autoconf Manual}).
3513 When @code{yacc} is invoked, it is passed @samp{YFLAGS} and
3514 @samp{AM_YFLAGS}. The former is a user variable and the latter is
3515 intended for the @file{Makefile.am} author.
3517 @samp{AM_YFLAGS} is usually used to pass the @code{-d} option to
3518 @code{yacc}. Automake knows what this means and will automatically
3519 adjust its rules to update and distribute the header file built by
3520 @code{yacc -d}. What Automake cannot guess, though, is where this
3521 header will be used: it is up to you to ensure the header gets built
3522 before it is first used. Typically this is necessary in order for
3523 dependency tracking to work when the header is included by another
3524 file. The common solution is listing the header file in
3525 @code{BUILT_SOURCES} (@pxref{Sources}) as follows.
3528 BUILT_SOURCES = parser.h
3531 foo_SOURCES = @dots{} parser.y @dots{}
3534 If a @code{lex} source file is seen, then your @file{configure.ac}
3535 must define the variable @samp{LEX}. You can use @samp{AC_PROG_LEX}
3536 to do this (@pxref{Particular Programs, , Particular Program Checks,
3537 autoconf, The Autoconf Manual}), but using @code{AM_PROG_LEX} macro
3538 (@pxref{Macros}) is recommended.
3540 When @code{lex} is invoked, it is passed @samp{LFLAGS} and
3541 @samp{AM_LFLAGS}. The former is a user variable and the latter is
3542 intended for the @file{Makefile.am} author.
3547 @cindex yacc, multiple parsers
3548 @cindex Multiple yacc parsers
3549 @cindex Multiple lex lexers
3550 @cindex lex, multiple lexers
3553 Automake makes it possible to include multiple @code{yacc} (or
3554 @code{lex}) source files in a single program. When there is more than
3555 one distinct @code{yacc} (or @code{lex}) source file in a directory,
3556 Automake uses a small program called @code{ylwrap} to run @code{yacc}
3557 (or @code{lex}) in a subdirectory. This is necessary because yacc's
3558 output filename is fixed, and a parallel make could conceivably invoke
3559 more than one instance of @code{yacc} simultaneously. The @code{ylwrap}
3560 program is distributed with Automake. It should appear in the directory
3561 specified by @samp{AC_CONFIG_AUX_DIR} (@pxref{Input, , Finding
3562 `configure' Input, autoconf, The Autoconf Manual}), or the current
3563 directory if that macro is not used in @file{configure.ac}.
3565 For @code{yacc}, simply managing locking is insufficient. The output of
3566 @code{yacc} always uses the same symbol names internally, so it isn't
3567 possible to link two @code{yacc} parsers into the same executable.
3569 We recommend using the following renaming hack used in @code{gdb}:
3571 #define yymaxdepth c_maxdepth
3572 #define yyparse c_parse
3574 #define yyerror c_error
3575 #define yylval c_lval
3576 #define yychar c_char
3577 #define yydebug c_debug
3578 #define yypact c_pact
3585 #define yyexca c_exca
3586 #define yyerrflag c_errflag
3587 #define yynerrs c_nerrs
3591 #define yy_yys c_yys
3592 #define yystate c_state
3595 #define yy_yyv c_yyv
3597 #define yylloc c_lloc
3598 #define yyreds c_reds
3599 #define yytoks c_toks
3600 #define yylhs c_yylhs
3601 #define yylen c_yylen
3602 #define yydefred c_yydefred
3603 #define yydgoto c_yydgoto
3604 #define yysindex c_yysindex
3605 #define yyrindex c_yyrindex
3606 #define yygindex c_yygindex
3607 #define yytable c_yytable
3608 #define yycheck c_yycheck
3609 #define yyname c_yyname
3610 #define yyrule c_yyrule
3613 For each define, replace the @samp{c_} prefix with whatever you like.
3614 These defines work for @code{bison}, @code{byacc}, and traditional
3615 @code{yacc}s. If you find a parser generator that uses a symbol not
3616 covered here, please report the new name so it can be added to the list.
3620 @section C++ Support
3623 @cindex Support for C++
3625 Automake includes full support for C++.
3627 Any package including C++ code must define the output variable
3628 @samp{CXX} in @file{configure.ac}; the simplest way to do this is to use
3629 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
3630 Program Checks, autoconf, The Autoconf Manual}).
3632 A few additional variables are defined when a C++ source file is seen:
3636 The name of the C++ compiler.
3639 Any flags to pass to the C++ compiler.
3642 The maintainer's variant of @code{CXXFLAGS}.
3645 The command used to actually compile a C++ source file. The file name
3646 is appended to form the complete command line.
3649 The command used to actually link a C++ program.
3653 @node Assembly Support
3654 @section Assembly Support
3656 Automake includes some support for assembly code.
3658 The variable @code{CCAS} holds the name of the compiler used to build
3659 assembly code. This compiler must work a bit like a C compiler; in
3660 particular it must accept @samp{-c} and @samp{-o}. The value of
3661 @code{CCASFLAGS} is passed to the compilation.
3665 You are required to set @code{CCAS} and @code{CCASFLAGS} via
3666 @file{configure.ac}. The autoconf macro @code{AM_PROG_AS} will do this
3667 for you. Unless they are already set, it simply sets @code{CCAS} to the
3668 C compiler and @code{CCASFLAGS} to the C compiler flags.
3670 Only the suffixes @samp{.s} and @samp{.S} are recognized by
3671 @code{automake} as being files containing assembly code.
3674 @node Fortran 77 Support
3675 @comment node-name, next, previous, up
3676 @section Fortran 77 Support
3678 @cindex Fortran 77 support
3679 @cindex Support for Fortran 77
3681 Automake includes full support for Fortran 77.
3683 Any package including Fortran 77 code must define the output variable
3684 @samp{F77} in @file{configure.ac}; the simplest way to do this is to use
3685 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
3686 Program Checks, autoconf, The Autoconf Manual}).
3688 A few additional variables are defined when a Fortran 77 source file is
3694 The name of the Fortran 77 compiler.
3697 Any flags to pass to the Fortran 77 compiler.
3700 The maintainer's variant of @code{FFLAGS}.
3703 Any flags to pass to the Ratfor compiler.
3706 The maintainer's variant of @code{RFLAGS}.
3709 The command used to actually compile a Fortran 77 source file. The file
3710 name is appended to form the complete command line.
3713 The command used to actually link a pure Fortran 77 program or shared
3718 Automake can handle preprocessing Fortran 77 and Ratfor source files in
3719 addition to compiling them@footnote{Much, if not most, of the
3720 information in the following sections pertaining to preprocessing
3721 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
3722 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}. Automake
3723 also contains some support for creating programs and shared libraries
3724 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
3725 Fortran 77 With C and C++}).
3727 These issues are covered in the following sections.
3730 * Preprocessing Fortran 77:: Preprocessing Fortran 77 sources
3731 * Compiling Fortran 77 Files:: Compiling Fortran 77 sources
3732 * Mixing Fortran 77 With C and C++:: Mixing Fortran 77 With C and C++
3736 @node Preprocessing Fortran 77
3737 @comment node-name, next, previous, up
3738 @subsection Preprocessing Fortran 77
3740 @cindex Preprocessing Fortran 77
3741 @cindex Fortran 77, Preprocessing
3742 @cindex Ratfor programs
3744 @file{N.f} is made automatically from @file{N.F} or @file{N.r}. This
3745 rule runs just the preprocessor to convert a preprocessable Fortran 77
3746 or Ratfor source file into a strict Fortran 77 source file. The precise
3747 command used is as follows:
3752 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
3755 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
3760 @node Compiling Fortran 77 Files
3761 @comment node-name, next, previous, up
3762 @subsection Compiling Fortran 77 Files
3764 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
3765 @file{N.r} by running the Fortran 77 compiler. The precise command used
3771 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
3774 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
3777 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
3782 @node Mixing Fortran 77 With C and C++
3783 @comment node-name, next, previous, up
3784 @subsection Mixing Fortran 77 With C and C++
3786 @cindex Fortran 77, mixing with C and C++
3787 @cindex Mixing Fortran 77 with C and C++
3788 @cindex Linking Fortran 77 with C and C++
3790 @cindex Mixing Fortran 77 with C and/or C++
3792 Automake currently provides @emph{limited} support for creating programs
3793 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
3794 However, there are many other issues related to mixing Fortran 77 with
3795 other languages that are @emph{not} (currently) handled by Automake, but
3796 that are handled by other packages@footnote{For example,
3797 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
3798 addresses all of these inter-language issues, and runs under nearly all
3799 Fortran 77, C and C++ compilers on nearly all platforms. However,
3800 @code{cfortran} is not yet Free Software, but it will be in the next
3804 Automake can help in two ways:
3808 Automatic selection of the linker depending on which combinations of
3812 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
3813 @samp{-l}) to pass to the automatically selected linker in order to link
3814 in the appropriate Fortran 77 intrinsic and run-time libraries.
3816 @cindex FLIBS, defined
3817 These extra Fortran 77 linker flags are supplied in the output variable
3818 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
3819 supplied with newer versions of Autoconf (Autoconf version 2.13 and
3820 later). @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
3824 If Automake detects that a program or shared library (as mentioned in
3825 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
3826 code that is a mixture of Fortran 77 and C and/or C++, then it requires
3827 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
3828 @file{configure.ac}, and that either @code{$(FLIBS)}
3829 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
3830 (for shared libraries) variables. It is the responsibility of the
3831 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
3832 appears in the appropriate @code{_LDADD} or
3833 @code{_LIBADD} variable.
3835 @cindex Mixed language example
3836 @cindex Example, mixed language
3838 For example, consider the following @file{Makefile.am}:
3842 foo_SOURCES = main.cc foo.f
3843 foo_LDADD = libfoo.la $(FLIBS)
3845 pkglib_LTLIBRARIES = libfoo.la
3846 libfoo_la_SOURCES = bar.f baz.c zardoz.cc
3847 libfoo_la_LIBADD = $(FLIBS)
3850 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
3851 is mentioned in @file{configure.ac}. Also, if @code{$(FLIBS)} hadn't
3852 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
3853 Automake would have issued a warning.
3858 * How the Linker is Chosen:: Automatic linker selection
3861 @node How the Linker is Chosen
3862 @comment node-name, next, previous, up
3863 @subsubsection How the Linker is Chosen
3865 @cindex Automatic linker selection
3866 @cindex Selecting the linker automatically
3868 The following diagram demonstrates under what conditions a particular
3869 linker is chosen by Automake.
3871 For example, if Fortran 77, C and C++ source code were to be compiled
3872 into a program, then the C++ linker will be used. In this case, if the
3873 C or Fortran 77 linkers required any special libraries that weren't
3874 included by the C++ linker, then they must be manually added to an
3875 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
3881 code \ C C++ Fortran
3882 ----------------- +---------+---------+---------+
3886 +---------+---------+---------+
3890 +---------+---------+---------+
3894 +---------+---------+---------+
3898 +---------+---------+---------+
3900 C + Fortran | | | x |
3902 +---------+---------+---------+
3904 C++ + Fortran | | x | |
3906 +---------+---------+---------+
3908 C + C++ + Fortran | | x | |
3910 +---------+---------+---------+
3915 @comment node-name, next, previous, up
3916 @section Java Support
3918 @cindex Java support
3919 @cindex Support for Java
3921 Automake includes support for compiled Java, using @code{gcj}, the Java
3922 front end to the GNU Compiler Collection.
3924 Any package including Java code to be compiled must define the output
3925 variable @samp{GCJ} in @file{configure.ac}; the variable @samp{GCJFLAGS}
3926 must also be defined somehow (either in @file{configure.ac} or
3927 @file{Makefile.am}). The simplest way to do this is to use the
3928 @code{AM_PROG_GCJ} macro.
3932 By default, programs including Java source files are linked with
3935 As always, the contents of @samp{AM_GCJFLAGS} are passed to every
3936 compilation invoking @code{gcj} (in its role as an ahead-of-time
3937 compiler -- when invoking it to create @file{.class} files,
3938 @samp{AM_JAVACFLAGS} is used instead). If it is necessary to pass
3939 options to @code{gcj} from @file{Makefile.am}, this variable, and not
3940 the user variable @samp{GCJFLAGS}, should be used.
3944 @code{gcj} can be used to compile @file{.java}, @file{.class},
3945 @file{.zip}, or @file{.jar} files.
3947 When linking, @code{gcj} requires that the main class be specified
3948 using the @samp{--main=} option. The easiest way to do this is to use
3949 the @code{_LDFLAGS} variable for the program.
3952 @node Support for Other Languages
3953 @comment node-name, next, previous, up
3954 @section Support for Other Languages
3956 Automake currently only includes full support for C, C++ (@pxref{C++
3957 Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java
3958 (@pxref{Java Support}). There is only rudimentary support for other
3959 languages, support for which will be improved based on user demand.
3961 Some limited support for adding your own languages is available via the
3962 suffix rule handling; see @ref{Suffixes}.
3966 @section Automatic de-ANSI-fication
3968 @cindex de-ANSI-fication, defined
3970 Although the GNU standards allow the use of ANSI C, this can have the
3971 effect of limiting portability of a package to some older compilers
3972 (notably the SunOS C compiler).
3974 Automake allows you to work around this problem on such machines by
3975 @dfn{de-ANSI-fying} each source file before the actual compilation takes
3978 @vindex AUTOMAKE_OPTIONS
3981 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
3982 (@pxref{Options}) contains the option @code{ansi2knr} then code to
3983 handle de-ANSI-fication is inserted into the generated
3986 This causes each C source file in the directory to be treated as ANSI C@.
3987 If an ANSI C compiler is available, it is used. If no ANSI C compiler
3988 is available, the @code{ansi2knr} program is used to convert the source
3989 files into K&R C, which is then compiled.
3991 The @code{ansi2knr} program is simple-minded. It assumes the source
3992 code will be formatted in a particular way; see the @code{ansi2knr} man
3995 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
3996 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
3997 these files are distributed with Automake. Also, the package
3998 @file{configure.ac} must call the macro @code{AM_C_PROTOTYPES}
4000 @cvindex AM_C_PROTOTYPES
4002 Automake also handles finding the @code{ansi2knr} support files in some
4003 other directory in the current package. This is done by prepending the
4004 relative path to the appropriate directory to the @code{ansi2knr}
4005 option. For instance, suppose the package has ANSI C code in the
4006 @file{src} and @file{lib} subdirectories. The files @file{ansi2knr.c} and
4007 @file{ansi2knr.1} appear in @file{lib}. Then this could appear in
4008 @file{src/Makefile.am}:
4011 AUTOMAKE_OPTIONS = ../lib/ansi2knr
4014 If no directory prefix is given, the files are assumed to be in the
4017 Note that automatic de-ANSI-fication will not work when the package is
4018 being built for a different host architecture. That is because automake
4019 currently has no way to build @code{ansi2knr} for the build machine.
4021 @c FIXME: this paragraph might be better moved to an `upgrading' section.
4022 @cindex @code{LTLIBOBJS} and @code{ansi2knr}
4023 @cindex @code{LIBOBJS} and @code{ansi2knr}
4024 @cindex @code{ansi2knr} and @code{LTLIBOBJS}
4025 @cindex @code{ansi2knr} and @code{LIBOBJS}
4026 Using @code{LIBOBJS} with source de-ANSI-fication used to require
4027 hand-crafted code in @file{configure} to append @code{$U} to basenames
4028 in @code{LIBOBJS}. This is no longer true today. Starting with version
4029 2.54, Autoconf takes care of rewriting @code{LIBOBJS} and
4030 @code{LTLIBOBJS}. (@pxref{AC_LIBOBJ vs LIBOBJS, , @code{AC_LIBOBJ}
4031 vs. @code{LIBOBJS}, autoconf, The Autoconf Manual})
4034 @section Automatic dependency tracking
4036 As a developer it is often painful to continually update the
4037 @file{Makefile.in} whenever the include-file dependencies change in a
4038 project. Automake supplies a way to automatically track dependency
4041 @cindex Dependency tracking
4042 @cindex Automatic dependency tracking
4044 Automake always uses complete dependencies for a compilation, including
4045 system headers. Automake's model is that dependency computation should
4046 be a side effect of the build. To this end, dependencies are computed
4047 by running all compilations through a special wrapper program called
4048 @code{depcomp}. @code{depcomp} understands how to coax many different C
4049 and C++ compilers into generating dependency information in the format
4050 it requires. @code{automake -a} will install @code{depcomp} into your
4051 source tree for you. If @code{depcomp} can't figure out how to properly
4052 invoke your compiler, dependency tracking will simply be disabled for
4057 Experience with earlier versions of Automake @footnote{See
4058 @uref{http://sources.redhat.com/automake/dependencies.html} for more
4059 information on the history and experiences with automatic dependency
4060 tracking in Automake} taught us that it is not reliable to generate
4061 dependencies only on the maintainer's system, as configurations vary too
4062 much. So instead Automake implements dependency tracking at build time.
4064 Automatic dependency tracking can be suppressed by putting
4065 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}, or
4066 passing @code{no-dependencies} as an argument to @code{AM_INIT_AUTOMAKE}
4067 (this should be the preferred way). Or, you can invoke @code{automake}
4068 with the @code{-i} option. Dependency tracking is enabled by default.
4070 @vindex AUTOMAKE_OPTIONS
4071 @opindex no-dependencies
4073 The person building your package also can choose to disable dependency
4074 tracking by configuring with @code{--disable-dependency-tracking}.
4076 @cindex Disabling dependency tracking
4077 @cindex Dependency tracking, disabling
4081 @section Support for executable extensions
4083 @cindex Executable extension
4084 @cindex Extension, executable
4087 On some platforms, such as Windows, executables are expected to have an
4088 extension such as @samp{.exe}. On these platforms, some compilers (GCC
4089 among them) will automatically generate @file{foo.exe} when asked to
4090 generate @file{foo}.
4092 Automake provides mostly-transparent support for this. Unfortunately
4093 @emph{mostly} doesn't yet mean @emph{fully}. Until the English
4094 dictionary is revised, you will have to assist Automake if your package
4095 must support those platforms.
4097 One thing you must be aware of is that, internally, Automake rewrites
4098 something like this:
4101 bin_PROGRAMS = liver
4107 bin_PROGRAMS = liver$(EXEEXT)
4110 The targets Automake generates are likewise given the @samp{$(EXEEXT)}
4111 extension. @code{EXEEXT}
4113 However, Automake cannot apply this rewriting to @code{configure}
4114 substitutions. This means that if you are conditionally building a
4115 program using such a substitution, then your @file{configure.ac} must
4116 take care to add @samp{$(EXEEXT)} when constructing the output variable.
4118 With Autoconf 2.13 and earlier, you must explicitly use @code{AC_EXEEXT}
4119 to get this support. With Autoconf 2.50, @code{AC_EXEEXT} is run
4120 automatically if you configure a compiler (say, through
4123 Sometimes maintainers like to write an explicit link rule for their
4124 program. Without executable extension support, this is easy---you
4125 simply write a rule whose target is the name of the program. However,
4126 when executable extension support is enabled, you must instead add the
4127 @samp{$(EXEEXT)} suffix.
4129 Unfortunately, due to the change in Autoconf 2.50, this means you must
4130 always add this extension. However, this is a problem for maintainers
4131 who know their package will never run on a platform that has
4132 executable extensions. For those maintainers, the @code{no-exeext}
4133 option (@pxref{Options}) will disable this feature. This works in a
4134 fairly ugly way; if @code{no-exeext} is seen, then the presence of a
4135 rule for a target named @code{foo} in @file{Makefile.am} will override
4136 an automake-generated rule for @code{foo$(EXEEXT)}. Without
4137 the @code{no-exeext} option, this use will give a diagnostic.
4141 @chapter Other Derived Objects
4143 Automake can handle derived objects which are not C programs. Sometimes
4144 the support for actually building such objects must be explicitly
4145 supplied, but Automake will still automatically handle installation and
4149 * Scripts:: Executable scripts
4150 * Headers:: Header files
4151 * Data:: Architecture-independent data files
4152 * Sources:: Derived sources
4157 @section Executable Scripts
4159 @cindex _SCRIPTS primary, defined
4160 @cindex SCRIPTS primary, defined
4161 @cindex Primary variable, SCRIPTS
4163 It is possible to define and install programs which are scripts. Such
4164 programs are listed using the @samp{SCRIPTS} primary name. Automake
4165 doesn't define any dependencies for scripts; the @file{Makefile.am}
4166 should include the appropriate rules.
4169 Automake does not assume that scripts are derived objects; such objects
4170 must be deleted by hand (@pxref{Clean}).
4172 The @code{automake} program itself is a Perl script that is generated
4173 from @file{automake.in}. Here is how this is handled:
4176 bin_SCRIPTS = automake
4177 CLEANFILES = $(bin_SCRIPTS)
4179 do_subst = sed -e 's,[@@]datadir[@@],$(datadir),g' \
4180 -e 's,[@@]PERL[@@],$(PERL),g' \
4181 -e 's,[@@]PACKAGE[@@],$(PACKAGE),g' \
4182 -e 's,[@@]VERSION[@@],$(VERSION),g' \
4185 automake: automake.in Makefile
4186 $(do_subst) < $(srcdir)/automake.in > automake
4190 Because---as we have just seen---scripts can be built, they are not
4191 distributed by default. Scripts that should be distributed can be
4192 specified using a @code{dist_} prefix as in other primaries. For
4193 instance the following @file{Makefile.am} declares that
4194 @file{my_script} should be distributed and installed in
4198 dist_sbin_SCRIPTS = my_script
4201 @cindex SCRIPTS, installation directories
4202 @cindex Installing scripts
4205 @vindex sbin_SCRIPTS
4206 @vindex libexec_SCRIPTS
4207 @vindex pkgdata_SCRIPTS
4208 @vindex noinst_SCRIPTS
4209 @vindex check_SCRIPTS
4211 Script objects can be installed in @code{bindir}, @code{sbindir},
4212 @code{libexecdir}, or @code{pkgdatadir}.
4214 Scripts that need not being installed can be listed in
4215 @code{noinst_SCRIPTS}, and among them, those which are needed only by
4216 @code{make check} should go in @code{check_SCRIPTS}.
4220 @section Header files
4222 @cindex _HEADERS primary, defined
4223 @cindex HEADERS primary, defined
4224 @cindex Primary variable, HEADERS
4226 @vindex noinst_HEADERS
4228 Header files are specified by the @samp{HEADERS} family of variables.
4229 Generally header files are not installed, so the @code{noinst_HEADERS}
4230 variable will be the most used. @footnote{However, for the case of a
4231 non-installed header file that is actually used by a particular program,
4232 we recommend listing it in the program's @samp{_SOURCES} variable
4233 instead of in @code{noinst_HEADERS}. We believe this is more clear.}
4236 All header files must be listed somewhere; missing ones will not appear
4237 in the distribution. Often it is clearest to list uninstalled headers
4238 with the rest of the sources for a program. @xref{A Program}. Headers
4239 listed in a @samp{_SOURCES} variable need not be listed in any
4240 @samp{_HEADERS} variable.
4242 @cindex HEADERS, installation directories
4243 @cindex Installing headers
4245 @vindex include_HEADERS
4246 @vindex oldinclude_HEADERS
4247 @vindex pkginclude_HEADERS
4249 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
4250 @code{pkgincludedir}.
4254 @section Architecture-independent data files
4256 @cindex _DATA primary, defined
4257 @cindex DATA primary, defined
4258 @cindex Primary variable, DATA
4260 Automake supports the installation of miscellaneous data files using the
4261 @samp{DATA} family of variables.
4265 @vindex sysconf_DATA
4266 @vindex sharedstate_DATA
4267 @vindex localstate_DATA
4268 @vindex pkgdata_DATA
4270 Such data can be installed in the directories @code{datadir},
4271 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
4274 By default, data files are @emph{not} included in a distribution. Of
4275 course, you can use the @samp{dist_} prefix to change this on a
4278 Here is how Automake declares its auxiliary data files:
4281 dist_pkgdata_DATA = clean-kr.am clean.am @dots{}
4286 @section Built sources
4288 Because Automake's automatic dependency tracking works as a side-effect
4289 of compilation (@pxref{Dependencies}) there is a bootstrap issue: a
4290 target should not be compiled before its dependencies are made, but
4291 these dependencies are unknown until the target is first compiled.
4293 Ordinarily this is not a problem, because dependencies are distributed
4294 sources: they preexist and do not need to be built. Suppose that
4295 @file{foo.c} includes @file{foo.h}. When it first compiles
4296 @file{foo.o}, @command{make} only knows that @file{foo.o} depends on
4297 @file{foo.c}. As a side-effect of this compilation @code{depcomp}
4298 records the @file{foo.h} dependency so that following invocations of
4299 @command{make} will honor it. In these conditions, it's clear there is
4300 no problem: either @file{foo.o} doesn't exist and has to be built
4301 (regardless of the dependencies), either accurate dependencies exist and
4302 they can be used to decide whether @file{foo.o} should be rebuilt.
4304 It's a different story if @file{foo.h} doesn't exist by the first
4305 @command{make} run. For instance there might be a rule to build
4306 @file{foo.h}. This time @file{file.o}'s build will fail because the
4307 compiler can't find @file{foo.h}. @command{make} failed to trigger the
4308 rule to build @file{foo.h} first by lack of dependency information.
4310 @vindex BUILT_SOURCES
4311 @cindex BUILT_SOURCES, defined
4313 The @code{BUILT_SOURCES} variable is a workaround for this problem. A
4314 source file listed in @code{BUILT_SOURCES} is made on @code{make all}
4315 or @code{make check} (or even @code{make install}) before other
4316 targets are processed. However, such a source file is not
4317 @emph{compiled} unless explicitly requested by mentioning it in some
4318 other @samp{_SOURCES} variable.
4320 So, to conclude our introductory example, we could use
4321 @code{BUILT_SOURCES = foo.h} to ensure @file{foo.h} gets built before
4322 any other target (including @file{foo.o}) during @code{make all} or
4325 @code{BUILT_SOURCES} is actually a bit of a misnomer, as any file which
4326 must be created early in the build process can be listed in this
4327 variable. Moreover, all built sources do not necessarily have to be
4328 listed in @code{BUILT_SOURCES}. For instance a generated @file{.c} file
4329 doesn't need to appear in @code{BUILT_SOURCES} (unless it is included by
4330 another source), because it's a known dependency of the associated
4333 It might be important to emphasize that @code{BUILT_SOURCES} is
4334 honored only by @code{make all}, @code{make check} and @code{make
4335 install}. This means you cannot build a specific target (e.g.,
4336 @code{make foo}) in a clean tree if it depends on a built source.
4337 However it will succeed if you have run @code{make all} earlier,
4338 because accurate dependencies are already available.
4340 The next section illustrates and discusses the handling of built sources
4344 * Built sources example:: Several ways to handle built sources.
4347 @node Built sources example
4348 @subsection Built sources example
4350 Suppose that @file{foo.c} includes @file{bindir.h}, which is
4351 installation-dependent and not distributed: it needs to be built. Here
4352 @file{bindir.h} defines the preprocessor macro @code{bindir} to the
4353 value of the @command{make} variable @code{bindir} (inherited from
4356 We suggest several implementations below. It's not meant to be an
4357 exhaustive listing of all ways to handle built sources, but it will give
4358 you a few ideas if you encounter this issue.
4360 @unnumberedsubsec First try
4362 This first implementation will illustrate the bootstrap issue mentioned
4363 in the previous section (@pxref{Sources}).
4365 Here is a tentative @file{Makefile.am}.
4371 nodist_foo_SOURCES = bindir.h
4372 CLEANFILES = bindir.h
4374 echo '#define bindir "$(bindir)"' >$@@
4377 This setup doesn't work, because Automake doesn't know that @file{foo.c}
4378 includes @file{bindir.h}. Remember, automatic dependency tracking works
4379 as a side-effect of compilation, so the dependencies of @file{foo.o} will
4380 be known only after @file{foo.o} has been compiled (@pxref{Dependencies}).
4381 The symptom is as follows.
4385 source='foo.c' object='foo.o' libtool=no \
4386 depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
4387 depmode=gcc /bin/sh ./depcomp \
4388 gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
4389 foo.c:2: bindir.h: No such file or directory
4390 make: *** [foo.o] Error 1
4393 @unnumberedsubsec Using @code{BUILT_SOURCES}
4395 A solution is to require @file{bindir.h} to be built before anything
4396 else. This is what @code{BUILT_SOURCES} is meant for (@pxref{Sources}).
4401 BUILT_SOURCES = bindir.h
4402 CLEANFILES = bindir.h
4404 echo '#define bindir "$(bindir)"' >$@@
4407 See how @file{bindir.h} get built first:
4411 echo '#define bindir "/usr/local/bin"' >bindir.h
4413 make[1]: Entering directory `/home/adl/tmp'
4414 source='foo.c' object='foo.o' libtool=no \
4415 depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
4416 depmode=gcc /bin/sh ./depcomp \
4417 gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
4418 gcc -g -O2 -o foo foo.o
4419 make[1]: Leaving directory `/home/adl/tmp'
4422 However, as said earlier, @code{BUILT_SOURCES} applies only to the
4423 @code{all}, @code{check}, and @code{install} targets. It still fails
4424 if you try to run @code{make foo} explicitly:
4428 test -z "bindir.h" || rm -f bindir.h
4429 test -z "foo" || rm -f foo
4431 % : > .deps/foo.Po # Suppress previously recorded dependencies
4433 source='foo.c' object='foo.o' libtool=no \
4434 depfile='.deps/foo.Po' tmpdepfile='.deps/foo.TPo' \
4435 depmode=gcc /bin/sh ./depcomp \
4436 gcc -I. -I. -g -O2 -c `test -f 'foo.c' || echo './'`foo.c
4437 foo.c:2: bindir.h: No such file or directory
4438 make: *** [foo.o] Error 1
4441 @unnumberedsubsec Recording dependencies manually
4443 Usually people are happy enough with @code{BUILT_SOURCES} because they
4444 never build targets such as @code{make foo} before @code{make all}, as
4445 in the previous example. However if this matters to you, you can
4446 avoid @code{BUILT_SOURCES} and record such dependencies explicitly in
4447 the @file{Makefile.am}.
4452 foo.$(OBJEXT): bindir.h
4453 CLEANFILES = bindir.h
4455 echo '#define bindir "$(bindir)"' >$@@
4458 You don't have to list @emph{all} the dependencies of @code{foo.o}
4459 explicitly, only those which might need to be built. If a dependency
4460 already exists, it will not hinder the first compilation and will be
4461 recorded by the normal dependency tracking code. (Note that after this
4462 first compilation the dependency tracking code will also have recorded
4463 the dependency between @code{foo.o} and @code{bindir.h}; so our explicit
4464 dependency is really useful to the first build only.)
4466 Adding explicit dependencies like this can be a bit dangerous if you are
4467 not careful enough. This is due to the way Automake tries not to
4468 overwrite your rules (it assumes you know better than it).
4469 @code{foo.$(OBJEXT): bindir.h} supersedes any rule Automake may want to
4470 output to build @code{foo.$(OBJEXT)}. It happens to work in this case
4471 because Automake doesn't have to output any @code{foo.$(OBJEXT):}
4472 target: it relies on a suffix rule instead (i.e., @code{.c.$(OBJEXT):}).
4473 Always check the generated @file{Makefile.in} if you do this.
4475 @unnumberedsubsec Build @file{bindir.h} from @file{configure}
4477 It's possible to define this preprocessor macro from @file{configure},
4478 either in @file{config.h} (@pxref{Defining Directories, , Defining
4479 Directories, autoconf, The Autoconf Manual}), or by processing a
4480 @file{bindir.h.in} file using @code{AC_CONFIG_FILES}
4481 (@pxref{Configuration Actions, ,Configuration Actions, autoconf, The
4484 At this point it should be clear that building @file{bindir.h} from
4485 @file{configure} work well for this example. @file{bindir.h} will exist
4486 before you build any target, hence will not cause any dependency issue.
4488 The Makefile can be shrunk as follows. We do not even have to mention
4496 However, it's not always possible to build sources from
4497 @file{configure}, especially when these sources are generated by a tool
4498 that needs to be built first...
4500 @unnumberedsubsec Build @file{bindir.c}, not @file{bindir.h}.
4502 Another attractive idea is to define @code{bindir} as a variable or
4503 function exported from @file{bindir.o}, and build @file{bindir.c}
4504 instead of @file{bindir.h}.
4507 noinst_PROGRAMS = foo
4508 foo_SOURCES = foo.c bindir.h
4509 nodist_foo_SOURCES = bindir.c
4510 CLEANFILES = bindir.c
4512 echo 'const char bindir[] = "$(bindir)";' >$@
4515 @file{bindir.h} contains just the variable's declaration and doesn't
4516 need to be built, so it won't cause any trouble. @file{bindir.o} is
4517 always dependent on @file{bindir.c}, so @file{bindir.c} will get built
4520 @unnumberedsubsec Which is best?
4522 There is no panacea, of course. Each solution has its merits and
4525 You cannot use @code{BUILT_SOURCES} if the ability to run @code{make
4526 foo} on a clean tree is important to you.
4528 You won't add explicit dependencies if you are leery of overriding
4529 an Automake rule by mistake.
4531 Building files from @file{./configure} is not always possible, neither
4532 is converting @file{.h} files into @file{.c} files.
4535 @node Other GNU Tools
4536 @chapter Other GNU Tools
4538 Since Automake is primarily intended to generate @file{Makefile.in}s for
4539 use in GNU programs, it tries hard to interoperate with other GNU tools.
4542 * Emacs Lisp:: Emacs Lisp
4553 @cindex _LISP primary, defined
4554 @cindex LISP primary, defined
4555 @cindex Primary variable, LISP
4561 Automake provides some support for Emacs Lisp. The @samp{LISP} primary
4562 is used to hold a list of @file{.el} files. Possible prefixes for this
4563 primary are @samp{lisp_} and @samp{noinst_}. Note that if
4564 @code{lisp_LISP} is defined, then @file{configure.ac} must run
4565 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
4567 Automake will byte-compile all Emacs Lisp source files using the Emacs
4568 found by @code{AM_PATH_LISPDIR}, if any was found.
4570 Byte-compiled Emacs Lisp files are not portable among all versions of
4571 Emacs, so it makes sense to turn this off if you expect sites to have
4572 more than one version of Emacs installed. Furthermore, many packages
4573 don't actually benefit from byte-compilation. Still, we recommend
4574 that you byte-compile your Emacs Lisp sources. It is probably better
4575 for sites with strange setups to cope for themselves than to make the
4576 installation less nice for everybody else.
4578 There are two ways to avoid byte-compiling. Historically, we have
4579 recommended the following construct.
4581 lisp_LISP = file1.el file2.el
4585 @code{ELCFILES} is an internal Automake variable that normally lists
4586 all @file{.elc} files that must be byte-compiled. Automake defines
4587 @code{ELCFILES} automatically from @code{lisp_LISP}. Emptying this
4588 variable explicitly prevents byte-compilation to occur.
4590 Since Automake 1.8, we now recommend using @code{lisp_DATA} instead. As
4593 lisp_DATA = file1.el file2.el
4596 Note that these two constructs are not equivalent. @code{_LISP} will
4597 not install a file if Emacs is not installed, while @code{_DATA} will
4598 always install its files.
4603 @cindex GNU Gettext support
4604 @cindex Gettext support
4605 @cindex Support for GNU Gettext
4607 If @code{AM_GNU_GETTEXT} is seen in @file{configure.ac}, then Automake
4608 turns on support for GNU gettext, a message catalog system for
4609 internationalization
4610 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
4612 The @code{gettext} support in Automake requires the addition of two
4613 subdirectories to the package, @file{intl} and @file{po}. Automake
4614 insures that these directories exist and are mentioned in
4617 @vindex dist_lisp_LISP
4618 @vindex dist_noinst_LISP
4619 Lisp sources are not distributed by default. You can prefix the
4620 @code{LISP} primary with @code{dist_}, as in @code{dist_lisp_LISP} or
4621 @code{dist_noinst_LISP}, to indicate that these files should be
4627 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
4628 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
4629 @xref{A Shared Library}.
4635 @cindex _JAVA primary, defined
4636 @cindex JAVA primary, defined
4637 @cindex Primary variable, JAVA
4639 Automake provides some minimal support for Java compilation with the
4640 @samp{JAVA} primary.
4642 Any @file{.java} files listed in a @samp{_JAVA} variable will be
4643 compiled with @code{JAVAC} at build time. By default, @file{.class}
4644 files are not included in the distribution.
4646 @cindex JAVA restrictions
4647 @cindex Restrictions for JAVA
4649 Currently Automake enforces the restriction that only one @samp{_JAVA}
4650 primary can be used in a given @file{Makefile.am}. The reason for this
4651 restriction is that, in general, it isn't possible to know which
4652 @file{.class} files were generated from which @file{.java} files -- so
4653 it would be impossible to know which files to install where. For
4654 instance, a @file{.java} file can define multiple classes; the resulting
4655 @file{.class} file names cannot be predicted without parsing the
4658 There are a few variables which are used when compiling Java sources:
4662 The name of the Java compiler. This defaults to @samp{javac}.
4665 The flags to pass to the compiler. This is considered to be a user
4666 variable (@pxref{User Variables}).
4669 More flags to pass to the Java compiler. This, and not
4670 @code{JAVACFLAGS}, should be used when it is necessary to put Java
4671 compiler flags into @file{Makefile.am}.
4674 The value of this variable is passed to the @samp{-d} option to
4675 @code{javac}. It defaults to @samp{$(top_builddir)}.
4678 This variable is an @code{sh} expression which is used to set the
4679 @code{CLASSPATH} environment variable on the @code{javac} command line.
4680 (In the future we will probably handle class path setting differently.)
4687 @cindex _PYTHON primary, defined
4688 @cindex PYTHON primary, defined
4689 @cindex Primary variable, PYTHON
4692 Automake provides support for Python compilation with the @samp{PYTHON}
4695 Any files listed in a @samp{_PYTHON} variable will be byte-compiled with
4696 @code{py-compile} at install time. @code{py-compile} actually creates
4697 both standard (@file{.pyc}) and byte-compiled (@file{.pyo}) versions of
4698 the source files. Note that because byte-compilation occurs at install
4699 time, any files listed in @samp{noinst_PYTHON} will not be compiled.
4700 Python source files are included in the distribution by default.
4702 Automake ships with an Autoconf macro called @code{AM_PATH_PYTHON} which
4703 will determine some Python-related directory variables (see below). If
4704 you have called @code{AM_PATH_PYTHON} from @file{configure.ac}, then you
4705 may use the following variables to list you Python source files in your
4706 variables: @samp{python_PYTHON}, @samp{pkgpython_PYTHON},
4707 @samp{pyexecdir_PYTHON}, @samp{pkgpyexecdir_PYTHON}, depending where you
4708 want your files installed.
4710 @code{AM_PATH_PYTHON([@var{VERSION}], [@var{ACTION-IF-FOUND}],
4711 [@var{ACTION-IF-NOT-FOUND}])} takes three optional arguments. It will
4712 search a Python interpreter on the system. The first argument, if
4713 present, is the minimum version of Python required for this package:
4714 @code{AM_PATH_PYTHON} will skip any Python interpreter which is older
4715 than @var{VERSION}. If an interpreter is found and satisfies
4716 @var{VERSION}, then @var{ACTION-IF-FOUND} is run. Otherwise,
4717 @var{ACTION-IF-NOT-FOUND} is run.
4719 If @var{ACTION-IF-NOT-FOUND} is not specified, the default is to abort
4720 configure. This is fine when Python is an absolute requirement for the
4721 package. Therefore if Python >= 2.2 is only @emph{optional} to the
4722 package, @code{AM_PATH_PYTHON} could be called as follows.
4725 AM_PATH_PYTHON(2.2,, :)
4728 @code{AM_PATH_PYTHON} creates several output variables based on the
4729 Python installation found during configuration.
4733 The name of the Python executable, or @code{:} if no suitable
4734 interpreter could be found.
4736 Assuming @var{ACTION-IF-NOT-FOUND} is used (otherwise @file{./configure}
4737 will abort if Python is absent), the value of @code{PYTHON} can be used
4738 to setup a conditional in order to disable the relevant part of a build
4742 AM_PATH_PYTHON(,, :)
4743 AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
4747 If the @var{ACTION-IF-NOT-FOUND}
4750 @item PYTHON_VERSION
4751 The Python version number, in the form @var{major}.@var{minor}
4752 (e.g. @samp{1.5}). This is currently the value of
4753 @code{sys.version[:3]}.
4756 The string @code{$@{prefix@}}. This term may be used in future work
4757 which needs the contents of Python's @code{sys.prefix}, but general
4758 consensus is to always use the value from configure.
4760 @item PYTHON_EXEC_PREFIX
4761 The string @code{$@{exec_prefix@}}. This term may be used in future work
4762 which needs the contents of Python's @code{sys.exec_prefix}, but general
4763 consensus is to always use the value from configure.
4765 @item PYTHON_PLATFORM
4766 The canonical name used by Python to describe the operating system, as
4767 given by @code{sys.platform}. This value is sometimes needed when
4768 building Python extensions.
4771 The directory name for the @file{site-packages} subdirectory of the
4772 standard Python install tree.
4775 This is is the directory under @code{pythondir} which is named after the
4776 package. That is, it is @samp{$(pythondir)/$(PACKAGE)}. It is provided
4780 This is the directory where Python extension modules (shared libraries)
4781 should be installed.
4784 This is a convenience variable which is defined as
4785 @samp{$(pyexecdir)/$(PACKAGE)}.
4788 All these directory variables have values that start with either
4789 @code{$@{prefix@}} or @code{$@{exec_prefix@}} unexpanded. This works
4790 fine in @file{Makefiles}, but it makes these variables hard to use in
4791 @file{configure}. This is mandated by the GNU coding standards, so
4792 that the user can run @code{make prefix=/foo install}. The Autoconf
4793 manual has a section with more details on this topic
4794 (@pxref{Installation Directory Variables, , Installation Directory
4795 Variables, autoconf, The Autoconf Manual}).
4799 @chapter Building documentation
4801 Currently Automake provides support for Texinfo and man pages.
4805 * Man pages:: Man pages
4812 @cindex _TEXINFOS primary, defined
4813 @cindex TEXINFOS primary, defined
4814 @cindex Primary variable, TEXINFOS
4815 @cindex HTML output using Texinfo
4816 @cindex PDF output using Texinfo
4817 @cindex PS output using Texinfo
4818 @cindex DVI output using Texinfo
4820 If the current directory contains Texinfo source, you must declare it
4821 with the @samp{TEXINFOS} primary. Generally Texinfo files are converted
4822 into info, and thus the @code{info_TEXINFOS} variable is most commonly used
4823 here. Any Texinfo source file must end in the @file{.texi},
4824 @file{.txi}, or @file{.texinfo} extension. We recommend @file{.texi}
4827 @vindex info_TEXINFOS
4829 Automake generates rules to build @file{.info}, @file{.dvi}, @file{.ps},
4830 @file{.pdf} and @file{.html} files from your Texinfo sources.
4831 The @file{.info} files are built by @code{make all} and installed
4832 by @code{make install} (unless you use @code{no-installinfo}, see below).
4833 The other files can be built on request by @code{make dvi}, @code{make ps},
4834 @code{make pdf} and @code{make html}.
4836 @cindex Texinfo flag, VERSION
4837 @cindex Texinfo flag, UPDATED
4838 @cindex Texinfo flag, EDITION
4839 @cindex Texinfo flag, UPDATED-MONTH
4841 @cindex VERSION Texinfo flag
4842 @cindex UPDATED Texinfo flag
4843 @cindex EDITION Texinfo flag
4844 @cindex UPDATED-MONTH Texinfo flag
4848 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
4849 that file will be automatically generated. The file @file{version.texi}
4850 defines four Texinfo flag you can reference using
4851 @code{@@value@{EDITION@}}, @code{@@value@{VERSION@}},
4852 @code{@@value@{UPDATED@}}, and @code{@@value@{UPDATED-MONTH@}}.
4857 Both of these flags hold the version number of your program. They are
4858 kept separate for clarity.
4861 This holds the date the primary @file{.texi} file was last modified.
4864 This holds the name of the month in which the primary @file{.texi} file
4868 The @file{version.texi} support requires the @code{mdate-sh} program;
4869 this program is supplied with Automake and automatically included when
4870 @code{automake} is invoked with the @code{--add-missing} option.
4872 If you have multiple Texinfo files, and you want to use the
4873 @file{version.texi} feature, then you have to have a separate version
4874 file for each Texinfo file. Automake will treat any include in a
4875 Texinfo file that matches @samp{vers*.texi} just as an automatically
4876 generated version file.
4878 Sometimes an info file actually depends on more than one @file{.texi}
4879 file. For instance, in GNU Hello, @file{hello.texi} includes the file
4880 @file{gpl.texi}. You can tell Automake about these dependencies using
4881 the @code{@var{texi}_TEXINFOS} variable. Here is how GNU Hello does it:
4886 info_TEXINFOS = hello.texi
4887 hello_TEXINFOS = gpl.texi
4892 By default, Automake requires the file @file{texinfo.tex} to appear in
4893 the same directory as the Texinfo source (this can be changed using the
4894 @code{TEXINFO_TEX} variable, see below). However, if you used
4895 @code{AC_CONFIG_AUX_DIR} in @file{configure.ac} (@pxref{Input, , Finding
4896 `configure' Input, autoconf, The Autoconf Manual}), then
4897 @file{texinfo.tex} is looked for there. Automake supplies
4898 @file{texinfo.tex} if @samp{--add-missing} is given.
4900 @opindex no-texinfo.tex
4902 The option @samp{no-texinfo.tex} can be used to eliminate the
4903 requirement for @file{texinfo.tex}. Use of the variable
4904 @code{TEXINFO_TEX} is preferable, however, because that allows the
4905 @code{dvi}, @code{ps}, and @code{pdf} targets to still work.
4907 @cindex Rule, install-info
4908 @cindex Rule, noinstall-info
4909 @cindex Target, install-info
4910 @cindex Target, noinstall-info
4911 @cindex install-info target
4912 @cindex noinstall-info target
4914 @opindex no-installinfo
4915 @trindex install-info
4917 Automake generates an @code{install-info} rule; some people apparently
4918 use this. By default, info pages are installed by @samp{make install}.
4919 This can be prevented via the @code{no-installinfo} option.
4921 The following variables are used by the Texinfo build rules.
4925 The name of the program invoked to build @file{.info} files. This
4926 variable is defined by Automake. If the @code{makeinfo} program is
4927 found on the system then it will be used by default; otherwise
4928 @code{missing} will be used instead.
4931 The command invoked to build @file{.html} files. Automake
4932 defines this to @code{$(MAKEINFO) --html}.
4935 User flags passed to each invocation of @code{$(MAKEINFO)} and
4936 @code{$(MAKEINFOHTML)}. This user variable (@pxref{User Variables}) is
4937 not expected to be defined in any @file{Makefile}; it can be used by
4938 users to pass extra flags to suit their needs.
4940 @item AM_MAKEINFOFLAGS
4941 @itemx AM_MAKEINFOHTMLFLAGS
4942 Maintainer flags passed to each @code{makeinfo} invocation. These
4943 are maintainer variables that can be overridden in @file{Makefile.am}.
4944 @code{$(AM_MAKEINFOFLAGS)} is passed to @code{makeinfo} when building
4945 @file{.info} files; and @code{$(AM_MAKEINFOHTMLFLAGS)} is used when
4946 building @file{.html} files.
4948 For instance the following setting can be used to obtain one single
4949 @file{.html} file per manual, without node separators.
4951 AM_MAKEINFOHTMLFLAGS = --no-headers --no-split
4954 By default, @code{$(AM_MAKEINFOHTMLFLAGS)} is set to
4955 @code{$(AM_MAKEINFOFLAGS)}. This means that defining
4956 @code{$(AM_MAKEINFOFLAGS)} without defining
4957 @code{$(AM_MAKEINFOHTMLFLAGS)} will impact builds of both @file{.info}
4958 and @file{.html} files.
4961 The name of the command that converts a @file{.texi} file into a
4962 @file{.dvi} file. This defaults to @code{texi2dvi}, a script that ships
4963 with the Texinfo package.
4966 The name of the command that translates a @file{.texi} file into a
4967 @file{.pdf} file. This defaults to @code{$(TEXI2DVI) --pdf --batch}.
4970 The name of the command that build a @file{.ps} file out of a
4971 @file{.dvi} file. This defaults to @code{dvips}.
4975 If your package has Texinfo files in many directories, you can use the
4976 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
4977 @file{texinfo.tex} for your package. The value of this variable should
4978 be the relative path from the current @file{Makefile.am} to
4982 TEXINFO_TEX = ../doc/texinfo.tex
4990 @cindex _MANS primary, defined
4991 @cindex MANS primary, defined
4992 @cindex Primary variable, MANS
4994 A package can also include man pages (but see the GNU standards on this
4995 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.) Man
4996 pages are declared using the @samp{MANS} primary. Generally the
4997 @code{man_MANS} variable is used. Man pages are automatically installed in
4998 the correct subdirectory of @code{mandir}, based on the file extension.
5002 File extensions such as @samp{.1c} are handled by looking for the valid
5003 part of the extension and using that to determine the correct
5004 subdirectory of @code{mandir}. Valid section names are the digits
5005 @samp{0} through @samp{9}, and the letters @samp{l} and @samp{n}.
5007 Sometimes developers prefer to name a man page something like
5008 @file{foo.man} in the source, and then rename it to have the correct
5009 suffix, e.g. @file{foo.1}, when installing the file. Automake also
5010 supports this mode. For a valid section named @var{SECTION}, there is a
5011 corresponding directory named @samp{man@var{SECTION}dir}, and a
5012 corresponding @samp{_MANS} variable. Files listed in such a variable
5013 are installed in the indicated section. If the file already has a
5014 valid suffix, then it is installed as-is; otherwise the file suffix is
5015 changed to match the section.
5017 For instance, consider this example:
5019 man1_MANS = rename.man thesame.1 alsothesame.1c
5022 In this case, @file{rename.man} will be renamed to @file{rename.1} when
5023 installed, but the other files will keep their names.
5025 @cindex Rule, install-man
5026 @cindex Rule, noinstall-man
5027 @cindex Target, install-man
5028 @cindex Target, noinstall-man
5029 @cindex install-man target
5030 @cindex noinstall-man target
5032 @c Use @samp{make install} per documentation: (texi)code.
5033 By default, man pages are installed by @samp{make install}. However,
5034 since the GNU project does not require man pages, many maintainers do
5035 not expend effort to keep the man pages up to date. In these cases, the
5036 @code{no-installman} option will prevent the man pages from being
5037 installed by default. The user can still explicitly install them via
5038 @samp{make install-man}.
5039 @opindex no-installman
5040 @trindex install-man
5042 Here is how the man pages are handled in GNU @code{cpio} (which includes
5043 both Texinfo documentation and man pages):
5046 man_MANS = cpio.1 mt.1
5047 EXTRA_DIST = $(man_MANS)
5050 Man pages are not currently considered to be source, because it is not
5051 uncommon for man pages to be automatically generated. Therefore they
5052 are not automatically included in the distribution. However, this can
5053 be changed by use of the @samp{dist_} prefix.
5055 The @samp{nobase_} prefix is meaningless for man pages and is
5060 @chapter What Gets Installed
5062 @cindex Installation support
5063 @cindex make install support
5065 @section Basics of installation
5067 Naturally, Automake handles the details of actually installing your
5068 program once it has been built. All files named by the various
5069 primaries are automatically installed in the appropriate places when the
5070 user runs @code{make install}.
5072 A file named in a primary is installed by copying the built file into
5073 the appropriate directory. The base name of the file is used when
5077 bin_PROGRAMS = hello subdir/goodbye
5080 In this example, both @samp{hello} and @samp{goodbye} will be installed
5081 in @code{$(bindir)}.
5083 Sometimes it is useful to avoid the basename step at install time. For
5084 instance, you might have a number of header files in subdirectories of
5085 the source tree which are laid out precisely how you want to install
5086 them. In this situation you can use the @samp{nobase_} prefix to
5087 suppress the base name step. For example:
5090 nobase_include_HEADERS = stdio.h sys/types.h
5093 Will install @file{stdio.h} in @code{$(includedir)} and @file{types.h}
5094 in @code{$(includedir)/sys}.
5096 @section The two parts of install
5098 Automake generates separate @code{install-data} and @code{install-exec}
5099 rules, in case the installer is installing on multiple machines which
5100 share directory structure---these targets allow the machine-independent
5101 parts to be installed only once. @code{install-exec} installs
5102 platform-dependent files, and @code{install-data} installs
5103 platform-independent files. The @code{install} target depends on both
5104 of these targets. While Automake tries to automatically segregate
5105 objects into the correct category, the @file{Makefile.am} author is, in
5106 the end, responsible for making sure this is done correctly.
5107 @trindex install-data
5108 @trindex install-exec
5110 @cindex Install, two parts of
5112 Variables using the standard directory prefixes @samp{data},
5113 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
5114 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
5115 installed by @samp{install-data}.
5117 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
5118 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
5119 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
5120 @samp{install-exec}.
5122 Any variable using a user-defined directory prefix with @samp{exec} in
5123 the name (e.g. @samp{myexecbin_PROGRAMS} is installed by
5124 @samp{install-exec}. All other user-defined prefixes are installed by
5125 @samp{install-data}.
5127 @section Extending installation
5129 It is possible to extend this mechanism by defining an
5130 @code{install-exec-local} or @code{install-data-local} rule. If these
5131 rules exist, they will be run at @samp{make install} time. These
5132 rules can do almost anything; care is required.
5133 @trindex install-exec-local
5134 @trindex install-data-local
5136 Automake also supports two install hooks, @code{install-exec-hook} and
5137 @code{install-data-hook}. These hooks are run after all other install
5138 rules of the appropriate type, exec or data, have completed. So, for
5139 instance, it is possible to perform post-installation modifications
5140 using an install hook.
5141 @cindex Install hook
5143 @section Staged installs
5146 Automake generates support for the @samp{DESTDIR} variable in all
5147 install rules. @samp{DESTDIR} is used during the @samp{make install}
5148 step to relocate install objects into a staging area. Each object and
5149 path is prefixed with the value of @samp{DESTDIR} before being copied
5150 into the install area. Here is an example of typical DESTDIR usage:
5153 make DESTDIR=/tmp/staging install
5156 This places install objects in a directory tree built under
5157 @file{/tmp/staging}. If @file{/gnu/bin/foo} and
5158 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
5159 would install @file{/tmp/staging/gnu/bin/foo} and
5160 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
5162 This feature is commonly used to build install images and packages. For
5163 more information, see @ref{Makefile Conventions, , , standards, The GNU
5166 Support for @samp{DESTDIR} is implemented by coding it directly into the
5167 install rules. If your @file{Makefile.am} uses a local install rule
5168 (e.g., @code{install-exec-local}) or an install hook, then you must
5169 write that code to respect @samp{DESTDIR}.
5171 @section Rules for the user
5173 Automake also generates rules for targets @code{uninstall},
5174 @code{installdirs}, and @code{install-strip}.
5176 @trindex installdirs
5177 @trindex install-strip
5179 Automake supports @code{uninstall-local} and @code{uninstall-hook}.
5180 There is no notion of separate uninstalls for ``exec'' and ``data'', as
5181 these features would not provide additional functionality.
5183 Note that @code{uninstall} is not meant as a replacement for a real
5188 @chapter What Gets Cleaned
5190 @cindex make clean support
5192 The GNU Makefile Standards specify a number of different clean rules.
5193 See @xref{Standard Targets, , Standard Targets for Users, standards,
5194 The GNU Coding Standards}.
5196 Generally the files that can be cleaned are determined automatically by
5197 Automake. Of course, Automake also recognizes some variables that can
5198 be defined to specify additional files to clean. These variables are
5199 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
5200 @code{MAINTAINERCLEANFILES}.
5201 @vindex MOSTLYCLEANFILES
5203 @vindex DISTCLEANFILES
5204 @vindex MAINTAINERCLEANFILES
5206 As the GNU Standards aren't always explicit as to which files should be
5207 removed by which rule, we've adopted a heuristic which we believe was
5208 first formulated by Fran@,{c}ois Pinard:
5212 If @code{make} built it, and it is commonly something that one would
5213 want to rebuild (for instance, a @file{.o} file), then
5214 @code{mostlyclean} should delete it.
5217 Otherwise, if @code{make} built it, then @code{clean} should delete it.
5220 If @code{configure} built it, then @code{distclean} should delete it.
5223 If the maintainer built it (for instance, a @file{.info} file), then
5224 @code{maintainer-clean} should delete it. However
5225 @code{maintainer-clean} should not delete anything that needs to exist
5226 in order to run @code{./configure && make}.
5229 We recommend that you follow this same set of heuristics in your
5234 @chapter What Goes in a Distribution
5236 @section Basics of distribution
5240 The @code{dist} rule in the generated @file{Makefile.in} can be used
5241 to generate a gzip'd @code{tar} file and other flavors of archive for
5242 distribution. The files is named based on the @samp{PACKAGE} and
5243 @samp{VERSION} variables defined by @code{AM_INIT_AUTOMAKE}
5244 (@pxref{Macros}); more precisely the gzip'd @code{tar} file is named
5245 @samp{@var{package}-@var{version}.tar.gz}.
5249 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
5250 is run. The default setting is @samp{--best}.
5252 For the most part, the files to distribute are automatically found by
5253 Automake: all source files are automatically included in a distribution,
5254 as are all @file{Makefile.am}s and @file{Makefile.in}s. Automake also
5255 has a built-in list of commonly used files which are automatically
5256 included if they are found in the current directory (either physically,
5257 or as the target of a @file{Makefile.am} rule). This list is printed by
5258 @samp{automake --help}. Also, files which are read by @code{configure}
5259 (i.e. the source files corresponding to the files specified in various
5260 Autoconf macros such as @code{AC_CONFIG_FILES} and siblings) are
5261 automatically distributed. Files included in @file{Makefile.am}s (using
5262 @code{include}) or in @file{configure.ac} (using @code{m4_include}), and
5263 helper scripts installed with @samp{automake --add-missing} are also
5266 @cvindex m4_include, distribution
5268 Still, sometimes there are files which must be distributed, but which
5269 are not covered in the automatic rules. These files should be listed in
5270 the @code{EXTRA_DIST} variable. You can mention files from
5271 subdirectories in @code{EXTRA_DIST}.
5273 You can also mention a directory in @code{EXTRA_DIST}; in this case the
5274 entire directory will be recursively copied into the distribution.
5275 Please note that this will also copy @emph{everything} in the directory,
5276 including CVS/RCS version control files. We recommend against using
5280 If you define @code{SUBDIRS}, Automake will recursively include the
5281 subdirectories in the distribution. If @code{SUBDIRS} is defined
5282 conditionally (@pxref{Conditionals}), Automake will normally include all
5283 directories that could possibly appear in @code{SUBDIRS} in the
5284 distribution. If you need to specify the set of directories
5285 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
5286 list of subdirectories to include in the distribution (@pxref{Top level}).
5287 @vindex DIST_SUBDIRS
5290 @section Fine-grained distribution control
5292 Sometimes you need tighter control over what does @emph{not} go into the
5293 distribution; for instance you might have source files which are
5294 generated and which you do not want to distribute. In this case
5295 Automake gives fine-grained control using the @samp{dist} and
5296 @samp{nodist} prefixes. Any primary or @samp{_SOURCES} variable can be
5297 prefixed with @samp{dist_} to add the listed files to the distribution.
5298 Similarly, @samp{nodist_} can be used to omit the files from the
5303 As an example, here is how you would cause some data to be distributed
5304 while leaving some source code out of the distribution:
5307 dist_data_DATA = distribute-this
5309 nodist_foo_SOURCES = do-not-distribute.c
5312 @section The dist hook
5316 Occasionally it is useful to be able to change the distribution before
5317 it is packaged up. If the @code{dist-hook} rule exists, it is run
5318 after the distribution directory is filled, but before the actual tar
5319 (or shar) file is created. One way to use this is for distributing
5320 files in subdirectories for which a new @file{Makefile.am} is overkill:
5324 mkdir $(distdir)/random
5325 cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
5328 Another way to to use this is for removing unnecessary files that get
5329 recursively included by specifying a directory in EXTRA_DIST:
5335 rm -rf `find $(distdir)/doc -name CVS`
5340 Two variables that come handy when writing @code{dist-hook} rules are
5341 @code{$(distdir)} and @code{$(top_distdir)}.
5343 @code{$(distdir)} points to the directory where the @code{dist} rule
5344 will copy files from the current directory before creating the
5345 tarball. If you are at the top-level directory, then @code{distdir =
5346 $(PACKAGE)-$(VERSION)}. When used from subdirectory named
5347 @file{foo/}, then @code{distdir = ../$(PACKAGE)-$(VERSION)/foo}.
5349 @code{$(top_distdir)} always points to the root directory of the
5350 distributed tree. At the top-level it's equal to @code{$(distdir)}.
5351 In the @file{foo/} subdirectory
5352 @code{top_distdir = ../$(PACKAGE)-$(VERSION)}.
5354 Note that when packages are nested using @code{AC_CONFIG_SUBDIRS}
5355 (@pxref{Subdirectories, AC_CONFIG_SUBDIRS, Configuring Other Packages
5356 in Subdirectories, autoconf, The Autoconf Manual}), then
5357 @code{$(distdir)} and @code{$(top_distdir)} are relative to the
5358 package where @code{make dist} was run, not to any sub-packages
5361 @section Checking the distribution
5363 @cindex make distcheck
5364 @cindex make distcleancheck
5365 @vindex distcleancheck_listfiles
5366 @cindex make distuninstallcheck
5367 @vindex distuninstallcheck_listfiles
5369 Automake also generates a @code{distcheck} rule which can be of help
5370 to ensure that a given distribution will actually work.
5371 @code{distcheck} makes a distribution, then tries to do a @code{VPATH}
5372 build, run the test suite, and finally make another tarfile to ensure the
5373 distribution is self-contained.
5376 Building the package involves running @code{./configure}. If you need
5377 to supply additional flags to @code{configure}, define them in the
5378 @code{DISTCHECK_CONFIGURE_FLAGS} variable, either in your top-level
5379 @file{Makefile.am}, or on the command line when invoking @code{make}.
5380 @vindex DISTCHECK_CONFIGURE_FLAGS
5382 If the @code{distcheck-hook} rule is defined in your top-level
5383 @file{Makefile.am}, then it will be invoked by @code{distcheck} after
5384 the new distribution has been unpacked, but before the unpacked copy
5385 is configured and built. Your @code{distcheck-hook} can do almost
5386 anything, though as always caution is advised. Generally this hook is
5387 used to check for potential distribution errors not caught by the
5388 standard mechanism. Note that @code{distcheck-hook} as well as
5389 @code{DISTCHECK_CONFIGURE_FLAGS} are not honored in a subpackage
5390 @file{Makefile.am}, but the @code{DISTCHECK_CONFIGURE_FLAGS} are
5391 passed down to the @code{configure} script of the subpackage.
5394 Speaking about potential distribution errors, @code{distcheck} will also
5395 ensure that the @code{distclean} rule actually removes all built
5396 files. This is done by running @code{make distcleancheck} at the end of
5397 the @code{VPATH} build. By default, @code{distcleancheck} will run
5398 @code{distclean} and then make sure the build tree has been emptied by
5399 running @code{$(distcleancheck_listfiles)}. Usually this check will
5400 find generated files that you forgot to add to the @code{DISTCLEANFILES}
5401 variable (@pxref{Clean}).
5402 @trindex distcleancheck
5404 The @code{distcleancheck} behavior should be OK for most packages,
5405 otherwise you have the possibility to override the definition of
5406 either the @code{distcleancheck} rule, or the
5407 @code{$(distcleancheck_listfiles)} variable. For instance to disable
5408 @code{distcleancheck} completely, add the following rule to your
5409 top-level @file{Makefile.am}:
5410 @vindex distcleancheck_listfiles
5417 If you want @code{distcleancheck} to ignore built files which have not
5418 been cleaned because they are also part of the distribution, add the
5419 following definition instead:
5422 distcleancheck_listfiles = \
5423 find -type f -exec sh -c 'test -f $(srcdir)/@{@} || echo @{@}' ';'
5426 The above definition is not the default because it's usually an error if
5427 your Makefiles cause some distributed files to be rebuilt when the user
5428 build the package. (Think about the user missing the tool required to
5429 build the file; or if the required tool is built by your package,
5430 consider the cross-compilation case where it can't be run.) There is
5431 a FAQ entry about this (@pxref{distcleancheck}), make sure you read it
5432 before playing with @code{distcleancheck_listfiles}.
5434 @code{distcheck} also checks that the @code{uninstall} rule works
5435 properly, both for ordinary and @samp{DESTDIR} builds. It does this
5436 by invoking @code{make uninstall}, and then it checks the install tree
5437 to see if any files are left over. This check will make sure that you
5438 correctly coded your @code{uninstall}-related rules.
5440 By default, the checking is done by the @code{distuninstallcheck} rule,
5441 and the list of files in the install tree is generated by
5442 @code{$(distuninstallcheck_listfiles}) (this is a variable whose value is
5443 a shell command to run that prints the list of files to stdout).
5445 Either of these can be overridden to modify the behavior of
5446 @code{distcheck}. For instance, to disable this check completely, you
5454 @section The types of distributions
5456 Automake generates rules to provide archives of the project for
5457 distributions in various formats. Their targets are:
5460 @item @code{dist-bzip2}
5461 Generate a bzip2 tar archive of the distribution. bzip2 archives are
5462 frequently smaller than gzipped archives.
5465 @item @code{dist-gzip}
5466 Generate a gzip tar archive of the distribution.
5469 @item @code{dist-shar}
5470 Generate a shar archive of the distribution.
5473 @item @code{dist-zip}
5474 Generate a zip archive of the distribution.
5477 @item @code{dist-tarZ}
5478 Generate a compressed tar archive of
5483 The rule @code{dist} (and its historical synonym @code{dist-all}) will
5484 create archives in all the enabled formats, @ref{Options}. By
5485 default, only the @code{dist-gzip} target is hooked to @code{dist}.
5489 @chapter Support for test suites
5494 Automake supports two forms of test suites.
5496 @section Simple Tests
5498 If the variable @code{TESTS} is defined, its value is taken to be a list
5499 of programs to run in order to do the testing. The programs can either
5500 be derived objects or source objects; the generated rule will look both
5501 in @code{srcdir} and @file{.}. Programs needing data files should look
5502 for them in @code{srcdir} (which is both an environment variable and a
5503 make variable) so they work when building in a separate directory
5504 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
5505 Manual}), and in particular for the @code{distcheck} rule
5508 @cindex Exit status 77, special interpretation
5510 The number of failures will be printed at the end of the run. If a
5511 given test program exits with a status of 77, then its result is ignored
5512 in the final count. This feature allows non-portable tests to be
5513 ignored in environments where they don't make sense.
5515 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
5516 variables for the test run; the environment variable @code{srcdir} is
5517 set in the rule. If all your test programs are scripts, you can also
5518 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
5519 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
5521 @vindex TESTS_ENVIRONMENT
5523 @cindex Tests, expected failure
5524 @cindex Expected test failure
5526 You may define the variable @code{XFAIL_TESTS} to a list of tests
5527 (usually a subset of @code{TESTS}) that are expected to fail. This will
5528 reverse the result of those tests.
5531 Automake ensures that each program listed in @code{TESTS} is built
5532 before any tests are run; you can list both source and derived programs
5533 in @code{TESTS}. For instance, you might want to run a C program as a
5534 test. To do this you would list its name in @code{TESTS} and also in
5535 @code{check_PROGRAMS}, and then specify it as you would any other
5538 @section DejaGnu Tests
5540 If @uref{ftp://ftp.gnu.org/gnu/dejagnu/, @samp{dejagnu}} appears in
5541 @code{AUTOMAKE_OPTIONS}, then a @code{dejagnu}-based test suite is
5542 assumed. The variable @code{DEJATOOL} is a list of names which are
5543 passed, one at a time, as the @code{--tool} argument to @code{runtest}
5544 invocations; it defaults to the name of the package.
5546 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
5547 @code{--srcdir} flags that are passed to dejagnu by default; this can be
5548 overridden if necessary.
5549 @vindex RUNTESTDEFAULTFLAGS
5551 The variables @code{EXPECT} and @code{RUNTEST} can
5552 also be overridden to provide project-specific values. For instance,
5553 you will need to do this if you are testing a compiler toolchain,
5554 because the default values do not take into account host and target
5561 The contents of the variable @code{RUNTESTFLAGS} are passed to the
5562 @code{runtest} invocation. This is considered a ``user variable''
5563 (@pxref{User Variables}). If you need to set @code{runtest} flags in
5564 @file{Makefile.am}, you can use @code{AM_RUNTESTFLAGS} instead.
5565 @vindex RUNTESTFLAGS
5566 @vindex AM_RUNTESTFLAGS
5568 @cindex @file{site.exp}
5569 Automake will generate rules to create a local @file{site.exp} file,
5570 defining various variables detected by @code{./configure}. This file
5571 is automatically read by DejaGnu. It is OK for the user of a package
5572 to edit this file in order to tune the test suite. However this is
5573 not the place where the test suite author should define new variables:
5574 this should be done elsewhere in the real test suite code.
5575 Especially, @file{site.exp} should not be distributed.
5577 For more information regarding DejaGnu test suites, see @xref{Top, , ,
5578 dejagnu, The DejaGnu Manual}.
5580 In either case, the testing is done via @samp{make check}.
5582 @section Install Tests
5584 The @code{installcheck} target is available to the user as a way to
5585 run any tests after the package has been installed. You can add tests
5586 to this by writing an @code{installcheck-local} rule.
5590 @chapter Rebuilding Makefiles
5591 @cindex rebuild rules
5593 Automake generates rules to automatically rebuild @file{Makefile}s,
5594 @file{configure}, and other derived files like @file{Makefile.in}.
5596 @cvindex AM_MAINTAINER_MODE
5597 If you are using @code{AM_MAINTAINER_MODE} in @file{configure.ac}, then
5598 these automatic rebuilding rules are only enabled in maintainer mode.
5600 @vindex ACLOCAL_AMFLAGS
5601 Sometimes you need to run @code{aclocal} with an argument like @code{-I}
5602 to tell it where to find @file{.m4} files. Since sometimes @code{make}
5603 will automatically run @code{aclocal}, you need a way to specify these
5604 arguments. You can do this by defining @code{ACLOCAL_AMFLAGS}; this
5605 holds arguments which are passed verbatim to @code{aclocal}. This variable
5606 is only useful in the top-level @file{Makefile.am}.
5608 @vindex CONFIG_STATUS_DEPENDENCIES
5609 @vindex CONFIGURE_DEPENDENCIES
5610 @cindex @file{version.sh}, example
5611 @cindex @file{version.m4}, example
5613 Sometimes it is convenient to supplement the rebuild rules for
5614 @file{configure} or @file{config.status} with additional dependencies.
5615 The variables @code{CONFIGURE_DEPENDENCIES} and
5616 @code{CONFIG_STATUS_DEPENDENCIES} can be used to list these extra
5617 dependencies. These variable should be defined in all
5618 @file{Makefile}s of the tree (because these two rebuild rules are
5619 output in all them), so it is safer and easier to @code{AC_SUBST} them
5620 from @file{configure.ac}. For instance the following statement will
5621 cause @file{configure} to be rerun each time @file{version.sh} is
5624 AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/version.sh'])
5627 Note the @code{$(top_srcdir)/} in the filename. Since this variable
5628 is to be used in all @file{Makefile}s, its value must be sensible at
5629 any level in the build hierarchy.
5631 Beware not to mistake @code{CONFIGURE_DEPENDENCIES} for
5632 @code{CONFIG_STATUS_DEPENDENCIES}.
5634 @code{CONFIGURE_DEPENDENCIES} adds dependencies to the
5635 @file{configure} rule, whose effect is to run @code{autoconf}. This
5636 variable should be seldom used, because @code{automake} already tracks
5637 @code{m4_include}d files. However it can be useful when playing
5638 tricky games with @code{m4_esyscmd} or similar non-recommendable
5639 macros with side effects.
5641 @code{CONFIG_STATUS_DEPENDENCIES} adds dependencies to the
5642 @file{config.status} rule, whose effect is to run @file{configure}.
5643 This variable should therefore carry any non-standard source that may
5644 be read as a side effect of running configure, like @file{version.sh}
5645 in the example above.
5647 Speaking of @file{version.sh} scripts, we recommend against them
5648 today. They are mainly used when the version of a package is updated
5649 automatically by a script (e.g., in daily builds). Here is what some
5650 old-style @file{configure.ac}s may look like:
5653 . $srcdir/version.sh
5654 AM_INIT_AUTOMAKE([name], $VERSION_NUMBER)
5658 Here, @file{version.sh} is a shell fragment that sets
5659 @code{VERSION_NUMBER}. The problem with this example is that
5660 @code{automake} cannot track dependencies (listing @file{version.sh}
5661 in @code{CONFIG_STATUS_DEPENDENCIES}, and distributing this file is up
5662 to the user), and that it uses the obsolete form of @code{AC_INIT} and
5663 @code{AM_INIT_AUTOMAKE}. Upgrading to the new syntax is not
5664 straightforward, because shell variables are not allowed in
5665 @code{AC_INIT}'s arguments. We recommend that @file{version.sh} be
5666 replaced by an M4 file that is included by @file{configure.ac}:
5668 m4_include([version.m4])
5669 AC_INIT([name], VERSION_NUMBER)
5674 Here @file{version.m4} could contain something like
5675 @code{m4_define([VERSION_NUMBER], [1.2])}. The advantage of this
5676 second form is that @code{automake} will take care of the dependencies
5677 when defining the rebuild rule, and will also distribute the file
5678 automatically. An inconvenience is that @code{autoconf} will now be
5679 rerun each time the version number is bumped, when only
5680 @file{configure} had to be rerun in the previous setup.
5684 @chapter Changing Automake's Behavior
5686 Various features of Automake can be controlled by options in the
5687 @file{Makefile.am}. Such options are applied on a per-@file{Makefile}
5688 basis when listed in a special @file{Makefile} variable named
5689 @code{AUTOMAKE_OPTIONS}. They are applied globally to all processed
5690 @file{Makefiles} when listed in the first argument of
5691 @code{AM_INIT_AUTOMAKE} in @file{configure.ac}. Currently understood
5693 @vindex AUTOMAKE_OPTIONS
5698 @itemx @code{foreign}
5699 @itemx @code{cygnus}
5700 @cindex Option, gnits
5702 @cindex Option, foreign
5703 @cindex Option, cygnus
5705 Set the strictness as appropriate. The @code{gnits} option also implies
5706 @code{readme-alpha} and @code{check-news}.
5708 @item @code{ansi2knr}
5709 @itemx @code{@var{path}/ansi2knr}
5710 @cindex Option, ansi2knr
5711 Turn on automatic de-ANSI-fication. @xref{ANSI}. If preceded by a
5712 path, the generated @file{Makefile.in} will look in the specified
5713 directory to find the @file{ansi2knr} program. The path should be a
5714 relative path to another directory in the same distribution (Automake
5715 currently does not check this).
5717 @item @code{check-news}
5718 @cindex Option, check-news
5719 Cause @code{make dist} to fail unless the current version number appears
5720 in the first few lines of the @file{NEWS} file.
5722 @item @code{dejagnu}
5723 @cindex Option, dejagnu
5724 Cause @code{dejagnu}-specific rules to be generated. @xref{Tests}.
5726 @item @code{dist-bzip2}
5727 @cindex Option, dist-bzip2
5728 Hook @code{dist-bzip2} to @code{dist}.
5731 @item @code{dist-shar}
5732 @cindex Option, dist-shar
5733 Hook @code{dist-shar} to @code{dist}.
5736 @item @code{dist-zip}
5737 @cindex Option, dist-zip
5738 Hook @code{dist-zip} to @code{dist}.
5741 @item @code{dist-tarZ}
5742 @cindex Option, dist-tarZ
5743 Hook @code{dist-tarZ} to @code{dist}.
5746 @item @code{no-define}
5747 @cindex Option, no-define
5748 This options is meaningful only when passed as an argument to
5749 @code{AM_INIT_AUTOMAKE}. It will prevent the @code{PACKAGE} and
5750 @code{VERSION} variables to be @code{AC_DEFINE}d.
5752 @item @code{no-dependencies}
5753 @cindex Option, no-dependencies
5754 This is similar to using @samp{--include-deps} on the command line, but
5755 is useful for those situations where you don't have the necessary bits
5756 to make automatic dependency tracking work @xref{Dependencies}. In this
5757 case the effect is to effectively disable automatic dependency tracking.
5759 @item @code{no-dist}
5760 @cindex Option, no-dist
5761 Don't emit any code related to @code{dist} target. This is useful
5762 when a package has its own method for making distributions.
5764 @item @code{no-dist-gzip}
5765 @cindex Option, no-dist-gzip
5766 Do not hook @code{dist-gzip} to @code{dist}.
5767 @trindex no-dist-gzip
5769 @item @code{no-exeext}
5770 @cindex Option, no-exeext
5771 If your @file{Makefile.am} defines a rule for target @samp{foo}, it
5772 will override a rule for a target named @samp{foo$(EXEEXT)}. This is
5773 necessary when @code{EXEEXT} is found to be empty. However, by
5774 default automake will generate an error for this use. The
5775 @code{no-exeext} option will disable this error. This is intended for
5776 use only where it is known in advance that the package will not be
5777 ported to Windows, or any other operating system using extensions on
5780 @item @code{no-installinfo}
5781 @cindex Option, no-installinfo
5782 The generated @file{Makefile.in} will not cause info pages to be built
5783 or installed by default. However, @code{info} and @code{install-info}
5784 targets will still be available. This option is disallowed at
5785 @samp{GNU} strictness and above.
5787 @trindex install-info
5789 @item @code{no-installman}
5790 @cindex Option, no-installman
5791 The generated @file{Makefile.in} will not cause man pages to be
5792 installed by default. However, an @code{install-man} target will still
5793 be available for optional installation. This option is disallowed at
5794 @samp{GNU} strictness and above.
5795 @trindex install-man
5797 @item @code{nostdinc}
5798 @cindex Option, nostdinc
5799 This option can be used to disable the standard @samp{-I} options which
5800 are ordinarily automatically provided by Automake.
5802 @item @code{no-texinfo.tex}
5803 @cindex Option, no-texinfo
5804 Don't require @file{texinfo.tex}, even if there are texinfo files in
5807 @item @code{readme-alpha}
5808 @cindex Option, readme-alpha
5809 If this release is an alpha release, and the file @file{README-alpha}
5810 exists, then it will be added to the distribution. If this option is
5811 given, version numbers are expected to follow one of two forms. The
5812 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
5813 element is a number; the final period and number should be left off for
5814 non-alpha releases. The second form is
5815 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
5816 letter; it should be omitted for non-alpha releases.
5818 @item @code{std-options}
5819 @cindex Options, std-options
5820 @cindex make installcheck
5821 Make the @code{installcheck} rule check that installed scripts and
5822 programs support the @code{--help} and @code{--version} options.
5823 This also provides a basic check that the program's
5824 run-time dependencies are satisfied after installation.
5826 @vindex AM_INSTALLCHECK_STD_OPTIONS_EXEMPT
5827 In a few situations, programs (or scripts) have to be exempted from this
5828 test. For instance @command{false} (from GNU sh-utils) is never
5829 successful, even for @code{--help} or @code{--version}. You can list
5830 such programs in the variable @code{AM_INSTALLCHECK_STD_OPTIONS_EXEMPT}.
5831 Programs (not scripts) listed in this variable should be suffixed by
5832 @code{$(EXEEXT)} for the sake of Win32 or OS/2. For instance suppose we
5833 build @code{false} as a program but @code{true.sh} as a script, and that
5834 neither of them support @code{--help} or @code{--version}:
5837 AUTOMAKE_OPTIONS = std-options
5838 bin_PROGRAMS = false ...
5839 bin_SCRIPTS = true.sh ...
5840 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false$(EXEEXT) true.sh
5843 @item @code{subdir-objects}
5844 If this option is specified, then objects are placed into the
5845 subdirectory of the build directory corresponding to the subdirectory of
5846 the source file. For instance if the source file is
5847 @file{subdir/file.cxx}, then the output file would be
5848 @file{subdir/file.o}.
5851 @cindex Option, version
5852 A version number (e.g. @samp{0.30}) can be specified. If Automake is not
5853 newer than the version specified, creation of the @file{Makefile.in}
5856 @item @code{-W@var{category}} or @code{--warnings=@var{category}}
5857 @cindex Option, warnings
5858 These options behave exactly like their command-line counterpart
5859 (@pxref{Invoking Automake}). This allows you to enable or disable some
5860 warning categories on a per-file basis. You can also setup some warnings
5861 for your entire project; for instance try @code{AM_INIT_AUTOMAKE([-Wall])}
5862 in your @file{configure.ac}.
5866 Unrecognized options are diagnosed by @code{automake}.
5868 If you want an option to apply to all the files in the tree, you can use
5869 the @code{AM_INIT_AUTOMAKE} macro in @file{configure.ac}.
5874 @chapter Miscellaneous Rules
5876 There are a few rules and variables that didn't fit anywhere else.
5879 * Tags:: Interfacing to etags and mkid
5880 * Suffixes:: Handling new file extensions
5881 * Multilibs:: Support for multilibs.
5886 @section Interfacing to @code{etags}
5888 @cindex TAGS support
5890 Automake will generate rules to generate @file{TAGS} files for use with
5891 GNU Emacs under some circumstances.
5893 If any C, C++ or Fortran 77 source code or headers are present, then
5894 @code{tags} and @code{TAGS} rules will be generated for the directory.
5897 At the topmost directory of a multi-directory package, a @code{tags}
5898 rule will be output which, when run, will generate a @file{TAGS} file
5899 that includes by reference all @file{TAGS} files from subdirectories.
5901 The @code{tags} rule will also be generated if the variable
5902 @code{ETAGS_ARGS} is defined. This variable is intended for use in
5903 directories which contain taggable source that @code{etags} does not
5904 understand. The user can use the @code{ETAGSFLAGS} to pass additional
5905 flags to @code{etags}; @code{AM_ETAGSFLAGS} is also available for use
5906 in @file{Makefile.am}.
5909 @vindex AM_ETAGSFLAGS
5911 Here is how Automake generates tags for its source, and for nodes in its
5915 ETAGS_ARGS = automake.in --lang=none \
5916 --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
5919 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
5920 want to set @samp{TAGS_DEPENDENCIES}. The contents of this variable
5921 are added directly to the dependencies for the @code{tags} rule.
5922 @vindex TAGS_DEPENDENCIES
5924 Automake also generates a @code{ctags} rule which can be used to
5925 build @command{vi}-style @file{tags} files. The variable @code{CTAGS}
5926 is the name of the program to invoke (by default @samp{ctags});
5927 @code{CTAGSFLAGS} can be used by the user to pass additional flags,
5928 and @code{AM_CTAGSFLAGS} can be used by the @file{Makefile.am}.
5930 Automake will also generate an @code{ID} rule which will run
5931 @code{mkid} on the source. This is only supported on a
5932 directory-by-directory basis.
5935 Automake also supports the @uref{http://www.gnu.org/software/global/,
5936 GNU Global Tags program}. The @code{GTAGS} rule runs Global Tags
5937 automatically and puts the result in the top build directory. The
5938 variable @code{GTAGS_ARGS} holds arguments which are passed to
5944 @section Handling new file extensions
5946 @cindex Adding new SUFFIXES
5947 @cindex SUFFIXES, adding
5950 It is sometimes useful to introduce a new implicit rule to handle a file
5951 type that Automake does not know about.
5953 For instance, suppose you had a compiler which could compile @samp{.foo}
5954 files to @samp{.o} files. You would simply define an suffix rule for
5962 Then you could directly use a @samp{.foo} file in a @samp{_SOURCES}
5963 variable and expect the correct results:
5967 doit_SOURCES = doit.foo
5970 This was the simpler and more common case. In other cases, you will
5971 have to help Automake to figure which extensions you are defining your
5972 suffix rule for. This usually happens when your extensions does not
5973 start with a dot. Then, all you have to do is to put a list of new
5974 suffixes in the @code{SUFFIXES} variable @strong{before} you define your
5977 For instance the following definition prevents Automake to misinterpret
5978 @samp{.idlC.cpp:} as an attempt to transform @samp{.idlC} into
5982 SUFFIXES = .idl C.cpp
5987 As you may have noted, the @code{SUFFIXES} variable behaves like the
5988 @code{.SUFFIXES} special target of @code{make}. You should not touch
5989 @code{.SUFFIXES} yourself, but use @code{SUFFIXES} instead and let
5990 Automake generate the suffix list for @code{.SUFFIXES}. Any given
5991 @code{SUFFIXES} go at the start of the generated suffixes list, followed
5992 by Automake generated suffixes not already in the list.
5995 @section Support for Multilibs
5997 Automake has support for an obscure feature called multilibs. A
5998 @dfn{multilib} is a library which is built for multiple different ABIs
5999 at a single time; each time the library is built with a different target
6000 flag combination. This is only useful when the library is intended to
6001 be cross-compiled, and it is almost exclusively used for compiler
6004 The multilib support is still experimental. Only use it if you are
6005 familiar with multilibs and can debug problems you might encounter.
6012 @cindex Including Makefile fragment
6013 @cindex Makefile fragment, including
6015 Automake supports an @code{include} directive which can be used to
6016 include other @file{Makefile} fragments when @code{automake} is run.
6017 Note that these fragments are read and interpreted by @code{automake},
6018 not by @code{make}. As with conditionals, @code{make} has no idea that
6019 @code{include} is in use.
6021 There are two forms of @code{include}:
6024 @item include $(srcdir)/file
6025 Include a fragment which is found relative to the current source
6028 @item include $(top_srcdir)/file
6029 Include a fragment which is found relative to the top source directory.
6032 Note that if a fragment is included inside a conditional, then the
6033 condition applies to the entire contents of that fragment.
6035 Makefile fragments included this way are always distributed because
6036 there are needed to rebuild @file{Makefile.in}.
6039 @chapter Conditionals
6041 @cindex Conditionals
6043 Automake supports a simple type of conditionals.
6045 @cvindex AM_CONDITIONAL
6046 Before using a conditional, you must define it by using
6047 @code{AM_CONDITIONAL} in the @code{configure.ac} file (@pxref{Macros}).
6049 @defmac AM_CONDITIONAL (@var{conditional}, @var{condition})
6050 The conditional name, @var{conditional}, should be a simple string
6051 starting with a letter and containing only letters, digits, and
6052 underscores. It must be different from @samp{TRUE} and @samp{FALSE}
6053 which are reserved by Automake.
6055 The shell @var{condition} (suitable for use in a shell @code{if}
6056 statement) is evaluated when @code{configure} is run. Note that you
6057 must arrange for @emph{every} @code{AM_CONDITIONAL} to be invoked every
6058 time @code{configure} is run -- if @code{AM_CONDITIONAL} is run
6059 conditionally (e.g., in a shell @code{if} statement), then the result
6060 will confuse automake.
6063 @cindex --enable-debug, example
6064 @cindex Example conditional --enable-debug
6065 @cindex Conditional example, --enable-debug
6067 Conditionals typically depend upon options which the user provides to
6068 the @code{configure} script. Here is an example of how to write a
6069 conditional which is true if the user uses the @samp{--enable-debug}
6073 AC_ARG_ENABLE(debug,
6074 [ --enable-debug Turn on debugging],
6075 [case "$@{enableval@}" in
6078 *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
6079 esac],[debug=false])
6080 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
6083 Here is an example of how to use that conditional in @file{Makefile.am}:
6095 noinst_PROGRAMS = $(DBG)
6098 This trivial example could also be handled using EXTRA_PROGRAMS
6099 (@pxref{Conditional Programs}).
6101 You may only test a single variable in an @code{if} statement, possibly
6102 negated using @samp{!}. The @code{else} statement may be omitted.
6103 Conditionals may be nested to any depth. You may specify an argument to
6104 @code{else} in which case it must be the negation of the condition used
6105 for the current @code{if}. Similarly you may specify the condition
6106 which is closed by an @code{end}:
6117 Unbalanced conditions are errors.
6119 Note that conditionals in Automake are not the same as conditionals in
6120 GNU Make. Automake conditionals are checked at configure time by the
6121 @file{configure} script, and affect the translation from
6122 @file{Makefile.in} to @file{Makefile}. They are based on options passed
6123 to @file{configure} and on results that @file{configure} has discovered
6124 about the host system. GNU Make conditionals are checked at @code{make}
6125 time, and are based on variables passed to the make program or defined
6126 in the @file{Makefile}.
6128 Automake conditionals will work with any make program.
6132 @chapter The effect of @code{--gnu} and @code{--gnits}
6134 @cindex --gnu, required files
6135 @cindex --gnu, complete description
6137 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
6138 variable) causes @code{automake} to check the following:
6142 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{AUTHORS},
6143 and @file{ChangeLog}, plus one of @file{COPYING.LIB}, @file{COPYING.LESSER}
6144 or @file{COPYING}, are required at the topmost directory of the package.
6147 The options @samp{no-installman} and @samp{no-installinfo} are
6151 Note that this option will be extended in the future to do even more
6152 checking; it is advisable to be familiar with the precise requirements
6153 of the GNU standards. Also, @samp{--gnu} can require certain
6154 non-standard GNU programs to exist for use by various maintainer-only
6155 rules; for instance in the future @code{pathchk} might be required for
6158 @cindex --gnits, complete description
6160 The @samp{--gnits} option does everything that @samp{--gnu} does, and
6161 checks the following as well:
6165 @samp{make installcheck} will check to make sure that the @code{--help}
6166 and @code{--version} really print a usage message and a version string,
6167 respectively. This is the @code{std-options} option (@pxref{Options}).
6170 @samp{make dist} will check to make sure the @file{NEWS} file has been
6171 updated to the current version.
6174 @samp{VERSION} is checked to make sure its format complies with Gnits
6176 @c FIXME xref when standards are finished
6179 @cindex README-alpha
6180 If @samp{VERSION} indicates that this is an alpha release, and the file
6181 @file{README-alpha} appears in the topmost directory of a package, then
6182 it is included in the distribution. This is done in @samp{--gnits}
6183 mode, and no other, because this mode is the only one where version
6184 number formats are constrained, and hence the only mode where Automake
6185 can automatically determine whether @file{README-alpha} should be
6189 The file @file{THANKS} is required.
6194 @chapter The effect of @code{--cygnus}
6196 @cindex Cygnus strictness
6198 Some packages, notably GNU GCC and GNU gdb, have a build environment
6199 originally written at Cygnus Support (subsequently renamed Cygnus
6200 Solutions, and then later purchased by Red Hat). Packages with this
6201 ancestry are sometimes referred to as ``Cygnus'' trees.
6203 A Cygnus tree has slightly different rules for how a @file{Makefile.in}
6204 is to be constructed. Passing @samp{--cygnus} to @code{automake} will
6205 cause any generated @file{Makefile.in} to comply with Cygnus rules.
6207 Here are the precise effects of @samp{--cygnus}:
6211 Info files are always created in the build directory, and not in the
6215 @file{texinfo.tex} is not required if a Texinfo source file is
6216 specified. The assumption is that the file will be supplied, but in a
6217 place that Automake cannot find. This assumption is an artifact of how
6218 Cygnus packages are typically bundled.
6221 @samp{make dist} is not supported, and the rules for it are not
6222 generated. Cygnus-style trees use their own distribution mechanism.
6225 Certain tools will be searched for in the build tree as well as in the
6226 user's @samp{PATH}. These tools are @code{runtest}, @code{expect},
6227 @code{makeinfo} and @code{texi2dvi}.
6230 @code{--foreign} is implied.
6233 The options @samp{no-installinfo} and @samp{no-dependencies} are
6237 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
6241 The @code{check} target doesn't depend on @code{all}.
6244 GNU maintainers are advised to use @samp{gnu} strictness in preference
6245 to the special Cygnus mode. Some day, perhaps, the differences between
6246 Cygnus trees and GNU trees will disappear (for instance, as GCC is made
6247 more standards compliant). At that time the special Cygnus mode will be
6252 @chapter When Automake Isn't Enough
6254 In some situations, where Automake is not up to one task, one has to
6255 resort to handwritten rules or even handwritten @file{Makefile}s.
6258 * Extending:: Adding new rules or overriding existing ones.
6259 * Third-Party Makefiles:: Integrating Non-Automake @file{Makefile}s.
6263 @section Extending Automake Rules
6265 With some minor exceptions (like @code{_PROGRAMS} variables being
6266 rewritten to append @code{$(EXEEXT)}), the contents of a
6267 @file{Makefile.am} is copied to @file{Makefile.in} verbatim.
6269 @cindex copying semantics
6271 These copying semantics means that many problems can be worked around
6272 by simply adding some @code{make} variables and rules to
6273 @file{Makefile.am}. Automake will ignore these additions.
6275 @cindex conflicting definitions
6276 @cindex rules, conflicting
6277 @cindex variables, conflicting
6278 @cindex definitions, conflicts
6280 Since a @file{Makefile.in} is built from data gathered from three
6281 different places (@file{Makefile.am}, @file{configure.ac}, and
6282 @command{automake} itself), it is possible to have conflicting
6283 definitions of rules or variables. When building @file{Makefile.in}
6284 the following priorities are respected by @command{automake} to ensure
6285 the user always have the last word. User defined variables in
6286 @file{Makefile.am} have priority over variables @code{AC_SUBST}ed from
6287 @file{configure.ac}, and @code{AC_SUBST}ed variables have priority
6288 over @command{automake}-defined variables. As far rules are
6289 concerned, a user-defined rule overrides any
6290 @command{automake}-defined rule for the same target.
6292 @cindex overriding rules
6293 @cindex overriding semantics
6294 @cindex rules, overriding
6296 These overriding semantics make it possible to fine tune some default
6297 settings of Automake, or replace some of its rules. Overriding
6298 Automake rules is often inadvisable, particularly in the topmost
6299 directory of a package with subdirectories. The @code{-Woverride}
6300 option (@pxref{Invoking Automake}) comes handy to catch overridden
6303 Note that Automake does not make any difference between rules with
6304 commands and rules that only specify dependencies. So it is not
6305 possible to append new dependencies to an @code{automake}-defined
6306 target without redefining the entire rule.
6308 @cindex -local targets
6309 @cindex local targets
6311 However, various useful targets have a @samp{-local} version you can
6312 specify in your @file{Makefile.in}. Automake will supplement the
6313 standard target with these user-supplied targets.
6328 @trindex check-local
6330 @trindex install-data-local
6331 @trindex install-exec
6332 @trindex install-exec-local
6334 @trindex uninstall-local
6335 @trindex mostlyclean
6336 @trindex mostlyclean-local
6338 @trindex clean-local
6340 @trindex distclean-local
6341 @trindex installdirs
6342 @trindex installdirs-local
6343 @trindex installcheck
6344 @trindex installcheck-local
6346 The targets that support a local version are @code{all}, @code{info},
6347 @code{dvi}, @code{ps}, @code{pdf}, @code{html}, @code{check},
6348 @code{install-data}, @code{install-exec}, @code{uninstall},
6349 @code{installdirs}, @code{installcheck} and the various @code{clean} targets
6350 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
6351 @code{maintainer-clean}). Note that there are no
6352 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
6353 use @code{uninstall-local}. It doesn't make sense to uninstall just
6354 data or just executables.
6356 For instance, here is one way to install a file in @file{/etc}:
6360 $(INSTALL_DATA) $(srcdir)/afile $(DESTDIR)/etc/afile
6363 @cindex -hook targets
6364 @cindex hook targets
6366 Some rule also have a way to run another rule, called a @dfn{hook},
6367 after their work is done. The hook is named after the principal target,
6368 with @samp{-hook} appended. The targets allowing hooks are
6369 @code{install-data}, @code{install-exec}, @code{uninstall}, @code{dist},
6370 and @code{distcheck}.
6371 @trindex install-data-hook
6372 @trindex install-exec-hook
6373 @trindex uninstall-hook
6376 For instance, here is how to create a hard link to an installed program:
6380 ln $(DESTDIR)$(bindir)/program$(EXEEXT) \
6381 $(DESTDIR)$(bindir)/proglink$(EXEEXT)
6384 Although cheaper and more portable than symbolic links, hard links
6385 will not work everywhere (for instance OS/2 does not have
6386 @command{ln}). Ideally you should fall back to @code{cp -p} when
6387 @code{ln} does not work. An easy way, if symbolic links are
6388 acceptable to you, is to add @code{AC_PROG_LN_S} to
6389 @file{configure.ac} (@pxref{Particular Programs, , Particular Program
6390 Checks, autoconf, The Autoconf Manual}) and use @code{$(LN_S)} in
6393 @cindex versioned binaries, installing
6394 @cindex installing versioned binaries
6395 @cindex LN_S example
6396 For instance, here is how you could install a versioned copy of a
6397 program using @code{$(LN_S)}:
6401 cd $(DESTDIR)$(bindir) && \
6402 mv -f prog$(EXEEXT) prog-$(VERSION)$(EXEEXT) && \
6403 $(LN_S) prog-$(VERSION)$(EXEEXT) prog$(EXEEXT)
6406 Note that we rename the program so that a new version will erase the
6407 symbolic link, not the real binary. Also we @code{cd} into the
6408 destination directory in order to create relative links.
6410 @c FIXME should include discussion of variables you can use in these
6413 @node Third-Party Makefiles
6414 @section Third-Party @file{Makefile}s
6416 @cindex Third-party packages, interfacing with
6417 @cindex Interfacing with third-party packages
6419 In most projects all @file{Makefile}s are generated by Automake. In
6420 some cases, however, projects need to embed subdirectories with
6421 handwritten @file{Makefile}s. For instance one subdirectory could be
6422 a third-party project with its own build system, not using Automake.
6424 It is possible to list arbitrary directories in @code{SUBDIRS} or
6425 @code{DIST_SUBDIRS} provided each of these directories has a
6426 @file{Makefile} that recognizes all the following recursive targets.
6428 @cindex recursive targets and third-party @file{Makefile}s
6429 When a user runs one of these targets, that target is run recursively
6430 in all subdirectories. This is why it is important that even
6431 third-party @file{Makefile}s support them.
6435 Compile the entire package. This is the default target in
6436 Automake-generated @file{Makefile}s, but it does not need to be the
6437 default in third-party @file{Makefile}s.
6443 Copy files to distribute into @code{$(distdir)}, before a tarball is
6444 constructed. Of course this target is not required if the
6445 @code{no-dist} option (@pxref{Options}) is used.
6447 The variables @code{$(top_distdir)} and @code{$(distdir)}
6448 (@pxref{Dist}) will be passed from the outer package to the subpackage
6449 when the @code{distdir} target is invoked. These two variables have
6450 been adjusted for the directory which is being recursed into, so they
6457 Install or uninstall files (@pxref{Install}).
6460 Install only the Texinfo documentation (@pxref{Texinfo}).
6463 Create install directories, but do not install any files.
6467 Check the package (@pxref{Tests}).
6472 @itemx maintainer-clean
6473 Cleaning rules (@pxref{Clean}).
6480 Build the documentation in various formats (@pxref{Texinfo}).
6484 Build @code{TAGS} and @code{CTAGS} (@pxref{Tags}).
6487 If you have ever used Gettext in a project, this is a good example of
6488 how third-party @file{Makefile}s can be used with Automake. The
6489 @file{Makefile}s @command{gettextize} puts in the @file{po/} and
6490 @file{intl/} directories are handwritten @file{Makefile}s that
6491 implement all these targets. That way they can be added to
6492 @code{SUBDIRS} in Automake packages.
6494 Directories which are only listed in @code{DIST_SUBDIRS} but not in
6495 @code{SUBDIRS} need only the @code{distclean},
6496 @code{maintainer-clean}, and @code{distdir} rules (@pxref{Top level}).
6498 Usually, many of these rules are irrelevant to the third-party
6499 subproject, but they are required for the whole package to work. It's
6500 OK to have a rule that does nothing, so if you are integrating a
6501 third-party project with no documentation or tag support, you could
6502 simply augment its @file{Makefile} as follows:
6505 EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags
6506 .PHONY: $(EMPTY_AUTOMAKE_TARGETS)
6507 $(EMPTY_AUTOMAKE_TARGETS):
6510 Another aspect of integrating third-party build systems is whether
6511 they support VPATH builds. Obviously if the subpackage does not
6512 support VPATH builds the whole package will not support VPATH builds.
6513 This in turns means that @code{make distcheck} will not work, because
6514 it relies on VPATH builds. Some people can live without this
6515 (actually, many Automake users have never heard of @code{make
6516 distcheck}). Other people may prefer to revamp the existing
6517 @file{Makefile}s to support VPATH. Doing so does not necessarily
6518 require Automake, only Autoconf is needed (@pxref{Build Directories, ,
6519 Build Directories, autoconf, The Autoconf Manual}). The necessary
6520 substitutions: @code{@@scrdir@@}, @code{@@top_srcdir@@}, and
6521 @code{@@top_buildir@@} are defined by @file{configure} when it
6522 processes a @file{Makefile} (@pxref{Preset Output Variables, , Preset
6523 Output Variables, autoconf, The Autoconf Manual}), they are not
6524 computed by the Makefile like the aforementioned @code{$(distdir)} and
6525 @code{$(top_distdir)} variables..
6527 It is sometimes inconvenient to modify a third-party @file{Makefile}
6528 to introduce the above required targets. For instance one may want to
6529 keep the third-party sources untouched to ease upgrades to new
6532 @cindex @file{GNUmakefile} including @file{Makefile}
6533 Here are two other ideas. If GNU make is assumed, one possibility is
6534 to add to that subdirectory a @file{GNUmakefile} that defines the
6535 required targets and include the third-party @file{Makefile}. For
6536 this to work in VPATH builds, @file{GNUmakefile} must lie in the build
6537 directory; the easiest way to do this is to write a
6538 @file{GNUmakefile.in} instead, and have it processed with
6539 @code{AC_CONFIG_FILES} from the outer package. For example if we
6540 assume @file{Makefile} defines all targets except the documentation
6541 targets, and that the @code{check} target is actually called
6542 @code{test}, we could write @file{GNUmakefile} (or
6543 @file{GNUmakefile.in}) like this:
6546 # First, include the real Makefile
6548 # Then, define the other targets needed by Automake Makefiles.
6549 .PHONY: dvi pdf ps info html check
6550 dvi pdf ps info html:
6554 @cindex Proxy @file{Makefile} for third-party packages
6555 A similar idea that does not use @code{include} is to write a proxy
6556 @file{Makefile} that dispatches rules to the real @file{Makefile},
6557 either with @code{$(MAKE) -f Makefile.real $(AM_MAKEFLAGS) target} (if
6558 it's OK to rename the original @file{Makefile}) or with @code{cd
6559 subdir && $(MAKE) $(AM_MAKEFLAGS) target} (if it's OK to store the
6560 subdirectory project one directory deeper). The good news is that
6561 this proxy @file{Makefile} can be generated with Automake. All we
6562 need are -local targets (@pxref{Extending}) that perform the dispatch.
6563 Of course the other Automake features are available, so you could
6564 decide to let Automake perform distribution or installation. Here is
6565 a possible @file{Makefile.am}:
6569 cd subdir && $(MAKE) $(AM_MAKEFLAGS) all
6571 cd subdir && $(MAKE) $(AM_MAKEFLAGS) test
6573 cd subdir && $(MAKE) $(AM_MAKEFLAGS) clean
6575 # Assuming the package knows how to install itself
6577 cd subdir && $(MAKE) $(AM_MAKEFLAGS) install-data
6579 cd subdir && $(MAKE) $(AM_MAKEFLAGS) install-exec
6581 cd subdir && $(MAKE) $(AM_MAKEFLAGS) uninstall
6583 # Distribute files from here.
6584 EXTRA_DIST = subdir/Makefile subdir/program.c ...
6587 Pushing this idea to the extreme, it is also possible to ignore the
6588 subproject build system and build everything from this proxy
6589 @file{Makefile.am}. This might sounds very sensible if you need VPATH
6590 builds but the subproject does not support them.
6593 @chapter Distributing @file{Makefile.in}s
6595 Automake places no restrictions on the distribution of the resulting
6596 @file{Makefile.in}s. We still encourage software authors to
6597 distribute their work under terms like those of the GPL, but doing so
6598 is not required to use Automake.
6600 Some of the files that can be automatically installed via the
6601 @code{--add-missing} switch do fall under the GPL@. However, these also
6602 have a special exception allowing you to distribute them with your
6603 package, regardless of the licensing you choose.
6606 @node API versioning
6607 @chapter Automake API versioning
6609 New Automake releases usually include bug fixes and new features.
6610 Unfortunately they may also introduce new bugs and incompatibilities.
6611 This makes four reasons why a package may require a particular Automake
6614 Things get worse when maintaining a large tree of packages, each one
6615 requiring a different version of Automake. In the past, this meant that
6616 any developer (and sometime users) had to install several versions of
6617 Automake in different places, and switch @samp{$PATH} appropriately for
6620 Starting with version 1.6, Automake installs versioned binaries. This
6621 means you can install several versions of Automake in the same
6622 @samp{$prefix}, and can select an arbitrary Automake version by running
6623 @samp{automake-1.6} or @samp{automake-1.7} without juggling with
6624 @samp{$PATH}. Furthermore, @file{Makefile}'s generated by Automake 1.6
6625 will use @samp{automake-1.6} explicitly in their rebuild rules.
6627 The number @samp{1.6} in @samp{automake-1.6} is Automake's API version,
6628 not Automake's version. If a bug fix release is made, for instance
6629 Automake 1.6.1, the API version will remain 1.6. This means that a
6630 package which work with Automake 1.6 should also work with 1.6.1; after
6631 all, this is what people expect from bug fix releases.
6633 If your package relies on a feature or a bug fix introduced in
6634 a release, you can pass this version as an option to Automake to ensure
6635 older releases will not be used. For instance, use this in your
6636 @file{configure.ac}:
6639 AM_INIT_AUTOMAKE(1.6.1) dnl Require Automake 1.6.1 or better.
6642 or, in a particular @file{Makefile.am}:
6645 AUTOMAKE_OPTIONS = 1.6.1 # Require Automake 1.6.1 or better.
6648 Automake will print an error message if its version is
6649 older than the requested version.
6652 @heading What is in the API
6654 Automake's programming interface is not easy to define. Basically it
6655 should include at least all @strong{documented} variables and targets
6656 that a @samp{Makefile.am} author can use, any behavior associated with
6657 them (e.g. the places where @samp{-hook}'s are run), the command line
6658 interface of @samp{automake} and @samp{aclocal}, @dots{}
6660 @heading What is not in the API
6662 Every undocumented variable, target, or command line option, is not part
6663 of the API@. You should avoid using them, as they could change from one
6664 version to the other (even in bug fix releases, if this helps to fix a
6667 If it turns out you need to use such a undocumented feature, contact
6668 @email{automake@@gnu.org} and try to get it documented and exercised by
6672 @chapter Upgrading a Package to a Newer Automake Version
6674 Automake maintains three kind of files in a package.
6677 @item @file{aclocal.m4}
6678 @item @file{Makefile.in}s
6679 @item auxiliary tools like @file{install-sh} or @file{py-compile}
6682 @file{aclocal.m4} is generated by @command{aclocal} and contains some
6683 Automake-supplied M4 macros. Auxiliary tools are installed by
6684 @samp{automake --add-missing} when needed. @file{Makefile.in}s are
6685 built from @file{Makefile.am} by @command{automake}, and rely on the
6686 definitions of the M4 macros put in @file{aclocal.m4} as well as the
6687 behavior of the auxiliary tools installed.
6689 Because all these files are closely related, it is important to
6690 regenerate all of them when upgrading to a newer Automake release.
6691 The usual way to do that is
6694 aclocal # with any option needed (such a -I m4)
6696 automake --add-missing --force-missing
6700 or more conveniently:
6706 The use of @code{--force-missing} ensures that auxiliary tools will be
6707 overridden by new versions (@pxref{Invoking Automake}).
6709 It is important to regenerate all these files each time Automake is
6710 upgraded, even between bug fixes releases. For instance it is not
6711 unusual for a bug fix to involve changes to both the rules generated
6712 in @file{Makefile.in} and the supporting M4 macros copied to
6715 Presently @command{automake} is able to diagnose situations where
6716 @file{aclocal.m4} has been generated with another version of
6717 @command{aclocal}. However it never checks whether auxiliary scripts
6718 are up-to-date. In other words, @command{automake} will tell you when
6719 @command{aclocal} needs to be rerun, but it will never diagnose a
6720 missing @code{--force-missing}.
6722 Before upgrading to a new major release, it is a good idea to read the
6723 file @file{NEWS}. This file lists all changes between releases: new
6724 features, obsolete constructs, known incompatibilities, and
6728 @chapter Frequently Asked Questions about Automake
6730 This chapter covers some questions that often come up on the mailing
6734 * CVS:: CVS and generated files
6735 * maintainer-mode:: missing and AM_MAINTAINER_MODE
6736 * wildcards:: Why doesn't Automake support wildcards?
6737 * distcleancheck:: Files left in build directory after distclean
6738 * renamed objects:: Why are object files sometimes renamed?
6739 * Multiple Outputs:: Writing rules for tools with many output files
6743 @section CVS and generated files
6745 @subsection Background: distributed generated files
6746 @cindex generated files, distributed
6747 @cindex rebuild rules
6749 Packages made with Autoconf and Automake ship with some generated
6750 files like @file{configure} or @file{Makefile.in}. These files were
6751 generated on the developer's host and are distributed so that
6752 end-users do not have to install the maintainer tools required to
6753 rebuild them. Other generated files like Lex scanners, Yacc parsers,
6754 or Info documentation, are usually distributed on similar grounds.
6756 Automake outputs rules in @file{Makefile}s to rebuild these files. For
6757 instance @command{make} will run @command{autoconf} to rebuild
6758 @file{configure} whenever @file{configure.ac} is changed. This makes
6759 development safer by ensuring a @file{configure} is never out-of-date
6760 with respect to @file{configure.ac}.
6762 As generated files shipped in packages are up-to-date, and because
6763 @command{tar} preserves times-tamps, these rebuild rules are not
6764 triggered when a user unpacks and builds a package.
6766 @subsection Background: CVS and timestamps
6767 @cindex timestamps and CVS
6768 @cindex CVS and timestamps
6770 Unless you use CVS keywords (in which case files must be updated at
6771 commit time), CVS preserves timestamp during @code{cvs commit} and
6772 @code{cvs import -d} operations.
6774 When you check out a file using @code{cvs checkout} its timestamp is
6775 set to that of the revision which is being checked out.
6777 However, during @command{cvs update}, files will have the date of the
6778 update, not the original timestamp of this revision. This is meant to
6779 make sure that @command{make} notices sources files have been updated.
6781 This times tamp shift is troublesome when both sources and generated
6782 files are kept under CVS. Because CVS processes files in alphabetical
6783 order, @file{configure.ac} will appear older than @file{configure}
6784 after a @command{cvs update} that updates both files, even if
6785 @file{configure} was newer than @file{configure.ac} when it was
6786 checked in. Calling @code{make} will then trigger a spurious rebuild
6787 of @file{configure}.
6789 @subsection Living with CVS in Autoconfiscated projects
6790 @cindex CVS and generated files
6791 @cindex generated files and CVS
6793 There are basically two clans amongst maintainers: those who keep all
6794 distributed files under CVS, including generated files, and those who
6795 keep generated files @emph{out} of CVS.
6797 @subsubheading All files in CVS
6801 The CVS repository contains all distributed files so you know exactly
6802 what is distributed, and you can checkout any prior version entirely.
6805 Maintainers can see how generated files evolve (for instance you can
6806 see what happens to your @file{Makefile.in}s when you upgrade Automake
6807 and make sure they look OK).
6810 Users do not need the autotools to build a checkout of the project, it
6811 works just like a released tarball.
6814 If users use @command{cvs update} to update their copy, instead of
6815 @command{cvs checkout} to fetch a fresh one, timestamps will be
6816 inaccurate. Some rebuild rules will be triggered and attempt to
6817 run developer tools such as @command{autoconf} or @command{automake}.
6819 Actually, calls to such tools are all wrapped into a call to the
6820 @command{missing} script discussed later (@pxref{maintainer-mode}).
6821 @command{missing} will take care of fixing the timestamps when these
6822 tools are not installed, so that the build can continue.
6825 In distributed development, developers are likely to have different
6826 version of the maintainer tools installed. In this case rebuilds
6827 triggered by timestamp lossage will lead to spurious changes
6828 to generated files. There are several solutions to this:
6832 All developers should use the same versions, so that the rebuilt files
6833 are identical to files in CVS. (This starts to be difficult when each
6834 project you work on uses different versions.)
6836 Or people use a script to fix the timestamp after a checkout (the GCC
6837 folks have such a script).
6839 Or @file{configure.ac} uses @code{AM_MAINTAINER_MODE}, which will
6840 disable all these rebuild rules by default. This is further discussed
6841 in @ref{maintainer-mode}.
6845 Although we focused on spurious rebuilds, the converse can also
6846 happen. CVS's timestamp handling can also let you think an
6847 out-of-date file is up-to-date.
6849 For instance, suppose a developer has modified @file{Makefile.am} and
6850 rebuilt @file{Makefile.in}, and then decide to do a last-minute change
6851 to @file{Makefile.am} right before checking in both files (without
6852 rebuilding @file{Makefile.in} to account for the change).
6854 This last change to @file{Makefile.am} make the copy of
6855 @file{Makefile.in} out-of-date. Since CVS processes files
6856 alphabetically, when another developer @code{cvs update} his or her
6857 tree, @file{Makefile.in} will happen to be newer than
6858 @file{Makefile.am}. This other developer will not see
6859 @file{Makefile.in} is out-of-date.
6863 @subsubheading Generated files out of CVS
6865 One way to get CVS and @code{make} working peacefully is to never
6866 store generated files in CVS, i.e., do not CVS-control files which
6867 are @code{Makefile} targets (also called @emph{derived} files).
6869 This way developers are not annoyed by changes to generated files. It
6870 does not matter if they all have different versions (assuming they are
6871 compatible, of course). And finally, timestamps are not lost, changes
6872 to sources files can't be missed as in the
6873 @file{Makefile.am}/@file{Makefile.in} example discussed earlier.
6875 The drawback is that the CVS repository is not an exact copy of what
6876 is distributed and that users now need to install various development
6877 tools (maybe even specific versions) before they can build a checkout.
6878 But, after all, CVS's job is versioning, not distribution.
6880 Allowing developers to use different versions of their tools can also
6881 hide bugs during distributed development. Indeed, developers will be
6882 using (hence testing) their own generated files, instead of the
6883 generated files that will be released actually. The developer who
6884 prepares the tarball might be using a version of the tool that
6885 produces bogus output (for instance a non-portable C file), something
6886 other developers could have noticed if they weren't using their own
6887 versions of this tool.
6889 @subsection Third-party files
6890 @cindex CVS and third-party files
6891 @cindex third-party files and CVS
6893 Another class of files not discussed here (because they do not cause
6894 timestamp issues) are files which are shipped with a package, but
6895 maintained elsewhere. For instance tools like @command{gettextize}
6896 and @command{autopoint} (from Gettext) or @command{libtoolize} (from
6897 Libtool), will install or update files in your package.
6899 These files, whether they are kept under CVS or not, raise similar
6900 concerns about version mismatch between developers' tools. The
6901 Gettext manual has a section about this, see @ref{CVS Issues, CVS
6902 Issues, Integrating with CVS, gettext, GNU gettext tools}.
6904 @node maintainer-mode
6905 @section @command{missing} and @code{AM_MAINTAINER_MODE}
6907 @subsection @command{missing}
6908 @cindex missing, purpose
6910 The @command{missing} script is a wrapper around several maintainer
6911 tools, designed to warn users if a maintainer tool is required but
6912 missing. Typical maintainer tools are @command{autoconf},
6913 @command{automake}, @command{bison}, etc. Because file generated by
6914 these tools are shipped with the other sources of a package, these
6915 tools shouldn't be required during a user build and they are not
6916 checked for in @file{configure}.
6918 However, if for some reason a rebuild rule is triggered and involves a
6919 missing tool, @command{missing} will notice it and warn the user.
6920 Besides the warning, when a tool is missing, @command{missing} will
6921 attempt to fix timestamps in a way which allow the build to continue.
6922 For instance @command{missing} will touch @file{configure} if
6923 @command{autoconf} is not installed. When all distributed files are
6924 kept under CVS, this feature of @command{missing} allows user
6925 @emph{with no maintainer tools} to build a package off CVS, bypassing
6926 any timestamp inconsistency implied by @code{cvs update}.
6928 If the required tool is installed, @command{missing} will run it and
6929 won't attempt to continue after failures. This is correct during
6930 development: developers love fixing failures. However, users with
6931 wrong versions of maintainer tools may get an error when the rebuild
6932 rule is spuriously triggered, halting the build. This failure to let
6933 the build continue is one of the arguments of the
6934 @code{AM_MAINTAINER_MODE} advocates.
6936 @subsection @code{AM_MAINTAINER_MODE}
6937 @cindex AM_MAINTAINER_MODE, purpose
6938 @cvindex AM_MAINTAINER_MODE
6940 @code{AM_MAINTAINER_MODE} disables the so called "rebuild rules" by
6941 default. If you have @code{AM_MAINTAINER_MODE} in
6942 @file{configure.ac}, and run @code{./configure && make}, then
6943 @command{make} will *never* attempt to rebuilt @file{configure},
6944 @file{Makefile.in}s, Lex or Yacc outputs, etc. I.e., this disables
6945 build rules for files which are usually distributed and that users
6946 should normally not have to update.
6948 If you run @code{./configure --enable-maintainer-mode}, then these
6949 rebuild rules will be active.
6951 People use @code{AM_MAINTAINER_MODE} either because they do want their
6952 users (or themselves) annoyed by timestamps lossage (@pxref{CVS}), or
6953 because they simply can't stand the rebuild rules and prefer running
6954 maintainer tools explicitly.
6956 @code{AM_MAINTAINER_MODE} also allows you to disable some custom build
6957 rules conditionally. Some developers use this feature to disable
6958 rules that need exotic tools that users may not have available.
6960 Several years ago Fran@,{c}ois Pinard pointed out several arguments
6961 against @code{AM_MAINTAINER_MODE}. Most of them relate to insecurity.
6962 By removing dependencies you get non-dependable builds: change to
6963 sources files can have no effect on generated files and this can be
6964 very confusing when unnoticed. He adds that security shouldn't be
6965 reserved to maintainers (what @code{--enable-maintainer-mode}
6966 suggests), on the contrary. If one user has to modify a
6967 @file{Makefile.am}, then either @file{Makefile.in} should be updated
6968 or a warning should be output (this is what Automake uses
6969 @code{missing} for) but the last thing you want is that nothing
6970 happens and the user doesn't notice it (this is what happens when
6971 rebuild rules are disabled by @code{AM_MAINTAINER_MODE}).
6973 Jim Meyering, the inventor of the @code{AM_MAINTAINER_MODE} macro was
6974 swayed by Fran@,{c}ois's arguments, and got rid of
6975 @code{AM_MAINTAINER_MODE} in all of his packages.
6977 Still many people continue to use @code{AM_MAINTAINER_MODE}, because
6978 it helps them working on projects where all files are kept under CVS,
6979 and because @command{missing} isn't enough if you have the wrong
6980 version of the tools.
6984 @section Why doesn't Automake support wildcards?
6987 Developers are lazy. They often would like to use wildcards in
6988 @file{Makefile.am}s, so they don't need to remember they have to
6989 update @file{Makefile.am}s every time they add, delete, or rename a
6992 There are several objections to this:
6995 When using CVS (or similar) developers need to remember they have to
6996 run @code{cvs add} or @code{cvs rm} anyway. Updating
6997 @file{Makefile.am} accordingly quickly becomes a reflex.
6999 Conversely, if your application doesn't compile
7000 because you forgot to add a file in @file{Makefile.am}, it will help
7001 you remember to @code{cvs add} it.
7004 Using wildcards makes easy to distribute files by mistake. For
7005 instance some code a developer is experimenting with (a test case,
7006 say) but which should not be part of the distribution.
7009 Using wildcards it's easy to omit some files by mistake. For
7010 instance one developer creates a new file, uses it at many places,
7011 but forget to commit it. Another developer then checkout the
7012 incomplete project and is able to run `make dist' successfully,
7013 even though a file is missing.
7016 Listing files, you control *exactly* what you distribute.
7017 If some file that should be distributed is missing from your
7018 tree, @code{make dist} will complain. Besides, you don't distribute
7019 more than what you listed.
7022 Finally it's really hard to @file{forget} adding a file to
7023 @file{Makefile.am}, because if you don't add it, it doesn't get
7024 compiled nor installed, so you can't even test it.
7027 Still, these are philosophical objections, and as such you may disagree,
7028 or find enough value in wildcards to dismiss all of them. Before you
7029 start writing a patch against Automake to teach it about wildcards,
7030 let's see the main technical issue: portability.
7032 Although @code{$(wildcard ...)} works with GNU @command{make}, it is
7033 not portable to other @command{make} implementations.
7035 The only way Automake could support @command{$(wildcard ...)} is by
7036 expending @command{$(wildcard ...)} when @command{automake} is run.
7037 Resulting @file{Makefile.in}s would be portable since they would
7038 list all files and not use @code{$(wildcard ...)}. However that
7039 means developers need to remember they must run @code{automake} each
7040 time they add, delete, or rename files.
7042 Compared to editing @file{Makefile.am}, this is really little win. Sure,
7043 it's easier and faster to type @code{automake; make} than to type
7044 @code{emacs Makefile.am; make}. But nobody bothered enough to write a
7045 patch add support for this syntax. Some people use scripts to
7046 generated file lists in @file{Makefile.am} or in separate
7047 @file{Makefile} fragments.
7049 Even if you don't care about portability, and are tempted to use
7050 @code{$(wildcard ...)} anyway because you target only GNU Make, you
7051 should know there are many places where Automake need to know exactly
7052 which files should be processed. As Automake doesn't know how to
7053 expand @code{$(wildcard ...)}, you cannot use it in these places.
7054 @code{$(wildcard ...)} is a black box comparable to @code{AC_SUBST}ed
7055 variables as far Automake is concerned.
7057 You can get warnings about @code{$(wildcard ...}) constructs using the
7058 @code{-Wportability} flag.
7060 @node distcleancheck
7061 @section Files left in build directory after distclean
7062 @cindex distclean, diagnostic
7063 @cindex dependencies and distributed files
7065 @trindex distcleancheck
7067 This is a diagnostic you might encounter while running @code{make
7070 As explained in @ref{Dist}, @code{make distcheck} attempts to build
7071 and check your package for errors like this one.
7073 @code{make distcheck} will perform a @code{VPATH} build of your
7074 package, and then call @code{make distclean}. Files left in the build
7075 directory after @code{make distclean} has run are listed after this
7078 This diagnostic really covers two kinds of errors:
7082 files that are forgotten by distclean;
7084 distributed files that are erroneously rebuilt.
7087 The former left-over files are not distributed, so the fix is to mark
7088 them for cleaning (@pxref{Clean}), this is obvious and doesn't deserve
7091 The latter bug is not always easy to understand and fix, so let's
7092 proceed with an example. Suppose our package contains a program for
7093 which we want to build a man page using @command{help2man}. GNU
7094 @command{help2man} produces simple manual pages from the @code{--help}
7095 and @code{--version} output of other commands (@pxref{Top, , Overview,
7096 help2man, The Help2man Manual}). Because we don't to force want our
7097 users to install @command{help2man}, we decide to distribute the
7098 generated man page using the following setup.
7101 # This Makefile.am is bogus.
7104 dist_man_MANS = foo.1
7107 help2man --output=foo.1 ./foo$(EXEEXT)
7110 This will effectively distribute the man page. However,
7111 @code{make distcheck} will fail with:
7114 ERROR: files left in build directory after distclean:
7118 Why was @file{foo.1} rebuilt? Because although distributed,
7119 @file{foo.1} depends on a non-distributed built file:
7120 @file{foo$(EXEEXT)}. @file{foo$(EXEEXT)} is built by the user, so it
7121 will always appear to be newer than the distributed @file{foo.1}.
7123 @code{make distcheck} caught an inconsistency in our package. Our
7124 intent was to distribute @file{foo.1} so users do not need installing
7125 @command{help2man}, however since this our rule causes this file to be
7126 always rebuilt, users @emph{do} need @command{help2man}. Either we
7127 should ensure that @file{foo.1} is not rebuilt by users, or there is
7128 no point in distributing @file{foo.1}.
7130 More generally, the rule is that distributed files should never depend
7131 on non-distributed built files. If you distribute something
7132 generated, distribute its sources.
7134 One way to fix the above example, while still distributing
7135 @file{foo.1} is to not depend on @file{foo$(EXEEXT)}. For instance,
7136 assuming @command{foo --version} and @command{foo --help} do not
7137 change unless @file{foo.c} or @file{configure.ac} change, we could
7138 write the following @file{Makefile.am}:
7143 dist_man_MANS = foo.1
7145 foo.1: foo.c $(top_srcdir)/configure.ac
7146 $(MAKE) $(AM_MAKEFLAGS) foo$(EXEEXT)
7147 help2man --output=foo.1 ./foo$(EXEEXT)
7150 This way, @file{foo.1} will not get rebuilt every time
7151 @file{foo$(EXEEXT)} changes. The @command{make} call makes sure
7152 @file{foo$(EXEEXT)} is up-to-date before @command{help2man}. Another
7153 way to ensure this would be to use separate directories for binaries
7154 and man pages, and set @code{SUBDIRS} so that binaries are built
7157 We could also decide not to distribute @file{foo.1}. In
7158 this case it's fine to have @file{foo.1} dependent upon
7159 @file{foo$(EXEEXT)}, since both will have to be rebuilt.
7160 However it would be impossible to build the package in a
7161 cross-compilation, because building @file{foo.1} involves
7162 an @emph{execution} of @file{foo$(EXEEXT)}.
7164 Another context where such errors are common is when distributed files
7165 are built by tools which are built by the package. The pattern is similar:
7168 distributed-file: built-tools distributed-sources
7173 should be changed to
7176 distributed-file: distributed-sources
7177 $(MAKE) $(AM_MAKEFLAGS) built-tools
7182 or you could choose not to distribute @file{distributed-file}, if
7183 cross-compilation does not matter.
7185 The points made through these examples are worth a summary:
7190 Distributed files should never depend upon non-distributed built
7193 Distributed files should be distributed will all their dependencies.
7195 If a file is @emph{intended} be rebuilt by users, there is no point in
7200 @vrindex distcleancheck_listfiles
7201 For desperate cases, it's always possible to disable this check by
7202 setting @code{distcleancheck_listfiles} as documented in @ref{Dist}.
7203 Make sure you do understand the reason why @code{make distcheck}
7204 complains before you do this. @code{distcleancheck_listfiles} is a
7205 way to @emph{hide} errors, not to fix them. You can always do better.
7207 @node renamed objects
7208 @section Why are object files sometimes renamed?
7210 This happens when per-target compilation flags are used. Object
7211 files need to be renamed just in case they would clash with object
7212 files compiled from the same sources, but with different flags.
7213 Consider the following example.
7216 bin_PROGRAMS = true false
7217 true_SOURCES = generic.c
7218 true_CPPFLAGS = -DEXIT_CODE=0
7219 false_SOURCES = generic.c
7220 false_CPPFLAGS = -DEXIT_CODE=1
7223 Obviously the two programs are built from the same source, but it
7224 would be bad if they shared the same object, because @file{generic.o}
7225 cannot be built with both @code{-DEXIT_CODE=0} *and*
7226 @code{-DEXIT_CODE=1}. Therefore @command{automake} outputs rules to
7227 build two different objects: @file{true-generic.o} and
7228 @file{false-generic.o}.
7230 @command{automake} doesn't actually look whether sources files are
7231 shared to decide if it must rename objects. It will just rename all
7232 objects of a target as soon as it sees per-target compilation flags
7235 It's OK to share object files when per-target compilation flags are not
7236 used. For instance @file{true} and @file{false} will both use
7237 @file{version.o} in the following example.
7240 AM_CPPFLAGS = -DVERSION=1.0
7241 bin_PROGRAMS = true false
7242 true_SOURCES = true.c version.c
7243 false_SOURCES = false.c version.c
7246 Note that the renaming of objects is also affected by the
7247 @code{_SHORTNAME} variable (@pxref{Program and Library Variables}).
7250 @node Multiple Outputs
7251 @section Handling Tools that Produce Many Outputs
7252 @cindex multiple outputs, rules with
7253 @cindex many outputs, rules with
7254 @cindex rules with multiple outputs
7256 This section describes a @command{make} idiom that can be used when a
7257 tool produces multiple output files. It is not specific to Automake
7258 and can be used in ordinary @file{Makefile}s.
7260 Suppose we have a program called @command{foo} that will read one file
7261 called @file{data.foo} and produce two files named @file{data.c} and
7262 @file{data.h}. We want to write a @file{Makefile} rule that captures
7263 this one-to-two dependency.
7265 The naive rule is incorrect:
7268 # This is incorrect.
7269 data.c data.h: data.foo
7274 What the above rule really says is that @file{data.c} and
7275 @file{data.h} each depend on @file{data.foo}, and can each be built by
7276 running @code{foo data.foo}. In other words it is equivalent to:
7279 # We do not want this.
7287 which means that @command{foo} can be run twice. Usually it will not
7288 be run twice, because @command{make} implementations are smart enough
7289 to check for the existence of the second file after the first one has
7290 been built; they will therefore detect that it already exists.
7291 However there are a few situations where it can run twice anyway:
7295 The most worrying case is when running a parallel @command{make}. If
7296 @file{data.c} and @file{data.h} are built in parallel, two @code{foo
7297 data.foo} commands will run concurrently. This is harmful.
7299 Another case is when the dependency (here @code{data.foo}) is
7300 (or depends upon) a phony target.
7303 A solution that works with parallel @command{make} but not with
7304 phony dependencies is the following:
7307 data.c data.h: data.foo
7313 The above rules are equivalent to
7318 data.h: data.foo data.c
7322 therefore a parallel @command{make} will have to serialize the builds
7323 of @file{data.c} and @file{data.h}, and will detect that the second is
7324 no longer needed once the first is over.
7326 Using this pattern is probably enough for most cases. However it does
7327 not scale easily to more output files (in this scheme all output files
7328 must be totally ordered by the dependency relation), so we will
7329 explore a more complicated solution.
7331 Another idea is to write the following:
7334 # There is still a problem with this one.
7341 The idea is that @code{foo data.foo} is run only when @file{data.c}
7342 needs to be updated, but we further state that @file{data.h} depends
7343 upon @file{data.c}. That way, if @file{data.h} is required and
7344 @file{data.foo} is out of date, the dependency on @file{data.c} will
7347 This is almost perfect, but suppose we have built @file{data.h} and
7348 @file{data.c}, and then we erase @file{data.h}. Then, running
7349 @code{make data.h} will not rebuild @file{data.h}. The above rules
7350 just state that @file{data.c} must be up-to-date with respect to
7351 @file{data.foo}, and this is already the case.
7353 What we need is a rule that forces a rebuild when @file{data.h} is
7354 missing. Here it is:
7360 @@if test -f $@@; then :; else \
7362 $(MAKE) $(AM_MAKEFLAGS) data.c; \
7366 The above scales easily to more outputs and more inputs. One of the
7367 output is picked up to serve as a witness of the run of the command,
7368 it depends upon all inputs, and all other outputs depend upon it. For
7369 instance if @command{foo} should additionally read @file{data.bar} and
7370 also produce @file{data.w} and @file{data.x}, we would write:
7373 data.c: data.foo data.bar
7374 foo data.foo data.bar
7375 data.h data.w data.x: data.c
7376 @@if test -f $@@; then :; else \
7378 $(MAKE) $(AM_MAKEFLAGS) data.c; \
7382 There is still a minor problem with this setup. @command{foo} outputs
7383 four files, but we do not know in which order these files are created.
7384 Suppose that @file{data.h} is created before @file{data.c}. Then we
7385 have a weird situation. The next time @command{make} is run,
7386 @file{data.h} will appear older than @file{data.c}, the second rule
7387 will be triggered, a shell will be started to execute the
7388 @code{if...fi} command, but actually it will just execute the
7389 @code{then} branch, that is: nothing. In other words, because the
7390 witness we selected is not the first file created by @command{foo},
7391 @command{make} will start a shell to do nothing each time it is run.
7393 A simple riposte is to fix the timestamps when this happens.
7396 data.c: data.foo data.bar
7397 foo data.foo data.bar
7398 data.h data.w data.x: data.c
7399 @@if test -f $@@; then \
7403 $(MAKE) $(AM_MAKEFLAGS) data.c; \
7407 Another solution, not incompatible with the previous one, is to use a
7408 different and dedicated file as witness, rather than using any of
7409 @command{foo}'s outputs.
7412 data.stamp: data.foo data.bar
7415 foo data.foo data.bar
7416 @@mv -f data.tmp $@@
7417 data.c data.h data.w data.x: data.stamp
7418 @@if test -f $@@; then \
7422 $(MAKE) $(AM_MAKEFLAGS) data.stamp; \
7426 @file{data.tmp} is created before @command{foo} is run, so it has a
7427 timestamp older than output files output by @command{foo}. It is then
7428 renamed to @file{data.stamp} after @command{foo} has run, because we
7429 do not want to update @file{data.stamp} if @command{foo} fails.
7431 Using a dedicated witness like this is very handy when the list of
7432 output files is not known beforehand. As an illustration, consider
7433 the following rules to compile many @file{*.el} files into
7434 @file{*.elc} files in a single command. It does not matter how
7435 @code{ELFILES} is defined (as long as it is not empty: empty targets
7436 are not accepted by POSIX).
7439 ELFILES = one.el two.el three.el @dots{}
7440 ELCFILES = $(ELFILES:=c)
7442 elc-stamp: $(ELFILES)
7445 $(elisp_comp) $(ELFILES)
7446 @@mv -f elc-temp $@@
7448 $(ELCFILES): elc-stamp
7449 @@if test -f $@@; then \
7453 $(MAKE) $(AM_MAKEFLAGS) elc-stamp; \
7457 For completeness it should be noted that GNU @command{make} is able to
7458 express rules with multiple output files using pattern rules
7459 (@pxref{Pattern Examples, , Pattern Rule Examples, make, The GNU Make
7460 Manual}). We do not discuss pattern rules here because they are not
7461 portable, but they can be convenient in packages that assume GNU
7464 @c ========================================================== Appendices
7467 @node Copying This Manual
7468 @appendix Copying This Manual
7471 * GNU Free Documentation License:: License for copying this manual
7481 * Macro and Variable Index:: Index of Autoconf macros and Automake variables
7482 * General Index:: General index
7485 @node Macro and Variable Index
7486 @appendixsec Macro and Variable Index
7491 @appendixsec General Index
7500 @c LocalWords: texinfo setfilename settitle setchapternewpage texi direntry
7501 @c LocalWords: dircategory in's aclocal ifinfo titlepage Tromey vskip pt sp
7502 @c LocalWords: filll defcodeindex ov cv op tr syncodeindex fn cp vr ifnottex
7503 @c LocalWords: dir Automake's ac Dist Gnits gnits cygnus dfn Autoconf's pxref
7504 @c LocalWords: cindex Autoconf autoconf perl samp cvs dist trindex SUBST foo
7505 @c LocalWords: xs emph FIXME ref vindex pkglibdir pkgincludedir pkgdatadir mt
7506 @c LocalWords: pkg libdir cvindex cpio bindir sbindir rmt pax sbin zar zardir
7507 @c LocalWords: HTML htmldir html noinst TEXINFOS nodist nobase strudel CFLAGS
7508 @c LocalWords: libmumble CC YFLAGS ansi knr itemx de fication config url comp
7509 @c LocalWords: depcomp elisp sh mdate mkinstalldirs mkdir py tex dvi ps pdf
7510 @c LocalWords: ylwrap zardoz INIT gettext acinclude mv FUNCS LIBOBJS LDADD fr
7511 @c LocalWords: uref featureful dnl src LINGUAS es ko nl pl sl sv PROG ISC doc
7512 @c LocalWords: POSIX STDC fcntl FUNC ALLOCA blksize struct stat intl po chmod
7513 @c LocalWords: ChangeLog SUBDIRS gettextize gpl testdata getopt INTLLIBS cpp
7514 @c LocalWords: localedir datadir DLOCALEDIR DEXIT CPPFLAGS autoreconf opindex
7515 @c LocalWords: AUX var symlink deps Wno Wnone package's aclocal's distclean
7516 @c LocalWords: ltmain xref LIBSOURCE LIBSOURCES LIBOBJ MEMCMP vs RANLIB CXX
7517 @c LocalWords: LDFLAGS LIBTOOL libtool XTRA LIBS gettext's acdir APIVERSION
7518 @c LocalWords: dirlist noindent usr MULTILIB multilib Multilibs TIOCGWINSZ sc
7519 @c LocalWords: GWINSZ termios SRCDIR tarball bzip LISPDIR lispdir XEmacs CCAS
7520 @c LocalWords: emacsen MicroEmacs CCASFLAGS UX GCJ gcj GCJFLAGS posix DMALLOC
7521 @c LocalWords: dmalloc ldmalloc REGEX regex rx DEPDIR DEP DEFUN aclocaldir fi
7522 @c LocalWords: mymacro myothermacro AMFLAGS autopoint autogen libtoolize yum
7523 @c LocalWords: autoheader README MAKEFLAGS subdir Inetutils sync COND endif
7524 @c LocalWords: Miller's installable includedir inc pkgdata EXEEXT libexec bsd
7525 @c LocalWords: pkglib libexecdir prog libcpio cpio's dlopen dlpreopen linux
7526 @c LocalWords: subsubsection OBJEXT esac lib LTLIBRARIES liblob LIBADD AR ar
7527 @c LocalWords: ARFLAGS cru ing maude libgettext lo LTLIBOBJS rpath SGI PRE yy
7528 @c LocalWords: libmaude CCLD CXXFLAGS FFLAGS LFLAGS OBJCFLAGS RFLAGS DEFS cc
7529 @c LocalWords: SHORTNAME vtable srcdir nostdinc basename yxx cxx ll lxx gdb
7530 @c LocalWords: lexers yymaxdepth maxdepth yyparse yylex yyerror yylval lval
7531 @c LocalWords: yychar yydebug yypact yyr yydef def yychk chk yypgo pgo yyact
7532 @c LocalWords: yyexca exca yyerrflag errflag yynerrs nerrs yyps yypv pv yys
7533 @c LocalWords: yystate yytmp tmp yyv yyval val yylloc lloc yyreds yytoks toks
7534 @c LocalWords: yylhs yylen yydefred yydgoto yysindex yyrindex yygindex yyname
7535 @c LocalWords: yytable yycheck yyrule byacc CXXCOMPILE CXXLINK FLINK cfortran
7536 @c LocalWords: Catalogue preprocessable FLIBS libfoo baz JAVACFLAGS java exe
7537 @c LocalWords: SunOS fying basenames exeext uninstalled oldinclude kr FSF's
7538 @c LocalWords: pkginclude oldincludedir sysconf sharedstate localstate gcc rm
7539 @c LocalWords: sysconfdir sharedstatedir localstatedir preexist CLEANFILES gz
7540 @c LocalWords: unnumberedsubsec depfile tmpdepfile depmode const interoperate
7541 @c LocalWords: JAVAC javac JAVAROOT builddir CLASSPATH ENV pyc pyo pkgpython
7542 @c LocalWords: pyexecdir pkgpyexecdir Python's pythondir pkgpythondir txi ois
7543 @c LocalWords: installinfo vers MAKEINFO makeinfo MAKEINFOFLAGS noinstall rf
7544 @c LocalWords: mandir thesame alsothesame installman myexecbin DESTDIR Pinard
7545 @c LocalWords: uninstall installdirs uninstalls MOSTLYCLEANFILES mostlyclean
7546 @c LocalWords: DISTCLEANFILES MAINTAINERCLEANFILES gzip'd GZIP gzip shar exp
7547 @c LocalWords: distdir distcheck distcleancheck listfiles distuninstallcheck
7548 @c LocalWords: VPATH tarfile stdout XFAIL DejaGnu dejagnu DEJATOOL runtest ln
7549 @c LocalWords: RUNTESTDEFAULTFLAGS toolchain RUNTESTFLAGS asis readme DVIPS
7550 @c LocalWords: installcheck gzipped tarZ std utils etags mkid multilibbing cd
7551 @c LocalWords: ARGS taggable ETAGSFLAGS lang ctags CTAGSFLAGS GTAGS gtags idl
7552 @c LocalWords: foocc doit idlC multilibs ABIs cmindex defmac ARG enableval
7553 @c LocalWords: MSG xtrue DBG pathchk CYGWIN afile proglink versioned CVS's
7554 @c LocalWords: wildcards Autoconfiscated subsubheading autotools Meyering API
7555 @c LocalWords: ois's wildcard Wportability cartouche vrindex printindex Duret
7556 @c LocalWords: DSOMEFLAG DVERSION automake Lutz insertcopying versioning FAQ
7557 @c LocalWords: LTLIBOBJ Libtool's libtool's libltdl dlopening itutions libbar
7558 @c LocalWords: WANTEDLIBS libhello sublibraries libtop libsub dlopened Ratfor
7559 @c LocalWords: mymodule timestamps timestamp underquoted MAKEINFOHTMLFLAGS
7560 @c LocalWords: GNUmakefile buildir