cygwin fixes
[automake.git] / automake.texi
blob7b854b3c6b2eaed53ddc52dcc2a56cf281aef989
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 admin
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 (C) 1995, 96 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, 96 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 variables.
80 @defcodeindex cv
81 @c Define an index of options.
82 @defcodeindex op
83 @c Define an index of targets.
84 @defcodeindex tr
86 @c Put everything in one index (arbitrarily chosen to be the concept index).
87 @syncodeindex cv cp
88 @syncodeindex op cp
89 @syncodeindex tr cp
91 @ifinfo
92 @node Top, Introduction, (dir), (dir)
93 @comment  node-name,  next,  previous,  up
94 @top GNU Automake
96 This file documents the GNU Automake package for creating GNU
97 Standards-compliant Makefiles from template files.  This edition
98 documents version @value{VERSION}.
100 @menu
101 * Introduction::                Automake's purpose
102 * Generalities::                General ideas
103 * Examples::                    Some example packages
104 * Invoking Automake::           Creating a Makefile.in
105 * configure::                   Scanning configure.in
106 * Top level::                   The top-level Makefile.am
107 * Programs::                    Building programs and libraries
108 * Other objects::               Other derived objects
109 * Other GNU Tools::             Other GNU Tools
110 * Documentation::               Building documentation
111 * Install::                     What gets installed
112 * Clean::                       What gets cleaned
113 * Dist::                        What goes in a distribution
114 * Tests::                       Support for test suites
115 * Options::                     Changing Automake's behavior
116 * Miscellaneous::               Miscellaneous rules
117 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
118 * Cygnus::                      The effect of @code{--cygnus}
119 * Extending::                   Extending Automake
120 * Distributing::                Distributing the Makefile.in
121 * Future::                      Some ideas for the future
122 * Index::                       General index
123 @end menu
125 @end ifinfo
127 @node Introduction
128 @chapter Introduction
130 Automake is a tool for automatically generating
131 @file{Makefile.in}s from files called @file{Makefile.am}.  The
132 @file{Makefile.am} is basically a series of @code{make} macro
133 definitions (with rules being thrown in occasionally).  The generated
134 @file{Makefile.in}s are compliant with the GNU Makefile standards.
136 The GNU Makefile Standards Document
137 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
138 is long, complicated, and subject to change.  The goal of Automake is to
139 remove the burden of Makefile maintenance from the back of the
140 individual GNU maintainer (and put it on the back of the Automake
141 maintainer).
143 The typical Automake input files is simply a series of macro
144 definitions.  Each such file is processed to create a
145 @file{Makefile.in}.  There should generally be one @file{Makefile.am}
146 per directory of a project.
148 Automake does constrain a project in certain ways; for instance it
149 assumes that the project uses Autoconf
150 (@pxref{Top, , The Autoconf Manual, autoconf, The Autoconf Manual}),
151 and enforces certain restrictions on the @file{configure.in} contents.
153 Automake requires @code{perl} in order to generate the
154 @file{Makefile.in}s.  However, the distributions created by Automake are
155 fully GNU standards-compliant, and do not require @code{perl} in order
156 to be built.
158 Mail suggestions and bug reports for Automake to
159 @email{automake-bugs@@gnu.ai.mit.edu}.
162 @node Generalities
163 @chapter General ideas
165 There are a few basic ideas that will help understand how Automake
166 works.
168 @menu
169 * General Operation::           General operation of Automake
170 * Depth::                       The kinds of packages
171 * Strictness::                  Standards conformance checking
172 * Uniform::                     The Uniform Naming Scheme
173 * Canonicalization::            How derived variables are named
174 @end menu
176 @node General Operation
177 @section General Operation
179 Automake works by reading a @file{Makefile.am} and generating a
180 @file{Makefile.in}.  Certain macros and targets defined in the
181 @file{Makefile.am} instruct automake to generate more specialized code;
182 for instances a @samp{bin_PROGRAMS} macro definition will cause targets
183 for compiling and linking to be generated.
185 The macro definitions and targets in the @file{Makefile.am} are copied
186 into the generated file.  This allows you to add arbitrary code into the
187 generated @file{Makefile.in}.  For instance the Automake distribution
188 includes a non-standard @code{cvs-dist} target, which the Automake
189 maintainer uses to make distributions from his source control system.
191 Note that GNU make extensions are not recognized by Automake.  Using
192 such extensions in a @file{Makefile.am} will lead to errors or confusing
193 behavior.
195 Automake tries to group comments with adjoining targets (or variable
196 definitions) in an intelligent way.
198 A target defined in @file{Makefile.am} generally overrides any such
199 target of a similar name that would be automatically generated by
200 @code{automake}.  Although this is a supported feature, it is generally
201 best to avoid making use of it, as sometimes the generated rules are
202 very particular.
204 Similarly, a variable defined in @file{Makefile.am} will override any
205 definition of the variable that @code{automake} would ordinarily create.
206 This feature is more often useful than the ability to override a target
207 definition.  Be warned that many of the variables generated by
208 @code{automake} are considered to be for internal use only, and their
209 names might change in future releases.
211 When examining a variable definition, Automake will recursively examine
212 variables referenced in the definition.  E.g., if Automake is looking at
213 the content of @samp{foo_SOURCES} in this snippet
215 @example
216 xs = a.c b.c
217 foo_SOURCES = c.c $(xs)
218 @end example
220 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
221 contents of @samp{foo_SOURCES}.
223 Automake also allows a form of comment which is @emph{not} copied into
224 the output; all lines beginning with @samp{##} are completely ignored by
225 Automake.
227 It is customary to make the first line of @file{Makefile.am} read:
229 @example
230 ## Process this file with automake to produce Makefile.in
231 @end example
233 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
234 @c I don't know quite what to say.
236 @c FIXME document customary ordering of Makefile.am here!
240 @node Depth
241 @section Depth
242 @code{automake} supports three kinds of directory hierarchy: ``flat'',
243 ``shallow'', and ``deep''.
245 A @dfn{flat} package is one in which all the files are in a single
246 directory.  The @file{Makefile.am} for such a package by definition
247 lacks a @code{SUBDIRS} macro.  An example of such a package is
248 @code{termutils}.
249 @vindex SUBDIRS
251 A @dfn{deep} package is one in which all the source lies in
252 subdirectories; the top level directory contains mainly configuration
253 information.  GNU cpio is a good example of such a package, as is GNU
254 @code{tar}.  The top level @file{Makefile.am} for a deep package will
255 contain a @code{SUBDIRS} macro, but no other macros to define objects
256 which are built.
258 A @dfn{shallow} package is one in which the primary source resides in
259 the top-level directory, while various parts (typically libraries)
260 reside in subdirectories.  Automake is one such package (as is GNU
261 @code{make}, which does not currently use @code{automake}).
264 @node Strictness
265 @section Strictness
266 While Automake is intended to be used by maintainers of GNU packages, it
267 does make some effort to accommodate those who wish to use it, but do
268 not want to use all the GNU conventions.
270 To this end, Automake supports three levels of @dfn{strictness}---the
271 strictness indicating how stringently Automake should check standards
272 conformance.
274 The valid strictness levels are:
276 @table @samp
277 @item foreign
278 Automake will check for only those things which are absolutely
279 required for proper operations.  For instance, whereas GNU standards
280 dictate the existence of a @file{NEWS} file, it will not be required in
281 this mode.  The name comes from the fact that Automake is intended to be
282 used for GNU programs; these relaxed rules are not the standard mode of
283 operation.
285 @item gnu
286 Automake will check---as much as possible---for compliance to the GNU
287 standards for packages.  This is the default.
289 @item gnits
290 Automake will check for compliance to the as-yet-unwritten Gnits
291 standards.  These are based on the GNU standards, but are even more
292 detailed.  Unless you are a Gnits standards contributor, it is
293 recommended that you avoid this option until such time as the Gnits
294 standard is actually published.
295 @end table
297 For more information on the precise implications of the strictness
298 level, see @xref{Gnits}.
301 @node Uniform
302 @section The Uniform Naming Scheme
303 Automake variables generally follow a uniform naming scheme that makes
304 it easy to decide how programs (and other derived objects) are built,
305 and how they are installed.  This scheme also supports @code{configure}
306 time determination of what should be built.
308 At @code{make} time, certain variables are used to determine which
309 objects are to be built.  These variables are called @dfn{primary}
310 variables.  For instance, the primary variable @code{PROGRAMS} holds a
311 list of programs which are to be compiled and linked.
312 @vindex PROGRAMS
314 A different set of variables is used to decide where the built objects
315 should be installed.  These variables are named after the primary
316 variables, but have a prefix indicating which standard directory should
317 be used as the installation directory.  The standard directory names are
318 given in the GNU standards
319 (@pxref{Directory Variables, , , standards, The GNU Coding
320 Standards}).
321 Automake extends this list with @code{pkglibdir}, @code{pkgincludedir},
322 and @code{pkgdatadir}; these are the same as the non-@samp{pkg}
323 versions, but with @samp{@@PACKAGE@@} appended.
324 @cvindex PACKAGE
326 For each primary, there is one additional variable named by prepending
327 @samp{EXTRA_} to the primary name.  This variable is used to list
328 objects which may or may not be built, depending on what
329 @code{configure} decides.  This variable is required because Automake
330 must statically know the entire list of objects to be built in order to
331 generate a @file{Makefile.in} that will work in all cases.
333 For instance, @code{cpio} decides at configure time which programs are
334 built.  Some of the programs are installed in @code{bindir}, and some
335 are installed in @code{sbindir}:
337 @example
338 EXTRA_PROGRAMS = mt rmt
339 bin_PROGRAMS = cpio pax
340 sbin_PROGRAMS = @@PROGRAMS@@
341 @end example
343 Defining a primary variable without a prefix (eg @code{PROGRAMS}) is an
344 error.
346 Note that the common @samp{dir} suffix is left off when constructing the
347 variable names; thus one writes @samp{bin_PROGRAMS} and not
348 @samp{bindir_PROGRAMS}.
350 Not every sort of object can be installed in every directory.  Automake
351 will flag those attempts it finds in error.  Automake will also diagnose
352 obvious misspellings in directory names.
354 Sometimes the standard directories---even as augmented by Automake---
355 are not enough.  In particular it is sometimes useful, for clarity, to
356 install objects in a subdirectory of some predefined directory.  To this
357 end, Automake allows you to extend the list of possible installation
358 directories.  A given prefix (eg @samp{zar}) is valid if a variable of
359 the same name with @samp{dir} appended is defined (eg @samp{zardir}).
361 For instance, until HTML support is part of Automake, you could use this
362 to install raw HTML documentation:
364 @example
365 htmldir = $(prefix)/html
366 html_DATA = automake.html
367 @end example
369 The special prefix @samp{noinst} indicates that the objects in question
370 should not be installed at all.
372 The special prefix @samp{check} indicates that the objects in question
373 should not be built until the @code{make check} command is run.
375 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
376 @samp{LISP}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS}, @samp{MANS},
377 and @samp{TEXINFOS}.
378 @vindex PROGRAMS
379 @vindex LIBRARIES
380 @vindex LISP
381 @vindex SCRIPTS
382 @vindex DATA
383 @vindex HEADERS
384 @vindex MANS
385 @vindex TEXINFOS
388 @node Canonicalization
389 @section How derived variables are named
391 Sometimes a Makefile variable name is derived from some text the user
392 supplies.  For instance program names are rewritten into Makefile macro
393 names.  Automake canonicalizes this text, so that it does not have to
394 follow Makefile variable naming rules.  All characters in the name
395 except for letters, numbers, and the underscore are turned into
396 underscores when making macro references.  E.g., if your program is named
397 @code{sniff-glue}, the derived variable name would be
398 @code{sniff_glue_SOURCES}, not @code{sniff-glue_SOURCES}.
401 @node Examples
402 @chapter Some example packages
404 @menu
405 * Hello::                       A classic program
406 * etags::                       Building etags and ctags
407 @end menu
409 @node Hello
410 @section A classic program
412 @code{hello} is renowned for its classic simplicity and versatility.
413 What better place to begin a tour?  The below shows how Automake could
414 be used with the Hello package.  The examples below are from the latest
415 GNU Hello, but all the maintainer-only code has been stripped out, as
416 well as all copyright comments.
418 Of course, GNU Hello is somewhat more featureful than your traditional
419 two-liner.  GNU Hello is internationalized, does option processing, and
420 has a manual and a test suite.  GNU Hello is a deep package.
422 Here is the @file{configure.in} from GNU Hello:
424 @example
425 dnl Process this file with autoconf to produce a configure script.
426 AC_INIT(src/hello.c)
427 AM_INIT_AUTOMAKE(hello, 1.3.11)
428 AM_CONFIG_HEADER(config.h)
430 dnl Set of available languages.
431 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
433 dnl Checks for programs.
434 AC_PROG_CC
435 AC_ISC_POSIX
437 dnl Checks for libraries.
439 dnl Checks for header files.
440 AC_STDC_HEADERS
441 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
443 dnl Checks for library functions.
444 AC_FUNC_ALLOCA
446 dnl Check for st_blksize in struct stat
447 AC_ST_BLKSIZE
449 dnl internationalization macros
450 AM_GNU_GETTEXT
451 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
452            src/Makefile tests/Makefile tests/hello],
453    [chmod +x tests/hello])
454 @end example
456 The @samp{AM_} macros are provided by Automake (or the Gettext library);
457 the rest are standard Autoconf macros.
460 The top-level @file{Makefile.am}:
462 @example
463 EXTRA_DIST = BUGS ChangeLog.O
464 SUBDIRS = doc intl po src tests
465 @end example
467 As you can see, all the work here is really done in subdirectories.
469 The @file{po} and @file{intl} directories are automatically generated
470 using @code{gettextize}; they will not be discussed here.
472 In @file{doc/Makefile.am} we see:
474 @example
475 info_TEXINFOS = hello.texi
476 hello_TEXINFOS = gpl.texi
477 @end example
479 This is sufficient to build, install, and distribute the Hello manual.
482 Here is @file{tests/Makefile.am}:
484 @example
485 TESTS = hello
486 EXTRA_DIST = hello.in testdata
487 @end example
489 The script @file{hello} is generated by @code{configure}, and is the
490 only test case.  @code{make check} will run this test.
492 Last, @file{src/Makefile.am}, where all the real work is done:
494 @example
495 bin_PROGRAMS = hello
496 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
497 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
498 localedir = $(datadir)/locale
499 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
500 @end example
503 @node etags
504 @section Building etags and ctags
506 Here is another, trickier example.  It shows how to generate two
507 programs (@code{ctags} and @code{etags}) from the same source file
508 (@file{etags.c}).  The difficult part is that each compilation of
509 @file{etags.c} requires different @code{cpp} flags.
511 @example
512 bin_PROGRAMS = etags ctags
513 ctags_SOURCES =
514 ctags_LDADD = ctags.o
516 etags.o:
517         $(COMPILE) -DETAGS_REGEXPS etags.c
519 ctags.o:
520         $(COMPILE) -DCTAGS -o ctags.o etags.c
521 @end example
523 Note that @code{ctags_SOURCES} is defined to be empty---that way no
524 implicit value is substituted.  The implicit value, however, is used to
525 generate @code{etags} from @file{etags.o}.
527 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
528 @code{ctags_DEPENDENCIES} is generated by Automake.
531 @node Invoking Automake
532 @chapter Creating a @file{Makefile.in}
534 To create all the @file{Makefile.in}s for a package, run the
535 @code{automake} program in the top level directory, with no arguments.
536 @code{automake} will automatically find each appropriate
537 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
538 and generate the corresponding @file{Makefile.in}.  Note that
539 @code{automake} has a rather simplistic view of what constitutes a
540 package; it assumes that a package has only one @file{configure.in}, at
541 the top.  If your package has multiple @file{configure.in}s, then you
542 must run @code{automake} in each directory holding a
543 @file{configure.in}.
545 You can optionally give @code{automake} an argument; @samp{.am} is
546 appended to the argument and the result is used as the name of the input
547 file.  This feature is generally only used to automatically rebuild an
548 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
549 be run from the topmost directory of a project, even if being used to
550 regenerate the @file{Makefile.in} in some subdirectory.  This is
551 necessary because @code{automake} must scan @file{configure.in}, and
552 because @code{automake} uses the knowledge that a @file{Makefile.in} is
553 in a subdirectory to change its behavior in some cases.
555 @code{automake} accepts the following options:
557 @table @code
558 @item -a
559 @itemx --add-missing
560 Automake requires certain common files to exist in certain situations;
561 for instance @file{config.guess} is required if @file{configure.in} runs
562 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
563 files; this option will cause the missing ones to be automatically added
564 to the package, whenever possible.  In general if Automake tells you a
565 file is missing, try using this option.
567 @item --amdir=@var{dir}
568 Look for Automake data files in directory @var{dir} instead of in the
569 installation directory.  This is typically used for debugging.
571 @item --build-dir=@var{dir}
572 Tell Automake where the build directory is.  This option is used when
573 including dependencies into a @file{Makefile.in} generated by @code{make
574 dist}; it should not be used otherwise.
576 @item --cygnus
577 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
578 of GNU or Gnits rules.  @xref{Cygnus} for more information.
580 @item --foreign
581 Set the global strictness to @samp{foreign}.  @xref{Strictness} for more
582 information.
584 @item --gnits
585 Set the global strictness to @samp{gnits}.  @xref{Gnits} for more
586 information.
588 @item --gnu
589 Set the global strictness to @samp{gnu}.  @xref{Gnits} for more
590 information.  This is the default strictness.
592 @item --help
593 Print a summary of the command line options and exit.
595 @item -i
596 @itemx --include-deps
597 Include all automatically generated dependency information
598 (@pxref{Dependencies}) in the generated
599 @file{Makefile.in}.  This is generally done when making a distribution;
600 see @ref{Dist}.
602 @item -o @var{dir}
603 @itemx --output-dir=@var{dir}
604 Put the generated @file{Makefile.in} in the directory @var{dir}.
605 Ordinarily each @file{Makefile.in} is created in the directory of the
606 corresponding @file{Makefile.am}.  This option is used when making
607 distributions.
609 @item --srcdir-name=@var{dir}
610 Tell Automake the name of the source directory associated with the
611 current build.  This option is used when including dependencies into a
612 @file{Makefile.in} generated by @code{make dist}; it should not be used
613 otherwise.
615 @item -v
616 @itemx --verbose
617 Cause Automake to print information about which files are being read or
618 created.
620 @item --version
621 Print the version number of Automake and exit.
622 @end table
625 @node configure
626 @chapter Scanning @file{configure.in}
628 Automake scans the package's @file{configure.in} to determine certain
629 information about the package.  Some @code{autoconf} macros are required
630 and some variables must be defined in @file{configure.in}.  Automake
631 will also use information from @file{configure.in} to further tailor its
632 output.
634 Automake also supplies some @code{autoconf} macros to make the
635 maintenance easier.  These macros can automatically be put into your
636 @file{aclocal.m4} using the @code{aclocal} program.
638 @menu
639 * Requirements::                Configuration requirements
640 * Optional::                    Other things Automake recognizes
641 * Invoking aclocal::            Auto-generating aclocal.m4
642 * Macros::                      Autoconf macros supplied with Automake
643 * Extending aclocal::           Writing your own aclocal macros
644 @end menu
647 @node Requirements
648 @section Configuration requirements
650 The simplest way to meet the basic Automake requirements is to use the
651 macro @code{AM_INIT_AUTOMAKE} (FIXME: xref).  But if you prefer, you can
652 do the required steps by hand:
653 @cvindex AM_INIT_AUTOMAKE
655 @itemize @bullet
656 @item
657 Define the variables @code{PACKAGE} and @code{VERSION} with
658 @code{AC_SUBST}.
659 @cvindex PACKAGE
660 @cvindex VERSION
661 @code{PACKAGE} should be the name of the package as it appears when
662 bundled for distribution.  For instance, Automake defines @code{PACKAGE}
663 to be @samp{automake}.  @code{VERSION} should be the version number of
664 the release that is being developed.  We recommend that you make
665 @file{configure.in} the only place in your package where the version
666 number is defined; this makes releases simpler.
668 Automake doesn't do any interpretation of @code{PACKAGE} or
669 @code{VERSION}, except in @samp{Gnits} mode (FIXME xref).
671 @item
672 Use the macro @code{AC_ARG_PROGRAM} if a program or script is installed.
673 @cvindex AC_ARG_PROGRAM
675 @item
676 Use @code{AC_PROG_MAKE_SET} if the package is not flat.
677 @cvindex AC_PROG_MAKE_SET
679 @item
680 Use @code{AM_PROG_INSTALL} if any scripts (@pxref{Scripts}) are
681 installed by the package.  Otherwise, use @code{AC_PROG_INSTALL}.
682 @cvindex AC_PROG_INSTALL
683 @cvindex AM_PROG_INSTALL
684 @end itemize
687 Here are the other macros which Automake requires but which are not run
688 by @code{AM_INIT_AUTOMAKE}:
690 @table @code
691 @item AC_OUTPUT
692 Automake uses this to determine which files to create.  Listed files
693 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
694 files are treated differently.  Currently the only difference is that a
695 @file{Makefile} is removed by @code{make distclean}, while other files
696 are removed by @code{make clean}.
697 @c FIXME: this is in violation of standards!
698 @cvindex AC_OUTPUT
699 @end table
701 @node Optional
702 @section Other things Automake recognizes
704 Automake will also recognize the use of certain macros and tailor the
705 generated @file{Makefile.in} appropriately.  Currently recognized macros
706 and their effects are:
708 @table @code
709 @item AC_CONFIG_HEADER
710 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
711 to @code{AC_CONFIG_HEADER} but does some useful Automake-specific work.
712 @cvindex AC_CONFIG_HEADER
714 @item AC_CONFIG_AUX_DIR
715 Automake will look for various helper scripts, such as
716 @file{mkinstalldirs}, in the directory named in this macro invocation.
717 If not seen, the scripts are looked for in their ``standard'' locations
718 (either the top source directory, or in the source directory
719 corresponding to the current @file{Makefile.am}, whichever is
720 appropriate).
721 @cvindex AC_CONFIG_AUX_DIR
722 FIXME: give complete list of things looked for in this directory
724 @item AC_PATH_XTRA
725 Automake will insert definitions for the variables defined by
726 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
727 or library.
728 @cvindex AC_PATH_XTRA
730 @item AC_CANONICAL_HOST
731 @itemx AC_CHECK_TOOL
732 Automake will ensure that @file{config.guess} and @file{config.sub}
733 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
734 @samp{host_triplet} are introduced.
735 @c fixme xref autoconf docs.
736 @cvindex AC_CANONICAL_HOST
737 @cvindex AC_CHECK_TOOL
738 @vindex host_alias
739 @vindex host_triplet
741 @item AC_CANONICAL_SYSTEM
742 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
743 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
744 @cvindex AC_CANONICAL_SYSTEM
745 @vindex build_alias
746 @vindex target_alias
748 @item AC_FUNC_ALLOCA
749 @itemx AC_FUNC_GETLOADAVG
750 @itemx AC_FUNC_MEMCMP
751 @itemx AC_STRUCT_ST_BLOCKS
752 @itemx AC_FUNC_FNMATCH
753 @itemx AM_FUNC_STRTOD
754 @itemx AC_REPLACE_FUNCS
755 @itemx AC_REPLACE_GNU_GETOPT
756 @itemx AM_WITH_REGEX
757 Automake will ensure that the appropriate dependencies are generated for
758 the objects corresponding to these macros.  Also, Automake will verify
759 that the appropriate source files are part of the distribution.  Note
760 that Automake does not come with any of the C sources required to use
761 these macros, so @code{automake -a} will not install the sources.
762 @xref{A Library} for more information.
763 @cvindex AC_FUNC_ALLOCA
764 @cvindex AC_FUNC_GETLOADAVG
765 @cvindex AC_FUNC_MEMCMP
766 @cvindex AC_STRUCT_ST_BLOCKS
767 @cvindex AC_FUNC_FNMATCH
768 @cvindex AC_FUNC_FNMATCH
769 @cvindex AC_REPLACE_FUNCS
770 @cvindex AC_REPLACE_GNU_GETOPT
771 @cvindex AM_FUNC_STRTOD
772 @cvindex AM_WITH_REGEX
774 @item LIBOBJS
775 Automake will detect statements which put @samp{.o} files into
776 @code{LIBOBJS}, and will treat these additional files as if they were
777 discovered via @code{AC_REPLACE_FUNCS}.
778 @cvindex LIBOBJS
780 @item AC_PROG_RANLIB
781 This is required if any libraries are built in the package.
782 @cvindex AC_PROG_RANLIB
784 @item AC_PROG_CXX
785 This is required if any C++ source is included.
786 @cvindex AC_PROG_CXX
788 @item AM_PROG_LIBTOOL
789 Automake will turn on processing for @code{libtool} (@pxref{Top, , The
790 Libtool Manual, libtool, The Libtool Manual}).
791 @cvindex AM_PROG_LIBTOOL
793 @item AC_PROG_YACC
794 If a Yacc source file is seen, then you must either use this macro or
795 define the variable @samp{YACC} in @file{configure.in}.  The former is
796 preferred.
797 @cvindex AC_PROG_YACC
798 @cvindex YACC
800 @item AC_DECL_YYTEXT
801 This macro is required if there is Lex source in the package.
802 @cvindex AC_DECL_YYTEXT
804 @item AC_PROG_LEX
805 If a Lex source file is seen, then this macro must be used.
806 @cvindex AC_PROG_LEX
808 @item ALL_LINGUAS
809 If Automake sees that this variable is set in @file{configure.in}, it
810 will check the @file{po} directory to ensure that all the named
811 @samp{.po} files exist, and that all the @samp{.po} files that exist are
812 named.
813 @cvindex ALL_LINGUAS
815 @item AM_C_PROTOTYPES
816 This is required when using automatic de-ANSI-fication, see @ref{ANSI}.
817 @cvindex AM_C_PROTOTYPES
819 @item AM_GNU_GETTEXT
820 This macro is required for packages which use GNU gettext
821 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
822 this macro it ensures that the package meets some of gettext's
823 requirements.
824 @cvindex AM_GNU_GETTEXT
826 @item AM_MAINTAINER_MODE
827 This macro adds a @samp{--enable-maintainer-mode} option to
828 @code{configure}.  If this is used, @code{automake} will cause
829 ``maintainer-only'' rules to be turned off by default in the generated
830 @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits} mode.
831 FIXME xref.
832 @cvindex AM_MAINTAINER_MODE
834 @item AC_SUBST
835 @itemx AC_CHECK_TOOL
836 @itemx AC_CHECK_PROG
837 @itemx AC_CHECK_PROGS
838 @itemx AC_PATH_PROG
839 @itemx AC_PATH_PROGS
840 For each of these macros, the first argument is automatically defined as
841 a variable in each generated @file{Makefile.in}.
842 @cvindex AC_SUBST
843 @cvindex AC_CHECK_TOOL
844 @cvindex AC_CHECK_PROG
845 @cvindex AC_CHECK_PROGS
846 @cvindex AC_PATH_PROG
847 @cvindex AC_PATH_PROGS
849 @end table
852 @node Invoking aclocal
853 @section Auto-generating aclocal.m4
855 Automake includes a number of Autoconf macros which can be used in your
856 package; some of them are actually required by Automake in certain
857 situations.  These macros must be defined in your @file{aclocal.m4};
858 otherwise they will not be seen by @code{autoconf}.
860 The @code{aclocal} program will automatically generate @file{aclocal.m4}
861 files based on the contents of @file{configure.in}.  This provides a
862 convenient way to get Automake-provided macros, without having to
863 search around.  Also, the @code{aclocal} mechanism is extensible for use
864 by other packages.
866 At startup, @code{aclocal} scans all the @samp{.m4} files it can find,
867 looking for macro definitions.  Then it scans @file{configure.in}.  Any
868 mention of one of the macros found in the first step causes that macro,
869 and any macros it in turn requires, to be put into @file{aclocal.m4}.
871 The contents of @file{acinclude.m4}, if it exists, are also
872 automatically included in @file{aclocal.m4}.  This is useful for
873 incorporating local macros into @file{configure}.
875 @code{aclocal} accepts the following options:
877 @table @code
878 @item --acdir=@var{dir}
879 Look for the macro files in @var{dir} instead of the installation
880 directory.  This is typically used for debugging.
882 @item --help
883 Print a summary of the command line options and exit.
885 @item -I @var{dir}
886 Add the directory @var{dir} to the list of directories searched for
887 @samp{.m4} files.
889 @item --output=@var{file}
890 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
892 @item --verbose
893 Print the names of the files it examines.
895 @item --version
896 Print the version number of Automake and exit.
897 @end table
900 @node Macros
901 @section Autoconf macros supplied with Automake
903 @c consider generating this node automatically from m4 files.
905 @table @code
906 @item AM_CONFIG_HEADER
907 Automake will generate rules to automatically regenerate the config
908 header.  If you do use this macro, you must create the file
909 @file{stamp-h.in} in your source directory.  It can be empty.
910 @cvindex AM_CONFIG_HEADER
912 @item AM_CYGWIN32
913 Check to see if this @code{configure} is being run in the
914 @samp{Cygwin32} environment.  (FIXME xref).  If so, define output
915 variable @code{EXEEXT} to @samp{.exe}; otherwise define it to the empty
916 string.  Automake recognizes this macro and uses it to generate
917 @file{Makefile.in}s which will automatically work under @samp{Cygwin32}.
918 In the @samp{Cygwin32} environment, @code{gcc} generates executables
919 whose names end in @samp{.exe}, even if this was not specified on the
920 command line.  Automake adds special code to @file{Makefile.in} to
921 gracefully deal with this.
923 @item AM_FUNC_STRTOD
924 If the @code{strtod} function is not available, or does not work
925 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
926 variable @code{LIBOBJS}.
927 @cvindex AM_FUNC_STRTOD
929 @item AM_FUNC_ERROR_AT_LINE
930 If the function @code{error_at_line} is not found, then add
931 @file{error.o} to @code{LIBOBJS}.
932 @cvindex AM_FUNC_ERROR_AT_LINE
934 @item AM_FUNC_MKTIME
935 Check for a working @code{mktime} function.  If not found, add
936 @file{mktime.o} to @samp{LIBOBJS}.
937 @cvindex AM_FUNC_MKTIME
939 @item AM_FUNC_OBSTACK
940 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
941 @samp{LIBOBJS}.
942 @cvindex AM_FUNC_OBSTACK
944 @item AM_C_PROTOTYPES
945 Check to see if function prototypes are understood by the compiler.  If
946 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
947 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
948 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
949 values to implement automatic de-ANSI-fication.
950 @cvindex AM_C_PROTOTYPES
952 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
953 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
954 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
955 found in @file{<termios.h>}.
956 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
958 @item AM_PATH_LISPDIR
959 Searches for the program @code{emacs}, and, if found, sets the output
960 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
961 @cvindex AM_PATH_LISPDIR
963 @item AM_PROG_CC_STDC
964 If the C compiler in not in ANSI C mode by default, try to add an option
965 to output variable @code{CC} to make it so.  This macro tries various
966 options that select ANSI C on some system or another.  It considers the
967 compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
968 handles function prototypes correctly.
970 If you use this macro, you should check after calling it whether the C
971 compiler has been set to accept ANSI C; if not, the shell variable
972 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
973 code in ANSI C, you can make an un-ANSIfied copy of it by using the
974 @code{ansi2knr} option.
975 @cvindex AM_PROG_CC_STDC
977 @item AM_PROG_INSTALL
978 Like @code{AC_PROG_INSTALL}, but also defines @code{INSTALL_SCRIPT}.
979 @cvindex AM_PROG_INSTALL
981 @item AM_SANITY_CHECK_CC
982 This checks to make sure that a file created in the build directory is
983 newer than a file in the source directory.  This can fail on systems
984 where the clock is set incorrectly.  This macro is automatically run
985 from @code{AM_INIT_AUTOMAKE}.
986 @cvindex AM_SANITY_CHECK_CC
988 @item AM_SYS_POSIX_TERMIOS
989 Check to see if POSIX termios headers and functions are available on the
990 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
991 @samp{yes}.  If not, set the variable to @samp{no}.
992 @cvindex AM_SYS_POSIX_TERMIOS
994 @item AM_TYPE_PTRDIFF_T
995 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
996 @file{<stddef.h>}.
997 @cvindex AM_TYPE_PTRDIFF_T
999 @item AM_WITH_DMALLOC
1000 Add support for the @code{dmalloc} package.  If the user configures with
1001 @samp{--with-dmalloc}, then define @code{WITH_DMALLOC} and add
1002 @samp{-ldmalloc} to @code{LIBS}.  The @code{dmalloc} package can be
1003 found at @url{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz}
1004 @cvindex AM_WITH_DMALLOC
1006 @item AM_WITH_REGEX
1007 Adds @samp{--with-regex} to the @code{configure} command line.  If
1008 specified (the default), then the @samp{regex} regular expression
1009 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1010 @samp{WITH_REGEX} is defined..  If @samp{--without-regex} is given, then
1011 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1012 into @samp{LIBOBJS}.
1013 @cvindex AM_WITH_REGEX
1014 @end table
1017 @node Extending aclocal
1018 @section Writing your own aclocal macros
1020 Aclocal doesn't have any built-in knowledge of any macros, so it is easy
1021 to extend it with your own macros.
1023 This is mostly used for libraries which want to supply their own
1024 Autoconf macros for use by other programs.  For instance the
1025 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1026 should be used by any package using @code{gettext}.  When the library is
1027 installed, it installs this macro so that @code{aclocal} will find it.
1029 A file of macros should be a series of @code{AC_DEFUN}'s.  Aclocal also
1030 understands @code{AC_REQUIRE}, so it is safe to put each macro in a
1031 separate file.
1033 A macro file's name should end in @samp{.m4}.  Such files should be
1034 installed in @file{$(datadir)/aclocal}.
1036 @node Top level
1037 @chapter The top-level @file{Makefile.am}
1039 In non-flat packages, the top level @file{Makefile.am} must tell
1040 Automake which subdirectories are to be built.  This is done via the
1041 @code{SUBDIRS} variable.
1042 @vindex SUBDIRS
1044 The @code{SUBDIRS} macro holds a list of subdirectories in which
1045 building of various sorts can occur.  Many targets (eg @code{all}) in
1046 the generated @file{Makefile} will run both locally and in all specified
1047 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1048 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1049 (after configuration).  This allows inclusion of libraries from packages
1050 which do not use Automake (such as @code{gettext}).
1052 In a deep package, the top-level @file{Makefile.am} is often very short.
1053 For instance, here is the @file{Makefile.am} from the Hello
1054 distribution:
1056 @example
1057 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1058 SUBDIRS = doc intl po src tests
1059 @end example
1061 @code{SUBDIRS} can contain configure substitutions (eg @samp{@@DIRS@@});
1062 Automake itself does not actually examine the contents of this variable.
1064 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1065 @code{AC_PROG_MAKE_SET}.
1067 The use of @code{SUBDIRS} is not restricted to just the top-level
1068 @file{Makefile.am}.  Automake can be used to construct packages of
1069 arbitrary depth.
1072 @node Programs
1073 @chapter Building Programs and Libraries
1075 A large part of Automake's functionality is dedicated to making it easy
1076 to build C programs and libraries.
1078 @menu
1079 * A Program::                   Building a program
1080 * A Library::                   Building a library
1081 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1082 * A Shared Library::            Building a Libtool library
1083 * Program variables::           Variables used when building a program
1084 * Yacc and Lex::                Yacc and Lex support
1085 * C++::                         C++ and other languages
1086 * ANSI::                        Automatic de-ANSI-fication
1087 * Dependencies::                Automatic dependency tracking
1088 @end menu
1091 @node A Program
1092 @section Building a program
1094 In a directory containing source that gets built into a program (as
1095 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1096 can be installed in @samp{bindir}, @samp{sbindir}, @samp{libexecdir},
1097 @samp{pkglibdir}, or not at all (@samp{noinst}).
1099 For instance:
1101 @example
1102 bin_PROGRAMS = hello
1103 @end example
1105 In this simple case, the resulting @file{Makefile.in} will contain code
1106 to generate a program named @code{hello}.  The variable
1107 @code{hello_SOURCES} is used to specify which source files get built
1108 into an executable:
1110 @example
1111 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
1112 @end example
1114 This causes each mentioned @samp{.c} file to be compiled into the
1115 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1117 If @samp{prog_SOURCES} is needed, but not specified, then it defaults to
1118 the single file @file{prog.c}.  In the example above, the definition of
1119 @code{hello_SOURCES} is actually redundant.
1120 @vindex _SOURCES
1121 @vindex SOURCES
1123 Multiple programs can be built in a single directory.  Multiple programs
1124 can share a single source file.  The source file must be listed in each
1125 @samp{_SOURCES} definition.
1127 Header files listed in a @samp{_SOURCES} definition will be included in
1128 the distribution but otherwise ignored.  In case it isn't obvious, you
1129 should not include the header file generated by @file{configure} in an
1130 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1131 (@samp{.l}) and yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1132 and Lex}.
1134 Sometimes it is useful to determine the programs that are to be built at
1135 configure time.  For instance, GNU @code{cpio} only builds @code{mt} and
1136 @code{rmt} under special circumstances.
1138 In this case, you must notify @code{automake} of all the programs that
1139 can possibly be built, but at the same time cause the generated
1140 @file{Makefile.in} to use the programs specified by @code{configure}.
1141 This is done by having @code{configure} substitute values into each
1142 @samp{_PROGRAMS} definition, while listing all optionally built programs in
1143 @code{EXTRA_PROGRAMS}.
1144 @vindex EXTRA_PROGRAMS
1146 If you need to link against libraries that are not found by
1147 @code{configure}, you can use @code{LDADD} to do so.  This variable
1148 actually can be used to add any options to the linker command line.
1149 @vindex LDADD
1151 Sometimes, multiple programs are built in one directory but do not share
1152 the same link-time requirements.  In this case, you can use the
1153 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1154 program as it appears in some @samp{_PROGRAMS} variable, and usually
1155 written in lowercase) to override the global @code{LDADD}.  (If this
1156 variable exists for a given program, then that program is not linked
1157 using @code{LDADD}.)
1158 @vindex _LDADD
1160 For instance, in GNU cpio, @code{pax}, @code{cpio}, and @code{mt} are
1161 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1162 built in the same directory, and has no such link requirement.  Also,
1163 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1164 is what cpio's @file{src/Makefile.am} looks like (abridged):
1166 @example
1167 bin_PROGRAMS = cpio pax @@MT@@
1168 libexec_PROGRAMS = @@RMT@@
1169 EXTRA_PROGRAMS = mt rmt
1171 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1172 rmt_LDADD =
1174 cpio_SOURCES = @dots{}
1175 pax_SOURCES = @dots{}
1176 mt_SOURCES = @dots{}
1177 rmt_SOURCES = @dots{}
1178 @end example
1180 @samp{prog_LDADD} is inappropriate for passing program-specific linker
1181 flags (except for @samp{-l} and @samp{-L}).  So, use the
1182 @samp{prog_LDFLAGS} variable for this purpose.
1183 @vindex _LDFLAGS
1185 It is also occasionally useful to have a program depend on some other
1186 target which is not actually part of that program.  This can be done
1187 using the @samp{prog_DEPENDENCIES} variable.  Each program depends on
1188 the contents of such a variable, but no further interpretation is done.
1190 If @samp{prog_DEPENDENCIES} is not supplied, it is computed by Automake.
1191 The automatically-assigned value is the contents of @samp{prog_LDADD},
1192 with most configure substitutions, @samp{-l}, and @samp{-L} options
1193 removed.  The configure substitutions that are left in are only
1194 @samp{@@LIBOBJS@@} and @samp{@@ALLOCA@@}; these are left because it is
1195 known that they will not cause an invalid value for
1196 @samp{prog_DEPENDENCIES} to be generated.
1199 @node A Library
1200 @section Building a library
1202 Building a library is much like building a program.  In this case, the
1203 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1204 @code{libdir} or @code{pkglibdir}.
1206 @xref{A Shared Library}, for information on how to build shared
1207 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1209 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1210 For instance to create a library named @file{libcpio.a}, but not install
1211 it, you would write:
1213 @example
1214 noinst_LIBRARIES = libcpio.a
1215 @end example
1217 The sources that go into a library are determined exactly as they are
1218 for programs, via the @samp{_SOURCES} variables.  Note that the library
1219 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1220 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1221 not @samp{liblob.a_SOURCES}.
1223 Extra objects can be added to a library using the @samp{library_LIBADD}
1224 variable.  This should be used for objects determined by
1225 @code{configure}.  Again from cpio:
1226 @vindex _LIBADD
1227 @vindex LIBADD
1229 @example
1230 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1231 @end example
1233 @node LIBOBJS
1234 @section Special handling for LIBOBJS and ALLOCA
1236 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1237 @code{@@ALLOCA@@}, and uses this information, plus the list of
1238 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1239 include the appropriate source files in the distribution (@pxref{Dist}).
1240 These source files are also automatically handled in the
1241 dependency-tracking scheme, see @xref{Dependencies}.
1243 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1244 @samp{_LDADD} or @samp{_LIBADD} variable.
1246 @node A Shared Library
1247 @section Building a Shared Library
1249 Building shared libraries is a relatively complex matter.  For this
1250 reason, GNU Libtool (@pxref{Top, , The Libtool Manual, libtool, The
1251 Libtool Manual}) was created to help build shared libraries in a
1252 platform-independent way.
1254 Automake uses Libtool to build libraries declared with
1255 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1256 of shared libraries to build.  For instance, to create a library named
1257 @file{libgettext.a} and its corresponding shared libraries, and install
1258 them in @samp{libdir}, write:
1260 @example
1261 lib_LTLIBRARIES = libgettext.la
1262 @end example
1264 Note that shared libraries @emph{must} be installed, so
1265 @samp{noinst_LTLIBRARIES} and @samp{check_LTLIBRARIES} are not allowed.
1267 For each library, the @samp{library_LIBADD} variable contains the names
1268 of extra libtool objects (@samp{.lo} files) to add to the shared
1269 library.  The @samp{library_LDFLAGS} variable contains any additional
1270 libtool flags, such as @samp{-version-info} or @samp{-static}.
1272 @xref{Using Automake, Using Automake with Libtool, libtool, The Libtool
1273 Manual, The Libtool Manual}, for more information.
1275 @node Program variables
1276 @section Variables used when building a program
1278 Occasionally it is useful to know which @file{Makefile} variables
1279 Automake uses for compilations; for instance you might need to do your
1280 own compilation in some special cases.
1282 Some variables are inherited from Autoconf; these are @code{CC},
1283 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1284 @code{LIBS}.
1285 @vindex LDFLAGS
1287 There are some additional variables which Automake itself defines:
1289 @table @code
1290 @item INCLUDES
1291 A list of @samp{-I} options.  This can be set in your @file{Makefile.am}
1292 if you have special directories you want to look in.  @code{automake}
1293 already provides some @samp{-I} options automatically.  In particular it
1294 generates @samp{-I$(srcdir)} and a @samp{-I} pointing to the directory
1295 holding @file{config.h} (if you've used @code{AC_CONFIG_HEADER} or
1296 @code{AM_CONFIG_HEADER}).
1298 @item COMPILE
1299 This is the command used to actually compile a C source file.  The
1300 filename is appended to form the complete command line.
1302 @item LINK
1303 This is the command used to actually link a C program.
1304 @end table
1307 @node Yacc and Lex
1308 @section Yacc and Lex support
1310 Automake has somewhat idiosyncratic support for Yacc and Lex.
1312 Automake assumes that the @samp{.c} file generated by yacc (or lex)
1313 should be named using the basename of the input file.  That is, for a
1314 yacc source file @file{foo.y}, automake will cause the intermediate file
1315 to be named @file{foo.c} (as opposed to @file{y.tab.c}, which is more
1316 traditional).
1318 The extension of a yacc source file is used to determine the extension
1319 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
1320 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1321 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1322 @samp{.cxx}.  Likewise, lex source files can be used to generate
1323 @samp{C} or @samp{C++}; the extensions @samp{.l}, @samp{.ll},
1324 @samp{.l++}, and @samp{.lxx} are recognized.
1326 You should never explicitly mention the intermediate (@samp{C} or
1327 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1328 file.
1330 The intermediate files generated by yacc (or lex) will be included in
1331 any distribution that is made.  That way the user doesn't need to have
1332 yacc or lex.
1334 If a yacc source file is seen, then your @file{configure.in} must define
1335 the variable @samp{YACC}.  This is most easily done by invoking the
1336 macro @samp{AC_PROG_YACC}.
1338 Similarly, if a lex source file is seen, then your @file{configure.in}
1339 must define the variable @samp{LEX}.  You can use @samp{AC_PROG_LEX} to
1340 do this.  Automake's lex support also requires that you use the
1341 @samp{AC_DECL_YYTEXT} macro---automake needs to know the value of
1342 @samp{LEX_OUTPUT_ROOT}.
1344 Any program including a lex source file must be linked against
1345 @samp{@@LEXLIB@@}.  You can do this by putting @samp{@@LEXLIB@@} into
1346 the appropriate @samp{LDADD} variable.
1348 Automake makes it possible to include multiple yacc (or lex) source
1349 files in a single program.  Automake uses a small program called
1350 @code{interlock} to manage locks between multiple yacc invocations.
1351 This is necessary because yacc's output filename is fixed, and a
1352 parallel make could conceivably invoke more than one instance of
1353 @code{yacc} simultaneously.  @code{interlock} is distributed with
1354 automake.  It should appear in the directory specified by
1355 @samp{AC_CONFIG_AUX_DIR}, or the current directory if that macro is not
1356 used in @file{configure.in}.
1358 For @code{yacc}, simply managing locking is insufficient.  @code{yacc}
1359 output also always uses the same symbol names internally, so it isn't
1360 possible to link two @code{yacc} parsers into the same executable.
1362 We recommend using the following renaming hack used in @code{gdb}:
1363 @example
1364 #define yymaxdepth c_maxdepth
1365 #define yyparse c_parse
1366 #define yylex   c_lex
1367 #define yyerror c_error
1368 #define yylval  c_lval
1369 #define yychar  c_char
1370 #define yydebug c_debug
1371 #define yypact  c_pact  
1372 #define yyr1    c_r1                    
1373 #define yyr2    c_r2                    
1374 #define yydef   c_def           
1375 #define yychk   c_chk           
1376 #define yypgo   c_pgo           
1377 #define yyact   c_act           
1378 #define yyexca  c_exca
1379 #define yyerrflag c_errflag
1380 #define yynerrs c_nerrs
1381 #define yyps    c_ps
1382 #define yypv    c_pv
1383 #define yys     c_s
1384 #define yy_yys  c_yys
1385 #define yystate c_state
1386 #define yytmp   c_tmp
1387 #define yyv     c_v
1388 #define yy_yyv  c_yyv
1389 #define yyval   c_val
1390 #define yylloc  c_lloc
1391 #define yyreds  c_reds
1392 #define yytoks  c_toks
1393 #define yylhs   c_yylhs
1394 #define yylen   c_yylen
1395 #define yydefred c_yydefred
1396 #define yydgoto c_yydgoto
1397 #define yysindex c_yysindex
1398 #define yyrindex c_yyrindex
1399 #define yygindex c_yygindex
1400 #define yytable  c_yytable
1401 #define yycheck  c_yycheck
1402 @end example
1404 For each define, replace the @samp{c_} prefix with whatever you like.
1405 These defines work for @code{bison}, @code{byacc}, and traditional
1406 @code{yacc}s.  If you find a parser generator that uses a symbol not
1407 covered here, please report the new name so it can be added to the list.
1410 @node C++
1411 @section C++ and other languages
1413 Automake includes full support for C++, and rudimentary support for
1414 other languages.  Support for other languages will be improved based on
1415 demand.
1417 Any package including C++ code must define the output variable
1418 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
1419 the @code{AC_PROG_CXX} macro.
1421 A few additional variables are defined when a C++ source file is seen:
1423 @table @code
1424 @item CXX
1425 The name of the C++ compiler.
1426 @vindex CXX
1428 @item CXXFLAGS
1429 Any flags to pass to the C++ compiler.
1430 @vindex CXXFLAGS
1432 @item CXXCOMPILE
1433 The command used to actually compile a C++ source file.  The file name
1434 is appended to form the complete command line.
1435 @vindex CXXCOMPILE
1437 @item CXXLINK
1438 The command used to actually link a C++ program.
1439 @vindex CXXLINK
1440 @end table
1443 @node ANSI
1444 @section Automatic de-ANSI-fication
1446 Although the GNU standards allow the use of ANSI C, this can have the
1447 effect of limiting portability of a package to some older compilers
1448 (notably SunOS).
1450 Automake allows you to work around this problem on such machines by
1451 ``de-ANSI-fying'' each source file before the actual compilation takes
1452 place.
1454 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
1455 @vindex AUTOMAKE_OPTIONS
1456 (@ref{Options}) contains the option @code{ansi2knr}
1457 @opindex ansi2knr
1458 then code to handle de-ANSI-fication is inserted into the generated
1459 @file{Makefile.in}.
1461 This causes each C source file in the directory to be treated as ANSI C.
1462 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
1463 is available, the @code{ansi2knr} program is used to convert the source
1464 files into K&R C, which is then compiled.
1466 The @code{ansi2knr} program is simple-minded.  It assumes the source
1467 code will be formatted in a particular way; see the @code{ansi2knr} man
1468 page for details.
1470 De-ANSI-fication support requires the source files @file{ansi2knr.c} and
1471 @file{ansi2knr.1} to be in the same package as the ANSI C source; these
1472 files are distributed with Automake.  Also, the package
1473 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}.
1474 @cvindex AM_C_PROTOTYPES
1476 Automake also handles finding the @code{ansi2knr} support files in some
1477 other directory in the current package.  This is done by prepending the
1478 relative path to the appropriate directory to the @code{ansi2knr}
1479 option.  For instance, suppose the package has ANSI C code in the
1480 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
1481 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
1482 @file{src/Makefile.am}:
1484 @example
1485 AUTOMAKE_OPTIONS = ../lib/ansi2knr
1486 @end example
1488 If no directory prefix is given, the files are assumed to be in the
1489 current directory.
1491 Note that the directory holding the @code{ansi2knr} support files must
1492 be built before all other directories using these files.  Automake does
1493 not currently check that this is the case.
1495 @node Dependencies
1496 @section Automatic dependency tracking
1498 As a developer it is often painful to continually update the
1499 @file{Makefile.in} whenever the include-file dependencies change in a
1500 project.  @code{automake} supplies a way to automatically track
1501 dependency changes, and distribute the dependencies in the generated
1502 @file{Makefile.in}.
1504 Currently this support requires the use of GNU @code{make} and
1505 @code{gcc}.  It might become possible in the future to supply a
1506 different dependency generating program, if there is enough demand.
1508 This mode is enabled by default if any C program or library is defined
1509 in the current directory.
1511 When you decide to make a distribution, the @code{dist} target will
1512 @trindex dist
1513 re-run @code{automake} with @samp{--include-deps} and other options.
1514 This will cause the previously generated dependencies to be inserted
1515 into the generated @file{Makefile.in}, and thus into the distribution.
1516 This step also turns off inclusion of the dependency generation code.
1518 When added to the @file{Makefile.in}, the dependencies have all
1519 system-specific dependencies automatically removed.  This can be done by
1520 listing the files in @samp{OMIT_DEPENDENCIES}.
1521 @vindex OMIT_DEPENDENCIES
1522 For instance all references to system header files are removed by
1523 @code{automake}.  Sometimes it is useful to specify that a certain
1524 header file should be removed.  For instance if your @file{configure.in}
1525 uses @samp{AM_WITH_REGEX}, then any dependency on @file{rx.h} or
1526 @file{regex.h} should be removed, because the correct one cannot be
1527 known until the user configures the package.
1529 As it turns out, @code{automake} is actually smart enough to handle this
1530 particular case.  It will also automatically omit @file{libintl.h} if
1531 @samp{AM_GNU_GETTEXT} is used.
1533 Automatic dependency tracking can be suppressed by putting
1534 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
1535 @vindex AUTOMAKE_OPTIONS
1536 @opindex no-dependencies
1538 If you unpack a distribution made by @code{make dist}, and you want to
1539 turn on the dependency-tracking code again, simply re-run
1540 @code{automake}.
1542 The actual dependency files are put under the build directory, in a
1543 subdirectory named @file{.deps}.  These depencencies are machine
1544 specific.  It is safe to delete them if you like; they will be
1545 automatically recreated during the next build.
1548 @node Other objects
1549 @chapter Other Derived Objects
1551 Automake can handle derived objects which are not C programs.  Sometimes
1552 the support for actually building such objects must be explicitly
1553 supplied, but Automake will still automatically handle installation and
1554 distribution.
1556 @menu
1557 * Scripts::                     Executable scripts
1558 * Headers::                     Header files
1559 * Data::                        Architecture-independent data files
1560 * Sources::                     Derived sources
1561 @end menu
1564 @node Scripts
1565 @section Executable Scripts
1567 It is possible to define and install programs which are scripts.  Such
1568 programs are listed using the @samp{SCRIPTS} primary name.
1569 @code{automake} doesn't define any dependencies for scripts; the
1570 @file{Makefile.am} should include the appropriate rules.
1571 @vindex SCRIPTS
1573 @code{automake} does not assume that scripts are derived objects; such
1574 objects must be deleted by hand; see @ref{Clean} for more information.
1576 @code{automake} itself is a script that is generated at configure time
1577 from @file{automake.in}.  Here is how this is handled:
1579 @example
1580 bin_SCRIPTS = automake
1581 @end example
1583 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
1584 for it is automatically generated.
1586 Script objects can be installed in @code{bindir}, @code{sbindir},
1587 @code{libexecdir}, or @code{pkgdatadir}.
1590 @node Headers
1591 @section Header files
1593 Header files are specified by the @samp{HEADERS} family of variables.
1594 Generally header files are not installed, so the @code{noinst_HEADERS}
1595 variable will be the most used.
1596 @vindex HEADERS
1598 All header files must be listed somewhere; missing ones will not appear
1599 in the distribution.  Often it is clearest to list uninstalled headers
1600 with the rest of the sources for a program.  @xref{A Program}.  Headers
1601 listed in a @samp{_SOURCES} variable need not be listed in any
1602 @samp{_HEADERS} variable.
1604 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
1605 @code{pkgincludedir}.
1608 @node Data
1609 @section Architecture-independent data files
1611 Automake supports the installation of miscellaneous data files using the
1612 @samp{DATA} family of variables.
1613 @vindex DATA
1615 Such data can be installed in the directories @code{datadir},
1616 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
1617 @code{pkgdatadir}.
1619 By default, data files are not included in a distribution.
1621 Here is how @code{automake} installs its auxiliary data files:
1623 @example
1624 pkgdata_DATA = clean-kr.am clean.am @dots{}
1625 @end example
1628 @node Sources
1629 @section Built sources
1631 Occasionally a file which would otherwise be called ``source'' (eg a C
1632 @samp{.h} file) is actually derived from some other file.  Such files
1633 should be listed in the @code{BUILT_SOURCES} variable.
1634 @vindex BUILT_SOURCES
1636 By default, built sources are not included in a distribution.
1638 Built sources are also not compiled by default.  You must either
1639 explicitly mention them in some other @samp{_SOURCES} variable for this
1640 to happen.
1643 @node Other GNU Tools
1644 @chapter Other GNU Tools
1646 Since Automake is primarily intended to generate @file{Makefile.in}s for
1647 use in GNU programs, it tries hard to interoperate with other GNU tools.
1649 @menu
1650 * Emacs Lisp::                  Emacs Lisp
1651 * gettext::                     Gettext
1652 * Guile::                       Guile
1653 * Libtool::                     Libtool
1654 @end menu
1656 @node Emacs Lisp
1657 @section Emacs Lisp
1659 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
1660 is used to hold a list of @samp{.el} files.  Possible prefixes for this
1661 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
1662 @code{lisp_LISP} is defined, then @file{configure.in} must run
1663 @code{AM_PATH_LISPDIR} (fixme xref).
1664 @vindex LISP
1665 @vindex lisp_LISP
1666 @vindex noinst_LISP
1668 By default Automake will byte-compile all Emacs Lisp source files using
1669 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
1670 byte-compiling, simply define the variable @samp{ELCFILES} to be empty.
1671 @vindex ELCFILES
1672 Byte-compiled Emacs Lisp files are not portable among all versions of
1673 Emacs, so it makes sense to turn this off if you expect sites to have
1674 more than one version of Emacs installed.  Furthermore, many packages
1675 don't actually benefit from byte-compilation.  Still, we recommand that
1676 you leave it enabled by default.  It is probably better for sites with
1677 strange setups to cope for themselves than to make the installation less
1678 nice for everybody else.
1680 @node gettext
1681 @section Gettext
1683 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
1684 turns on support for GNU gettext, a message catalog system for
1685 internationalization
1686 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
1688 The @code{gettext} support in Automake requires the addition of two
1689 subdirectories to the package, @file{intl} and @file{po}.  Automake
1690 ensure that these directories exist and are mentioned in @code{SUBDIRS}.
1692 Furthermore, Automake checks that the definition of @samp{ALL_LINGUAS}
1693 in @file{configure.in} corresponds to all the valid @samp{.po} files,
1694 and nothing more.
1697 @node Guile
1698 @section Guile
1700 Automake provides some automatic support for writing Guile modules.
1701 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
1702 macro is used in @file{configure.in}.
1704 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
1705 macro is understood to mean:
1706 @itemize @bullet
1707 @item
1708 @code{AM_INIT_AUTOMAKE} is run.
1710 @item
1711 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
1712 @end itemize
1714 As the Guile module code matures, no doubt the Automake support will
1715 grow as well.
1717 @node Libtool
1718 @section Libtool
1720 Automake provides support for GNU Libtool (@pxref{Top, , The Libtool
1721 Manual, libtool, The Libtool Manual}) with the @samp{LTLIBRARIES}
1722 primary.  @xref{A Shared Library}.
1724 @node Documentation
1725 @chapter Building documentation
1727 Currently Automake provides support for Texinfo and man pages.
1729 @menu
1730 * Texinfo::                     Texinfo
1731 * Man pages::                   Man pages
1732 @end menu
1735 @node Texinfo
1736 @section Texinfo
1738 If the current directory contains Texinfo source, you must declare it
1739 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
1740 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
1741 here.  Note that any Texinfo source file must end in the @samp{.texi} or
1742 @samp{.texinfo} extension.
1743 @vindex TEXINFOS
1744 @vindex info_TEXINFOS
1746 If the @samp{.texi} file @code{@@include}s @file{version.texi}, then that
1747 file will be automatically generated.  @file{version.texi} defines three
1748 Texinfo macros you can reference: @code{EDITION}, @code{VERSION}, and
1749 @code{UPDATED}.  The first two hold the version number of your package
1750 (but are kept separate for clarity); the last is the date the primary
1751 file was last modified.  The @file{version.texi} support requires the
1752 @code{mdate-sh} program; this program is supplied with Automake.
1754 Sometimes an info file actually depends on more than one @samp{.texi}
1755 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
1756 @file{gpl.texi} You can tell Automake about these dependencies using the
1757 @samp{@var{texi}_TEXINFOS} variable.  Here is how Hello does it:
1758 @vindex TEXINFOS
1759 @vindex _TEXINFOS
1761 @example
1762 info_TEXINFOS = hello.texi
1763 hello_TEXINFOS = gpl.texi
1764 @end example
1766 By default, Automake requires the file @file{texinfo.tex} to appear in
1767 the same directory as the Texinfo source.  However, if you used
1768 @code{AC_CONFIG_AUX_DIR} in @file{configure.in}, then @file{texinfo.tex}
1769 is looked for there.  Automake supplies @file{texinfo.tex} if
1770 @samp{--add-missing} is given.  The option @samp{no-texinfo.tex} can be
1771 used to eliminate the requirement for @file{texinfo.tex}; this is useful
1772 if manuals appear in many directories.
1774 Automake generates an @code{install-info} target; some people apparently
1775 use this.  By default, info pages are installed by @samp{make install}.
1776 This can be prevented via the @code{no-installinfo} option.
1779 @node Man pages
1780 @section Man pages
1782 A package can also include man pages.  (Though see the GNU standards on
1783 this matter, @ref{Man Pages, , , standards, The GNU Coding
1784 Standards}.)  Man pages are declared using the @samp{MANS} primary.
1785 Generally the @code{man_MANS} macro is used.  Man pages are
1786 automatically installed in the correct subdirectory of @code{mandir},
1787 based on the file extension.
1788 @vindex MANS
1789 @vindex man_MANS
1791 @c Use @samp{make install} per documentation: (texi)code.
1792 By default, man pages are installed by @samp{make install}.  However,
1793 since the GNU project does not require man pages, many maintainers do
1794 not expend effort to keep the man pages up to date.  In these cases, the
1795 @code{no-installman} option will prevent the man pages from being
1796 installed by default.  The user can still explicitly install them via
1797 @samp{make install-man}.
1798 @opindex no-installman
1799 @trindex install-man
1801 Here is how the documentation is handled in GNU @code{cpio} (which
1802 includes both Texinfo documentation and man pages):
1804 @example
1805 info_TEXINFOS = cpio.texi
1806 man_MANS = cpio.1 mt.1
1807 @end example
1809 Texinfo source, info pages and man pages are all considered to be source
1810 for the purposes of making a distribution.
1813 @node Install
1814 @chapter What Gets Installed
1816 Naturally, Automake handles the details of actually installing your
1817 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
1818 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
1819 automatically installed in the appropriate places.
1821 Automake also handles installing any specified info and man pages.
1823 Automake generates separate @code{install-data} and @code{install-exec}
1824 targets, in case the installer is installing on multiple machines which
1825 share directory structure---these targets allow the machine-independent
1826 parts to be installed only once.  The @code{install} target depends on
1827 both of these targets.
1828 @trindex install-data
1829 @trindex install-exec
1830 @trindex install
1832 Automake also generates an @code{uninstall} target, and an
1833 @code{installdirs} target.
1834 @trindex uninstall
1835 @trindex installdirs
1837 It is possible to extend this mechanism by defining an
1838 @code{install-exec-local} or @code{install-data-local} target.  If these
1839 targets exist, they will be run at @samp{make install} time.
1840 @trindex install-exec-local
1841 @trindex install-data-local
1843 Variables using the standard directory prefixes @samp{data},
1844 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
1845 @samp{pkgdata}, or @samp{pkginclude} (eg @samp{data_DATA}) are installed
1846 by @samp{install-data}.
1848 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
1849 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
1850 @samp{pkglib} (eg @samp{bin_PROGRAMS}) are installed by
1851 @samp{install-exec}.
1853 Any variable using a user-defined directory prefix with @samp{exec} in
1854 the name (eg @samp{myexecbin_PROGRAMS} is installed by
1855 @samp{install-exec}.  All other user-defined prefixes are installed by
1856 @samp{install-data}.
1859 @node Clean
1860 @chapter What Gets Cleaned
1862 The GNU Makefile Standards specify a number of different clean rules.
1863 @c FIXME xref
1864 Generally the files that can cleaned are determined automatically by
1865 Automake.  Of course, Automake also recognizes some variables that can
1866 be defined to specify additional files to clean.  These variables are
1867 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
1868 @code{MAINTAINERCLEANFILES}.
1869 @vindex MOSTLYCLEANFILES
1870 @vindex CLEANFILES
1871 @vindex DISTCLEANFILES
1872 @vindex MAINTAINERCLEANFILES
1875 @node Dist
1876 @chapter What Goes in a Distribution
1878 The @code{dist} target in the generated @file{Makefile.in} can be used
1879 to generate a gzip'd @code{tar} file for distribution.  The tar file is
1880 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
1881 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
1882 @cvindex PACKAGE
1883 @cvindex VERSION
1884 @trindex dist
1886 For the most part, the files to distribute are automatically found by
1887 Automake: all source files are automatically included in a distribution,
1888 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
1889 has a built-in list of commonly used files which, if present in the
1890 current directory, are automatically included.  This list is printed by
1891 @samp{automake --help}.  Also, files which are read by @code{configure}
1892 (ie, the source files corresponding to the files specified in the
1893 @code{AC_OUTPUT} invocation) are automatically distributed.
1895 Still, sometimes there are files which must be distributed, but which
1896 are not covered in the automatic rules.  These files should be listed in
1897 the @code{EXTRA_DIST} variable.  Note that @code{EXTRA_DIST} can only
1898 handle files in the current directory; files in other directories will
1899 cause @code{make dist} runtime failures.
1900 @vindex EXTRA_DIST
1902 Occasionally it is useful to be able to change the distribution before
1903 it is packaged up.  If the @code{dist-hook} target exists, it is run
1904 after the distribution directory is filled, but before the actual tar
1905 (or shar) file is created.  One way to use this is for distributing
1906 files in subdirectories for which a new @file{Makefile.am} is overkill:
1908 @example
1909 dist-hook:
1910         mkdir $(distdir)/random
1911         cp -p random/a1 random/a2 $(distdir)/random
1912 @end example
1914 Automake also generates a @code{distcheck} target which can be help to
1915 ensure that a given distribution will actually work.  @code{distcheck}
1916 makes a distribution, and then tries to do a @code{VPATH} build.
1917 @trindex distcheck
1918 @c FIXME: document distcheck-hook here
1920 @node Tests
1921 @chapter Support for test suites
1923 Automake supports a two forms of test suite.
1925 If the variable @code{TESTS} is defined, its value is taken to be a list
1926 of programs to run in order to do the testing.  The programs can either
1927 be derived objects or source objects; the generated rule will look both
1928 in @var{srcdir} and @file{.}.  The number of failures will be printed at
1929 the end of the run.  The variable @code{TESTS_ENVIRONMENT} can be used
1930 to set environment variables for the test run; the environment variable
1931 @code{srcdir} is set in the rule.  If all your test programs are
1932 scripts, you can also set @code{TESTS_ENVIRONMENT} to an invocation of
1933 the shell (eg @samp{$(SHELL) -x}); this can be useful for debugging the
1934 tests.
1935 @vindex TESTS
1936 @vindex TESTS_ENVIRONMENT
1938 If @samp{dejagnu} appears in @code{AUTOMAKE_OPTIONS}, then the a
1939 @code{dejagnu}-based test suite is assumed.  The value of the variable
1940 @code{DEJATOOL} is passed as the @code{--tool} argument to
1941 @code{runtest}; it defaults to the name of the package.  The variables
1942 @code{EXPECT}, @code{RUNTEST} and @code{RUNTESTFLAGS} can also be
1943 overridden to provide project-specific values.  For instance, you will
1944 need to do this if you are testing a compiler toolchain, because the
1945 default values do not take into account host and target names.
1946 @opindex dejagnu
1947 @vindex DEJATOOL
1948 @vindex EXPECT
1949 @vindex RUNTEST
1950 @vindex RUNTESTFLAGS
1951 @c FIXME xref dejagnu
1953 In either case, the testing is done via @samp{make check}.
1956 @node Options
1957 @chapter Changing Automake's Behavior
1959 Various features of Automake can be controlled by options in the
1960 @file{Makefile.am}.  Such options are listed in a special variable named
1961 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
1962 @vindex AUTOMAKE_OPTIONS
1964 @table @asis
1965 @item @code{gnits}
1966 @itemx @code{gnu}
1967 @itemx @code{foreign}
1968 Set the strictness as appropriate.
1970 @item @code{no-installman}
1971 The generated @file{Makefile.in} will not cause man pages to be
1972 installed by default.  However, an @code{install-man} target will still
1973 be available for optional installation.  This option is disallowed at
1974 @samp{GNU} strictness and above.
1975 @trindex install-man
1977 @item @code{no-installinfo}
1978 The generated @file{Makefile.in} will not cause info pages to be built
1979 or installed by default.  However, @code{info} and @code{install-info}
1980 targets will still be available.  This option is disallowed at
1981 @samp{GNU} strictness and above.
1982 @trindex info
1983 @trindex install-info
1985 @item @code{ansi2knr}
1986 @itemx @code{path/ansi2knr}
1987 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceeded by a
1988 path, the generated @file{Makefile.in} will look in the specified
1989 directory to find the @file{ansi2knr} program.  Generally the path
1990 should be a relative path to another directory in the same distribution
1991 (though Automake currently does not check this).  It is up to you to
1992 make sure that the specified directory is built before the current
1993 directory; if @file{ansi2knr} does not exist then the build will fail.
1995 @item @code{dejagnu}
1996 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
1998 @item @code{dist-shar}
1999 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
2000 target.  This new target will create a shar archive of the
2001 distribution.
2002 @trindex dist-shar
2004 @item @code{dist-zip}
2005 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
2006 target.  This new target will create a zip archive of the distribution.
2007 @trindex dist-zip
2009 @item @code{dist-tarZ}
2010 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
2011 target.  This new target will create a compressed tar archive of the
2012 distribution; a traditional @code{tar} and @code{compress} will be
2013 assumed.  Warning: if you are actually using @code{GNU tar}, then the
2014 generated archive might contain nonportable constructs.
2015 @trindex dist-tarZ
2017 @item @code{no-dependencies}
2018 This is similar to using @samp{--include-deps} on the command line, but
2019 is useful for those situations where you don't have the necessary bits
2020 to make automatic dependency tracking work @xref{Dependencies}.  In this
2021 case the effect is to effectively disable automatic dependency tracking.
2023 @item @code{no-texinfo.tex}
2024 Don't require @file{texinfo.tex}, even if there are texinfo files in
2025 this directory.
2027 @item @var{version}
2028 A version number (eg @samp{0.30}) can be specified.  If Automake is not
2029 newer than the version specified, creation of the @file{Makefile.in}
2030 will be suppressed.
2031 @end table
2033 Unrecognized options are diagnosed by @code{automake}.
2036 @node Miscellaneous
2037 @chapter Miscellaneous Rules
2039 There are a few rules and variables that didn't fit anywhere else.
2041 @menu
2042 * Tags::                        Interfacing to etags and mkid
2043 * Suffixes::                    Handling new file extensions
2044 @end menu
2047 @node Tags
2048 @section Interfacing to @code{etags}
2050 @code{automake} will generate rules to generate @file{TAGS} files for
2051 use with GNU Emacs under some circumstances.
2053 If any C source code or headers are present, then @code{tags} and
2054 @code{TAGS} targets will be generated for the directory.
2055 @trindex tags
2057 At the topmost directory of a multi-directory package, a @code{tags}
2058 target file will be generated which, when run, will generate a
2059 @file{TAGS} file that includes by reference all @file{TAGS} files from
2060 subdirectories.
2062 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
2063 will be generated.  This variable is intended for use in directories
2064 which contain taggable source that @code{etags} does not understand.
2065 @vindex ETAGS_ARGS
2067 Here is how Automake generates tags for its source, and for nodes in its
2068 Texinfo file:
2070 @example
2071 ETAGS_ARGS = automake.in --lang=none \
2072  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
2073 @end example
2075 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
2076 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
2077 are added directly to the dependencies for the @code{tags} target.
2078 @vindex TAGS_DEPENDENCIES
2080 Automake will also generate an @code{ID} target which will run
2081 @code{mkid} on the source.  This is only supported on a
2082 directory-by-directory basis.
2083 @trindex id
2086 @node Suffixes
2087 @section Handling new file extensions
2089 It is sometimes useful to introduce a new implicit rule to handle a file
2090 type that Automake does not know about.  If this is done, you must
2091 notify GNU Make of the new suffixes.  This can be done by putting a list
2092 of new suffixes in the @code{SUFFIXES} variable.
2093 @vindex SUFFIXES
2095 For instance, currently automake does not provide any Java support.  If
2096 you wrote a macro to generate @samp{.class} files from @samp{.java}
2097 source files, you would also need to add these suffixes to the list:
2099 @example
2100 SUFFIXES = .java .class
2101 @end example
2104 @node Gnits
2105 @chapter The effect of @code{--gnu} and @code{--gnits}
2107 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
2108 variable) causes @code{automake} to check the following:
2110 @itemize @bullet
2111 @item
2112 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
2113 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
2114 directory of the package.
2116 @item
2117 The options @samp{no-installman} and @samp{no-installinfo} are
2118 prohibited.
2119 @end itemize
2121 Note that this option will be extended in the future to do even more
2122 checking; it is advisable to be familiar with the precise requirements
2123 of the GNU standards.  Also, @samp{--gnu} can require certain
2124 non-standard GNU programs to exist for use by various maintainer-only
2125 targets; for instance in the future @code{pathchk} might be required for
2126 @samp{make dist}.
2128 The @samp{--gnits} option does everything that @samp{--gnu} does, and
2129 checks the following as well:
2131 @itemize @bullet
2132 @item
2133 @samp{make dist} will check to make sure the @file{NEWS} file has been
2134 updated to the current version.
2136 @item
2137 The file @file{COPYING.LIB} is prohibited.  The LGPL is apparently
2138 considered a failed experiment.
2140 @item
2141 @samp{VERSION} is checked to make sure its format complies with Gnits
2142 standards.
2143 @c FIXME xref when standards are finished
2145 @item
2146 If @samp{VERSION} indicates that this is an alpha release, and the file
2147 @file{README-alpha} appears in the topmost directory of a package, then
2148 it is included in the distribution.
2150 @item
2151 The file @file{THANKS} is required.
2152 @end itemize
2155 @node Cygnus
2156 @chapter The effect of @code{--cygnus}
2158 Cygnus Support has slightly different rules for how a @file{Makefile.in}
2159 is to be constructed.  Passing @samp{--cygnus} to @code{automake} will
2160 cause any generated @file{Makefile.in} to comply with Cygnus rules.
2162 Here are the precise effects of @samp{--cygnus}:
2164 @itemize @bullet
2165 @item
2166 Info files are always created in the build directory, and not in the
2167 source directory.
2169 @item
2170 @file{texinfo.tex} is not required if a Texinfo source file is
2171 specified.  The assumption is that the file will be supplied, but in a
2172 place that @code{automake} cannot find.  This assumption is an artifact
2173 of how Cygnus packages are typically bundled.
2175 @item
2176 @samp{make dist} will look for files in the build directory as well as
2177 the source directory.  This is required to support putting info files
2178 into the build directory.
2180 @item
2181 Certain tools will be searched for in the build tree as well as in the
2182 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
2183 @code{makeinfo} and @code{texi2dvi}.
2185 @item
2186 @code{--foreign} is implied.
2188 @item
2189 The options @samp{no-installinfo} and @samp{no-dependencies} are
2190 implied.
2192 @item
2193 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
2194 required.
2195 @end itemize
2197 GNU maintainers are advised to use @samp{gnu} strictness in preference
2198 to the special Cygnus mode.
2201 @node Extending
2202 @chapter When Automake Isn't Enough
2204 Automake's implicit copying semantics means that many problems can be
2205 worked around by simply adding some @code{make} targets and rules to
2206 @file{Makefile.in}.  @code{automake} will ignore these additions.
2208 There are some caveats to doing this.  Although you can overload a
2209 target already used by @code{automake}, it is often inadvisable,
2210 particularly in the topmost directory of a non-flat package.  However,
2211 various useful targets have a @samp{-local} version you can specify in your
2212 @file{Makefile.in}.  Automake will supplement the standard target with
2213 these user-supplied targets.
2215 The targets that support a local version are @code{all}, @code{info},
2216 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
2217 @code{uninstall}, and the various @code{clean} targets
2218 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
2219 @code{maintainer-clean}).  Note that there are no
2220 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
2221 use @code{uninstall-local}.  It doesn't make sense to uninstall just
2222 data or just executables.
2223 @trindex all
2224 @trindex info
2225 @trindex dvi
2226 @trindex check
2227 @trindex install-data
2228 @trindex install-exec
2229 @trindex uninstall
2231 For instance, here is one way to install a file in @file{/etc}:
2233 @example
2234 install-data-local:
2235         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
2236 @end example
2238 Some targets also have a way to run another target, called a @dfn{hook},
2239 after their work is done.  The hook is named after the principal target,
2240 with @samp{-hook} appended.  The targets allowing hooks are
2241 @code{install-data}, @code{install-exec}, @code{dist}, and
2242 @code{distcheck}.
2243 @trindex install-data-hook
2244 @trindex install-exec-hook
2245 @trindex dist-hook
2247 For instance, here is how to create a hard link to an installed program:
2249 @example
2250 install-exec-hook:
2251         ln $(bindir)/program $(bindir)/proglink
2252 @end example
2254 @c FIXME should include discussion of variables you can use in these
2255 @c rules
2258 @node Distributing
2259 @chapter Distributing @file{Makefile.in}s
2261 Automake places no restrictions on the distribution of the resulting
2262 @file{Makefile.in}s.  We still encourage software authors to distribute
2263 their work under terms like those of the GPL, but doing so is not
2264 required to use Automake.
2266 Some of the files that can be automatically installed via the
2267 @code{--add-missing} switch do fall under the GPL; examine each file
2268 to see.
2271 @node Future
2272 @chapter Some ideas for the future
2274 Here are some things that might happen in the future:
2276 @itemize @bullet
2277 @item
2278 HTML support.
2280 @item
2281 The output will be cleaned up.  For instance, only variables which are
2282 actually used will appear in the generated @file{Makefile.in}.
2284 @item
2285 There will be support for automatically recoding a distribution.  The
2286 intent is to allow a maintainer to use whatever character set is most
2287 convenient locally, but for all distributions to be Unicode or
2288 @w{ISO 10646} with the UTF-8 encoding.
2290 @item
2291 Support for automatically generating packages (eg Solaris packages, or
2292 RPM packages).
2293 @end itemize
2295 @node Index
2296 @unnumbered Index
2298 @printindex cp
2300 @contents
2301 @bye