quoting fix from Per
[automake.git] / automake.texi
blobbf1b8909630dbdf50d649868078629e70305045c
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.
530 Of course, these explicit rules do not work if the de-ANSI-fication
531 feature is used; supporting that would require more work.
534 @node Invoking Automake
535 @chapter Creating a @file{Makefile.in}
537 To create all the @file{Makefile.in}s for a package, run the
538 @code{automake} program in the top level directory, with no arguments.
539 @code{automake} will automatically find each appropriate
540 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
541 and generate the corresponding @file{Makefile.in}.  Note that
542 @code{automake} has a rather simplistic view of what constitutes a
543 package; it assumes that a package has only one @file{configure.in}, at
544 the top.  If your package has multiple @file{configure.in}s, then you
545 must run @code{automake} in each directory holding a
546 @file{configure.in}.
548 You can optionally give @code{automake} an argument; @samp{.am} is
549 appended to the argument and the result is used as the name of the input
550 file.  This feature is generally only used to automatically rebuild an
551 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
552 be run from the topmost directory of a project, even if being used to
553 regenerate the @file{Makefile.in} in some subdirectory.  This is
554 necessary because @code{automake} must scan @file{configure.in}, and
555 because @code{automake} uses the knowledge that a @file{Makefile.in} is
556 in a subdirectory to change its behavior in some cases.
558 @code{automake} accepts the following options:
560 @table @code
561 @item -a
562 @itemx --add-missing
563 Automake requires certain common files to exist in certain situations;
564 for instance @file{config.guess} is required if @file{configure.in} runs
565 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
566 files; this option will cause the missing ones to be automatically added
567 to the package, whenever possible.  In general if Automake tells you a
568 file is missing, try using this option.
570 @item --amdir=@var{dir}
571 Look for Automake data files in directory @var{dir} instead of in the
572 installation directory.  This is typically used for debugging.
574 @item --build-dir=@var{dir}
575 Tell Automake where the build directory is.  This option is used when
576 including dependencies into a @file{Makefile.in} generated by @code{make
577 dist}; it should not be used otherwise.
579 @item --cygnus
580 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
581 of GNU or Gnits rules.  @xref{Cygnus} for more information.
583 @item --foreign
584 Set the global strictness to @samp{foreign}.  @xref{Strictness} for more
585 information.
587 @item --gnits
588 Set the global strictness to @samp{gnits}.  @xref{Gnits} for more
589 information.
591 @item --gnu
592 Set the global strictness to @samp{gnu}.  @xref{Gnits} for more
593 information.  This is the default strictness.
595 @item --help
596 Print a summary of the command line options and exit.
598 @item -i
599 @itemx --include-deps
600 Include all automatically generated dependency information
601 (@pxref{Dependencies}) in the generated
602 @file{Makefile.in}.  This is generally done when making a distribution;
603 see @ref{Dist}.
605 @item -o @var{dir}
606 @itemx --output-dir=@var{dir}
607 Put the generated @file{Makefile.in} in the directory @var{dir}.
608 Ordinarily each @file{Makefile.in} is created in the directory of the
609 corresponding @file{Makefile.am}.  This option is used when making
610 distributions.
612 @item --srcdir-name=@var{dir}
613 Tell Automake the name of the source directory associated with the
614 current build.  This option is used when including dependencies into a
615 @file{Makefile.in} generated by @code{make dist}; it should not be used
616 otherwise.
618 @item -v
619 @itemx --verbose
620 Cause Automake to print information about which files are being read or
621 created.
623 @item --version
624 Print the version number of Automake and exit.
625 @end table
628 @node configure
629 @chapter Scanning @file{configure.in}
631 Automake scans the package's @file{configure.in} to determine certain
632 information about the package.  Some @code{autoconf} macros are required
633 and some variables must be defined in @file{configure.in}.  Automake
634 will also use information from @file{configure.in} to further tailor its
635 output.
637 Automake also supplies some @code{autoconf} macros to make the
638 maintenance easier.  These macros can automatically be put into your
639 @file{aclocal.m4} using the @code{aclocal} program.
641 @menu
642 * Requirements::                Configuration requirements
643 * Optional::                    Other things Automake recognizes
644 * Invoking aclocal::            Auto-generating aclocal.m4
645 * Macros::                      Autoconf macros supplied with Automake
646 * Extending aclocal::           Writing your own aclocal macros
647 @end menu
650 @node Requirements
651 @section Configuration requirements
653 The simplest way to meet the basic Automake requirements is to use the
654 macro @code{AM_INIT_AUTOMAKE} (FIXME: xref).  But if you prefer, you can
655 do the required steps by hand:
656 @cvindex AM_INIT_AUTOMAKE
658 @itemize @bullet
659 @item
660 Define the variables @code{PACKAGE} and @code{VERSION} with
661 @code{AC_SUBST}.
662 @cvindex PACKAGE
663 @cvindex VERSION
664 @code{PACKAGE} should be the name of the package as it appears when
665 bundled for distribution.  For instance, Automake defines @code{PACKAGE}
666 to be @samp{automake}.  @code{VERSION} should be the version number of
667 the release that is being developed.  We recommend that you make
668 @file{configure.in} the only place in your package where the version
669 number is defined; this makes releases simpler.
671 Automake doesn't do any interpretation of @code{PACKAGE} or
672 @code{VERSION}, except in @samp{Gnits} mode (FIXME xref).
674 @item
675 Use the macro @code{AC_ARG_PROGRAM} if a program or script is installed.
676 @cvindex AC_ARG_PROGRAM
678 @item
679 Use @code{AC_PROG_MAKE_SET} if the package is not flat.
680 @cvindex AC_PROG_MAKE_SET
682 @item
683 Use @code{AM_SANITY_CHECK} to make sure the build environment is sane.
685 @item
686 Use @code{AM_PROG_INSTALL} if any scripts (@pxref{Scripts}) are
687 installed by the package.  Otherwise, use @code{AC_PROG_INSTALL}.
688 @cvindex AC_PROG_INSTALL
689 @cvindex AM_PROG_INSTALL
691 @item
692 Use @code{AM_MISSING_PROG} to see whether the programs @code{aclocal},
693 @code{autoconf}, @code{automake}, @code{autoheader}, and @code{makeinfo}
694 are in the build environment.  Here is how this is done:
695 @example
696 missing_dir=`cd $ac_aux_dir && pwd`
697 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
698 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
699 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
700 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
701 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
702 @end example
703 @end itemize
706 Here are the other macros which Automake requires but which are not run
707 by @code{AM_INIT_AUTOMAKE}:
709 @table @code
710 @item AC_OUTPUT
711 Automake uses this to determine which files to create.  Listed files
712 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
713 files are treated differently.  Currently the only difference is that a
714 @file{Makefile} is removed by @code{make distclean}, while other files
715 are removed by @code{make clean}.
716 @c FIXME: this is in violation of standards!
717 @cvindex AC_OUTPUT
718 @end table
720 @node Optional
721 @section Other things Automake recognizes
723 Automake will also recognize the use of certain macros and tailor the
724 generated @file{Makefile.in} appropriately.  Currently recognized macros
725 and their effects are:
727 @table @code
728 @item AC_CONFIG_HEADER
729 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
730 to @code{AC_CONFIG_HEADER} but does some useful Automake-specific work.
731 @cvindex AC_CONFIG_HEADER
733 @item AC_CONFIG_AUX_DIR
734 Automake will look for various helper scripts, such as
735 @file{mkinstalldirs}, in the directory named in this macro invocation.
736 If not seen, the scripts are looked for in their ``standard'' locations
737 (either the top source directory, or in the source directory
738 corresponding to the current @file{Makefile.am}, whichever is
739 appropriate).
740 @cvindex AC_CONFIG_AUX_DIR
741 FIXME: give complete list of things looked for in this directory
743 @item AC_PATH_XTRA
744 Automake will insert definitions for the variables defined by
745 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
746 or library.
747 @cvindex AC_PATH_XTRA
749 @item AC_CANONICAL_HOST
750 @itemx AC_CHECK_TOOL
751 Automake will ensure that @file{config.guess} and @file{config.sub}
752 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
753 @samp{host_triplet} are introduced.
754 @c fixme xref autoconf docs.
755 @cvindex AC_CANONICAL_HOST
756 @cvindex AC_CHECK_TOOL
757 @vindex host_alias
758 @vindex host_triplet
760 @item AC_CANONICAL_SYSTEM
761 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
762 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
763 @cvindex AC_CANONICAL_SYSTEM
764 @vindex build_alias
765 @vindex target_alias
767 @item AC_FUNC_ALLOCA
768 @itemx AC_FUNC_GETLOADAVG
769 @itemx AC_FUNC_MEMCMP
770 @itemx AC_STRUCT_ST_BLOCKS
771 @itemx AC_FUNC_FNMATCH
772 @itemx AM_FUNC_STRTOD
773 @itemx AC_REPLACE_FUNCS
774 @itemx AC_REPLACE_GNU_GETOPT
775 @itemx AM_WITH_REGEX
776 Automake will ensure that the appropriate dependencies are generated for
777 the objects corresponding to these macros.  Also, Automake will verify
778 that the appropriate source files are part of the distribution.  Note
779 that Automake does not come with any of the C sources required to use
780 these macros, so @code{automake -a} will not install the sources.
781 @xref{A Library} for more information.
782 @cvindex AC_FUNC_ALLOCA
783 @cvindex AC_FUNC_GETLOADAVG
784 @cvindex AC_FUNC_MEMCMP
785 @cvindex AC_STRUCT_ST_BLOCKS
786 @cvindex AC_FUNC_FNMATCH
787 @cvindex AC_FUNC_FNMATCH
788 @cvindex AC_REPLACE_FUNCS
789 @cvindex AC_REPLACE_GNU_GETOPT
790 @cvindex AM_FUNC_STRTOD
791 @cvindex AM_WITH_REGEX
793 @item LIBOBJS
794 Automake will detect statements which put @samp{.o} files into
795 @code{LIBOBJS}, and will treat these additional files as if they were
796 discovered via @code{AC_REPLACE_FUNCS}.
797 @cvindex LIBOBJS
799 @item AC_PROG_RANLIB
800 This is required if any libraries are built in the package.
801 @cvindex AC_PROG_RANLIB
803 @item AC_PROG_CXX
804 This is required if any C++ source is included.
805 @cvindex AC_PROG_CXX
807 @item AM_PROG_LIBTOOL
808 Automake will turn on processing for @code{libtool} (@pxref{Top, , The
809 Libtool Manual, libtool, The Libtool Manual}).
810 @cvindex AM_PROG_LIBTOOL
812 @item AC_PROG_YACC
813 If a Yacc source file is seen, then you must either use this macro or
814 define the variable @samp{YACC} in @file{configure.in}.  The former is
815 preferred.
816 @cvindex AC_PROG_YACC
817 @cvindex YACC
819 @item AC_DECL_YYTEXT
820 This macro is required if there is Lex source in the package.
821 @cvindex AC_DECL_YYTEXT
823 @item AC_PROG_LEX
824 If a Lex source file is seen, then this macro must be used.
825 @cvindex AC_PROG_LEX
827 @item ALL_LINGUAS
828 If Automake sees that this variable is set in @file{configure.in}, it
829 will check the @file{po} directory to ensure that all the named
830 @samp{.po} files exist, and that all the @samp{.po} files that exist are
831 named.
832 @cvindex ALL_LINGUAS
834 @item AM_C_PROTOTYPES
835 This is required when using automatic de-ANSI-fication, see @ref{ANSI}.
836 @cvindex AM_C_PROTOTYPES
838 @item AM_GNU_GETTEXT
839 This macro is required for packages which use GNU gettext
840 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
841 this macro it ensures that the package meets some of gettext's
842 requirements.
843 @cvindex AM_GNU_GETTEXT
845 @item AM_MAINTAINER_MODE
846 This macro adds a @samp{--enable-maintainer-mode} option to
847 @code{configure}.  If this is used, @code{automake} will cause
848 ``maintainer-only'' rules to be turned off by default in the generated
849 @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits} mode.
850 FIXME xref.
851 @cvindex AM_MAINTAINER_MODE
853 @item AC_SUBST
854 @itemx AC_CHECK_TOOL
855 @itemx AC_CHECK_PROG
856 @itemx AC_CHECK_PROGS
857 @itemx AC_PATH_PROG
858 @itemx AC_PATH_PROGS
859 For each of these macros, the first argument is automatically defined as
860 a variable in each generated @file{Makefile.in}.
861 @cvindex AC_SUBST
862 @cvindex AC_CHECK_TOOL
863 @cvindex AC_CHECK_PROG
864 @cvindex AC_CHECK_PROGS
865 @cvindex AC_PATH_PROG
866 @cvindex AC_PATH_PROGS
868 @end table
871 @node Invoking aclocal
872 @section Auto-generating aclocal.m4
874 Automake includes a number of Autoconf macros which can be used in your
875 package; some of them are actually required by Automake in certain
876 situations.  These macros must be defined in your @file{aclocal.m4};
877 otherwise they will not be seen by @code{autoconf}.
879 The @code{aclocal} program will automatically generate @file{aclocal.m4}
880 files based on the contents of @file{configure.in}.  This provides a
881 convenient way to get Automake-provided macros, without having to
882 search around.  Also, the @code{aclocal} mechanism is extensible for use
883 by other packages.
885 At startup, @code{aclocal} scans all the @samp{.m4} files it can find,
886 looking for macro definitions.  Then it scans @file{configure.in}.  Any
887 mention of one of the macros found in the first step causes that macro,
888 and any macros it in turn requires, to be put into @file{aclocal.m4}.
890 The contents of @file{acinclude.m4}, if it exists, are also
891 automatically included in @file{aclocal.m4}.  This is useful for
892 incorporating local macros into @file{configure}.
894 @code{aclocal} accepts the following options:
896 @table @code
897 @item --acdir=@var{dir}
898 Look for the macro files in @var{dir} instead of the installation
899 directory.  This is typically used for debugging.
901 @item --help
902 Print a summary of the command line options and exit.
904 @item -I @var{dir}
905 Add the directory @var{dir} to the list of directories searched for
906 @samp{.m4} files.
908 @item --output=@var{file}
909 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
911 @item --verbose
912 Print the names of the files it examines.
914 @item --version
915 Print the version number of Automake and exit.
916 @end table
919 @node Macros
920 @section Autoconf macros supplied with Automake
922 @c consider generating this node automatically from m4 files.
924 @table @code
925 @item AM_CONFIG_HEADER
926 Automake will generate rules to automatically regenerate the config
927 header.  If you do use this macro, you must create the file
928 @file{stamp-h.in} in your source directory.  It can be empty.
929 @cvindex AM_CONFIG_HEADER
931 @item AM_CYGWIN32
932 Check to see if this @code{configure} is being run in the
933 @samp{Cygwin32} environment.  (FIXME xref).  If so, define output
934 variable @code{EXEEXT} to @samp{.exe}; otherwise define it to the empty
935 string.  Automake recognizes this macro and uses it to generate
936 @file{Makefile.in}s which will automatically work under @samp{Cygwin32}.
937 In the @samp{Cygwin32} environment, @code{gcc} generates executables
938 whose names end in @samp{.exe}, even if this was not specified on the
939 command line.  Automake adds special code to @file{Makefile.in} to
940 gracefully deal with this.
942 @item AM_FUNC_STRTOD
943 If the @code{strtod} function is not available, or does not work
944 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
945 variable @code{LIBOBJS}.
946 @cvindex AM_FUNC_STRTOD
948 @item AM_FUNC_ERROR_AT_LINE
949 If the function @code{error_at_line} is not found, then add
950 @file{error.o} to @code{LIBOBJS}.
951 @cvindex AM_FUNC_ERROR_AT_LINE
953 @item AM_FUNC_MKTIME
954 Check for a working @code{mktime} function.  If not found, add
955 @file{mktime.o} to @samp{LIBOBJS}.
956 @cvindex AM_FUNC_MKTIME
958 @item AM_FUNC_OBSTACK
959 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
960 @samp{LIBOBJS}.
961 @cvindex AM_FUNC_OBSTACK
963 @item AM_C_PROTOTYPES
964 Check to see if function prototypes are understood by the compiler.  If
965 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
966 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
967 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
968 values to implement automatic de-ANSI-fication.
969 @cvindex AM_C_PROTOTYPES
971 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
972 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
973 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
974 found in @file{<termios.h>}.
975 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
977 @item AM_INIT_AUTOMAKE
978 Runs many macros that most @file{configure.in}'s need.  This macro has
979 two required arguments, the package and the version number.  By default
980 this macro @code{AC_DEFINE}'s @samp{PACKAGE} and @samp{VERSION}.  This
981 can be avoided by passing in a non-empty third argument.
983 @item AM_PATH_LISPDIR
984 Searches for the program @code{emacs}, and, if found, sets the output
985 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
986 @cvindex AM_PATH_LISPDIR
988 @item AM_PROG_CC_STDC
989 If the C compiler in not in ANSI C mode by default, try to add an option
990 to output variable @code{CC} to make it so.  This macro tries various
991 options that select ANSI C on some system or another.  It considers the
992 compiler to be in ANSI C mode if it defines @code{__STDC__} to 1 and
993 handles function prototypes correctly.
995 If you use this macro, you should check after calling it whether the C
996 compiler has been set to accept ANSI C; if not, the shell variable
997 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
998 code in ANSI C, you can make an un-ANSIfied copy of it by using the
999 @code{ansi2knr} option.
1000 @cvindex AM_PROG_CC_STDC
1002 @item AM_PROG_INSTALL
1003 Like @code{AC_PROG_INSTALL}, but also defines @code{INSTALL_SCRIPT}.
1004 @cvindex AM_PROG_INSTALL
1006 @item AM_SANITY_CHECK
1007 This checks to make sure that a file created in the build directory is
1008 newer than a file in the source directory.  This can fail on systems
1009 where the clock is set incorrectly.  This macro is automatically run
1010 from @code{AM_INIT_AUTOMAKE}.
1011 @cvindex AM_SANITY_CHECK
1013 @item AM_SYS_POSIX_TERMIOS
1014 Check to see if POSIX termios headers and functions are available on the
1015 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1016 @samp{yes}.  If not, set the variable to @samp{no}.
1017 @cvindex AM_SYS_POSIX_TERMIOS
1019 @item AM_TYPE_PTRDIFF_T
1020 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
1021 @file{<stddef.h>}.
1022 @cvindex AM_TYPE_PTRDIFF_T
1024 @item AM_WITH_DMALLOC
1025 Add support for the @code{dmalloc} package.  If the user configures with
1026 @samp{--with-dmalloc}, then define @code{WITH_DMALLOC} and add
1027 @samp{-ldmalloc} to @code{LIBS}.  The @code{dmalloc} package can be
1028 found at @url{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz}
1029 @cvindex AM_WITH_DMALLOC
1031 @item AM_WITH_REGEX
1032 Adds @samp{--with-regex} to the @code{configure} command line.  If
1033 specified (the default), then the @samp{regex} regular expression
1034 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1035 @samp{WITH_REGEX} is defined..  If @samp{--without-regex} is given, then
1036 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1037 into @samp{LIBOBJS}.
1038 @cvindex AM_WITH_REGEX
1039 @end table
1042 @node Extending aclocal
1043 @section Writing your own aclocal macros
1045 Aclocal doesn't have any built-in knowledge of any macros, so it is easy
1046 to extend it with your own macros.
1048 This is mostly used for libraries which want to supply their own
1049 Autoconf macros for use by other programs.  For instance the
1050 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1051 should be used by any package using @code{gettext}.  When the library is
1052 installed, it installs this macro so that @code{aclocal} will find it.
1054 A file of macros should be a series of @code{AC_DEFUN}'s.  Aclocal also
1055 understands @code{AC_REQUIRE}, so it is safe to put each macro in a
1056 separate file.
1058 A macro file's name should end in @samp{.m4}.  Such files should be
1059 installed in @file{$(datadir)/aclocal}.
1061 @node Top level
1062 @chapter The top-level @file{Makefile.am}
1064 In non-flat packages, the top level @file{Makefile.am} must tell
1065 Automake which subdirectories are to be built.  This is done via the
1066 @code{SUBDIRS} variable.
1067 @vindex SUBDIRS
1069 The @code{SUBDIRS} macro holds a list of subdirectories in which
1070 building of various sorts can occur.  Many targets (eg @code{all}) in
1071 the generated @file{Makefile} will run both locally and in all specified
1072 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1073 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1074 (after configuration).  This allows inclusion of libraries from packages
1075 which do not use Automake (such as @code{gettext}).
1077 In a deep package, the top-level @file{Makefile.am} is often very short.
1078 For instance, here is the @file{Makefile.am} from the Hello
1079 distribution:
1081 @example
1082 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1083 SUBDIRS = doc intl po src tests
1084 @end example
1086 @code{SUBDIRS} can contain configure substitutions (eg @samp{@@DIRS@@});
1087 Automake itself does not actually examine the contents of this variable.
1089 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1090 @code{AC_PROG_MAKE_SET}.
1092 The use of @code{SUBDIRS} is not restricted to just the top-level
1093 @file{Makefile.am}.  Automake can be used to construct packages of
1094 arbitrary depth.
1097 @node Programs
1098 @chapter Building Programs and Libraries
1100 A large part of Automake's functionality is dedicated to making it easy
1101 to build C programs and libraries.
1103 @menu
1104 * A Program::                   Building a program
1105 * A Library::                   Building a library
1106 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1107 * A Shared Library::            Building a Libtool library
1108 * Program variables::           Variables used when building a program
1109 * Yacc and Lex::                Yacc and Lex support
1110 * C++::                         C++ and other languages
1111 * ANSI::                        Automatic de-ANSI-fication
1112 * Dependencies::                Automatic dependency tracking
1113 @end menu
1116 @node A Program
1117 @section Building a program
1119 In a directory containing source that gets built into a program (as
1120 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1121 can be installed in @samp{bindir}, @samp{sbindir}, @samp{libexecdir},
1122 @samp{pkglibdir}, or not at all (@samp{noinst}).
1124 For instance:
1126 @example
1127 bin_PROGRAMS = hello
1128 @end example
1130 In this simple case, the resulting @file{Makefile.in} will contain code
1131 to generate a program named @code{hello}.  The variable
1132 @code{hello_SOURCES} is used to specify which source files get built
1133 into an executable:
1135 @example
1136 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
1137 @end example
1139 This causes each mentioned @samp{.c} file to be compiled into the
1140 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1142 If @samp{prog_SOURCES} is needed, but not specified, then it defaults to
1143 the single file @file{prog.c}.  In the example above, the definition of
1144 @code{hello_SOURCES} is actually redundant.
1145 @vindex _SOURCES
1146 @vindex SOURCES
1148 Multiple programs can be built in a single directory.  Multiple programs
1149 can share a single source file.  The source file must be listed in each
1150 @samp{_SOURCES} definition.
1152 Header files listed in a @samp{_SOURCES} definition will be included in
1153 the distribution but otherwise ignored.  In case it isn't obvious, you
1154 should not include the header file generated by @file{configure} in an
1155 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1156 (@samp{.l}) and yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1157 and Lex}.
1159 Sometimes it is useful to determine the programs that are to be built at
1160 configure time.  For instance, GNU @code{cpio} only builds @code{mt} and
1161 @code{rmt} under special circumstances.
1163 In this case, you must notify @code{automake} of all the programs that
1164 can possibly be built, but at the same time cause the generated
1165 @file{Makefile.in} to use the programs specified by @code{configure}.
1166 This is done by having @code{configure} substitute values into each
1167 @samp{_PROGRAMS} definition, while listing all optionally built programs in
1168 @code{EXTRA_PROGRAMS}.
1169 @vindex EXTRA_PROGRAMS
1171 If you need to link against libraries that are not found by
1172 @code{configure}, you can use @code{LDADD} to do so.  This variable
1173 actually can be used to add any options to the linker command line.
1174 @vindex LDADD
1176 Sometimes, multiple programs are built in one directory but do not share
1177 the same link-time requirements.  In this case, you can use the
1178 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1179 program as it appears in some @samp{_PROGRAMS} variable, and usually
1180 written in lowercase) to override the global @code{LDADD}.  (If this
1181 variable exists for a given program, then that program is not linked
1182 using @code{LDADD}.)
1183 @vindex _LDADD
1185 For instance, in GNU cpio, @code{pax}, @code{cpio}, and @code{mt} are
1186 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1187 built in the same directory, and has no such link requirement.  Also,
1188 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1189 is what cpio's @file{src/Makefile.am} looks like (abridged):
1191 @example
1192 bin_PROGRAMS = cpio pax @@MT@@
1193 libexec_PROGRAMS = @@RMT@@
1194 EXTRA_PROGRAMS = mt rmt
1196 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1197 rmt_LDADD =
1199 cpio_SOURCES = @dots{}
1200 pax_SOURCES = @dots{}
1201 mt_SOURCES = @dots{}
1202 rmt_SOURCES = @dots{}
1203 @end example
1205 @samp{prog_LDADD} is inappropriate for passing program-specific linker
1206 flags (except for @samp{-l} and @samp{-L}).  So, use the
1207 @samp{prog_LDFLAGS} variable for this purpose.
1208 @vindex _LDFLAGS
1210 It is also occasionally useful to have a program depend on some other
1211 target which is not actually part of that program.  This can be done
1212 using the @samp{prog_DEPENDENCIES} variable.  Each program depends on
1213 the contents of such a variable, but no further interpretation is done.
1215 If @samp{prog_DEPENDENCIES} is not supplied, it is computed by Automake.
1216 The automatically-assigned value is the contents of @samp{prog_LDADD},
1217 with most configure substitutions, @samp{-l}, and @samp{-L} options
1218 removed.  The configure substitutions that are left in are only
1219 @samp{@@LIBOBJS@@} and @samp{@@ALLOCA@@}; these are left because it is
1220 known that they will not cause an invalid value for
1221 @samp{prog_DEPENDENCIES} to be generated.
1224 @node A Library
1225 @section Building a library
1227 Building a library is much like building a program.  In this case, the
1228 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1229 @code{libdir} or @code{pkglibdir}.
1231 @xref{A Shared Library}, for information on how to build shared
1232 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1234 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1235 For instance to create a library named @file{libcpio.a}, but not install
1236 it, you would write:
1238 @example
1239 noinst_LIBRARIES = libcpio.a
1240 @end example
1242 The sources that go into a library are determined exactly as they are
1243 for programs, via the @samp{_SOURCES} variables.  Note that the library
1244 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1245 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1246 not @samp{liblob.a_SOURCES}.
1248 Extra objects can be added to a library using the @samp{library_LIBADD}
1249 variable.  This should be used for objects determined by
1250 @code{configure}.  Again from cpio:
1251 @vindex _LIBADD
1252 @vindex LIBADD
1254 @example
1255 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1256 @end example
1258 @node LIBOBJS
1259 @section Special handling for LIBOBJS and ALLOCA
1261 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1262 @code{@@ALLOCA@@}, and uses this information, plus the list of
1263 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1264 include the appropriate source files in the distribution (@pxref{Dist}).
1265 These source files are also automatically handled in the
1266 dependency-tracking scheme, see @xref{Dependencies}.
1268 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1269 @samp{_LDADD} or @samp{_LIBADD} variable.
1271 @node A Shared Library
1272 @section Building a Shared Library
1274 Building shared libraries is a relatively complex matter.  For this
1275 reason, GNU Libtool (@pxref{Top, , The Libtool Manual, libtool, The
1276 Libtool Manual}) was created to help build shared libraries in a
1277 platform-independent way.
1279 Automake uses Libtool to build libraries declared with the
1280 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1281 of shared libraries to build.  For instance, to create a library named
1282 @file{libgettext.a} and its corresponding shared libraries, and install
1283 them in @samp{libdir}, write:
1285 @example
1286 lib_LTLIBRARIES = libgettext.la
1287 @end example
1289 Note that shared libraries @emph{must} be installed, so
1290 @samp{noinst_LTLIBRARIES} and @samp{check_LTLIBRARIES} are not allowed.
1292 For each library, the @samp{library_LIBADD} variable contains the names
1293 of extra libtool objects (@samp{.lo} files) to add to the shared
1294 library.  The @samp{library_LDFLAGS} variable contains any additional
1295 libtool flags, such as @samp{-version-info} or @samp{-static}.
1297 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1298 libtool, The Libtool Manual}, for more information.
1300 @node Program variables
1301 @section Variables used when building a program
1303 Occasionally it is useful to know which @file{Makefile} variables
1304 Automake uses for compilations; for instance you might need to do your
1305 own compilation in some special cases.
1307 Some variables are inherited from Autoconf; these are @code{CC},
1308 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1309 @code{LIBS}.
1310 @vindex LDFLAGS
1312 There are some additional variables which Automake itself defines:
1314 @table @code
1315 @item INCLUDES
1316 A list of @samp{-I} options.  This can be set in your @file{Makefile.am}
1317 if you have special directories you want to look in.  @code{automake}
1318 already provides some @samp{-I} options automatically.  In particular it
1319 generates @samp{-I$(srcdir)} and a @samp{-I} pointing to the directory
1320 holding @file{config.h} (if you've used @code{AC_CONFIG_HEADER} or
1321 @code{AM_CONFIG_HEADER}).
1323 @item COMPILE
1324 This is the command used to actually compile a C source file.  The
1325 filename is appended to form the complete command line.
1327 @item LINK
1328 This is the command used to actually link a C program.
1329 @end table
1332 @node Yacc and Lex
1333 @section Yacc and Lex support
1335 Automake has somewhat idiosyncratic support for Yacc and Lex.
1337 Automake assumes that the @samp{.c} file generated by yacc (or lex)
1338 should be named using the basename of the input file.  That is, for a
1339 yacc source file @file{foo.y}, automake will cause the intermediate file
1340 to be named @file{foo.c} (as opposed to @file{y.tab.c}, which is more
1341 traditional).
1343 The extension of a yacc source file is used to determine the extension
1344 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
1345 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1346 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1347 @samp{.cxx}.  Likewise, lex source files can be used to generate
1348 @samp{C} or @samp{C++}; the extensions @samp{.l}, @samp{.ll},
1349 @samp{.l++}, and @samp{.lxx} are recognized.
1351 You should never explicitly mention the intermediate (@samp{C} or
1352 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1353 file.
1355 The intermediate files generated by yacc (or lex) will be included in
1356 any distribution that is made.  That way the user doesn't need to have
1357 yacc or lex.
1359 If a yacc source file is seen, then your @file{configure.in} must define
1360 the variable @samp{YACC}.  This is most easily done by invoking the
1361 macro @samp{AC_PROG_YACC}.
1363 Similarly, if a lex source file is seen, then your @file{configure.in}
1364 must define the variable @samp{LEX}.  You can use @samp{AC_PROG_LEX} to
1365 do this.  Automake's lex support also requires that you use the
1366 @samp{AC_DECL_YYTEXT} macro---automake needs to know the value of
1367 @samp{LEX_OUTPUT_ROOT}.
1369 Any program including a lex source file must be linked against
1370 @samp{@@LEXLIB@@}.  You can do this by putting @samp{@@LEXLIB@@} into
1371 the appropriate @samp{LDADD} variable.
1373 Automake makes it possible to include multiple yacc (or lex) source
1374 files in a single program.  Automake uses a small program called
1375 @code{interlock} to manage locks between multiple yacc invocations.
1376 This is necessary because yacc's output filename is fixed, and a
1377 parallel make could conceivably invoke more than one instance of
1378 @code{yacc} simultaneously.  @code{interlock} is distributed with
1379 automake.  It should appear in the directory specified by
1380 @samp{AC_CONFIG_AUX_DIR}, or the current directory if that macro is not
1381 used in @file{configure.in}.
1383 For @code{yacc}, simply managing locking is insufficient.  @code{yacc}
1384 output also always uses the same symbol names internally, so it isn't
1385 possible to link two @code{yacc} parsers into the same executable.
1387 We recommend using the following renaming hack used in @code{gdb}:
1388 @example
1389 #define yymaxdepth c_maxdepth
1390 #define yyparse c_parse
1391 #define yylex   c_lex
1392 #define yyerror c_error
1393 #define yylval  c_lval
1394 #define yychar  c_char
1395 #define yydebug c_debug
1396 #define yypact  c_pact  
1397 #define yyr1    c_r1                    
1398 #define yyr2    c_r2                    
1399 #define yydef   c_def           
1400 #define yychk   c_chk           
1401 #define yypgo   c_pgo           
1402 #define yyact   c_act           
1403 #define yyexca  c_exca
1404 #define yyerrflag c_errflag
1405 #define yynerrs c_nerrs
1406 #define yyps    c_ps
1407 #define yypv    c_pv
1408 #define yys     c_s
1409 #define yy_yys  c_yys
1410 #define yystate c_state
1411 #define yytmp   c_tmp
1412 #define yyv     c_v
1413 #define yy_yyv  c_yyv
1414 #define yyval   c_val
1415 #define yylloc  c_lloc
1416 #define yyreds  c_reds
1417 #define yytoks  c_toks
1418 #define yylhs   c_yylhs
1419 #define yylen   c_yylen
1420 #define yydefred c_yydefred
1421 #define yydgoto c_yydgoto
1422 #define yysindex c_yysindex
1423 #define yyrindex c_yyrindex
1424 #define yygindex c_yygindex
1425 #define yytable  c_yytable
1426 #define yycheck  c_yycheck
1427 @end example
1429 For each define, replace the @samp{c_} prefix with whatever you like.
1430 These defines work for @code{bison}, @code{byacc}, and traditional
1431 @code{yacc}s.  If you find a parser generator that uses a symbol not
1432 covered here, please report the new name so it can be added to the list.
1435 @node C++
1436 @section C++ and other languages
1438 Automake includes full support for C++, and rudimentary support for
1439 other languages.  Support for other languages will be improved based on
1440 demand.
1442 Any package including C++ code must define the output variable
1443 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
1444 the @code{AC_PROG_CXX} macro.
1446 A few additional variables are defined when a C++ source file is seen:
1448 @table @code
1449 @item CXX
1450 The name of the C++ compiler.
1451 @vindex CXX
1453 @item CXXFLAGS
1454 Any flags to pass to the C++ compiler.
1455 @vindex CXXFLAGS
1457 @item CXXCOMPILE
1458 The command used to actually compile a C++ source file.  The file name
1459 is appended to form the complete command line.
1460 @vindex CXXCOMPILE
1462 @item CXXLINK
1463 The command used to actually link a C++ program.
1464 @vindex CXXLINK
1465 @end table
1468 @node ANSI
1469 @section Automatic de-ANSI-fication
1471 Although the GNU standards allow the use of ANSI C, this can have the
1472 effect of limiting portability of a package to some older compilers
1473 (notably SunOS).
1475 Automake allows you to work around this problem on such machines by
1476 ``de-ANSI-fying'' each source file before the actual compilation takes
1477 place.
1479 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
1480 @vindex AUTOMAKE_OPTIONS
1481 (@ref{Options}) contains the option @code{ansi2knr}
1482 @opindex ansi2knr
1483 then code to handle de-ANSI-fication is inserted into the generated
1484 @file{Makefile.in}.
1486 This causes each C source file in the directory to be treated as ANSI C.
1487 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
1488 is available, the @code{ansi2knr} program is used to convert the source
1489 files into K&R C, which is then compiled.
1491 The @code{ansi2knr} program is simple-minded.  It assumes the source
1492 code will be formatted in a particular way; see the @code{ansi2knr} man
1493 page for details.
1495 De-ANSI-fication support requires the source files @file{ansi2knr.c} and
1496 @file{ansi2knr.1} to be in the same package as the ANSI C source; these
1497 files are distributed with Automake.  Also, the package
1498 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}.
1499 @cvindex AM_C_PROTOTYPES
1501 Automake also handles finding the @code{ansi2knr} support files in some
1502 other directory in the current package.  This is done by prepending the
1503 relative path to the appropriate directory to the @code{ansi2knr}
1504 option.  For instance, suppose the package has ANSI C code in the
1505 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
1506 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
1507 @file{src/Makefile.am}:
1509 @example
1510 AUTOMAKE_OPTIONS = ../lib/ansi2knr
1511 @end example
1513 If no directory prefix is given, the files are assumed to be in the
1514 current directory.
1516 Note that the directory holding the @code{ansi2knr} support files must
1517 be built before all other directories using these files.  Automake does
1518 not currently check that this is the case.
1520 @node Dependencies
1521 @section Automatic dependency tracking
1523 As a developer it is often painful to continually update the
1524 @file{Makefile.in} whenever the include-file dependencies change in a
1525 project.  @code{automake} supplies a way to automatically track
1526 dependency changes, and distribute the dependencies in the generated
1527 @file{Makefile.in}.
1529 Currently this support requires the use of GNU @code{make} and
1530 @code{gcc}.  It might become possible in the future to supply a
1531 different dependency generating program, if there is enough demand.
1533 This mode is enabled by default if any C program or library is defined
1534 in the current directory.
1536 When you decide to make a distribution, the @code{dist} target will
1537 @trindex dist
1538 re-run @code{automake} with @samp{--include-deps} and other options.
1539 This will cause the previously generated dependencies to be inserted
1540 into the generated @file{Makefile.in}, and thus into the distribution.
1541 This step also turns off inclusion of the dependency generation code.
1543 When added to the @file{Makefile.in}, the dependencies have all
1544 system-specific dependencies automatically removed.  This can be done by
1545 listing the files in @samp{OMIT_DEPENDENCIES}.
1546 @vindex OMIT_DEPENDENCIES
1547 For instance all references to system header files are removed by
1548 @code{automake}.  Sometimes it is useful to specify that a certain
1549 header file should be removed.  For instance if your @file{configure.in}
1550 uses @samp{AM_WITH_REGEX}, then any dependency on @file{rx.h} or
1551 @file{regex.h} should be removed, because the correct one cannot be
1552 known until the user configures the package.
1554 As it turns out, @code{automake} is actually smart enough to handle this
1555 particular case.  It will also automatically omit @file{libintl.h} if
1556 @samp{AM_GNU_GETTEXT} is used.
1558 Automatic dependency tracking can be suppressed by putting
1559 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
1560 @vindex AUTOMAKE_OPTIONS
1561 @opindex no-dependencies
1563 If you unpack a distribution made by @code{make dist}, and you want to
1564 turn on the dependency-tracking code again, simply re-run
1565 @code{automake}.
1567 The actual dependency files are put under the build directory, in a
1568 subdirectory named @file{.deps}.  These depencencies are machine
1569 specific.  It is safe to delete them if you like; they will be
1570 automatically recreated during the next build.
1573 @node Other objects
1574 @chapter Other Derived Objects
1576 Automake can handle derived objects which are not C programs.  Sometimes
1577 the support for actually building such objects must be explicitly
1578 supplied, but Automake will still automatically handle installation and
1579 distribution.
1581 @menu
1582 * Scripts::                     Executable scripts
1583 * Headers::                     Header files
1584 * Data::                        Architecture-independent data files
1585 * Sources::                     Derived sources
1586 @end menu
1589 @node Scripts
1590 @section Executable Scripts
1592 It is possible to define and install programs which are scripts.  Such
1593 programs are listed using the @samp{SCRIPTS} primary name.
1594 @code{automake} doesn't define any dependencies for scripts; the
1595 @file{Makefile.am} should include the appropriate rules.
1596 @vindex SCRIPTS
1598 @code{automake} does not assume that scripts are derived objects; such
1599 objects must be deleted by hand; see @ref{Clean} for more information.
1601 @code{automake} itself is a script that is generated at configure time
1602 from @file{automake.in}.  Here is how this is handled:
1604 @example
1605 bin_SCRIPTS = automake
1606 @end example
1608 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
1609 for it is automatically generated.
1611 Script objects can be installed in @code{bindir}, @code{sbindir},
1612 @code{libexecdir}, or @code{pkgdatadir}.
1615 @node Headers
1616 @section Header files
1618 Header files are specified by the @samp{HEADERS} family of variables.
1619 Generally header files are not installed, so the @code{noinst_HEADERS}
1620 variable will be the most used.
1621 @vindex HEADERS
1623 All header files must be listed somewhere; missing ones will not appear
1624 in the distribution.  Often it is clearest to list uninstalled headers
1625 with the rest of the sources for a program.  @xref{A Program}.  Headers
1626 listed in a @samp{_SOURCES} variable need not be listed in any
1627 @samp{_HEADERS} variable.
1629 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
1630 @code{pkgincludedir}.
1633 @node Data
1634 @section Architecture-independent data files
1636 Automake supports the installation of miscellaneous data files using the
1637 @samp{DATA} family of variables.
1638 @vindex DATA
1640 Such data can be installed in the directories @code{datadir},
1641 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
1642 @code{pkgdatadir}.
1644 By default, data files are not included in a distribution.
1646 Here is how @code{automake} installs its auxiliary data files:
1648 @example
1649 pkgdata_DATA = clean-kr.am clean.am @dots{}
1650 @end example
1653 @node Sources
1654 @section Built sources
1656 Occasionally a file which would otherwise be called ``source'' (eg a C
1657 @samp{.h} file) is actually derived from some other file.  Such files
1658 should be listed in the @code{BUILT_SOURCES} variable.
1659 @vindex BUILT_SOURCES
1661 By default, built sources are not included in a distribution.
1663 Built sources are also not compiled by default.  You must either
1664 explicitly mention them in some other @samp{_SOURCES} variable for this
1665 to happen.
1667 Note that, in some cases, @code{BUILT_SOURCES} will work in somewhat
1668 suprising ways.  In order to get the built sources to work with
1669 automatic dependency tracking, the @file{Makefile} must depend on
1670 @code{$(BUILT_SOURCES)}.  This can cause these sources to be rebuilt at
1671 what might seem like funny times.
1674 @node Other GNU Tools
1675 @chapter Other GNU Tools
1677 Since Automake is primarily intended to generate @file{Makefile.in}s for
1678 use in GNU programs, it tries hard to interoperate with other GNU tools.
1680 @menu
1681 * Emacs Lisp::                  Emacs Lisp
1682 * gettext::                     Gettext
1683 * Guile::                       Guile
1684 * Libtool::                     Libtool
1685 @end menu
1687 @node Emacs Lisp
1688 @section Emacs Lisp
1690 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
1691 is used to hold a list of @samp{.el} files.  Possible prefixes for this
1692 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
1693 @code{lisp_LISP} is defined, then @file{configure.in} must run
1694 @code{AM_PATH_LISPDIR} (fixme xref).
1695 @vindex LISP
1696 @vindex lisp_LISP
1697 @vindex noinst_LISP
1699 By default Automake will byte-compile all Emacs Lisp source files using
1700 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
1701 byte-compiling, simply define the variable @samp{ELCFILES} to be empty.
1702 @vindex ELCFILES
1703 Byte-compiled Emacs Lisp files are not portable among all versions of
1704 Emacs, so it makes sense to turn this off if you expect sites to have
1705 more than one version of Emacs installed.  Furthermore, many packages
1706 don't actually benefit from byte-compilation.  Still, we recommand that
1707 you leave it enabled by default.  It is probably better for sites with
1708 strange setups to cope for themselves than to make the installation less
1709 nice for everybody else.
1711 @node gettext
1712 @section Gettext
1714 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
1715 turns on support for GNU gettext, a message catalog system for
1716 internationalization
1717 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
1719 The @code{gettext} support in Automake requires the addition of two
1720 subdirectories to the package, @file{intl} and @file{po}.  Automake
1721 ensure that these directories exist and are mentioned in @code{SUBDIRS}.
1723 Furthermore, Automake checks that the definition of @samp{ALL_LINGUAS}
1724 in @file{configure.in} corresponds to all the valid @samp{.po} files,
1725 and nothing more.
1728 @node Guile
1729 @section Guile
1731 Automake provides some automatic support for writing Guile modules.
1732 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
1733 macro is used in @file{configure.in}.
1735 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
1736 macro is understood to mean:
1737 @itemize @bullet
1738 @item
1739 @code{AM_INIT_AUTOMAKE} is run.
1741 @item
1742 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
1743 @end itemize
1745 As the Guile module code matures, no doubt the Automake support will
1746 grow as well.
1748 @node Libtool
1749 @section Libtool
1751 Automake provides support for GNU Libtool (@pxref{Top, , The Libtool
1752 Manual, libtool, The Libtool Manual}) with the @samp{LTLIBRARIES}
1753 primary.  @xref{A Shared Library}.
1755 @node Documentation
1756 @chapter Building documentation
1758 Currently Automake provides support for Texinfo and man pages.
1760 @menu
1761 * Texinfo::                     Texinfo
1762 * Man pages::                   Man pages
1763 @end menu
1766 @node Texinfo
1767 @section Texinfo
1769 If the current directory contains Texinfo source, you must declare it
1770 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
1771 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
1772 here.  Note that any Texinfo source file must end in the @samp{.texi} or
1773 @samp{.texinfo} extension.
1774 @vindex TEXINFOS
1775 @vindex info_TEXINFOS
1777 If the @samp{.texi} file @code{@@include}s @file{version.texi}, then that
1778 file will be automatically generated.  @file{version.texi} defines three
1779 Texinfo macros you can reference: @code{EDITION}, @code{VERSION}, and
1780 @code{UPDATED}.  The first two hold the version number of your package
1781 (but are kept separate for clarity); the last is the date the primary
1782 file was last modified.  The @file{version.texi} support requires the
1783 @code{mdate-sh} program; this program is supplied with Automake.
1785 Sometimes an info file actually depends on more than one @samp{.texi}
1786 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
1787 @file{gpl.texi} You can tell Automake about these dependencies using the
1788 @samp{@var{texi}_TEXINFOS} variable.  Here is how Hello does it:
1789 @vindex TEXINFOS
1790 @vindex _TEXINFOS
1792 @example
1793 info_TEXINFOS = hello.texi
1794 hello_TEXINFOS = gpl.texi
1795 @end example
1797 By default, Automake requires the file @file{texinfo.tex} to appear in
1798 the same directory as the Texinfo source.  However, if you used
1799 @code{AC_CONFIG_AUX_DIR} in @file{configure.in}, then @file{texinfo.tex}
1800 is looked for there.  Automake supplies @file{texinfo.tex} if
1801 @samp{--add-missing} is given.  The option @samp{no-texinfo.tex} can be
1802 used to eliminate the requirement for @file{texinfo.tex}; this is useful
1803 if manuals appear in many directories.
1805 Automake generates an @code{install-info} target; some people apparently
1806 use this.  By default, info pages are installed by @samp{make install}.
1807 This can be prevented via the @code{no-installinfo} option.
1810 @node Man pages
1811 @section Man pages
1813 A package can also include man pages.  (Though see the GNU standards on
1814 this matter, @ref{Man Pages, , , standards, The GNU Coding
1815 Standards}.)  Man pages are declared using the @samp{MANS} primary.
1816 Generally the @code{man_MANS} macro is used.  Man pages are
1817 automatically installed in the correct subdirectory of @code{mandir},
1818 based on the file extension.
1819 @vindex MANS
1820 @vindex man_MANS
1822 @c Use @samp{make install} per documentation: (texi)code.
1823 By default, man pages are installed by @samp{make install}.  However,
1824 since the GNU project does not require man pages, many maintainers do
1825 not expend effort to keep the man pages up to date.  In these cases, the
1826 @code{no-installman} option will prevent the man pages from being
1827 installed by default.  The user can still explicitly install them via
1828 @samp{make install-man}.
1829 @opindex no-installman
1830 @trindex install-man
1832 Here is how the documentation is handled in GNU @code{cpio} (which
1833 includes both Texinfo documentation and man pages):
1835 @example
1836 info_TEXINFOS = cpio.texi
1837 man_MANS = cpio.1 mt.1
1838 @end example
1840 Texinfo source, info pages and man pages are all considered to be source
1841 for the purposes of making a distribution.
1844 @node Install
1845 @chapter What Gets Installed
1847 Naturally, Automake handles the details of actually installing your
1848 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
1849 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
1850 automatically installed in the appropriate places.
1852 Automake also handles installing any specified info and man pages.
1854 Automake generates separate @code{install-data} and @code{install-exec}
1855 targets, in case the installer is installing on multiple machines which
1856 share directory structure---these targets allow the machine-independent
1857 parts to be installed only once.  The @code{install} target depends on
1858 both of these targets.
1859 @trindex install-data
1860 @trindex install-exec
1861 @trindex install
1863 Automake also generates an @code{uninstall} target, and an
1864 @code{installdirs} target.
1865 @trindex uninstall
1866 @trindex installdirs
1868 It is possible to extend this mechanism by defining an
1869 @code{install-exec-local} or @code{install-data-local} target.  If these
1870 targets exist, they will be run at @samp{make install} time.
1871 @trindex install-exec-local
1872 @trindex install-data-local
1874 Variables using the standard directory prefixes @samp{data},
1875 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
1876 @samp{pkgdata}, or @samp{pkginclude} (eg @samp{data_DATA}) are installed
1877 by @samp{install-data}.
1879 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
1880 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
1881 @samp{pkglib} (eg @samp{bin_PROGRAMS}) are installed by
1882 @samp{install-exec}.
1884 Any variable using a user-defined directory prefix with @samp{exec} in
1885 the name (eg @samp{myexecbin_PROGRAMS} is installed by
1886 @samp{install-exec}.  All other user-defined prefixes are installed by
1887 @samp{install-data}.
1890 @node Clean
1891 @chapter What Gets Cleaned
1893 The GNU Makefile Standards specify a number of different clean rules.
1894 @c FIXME xref
1895 Generally the files that can cleaned are determined automatically by
1896 Automake.  Of course, Automake also recognizes some variables that can
1897 be defined to specify additional files to clean.  These variables are
1898 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
1899 @code{MAINTAINERCLEANFILES}.
1900 @vindex MOSTLYCLEANFILES
1901 @vindex CLEANFILES
1902 @vindex DISTCLEANFILES
1903 @vindex MAINTAINERCLEANFILES
1906 @node Dist
1907 @chapter What Goes in a Distribution
1909 The @code{dist} target in the generated @file{Makefile.in} can be used
1910 to generate a gzip'd @code{tar} file for distribution.  The tar file is
1911 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
1912 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
1913 @cvindex PACKAGE
1914 @cvindex VERSION
1915 @trindex dist
1917 For the most part, the files to distribute are automatically found by
1918 Automake: all source files are automatically included in a distribution,
1919 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
1920 has a built-in list of commonly used files which, if present in the
1921 current directory, are automatically included.  This list is printed by
1922 @samp{automake --help}.  Also, files which are read by @code{configure}
1923 (ie, the source files corresponding to the files specified in the
1924 @code{AC_OUTPUT} invocation) are automatically distributed.
1926 Still, sometimes there are files which must be distributed, but which
1927 are not covered in the automatic rules.  These files should be listed in
1928 the @code{EXTRA_DIST} variable.  Note that @code{EXTRA_DIST} can only
1929 handle files in the current directory; files in other directories will
1930 cause @code{make dist} runtime failures.
1931 @vindex EXTRA_DIST
1933 Occasionally it is useful to be able to change the distribution before
1934 it is packaged up.  If the @code{dist-hook} target exists, it is run
1935 after the distribution directory is filled, but before the actual tar
1936 (or shar) file is created.  One way to use this is for distributing
1937 files in subdirectories for which a new @file{Makefile.am} is overkill:
1939 @example
1940 dist-hook:
1941         mkdir $(distdir)/random
1942         cp -p random/a1 random/a2 $(distdir)/random
1943 @end example
1945 Automake also generates a @code{distcheck} target which can be help to
1946 ensure that a given distribution will actually work.  @code{distcheck}
1947 makes a distribution, and then tries to do a @code{VPATH} build.
1948 @trindex distcheck
1949 @c FIXME: document distcheck-hook here
1951 @node Tests
1952 @chapter Support for test suites
1954 Automake supports a two forms of test suite.
1956 If the variable @code{TESTS} is defined, its value is taken to be a list
1957 of programs to run in order to do the testing.  The programs can either
1958 be derived objects or source objects; the generated rule will look both
1959 in @var{srcdir} and @file{.}.  The number of failures will be printed at
1960 the end of the run.  The variable @code{TESTS_ENVIRONMENT} can be used
1961 to set environment variables for the test run; the environment variable
1962 @code{srcdir} is set in the rule.  If all your test programs are
1963 scripts, you can also set @code{TESTS_ENVIRONMENT} to an invocation of
1964 the shell (eg @samp{$(SHELL) -x}); this can be useful for debugging the
1965 tests.
1966 @vindex TESTS
1967 @vindex TESTS_ENVIRONMENT
1969 If @samp{dejagnu} appears in @code{AUTOMAKE_OPTIONS}, then the a
1970 @code{dejagnu}-based test suite is assumed.  The value of the variable
1971 @code{DEJATOOL} is passed as the @code{--tool} argument to
1972 @code{runtest}; it defaults to the name of the package.  The variables
1973 @code{EXPECT}, @code{RUNTEST} and @code{RUNTESTFLAGS} can also be
1974 overridden to provide project-specific values.  For instance, you will
1975 need to do this if you are testing a compiler toolchain, because the
1976 default values do not take into account host and target names.
1977 @opindex dejagnu
1978 @vindex DEJATOOL
1979 @vindex EXPECT
1980 @vindex RUNTEST
1981 @vindex RUNTESTFLAGS
1982 @c FIXME xref dejagnu
1984 In either case, the testing is done via @samp{make check}.
1987 @node Options
1988 @chapter Changing Automake's Behavior
1990 Various features of Automake can be controlled by options in the
1991 @file{Makefile.am}.  Such options are listed in a special variable named
1992 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
1993 @vindex AUTOMAKE_OPTIONS
1995 @table @asis
1996 @item @code{gnits}
1997 @itemx @code{gnu}
1998 @itemx @code{foreign}
1999 Set the strictness as appropriate.
2001 @item @code{no-installman}
2002 The generated @file{Makefile.in} will not cause man pages to be
2003 installed by default.  However, an @code{install-man} target will still
2004 be available for optional installation.  This option is disallowed at
2005 @samp{GNU} strictness and above.
2006 @trindex install-man
2008 @item @code{no-installinfo}
2009 The generated @file{Makefile.in} will not cause info pages to be built
2010 or installed by default.  However, @code{info} and @code{install-info}
2011 targets will still be available.  This option is disallowed at
2012 @samp{GNU} strictness and above.
2013 @trindex info
2014 @trindex install-info
2016 @item @code{ansi2knr}
2017 @itemx @code{path/ansi2knr}
2018 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceeded by a
2019 path, the generated @file{Makefile.in} will look in the specified
2020 directory to find the @file{ansi2knr} program.  Generally the path
2021 should be a relative path to another directory in the same distribution
2022 (though Automake currently does not check this).  It is up to you to
2023 make sure that the specified directory is built before the current
2024 directory; if @file{ansi2knr} does not exist then the build will fail.
2026 @item @code{dejagnu}
2027 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
2029 @item @code{dist-shar}
2030 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
2031 target.  This new target will create a shar archive of the
2032 distribution.
2033 @trindex dist-shar
2035 @item @code{dist-zip}
2036 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
2037 target.  This new target will create a zip archive of the distribution.
2038 @trindex dist-zip
2040 @item @code{dist-tarZ}
2041 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
2042 target.  This new target will create a compressed tar archive of the
2043 distribution; a traditional @code{tar} and @code{compress} will be
2044 assumed.  Warning: if you are actually using @code{GNU tar}, then the
2045 generated archive might contain nonportable constructs.
2046 @trindex dist-tarZ
2048 @item @code{no-dependencies}
2049 This is similar to using @samp{--include-deps} on the command line, but
2050 is useful for those situations where you don't have the necessary bits
2051 to make automatic dependency tracking work @xref{Dependencies}.  In this
2052 case the effect is to effectively disable automatic dependency tracking.
2054 @item @code{no-texinfo.tex}
2055 Don't require @file{texinfo.tex}, even if there are texinfo files in
2056 this directory.
2058 @item @var{version}
2059 A version number (eg @samp{0.30}) can be specified.  If Automake is not
2060 newer than the version specified, creation of the @file{Makefile.in}
2061 will be suppressed.
2062 @end table
2064 Unrecognized options are diagnosed by @code{automake}.
2067 @node Miscellaneous
2068 @chapter Miscellaneous Rules
2070 There are a few rules and variables that didn't fit anywhere else.
2072 @menu
2073 * Tags::                        Interfacing to etags and mkid
2074 * Suffixes::                    Handling new file extensions
2075 @end menu
2078 @node Tags
2079 @section Interfacing to @code{etags}
2081 @code{automake} will generate rules to generate @file{TAGS} files for
2082 use with GNU Emacs under some circumstances.
2084 If any C source code or headers are present, then @code{tags} and
2085 @code{TAGS} targets will be generated for the directory.
2086 @trindex tags
2088 At the topmost directory of a multi-directory package, a @code{tags}
2089 target file will be generated which, when run, will generate a
2090 @file{TAGS} file that includes by reference all @file{TAGS} files from
2091 subdirectories.
2093 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
2094 will be generated.  This variable is intended for use in directories
2095 which contain taggable source that @code{etags} does not understand.
2096 @vindex ETAGS_ARGS
2098 Here is how Automake generates tags for its source, and for nodes in its
2099 Texinfo file:
2101 @example
2102 ETAGS_ARGS = automake.in --lang=none \
2103  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
2104 @end example
2106 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
2107 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
2108 are added directly to the dependencies for the @code{tags} target.
2109 @vindex TAGS_DEPENDENCIES
2111 Automake will also generate an @code{ID} target which will run
2112 @code{mkid} on the source.  This is only supported on a
2113 directory-by-directory basis.
2114 @trindex id
2117 @node Suffixes
2118 @section Handling new file extensions
2120 It is sometimes useful to introduce a new implicit rule to handle a file
2121 type that Automake does not know about.  If this is done, you must
2122 notify GNU Make of the new suffixes.  This can be done by putting a list
2123 of new suffixes in the @code{SUFFIXES} variable.
2124 @vindex SUFFIXES
2126 For instance, currently automake does not provide any Java support.  If
2127 you wrote a macro to generate @samp{.class} files from @samp{.java}
2128 source files, you would also need to add these suffixes to the list:
2130 @example
2131 SUFFIXES = .java .class
2132 @end example
2135 @node Gnits
2136 @chapter The effect of @code{--gnu} and @code{--gnits}
2138 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
2139 variable) causes @code{automake} to check the following:
2141 @itemize @bullet
2142 @item
2143 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
2144 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
2145 directory of the package.
2147 @item
2148 The options @samp{no-installman} and @samp{no-installinfo} are
2149 prohibited.
2150 @end itemize
2152 Note that this option will be extended in the future to do even more
2153 checking; it is advisable to be familiar with the precise requirements
2154 of the GNU standards.  Also, @samp{--gnu} can require certain
2155 non-standard GNU programs to exist for use by various maintainer-only
2156 targets; for instance in the future @code{pathchk} might be required for
2157 @samp{make dist}.
2159 The @samp{--gnits} option does everything that @samp{--gnu} does, and
2160 checks the following as well:
2162 @itemize @bullet
2163 @item
2164 @samp{make dist} will check to make sure the @file{NEWS} file has been
2165 updated to the current version.
2167 @item
2168 The file @file{COPYING.LIB} is prohibited.  The LGPL is apparently
2169 considered a failed experiment.
2171 @item
2172 @samp{VERSION} is checked to make sure its format complies with Gnits
2173 standards.
2174 @c FIXME xref when standards are finished
2176 @item
2177 If @samp{VERSION} indicates that this is an alpha release, and the file
2178 @file{README-alpha} appears in the topmost directory of a package, then
2179 it is included in the distribution.  This is done in @samp{--gnits}
2180 mode, and no other, because this mode is the only one where version
2181 number formats are constrained, and hence the only mode where
2182 @code{automake} can automatically determine whether @file{README-alpha}
2183 should be included.
2185 @item
2186 The file @file{THANKS} is required.
2187 @end itemize
2190 @node Cygnus
2191 @chapter The effect of @code{--cygnus}
2193 Cygnus Support has slightly different rules for how a @file{Makefile.in}
2194 is to be constructed.  Passing @samp{--cygnus} to @code{automake} will
2195 cause any generated @file{Makefile.in} to comply with Cygnus rules.
2197 Here are the precise effects of @samp{--cygnus}:
2199 @itemize @bullet
2200 @item
2201 Info files are always created in the build directory, and not in the
2202 source directory.
2204 @item
2205 @file{texinfo.tex} is not required if a Texinfo source file is
2206 specified.  The assumption is that the file will be supplied, but in a
2207 place that @code{automake} cannot find.  This assumption is an artifact
2208 of how Cygnus packages are typically bundled.
2210 @item
2211 @samp{make dist} will look for files in the build directory as well as
2212 the source directory.  This is required to support putting info files
2213 into the build directory.
2215 @item
2216 Certain tools will be searched for in the build tree as well as in the
2217 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
2218 @code{makeinfo} and @code{texi2dvi}.
2220 @item
2221 @code{--foreign} is implied.
2223 @item
2224 The options @samp{no-installinfo} and @samp{no-dependencies} are
2225 implied.
2227 @item
2228 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
2229 required.
2230 @end itemize
2232 GNU maintainers are advised to use @samp{gnu} strictness in preference
2233 to the special Cygnus mode.
2236 @node Extending
2237 @chapter When Automake Isn't Enough
2239 Automake's implicit copying semantics means that many problems can be
2240 worked around by simply adding some @code{make} targets and rules to
2241 @file{Makefile.in}.  @code{automake} will ignore these additions.
2243 There are some caveats to doing this.  Although you can overload a
2244 target already used by @code{automake}, it is often inadvisable,
2245 particularly in the topmost directory of a non-flat package.  However,
2246 various useful targets have a @samp{-local} version you can specify in your
2247 @file{Makefile.in}.  Automake will supplement the standard target with
2248 these user-supplied targets.
2250 The targets that support a local version are @code{all}, @code{info},
2251 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
2252 @code{uninstall}, and the various @code{clean} targets
2253 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
2254 @code{maintainer-clean}).  Note that there are no
2255 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
2256 use @code{uninstall-local}.  It doesn't make sense to uninstall just
2257 data or just executables.
2258 @trindex all
2259 @trindex info
2260 @trindex dvi
2261 @trindex check
2262 @trindex install-data
2263 @trindex install-exec
2264 @trindex uninstall
2266 For instance, here is one way to install a file in @file{/etc}:
2268 @example
2269 install-data-local:
2270         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
2271 @end example
2273 Some targets also have a way to run another target, called a @dfn{hook},
2274 after their work is done.  The hook is named after the principal target,
2275 with @samp{-hook} appended.  The targets allowing hooks are
2276 @code{install-data}, @code{install-exec}, @code{dist}, and
2277 @code{distcheck}.
2278 @trindex install-data-hook
2279 @trindex install-exec-hook
2280 @trindex dist-hook
2282 For instance, here is how to create a hard link to an installed program:
2284 @example
2285 install-exec-hook:
2286         ln $(bindir)/program $(bindir)/proglink
2287 @end example
2289 @c FIXME should include discussion of variables you can use in these
2290 @c rules
2293 @node Distributing
2294 @chapter Distributing @file{Makefile.in}s
2296 Automake places no restrictions on the distribution of the resulting
2297 @file{Makefile.in}s.  We still encourage software authors to distribute
2298 their work under terms like those of the GPL, but doing so is not
2299 required to use Automake.
2301 Some of the files that can be automatically installed via the
2302 @code{--add-missing} switch do fall under the GPL; examine each file
2303 to see.
2306 @node Future
2307 @chapter Some ideas for the future
2309 Here are some things that might happen in the future:
2311 @itemize @bullet
2312 @item
2313 HTML support.
2315 @item
2316 The output will be cleaned up.  For instance, only variables which are
2317 actually used will appear in the generated @file{Makefile.in}.
2319 @item
2320 There will be support for automatically recoding a distribution.  The
2321 intent is to allow a maintainer to use whatever character set is most
2322 convenient locally, but for all distributions to be Unicode or
2323 @w{ISO 10646} with the UTF-8 encoding.
2325 @item
2326 Support for automatically generating packages (eg Debian packages, RPM
2327 packages, Solaris packages, etc).  This will happen more quickly if
2328 someone with package-building experience can tell me what would be
2329 helpful.
2331 @item
2332 Rewrite in Guile.  This won't happen in the near future, but it will
2333 eventually happen.
2334 @end itemize
2336 @node Index
2337 @unnumbered Index
2339 @printindex cp
2341 @contents
2342 @bye