1 \input texinfo @c -*-texinfo-*-
3 @setfilename automake.info
10 @dircategory GNU programming tools
12 * automake: (automake). Making Makefile.in's
15 @dircategory Individual utilities
17 * aclocal: (automake)Invoking aclocal. Generating aclocal.m4
21 This file documents GNU automake @value{VERSION}
23 Copyright 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
25 Permission is granted to make and distribute verbatim copies of
26 this manual provided the copyright notice and this permission notice
27 are preserved on all copies.
30 Permission is granted to process this file through TeX and print the
31 results, provided the printed document carries copying permission
32 notice identical to this one except for the removal of this paragraph
36 Permission is granted to copy and distribute modified versions of this
37 manual under the conditions for verbatim copying, provided that the entire
38 resulting derived work is distributed under the terms of a permission
39 notice identical to this one.
41 Permission is granted to copy and distribute translations of this manual
42 into another language, under the above conditions for modified versions,
43 except that this permission notice may be stated in a translation approved
50 @subtitle For version @value{VERSION}, @value{UPDATED}
51 @author David MacKenzie and Tom Tromey
54 @vskip 0pt plus 1filll
55 Copyright @copyright{} 1995, 1996, 2000, 2001 Free Software Foundation, Inc.
57 This is the first edition of the GNU Automake documentation,@*
58 and is consistent with GNU Automake @value{VERSION}.@*
60 Published by the Free Software Foundation @*
61 59 Temple Place - Suite 330, @*
62 Boston, MA 02111-1307 USA @*
64 Permission is granted to make and distribute verbatim copies of
65 this manual provided the copyright notice and this permission notice
66 are preserved on all copies.
68 Permission is granted to copy and distribute modified versions of this
69 manual under the conditions for verbatim copying, provided that the entire
70 resulting derived work is distributed under the terms of a permission
71 notice identical to this one.
73 Permission is granted to copy and distribute translations of this manual
74 into another language, under the above conditions for modified versions,
75 except that this permission notice may be stated in a translation
76 approved by the Free Software Foundation.
79 @c Define an index of configure output variables.
81 @c Define an index of configure variables.
83 @c Define an index of options.
85 @c Define an index of targets.
87 @c Define an index of commands.
90 @c Put the macros and variables into their own index.
91 @c @syncodeindex fn cp
96 @c Put everything else into one index (arbitrarily chosen to be the concept index).
102 @node Top, Introduction, (dir), (dir)
103 @comment node-name, next, previous, up
106 This file documents the GNU Automake package. Automake is a program
107 which creates GNU standards-compliant Makefiles from template files.
108 This edition documents version @value{VERSION}.
111 * Introduction:: Automake's purpose
112 * Generalities:: General ideas
113 * Examples:: Some example packages
114 * Invoking Automake:: Creating a Makefile.in
115 * configure:: Scanning configure.ac or configure.in
116 * Top level:: The top-level Makefile.am
117 * Rebuilding:: Automatic rebuilding of Makefile
118 * Programs:: Building programs and libraries
119 * Other objects:: Other derived objects
120 * Other GNU Tools:: Other GNU Tools
121 * Documentation:: Building documentation
122 * Install:: What gets installed
123 * Clean:: What gets cleaned
124 * Dist:: What goes in a distribution
125 * Tests:: Support for test suites
126 * Options:: Changing Automake's behavior
127 * Miscellaneous:: Miscellaneous rules
128 * Include:: Including extra files in an Automake template.
129 * Conditionals:: Conditionals
130 * Gnits:: The effect of @code{--gnu} and @code{--gnits}
131 * Cygnus:: The effect of @code{--cygnus}
132 * Extending:: Extending Automake
133 * Distributing:: Distributing the Makefile.in
134 * Macro and Variable Index::
141 @node Introduction, Generalities, Top, Top
142 @chapter Introduction
144 Automake is a tool for automatically generating @file{Makefile.in}s from
145 files called @file{Makefile.am}. Each @file{Makefile.am} is basically a
146 series of @code{make} macro definitions (with rules being thrown in
147 occasionally). The generated @file{Makefile.in}s are compliant with the
148 GNU Makefile standards.
150 @cindex GNU Makefile standards
152 The GNU Makefile Standards Document
153 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
154 is long, complicated, and subject to change. The goal of Automake is to
155 remove the burden of Makefile maintenance from the back of the
156 individual GNU maintainer (and put it on the back of the Automake
159 The typical Automake input file is simply a series of macro definitions.
160 Each such file is processed to create a @file{Makefile.in}. There
161 should generally be one @file{Makefile.am} per directory of a project.
163 @cindex Constraints of Automake
164 @cindex Automake constraints
166 Automake does constrain a project in certain ways; for instance it
167 assumes that the project uses Autoconf (@pxref{Top, , Introduction,
168 autoconf, The Autoconf Manual}), and enforces certain restrictions on
169 the @file{configure.in} contents@footnote{Autoconf 2.50 promotes
170 @file{configure.ac} over @file{configure.in}. The rest of this
171 documentation will refer to @file{configure.in} as this use is not yet
172 spread, but Automake supports @file{configure.ac} too.}.
174 @cindex Automake requirements
175 @cindex Requirements, Automake
177 Automake requires @code{perl} in order to generate the
178 @file{Makefile.in}s. However, the distributions created by Automake are
179 fully GNU standards-compliant, and do not require @code{perl} in order
182 @cindex BUGS, reporting
183 @cindex Reporting BUGS
184 @cindex E-mail, bug reports
186 Mail suggestions and bug reports for Automake to
187 @email{bug-automake@@gnu.org}.
190 @node Generalities, Examples, Introduction, Top
191 @chapter General ideas
193 The following sections cover a few basic ideas that will help you
194 understand how Automake works.
197 * General Operation:: General operation of Automake
198 * Strictness:: Standards conformance checking
199 * Uniform:: The Uniform Naming Scheme
200 * Canonicalization:: How derived variables are named
201 * User Variables:: Variables reserved for the user
205 @node General Operation, Strictness, Generalities, Generalities
206 @section General Operation
208 Automake works by reading a @file{Makefile.am} and generating a
209 @file{Makefile.in}. Certain macros and targets defined in the
210 @file{Makefile.am} instruct Automake to generate more specialized code;
211 for instance, a @samp{bin_PROGRAMS} macro definition will cause targets
212 for compiling and linking programs to be generated.
214 @cindex Non-standard targets
215 @cindex cvs-dist, non-standard example
218 The macro definitions and targets in the @file{Makefile.am} are copied
219 verbatim into the generated file. This allows you to add arbitrary code
220 into the generated @file{Makefile.in}. For instance the Automake
221 distribution includes a non-standard @code{cvs-dist} target, which the
222 Automake maintainer uses to make distributions from his source control
225 @cindex GNU make extensions
227 Note that GNU make extensions are not recognized by Automake. Using
228 such extensions in a @file{Makefile.am} will lead to errors or confusing
231 Automake tries to group comments with adjoining targets and macro
232 definitions in an intelligent way.
234 @cindex Make targets, overriding
235 @cindex Overriding make targets
237 A target defined in @file{Makefile.am} generally overrides any such
238 target of a similar name that would be automatically generated by
239 @code{automake}. Although this is a supported feature, it is generally
240 best to avoid making use of it, as sometimes the generated rules are
243 @cindex Macros, overriding
244 @cindex Overriding make macros
246 Similarly, a macro defined in @file{Makefile.am} will override any
247 definition of the macro that @code{automake} would ordinarily create.
248 This feature is more often useful than the ability to override a target
249 definition. Be warned that many of the macros generated by
250 @code{automake} are considered to be for internal use only, and their
251 names might change in future releases.
253 @cindex Recursive operation of Automake
254 @cindex Automake, recursive operation
255 @cindex Example of recursive operation
257 When examining a macro definition, Automake will recursively examine
258 macros referenced in the definition. For example, if Automake is
259 looking at the content of @code{foo_SOURCES} in this snippet
263 foo_SOURCES = c.c $(xs)
266 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
267 contents of @code{foo_SOURCES}.
269 @cindex ## (special Automake comment)
270 @cindex Special Automake comment
271 @cindex Comment, special to Automake
273 Automake also allows a form of comment which is @emph{not} copied into
274 the output; all lines beginning with @samp{##} (leading spaces allowed)
275 are completely ignored by Automake.
277 It is customary to make the first line of @file{Makefile.am} read:
279 @cindex Makefile.am, first line
280 @cindex First line of Makefile.am
283 ## Process this file with automake to produce Makefile.in
286 @c FIXME discuss putting a copyright into Makefile.am here? I would but
287 @c I don't know quite what to say.
289 @c FIXME document customary ordering of Makefile.am here!
292 @node Strictness, Uniform, General Operation, Generalities
295 @cindex Non-GNU packages
297 While Automake is intended to be used by maintainers of GNU packages, it
298 does make some effort to accommodate those who wish to use it, but do
299 not want to use all the GNU conventions.
301 @cindex Strictness, defined
302 @cindex Strictness, foreign
303 @cindex foreign strictness
304 @cindex Strictness, gnu
305 @cindex gnits strictness
306 @cindex Strictness, gnits
307 @cindex gnits strictness
309 To this end, Automake supports three levels of @dfn{strictness}---the
310 strictness indicating how stringently Automake should check standards
313 The valid strictness levels are:
317 Automake will check for only those things which are absolutely
318 required for proper operations. For instance, whereas GNU standards
319 dictate the existence of a @file{NEWS} file, it will not be required in
320 this mode. The name comes from the fact that Automake is intended to be
321 used for GNU programs; these relaxed rules are not the standard mode of
325 Automake will check---as much as possible---for compliance to the GNU
326 standards for packages. This is the default.
329 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
330 standards}. These are based on the GNU standards, but are even more
331 detailed. Unless you are a Gnits standards contributor, it is
332 recommended that you avoid this option until such time as the Gnits
333 standard is actually published (which may never happen).
336 For more information on the precise implications of the strictness
337 level, see @ref{Gnits}.
340 @node Uniform, Canonicalization, Strictness, Generalities
341 @section The Uniform Naming Scheme
343 @cindex Uniform naming scheme
345 Automake macros (from here on referred to as @emph{variables}) generally
346 follow a @dfn{uniform naming scheme} that makes it easy to decide how
347 programs (and other derived objects) are built, and how they are
348 installed. This scheme also supports @code{configure} time
349 determination of what should be built.
351 @cindex _PROGRAMS primary variable
352 @cindex PROGRAMS primary variable
353 @cindex Primary variable, PROGRAMS
355 @cindex Primary variable, defined
357 At @code{make} time, certain variables are used to determine which
358 objects are to be built. These variables are called @dfn{primary
359 variables}. For instance, the primary variable @code{PROGRAMS} holds a
360 list of programs which are to be compiled and linked.
363 @cindex pkglibdir, defined
364 @cindex pkgincludedir, defined
365 @cindex pkgdatadir, defined
368 @vindex pkgincludedir
371 A different set of variables is used to decide where the built objects
372 should be installed. These variables are named after the primary
373 variables, but have a prefix indicating which standard directory should
374 be used as the installation directory. The standard directory names are
375 given in the GNU standards (@pxref{Directory Variables, , , standards,
376 The GNU Coding Standards}). Automake extends this list with
377 @code{pkglibdir}, @code{pkgincludedir}, and @code{pkgdatadir}; these are
378 the same as the non-@samp{pkg} versions, but with @samp{@@PACKAGE@@}
379 appended. For instance, @code{pkglibdir} is defined as
380 @code{$(libdir)/@@PACKAGE@@}.
383 @cindex EXTRA_, prepending
385 For each primary, there is one additional variable named by prepending
386 @samp{EXTRA_} to the primary name. This variable is used to list
387 objects which may or may not be built, depending on what
388 @code{configure} decides. This variable is required because Automake
389 must statically know the entire list of objects that may be built in
390 order to generate a @file{Makefile.in} that will work in all cases.
392 @cindex EXTRA_PROGRAMS, defined
393 @cindex Example, EXTRA_PROGRAMS
396 For instance, @code{cpio} decides at configure time which programs are
397 built. Some of the programs are installed in @code{bindir}, and some
398 are installed in @code{sbindir}:
401 EXTRA_PROGRAMS = mt rmt
402 bin_PROGRAMS = cpio pax
403 sbin_PROGRAMS = @@MORE_PROGRAMS@@
406 Defining a primary variable without a prefix (e.g. @code{PROGRAMS}) is
409 Note that the common @samp{dir} suffix is left off when constructing the
410 variable names; thus one writes @samp{bin_PROGRAMS} and not
411 @samp{bindir_PROGRAMS}.
413 Not every sort of object can be installed in every directory. Automake
414 will flag those attempts it finds in error. Automake will also diagnose
415 obvious misspellings in directory names.
417 @cindex Extending list of installation directories
418 @cindex Installation directories, extending list
420 Sometimes the standard directories---even as augmented by Automake---
421 are not enough. In particular it is sometimes useful, for clarity, to
422 install objects in a subdirectory of some predefined directory. To this
423 end, Automake allows you to extend the list of possible installation
424 directories. A given prefix (e.g. @samp{zar}) is valid if a variable of
425 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
427 @cindex HTML support, example
429 For instance, until HTML support is part of Automake, you could use this
430 to install raw HTML documentation:
433 htmldir = $(prefix)/html
434 html_DATA = automake.html
437 @cindex noinst primary prefix, definition
439 The special prefix @samp{noinst} indicates that the objects in question
440 should not be installed at all.
442 @cindex check primary prefix, definition
444 The special prefix @samp{check} indicates that the objects in question
445 should not be built until the @code{make check} command is run.
447 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
448 @samp{LISP}, @samp{PYTHON}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS},
449 @samp{MANS}, and @samp{TEXINFOS}.
460 Some primaries also allow additional prefixes which control other
461 aspects of @code{automake}'s behavior. The currently defined prefixes
462 are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}. These prefixes
466 @node Canonicalization, User Variables, Uniform, Generalities
467 @section How derived variables are named
469 @cindex canonicalizing Automake macros
471 Sometimes a Makefile variable name is derived from some text the user
472 supplies. For instance, program names are rewritten into Makefile macro
473 names. Automake canonicalizes this text, so that it does not have to
474 follow Makefile macro naming rules. All characters in the name except
475 for letters, numbers, the strudel (@@), and the underscore are turned into
476 underscores when making macro references. For example, if your program
477 is named @code{sniff-glue}, the derived variable name would be
478 @code{sniff_glue_SOURCES}, not @code{sniff-glue_SOURCES}. The strudel
479 is an addition since Automake 1.4c, to make the use of Autoconf
480 substitutions in macro names less obfuscating.
483 @node User Variables, , Canonicalization, Generalities
484 @section Variables reserved for the user
486 @cindex variables, reserved for the user
487 @cindex user variables
489 Some @code{Makefile} variables are reserved by the GNU Coding Standards
490 for the use of the ``user'' -- the person building the package. For
491 instance, @code{CFLAGS} is one such variable.
493 Sometimes package developers are tempted to set user variables such as
494 @code{CFLAGS} because it appears to make their job easier -- they don't
495 have to introduce a second variable into every target.
497 However, the package itself should never set a user variable,
498 particularly not to include switches which are required for proper
499 compilation of the package. Since these variables are documented as
500 being for the package builder, that person rightfully expects to be able
501 to override any of these variables at build time.
503 To get around this problem, automake introduces an automake-specific
504 shadow variable for each user flag variable. (Shadow variables are not
505 introduced for variables like @code{CC}, where they would make no
506 sense.) The shadow variable is named by prepending @samp{AM_} to the
507 user variable's name. For instance, the shadow variable for
508 @code{YFLAGS} is @code{AM_YFLAGS}.
512 @node Examples, Invoking Automake, Generalities, Top
513 @chapter Some example packages
516 * Complete:: A simple example, start to finish
517 * Hello:: A classic program
518 * etags:: Building etags and ctags
522 @node Complete, Hello, Examples, Examples
523 @section A simple example, start to finish
525 @cindex Complete example
527 Let's suppose you just finished writing @code{zardoz}, a program to make
528 your head float from vortex to vortex. You've been using Autoconf to
529 provide a portability framework, but your @file{Makefile.in}s have been
530 ad-hoc. You want to make them bulletproof, so you turn to Automake.
532 @cindex AM_INIT_AUTOMAKE, example use
534 The first step is to update your @file{configure.in} to include the
535 commands that @code{automake} needs. The way to do this is to add an
536 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
539 AM_INIT_AUTOMAKE(zardoz, 1.0)
542 Since your program doesn't have any complicating factors (e.g., it
543 doesn't use @code{gettext}, it doesn't want to build a shared library),
544 you're done with this part. That was easy!
546 @cindex aclocal program, introduction
547 @cindex aclocal.m4, preexisting
548 @cindex acinclude.m4, defined
550 Now you must regenerate @file{configure}. But to do that, you'll need
551 to tell @code{autoconf} how to find the new macro you've used. The
552 easiest way to do this is to use the @code{aclocal} program to generate
553 your @file{aclocal.m4} for you. But wait... you already have an
554 @file{aclocal.m4}, because you had to write some hairy macros for your
555 program. The @code{aclocal} program lets you put your own macros into
556 @file{acinclude.m4}, so simply rename and then run:
559 mv aclocal.m4 acinclude.m4
564 @cindex zardoz example
566 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
567 Since @code{zardoz} is a user program, you want to install it where the
568 rest of the user programs go. Additionally, @code{zardoz} has some
569 Texinfo documentation. Your @file{configure.in} script uses
570 @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
571 So here's what you'd write:
574 bin_PROGRAMS = zardoz
575 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
576 zardoz_LDADD = @@LIBOBJS@@
578 info_TEXINFOS = zardoz.texi
581 Now you can run @code{automake --add-missing} to generate your
582 @file{Makefile.in} and grab any auxiliary files you might need, and
586 @node Hello, etags, Complete, Examples
587 @section A classic program
589 @cindex Example, GNU Hello
590 @cindex Hello example
591 @cindex GNU Hello, example
593 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
594 renowned for its classic simplicity and versatility. This section shows
595 how Automake could be used with the GNU Hello package. The examples
596 below are from the latest beta version of GNU Hello, but with all of the
597 maintainer-only code stripped out, as well as all copyright comments.
599 Of course, GNU Hello is somewhat more featureful than your traditional
600 two-liner. GNU Hello is internationalized, does option processing, and
601 has a manual and a test suite.
603 @cindex configure.in, from GNU Hello
604 @cindex GNU Hello, configure.in
605 @cindex Hello, configure.in
607 Here is the @file{configure.in} from GNU Hello:
610 dnl Process this file with autoconf to produce a configure script.
612 AM_INIT_AUTOMAKE(hello, 1.3.11)
613 AM_CONFIG_HEADER(config.h)
615 dnl Set of available languages.
616 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
618 dnl Checks for programs.
622 dnl Checks for libraries.
624 dnl Checks for header files.
626 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
628 dnl Checks for library functions.
631 dnl Check for st_blksize in struct stat
634 dnl internationalization macros
636 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
637 src/Makefile tests/Makefile tests/hello],
638 [chmod +x tests/hello])
641 The @samp{AM_} macros are provided by Automake (or the Gettext library);
642 the rest are standard Autoconf macros.
645 The top-level @file{Makefile.am}:
648 EXTRA_DIST = BUGS ChangeLog.O
649 SUBDIRS = doc intl po src tests
652 As you can see, all the work here is really done in subdirectories.
654 The @file{po} and @file{intl} directories are automatically generated
655 using @code{gettextize}; they will not be discussed here.
657 @cindex Texinfo file handling example
658 @cindex Example, handling Texinfo files
660 In @file{doc/Makefile.am} we see:
663 info_TEXINFOS = hello.texi
664 hello_TEXINFOS = gpl.texi
667 This is sufficient to build, install, and distribute the GNU Hello
670 @cindex Regression test example
671 @cindex Example, regression test
673 Here is @file{tests/Makefile.am}:
677 EXTRA_DIST = hello.in testdata
680 The script @file{hello} is generated by @code{configure}, and is the
681 only test case. @code{make check} will run this test.
683 @cindex INCLUDES, example usage
685 Last we have @file{src/Makefile.am}, where all the real work is done:
689 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
690 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
691 localedir = $(datadir)/locale
692 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
696 @node etags, , Hello, Examples
697 @section Building etags and ctags
699 @cindex Example, ctags and etags
700 @cindex ctags Example
701 @cindex etags Example
703 Here is another, trickier example. It shows how to generate two
704 programs (@code{ctags} and @code{etags}) from the same source file
705 (@file{etags.c}). The difficult part is that each compilation of
706 @file{etags.c} requires different @code{cpp} flags.
709 bin_PROGRAMS = etags ctags
711 ctags_LDADD = ctags.o
714 $(COMPILE) -DETAGS_REGEXPS -c etags.c
717 $(COMPILE) -DCTAGS -o ctags.o -c etags.c
720 Note that @code{ctags_SOURCES} is defined to be empty---that way no
721 implicit value is substituted. The implicit value, however, is used to
722 generate @code{etags} from @file{etags.o}.
724 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
725 @code{ctags_DEPENDENCIES} is generated by Automake.
727 The above rules won't work if your compiler doesn't accept both
728 @samp{-c} and @samp{-o}. The simplest fix for this is to introduce a
729 bogus dependency (to avoid problems with a parallel @code{make}):
732 etags.o: etags.c ctags.o
733 $(COMPILE) -DETAGS_REGEXPS -c etags.c
736 $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
739 Also, these explicit rules do not work if the de-ANSI-fication feature
740 is used (@pxref{ANSI}). Supporting de-ANSI-fication requires a little
744 etags._o: etags._c ctags.o
745 $(COMPILE) -DETAGS_REGEXPS -c etags.c
748 $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o
751 As it turns out, there is also a much easier way to do this same task.
752 Some of the above techniques are useful enough that we've kept the
753 example in the manual. However if you were to build @code{etags} and
754 @code{ctags} in real life, you would probably use per-program
755 compilation flags, like so:
758 bin_PROGRAMS = ctags etags
760 ctags_SOURCES = etags.c
761 ctags_CFLAGS = -DCTAGS
763 etags_SOURCES = etags.c
764 etags_CFLAGS = -DETAGS_REGEXPS
767 In this case Automake will cause @file{etags.c} to be compiled twice,
768 with different flags. De-ANSI-fication will work automatically. In
769 this instance, the names of the object files would be chosen by
770 automake; they would be @file{ctags-etags.c} and @file{etags-etags.o}.
771 (The name of the object files rarely matters.)
774 @node Invoking Automake, configure, Examples, Top
775 @chapter Creating a @file{Makefile.in}
777 @cindex Multiple configure.in files
778 @cindex Invoking Automake
779 @cindex Automake, invoking
781 To create all the @file{Makefile.in}s for a package, run the
782 @code{automake} program in the top level directory, with no arguments.
783 @code{automake} will automatically find each appropriate
784 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
785 and generate the corresponding @file{Makefile.in}. Note that
786 @code{automake} has a rather simplistic view of what constitutes a
787 package; it assumes that a package has only one @file{configure.in}, at
788 the top. If your package has multiple @file{configure.in}s, then you
789 must run @code{automake} in each directory holding a
792 You can optionally give @code{automake} an argument; @file{.am} is
793 appended to the argument and the result is used as the name of the input
794 file. This feature is generally only used to automatically rebuild an
795 out-of-date @file{Makefile.in}. Note that @code{automake} must always
796 be run from the topmost directory of a project, even if being used to
797 regenerate the @file{Makefile.in} in some subdirectory. This is
798 necessary because @code{automake} must scan @file{configure.in}, and
799 because @code{automake} uses the knowledge that a @file{Makefile.in} is
800 in a subdirectory to change its behavior in some cases.
802 @cindex Automake options
803 @cindex Options, Automake
805 @code{automake} accepts the following options:
807 @cindex Extra files distributed with Automake
808 @cindex Files distributed with Automake
815 @opindex --add-missing
816 Automake requires certain common files to exist in certain situations;
817 for instance @file{config.guess} is required if @file{configure.in} runs
818 @code{AC_CANONICAL_HOST}. Automake is distributed with several of these
819 files; this option will cause the missing ones to be automatically added
820 to the package, whenever possible. In general if Automake tells you a
821 file is missing, try using this option. By default Automake tries to
822 make a symbolic link pointing to its own copy of the missing file; this
823 can be changed with @code{--copy}.
825 @item --libdir=@var{dir}
827 Look for Automake data files in directory @var{dir} instead of in the
828 installation directory. This is typically used for debugging.
834 When used with @code{--add-missing}, causes installed files to be
835 copied. The default is to make a symbolic link.
839 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
840 of GNU or Gnits rules. For more information, see @ref{Cygnus}.
844 @itemx --force-missing
845 @opindex --force-missing
846 When used with @code{--add-missing}, causes standard files to be rebuilt
847 even if they already exist in the source tree. This involves removing
848 the file from the source tree before creating the new symlink (or, with
849 @code{--copy}, copying the new file).
853 Set the global strictness to @samp{foreign}. For more information, see
858 Set the global strictness to @samp{gnits}. For more information, see
863 Set the global strictness to @samp{gnu}. For more information, see
864 @ref{Gnits}. This is the default strictness.
868 Print a summary of the command line options and exit.
871 @itemx --include-deps
873 @opindex --include-deps
874 Include all automatically generated dependency information
875 (@pxref{Dependencies}) in the generated
876 @file{Makefile.in}. This is generally done when making a distribution;
881 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
882 @file{configure.in}. This option causes it to only update those
883 @file{Makefile.in}s which are out of date with respect to one of their
887 @itemx --output-dir=@var{dir}
889 @opindex --output-dir
890 Put the generated @file{Makefile.in} in the directory @var{dir}.
891 Ordinarily each @file{Makefile.in} is created in the directory of the
892 corresponding @file{Makefile.am}. This option is used when making
899 Cause Automake to print information about which files are being read or
904 Print the version number of Automake and exit.
908 @node configure, Top level, Invoking Automake, Top
909 @chapter Scanning @file{configure.in}
911 @cindex configure.in, scanning
912 @cindex Scanning configure.in
914 Automake scans the package's @file{configure.in} to determine certain
915 information about the package. Some @code{autoconf} macros are required
916 and some variables must be defined in @file{configure.in}. Automake
917 will also use information from @file{configure.in} to further tailor its
920 Automake also supplies some Autoconf macros to make the maintenance
921 easier. These macros can automatically be put into your
922 @file{aclocal.m4} using the @code{aclocal} program.
925 * Requirements:: Configuration requirements
926 * Optional:: Other things Automake recognizes
927 * Invoking aclocal:: Auto-generating aclocal.m4
928 * Macros:: Autoconf macros supplied with Automake
929 * Extending aclocal:: Writing your own aclocal macros
933 @node Requirements, Optional, configure, configure
934 @section Configuration requirements
936 @cindex Automake requirements
937 @cindex Requirements of Automake
939 The one real requirement of Automake is that your @file{configure.in}
940 call @code{AM_INIT_AUTOMAKE}. This macro does several things which are
941 required for proper Automake operation.
942 @cvindex AM_INIT_AUTOMAKE
944 Here are the other macros which Automake requires but which are not run
945 by @code{AM_INIT_AUTOMAKE}:
947 @cindex AC_OUTPUT, scanning
951 Automake uses this to determine which files to create (@pxref{Output, ,
952 Creating Output Files, autoconf, The Autoconf Manual}). Listed files
953 named @code{Makefile} are treated as @file{Makefile}s. Other listed
954 files are treated differently. Currently the only difference is that a
955 @file{Makefile} is removed by @code{make distclean}, while other files
956 are removed by @code{make clean}.
957 @c FIXME: this is in violation of standards!
961 You may need the following macros in some conditions, even though they
965 @item AC_CHECK_TOOL([STRIP],[strip])
966 @cindex STRIP, how to setup
967 @cindex install-strip and STRIP
968 @cvindex AC_CHECK_TOOL([STRIP],[strip])
969 Installed binaries are usually stripped using @code{strip} when you run
970 @code{make install-strip}. However @code{strip} might not be the
971 right tool to use in cross-compilation environments, therefore
972 Automake will honor the @code{STRIP} environment variable to overrule
973 the program used to perform stripping. Automake will not set @code{STRIP}
974 itself. If your package is not setup for cross-compilation you do not
975 have to care (@code{strip} is ok), otherwise you can set @code{STRIP}
976 automatically by calling @code{AC_CHECK_TOOL([STRIP],[strip])} from
977 your @file{configure.in}.
981 @node Optional, Invoking aclocal, Requirements, configure
982 @section Other things Automake recognizes
984 @cindex Macros Automake recognizes
985 @cindex Recognized macros by Automake
987 Automake will also recognize the use of certain macros and tailor the
988 generated @file{Makefile.in} appropriately. Currently recognized macros
989 and their effects are:
992 @item AC_CONFIG_HEADER
993 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
994 to @code{AC_CONFIG_HEADER} (@pxref{Configuration Headers, ,
995 Configuration Header Files, autoconf, The Autoconf Manual}), but does
996 some useful Automake-specific work.
997 @cvindex AC_CONFIG_HEADER
999 @item AC_CONFIG_AUX_DIR
1000 Automake will look for various helper scripts, such as
1001 @file{mkinstalldirs}, in the directory named in this macro invocation.
1002 If not seen, the scripts are looked for in their @samp{standard}
1003 locations (either the top source directory, or in the source directory
1004 corresponding to the current @file{Makefile.am}, whichever is
1005 appropriate). @xref{Input, , Finding `configure' Input, autoconf, The
1007 @cvindex AC_CONFIG_AUX_DIR
1008 FIXME: give complete list of things looked for in this directory
1011 Automake will insert definitions for the variables defined by
1012 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
1013 or library. @xref{System Services, , System Services, autoconf, The
1015 @cvindex AC_PATH_XTRA
1017 @item AC_CANONICAL_HOST
1018 @itemx AC_CHECK_TOOL
1019 Automake will ensure that @file{config.guess} and @file{config.sub}
1020 exist. Also, the @file{Makefile} variables @samp{host_alias} and
1021 @samp{host_triplet} are introduced. See both @ref{Canonicalizing, ,
1022 Getting the Canonical System Type, autoconf, The Autoconf Manual}, and
1023 @ref{Generic Programs, , Generic Program Checks, autoconf, The Autoconf
1025 @c fixme xref autoconf docs.
1026 @cvindex AC_CANONICAL_HOST
1027 @cvindex AC_CHECK_TOOL
1029 @vindex host_triplet
1031 @item AC_CANONICAL_SYSTEM
1032 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
1033 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
1034 @xref{Canonicalizing, , Getting the Canonical System Type, autoconf, The
1036 @cvindex AC_CANONICAL_SYSTEM
1038 @vindex target_alias
1040 @item AC_FUNC_ALLOCA
1041 @itemx AC_FUNC_GETLOADAVG
1042 @itemx AC_FUNC_MEMCMP
1043 @itemx AC_STRUCT_ST_BLOCKS
1044 @itemx AC_FUNC_FNMATCH
1045 @itemx AC_FUNC_MKTIME
1046 @itemx AM_FUNC_STRTOD
1047 @itemx AC_REPLACE_FUNCS
1048 @itemx AC_REPLACE_GNU_GETOPT
1049 @itemx AM_WITH_REGEX
1050 Automake will ensure that the appropriate dependencies are generated for
1051 the objects corresponding to these macros. Also, Automake will verify
1052 that the appropriate source files are part of the distribution. Note
1053 that Automake does not come with any of the C sources required to use
1054 these macros, so @code{automake -a} will not install the sources.
1055 @xref{A Library}, for more information. Also, see @ref{Particular
1056 Functions, , Particular Function Checks, autoconf, The Autoconf Manual}.
1057 @cvindex AC_FUNC_ALLOCA
1058 @cvindex AC_FUNC_GETLOADAVG
1059 @cvindex AC_FUNC_MEMCMP
1060 @cvindex AC_STRUCT_ST_BLOCKS
1061 @cvindex AC_FUNC_FNMATCH
1062 @cvindex AC_FUNC_FNMATCH
1063 @cvindex AC_REPLACE_FUNCS
1064 @cvindex AC_REPLACE_GNU_GETOPT
1065 @cvindex AM_FUNC_STRTOD
1066 @cvindex AM_WITH_REGEX
1067 @cvindex AC_FUNC_MKTIME
1070 Automake will detect statements which put @file{.o} files into
1071 @code{LIBOBJS}, and will treat these additional files as if they were
1072 discovered via @code{AC_REPLACE_FUNCS}. @xref{Generic Functions, ,
1073 Generic Function Checks, autoconf, The Autoconf Manual}.
1076 @item AC_PROG_RANLIB
1077 This is required if any libraries are built in the package.
1078 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1080 @cvindex AC_PROG_RANLIB
1083 This is required if any C++ source is included. @xref{Particular
1084 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1085 @cvindex AC_PROG_CXX
1088 This is required if any Fortran 77 source is included. This macro is
1089 distributed with Autoconf version 2.13 and later. @xref{Particular
1090 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1091 @cvindex AC_PROG_F77
1093 @item AC_F77_LIBRARY_LDFLAGS
1094 This is required for programs and shared libraries that are a mixture of
1095 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1096 C++}). @xref{Macros, , Autoconf macros supplied with Automake}.
1097 @cvindex AC_F77_LIBRARY_LDFLAGS
1099 @item AC_PROG_LIBTOOL
1100 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1101 Introduction, libtool, The Libtool Manual}).
1102 @cvindex AC_PROG_LIBTOOL
1105 If a Yacc source file is seen, then you must either use this macro or
1106 define the variable @samp{YACC} in @file{configure.in}. The former is
1107 preferred (@pxref{Particular Programs, , Particular Program Checks,
1108 autoconf, The Autoconf Manual}).
1109 @cvindex AC_PROG_YACC
1112 @item AC_DECL_YYTEXT
1113 This macro is required if there is Lex source in the package.
1114 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1116 @cvindex AC_DECL_YYTEXT
1119 If a Lex source file is seen, then this macro must be used.
1120 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1122 @cvindex AC_PROG_LEX
1125 If Automake sees that this variable is set in @file{configure.in}, it
1126 will check the @file{po} directory to ensure that all the named
1127 @samp{.po} files exist, and that all the @samp{.po} files that exist are
1129 @cvindex ALL_LINGUAS
1131 @item AM_C_PROTOTYPES
1132 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1133 @cvindex AM_C_PROTOTYPES
1135 @item AM_GNU_GETTEXT
1136 This macro is required for packages which use GNU gettext
1137 (@pxref{gettext}). It is distributed with gettext. If Automake sees
1138 this macro it ensures that the package meets some of gettext's
1140 @cvindex AM_GNU_GETTEXT
1142 @item AM_MAINTAINER_MODE
1143 @opindex --enable-maintainer-mode
1144 This macro adds a @samp{--enable-maintainer-mode} option to
1145 @code{configure}. If this is used, @code{automake} will cause
1146 @samp{maintainer-only} rules to be turned off by default in the
1147 generated @file{Makefile.in}s. This macro is disallowed in @samp{Gnits}
1148 mode (@pxref{Gnits}). This macro defines the @samp{MAINTAINER_MODE}
1149 conditional, which you can use in your own @file{Makefile.am}.
1150 @cvindex AM_MAINTAINER_MODE
1153 @itemx AC_CHECK_TOOL
1154 @itemx AC_CHECK_PROG
1155 @itemx AC_CHECK_PROGS
1157 @itemx AC_PATH_PROGS
1158 For each of these macros, the first argument is automatically defined as
1159 a variable in each generated @file{Makefile.in}. @xref{Setting Output
1160 Variables, , Setting Output Variables, autoconf, The Autoconf Manual},
1161 and @ref{Generic Programs, , Generic Program Checks, autoconf, The
1164 @cvindex AC_CHECK_TOOL
1165 @cvindex AC_CHECK_PROG
1166 @cvindex AC_CHECK_PROGS
1167 @cvindex AC_PATH_PROG
1168 @cvindex AC_PATH_PROGS
1173 @node Invoking aclocal, Macros, Optional, configure
1174 @section Auto-generating aclocal.m4
1176 @cindex Invoking aclocal
1177 @cindex aclocal, Invoking
1179 Automake includes a number of Autoconf macros which can be used in your
1180 package; some of them are actually required by Automake in certain
1181 situations. These macros must be defined in your @file{aclocal.m4};
1182 otherwise they will not be seen by @code{autoconf}.
1184 The @code{aclocal} program will automatically generate @file{aclocal.m4}
1185 files based on the contents of @file{configure.in}. This provides a
1186 convenient way to get Automake-provided macros, without having to
1187 search around. Also, the @code{aclocal} mechanism is extensible for use
1190 At startup, @code{aclocal} scans all the @file{.m4} files it can find,
1191 looking for macro definitions. Then it scans @file{configure.in}. Any
1192 mention of one of the macros found in the first step causes that macro,
1193 and any macros it in turn requires, to be put into @file{aclocal.m4}.
1195 The contents of @file{acinclude.m4}, if it exists, are also
1196 automatically included in @file{aclocal.m4}. This is useful for
1197 incorporating local macros into @file{configure}.
1199 @code{aclocal} tries to be smart about looking for new @code{AC_DEFUN}s
1200 in the files it scans. It will warn if it finds duplicates. It also
1201 tries to copy the full text of the scanned file into @file{aclocal.m4},
1202 including both @samp{#} and @samp{dnl} comments. If you want to make a
1203 comment which will be completely ignored by @code{aclocal}, use
1204 @samp{##} as the comment leader.
1206 @code{aclocal} accepts the following options:
1209 @item --acdir=@var{dir}
1211 Look for the macro files in @var{dir} instead of the installation
1212 directory. This is typically used for debugging.
1216 Print a summary of the command line options and exit.
1220 Add the directory @var{dir} to the list of directories searched for
1223 @item --output=@var{file}
1225 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1227 @item --print-ac-dir
1228 @opindex --print-ac-dir
1229 Prints the name of the directory which @code{aclocal} will search to
1230 find the @file{.m4} files. When this option is given, normal processing
1231 is suppressed. This option can be used by a package to determine where
1232 to install a macro file.
1236 Print the names of the files it examines.
1240 Print the version number of Automake and exit.
1244 @node Macros, Extending aclocal, Invoking aclocal, configure
1245 @section Autoconf macros supplied with Automake
1247 @c consider generating this node automatically from m4 files.
1250 @item AM_CONFIG_HEADER
1251 Automake will generate rules to automatically regenerate the config
1252 header. If you do use this macro, you must create the file
1253 @file{stamp-h.in} in your source directory. It can be empty.
1254 @cvindex AM_CONFIG_HEADER
1256 @item AM_ENABLE_MULTILIB
1257 This is used when a ``multilib'' library is being built. A
1258 @dfn{multilib} library is one that is built multiple times, once per
1259 target flag combination. This is only useful when the library is
1260 intended to be cross-compiled. The first optional argument is the name
1261 of the @file{Makefile} being generated; it defaults to @samp{Makefile}.
1262 The second option argument is used to find the top source directory; it
1263 defaults to the empty string (generally this should not be used unless
1264 you are familiar with the internals).
1266 @item AM_FUNC_STRTOD
1267 If the @code{strtod} function is not available, or does not work
1268 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
1269 variable @code{LIBOBJS}.
1270 @cvindex AM_FUNC_STRTOD
1272 @item AM_FUNC_ERROR_AT_LINE
1273 If the function @code{error_at_line} is not found, then add
1274 @file{error.o} to @code{LIBOBJS}.
1275 @cvindex AM_FUNC_ERROR_AT_LINE
1277 @item AM_FUNC_OBSTACK
1278 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
1280 @cvindex AM_FUNC_OBSTACK
1282 @item AM_C_PROTOTYPES
1283 Check to see if function prototypes are understood by the compiler. If
1284 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1285 @samp{ANSI2KNR} to the empty string. Otherwise, set @samp{U} to
1286 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}. Automake uses these
1287 values to implement automatic de-ANSI-fication.
1288 @cvindex AM_C_PROTOTYPES
1290 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1291 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1292 define @code{GWINSZ_IN_SYS_IOCTL}. Otherwise @code{TIOCGWINSZ} can be
1293 found in @file{<termios.h>}.
1294 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1296 @item AM_INIT_AUTOMAKE
1297 Runs many macros that most @file{configure.in}'s need. This macro has
1298 two required arguments, the package and the version number. By default
1299 this macro @code{AC_DEFINE}'s @samp{PACKAGE} and @samp{VERSION}. This
1300 can be avoided by passing in a non-empty third argument.
1302 @item AM_PATH_LISPDIR
1303 Searches for the program @code{emacs}, and, if found, sets the output
1304 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1305 @cvindex AM_PATH_LISPDIR
1307 @item AM_PROG_CC_STDC
1308 If the C compiler in not in ANSI C mode by default, try to add an option
1309 to output variable @code{CC} to make it so. This macro tries various
1310 options that select ANSI C on some system or another. It considers the
1311 compiler to be in ANSI C mode if it handles function prototypes correctly.
1313 If you use this macro, you should check after calling it whether the C
1314 compiler has been set to accept ANSI C; if not, the shell variable
1315 @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
1316 code in ANSI C, you can make an un-ANSIfied copy of it by using the
1317 @code{ansi2knr} option (@pxref{ANSI}).
1320 @cindex HP-UX 10, lex problems
1321 @cindex lex problems with HP-UX 10
1322 Like @code{AC_PROG_LEX} with @code{AC_DECL_YYTEXT} (@pxref{Particular
1323 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}),
1324 but uses the @code{missing} script on systems that do not have
1325 @code{lex}. @samp{HP-UX 10} is one such system.
1327 Autoconf 2.50 and higher, in order to simplify the interface, includes
1328 the body of @code{AC_DECL_YYTEXT} in @code{AC_PROG_LEX}. To ensure
1329 backward compatibility, @code{AC_DECL_YYTEXT} is nevertheless defined as
1330 an invocation of @code{AC_PROG_LEX}. Since @code{AM_PROG_LEX} invokes
1331 both, it causes an annoying but benign warning (@code{AC_PROG_LEX}
1332 invoked multiple times) which you should just ignore. In the future,
1333 once Automake requires Autoconf 2.50, this issue will be fixed, but the
1334 current compatibility with Autoconf 2.13 prevents this.
1337 This macro finds the @code{gcj} program or causes an error. It sets
1338 @samp{GCJ} and @samp{GCJFLAGS}. @code{gcj} is the Java front-end to the
1340 @cvindex AM_PROG_GCJ
1342 @item AM_SANITY_CHECK
1343 This checks to make sure that a file created in the build directory is
1344 newer than a file in the source directory. This can fail on systems
1345 where the clock is set incorrectly. This macro is automatically run
1346 from @code{AM_INIT_AUTOMAKE}.
1348 @item AM_SYS_POSIX_TERMIOS
1349 @cvindex am_cv_sys_posix_termios
1350 @cindex POSIX termios headers
1351 @cindex termios POSIX headers
1352 Check to see if POSIX termios headers and functions are available on the
1353 system. If so, set the shell variable @code{am_cv_sys_posix_termios} to
1354 @samp{yes}. If not, set the variable to @samp{no}.
1356 @item AM_TYPE_PTRDIFF_T
1357 @cvindex HAVE_PTRDIFF_T
1359 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
1362 @item AM_WITH_DMALLOC
1363 @cvindex WITH_DMALLOC
1364 @cindex dmalloc, support for
1365 @opindex --with-dmalloc
1367 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1368 package. If the user configures with @samp{--with-dmalloc}, then define
1369 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1373 @opindex --with-regex
1374 @cindex regex package
1376 Adds @samp{--with-regex} to the @code{configure} command line. If
1377 specified (the default), then the @samp{regex} regular expression
1378 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1379 @samp{WITH_REGEX} is defined.. If @samp{--without-regex} is given, then
1380 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1381 into @samp{LIBOBJS}.
1386 @node Extending aclocal, , Macros, configure
1387 @section Writing your own aclocal macros
1389 @cindex aclocal, extending
1390 @cindex Extending aclocal
1392 The @code{aclocal} program doesn't have any built-in knowledge of any
1393 macros, so it is easy to extend it with your own macros.
1395 This is mostly used for libraries which want to supply their own
1396 Autoconf macros for use by other programs. For instance the
1397 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1398 should be used by any package using @code{gettext}. When the library is
1399 installed, it installs this macro so that @code{aclocal} will find it.
1401 A file of macros should be a series of @code{AC_DEFUN}'s. The
1402 @code{aclocal} programs also understands @code{AC_REQUIRE}, so it is
1403 safe to put each macro in a separate file. @xref{Prerequisite Macros, ,
1404 , autoconf, The Autoconf Manual}, and @ref{Macro Definitions, , ,
1405 autoconf, The Autoconf Manual}.
1407 A macro file's name should end in @file{.m4}. Such files should be
1408 installed in @file{$(datadir)/aclocal}.
1411 @node Top level, Rebuilding, configure, Top
1412 @chapter The top-level @file{Makefile.am}
1414 @cindex SUBDIRS, explained
1416 In packages with subdirectories, the top level @file{Makefile.am} must
1417 tell Automake which subdirectories are to be built. This is done via
1418 the @code{SUBDIRS} variable.
1421 The @code{SUBDIRS} macro holds a list of subdirectories in which
1422 building of various sorts can occur. Many targets (e.g. @code{all}) in
1423 the generated @file{Makefile} will run both locally and in all specified
1424 subdirectories. Note that the directories listed in @code{SUBDIRS} are
1425 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1426 (after configuration). This allows inclusion of libraries from packages
1427 which do not use Automake (such as @code{gettext}). The directories
1428 mentioned in @code{SUBDIRS} must be direct children of the current
1429 directory. For instance, you cannot put @samp{src/subdir} into
1432 In packages that use subdirectories, the top-level @file{Makefile.am} is
1433 often very short. For instance, here is the @file{Makefile.am} from the
1434 GNU Hello distribution:
1437 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1438 SUBDIRS = doc intl po src tests
1441 @cindex SUBDIRS, overriding
1442 @cindex Overriding SUBDIRS
1444 It is possible to override the @code{SUBDIRS} variable if, like in the
1445 case of GNU @code{Inetutils}, you want to only build a subset of the
1446 entire package. In your @file{Makefile.am} include:
1449 SUBDIRS = @@MY_SUBDIRS@@
1452 Then in your @file{configure.in} you can specify:
1455 MY_SUBDIRS = "src doc lib po"
1456 AC_SUBST(MY_SUBDIRS)
1459 (Note that we don't use the variable name @code{SUBDIRS} in our
1460 @file{configure.in}; that would cause Automake to believe that every
1461 @file{Makefile.in} should recurse into the listed subdirectories.)
1463 The upshot of this is that Automake is tricked into building the package
1464 to take the subdirs, but doesn't actually bind that list until
1465 @code{configure} is run.
1467 Although the @code{SUBDIRS} macro can contain configure substitutions
1468 (e.g. @samp{@@DIRS@@}); Automake itself does not actually examine the
1469 contents of this variable.
1471 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1472 @code{AC_PROG_MAKE_SET}.
1474 The use of @code{SUBDIRS} is not restricted to just the top-level
1475 @file{Makefile.am}. Automake can be used to construct packages of
1478 By default, Automake generates @file{Makefiles} which work depth-first
1479 (@samp{postfix}). However, it is possible to change this ordering. You
1480 can do this by putting @samp{.} into @code{SUBDIRS}. For instance,
1481 putting @samp{.} first will cause a @samp{prefix} ordering of
1484 Sometimes, such as when running @code{make dist}, you want all possible
1485 subdirectories to be examined. In this case Automake will use
1486 @code{DIST_SUBDIRS}, instead of @code{SUBDIRS}, to determine where to
1487 recurse. This variable will also be used when the user runs
1488 @code{distclean} or @code{maintainer-clean}. It should be set to the
1489 full list of subdirectories in the project. If this macro is not set,
1490 Automake will attempt to set it for you.
1493 @node Rebuilding, Programs, Top level, Top
1494 @chapter Rebuilding Makefiles
1496 Automake generates rules to automatically rebuild @file{Makefile}s,
1497 @file{configure}, and other derived files like @file{Makefile.in}.
1499 If you are using @code{AM_MAINTAINER_MODE} in @file{configure.in}, then
1500 these automatic rebuilding rules are only enabled in maintainer mode.
1502 Sometimes you need to run @code{aclocal} with an argument like @code{-I}
1503 to tell it where to find @file{.m4} files. Since sometimes @code{make}
1504 will automatically run @code{aclocal}, you need a way to specify these
1505 arguments. You can do this by defining @code{ACLOCAL_AMFLAGS}; this
1506 holds arguments which are passed verbatim to @code{aclocal}. This macro
1507 is only useful in the top-level @file{Makefile.am}.
1508 @cindex ACLOCAL_AMFLAGS
1511 @node Programs, Other objects, Rebuilding, Top
1512 @chapter Building Programs and Libraries
1514 A large part of Automake's functionality is dedicated to making it easy
1515 to build programs and libraries.
1518 * A Program:: Building a program
1519 * A Library:: Building a library
1520 * Program and Library Variables::
1521 Variables controlling program and
1523 * LIBOBJS:: Special handling for LIBOBJS and ALLOCA
1524 * A Shared Library:: Building a Libtool library
1525 * Program variables:: Variables used when building a program
1526 * Yacc and Lex:: Yacc and Lex support
1528 * Fortran 77 Support::
1530 * Support for Other Languages::
1531 * ANSI:: Automatic de-ANSI-fication
1532 * Dependencies:: Automatic dependency tracking
1536 @node A Program, A Library, Programs, Programs
1537 @section Building a program
1539 @cindex PROGRAMS, bindir
1540 @vindex bin_PROGRAMS
1541 @vindex sbin_PROGRAMS
1542 @vindex libexec_PROGRAMS
1543 @vindex pkglib_PROGRAMS
1544 @vindex noinst_PROGRAMS
1546 In a directory containing source that gets built into a program (as
1547 opposed to a library), the @samp{PROGRAMS} primary is used. Programs
1548 can be installed in @code{bindir}, @code{sbindir}, @code{libexecdir},
1549 @code{pkglibdir}, or not at all (@samp{noinst}). They can also be built
1550 only for @code{make check}, in which case the prefix is @samp{check}.
1555 bin_PROGRAMS = hello
1558 In this simple case, the resulting @file{Makefile.in} will contain code
1559 to generate a program named @code{hello}.
1561 Associated with each program are several assisting variables which are
1562 named after the program. These variables are all optional, and have
1563 reasonable defaults. Each variable, its use, and default is spelled out
1564 below; we use the ``hello'' example throughout.
1566 The variable @code{hello_SOURCES} is used to specify which source files
1567 get built into an executable:
1570 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
1573 This causes each mentioned @samp{.c} file to be compiled into the
1574 corresponding @samp{.o}. Then all are linked to produce @file{hello}.
1576 @cindex _SOURCES primary, defined
1577 @cindex SOURCES primary, defined
1578 @cindex Primary variable, SOURCES
1580 If @samp{hello_SOURCES} is not specified, then it defaults to the single
1581 file @file{hello.c}; that is, the default is to compile a single C file
1582 whose base name is the name of the program itself. (This is a terrible
1583 default but we are stuck with it for historical reasons.)
1587 Multiple programs can be built in a single directory. Multiple programs
1588 can share a single source file, which must be listed in each
1589 @samp{_SOURCES} definition.
1591 @cindex Header files in _SOURCES
1592 @cindex _SOURCES and header files
1594 Header files listed in a @samp{_SOURCES} definition will be included in
1595 the distribution but otherwise ignored. In case it isn't obvious, you
1596 should not include the header file generated by @file{configure} in an
1597 @samp{_SOURCES} variable; this file should not be distributed. Lex
1598 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1601 You can't put a configure substitution (e.g., @samp{@@FOO@@}) into a
1602 @samp{_SOURCES} variable. The reason for this is a bit hard to explain,
1603 but suffice to say that it simply won't work. Automake will give an
1604 error if you try to do this.
1606 @cindex EXTRA_prog_SOURCES, defined
1608 Automake must know all the source files that could possibly go into a
1609 program, even if not all the files are built in every circumstance.
1610 Any files which are only conditionally built should be listed in the
1611 appropriate @samp{EXTRA_} variable. For instance, if
1612 @file{hello-linux.c} were conditionally included in @code{hello}, the
1613 @file{Makefile.am} would contain:
1616 EXTRA_hello_SOURCES = hello-linux.c
1619 Similarly, sometimes it is useful to determine the programs that are to
1620 be built at configure time. For instance, GNU @code{cpio} only builds
1621 @code{mt} and @code{rmt} under special circumstances.
1623 @cindex EXTRA_PROGRAMS, defined
1625 In this case, you must notify Automake of all the programs that can
1626 possibly be built, but at the same time cause the generated
1627 @file{Makefile.in} to use the programs specified by @code{configure}.
1628 This is done by having @code{configure} substitute values into each
1629 @samp{_PROGRAMS} definition, while listing all optionally built programs
1630 in @code{EXTRA_PROGRAMS}.
1631 @vindex EXTRA_PROGRAMS
1633 If you need to link against libraries that are not found by
1634 @code{configure}, you can use @code{LDADD} to do so. This variable
1635 actually can be used to add any options to the linker command line.
1638 @cindex prog_LDADD, defined
1640 Sometimes, multiple programs are built in one directory but do not share
1641 the same link-time requirements. In this case, you can use the
1642 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1643 program as it appears in some @samp{_PROGRAMS} variable, and usually
1644 written in lowercase) to override the global @code{LDADD}. If this
1645 variable exists for a given program, then that program is not linked
1649 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
1650 linked against the library @file{libcpio.a}. However, @code{rmt} is
1651 built in the same directory, and has no such link requirement. Also,
1652 @code{mt} and @code{rmt} are only built on certain architectures. Here
1653 is what cpio's @file{src/Makefile.am} looks like (abridged):
1656 bin_PROGRAMS = cpio pax @@MT@@
1657 libexec_PROGRAMS = @@RMT@@
1658 EXTRA_PROGRAMS = mt rmt
1660 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1663 cpio_SOURCES = @dots{}
1664 pax_SOURCES = @dots{}
1665 mt_SOURCES = @dots{}
1666 rmt_SOURCES = @dots{}
1669 @cindex _LDFLAGS, defined
1671 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
1672 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
1673 @samp{-dlpreopen}). So, use the @samp{@var{prog}_LDFLAGS} variable for
1677 @cindex _DEPENDENCIES, defined
1679 It is also occasionally useful to have a program depend on some other
1680 target which is not actually part of that program. This can be done
1681 using the @samp{@var{prog}_DEPENDENCIES} variable. Each program depends
1682 on the contents of such a variable, but no further interpretation is
1685 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
1686 Automake. The automatically-assigned value is the contents of
1687 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
1688 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed. The
1689 configure substitutions that are left in are only @samp{@@LIBOBJS@@} and
1690 @samp{@@ALLOCA@@}; these are left because it is known that they will not
1691 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
1694 Sometimes you want to compile a single source file two different ways
1697 @node A Library, Program and Library Variables, A Program, Programs
1698 @section Building a library
1700 @cindex _LIBRARIES primary, defined
1701 @cindex LIBRARIES primary, defined
1702 @cindex Primary variable, LIBRARIES
1704 @vindex lib_LIBRARIES
1705 @vindex pkglib_LIBRARIES
1706 @vindex noinst_LIBRARIES
1708 Building a library is much like building a program. In this case, the
1709 name of the primary is @samp{LIBRARIES}. Libraries can be installed in
1710 @code{libdir} or @code{pkglibdir}.
1712 @xref{A Shared Library}, for information on how to build shared
1713 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1715 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1716 For instance to create a library named @file{libcpio.a}, but not install
1717 it, you would write:
1720 noinst_LIBRARIES = libcpio.a
1723 The sources that go into a library are determined exactly as they are
1724 for programs, via the @samp{_SOURCES} variables. Note that the library
1725 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1726 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1727 not @samp{liblob.a_SOURCES}.
1729 @cindex _LIBADD primary, defined
1730 @cindex LIBADD primary, defined
1731 @cindex Primary variable, LIBADD
1733 Extra objects can be added to a library using the
1734 @samp{@var{library}_LIBADD} variable. This should be used for objects
1735 determined by @code{configure}. Again from @code{cpio}:
1740 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1743 In addition, sources for extra objects that will not exist until
1744 configure-time must be added to the @code{BUILT_SOURCES} variable
1748 @node Program and Library Variables, LIBOBJS, A Library, Programs
1749 @section Program and Library Variables
1751 Associated with each program are a collection of variables which can be
1752 used to modify how that program is built. There is a similar list of
1753 such variables for each library. The canonical name of the program (or
1754 library) is used as a base for naming these variables.
1756 In the list below, we use the name ``maude'' to refer to the program or
1757 library. In your @file{Makefile.am} you would replace this with the
1758 canonical name of your program. This list also refers to ``maude'' as a
1759 program, but in general the same rules apply for both static and dynamic
1760 libraries; the documentation below notes situations where programs and
1765 This variable, if it exists, lists all the source files which are
1766 compiled to build the program. These files are added to the
1767 distribution by default. When building the program, Automake will cause
1768 each source file to be compiled to a single @file{.o} file (or
1769 @file{.lo} when using libtool). Normally these object files are named
1770 after the source file, but other factors can change this. If a file in
1771 the @samp{_SOURCES} variable has an unrecognized extension, Automake
1772 will do one of two things with it. If a suffix rule exists for turning
1773 files with the unrecognized extension into @file{.o} files, then
1774 automake will treat this file as it will any other source file
1775 (@pxref{Support for Other Languages}). Otherwise, the file will be
1776 ignored as though it were a header file.
1778 The prefixes @samp{dist_} and @samp{nodist_} can be used to control
1779 whether files listed in a @samp{_SOURCES} variable are distributed.
1780 @samp{dist_} is redundant, as sources are distributed by default, but it
1781 can be specified for clarity if desired.
1783 It is possible to have both @samp{dist_} and @samp{nodist_} variants of
1784 a given @samp{_SOURCES} variable at once; this lets you easily
1785 distribute some files and not others, for instance:
1788 nodist_maude_SOURCES = nodist.c
1789 dist_maude_SOURCES = dist-me.c
1793 @item EXTRA_maude_SOURCES
1794 Automake needs to know the list of files you intend to compile
1795 @emph{statically}. For one thing, this is the only way Automake has of
1796 knowing what sort of language support a given @file{Makefile.in}
1797 requires. @footnote{There are other, more obscure reasons reasons for
1798 this limitation as well.} This means that, for example, you can't put a
1799 configure substitution like @samp{@@my_sources@@} into a @samp{_SOURCES}
1800 variable. If you intend to conditionally compile source files and use
1801 @file{configure} to substitute the appropriate object names into, e.g.,
1802 @samp{_LDADD} (see below), then you should list the corresponding source
1803 files in the @samp{EXTRA_} variable.
1805 This variable also supports @samp{dist_} and @samp{nodist_} prefixes,
1806 e.g., @samp{nodist_EXTRA_maude_SOURCES}.
1813 Automake allows you to set compilation flags on a per-program (or
1814 per-library) basis. A single source file can be included in several
1815 programs, and it will potentially be compiled with different flags for
1816 each program. This works for any language directly supported by
1817 Automake. The flags are @samp{_CFLAGS}, @samp{_CXXFLAGS},
1818 @samp{_OBJCFLAGS}, @samp{_YFLAGS}, @samp{_ASFLAGS}, @samp{_FFLAGS},
1819 @samp{_RFLAGS}, and @samp{_GCJFLAGS}.
1821 When using a per-program compilation flag, Automake will choose a
1822 different name for the intermediate object files. Ordinarily a file
1823 like @file{sample.c} will be compiled to produce @file{sample.o}.
1824 However, if the program's @samp{_CFLAGS} variable is set, then the
1825 object file will be named, for instance, @file{maude-sample.o}.
1827 @item maude_DEPENDENCIES
1830 @item maude_SHORTNAME
1831 On some platforms the allowable file names are very short. In order to
1832 support these systems and per-program compilation flags at the same
1833 time, Automake allows you to set a ``short name'' which will influence
1834 how intermediate object files are named. For instance, if you set
1835 @samp{maude_SHORTNAME} to @samp{m}, then in the above per-program
1836 compilation flag example the object file would be named
1837 @file{m-sample.o} rather than @file{maude-sample.o}. This facility is
1838 rarely needed in practice, and we recommend avoiding it until you find
1843 @node LIBOBJS, A Shared Library, Program and Library Variables, Programs
1844 @section Special handling for LIBOBJS and ALLOCA
1846 @cindex @@LIBOBJS@@, special handling
1847 @cindex @@ALLOCA@@, special handling
1849 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1850 @code{@@ALLOCA@@}, and uses this information, plus the list of
1851 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1852 include the appropriate source files in the distribution (@pxref{Dist}).
1853 These source files are also automatically handled in the
1854 dependency-tracking scheme; see @xref{Dependencies}.
1856 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1857 @samp{_LDADD} or @samp{_LIBADD} variable.
1860 @node A Shared Library, Program variables, LIBOBJS, Programs
1861 @section Building a Shared Library
1863 @cindex Shared libraries, support for
1865 Building shared libraries is a relatively complex matter. For this
1866 reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
1867 Libtool Manual}) was created to help build shared libraries in a
1868 platform-independent way.
1870 @cindex _LTLIBRARIES primary, defined
1871 @cindex LTLIBRARIES primary, defined
1872 @cindex Primary variable, LTLIBRARIES
1873 @cindex Example of shared libraries
1875 @cindex suffix .la, defined
1877 Automake uses Libtool to build libraries declared with the
1878 @samp{LTLIBRARIES} primary. Each @samp{_LTLIBRARIES} variable is a list
1879 of shared libraries to build. For instance, to create a library named
1880 @file{libgettext.a} and its corresponding shared libraries, and install
1881 them in @samp{libdir}, write:
1884 lib_LTLIBRARIES = libgettext.la
1887 @vindex lib_LTLIBRARIES
1888 @vindex pkglib_LTLIBRARIES
1889 @vindex noinst_LTLIBRARIES
1890 @vindex check_LTLIBRARIES
1892 @cindex check_LTLIBRARIES, not allowed
1894 Note that shared libraries @emph{must} be installed, so
1895 @code{check_LTLIBRARIES} is not allowed. However,
1896 @code{noinst_LTLIBRARIES} is allowed. This feature should be used for
1897 libtool ``convenience libraries''.
1899 @cindex suffix .lo, defined
1901 For each library, the @samp{@var{library}_LIBADD} variable contains the
1902 names of extra libtool objects (@file{.lo} files) to add to the shared
1903 library. The @samp{@var{library}_LDFLAGS} variable contains any
1904 additional libtool flags, such as @samp{-version-info} or
1907 @cindex @@LTLIBOBJS@@, special handling
1909 Where an ordinary library might include @code{@@LIBOBJS@@}, a libtool
1910 library must use @code{@@LTLIBOBJS@@}. This is required because the
1911 object files that libtool operates on do not necessarily end in
1912 @file{.o}. The libtool manual contains more details on this topic.
1914 For libraries installed in some directory, Automake will automatically
1915 supply the appropriate @samp{-rpath} option. However, for libraries
1916 determined at configure time (and thus mentioned in
1917 @code{EXTRA_LTLIBRARIES}), Automake does not know the eventual
1918 installation directory; for such libraries you must add the
1919 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
1922 Ordinarily, Automake requires that a shared library's name start with
1923 @samp{lib}. However, if you are building a dynamically loadable module
1924 then you might wish to use a "nonstandard" name. In this case, put
1925 @code{-module} into the @samp{_LDFLAGS} variable.
1927 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1928 libtool, The Libtool Manual}, for more information.
1931 @node Program variables, Yacc and Lex, A Shared Library, Programs
1932 @section Variables used when building a program
1934 Occasionally it is useful to know which @file{Makefile} variables
1935 Automake uses for compilations; for instance you might need to do your
1936 own compilation in some special cases.
1938 Some variables are inherited from Autoconf; these are @code{CC},
1939 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1943 There are some additional variables which Automake itself defines:
1947 A list of @samp{-I} options. This can be set in your @file{Makefile.am}
1948 if you have special directories you want to look in. Automake already
1949 provides some @samp{-I} options automatically. In particular it
1950 generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I} pointing to
1951 the directory holding @file{config.h} (if you've used
1952 @code{AC_CONFIG_HEADER} or @code{AM_CONFIG_HEADER}). You can disable
1953 the default @samp{-I} options using the @samp{nostdinc} option.
1955 @code{INCLUDES} can actually be used for other @code{cpp} options
1956 besides @samp{-I}. For instance, it is sometimes used to pass arbitrary
1957 @samp{-D} options to the compiler.
1960 This is the command used to actually compile a C source file. The
1961 filename is appended to form the complete command line.
1964 This is the command used to actually link a C program.
1968 @node Yacc and Lex, C++ Support, Program variables, Programs
1969 @section Yacc and Lex support
1971 Automake has somewhat idiosyncratic support for Yacc and Lex.
1973 Automake assumes that the @file{.c} file generated by @code{yacc} (or
1974 @code{lex}) should be named using the basename of the input file. That
1975 is, for a yacc source file @file{foo.y}, Automake will cause the
1976 intermediate file to be named @file{foo.c} (as opposed to
1977 @file{y.tab.c}, which is more traditional).
1979 The extension of a yacc source file is used to determine the extension
1980 of the resulting @samp{C} or @samp{C++} file. Files with the extension
1981 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1982 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1985 Likewise, lex source files can be used to generate @samp{C} or
1986 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
1987 @samp{.lxx} are recognized.
1989 You should never explicitly mention the intermediate (@samp{C} or
1990 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1993 The intermediate files generated by @code{yacc} (or @code{lex}) will be
1994 included in any distribution that is made. That way the user doesn't
1995 need to have @code{yacc} or @code{lex}.
1997 If a @code{yacc} source file is seen, then your @file{configure.in} must
1998 define the variable @samp{YACC}. This is most easily done by invoking
1999 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
2000 Program Checks, autoconf, The Autoconf Manual}).
2002 Similarly, if a @code{lex} source file is seen, then your
2003 @file{configure.in} must define the variable @samp{LEX}. You can use
2004 @samp{AC_PROG_LEX} to do this (@pxref{Particular Programs, , Particular
2005 Program Checks, autoconf, The Autoconf Manual}). Automake's @code{lex}
2006 support also requires that you use the @samp{AC_DECL_YYTEXT}
2007 macro---automake needs to know the value of @samp{LEX_OUTPUT_ROOT}.
2008 This is all handled for you if you use the @code{AM_PROG_LEX} macro
2012 @cindex yacc, multiple parsers
2013 @cindex Multiple yacc parsers
2014 @cindex Multiple lex lexers
2015 @cindex lex, multiple lexers
2018 Automake makes it possible to include multiple @code{yacc} (or
2019 @code{lex}) source files in a single program. Automake uses a small
2020 program called @code{ylwrap} to run @code{yacc} (or @code{lex}) in a
2021 subdirectory. This is necessary because yacc's output filename is
2022 fixed, and a parallel make could conceivably invoke more than one
2023 instance of @code{yacc} simultaneously. The @code{ylwrap} program is
2024 distributed with Automake. It should appear in the directory specified
2025 by @samp{AC_CONFIG_AUX_DIR} (@pxref{Input, , Finding `configure' Input,
2026 autoconf, The Autoconf Manual}), or the current directory if that macro
2027 is not used in @file{configure.in}.
2029 For @code{yacc}, simply managing locking is insufficient. The output of
2030 @code{yacc} always uses the same symbol names internally, so it isn't
2031 possible to link two @code{yacc} parsers into the same executable.
2033 We recommend using the following renaming hack used in @code{gdb}:
2035 #define yymaxdepth c_maxdepth
2036 #define yyparse c_parse
2038 #define yyerror c_error
2039 #define yylval c_lval
2040 #define yychar c_char
2041 #define yydebug c_debug
2042 #define yypact c_pact
2049 #define yyexca c_exca
2050 #define yyerrflag c_errflag
2051 #define yynerrs c_nerrs
2055 #define yy_yys c_yys
2056 #define yystate c_state
2059 #define yy_yyv c_yyv
2061 #define yylloc c_lloc
2062 #define yyreds c_reds
2063 #define yytoks c_toks
2064 #define yylhs c_yylhs
2065 #define yylen c_yylen
2066 #define yydefred c_yydefred
2067 #define yydgoto c_yydgoto
2068 #define yysindex c_yysindex
2069 #define yyrindex c_yyrindex
2070 #define yygindex c_yygindex
2071 #define yytable c_yytable
2072 #define yycheck c_yycheck
2073 #define yyname c_yyname
2074 #define yyrule c_yyrule
2077 For each define, replace the @samp{c_} prefix with whatever you like.
2078 These defines work for @code{bison}, @code{byacc}, and traditional
2079 @code{yacc}s. If you find a parser generator that uses a symbol not
2080 covered here, please report the new name so it can be added to the list.
2083 @node C++ Support, Fortran 77 Support, Yacc and Lex, Programs
2084 @section C++ Support
2087 @cindex Support for C++
2089 Automake includes full support for C++.
2091 Any package including C++ code must define the output variable
2092 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
2093 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
2094 Program Checks, autoconf, The Autoconf Manual}).
2096 A few additional variables are defined when a C++ source file is seen:
2100 The name of the C++ compiler.
2103 Any flags to pass to the C++ compiler.
2106 The command used to actually compile a C++ source file. The file name
2107 is appended to form the complete command line.
2110 The command used to actually link a C++ program.
2114 @node Fortran 77 Support, Java Support, C++ Support, Programs
2115 @comment node-name, next, previous, up
2116 @section Fortran 77 Support
2118 @cindex Fortran 77 support
2119 @cindex Support for Fortran 77
2121 Automake includes full support for Fortran 77.
2123 Any package including Fortran 77 code must define the output variable
2124 @samp{F77} in @file{configure.in}; the simplest way to do this is to use
2125 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
2126 Program Checks, autoconf, The Autoconf Manual}). @xref{Fortran 77 and
2129 A few additional variables are defined when a Fortran 77 source file is
2135 The name of the Fortran 77 compiler.
2138 Any flags to pass to the Fortran 77 compiler.
2141 Any flags to pass to the Ratfor compiler.
2144 The command used to actually compile a Fortran 77 source file. The file
2145 name is appended to form the complete command line.
2148 The command used to actually link a pure Fortran 77 program or shared
2153 Automake can handle preprocessing Fortran 77 and Ratfor source files in
2154 addition to compiling them@footnote{Much, if not most, of the
2155 information in the following sections pertaining to preprocessing
2156 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
2157 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}. Automake
2158 also contains some support for creating programs and shared libraries
2159 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
2160 Fortran 77 With C and C++}).
2162 These issues are covered in the following sections.
2165 * Preprocessing Fortran 77::
2166 * Compiling Fortran 77 Files::
2167 * Mixing Fortran 77 With C and C++::
2168 * Fortran 77 and Autoconf::
2172 @node Preprocessing Fortran 77, Compiling Fortran 77 Files, Fortran 77 Support, Fortran 77 Support
2173 @comment node-name, next, previous, up
2174 @subsection Preprocessing Fortran 77
2176 @cindex Preprocessing Fortran 77
2177 @cindex Fortran 77, Preprocessing
2178 @cindex Ratfor programs
2180 @file{N.f} is made automatically from @file{N.F} or @file{N.r}. This
2181 rule runs just the preprocessor to convert a preprocessable Fortran 77
2182 or Ratfor source file into a strict Fortran 77 source file. The precise
2183 command used is as follows:
2188 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2191 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2196 @node Compiling Fortran 77 Files, Mixing Fortran 77 With C and C++, Preprocessing Fortran 77, Fortran 77 Support
2197 @comment node-name, next, previous, up
2198 @subsection Compiling Fortran 77 Files
2200 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
2201 @file{N.r} by running the Fortran 77 compiler. The precise command used
2207 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
2210 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2213 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2218 @node Mixing Fortran 77 With C and C++, Fortran 77 and Autoconf, Compiling Fortran 77 Files, Fortran 77 Support
2219 @comment node-name, next, previous, up
2220 @subsection Mixing Fortran 77 With C and C++
2222 @cindex Fortran 77, mixing with C and C++
2223 @cindex Mixing Fortran 77 with C and C++
2224 @cindex Linking Fortran 77 with C and C++
2226 @cindex Mixing Fortran 77 with C and/or C++
2228 Automake currently provides @emph{limited} support for creating programs
2229 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
2230 However, there are many other issues related to mixing Fortran 77 with
2231 other languages that are @emph{not} (currently) handled by Automake, but
2232 that are handled by other packages@footnote{For example,
2233 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
2234 addresses all of these inter-language issues, and runs under nearly all
2235 Fortran 77, C and C++ compilers on nearly all platforms. However,
2236 @code{cfortran} is not yet Free Software, but it will be in the next
2240 Automake can help in two ways:
2244 Automatic selection of the linker depending on which combinations of
2248 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
2249 @samp{-l}) to pass to the automatically selected linker in order to link
2250 in the appropriate Fortran 77 intrinsic and run-time libraries.
2252 @cindex FLIBS, defined
2253 These extra Fortran 77 linker flags are supplied in the output variable
2254 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
2255 supplied with newer versions of Autoconf (Autoconf version 2.13 and
2256 later). @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
2260 If Automake detects that a program or shared library (as mentioned in
2261 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
2262 code that is a mixture of Fortran 77 and C and/or C++, then it requires
2263 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
2264 @file{configure.in}, and that either @code{$(FLIBS)} or @code{@@FLIBS@@}
2265 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
2266 (for shared libraries) variables. It is the responsibility of the
2267 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
2268 or @code{@@FLIBS@@} appears in the appropriate @code{_LDADD} or
2269 @code{_LIBADD} variable.
2271 @cindex Mixed language example
2272 @cindex Example, mixed language
2274 For example, consider the following @file{Makefile.am}:
2278 foo_SOURCES = main.cc foo.f
2279 foo_LDADD = libfoo.la @@FLIBS@@
2281 pkglib_LTLIBRARIES = libfoo.la
2282 libfoo_la_SOURCES = bar.f baz.c zardoz.cc
2283 libfoo_la_LIBADD = $(FLIBS)
2286 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
2287 is mentioned in @file{configure.in}. Also, if @code{@@FLIBS@@} hadn't
2288 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
2289 Automake would have issued a warning.
2294 * How the Linker is Chosen::
2297 @node How the Linker is Chosen, , Mixing Fortran 77 With C and C++, Mixing Fortran 77 With C and C++
2298 @comment node-name, next, previous, up
2299 @subsubsection How the Linker is Chosen
2301 @cindex Automatic linker selection
2302 @cindex Selecting the linker automatically
2304 The following diagram demonstrates under what conditions a particular
2305 linker is chosen by Automake.
2307 For example, if Fortran 77, C and C++ source code were to be compiled
2308 into a program, then the C++ linker will be used. In this case, if the
2309 C or Fortran 77 linkers required any special libraries that weren't
2310 included by the C++ linker, then they must be manually added to an
2311 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
2317 code \ C C++ Fortran
2318 ----------------- +---------+---------+---------+
2322 +---------+---------+---------+
2326 +---------+---------+---------+
2330 +---------+---------+---------+
2334 +---------+---------+---------+
2336 C + Fortran | | | x |
2338 +---------+---------+---------+
2340 C++ + Fortran | | x | |
2342 +---------+---------+---------+
2344 C + C++ + Fortran | | x | |
2346 +---------+---------+---------+
2350 @node Fortran 77 and Autoconf, , Mixing Fortran 77 With C and C++, Fortran 77 Support
2351 @comment node-name, next, previous, up
2352 @subsection Fortran 77 and Autoconf
2354 The current Automake support for Fortran 77 requires a recent enough
2355 version Autoconf that also includes support for Fortran 77. Full
2356 Fortran 77 support was added to Autoconf 2.13, so you will want to use
2357 that version of Autoconf or later.
2360 @node Java Support, Support for Other Languages, Fortran 77 Support, Programs
2361 @comment node-name, next, previous, up
2362 @section Java Support
2364 @cindex Java support
2365 @cindex Support for Java
2367 Automake includes support for compiled Java, using @code{gcj}, the Java
2368 front end to the GNU C compiler.
2370 Any package including Java code to be compiled must define the output
2371 variable @samp{GCJ} in @file{configure.in}; the variable @samp{GCJFLAGS}
2372 must also be defined somehow (either in @file{configure.in} or
2373 @file{Makefile.am}). The simplest way to do this is to use the
2374 @code{AM_PROG_GCJ} macro.
2376 By default, programs including Java source files are linked with
2380 @node Support for Other Languages, ANSI, Java Support, Programs
2381 @comment node-name, next, previous, up
2382 @section Support for Other Languages
2384 Automake currently only includes full support for C, C++ (@pxref{C++
2385 Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java
2386 (@pxref{Java Support}). There is only rudimentary support for other
2387 languages, support for which will be improved based on user demand.
2389 @c FIXME: mention suffix rule processing here.
2392 @node ANSI, Dependencies, Support for Other Languages, Programs
2393 @section Automatic de-ANSI-fication
2395 @cindex de-ANSI-fication, defined
2397 Although the GNU standards allow the use of ANSI C, this can have the
2398 effect of limiting portability of a package to some older compilers
2401 Automake allows you to work around this problem on such machines by
2402 @dfn{de-ANSI-fying} each source file before the actual compilation takes
2405 @vindex AUTOMAKE_OPTIONS
2408 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
2409 (@pxref{Options}) contains the option @code{ansi2knr} then code to
2410 handle de-ANSI-fication is inserted into the generated
2413 This causes each C source file in the directory to be treated as ANSI C.
2414 If an ANSI C compiler is available, it is used. If no ANSI C compiler
2415 is available, the @code{ansi2knr} program is used to convert the source
2416 files into K&R C, which is then compiled.
2418 The @code{ansi2knr} program is simple-minded. It assumes the source
2419 code will be formatted in a particular way; see the @code{ansi2knr} man
2422 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
2423 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
2424 these files are distributed with Automake. Also, the package
2425 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}
2427 @cvindex AM_C_PROTOTYPES
2429 Automake also handles finding the @code{ansi2knr} support files in some
2430 other directory in the current package. This is done by prepending the
2431 relative path to the appropriate directory to the @code{ansi2knr}
2432 option. For instance, suppose the package has ANSI C code in the
2433 @file{src} and @file{lib} subdirs. The files @file{ansi2knr.c} and
2434 @file{ansi2knr.1} appear in @file{lib}. Then this could appear in
2435 @file{src/Makefile.am}:
2438 AUTOMAKE_OPTIONS = ../lib/ansi2knr
2441 If no directory prefix is given, the files are assumed to be in the
2444 Files mentioned in @code{LIBOBJS} which need de-ANSI-fication will not
2445 be automatically handled. That's because @code{configure} will generate
2446 an object name like @file{regex.o}, while @code{make} will be looking
2447 for @file{regex_.o} (when de-ANSI-fying). Eventually this problem will
2448 be fixed via @code{autoconf} magic, but for now you must put this code
2449 into your @file{configure.in}, just before the @code{AC_OUTPUT} call:
2452 # This is necessary so that .o files in LIBOBJS are also built via
2453 # the ANSI2KNR-filtering rules.
2454 LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
2458 @node Dependencies, , ANSI, Programs
2459 @section Automatic dependency tracking
2461 As a developer it is often painful to continually update the
2462 @file{Makefile.in} whenever the include-file dependencies change in a
2463 project. Automake supplies a way to automatically track dependency
2464 changes, and distribute the dependencies in the generated
2467 Currently this support requires the use of GNU @code{make} and
2468 @code{gcc}. It might become possible in the future to supply a
2469 different dependency generating program, if there is enough demand. In
2470 the meantime, this mode is enabled by default if any C program or
2471 library is defined in the current directory, so you may get a @samp{Must
2472 be a separator} error from non-GNU make.
2476 When you decide to make a distribution, the @code{dist} target will
2477 re-run @code{automake} with @samp{--include-deps} and other options.
2478 @xref{Invoking Automake}, and @ref{Options}. This will cause the
2479 previously generated dependencies to be inserted into the generated
2480 @file{Makefile.in}, and thus into the distribution. This step also
2481 turns off inclusion of the dependency generation code, so that those who
2482 download your distribution but don't use GNU @code{make} and @code{gcc}
2483 will not get errors.
2485 @vindex OMIT_DEPENDENCIES
2487 When added to the @file{Makefile.in}, the dependencies have all
2488 system-specific dependencies automatically removed. This can be done by
2489 listing the files in @samp{OMIT_DEPENDENCIES}. For instance all
2490 references to system header files are removed by Automake. Sometimes it
2491 is useful to specify that a certain header file should be removed. For
2492 instance if your @file{configure.in} uses @samp{AM_WITH_REGEX}, then any
2493 dependency on @file{rx.h} or @file{regex.h} should be removed, because
2494 the correct one cannot be known until the user configures the package.
2496 As it turns out, Automake is actually smart enough to handle the
2497 particular case of the regular expression header. It will also
2498 automatically omit @file{libintl.h} if @samp{AM_GNU_GETTEXT} is used.
2500 @vindex AUTOMAKE_OPTIONS
2501 @opindex no-dependencies
2503 Automatic dependency tracking can be suppressed by putting
2504 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
2506 If you unpack a distribution made by @code{make dist}, and you want to
2507 turn on the dependency-tracking code again, simply re-run
2510 The actual dependency files are put under the build directory, in a
2511 subdirectory named @file{.deps}. These dependencies are machine
2512 specific. It is safe to delete them if you like; they will be
2513 automatically recreated during the next build.
2516 @node Other objects, Other GNU Tools, Programs, Top
2517 @chapter Other Derived Objects
2519 Automake can handle derived objects which are not C programs. Sometimes
2520 the support for actually building such objects must be explicitly
2521 supplied, but Automake will still automatically handle installation and
2525 * Scripts:: Executable scripts
2526 * Headers:: Header files
2527 * Data:: Architecture-independent data files
2528 * Sources:: Derived sources
2532 @node Scripts, Headers, Other objects, Other objects
2533 @section Executable Scripts
2535 @cindex _SCRIPTS primary, defined
2536 @cindex SCRIPTS primary, defined
2537 @cindex Primary variable, SCRIPTS
2539 It is possible to define and install programs which are scripts. Such
2540 programs are listed using the @samp{SCRIPTS} primary name. Automake
2541 doesn't define any dependencies for scripts; the @file{Makefile.am}
2542 should include the appropriate rules.
2545 Automake does not assume that scripts are derived objects; such objects
2546 must be deleted by hand (@pxref{Clean}).
2548 The @code{automake} program itself is a Perl script that is generated at
2549 configure time from @file{automake.in}. Here is how this is handled:
2552 bin_SCRIPTS = automake
2555 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
2556 for it is automatically generated.
2558 @cindex SCRIPTS, installation directories
2559 @cindex Installing scripts
2562 @vindex sbin_SCRIPTS
2563 @vindex libexec_SCRIPTS
2564 @vindex pkgdata_SCRIPTS
2565 @vindex noinst_SCRIPTS
2567 Script objects can be installed in @code{bindir}, @code{sbindir},
2568 @code{libexecdir}, or @code{pkgdatadir}.
2571 @node Headers, Data, Scripts, Other objects
2572 @section Header files
2574 @cindex _HEADERS primary, defined
2575 @cindex HEADERS primary, defined
2576 @cindex Primary variable, HEADERS
2578 @vindex noinst_HEADERS
2580 Header files are specified by the @samp{HEADERS} family of variables.
2581 Generally header files are not installed, so the @code{noinst_HEADERS}
2582 variable will be the most used.
2585 All header files must be listed somewhere; missing ones will not appear
2586 in the distribution. Often it is clearest to list uninstalled headers
2587 with the rest of the sources for a program. @xref{A Program}. Headers
2588 listed in a @samp{_SOURCES} variable need not be listed in any
2589 @samp{_HEADERS} variable.
2591 @cindex HEADERS, installation directories
2592 @cindex Installing headers
2594 @vindex include_HEADERS
2595 @vindex oldinclude_HEADERS
2596 @vindex pkginclude_HEADERS
2598 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
2599 @code{pkgincludedir}.
2602 @node Data, Sources, Headers, Other objects
2603 @section Architecture-independent data files
2605 @cindex _DATA primary, defined
2606 @cindex DATA primary, defined
2607 @cindex Primary variable, DATA
2609 Automake supports the installation of miscellaneous data files using the
2610 @samp{DATA} family of variables.
2614 @vindex sysconf_DATA
2615 @vindex sharedstate_DATA
2616 @vindex localstate_DATA
2617 @vindex pkgdata_DATA
2619 Such data can be installed in the directories @code{datadir},
2620 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
2623 By default, data files are @emph{not} included in a distribution.
2625 Here is how Automake installs its auxiliary data files:
2628 pkgdata_DATA = clean-kr.am clean.am @dots{}
2632 @node Sources, , Data, Other objects
2633 @section Built sources
2635 @cindex BUILT_SOURCES, defined
2637 Occasionally a file which would otherwise be called @samp{source}
2638 (e.g. a C @samp{.h} file) is actually derived from some other file.
2639 Such files should be listed in the @code{BUILT_SOURCES} variable.
2640 @vindex BUILT_SOURCES
2642 @code{BUILT_SOURCES} is actually a bit of a misnomer, as any file which
2643 must be created early in the build process can be listed in this
2646 A source file listed in @code{BUILT_SOURCES} is created before the other
2647 @code{all} targets are made. However, such a source file is not
2648 compiled unless explicitly requested by mentioning it in some other
2649 @samp{_SOURCES} variable.
2652 @node Other GNU Tools, Documentation, Other objects, Top
2653 @chapter Other GNU Tools
2655 Since Automake is primarily intended to generate @file{Makefile.in}s for
2656 use in GNU programs, it tries hard to interoperate with other GNU tools.
2659 * Emacs Lisp:: Emacs Lisp
2668 @node Emacs Lisp, gettext, Other GNU Tools, Other GNU Tools
2671 @cindex _LISP primary, defined
2672 @cindex LISP primary, defined
2673 @cindex Primary variable, LISP
2679 Automake provides some support for Emacs Lisp. The @samp{LISP} primary
2680 is used to hold a list of @file{.el} files. Possible prefixes for this
2681 primary are @samp{lisp_} and @samp{noinst_}. Note that if
2682 @code{lisp_LISP} is defined, then @file{configure.in} must run
2683 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
2687 By default Automake will byte-compile all Emacs Lisp source files using
2688 the Emacs found by @code{AM_PATH_LISPDIR}. If you wish to avoid
2689 byte-compiling, simply define the variable @code{ELCFILES} to be empty.
2690 Byte-compiled Emacs Lisp files are not portable among all versions of
2691 Emacs, so it makes sense to turn this off if you expect sites to have
2692 more than one version of Emacs installed. Furthermore, many packages
2693 don't actually benefit from byte-compilation. Still, we recommend that
2694 you leave it enabled by default. It is probably better for sites with
2695 strange setups to cope for themselves than to make the installation less
2696 nice for everybody else.
2699 @node gettext, Guile, Emacs Lisp, Other GNU Tools
2702 @cindex GNU Gettext support
2703 @cindex Gettext support
2704 @cindex Support for GNU Gettext
2706 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
2707 turns on support for GNU gettext, a message catalog system for
2708 internationalization
2709 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
2711 The @code{gettext} support in Automake requires the addition of two
2712 subdirectories to the package, @file{intl} and @file{po}. Automake
2713 insures that these directories exist and are mentioned in
2716 Furthermore, Automake checks that the definition of @code{ALL_LINGUAS}
2717 in @file{configure.in} corresponds to all the valid @file{.po} files,
2721 @node Guile, Libtool, gettext, Other GNU Tools
2724 Automake provides some automatic support for writing Guile modules.
2725 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
2726 macro is used in @file{configure.in}.
2728 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
2729 macro is understood to mean:
2732 @code{AM_INIT_AUTOMAKE} is run.
2735 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
2738 As the Guile module code matures, no doubt the Automake support will
2742 @node Libtool, Java, Guile, Other GNU Tools
2745 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
2746 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
2747 @xref{A Shared Library}.
2750 @node Java, Python, Libtool, Other GNU Tools
2753 @cindex _JAVA primary, defined
2754 @cindex JAVA primary, defined
2755 @cindex Primary variable, JAVA
2757 Automake provides some minimal support for Java compilation with the
2758 @samp{JAVA} primary.
2760 Any @file{.java} files listed in a @samp{_JAVA} variable will be
2761 compiled with @code{JAVAC} at build time. By default, @file{.class}
2762 files are not included in the distribution.
2764 @cindex JAVA restrictions
2765 @cindex Restrictions for JAVA
2767 Currently Automake enforces the restriction that only one @samp{_JAVA}
2768 primary can be used in a given @file{Makefile.am}. The reason for this
2769 restriction is that, in general, it isn't possible to know which
2770 @file{.class} files were generated from which @file{.java} files -- so
2771 it would be impossible to know which files to install where.
2773 @node Python, , Java, Other GNU Tools
2776 @cindex _PYTHON primary, defined
2777 @cindex PYTHON primary, defined
2778 @cindex Primary variable, PYTHON
2781 Automake provides support for Python modules. Automake will turn on
2782 Python support if the @code{AM_CHECK_PYTHON} macro is used in
2783 @file{configure.in}. The @samp{PYTHON} primary is used to hold a list
2784 of @file{.py} files. Possible prefixes for this primary are
2785 @samp{python_} and @samp{noinst_}. Note that if @code{python_PYTHON} is
2786 defined, then @file{configure.in} must run @code{AM_CHECK_PYTHON}.
2788 @code{AM_CHECK_PYTHON} takes a single argument --- either the word
2789 @samp{module} or @samp{package}. The first installs files directly into
2790 the @file{site-packages} directory and is used when the @file{.py[co]}
2791 files must be on the @code{PYTHONPATH}. The second is used for modules
2792 distributed as a package, which should be installed in a subdirectory
2793 of @file{site-packages} and contain the @file{__init__.py} file. The
2794 subdirectory name is the same as the name given by @samp{PACKAGE}.
2797 @code{AM_CHECK_PYTHON} creates several output variables based on the
2798 Python installation found during configuration.
2802 The name of the Python executable.
2804 @item PYTHON_VERSION
2805 The Python version number, in the form @var{major}.@var{minor}
2806 (e.g. @samp{1.5}). This is currently the value of
2807 @code{sys.version[:3]}.
2810 The string @code{$prefix}. This term may be used in future work
2811 which needs the contents of Python's @code{sys.prefix}, but general
2812 consensus is to always use the value from configure.
2814 @item PYTHON_EXEC_PREFIX
2815 The string @code{$exec_prefix}. This term may be used in future work
2816 which needs the contents of Python's @code{sys.exec_prefix}, but general
2817 consensus is to always use the value from configure.
2819 @item PYTHON_PLATFORM
2820 The canonical name used by Python to describe the operating system, as
2821 given by @code{sys.platform}. This value is sometimes needed when
2822 building Python extensions.
2825 The directory name for the top of the standard Python library.
2828 The location of the platform-independent @file{site-packages} directory,
2829 where `module' files are installed. Note that older versions of Python
2830 (pre-1.5) used @file{$prefix/lib/site-python} so future versions of
2831 Automake's Python support may provide backwards compatibility.
2833 @item PYTHON_SITE_PACKAGE
2834 The string @code{$PYTHON_SITE/$PACKAGE}. This is the default
2835 installation directory for a Python `package.'
2837 @item PYTHON_SITE_INSTALL
2838 The top-level directory in which the Python files will be installed. It
2839 will be the value of either @samp{PYTHON_SITE} or @samp{PYTHON_PACKAGE}
2840 depending on the argument given to @code{AM_CHECK_PYTHON}.
2842 @item PYTHON_SITE_EXEC
2843 The location of the platform-dependent @file{site-packages} directory,
2844 where shared library extensions should be placed. Note that older
2845 versions of Python (pre-1.5) used @file{sharedmodules} so future version
2846 of Automake's Python support may provide backwards compatibility.
2853 By default Automake will byte-compile all Python source files to both
2854 @file{.pyc} and @file{.pyo} forms. If you wish to avoid generating the
2855 optimized byte-code files, simply define the variable @code{PYOFILES} to
2856 be empty. Similarly, if you don't wish to generate the standard
2857 byte-compiled files, define the variable @code{PYCFILES} to be empty.
2860 @node Documentation, Install, Other GNU Tools, Top
2861 @chapter Building documentation
2863 Currently Automake provides support for Texinfo and man pages.
2867 * Man pages:: Man pages
2871 @node Texinfo, Man pages, Documentation, Documentation
2874 @cindex _TEXINFOS primary, defined
2875 @cindex TEXINFOS primary, defined
2876 @cindex Primary variable, TEXINFOS
2878 If the current directory contains Texinfo source, you must declare it
2879 with the @samp{TEXINFOS} primary. Generally Texinfo files are converted
2880 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
2881 here. Any Texinfo source file must end in the @file{.texi},
2882 @file{.txi}, or @file{.texinfo} extension. We recommend @file{.texi}
2885 @vindex info_TEXINFOS
2887 @cindex Texinfo macro, VERSION
2888 @cindex Texinfo macro, UPDATED
2889 @cindex Texinfo macro, EDITION
2890 @cindex Texinfo macro, UPDATED-MONTH
2892 @cindex VERSION Texinfo macro
2893 @cindex UPDATED Texinfo macro
2894 @cindex EDITION Texinfo macro
2895 @cindex UPDATED-MONTH Texinfo macro
2899 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
2900 that file will be automatically generated. The file @file{version.texi}
2901 defines four Texinfo macros you can reference:
2906 Both of these macros hold the version number of your program. They are
2907 kept separate for clarity.
2910 This holds the date the primary @file{.texi} file was last modified.
2913 This holds the name of the month in which the primary @file{.texi} file
2917 The @file{version.texi} support requires the @code{mdate-sh} program;
2918 this program is supplied with Automake and automatically included when
2919 @code{automake} is invoked with the @code{--add-missing} option.
2921 If you have multiple Texinfo files, and you want to use the
2922 @file{version.texi} feature, then you have to have a separate version
2923 file for each Texinfo file. Automake will treat any include in a
2924 Texinfo file that matches @samp{vers*.texi} just as an automatically
2925 generated version file.
2927 When an info file is rebuilt, the program named by the @code{MAKEINFO}
2928 variable is used to invoke it. If the @code{makeinfo} program is found
2929 on the system then it will be used by default; otherwise @code{missing}
2930 will be used instead. The flags in the variables @code{MAKEINFOFLAGS}
2931 and @code{AM_MAKEINFOFLAGS} will be passed to the @code{makeinfo}
2932 invocation; the first of these is intended for use by the user
2933 (@pxref{User Variables}) and the second by the @file{Makefile.am}
2936 @vindex MAKEINFOFLAGS
2937 @vindex AM_MAKEINFOFLAGS
2939 Sometimes an info file actually depends on more than one @file{.texi}
2940 file. For instance, in GNU Hello, @file{hello.texi} includes the file
2941 @file{gpl.texi}. You can tell Automake about these dependencies using
2942 the @code{@var{texi}_TEXINFOS} variable. Here is how GNU Hello does it:
2947 info_TEXINFOS = hello.texi
2948 hello_TEXINFOS = gpl.texi
2953 By default, Automake requires the file @file{texinfo.tex} to appear in
2954 the same directory as the Texinfo source. However, if you used
2955 @code{AC_CONFIG_AUX_DIR} in @file{configure.in} (@pxref{Input, , Finding
2956 `configure' Input, autoconf, The Autoconf Manual}), then
2957 @file{texinfo.tex} is looked for there. Automake supplies
2958 @file{texinfo.tex} if @samp{--add-missing} is given.
2962 If your package has Texinfo files in many directories, you can use the
2963 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
2964 @file{texinfo.tex} for your package. The value of this variable should
2965 be the relative path from the current @file{Makefile.am} to
2969 TEXINFO_TEX = ../doc/texinfo.tex
2972 @opindex no-texinfo.tex
2974 The option @samp{no-texinfo.tex} can be used to eliminate the
2975 requirement for @file{texinfo.tex}. Use of the variable
2976 @code{TEXINFO_TEX} is preferable, however, because that allows the
2977 @code{dvi} target to still work.
2979 @cindex Target, install-info
2980 @cindex Target, noinstall-info
2981 @cindex install-info target
2982 @cindex noinstall-info target
2984 @opindex no-installinfo
2985 @trindex install-info
2987 Automake generates an @code{install-info} target; some people apparently
2988 use this. By default, info pages are installed by @samp{make install}.
2989 This can be prevented via the @code{no-installinfo} option.
2992 @node Man pages, , Texinfo, Documentation
2995 @cindex _MANS primary, defined
2996 @cindex MANS primary, defined
2997 @cindex Primary variable, MANS
2999 A package can also include man pages (but see the GNU standards on this
3000 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.) Man
3001 pages are declared using the @samp{MANS} primary. Generally the
3002 @code{man_MANS} macro is used. Man pages are automatically installed in
3003 the correct subdirectory of @code{mandir}, based on the file extension.
3007 File extensions such as @samp{.1c} are handled by looking for the valid
3008 part of the extension and using that to determine the correct
3009 subdirectory of @code{mandir}. Valid section names are the digits
3010 @samp{0} through @samp{9}, and the letters @samp{l} and @samp{n}.
3012 Sometimes developers prefer to name a man page something like
3013 @file{foo.man} in the source, and then rename it to have the correct
3014 suffix, e.g. @file{foo.1}, when installing the file. Automake also
3015 supports this mode. For a valid section named @var{SECTION}, there is a
3016 corresponding directory named @samp{man@var{SECTION}dir}, and a
3017 corresponding @samp{_MANS} variable. Files listed in such a variable
3018 are installed in the indicated section. If the file already has a
3019 valid suffix, then it is installed as-is; otherwise the file suffix is
3020 changed to match the section.
3022 For instance, consider this example:
3024 man1_MANS = rename.man thesame.1 alsothesame.1c
3027 In this case, @file{rename.man} will be renamed to @file{rename.1} when
3028 installed, but the other files will keep their names.
3030 @cindex Target, install-man
3031 @cindex Target, noinstall-man
3032 @cindex install-man target
3033 @cindex noinstall-man target
3035 @c Use @samp{make install} per documentation: (texi)code.
3036 By default, man pages are installed by @samp{make install}. However,
3037 since the GNU project does not require man pages, many maintainers do
3038 not expend effort to keep the man pages up to date. In these cases, the
3039 @code{no-installman} option will prevent the man pages from being
3040 installed by default. The user can still explicitly install them via
3041 @samp{make install-man}.
3042 @opindex no-installman
3043 @trindex install-man
3045 Here is how the documentation is handled in GNU @code{cpio} (which
3046 includes both Texinfo documentation and man pages):
3049 info_TEXINFOS = cpio.texi
3050 man_MANS = cpio.1 mt.1
3051 EXTRA_DIST = $(man_MANS)
3054 Texinfo source and info pages are all considered to be source for the
3055 purposes of making a distribution.
3057 Man pages are not currently considered to be source, because it is not
3058 uncommon for man pages to be automatically generated. For the same
3059 reason, they are not automatically included in the distribution.
3062 @node Install, Clean, Documentation, Top
3063 @chapter What Gets Installed
3065 @cindex Installation support
3066 @cindex make install support
3068 Naturally, Automake handles the details of actually installing your
3069 program once it has been built. All @code{PROGRAMS}, @code{SCRIPTS},
3070 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
3071 automatically installed in the appropriate places.
3073 Automake also handles installing any specified info and man pages.
3075 Automake generates separate @code{install-data} and @code{install-exec}
3076 targets, in case the installer is installing on multiple machines which
3077 share directory structure---these targets allow the machine-independent
3078 parts to be installed only once. The @code{install} target depends on
3079 both of these targets.
3080 @trindex install-data
3081 @trindex install-exec
3084 Automake also generates an @code{uninstall} target, an
3085 @code{installdirs} target, and an @code{install-strip} target.
3087 @trindex installdirs
3088 @trindex install-strip
3090 It is possible to extend this mechanism by defining an
3091 @code{install-exec-local} or @code{install-data-local} target. If these
3092 targets exist, they will be run at @samp{make install} time.
3093 @trindex install-exec-local
3094 @trindex install-data-local
3096 Variables using the standard directory prefixes @samp{data},
3097 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
3098 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
3099 installed by @samp{install-data}.
3101 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
3102 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
3103 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
3104 @samp{install-exec}.
3106 Any variable using a user-defined directory prefix with @samp{exec} in
3107 the name (e.g. @samp{myexecbin_PROGRAMS} is installed by
3108 @samp{install-exec}. All other user-defined prefixes are installed by
3109 @samp{install-data}.
3112 Automake generates support for the @samp{DESTDIR} variable in all
3113 install rules. @samp{DESTDIR} is used during the @samp{make install}
3114 step to relocate install objects into a staging area. Each object and
3115 path is prefixed with the value of @samp{DESTDIR} before being copied
3116 into the install area. Here is an example of typical DESTDIR usage:
3119 make DESTDIR=/tmp/staging install
3122 This places install objects in a directory tree built under
3123 @file{/tmp/staging}. If @file{/gnu/bin/foo} and
3124 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
3125 would install @file{/tmp/staging/gnu/bin/foo} and
3126 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
3128 This feature is commonly used to build install images and packages. For
3129 more information, see @ref{Makefile Conventions, , , standards, The GNU
3133 @node Clean, Dist, Install, Top
3134 @chapter What Gets Cleaned
3136 @cindex make clean support
3138 The GNU Makefile Standards specify a number of different clean rules.
3140 Generally the files that can be cleaned are determined automatically by
3141 Automake. Of course, Automake also recognizes some variables that can
3142 be defined to specify additional files to clean. These variables are
3143 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
3144 @code{MAINTAINERCLEANFILES}.
3145 @vindex MOSTLYCLEANFILES
3147 @vindex DISTCLEANFILES
3148 @vindex MAINTAINERCLEANFILES
3151 @node Dist, Tests, Clean, Top
3152 @chapter What Goes in a Distribution
3155 @cindex make distcheck
3157 The @code{dist} target in the generated @file{Makefile.in} can be used
3158 to generate a gzip'd @code{tar} file for distribution. The tar file is
3159 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
3160 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
3164 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
3165 is run. The default setting is @samp{--best}.
3167 For the most part, the files to distribute are automatically found by
3168 Automake: all source files are automatically included in a distribution,
3169 as are all @file{Makefile.am}s and @file{Makefile.in}s. Automake also
3170 has a built-in list of commonly used files which, if present in the
3171 current directory, are automatically included. This list is printed by
3172 @samp{automake --help}. Also, files which are read by @code{configure}
3173 (i.e. the source files corresponding to the files specified in the
3174 @code{AC_OUTPUT} invocation) are automatically distributed.
3176 Still, sometimes there are files which must be distributed, but which
3177 are not covered in the automatic rules. These files should be listed in
3178 the @code{EXTRA_DIST} variable. You can mention files from
3179 subdirectories in @code{EXTRA_DIST}. You can also mention a directory
3180 there; in this case the entire directory will be recursively copied into
3181 the distribution. Please note that this will also copy
3182 @emph{everything} in the directory, including CVS/RCS version control
3187 Sometimes you need tighter control over what does @emph{not} go into the
3188 distribution; for instance you might have source files which are
3189 generated and which you do not want to distribute. In this case
3190 Automake gives fine-grained control using the @samp{dist} and
3191 @samp{nodist} prefixes. Any primary or @samp{_SOURCES} variable can be
3192 prefixed with @samp{dist_} to add the listed files to the distribution.
3193 Similarly, @samp{nodist_} can be used to omit the files from the
3198 As an example, here is how you would cause some data to be distributed
3199 while leaving some source code out of the distribution:
3202 dist_data_DATA = distribute-this
3204 nodist_foo_SOURCES = do-not-distribute.c
3207 Another way to to use this is for removing unnecessary files that get
3208 recursively included by specifying a directory in EXTRA_DIST:
3214 rm -rf `find $(distdir)/doc -name CVS`
3217 If you define @code{SUBDIRS}, Automake will recursively include the
3218 subdirectories in the distribution. If @code{SUBDIRS} is defined
3219 conditionally (@pxref{Conditionals}), Automake will normally include all
3220 directories that could possibly appear in @code{SUBDIRS} in the
3221 distribution. If you need to specify the set of directories
3222 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
3223 list of subdirectories to include in the distribution.
3224 @vindex DIST_SUBDIRS
3228 Occasionally it is useful to be able to change the distribution before
3229 it is packaged up. If the @code{dist-hook} target exists, it is run
3230 after the distribution directory is filled, but before the actual tar
3231 (or shar) file is created. One way to use this is for distributing
3232 files in subdirectories for which a new @file{Makefile.am} is overkill:
3236 mkdir $(distdir)/random
3237 cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
3240 Automake also generates a @code{distcheck} target which can be of help
3241 to ensure that a given distribution will actually work.
3242 @code{distcheck} makes a distribution, and then tries to do a
3246 If the target @code{distcheck-hook} is defined in your
3247 @file{Makefile.am}, then it will be invoked by @code{distcheck} after
3248 the new distribution has been unpacked, but before the unpacked copy is
3249 configured and built. Your @code{distcheck-hook} can do almost
3250 anything, though as always caution is advised. Generally this hook is
3251 used to check for potential distribution errors not caught by the
3255 @node Tests, Options, Dist, Top
3256 @chapter Support for test suites
3261 Automake supports two forms of test suites.
3263 @section Simple Tests
3265 If the variable @code{TESTS} is defined, its value is taken to be a list
3266 of programs to run in order to do the testing. The programs can either
3267 be derived objects or source objects; the generated rule will look both
3268 in @code{srcdir} and @file{.}. Programs needing data files should look
3269 for them in @code{srcdir} (which is both an environment variable and a
3270 make variable) so they work when building in a separate directory
3271 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
3272 Manual}), and in particular for the @code{distcheck} target
3275 @cindex Exit status 77, special interpretation
3277 The number of failures will be printed at the end of the run. If a
3278 given test program exits with a status of 77, then its result is ignored
3279 in the final count. This feature allows non-portable tests to be
3280 ignored in environments where they don't make sense.
3282 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
3283 variables for the test run; the environment variable @code{srcdir} is
3284 set in the rule. If all your test programs are scripts, you can also
3285 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
3286 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
3288 @vindex TESTS_ENVIRONMENT
3290 @cindex Tests, expected failure
3291 @cindex Expected test failure
3293 You may define the variable @code{XFAIL_TESTS} to a list of tests
3294 (usually a subset of @code{TESTS}) that are expected to fail. This will
3295 reverse the result of those tests.
3298 Automake ensures that each program listed in @code{TESTS} is built
3299 before any tests are run; you can list both source and derived programs
3300 in @code{TESTS}. For instance, you might want to run a C program as a
3301 test. To do this you would list its name in @code{TESTS} and also in
3302 @code{check_PROGRAMS}, and then specify it as you would any other
3305 @section DejaGNU Tests
3307 If @uref{ftp://prep.ai.mit.edu/pub/gnu/dejagnu-1.3.tar.gz,
3308 @samp{dejagnu}} appears in @code{AUTOMAKE_OPTIONS}, then a
3309 @code{dejagnu}-based test suite is assumed. The variable
3310 @code{DEJATOOL} is a list of names which are passed, one at a time, as
3311 the @code{--tool} argument to @code{runtest} invocations; it defaults to
3312 the name of the package.
3314 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
3315 @code{--srcdir} flags that are passed to dejagnu by default; this can be
3316 overridden if necessary.
3317 @vindex RUNTESTDEFAULTFLAGS
3319 The variables @code{EXPECT} and @code{RUNTEST} can
3320 also be overridden to provide project-specific values. For instance,
3321 you will need to do this if you are testing a compiler toolchain,
3322 because the default values do not take into account host and target
3329 The contents of the variable @code{RUNTESTFLAGS} are passed to the
3330 @code{runtest} invocation. This is considered a ``user variable''
3331 (@pxref{User Variables}). If you need to set @code{runtest} flags in
3332 @file{Makefile.am}, you can use @code{AM_RUNTESTFLAGS} instead.
3333 @vindex RUNTESTFLAGS
3334 @vindex AM_RUNTESTFLAGS
3335 @c FIXME xref dejagnu
3337 In either case, the testing is done via @samp{make check}.
3340 @node Options, Miscellaneous, Tests, Top
3341 @chapter Changing Automake's Behavior
3343 Various features of Automake can be controlled by options in the
3344 @file{Makefile.am}. Such options are listed in a special variable named
3345 @code{AUTOMAKE_OPTIONS}. Currently understood options are:
3346 @vindex AUTOMAKE_OPTIONS
3351 @itemx @code{foreign}
3353 @cindex Option, gnits
3355 @cindex Option, foreign
3356 @cindex Option, cygnus
3358 Set the strictness as appropriate. The @code{gnits} option also implies
3359 @code{readme-alpha} and @code{check-news}.
3361 @item @code{ansi2knr}
3362 @itemx @code{path/ansi2knr}
3363 @cindex Option, ansi2knr
3364 Turn on automatic de-ANSI-fication. @xref{ANSI}. If preceded by a
3365 path, the generated @file{Makefile.in} will look in the specified
3366 directory to find the @file{ansi2knr} program. Generally the path
3367 should be a relative path to another directory in the same distribution
3368 (though Automake currently does not check this).
3370 @item @code{check-news}
3371 @cindex Option, check-news
3372 Cause @code{make dist} to fail unless the current version number appears
3373 in the first few lines of the @file{NEWS} file.
3375 @item @code{dejagnu}
3376 @cindex Option, dejagnu
3377 Cause @code{dejagnu}-specific rules to be generated. @xref{Tests}.
3379 @item @code{dist-bzip2}
3380 @cindex Option, dist-bzip2
3381 Generate a @code{dist-bzip2} target as well as the ordinary @code{dist}
3382 target. This new target will create a bzip2 tar archive of the
3383 distribution. bzip2 archives are frequently smaller than even gzipped
3387 @item @code{dist-shar}
3388 @cindex Option, dist-shar
3389 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
3390 target. This new target will create a shar archive of the
3394 @item @code{dist-zip}
3395 @cindex Option, dist-zip
3396 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
3397 target. This new target will create a zip archive of the distribution.
3400 @item @code{dist-tarZ}
3401 @cindex Option, dist-tarZ
3402 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
3403 target. This new target will create a compressed tar archive of the
3407 @item @code{no-dependencies}
3408 @cindex Option, no-dependencies
3409 This is similar to using @samp{--include-deps} on the command line, but
3410 is useful for those situations where you don't have the necessary bits
3411 to make automatic dependency tracking work @xref{Dependencies}. In this
3412 case the effect is to effectively disable automatic dependency tracking.
3414 @item @code{no-installinfo}
3415 @cindex Option, no-installinfo
3416 The generated @file{Makefile.in} will not cause info pages to be built
3417 or installed by default. However, @code{info} and @code{install-info}
3418 targets will still be available. This option is disallowed at
3419 @samp{GNU} strictness and above.
3421 @trindex install-info
3423 @item @code{no-installman}
3424 @cindex Option, no-installman
3425 The generated @file{Makefile.in} will not cause man pages to be
3426 installed by default. However, an @code{install-man} target will still
3427 be available for optional installation. This option is disallowed at
3428 @samp{GNU} strictness and above.
3429 @trindex install-man
3431 @item @code{nostdinc}
3432 @cindex Option, nostdinc
3433 This option can be used to disable the standard @samp{-I} options which
3434 are ordinarily automatically provided by Automake.
3436 @item @code{no-texinfo.tex}
3437 @cindex Option, no-texinfo
3438 Don't require @file{texinfo.tex}, even if there are texinfo files in
3441 @item @code{readme-alpha}
3442 @cindex Option, readme-alpha
3443 If this release is an alpha release, and the file @file{README-alpha}
3444 exists, then it will be added to the distribution. If this option is
3445 given, version numbers are expected to follow one of two forms. The
3446 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
3447 element is a number; the final period and number should be left off for
3448 non-alpha releases. The second form is
3449 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
3450 letter; it should be omitted for non-alpha releases.
3453 @cindex Option, version
3454 A version number (e.g. @samp{0.30}) can be specified. If Automake is not
3455 newer than the version specified, creation of the @file{Makefile.in}
3459 Unrecognized options are diagnosed by @code{automake}.
3462 @node Miscellaneous, Include, Options, Top
3463 @chapter Miscellaneous Rules
3465 There are a few rules and variables that didn't fit anywhere else.
3468 * Tags:: Interfacing to etags and mkid
3469 * Suffixes:: Handling new file extensions
3473 @node Tags, Suffixes, Miscellaneous, Miscellaneous
3474 @section Interfacing to @code{etags}
3476 @cindex TAGS support
3478 Automake will generate rules to generate @file{TAGS} files for use with
3479 GNU Emacs under some circumstances.
3481 If any C, C++ or Fortran 77 source code or headers are present, then
3482 @code{tags} and @code{TAGS} targets will be generated for the directory.
3485 At the topmost directory of a multi-directory package, a @code{tags}
3486 target file will be generated which, when run, will generate a
3487 @file{TAGS} file that includes by reference all @file{TAGS} files from
3490 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
3491 will be generated. This variable is intended for use in directories
3492 which contain taggable source that @code{etags} does not understand.
3495 Here is how Automake generates tags for its source, and for nodes in its
3499 ETAGS_ARGS = automake.in --lang=none \
3500 --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
3503 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
3504 want to set @samp{TAGS_DEPENDENCIES}. The contents of this variable
3505 are added directly to the dependencies for the @code{tags} target.
3506 @vindex TAGS_DEPENDENCIES
3508 Automake will also generate an @code{ID} target which will run
3509 @code{mkid} on the source. This is only supported on a
3510 directory-by-directory basis.
3513 Automake also supports the GNU Global Tags program. The @code{GTAGS}
3514 target runs Global Tags automatically and puts the result in the top
3518 @node Suffixes, , Tags, Miscellaneous
3519 @section Handling new file extensions
3521 @cindex Adding new SUFFIXES
3522 @cindex SUFFIXES, adding
3524 It is sometimes useful to introduce a new implicit rule to handle a file
3525 type that Automake does not know about. If this is done, you must
3526 notify GNU Make of the new suffixes. This can be done by putting a list
3527 of new suffixes in the @code{SUFFIXES} variable.
3530 For instance, currently Automake does not provide any Java support. If
3531 you wrote a macro to generate @samp{.class} files from @samp{.java}
3532 source files, you would also need to add these suffixes to the list:
3535 SUFFIXES = .java .class
3538 Any given @code{SUFFIXES} go at the start of the generated suffixes
3539 list, followed by automake generated suffixes not already in the list.
3542 @node Include, Conditionals, Miscellaneous, Top
3546 To include another file (perhaps for common rules),
3547 the following syntax is supported:
3549 include ($(srcdir)|$(top_srcdir))/filename
3551 Using files in the current directory:
3553 include $(srcdir)/Makefile.extra
3557 include Makefile.generated
3560 Using a file in the top level directory:
3562 include $(top_srcdir)/filename
3566 @node Conditionals, Gnits, Include, Top
3567 @chapter Conditionals
3569 @cindex Conditionals
3571 Automake supports a simple type of conditionals.
3573 @cvindex AM_CONDITIONAL
3574 Before using a conditional, you must define it by using
3575 @code{AM_CONDITIONAL} in the @code{configure.in} file (@pxref{Macros}).
3577 @defmac AM_CONDITIONAL (@var{conditional}, @var{condition})
3578 The conditional name, @var{conditional}, should be a simple string
3579 starting with a letter and containing only letters, digits, and
3580 underscores. It must be different from @samp{TRUE} and @samp{FALSE}
3581 which are reserved by Automake.
3583 The shell @var{condition} (suitable for use in a shell @code{if}
3584 statement) is evaluated when @code{configure} is run.
3587 @cindex --enable-debug, example
3588 @cindex Example conditional --enable-debug
3589 @cindex Conditional example, --enable-debug
3591 Conditionals typically depend upon options which the user provides to
3592 the @code{configure} script. Here is an example of how to write a
3593 conditional which is true if the user uses the @samp{--enable-debug}
3597 AC_ARG_ENABLE(debug,
3598 [ --enable-debug Turn on debugging],
3599 [case "$@{enableval@}" in
3602 *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
3603 esac],[debug=false])
3604 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
3607 Here is an example of how to use that conditional in @file{Makefile.am}:
3619 noinst_PROGRAMS = $(DBG)
3622 This trivial example could also be handled using EXTRA_PROGRAMS
3623 (@pxref{A Program}).
3625 You may only test a single variable in an @code{if} statement, possibly
3626 negated using @samp{!}. The @code{else} statement may be omitted.
3627 Conditionals may be nested to any depth. You may specify an argument to
3628 @code{else} in which case it must be the negation of the condition used
3629 for the current @code{if}. Similarly you may specify the condition
3630 which is closed by an @code{end}:
3641 Unbalanced conditions are errors.
3643 Note that conditionals in Automake are not the same as conditionals in
3644 GNU Make. Automake conditionals are checked at configure time by the
3645 @file{configure} script, and affect the translation from
3646 @file{Makefile.in} to @file{Makefile}. They are based on options passed
3647 to @file{configure} and on results that @file{configure} has discovered
3648 about the host system. GNU Make conditionals are checked at @code{make}
3649 time, and are based on variables passed to the make program or defined
3650 in the @file{Makefile}.
3652 Automake conditionals will work with any make program.
3655 @node Gnits, Cygnus, Conditionals, Top
3656 @chapter The effect of @code{--gnu} and @code{--gnits}
3658 @cindex --gnu, required files
3659 @cindex --gnu, complete description
3661 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
3662 variable) causes @code{automake} to check the following:
3666 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
3667 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
3668 directory of the package.
3671 The options @samp{no-installman} and @samp{no-installinfo} are
3675 Note that this option will be extended in the future to do even more
3676 checking; it is advisable to be familiar with the precise requirements
3677 of the GNU standards. Also, @samp{--gnu} can require certain
3678 non-standard GNU programs to exist for use by various maintainer-only
3679 targets; for instance in the future @code{pathchk} might be required for
3682 @cindex --gnits, complete description
3684 The @samp{--gnits} option does everything that @samp{--gnu} does, and
3685 checks the following as well:
3689 @samp{make dist} will check to make sure the @file{NEWS} file has been
3690 updated to the current version.
3693 @samp{VERSION} is checked to make sure its format complies with Gnits
3695 @c FIXME xref when standards are finished
3698 @cindex README-alpha
3699 If @samp{VERSION} indicates that this is an alpha release, and the file
3700 @file{README-alpha} appears in the topmost directory of a package, then
3701 it is included in the distribution. This is done in @samp{--gnits}
3702 mode, and no other, because this mode is the only one where version
3703 number formats are constrained, and hence the only mode where Automake
3704 can automatically determine whether @file{README-alpha} should be
3708 The file @file{THANKS} is required.
3712 @node Cygnus, Extending, Gnits, Top
3713 @chapter The effect of @code{--cygnus}
3715 @cindex Cygnus strictness
3717 Cygnus Solutions has slightly different rules for how a
3718 @file{Makefile.in} is to be constructed. Passing @samp{--cygnus} to
3719 @code{automake} will cause any generated @file{Makefile.in} to comply
3722 Here are the precise effects of @samp{--cygnus}:
3726 Info files are always created in the build directory, and not in the
3730 @file{texinfo.tex} is not required if a Texinfo source file is
3731 specified. The assumption is that the file will be supplied, but in a
3732 place that Automake cannot find. This assumption is an artifact of how
3733 Cygnus packages are typically bundled.
3736 @samp{make dist} will look for files in the build directory as well as
3737 the source directory. This is required to support putting info files
3738 into the build directory.
3741 Certain tools will be searched for in the build tree as well as in the
3742 user's @samp{PATH}. These tools are @code{runtest}, @code{expect},
3743 @code{makeinfo} and @code{texi2dvi}.
3746 @code{--foreign} is implied.
3749 The options @samp{no-installinfo} and @samp{no-dependencies} are
3753 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
3757 The @code{check} target doesn't depend on @code{all}.
3760 GNU maintainers are advised to use @samp{gnu} strictness in preference
3761 to the special Cygnus mode.
3764 @node Extending, Distributing, Cygnus, Top
3765 @chapter When Automake Isn't Enough
3767 Automake's implicit copying semantics means that many problems can be
3768 worked around by simply adding some @code{make} targets and rules to
3769 @file{Makefile.in}. Automake will ignore these additions.
3771 @cindex -local targets
3772 @cindex local targets
3774 There are some caveats to doing this. Although you can overload a
3775 target already used by Automake, it is often inadvisable, particularly
3776 in the topmost directory of a package with subdirectories. However,
3777 various useful targets have a @samp{-local} version you can specify in
3778 your @file{Makefile.in}. Automake will supplement the standard target
3779 with these user-supplied targets.
3784 @trindex check-local
3785 @trindex install-data-local
3786 @trindex install-exec-local
3787 @trindex uninstall-local
3788 @trindex mostlyclean-local
3789 @trindex clean-local
3790 @trindex distclean-local
3792 The targets that support a local version are @code{all}, @code{info},
3793 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
3794 @code{uninstall}, and the various @code{clean} targets
3795 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
3796 @code{maintainer-clean}). Note that there are no
3797 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
3798 use @code{uninstall-local}. It doesn't make sense to uninstall just
3799 data or just executables.
3804 @trindex install-data
3805 @trindex install-exec
3808 For instance, here is one way to install a file in @file{/etc}:
3812 $(INSTALL_DATA) $(srcdir)/afile /etc/afile
3815 @cindex -hook targets
3816 @cindex hook targets
3818 Some targets also have a way to run another target, called a @dfn{hook},
3819 after their work is done. The hook is named after the principal target,
3820 with @samp{-hook} appended. The targets allowing hooks are
3821 @code{install-data}, @code{install-exec}, @code{dist}, and
3823 @trindex install-data-hook
3824 @trindex install-exec-hook
3827 For instance, here is how to create a hard link to an installed program:
3831 ln $(bindir)/program $(bindir)/proglink
3834 @c FIXME should include discussion of variables you can use in these
3838 @node Distributing, Macro and Variable Index, Extending, Top
3839 @chapter Distributing @file{Makefile.in}s
3841 Automake places no restrictions on the distribution of the resulting
3842 @file{Makefile.in}s. We still encourage software authors to distribute
3843 their work under terms like those of the GPL, but doing so is not
3844 required to use Automake.
3846 Some of the files that can be automatically installed via the
3847 @code{--add-missing} switch do fall under the GPL; examine each file
3852 @node Macro and Variable Index, General Index, Distributing, Top
3853 @unnumbered Macro and Variable Index
3859 @node General Index, , Macro and Variable Index, Top
3860 @unnumbered General Index