* makevars.test: Fail if automake fails.
[automake.git] / automake.texi
blobabe2d9f45e4494d7c9f61a36e5ced8967e1709dc
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename automake.info
4 @settitle automake
5 @setchapternewpage off
6 @c %**end of header
8 @include version.texi
10 @dircategory GNU programming tools
11 @direntry
12 * automake: (automake).         Making Makefile.in's
13 @end direntry
15 @dircategory Individual utilities
16 @direntry
17 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4
18 @end direntry
20 @ifinfo
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.
29 @ignore
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
35 @end ignore
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
44 by the Foundation.
45 @end ifinfo
48 @titlepage
49 @title GNU Automake
50 @subtitle For version @value{VERSION}, @value{UPDATED}
51 @author David MacKenzie and Tom Tromey
53 @page
54 @vskip 0pt plus 1filll
55 Copyright @copyright{} 1995, 1996, 2000, 2001 Free Software Foundation, Inc.
56 @sp 2
57 This is the first edition of the GNU Automake documentation,@*
58 and is consistent with GNU Automake @value{VERSION}.@*
59 @sp 2
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.
77 @end titlepage
79 @c Define an index of configure output variables.
80 @defcodeindex ov
81 @c Define an index of configure variables.
82 @defcodeindex cv
83 @c Define an index of options.
84 @defcodeindex op
85 @c Define an index of targets.
86 @defcodeindex tr
87 @c Define an index of commands.
88 @defcodeindex cm
90 @c Put the macros and variables into their own index.
91 @c @syncodeindex fn cp
92 @syncodeindex ov vr
93 @syncodeindex cv vr
94 @syncodeindex fn vr
96 @c Put everything else into one index (arbitrarily chosen to be the concept index).
97 @syncodeindex op cp
98 @syncodeindex tr cp
99 @syncodeindex cm cp
101 @ifinfo
102 @node Top, Introduction, (dir), (dir)
103 @comment  node-name,  next,  previous,  up
104 @top GNU Automake
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}.
110 @menu
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 * Programs::                    Building programs and libraries
118 * Other objects::               Other derived objects
119 * Other GNU Tools::             Other GNU Tools
120 * Documentation::               Building documentation
121 * Install::                     What gets installed
122 * Clean::                       What gets cleaned
123 * Dist::                        What goes in a distribution
124 * Tests::                       Support for test suites
125 * Options::                     Changing Automake's behavior
126 * Miscellaneous::               Miscellaneous rules
127 * Include::                     Including extra files in an Automake template.
128 * Conditionals::                Conditionals
129 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
130 * Cygnus::                      The effect of @code{--cygnus}
131 * Extending::                   Extending Automake
132 * Distributing::                Distributing the Makefile.in
133 * Future::                      Some ideas for the future
134 * Macro and Variable Index::
135 * General Index::
136 @end menu
138 @end ifinfo
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
157 maintainer).
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
180 to be built.
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.
196 @menu
197 * General Operation::           General operation of Automake
198 * Depth::                       The kinds of packages
199 * Strictness::                  Standards conformance checking
200 * Uniform::                     The Uniform Naming Scheme
201 * Canonicalization::            How derived variables are named
202 @end menu
205 @node General Operation, Depth, 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
216 @trindex cvs-dist
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
223 system.
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
229 behavior.
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
241 very particular.
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
261 @example
262 xs = a.c b.c
263 foo_SOURCES = c.c $(xs)
264 @end example
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{##} are completely ignored by
275 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
282 @example
283 ## Process this file with automake to produce Makefile.in
284 @end example
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 Depth, Strictness, General Operation, Generalities
293 @section Depth
295 @cindex Flat package
296 @cindex Package, Flat
297 @cindex Shallow package
298 @cindex Package, shallow
299 @cindex Deep package
300 @cindex Package, deep
302 @code{automake} supports three kinds of directory hierarchy:
303 @samp{flat}, @samp{shallow}, and @samp{deep}.
305 A @dfn{flat} package is one in which all the files are in a single
306 directory.  The @file{Makefile.am} for such a package by definition
307 lacks a @code{SUBDIRS} macro.  An example of such a package is
308 @code{termutils}.
309 @vindex SUBDIRS
311 @cindex SUBDIRS, deep package
313 A @dfn{deep} package is one in which all the source lies in
314 subdirectories; the top level directory contains mainly configuration
315 information.  GNU @code{cpio} is a good example of such a package, as is
316 GNU @code{tar}.  The top level @file{Makefile.am} for a deep package
317 will contain a @code{SUBDIRS} macro, but no other macros to define
318 objects which are built.
320 A @dfn{shallow} package is one in which the primary source resides in
321 the top-level directory, while various parts (typically libraries)
322 reside in subdirectories.  Automake is one such package (as is GNU
323 @code{make}, which does not currently use @code{automake}).
326 @node Strictness, Uniform, Depth, Generalities
327 @section Strictness
329 @cindex Non-GNU packages
331 While Automake is intended to be used by maintainers of GNU packages, it
332 does make some effort to accommodate those who wish to use it, but do
333 not want to use all the GNU conventions.
335 @cindex Strictness, defined
336 @cindex Strictness, foreign
337 @cindex foreign strictness
338 @cindex Strictness, gnu
339 @cindex gnits strictness
340 @cindex Strictness, gnits
341 @cindex gnits strictness
343 To this end, Automake supports three levels of @dfn{strictness}---the
344 strictness indicating how stringently Automake should check standards
345 conformance.
347 The valid strictness levels are:
349 @table @samp
350 @item foreign
351 Automake will check for only those things which are absolutely
352 required for proper operations.  For instance, whereas GNU standards
353 dictate the existence of a @file{NEWS} file, it will not be required in
354 this mode.  The name comes from the fact that Automake is intended to be
355 used for GNU programs; these relaxed rules are not the standard mode of
356 operation.
358 @item gnu
359 Automake will check---as much as possible---for compliance to the GNU
360 standards for packages.  This is the default.
362 @item gnits
363 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
364 standards}.  These are based on the GNU standards, but are even more
365 detailed.  Unless you are a Gnits standards contributor, it is
366 recommended that you avoid this option until such time as the Gnits
367 standard is actually published.
368 @end table
370 For more information on the precise implications of the strictness
371 level, see @ref{Gnits}.
374 @node Uniform, Canonicalization, Strictness, Generalities
375 @section The Uniform Naming Scheme
377 @cindex Uniform naming scheme
379 Automake macros (from here on referred to as @emph{variables}) generally
380 follow a @dfn{uniform naming scheme} that makes it easy to decide how
381 programs (and other derived objects) are built, and how they are
382 installed.  This scheme also supports @code{configure} time
383 determination of what should be built.
385 @cindex _PROGRAMS primary variable
386 @cindex PROGRAMS primary variable
387 @cindex Primary variable, PROGRAMS
389 @cindex Primary variable, defined
391 At @code{make} time, certain variables are used to determine which
392 objects are to be built.  These variables are called @dfn{primary
393 variables}.  For instance, the primary variable @code{PROGRAMS} holds a
394 list of programs which are to be compiled and linked.
395 @vindex PROGRAMS
397 @cindex pkglibdir, defined
398 @cindex pkgincludedir, defined
399 @cindex pkgdatadir, defined
401 @vindex pkglibdir
402 @vindex pkgincludedir
403 @vindex pkgdatadir
405 A different set of variables is used to decide where the built objects
406 should be installed.  These variables are named after the primary
407 variables, but have a prefix indicating which standard directory should
408 be used as the installation directory.  The standard directory names are
409 given in the GNU standards (@pxref{Directory Variables, , , standards,
410 The GNU Coding Standards}).  Automake extends this list with
411 @code{pkglibdir}, @code{pkgincludedir}, and @code{pkgdatadir}; these are
412 the same as the non-@samp{pkg} versions, but with @samp{@@PACKAGE@@}
413 appended.  For instance, @code{pkglibdir} is defined as
414 @code{$(libdir)/@@PACKAGE@@}.
415 @cvindex PACKAGE
417 @cindex EXTRA_, prepending
419 For each primary, there is one additional variable named by prepending
420 @samp{EXTRA_} to the primary name.  This variable is used to list
421 objects which may or may not be built, depending on what
422 @code{configure} decides.  This variable is required because Automake
423 must statically know the entire list of objects that may be built in
424 order to generate a @file{Makefile.in} that will work in all cases.
426 @cindex EXTRA_PROGRAMS, defined
427 @cindex Example, EXTRA_PROGRAMS
428 @cindex cpio example
430 For instance, @code{cpio} decides at configure time which programs are
431 built.  Some of the programs are installed in @code{bindir}, and some
432 are installed in @code{sbindir}:
434 @example
435 EXTRA_PROGRAMS = mt rmt
436 bin_PROGRAMS = cpio pax
437 sbin_PROGRAMS = @@PROGRAMS@@
438 @end example
440 Defining a primary variable without a prefix (e.g. @code{PROGRAMS}) is
441 an error.
443 Note that the common @samp{dir} suffix is left off when constructing the
444 variable names; thus one writes @samp{bin_PROGRAMS} and not
445 @samp{bindir_PROGRAMS}.
447 Not every sort of object can be installed in every directory.  Automake
448 will flag those attempts it finds in error.  Automake will also diagnose
449 obvious misspellings in directory names.
451 @cindex Extending list of installation directories
452 @cindex Installation directories, extending list
454 Sometimes the standard directories---even as augmented by Automake---
455 are not enough.  In particular it is sometimes useful, for clarity, to
456 install objects in a subdirectory of some predefined directory.  To this
457 end, Automake allows you to extend the list of possible installation
458 directories.  A given prefix (e.g. @samp{zar}) is valid if a variable of
459 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
461 @cindex HTML support, example
463 For instance, until HTML support is part of Automake, you could use this
464 to install raw HTML documentation:
466 @example
467 htmldir = $(prefix)/html
468 html_DATA = automake.html
469 @end example
471 @cindex noinst primary prefix, definition
473 The special prefix @samp{noinst} indicates that the objects in question
474 should not be installed at all.
476 @cindex check primary prefix, definition
478 The special prefix @samp{check} indicates that the objects in question
479 should not be built until the @code{make check} command is run.
481 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
482 @samp{LISP}, @samp{PYTHON}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS},
483 @samp{MANS}, and @samp{TEXINFOS}.
484 @vindex PROGRAMS
485 @vindex LIBRARIES
486 @vindex LISP
487 @vindex PYTHON
488 @vindex SCRIPTS
489 @vindex DATA
490 @vindex HEADERS
491 @vindex MANS
492 @vindex TEXINFOS
495 @node Canonicalization,  , Uniform, Generalities
496 @section How derived variables are named
498 @cindex canonicalizing Automake macros
500 Sometimes a Makefile variable name is derived from some text the user
501 supplies.  For instance, program names are rewritten into Makefile macro
502 names.  Automake canonicalizes this text, so that it does not have to
503 follow Makefile macro naming rules.  All characters in the name except
504 for letters, numbers, and the underscore are turned into underscores
505 when making macro references.  For example, if your program is named
506 @code{sniff-glue}, the derived variable name would be
507 @code{sniff_glue_SOURCES}, not @code{sniff-glue_SOURCES}.
509 @node Examples, Invoking Automake, Generalities, Top
510 @chapter Some example packages
512 @menu
513 * Complete::                    A simple example, start to finish
514 * Hello::                       A classic program
515 * etags::                       Building etags and ctags
516 @end menu
519 @node Complete, Hello, Examples, Examples
520 @section A simple example, start to finish
522 @cindex Complete example
524 Let's suppose you just finished writing @code{zardoz}, a program to make
525 your head float from vortex to vortex.  You've been using Autoconf to
526 provide a portability framework, but your @file{Makefile.in}s have been
527 ad-hoc.  You want to make them bulletproof, so you turn to Automake.
529 @cindex AM_INIT_AUTOMAKE, example use
531 The first step is to update your @file{configure.in} to include the
532 commands that @code{automake} needs.  The way to do this is to add an
533 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
535 @example
536 AM_INIT_AUTOMAKE(zardoz, 1.0)
537 @end example
539 Since your program doesn't have any complicating factors (e.g., it
540 doesn't use @code{gettext}, it doesn't want to build a shared library),
541 you're done with this part.  That was easy!
543 @cindex aclocal program, introduction
544 @cindex aclocal.m4, preexisting
545 @cindex acinclude.m4, defined
547 Now you must regenerate @file{configure}.  But to do that, you'll need
548 to tell @code{autoconf} how to find the new macro you've used.  The
549 easiest way to do this is to use the @code{aclocal} program to generate
550 your @file{aclocal.m4} for you.  But wait... you already have an
551 @file{aclocal.m4}, because you had to write some hairy macros for your
552 program.  The @code{aclocal} program lets you put your own macros into
553 @file{acinclude.m4}, so simply rename and then run:
555 @example
556 mv aclocal.m4 acinclude.m4
557 aclocal
558 autoconf
559 @end example
561 @cindex zardoz example
563 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
564 Since @code{zardoz} is a user program, you want to install it where the
565 rest of the user programs go.  Additionally, @code{zardoz} has some
566 Texinfo documentation.  Your @file{configure.in} script uses
567 @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
568 So here's what you'd write:
570 @example
571 bin_PROGRAMS = zardoz
572 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
573 zardoz_LDADD = @@LIBOBJS@@
575 info_TEXINFOS = zardoz.texi
576 @end example
578 Now you can run @code{automake --add-missing} to generate your
579 @file{Makefile.in} and grab any auxiliary files you might need, and
580 you're done!
583 @node Hello, etags, Complete, Examples
584 @section A classic program
586 @cindex Example, GNU Hello
587 @cindex Hello example
588 @cindex GNU Hello, example
590 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
591 renowned for its classic simplicity and versatility.  This section shows
592 how Automake could be used with the GNU Hello package.  The examples
593 below are from the latest beta version of GNU Hello, but with all of the
594 maintainer-only code stripped out, as well as all copyright comments.
596 Of course, GNU Hello is somewhat more featureful than your traditional
597 two-liner.  GNU Hello is internationalized, does option processing, and
598 has a manual and a test suite.  GNU Hello is a deep package.
600 @cindex configure.in, from GNU Hello
601 @cindex GNU Hello, configure.in
602 @cindex Hello, configure.in
604 Here is the @file{configure.in} from GNU Hello:
606 @example
607 dnl Process this file with autoconf to produce a configure script.
608 AC_INIT(src/hello.c)
609 AM_INIT_AUTOMAKE(hello, 1.3.11)
610 AM_CONFIG_HEADER(config.h)
612 dnl Set of available languages.
613 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
615 dnl Checks for programs.
616 AC_PROG_CC
617 AC_ISC_POSIX
619 dnl Checks for libraries.
621 dnl Checks for header files.
622 AC_STDC_HEADERS
623 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
625 dnl Checks for library functions.
626 AC_FUNC_ALLOCA
628 dnl Check for st_blksize in struct stat
629 AC_ST_BLKSIZE
631 dnl internationalization macros
632 AM_GNU_GETTEXT
633 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
634            src/Makefile tests/Makefile tests/hello],
635    [chmod +x tests/hello])
636 @end example
638 The @samp{AM_} macros are provided by Automake (or the Gettext library);
639 the rest are standard Autoconf macros.
642 The top-level @file{Makefile.am}:
644 @example
645 EXTRA_DIST = BUGS ChangeLog.O
646 SUBDIRS = doc intl po src tests
647 @end example
649 As you can see, all the work here is really done in subdirectories.
651 The @file{po} and @file{intl} directories are automatically generated
652 using @code{gettextize}; they will not be discussed here.
654 @cindex Texinfo file handling example
655 @cindex Example, handling Texinfo files
657 In @file{doc/Makefile.am} we see:
659 @example
660 info_TEXINFOS = hello.texi
661 hello_TEXINFOS = gpl.texi
662 @end example
664 This is sufficient to build, install, and distribute the GNU Hello
665 manual.
667 @cindex Regression test example
668 @cindex Example, regression test
670 Here is @file{tests/Makefile.am}:
672 @example
673 TESTS = hello
674 EXTRA_DIST = hello.in testdata
675 @end example
677 The script @file{hello} is generated by @code{configure}, and is the
678 only test case.  @code{make check} will run this test.
680 @cindex INCLUDES, example usage
682 Last we have @file{src/Makefile.am}, where all the real work is done:
684 @example
685 bin_PROGRAMS = hello
686 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
687 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
688 localedir = $(datadir)/locale
689 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
690 @end example
693 @node etags,  , Hello, Examples
694 @section Building etags and ctags
696 @cindex Example, ctags and etags
697 @cindex ctags Example
698 @cindex etags Example
700 Here is another, trickier example.  It shows how to generate two
701 programs (@code{ctags} and @code{etags}) from the same source file
702 (@file{etags.c}).  The difficult part is that each compilation of
703 @file{etags.c} requires different @code{cpp} flags.
705 @example
706 bin_PROGRAMS = etags ctags
707 ctags_SOURCES =
708 ctags_LDADD = ctags.o
710 etags.o: etags.c
711         $(COMPILE) -DETAGS_REGEXPS -c etags.c
713 ctags.o: etags.c
714         $(COMPILE) -DCTAGS -o ctags.o -c etags.c
715 @end example
717 Note that @code{ctags_SOURCES} is defined to be empty---that way no
718 implicit value is substituted.  The implicit value, however, is used to
719 generate @code{etags} from @file{etags.o}.
721 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
722 @code{ctags_DEPENDENCIES} is generated by Automake.
724 The above rules won't work if your compiler doesn't accept both
725 @samp{-c} and @samp{-o}.  The simplest fix for this is to introduce a
726 bogus dependency (to avoid problems with a parallel @code{make}):
728 @example
729 etags.o: etags.c ctags.o
730         $(COMPILE) -DETAGS_REGEXPS -c etags.c
732 ctags.o: etags.c
733         $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
734 @end example
736 Also, these explicit rules do not work if the de-ANSI-fication feature
737 is used (@pxref{ANSI}).  Supporting de-ANSI-fication requires a little
738 more work:
740 @example
741 etags._o: etags._c ctags.o
742         $(COMPILE) -DETAGS_REGEXPS -c etags.c
744 ctags._o: etags._c
745         $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o
746 @end example
749 @node Invoking Automake, configure, Examples, Top
750 @chapter Creating a @file{Makefile.in}
752 @cindex Multiple configure.in files
753 @cindex Invoking Automake
754 @cindex Automake, invoking
756 To create all the @file{Makefile.in}s for a package, run the
757 @code{automake} program in the top level directory, with no arguments.
758 @code{automake} will automatically find each appropriate
759 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
760 and generate the corresponding @file{Makefile.in}.  Note that
761 @code{automake} has a rather simplistic view of what constitutes a
762 package; it assumes that a package has only one @file{configure.in}, at
763 the top.  If your package has multiple @file{configure.in}s, then you
764 must run @code{automake} in each directory holding a
765 @file{configure.in}.
767 You can optionally give @code{automake} an argument; @file{.am} is
768 appended to the argument and the result is used as the name of the input
769 file.  This feature is generally only used to automatically rebuild an
770 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
771 be run from the topmost directory of a project, even if being used to
772 regenerate the @file{Makefile.in} in some subdirectory.  This is
773 necessary because @code{automake} must scan @file{configure.in}, and
774 because @code{automake} uses the knowledge that a @file{Makefile.in} is
775 in a subdirectory to change its behavior in some cases.
777 @cindex Automake options
778 @cindex Options, Automake
780 @code{automake} accepts the following options:
782 @cindex Extra files distributed with Automake
783 @cindex Files distributed with Automake
784 @cindex config.guess
786 @table @samp
787 @item -a
788 @itemx --add-missing
789 @opindex -a
790 @opindex --add-missing
791 Automake requires certain common files to exist in certain situations;
792 for instance @file{config.guess} is required if @file{configure.in} runs
793 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
794 files; this option will cause the missing ones to be automatically added
795 to the package, whenever possible.  In general if Automake tells you a
796 file is missing, try using this option.  By default Automake tries to
797 make a symbolic link pointing to its own copy of the missing file; this
798 can be changed with @code{--copy}.
800 @item --amdir=@var{dir}
801 @opindex --amdir
802 Look for Automake data files in directory @var{dir} instead of in the
803 installation directory.  This is typically used for debugging.
805 @item --build-dir=@var{dir}
806 @opindex --build-dir
807 Tell Automake where the build directory is.  This option is used when
808 including dependencies into a @file{Makefile.in} generated by @code{make
809 dist}; it should not be used otherwise.
811 @item -c
812 @item --copy
813 When used with @code{--add-missing}, causes installed files to be
814 copied.  The default is to make a symbolic link.
816 @item --cygnus
817 @opindex --cygnus
818 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
819 of GNU or Gnits rules.  For more information, see @ref{Cygnus}.
821 @item --force-missing
822 @opindex --force-missing
823 When used with @code{--add-missing}, causes standard files to be rebuilt
824 even if they already exist in the source tree.  This involves removing
825 the file from the source tree before creating the new symlink (or, with
826 @code{--copy}, copying the new file).
828 @item --foreign
829 @opindex --foreign
830 Set the global strictness to @samp{foreign}.  For more information, see
831 @ref{Strictness}.
833 @item --gnits
834 @opindex --gnits
835 Set the global strictness to @samp{gnits}.  For more information, see
836 @ref{Gnits}.
838 @item --gnu
839 @opindex --gnu
840 Set the global strictness to @samp{gnu}.  For more information, see
841 @ref{Gnits}.  This is the default strictness.
843 @item --help
844 @opindex --help
845 Print a summary of the command line options and exit.
847 @item -i
848 @itemx --include-deps
849 @opindex -i
850 @opindex --include-deps
851 Include all automatically generated dependency information
852 (@pxref{Dependencies}) in the generated
853 @file{Makefile.in}.  This is generally done when making a distribution;
854 see @ref{Dist}.
856 @item --generate-deps
857 @opindex --generate-deps
858 Generate a file concatenating all automatically generated dependency
859 information (@pxref{Dependencies}) into one file, @file{.dep_segment}.
860 This is generally done when making a distribution; see @ref{Dist}.  It
861 is useful when maintaining a @file{SMakefile} or makefiles for other
862 platforms (@file{Makefile.DOS}, etc.)  It can only be used in
863 conjunction with @samp{--include-deps}, @samp{--srcdir-name}, and
864 @samp{--build-dir}.  Note that if this option is given, no other
865 processing is done.
867 @item --no-force
868 @opindex --no-force
869 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
870 @file{configure.in}.  This option causes it to only update those
871 @file{Makefile.in}s which are out of date with respect to one of their
872 dependents.
874 @item -o @var{dir}
875 @itemx --output-dir=@var{dir}
876 @opindex -o
877 @opindex --output-dir
878 Put the generated @file{Makefile.in} in the directory @var{dir}.
879 Ordinarily each @file{Makefile.in} is created in the directory of the
880 corresponding @file{Makefile.am}.  This option is used when making
881 distributions.
883 @item --srcdir-name=@var{dir}
884 @opindex --srcdir-name
885 Tell Automake the name of the source directory associated with the
886 current build.  This option is used when including dependencies into a
887 @file{Makefile.in} generated by @code{make dist}; it should not be used
888 otherwise.
890 @item -v
891 @itemx --verbose
892 @opindex -v
893 @opindex --verbose
894 Cause Automake to print information about which files are being read or
895 created.
897 @item --version
898 @opindex --version
899 Print the version number of Automake and exit.
900 @end table
903 @node configure, Top level, Invoking Automake, Top
904 @chapter Scanning @file{configure.in}
906 @cindex configure.in, scanning
907 @cindex Scanning configure.in
909 Automake scans the package's @file{configure.in} to determine certain
910 information about the package.  Some @code{autoconf} macros are required
911 and some variables must be defined in @file{configure.in}.  Automake
912 will also use information from @file{configure.in} to further tailor its
913 output.
915 Automake also supplies some Autoconf macros to make the maintenance
916 easier.  These macros can automatically be put into your
917 @file{aclocal.m4} using the @code{aclocal} program.
919 @menu
920 * Requirements::                Configuration requirements
921 * Optional::                    Other things Automake recognizes
922 * Invoking aclocal::            Auto-generating aclocal.m4
923 * Macros::                      Autoconf macros supplied with Automake
924 * Extending aclocal::           Writing your own aclocal macros
925 @end menu
928 @node Requirements, Optional, configure, configure
929 @section Configuration requirements
931 @cindex Automake requirements
932 @cindex Requirements of Automake
934 The one real requirement of Automake is that your @file{configure.in}
935 call @code{AM_INIT_AUTOMAKE}.  This macro does several things which are
936 required for proper Automake operation.
937 @cvindex AM_INIT_AUTOMAKE
939 Here are the other macros which Automake requires but which are not run
940 by @code{AM_INIT_AUTOMAKE}:
942 @cindex AC_OUTPUT, scanning
944 @table @code
945 @item AC_OUTPUT
946 Automake uses this to determine which files to create (@pxref{Output, ,
947 Creating Output Files, autoconf, The Autoconf Manual}).  Listed files
948 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
949 files are treated differently.  Currently the only difference is that a
950 @file{Makefile} is removed by @code{make distclean}, while other files
951 are removed by @code{make clean}.
952 @c FIXME: this is in violation of standards!
953 @cvindex AC_OUTPUT
954 @end table
957 @node Optional, Invoking aclocal, Requirements, configure
958 @section Other things Automake recognizes
960 @cindex Macros Automake recognizes
961 @cindex Recognized macros by Automake
963 Automake will also recognize the use of certain macros and tailor the
964 generated @file{Makefile.in} appropriately.  Currently recognized macros
965 and their effects are:
967 @table @code
968 @item AC_CONFIG_HEADER
969 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
970 to @code{AC_CONFIG_HEADER} (@pxref{Configuration Headers, ,
971 Configuration Header Files, autoconf, The Autoconf Manual}), but does
972 some useful Automake-specific work.
973 @cvindex AC_CONFIG_HEADER
975 @item AC_CONFIG_AUX_DIR
976 Automake will look for various helper scripts, such as
977 @file{mkinstalldirs}, in the directory named in this macro invocation.
978 If not seen, the scripts are looked for in their @samp{standard}
979 locations (either the top source directory, or in the source directory
980 corresponding to the current @file{Makefile.am}, whichever is
981 appropriate).  @xref{Input, , Finding `configure' Input, autoconf, The
982 Autoconf Manual}.
983 @cvindex AC_CONFIG_AUX_DIR
984 FIXME: give complete list of things looked for in this directory
986 @item AC_PATH_XTRA
987 Automake will insert definitions for the variables defined by
988 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
989 or library.  @xref{System Services, , System Services, autoconf, The
990 Autoconf Manual}.
991 @cvindex AC_PATH_XTRA
993 @item AC_CANONICAL_HOST
994 @itemx AC_CHECK_TOOL
995 Automake will ensure that @file{config.guess} and @file{config.sub}
996 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
997 @samp{host_triplet} are introduced.  See both @ref{Canonicalizing, ,
998 Getting the Canonical System Type, autoconf, The Autoconf Manual}, and
999 @ref{Generic Programs, , Generic Program Checks, autoconf, The Autoconf
1000 Manual}.
1001 @c fixme xref autoconf docs.
1002 @cvindex AC_CANONICAL_HOST
1003 @cvindex AC_CHECK_TOOL
1004 @vindex host_alias
1005 @vindex host_triplet
1007 @item AC_CANONICAL_SYSTEM
1008 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
1009 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
1010 @xref{Canonicalizing, , Getting the Canonical System Type, autoconf, The
1011 Autoconf Manual}.
1012 @cvindex AC_CANONICAL_SYSTEM
1013 @vindex build_alias
1014 @vindex target_alias
1016 @item AC_FUNC_ALLOCA
1017 @itemx AC_FUNC_GETLOADAVG
1018 @itemx AC_FUNC_MEMCMP
1019 @itemx AC_STRUCT_ST_BLOCKS
1020 @itemx AC_FUNC_FNMATCH
1021 @itemx AC_FUNC_MKTIME
1022 @itemx AM_FUNC_STRTOD
1023 @itemx AC_REPLACE_FUNCS
1024 @itemx AC_REPLACE_GNU_GETOPT
1025 @itemx AM_WITH_REGEX
1026 Automake will ensure that the appropriate dependencies are generated for
1027 the objects corresponding to these macros.  Also, Automake will verify
1028 that the appropriate source files are part of the distribution.  Note
1029 that Automake does not come with any of the C sources required to use
1030 these macros, so @code{automake -a} will not install the sources.
1031 @xref{A Library}, for more information.  Also, see @ref{Particular
1032 Functions, , Particular Function Checks, autoconf, The Autoconf Manual}.
1033 @cvindex AC_FUNC_ALLOCA
1034 @cvindex AC_FUNC_GETLOADAVG
1035 @cvindex AC_FUNC_MEMCMP
1036 @cvindex AC_STRUCT_ST_BLOCKS
1037 @cvindex AC_FUNC_FNMATCH
1038 @cvindex AC_FUNC_FNMATCH
1039 @cvindex AC_REPLACE_FUNCS
1040 @cvindex AC_REPLACE_GNU_GETOPT
1041 @cvindex AM_FUNC_STRTOD
1042 @cvindex AM_WITH_REGEX
1043 @cvindex AC_FUNC_MKTIME
1045 @item LIBOBJS
1046 Automake will detect statements which put @file{.o} files into
1047 @code{LIBOBJS}, and will treat these additional files as if they were
1048 discovered via @code{AC_REPLACE_FUNCS}.  @xref{Generic Functions, ,
1049 Generic Function Checks, autoconf, The Autoconf Manual}.
1050 @cvindex LIBOBJS
1052 @item AC_PROG_RANLIB
1053 This is required if any libraries are built in the package.
1054 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1055 Autoconf Manual}.
1056 @cvindex AC_PROG_RANLIB
1058 @item AC_PROG_CXX
1059 This is required if any C++ source is included.  @xref{Particular
1060 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1061 @cvindex AC_PROG_CXX
1063 @item AC_PROG_F77
1064 This is required if any Fortran 77 source is included.  This macro is
1065 distributed with Autoconf version 2.13 and later.  @xref{Particular
1066 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1067 @cvindex AC_PROG_F77
1069 @item AC_F77_LIBRARY_LDFLAGS
1070 This is required for programs and shared libraries that are a mixture of
1071 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1072 C++}).  @xref{Macros, , Autoconf macros supplied with Automake}.
1073 @cvindex AC_F77_LIBRARY_LDFLAGS
1075 @item AC_PROG_LIBTOOL
1076 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1077 Introduction, libtool, The Libtool Manual}).
1078 @cvindex AC_PROG_LIBTOOL
1080 @item AC_PROG_YACC
1081 If a Yacc source file is seen, then you must either use this macro or
1082 define the variable @samp{YACC} in @file{configure.in}.  The former is
1083 preferred (@pxref{Particular Programs, , Particular Program Checks,
1084 autoconf, The Autoconf Manual}).
1085 @cvindex AC_PROG_YACC
1086 @cvindex YACC
1088 @item AC_DECL_YYTEXT
1089 This macro is required if there is Lex source in the package.
1090 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1091 Autoconf Manual}.
1092 @cvindex AC_DECL_YYTEXT
1094 @item AC_PROG_LEX
1095 If a Lex source file is seen, then this macro must be used.
1096 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1097 Autoconf Manual}.
1098 @cvindex AC_PROG_LEX
1100 @item ALL_LINGUAS
1101 If Automake sees that this variable is set in @file{configure.in}, it
1102 will check the @file{po} directory to ensure that all the named
1103 @samp{.po} files exist, and that all the @samp{.po} files that exist are
1104 named.
1105 @cvindex ALL_LINGUAS
1107 @item AM_C_PROTOTYPES
1108 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1109 @cvindex AM_C_PROTOTYPES
1111 @item AM_GNU_GETTEXT
1112 This macro is required for packages which use GNU gettext
1113 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
1114 this macro it ensures that the package meets some of gettext's
1115 requirements.
1116 @cvindex AM_GNU_GETTEXT
1118 @item AM_MAINTAINER_MODE
1119 @opindex --enable-maintainer-mode
1120 This macro adds a @samp{--enable-maintainer-mode} option to
1121 @code{configure}.  If this is used, @code{automake} will cause
1122 @samp{maintainer-only} rules to be turned off by default in the
1123 generated @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits}
1124 mode (@pxref{Gnits}).  This macro defines the @samp{MAINTAINER_MODE}
1125 conditional, which you can use in your own @file{Makefile.am}.
1126 @cvindex AM_MAINTAINER_MODE
1128 @item AC_SUBST
1129 @itemx AC_CHECK_TOOL
1130 @itemx AC_CHECK_PROG
1131 @itemx AC_CHECK_PROGS
1132 @itemx AC_PATH_PROG
1133 @itemx AC_PATH_PROGS
1134 For each of these macros, the first argument is automatically defined as
1135 a variable in each generated @file{Makefile.in}.  @xref{Setting Output
1136 Variables, , Setting Output Variables, autoconf, The Autoconf Manual},
1137 and @ref{Generic Programs, , Generic Program Checks, autoconf, The
1138 Autoconf Manual}.
1139 @cvindex AC_SUBST
1140 @cvindex AC_CHECK_TOOL
1141 @cvindex AC_CHECK_PROG
1142 @cvindex AC_CHECK_PROGS
1143 @cvindex AC_PATH_PROG
1144 @cvindex AC_PATH_PROGS
1146 @end table
1149 @node Invoking aclocal, Macros, Optional, configure
1150 @section Auto-generating aclocal.m4
1152 @cindex Invoking aclocal
1153 @cindex aclocal, Invoking
1155 Automake includes a number of Autoconf macros which can be used in your
1156 package; some of them are actually required by Automake in certain
1157 situations.  These macros must be defined in your @file{aclocal.m4};
1158 otherwise they will not be seen by @code{autoconf}.
1160 The @code{aclocal} program will automatically generate @file{aclocal.m4}
1161 files based on the contents of @file{configure.in}.  This provides a
1162 convenient way to get Automake-provided macros, without having to
1163 search around.  Also, the @code{aclocal} mechanism is extensible for use
1164 by other packages.
1166 At startup, @code{aclocal} scans all the @file{.m4} files it can find,
1167 looking for macro definitions.  Then it scans @file{configure.in}.  Any
1168 mention of one of the macros found in the first step causes that macro,
1169 and any macros it in turn requires, to be put into @file{aclocal.m4}.
1171 The contents of @file{acinclude.m4}, if it exists, are also
1172 automatically included in @file{aclocal.m4}.  This is useful for
1173 incorporating local macros into @file{configure}.
1175 @code{aclocal} tries to be smart about looking for new @code{AC_DEFUN}s
1176 in the files it scans.  It will warn if it finds duplicates.  It also
1177 tries to copy the full text of the scanned file into @file{aclocal.m4},
1178 including both @samp{#} and @samp{dnl} comments.  If you want to make a
1179 comment which will be completely ignored by @code{aclocal}, use
1180 @samp{##} as the comment leader.
1182 @code{aclocal} accepts the following options:
1184 @table @code
1185 @item --acdir=@var{dir}
1186 @opindex --acdir
1187 Look for the macro files in @var{dir} instead of the installation
1188 directory.  This is typically used for debugging.
1190 @item --help
1191 @opindex --help
1192 Print a summary of the command line options and exit.
1194 @item -I @var{dir}
1195 @opindex -I
1196 Add the directory @var{dir} to the list of directories searched for
1197 @file{.m4} files.
1199 @item --output=@var{file}
1200 @opindex --output
1201 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1203 @item --print-ac-dir
1204 @opindex --print-ac-dir
1205 Prints the name of the directory which @code{aclocal} will search to
1206 find the @file{.m4} files.  When this option is given, normal processing
1207 is suppressed.  This option can be used by a package to determine where
1208 to install a macro file.
1210 @item --verbose
1211 @opindex --verbose
1212 Print the names of the files it examines.
1214 @item --version
1215 @opindex --version
1216 Print the version number of Automake and exit.
1217 @end table
1220 @node Macros, Extending aclocal, Invoking aclocal, configure
1221 @section Autoconf macros supplied with Automake
1223 @c consider generating this node automatically from m4 files.
1225 @table @code
1226 @item AM_CONFIG_HEADER
1227 Automake will generate rules to automatically regenerate the config
1228 header.  If you do use this macro, you must create the file
1229 @file{stamp-h.in} in your source directory.  It can be empty.
1230 @cvindex AM_CONFIG_HEADER
1232 @item AM_ENABLE_MULTILIB
1233 This is used when a ``multilib'' library is being built.  A
1234 @dfn{multilib} library is one that is built multiple times, once per
1235 target flag combination.  This is only useful when the library is
1236 intended to be cross-compiled.  The first optional argument is the name
1237 of the @file{Makefile} being generated; it defaults to @samp{Makefile}.
1238 The second option argument is used to find the top source directory; it
1239 defaults to the empty string (generally this should not be used unless
1240 you are familiar with the internals).
1242 @item AM_FUNC_STRTOD
1243 If the @code{strtod} function is not available, or does not work
1244 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
1245 variable @code{LIBOBJS}.
1246 @cvindex AM_FUNC_STRTOD
1248 @item AM_FUNC_ERROR_AT_LINE
1249 If the function @code{error_at_line} is not found, then add
1250 @file{error.o} to @code{LIBOBJS}.
1251 @cvindex AM_FUNC_ERROR_AT_LINE
1253 @item AM_FUNC_OBSTACK
1254 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
1255 @samp{LIBOBJS}.
1256 @cvindex AM_FUNC_OBSTACK
1258 @item AM_C_PROTOTYPES
1259 Check to see if function prototypes are understood by the compiler.  If
1260 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1261 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
1262 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
1263 values to implement automatic de-ANSI-fication.
1264 @cvindex AM_C_PROTOTYPES
1266 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1267 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1268 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
1269 found in @file{<termios.h>}.
1270 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1272 @item AM_INIT_AUTOMAKE
1273 Runs many macros that most @file{configure.in}'s need.  This macro has
1274 two required arguments, the package and the version number.  By default
1275 this macro @code{AC_DEFINE}'s @samp{PACKAGE} and @samp{VERSION}.  This
1276 can be avoided by passing in a non-empty third argument.
1278 @item AM_PATH_LISPDIR
1279 Searches for the program @code{emacs}, and, if found, sets the output
1280 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1281 @cvindex AM_PATH_LISPDIR
1283 @item AM_PROG_CC_STDC
1284 If the C compiler in not in ANSI C mode by default, try to add an option
1285 to output variable @code{CC} to make it so.  This macro tries various
1286 options that select ANSI C on some system or another.  It considers the
1287 compiler to be in ANSI C mode if it handles function prototypes correctly.
1289 If you use this macro, you should check after calling it whether the C
1290 compiler has been set to accept ANSI C; if not, the shell variable
1291 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
1292 code in ANSI C, you can make an un-ANSIfied copy of it by using the
1293 @code{ansi2knr} option (@pxref{ANSI}).
1295 @item AM_PROG_LEX
1296 @cindex HP-UX 10, lex problems
1297 @cindex lex problems with HP-UX 10
1298 Like @code{AC_PROG_LEX} with @code{AC_DECL_YYTEXT} (@pxref{Particular
1299 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}),
1300 but uses the @code{missing} script on systems that do not have
1301 @code{lex}.  @samp{HP-UX 10} is one such system.
1303 @item AM_PROG_GCJ
1304 This macro finds the @code{gcj} program or causes an error.  It sets
1305 @samp{GCJ} and @samp{GCJFLAGS}.  @code{gcj} is the Java front-end to the
1306 GNU C compiler.
1307 @cvindex AM_PROG_GCJ
1309 @item AM_SANITY_CHECK
1310 This checks to make sure that a file created in the build directory is
1311 newer than a file in the source directory.  This can fail on systems
1312 where the clock is set incorrectly.  This macro is automatically run
1313 from @code{AM_INIT_AUTOMAKE}.
1315 @item AM_SYS_POSIX_TERMIOS
1316 @cvindex am_cv_sys_posix_termios
1317 @cindex POSIX termios headers
1318 @cindex termios POSIX headers
1319 Check to see if POSIX termios headers and functions are available on the
1320 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1321 @samp{yes}.  If not, set the variable to @samp{no}.
1323 @item AM_TYPE_PTRDIFF_T
1324 @cvindex HAVE_PTRDIFF_T
1325 @vindex ptrdiff_t
1326 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
1327 @file{<stddef.h>}.
1329 @item AM_WITH_DMALLOC
1330 @cvindex WITH_DMALLOC
1331 @cindex dmalloc, support for
1332 @opindex --with-dmalloc
1333 Add support for the
1334 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1335 package.  If the user configures with @samp{--with-dmalloc}, then define
1336 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1338 @item AM_WITH_REGEX
1339 @cvindex WITH_REGEX
1340 @opindex --with-regex
1341 @cindex regex package
1342 @cindex rx package
1343 Adds @samp{--with-regex} to the @code{configure} command line.  If
1344 specified (the default), then the @samp{regex} regular expression
1345 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1346 @samp{WITH_REGEX} is defined..  If @samp{--without-regex} is given, then
1347 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1348 into @samp{LIBOBJS}.
1350 @end table
1353 @node Extending aclocal,  , Macros, configure
1354 @section Writing your own aclocal macros
1356 @cindex aclocal, extending
1357 @cindex Extending aclocal
1359 The @code{aclocal} program doesn't have any built-in knowledge of any
1360 macros, so it is easy to extend it with your own macros.
1362 This is mostly used for libraries which want to supply their own
1363 Autoconf macros for use by other programs.  For instance the
1364 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1365 should be used by any package using @code{gettext}.  When the library is
1366 installed, it installs this macro so that @code{aclocal} will find it.
1368 A file of macros should be a series of @code{AC_DEFUN}'s.  The
1369 @code{aclocal} programs also understands @code{AC_REQUIRE}, so it is
1370 safe to put each macro in a separate file.  @xref{Prerequisite Macros, ,
1371 , autoconf, The Autoconf Manual}, and @ref{Macro Definitions, , ,
1372 autoconf, The Autoconf Manual}.
1374 A macro file's name should end in @file{.m4}.  Such files should be
1375 installed in @file{$(datadir)/aclocal}.
1378 @node Top level, Programs, configure, Top
1379 @chapter The top-level @file{Makefile.am}
1381 @cindex SUBDIRS, explained
1383 In non-flat packages, the top level @file{Makefile.am} must tell
1384 Automake which subdirectories are to be built.  This is done via the
1385 @code{SUBDIRS} variable.
1386 @vindex SUBDIRS
1388 The @code{SUBDIRS} macro holds a list of subdirectories in which
1389 building of various sorts can occur.  Many targets (e.g. @code{all}) in
1390 the generated @file{Makefile} will run both locally and in all specified
1391 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1392 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1393 (after configuration).  This allows inclusion of libraries from packages
1394 which do not use Automake (such as @code{gettext}).  The directories
1395 mentioned in @code{SUBDIRS} must be direct children of the current
1396 directory.  For instance, you cannot put @samp{src/subdir} into
1397 @code{SUBDIRS}.
1399 In a deep package, the top-level @file{Makefile.am} is often very short.
1400 For instance, here is the @file{Makefile.am} from the GNU Hello
1401 distribution:
1403 @example
1404 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1405 SUBDIRS = doc intl po src tests
1406 @end example
1408 @cindex SUBDIRS, overriding
1409 @cindex Overriding SUBDIRS
1411 It is possible to override the @code{SUBDIRS} variable if, like in the
1412 case of GNU @code{Inetutils}, you want to only build a subset of the
1413 entire package.  In your @file{Makefile.am} include:
1415 @example
1416 SUBDIRS = @@MY_SUBDIRS@@
1417 @end example
1419 Then in your @file{configure.in} you can specify:
1421 @example
1422 MY_SUBDIRS = "src doc lib po"
1423 AC_SUBST(MY_SUBDIRS)
1424 @end example
1426 (Note that we don't use the variable name @code{SUBDIRS} in our
1427 @file{configure.in}; that would cause Automake to believe that every
1428 @file{Makefile.in} should recurse into the listed subdirectories.)
1430 The upshot of this is that Automake is tricked into building the package
1431 to take the subdirs, but doesn't actually bind that list until
1432 @code{configure} is run.
1434 Although the @code{SUBDIRS} macro can contain configure substitutions
1435 (e.g. @samp{@@DIRS@@}); Automake itself does not actually examine the
1436 contents of this variable.
1438 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1439 @code{AC_PROG_MAKE_SET}.
1441 The use of @code{SUBDIRS} is not restricted to just the top-level
1442 @file{Makefile.am}.  Automake can be used to construct packages of
1443 arbitrary depth.
1445 By default, Automake generates @file{Makefiles} which work depth-first
1446 (@samp{postfix}).  However, it is possible to change this ordering.  You
1447 can do this by putting @samp{.} into @code{SUBDIRS}.  For instance,
1448 putting @samp{.}  first will cause a @samp{prefix} ordering of
1449 directories.
1451 Sometimes, such as when running @code{make dist}, you want all possible
1452 subdirectories to be examined.  In this case Automake will use
1453 @code{DIST_SUBDIRS}, instead of @code{SUBDIRS}, to determine where to
1454 recurse.  This variable will also be used when the user runs
1455 @code{distclean} or @code{maintainer-clean}.  It should be set to the
1456 full list of subdirectories in the project.  If this macro is not set,
1457 Automake will attempt to set it for you.
1460 @node Programs, Other objects, Top level, Top
1461 @chapter Building Programs and Libraries
1463 A large part of Automake's functionality is dedicated to making it easy
1464 to build programs and libraries.
1466 @menu
1467 * A Program::                   Building a program
1468 * A Library::                   Building a library
1469 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1470 * A Shared Library::            Building a Libtool library
1471 * Program variables::           Variables used when building a program
1472 * Yacc and Lex::                Yacc and Lex support
1473 * C++ Support::
1474 * Fortran 77 Support::
1475 * Java Support::
1476 * Support for Other Languages::
1477 * ANSI::                        Automatic de-ANSI-fication
1478 * Dependencies::                Automatic dependency tracking
1479 @end menu
1482 @node A Program, A Library, Programs, Programs
1483 @section Building a program
1485 @cindex PROGRAMS, bindir
1486 @vindex bin_PROGRAMS
1487 @vindex sbin_PROGRAMS
1488 @vindex libexec_PROGRAMS
1489 @vindex pkglib_PROGRAMS
1490 @vindex noinst_PROGRAMS
1492 In a directory containing source that gets built into a program (as
1493 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1494 can be installed in @code{bindir}, @code{sbindir}, @code{libexecdir},
1495 @code{pkglibdir}, or not at all (@samp{noinst}).
1497 For instance:
1499 @example
1500 bin_PROGRAMS = hello
1501 @end example
1503 In this simple case, the resulting @file{Makefile.in} will contain code
1504 to generate a program named @code{hello}.  The variable
1505 @code{hello_SOURCES} is used to specify which source files get built
1506 into an executable:
1508 @example
1509 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
1510 @end example
1512 This causes each mentioned @samp{.c} file to be compiled into the
1513 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1515 @cindex _SOURCES primary, defined
1516 @cindex SOURCES primary, defined
1517 @cindex Primary variable, SOURCES
1519 If @samp{@var{prog}_SOURCES} is needed, but not specified, then it
1520 defaults to the single file @file{prog.c}.
1521 @vindex _SOURCES
1522 @vindex SOURCES
1524 Multiple programs can be built in a single directory.  Multiple programs
1525 can share a single source file, which must be listed in each
1526 @samp{_SOURCES} definition.
1528 @cindex Header files in _SOURCES
1529 @cindex _SOURCES and header files
1531 Header files listed in a @samp{_SOURCES} definition will be included in
1532 the distribution but otherwise ignored.  In case it isn't obvious, you
1533 should not include the header file generated by @file{configure} in an
1534 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1535 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1536 and Lex}.
1538 @cindex EXTRA_prog_SOURCES, defined
1540 Automake must know all the source files that could possibly go into a
1541 program, even if not all the files are built in every circumstance.
1542 Any files which are only conditionally built should be listed in the
1543 appropriate @samp{EXTRA_} variable.  For instance, if
1544 @file{hello-linux.c} were conditionally included in @code{hello}, the
1545 @file{Makefile.am} would contain:
1547 @example
1548 EXTRA_hello_SOURCES = hello-linux.c
1549 @end example
1551 Similarly, sometimes it is useful to determine the programs that are to
1552 be built at configure time.  For instance, GNU @code{cpio} only builds
1553 @code{mt} and @code{rmt} under special circumstances.
1555 @cindex EXTRA_PROGRAMS, defined
1557 In this case, you must notify Automake of all the programs that can
1558 possibly be built, but at the same time cause the generated
1559 @file{Makefile.in} to use the programs specified by @code{configure}.
1560 This is done by having @code{configure} substitute values into each
1561 @samp{_PROGRAMS} definition, while listing all optionally built programs
1562 in @code{EXTRA_PROGRAMS}.
1563 @vindex EXTRA_PROGRAMS
1565 If you need to link against libraries that are not found by
1566 @code{configure}, you can use @code{LDADD} to do so.  This variable
1567 actually can be used to add any options to the linker command line.
1568 @vindex LDADD
1570 @cindex prog_LDADD, defined
1572 Sometimes, multiple programs are built in one directory but do not share
1573 the same link-time requirements.  In this case, you can use the
1574 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1575 program as it appears in some @samp{_PROGRAMS} variable, and usually
1576 written in lowercase) to override the global @code{LDADD}.  If this
1577 variable exists for a given program, then that program is not linked
1578 using @code{LDADD}.
1579 @vindex _LDADD
1581 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
1582 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1583 built in the same directory, and has no such link requirement.  Also,
1584 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1585 is what cpio's @file{src/Makefile.am} looks like (abridged):
1587 @example
1588 bin_PROGRAMS = cpio pax @@MT@@
1589 libexec_PROGRAMS = @@RMT@@
1590 EXTRA_PROGRAMS = mt rmt
1592 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1593 rmt_LDADD =
1595 cpio_SOURCES = @dots{}
1596 pax_SOURCES = @dots{}
1597 mt_SOURCES = @dots{}
1598 rmt_SOURCES = @dots{}
1599 @end example
1601 @cindex _LDFLAGS, defined
1603 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
1604 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
1605 @samp{-dlpreopen}).  So, use the @samp{@var{prog}_LDFLAGS} variable for
1606 this purpose.
1607 @vindex _LDFLAGS
1609 @cindex _DEPENDENCIES, defined
1611 It is also occasionally useful to have a program depend on some other
1612 target which is not actually part of that program.  This can be done
1613 using the @samp{@var{prog}_DEPENDENCIES} variable.  Each program depends
1614 on the contents of such a variable, but no further interpretation is
1615 done.
1617 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
1618 Automake.  The automatically-assigned value is the contents of
1619 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
1620 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed.  The
1621 configure substitutions that are left in are only @samp{@@LIBOBJS@@} and
1622 @samp{@@ALLOCA@@}; these are left because it is known that they will not
1623 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
1624 generated.
1627 @node A Library, LIBOBJS, A Program, Programs
1628 @section Building a library
1630 @cindex _LIBRARIES primary, defined
1631 @cindex LIBRARIES primary, defined
1632 @cindex Primary variable, LIBRARIES
1634 @vindex lib_LIBRARIES
1635 @vindex pkglib_LIBRARIES
1636 @vindex noinst_LIBRARIES
1638 Building a library is much like building a program.  In this case, the
1639 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1640 @code{libdir} or @code{pkglibdir}.
1642 @xref{A Shared Library}, for information on how to build shared
1643 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1645 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1646 For instance to create a library named @file{libcpio.a}, but not install
1647 it, you would write:
1649 @example
1650 noinst_LIBRARIES = libcpio.a
1651 @end example
1653 The sources that go into a library are determined exactly as they are
1654 for programs, via the @samp{_SOURCES} variables.  Note that the library
1655 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1656 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1657 not @samp{liblob.a_SOURCES}.
1659 @cindex _LIBADD primary, defined
1660 @cindex LIBADD primary, defined
1661 @cindex Primary variable, LIBADD
1663 Extra objects can be added to a library using the
1664 @samp{@var{library}_LIBADD} variable.  This should be used for objects
1665 determined by @code{configure}.  Again from @code{cpio}:
1666 @vindex _LIBADD
1667 @vindex LIBADD
1669 @example
1670 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1671 @end example
1673 In addition, sources for extra objects that will not exist until
1674 configure-time must be added to the @code{BUILT_SOURCES} variable
1675 (@pxref{Sources}).
1678 @node LIBOBJS, A Shared Library, A Library, Programs
1679 @section Special handling for LIBOBJS and ALLOCA
1681 @cindex @@LIBOBJS@@, special handling
1682 @cindex @@ALLOCA@@, special handling
1684 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1685 @code{@@ALLOCA@@}, and uses this information, plus the list of
1686 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1687 include the appropriate source files in the distribution (@pxref{Dist}).
1688 These source files are also automatically handled in the
1689 dependency-tracking scheme; see @xref{Dependencies}.
1691 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1692 @samp{_LDADD} or @samp{_LIBADD} variable.
1695 @node A Shared Library, Program variables, LIBOBJS, Programs
1696 @section Building a Shared Library
1698 @cindex Shared libraries, support for
1700 Building shared libraries is a relatively complex matter.  For this
1701 reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
1702 Libtool Manual}) was created to help build shared libraries in a
1703 platform-independent way.
1705 @cindex _LTLIBRARIES primary, defined
1706 @cindex LTLIBRARIES primary, defined
1707 @cindex Primary variable, LTLIBRARIES
1708 @cindex Example of shared libraries
1710 @cindex suffix .la, defined
1712 Automake uses Libtool to build libraries declared with the
1713 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1714 of shared libraries to build.  For instance, to create a library named
1715 @file{libgettext.a} and its corresponding shared libraries, and install
1716 them in @samp{libdir}, write:
1718 @example
1719 lib_LTLIBRARIES = libgettext.la
1720 @end example
1722 @vindex lib_LTLIBRARIES
1723 @vindex pkglib_LTLIBRARIES
1724 @vindex noinst_LTLIBRARIES
1725 @vindex check_LTLIBRARIES
1727 @cindex check_LTLIBRARIES, not allowed
1729 Note that shared libraries @emph{must} be installed, so
1730 @code{check_LTLIBRARIES} is not allowed.  However,
1731 @code{noinst_LTLIBRARIES} is allowed.  This feature should be used for
1732 libtool ``convenience libraries''.
1734 @cindex suffix .lo, defined
1736 For each library, the @samp{@var{library}_LIBADD} variable contains the
1737 names of extra libtool objects (@file{.lo} files) to add to the shared
1738 library.  The @samp{@var{library}_LDFLAGS} variable contains any
1739 additional libtool flags, such as @samp{-version-info} or
1740 @samp{-static}.
1742 @cindex @@LTLIBOBJS@@, special handling
1744 Where an ordinary library might include @code{@@LIBOBJS@@}, a libtool
1745 library must use @code{@@LTLIBOBJS@@}.  This is required because the
1746 object files that libtool operates on do not necessarily end in
1747 @file{.o}.  The libtool manual contains more details on this topic.
1749 For libraries installed in some directory, Automake will automatically
1750 supply the appropriate @samp{-rpath} option.  However, for libraries
1751 determined at configure time (and thus mentioned in
1752 @code{EXTRA_LTLIBRARIES}), Automake does not know the eventual
1753 installation directory; for such libraries you must add the
1754 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
1755 hand.
1757 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1758 libtool, The Libtool Manual}, for more information.
1761 @node Program variables, Yacc and Lex, A Shared Library, Programs
1762 @section Variables used when building a program
1764 Occasionally it is useful to know which @file{Makefile} variables
1765 Automake uses for compilations; for instance you might need to do your
1766 own compilation in some special cases.
1768 Some variables are inherited from Autoconf; these are @code{CC},
1769 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1770 @code{LIBS}.
1771 @vindex LDFLAGS
1773 There are some additional variables which Automake itself defines:
1775 @vtable @code
1776 @item INCLUDES
1777 A list of @samp{-I} options.  This can be set in your @file{Makefile.am}
1778 if you have special directories you want to look in.  Automake already
1779 provides some @samp{-I} options automatically.  In particular it
1780 generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I} pointing to
1781 the directory holding @file{config.h} (if you've used
1782 @code{AC_CONFIG_HEADER} or @code{AM_CONFIG_HEADER}).  You can disable
1783 the default @samp{-I} options using the @samp{nostdinc} option.
1785 @code{INCLUDES} can actually be used for other @code{cpp} options
1786 besides @samp{-I}.  For instance, it is sometimes used to pass arbitrary
1787 @samp{-D} options to the compiler.
1789 @item COMPILE
1790 This is the command used to actually compile a C source file.  The
1791 filename is appended to form the complete command line.
1793 @item LINK
1794 This is the command used to actually link a C program.
1795 @end vtable
1798 @node Yacc and Lex, C++ Support, Program variables, Programs
1799 @section Yacc and Lex support
1801 Automake has somewhat idiosyncratic support for Yacc and Lex.
1803 Automake assumes that the @file{.c} file generated by @code{yacc} (or
1804 @code{lex}) should be named using the basename of the input file.  That
1805 is, for a yacc source file @file{foo.y}, Automake will cause the
1806 intermediate file to be named @file{foo.c} (as opposed to
1807 @file{y.tab.c}, which is more traditional).
1809 The extension of a yacc source file is used to determine the extension
1810 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
1811 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1812 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1813 @samp{.cxx}.
1815 Likewise, lex source files can be used to generate @samp{C} or
1816 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
1817 @samp{.lxx} are recognized.
1819 You should never explicitly mention the intermediate (@samp{C} or
1820 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1821 file.
1823 The intermediate files generated by @code{yacc} (or @code{lex}) will be
1824 included in any distribution that is made.  That way the user doesn't
1825 need to have @code{yacc} or @code{lex}.
1827 If a @code{yacc} source file is seen, then your @file{configure.in} must
1828 define the variable @samp{YACC}.  This is most easily done by invoking
1829 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
1830 Program Checks, autoconf, The Autoconf Manual}).
1832 Similarly, if a @code{lex} source file is seen, then your
1833 @file{configure.in} must define the variable @samp{LEX}.  You can use
1834 @samp{AC_PROG_LEX} to do this (@pxref{Particular Programs, , Particular
1835 Program Checks, autoconf, The Autoconf Manual}).  Automake's @code{lex}
1836 support also requires that you use the @samp{AC_DECL_YYTEXT}
1837 macro---automake needs to know the value of @samp{LEX_OUTPUT_ROOT}.
1838 This is all handled for you if you use the @code{AM_PROG_LEX} macro
1839 (@pxref{Macros}).
1841 @cindex ylwrap
1842 @cindex yacc, multiple parsers
1843 @cindex Multiple yacc parsers
1844 @cindex Multiple lex lexers
1845 @cindex lex, multiple lexers
1848 Automake makes it possible to include multiple @code{yacc} (or
1849 @code{lex}) source files in a single program.  Automake uses a small
1850 program called @code{ylwrap} to run @code{yacc} (or @code{lex}) in a
1851 subdirectory.  This is necessary because yacc's output filename is
1852 fixed, and a parallel make could conceivably invoke more than one
1853 instance of @code{yacc} simultaneously.  The @code{ylwrap} program is
1854 distributed with Automake.  It should appear in the directory specified
1855 by @samp{AC_CONFIG_AUX_DIR} (@pxref{Input, , Finding `configure' Input,
1856 autoconf, The Autoconf Manual}), or the current directory if that macro
1857 is not used in @file{configure.in}.
1859 For @code{yacc}, simply managing locking is insufficient.  The output of
1860 @code{yacc} always uses the same symbol names internally, so it isn't
1861 possible to link two @code{yacc} parsers into the same executable.
1863 We recommend using the following renaming hack used in @code{gdb}:
1864 @example
1865 #define yymaxdepth c_maxdepth
1866 #define yyparse c_parse
1867 #define yylex   c_lex
1868 #define yyerror c_error
1869 #define yylval  c_lval
1870 #define yychar  c_char
1871 #define yydebug c_debug
1872 #define yypact  c_pact
1873 #define yyr1    c_r1
1874 #define yyr2    c_r2
1875 #define yydef   c_def
1876 #define yychk   c_chk
1877 #define yypgo   c_pgo
1878 #define yyact   c_act
1879 #define yyexca  c_exca
1880 #define yyerrflag c_errflag
1881 #define yynerrs c_nerrs
1882 #define yyps    c_ps
1883 #define yypv    c_pv
1884 #define yys     c_s
1885 #define yy_yys  c_yys
1886 #define yystate c_state
1887 #define yytmp   c_tmp
1888 #define yyv     c_v
1889 #define yy_yyv  c_yyv
1890 #define yyval   c_val
1891 #define yylloc  c_lloc
1892 #define yyreds  c_reds
1893 #define yytoks  c_toks
1894 #define yylhs   c_yylhs
1895 #define yylen   c_yylen
1896 #define yydefred c_yydefred
1897 #define yydgoto c_yydgoto
1898 #define yysindex c_yysindex
1899 #define yyrindex c_yyrindex
1900 #define yygindex c_yygindex
1901 #define yytable  c_yytable
1902 #define yycheck  c_yycheck
1903 #define yyname   c_yyname
1904 #define yyrule   c_yyrule
1905 @end example
1907 For each define, replace the @samp{c_} prefix with whatever you like.
1908 These defines work for @code{bison}, @code{byacc}, and traditional
1909 @code{yacc}s.  If you find a parser generator that uses a symbol not
1910 covered here, please report the new name so it can be added to the list.
1913 @node C++ Support, Fortran 77 Support, Yacc and Lex, Programs
1914 @section C++ Support
1916 @cindex C++ support
1917 @cindex Support for C++
1919 Automake includes full support for C++.
1921 Any package including C++ code must define the output variable
1922 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
1923 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
1924 Program Checks, autoconf, The Autoconf Manual}).
1926 A few additional variables are defined when a C++ source file is seen:
1928 @vtable @code
1929 @item CXX
1930 The name of the C++ compiler.
1932 @item CXXFLAGS
1933 Any flags to pass to the C++ compiler.
1935 @item CXXCOMPILE
1936 The command used to actually compile a C++ source file.  The file name
1937 is appended to form the complete command line.
1939 @item CXXLINK
1940 The command used to actually link a C++ program.
1941 @end vtable
1944 @node Fortran 77 Support, Java Support, C++ Support, Programs
1945 @comment  node-name,  next,  previous,  up
1946 @section Fortran 77 Support
1948 @cindex Fortran 77 support
1949 @cindex Support for Fortran 77
1951 Automake includes full support for Fortran 77.
1953 Any package including Fortran 77 code must define the output variable
1954 @samp{F77} in @file{configure.in}; the simplest way to do this is to use
1955 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
1956 Program Checks, autoconf, The Autoconf Manual}).  @xref{Fortran 77 and
1957 Autoconf}.
1959 A few additional variables are defined when a Fortran 77 source file is
1960 seen:
1962 @vtable @code
1964 @item F77
1965 The name of the Fortran 77 compiler.
1967 @item FFLAGS
1968 Any flags to pass to the Fortran 77 compiler.
1970 @item RFLAGS
1971 Any flags to pass to the Ratfor compiler.
1973 @item F77COMPILE
1974 The command used to actually compile a Fortran 77 source file.  The file
1975 name is appended to form the complete command line.
1977 @item FLINK
1978 The command used to actually link a pure Fortran 77 program or shared
1979 library.
1981 @end vtable
1983 Automake can handle preprocessing Fortran 77 and Ratfor source files in
1984 addition to compiling them@footnote{Much, if not most, of the
1985 information in the following sections pertaining to preprocessing
1986 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
1987 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}.  Automake
1988 also contains some support for creating programs and shared libraries
1989 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
1990 Fortran 77 With C and C++}).
1992 These issues are covered in the following sections.
1994 @menu
1995 * Preprocessing Fortran 77::
1996 * Compiling Fortran 77 Files::
1997 * Mixing Fortran 77 With C and C++::
1998 * Fortran 77 and Autoconf::
1999 @end menu
2002 @node Preprocessing Fortran 77, Compiling Fortran 77 Files, Fortran 77 Support, Fortran 77 Support
2003 @comment  node-name,  next,  previous,  up
2004 @subsection Preprocessing Fortran 77
2006 @cindex Preprocessing Fortran 77
2007 @cindex Fortran 77, Preprocessing
2008 @cindex Ratfor programs
2010 @file{N.f} is made automatically from @file{N.F} or @file{N.r}.  This
2011 rule runs just the preprocessor to convert a preprocessable Fortran 77
2012 or Ratfor source file into a strict Fortran 77 source file.  The precise
2013 command used is as follows:
2015 @table @file
2017 @item .F
2018 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2020 @item .r
2021 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2023 @end table
2026 @node Compiling Fortran 77 Files, Mixing Fortran 77 With C and C++, Preprocessing Fortran 77, Fortran 77 Support
2027 @comment  node-name,  next,  previous,  up
2028 @subsection Compiling Fortran 77 Files
2030 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
2031 @file{N.r} by running the Fortran 77 compiler.  The precise command used
2032 is as follows:
2034 @table @file
2036 @item .f
2037 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
2039 @item .F
2040 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2042 @item .r
2043 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2045 @end table
2048 @node Mixing Fortran 77 With C and C++, Fortran 77 and Autoconf, Compiling Fortran 77 Files, Fortran 77 Support
2049 @comment  node-name,  next,  previous,  up
2050 @subsection Mixing Fortran 77 With C and C++
2052 @cindex Fortran 77, mixing with C and C++
2053 @cindex Mixing Fortran 77 with C and C++
2054 @cindex Linking Fortran 77 with C and C++
2055 @cindex cfortran
2056 @cindex Mixing Fortran 77 with C and/or C++
2058 Automake currently provides @emph{limited} support for creating programs
2059 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
2060 However, there are many other issues related to mixing Fortran 77 with
2061 other languages that are @emph{not} (currently) handled by Automake, but
2062 that are handled by other packages@footnote{For example,
2063 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
2064 addresses all of these inter-language issues, and runs under nearly all
2065 Fortran 77, C and C++ compilers on nearly all platforms.  However,
2066 @code{cfortran} is not yet Free Software, but it will be in the next
2067 major release.}.
2069 @page
2070 Automake can help in two ways:
2072 @enumerate
2073 @item
2074 Automatic selection of the linker depending on which combinations of
2075 source code.
2077 @item
2078 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
2079 @samp{-l}) to pass to the automatically selected linker in order to link
2080 in the appropriate Fortran 77 intrinsic and run-time libraries.
2082 @cindex FLIBS, defined
2083 These extra Fortran 77 linker flags are supplied in the output variable
2084 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
2085 supplied with newer versions of Autoconf (Autoconf version 2.13 and
2086 later).  @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
2087 Autoconf}.
2088 @end enumerate
2090 If Automake detects that a program or shared library (as mentioned in
2091 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
2092 code that is a mixture of Fortran 77 and C and/or C++, then it requires
2093 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
2094 @file{configure.in}, and that either @code{$(FLIBS)} or @code{@@FLIBS@@}
2095 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
2096 (for shared libraries) variables.  It is the responsibility of the
2097 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
2098 or @code{@@FLIBS@@} appears in the appropriate @code{_LDADD} or
2099 @code{_LIBADD} variable.
2101 @cindex Mixed language example
2102 @cindex Example, mixed language
2104 For example, consider the following @file{Makefile.am}:
2106 @example
2107 bin_PROGRAMS = foo
2108 foo_SOURCES  = main.cc foo.f
2109 foo_LDADD    = libfoo.la @@FLIBS@@
2111 pkglib_LTLIBRARIES = libfoo.la
2112 libfoo_la_SOURCES  = bar.f baz.c zardoz.cc
2113 libfoo_la_LIBADD   = $(FLIBS)
2114 @end example
2116 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
2117 is mentioned in @file{configure.in}.  Also, if @code{@@FLIBS@@} hadn't
2118 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
2119 Automake would have issued a warning.
2122 @page
2123 @menu
2124 * How the Linker is Chosen::
2125 @end menu
2127 @node How the Linker is Chosen,  , Mixing Fortran 77 With C and C++, Mixing Fortran 77 With C and C++
2128 @comment  node-name,  next,  previous,  up
2129 @subsubsection How the Linker is Chosen
2131 @cindex Automatic linker selection
2132 @cindex Selecting the linker automatically
2134 The following diagram demonstrates under what conditions a particular
2135 linker is chosen by Automake.
2137 For example, if Fortran 77, C and C++ source code were to be compiled
2138 into a program, then the C++ linker will be used.  In this case, if the
2139 C or Fortran 77 linkers required any special libraries that weren't
2140 included by the C++ linker, then they must be manually added to an
2141 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
2142 @file{Makefile.am}.
2144 @example
2145                      \              Linker
2146           source      \
2147            code        \     C        C++     Fortran
2148      -----------------  +---------+---------+---------+
2149                         |         |         |         |
2150      C                  |    x    |         |         |
2151                         |         |         |         |
2152                         +---------+---------+---------+
2153                         |         |         |         |
2154          C++            |         |    x    |         |
2155                         |         |         |         |
2156                         +---------+---------+---------+
2157                         |         |         |         |
2158                Fortran  |         |         |    x    |
2159                         |         |         |         |
2160                         +---------+---------+---------+
2161                         |         |         |         |
2162      C + C++            |         |    x    |         |
2163                         |         |         |         |
2164                         +---------+---------+---------+
2165                         |         |         |         |
2166      C +       Fortran  |         |         |    x    |
2167                         |         |         |         |
2168                         +---------+---------+---------+
2169                         |         |         |         |
2170          C++ + Fortran  |         |    x    |         |
2171                         |         |         |         |
2172                         +---------+---------+---------+
2173                         |         |         |         |
2174      C + C++ + Fortran  |         |    x    |         |
2175                         |         |         |         |
2176                         +---------+---------+---------+
2177 @end example
2180 @node Fortran 77 and Autoconf,  , Mixing Fortran 77 With C and C++, Fortran 77 Support
2181 @comment  node-name,  next,  previous,  up
2182 @subsection Fortran 77 and Autoconf
2184 The current Automake support for Fortran 77 requires a recent enough
2185 version Autoconf that also includes support for Fortran 77.  Full
2186 Fortran 77 support was added to Autoconf 2.13, so you will want to use
2187 that version of Autoconf or later.
2190 @node Java Support, Support for Other Languages, Fortran 77 Support, Programs
2191 @comment  node-name,  next,  previous,  up
2193 Automake includes support for compiled Java, using @code{gcj}, the Java
2194 front end to the GNU C compiler.
2196 Any package including Java code to be compiled must define the output
2197 variable @samp{GCJ} in @file{configure.in}; the variable @samp{GCJFLAGS}
2198 must also be defined somehow (either in @file{configure.in} or
2199 @file{Makefile.am}).  The simplest way to do this is to use the
2200 @code{AM_PROG_GCJ} macro.
2202 By default, programs including Java source files are linked with
2203 @code{gcj}.
2206 @node Support for Other Languages, ANSI, Java Support, Programs
2207 @comment  node-name,  next,  previous,  up
2208 @section Support for Other Languages
2210 Automake currently only includes full support for C, C++ (@pxref{C++
2211 Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java
2212 (@pxref{Java Support}).  There is only rudimentary support for other
2213 languages, support for which will be improved based on user demand.
2215 @c FIXME: mention suffix rule processing here.
2218 @node ANSI, Dependencies, Support for Other Languages, Programs
2219 @section Automatic de-ANSI-fication
2221 @cindex de-ANSI-fication, defined
2223 Although the GNU standards allow the use of ANSI C, this can have the
2224 effect of limiting portability of a package to some older compilers
2225 (notably SunOS).
2227 Automake allows you to work around this problem on such machines by
2228 @dfn{de-ANSI-fying} each source file before the actual compilation takes
2229 place.
2231 @vindex AUTOMAKE_OPTIONS
2232 @opindex ansi2knr
2234 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
2235 (@pxref{Options}) contains the option @code{ansi2knr} then code to
2236 handle de-ANSI-fication is inserted into the generated
2237 @file{Makefile.in}.
2239 This causes each C source file in the directory to be treated as ANSI C.
2240 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
2241 is available, the @code{ansi2knr} program is used to convert the source
2242 files into K&R C, which is then compiled.
2244 The @code{ansi2knr} program is simple-minded.  It assumes the source
2245 code will be formatted in a particular way; see the @code{ansi2knr} man
2246 page for details.
2248 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
2249 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
2250 these files are distributed with Automake.  Also, the package
2251 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}
2252 (@pxref{Macros}).
2253 @cvindex AM_C_PROTOTYPES
2255 Automake also handles finding the @code{ansi2knr} support files in some
2256 other directory in the current package.  This is done by prepending the
2257 relative path to the appropriate directory to the @code{ansi2knr}
2258 option.  For instance, suppose the package has ANSI C code in the
2259 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
2260 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
2261 @file{src/Makefile.am}:
2263 @example
2264 AUTOMAKE_OPTIONS = ../lib/ansi2knr
2265 @end example
2267 If no directory prefix is given, the files are assumed to be in the
2268 current directory.
2270 Files mentioned in @code{LIBOBJS} which need de-ANSI-fication will not
2271 be automatically handled.  That's because @code{configure} will generate
2272 an object name like @file{regex.o}, while @code{make} will be looking
2273 for @file{regex_.o} (when de-ANSI-fying).  Eventually this problem will
2274 be fixed via @code{autoconf} magic, but for now you must put this code
2275 into your @file{configure.in}, just before the @code{AC_OUTPUT} call:
2277 @example
2278 # This is necessary so that .o files in LIBOBJS are also built via
2279 # the ANSI2KNR-filtering rules.
2280 LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
2281 @end example
2284 @node Dependencies,  , ANSI, Programs
2285 @section Automatic dependency tracking
2287 As a developer it is often painful to continually update the
2288 @file{Makefile.in} whenever the include-file dependencies change in a
2289 project.  Automake supplies a way to automatically track dependency
2290 changes, and distribute the dependencies in the generated
2291 @file{Makefile.in}.
2293 Currently this support requires the use of GNU @code{make} and
2294 @code{gcc}.  It might become possible in the future to supply a
2295 different dependency generating program, if there is enough demand.  In
2296 the meantime, this mode is enabled by default if any C program or
2297 library is defined in the current directory, so you may get a @samp{Must
2298 be a separator} error from non-GNU make.
2300 @trindex dist
2302 When you decide to make a distribution, the @code{dist} target will
2303 re-run @code{automake} with @samp{--include-deps} and other options.
2304 @xref{Invoking Automake}, and @ref{Options}.  This will cause the
2305 previously generated dependencies to be inserted into the generated
2306 @file{Makefile.in}, and thus into the distribution.  This step also
2307 turns off inclusion of the dependency generation code, so that those who
2308 download your distribution but don't use GNU @code{make} and @code{gcc}
2309 will not get errors.
2311 @vindex OMIT_DEPENDENCIES
2313 When added to the @file{Makefile.in}, the dependencies have all
2314 system-specific dependencies automatically removed.  This can be done by
2315 listing the files in @samp{OMIT_DEPENDENCIES}.  For instance all
2316 references to system header files are removed by Automake.  Sometimes it
2317 is useful to specify that a certain header file should be removed.  For
2318 instance if your @file{configure.in} uses @samp{AM_WITH_REGEX}, then any
2319 dependency on @file{rx.h} or @file{regex.h} should be removed, because
2320 the correct one cannot be known until the user configures the package.
2322 As it turns out, Automake is actually smart enough to handle the
2323 particular case of the regular expression header.  It will also
2324 automatically omit @file{libintl.h} if @samp{AM_GNU_GETTEXT} is used.
2326 @vindex AUTOMAKE_OPTIONS
2327 @opindex no-dependencies
2329 Automatic dependency tracking can be suppressed by putting
2330 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
2332 If you unpack a distribution made by @code{make dist}, and you want to
2333 turn on the dependency-tracking code again, simply re-run
2334 @code{automake}.
2336 The actual dependency files are put under the build directory, in a
2337 subdirectory named @file{.deps}.  These dependencies are machine
2338 specific.  It is safe to delete them if you like; they will be
2339 automatically recreated during the next build.
2342 @node Other objects, Other GNU Tools, Programs, Top
2343 @chapter Other Derived Objects
2345 Automake can handle derived objects which are not C programs.  Sometimes
2346 the support for actually building such objects must be explicitly
2347 supplied, but Automake will still automatically handle installation and
2348 distribution.
2350 @menu
2351 * Scripts::                     Executable scripts
2352 * Headers::                     Header files
2353 * Data::                        Architecture-independent data files
2354 * Sources::                     Derived sources
2355 @end menu
2358 @node Scripts, Headers, Other objects, Other objects
2359 @section Executable Scripts
2361 @cindex _SCRIPTS primary, defined
2362 @cindex SCRIPTS primary, defined
2363 @cindex Primary variable, SCRIPTS
2365 It is possible to define and install programs which are scripts.  Such
2366 programs are listed using the @samp{SCRIPTS} primary name.  Automake
2367 doesn't define any dependencies for scripts; the @file{Makefile.am}
2368 should include the appropriate rules.
2369 @vindex SCRIPTS
2371 Automake does not assume that scripts are derived objects; such objects
2372 must be deleted by hand (@pxref{Clean}).
2374 The @code{automake} program itself is a Perl script that is generated at
2375 configure time from @file{automake.in}.  Here is how this is handled:
2377 @example
2378 bin_SCRIPTS = automake
2379 @end example
2381 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
2382 for it is automatically generated.
2384 @cindex SCRIPTS, installation directories
2385 @cindex Installing scripts
2387 @vindex bin_SCRIPTS
2388 @vindex sbin_SCRIPTS
2389 @vindex libexec_SCRIPTS
2390 @vindex pkgdata_SCRIPTS
2391 @vindex noinst_SCRIPTS
2393 Script objects can be installed in @code{bindir}, @code{sbindir},
2394 @code{libexecdir}, or @code{pkgdatadir}.
2397 @node Headers, Data, Scripts, Other objects
2398 @section Header files
2400 @cindex _HEADERS primary, defined
2401 @cindex HEADERS primary, defined
2402 @cindex Primary variable, HEADERS
2404 @vindex noinst_HEADERS
2406 Header files are specified by the @samp{HEADERS} family of variables.
2407 Generally header files are not installed, so the @code{noinst_HEADERS}
2408 variable will be the most used.
2409 @vindex HEADERS
2411 All header files must be listed somewhere; missing ones will not appear
2412 in the distribution.  Often it is clearest to list uninstalled headers
2413 with the rest of the sources for a program.  @xref{A Program}.  Headers
2414 listed in a @samp{_SOURCES} variable need not be listed in any
2415 @samp{_HEADERS} variable.
2417 @cindex HEADERS, installation directories
2418 @cindex Installing headers
2420 @vindex include_HEADERS
2421 @vindex oldinclude_HEADERS
2422 @vindex pkginclude_HEADERS
2424 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
2425 @code{pkgincludedir}.
2428 @node Data, Sources, Headers, Other objects
2429 @section Architecture-independent data files
2431 @cindex _DATA primary, defined
2432 @cindex DATA primary, defined
2433 @cindex Primary variable, DATA
2435 Automake supports the installation of miscellaneous data files using the
2436 @samp{DATA} family of variables.
2437 @vindex DATA
2439 @vindex data_DATA
2440 @vindex sysconf_DATA
2441 @vindex sharedstate_DATA
2442 @vindex localstate_DATA
2443 @vindex pkgdata_DATA
2445 Such data can be installed in the directories @code{datadir},
2446 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
2447 @code{pkgdatadir}.
2449 By default, data files are @emph{not} included in a distribution.
2451 Here is how Automake installs its auxiliary data files:
2453 @example
2454 pkgdata_DATA = clean-kr.am clean.am @dots{}
2455 @end example
2458 @node Sources,  , Data, Other objects
2459 @section Built sources
2461 @cindex BUILT_SOURCES, defined
2463 Occasionally a file which would otherwise be called @samp{source}
2464 (e.g. a C @samp{.h} file) is actually derived from some other file.
2465 Such files should be listed in the @code{BUILT_SOURCES} variable.
2466 @vindex BUILT_SOURCES
2468 @code{BUILT_SOURCES} is actually a bit of a misnomer, as any file which
2469 must be created early in the build process can be listed in this
2470 variable.
2472 A source file listed in @code{BUILT_SOURCES} is created before the other
2473 @code{all} targets are made.  However, such a source file is not
2474 compiled unless explicitly requested by mentioning it in some other
2475 @samp{_SOURCES} variable.
2478 @node Other GNU Tools, Documentation, Other objects, Top
2479 @chapter Other GNU Tools
2481 Since Automake is primarily intended to generate @file{Makefile.in}s for
2482 use in GNU programs, it tries hard to interoperate with other GNU tools.
2484 @menu
2485 * Emacs Lisp::                  Emacs Lisp
2486 * gettext::                     Gettext
2487 * Guile::                       Guile
2488 * Libtool::                     Libtool
2489 * Java::                        Java
2490 * Python::                      Python
2491 @end menu
2494 @node Emacs Lisp, gettext, Other GNU Tools, Other GNU Tools
2495 @section Emacs Lisp
2497 @cindex _LISP primary, defined
2498 @cindex LISP primary, defined
2499 @cindex Primary variable, LISP
2501 @vindex LISP
2502 @vindex lisp_LISP
2503 @vindex noinst_LISP
2505 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
2506 is used to hold a list of @file{.el} files.  Possible prefixes for this
2507 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
2508 @code{lisp_LISP} is defined, then @file{configure.in} must run
2509 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
2511 @vindex ELCFILES
2513 By default Automake will byte-compile all Emacs Lisp source files using
2514 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
2515 byte-compiling, simply define the variable @code{ELCFILES} to be empty.
2516 Byte-compiled Emacs Lisp files are not portable among all versions of
2517 Emacs, so it makes sense to turn this off if you expect sites to have
2518 more than one version of Emacs installed.  Furthermore, many packages
2519 don't actually benefit from byte-compilation.  Still, we recommend that
2520 you leave it enabled by default.  It is probably better for sites with
2521 strange setups to cope for themselves than to make the installation less
2522 nice for everybody else.
2525 @node gettext, Guile, Emacs Lisp, Other GNU Tools
2526 @section Gettext
2528 @cindex GNU Gettext support
2529 @cindex Gettext support
2530 @cindex Support for GNU Gettext
2532 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
2533 turns on support for GNU gettext, a message catalog system for
2534 internationalization
2535 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
2537 The @code{gettext} support in Automake requires the addition of two
2538 subdirectories to the package, @file{intl} and @file{po}.  Automake
2539 insures that these directories exist and are mentioned in
2540 @code{SUBDIRS}.
2542 Furthermore, Automake checks that the definition of @code{ALL_LINGUAS}
2543 in @file{configure.in} corresponds to all the valid @file{.po} files,
2544 and nothing more.
2547 @node Guile, Libtool, gettext, Other GNU Tools
2548 @section Guile
2550 Automake provides some automatic support for writing Guile modules.
2551 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
2552 macro is used in @file{configure.in}.
2554 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
2555 macro is understood to mean:
2556 @itemize @bullet
2557 @item
2558 @code{AM_INIT_AUTOMAKE} is run.
2560 @item
2561 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
2562 @end itemize
2564 As the Guile module code matures, no doubt the Automake support will
2565 grow as well.
2568 @node Libtool, Java, Guile, Other GNU Tools
2569 @section Libtool
2571 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
2572 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
2573 @xref{A Shared Library}.
2576 @node Java, Python, Libtool, Other GNU Tools
2577 @section Java
2579 @cindex _JAVA primary, defined
2580 @cindex JAVA primary, defined
2581 @cindex Primary variable, JAVA
2583 Automake provides some minimal support for Java compilation with the
2584 @samp{JAVA} primary.
2586 Any @file{.java} files listed in a @samp{_JAVA} variable will be
2587 compiled with @code{JAVAC} at build time.  By default, @file{.class}
2588 files are not included in the distribution.
2590 @cindex JAVA restrictions
2591 @cindex Restrictions for JAVA
2593 Currently Automake enforces the restriction that only one @samp{_JAVA}
2594 primary can be used in a given @file{Makefile.am}.  The reason for this
2595 restriction is that, in general, it isn't possible to know which
2596 @file{.class} files were generated from which @file{.java} files -- so
2597 it would be impossible to know which files to install where.
2599 @node Python,  , Java, Other GNU Tools
2600 @section Python
2602 @cindex _PYTHON primary, defined
2603 @cindex PYTHON primary, defined
2604 @cindex Primary variable, PYTHON
2607 Automake provides support for Python modules.  Automake will turn on
2608 Python support if the @code{AM_CHECK_PYTHON} macro is used in
2609 @file{configure.in}.  The @samp{PYTHON} primary is used to hold a list
2610 of @file{.py} files.  Possible prefixes for this primary are
2611 @samp{python_} and @samp{noinst_}.  Note that if @code{python_PYTHON} is
2612 defined, then @file{configure.in} must run @code{AM_CHECK_PYTHON}.
2614 @code{AM_CHECK_PYTHON} takes a single argument --- either the word
2615 @samp{module} or @samp{package}.  The first installs files directly into
2616 the @file{site-packages} directory and is used when the @file{.py[co]}
2617 files must be on the @code{PYTHONPATH}.  The second is used for modules
2618 distributed as a package, which should be installed in a subdirectory
2619 of @file{site-packages} and contain the @file{__init__.py} file.  The
2620 subdirectory name is the same as the name given by @samp{PACKAGE}.
2623 @code{AM_CHECK_PYTHON} creates several output variables based on the
2624 Python installation found during configuration.
2626 @table @samp
2627 @item PYTHON
2628 The name of the Python executable.
2630 @item PYTHON_VERSION
2631 The Python version number, in the form @var{major}.@var{minor}
2632 (e.g. @samp{1.5}).  This is currently the value of
2633 @code{sys.version[:3]}.
2635 @item PYTHON_PREFIX
2636 The string @code{$prefix}.  This term may be used in future work
2637 which needs the contents of Python's @code{sys.prefix}, but general
2638 consensus is to always use the value from configure.
2640 @item PYTHON_EXEC_PREFIX
2641 The string @code{$exec_prefix}.  This term may be used in future work
2642 which needs the contents of Python's @code{sys.exec_prefix}, but general
2643 consensus is to always use the value from configure.
2645 @item PYTHON_PLATFORM
2646 The canonical name used by Python to describe the operating system, as
2647 given by @code{sys.platform}.  This value is sometimes needed when
2648 building Python extensions.
2650 @item pythondir
2651 The directory name for the top of the standard Python library.
2653 @item PYTHON_SITE
2654 The location of the platform-independent @file{site-packages} directory,
2655 where `module' files are installed.  Note that older versions of Python
2656 (pre-1.5) used @file{$prefix/lib/site-python} so future versions of
2657 Automake's Python support may provide backwards compatibility.
2659 @item PYTHON_SITE_PACKAGE
2660 The string @code{$PYTHON_SITE/$PACKAGE}.  This is the default
2661 installation directory for a Python `package.'
2663 @item PYTHON_SITE_INSTALL
2664 The top-level directory in which the Python files will be installed.  It
2665 will be the value of either @samp{PYTHON_SITE} or @samp{PYTHON_PACKAGE}
2666 depending on the argument given to @code{AM_CHECK_PYTHON}.
2668 @item PYTHON_SITE_EXEC
2669 The location of the platform-dependent @file{site-packages} directory,
2670 where shared library extensions should be placed.  Note that older
2671 versions of Python (pre-1.5) used @file{sharedmodules} so future version
2672 of Automake's Python support may provide backwards compatibility.
2674 @end table
2676 @vindex PYCFILES
2677 @vindex PYOFILES
2679 By default Automake will byte-compile all Python source files to both
2680 @file{.pyc} and @file{.pyo} forms.  If you wish to avoid generating the
2681 optimized byte-code files, simply define the variable @code{PYOFILES} to
2682 be empty.  Similarly, if you don't wish to generate the standard
2683 byte-compiled files, define the variable @code{PYCFILES} to be empty.
2686 @node Documentation, Install, Other GNU Tools, Top
2687 @chapter Building documentation
2689 Currently Automake provides support for Texinfo and man pages.
2691 @menu
2692 * Texinfo::                     Texinfo
2693 * Man pages::                   Man pages
2694 @end menu
2697 @node Texinfo, Man pages, Documentation, Documentation
2698 @section Texinfo
2700 @cindex _TEXINFOS primary, defined
2701 @cindex TEXINFOS primary, defined
2702 @cindex Primary variable, TEXINFOS
2704 If the current directory contains Texinfo source, you must declare it
2705 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
2706 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
2707 here.  Note that any Texinfo source file must end in the @file{.texi} or
2708 @file{.texinfo} extension.
2709 @vindex TEXINFOS
2710 @vindex info_TEXINFOS
2712 @cindex Texinfo macro, VERSION
2713 @cindex Texinfo macro, UPDATED
2714 @cindex Texinfo macro, EDITION
2716 @cindex VERSION Texinfo macro
2717 @cindex UPDATED Texinfo macro
2718 @cindex EDITION Texinfo macro
2720 @cindex mdate-sh
2722 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
2723 that file will be automatically generated.  The file @file{version.texi}
2724 defines three Texinfo macros you can reference: @code{EDITION},
2725 @code{VERSION}, and @code{UPDATED}.  The first two hold the version
2726 number of your package (but are kept separate for clarity); the last is
2727 the date the primary file was last modified.  The @file{version.texi}
2728 support requires the @code{mdate-sh} program; this program is supplied
2729 with Automake and automatically included when @code{automake} is invoked
2730 with the @code{--add-missing} option.
2732 If you have multiple Texinfo files, and you want to use the
2733 @file{version.texi} feature, then you have to have a separate version
2734 file for each Texinfo file.  Automake will treat any include in a
2735 Texinfo file that matches @samp{vers*.texi} just as an automatically
2736 generated version file.
2738 Sometimes an info file actually depends on more than one @file{.texi}
2739 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
2740 @file{gpl.texi}.  You can tell Automake about these dependencies using
2741 the @code{@var{texi}_TEXINFOS} variable.  Here is how GNU Hello does it:
2742 @vindex TEXINFOS
2743 @vindex _TEXINFOS
2745 @example
2746 info_TEXINFOS = hello.texi
2747 hello_TEXINFOS = gpl.texi
2748 @end example
2750 @cindex texinfo.tex
2752 By default, Automake requires the file @file{texinfo.tex} to appear in
2753 the same directory as the Texinfo source.  However, if you used
2754 @code{AC_CONFIG_AUX_DIR} in @file{configure.in} (@pxref{Input, , Finding
2755 `configure' Input, autoconf, The Autoconf Manual}), then
2756 @file{texinfo.tex} is looked for there.  Automake supplies
2757 @file{texinfo.tex} if @samp{--add-missing} is given.
2759 @vindex TEXINFO_TEX
2761 If your package has Texinfo files in many directories, you can use the
2762 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
2763 @file{texinfo.tex} for your package.  The value of this variable should
2764 be the relative path from the current @file{Makefile.am} to
2765 @file{texinfo.tex}:
2767 @example
2768 TEXINFO_TEX = ../doc/texinfo.tex
2769 @end example
2771 @opindex no-texinfo.tex
2773 The option @samp{no-texinfo.tex} can be used to eliminate the
2774 requirement for @file{texinfo.tex}.  Use of the variable
2775 @code{TEXINFO_TEX} is preferable, however, because that allows the
2776 @code{dvi} target to still work.
2778 @cindex Target, install-info
2779 @cindex Target, noinstall-info
2780 @cindex install-info target
2781 @cindex noinstall-info target
2783 @opindex no-installinfo
2784 @trindex install-info
2786 Automake generates an @code{install-info} target; some people apparently
2787 use this.  By default, info pages are installed by @samp{make install}.
2788 This can be prevented via the @code{no-installinfo} option.
2791 @node Man pages,  , Texinfo, Documentation
2792 @section Man pages
2794 @cindex _MANS primary, defined
2795 @cindex MANS primary, defined
2796 @cindex Primary variable, MANS
2798 A package can also include man pages (but see the GNU standards on this
2799 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.)  Man
2800 pages are declared using the @samp{MANS} primary.  Generally the
2801 @code{man_MANS} macro is used.  Man pages are automatically installed in
2802 the correct subdirectory of @code{mandir}, based on the file extension.
2803 @vindex MANS
2804 @vindex man_MANS
2806 File extensions such as @samp{.1c} are handled by looking for the valid
2807 part of the extension and using that to determine the correct
2808 subdirectory of @code{mandir}.  Valid section names are the digits
2809 @samp{0} through @samp{9}, and the letters @samp{l} and @samp{n}.
2811 Sometimes developers prefer to name a man page something like
2812 @file{foo.man} in the source, and then rename it to have the correct
2813 suffix, e.g. @file{foo.1}, when installing the file.  Automake also
2814 supports this mode.  For a valid section named @var{SECTION}, there is a
2815 corresponding directory named @samp{man@var{SECTION}dir}, and a
2816 corresponding @samp{_MANS} variable.  Files listed in such a variable
2817 are installed in the indicated section.  If the file already has a
2818 valid suffix, then it is installed as-is; otherwise the file suffix is
2819 changed to match the section.
2821 For instance, consider this example:
2822 @example
2823 man1_MANS = rename.man thesame.1 alsothesame.1c
2824 @end example
2826 In this case, @file{rename.man} will be renamed to @file{rename.1} when
2827 installed, but the other files will keep their names.
2829 @cindex Target, install-man
2830 @cindex Target, noinstall-man
2831 @cindex install-man target
2832 @cindex noinstall-man target
2834 @c Use @samp{make install} per documentation: (texi)code.
2835 By default, man pages are installed by @samp{make install}.  However,
2836 since the GNU project does not require man pages, many maintainers do
2837 not expend effort to keep the man pages up to date.  In these cases, the
2838 @code{no-installman} option will prevent the man pages from being
2839 installed by default.  The user can still explicitly install them via
2840 @samp{make install-man}.
2841 @opindex no-installman
2842 @trindex install-man
2844 Here is how the documentation is handled in GNU @code{cpio} (which
2845 includes both Texinfo documentation and man pages):
2847 @example
2848 info_TEXINFOS = cpio.texi
2849 man_MANS = cpio.1 mt.1
2850 EXTRA_DIST = $(man_MANS)
2851 @end example
2853 Texinfo source and info pages are all considered to be source for the
2854 purposes of making a distribution.
2856 Man pages are not currently considered to be source, because it is not
2857 uncommon for man pages to be automatically generated.  For the same
2858 reason, they are not automatically included in the distribution.
2861 @node Install, Clean, Documentation, Top
2862 @chapter What Gets Installed
2864 @cindex Installation support
2865 @cindex make install support
2867 Naturally, Automake handles the details of actually installing your
2868 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
2869 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
2870 automatically installed in the appropriate places.
2872 Automake also handles installing any specified info and man pages.
2874 Automake generates separate @code{install-data} and @code{install-exec}
2875 targets, in case the installer is installing on multiple machines which
2876 share directory structure---these targets allow the machine-independent
2877 parts to be installed only once.  The @code{install} target depends on
2878 both of these targets.
2879 @trindex install-data
2880 @trindex install-exec
2881 @trindex install
2883 Automake also generates an @code{uninstall} target, an
2884 @code{installdirs} target, and an @code{install-strip} target.
2885 @trindex uninstall
2886 @trindex installdirs
2887 @trindex install-strip
2889 It is possible to extend this mechanism by defining an
2890 @code{install-exec-local} or @code{install-data-local} target.  If these
2891 targets exist, they will be run at @samp{make install} time.
2892 @trindex install-exec-local
2893 @trindex install-data-local
2895 Variables using the standard directory prefixes @samp{data},
2896 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
2897 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
2898 installed by @samp{install-data}.
2900 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
2901 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
2902 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
2903 @samp{install-exec}.
2905 Any variable using a user-defined directory prefix with @samp{exec} in
2906 the name (e.g. @samp{myexecbin_PROGRAMS} is installed by
2907 @samp{install-exec}.  All other user-defined prefixes are installed by
2908 @samp{install-data}.
2910 @vindex DESTDIR
2911 Automake generates support for the @samp{DESTDIR} variable in all
2912 install rules.  @samp{DESTDIR} is used during the @samp{make install}
2913 step to relocate install objects into a staging area.  Each object and
2914 path is prefixed with the value of @samp{DESTDIR} before being copied
2915 into the install area.  Here is an example of typical DESTDIR usage:
2917 @example
2918 make DESTDIR=/tmp/staging install
2919 @end example
2921 This places install objects in a directory tree built under
2922 @file{/tmp/staging}.  If @file{/gnu/bin/foo} and
2923 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
2924 would install @file{/tmp/staging/gnu/bin/foo} and
2925 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
2927 This feature is commonly used to build install images and packages.  For
2928 more information, see @ref{Makefile Conventions, , , standards, The GNU
2929 Coding Standards}.
2932 @node Clean, Dist, Install, Top
2933 @chapter What Gets Cleaned
2935 @cindex make clean support
2937 The GNU Makefile Standards specify a number of different clean rules.
2938 @c FIXME xref
2939 Generally the files that can be cleaned are determined automatically by
2940 Automake.  Of course, Automake also recognizes some variables that can
2941 be defined to specify additional files to clean.  These variables are
2942 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
2943 @code{MAINTAINERCLEANFILES}.
2944 @vindex MOSTLYCLEANFILES
2945 @vindex CLEANFILES
2946 @vindex DISTCLEANFILES
2947 @vindex MAINTAINERCLEANFILES
2950 @node Dist, Tests, Clean, Top
2951 @chapter What Goes in a Distribution
2953 @cindex make dist
2954 @cindex make distcheck
2956 The @code{dist} target in the generated @file{Makefile.in} can be used
2957 to generate a gzip'd @code{tar} file for distribution.  The tar file is
2958 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
2959 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
2960 @cvindex PACKAGE
2961 @cvindex VERSION
2962 @trindex dist
2963 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
2964 is run.  The default setting is @samp{--best}.
2966 For the most part, the files to distribute are automatically found by
2967 Automake: all source files are automatically included in a distribution,
2968 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
2969 has a built-in list of commonly used files which, if present in the
2970 current directory, are automatically included.  This list is printed by
2971 @samp{automake --help}.  Also, files which are read by @code{configure}
2972 (i.e. the source files corresponding to the files specified in the
2973 @code{AC_OUTPUT} invocation) are automatically distributed.
2975 Still, sometimes there are files which must be distributed, but which
2976 are not covered in the automatic rules.  These files should be listed in
2977 the @code{EXTRA_DIST} variable.  You can mention files from
2978 subdirectories in @code{EXTRA_DIST}.  You can also mention a directory
2979 there; in this case the entire directory will be recursively copied into
2980 the distribution.
2981 @vindex EXTRA_DIST
2983 Sometimes you need tighter control over what does @emph{not} go into the
2984 distribution; for instance you might have source files which are
2985 generated and which you do not want to distribute.  In this case
2986 Automake gives fine-grained control using the @samp{dist} and
2987 @samp{nodist} prefixes.  Any primary or @samp{_SOURCES} variable can be
2988 prefixed with @samp{dist_} to add the listed files to the distribution.
2989 Similarly, @samp{nodist_} can be used to omit the files from the
2990 distribution.
2991 @vindex dist_
2992 @vindex nodist_
2994 As an example, here is how you would cause some data to be distributed
2995 while leaving some source code out of the distribution:
2997 @example
2998 dist_data_DATA = distribute-this
2999 bin_PROGRAMS = foo
3000 nodist_foo_SOURCES = do-not-distribute.c
3001 @end example
3003 If you define @code{SUBDIRS}, Automake will recursively include the
3004 subdirectories in the distribution.  If @code{SUBDIRS} is defined
3005 conditionally (@pxref{Conditionals}), Automake will normally include all
3006 directories that could possibly appear in @code{SUBDIRS} in the
3007 distribution.  If you need to specify the set of directories
3008 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
3009 list of subdirectories to include in the distribution.
3010 @vindex DIST_SUBDIRS
3012 @trindex dist-hook
3014 Occasionally it is useful to be able to change the distribution before
3015 it is packaged up.  If the @code{dist-hook} target exists, it is run
3016 after the distribution directory is filled, but before the actual tar
3017 (or shar) file is created.  One way to use this is for distributing
3018 files in subdirectories for which a new @file{Makefile.am} is overkill:
3020 @example
3021 dist-hook:
3022         mkdir $(distdir)/random
3023         cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
3024 @end example
3026 Automake also generates a @code{distcheck} target which can be of help
3027 to ensure that a given distribution will actually work.
3028 @code{distcheck} makes a distribution, and then tries to do a
3029 @code{VPATH} build.
3030 @trindex distcheck
3031 @c FIXME: document distcheck-hook here
3034 @node Tests, Options, Dist, Top
3035 @chapter Support for test suites
3037 @cindex Test suites
3038 @cindex make check
3040 Automake supports two forms of test suites.
3042 If the variable @code{TESTS} is defined, its value is taken to be a list
3043 of programs to run in order to do the testing.  The programs can either
3044 be derived objects or source objects; the generated rule will look both
3045 in @code{srcdir} and @file{.}.  Programs needing data files should look
3046 for them in @code{srcdir} (which is both an environment variable and a
3047 make variable) so they work when building in a separate directory
3048 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
3049 Manual}), and in particular for the @code{distcheck} target
3050 (@pxref{Dist}).
3052 @cindex Exit status 77, special interpretation
3054 The number of failures will be printed at the end of the run.  If a
3055 given test program exits with a status of 77, then its result is ignored
3056 in the final count.  This feature allows non-portable tests to be
3057 ignored in environments where they don't make sense.
3059 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
3060 variables for the test run; the environment variable @code{srcdir} is
3061 set in the rule.  If all your test programs are scripts, you can also
3062 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
3063 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
3064 @vindex TESTS
3065 @vindex TESTS_ENVIRONMENT
3067 If @uref{ftp://prep.ai.mit.edu/pub/gnu/dejagnu-1.3.tar.gz,
3068 @samp{dejagnu}} appears in @code{AUTOMAKE_OPTIONS}, then a
3069 @code{dejagnu}-based test suite is assumed.  The variable
3070 @code{DEJATOOL} is a list of names which are passed, one at a time, as
3071 the @code{--tool} argument to @code{runtest} invocations; it defaults to
3072 the name of the package.
3074 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
3075 @code{--srcdir} flags that are passed to dejagnu by default; this can be
3076 overridden if necessary.
3077 @vindex RUNTESTDEFAULTFLAGS
3079 The variables @code{EXPECT}, @code{RUNTEST} and @code{RUNTESTFLAGS} can
3080 also be overridden to provide project-specific values.  For instance,
3081 you will need to do this if you are testing a compiler toolchain,
3082 because the default values do not take into account host and target
3083 names.
3084 @opindex dejagnu
3085 @vindex DEJATOOL
3086 @vindex EXPECT
3087 @vindex RUNTEST
3088 @vindex RUNTESTFLAGS
3089 @c FIXME xref dejagnu
3091 If you're not using dejagnu, you may define the variable
3092 @samp{XFAIL_TESTS} to a list of tests (usually a subset of @samp{TESTS})
3093 that are expected to fail.  This will reverse the result of those tests.
3095 In either case, the testing is done via @samp{make check}.
3098 @node Options, Miscellaneous, Tests, Top
3099 @chapter Changing Automake's Behavior
3101 Various features of Automake can be controlled by options in the
3102 @file{Makefile.am}.  Such options are listed in a special variable named
3103 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
3104 @vindex AUTOMAKE_OPTIONS
3106 @table @asis
3107 @item @code{gnits}
3108 @itemx @code{gnu}
3109 @itemx @code{foreign}
3110 @item @code{cygnus}
3111 @cindex Option, gnits
3112 @cindex Option, gnu
3113 @cindex Option, foreign
3114 @cindex Option, cygnus
3116 Set the strictness as appropriate.  The @code{gnits} option also implies
3117 @code{readme-alpha} and @code{check-news}.
3119 @item @code{ansi2knr}
3120 @itemx @code{path/ansi2knr}
3121 @cindex Option, ansi2knr
3122 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceded by a
3123 path, the generated @file{Makefile.in} will look in the specified
3124 directory to find the @file{ansi2knr} program.  Generally the path
3125 should be a relative path to another directory in the same distribution
3126 (though Automake currently does not check this).
3128 @item @code{check-news}
3129 @cindex Option, check-news
3130 Cause @code{make dist} to fail unless the current version number appears
3131 in the first few lines of the @file{NEWS} file.
3133 @item @code{dejagnu}
3134 @cindex Option, dejagnu
3135 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
3137 @item @code{dist-bzip2}
3138 @cindex Option, dist-bzip2
3139 Generate a @code{dist-bzip2} target as well as the ordinary @code{dist}
3140 target.  This new target will create a bzip2 tar archive of the
3141 distribution.  bzip2 archives are frequently smaller than even gzipped
3142 archives.
3143 @trindex dist-bzip2
3145 @item @code{dist-shar}
3146 @cindex Option, dist-shar
3147 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
3148 target.  This new target will create a shar archive of the
3149 distribution.
3150 @trindex dist-shar
3152 @item @code{dist-zip}
3153 @cindex Option, dist-zip
3154 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
3155 target.  This new target will create a zip archive of the distribution.
3156 @trindex dist-zip
3158 @item @code{dist-tarZ}
3159 @cindex Option, dist-tarZ
3160 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
3161 target.  This new target will create a compressed tar archive of the
3162 distribution.
3163 @trindex dist-tarZ
3165 @item @code{no-dependencies}
3166 @cindex Option, no-dependencies
3167 This is similar to using @samp{--include-deps} on the command line, but
3168 is useful for those situations where you don't have the necessary bits
3169 to make automatic dependency tracking work @xref{Dependencies}.  In this
3170 case the effect is to effectively disable automatic dependency tracking.
3172 @item @code{no-installinfo}
3173 @cindex Option, no-installinfo
3174 The generated @file{Makefile.in} will not cause info pages to be built
3175 or installed by default.  However, @code{info} and @code{install-info}
3176 targets will still be available.  This option is disallowed at
3177 @samp{GNU} strictness and above.
3178 @trindex info
3179 @trindex install-info
3181 @item @code{no-installman}
3182 @cindex Option, no-installman
3183 The generated @file{Makefile.in} will not cause man pages to be
3184 installed by default.  However, an @code{install-man} target will still
3185 be available for optional installation.  This option is disallowed at
3186 @samp{GNU} strictness and above.
3187 @trindex install-man
3189 @item @code{nostdinc}
3190 @cindex Option, nostdinc
3191 This option can be used to disable the standard @samp{-I} options which
3192 are ordinarily automatically provided by Automake.
3194 @item @code{no-texinfo.tex}
3195 @cindex Option, no-texinfo
3196 Don't require @file{texinfo.tex}, even if there are texinfo files in
3197 this directory.
3199 @item @code{readme-alpha}
3200 @cindex Option, readme-alpha
3201 If this release is an alpha release, and the file @file{README-alpha}
3202 exists, then it will be added to the distribution.  If this option is
3203 given, version numbers are expected to follow one of two forms.  The
3204 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
3205 element is a number; the final period and number should be left off for
3206 non-alpha releases.  The second form is
3207 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
3208 letter; it should be omitted for non-alpha releases.
3210 @item @var{version}
3211 @cindex Option, version
3212 A version number (e.g. @samp{0.30}) can be specified.  If Automake is not
3213 newer than the version specified, creation of the @file{Makefile.in}
3214 will be suppressed.
3215 @end table
3217 Unrecognized options are diagnosed by @code{automake}.
3220 @node Miscellaneous, Include, Options, Top
3221 @chapter Miscellaneous Rules
3223 There are a few rules and variables that didn't fit anywhere else.
3225 @menu
3226 * Tags::                        Interfacing to etags and mkid
3227 * Suffixes::                    Handling new file extensions
3228 @end menu
3231 @node Tags, Suffixes, Miscellaneous, Miscellaneous
3232 @section Interfacing to @code{etags}
3234 @cindex TAGS support
3236 Automake will generate rules to generate @file{TAGS} files for use with
3237 GNU Emacs under some circumstances.
3239 If any C, C++ or Fortran 77 source code or headers are present, then
3240 @code{tags} and @code{TAGS} targets will be generated for the directory.
3241 @trindex tags
3243 At the topmost directory of a multi-directory package, a @code{tags}
3244 target file will be generated which, when run, will generate a
3245 @file{TAGS} file that includes by reference all @file{TAGS} files from
3246 subdirectories.
3248 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
3249 will be generated.  This variable is intended for use in directories
3250 which contain taggable source that @code{etags} does not understand.
3251 @vindex ETAGS_ARGS
3253 Here is how Automake generates tags for its source, and for nodes in its
3254 Texinfo file:
3256 @example
3257 ETAGS_ARGS = automake.in --lang=none \
3258  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
3259 @end example
3261 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
3262 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
3263 are added directly to the dependencies for the @code{tags} target.
3264 @vindex TAGS_DEPENDENCIES
3266 Automake will also generate an @code{ID} target which will run
3267 @code{mkid} on the source.  This is only supported on a
3268 directory-by-directory basis.
3269 @trindex id
3271 Automake also supports the GNU Global Tags program.  The @code{GTAGS}
3272 target runs Global Tags automatically and puts the result in the top
3273 build directory.
3276 @node Suffixes,  , Tags, Miscellaneous
3277 @section Handling new file extensions
3279 @cindex Adding new SUFFIXES
3280 @cindex SUFFIXES, adding
3282 It is sometimes useful to introduce a new implicit rule to handle a file
3283 type that Automake does not know about.  If this is done, you must
3284 notify GNU Make of the new suffixes.  This can be done by putting a list
3285 of new suffixes in the @code{SUFFIXES} variable.
3286 @vindex SUFFIXES
3288 For instance, currently Automake does not provide any Java support.  If
3289 you wrote a macro to generate @samp{.class} files from @samp{.java}
3290 source files, you would also need to add these suffixes to the list:
3292 @example
3293 SUFFIXES = .java .class
3294 @end example
3296 Any given @code{SUFFIXES} go at the start of the generated suffixes
3297 list, followed by automake generated suffixes not already in the list.
3300 @node Include, Conditionals, Miscellaneous, Top
3301 @chapter Include
3303 @cmindex include
3304 To include another file (perhaps for common rules),
3305 the following syntax is supported:
3307 include ($(srcdir)|$(top_srcdir))/filename
3309 Using files in the current directory:
3310 @example
3311 include $(srcdir)/Makefile.extra
3312 @end example
3314 @example
3315 include Makefile.generated
3316 @end example
3318 Using a file in the top level directory:
3319 @example
3320 include $(top_srcdir)/filename
3321 @end example
3324 @node Conditionals, Gnits, Include, Top
3325 @chapter Conditionals
3327 @cindex Conditionals
3329 Automake supports a simple type of conditionals.
3331 @cvindex AM_CONDITIONAL
3332 Before using a conditional, you must define it by using
3333 @code{AM_CONDITIONAL} in the @code{configure.in} file (@pxref{Macros}).
3334 The @code{AM_CONDITIONAL} macro takes two arguments.
3336 The first argument to @code{AM_CONDITIONAL} is the name of the
3337 conditional.  This should be a simple string starting with a letter and
3338 containing only letters, digits, and underscores.
3340 The second argument to @code{AM_CONDITIONAL} is a shell condition,
3341 suitable for use in a shell @code{if} statement.  The condition is
3342 evaluated when @code{configure} is run.
3344 @cindex --enable-debug, example
3345 @cindex Example conditional --enable-debug
3346 @cindex Conditional example,  --enable-debug
3348 Conditionals typically depend upon options which the user provides to
3349 the @code{configure} script.  Here is an example of how to write a
3350 conditional which is true if the user uses the @samp{--enable-debug}
3351 option.
3353 @example
3354 AC_ARG_ENABLE(debug,
3355 [  --enable-debug    Turn on debugging],
3356 [case "$@{enableval@}" in
3357   yes) debug=true ;;
3358   no)  debug=false ;;
3359   *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
3360 esac],[debug=false])
3361 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
3362 @end example
3364 Here is an example of how to use that conditional in @file{Makefile.am}:
3366 @cmindex if
3367 @cmindex endif
3368 @cmindex else
3370 @example
3371 if DEBUG
3372 DBG = debug
3373 else
3374 DBG =
3375 endif
3376 noinst_PROGRAMS = $(DBG)
3377 @end example
3379 This trivial example could also be handled using EXTRA_PROGRAMS
3380 (@pxref{A Program}).
3382 You may only test a single variable in an @code{if} statement.  The
3383 @code{else} statement may be omitted.  Conditionals may be nested to any
3384 depth.
3386 Note that conditionals in Automake are not the same as conditionals in
3387 GNU Make.  Automake conditionals are checked at configure time by the
3388 @file{configure} script, and affect the translation from
3389 @file{Makefile.in} to @file{Makefile}.  They are based on options passed
3390 to @file{configure} and on results that @file{configure} has discovered
3391 about the host system.  GNU Make conditionals are checked at @code{make}
3392 time, and are based on variables passed to the make program or defined
3393 in the @file{Makefile}.
3395 Automake conditionals will work with any make program.
3398 @node Gnits, Cygnus, Conditionals, Top
3399 @chapter The effect of @code{--gnu} and @code{--gnits}
3401 @cindex --gnu, required files
3402 @cindex --gnu, complete description
3404 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
3405 variable) causes @code{automake} to check the following:
3407 @itemize @bullet
3408 @item
3409 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
3410 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
3411 directory of the package.
3413 @item
3414 The options @samp{no-installman} and @samp{no-installinfo} are
3415 prohibited.
3416 @end itemize
3418 Note that this option will be extended in the future to do even more
3419 checking; it is advisable to be familiar with the precise requirements
3420 of the GNU standards.  Also, @samp{--gnu} can require certain
3421 non-standard GNU programs to exist for use by various maintainer-only
3422 targets; for instance in the future @code{pathchk} might be required for
3423 @samp{make dist}.
3425 @cindex --gnits, complete description
3427 The @samp{--gnits} option does everything that @samp{--gnu} does, and
3428 checks the following as well:
3430 @itemize @bullet
3431 @item
3432 @samp{make dist} will check to make sure the @file{NEWS} file has been
3433 updated to the current version.
3435 @item
3436 @samp{VERSION} is checked to make sure its format complies with Gnits
3437 standards.
3438 @c FIXME xref when standards are finished
3440 @item
3441 @cindex README-alpha
3442 If @samp{VERSION} indicates that this is an alpha release, and the file
3443 @file{README-alpha} appears in the topmost directory of a package, then
3444 it is included in the distribution.  This is done in @samp{--gnits}
3445 mode, and no other, because this mode is the only one where version
3446 number formats are constrained, and hence the only mode where Automake
3447 can automatically determine whether @file{README-alpha} should be
3448 included.
3450 @item
3451 The file @file{THANKS} is required.
3452 @end itemize
3455 @node Cygnus, Extending, Gnits, Top
3456 @chapter The effect of @code{--cygnus}
3458 @cindex Cygnus strictness
3460 Cygnus Solutions has slightly different rules for how a
3461 @file{Makefile.in} is to be constructed.  Passing @samp{--cygnus} to
3462 @code{automake} will cause any generated @file{Makefile.in} to comply
3463 with Cygnus rules.
3465 Here are the precise effects of @samp{--cygnus}:
3467 @itemize @bullet
3468 @item
3469 Info files are always created in the build directory, and not in the
3470 source directory.
3472 @item
3473 @file{texinfo.tex} is not required if a Texinfo source file is
3474 specified.  The assumption is that the file will be supplied, but in a
3475 place that Automake cannot find.  This assumption is an artifact of how
3476 Cygnus packages are typically bundled.
3478 @item
3479 @samp{make dist} will look for files in the build directory as well as
3480 the source directory.  This is required to support putting info files
3481 into the build directory.
3483 @item
3484 Certain tools will be searched for in the build tree as well as in the
3485 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
3486 @code{makeinfo} and @code{texi2dvi}.
3488 @item
3489 @code{--foreign} is implied.
3491 @item
3492 The options @samp{no-installinfo} and @samp{no-dependencies} are
3493 implied.
3495 @item
3496 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
3497 required.
3499 @item
3500 The @code{check} target doesn't depend on @code{all}.
3501 @end itemize
3503 GNU maintainers are advised to use @samp{gnu} strictness in preference
3504 to the special Cygnus mode.
3507 @node Extending, Distributing, Cygnus, Top
3508 @chapter When Automake Isn't Enough
3510 Automake's implicit copying semantics means that many problems can be
3511 worked around by simply adding some @code{make} targets and rules to
3512 @file{Makefile.in}.  Automake will ignore these additions.
3514 @cindex -local targets
3515 @cindex local targets
3517 There are some caveats to doing this.  Although you can overload a
3518 target already used by Automake, it is often inadvisable, particularly
3519 in the topmost directory of a non-flat package.  However, various useful
3520 targets have a @samp{-local} version you can specify in your
3521 @file{Makefile.in}.  Automake will supplement the standard target with
3522 these user-supplied targets.
3524 @trindex  all-local
3525 @trindex  info-local
3526 @trindex  dvi-local
3527 @trindex  check-local
3528 @trindex  install-data-local
3529 @trindex  install-exec-local
3530 @trindex  uninstall-local
3531 @trindex  mostlyclean-local
3532 @trindex  clean-local
3533 @trindex  distclean-local
3535 The targets that support a local version are @code{all}, @code{info},
3536 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
3537 @code{uninstall}, and the various @code{clean} targets
3538 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
3539 @code{maintainer-clean}).  Note that there are no
3540 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
3541 use @code{uninstall-local}.  It doesn't make sense to uninstall just
3542 data or just executables.
3543 @trindex all
3544 @trindex info
3545 @trindex dvi
3546 @trindex check
3547 @trindex install-data
3548 @trindex install-exec
3549 @trindex uninstall
3551 For instance, here is one way to install a file in @file{/etc}:
3553 @example
3554 install-data-local:
3555         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
3556 @end example
3558 @cindex -hook targets
3559 @cindex hook targets
3561 Some targets also have a way to run another target, called a @dfn{hook},
3562 after their work is done.  The hook is named after the principal target,
3563 with @samp{-hook} appended.  The targets allowing hooks are
3564 @code{install-data}, @code{install-exec}, @code{dist}, and
3565 @code{distcheck}.
3566 @trindex install-data-hook
3567 @trindex install-exec-hook
3568 @trindex dist-hook
3570 For instance, here is how to create a hard link to an installed program:
3572 @example
3573 install-exec-hook:
3574         ln $(bindir)/program $(bindir)/proglink
3575 @end example
3577 @c FIXME should include discussion of variables you can use in these
3578 @c rules
3581 @node Distributing, Future, Extending, Top
3582 @chapter Distributing @file{Makefile.in}s
3584 Automake places no restrictions on the distribution of the resulting
3585 @file{Makefile.in}s.  We still encourage software authors to distribute
3586 their work under terms like those of the GPL, but doing so is not
3587 required to use Automake.
3589 Some of the files that can be automatically installed via the
3590 @code{--add-missing} switch do fall under the GPL; examine each file
3591 to see.
3594 @node Future, Macro and Variable Index, Distributing, Top
3595 @chapter Some ideas for the future
3597 @cindex Future directions
3599 Here are some things that might happen in the future:
3601 @itemize @bullet
3602 @item
3603 HTML support.
3605 @item
3606 The output will be cleaned up.  For instance, only variables which are
3607 actually used will appear in the generated @file{Makefile.in}.
3609 @item
3610 There will be support for automatically recoding a distribution.  The
3611 intent is to allow a maintainer to use whatever character set is most
3612 convenient locally, but for all distributions to be Unicode or
3613 @w{ISO 10646} with the UTF-8 encoding.
3615 @cindex Guile rewrite
3617 @item
3618 Rewrite in Guile.  This won't happen in the near future, but it will
3619 eventually happen.
3620 @end itemize
3623 @page
3624 @node Macro and Variable Index, General Index, Future, Top
3625 @unnumbered Macro and Variable Index
3627 @printindex vr
3630 @page
3631 @node General Index,  , Macro and Variable Index, Top
3632 @unnumbered General Index
3634 @printindex cp
3637 @page
3638 @contents
3639 @bye