Nothing
[automake.git] / automake.texi
blobcd58189d430da81e53bfc86a324b37f2939a3436
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 @c Yes, this appears in many Texinfo files.  He's just a likeable guy.
11 @ifinfo
12 @set Francois Franc,ois
13 @end ifinfo
14 @tex
15 @set Francois Fran\noexpand\ptexc cois
16 @end tex
18 @ifinfo
19 @format
20 START-INFO-DIR-ENTRY
21 * automake: (automake).         Making Makefile.in's
22 END-INFO-DIR-ENTRY
23 @end format
24 @end ifinfo
26 @ifinfo
27 This file documents GNU automake @value{VERSION}
29 Copyright (C) 1995 Free Software Foundation, Inc.
31 Permission is granted to make and distribute verbatim copies of
32 this manual provided the copyright notice and this permission notice
33 are preserved on all copies.
35 @ignore
36 Permission is granted to process this file through TeX and print the
37 results, provided the printed document carries copying permission
38 notice identical to this one except for the removal of this paragraph
41 @end ignore
42 Permission is granted to copy and distribute modified versions of this
43 manual under the conditions for verbatim copying, provided that the entire
44 resulting derived work is distributed under the terms of a permission
45 notice identical to this one.
47 Permission is granted to copy and distribute translations of this manual
48 into another language, under the above conditions for modified versions,
49 except that this permission notice may be stated in a translation approved
50 by the Foundation.
51 @end ifinfo
54 @titlepage
55 @title GNU Automake
56 @subtitle For version @value{VERSION}, @value{UPDATED}
57 @c copyright page
58 @page
59 @vskip 0pt plus 1filll
60 Copyright @copyright{} 1995 Free Software Foundation, Inc.
61 @sp 2
62 This is the first edition of the GNU Automake documentation,@*
63 and is consistent with GNU Automake @value{VERSION}.@*
64 @sp 2
65 Published by the Free Software Foundation @*
66 675 Massachusetts Avenue, @*
67 Cambridge, MA 02139 USA @*
69 Permission is granted to make and distribute verbatim copies of
70 this manual provided the copyright notice and this permission notice
71 are preserved on all copies.
73 Permission is granted to copy and distribute modified versions of this
74 manual under the conditions for verbatim copying, provided that the entire
75 resulting derived work is distributed under the terms of a permission
76 notice identical to this one.
78 Permission is granted to copy and distribute translations of this manual
79 into another language, under the above conditions for modified versions,
80 except that this permission notice may be stated in a translation
81 approved by the Free Software Foundation.
82 @end titlepage
84 @c Define an index of configure variables.
85 @defcodeindex cv
86 @c Define an index of options.
87 @defcodeindex op
88 @c Define an index of targets.
89 @defcodeindex tr
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 * Invoking Automake::           Creating a Makefile.in
103 * Generalities::                General ideas
104 * configure::                   Scanning configure.in
105 * Top level::                   The top-level Makefile.am
106 * Programs::                    Building programs and libraries
107 * Other objects::               Other derived objects
108 * Documentation::               Building documentation
109 * Install::                     What gets installed
110 * Clean::                       What gets cleaned
111 * Dist::                        What goes in a distribution
112 * Tests::                       Support for test suites
113 * Options::                     Changing Automake's behavior
114 * Miscellaneous::               Miscellaneous rules
115 * Extending::                   Extending Automake
116 * Distributing::                Distributing the Makefile.in
117 * Examples::                    Some example packages
118 * Future::                      Some ideas for the future
119 * Variables::                   Index of variables
120 * Configure variables::         Index of configure variables and macros
121 * Targets::                     Index of targets
122 @end menu
124 @end ifinfo
126 @node Introduction
127 @chapter Introduction
129 Automake is a tool for automatically generating
130 @file{Makefile.in}s from files called @file{Makefile.am}.  The
131 @file{Makefile.am} is basically a series of @code{make} macro
132 definitions (with rules being thrown in occasionally).  The generated
133 @file{Makefile.in}s are compliant with the GNU Makefile standards.
135 The GNU Makefile Standards Document
136 (@pxref{Makefile Conventions, , , standards.info, The GNU Coding Standards})
137 is long, complicated, and subject to change.  The goal of Automake is to
138 remove the burden of Makefile maintenance from the back of the
139 individual GNU maintainer (and put it on the back of the Automake
140 maintainer).
142 The typical Automake input files is simply a series of macro
143 definitions.  Each such file is processed to create a
144 @file{Makefile.in}.  There should generally be one @file{Makefile.am}
145 per directory of a project.
147 Automake does constrain a project in certain ways; for instance it
148 assumes that the project uses Autoconf
149 (@pxref{Top, , The Autoconf Manual, autoconf.info, The Autoconf Manual}),
150 and enforces certain restrictions on the @file{configure.in} contents.
152 @code{Automake} requires @code{perl} in order to generate the
153 @file{Makefile.in}s.  However, the distributions created by Automake are
154 fully GNU standards-compliant, and do not require @code{perl} in order
155 to be built.
157 Mail suggestions and bug reports for Automake to tromey@@cygnus.com.
160 @node Invoking Automake
161 @chapter Creating a @file{Makefile.in}
163 To create all the @file{Makefile.in}s for a package, run the
164 @code{automake} program in the top level directory, with no arguments.
165 @code{automake} will automatically find each appropriate
166 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
167 and generate the corresponding @file{Makefile.in}.
169 You can optionally give @code{automake} an argument; @samp{.am} is
170 appended to the argument and the result is used as the name of the input
171 file.  This feature is generally only used to automatically rebuild an
172 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
173 be run from the topmost directory of a project, even if being used to
174 regenerate the @file{Makefile.in} in some subdirectory.  This is
175 necessary because @code{automake} must scan @file{configure.in}, and
176 because @code{automake} uses the knowledge that a @file{Makefile.in} is
177 in a subdirectory to change its behavior in some cases.
179 @code{automake} accepts the following options:
181 @table @code
182 @item --amdir=@var{dir}
183 Look for Automake data files in directory @var{dir} instead of in the
184 installation directory.  This is typically used for debugging.
186 @item --foreign
187 An alias for @samp{--strictness=foreign}.
189 @item --gnits
190 An alias for @samp{--strictness=gnits}.
192 @item --gnu
193 An alias for @samp{--strictness=gnu}.
195 @item --help
196 Print a summary of the command line options and exit.
198 @item --include-deps
199 Include all automatically generated dependency information
200 (@pxref{Dependencies}) in the generated
201 @file{Makefile.in}.  This is generally done when making a distribution;
202 see @ref{Dist}.
204 @item --add-missing
205 Automake requires certain common files to exist in certain situations;
206 for instance @file{config.guess} is required if @file{configure.in} runs
207 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
208 files; this option will cause the missing ones to be automatically added
209 to the package, whenever possible.
211 @item --output-dir=@var{dir}
212 Put the generated @file{Makefile.in} in the directory @var{dir}.
213 Ordinarily each @file{Makefile.in} is created in the directory of the
214 corresponding @file{Makefile.am}.  This option is used when making
215 distributions.
217 @item --strictness=@var{level}
218 Set the global strictness to @var{level}; this can be overridden in each
219 @file{Makefile.am} if required.  @xref{Generalities} for more
220 information.
222 @item --verbose
223 Cause Automake to print information about which files are being read or
224 created.
226 @item --version
227 Print the version number of Automake and exit.
228 @end table
231 @node Generalities
232 @chapter General ideas
234 @section Depth
235 @code{automake} supports three kinds of directory hierarchy: ``flat'',
236 ``shallow'', and ``deep''.
238 A @dfn{flat} package is one in which all the files are in a single
239 directory.  The @file{Makefile.am} for such a package by definition
240 lacks a @code{SUBDIRS} macro.  An example of such a package is
241 @code{termutils}.
242 @vindex SUBDIRS
244 A @dfn{deep} package is one in which all the source lies in
245 subdirectories; the top level directory contains mainly configuration
246 information.  GNU cpio is a good example of such a package, as is GNU
247 @code{tar}.  The top level @file{Makefile.am} for a deep package will
248 contain a @code{SUBDIRS} macro, but no other macros to define objects
249 which are built.
251 A @dfn{shallow} package is one in which the primary source resides in
252 the top-level directory, while various parts (typically libraries)
253 reside in subdirectories.  @code{automake} is one such package (as is
254 GNU @code{make}, which does not currently use @code{automake}).
257 @section Strictness
258 While Automake is intended to be used by maintainers of GNU packages, it
259 does make some effort to accomodate those who wish to use it, but do not
260 want to use all the GNU conventions.
262 To this end, Automake supports three levels of @dfn{strictness} -- the
263 strictness indicating how stringently Automake should check standards
264 conformance.
266 The valid strictness levels are:
268 @table @samp
269 @item foreign
270 Automake will check for only those things which are absolutely
271 required for proper operations.  For instance, whereas GNU standards
272 dictate the existence of a @file{NEWS} file, it will not be required in
273 this mode.  The name comes from the fact that Automake is intended to be
274 used for GNU programs; these relaxed rules are not the standard mode of
275 operation.
277 @item gnu
278 Automake will check -- as much as possible -- for compliance to the GNU
279 standards for packages.  This is the default.
281 @item gnits
282 Automake will check for compliance to the as-yet-unwritten GNITS
283 standards.  These are based on the GNU standards, but are even more
284 detailed.  Unless you are a GNITS standards contributor, it is
285 recommended that you avoid this option until such time as the GNITS
286 standard is actually published.
287 @end table
290 @section The Uniform Naming Scheme
291 Automake variables generally follow a uniform naming scheme that makes
292 it easy to decide how programs (and other derived objects) are built,
293 and how they are installed.  This scheme also supports @code{configure}
294 time determination of what should be built.
296 At @code{make} time, certain variables are used to determine which
297 objects are to be built.  These variables are called @dfn{primary}
298 variables.  For instance, the primary variable @code{PROGRAMS} holds a
299 list of programs which are to be compiled and linked.
300 @vindex PROGRAMS
302 A different set of variables is used to decide where the built objects
303 should be installed.  These variables are named after the primary
304 variables, but have a prefix indicating which standard directory should
305 be used as the installation directory.  The standard directory names are
306 given in the GNU standards
307 (@pxref{Directory Variables, , , standards.info, The GNU Coding
308 Standards}).
309 @code{automake} extends this list with @code{pkglibdir},
310 @code{pkgincludedir}, and @code{pkgdatadir}; these are the same as the
311 non-@samp{pkg} versions, but with @samp{@@PACKAGE@@} appended.
312 @cvindex PACKAGE
314 For each primary, there is one additional variable named by prepending
315 @samp{EXTRA_} to the primary name.  This variable is used to list
316 objects which may or may not be built, depending on what
317 @code{configure} decides.  This variable is required because Automake
318 must know the entire list of objects to be built in order to generate a
319 @file{Makefile.in} that will work in all cases.
321 For instance, @code{cpio} decides at configure time which programs are
322 built.  Some of the programs are installed in @code{bindir}, and some
323 are installed in @code{sbindir}:
325 @example
326 EXTRA_PROGRAMS = mt rmt
327 bin_PROGRAMS = cpio pax
328 sbin_PROGRAMS = @@PROGRAMS@@
329 @end example
331 Defining a primary variable is an error.
333 Note that the common @samp{dir} suffix is left off when constructing the
334 variable names; thus one writes @samp{bin_PROGRAMS} and not
335 @samp{bindir_PROGRAMS}.
337 Not every sort of object can be installed in every directory.  Automake
338 will flag those attempts it finds in error.  Automake will also diagnose
339 obvious misspellings in directory names.
341 Sometimes the standard directories -- even as augmented by Automake --
342 are not enough.  In particular it is sometimes useful, for clarity, to
343 install objects in a subdirectory of some predefined directory.  To this
344 end, Automake allows you to extend the list of possible installation
345 directories.  A given prefix (eg @samp{zar}) is valid if a variable of
346 the same name with @samp{dir} appended is defined (eg @samp{zardir}).
348 For instance, until HTML support is part of Automake, you could use this
349 to install raw HTML documentation:
351 @example
352 htmldir = $(prefix)/html
353 html_DATA = automake.html
354 @end example
356 The special prefix @samp{noinst} indicates that the objects in question
357 should not be installed at all.
359 The special prefix @samp{check} indicates that the objects in question
360 should not be built until the @code{make check} command is run.
362 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
363 @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS}, @samp{MANS}, and
364 @samp{TEXINFOS}.
365 @vindex PROGRAMS
366 @vindex LIBRARIES
367 @vindex SCRIPTS
368 @vindex DATA
369 @vindex HEADERS
370 @vindex MANS
371 @vindex TEXINFOS
373 @section General Operation
374 Automake essentially works by reading a @file{Makefile.am} and
375 generating a @file{Makefile.in}.  The macro definitions and targets in
376 the @file{Makefile.am} are copied into the generated file.
378 Automake tries to group comments with adjoining targets (or variable
379 definitions) in an intelligent way.
381 A target defined in @file{Makefile.am} generally overrides any such
382 target of a similar name that would be automatically generated by
383 @code{automake}.  Although this is a supported feature, it is generally
384 best to avoid making use of it, as sometimes the generated rules are
385 very particular.
387 Automake also allows a form of comment which is @emph{not} copied into
388 the output; all lines beginning with @samp{##} are completely ignored by
389 Automake.
391 It is customary to make the first line of @file{Makefile.am} read:
393 @example
394 ## Process this file with automake to produce Makefile.in
395 @end example
397 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
398 @c I don't know quite what to say.
400 @c FIXME document customary ordering of Makefile.am here!
403 @node configure
404 @chapter Scanning @file{configure.in}
406 Automake requires certain variables to be defined and certain macros to
407 be used in the package @file{configure.in}.
409 One such requirement is that @file{configure.in} must define the
410 variables @code{PACKAGE} and @code{VERSION} with @code{AC_SUBST}.
411 @cvindex PACKAGE
412 @cvindex VERSION
413 @code{PACKAGE} should be the name of the package as it appears when
414 bundled for distribution.  For instance, Automake definees
415 @code{PACKAGE} to be @samp{automake}.  @code{VERSION} should be the
416 version number of the release that is being developed.  We recommend
417 that you make @file{configure.in} the only place in your package where
418 the version number is defined; this makes releases simpler.
420 Automake requires the use of the macro @code{AC_ARG_PROGRAM} if a
421 program or script is installed.
422 @cvindex AC_ARG_PROGRAM
424 If your package is not a flat distribution, Automake requires the use of
425 @code{AC_PROG_MAKE_SET}.
426 @cvindex AC_PROG_MAKE_SET
428 Automake will also recognize the use of certain macros and tailor the
429 generated @file{Makefile.in} appropriately.  Currently recognized macros
430 and their effects are:
432 @table @code
433 @item AC_CONFIG_HEADER
434 Automake will generate rules to automatically regenerate the config
435 header.  If you do use this macro, you must create the file
436 @file{stamp-h.in}.  It can be empty.  Also, the @code{AC_OUTPUT} command
437 in @file{configure.in} must create @file{stamp-h}, eg:
438 @example
439 AC_OUTPUT(Makefile, [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h])
440 @end example
441 @cvindex AC_CONFIG_HEADER
443 @item AC_CONFIG_AUX_DIR
444 Automake will look for various helper scripts, such as
445 @file{mkinstalldirs}, in the directory named in this macro invocation.
446 If not seen, the scripts are looked for in their ``standard'' locations
447 (either the top source directory, or in the source directory
448 corresponding to the current @file{Makefile.am}, whichever is
449 appropriate).
450 @cvindex AC_CONFIG_AUX_DIR
452 @item AC_OUTPUT
453 Automake uses this to determine which files to create.
454 @cvindex AC_OUTPUT
456 @item AC_PATH_XTRA
457 Automake will insert definitions for the variables defined by
458 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
459 or library.
460 @cvindex AC_PATH_XTRA
462 @item AC_CANONICAL_HOST
463 @item AC_CANONICAL_SYSTEM
464 @item AC_CHECK_TOOL
465 Automake will ensure that @file{config.guess} and @file{config.sub}
466 exist.
467 @cvindex AC_CANONICAL_HOST
468 @cvindex AC_CANONICAL_SYSTEM
469 @cvindex AC_CHECK_TOOL
471 @item AC_FUNC_ALLOCA
472 @item AC_FUNC_GETLOADAVG
473 @item AC_FUNC_MEMCMP
474 @item AC_STRUCT_ST_BLOCKS
475 @item fp_FUNC_FNMATCH
476 @item AC_FUNC_FNMATCH
477 @item AC_REPLACE_FUNCS
478 @item AC_REPLACE_GNU_GETOPT
479 Automake will ensure that the appropriate source files are part of the
480 distribution, and will ensure that the appropriate dependencies are
481 generated for these objects.  @xref{A Library} for more
482 information.
483 @cvindex AC_FUNC_ALLOCA
484 @cvindex AC_FUNC_GETLOADAVG
485 @cvindex AC_FUNC_MEMCMP
486 @cvindex AC_STRUCT_ST_BLOCKS
487 @cvindex fp_FUNC_FNMATCH
488 @cvindex AC_FUNC_FNMATCH
489 @cvindex AC_REPLACE_FUNCS
490 @cvindex AC_REPLACE_GNU_GETOPT
492 Automake will also detect statements which put @samp{.o} files into
493 @code{LIBOBJS}, and will treat these additional files in a similar way.
494 @cvindex LIBOBJS
496 @item AC_PROG_RANLIB
497 This is required if any libraries are built in the package.
498 @cvindex AC_PROG_RANLIB
500 @item AC_PROG_INSTALL
501 @item fp_PROG_INSTALL
502 @code{fp_PROG_INSTALL} is required if any scripts (@pxref{Scripts}) are
503 installed by the package.  Otherwise, @code{AC_PROG_INSTALL} is
504 required.
505 @cvindex AC_PROG_INSTALL
506 @cvindex fp_PROG_INSTALL
508 @item gm_PROG_LIBTOOL
509 @item AC_PROG_LIBTOOL
510 Automake will turn on processing for @code{libtool} (@pxref{Top, , The
511 Libtool Manual, libtool.info, The Libtool Manual}).  This work is
512 still preliminary.
513 @cvindex gm_PROG_LIBTOOL
514 @cvindex AC_PROG_LIBTOOL
516 @item ALL_LINGUAS
517 If Automake sees that this variable is set in @file{configure.in}, it
518 will check the @file{po} directory to ensure that all the named
519 @samp{.po} files exist, and that all the @samp{.po} files that exist are
520 named.
521 @cvindex ALL_LINGUAS
523 @item fp_C_PROTOTYPES
524 This is required when using automatic de-ANSI-fication, see @ref{ANSI}.
525 @cvindex fp_C_PROTOTYPES
527 @item ud_GNU_GETTEXT
528 This macro is required for packages which use GNU gettext (FIXME xref).
529 It is distributed with gettext.  Automake uses this macro to ensure that
530 the package meets some of gettext's requirements.
531 @cvindex ud_GNU_GETTEXT
533 @item jm_MAINTAINER_MODE
534 This macro adds a @samp{--enable-maintainer-mode} option to
535 @code{configure}.  If this is used, @code{automake} will cause
536 ``maintainer-only'' rules to be turned off by default in the generated
537 @file{Makefile.in}s.
538 @cvindex jm_MAINTAINER_MODE
539 @end table
541 The @samp{fp_} macros are from @value{Francois} Pinard and the
542 @samp{jm_} macro is from Jim Meyering.  Both sets are included with
543 Automake.  @code{automake} will tell where the macros can be found if
544 they are missing.
547 @node Top level
548 @chapter The top-level @file{Makefile.am}
550 In non-flat packages, the top level @file{Makefile.am} must tell
551 Automake which subdirectories are to be built.  This is done via the
552 @code{SUBDIRS} variable.
553 @vindex SUBDIRS
555 The @code{SUBDIRS} macro holds a list of subdirectories in which
556 building of various sorts can occur.  Many targets (eg @code{all}) in
557 the generated @file{Makefile} will run both locally and in all specified
558 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
559 not required to contain @file{Makefile.am}s; only @file{Makefile}s
560 (after configuration).  This allows inclusion of libraries from packages
561 which do not use Automake (such as @code{gettext}).
563 In a deep package, the top-level @file{Makefile.am} is often very short.
564 For instance, here is the @file{Makefile.am} from the textutils
565 distribution:
567 @example
568 SUBDIRS = lib src doc man
569 EXTRA_DIST = @@README_ALPHA@@
570 @end example
572 @code{SUBDIRS} can contain configure substitutions (eg @samp{@@DIRS@@});
573 Automake itself does not actually examine the contents of this variable.
575 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
576 @code{AC_PROG_MAKE_SET}.
579 @node Programs
580 @chapter Building Programs and Libraries
582 A large part of Automake's functionality is dedicated to making it easy
583 to build C programs and libraries.
585 @menu
586 * A Program::                   Building a program
587 * A Library::                   Building a library
588 * ANSI::                        Automatic de-ANSI-fication
589 * Dependencies::                Automatic dependency tracking
590 @end menu
593 @node A Program
594 @section Building a program
596 In a directory containing source that gets built into a program (as
597 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
598 can be installed in @code{bindir}, @code{sbindir}, @code{libexecdir},
599 @code{pkglibdir}, or not at all.
601 For instance:
603 @example
604 bin_PROGRAMS = hello
605 @end example
607 In this simple case, the resulting @file{Makefile.in} will contain code
608 to generate a program named @code{hello}.  The variable
609 @code{hello_SOURCES} is used to specify which source files get built
610 into an executable:
612 @example
613 hello_SOURCES = hello.c
614 @end example
616 This causes @file{hello.c} to be compiled into @file{hello.o}, and then
617 linked to produce @file{hello}.
619 If @samp{prog_SOURCES} is needed, but not specified, then it defaults to
620 the single file @file{prog.c}.  Id est in the example above, the
621 definition of @code{hello_SOURCES} is actually redundant.
622 @vindex _SOURCES
623 @vindex SOURCES
625 Multiple programs can be built in a single directory.  Multiple programs
626 can share a single source file.  The source file must be listed in each
627 @samp{_SOURCES} definition.
629 Header files listed in a @samp{_SOURCES} definition will be ignored.
630 Lex (@samp{.l}) and yacc (@samp{.y}) files can also be listed; support
631 for these should work but is still preliminary.
632 @c lex & yacc should have a separate section
634 Sometimes it is useful to determine the programs that are to be built at
635 configure time.  For instance, GNU @code{cpio} only builts @code{mt} and
636 @code{rmt} under special circumstances.
638 In this case, you must notify @code{Automake} of all the programs that
639 can possibly be built, but at the same time cause the generated
640 @file{Makefile.in} to use the programs specified by @code{configure}.
641 This is done by having @code{configure} substitute values into each
642 @samp{_PROGRAMS} definition, while listing all optionally built programs in
643 @code{EXTRA_PROGRAMS}.
644 @vindex EXTRA_PROGRAMS
646 If you need to link against libraries that are not found by
647 @code{configure}, you can use @code{LDADD} to do so.  This variable
648 actually can be used to add any options to the linker command line.
649 @vindex LDADD
651 Sometimes, multiple programs are built in one directory but do not share
652 the same link-time requirements.  In this case, you can use the
653 @samp{@var{prog}_LDADD} variable (where @var{PROG} is the name of the
654 program as it appears in some @samp{_PROGRAMS} variable, and usually
655 written in lowercase) to override the global @code{LDADD}.  (If this
656 variable exists for a given program, then that program is not linked
657 using @code{LDADD}.)
658 @vindex _LDADD
660 For instance, in GNU cpio, @code{pax}, @code{cpio}, and @code{mt} are
661 linked against the library @file{libcpio.a}.  However, @code{rmt} is
662 built in the same directory, and has no such link requirement.  Also,
663 @code{mt} and @code{rmt} are only built on certain architectures.  Here
664 is what cpio's @file{src/Makefile.am} looks like (abridged):
666 @example
667 bin_PROGRAMS = cpio pax @@MT@@
668 libexec_PROGRAMS = @@RMT@@
669 EXTRA_PROGRAMS = mt rmt
671 LDADD = ../lib/libcpio.a @@INTLLIBS@@
672 rmt_LDADD =
674 cpio_SOURCES = @dots{}
675 pax_SOURCES = @dots{}
676 mt_SOURCES = @dots{}
677 rmt_SOURCES = @dots{}
678 @end example
680 It is also occasionally useful to have a program depend on some other
681 target which is not actually part of that program.  This can be done
682 using the @samp{prog_DEPENDENCIES} variable.  Each program depends on
683 the contents of such a variable, but no further interpretation is done.
685 Since program names are rewritten into Makefile macro names, program
686 names must follow Makefile macro syntax.  Sometimes it is useful to have
687 a program whose name does not follow such rules.  In these cases,
688 Automake canonicalizes the program name.  All characters in the name
689 except for letters, numbers, and the underscore are turned into
690 underscores when making macro references.  Eg, if your program is named
691 @code{sniff-glue}, you would use @code{sniff_glue_SOURCES}, not
692 @code{sniff-glue_SOURCES}.
695 @node A Library
696 @section Building a library
698 Building a library is much like building a program.  In this case, the
699 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
700 @code{libdir} or @code{pkglibdir}.
702 Each @samp{_LIBRARIES} variable is a list of the base names of
703 libraries to be built.  For instance to create a library named
704 @file{libcpio.a}, but not install it, you would write:
706 @example
707 noinst_LIBRARIES = cpio
708 @end example
710 The sources that go into a library are determined exactly as they are
711 for programs, via the @samp{_SOURCES} variables.  Note that programs and
712 libraries share a namespace, so one cannot have a program (@file{lob}) and
713 a library (@file{liblob.a}) with the same name in one directory.
715 Extra objects can be added to a library using the @samp{library_LIBADD}
716 variable.  This should be used for objects determined by
717 @code{configure}.  Again from cpio:
718 @vindex _LIBADD
719 @vindex LIBADD
721 @example
722 cpio_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
723 @end example
725 Note that Automake explicitly recognizes the use of @code{@@LIBOBJS@@}
726 and @code{@@ALLOCA@@} in the above example, and uses this information,
727 plus the list of @code{LIBOBJS} files derived from @file{configure.in}
728 to automatically include the appropriate source files in the
729 distribution (@pxref{Dist}).  These source files are also automatically
730 handled in the dependency-tracking scheme, see @xref{Dependencies}.
733 @node ANSI
734 @section Automatic de-ANSI-fication
736 Although the GNU standards prohibit it, some GNU programs are written in
737 ANSI C; see FIXME.  This is possible because each source file can be
738 ``de-ANSI-fied'' before the actual compilation takes place.
740 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
741 @vindex AUTOMAKE_OPTIONS
742 (@ref{Options}) contains the option @code{ansi2knr}
743 @opindex ansi2knr
744 then code to handle de-ANSI-fication is inserted into the generated
745 @file{Makefile.in}.
747 This causes each source file to be treated as ANSI C.  If an ANSI C
748 compiler is available, it is used.
750 This support requires the source files @file{ansi2knr.c} and
751 @file{ansi2knr.1} to be in the same directory as the ANSI C source;
752 these files are distributed with Automake.
753 Also, the package @file{configure.in} must call the macro
754 @code{fp_C_PROTOTYPES}.
755 @cvindex fp_C_PROTOTYPES
758 @node Dependencies
759 @section Automatic dependency tracking
761 As a developer it is often painful to continually update the
762 @file{Makefile.in} whenever the include-file dependencies change in a
763 project.  @code{automake} supplies a way to automatically track
764 dependency changes, and distribute the dependencies in the generated
765 @file{Makefile.in}.
767 Currently this support requires the use of GNU @code{make} and
768 @code{gcc}.  It might become possible in the future to supply a
769 different dependency generating program, if there is enough demand.
771 This mode is enabled by default if any C program or library is defined
772 in the current directory.
774 When you decide to make a distribution, the @code{dist} target will
775 @trindex dist
776 re-run @code{automake} with the @samp{--include-deps} option.  This
777 @c FIXME XREF?
778 causes the previously generated dependencies to be inserted into the
779 generated @file{Makefile.in}, and thus into the distribution.
780 @samp{--include-deps} also turns off inclusion of the dependency
781 generation code.
783 This mode can be suppressed by putting @code{no-dependencies} in the
784 variable @code{AUTOMAKE_OPTIONS}.
785 @vindex AUTOMAKE_OPTIONS
786 @opindex no-dependencies
789 @node Other objects
790 @chapter Other Derived Objects
792 Automake can handle derived objects which are not C programs.  Sometimes
793 the support for actually building such objects must be explicitly
794 supplied, but Automake will still automatically handle installation and
795 distribution.
797 @menu
798 * Scripts::                     Executable scripts
799 * Headers::                     Header files
800 * Data::                        Architecture-independent data files
801 * Sources::                     Derived sources
802 @end menu
805 @node Scripts
806 @section Executable Scripts
808 It is possible to define and install programs which are scripts.  Such
809 programs are listed using the @samp{SCRIPTS} primary name.
810 @code{automake} doesn't define any dependencies for scripts; the
811 @file{Makefile.am} should include the appropriate rules.
812 @vindex SCRIPTS
814 @code{automake} does not assume that scripts are derived objects; such
815 objects are must be deleted by hand; see @ref{Clean} for more
816 information.
818 @code{automake} itself is a script that is generated at configure time
819 from @file{automake.in}.  Here is how this is handled:
821 @example
822 bin_SCRIPTS = automake
823 @end example
825 Since @code{automake} appears in the @code{AC_OUTPUT} macro,
826 dependencies for it are automatically generated.
828 Script objects can be installed in @code{bindir}, @code{sbindir},
829 @code{libexecdir}, or @code{pkgdatadir}.
832 @node Headers
833 @section Header files
835 Header files are specified by the @samp{HEADERS} family of variables.
836 Generally header files are not installed, so the @code{noinst_HEADERS}
837 variable will be the most used.
838 @vindex HEADERS
840 All header files must be listed somewhere; missing ones will not appear
841 in the distribution.  Often it is most convenient to list uninstalled
842 headers with the rest of the sources for a program.  @xref{A Program}.
844 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
845 @code{pkgincludedir}.
848 @node Data
849 @section Architecture-independent data files
851 Automake supports the installation of miscellaneous data files using the
852 @samp{DATA} family of variables.
853 @vindex DATA
855 Such data can be installed in the directories @code{datadir},
856 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
857 @code{pkgdatadir}.
859 All such data files are included in the distribution.
861 Here is how @code{autoconf} installs its auxiliary data files:
863 @example
864 pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \
865 compile.am data.am depend.am dist-subd-top.am dist-subd-vars.am \
866 dist-subd.am dist-vars.am dist.am footer.am header-vars.am header.am \
867 libscripts.am libprograms.am libraries-vars.am libraries.am library.am \
868 mans-vars.am mans.am packagedata.am program.am programs.am remake-hdr.am \
869 remake-subd.am remake.am scripts.am subdirs.am tags.am tags-subd.am \
870 texinfos-vars.am texinfos.am hack-make.sed nl-remove.sed
871 @end example
874 @node Sources
875 @section Built sources
877 Occasionally a file which would otherwise be called ``source'' (eg a C
878 @samp{.h} file) is actually derived from some other file.  Such files
879 should be listed in the @code{BUILT_SOURCES} variable.
880 @vindex BUILT_SOURCES
882 Files listed in @code{BUILT_SOURCES} are built before any automatic
883 dependency tracking is done.  Built sources are included in a
884 distribution.
887 @node Documentation
888 @chapter Building documentation
890 Currently Automake provides support for Texinfo and man pages.
892 @menu
893 * Texinfo::                     Texinfo
894 * Man pages::                   Man pages
895 @end menu
898 @node Texinfo
899 @section Texinfo
901 If the current directory contains Texinfo source, you must declare it
902 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
903 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
904 here.  Note that any Texinfo source file must end in the @samp{.texi}
905 extension (@samp{.texinfo} won't work).
906 @vindex TEXINFOS
907 @vindex info_TEXINFOS
909 If the @samp{.texi} file @code{@@include}s @file{version.texi}, then that
910 file will be automatically generated.  @file{version.texi} defines three
911 Texinfo macros you can reference: @code{EDITION}, @code{VERSION}, and
912 @code{UPDATED}.  The first two hold the version number of your package
913 (but are kept separate for clarity); the last is the date the primary
914 file was last modified.  The @file{version.texi} support requires the
915 @code{mdate-sh} program; this program is supplied with Automake.
917 Sometimes an info file actually depends on more than one @samp{.texi}
918 file.  For instance, in the @code{xdvik} distribution,
919 @file{kpathsea.texi} includes the files @file{install.texi},
920 @file{copying.texi}, and @file{freedom.texi}.  You can tell Automake
921 about these dependencies using the @samp{texi_TEXINFOS} variable.  Here
922 is how @code{xdvik} could do it:
923 @vindex TEXINFOS
924 @vindex _TEXINFOS
926 @example
927 info_TEXINFOS = kpathsea.texi
928 kpathsea_TEXINFOS = install.texi copying.texi freedom.texi
929 @end example
931 Automake will warn if a directory containing Texinfo source does not
932 also contain the file @file{texinfo.tex}.  This file is supplied with
933 Automake.
935 Automake generates an @code{install-info} target; some people apparently
936 use this.
939 @node Man pages
940 @section Man pages
942 A package can also include man pages.  (Though see the GNU standards on
943 this matter, @ref{Man Pages, , , standards.info, The GNU Coding
944 Standards}.)  Man pages are declared using the @samp{MANS} primary.
945 Generally the @code{man_MANS} macro is used.  Man pages are
946 automatically installed in the correct subdirectory of @code{mandir},
947 based on the file extension.
948 @vindex MANS
949 @vindex man_MANS
951 @c Use @samp{make install} per documentation: (texi.info)code.
952 By default, man pages are installed by @samp{make install}.  However,
953 since the GNU project does not require man pages, many maintainers do
954 not expend effort to keep the man pages up to date.  In these cases, the
955 @code{no-installman} option will prevent the man pages from being
956 installed by default.  The user can still explicitly install them via
957 @samp{make install-man}.
958 @opindex no-installman
959 @trindex install-man
961 Here is how the documentation is handled in GNU @code{cpio} (which
962 includes both Texinfo documentation and man pages):
964 @example
965 info_TEXINFOS = cpio.texi
966 man_MANS = cpio.1 mt.1
967 @end example
969 Texinfo source, info pages and man pages are all considered to be source
970 for the purposes of making a distribution.
973 @node Install
974 @chapter What Gets Installed
976 Naturally, Automake handles the details of actually installing your
977 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
978 @code{LIBRARIES}, @code{DATA} and @code{HEADERS} are automatically
979 installed in the appropriate places.
981 Automake also handles installing any specified info and man pages.
983 Automake generates separate @code{install-data} and @code{install-exec}
984 targets, in case the installer is installing on multiple machines which
985 share directory structure -- these targets allow the machine-independent
986 parts to be installed only once.  The @code{install} target depends on
987 both of these targets.
988 @trindex install-data
989 @trindex install-exec
990 @trindex install
992 Automake also generates an @code{uninstall} target, and an
993 @code{installdirs} target.
994 @trindex uninstall
995 @trindex installdirs
997 It is possible to extend this mechanism by defining an
998 @code{install-exec-local} or @code{install-data-local} target.  If these
999 targets exist, they will be run at @samp{make install} time.
1000 @trindex install-exec-local
1001 @trindex install-data-local
1004 @node Clean
1005 @chapter What Gets Cleaned
1007 The GNU Makefile Standards specify a number of different clean rules.
1008 @c FIXME xref
1009 Generally the files that can cleaned are determined automatically by
1010 Automake.  Of course, Automake also recognizes some variables that can
1011 be defined to specify additional files to clean.  These variables are
1012 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
1013 @code{MAINTAINERCLEANFILES}.
1014 @vindex MOSTLYCLEANFILES
1015 @vindex CLEANFILES
1016 @vindex DISTCLEANFILES
1017 @vindex MAINTAINERCLEANFILES
1019 In Automake, the @code{automake} program is not automatically removed,
1020 because it is an executable script.  So this code in @file{Makefile.am}
1021 causes it to be removed by @samp{make clean}:
1023 @example
1024 CLEANFILES = automake
1025 @end example
1028 @node Dist
1029 @chapter What Goes in a Distribution
1031 The @code{dist} target in the generated @file{Makefile.in} can be used
1032 to generate a gzip'd @code{tar} file for distribution.  The tar file is
1033 named based on the @var{PACKAGE} and @var{VERSION} variables.
1034 @cvindex PACKAGE
1035 @cvindex VERSION
1036 @trindex dist
1038 For the most part, the files to distribute are automatically found by
1039 Automake: all source files are automatically included in a distribution,
1040 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
1041 has a built-in list of commonly used files which, if present in the
1042 current directory, are automatically included.  This list is printed by
1043 @samp{automake --help}.  Also, files which are read by @code{configure}
1044 (ie, the source files corresponding to the files specified in the
1045 @code{AC_OUTPUT} invocation) are automatically distributed.
1047 Still, sometimes there are files which must be distributed, but which
1048 are not covered in the automatic rules.  These files should be listed in
1049 the @code{EXTRA_DIST} variable.
1050 @vindex EXTRA_DIST
1052 Occasionally it is useful to be able to change the distribution before
1053 it is packaged up.  If the @code{dist-hook} target exists, it is run
1054 after the distribution directory is filled, but before the actual tar
1055 (or shar) file is created.  One way to use this is for distributing file
1056 in subdirectories for which a new @file{Makefile.am} is overkill:
1058 @example
1059 dist-hook:
1060         mkdir $(distdir)/random
1061         cp -p random/a1 random/a2 $(distdir)/random
1062 @end example
1064 Automake also generates a @code{distcheck} target which can be help to
1065 ensure that a given distribution will actually work.  @code{distcheck}
1066 makes a distribution, and then tries to do a @code{VPATH} build.
1067 @trindex distcheck
1070 @node Tests
1071 @chapter Support for test suites
1073 Automake supports a simple form of test suite.  If the variable
1074 @code{TESTS} is defined, its value is taken to be a list of programs to
1075 run in order to do the testing.  The programs can either be derived
1076 objects or source objects; the generated rule will look both in
1077 @var{srcdir} and @file{.}.
1079 The testing is done via @samp{make check}.  The number of failures will
1080 be printed at the end of the run.
1082 In the future there will be some support for test suites which use
1083 @code{DejaGnu}.
1086 @node Options
1087 @chapter Changing Automake's Behavior
1089 Various features of Automake can be controlled by options in the
1090 @file{Makefile.am}.  Such options are listed in a special variable named
1091 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
1092 @vindex AUTOMAKE_OPTIONS
1094 @table @asis
1095 @item @code{gnits}
1096 @itemx @code{gnu}
1097 @itemx @code{foreign}
1098 The same as the corresponding @samp{--strictness} option.
1100 @item @code{no-installman}
1101 The generated @file{Makefile.in} will not cause man pages to be
1102 installed by default.  However, an @code{install-man} target will still
1103 be available for optional installation.
1104 @trindex install-man
1106 @item @code{ansi2knr}
1107 Turn on automatic de-ANSI-fication.
1109 @item @code{dist-shar}
1110 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
1111 target.
1112 @trindex dist-shar
1114 @item @code{dist-zip}
1115 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
1116 target.
1117 @trindex dist-zip
1119 @item @code{no-dependencies}
1120 This is similar to using @samp{--include-deps} on the command line, but
1121 is useful for those situations where you don't have the necessary bits
1122 to make automatic dependency tracking work @xref{Dependencies}.  In this
1123 case the effect is to effectively disable automatic dependency tracking.
1125 @item @var{version}
1126 A version number (eg @samp{0.30}) can be specified.  If Automake is not
1127 newer than the version specified, creation of the @file{Makefile.in}
1128 will be suppressed.
1129 @end table
1131 Unrecognized options are diagnosed by @code{automake}.
1134 @node Miscellaneous
1135 @chapter Miscellaneous Rules
1137 There are a few rules and variables that didn't fit anywhere else.
1139 @menu
1140 * Tags::                        Interfacing to etags and mkid
1141 * Suffixes::                    Handling new file extensions
1142 * Built::                       Built sources
1143 @end menu
1146 @node Tags
1147 @section Interfacing to @code{etags}
1149 @code{automake} will generate rules to generate @file{TAGS} files for
1150 use with GNU Emacs under some circumstances.
1152 If any C source code or headers are present, then a @code{tags} target
1153 will be generated for the directory.
1154 @trindex tags
1156 At the topmost directory of a multi-directory package, a @code{tags}
1157 target file will be generated which, when run, will generate a
1158 @file{TAGS} file that includes by reference all @file{TAGS} files from
1159 subdirectories.
1161 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
1162 will be generated.  This variable is intended for use in directories
1163 which contain taggable source that @code{etags} does not understand.
1165 Here is how Automake generates tags for its source, and for nodes in its
1166 Texinfo file:
1168 @example
1169 ETAGS_ARGS = automake.in --lang=none \
1170  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
1171 @end example
1173 Automake will also generate an @code{ID} target which will run
1174 @code{mkid} on the source.  This is only supported on a
1175 directory-by-directory basis.
1176 @trindex id
1179 @node Suffixes
1180 @section Handling new file extensions
1182 It is sometimes useful to introduce a new implicit rule to handle a file
1183 type that Automake does not know about.  If this is done, you must
1184 notify GNU Make of the new suffixes.  This can be done by putting a list
1185 of new suffixes in the @code{SUFFIXES} variable.
1186 @vindex SUFFIXES
1189 @node Built
1190 @section Built sources
1192 FIXME write this
1195 @node Extending
1196 @chapter When Automake Isn't Enough
1198 Sometimes @code{automake} isn't enough.  Then you just lose.
1200 Actually, @code{automake}s implicit copying semantics means that many
1201 problems can be worked around by simply adding some @code{make} targets
1202 and rules to @file{Makefile.in}.  @code{automake} will ignore these
1203 additions.
1205 There are some caveats to doing this.  Although you can overload a
1206 target already used by @code{automake}, it is often inadvisable,
1207 particularly in the topmost directory of a non-flat package.  However,
1208 various useful targets have a @samp{-local} version you can specify in your
1209 @file{Makefile.in}.  Automake will supplement the standard target with
1210 these user-supplied targets.
1212 The targets that support a local version are @code{all}, @code{info},
1213 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec}, and
1214 @code{uninstall}.
1215 @trindex all
1216 @trindex info
1217 @trindex dvi
1218 @trindex check
1219 @trindex install-data
1220 @trindex install-exec
1221 @trindex uninstall
1223 For instance, here is how to install a file in @file{/etc}:
1225 @example
1226 install-data-local:
1227         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
1228 @end example
1230 Some targets also have a way to run another target, called a @dfn{hook},
1231 after their work is done.  The hook is named after the principal target,
1232 with @samp{-hook} appended.  The targets allowing hooks are
1233 @code{install-data}, @code{install-exec}, and @code{dist}.
1234 @trindex install-data-hook
1235 @trindex install-exec-hook
1236 @trindex dist-hook
1238 For instance, here is how to create a hard link to an installed program:
1240 @example
1241 install-exec-hook:
1242         $(LN) $(bindir)/program $(bindir)/proglink
1243 @end example
1245 @c FIXME should include discussion of variables you can use in these
1246 @c rules
1249 @node Distributing
1250 @chapter Distributing @file{Makefile.in}s
1252 Automake places no restrictions on the distribution of the resulting
1253 @file{Makefile.in}s.  We still encourage software authors to distribute
1254 their work under terms like those of the GPL, but doing so is not
1255 required to use Automake.
1257 Some of the files that can be automatically installed via the
1258 @samp{--add-missing} switch do fall under the GPL; examine each file
1259 to see.
1262 @node Examples
1263 @chapter Some example packages
1265 Here are some examples of how Automake can be used.
1267 @menu
1268 * Hello::                       The simplest GNU program
1269 * Tricky::                      A trickier example
1270 * Automake::                    Automake's own use
1271 * Textutils::                   A deep hierarchy
1272 @end menu
1274 @node Hello
1275 @section The simplest GNU program
1277 @code{hello} is renowned for its classic simplicity and versatility.
1278 What better place to begin a tour?  The below shows what could be used
1279 as the Hello distribution's @file{Makefile.am}.
1281 @example
1282 bin_PROGRAMS = hello
1283 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h
1284 hello_LDADD = @@ALLOCA@@
1285 info_TEXINFOS = hello.texi
1286 hello_TEXINFOS = gpl.texi
1288 EXTRA_DIST = testdata
1290 check-local: hello
1291         @@echo expect no output from diff
1292         ./hello > test.out
1293         diff -c $(srcdir)/testdata test.out
1294         rm -f test.out
1295 @end example
1297 Of course, Automake also requires some minor changes to
1298 @file{configure.in}.  The new @file{configure.in} would read:
1300 @example
1301 dnl Process this file with autoconf to produce a configure script.
1302 AC_INIT(hello.c)
1303 VERSION=1.3
1304 AC_SUBST(VERSION)
1305 PACKAGE=hello
1306 AC_SUBST(PACKAGE)
1307 AC_PROG_CC
1308 AC_PROG_CPP
1309 AC_PROG_INSTALL
1310 AC_STDC_HEADERS
1311 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h)
1312 AC_ALLOCA
1313 AC_OUTPUT(Makefile)
1314 @end example
1316 If Hello were really going to use Automake, the @file{version.c} file
1317 would probably be deleted, or changed so as to be automatically
1318 generated.
1321 @node Tricky
1322 @section A tricker example
1324 Here is another, trickier example.  It shows how to generate two
1325 programs (@code{ctags} and @code{etags}) from the same source file
1326 (@file{etags.c}).  The difficult part is that each compilation of
1327 @file{etags.c} requires different @code{cpp} flags.
1329 @example
1330 bin_PROGRAMS = etags ctags
1331 ctags_SOURCES =
1332 ctags_LDADD = ctags.o
1333 ctags_DEPENDENCIES = ctags.o
1335 etags.o:
1336         $(COMPILE) -DETAGS_REGEXPS etags.c
1338 ctags.o:
1339         $(COMPILE) -DCTAGS -o ctags.o etags.c
1340 @end example
1342 Note that @code{ctags_SOURCES} is defined to be empty -- that way no
1343 implicit value is substituted.  The implicit value, however, is used to
1344 generate @code{etags} from @file{etags.o}.
1346 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line,
1347 while @code{ctags_DEPENDENCIES} exists to make sure that @file{ctags.o}
1348 gets built in the first place.
1350 This is a somewhat pathological example.
1353 @node Automake
1354 @section Automake uses itself
1356 Automake, of course, uses itself to generate its @file{Makefile.in}.
1357 Since Automake is a shallow package, it has more than one
1358 @file{Makefile.am}.  Here is the top-level @file{Makefile.am}:
1360 @example
1361 ## Process this file with automake to create Makefile.in
1363 AUTOMAKE_OPTIONS = gnits
1364 MAINT_CHARSET = latin1
1365 PERL = @@PERL@@
1367 SUBDIRS = tests
1369 bin_SCRIPTS = automake
1370 info_TEXINFOS = automake.texi
1372 pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \
1373 compile.am data.am depend.am \
1374 dist-vars.am footer.am header.am header-vars.am \
1375 kr-vars.am libraries-vars.am \
1376 libraries.am library.am mans-vars.am \
1377 program.am programs.am remake-hdr.am \
1378 remake-subd.am remake.am scripts.am subdirs.am tags.am tags-subd.am \
1379 tags-clean.am \
1380 texi-version.am texinfos-vars.am texinfos.am \
1381 libraries-clean.am programs-clean.am data-clean.am \
1382 COPYING INSTALL texinfo.tex \
1383 ansi2knr.c ansi2knr.1 \
1384 aclocal.m4
1386 ## These must all be executable when installed.
1387 pkgdata_SCRIPTS = config.guess config.sub install-sh mdate-sh mkinstalldirs
1389 CLEANFILES = automake
1391 # The following requires a fixed version of the Emacs 19.30 etags.
1392 ETAGS_ARGS = automake.in --lang=none \
1393  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
1395 ## `test -x' is not portable.  So we use Perl instead.  If Perl
1396 ## doesn't exist, then this test is meaningless anyway.
1397 # Check to make sure some installed files are executable.
1398 installcheck-local:
1399         $(PERL) -e "exit ! -x '$(pkgdatadir)/config.guess';"
1400         $(PERL) -e "exit ! -x '$(pkgdatadir)/config.sub';"
1401         $(PERL) -e "exit ! -x '$(pkgdatadir)/install-sh';"
1402         $(PERL) -e "exit ! -x '$(pkgdatadir)/mdate-sh';"
1403         $(PERL) -e "exit ! -x '$(pkgdatadir)/mkinstalldirs';"
1405 # Some simple checks:
1406 # * syntax check with perl4 and perl5.
1407 # * make sure the scripts don't use 'true'
1408 # * expect no instances of '$@{...@}'
1409 # These are only really guaranteed to work on my machine.
1410 maintainer-check: automake check
1411         $(PERL) -c -w automake
1412         @@if grep '^[^#].*true' $(srcdir)/[a-z]*.am; then \
1413           echo "can't use 'true' in GNU Makefile" 1>&2; \
1414           exit 1;                               \
1415         else :; fi
1416         @@if test `fgrep '$$@{' $(srcdir)/[a-z]*.am | wc -l` -ne 0; then \
1417           echo "found too many uses of '\$$@{'" 1>&2; \
1418           exit 1;                               \
1419         fi
1420         if $(SHELL) -c 'perl4.036 -v' >/dev/null 2>&1; then \
1421           perl4.036 -c -w automake; \
1422         else :; fi
1424 # Tag before making distribution.  Also, don't make a distribution if
1425 # checks fail.  Also, make sure the NEWS file is up-to-date.
1426 cvs-dist: maintainer-check
1427         @@if sed 1q NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
1428           echo "NEWS not updated; not releasing" 1>&2; \
1429           exit 1;                               \
1430         fi
1431         cvs tag `echo "Release-$(VERSION)" | sed 's/\./-/g'`
1432         $(MAKE) dist
1433 @end example
1435 As you can see, Automake defines many of its own rules, to make the
1436 maintainer's job easier.  For instance the @code{cvs-dist} rule
1437 automatically tags the current version in the CVS repository, and then
1438 makes a standard distribution.
1440 Automake consists primarily of one program, @code{automake}, and a
1441 number of auxiliary scripts.  Automake also installs a number of
1442 programs which are possibly installed via the @samp{--add-missing}
1443 option; these scripts are listed in the @code{pkgdata_SCRIPTS} variable.
1445 Automake also has a @file{tests} subdirectory, as indicated in the
1446 @code{SUBDIRS} variable above.  Here is @file{tests/Makefile.am}:
1448 @example
1449 ## Process this file with automake to create Makefile.in
1451 AUTOMAKE_OPTIONS = gnits
1453 TESTS = mdate.test vtexi.test acoutput.test instexec.test checkall.test \
1454 acoutnoq.test acouttbs.test libobj.test proginst.test acoutqnl.test \
1455 confincl.test spelling.test prefix.test badprog.test depend.test
1457 EXTRA_DIST = defs
1458 @end example
1460 This is where all the tests are really run.  @file{defs} is an
1461 initialization file used by each test script; it is explicitly mentioned
1462 because @code{automake} has no way of automatically finding it.
1465 @node Textutils
1466 @section A deep hierarchy
1468 The GNU textutils are a collection of programs for manipulating text
1469 files.  They are distributed as a deep package.  The textutils have only
1470 recently been modified to use Automake; the examples come from a
1471 prerelease.
1473 Here is the top-level @file{Makefile.am}:
1475 @example
1476 SUBDIRS = lib src doc man
1477 @end example
1479 In the @file{lib} directory, a library is built which is used by each
1480 textutil.  Here is @file{lib/Makefile.am}:
1482 @example
1483 noinst_LIBRARIES = tu
1485 EXTRA_DIST = rx.c regex.c
1487 tu_SOURCES = error.h getline.h getopt.h linebuffer.h \
1488 long-options.h md5.h regex.h rx.h xstrtod.h xstrtol.h xstrtoul.h \
1489 error.c full-write.c getline.c getopt.c getopt1.c \
1490 linebuffer.c long-options.c md5.c memchr.c safe-read.c \
1491 xmalloc.c xstrtod.c xstrtol.c xstrtoul.c
1493 tu_LIBADD = @@REGEXOBJ@@ @@LIBOBJS@@ @@ALLOCA@@
1494 @end example
1496 The @file{src} directory contains the source for all the textutils -- 23
1497 programs in all.  The @file{Makefile.am} for this directory also
1498 includes some simple checking code, and constructs a @file{version.c}
1499 file on the fly:
1501 @example
1502 bin_PROGRAMS = cat cksum comm csplit cut expand fmt fold head join md5sum \
1503 nl od paste pr sort split sum tac tail tr unexpand uniq wc
1505 noinst_HEADERS = system.h version.h
1506 DISTCLEANFILES = stamp-v version.c
1508 INCLUDES = -I$(top_srcdir)/lib
1510 LDADD = version.o ../lib/libtu.a
1512 $(PROGRAMS): version.o ../lib/libtu.a
1514 AUTOMAKE_OPTIONS = ansi2knr
1516 version.c: stamp-v
1517 stamp-v: Makefile
1518         rm -f t-version.c
1519         echo '#include <config.h>' > t-version.c
1520         echo '#include "version.h"' >> t-version.c
1521         echo 'const char *version_string = "'GNU @@PACKAGE@@ @@VERSION@@'";' \
1522                 >> t-version.c
1523         if cmp -s version.c t-version.c; then   \
1524           rm t-version.c;                       \
1525         else                                    \
1526           mv t-version.c version.c;             \
1527         fi
1528         echo timestamp > $@@
1530 check: md5sum
1531         ./md5sum \
1532          --string="" \
1533          --string="a" \
1534          --string="abc" \
1535          --string="message digest" \
1536          --string="abcdefghijklmnopqrstuvwxyz" \
1537          --string="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" \
1538          --string="12345678901234567890123456789012345678901234567890123456789012345678901234567890" \
1539        | diff -c $(srcdir)/md5-test.rfc -
1540 @end example
1542 The @file{doc} directory builds the info documentation for the
1543 textutils:
1545 @example
1546 info_TEXINFOS = textutils.texi
1547 @end example
1549 And, last, the @file{man} directory installs the man pages for all the
1550 textutils:
1552 @example
1553 man_MANS = cat.1 cksum.1 comm.1 csplit.1 cut.1 expand.1 fmt.1 fold.1 head.1 \
1554 join.1 md5sum.1 nl.1 od.1 paste.1 pr.1 sort.1 split.1 sum.1 tac.1 tail.1 \
1555 tr.1 unexpand.1 uniq.1 wc.1
1556 @end example
1558 You can now see how easy it is to handle even a largish project using
1559 Automake.
1562 @node Future
1563 @chapter Some ideas for the future
1565 Here are some things that might happen in the future:
1567 @itemize @bullet
1568 @item
1569 HTML support.
1571 @item
1572 The output will be cleaned up.  For instance, only variables which are
1573 actually used will appear in the generated @file{Makefile.in}.
1575 @item
1576 There will be support for automatically recoding a distribution.  The
1577 intent is to allow a maintainer to use whatever character set is most
1578 convenient locally, but for all distributions to be Unicode or
1579 @w{ISO 10646} with the UTF-8 encoding.
1580 @end itemize
1583 @node Variables
1584 @unnumbered Index of Variables
1586 @printindex vr
1589 @node Configure variables
1590 @unnumbered Index of Configure Variables and Macros
1592 @printindex cv
1595 @node Targets
1596 @unnumbered Index of Targets
1598 @printindex tr
1601 @bye