updated version
[automake.git] / automake.texi
blob572ef4988fdfe9a7f6c2d081fdf7467af0f96371
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename automake.info
4 @settitle automake
5 @setchapternewpage off
6 @c %**end of header
8 @include version.texi
10 @dircategory GNU programming tools
11 @direntry
12 * automake: (automake).         Making Makefile.in's
13 @end direntry
15 @dircategory Individual utilities
16 @direntry
17 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4
18 @end direntry
20 @ifinfo
21 This file documents GNU automake @value{VERSION}
23 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001
24 Free Software Foundation, Inc.
26 Permission is granted to make and distribute verbatim copies of
27 this manual provided the copyright notice and this permission notice
28 are preserved on all copies.
30 @ignore
31 Permission is granted to process this file through TeX and print the
32 results, provided the printed document carries copying permission
33 notice identical to this one except for the removal of this paragraph
36 @end ignore
37 Permission is granted to copy and distribute modified versions of this
38 manual under the conditions for verbatim copying, provided that the entire
39 resulting derived work is distributed under the terms of a permission
40 notice identical to this one.
42 Permission is granted to copy and distribute translations of this manual
43 into another language, under the above conditions for modified versions,
44 except that this permission notice may be stated in a translation approved
45 by the Foundation.
46 @end ifinfo
49 @titlepage
50 @title GNU Automake
51 @subtitle For version @value{VERSION}, @value{UPDATED}
52 @author David MacKenzie and Tom Tromey
54 @page
55 @vskip 0pt plus 1filll
56 Copyright @copyright{} 1995, 1996, 2000, 2001, 2002 Free Software Foundation, Inc.
57 @sp 2
58 This is the first edition of the GNU Automake documentation,@*
59 and is consistent with GNU Automake @value{VERSION}.@*
60 @sp 2
61 Published by the Free Software Foundation @*
62 59 Temple Place - Suite 330, @*
63 Boston, MA 02111-1307 USA @*
65 Permission is granted to make and distribute verbatim copies of
66 this manual provided the copyright notice and this permission notice
67 are preserved on all copies.
69 Permission is granted to copy and distribute modified versions of this
70 manual under the conditions for verbatim copying, provided that the entire
71 resulting derived work is distributed under the terms of a permission
72 notice identical to this one.
74 Permission is granted to copy and distribute translations of this manual
75 into another language, under the above conditions for modified versions,
76 except that this permission notice may be stated in a translation
77 approved by the Free Software Foundation.
78 @end titlepage
80 @c Define an index of configure output variables.
81 @defcodeindex ov
82 @c Define an index of configure variables.
83 @defcodeindex cv
84 @c Define an index of options.
85 @defcodeindex op
86 @c Define an index of targets.
87 @defcodeindex tr
88 @c Define an index of commands.
89 @defcodeindex cm
91 @c Put the macros and variables into their own index.
92 @c @syncodeindex fn cp
93 @syncodeindex ov vr
94 @syncodeindex cv vr
95 @syncodeindex fn vr
97 @c Put everything else into one index (arbitrarily chosen to be the concept index).
98 @syncodeindex op cp
99 @syncodeindex tr cp
100 @syncodeindex cm cp
102 @ifnottex
103 @node Top, Introduction, (dir), (dir)
104 @comment  node-name,  next,  previous,  up
105 @top GNU Automake
107 This file documents the GNU Automake package.  Automake is a program
108 which creates GNU standards-compliant Makefiles from template files.
109 This edition documents version @value{VERSION}.
111 @menu
112 * Introduction::                Automake's purpose
113 * Generalities::                General ideas
114 * Examples::                    Some example packages
115 * Invoking Automake::           Creating a Makefile.in
116 * configure::                   Scanning configure.ac or configure.in
117 * Top level::                   The top-level Makefile.am
118 * Alternative::                 An alternative approach to subdirectories
119 * Rebuilding::                  Automatic rebuilding of Makefile
120 * Programs::                    Building programs and libraries
121 * Other objects::               Other derived objects
122 * Other GNU Tools::             Other GNU Tools
123 * Documentation::               Building documentation
124 * Install::                     What gets installed
125 * Clean::                       What gets cleaned
126 * Dist::                        What goes in a distribution
127 * Tests::                       Support for test suites
128 * Options::                     Changing Automake's behavior
129 * Miscellaneous::               Miscellaneous rules
130 * Include::                     Including extra files in an Automake template.
131 * Conditionals::                Conditionals
132 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
133 * Cygnus::                      The effect of @code{--cygnus}
134 * Extending::                   Extending Automake
135 * Distributing::                Distributing the Makefile.in
136 * Macro and Variable Index::
137 * General Index::
138 @end menu
140 @end ifnottex
143 @node Introduction, Generalities, Top, Top
144 @chapter Introduction
146 Automake is a tool for automatically generating @file{Makefile.in}s from
147 files called @file{Makefile.am}.  Each @file{Makefile.am} is basically a
148 series of @code{make} macro definitions (with rules being thrown in
149 occasionally).  The generated @file{Makefile.in}s are compliant with the
150 GNU Makefile standards.
152 @cindex GNU Makefile standards
154 The GNU Makefile Standards Document
155 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
156 is long, complicated, and subject to change.  The goal of Automake is to
157 remove the burden of Makefile maintenance from the back of the
158 individual GNU maintainer (and put it on the back of the Automake
159 maintainer).
161 The typical Automake input file is simply a series of macro definitions.
162 Each such file is processed to create a @file{Makefile.in}.  There
163 should generally be one @file{Makefile.am} per directory of a project.
165 @cindex Constraints of Automake
166 @cindex Automake constraints
168 Automake does constrain a project in certain ways; for instance it
169 assumes that the project uses Autoconf (@pxref{Top, , Introduction,
170 autoconf, The Autoconf Manual}), and enforces certain restrictions on
171 the @file{configure.in} contents@footnote{Autoconf 2.50 promotes
172 @file{configure.ac} over @file{configure.in}.  The rest of this
173 documentation will refer to @file{configure.in} as this use is not yet
174 spread, but Automake supports @file{configure.ac} too.}.
176 @cindex Automake requirements
177 @cindex Requirements, Automake
179 Automake requires @code{perl} in order to generate the
180 @file{Makefile.in}s.  However, the distributions created by Automake are
181 fully GNU standards-compliant, and do not require @code{perl} in order
182 to be built.
184 @cindex BUGS, reporting
185 @cindex Reporting BUGS
186 @cindex E-mail, bug reports
188 Mail suggestions and bug reports for Automake to
189 @email{bug-automake@@gnu.org}.
192 @node Generalities, Examples, Introduction, Top
193 @chapter General ideas
195 The following sections cover a few basic ideas that will help you
196 understand how Automake works.
198 @menu
199 * General Operation::           General operation of Automake
200 * Strictness::                  Standards conformance checking
201 * Uniform::                     The Uniform Naming Scheme
202 * Canonicalization::            How derived variables are named
203 * User Variables::              Variables reserved for the user
204 * Auxiliary Programs::          Programs automake might require
205 @end menu
208 @node General Operation, Strictness, Generalities, Generalities
209 @section General Operation
211 Automake works by reading a @file{Makefile.am} and generating a
212 @file{Makefile.in}.  Certain macros and targets defined in the
213 @file{Makefile.am} instruct Automake to generate more specialized code;
214 for instance, a @samp{bin_PROGRAMS} macro definition will cause targets
215 for compiling and linking programs to be generated.
217 @cindex Non-standard targets
218 @cindex cvs-dist, non-standard example
219 @trindex cvs-dist
221 The macro definitions and targets in the @file{Makefile.am} are copied
222 verbatim into the generated file.  This allows you to add arbitrary code
223 into the generated @file{Makefile.in}.  For instance the Automake
224 distribution includes a non-standard @code{cvs-dist} target, which the
225 Automake maintainer uses to make distributions from his source control
226 system.
228 @cindex GNU make extensions
230 Note that GNU make extensions are not recognized by Automake.  Using
231 such extensions in a @file{Makefile.am} will lead to errors or confusing
232 behavior.
234 Automake tries to group comments with adjoining targets and macro
235 definitions in an intelligent way.
237 @cindex Make targets, overriding
238 @cindex Overriding make targets
240 A target defined in @file{Makefile.am} generally overrides any such
241 target of a similar name that would be automatically generated by
242 @code{automake}.  Although this is a supported feature, it is generally
243 best to avoid making use of it, as sometimes the generated rules are
244 very particular.
246 @cindex Macros, overriding
247 @cindex Overriding make macros
249 Similarly, a macro defined in @file{Makefile.am} will override any
250 definition of the macro that @code{automake} would ordinarily create.
251 This feature is more often useful than the ability to override a target
252 definition.  Be warned that many of the macros generated by
253 @code{automake} are considered to be for internal use only, and their
254 names might change in future releases.
256 @cindex Recursive operation of Automake
257 @cindex Automake, recursive operation
258 @cindex Example of recursive operation
260 When examining a macro definition, Automake will recursively examine
261 macros referenced in the definition.  For example, if Automake is
262 looking at the content of @code{foo_SOURCES} in this snippet
264 @example
265 xs = a.c b.c
266 foo_SOURCES = c.c $(xs)
267 @end example
269 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
270 contents of @code{foo_SOURCES}.
272 @cindex ## (special Automake comment)
273 @cindex Special Automake comment
274 @cindex Comment, special to Automake
276 Automake also allows a form of comment which is @emph{not} copied into
277 the output; all lines beginning with @samp{##} (leading spaces allowed)
278 are completely ignored by Automake.
280 It is customary to make the first line of @file{Makefile.am} read:
282 @cindex Makefile.am, first line
283 @cindex First line of Makefile.am
285 @example
286 ## Process this file with automake to produce Makefile.in
287 @end example
289 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
290 @c I don't know quite what to say.
292 @c FIXME document customary ordering of Makefile.am here!
295 @node Strictness, Uniform, General Operation, Generalities
296 @section Strictness
298 @cindex Non-GNU packages
300 While Automake is intended to be used by maintainers of GNU packages, it
301 does make some effort to accommodate those who wish to use it, but do
302 not want to use all the GNU conventions.
304 @cindex Strictness, defined
305 @cindex Strictness, foreign
306 @cindex foreign strictness
307 @cindex Strictness, gnu
308 @cindex gnits strictness
309 @cindex Strictness, gnits
310 @cindex gnits strictness
312 To this end, Automake supports three levels of @dfn{strictness}---the
313 strictness indicating how stringently Automake should check standards
314 conformance.
316 The valid strictness levels are:
318 @table @samp
319 @item foreign
320 Automake will check for only those things which are absolutely
321 required for proper operations.  For instance, whereas GNU standards
322 dictate the existence of a @file{NEWS} file, it will not be required in
323 this mode.  The name comes from the fact that Automake is intended to be
324 used for GNU programs; these relaxed rules are not the standard mode of
325 operation.
327 @item gnu
328 Automake will check---as much as possible---for compliance to the GNU
329 standards for packages.  This is the default.
331 @item gnits
332 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
333 standards}.  These are based on the GNU standards, but are even more
334 detailed.  Unless you are a Gnits standards contributor, it is
335 recommended that you avoid this option until such time as the Gnits
336 standard is actually published (which may never happen).
337 @end table
339 For more information on the precise implications of the strictness
340 level, see @ref{Gnits}.
342 Automake also has a special ``cygnus'' mode which is similar to
343 strictness but handled differently.  This mode is useful for packages
344 which are put into a ``Cygnus'' style tree (e.g., the GCC tree).  For
345 more information on this mode, see @ref{Cygnus}.
348 @node Uniform, Canonicalization, Strictness, Generalities
349 @section The Uniform Naming Scheme
351 @cindex Uniform naming scheme
353 Automake macros (from here on referred to as @emph{variables}) generally
354 follow a @dfn{uniform naming scheme} that makes it easy to decide how
355 programs (and other derived objects) are built, and how they are
356 installed.  This scheme also supports @code{configure} time
357 determination of what should be built.
359 @cindex _PROGRAMS primary variable
360 @cindex PROGRAMS primary variable
361 @cindex Primary variable, PROGRAMS
363 @cindex Primary variable, defined
365 At @code{make} time, certain variables are used to determine which
366 objects are to be built.  The variable names are made of several pieces
367 which are concatenated together.
369 The piece which tells automake what is being built is commonly called
370 the @dfn{primary}.  For instance, the primary @code{PROGRAMS} holds a
371 list of programs which are to be compiled and linked.
372 @vindex PROGRAMS
374 @cindex pkglibdir, defined
375 @cindex pkgincludedir, defined
376 @cindex pkgdatadir, defined
378 @vindex pkglibdir
379 @vindex pkgincludedir
380 @vindex pkgdatadir
382 A different set of names is used to decide where the built objects
383 should be installed.  These names are prefixes to the primary which
384 indicate which standard directory should be used as the installation
385 directory.  The standard directory names are given in the GNU standards
386 (@pxref{Directory Variables, , , standards, The GNU Coding Standards}).
387 Automake extends this list with @code{pkglibdir}, @code{pkgincludedir},
388 and @code{pkgdatadir}; these are the same as the non-@samp{pkg}
389 versions, but with @samp{@@PACKAGE@@} appended.  For instance,
390 @code{pkglibdir} is defined as @code{$(libdir)/@@PACKAGE@@}.
391 @cvindex PACKAGE
393 @cindex EXTRA_, prepending
395 For each primary, there is one additional variable named by prepending
396 @samp{EXTRA_} to the primary name.  This variable is used to list
397 objects which may or may not be built, depending on what
398 @code{configure} decides.  This variable is required because Automake
399 must statically know the entire list of objects that may be built in
400 order to generate a @file{Makefile.in} that will work in all cases.
402 @cindex EXTRA_PROGRAMS, defined
403 @cindex Example, EXTRA_PROGRAMS
404 @cindex cpio example
406 For instance, @code{cpio} decides at configure time which programs are
407 built.  Some of the programs are installed in @code{bindir}, and some
408 are installed in @code{sbindir}:
410 @example
411 EXTRA_PROGRAMS = mt rmt
412 bin_PROGRAMS = cpio pax
413 sbin_PROGRAMS = @@MORE_PROGRAMS@@
414 @end example
416 Defining a primary without a prefix as a variable, e.g.,
417 @code{PROGRAMS}, is an error.
419 Note that the common @samp{dir} suffix is left off when constructing the
420 variable names; thus one writes @samp{bin_PROGRAMS} and not
421 @samp{bindir_PROGRAMS}.
423 Not every sort of object can be installed in every directory.  Automake
424 will flag those attempts it finds in error.  Automake will also diagnose
425 obvious misspellings in directory names.
427 @cindex Extending list of installation directories
428 @cindex Installation directories, extending list
430 Sometimes the standard directories---even as augmented by Automake---
431 are not enough.  In particular it is sometimes useful, for clarity, to
432 install objects in a subdirectory of some predefined directory.  To this
433 end, Automake allows you to extend the list of possible installation
434 directories.  A given prefix (e.g. @samp{zar}) is valid if a variable of
435 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
437 @cindex HTML support, example
439 For instance, until HTML support is part of Automake, you could use this
440 to install raw HTML documentation:
442 @example
443 htmldir = $(prefix)/html
444 html_DATA = automake.html
445 @end example
447 @cindex noinst primary prefix, definition
449 The special prefix @samp{noinst} indicates that the objects in question
450 should not be installed at all.
452 @cindex check primary prefix, definition
454 The special prefix @samp{check} indicates that the objects in question
455 should not be built until the @code{make check} command is run.
457 The current primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
458 @samp{LISP}, @samp{PYTHON}, @samp{JAVA}, @samp{SCRIPTS}, @samp{DATA},
459 @samp{HEADERS}, @samp{MANS}, and @samp{TEXINFOS}.
460 @vindex PROGRAMS
461 @vindex LIBRARIES
462 @vindex LISP
463 @vindex PYTHON
464 @vindex JAVA
465 @vindex SCRIPTS
466 @vindex DATA
467 @vindex HEADERS
468 @vindex MANS
469 @vindex TEXINFOS
471 Some primaries also allow additional prefixes which control other
472 aspects of @code{automake}'s behavior.  The currently defined prefixes
473 are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
474 are explained later.
477 @node Canonicalization, User Variables, Uniform, Generalities
478 @section How derived variables are named
480 @cindex canonicalizing Automake macros
482 Sometimes a Makefile variable name is derived from some text the
483 maintainer supplies.  For instance, a program name listed in
484 @samp{_PROGRAMS} is rewritten into the name of a @samp{_SOURCES}
485 variable.  In cases like this, Automake canonicalizes the text, so that
486 program names and the like do not have to follow Makefile macro naming
487 rules.  All characters in the name except for letters, numbers, the
488 strudel (@@), and the underscore are turned into underscores when making
489 macro references.
491 For example, if your program is named @code{sniff-glue}, the derived
492 variable name would be @code{sniff_glue_SOURCES}, not
493 @code{sniff-glue_SOURCES}.
495 The strudel is an addition, to make the use of Autoconf substitutions in
496 macro names less obfuscating.
499 @node User Variables, Auxiliary Programs, Canonicalization, Generalities
500 @section Variables reserved for the user
502 @cindex variables, reserved for the user
503 @cindex user variables
505 Some @code{Makefile} variables are reserved by the GNU Coding Standards
506 for the use of the ``user'' -- the person building the package.  For
507 instance, @code{CFLAGS} is one such variable.
509 Sometimes package developers are tempted to set user variables such as
510 @code{CFLAGS} because it appears to make their job easier -- they don't
511 have to introduce a second variable into every target.
513 However, the package itself should never set a user variable,
514 particularly not to include switches which are required for proper
515 compilation of the package.  Since these variables are documented as
516 being for the package builder, that person rightfully expects to be able
517 to override any of these variables at build time.
519 To get around this problem, automake introduces an automake-specific
520 shadow variable for each user flag variable.  (Shadow variables are not
521 introduced for variables like @code{CC}, where they would make no
522 sense.)  The shadow variable is named by prepending @samp{AM_} to the
523 user variable's name.  For instance, the shadow variable for
524 @code{YFLAGS} is @code{AM_YFLAGS}.
527 @node Auxiliary Programs, , User Variables, Generalities
528 @section Programs automake might require
530 @cindex Programs, auxiliary
531 @cindex Auxiliary programs
533 Automake sometimes requires helper programs so that the generated
534 @file{Makefile} can do its work properly.  There are a fairly large
535 number of them, and we list them here.
537 @table @code
538 @item ansi2knr.c
539 @itemx ansi2knr.1
540 These two files are used by the automatic de-ANSI-fication support
541 (@pxref{ANSI}).
543 @item compile
544 This is a wrapper for compilers which don't accept both @samp{-c} and
545 @samp{-o} at the same time.  It is only used when absolutely required.
546 Such compilers are rare.
548 @item config.guess
549 @itemx config.sub
550 These programs compute the canonical triplets for the given build, host,
551 or target architecture.
553 @item depcomp
554 This program understands how to run a compiler so that it will generate
555 not only the desired output but also dependency information which is
556 then used by the automatic dependency tracking feature.
558 @item elisp-comp
559 This program is used to byte-compile Emacs Lisp code.
561 @item install-sh
562 This is a replacement for the @code{install} program which works on
563 platforms where @code{install} is unavailable or unusable.
565 @item mdate-sh
566 This script is used to generate a @file{version.texi} file.  It examines
567 a file and prints some date information about it.
569 @item missing
570 This wraps a number of programs which are typically only required by
571 maintainers.  If the program in question doesn't exist, @code{missing}
572 prints an informative warning and attempts to fix things so that the
573 build can continue.
575 @item mkinstalldirs
576 This works around the fact that @code{mkdir -p} is not portable.
578 @item py-compile
579 This is used to byte-compile Python scripts.
581 @item texinfo.tex
582 Not a program, this file is required for @code{make dvi} to work when
583 Texinfo sources are in the package.
585 @item ylwrap
586 This program wraps @code{lex} and @code{yacc} and ensures that, for
587 instance, multiple @code{yacc} instances can be invoked in a single
588 directory in parallel.
590 @end table
593 @node Examples, Invoking Automake, Generalities, Top
594 @chapter Some example packages
596 @menu
597 * Complete::                    A simple example, start to finish
598 * Hello::                       A classic program
599 * etags::                       Building etags and ctags
600 @end menu
603 @node Complete, Hello, Examples, Examples
604 @section A simple example, start to finish
606 @cindex Complete example
608 Let's suppose you just finished writing @code{zardoz}, a program to make
609 your head float from vortex to vortex.  You've been using Autoconf to
610 provide a portability framework, but your @file{Makefile.in}s have been
611 ad-hoc.  You want to make them bulletproof, so you turn to Automake.
613 @cindex AM_INIT_AUTOMAKE, example use
615 The first step is to update your @file{configure.in} to include the
616 commands that @code{automake} needs.  The way to do this is to add an
617 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
619 @example
620 AC_INIT(zardoz, 1.0)
621 AM_INIT_AUTOMAKE
623 @end example
625 Since your program doesn't have any complicating factors (e.g., it
626 doesn't use @code{gettext}, it doesn't want to build a shared library),
627 you're done with this part.  That was easy!
629 @cindex aclocal program, introduction
630 @cindex aclocal.m4, preexisting
631 @cindex acinclude.m4, defined
633 Now you must regenerate @file{configure}.  But to do that, you'll need
634 to tell @code{autoconf} how to find the new macro you've used.  The
635 easiest way to do this is to use the @code{aclocal} program to generate
636 your @file{aclocal.m4} for you.  But wait... you already have an
637 @file{aclocal.m4}, because you had to write some hairy macros for your
638 program.  The @code{aclocal} program lets you put your own macros into
639 @file{acinclude.m4}, so simply rename and then run:
641 @example
642 mv aclocal.m4 acinclude.m4
643 aclocal
644 autoconf
645 @end example
647 @cindex zardoz example
649 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
650 Since @code{zardoz} is a user program, you want to install it where the
651 rest of the user programs go.  Additionally, @code{zardoz} has some
652 Texinfo documentation.  Your @file{configure.in} script uses
653 @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
654 So here's what you'd write:
656 @example
657 bin_PROGRAMS = zardoz
658 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
659 zardoz_LDADD = @@LIBOBJS@@
661 info_TEXINFOS = zardoz.texi
662 @end example
664 Now you can run @code{automake --add-missing} to generate your
665 @file{Makefile.in} and grab any auxiliary files you might need, and
666 you're done!
669 @node Hello, etags, Complete, Examples
670 @section A classic program
672 @cindex Example, GNU Hello
673 @cindex Hello example
674 @cindex GNU Hello, example
676 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
677 renowned for its classic simplicity and versatility.  This section shows
678 how Automake could be used with the GNU Hello package.  The examples
679 below are from the latest beta version of GNU Hello, but with all of the
680 maintainer-only code stripped out, as well as all copyright comments.
682 Of course, GNU Hello is somewhat more featureful than your traditional
683 two-liner.  GNU Hello is internationalized, does option processing, and
684 has a manual and a test suite.
686 @cindex configure.in, from GNU Hello
687 @cindex GNU Hello, configure.in
688 @cindex Hello, configure.in
690 Here is the @file{configure.in} from GNU Hello:
691 @c FIXME: This definitively requires an update.
693 @example
694 dnl Process this file with autoconf to produce a configure script.
695 AC_INIT(src/hello.c)
696 AM_INIT_AUTOMAKE(hello, 1.3.11)
697 AM_CONFIG_HEADER(config.h)
699 dnl Set of available languages.
700 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
702 dnl Checks for programs.
703 AC_PROG_CC
704 AC_ISC_POSIX
706 dnl Checks for libraries.
708 dnl Checks for header files.
709 AC_STDC_HEADERS
710 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
712 dnl Checks for library functions.
713 AC_FUNC_ALLOCA
715 dnl Check for st_blksize in struct stat
716 AC_ST_BLKSIZE
718 dnl internationalization macros
719 AM_GNU_GETTEXT
720 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
721            src/Makefile tests/Makefile tests/hello],
722    [chmod +x tests/hello])
723 @end example
725 The @samp{AM_} macros are provided by Automake (or the Gettext library);
726 the rest are standard Autoconf macros.
729 The top-level @file{Makefile.am}:
731 @example
732 EXTRA_DIST = BUGS ChangeLog.O
733 SUBDIRS = doc intl po src tests
734 @end example
736 As you can see, all the work here is really done in subdirectories.
738 The @file{po} and @file{intl} directories are automatically generated
739 using @code{gettextize}; they will not be discussed here.
741 @cindex Texinfo file handling example
742 @cindex Example, handling Texinfo files
744 In @file{doc/Makefile.am} we see:
746 @example
747 info_TEXINFOS = hello.texi
748 hello_TEXINFOS = gpl.texi
749 @end example
751 This is sufficient to build, install, and distribute the GNU Hello
752 manual.
754 @cindex Regression test example
755 @cindex Example, regression test
757 Here is @file{tests/Makefile.am}:
759 @example
760 TESTS = hello
761 EXTRA_DIST = hello.in testdata
762 @end example
764 The script @file{hello} is generated by @code{configure}, and is the
765 only test case.  @code{make check} will run this test.
767 @cindex INCLUDES, example usage
769 Last we have @file{src/Makefile.am}, where all the real work is done:
771 @example
772 bin_PROGRAMS = hello
773 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
774 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
775 localedir = $(datadir)/locale
776 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
777 @end example
780 @node etags,  , Hello, Examples
781 @section Building etags and ctags
783 @cindex Example, ctags and etags
784 @cindex ctags Example
785 @cindex etags Example
787 Here is another, trickier example.  It shows how to generate two
788 programs (@code{ctags} and @code{etags}) from the same source file
789 (@file{etags.c}).  The difficult part is that each compilation of
790 @file{etags.c} requires different @code{cpp} flags.
792 @example
793 bin_PROGRAMS = etags ctags
794 ctags_SOURCES =
795 ctags_LDADD = ctags.o
797 etags.o: etags.c
798         $(COMPILE) -DETAGS_REGEXPS -c etags.c
800 ctags.o: etags.c
801         $(COMPILE) -DCTAGS -o ctags.o -c etags.c
802 @end example
804 Note that @code{ctags_SOURCES} is defined to be empty---that way no
805 implicit value is substituted.  The implicit value, however, is used to
806 generate @code{etags} from @file{etags.o}.
808 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
809 @code{ctags_DEPENDENCIES} is generated by Automake.
811 The above rules won't work if your compiler doesn't accept both
812 @samp{-c} and @samp{-o}.  The simplest fix for this is to introduce a
813 bogus dependency (to avoid problems with a parallel @code{make}):
815 @example
816 etags.o: etags.c ctags.o
817         $(COMPILE) -DETAGS_REGEXPS -c etags.c
819 ctags.o: etags.c
820         $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
821 @end example
823 Also, these explicit rules do not work if the de-ANSI-fication feature
824 is used (@pxref{ANSI}).  Supporting de-ANSI-fication requires a little
825 more work:
827 @example
828 etags._o: etags._c ctags.o
829         $(COMPILE) -DETAGS_REGEXPS -c etags.c
831 ctags._o: etags._c
832         $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o
833 @end example
835 As it turns out, there is also a much easier way to do this same task.
836 Some of the above techniques are useful enough that we've kept the
837 example in the manual.  However if you were to build @code{etags} and
838 @code{ctags} in real life, you would probably use per-program
839 compilation flags, like so:
841 @example
842 bin_PROGRAMS = ctags etags
844 ctags_SOURCES = etags.c
845 ctags_CFLAGS = -DCTAGS
847 etags_SOURCES = etags.c
848 etags_CFLAGS = -DETAGS_REGEXPS
849 @end example
851 In this case Automake will cause @file{etags.c} to be compiled twice,
852 with different flags.  De-ANSI-fication will work automatically.  In
853 this instance, the names of the object files would be chosen by
854 automake; they would be @file{ctags-etags.o} and @file{etags-etags.o}.
855 (The name of the object files rarely matters.)
858 @node Invoking Automake, configure, Examples, Top
859 @chapter Creating a @file{Makefile.in}
861 @cindex Multiple configure.in files
862 @cindex Invoking Automake
863 @cindex Automake, invoking
865 To create all the @file{Makefile.in}s for a package, run the
866 @code{automake} program in the top level directory, with no arguments.
867 @code{automake} will automatically find each appropriate
868 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
869 and generate the corresponding @file{Makefile.in}.  Note that
870 @code{automake} has a rather simplistic view of what constitutes a
871 package; it assumes that a package has only one @file{configure.in}, at
872 the top.  If your package has multiple @file{configure.in}s, then you
873 must run @code{automake} in each directory holding a
874 @file{configure.in}.
876 You can optionally give @code{automake} an argument; @file{.am} is
877 appended to the argument and the result is used as the name of the input
878 file.  This feature is generally only used to automatically rebuild an
879 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
880 be run from the topmost directory of a project, even if being used to
881 regenerate the @file{Makefile.in} in some subdirectory.  This is
882 necessary because @code{automake} must scan @file{configure.in}, and
883 because @code{automake} uses the knowledge that a @file{Makefile.in} is
884 in a subdirectory to change its behavior in some cases.
886 @cindex Automake options
887 @cindex Options, Automake
889 @code{automake} accepts the following options:
891 @cindex Extra files distributed with Automake
892 @cindex Files distributed with Automake
893 @cindex config.guess
895 @table @samp
896 @item -a
897 @itemx --add-missing
898 @opindex -a
899 @opindex --add-missing
900 Automake requires certain common files to exist in certain situations;
901 for instance @file{config.guess} is required if @file{configure.in} runs
902 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
903 files; this option will cause the missing ones to be automatically added
904 to the package, whenever possible.  In general if Automake tells you a
905 file is missing, try using this option.  By default Automake tries to
906 make a symbolic link pointing to its own copy of the missing file; this
907 can be changed with @code{--copy}.
909 @item --libdir=@var{dir}
910 @opindex --libdir
911 Look for Automake data files in directory @var{dir} instead of in the
912 installation directory.  This is typically used for debugging.
914 @item -c
915 @opindex -c
916 @itemx --copy
917 @opindex --copy
918 When used with @code{--add-missing}, causes installed files to be
919 copied.  The default is to make a symbolic link.
921 @item --cygnus
922 @opindex --cygnus
923 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
924 of GNU or Gnits rules.  For more information, see @ref{Cygnus}.
926 @item -f
927 @opindex -f
928 @itemx --force-missing
929 @opindex --force-missing
930 When used with @code{--add-missing}, causes standard files to be rebuilt
931 even if they already exist in the source tree.  This involves removing
932 the file from the source tree before creating the new symlink (or, with
933 @code{--copy}, copying the new file).
935 @item --foreign
936 @opindex --foreign
937 Set the global strictness to @samp{foreign}.  For more information, see
938 @ref{Strictness}.
940 @item --gnits
941 @opindex --gnits
942 Set the global strictness to @samp{gnits}.  For more information, see
943 @ref{Gnits}.
945 @item --gnu
946 @opindex --gnu
947 Set the global strictness to @samp{gnu}.  For more information, see
948 @ref{Gnits}.  This is the default strictness.
950 @item --help
951 @opindex --help
952 Print a summary of the command line options and exit.
954 @item -i
955 @itemx --ignore-deps
956 @opindex -i
957 This disables the dependency tracking feature; see @ref{Dependencies}.
959 @item --include-deps
960 @opindex --include-deps
961 This enables the dependency tracking feature.  This feature is enabled
962 by default.  This option is provided for historical reasons only and
963 probably should not be used.
965 @item --no-force
966 @opindex --no-force
967 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
968 @file{configure.in}.  This option causes it to only update those
969 @file{Makefile.in}s which are out of date with respect to one of their
970 dependents.
972 @item -o @var{dir}
973 @itemx --output-dir=@var{dir}
974 @opindex -o
975 @opindex --output-dir
976 Put the generated @file{Makefile.in} in the directory @var{dir}.
977 Ordinarily each @file{Makefile.in} is created in the directory of the
978 corresponding @file{Makefile.am}.  This option is used when making
979 distributions.
981 @item -v
982 @itemx --verbose
983 @opindex -v
984 @opindex --verbose
985 Cause Automake to print information about which files are being read or
986 created.
988 @item --version
989 @opindex --version
990 Print the version number of Automake and exit.
992 @item --Werror
993 @itemx --Wno-error
994 @opindex --Werror
995 @opindex --Wno-error
996 @samp{--Werror} will cause all warnings issued by @code{automake} to
997 become errors.  Errors affect the exit status of @code{automake}, while
998 warnings do not.  @samp{--Wno-error}, the default, causes warnings to be
999 treated as warnings only.
1000 @end table
1003 @node configure, Top level, Invoking Automake, Top
1004 @chapter Scanning @file{configure.in}
1006 @cindex configure.in, scanning
1007 @cindex Scanning configure.in
1009 Automake scans the package's @file{configure.in} to determine certain
1010 information about the package.  Some @code{autoconf} macros are required
1011 and some variables must be defined in @file{configure.in}.  Automake
1012 will also use information from @file{configure.in} to further tailor its
1013 output.
1015 Automake also supplies some Autoconf macros to make the maintenance
1016 easier.  These macros can automatically be put into your
1017 @file{aclocal.m4} using the @code{aclocal} program.
1019 @menu
1020 * Requirements::                Configuration requirements
1021 * Optional::                    Other things Automake recognizes
1022 * Invoking aclocal::            Auto-generating aclocal.m4
1023 * Macros::                      Autoconf macros supplied with Automake
1024 * Extending aclocal::           Writing your own aclocal macros
1025 @end menu
1028 @node Requirements, Optional, configure, configure
1029 @section Configuration requirements
1031 @cindex Automake requirements
1032 @cindex Requirements of Automake
1034 The one real requirement of Automake is that your @file{configure.in}
1035 call @code{AM_INIT_AUTOMAKE}.  This macro does several things which are
1036 required for proper Automake operation.
1037 @cvindex AM_INIT_AUTOMAKE
1039 Here are the other macros which Automake requires but which are not run
1040 by @code{AM_INIT_AUTOMAKE}:
1042 @cindex AC_OUTPUT, scanning
1044 @table @code
1045 @item AC_OUTPUT
1046 Automake uses this to determine which files to create (@pxref{Output, ,
1047 Creating Output Files, autoconf, The Autoconf Manual}).  Listed files
1048 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
1049 files are treated differently.  Currently the only difference is that a
1050 @file{Makefile} is removed by @code{make distclean}, while other files
1051 are removed by @code{make clean}.
1052 @c FIXME: this is in violation of standards!
1053 @cvindex AC_OUTPUT
1054 @end table
1057 @node Optional, Invoking aclocal, Requirements, configure
1058 @section Other things Automake recognizes
1060 @cindex Macros Automake recognizes
1061 @cindex Recognized macros by Automake
1063 Automake will also recognize the use of certain macros and tailor the
1064 generated @file{Makefile.in} appropriately.  Currently recognized macros
1065 and their effects are:
1067 @table @code
1068 @item AC_CONFIG_HEADER
1069 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
1070 to @code{AC_CONFIG_HEADER} (@pxref{Configuration Headers, ,
1071 Configuration Header Files, autoconf, The Autoconf Manual}), but does
1072 some useful Automake-specific work.
1073 @cvindex AC_CONFIG_HEADER
1075 @item AC_CONFIG_AUX_DIR
1076 Automake will look for various helper scripts, such as
1077 @file{mkinstalldirs}, in the directory named in this macro invocation.
1078 If not seen, the scripts are looked for in their @samp{standard}
1079 locations (either the top source directory, or in the source directory
1080 corresponding to the current @file{Makefile.am}, whichever is
1081 appropriate).  @xref{Input, , Finding `configure' Input, autoconf, The
1082 Autoconf Manual}.
1083 @cvindex AC_CONFIG_AUX_DIR
1084 FIXME: give complete list of things looked for in this directory
1086 @item AC_PATH_XTRA
1087 Automake will insert definitions for the variables defined by
1088 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
1089 or library.  @xref{System Services, , System Services, autoconf, The
1090 Autoconf Manual}.
1091 @cvindex AC_PATH_XTRA
1093 @item AC_CANONICAL_HOST
1094 @itemx AC_CHECK_TOOL
1095 Automake will ensure that @file{config.guess} and @file{config.sub}
1096 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
1097 @samp{host_triplet} are introduced.  See both @ref{Canonicalizing, ,
1098 Getting the Canonical System Type, autoconf, The Autoconf Manual}, and
1099 @ref{Generic Programs, , Generic Program Checks, autoconf, The Autoconf
1100 Manual}.
1101 @c fixme xref autoconf docs.
1102 @cvindex AC_CANONICAL_HOST
1103 @cvindex AC_CHECK_TOOL
1104 @vindex host_alias
1105 @vindex host_triplet
1107 @item AC_CANONICAL_SYSTEM
1108 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
1109 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
1110 @xref{Canonicalizing, , Getting the Canonical System Type, autoconf, The
1111 Autoconf Manual}.
1112 @cvindex AC_CANONICAL_SYSTEM
1113 @vindex build_alias
1114 @vindex target_alias
1116 @item  AC_FUNC_ALLOCA
1117 @itemx AC_FUNC_ERROR_AT_LINE
1118 @itemx AC_FUNC_FNMATCH
1119 @itemx AC_FUNC_GETLOADAVG
1120 @itemx AC_FUNC_MEMCMP
1121 @itemx AC_FUNC_MKTIME
1122 @itemx AC_FUNC_OBSTACK
1123 @itemx AC_FUNC_STRTOD
1124 @itemx AC_REPLACE_FUNCS
1125 @itemx AC_REPLACE_GNU_GETOPT
1126 @itemx AC_STRUCT_ST_BLOCKS
1127 @itemx AM_WITH_REGEX
1128 Automake will ensure that the appropriate dependencies are generated for
1129 the objects corresponding to these macros.  Also, Automake will verify
1130 that the appropriate source files are part of the distribution.  Note
1131 that Automake does not come with any of the C sources required to use
1132 these macros, so @code{automake -a} will not install the sources.
1133 @xref{A Library}, for more information.  Also, see @ref{Particular
1134 Functions, , Particular Function Checks, autoconf, The Autoconf Manual}.
1135 @cvindex AC_FUNC_ALLOCA
1136 @cvindex AC_FUNC_ERROR_AT_LINE
1137 @cvindex AC_FUNC_FNMATCH
1138 @cvindex AC_FUNC_GETLOADAVG
1139 @cvindex AC_FUNC_MEMCMP
1140 @cvindex AC_FUNC_MKTIME
1141 @cvindex AC_FUNC_OBSTACK
1142 @cvindex AC_FUNC_STRTOD
1143 @cvindex AC_REPLACE_FUNCS
1144 @cvindex AC_REPLACE_GNU_GETOPT
1145 @cvindex AC_STRUCT_ST_BLOCKS
1146 @cvindex AM_WITH_REGEX
1148 @item LIBOBJS
1149 Automake will detect statements which put @file{.o} files into
1150 @code{LIBOBJS}, and will treat these additional files as if they were
1151 discovered via @code{AC_REPLACE_FUNCS}.  @xref{Generic Functions, ,
1152 Generic Function Checks, autoconf, The Autoconf Manual}.
1153 @cvindex LIBOBJS
1155 @item AC_PROG_RANLIB
1156 This is required if any libraries are built in the package.
1157 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1158 Autoconf Manual}.
1159 @cvindex AC_PROG_RANLIB
1161 @item AC_PROG_CXX
1162 This is required if any C++ source is included.  @xref{Particular
1163 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1164 @cvindex AC_PROG_CXX
1166 @item AC_PROG_F77
1167 This is required if any Fortran 77 source is included.  This macro is
1168 distributed with Autoconf version 2.13 and later.  @xref{Particular
1169 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1170 @cvindex AC_PROG_F77
1172 @item AC_F77_LIBRARY_LDFLAGS
1173 This is required for programs and shared libraries that are a mixture of
1174 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1175 C++}).  @xref{Macros, , Autoconf macros supplied with Automake}.
1176 @cvindex AC_F77_LIBRARY_LDFLAGS
1178 @item AC_PROG_LIBTOOL
1179 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1180 Introduction, libtool, The Libtool Manual}).
1181 @cvindex AC_PROG_LIBTOOL
1183 @item AC_PROG_YACC
1184 If a Yacc source file is seen, then you must either use this macro or
1185 define the variable @samp{YACC} in @file{configure.in}.  The former is
1186 preferred (@pxref{Particular Programs, , Particular Program Checks,
1187 autoconf, The Autoconf Manual}).
1188 @cvindex AC_PROG_YACC
1189 @cvindex YACC
1191 @item AC_PROG_LEX
1192 If a Lex source file is seen, then this macro must be used.
1193 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1194 Autoconf Manual}.
1195 @cvindex AC_PROG_LEX
1197 @item AM_C_PROTOTYPES
1198 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1199 @cvindex AM_C_PROTOTYPES
1201 @item AM_GNU_GETTEXT
1202 This macro is required for packages which use GNU gettext
1203 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
1204 this macro it ensures that the package meets some of gettext's
1205 requirements.
1206 @cvindex AM_GNU_GETTEXT
1208 @item AM_MAINTAINER_MODE
1209 @opindex --enable-maintainer-mode
1210 This macro adds a @samp{--enable-maintainer-mode} option to
1211 @code{configure}.  If this is used, @code{automake} will cause
1212 @samp{maintainer-only} rules to be turned off by default in the
1213 generated @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits}
1214 mode (@pxref{Gnits}).  This macro defines the @samp{MAINTAINER_MODE}
1215 conditional, which you can use in your own @file{Makefile.am}.
1216 @cvindex AM_MAINTAINER_MODE
1218 @item AC_SUBST
1219 @itemx AC_CHECK_TOOL
1220 @itemx AC_CHECK_PROG
1221 @itemx AC_CHECK_PROGS
1222 @itemx AC_PATH_PROG
1223 @itemx AC_PATH_PROGS
1224 For each of these macros, the first argument is automatically defined as
1225 a variable in each generated @file{Makefile.in}.  @xref{Setting Output
1226 Variables, , Setting Output Variables, autoconf, The Autoconf Manual},
1227 and @ref{Generic Programs, , Generic Program Checks, autoconf, The
1228 Autoconf Manual}.
1229 @cvindex AC_SUBST
1230 @cvindex AC_CHECK_TOOL
1231 @cvindex AC_CHECK_PROG
1232 @cvindex AC_CHECK_PROGS
1233 @cvindex AC_PATH_PROG
1234 @cvindex AC_PATH_PROGS
1236 @end table
1239 @node Invoking aclocal, Macros, Optional, configure
1240 @section Auto-generating aclocal.m4
1242 @cindex Invoking aclocal
1243 @cindex aclocal, Invoking
1245 Automake includes a number of Autoconf macros which can be used in your
1246 package; some of them are actually required by Automake in certain
1247 situations.  These macros must be defined in your @file{aclocal.m4};
1248 otherwise they will not be seen by @code{autoconf}.
1250 The @code{aclocal} program will automatically generate @file{aclocal.m4}
1251 files based on the contents of @file{configure.in}.  This provides a
1252 convenient way to get Automake-provided macros, without having to
1253 search around.  Also, the @code{aclocal} mechanism is extensible for use
1254 by other packages.
1256 At startup, @code{aclocal} scans all the @file{.m4} files it can find,
1257 looking for macro definitions.  Then it scans @file{configure.in}.  Any
1258 mention of one of the macros found in the first step causes that macro,
1259 and any macros it in turn requires, to be put into @file{aclocal.m4}.
1261 The contents of @file{acinclude.m4}, if it exists, are also
1262 automatically included in @file{aclocal.m4}.  This is useful for
1263 incorporating local macros into @file{configure}.
1265 @code{aclocal} tries to be smart about looking for new @code{AC_DEFUN}s
1266 in the files it scans.  It will warn if it finds duplicates.  It also
1267 tries to copy the full text of the scanned file into @file{aclocal.m4},
1268 including both @samp{#} and @samp{dnl} comments.  If you want to make a
1269 comment which will be completely ignored by @code{aclocal}, use
1270 @samp{##} as the comment leader.
1272 @code{aclocal} accepts the following options:
1274 @table @code
1275 @item --acdir=@var{dir}
1276 @opindex --acdir
1277 Look for the macro files in @var{dir} instead of the installation
1278 directory.  This is typically used for debugging.
1280 @item --help
1281 @opindex --help
1282 Print a summary of the command line options and exit.
1284 @item -I @var{dir}
1285 @opindex -I
1286 Add the directory @var{dir} to the list of directories searched for
1287 @file{.m4} files.
1289 @item --output=@var{file}
1290 @opindex --output
1291 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1293 @item --print-ac-dir
1294 @opindex --print-ac-dir
1295 Prints the name of the directory which @code{aclocal} will search to
1296 find the @file{.m4} files.  When this option is given, normal processing
1297 is suppressed.  This option can be used by a package to determine where
1298 to install a macro file.
1300 @item --verbose
1301 @opindex --verbose
1302 Print the names of the files it examines.
1304 @item --version
1305 @opindex --version
1306 Print the version number of Automake and exit.
1307 @end table
1310 @node Macros, Extending aclocal, Invoking aclocal, configure
1311 @section Autoconf macros supplied with Automake
1313 @c consider generating this node automatically from m4 files.
1315 @table @code
1316 @item AM_CONFIG_HEADER
1317 Automake will generate rules to automatically regenerate the config
1318 header.
1319 @cvindex AM_CONFIG_HEADER
1321 @item AM_ENABLE_MULTILIB
1322 This is used when a ``multilib'' library is being built.  The first
1323 optional argument is the name of the @file{Makefile} being generated; it
1324 defaults to @samp{Makefile}.  The second option argument is used to find
1325 the top source directory; it defaults to the empty string (generally
1326 this should not be used unless you are familiar with the internals).
1327 @xref{Multilibs}.
1329 @item _AM_DEPENDENCIES
1330 @itemx AM_SET_DEPDIR
1331 @itemx AM_DEP_TRACK
1332 @itemx AM_OUTPUT_DEPENDENCY_COMMANDS
1333 These macros are used to implement automake's automatic dependency
1334 tracking scheme.  They are called automatically by automake when
1335 required, and there should be no need to invoke them manually.
1337 @item AM_C_PROTOTYPES
1338 Check to see if function prototypes are understood by the compiler.  If
1339 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1340 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
1341 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
1342 values to implement automatic de-ANSI-fication.
1343 @cvindex AM_C_PROTOTYPES
1345 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1346 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1347 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
1348 found in @file{<termios.h>}.
1349 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1351 @item AM_INIT_AUTOMAKE([OPTIONS])
1352 @itemx AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
1353 Runs many macros that most @file{configure.in}'s need.  This macro has
1354 two forms, the second of which has two required arguments: the package
1355 and the version number.  This latter form is obsolete because the
1356 @var{package} and @var{version} are now arguments of the @samp{AC_INIT}
1357 Autoconf macro, and Automake can get this information from there.
1359 If your @file{configure.in} has:
1360 @example
1361 AC_INIT(src/foo.c)
1362 AM_INIT_AUTOMAKE(mumble, 1.5)
1363 @end example
1364 you can modernize it as follow:
1365 @example
1366 AC_INIT(mumble, 1.5)
1367 AC_CONFIG_SRCDIR(src/foo.c)
1368 AM_INIT_AUTOMAKE
1369 @end example
1371 If this macro is called with a single argument, it is interpreted as a
1372 space-separated list of Automake options which should be applied to
1373 every @file{Makefile.am} in the tree.  The effect is as if each option
1374 were listed in @code{AUTOMAKE_OPTIONS}.
1376 By default this macro @code{AC_DEFINE}'s @samp{PACKAGE} and
1377 @samp{VERSION}.  This can be avoided by passing the @samp{no-define}
1378 option, as in:
1379 @example
1380 AM_INIT_AUTOMAKE([gnits 1.5 no-define dist-bzip2])
1381 @end example
1382 or by passing a third non-empty argument to the obsolete form.
1384 @cvindex PACKAGE, prevent definition
1385 @cvindex VERSION, prevent definition
1387 @item AM_MAKE_INCLUDE
1388 This macro is used to discover how the user's @code{make} handles
1389 @code{include} statements.  This macro is automatically invoked when
1390 needed; there should be no need to invoke it manually.
1392 @item AM_PATH_LISPDIR
1393 Searches for the program @code{emacs}, and, if found, sets the output
1394 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1395 @cvindex AM_PATH_LISPDIR
1397 @item AM_PROG_AS
1398 Use this macro when you have assembly code in your project.  This will
1399 choose the assembler for you (by default the C compiler) and set
1400 @code{CCAS}, and will also set @code{CCASFLAGS} if required.
1402 @item AM_PROG_CC_C_O
1403 This is like @code{AC_PROG_CC_C_O}, but it generates its results in the
1404 manner required by automake.  You must use this instead of
1405 @code{AC_PROG_CC_C_O} when you need this functionality.
1407 @item AM_PROG_CC_STDC
1408 If the C compiler is not in ANSI C mode by default, try to add an option
1409 to output variable @code{CC} to make it so.  This macro tries various
1410 options that select ANSI C on some system or another.  It considers the
1411 compiler to be in ANSI C mode if it handles function prototypes correctly.
1413 If you use this macro, you should check after calling it whether the C
1414 compiler has been set to accept ANSI C; if not, the shell variable
1415 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
1416 code in ANSI C, you can make an un-ANSIfied copy of it by using the
1417 @code{ansi2knr} option (@pxref{ANSI}).
1419 @item AM_PROG_LEX
1420 @cindex HP-UX 10, lex problems
1421 @cindex lex problems with HP-UX 10
1422 Like @code{AC_PROG_LEX} (@pxref{Particular Programs, , Particular
1423 Program Checks, autoconf, The Autoconf Manual}), but uses the
1424 @code{missing} script on systems that do not have @code{lex}.
1425 @samp{HP-UX 10} is one such system.
1427 @item AM_PROG_GCJ
1428 This macro finds the @code{gcj} program or causes an error.  It sets
1429 @samp{GCJ} and @samp{GCJFLAGS}.  @code{gcj} is the Java front-end to the
1430 GNU Compiler Collection.
1431 @cvindex AM_PROG_GCJ
1433 @item AM_PROG_INSTALL_STRIP
1434 This is used to find a version of @code{install} which can be used to
1435 @code{strip} a program at installation time.  This macro is
1436 automatically included when required.
1438 @item AM_SANITY_CHECK
1439 This checks to make sure that a file created in the build directory is
1440 newer than a file in the source directory.  This can fail on systems
1441 where the clock is set incorrectly.  This macro is automatically run
1442 from @code{AM_INIT_AUTOMAKE}.
1444 @item AM_SYS_POSIX_TERMIOS
1445 @cvindex am_cv_sys_posix_termios
1446 @cindex POSIX termios headers
1447 @cindex termios POSIX headers
1448 Check to see if POSIX termios headers and functions are available on the
1449 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1450 @samp{yes}.  If not, set the variable to @samp{no}.
1452 @item AM_WITH_DMALLOC
1453 @cvindex WITH_DMALLOC
1454 @cindex dmalloc, support for
1455 @opindex --with-dmalloc
1456 Add support for the
1457 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1458 package.  If the user configures with @samp{--with-dmalloc}, then define
1459 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1461 @item AM_WITH_REGEX
1462 @cvindex WITH_REGEX
1463 @opindex --with-regex
1464 @cindex regex package
1465 @cindex rx package
1466 Adds @samp{--with-regex} to the @code{configure} command line.  If
1467 specified (the default), then the @samp{regex} regular expression
1468 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1469 @samp{WITH_REGEX} is defined.  If @samp{--without-regex} is given, then
1470 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1471 into @samp{LIBOBJS}.
1473 @end table
1476 @node Extending aclocal,  , Macros, configure
1477 @section Writing your own aclocal macros
1479 @cindex aclocal, extending
1480 @cindex Extending aclocal
1482 The @code{aclocal} program doesn't have any built-in knowledge of any
1483 macros, so it is easy to extend it with your own macros.
1485 This is mostly used for libraries which want to supply their own
1486 Autoconf macros for use by other programs.  For instance the
1487 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1488 should be used by any package using @code{gettext}.  When the library is
1489 installed, it installs this macro so that @code{aclocal} will find it.
1491 A file of macros should be a series of @code{AC_DEFUN}'s.  The
1492 @code{aclocal} programs also understands @code{AC_REQUIRE}, so it is
1493 safe to put each macro in a separate file.  @xref{Prerequisite Macros, ,
1494 , autoconf, The Autoconf Manual}, and @ref{Macro Definitions, , ,
1495 autoconf, The Autoconf Manual}.
1497 A macro file's name should end in @file{.m4}.  Such files should be
1498 installed in @file{$(datadir)/aclocal}.
1501 @node Top level, Alternative, configure, Top
1502 @chapter The top-level @file{Makefile.am}
1504 @cindex SUBDIRS, explained
1506 In packages with subdirectories, the top level @file{Makefile.am} must
1507 tell Automake which subdirectories are to be built.  This is done via
1508 the @code{SUBDIRS} variable.
1509 @vindex SUBDIRS
1511 The @code{SUBDIRS} macro holds a list of subdirectories in which
1512 building of various sorts can occur.  Many targets (e.g. @code{all}) in
1513 the generated @file{Makefile} will run both locally and in all specified
1514 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1515 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1516 (after configuration).  This allows inclusion of libraries from packages
1517 which do not use Automake (such as @code{gettext}).  The directories
1518 mentioned in @code{SUBDIRS} must be direct children of the current
1519 directory.  For instance, you cannot put @samp{src/subdir} into
1520 @code{SUBDIRS}.
1522 In packages that use subdirectories, the top-level @file{Makefile.am} is
1523 often very short.  For instance, here is the @file{Makefile.am} from the
1524 GNU Hello distribution:
1526 @example
1527 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1528 SUBDIRS = doc intl po src tests
1529 @end example
1531 @cindex SUBDIRS, overriding
1532 @cindex Overriding SUBDIRS
1534 It is possible to override the @code{SUBDIRS} variable if, like in the
1535 case of GNU @code{Inetutils}, you want to only build a subset of the
1536 entire package.  In your @file{Makefile.am} include:
1538 @example
1539 SUBDIRS = @@MY_SUBDIRS@@
1540 @end example
1542 Then in your @file{configure.in} you can specify:
1544 @example
1545 MY_SUBDIRS="src doc lib po"
1546 AC_SUBST(MY_SUBDIRS)
1547 @end example
1549 (Note that we don't use the variable name @code{SUBDIRS} in our
1550 @file{configure.in}; that would cause Automake to believe that every
1551 @file{Makefile.in} should recurse into the listed subdirectories.)
1553 The upshot of this is that Automake is tricked into building the package
1554 to take the subdirs, but doesn't actually bind that list until
1555 @code{configure} is run.
1557 Although the @code{SUBDIRS} macro can contain configure substitutions
1558 (e.g. @samp{@@DIRS@@}); Automake itself does not actually examine the
1559 contents of this variable.
1561 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1562 @code{AC_PROG_MAKE_SET}.  When Automake invokes @code{make} in a
1563 subdirectory, it uses the value of the @code{MAKE} variable.  It passes
1564 the value of the variable @code{AM_MAKEFLAGS} to the @code{make}
1565 invocation; this can be set in @file{Makefile.am} if there are flags you
1566 must always pass to @code{make}.
1567 @vindex MAKE
1568 @vindex MAKEFLAGS
1570 The use of @code{SUBDIRS} is not restricted to just the top-level
1571 @file{Makefile.am}.  Automake can be used to construct packages of
1572 arbitrary depth.
1574 By default, Automake generates @file{Makefiles} which work depth-first
1575 (@samp{postfix}).  However, it is possible to change this ordering.  You
1576 can do this by putting @samp{.} into @code{SUBDIRS}.  For instance,
1577 putting @samp{.}  first will cause a @samp{prefix} ordering of
1578 directories.  All @samp{clean} targets are run in reverse order of build
1579 targets.
1581 Sometimes, such as when running @code{make dist}, you want all possible
1582 subdirectories to be examined.  In this case Automake will use
1583 @code{DIST_SUBDIRS}, instead of @code{SUBDIRS}, to determine where to
1584 recurse.  This variable will also be used when the user runs
1585 @code{distclean} or @code{maintainer-clean}.  It should be set to the
1586 full list of subdirectories in the project.  If this macro is not set,
1587 Automake will attempt to set it for you.
1590 @node Alternative, Rebuilding, Top level, Top
1591 @chapter An Alternative Approach to Subdirectories
1593 If you've ever read Peter Miller's excellent paper,
1594 @uref{http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html,
1595 Recursive Make Considered Harmful}, the preceding section on the use of
1596 subdirectories will probably come as unwelcome advice.  For those who
1597 haven't read the paper, Miller's main thesis is that recursive
1598 @code{make} invocations are both slow and error-prone.
1600 Automake provides sufficient cross-directory support @footnote{We
1601 believe.  This work is new and there are probably warts.
1602 @xref{Introduction}, for information on reporting bugs.} to enable you
1603 to write a single @file{Makefile.am} for a complex multi-directory
1604 package.
1607 By default an installable file specified in a subdirectory will have its
1608 directory name stripped before installation.  For instance, in this
1609 example, the header file will be installed as
1610 @file{$(includedir)/stdio.h}:
1612 @example
1613 include_HEADERS = inc/stdio.h
1614 @end example
1616 @cindex nobase_
1617 @cindex Path stripping, avoiding
1618 @cindex Avoiding path stripping
1620 However, the @samp{nobase_} prefix can be used to circumvent this path
1621 stripping.  In this example, the header file will be installed as
1622 @file{$(includedir)/sys/types.h}:
1624 @example
1625 nobase_include_HEADERS = sys/types.h
1626 @end example
1629 @node Rebuilding, Programs, Alternative, Top
1630 @chapter Rebuilding Makefiles
1632 Automake generates rules to automatically rebuild @file{Makefile}s,
1633 @file{configure}, and other derived files like @file{Makefile.in}.
1635 If you are using @code{AM_MAINTAINER_MODE} in @file{configure.in}, then
1636 these automatic rebuilding rules are only enabled in maintainer mode.
1638 Sometimes you need to run @code{aclocal} with an argument like @code{-I}
1639 to tell it where to find @file{.m4} files.  Since sometimes @code{make}
1640 will automatically run @code{aclocal}, you need a way to specify these
1641 arguments.  You can do this by defining @code{ACLOCAL_AMFLAGS}; this
1642 holds arguments which are passed verbatim to @code{aclocal}.  This macro
1643 is only useful in the top-level @file{Makefile.am}.
1644 @vindex ACLOCAL_AMFLAGS
1647 @node Programs, Other objects, Rebuilding, Top
1648 @chapter Building Programs and Libraries
1650 A large part of Automake's functionality is dedicated to making it easy
1651 to build programs and libraries.
1653 @menu
1654 * A Program::                   Building a program
1655 * A Library::                   Building a library
1656 * A Shared Library::            Building a Libtool library
1657 * Program and Library Variables::
1658                                 Variables controlling program and
1659                                 library builds
1660 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1661 * Program variables::           Variables used when building a program
1662 * Yacc and Lex::                Yacc and Lex support
1663 * C++ Support::
1664 * Assembly Support::
1665 * Fortran 77 Support::
1666 * Java Support::
1667 * Support for Other Languages::
1668 * ANSI::                        Automatic de-ANSI-fication
1669 * Dependencies::                Automatic dependency tracking
1670 * EXEEXT::                      Support for executable extensions
1671 @end menu
1674 @node A Program, A Library, Programs, Programs
1675 @section Building a program
1677 @subsection Introductory blathering
1679 @cindex PROGRAMS, bindir
1680 @vindex bin_PROGRAMS
1681 @vindex sbin_PROGRAMS
1682 @vindex libexec_PROGRAMS
1683 @vindex pkglib_PROGRAMS
1684 @vindex noinst_PROGRAMS
1686 In a directory containing source that gets built into a program (as
1687 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1688 can be installed in @code{bindir}, @code{sbindir}, @code{libexecdir},
1689 @code{pkglibdir}, or not at all (@samp{noinst}).  They can also be built
1690 only for @code{make check}, in which case the prefix is @samp{check}.
1692 For instance:
1694 @example
1695 bin_PROGRAMS = hello
1696 @end example
1698 In this simple case, the resulting @file{Makefile.in} will contain code
1699 to generate a program named @code{hello}.
1701 Associated with each program are several assisting variables which are
1702 named after the program.  These variables are all optional, and have
1703 reasonable defaults.  Each variable, its use, and default is spelled out
1704 below; we use the ``hello'' example throughout.
1706 The variable @code{hello_SOURCES} is used to specify which source files
1707 get built into an executable:
1709 @example
1710 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
1711 @end example
1713 This causes each mentioned @samp{.c} file to be compiled into the
1714 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1716 @cindex _SOURCES primary, defined
1717 @cindex SOURCES primary, defined
1718 @cindex Primary variable, SOURCES
1720 If @samp{hello_SOURCES} is not specified, then it defaults to the single
1721 file @file{hello.c}; that is, the default is to compile a single C file
1722 whose base name is the name of the program itself.  (This is a terrible
1723 default but we are stuck with it for historical reasons.)
1724 @vindex _SOURCES
1725 @vindex SOURCES
1727 Multiple programs can be built in a single directory.  Multiple programs
1728 can share a single source file, which must be listed in each
1729 @samp{_SOURCES} definition.
1731 @cindex Header files in _SOURCES
1732 @cindex _SOURCES and header files
1734 Header files listed in a @samp{_SOURCES} definition will be included in
1735 the distribution but otherwise ignored.  In case it isn't obvious, you
1736 should not include the header file generated by @file{configure} in a
1737 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1738 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1739 and Lex}.
1741 @subsection Conditional compilations
1743 You can't put a configure substitution (e.g., @samp{@@FOO@@}) into a
1744 @samp{_SOURCES} variable.  The reason for this is a bit hard to explain,
1745 but suffice to say that it simply won't work.  Automake will give an
1746 error if you try to do this.
1748 @cindex EXTRA_prog_SOURCES, defined
1750 Automake must know all the source files that could possibly go into a
1751 program, even if not all the files are built in every circumstance.
1752 Any files which are only conditionally built should be listed in the
1753 appropriate @samp{EXTRA_} variable.  For instance, if
1754 @file{hello-linux.c} were conditionally included in @code{hello}, the
1755 @file{Makefile.am} would contain:
1757 @example
1758 EXTRA_hello_SOURCES = hello-linux.c
1759 @end example
1761 In this case, @file{hello-linux.o} would be added, via a
1762 @file{configure} substitution, to @code{hello_LDADD} in order to cause
1763 it to be built and linked in.
1765 An often simpler way to compile source files conditionally is to use
1766 Automake conditionals.  For instance, you could use this construct to
1767 conditionally use @file{hello-linux.c} or @file{hello-generic.c} as the
1768 basis for your program @file{hello}:
1770 @example
1771 if LINUX
1772 hello_SOURCES = hello-linux.c
1773 else
1774 hello_SOURCES = hello-generic.c
1775 endif
1776 @end example
1778 When using conditionals like this you don't need to use the
1779 @samp{EXTRA_} variable, because Automake will examine the contents of
1780 each variable to construct the complete list of source files.
1782 Sometimes it is useful to determine the programs that are to be built at
1783 configure time.  For instance, GNU @code{cpio} only builds @code{mt} and
1784 @code{rmt} under special circumstances.
1786 @cindex EXTRA_PROGRAMS, defined
1788 In this case, you must notify Automake of all the programs that can
1789 possibly be built, but at the same time cause the generated
1790 @file{Makefile.in} to use the programs specified by @code{configure}.
1791 This is done by having @code{configure} substitute values into each
1792 @samp{_PROGRAMS} definition, while listing all optionally built programs
1793 in @code{EXTRA_PROGRAMS}.
1794 @vindex EXTRA_PROGRAMS
1796 Of course you can use Automake conditionals to determine the programs to
1797 be built.
1799 @subsection Linking the program
1801 If you need to link against libraries that are not found by
1802 @code{configure}, you can use @code{LDADD} to do so.  This variable
1803 actually can be used to add any options to the linker command line.
1804 @vindex LDADD
1806 @cindex prog_LDADD, defined
1808 Sometimes, multiple programs are built in one directory but do not share
1809 the same link-time requirements.  In this case, you can use the
1810 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1811 program as it appears in some @samp{_PROGRAMS} variable, and usually
1812 written in lowercase) to override the global @code{LDADD}.  If this
1813 variable exists for a given program, then that program is not linked
1814 using @code{LDADD}.
1815 @vindex _LDADD
1817 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
1818 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1819 built in the same directory, and has no such link requirement.  Also,
1820 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1821 is what cpio's @file{src/Makefile.am} looks like (abridged):
1823 @example
1824 bin_PROGRAMS = cpio pax @@MT@@
1825 libexec_PROGRAMS = @@RMT@@
1826 EXTRA_PROGRAMS = mt rmt
1828 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1829 rmt_LDADD =
1831 cpio_SOURCES = @dots{}
1832 pax_SOURCES = @dots{}
1833 mt_SOURCES = @dots{}
1834 rmt_SOURCES = @dots{}
1835 @end example
1837 @cindex _LDFLAGS, defined
1839 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
1840 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
1841 @samp{-dlpreopen}).  So, use the @samp{@var{prog}_LDFLAGS} variable for
1842 this purpose.
1843 @vindex _LDFLAGS
1845 @cindex _DEPENDENCIES, defined
1847 It is also occasionally useful to have a program depend on some other
1848 target which is not actually part of that program.  This can be done
1849 using the @samp{@var{prog}_DEPENDENCIES} variable.  Each program depends
1850 on the contents of such a variable, but no further interpretation is
1851 done.
1853 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
1854 Automake.  The automatically-assigned value is the contents of
1855 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
1856 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed.  The
1857 configure substitutions that are left in are only @samp{@@LIBOBJS@@} and
1858 @samp{@@ALLOCA@@}; these are left because it is known that they will not
1859 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
1860 generated.
1863 @node A Library, A Shared Library, A Program, Programs
1864 @section Building a library
1866 @cindex _LIBRARIES primary, defined
1867 @cindex LIBRARIES primary, defined
1868 @cindex Primary variable, LIBRARIES
1870 @vindex lib_LIBRARIES
1871 @vindex pkglib_LIBRARIES
1872 @vindex noinst_LIBRARIES
1874 Building a library is much like building a program.  In this case, the
1875 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1876 @code{libdir} or @code{pkglibdir}.
1878 @xref{A Shared Library}, for information on how to build shared
1879 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1881 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1882 For instance to create a library named @file{libcpio.a}, but not install
1883 it, you would write:
1885 @example
1886 noinst_LIBRARIES = libcpio.a
1887 @end example
1889 The sources that go into a library are determined exactly as they are
1890 for programs, via the @samp{_SOURCES} variables.  Note that the library
1891 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1892 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1893 not @samp{liblob.a_SOURCES}.
1895 @cindex _LIBADD primary, defined
1896 @cindex LIBADD primary, defined
1897 @cindex Primary variable, LIBADD
1899 Extra objects can be added to a library using the
1900 @samp{@var{library}_LIBADD} variable.  This should be used for objects
1901 determined by @code{configure}.  Again from @code{cpio}:
1902 @vindex _LIBADD
1903 @vindex LIBADD
1905 @example
1906 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1907 @end example
1909 In addition, sources for extra objects that will not exist until
1910 configure-time must be added to the @code{BUILT_SOURCES} variable
1911 (@pxref{Sources}).
1914 @node A Shared Library, Program and Library Variables, A Library, Programs
1915 @section Building a Shared Library
1917 @cindex Shared libraries, support for
1919 Building shared libraries is a relatively complex matter.  For this
1920 reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
1921 Libtool Manual}) was created to help build shared libraries in a
1922 platform-independent way.
1924 @cindex _LTLIBRARIES primary, defined
1925 @cindex LTLIBRARIES primary, defined
1926 @cindex Primary variable, LTLIBRARIES
1927 @cindex Example of shared libraries
1929 @cindex suffix .la, defined
1931 Automake uses Libtool to build libraries declared with the
1932 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1933 of shared libraries to build.  For instance, to create a library named
1934 @file{libgettext.a} and its corresponding shared libraries, and install
1935 them in @samp{libdir}, write:
1937 @example
1938 lib_LTLIBRARIES = libgettext.la
1939 @end example
1941 @vindex lib_LTLIBRARIES
1942 @vindex pkglib_LTLIBRARIES
1943 @vindex noinst_LTLIBRARIES
1944 @vindex check_LTLIBRARIES
1946 @cindex check_LTLIBRARIES, not allowed
1948 Note that shared libraries @emph{must} be installed in order to work
1949 properly, so @code{check_LTLIBRARIES} is not allowed.  However,
1950 @code{noinst_LTLIBRARIES} is allowed.  This feature should be used for
1951 libtool ``convenience libraries''.
1953 @cindex suffix .lo, defined
1955 For each library, the @samp{@var{library}_LIBADD} variable contains the
1956 names of extra libtool objects (@file{.lo} files) to add to the shared
1957 library.  The @samp{@var{library}_LDFLAGS} variable contains any
1958 additional libtool flags, such as @samp{-version-info} or
1959 @samp{-static}.
1961 @cindex @@LTLIBOBJS@@, special handling
1963 Where an ordinary library might include @code{@@LIBOBJS@@}, a libtool
1964 library must use @code{@@LTLIBOBJS@@}.  This is required because the
1965 object files that libtool operates on do not necessarily end in
1966 @file{.o}.  The libtool manual contains more details on this topic.
1968 For libraries installed in some directory, Automake will automatically
1969 supply the appropriate @samp{-rpath} option.  However, for libraries
1970 determined at configure time (and thus mentioned in
1971 @code{EXTRA_LTLIBRARIES}), Automake does not know the eventual
1972 installation directory; for such libraries you must add the
1973 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
1974 hand.
1976 Ordinarily, Automake requires that a shared library's name start with
1977 @samp{lib}.  However, if you are building a dynamically loadable module
1978 then you might wish to use a "nonstandard" name.  In this case, put
1979 @code{-module} into the @samp{_LDFLAGS} variable.
1981 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1982 libtool, The Libtool Manual}, for more information.
1985 @node Program and Library Variables, LIBOBJS, A Shared Library, Programs
1986 @section Program and Library Variables
1988 Associated with each program are a collection of variables which can be
1989 used to modify how that program is built.  There is a similar list of
1990 such variables for each library.  The canonical name of the program (or
1991 library) is used as a base for naming these variables.
1993 In the list below, we use the name ``maude'' to refer to the program or
1994 library.  In your @file{Makefile.am} you would replace this with the
1995 canonical name of your program.  This list also refers to ``maude'' as a
1996 program, but in general the same rules apply for both static and dynamic
1997 libraries; the documentation below notes situations where programs and
1998 libraries differ.
2000 @table @samp
2001 @item maude_SOURCES
2002 This variable, if it exists, lists all the source files which are
2003 compiled to build the program.  These files are added to the
2004 distribution by default.  When building the program, Automake will cause
2005 each source file to be compiled to a single @file{.o} file (or
2006 @file{.lo} when using libtool).  Normally these object files are named
2007 after the source file, but other factors can change this.  If a file in
2008 the @samp{_SOURCES} variable has an unrecognized extension, Automake
2009 will do one of two things with it.  If a suffix rule exists for turning
2010 files with the unrecognized extension into @file{.o} files, then
2011 automake will treat this file as it will any other source file
2012 (@pxref{Support for Other Languages}).  Otherwise, the file will be
2013 ignored as though it were a header file.
2015 The prefixes @samp{dist_} and @samp{nodist_} can be used to control
2016 whether files listed in a @samp{_SOURCES} variable are distributed.
2017 @samp{dist_} is redundant, as sources are distributed by default, but it
2018 can be specified for clarity if desired.
2020 It is possible to have both @samp{dist_} and @samp{nodist_} variants of
2021 a given @samp{_SOURCES} variable at once; this lets you easily
2022 distribute some files and not others, for instance:
2024 @example
2025 nodist_maude_SOURCES = nodist.c
2026 dist_maude_SOURCES = dist-me.c
2027 @end example
2029 By default the output file (on Unix systems, the @file{.o} file) will be
2030 put into the current build directory.  However, if the option
2031 @code{subdir-objects} is in effect in the current directory then the
2032 @file{.o} file will be put into the subdirectory named after the source
2033 file.  For instance, with @code{subdir-objects} enabled,
2034 @file{sub/dir/file.c} will be compiled to @file{sub/dir/file.o}.  Some
2035 people prefer this mode of operation.  You can specify
2036 @code{subdir-objects} in @code{AUTOMAKE_OPTIONS} (@pxref{Options}).
2037 @cindex Subdirectory, objects in
2038 @cindex Objects in subdirectory
2041 @item EXTRA_maude_SOURCES
2042 Automake needs to know the list of files you intend to compile
2043 @emph{statically}.  For one thing, this is the only way Automake has of
2044 knowing what sort of language support a given @file{Makefile.in}
2045 requires.  @footnote{There are other, more obscure reasons reasons for
2046 this limitation as well.}  This means that, for example, you can't put a
2047 configure substitution like @samp{@@my_sources@@} into a @samp{_SOURCES}
2048 variable.  If you intend to conditionally compile source files and use
2049 @file{configure} to substitute the appropriate object names into, e.g.,
2050 @samp{_LDADD} (see below), then you should list the corresponding source
2051 files in the @samp{EXTRA_} variable.
2053 This variable also supports @samp{dist_} and @samp{nodist_} prefixes,
2054 e.g., @samp{nodist_EXTRA_maude_SOURCES}.
2056 @item maude_AR
2057 A static library is created by default by invoking @code{$(AR) cru}
2058 followed by the name of the library and then the objects being put into
2059 the library.  You can override this by setting the @samp{_AR} variable.
2060 This is usually used with C++; some C++ compilers require a special
2061 invocation in order to instantiate all the templates which should go
2062 into a library.  For instance, the SGI C++ compiler likes this macro set
2063 like so:
2064 @example
2065 libmaude_a_AR = $(CXX) -ar -o
2066 @end example
2068 @item maude_LIBADD
2069 Extra objects can be added to a static library using the @samp{_LIBADD}
2070 variable.  This should be used for objects determined by
2071 @code{configure}.  Note that @samp{_LIBADD} is not used for shared
2072 libraries; there you must use @samp{_LDADD}.
2074 @item maude_LDADD
2075 Extra objects can be added to a shared library or a program by listing
2076 them in the @samp{_LDADD} variable.  This should be used for objects
2077 determined by @code{configure}.
2079 @samp{_LDADD} is inappropriate for passing program-specific linker flags
2080 (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen}).
2081 Use the @samp{_LDFLAGS} variable for this purpose.
2083 For instance, if your @file{configure.in} uses @code{AC_PATH_XTRA}, you
2084 could link your program against the X libraries like so:
2086 @example
2087 maude_LDADD = $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS)
2088 @end example
2090 @item maude_LDFLAGS
2091 This variable is used to pass extra flags to the link step of a program
2092 or a shared library.
2094 @item maude_LINK
2095 You can override the linker on a per-program basis.  By default the
2096 linker is chosen according to the languages used by the program.  For
2097 instance, a program that includes C++ source code would use the C++
2098 compiler to link.  The @samp{_LINK} variable must hold the name of a
2099 command which can be passed all the @file{.o} file names as arguments.
2100 Note that the name of the underlying program is @emph{not} passed to
2101 @samp{_LINK}; typically one uses @samp{$@@}:
2103 @example
2104 maude_LINK = $(CCLD) -magic -o $@@
2105 @end example
2107 @item maude_CFLAGS
2108 Automake allows you to set compilation flags on a per-program (or
2109 per-library) basis.  A single source file can be included in several
2110 programs, and it will potentially be compiled with different flags for
2111 each program.  This works for any language directly supported by
2112 Automake.  The flags are @samp{_CFLAGS}, @samp{_CXXFLAGS},
2113 @samp{_OBJCFLAGS}, @samp{_YFLAGS}, @samp{_CCASFLAGS}, @samp{_FFLAGS},
2114 @samp{_RFLAGS}, and @samp{_GCJFLAGS}.
2116 When using a per-program compilation flag, Automake will choose a
2117 different name for the intermediate object files.  Ordinarily a file
2118 like @file{sample.c} will be compiled to produce @file{sample.o}.
2119 However, if the program's @samp{_CFLAGS} variable is set, then the
2120 object file will be named, for instance, @file{maude-sample.o}.
2122 In compilations with per-program flags, the ordinary @samp{AM_} form of
2123 the flags variable is @emph{not} automatically included in the
2124 compilation (however, the user form of the variable @emph{is} included).
2125 So for instance, if you want the hypothetical @file{maude} compilations
2126 to also use the value of @samp{AM_CFLAGS}, you would need to write:
2128 @example
2129 maude_CFLAGS = ... your flags ... $(AM_CFLAGS)
2130 @end example
2132 @item maude_DEPENDENCIES
2133 It is also occasionally useful to have a program depend on some other
2134 target which is not actually part of that program.  This can be done
2135 using the @samp{_DEPENDENCIES} variable.  Each program depends on the
2136 contents of such a variable, but no further interpretation is done.
2138 If @samp{_DEPENDENCIES} is not supplied, it is computed by Automake.
2139 The automatically-assigned value is the contents of @samp{_LDADD}, with
2140 most configure substitutions, @samp{-l}, @samp{-L}, @samp{-dlopen} and
2141 @samp{-dlpreopen} options removed.  The configure substitutions that are
2142 left in are only @samp{@@LIBOBJS@@} and @samp{@@ALLOCA@@}; these are
2143 left because it is known that they will not cause an invalid value for
2144 @samp{_DEPENDENCIES} to be generated.
2146 @item maude_SHORTNAME
2147 On some platforms the allowable file names are very short.  In order to
2148 support these systems and per-program compilation flags at the same
2149 time, Automake allows you to set a ``short name'' which will influence
2150 how intermediate object files are named.  For instance, if you set
2151 @samp{maude_SHORTNAME} to @samp{m}, then in the above per-program
2152 compilation flag example the object file would be named
2153 @file{m-sample.o} rather than @file{maude-sample.o}.  This facility is
2154 rarely needed in practice, and we recommend avoiding it until you find
2155 it is required.
2156 @end table
2159 @node LIBOBJS, Program variables, Program and Library Variables, Programs
2160 @section Special handling for LIBOBJS and ALLOCA
2162 @cindex @@LIBOBJS@@, special handling
2163 @cindex @@ALLOCA@@, special handling
2165 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
2166 @code{@@ALLOCA@@}, and uses this information, plus the list of
2167 @code{LIBOBJS} files derived from @file{configure.in} to automatically
2168 include the appropriate source files in the distribution (@pxref{Dist}).
2169 These source files are also automatically handled in the
2170 dependency-tracking scheme; see @xref{Dependencies}.
2172 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
2173 @samp{_LDADD} or @samp{_LIBADD} variable.
2176 @node Program variables, Yacc and Lex, LIBOBJS, Programs
2177 @section Variables used when building a program
2179 Occasionally it is useful to know which @file{Makefile} variables
2180 Automake uses for compilations; for instance you might need to do your
2181 own compilation in some special cases.
2183 Some variables are inherited from Autoconf; these are @code{CC},
2184 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
2185 @code{LIBS}.
2186 @vindex LDFLAGS
2188 There are some additional variables which Automake itself defines:
2190 @vtable @code
2191 @item AM_CPPFLAGS
2192 The contents of this macro are passed to every compilation which invokes
2193 the C preprocessor; it is a list of arguments to the preprocessor.  For
2194 instance, @samp{-I} and @samp{-D} options should be listed here.
2196 Automake already provides some @samp{-I} options automatically.  In
2197 particular it generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I}
2198 pointing to the directory holding @file{config.h} (if you've used
2199 @code{AC_CONFIG_HEADER} or @code{AM_CONFIG_HEADER}).  You can disable
2200 the default @samp{-I} options using the @samp{nostdinc} option.
2202 @item INCLUDES
2203 This does the same job as @samp{AM_CPPFLAGS}.  It is an older name for
2204 the same functionality.  This macro is deprecated; we suggest using
2205 @samp{AM_CPPFLAGS} instead.
2207 @item AM_CFLAGS
2208 This is the variable which the @file{Makefile.am} author can use to pass
2209 in additional C compiler flags.  It is more fully documented elsewhere.
2210 In some situations, this is not used, in preference to the
2211 per-executable (or per-library) @code{CFLAGS}.
2213 @item COMPILE
2214 This is the command used to actually compile a C source file.  The
2215 filename is appended to form the complete command line.
2217 @item LINK
2218 This is the command used to actually link a C program.  It already
2219 includes @samp{-o $@@} and the usual variable references (for instance,
2220 @code{CFLAGS}); it takes as ``arguments'' the names of the object files
2221 and libraries to link in.
2222 @end vtable
2225 @node Yacc and Lex, C++ Support, Program variables, Programs
2226 @section Yacc and Lex support
2228 Automake has somewhat idiosyncratic support for Yacc and Lex.
2230 Automake assumes that the @file{.c} file generated by @code{yacc} (or
2231 @code{lex}) should be named using the basename of the input file.  That
2232 is, for a yacc source file @file{foo.y}, Automake will cause the
2233 intermediate file to be named @file{foo.c} (as opposed to
2234 @file{y.tab.c}, which is more traditional).
2236 The extension of a yacc source file is used to determine the extension
2237 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
2238 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
2239 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
2240 @samp{.cxx}.
2242 Likewise, lex source files can be used to generate @samp{C} or
2243 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
2244 @samp{.lxx} are recognized.
2246 You should never explicitly mention the intermediate (@samp{C} or
2247 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
2248 file.
2250 The intermediate files generated by @code{yacc} (or @code{lex}) will be
2251 included in any distribution that is made.  That way the user doesn't
2252 need to have @code{yacc} or @code{lex}.
2254 If a @code{yacc} source file is seen, then your @file{configure.in} must
2255 define the variable @samp{YACC}.  This is most easily done by invoking
2256 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
2257 Program Checks, autoconf, The Autoconf Manual}).
2259 When @code{yacc} is invoked, it is passed @samp{YFLAGS} and
2260 @samp{AM_YFLAGS}.  The former is a user variable and the latter is
2261 intended for the @file{Makefile.am} author.
2263 Similarly, if a @code{lex} source file is seen, then your
2264 @file{configure.in} must define the variable @samp{LEX}.  You can use
2265 @samp{AC_PROG_LEX} to do this (@pxref{Particular Programs, , Particular
2266 Program Checks, autoconf, The Autoconf Manual}), but using
2267 @code{AM_PROG_LEX} macro (@pxref{Macros}) is recommended.
2269 When @code{lex} is invoked, it is passed @samp{LFLAGS} and
2270 @samp{AM_LFLAGS}.  The former is a user variable and the latter is
2271 intended for the @file{Makefile.am} author.
2275 @cindex ylwrap
2276 @cindex yacc, multiple parsers
2277 @cindex Multiple yacc parsers
2278 @cindex Multiple lex lexers
2279 @cindex lex, multiple lexers
2282 Automake makes it possible to include multiple @code{yacc} (or
2283 @code{lex}) source files in a single program.  Automake uses a small
2284 program called @code{ylwrap} to run @code{yacc} (or @code{lex}) in a
2285 subdirectory.  This is necessary because yacc's output filename is
2286 fixed, and a parallel make could conceivably invoke more than one
2287 instance of @code{yacc} simultaneously.  The @code{ylwrap} program is
2288 distributed with Automake.  It should appear in the directory specified
2289 by @samp{AC_CONFIG_AUX_DIR} (@pxref{Input, , Finding `configure' Input,
2290 autoconf, The Autoconf Manual}), or the current directory if that macro
2291 is not used in @file{configure.in}.
2293 For @code{yacc}, simply managing locking is insufficient.  The output of
2294 @code{yacc} always uses the same symbol names internally, so it isn't
2295 possible to link two @code{yacc} parsers into the same executable.
2297 We recommend using the following renaming hack used in @code{gdb}:
2298 @example
2299 #define yymaxdepth c_maxdepth
2300 #define yyparse c_parse
2301 #define yylex   c_lex
2302 #define yyerror c_error
2303 #define yylval  c_lval
2304 #define yychar  c_char
2305 #define yydebug c_debug
2306 #define yypact  c_pact
2307 #define yyr1    c_r1
2308 #define yyr2    c_r2
2309 #define yydef   c_def
2310 #define yychk   c_chk
2311 #define yypgo   c_pgo
2312 #define yyact   c_act
2313 #define yyexca  c_exca
2314 #define yyerrflag c_errflag
2315 #define yynerrs c_nerrs
2316 #define yyps    c_ps
2317 #define yypv    c_pv
2318 #define yys     c_s
2319 #define yy_yys  c_yys
2320 #define yystate c_state
2321 #define yytmp   c_tmp
2322 #define yyv     c_v
2323 #define yy_yyv  c_yyv
2324 #define yyval   c_val
2325 #define yylloc  c_lloc
2326 #define yyreds  c_reds
2327 #define yytoks  c_toks
2328 #define yylhs   c_yylhs
2329 #define yylen   c_yylen
2330 #define yydefred c_yydefred
2331 #define yydgoto c_yydgoto
2332 #define yysindex c_yysindex
2333 #define yyrindex c_yyrindex
2334 #define yygindex c_yygindex
2335 #define yytable  c_yytable
2336 #define yycheck  c_yycheck
2337 #define yyname   c_yyname
2338 #define yyrule   c_yyrule
2339 @end example
2341 For each define, replace the @samp{c_} prefix with whatever you like.
2342 These defines work for @code{bison}, @code{byacc}, and traditional
2343 @code{yacc}s.  If you find a parser generator that uses a symbol not
2344 covered here, please report the new name so it can be added to the list.
2347 @node C++ Support, Assembly Support, Yacc and Lex, Programs
2348 @section C++ Support
2350 @cindex C++ support
2351 @cindex Support for C++
2353 Automake includes full support for C++.
2355 Any package including C++ code must define the output variable
2356 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
2357 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
2358 Program Checks, autoconf, The Autoconf Manual}).
2360 A few additional variables are defined when a C++ source file is seen:
2362 @vtable @code
2363 @item CXX
2364 The name of the C++ compiler.
2366 @item CXXFLAGS
2367 Any flags to pass to the C++ compiler.
2369 @item AM_CXXFLAGS
2370 The maintainer's variant of @code{CXXFLAGS}.
2372 @item CXXCOMPILE
2373 The command used to actually compile a C++ source file.  The file name
2374 is appended to form the complete command line.
2376 @item CXXLINK
2377 The command used to actually link a C++ program.
2378 @end vtable
2381 @node Assembly Support, Fortran 77 Support, C++ Support, Programs
2382 @section Assembly Support
2384 Automake includes some support for assembly code.
2386 The variable @code{CCAS} holds the name of the compiler used to build
2387 assembly code.  This compiler must work a bit like a C compiler; in
2388 particular it must accept @samp{-c} and @samp{-o}.  The value of
2389 @code{CCASFLAGS} is passed to the compilation.
2390 @vindex CCAS
2391 @vindex CCASFLAGS
2393 You are required to set @code{CCAS} and @code{CCASFLAGS} via
2394 @file{configure.in}.  The autoconf macro @code{AM_PROG_AS} will do this
2395 for you.  Unless they are already set, it simply sets @code{CCAS} to the
2396 C compiler and @code{CCASFLAGS} to the C compiler flags.
2398 Only the suffixes @samp{.s} and @samp{.S} are recognized by
2399 @code{automake} as being files containing assembly code.
2402 @node Fortran 77 Support, Java Support, Assembly Support, Programs
2403 @comment  node-name,  next,  previous,  up
2404 @section Fortran 77 Support
2406 @cindex Fortran 77 support
2407 @cindex Support for Fortran 77
2409 Automake includes full support for Fortran 77.
2411 Any package including Fortran 77 code must define the output variable
2412 @samp{F77} in @file{configure.in}; the simplest way to do this is to use
2413 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
2414 Program Checks, autoconf, The Autoconf Manual}).  @xref{Fortran 77 and
2415 Autoconf}.
2417 A few additional variables are defined when a Fortran 77 source file is
2418 seen:
2420 @vtable @code
2422 @item F77
2423 The name of the Fortran 77 compiler.
2425 @item FFLAGS
2426 Any flags to pass to the Fortran 77 compiler.
2428 @item AM_FFLAGS
2429 The maintainer's variant of @code{FFLAGS}.
2431 @item RFLAGS
2432 Any flags to pass to the Ratfor compiler.
2434 @item AM_RFLAGS
2435 The maintainer's variant of @code{RFLAGS}.
2437 @item F77COMPILE
2438 The command used to actually compile a Fortran 77 source file.  The file
2439 name is appended to form the complete command line.
2441 @item FLINK
2442 The command used to actually link a pure Fortran 77 program or shared
2443 library.
2445 @end vtable
2447 Automake can handle preprocessing Fortran 77 and Ratfor source files in
2448 addition to compiling them@footnote{Much, if not most, of the
2449 information in the following sections pertaining to preprocessing
2450 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
2451 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}.  Automake
2452 also contains some support for creating programs and shared libraries
2453 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
2454 Fortran 77 With C and C++}).
2456 These issues are covered in the following sections.
2458 @menu
2459 * Preprocessing Fortran 77::
2460 * Compiling Fortran 77 Files::
2461 * Mixing Fortran 77 With C and C++::
2462 * Fortran 77 and Autoconf::
2463 @end menu
2466 @node Preprocessing Fortran 77, Compiling Fortran 77 Files, Fortran 77 Support, Fortran 77 Support
2467 @comment  node-name,  next,  previous,  up
2468 @subsection Preprocessing Fortran 77
2470 @cindex Preprocessing Fortran 77
2471 @cindex Fortran 77, Preprocessing
2472 @cindex Ratfor programs
2474 @file{N.f} is made automatically from @file{N.F} or @file{N.r}.  This
2475 rule runs just the preprocessor to convert a preprocessable Fortran 77
2476 or Ratfor source file into a strict Fortran 77 source file.  The precise
2477 command used is as follows:
2479 @table @file
2481 @item .F
2482 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2484 @item .r
2485 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2487 @end table
2490 @node Compiling Fortran 77 Files, Mixing Fortran 77 With C and C++, Preprocessing Fortran 77, Fortran 77 Support
2491 @comment  node-name,  next,  previous,  up
2492 @subsection Compiling Fortran 77 Files
2494 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
2495 @file{N.r} by running the Fortran 77 compiler.  The precise command used
2496 is as follows:
2498 @table @file
2500 @item .f
2501 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
2503 @item .F
2504 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2506 @item .r
2507 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2509 @end table
2512 @node Mixing Fortran 77 With C and C++, Fortran 77 and Autoconf, Compiling Fortran 77 Files, Fortran 77 Support
2513 @comment  node-name,  next,  previous,  up
2514 @subsection Mixing Fortran 77 With C and C++
2516 @cindex Fortran 77, mixing with C and C++
2517 @cindex Mixing Fortran 77 with C and C++
2518 @cindex Linking Fortran 77 with C and C++
2519 @cindex cfortran
2520 @cindex Mixing Fortran 77 with C and/or C++
2522 Automake currently provides @emph{limited} support for creating programs
2523 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
2524 However, there are many other issues related to mixing Fortran 77 with
2525 other languages that are @emph{not} (currently) handled by Automake, but
2526 that are handled by other packages@footnote{For example,
2527 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
2528 addresses all of these inter-language issues, and runs under nearly all
2529 Fortran 77, C and C++ compilers on nearly all platforms.  However,
2530 @code{cfortran} is not yet Free Software, but it will be in the next
2531 major release.}.
2533 @page
2534 Automake can help in two ways:
2536 @enumerate
2537 @item
2538 Automatic selection of the linker depending on which combinations of
2539 source code.
2541 @item
2542 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
2543 @samp{-l}) to pass to the automatically selected linker in order to link
2544 in the appropriate Fortran 77 intrinsic and run-time libraries.
2546 @cindex FLIBS, defined
2547 These extra Fortran 77 linker flags are supplied in the output variable
2548 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
2549 supplied with newer versions of Autoconf (Autoconf version 2.13 and
2550 later).  @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
2551 Autoconf}.
2552 @end enumerate
2554 If Automake detects that a program or shared library (as mentioned in
2555 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
2556 code that is a mixture of Fortran 77 and C and/or C++, then it requires
2557 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
2558 @file{configure.in}, and that either @code{$(FLIBS)} or @code{@@FLIBS@@}
2559 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
2560 (for shared libraries) variables.  It is the responsibility of the
2561 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
2562 or @code{@@FLIBS@@} appears in the appropriate @code{_LDADD} or
2563 @code{_LIBADD} variable.
2565 @cindex Mixed language example
2566 @cindex Example, mixed language
2568 For example, consider the following @file{Makefile.am}:
2570 @example
2571 bin_PROGRAMS = foo
2572 foo_SOURCES  = main.cc foo.f
2573 foo_LDADD    = libfoo.la @@FLIBS@@
2575 pkglib_LTLIBRARIES = libfoo.la
2576 libfoo_la_SOURCES  = bar.f baz.c zardoz.cc
2577 libfoo_la_LIBADD   = $(FLIBS)
2578 @end example
2580 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
2581 is mentioned in @file{configure.in}.  Also, if @code{@@FLIBS@@} hadn't
2582 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
2583 Automake would have issued a warning.
2586 @page
2587 @menu
2588 * How the Linker is Chosen::
2589 @end menu
2591 @node How the Linker is Chosen,  , Mixing Fortran 77 With C and C++, Mixing Fortran 77 With C and C++
2592 @comment  node-name,  next,  previous,  up
2593 @subsubsection How the Linker is Chosen
2595 @cindex Automatic linker selection
2596 @cindex Selecting the linker automatically
2598 The following diagram demonstrates under what conditions a particular
2599 linker is chosen by Automake.
2601 For example, if Fortran 77, C and C++ source code were to be compiled
2602 into a program, then the C++ linker will be used.  In this case, if the
2603 C or Fortran 77 linkers required any special libraries that weren't
2604 included by the C++ linker, then they must be manually added to an
2605 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
2606 @file{Makefile.am}.
2608 @example
2609                      \              Linker
2610           source      \
2611            code        \     C        C++     Fortran
2612      -----------------  +---------+---------+---------+
2613                         |         |         |         |
2614      C                  |    x    |         |         |
2615                         |         |         |         |
2616                         +---------+---------+---------+
2617                         |         |         |         |
2618          C++            |         |    x    |         |
2619                         |         |         |         |
2620                         +---------+---------+---------+
2621                         |         |         |         |
2622                Fortran  |         |         |    x    |
2623                         |         |         |         |
2624                         +---------+---------+---------+
2625                         |         |         |         |
2626      C + C++            |         |    x    |         |
2627                         |         |         |         |
2628                         +---------+---------+---------+
2629                         |         |         |         |
2630      C +       Fortran  |         |         |    x    |
2631                         |         |         |         |
2632                         +---------+---------+---------+
2633                         |         |         |         |
2634          C++ + Fortran  |         |    x    |         |
2635                         |         |         |         |
2636                         +---------+---------+---------+
2637                         |         |         |         |
2638      C + C++ + Fortran  |         |    x    |         |
2639                         |         |         |         |
2640                         +---------+---------+---------+
2641 @end example
2644 @node Fortran 77 and Autoconf,  , Mixing Fortran 77 With C and C++, Fortran 77 Support
2645 @comment  node-name,  next,  previous,  up
2646 @subsection Fortran 77 and Autoconf
2648 The current Automake support for Fortran 77 requires a recent enough
2649 version of Autoconf that also includes support for Fortran 77.  Full
2650 Fortran 77 support was added to Autoconf 2.13, so you will want to use
2651 that version of Autoconf or later.
2654 @node Java Support, Support for Other Languages, Fortran 77 Support, Programs
2655 @comment  node-name,  next,  previous,  up
2656 @section Java Support
2658 @cindex Java support
2659 @cindex Support for Java
2661 Automake includes support for compiled Java, using @code{gcj}, the Java
2662 front end to the GNU Compiler Collection.
2664 Any package including Java code to be compiled must define the output
2665 variable @samp{GCJ} in @file{configure.in}; the variable @samp{GCJFLAGS}
2666 must also be defined somehow (either in @file{configure.in} or
2667 @file{Makefile.am}).  The simplest way to do this is to use the
2668 @code{AM_PROG_GCJ} macro.
2670 @vindex GCJFLAGS
2672 By default, programs including Java source files are linked with
2673 @code{gcj}.
2675 As always, the contents of @samp{AM_GCJFLAGS} are passed to every
2676 compilation invoking @code{gcj} (in its role as an ahead-of-time
2677 compiler -- when invoking it to create @file{.class} files,
2678 @samp{AM_JAVACFLAGS} is used instead).  If it is necessary to pass
2679 options to @code{gcj} from @file{Makefile.am}, this macro, and not the
2680 user macro @samp{GCJFLAGS}, should be used.
2682 @vindex AM_GCJFLAGS
2684 @code{gcj} can be used to compile @file{.java}, @file{.class},
2685 @file{.zip}, or @file{.jar} files.
2688 @node Support for Other Languages, ANSI, Java Support, Programs
2689 @comment  node-name,  next,  previous,  up
2690 @section Support for Other Languages
2692 Automake currently only includes full support for C, C++ (@pxref{C++
2693 Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java
2694 (@pxref{Java Support}).  There is only rudimentary support for other
2695 languages, support for which will be improved based on user demand.
2697 Some limited support for adding your own languages is available via the
2698 suffix rule handling; see @ref{Suffixes}.
2701 @node ANSI, Dependencies, Support for Other Languages, Programs
2702 @section Automatic de-ANSI-fication
2704 @cindex de-ANSI-fication, defined
2706 Although the GNU standards allow the use of ANSI C, this can have the
2707 effect of limiting portability of a package to some older compilers
2708 (notably the SunOS C compiler).
2710 Automake allows you to work around this problem on such machines by
2711 @dfn{de-ANSI-fying} each source file before the actual compilation takes
2712 place.
2714 @vindex AUTOMAKE_OPTIONS
2715 @opindex ansi2knr
2717 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
2718 (@pxref{Options}) contains the option @code{ansi2knr} then code to
2719 handle de-ANSI-fication is inserted into the generated
2720 @file{Makefile.in}.
2722 This causes each C source file in the directory to be treated as ANSI C.
2723 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
2724 is available, the @code{ansi2knr} program is used to convert the source
2725 files into K&R C, which is then compiled.
2727 The @code{ansi2knr} program is simple-minded.  It assumes the source
2728 code will be formatted in a particular way; see the @code{ansi2knr} man
2729 page for details.
2731 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
2732 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
2733 these files are distributed with Automake.  Also, the package
2734 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}
2735 (@pxref{Macros}).
2736 @cvindex AM_C_PROTOTYPES
2738 Automake also handles finding the @code{ansi2knr} support files in some
2739 other directory in the current package.  This is done by prepending the
2740 relative path to the appropriate directory to the @code{ansi2knr}
2741 option.  For instance, suppose the package has ANSI C code in the
2742 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
2743 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
2744 @file{src/Makefile.am}:
2746 @example
2747 AUTOMAKE_OPTIONS = ../lib/ansi2knr
2748 @end example
2750 If no directory prefix is given, the files are assumed to be in the
2751 current directory.
2753 Files mentioned in @code{LIBOBJS} which need de-ANSI-fication will not
2754 be automatically handled.  That's because @code{configure} will generate
2755 an object name like @file{regex.o}, while @code{make} will be looking
2756 for @file{regex_.o} (when de-ANSI-fying).  Eventually this problem will
2757 be fixed via @code{autoconf} magic, but for now you must put this code
2758 into your @file{configure.in}, just before the @code{AC_OUTPUT} call:
2760 @example
2761 # This is necessary so that .o files in LIBOBJS are also built via
2762 # the ANSI2KNR-filtering rules.
2763 LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
2764 @end example
2766 Note that automatic de-ANSI-fication will not work when the package is
2767 being built for a different host architecture.  That is because automake
2768 currently has no way to build @code{ansi2knr} for the build machine.
2771 @node Dependencies, EXEEXT, ANSI, Programs
2772 @section Automatic dependency tracking
2774 As a developer it is often painful to continually update the
2775 @file{Makefile.in} whenever the include-file dependencies change in a
2776 project.  Automake supplies a way to automatically track dependency
2777 changes.
2779 @cindex Dependency tracking
2780 @cindex Automatic dependency tracking
2782 Automake always uses complete dependencies for a compilation, including
2783 system headers.  Automake's model is that dependency computation should
2784 be a side effect of the build.  To this end, dependencies are computed
2785 by running all compilations through a special wrapper program called
2786 @code{depcomp}.  @code{depcomp} understands how to coax many different C
2787 and C++ compilers into generating dependency information in the format
2788 it requires.  @code{automake -a} will install @code{depcomp} into your
2789 source tree for you.  If @code{depcomp} can't figure out how to properly
2790 invoke your compiler, dependency tracking will simply be disabled for
2791 your build.
2793 @cindex depcomp
2795 Experience with earlier versions of Automake @footnote{See
2796 @uref{http://sources.redhat.com/automake/dependencies.html} for more
2797 information on the history and experiences with automatic dependency
2798 tracking in Automake} taught us that it is not reliable to generate
2799 dependencies only on the maintainer's system, as configurations vary too
2800 much.  So instead Automake implements dependency tracking at build time.
2802 Automatic dependency tracking can be suppressed by putting
2803 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.  Or, you
2804 can invoke @code{automake} with the @code{-i} option.  Dependency
2805 tracking is enabled by default.
2807 @vindex AUTOMAKE_OPTIONS
2808 @opindex no-dependencies
2810 The person building your package also can choose to disable dependency
2811 tracking by configuring with @code{--disable-dependency-tracking}.
2813 @cindex Disabling dependency tracking
2814 @cindex Dependency tracking, disabling
2817 @node EXEEXT, , Dependencies, Programs
2818 @section Support for executable extensions
2820 @cindex Executable extension
2821 @cindex Extension, executable
2822 @cindex Windows
2824 On some platforms, such as Windows, executables are expected to have an
2825 extension such as @samp{.exe}.  On these platforms, some compilers (GCC
2826 among them) will automatically generate @file{foo.exe} when asked to
2827 generate @file{foo}.
2829 Automake provides mostly-transparent support for this.  Unfortunately
2830 the support isn't completely transparent; if you want your package to
2831 support these platforms then you must assist.
2833 One thing you must be aware of is that, internally, Automake rewrites
2834 something like this:
2836 @example
2837 bin_PROGRAMS = liver
2838 @end example
2840 to this:
2842 @example
2843 bin_PROGRAMS = liver$(EXEEXT)
2844 @end example
2846 The targets Automake generates are likewise given the @samp{$(EXEEXT)}
2847 extension.  @code{EXEEXT}
2849 However, Automake cannot apply this rewriting to @code{configure}
2850 substitutions.  This means that if you are conditionally building a
2851 program using such a substitution, then your @file{configure.in} must
2852 take care to add @samp{$(EXEEXT)} when constructing the output variable.
2854 With Autoconf 2.13 and earlier, you must explicitly use @code{AC_EXEEXT}
2855 to get this support.  With Autoconf 2.50, @code{AC_EXEEXT} is run
2856 automatically if you configure a compiler (say, through
2857 @code{AC_PROG_CC}).
2859 Sometimes maintainers like to write an explicit link rule for their
2860 program.  Without executable extension support, this is easy---you
2861 simply write a target with the same name as the program.  However, when
2862 executable extension support is enabled, you must instead add the
2863 @samp{$(EXEEXT)} suffix.
2865 Unfortunately, due to the change in Autoconf 2.50, this means you must
2866 always add this extension.  However, this is a problem for maintainers
2867 who know their package will never run on a platform that has executable
2868 extensions.  For those maintainers, the @code{no-exeext} option
2869 (@pxref{Options}) will disable this feature.  This works in a fairly
2870 ugly way; if @code{no-exeext} is seen, then the presence of a target
2871 named @code{foo} in @file{Makefile.am} will override an
2872 automake-generated target of the form @code{foo$(EXEEXT)}.  Without the
2873 @code{no-exeext} option, this use will give an error.
2876 @node Other objects, Other GNU Tools, Programs, Top
2877 @chapter Other Derived Objects
2879 Automake can handle derived objects which are not C programs.  Sometimes
2880 the support for actually building such objects must be explicitly
2881 supplied, but Automake will still automatically handle installation and
2882 distribution.
2884 @menu
2885 * Scripts::                     Executable scripts
2886 * Headers::                     Header files
2887 * Data::                        Architecture-independent data files
2888 * Sources::                     Derived sources
2889 @end menu
2892 @node Scripts, Headers, Other objects, Other objects
2893 @section Executable Scripts
2895 @cindex _SCRIPTS primary, defined
2896 @cindex SCRIPTS primary, defined
2897 @cindex Primary variable, SCRIPTS
2899 It is possible to define and install programs which are scripts.  Such
2900 programs are listed using the @samp{SCRIPTS} primary name.  Automake
2901 doesn't define any dependencies for scripts; the @file{Makefile.am}
2902 should include the appropriate rules.
2903 @vindex SCRIPTS
2905 Automake does not assume that scripts are derived objects; such objects
2906 must be deleted by hand (@pxref{Clean}).
2908 The @code{automake} program itself is a Perl script that is generated at
2909 configure time from @file{automake.in}.  Here is how this is handled:
2911 @example
2912 bin_SCRIPTS = automake
2913 @end example
2915 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
2916 for it is automatically generated.
2918 @cindex SCRIPTS, installation directories
2919 @cindex Installing scripts
2921 @vindex bin_SCRIPTS
2922 @vindex sbin_SCRIPTS
2923 @vindex libexec_SCRIPTS
2924 @vindex pkgdata_SCRIPTS
2925 @vindex noinst_SCRIPTS
2927 Script objects can be installed in @code{bindir}, @code{sbindir},
2928 @code{libexecdir}, or @code{pkgdatadir}.
2931 @node Headers, Data, Scripts, Other objects
2932 @section Header files
2934 @cindex _HEADERS primary, defined
2935 @cindex HEADERS primary, defined
2936 @cindex Primary variable, HEADERS
2938 @vindex noinst_HEADERS
2940 Header files are specified by the @samp{HEADERS} family of variables.
2941 Generally header files are not installed, so the @code{noinst_HEADERS}
2942 variable will be the most used.  @footnote{However, for the case of a
2943 non-installed header file that is actually used by a particular program,
2944 we recommend listing it in the program's @samp{_SOURCES} variable
2945 instead of in @code{noinst_HEADERS}.  We believe this is more clear.}
2946 @vindex HEADERS
2948 All header files must be listed somewhere; missing ones will not appear
2949 in the distribution.  Often it is clearest to list uninstalled headers
2950 with the rest of the sources for a program.  @xref{A Program}.  Headers
2951 listed in a @samp{_SOURCES} variable need not be listed in any
2952 @samp{_HEADERS} variable.
2954 @cindex HEADERS, installation directories
2955 @cindex Installing headers
2957 @vindex include_HEADERS
2958 @vindex oldinclude_HEADERS
2959 @vindex pkginclude_HEADERS
2961 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
2962 @code{pkgincludedir}.
2965 @node Data, Sources, Headers, Other objects
2966 @section Architecture-independent data files
2968 @cindex _DATA primary, defined
2969 @cindex DATA primary, defined
2970 @cindex Primary variable, DATA
2972 Automake supports the installation of miscellaneous data files using the
2973 @samp{DATA} family of variables.
2974 @vindex DATA
2976 @vindex data_DATA
2977 @vindex sysconf_DATA
2978 @vindex sharedstate_DATA
2979 @vindex localstate_DATA
2980 @vindex pkgdata_DATA
2982 Such data can be installed in the directories @code{datadir},
2983 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
2984 @code{pkgdatadir}.
2986 By default, data files are @emph{not} included in a distribution.  Of
2987 course, you can use the @samp{dist_} prefix to change this on a
2988 per-variable basis.
2990 Here is how Automake installs its auxiliary data files:
2992 @example
2993 pkgdata_DATA = clean-kr.am clean.am @dots{}
2994 @end example
2997 @node Sources,  , Data, Other objects
2998 @section Built sources
3000 @cindex BUILT_SOURCES, defined
3002 Occasionally a file which would otherwise be called @samp{source}
3003 (e.g. a C @samp{.h} file) is actually derived from some other file.
3004 Such files should be listed in the @code{BUILT_SOURCES} variable.
3005 @vindex BUILT_SOURCES
3007 @code{BUILT_SOURCES} is actually a bit of a misnomer, as any file which
3008 must be created early in the build process can be listed in this
3009 variable.
3011 A source file listed in @code{BUILT_SOURCES} is created before the other
3012 @code{all} targets are made.  However, such a source file is not
3013 compiled unless explicitly requested by mentioning it in some other
3014 @samp{_SOURCES} variable.
3016 So, for instance, if you had header files which were created by a script
3017 run at build time, then you would list these headers in
3018 @code{BUILT_SOURCES}, to ensure that they would be built before any
3019 other compilations (perhaps ones using these headers) were started.
3022 @node Other GNU Tools, Documentation, Other objects, Top
3023 @chapter Other GNU Tools
3025 Since Automake is primarily intended to generate @file{Makefile.in}s for
3026 use in GNU programs, it tries hard to interoperate with other GNU tools.
3028 @menu
3029 * Emacs Lisp::                  Emacs Lisp
3030 * gettext::                     Gettext
3031 * Libtool::                     Libtool
3032 * Java::                        Java
3033 * Python::                      Python
3034 @end menu
3037 @node Emacs Lisp, gettext, Other GNU Tools, Other GNU Tools
3038 @section Emacs Lisp
3040 @cindex _LISP primary, defined
3041 @cindex LISP primary, defined
3042 @cindex Primary variable, LISP
3044 @vindex LISP
3045 @vindex lisp_LISP
3046 @vindex noinst_LISP
3048 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
3049 is used to hold a list of @file{.el} files.  Possible prefixes for this
3050 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
3051 @code{lisp_LISP} is defined, then @file{configure.in} must run
3052 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
3054 @vindex ELCFILES
3056 By default Automake will byte-compile all Emacs Lisp source files using
3057 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
3058 byte-compiling, simply define the variable @code{ELCFILES} to be empty.
3059 Byte-compiled Emacs Lisp files are not portable among all versions of
3060 Emacs, so it makes sense to turn this off if you expect sites to have
3061 more than one version of Emacs installed.  Furthermore, many packages
3062 don't actually benefit from byte-compilation.  Still, we recommend that
3063 you leave it enabled by default.  It is probably better for sites with
3064 strange setups to cope for themselves than to make the installation less
3065 nice for everybody else.
3068 @node gettext, Libtool, Emacs Lisp, Other GNU Tools
3069 @section Gettext
3071 @cindex GNU Gettext support
3072 @cindex Gettext support
3073 @cindex Support for GNU Gettext
3075 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
3076 turns on support for GNU gettext, a message catalog system for
3077 internationalization
3078 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
3080 The @code{gettext} support in Automake requires the addition of two
3081 subdirectories to the package, @file{intl} and @file{po}.  Automake
3082 insures that these directories exist and are mentioned in
3083 @code{SUBDIRS}.
3086 @node Libtool, Java, gettext, Other GNU Tools
3087 @section Libtool
3089 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
3090 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
3091 @xref{A Shared Library}.
3094 @node Java, Python, Libtool, Other GNU Tools
3095 @section Java
3097 @cindex _JAVA primary, defined
3098 @cindex JAVA primary, defined
3099 @cindex Primary variable, JAVA
3101 Automake provides some minimal support for Java compilation with the
3102 @samp{JAVA} primary.
3104 Any @file{.java} files listed in a @samp{_JAVA} variable will be
3105 compiled with @code{JAVAC} at build time.  By default, @file{.class}
3106 files are not included in the distribution.
3108 @cindex JAVA restrictions
3109 @cindex Restrictions for JAVA
3111 Currently Automake enforces the restriction that only one @samp{_JAVA}
3112 primary can be used in a given @file{Makefile.am}.  The reason for this
3113 restriction is that, in general, it isn't possible to know which
3114 @file{.class} files were generated from which @file{.java} files -- so
3115 it would be impossible to know which files to install where.  For
3116 instance, a @file{.java} file can define multiple classes; the resulting
3117 @file{.class} file names cannot be predicted without parsing the
3118 @file{.java} file.
3120 There are a few variables which are used when compiling Java sources:
3122 @vtable @code
3123 @item JAVAC
3124 The name of the Java compiler.  This defaults to @samp{javac}.
3126 @item JAVACFLAGS
3127 The flags to pass to the compiler.  This is considered to be a user
3128 variable (@pxref{User Variables}).
3130 @item AM_JAVACFLAGS
3131 More flags to pass to the Java compiler.  This, and not
3132 @code{JAVACFLAGS}, should be used when it is necessary to put Java
3133 compiler flags into @file{Makefile.am}.
3135 @item JAVAROOT
3136 The value of this variable is passed to the @samp{-d} option to
3137 @code{javac}.  It defaults to @samp{$(top_builddir)}.
3139 @item CLASSPATH_ENV
3140 This variable is an @code{sh} expression which is used to set the
3141 @code{CLASSPATH} environment variable on the @code{javac} command line.
3142 (In the future we will probably handle class path setting differently.)
3143 @end vtable
3146 @node Python,  , Java, Other GNU Tools
3147 @section Python
3149 @cindex _PYTHON primary, defined
3150 @cindex PYTHON primary, defined
3151 @cindex Primary variable, PYTHON
3154 Automake provides support for Python compilation with the @samp{PYTHON}
3155 primary.
3157 Any files listed in a @samp{_PYTHON} variable will be byte-compiled with
3158 @code{py-compile} at install time.  @code{py-compile} actually creates
3159 both standard (@file{.pyc}) and byte-compiled (@file{.pyo}) versions of
3160 the source files.  Note that because byte-compilation occurs at install
3161 time, any files listed in @samp{noinst_PYTHON} will not be compiled.
3162 Python source files are included in the distribution by default.
3164 Automake ships with an Autoconf macro called @code{AM_PATH_PYTHON} which
3165 will determine some Python-related directory variables (see below).  If
3166 have called @code{AM_PATH_PYTHON} from you @file{configure.in}, then you
3167 may use the following variables to list you Python source files in your
3168 variables: @samp{python_PYTHON}, @samp{pkgpython_PYTHON},
3169 @samp{pkgpython_PYTHON}, @samp{pyexecdir_PYTHON},
3170 @samp{pkgpyexecdir_PYTHON}, depending where you want your files
3171 installed.
3173 @code{AM_PATH_PYTHON} takes a single optional argument.  This argument,
3174 if present, is the minimum version of Python which can be used for this
3175 package.  If the version of Python found on the system is older than the
3176 required version, then @code{AM_PATH_PYTHON} will cause an error.
3178 @code{AM_PATH_PYTHON} creates several output variables based on the
3179 Python installation found during configuration.
3181 @vtable @code
3182 @item PYTHON
3183 The name of the Python executable.
3185 @item PYTHON_VERSION
3186 The Python version number, in the form @var{major}.@var{minor}
3187 (e.g. @samp{1.5}).  This is currently the value of
3188 @code{sys.version[:3]}.
3190 @item PYTHON_PREFIX
3191 The string @code{$prefix}.  This term may be used in future work
3192 which needs the contents of Python's @code{sys.prefix}, but general
3193 consensus is to always use the value from configure.
3195 @item PYTHON_EXEC_PREFIX
3196 The string @code{$exec_prefix}.  This term may be used in future work
3197 which needs the contents of Python's @code{sys.exec_prefix}, but general
3198 consensus is to always use the value from configure.
3200 @item PYTHON_PLATFORM
3201 The canonical name used by Python to describe the operating system, as
3202 given by @code{sys.platform}.  This value is sometimes needed when
3203 building Python extensions.
3205 @item pythondir
3206 The directory name for the @file{site-packages} subdirectory of the
3207 standard Python install tree.
3209 @item pkgpythondir
3210 This is is the directory under @code{pythondir} which is named after the
3211 package.  That is, it is @samp{$(pythondir)/$(PACKAGE)}.  It is provided
3212 as a convenience.
3214 @item pyexecdir
3215 This is the directory where Python extension modules (shared libraries)
3216 should be installed.
3218 @item pkgpyexecdir
3219 This is a convenience variable which is defined as
3220 @samp{$(pyexecdir)/$(PACKAGE)}.
3221 @end vtable
3224 @node Documentation, Install, Other GNU Tools, Top
3225 @chapter Building documentation
3227 Currently Automake provides support for Texinfo and man pages.
3229 @menu
3230 * Texinfo::                     Texinfo
3231 * Man pages::                   Man pages
3232 @end menu
3235 @node Texinfo, Man pages, Documentation, Documentation
3236 @section Texinfo
3238 @cindex _TEXINFOS primary, defined
3239 @cindex TEXINFOS primary, defined
3240 @cindex Primary variable, TEXINFOS
3242 If the current directory contains Texinfo source, you must declare it
3243 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
3244 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
3245 here.  Any Texinfo source file must end in the @file{.texi},
3246 @file{.txi}, or @file{.texinfo} extension.  We recommend @file{.texi}
3247 for new manuals.
3248 @vindex TEXINFOS
3249 @vindex info_TEXINFOS
3251 @cindex Texinfo macro, VERSION
3252 @cindex Texinfo macro, UPDATED
3253 @cindex Texinfo macro, EDITION
3254 @cindex Texinfo macro, UPDATED-MONTH
3256 @cindex VERSION Texinfo macro
3257 @cindex UPDATED Texinfo macro
3258 @cindex EDITION Texinfo macro
3259 @cindex UPDATED-MONTH Texinfo macro
3261 @cindex mdate-sh
3263 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
3264 that file will be automatically generated.  The file @file{version.texi}
3265 defines four Texinfo macros you can reference:
3267 @table @code
3268 @item EDITION
3269 @itemx VERSION
3270 Both of these macros hold the version number of your program.  They are
3271 kept separate for clarity.
3273 @item UPDATED
3274 This holds the date the primary @file{.texi} file was last modified.
3276 @item UPDATED-MONTH
3277 This holds the name of the month in which the primary @file{.texi} file
3278 was last modified.
3279 @end table
3281 The @file{version.texi} support requires the @code{mdate-sh} program;
3282 this program is supplied with Automake and automatically included when
3283 @code{automake} is invoked with the @code{--add-missing} option.
3285 If you have multiple Texinfo files, and you want to use the
3286 @file{version.texi} feature, then you have to have a separate version
3287 file for each Texinfo file.  Automake will treat any include in a
3288 Texinfo file that matches @samp{vers*.texi} just as an automatically
3289 generated version file.
3291 When an info file is rebuilt, the program named by the @code{MAKEINFO}
3292 variable is used to invoke it.  If the @code{makeinfo} program is found
3293 on the system then it will be used by default; otherwise @code{missing}
3294 will be used instead.  The flags in the variables @code{MAKEINFOFLAGS}
3295 and @code{AM_MAKEINFOFLAGS} will be passed to the @code{makeinfo}
3296 invocation; the first of these is intended for use by the user
3297 (@pxref{User Variables}) and the second by the @file{Makefile.am}
3298 writer.
3299 @vindex MAKEINFO
3300 @vindex MAKEINFOFLAGS
3301 @vindex AM_MAKEINFOFLAGS
3303 Sometimes an info file actually depends on more than one @file{.texi}
3304 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
3305 @file{gpl.texi}.  You can tell Automake about these dependencies using
3306 the @code{@var{texi}_TEXINFOS} variable.  Here is how GNU Hello does it:
3307 @vindex TEXINFOS
3308 @vindex _TEXINFOS
3310 @example
3311 info_TEXINFOS = hello.texi
3312 hello_TEXINFOS = gpl.texi
3313 @end example
3315 @cindex texinfo.tex
3317 By default, Automake requires the file @file{texinfo.tex} to appear in
3318 the same directory as the Texinfo source.  However, if you used
3319 @code{AC_CONFIG_AUX_DIR} in @file{configure.in} (@pxref{Input, , Finding
3320 `configure' Input, autoconf, The Autoconf Manual}), then
3321 @file{texinfo.tex} is looked for there.  Automake supplies
3322 @file{texinfo.tex} if @samp{--add-missing} is given.
3324 @vindex TEXINFO_TEX
3326 If your package has Texinfo files in many directories, you can use the
3327 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
3328 @file{texinfo.tex} for your package.  The value of this variable should
3329 be the relative path from the current @file{Makefile.am} to
3330 @file{texinfo.tex}:
3332 @example
3333 TEXINFO_TEX = ../doc/texinfo.tex
3334 @end example
3336 @opindex no-texinfo.tex
3338 The option @samp{no-texinfo.tex} can be used to eliminate the
3339 requirement for @file{texinfo.tex}.  Use of the variable
3340 @code{TEXINFO_TEX} is preferable, however, because that allows the
3341 @code{dvi} target to still work.
3343 @cindex Target, install-info
3344 @cindex Target, noinstall-info
3345 @cindex install-info target
3346 @cindex noinstall-info target
3348 @opindex no-installinfo
3349 @trindex install-info
3351 Automake generates an @code{install-info} target; some people apparently
3352 use this.  By default, info pages are installed by @samp{make install}.
3353 This can be prevented via the @code{no-installinfo} option.
3356 @node Man pages,  , Texinfo, Documentation
3357 @section Man pages
3359 @cindex _MANS primary, defined
3360 @cindex MANS primary, defined
3361 @cindex Primary variable, MANS
3363 A package can also include man pages (but see the GNU standards on this
3364 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.)  Man
3365 pages are declared using the @samp{MANS} primary.  Generally the
3366 @code{man_MANS} macro is used.  Man pages are automatically installed in
3367 the correct subdirectory of @code{mandir}, based on the file extension.
3368 @vindex MANS
3369 @vindex man_MANS
3371 File extensions such as @samp{.1c} are handled by looking for the valid
3372 part of the extension and using that to determine the correct
3373 subdirectory of @code{mandir}.  Valid section names are the digits
3374 @samp{0} through @samp{9}, and the letters @samp{l} and @samp{n}.
3376 Sometimes developers prefer to name a man page something like
3377 @file{foo.man} in the source, and then rename it to have the correct
3378 suffix, e.g. @file{foo.1}, when installing the file.  Automake also
3379 supports this mode.  For a valid section named @var{SECTION}, there is a
3380 corresponding directory named @samp{man@var{SECTION}dir}, and a
3381 corresponding @samp{_MANS} variable.  Files listed in such a variable
3382 are installed in the indicated section.  If the file already has a
3383 valid suffix, then it is installed as-is; otherwise the file suffix is
3384 changed to match the section.
3386 For instance, consider this example:
3387 @example
3388 man1_MANS = rename.man thesame.1 alsothesame.1c
3389 @end example
3391 In this case, @file{rename.man} will be renamed to @file{rename.1} when
3392 installed, but the other files will keep their names.
3394 @cindex Target, install-man
3395 @cindex Target, noinstall-man
3396 @cindex install-man target
3397 @cindex noinstall-man target
3399 @c Use @samp{make install} per documentation: (texi)code.
3400 By default, man pages are installed by @samp{make install}.  However,
3401 since the GNU project does not require man pages, many maintainers do
3402 not expend effort to keep the man pages up to date.  In these cases, the
3403 @code{no-installman} option will prevent the man pages from being
3404 installed by default.  The user can still explicitly install them via
3405 @samp{make install-man}.
3406 @opindex no-installman
3407 @trindex install-man
3409 Here is how the man pages are handled in GNU @code{cpio} (which includes
3410 both Texinfo documentation and man pages):
3412 @example
3413 man_MANS = cpio.1 mt.1
3414 EXTRA_DIST = $(man_MANS)
3415 @end example
3417 Man pages are not currently considered to be source, because it is not
3418 uncommon for man pages to be automatically generated.  Therefore they
3419 are not automatically included in the distribution.  However, this can
3420 be changed by use of the @samp{dist_} prefix.
3422 The @samp{nobase_} prefix is meaningless for man pages and is
3423 disallowed.
3426 @node Install, Clean, Documentation, Top
3427 @chapter What Gets Installed
3429 @cindex Installation support
3430 @cindex make install support
3432 @section Basics of installation
3434 Naturally, Automake handles the details of actually installing your
3435 program once it has been built.  All files named by the various
3436 primaries are automatically installed in the appropriate places when the
3437 user runs @code{make install}.
3439 A file named in a primary is installed by copying the built file into
3440 the appropriate directory.  The base name of the file is used when
3441 installing.
3443 @example
3444 bin_PROGRAMS = hello subdir/goodbye
3445 @end example
3447 In this example, both @samp{hello} and @samp{goodbye} will be installed
3448 in @code{$(bindir)}.
3450 Sometimes it is useful to avoid the basename step at install time.  For
3451 instance, you might have a number of header files in subdirectories of
3452 the source tree which are laid out precisely how you want to install
3453 them.  In this situation you can use the @samp{nobase_} prefix to
3454 suppress the base name step.  For example:
3456 @example
3457 nobase_include_HEADERS = stdio.h sys/types.h
3458 @end example
3460 Will install @file{stdio.h} in @code{$(includedir)} and @file{types.h}
3461 in @code{$(includedir)/sys}.
3463 @section The two parts of install
3465 Automake generates separate @code{install-data} and @code{install-exec}
3466 targets, in case the installer is installing on multiple machines which
3467 share directory structure---these targets allow the machine-independent
3468 parts to be installed only once.  @code{install-exec} installs
3469 platform-dependent files, and @code{install-data} installs
3470 platform-independent files.  The @code{install} target depends on both
3471 of these targets.  While Automake tries to automatically segregate
3472 objects into the correct category, the @file{Makefile.am} author is, in
3473 the end, responsible for making sure this is done correctly.
3474 @trindex install-data
3475 @trindex install-exec
3476 @trindex install
3477 @cindex Install, two parts of
3479 Variables using the standard directory prefixes @samp{data},
3480 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
3481 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
3482 installed by @samp{install-data}.
3484 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
3485 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
3486 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
3487 @samp{install-exec}.
3489 Any variable using a user-defined directory prefix with @samp{exec} in
3490 the name (e.g. @samp{myexecbin_PROGRAMS} is installed by
3491 @samp{install-exec}.  All other user-defined prefixes are installed by
3492 @samp{install-data}.
3494 @section Extending installation
3496 It is possible to extend this mechanism by defining an
3497 @code{install-exec-local} or @code{install-data-local} target.  If these
3498 targets exist, they will be run at @samp{make install} time.  These
3499 rules can do almost anything; care is required.
3500 @trindex install-exec-local
3501 @trindex install-data-local
3503 Automake also supports two install hooks, @code{install-exec-hook} and
3504 @code{install-data-hook}.  These hooks are run after all other install
3505 rules of the appropriate type, exec or data, have completed.  So, for
3506 instance, it is possible to perform post-installation modifications
3507 using an install hook.
3508 @cindex Install hook
3510 @section Staged installs
3512 @vindex DESTDIR
3513 Automake generates support for the @samp{DESTDIR} variable in all
3514 install rules.  @samp{DESTDIR} is used during the @samp{make install}
3515 step to relocate install objects into a staging area.  Each object and
3516 path is prefixed with the value of @samp{DESTDIR} before being copied
3517 into the install area.  Here is an example of typical DESTDIR usage:
3519 @example
3520 make DESTDIR=/tmp/staging install
3521 @end example
3523 This places install objects in a directory tree built under
3524 @file{/tmp/staging}.  If @file{/gnu/bin/foo} and
3525 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
3526 would install @file{/tmp/staging/gnu/bin/foo} and
3527 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
3529 This feature is commonly used to build install images and packages.  For
3530 more information, see @ref{Makefile Conventions, , , standards, The GNU
3531 Coding Standards}.
3533 Support for @samp{DESTDIR} is implemented by coding it directly into the
3534 install rules.  If your @file{Makefile.am} uses a local install rule
3535 (e.g., @code{install-exec-local}) or an install hook, then you must
3536 write that code to respect @samp{DESTDIR}.
3538 @section Rules for the user
3540 Automake also generates an @code{uninstall} target, an
3541 @code{installdirs} target, and an @code{install-strip} target.
3542 @trindex uninstall
3543 @trindex installdirs
3544 @trindex install-strip
3546 Automake supports @code{uninstall-local} and @code{uninstall-hook}.
3547 There is no notion of separate uninstalls for ``exec'' and ``data'', as
3548 these features would not provide additional functionality.
3550 Note that @code{uninstall} is not meant as a replacement for a real
3551 packaging tool.
3554 @node Clean, Dist, Install, Top
3555 @chapter What Gets Cleaned
3557 @cindex make clean support
3559 The GNU Makefile Standards specify a number of different clean rules.
3560 @c FIXME xref
3561 Generally the files that can be cleaned are determined automatically by
3562 Automake.  Of course, Automake also recognizes some variables that can
3563 be defined to specify additional files to clean.  These variables are
3564 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
3565 @code{MAINTAINERCLEANFILES}.
3566 @vindex MOSTLYCLEANFILES
3567 @vindex CLEANFILES
3568 @vindex DISTCLEANFILES
3569 @vindex MAINTAINERCLEANFILES
3571 As the GNU Standards aren't always explicit as to which files should be
3572 removed by which target, we've adopted a heuristic which we believe was
3573 first formulated by Fran@,{c}ois Pinard:
3575 @itemize @bullet
3576 @item
3577 If @code{make} built it, and it is commonly something that one would
3578 want to rebuild (for instance, a @file{.o} file), then
3579 @code{mostlyclean} should delete it.
3581 @item
3582 Otherwise, if @code{make} built it, then @code{clean} should delete it.
3584 @item
3585 If @code{configure} built it, then @code{distclean} should delete it
3587 @item
3588 If the maintainer built it, then @code{maintainer-clean} should
3589 delete it.
3590 @end itemize
3592 We recommend that you follow this same set of heuristics in your
3593 @file{Makefile.am}.
3596 @node Dist, Tests, Clean, Top
3597 @chapter What Goes in a Distribution
3599 @section Basics of distribution
3601 @cindex make dist
3603 The @code{dist} target in the generated @file{Makefile.in} can be used
3604 to generate a gzip'd @code{tar} file and other flavors of archive for
3605 distribution.  The files is named based on the @samp{PACKAGE} and
3606 @samp{VERSION} variables; more precisely the gzip'd @code{tar} file is
3607 named @samp{@var{package}-@var{version}.tar.gz}.
3608 @cvindex PACKAGE
3609 @cvindex VERSION
3610 @trindex dist
3611 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
3612 is run.  The default setting is @samp{--best}.
3614 For the most part, the files to distribute are automatically found by
3615 Automake: all source files are automatically included in a distribution,
3616 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
3617 has a built-in list of commonly used files which are automatically
3618 included if they are found in the current directory (either physically,
3619 or as the target of a @file{Makefile.am} rule).  This list is printed by
3620 @samp{automake --help}.  Also, files which are read by @code{configure}
3621 (i.e. the source files corresponding to the files specified in the
3622 @code{AC_OUTPUT} invocation) are automatically distributed.
3624 Still, sometimes there are files which must be distributed, but which
3625 are not covered in the automatic rules.  These files should be listed in
3626 the @code{EXTRA_DIST} variable.  You can mention files from
3627 subdirectories in @code{EXTRA_DIST}.
3629 You can also mention a directory in @code{EXTRA_DIST}; in this case the
3630 entire directory will be recursively copied into the distribution.
3631 Please note that this will also copy @emph{everything} in the directory,
3632 including CVS/RCS version control files.  We recommend against using
3633 this feature.
3635 @vindex EXTRA_DIST
3637 @section Fine-grained distribution control
3639 Sometimes you need tighter control over what does @emph{not} go into the
3640 distribution; for instance you might have source files which are
3641 generated and which you do not want to distribute.  In this case
3642 Automake gives fine-grained control using the @samp{dist} and
3643 @samp{nodist} prefixes.  Any primary or @samp{_SOURCES} variable can be
3644 prefixed with @samp{dist_} to add the listed files to the distribution.
3645 Similarly, @samp{nodist_} can be used to omit the files from the
3646 distribution.
3647 @vindex dist_
3648 @vindex nodist_
3650 As an example, here is how you would cause some data to be distributed
3651 while leaving some source code out of the distribution:
3653 @example
3654 dist_data_DATA = distribute-this
3655 bin_PROGRAMS = foo
3656 nodist_foo_SOURCES = do-not-distribute.c
3657 @end example
3659 @section The dist hook
3661 Another way to to use this is for removing unnecessary files that get
3662 recursively included by specifying a directory in EXTRA_DIST:
3664 @example
3665 EXTRA_DIST = doc
3667 dist-hook:
3668         rm -rf `find $(distdir)/doc -name CVS`
3669 @end example
3671 If you define @code{SUBDIRS}, Automake will recursively include the
3672 subdirectories in the distribution.  If @code{SUBDIRS} is defined
3673 conditionally (@pxref{Conditionals}), Automake will normally include all
3674 directories that could possibly appear in @code{SUBDIRS} in the
3675 distribution.  If you need to specify the set of directories
3676 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
3677 list of subdirectories to include in the distribution.
3678 @vindex DIST_SUBDIRS
3680 @trindex dist-hook
3682 Occasionally it is useful to be able to change the distribution before
3683 it is packaged up.  If the @code{dist-hook} target exists, it is run
3684 after the distribution directory is filled, but before the actual tar
3685 (or shar) file is created.  One way to use this is for distributing
3686 files in subdirectories for which a new @file{Makefile.am} is overkill:
3688 @example
3689 dist-hook:
3690         mkdir $(distdir)/random
3691         cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
3692 @end example
3694 @section Checking the distribution
3696 @cindex make distcheck
3697 @cindex make distcleancheck
3698 @vindex distcleancheck_listfiles
3700 Automake also generates a @code{distcheck} target which can be of help
3701 to ensure that a given distribution will actually work.
3702 @code{distcheck} makes a distribution, then tries to do a @code{VPATH}
3703 build, run the testsuite, and finally make another tarfile to ensure the
3704 distribution is self-contained.
3705 @trindex distcheck
3707 Building the package involves running @code{./configure}.  If you need
3708 to supply additional flags to @code{configure}, define them in the
3709 @code{DISTCHECK_CONFIGURE_FLAGS} variable, either in your top-level
3710 @file{Makefile.am}, or on the commande line when invoking @code{make}.
3711 @vindex DISTCHECK_CONFIGURE_FLAGS
3713 If the target @code{distcheck-hook} is defined in your
3714 @file{Makefile.am}, then it will be invoked by @code{distcheck} after
3715 the new distribution has been unpacked, but before the unpacked copy is
3716 configured and built.  Your @code{distcheck-hook} can do almost
3717 anything, though as always caution is advised.  Generally this hook is
3718 used to check for potential distribution errors not caught by the
3719 standard mechanism.
3721 Speaking about potential distribution errors, @code{distcheck} will also
3722 ensure that the @code{distclean} target actually removes all built
3723 files.  This is done by running @code{make distcleancheck} at the end of
3724 the @code{VPATH} build.  By default, @code{distcleancheck} will run
3725 @code{distclean} and then make sure the build tree has been emptied by
3726 running @code{$(distcleancheck_listfiles)}.  Usually this check will
3727 find generated files that you forgot to add to the @code{DISTCLEANFILES}
3728 variable (@pxref{Clean}).
3729 @trindex distcleancheck
3731 The @code{distcleancheck} behaviour should be ok for most packages,
3732 otherwise you have the possibility to override the definitition of
3733 either the @code{distcleancheck} target, or the
3734 @code{$(distcleancheck_listfiles)} variable.  For instance to disable
3735 @code{distcleancheck} completely, add the following rule to your
3736 top-level @file{Makefile.am}:
3737 @vindex distcleancheck_listfiles
3739 @example
3740 distcleancheck:
3741         @@:
3742 @end example
3744 If you want @code{distcleancheck} to ignore built files which have not
3745 been cleaned because they are also part of the distribution, add the
3746 following definition instead:
3748 @example
3749 distcleancheck_listfiles = \
3750   find -type f -exec sh -c 'test -f $(scrdir)/@{@} || echo @{@}'
3751 @end example
3753 The above definition is not the default because it's usually an error if
3754 your Makefiles cause some distributed files to be rebuilt when the user
3755 build the package.  (Think about the user missing the tool required to
3756 build the file; or if the required tool is built by your package,
3757 consider the cross-compilation case where it can't be run.)
3759 @section The types of distributions
3761 @trindex dist-gzip
3762 Automake generates a @samp{.tar.gz} file when asked to create a
3763 distribution and other archives formats, @ref{Options}.  The target
3764 @code{dist-gzip} generates the @samp{.tar.gz} file only.
3767 @node Tests, Options, Dist, Top
3768 @chapter Support for test suites
3770 @cindex Test suites
3771 @cindex make check
3773 Automake supports two forms of test suites.
3775 @section Simple Tests
3777 If the variable @code{TESTS} is defined, its value is taken to be a list
3778 of programs to run in order to do the testing.  The programs can either
3779 be derived objects or source objects; the generated rule will look both
3780 in @code{srcdir} and @file{.}.  Programs needing data files should look
3781 for them in @code{srcdir} (which is both an environment variable and a
3782 make variable) so they work when building in a separate directory
3783 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
3784 Manual}), and in particular for the @code{distcheck} target
3785 (@pxref{Dist}).
3787 @cindex Exit status 77, special interpretation
3789 The number of failures will be printed at the end of the run.  If a
3790 given test program exits with a status of 77, then its result is ignored
3791 in the final count.  This feature allows non-portable tests to be
3792 ignored in environments where they don't make sense.
3794 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
3795 variables for the test run; the environment variable @code{srcdir} is
3796 set in the rule.  If all your test programs are scripts, you can also
3797 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
3798 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
3799 @vindex TESTS
3800 @vindex TESTS_ENVIRONMENT
3802 @cindex Tests, expected failure
3803 @cindex Expected test failure
3805 You may define the variable @code{XFAIL_TESTS} to a list of tests
3806 (usually a subset of @code{TESTS}) that are expected to fail.  This will
3807 reverse the result of those tests.
3808 @vindex XFAIL_TESTS
3810 Automake ensures that each program listed in @code{TESTS} is built
3811 before any tests are run; you can list both source and derived programs
3812 in @code{TESTS}.  For instance, you might want to run a C program as a
3813 test.  To do this you would list its name in @code{TESTS} and also in
3814 @code{check_PROGRAMS}, and then specify it as you would any other
3815 program.
3817 @section DejaGNU Tests
3819 If @uref{ftp://prep.ai.mit.edu/pub/gnu/dejagnu-1.3.tar.gz,
3820 @samp{dejagnu}} appears in @code{AUTOMAKE_OPTIONS}, then a
3821 @code{dejagnu}-based test suite is assumed.  The variable
3822 @code{DEJATOOL} is a list of names which are passed, one at a time, as
3823 the @code{--tool} argument to @code{runtest} invocations; it defaults to
3824 the name of the package.
3826 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
3827 @code{--srcdir} flags that are passed to dejagnu by default; this can be
3828 overridden if necessary.
3829 @vindex RUNTESTDEFAULTFLAGS
3831 The variables @code{EXPECT} and @code{RUNTEST} can
3832 also be overridden to provide project-specific values.  For instance,
3833 you will need to do this if you are testing a compiler toolchain,
3834 because the default values do not take into account host and target
3835 names.
3836 @opindex dejagnu
3837 @vindex DEJATOOL
3838 @vindex EXPECT
3839 @vindex RUNTEST
3841 The contents of the variable @code{RUNTESTFLAGS} are passed to the
3842 @code{runtest} invocation.  This is considered a ``user variable''
3843 (@pxref{User Variables}).  If you need to set @code{runtest} flags in
3844 @file{Makefile.am}, you can use @code{AM_RUNTESTFLAGS} instead.
3845 @vindex RUNTESTFLAGS
3846 @vindex AM_RUNTESTFLAGS
3847 @c FIXME xref dejagnu
3849 In either case, the testing is done via @samp{make check}.
3851 @section Install Tests
3853 The @code{installcheck} target is available to the user as a way to run
3854 any tests after the package has been installed.  You can add tests to
3855 this by writing an @code{installcheck-local} target.
3858 @node Options, Miscellaneous, Tests, Top
3859 @chapter Changing Automake's Behavior
3861 Various features of Automake can be controlled by options in the
3862 @file{Makefile.am}.  Such options are applied on a per-@file{Makefile}
3863 basis when listed in a special @file{Makefile} variable named
3864 @code{AUTOMAKE_OPTIONS}.  They are applied globally to all processed
3865 @file{Makefiles} when listed in the first argument of
3866 @code{AM_INIT_AUTOMAKE} in @file{configure.in}.  Currently understood
3867 options are:
3868 @vindex AUTOMAKE_OPTIONS
3870 @table @asis
3871 @item @code{gnits}
3872 @itemx @code{gnu}
3873 @itemx @code{foreign}
3874 @itemx @code{cygnus}
3875 @cindex Option, gnits
3876 @cindex Option, gnu
3877 @cindex Option, foreign
3878 @cindex Option, cygnus
3880 Set the strictness as appropriate.  The @code{gnits} option also implies
3881 @code{readme-alpha} and @code{check-news}.
3883 @item @code{ansi2knr}
3884 @itemx @code{@var{path}/ansi2knr}
3885 @cindex Option, ansi2knr
3886 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceded by a
3887 path, the generated @file{Makefile.in} will look in the specified
3888 directory to find the @file{ansi2knr} program.  The path should be a
3889 relative path to another directory in the same distribution (Automake
3890 currently does not check this).
3892 @item @code{check-news}
3893 @cindex Option, check-news
3894 Cause @code{make dist} to fail unless the current version number appears
3895 in the first few lines of the @file{NEWS} file.
3897 @item @code{dejagnu}
3898 @cindex Option, dejagnu
3899 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
3901 @item @code{dist-bzip2}
3902 @cindex Option, dist-bzip2
3903 Generate a @code{dist-bzip2} target, creating a bzip2 tar archive of the
3904 distribution.  @code{dist} will create it in addition to the other
3905 formats.  bzip2 archives are frequently smaller than gzipped archives.
3906 @trindex dist-bzip2
3908 @item @code{dist-shar}
3909 @cindex Option, dist-shar
3910 Generate a @code{dist-shar} target, creating a shar archive of the
3911 distribution.  @code{dist} will create it in addition to the other
3912 formats.
3913 @trindex dist-shar
3915 @item @code{dist-zip}
3916 @cindex Option, dist-zip
3917 Generate a @code{dist-zip} target, creating a zip archive of the
3918 distribution.  @code{dist} will create it in addition to the other
3919 formats.
3920 @trindex dist-zip
3922 @item @code{dist-tarZ}
3923 @cindex Option, dist-tarZ
3924 Generate a @code{dist-tarZ} target, creating a compressed tar archive of
3925 the distribution.  @code{dist} will create it in addition to the other
3926 formats.
3927 @trindex dist-tarZ
3929 @item @code{no-define}
3930 @cindex Option, no-define
3931 This options is meaningful only when passed as an argument to
3932 AM_INIT_AUTOMAKE.  It will prevent the @code{PACKAGE} and @code{VERSION}
3933 variable to be @code{AC_DEFINE}d.
3935 @item @code{no-dependencies}
3936 @cindex Option, no-dependencies
3937 This is similar to using @samp{--include-deps} on the command line, but
3938 is useful for those situations where you don't have the necessary bits
3939 to make automatic dependency tracking work @xref{Dependencies}.  In this
3940 case the effect is to effectively disable automatic dependency tracking.
3942 @item @code{no-exeext}
3943 @cindex Option, no-exeext
3944 If your @file{Makefile.am} defines a target @samp{foo}, it will override
3945 a target named @samp{foo$(EXEEXT)}.  This is necessary when
3946 @code{EXEEXT} is found to be empty.  However, by default automake will
3947 generate an error for this use.  The @code{no-exeext} option will
3948 disable this error.  This is intended for use only where it is known in
3949 advance that the package will not be ported to Windows, or any other
3950 operating system using extensions on executables.
3952 @item @code{no-installinfo}
3953 @cindex Option, no-installinfo
3954 The generated @file{Makefile.in} will not cause info pages to be built
3955 or installed by default.  However, @code{info} and @code{install-info}
3956 targets will still be available.  This option is disallowed at
3957 @samp{GNU} strictness and above.
3958 @trindex info
3959 @trindex install-info
3961 @item @code{no-installman}
3962 @cindex Option, no-installman
3963 The generated @file{Makefile.in} will not cause man pages to be
3964 installed by default.  However, an @code{install-man} target will still
3965 be available for optional installation.  This option is disallowed at
3966 @samp{GNU} strictness and above.
3967 @trindex install-man
3969 @item @code{nostdinc}
3970 @cindex Option, nostdinc
3971 This option can be used to disable the standard @samp{-I} options which
3972 are ordinarily automatically provided by Automake.
3974 @item @code{no-texinfo.tex}
3975 @cindex Option, no-texinfo
3976 Don't require @file{texinfo.tex}, even if there are texinfo files in
3977 this directory.
3979 @item @code{readme-alpha}
3980 @cindex Option, readme-alpha
3981 If this release is an alpha release, and the file @file{README-alpha}
3982 exists, then it will be added to the distribution.  If this option is
3983 given, version numbers are expected to follow one of two forms.  The
3984 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
3985 element is a number; the final period and number should be left off for
3986 non-alpha releases.  The second form is
3987 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
3988 letter; it should be omitted for non-alpha releases.
3990 @item @code{subdir-objects}
3991 If this option is specified, then objects are placed into the
3992 subdirectory of the build directory corresponding to the subdirectory of
3993 the source file.  For instance if the source file is
3994 @file{subdir/file.cxx}, then the output file would be
3995 @file{subdir/file.o}.
3997 @item @var{version}
3998 @cindex Option, version
3999 A version number (e.g. @samp{0.30}) can be specified.  If Automake is not
4000 newer than the version specified, creation of the @file{Makefile.in}
4001 will be suppressed.
4002 @end table
4004 Unrecognized options are diagnosed by @code{automake}.
4006 If you want an option to apply to all the files in the tree, you can use
4007 the @code{AM_AUTOMAKE_OPTIONS} macro in @file{configure.in}.
4008 @xref{Macros}.
4011 @node Miscellaneous, Include, Options, Top
4012 @chapter Miscellaneous Rules
4014 There are a few rules and variables that didn't fit anywhere else.
4016 @menu
4017 * Tags::                        Interfacing to etags and mkid
4018 * Suffixes::                    Handling new file extensions
4019 * Multilibs::                   Support for multilibbing.
4020 @end menu
4023 @node Tags, Suffixes, Miscellaneous, Miscellaneous
4024 @section Interfacing to @code{etags}
4026 @cindex TAGS support
4028 Automake will generate rules to generate @file{TAGS} files for use with
4029 GNU Emacs under some circumstances.
4031 If any C, C++ or Fortran 77 source code or headers are present, then
4032 @code{tags} and @code{TAGS} targets will be generated for the directory.
4033 @trindex tags
4035 At the topmost directory of a multi-directory package, a @code{tags}
4036 target file will be generated which, when run, will generate a
4037 @file{TAGS} file that includes by reference all @file{TAGS} files from
4038 subdirectories.
4040 The @code{tags} target will also be generated if the variable
4041 @code{ETAGS_ARGS} is defined.  This variable is intended for use in
4042 directories which contain taggable source that @code{etags} does not
4043 understand.  The user can use the @code{ETAGSFLAGS} to pass additional
4044 flags to @code{etags}; @code{AM_ETAGSFLAGS} is also available for use in
4045 @file{Makefile.am}.
4046 @vindex ETAGS_ARGS
4047 @vindex ETAGSFLAGS
4048 @vindex AM_ETAGSFLAGS
4050 Here is how Automake generates tags for its source, and for nodes in its
4051 Texinfo file:
4053 @example
4054 ETAGS_ARGS = automake.in --lang=none \
4055  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
4056 @end example
4058 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
4059 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
4060 are added directly to the dependencies for the @code{tags} target.
4061 @vindex TAGS_DEPENDENCIES
4063 Automake will also generate an @code{ID} target which will run
4064 @code{mkid} on the source.  This is only supported on a
4065 directory-by-directory basis.
4066 @trindex id
4068 Automake also supports the @uref{http://www.gnu.org/software/global/,
4069 GNU Global Tags program}.  The @code{GTAGS} target runs Global Tags
4070 automatically and puts the result in the top build directory.  The
4071 variable @code{GTAGS_ARGS} holds arguments which are passed to
4072 @code{gtags}.
4073 @vindex GTAGS_ARGS
4076 @node Suffixes, Multilibs, Tags, Miscellaneous
4077 @section Handling new file extensions
4079 @cindex Adding new SUFFIXES
4080 @cindex SUFFIXES, adding
4081 @vindex SUFFIXES
4083 It is sometimes useful to introduce a new implicit rule to handle a file
4084 type that Automake does not know about.
4086 For instance, suppose you had a compiler which could compile @samp{.foo}
4087 files to @samp{.o} files.  You would simply define an suffix rule for
4088 your language:
4090 @example
4091 .foo.o:
4092         foocc -c -o $@@ $<
4093 @end example
4095 Then you could directly use a @samp{.foo} file in a @samp{_SOURCES}
4096 variable and expect the correct results:
4098 @example
4099 bin_PROGRAMS = doit
4100 doit_SOURCES = doit.foo
4101 @end example
4103 This was the simpler and more common case.  In other cases, you will
4104 have to help Automake to figure which extensions you are defining your
4105 suffix rule for.  This usually happens when your extensions does not
4106 start with a dot.  Then, all you have to do is to put a list of new
4107 suffixes in the @code{SUFFIXES} variable @strong{before} you define your
4108 implicit rule.
4110 For instance the following definition prevents Automake to misinterpret
4111 @samp{.idlC.cpp:} as an attemp to transform @samp{.idlC} into
4112 @samp{.cpp}.
4114 @example
4115 SUFFIXES = .idl C.cpp
4116 .idlC.cpp:
4117         # whatever
4118 @end example
4120 As you may have noted, the @code{SUFFIXES} macro behaves like the
4121 @code{.SUFFIXES} special target of @code{make}.  You should not touch
4122 @code{.SUFFIXES} yourself, but use @code{SUFFIXES} instead and let
4123 Automake generate the suffix list for @code{.SUFFIXES}.  Any given
4124 @code{SUFFIXES} go at the start of the generated suffixes list, followed
4125 by Automake generated suffixes not already in the list.
4127 @node Multilibs, , Suffixes, Miscellaneous
4128 @section Support for Multilibs
4130 Automake has support for an obscure feature called multilibs.  A
4131 @dfn{multilib} is a library which is built for multiple different ABIs
4132 at a single time; each time the library is built with a different target
4133 flag combination.  This is only useful when the library is intended to
4134 be cross-compiled, and it is almost exclusively used for compiler
4135 support libraries.
4137 The multilib support is still experimental.  Only use it if you are
4138 familiar with multilibs and can debug problems you might encounter.
4141 @node Include, Conditionals, Miscellaneous, Top
4142 @chapter Include
4144 @cmindex include
4145 @cindex Including Makefile fragment
4146 @cindex Makefile fragment, including
4148 Automake supports an @code{include} directive which can be used to
4149 include other @file{Makefile} fragments when @code{automake} is run.
4150 Note that these fragments are read and interpreted by @code{automake},
4151 not by @code{make}.  As with conditionals, @code{make} has no idea that
4152 @code{include} is in use.
4154 There are two forms of @code{include}:
4156 @table @code
4157 @item include $(srcdir)/file
4158 Include a fragment which is found relative to the current source
4159 directory.
4161 @item include $(top_srcdir)/file
4162 Include a fragment which is found relative to the top source directory.
4163 @end table
4165 Note that if a fragment is included inside a conditional, then the
4166 condition applies to the entire contents of that fragment.
4169 @node Conditionals, Gnits, Include, Top
4170 @chapter Conditionals
4172 @cindex Conditionals
4174 Automake supports a simple type of conditionals.
4176 @cvindex AM_CONDITIONAL
4177 Before using a conditional, you must define it by using
4178 @code{AM_CONDITIONAL} in the @code{configure.in} file (@pxref{Macros}).
4180 @defmac AM_CONDITIONAL (@var{conditional}, @var{condition})
4181 The conditional name, @var{conditional}, should be a simple string
4182 starting with a letter and containing only letters, digits, and
4183 underscores.  It must be different from @samp{TRUE} and @samp{FALSE}
4184 which are reserved by Automake.
4186 The shell @var{condition} (suitable for use in a shell @code{if}
4187 statement) is evaluated when @code{configure} is run.  Note that you
4188 must arrange for @emph{every} @code{AM_CONDITIONAL} to be invoked every
4189 time @code{configure} is run -- if @code{AM_CONDITIONAL} is run
4190 conditionally (e.g., in a shell @code{if} statement), then the result
4191 will confuse automake.
4192 @end defmac
4194 @cindex --enable-debug, example
4195 @cindex Example conditional --enable-debug
4196 @cindex Conditional example,  --enable-debug
4198 Conditionals typically depend upon options which the user provides to
4199 the @code{configure} script.  Here is an example of how to write a
4200 conditional which is true if the user uses the @samp{--enable-debug}
4201 option.
4203 @example
4204 AC_ARG_ENABLE(debug,
4205 [  --enable-debug    Turn on debugging],
4206 [case "$@{enableval@}" in
4207   yes) debug=true ;;
4208   no)  debug=false ;;
4209   *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
4210 esac],[debug=false])
4211 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
4212 @end example
4214 Here is an example of how to use that conditional in @file{Makefile.am}:
4216 @cmindex if
4217 @cmindex endif
4218 @cmindex else
4220 @example
4221 if DEBUG
4222 DBG = debug
4223 else
4224 DBG =
4225 endif
4226 noinst_PROGRAMS = $(DBG)
4227 @end example
4229 This trivial example could also be handled using EXTRA_PROGRAMS
4230 (@pxref{A Program}).
4232 You may only test a single variable in an @code{if} statement, possibly
4233 negated using @samp{!}.  The @code{else} statement may be omitted.
4234 Conditionals may be nested to any depth.  You may specify an argument to
4235 @code{else} in which case it must be the negation of the condition used
4236 for the current @code{if}.  Similarly you may specify the condition
4237 which is closed by an @code{end}:
4239 @example
4240 if DEBUG
4241 DBG = debug
4242 else !DEBUG
4243 DBG =
4244 endif !DEBUG
4245 @end example
4247 @noindent
4248 Unbalanced conditions are errors.
4250 Note that conditionals in Automake are not the same as conditionals in
4251 GNU Make.  Automake conditionals are checked at configure time by the
4252 @file{configure} script, and affect the translation from
4253 @file{Makefile.in} to @file{Makefile}.  They are based on options passed
4254 to @file{configure} and on results that @file{configure} has discovered
4255 about the host system.  GNU Make conditionals are checked at @code{make}
4256 time, and are based on variables passed to the make program or defined
4257 in the @file{Makefile}.
4259 Automake conditionals will work with any make program.
4262 @node Gnits, Cygnus, Conditionals, Top
4263 @chapter The effect of @code{--gnu} and @code{--gnits}
4265 @cindex --gnu, required files
4266 @cindex --gnu, complete description
4268 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
4269 variable) causes @code{automake} to check the following:
4271 @itemize @bullet
4272 @item
4273 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
4274 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
4275 directory of the package.
4277 @item
4278 The options @samp{no-installman} and @samp{no-installinfo} are
4279 prohibited.
4280 @end itemize
4282 Note that this option will be extended in the future to do even more
4283 checking; it is advisable to be familiar with the precise requirements
4284 of the GNU standards.  Also, @samp{--gnu} can require certain
4285 non-standard GNU programs to exist for use by various maintainer-only
4286 targets; for instance in the future @code{pathchk} might be required for
4287 @samp{make dist}.
4289 @cindex --gnits, complete description
4291 The @samp{--gnits} option does everything that @samp{--gnu} does, and
4292 checks the following as well:
4294 @itemize @bullet
4295 @item
4296 @samp{make dist} will check to make sure the @file{NEWS} file has been
4297 updated to the current version.
4299 @item
4300 @samp{VERSION} is checked to make sure its format complies with Gnits
4301 standards.
4302 @c FIXME xref when standards are finished
4304 @item
4305 @cindex README-alpha
4306 If @samp{VERSION} indicates that this is an alpha release, and the file
4307 @file{README-alpha} appears in the topmost directory of a package, then
4308 it is included in the distribution.  This is done in @samp{--gnits}
4309 mode, and no other, because this mode is the only one where version
4310 number formats are constrained, and hence the only mode where Automake
4311 can automatically determine whether @file{README-alpha} should be
4312 included.
4314 @item
4315 The file @file{THANKS} is required.
4316 @end itemize
4319 @node Cygnus, Extending, Gnits, Top
4320 @chapter The effect of @code{--cygnus}
4322 @cindex Cygnus strictness
4324 Some packages, notably GNU GCC and GNU gdb, have a build environment
4325 originally written at Cygnus Support (subsequently renamed Cygnus
4326 Solutions, and then later purchased by Red Hat).  Packages with this
4327 ancestry are sometimes referred to as ``Cygnus'' trees.
4329 A Cygnus tree has slightly different rules for how a @file{Makefile.in}
4330 is to be constructed.  Passing @samp{--cygnus} to @code{automake} will
4331 cause any generated @file{Makefile.in} to comply with Cygnus rules.
4333 Here are the precise effects of @samp{--cygnus}:
4335 @itemize @bullet
4336 @item
4337 Info files are always created in the build directory, and not in the
4338 source directory.
4340 @item
4341 @file{texinfo.tex} is not required if a Texinfo source file is
4342 specified.  The assumption is that the file will be supplied, but in a
4343 place that Automake cannot find.  This assumption is an artifact of how
4344 Cygnus packages are typically bundled.
4346 @item
4347 @samp{make dist} is not supported, and the rules for it are not
4348 generated.  Cygnus-style trees use their own distribution mechanism.
4350 @item
4351 Certain tools will be searched for in the build tree as well as in the
4352 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
4353 @code{makeinfo} and @code{texi2dvi}.
4355 @item
4356 @code{--foreign} is implied.
4358 @item
4359 The options @samp{no-installinfo} and @samp{no-dependencies} are
4360 implied.
4362 @item
4363 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
4364 required.
4366 @item
4367 The @code{check} target doesn't depend on @code{all}.
4368 @end itemize
4370 GNU maintainers are advised to use @samp{gnu} strictness in preference
4371 to the special Cygnus mode.  Some day, perhaps, the differences between
4372 Cygnus trees and GNU trees will disappear (for instance, as GCC is made
4373 more standards compliant).  At that time the special Cygnus mode will be
4374 removed.
4377 @node Extending, Distributing, Cygnus, Top
4378 @chapter When Automake Isn't Enough
4380 Automake's implicit copying semantics means that many problems can be
4381 worked around by simply adding some @code{make} targets and rules to
4382 @file{Makefile.in}.  Automake will ignore these additions.
4384 @cindex -local targets
4385 @cindex local targets
4387 There are some caveats to doing this.  Although you can overload a
4388 target already used by Automake, it is often inadvisable, particularly
4389 in the topmost directory of a package with subdirectories.  However,
4390 various useful targets have a @samp{-local} version you can specify in
4391 your @file{Makefile.in}.  Automake will supplement the standard target
4392 with these user-supplied targets.
4394 @trindex  all-local
4395 @trindex  info-local
4396 @trindex  dvi-local
4397 @trindex  check-local
4398 @trindex  install-data-local
4399 @trindex  install-exec-local
4400 @trindex  uninstall-local
4401 @trindex  mostlyclean-local
4402 @trindex  clean-local
4403 @trindex  distclean-local
4404 @trindex  installdirs-local
4405 @trindex  installcheck-local
4407 The targets that support a local version are @code{all}, @code{info},
4408 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
4409 @code{uninstall}, @code{installdirs}, @code{installcheck} and the
4410 various @code{clean} targets (@code{mostlyclean}, @code{clean},
4411 @code{distclean}, and @code{maintainer-clean}).  Note that there are no
4412 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
4413 use @code{uninstall-local}.  It doesn't make sense to uninstall just
4414 data or just executables.
4415 @trindex all
4416 @trindex info
4417 @trindex dvi
4418 @trindex check
4419 @trindex install-data
4420 @trindex install-exec
4421 @trindex uninstall
4423 For instance, here is one way to install a file in @file{/etc}:
4425 @example
4426 install-data-local:
4427         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
4428 @end example
4430 @cindex -hook targets
4431 @cindex hook targets
4433 Some targets also have a way to run another target, called a @dfn{hook},
4434 after their work is done.  The hook is named after the principal target,
4435 with @samp{-hook} appended.  The targets allowing hooks are
4436 @code{install-data}, @code{install-exec}, @code{uninstall}, @code{dist},
4437 and @code{distcheck}.
4438 @trindex install-data-hook
4439 @trindex install-exec-hook
4440 @trindex uninstall-hook
4441 @trindex dist-hook
4443 For instance, here is how to create a hard link to an installed program:
4445 @example
4446 install-exec-hook:
4447         ln $(bindir)/program $(bindir)/proglink
4448 @end example
4450 @c FIXME should include discussion of variables you can use in these
4451 @c rules
4454 @node Distributing, Macro and Variable Index, Extending, Top
4455 @chapter Distributing @file{Makefile.in}s
4457 Automake places no restrictions on the distribution of the resulting
4458 @file{Makefile.in}s.  We still encourage software authors to distribute
4459 their work under terms like those of the GPL, but doing so is not
4460 required to use Automake.
4462 Some of the files that can be automatically installed via the
4463 @code{--add-missing} switch do fall under the GPL.  However, these also
4464 have a special exception allowing you to distribute them with your
4465 package, regardless of the licensing you choose.
4468 @page
4469 @node Macro and Variable Index, General Index, Distributing, Top
4470 @unnumbered Macro and Variable Index
4472 @printindex vr
4475 @page
4476 @node General Index,  , Macro and Variable Index, Top
4477 @unnumbered General Index
4479 @printindex cp
4482 @page
4483 @contents
4484 @bye