Fix for PR automake/175:
[automake.git] / automake.texi
blobe655cbb00381e9af5fde2baf8f377062ca961600
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename automake.info
4 @settitle automake
5 @setchapternewpage off
6 @c %**end of header
8 @include version.texi
10 @dircategory GNU programming tools
11 @direntry
12 * automake: (automake).         Making Makefile.in's
13 @end direntry
15 @dircategory Individual utilities
16 @direntry
17 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4
18 @end direntry
20 @ifinfo
21 This file documents GNU automake @value{VERSION}
23 Copyright 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
25 Permission is granted to make and distribute verbatim copies of
26 this manual provided the copyright notice and this permission notice
27 are preserved on all copies.
29 @ignore
30 Permission is granted to process this file through TeX and print the
31 results, provided the printed document carries copying permission
32 notice identical to this one except for the removal of this paragraph
35 @end ignore
36 Permission is granted to copy and distribute modified versions of this
37 manual under the conditions for verbatim copying, provided that the entire
38 resulting derived work is distributed under the terms of a permission
39 notice identical to this one.
41 Permission is granted to copy and distribute translations of this manual
42 into another language, under the above conditions for modified versions,
43 except that this permission notice may be stated in a translation approved
44 by the Foundation.
45 @end ifinfo
48 @titlepage
49 @title GNU Automake
50 @subtitle For version @value{VERSION}, @value{UPDATED}
51 @author David MacKenzie and Tom Tromey
53 @page
54 @vskip 0pt plus 1filll
55 Copyright @copyright{} 1995, 1996, 2000, 2001 Free Software Foundation, Inc.
56 @sp 2
57 This is the first edition of the GNU Automake documentation,@*
58 and is consistent with GNU Automake @value{VERSION}.@*
59 @sp 2
60 Published by the Free Software Foundation @*
61 59 Temple Place - Suite 330, @*
62 Boston, MA 02111-1307 USA @*
64 Permission is granted to make and distribute verbatim copies of
65 this manual provided the copyright notice and this permission notice
66 are preserved on all copies.
68 Permission is granted to copy and distribute modified versions of this
69 manual under the conditions for verbatim copying, provided that the entire
70 resulting derived work is distributed under the terms of a permission
71 notice identical to this one.
73 Permission is granted to copy and distribute translations of this manual
74 into another language, under the above conditions for modified versions,
75 except that this permission notice may be stated in a translation
76 approved by the Free Software Foundation.
77 @end titlepage
79 @c Define an index of configure output variables.
80 @defcodeindex ov
81 @c Define an index of configure variables.
82 @defcodeindex cv
83 @c Define an index of options.
84 @defcodeindex op
85 @c Define an index of targets.
86 @defcodeindex tr
87 @c Define an index of commands.
88 @defcodeindex cm
90 @c Put the macros and variables into their own index.
91 @c @syncodeindex fn cp
92 @syncodeindex ov vr
93 @syncodeindex cv vr
94 @syncodeindex fn vr
96 @c Put everything else into one index (arbitrarily chosen to be the concept index).
97 @syncodeindex op cp
98 @syncodeindex tr cp
99 @syncodeindex cm cp
101 @ifnottex
102 @node Top, Introduction, (dir), (dir)
103 @comment  node-name,  next,  previous,  up
104 @top GNU Automake
106 This file documents the GNU Automake package.  Automake is a program
107 which creates GNU standards-compliant Makefiles from template files.
108 This edition documents version @value{VERSION}.
110 @menu
111 * Introduction::                Automake's purpose
112 * Generalities::                General ideas
113 * Examples::                    Some example packages
114 * Invoking Automake::           Creating a Makefile.in
115 * configure::                   Scanning configure.ac or configure.in
116 * Top level::                   The top-level Makefile.am
117 * Rebuilding::                  Automatic rebuilding of Makefile
118 * Programs::                    Building programs and libraries
119 * Other objects::               Other derived objects
120 * Other GNU Tools::             Other GNU Tools
121 * Documentation::               Building documentation
122 * Install::                     What gets installed
123 * Clean::                       What gets cleaned
124 * Dist::                        What goes in a distribution
125 * Tests::                       Support for test suites
126 * Options::                     Changing Automake's behavior
127 * Miscellaneous::               Miscellaneous rules
128 * Include::                     Including extra files in an Automake template.
129 * Conditionals::                Conditionals
130 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
131 * Cygnus::                      The effect of @code{--cygnus}
132 * Extending::                   Extending Automake
133 * Distributing::                Distributing the Makefile.in
134 * Macro and Variable Index::
135 * General Index::
136 @end menu
138 @end ifnottex
141 @node Introduction, Generalities, Top, Top
142 @chapter Introduction
144 Automake is a tool for automatically generating @file{Makefile.in}s from
145 files called @file{Makefile.am}.  Each @file{Makefile.am} is basically a
146 series of @code{make} macro definitions (with rules being thrown in
147 occasionally).  The generated @file{Makefile.in}s are compliant with the
148 GNU Makefile standards.
150 @cindex GNU Makefile standards
152 The GNU Makefile Standards Document
153 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
154 is long, complicated, and subject to change.  The goal of Automake is to
155 remove the burden of Makefile maintenance from the back of the
156 individual GNU maintainer (and put it on the back of the Automake
157 maintainer).
159 The typical Automake input file is simply a series of macro definitions.
160 Each such file is processed to create a @file{Makefile.in}.  There
161 should generally be one @file{Makefile.am} per directory of a project.
163 @cindex Constraints of Automake
164 @cindex Automake constraints
166 Automake does constrain a project in certain ways; for instance it
167 assumes that the project uses Autoconf (@pxref{Top, , Introduction,
168 autoconf, The Autoconf Manual}), and enforces certain restrictions on
169 the @file{configure.in} contents@footnote{Autoconf 2.50 promotes
170 @file{configure.ac} over @file{configure.in}.  The rest of this
171 documentation will refer to @file{configure.in} as this use is not yet
172 spread, but Automake supports @file{configure.ac} too.}.
174 @cindex Automake requirements
175 @cindex Requirements, Automake
177 Automake requires @code{perl} in order to generate the
178 @file{Makefile.in}s.  However, the distributions created by Automake are
179 fully GNU standards-compliant, and do not require @code{perl} in order
180 to be built.
182 @cindex BUGS, reporting
183 @cindex Reporting BUGS
184 @cindex E-mail, bug reports
186 Mail suggestions and bug reports for Automake to
187 @email{bug-automake@@gnu.org}.
190 @node Generalities, Examples, Introduction, Top
191 @chapter General ideas
193 The following sections cover a few basic ideas that will help you
194 understand how Automake works.
196 @menu
197 * General Operation::           General operation of Automake
198 * Strictness::                  Standards conformance checking
199 * Uniform::                     The Uniform Naming Scheme
200 * Canonicalization::            How derived variables are named
201 * User Variables::              Variables reserved for the user
202 @end menu
205 @node General Operation, Strictness, Generalities, Generalities
206 @section General Operation
208 Automake works by reading a @file{Makefile.am} and generating a
209 @file{Makefile.in}.  Certain macros and targets defined in the
210 @file{Makefile.am} instruct Automake to generate more specialized code;
211 for instance, a @samp{bin_PROGRAMS} macro definition will cause targets
212 for compiling and linking programs to be generated.
214 @cindex Non-standard targets
215 @cindex cvs-dist, non-standard example
216 @trindex cvs-dist
218 The macro definitions and targets in the @file{Makefile.am} are copied
219 verbatim into the generated file.  This allows you to add arbitrary code
220 into the generated @file{Makefile.in}.  For instance the Automake
221 distribution includes a non-standard @code{cvs-dist} target, which the
222 Automake maintainer uses to make distributions from his source control
223 system.
225 @cindex GNU make extensions
227 Note that GNU make extensions are not recognized by Automake.  Using
228 such extensions in a @file{Makefile.am} will lead to errors or confusing
229 behavior.
231 Automake tries to group comments with adjoining targets and macro
232 definitions in an intelligent way.
234 @cindex Make targets, overriding
235 @cindex Overriding make targets
237 A target defined in @file{Makefile.am} generally overrides any such
238 target of a similar name that would be automatically generated by
239 @code{automake}.  Although this is a supported feature, it is generally
240 best to avoid making use of it, as sometimes the generated rules are
241 very particular.
243 @cindex Macros, overriding
244 @cindex Overriding make macros
246 Similarly, a macro defined in @file{Makefile.am} will override any
247 definition of the macro that @code{automake} would ordinarily create.
248 This feature is more often useful than the ability to override a target
249 definition.  Be warned that many of the macros generated by
250 @code{automake} are considered to be for internal use only, and their
251 names might change in future releases.
253 @cindex Recursive operation of Automake
254 @cindex Automake, recursive operation
255 @cindex Example of recursive operation
257 When examining a macro definition, Automake will recursively examine
258 macros referenced in the definition.  For example, if Automake is
259 looking at the content of @code{foo_SOURCES} in this snippet
261 @example
262 xs = a.c b.c
263 foo_SOURCES = c.c $(xs)
264 @end example
266 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
267 contents of @code{foo_SOURCES}.
269 @cindex ## (special Automake comment)
270 @cindex Special Automake comment
271 @cindex Comment, special to Automake
273 Automake also allows a form of comment which is @emph{not} copied into
274 the output; all lines beginning with @samp{##} (leading spaces allowed)
275 are completely ignored by Automake.
277 It is customary to make the first line of @file{Makefile.am} read:
279 @cindex Makefile.am, first line
280 @cindex First line of Makefile.am
282 @example
283 ## Process this file with automake to produce Makefile.in
284 @end example
286 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
287 @c I don't know quite what to say.
289 @c FIXME document customary ordering of Makefile.am here!
292 @node Strictness, Uniform, General Operation, Generalities
293 @section Strictness
295 @cindex Non-GNU packages
297 While Automake is intended to be used by maintainers of GNU packages, it
298 does make some effort to accommodate those who wish to use it, but do
299 not want to use all the GNU conventions.
301 @cindex Strictness, defined
302 @cindex Strictness, foreign
303 @cindex foreign strictness
304 @cindex Strictness, gnu
305 @cindex gnits strictness
306 @cindex Strictness, gnits
307 @cindex gnits strictness
309 To this end, Automake supports three levels of @dfn{strictness}---the
310 strictness indicating how stringently Automake should check standards
311 conformance.
313 The valid strictness levels are:
315 @table @samp
316 @item foreign
317 Automake will check for only those things which are absolutely
318 required for proper operations.  For instance, whereas GNU standards
319 dictate the existence of a @file{NEWS} file, it will not be required in
320 this mode.  The name comes from the fact that Automake is intended to be
321 used for GNU programs; these relaxed rules are not the standard mode of
322 operation.
324 @item gnu
325 Automake will check---as much as possible---for compliance to the GNU
326 standards for packages.  This is the default.
328 @item gnits
329 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
330 standards}.  These are based on the GNU standards, but are even more
331 detailed.  Unless you are a Gnits standards contributor, it is
332 recommended that you avoid this option until such time as the Gnits
333 standard is actually published (which may never happen).
334 @end table
336 For more information on the precise implications of the strictness
337 level, see @ref{Gnits}.
340 @node Uniform, Canonicalization, Strictness, Generalities
341 @section The Uniform Naming Scheme
343 @cindex Uniform naming scheme
345 Automake macros (from here on referred to as @emph{variables}) generally
346 follow a @dfn{uniform naming scheme} that makes it easy to decide how
347 programs (and other derived objects) are built, and how they are
348 installed.  This scheme also supports @code{configure} time
349 determination of what should be built.
351 @cindex _PROGRAMS primary variable
352 @cindex PROGRAMS primary variable
353 @cindex Primary variable, PROGRAMS
355 @cindex Primary variable, defined
357 At @code{make} time, certain variables are used to determine which
358 objects are to be built.  These variables are called @dfn{primary
359 variables}.  For instance, the primary variable @code{PROGRAMS} holds a
360 list of programs which are to be compiled and linked.
361 @vindex PROGRAMS
363 @cindex pkglibdir, defined
364 @cindex pkgincludedir, defined
365 @cindex pkgdatadir, defined
367 @vindex pkglibdir
368 @vindex pkgincludedir
369 @vindex pkgdatadir
371 A different set of variables is used to decide where the built objects
372 should be installed.  These variables are named after the primary
373 variables, but have a prefix indicating which standard directory should
374 be used as the installation directory.  The standard directory names are
375 given in the GNU standards (@pxref{Directory Variables, , , standards,
376 The GNU Coding Standards}).  Automake extends this list with
377 @code{pkglibdir}, @code{pkgincludedir}, and @code{pkgdatadir}; these are
378 the same as the non-@samp{pkg} versions, but with @samp{@@PACKAGE@@}
379 appended.  For instance, @code{pkglibdir} is defined as
380 @code{$(libdir)/@@PACKAGE@@}.
381 @cvindex PACKAGE
383 @cindex EXTRA_, prepending
385 For each primary, there is one additional variable named by prepending
386 @samp{EXTRA_} to the primary name.  This variable is used to list
387 objects which may or may not be built, depending on what
388 @code{configure} decides.  This variable is required because Automake
389 must statically know the entire list of objects that may be built in
390 order to generate a @file{Makefile.in} that will work in all cases.
392 @cindex EXTRA_PROGRAMS, defined
393 @cindex Example, EXTRA_PROGRAMS
394 @cindex cpio example
396 For instance, @code{cpio} decides at configure time which programs are
397 built.  Some of the programs are installed in @code{bindir}, and some
398 are installed in @code{sbindir}:
400 @example
401 EXTRA_PROGRAMS = mt rmt
402 bin_PROGRAMS = cpio pax
403 sbin_PROGRAMS = @@MORE_PROGRAMS@@
404 @end example
406 Defining a primary variable without a prefix (e.g. @code{PROGRAMS}) is
407 an error.
409 Note that the common @samp{dir} suffix is left off when constructing the
410 variable names; thus one writes @samp{bin_PROGRAMS} and not
411 @samp{bindir_PROGRAMS}.
413 Not every sort of object can be installed in every directory.  Automake
414 will flag those attempts it finds in error.  Automake will also diagnose
415 obvious misspellings in directory names.
417 @cindex Extending list of installation directories
418 @cindex Installation directories, extending list
420 Sometimes the standard directories---even as augmented by Automake---
421 are not enough.  In particular it is sometimes useful, for clarity, to
422 install objects in a subdirectory of some predefined directory.  To this
423 end, Automake allows you to extend the list of possible installation
424 directories.  A given prefix (e.g. @samp{zar}) is valid if a variable of
425 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
427 @cindex HTML support, example
429 For instance, until HTML support is part of Automake, you could use this
430 to install raw HTML documentation:
432 @example
433 htmldir = $(prefix)/html
434 html_DATA = automake.html
435 @end example
437 @cindex noinst primary prefix, definition
439 The special prefix @samp{noinst} indicates that the objects in question
440 should not be installed at all.
442 @cindex check primary prefix, definition
444 The special prefix @samp{check} indicates that the objects in question
445 should not be built until the @code{make check} command is run.
447 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
448 @samp{LISP}, @samp{PYTHON}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS},
449 @samp{MANS}, and @samp{TEXINFOS}.
450 @vindex PROGRAMS
451 @vindex LIBRARIES
452 @vindex LISP
453 @vindex PYTHON
454 @vindex SCRIPTS
455 @vindex DATA
456 @vindex HEADERS
457 @vindex MANS
458 @vindex TEXINFOS
460 Some primaries also allow additional prefixes which control other
461 aspects of @code{automake}'s behavior.  The currently defined prefixes
462 are @samp{dist_}, @samp{nodist_}, and @samp{nobase_}.  These prefixes
463 are explained later.
466 @node Canonicalization, User Variables, Uniform, Generalities
467 @section How derived variables are named
469 @cindex canonicalizing Automake macros
471 Sometimes a Makefile variable name is derived from some text the user
472 supplies.  For instance, program names are rewritten into Makefile macro
473 names.  Automake canonicalizes this text, so that it does not have to
474 follow Makefile macro naming rules.  All characters in the name except
475 for letters, numbers, the strudel (@@), and the underscore are turned into
476 underscores when making macro references.  For example, if your program
477 is named @code{sniff-glue}, the derived variable name would be
478 @code{sniff_glue_SOURCES}, not @code{sniff-glue_SOURCES}.  The strudel
479 is an addition since Automake 1.4c, to make the use of Autoconf
480 substitutions in macro names less obfuscating.
483 @node User Variables, , Canonicalization, Generalities
484 @section Variables reserved for the user
486 @cindex variables, reserved for the user
487 @cindex user variables
489 Some @code{Makefile} variables are reserved by the GNU Coding Standards
490 for the use of the ``user'' -- the person building the package.  For
491 instance, @code{CFLAGS} is one such variable.
493 Sometimes package developers are tempted to set user variables such as
494 @code{CFLAGS} because it appears to make their job easier -- they don't
495 have to introduce a second variable into every target.
497 However, the package itself should never set a user variable,
498 particularly not to include switches which are required for proper
499 compilation of the package.  Since these variables are documented as
500 being for the package builder, that person rightfully expects to be able
501 to override any of these variables at build time.
503 To get around this problem, automake introduces an automake-specific
504 shadow variable for each user flag variable.  (Shadow variables are not
505 introduced for variables like @code{CC}, where they would make no
506 sense.)  The shadow variable is named by prepending @samp{AM_} to the
507 user variable's name.  For instance, the shadow variable for
508 @code{YFLAGS} is @code{AM_YFLAGS}.
512 @node Examples, Invoking Automake, Generalities, Top
513 @chapter Some example packages
515 @menu
516 * Complete::                    A simple example, start to finish
517 * Hello::                       A classic program
518 * etags::                       Building etags and ctags
519 @end menu
522 @node Complete, Hello, Examples, Examples
523 @section A simple example, start to finish
525 @cindex Complete example
527 Let's suppose you just finished writing @code{zardoz}, a program to make
528 your head float from vortex to vortex.  You've been using Autoconf to
529 provide a portability framework, but your @file{Makefile.in}s have been
530 ad-hoc.  You want to make them bulletproof, so you turn to Automake.
532 @cindex AM_INIT_AUTOMAKE, example use
534 The first step is to update your @file{configure.in} to include the
535 commands that @code{automake} needs.  The way to do this is to add an
536 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
538 @example
539 AM_INIT_AUTOMAKE(zardoz, 1.0)
540 @end example
542 Since your program doesn't have any complicating factors (e.g., it
543 doesn't use @code{gettext}, it doesn't want to build a shared library),
544 you're done with this part.  That was easy!
546 @cindex aclocal program, introduction
547 @cindex aclocal.m4, preexisting
548 @cindex acinclude.m4, defined
550 Now you must regenerate @file{configure}.  But to do that, you'll need
551 to tell @code{autoconf} how to find the new macro you've used.  The
552 easiest way to do this is to use the @code{aclocal} program to generate
553 your @file{aclocal.m4} for you.  But wait... you already have an
554 @file{aclocal.m4}, because you had to write some hairy macros for your
555 program.  The @code{aclocal} program lets you put your own macros into
556 @file{acinclude.m4}, so simply rename and then run:
558 @example
559 mv aclocal.m4 acinclude.m4
560 aclocal
561 autoconf
562 @end example
564 @cindex zardoz example
566 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
567 Since @code{zardoz} is a user program, you want to install it where the
568 rest of the user programs go.  Additionally, @code{zardoz} has some
569 Texinfo documentation.  Your @file{configure.in} script uses
570 @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
571 So here's what you'd write:
573 @example
574 bin_PROGRAMS = zardoz
575 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
576 zardoz_LDADD = @@LIBOBJS@@
578 info_TEXINFOS = zardoz.texi
579 @end example
581 Now you can run @code{automake --add-missing} to generate your
582 @file{Makefile.in} and grab any auxiliary files you might need, and
583 you're done!
586 @node Hello, etags, Complete, Examples
587 @section A classic program
589 @cindex Example, GNU Hello
590 @cindex Hello example
591 @cindex GNU Hello, example
593 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
594 renowned for its classic simplicity and versatility.  This section shows
595 how Automake could be used with the GNU Hello package.  The examples
596 below are from the latest beta version of GNU Hello, but with all of the
597 maintainer-only code stripped out, as well as all copyright comments.
599 Of course, GNU Hello is somewhat more featureful than your traditional
600 two-liner.  GNU Hello is internationalized, does option processing, and
601 has a manual and a test suite.
603 @cindex configure.in, from GNU Hello
604 @cindex GNU Hello, configure.in
605 @cindex Hello, configure.in
607 Here is the @file{configure.in} from GNU Hello:
609 @example
610 dnl Process this file with autoconf to produce a configure script.
611 AC_INIT(src/hello.c)
612 AM_INIT_AUTOMAKE(hello, 1.3.11)
613 AM_CONFIG_HEADER(config.h)
615 dnl Set of available languages.
616 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
618 dnl Checks for programs.
619 AC_PROG_CC
620 AC_ISC_POSIX
622 dnl Checks for libraries.
624 dnl Checks for header files.
625 AC_STDC_HEADERS
626 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
628 dnl Checks for library functions.
629 AC_FUNC_ALLOCA
631 dnl Check for st_blksize in struct stat
632 AC_ST_BLKSIZE
634 dnl internationalization macros
635 AM_GNU_GETTEXT
636 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
637            src/Makefile tests/Makefile tests/hello],
638    [chmod +x tests/hello])
639 @end example
641 The @samp{AM_} macros are provided by Automake (or the Gettext library);
642 the rest are standard Autoconf macros.
645 The top-level @file{Makefile.am}:
647 @example
648 EXTRA_DIST = BUGS ChangeLog.O
649 SUBDIRS = doc intl po src tests
650 @end example
652 As you can see, all the work here is really done in subdirectories.
654 The @file{po} and @file{intl} directories are automatically generated
655 using @code{gettextize}; they will not be discussed here.
657 @cindex Texinfo file handling example
658 @cindex Example, handling Texinfo files
660 In @file{doc/Makefile.am} we see:
662 @example
663 info_TEXINFOS = hello.texi
664 hello_TEXINFOS = gpl.texi
665 @end example
667 This is sufficient to build, install, and distribute the GNU Hello
668 manual.
670 @cindex Regression test example
671 @cindex Example, regression test
673 Here is @file{tests/Makefile.am}:
675 @example
676 TESTS = hello
677 EXTRA_DIST = hello.in testdata
678 @end example
680 The script @file{hello} is generated by @code{configure}, and is the
681 only test case.  @code{make check} will run this test.
683 @cindex INCLUDES, example usage
685 Last we have @file{src/Makefile.am}, where all the real work is done:
687 @example
688 bin_PROGRAMS = hello
689 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
690 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
691 localedir = $(datadir)/locale
692 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
693 @end example
696 @node etags,  , Hello, Examples
697 @section Building etags and ctags
699 @cindex Example, ctags and etags
700 @cindex ctags Example
701 @cindex etags Example
703 Here is another, trickier example.  It shows how to generate two
704 programs (@code{ctags} and @code{etags}) from the same source file
705 (@file{etags.c}).  The difficult part is that each compilation of
706 @file{etags.c} requires different @code{cpp} flags.
708 @example
709 bin_PROGRAMS = etags ctags
710 ctags_SOURCES =
711 ctags_LDADD = ctags.o
713 etags.o: etags.c
714         $(COMPILE) -DETAGS_REGEXPS -c etags.c
716 ctags.o: etags.c
717         $(COMPILE) -DCTAGS -o ctags.o -c etags.c
718 @end example
720 Note that @code{ctags_SOURCES} is defined to be empty---that way no
721 implicit value is substituted.  The implicit value, however, is used to
722 generate @code{etags} from @file{etags.o}.
724 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
725 @code{ctags_DEPENDENCIES} is generated by Automake.
727 The above rules won't work if your compiler doesn't accept both
728 @samp{-c} and @samp{-o}.  The simplest fix for this is to introduce a
729 bogus dependency (to avoid problems with a parallel @code{make}):
731 @example
732 etags.o: etags.c ctags.o
733         $(COMPILE) -DETAGS_REGEXPS -c etags.c
735 ctags.o: etags.c
736         $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
737 @end example
739 Also, these explicit rules do not work if the de-ANSI-fication feature
740 is used (@pxref{ANSI}).  Supporting de-ANSI-fication requires a little
741 more work:
743 @example
744 etags._o: etags._c ctags.o
745         $(COMPILE) -DETAGS_REGEXPS -c etags.c
747 ctags._o: etags._c
748         $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o
749 @end example
752 @node Invoking Automake, configure, Examples, Top
753 @chapter Creating a @file{Makefile.in}
755 @cindex Multiple configure.in files
756 @cindex Invoking Automake
757 @cindex Automake, invoking
759 To create all the @file{Makefile.in}s for a package, run the
760 @code{automake} program in the top level directory, with no arguments.
761 @code{automake} will automatically find each appropriate
762 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
763 and generate the corresponding @file{Makefile.in}.  Note that
764 @code{automake} has a rather simplistic view of what constitutes a
765 package; it assumes that a package has only one @file{configure.in}, at
766 the top.  If your package has multiple @file{configure.in}s, then you
767 must run @code{automake} in each directory holding a
768 @file{configure.in}.
770 You can optionally give @code{automake} an argument; @file{.am} is
771 appended to the argument and the result is used as the name of the input
772 file.  This feature is generally only used to automatically rebuild an
773 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
774 be run from the topmost directory of a project, even if being used to
775 regenerate the @file{Makefile.in} in some subdirectory.  This is
776 necessary because @code{automake} must scan @file{configure.in}, and
777 because @code{automake} uses the knowledge that a @file{Makefile.in} is
778 in a subdirectory to change its behavior in some cases.
780 @cindex Automake options
781 @cindex Options, Automake
783 @code{automake} accepts the following options:
785 @cindex Extra files distributed with Automake
786 @cindex Files distributed with Automake
787 @cindex config.guess
789 @table @samp
790 @item -a
791 @itemx --add-missing
792 @opindex -a
793 @opindex --add-missing
794 Automake requires certain common files to exist in certain situations;
795 for instance @file{config.guess} is required if @file{configure.in} runs
796 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
797 files; this option will cause the missing ones to be automatically added
798 to the package, whenever possible.  In general if Automake tells you a
799 file is missing, try using this option.  By default Automake tries to
800 make a symbolic link pointing to its own copy of the missing file; this
801 can be changed with @code{--copy}.
803 @item --libdir=@var{dir}
804 @opindex --libdir
805 Look for Automake data files in directory @var{dir} instead of in the
806 installation directory.  This is typically used for debugging.
808 @item -c
809 @opindex -c
810 @itemx --copy
811 @opindex --copy
812 When used with @code{--add-missing}, causes installed files to be
813 copied.  The default is to make a symbolic link.
815 @item --cygnus
816 @opindex --cygnus
817 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
818 of GNU or Gnits rules.  For more information, see @ref{Cygnus}.
820 @item -f
821 @opindex -f
822 @itemx --force-missing
823 @opindex --force-missing
824 When used with @code{--add-missing}, causes standard files to be rebuilt
825 even if they already exist in the source tree.  This involves removing
826 the file from the source tree before creating the new symlink (or, with
827 @code{--copy}, copying the new file).
829 @item --foreign
830 @opindex --foreign
831 Set the global strictness to @samp{foreign}.  For more information, see
832 @ref{Strictness}.
834 @item --gnits
835 @opindex --gnits
836 Set the global strictness to @samp{gnits}.  For more information, see
837 @ref{Gnits}.
839 @item --gnu
840 @opindex --gnu
841 Set the global strictness to @samp{gnu}.  For more information, see
842 @ref{Gnits}.  This is the default strictness.
844 @item --help
845 @opindex --help
846 Print a summary of the command line options and exit.
848 @item -i
849 @itemx --include-deps
850 @opindex -i
851 @opindex --include-deps
852 Include all automatically generated dependency information
853 (@pxref{Dependencies}) in the generated
854 @file{Makefile.in}.  This is generally done when making a distribution;
855 see @ref{Dist}.
857 @item --no-force
858 @opindex --no-force
859 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
860 @file{configure.in}.  This option causes it to only update those
861 @file{Makefile.in}s which are out of date with respect to one of their
862 dependents.
864 @item -o @var{dir}
865 @itemx --output-dir=@var{dir}
866 @opindex -o
867 @opindex --output-dir
868 Put the generated @file{Makefile.in} in the directory @var{dir}.
869 Ordinarily each @file{Makefile.in} is created in the directory of the
870 corresponding @file{Makefile.am}.  This option is used when making
871 distributions.
873 @item -v
874 @itemx --verbose
875 @opindex -v
876 @opindex --verbose
877 Cause Automake to print information about which files are being read or
878 created.
880 @item --version
881 @opindex --version
882 Print the version number of Automake and exit.
883 @end table
886 @node configure, Top level, Invoking Automake, Top
887 @chapter Scanning @file{configure.in}
889 @cindex configure.in, scanning
890 @cindex Scanning configure.in
892 Automake scans the package's @file{configure.in} to determine certain
893 information about the package.  Some @code{autoconf} macros are required
894 and some variables must be defined in @file{configure.in}.  Automake
895 will also use information from @file{configure.in} to further tailor its
896 output.
898 Automake also supplies some Autoconf macros to make the maintenance
899 easier.  These macros can automatically be put into your
900 @file{aclocal.m4} using the @code{aclocal} program.
902 @menu
903 * Requirements::                Configuration requirements
904 * Optional::                    Other things Automake recognizes
905 * Invoking aclocal::            Auto-generating aclocal.m4
906 * Macros::                      Autoconf macros supplied with Automake
907 * Extending aclocal::           Writing your own aclocal macros
908 @end menu
911 @node Requirements, Optional, configure, configure
912 @section Configuration requirements
914 @cindex Automake requirements
915 @cindex Requirements of Automake
917 The one real requirement of Automake is that your @file{configure.in}
918 call @code{AM_INIT_AUTOMAKE}.  This macro does several things which are
919 required for proper Automake operation.
920 @cvindex AM_INIT_AUTOMAKE
922 Here are the other macros which Automake requires but which are not run
923 by @code{AM_INIT_AUTOMAKE}:
925 @cindex AC_OUTPUT, scanning
927 @table @code
928 @item AC_OUTPUT
929 Automake uses this to determine which files to create (@pxref{Output, ,
930 Creating Output Files, autoconf, The Autoconf Manual}).  Listed files
931 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
932 files are treated differently.  Currently the only difference is that a
933 @file{Makefile} is removed by @code{make distclean}, while other files
934 are removed by @code{make clean}.
935 @c FIXME: this is in violation of standards!
936 @cvindex AC_OUTPUT
937 @end table
940 @node Optional, Invoking aclocal, Requirements, configure
941 @section Other things Automake recognizes
943 @cindex Macros Automake recognizes
944 @cindex Recognized macros by Automake
946 Automake will also recognize the use of certain macros and tailor the
947 generated @file{Makefile.in} appropriately.  Currently recognized macros
948 and their effects are:
950 @table @code
951 @item AC_CONFIG_HEADER
952 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
953 to @code{AC_CONFIG_HEADER} (@pxref{Configuration Headers, ,
954 Configuration Header Files, autoconf, The Autoconf Manual}), but does
955 some useful Automake-specific work.
956 @cvindex AC_CONFIG_HEADER
958 @item AC_CONFIG_AUX_DIR
959 Automake will look for various helper scripts, such as
960 @file{mkinstalldirs}, in the directory named in this macro invocation.
961 If not seen, the scripts are looked for in their @samp{standard}
962 locations (either the top source directory, or in the source directory
963 corresponding to the current @file{Makefile.am}, whichever is
964 appropriate).  @xref{Input, , Finding `configure' Input, autoconf, The
965 Autoconf Manual}.
966 @cvindex AC_CONFIG_AUX_DIR
967 FIXME: give complete list of things looked for in this directory
969 @item AC_PATH_XTRA
970 Automake will insert definitions for the variables defined by
971 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
972 or library.  @xref{System Services, , System Services, autoconf, The
973 Autoconf Manual}.
974 @cvindex AC_PATH_XTRA
976 @item AC_CANONICAL_HOST
977 @itemx AC_CHECK_TOOL
978 Automake will ensure that @file{config.guess} and @file{config.sub}
979 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
980 @samp{host_triplet} are introduced.  See both @ref{Canonicalizing, ,
981 Getting the Canonical System Type, autoconf, The Autoconf Manual}, and
982 @ref{Generic Programs, , Generic Program Checks, autoconf, The Autoconf
983 Manual}.
984 @c fixme xref autoconf docs.
985 @cvindex AC_CANONICAL_HOST
986 @cvindex AC_CHECK_TOOL
987 @vindex host_alias
988 @vindex host_triplet
990 @item AC_CANONICAL_SYSTEM
991 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
992 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
993 @xref{Canonicalizing, , Getting the Canonical System Type, autoconf, The
994 Autoconf Manual}.
995 @cvindex AC_CANONICAL_SYSTEM
996 @vindex build_alias
997 @vindex target_alias
999 @item AC_FUNC_ALLOCA
1000 @itemx AC_FUNC_GETLOADAVG
1001 @itemx AC_FUNC_MEMCMP
1002 @itemx AC_STRUCT_ST_BLOCKS
1003 @itemx AC_FUNC_FNMATCH
1004 @itemx AC_FUNC_MKTIME
1005 @itemx AM_FUNC_STRTOD
1006 @itemx AC_REPLACE_FUNCS
1007 @itemx AC_REPLACE_GNU_GETOPT
1008 @itemx AM_WITH_REGEX
1009 Automake will ensure that the appropriate dependencies are generated for
1010 the objects corresponding to these macros.  Also, Automake will verify
1011 that the appropriate source files are part of the distribution.  Note
1012 that Automake does not come with any of the C sources required to use
1013 these macros, so @code{automake -a} will not install the sources.
1014 @xref{A Library}, for more information.  Also, see @ref{Particular
1015 Functions, , Particular Function Checks, autoconf, The Autoconf Manual}.
1016 @cvindex AC_FUNC_ALLOCA
1017 @cvindex AC_FUNC_GETLOADAVG
1018 @cvindex AC_FUNC_MEMCMP
1019 @cvindex AC_STRUCT_ST_BLOCKS
1020 @cvindex AC_FUNC_FNMATCH
1021 @cvindex AC_FUNC_FNMATCH
1022 @cvindex AC_REPLACE_FUNCS
1023 @cvindex AC_REPLACE_GNU_GETOPT
1024 @cvindex AM_FUNC_STRTOD
1025 @cvindex AM_WITH_REGEX
1026 @cvindex AC_FUNC_MKTIME
1028 @item LIBOBJS
1029 Automake will detect statements which put @file{.o} files into
1030 @code{LIBOBJS}, and will treat these additional files as if they were
1031 discovered via @code{AC_REPLACE_FUNCS}.  @xref{Generic Functions, ,
1032 Generic Function Checks, autoconf, The Autoconf Manual}.
1033 @cvindex LIBOBJS
1035 @item AC_PROG_RANLIB
1036 This is required if any libraries are built in the package.
1037 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1038 Autoconf Manual}.
1039 @cvindex AC_PROG_RANLIB
1041 @item AC_PROG_CXX
1042 This is required if any C++ source is included.  @xref{Particular
1043 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1044 @cvindex AC_PROG_CXX
1046 @item AC_PROG_F77
1047 This is required if any Fortran 77 source is included.  This macro is
1048 distributed with Autoconf version 2.13 and later.  @xref{Particular
1049 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1050 @cvindex AC_PROG_F77
1052 @item AC_F77_LIBRARY_LDFLAGS
1053 This is required for programs and shared libraries that are a mixture of
1054 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1055 C++}).  @xref{Macros, , Autoconf macros supplied with Automake}.
1056 @cvindex AC_F77_LIBRARY_LDFLAGS
1058 @item AC_PROG_LIBTOOL
1059 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1060 Introduction, libtool, The Libtool Manual}).
1061 @cvindex AC_PROG_LIBTOOL
1063 @item AC_PROG_YACC
1064 If a Yacc source file is seen, then you must either use this macro or
1065 define the variable @samp{YACC} in @file{configure.in}.  The former is
1066 preferred (@pxref{Particular Programs, , Particular Program Checks,
1067 autoconf, The Autoconf Manual}).
1068 @cvindex AC_PROG_YACC
1069 @cvindex YACC
1071 @item AC_DECL_YYTEXT
1072 This macro is required if there is Lex source in the package.
1073 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1074 Autoconf Manual}.
1075 @cvindex AC_DECL_YYTEXT
1077 @item AC_PROG_LEX
1078 If a Lex source file is seen, then this macro must be used.
1079 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1080 Autoconf Manual}.
1081 @cvindex AC_PROG_LEX
1083 @item ALL_LINGUAS
1084 If Automake sees that this variable is set in @file{configure.in}, it
1085 will check the @file{po} directory to ensure that all the named
1086 @samp{.po} files exist, and that all the @samp{.po} files that exist are
1087 named.
1088 @cvindex ALL_LINGUAS
1090 @item AM_C_PROTOTYPES
1091 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1092 @cvindex AM_C_PROTOTYPES
1094 @item AM_GNU_GETTEXT
1095 This macro is required for packages which use GNU gettext
1096 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
1097 this macro it ensures that the package meets some of gettext's
1098 requirements.
1099 @cvindex AM_GNU_GETTEXT
1101 @item AM_MAINTAINER_MODE
1102 @opindex --enable-maintainer-mode
1103 This macro adds a @samp{--enable-maintainer-mode} option to
1104 @code{configure}.  If this is used, @code{automake} will cause
1105 @samp{maintainer-only} rules to be turned off by default in the
1106 generated @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits}
1107 mode (@pxref{Gnits}).  This macro defines the @samp{MAINTAINER_MODE}
1108 conditional, which you can use in your own @file{Makefile.am}.
1109 @cvindex AM_MAINTAINER_MODE
1111 @item AC_SUBST
1112 @itemx AC_CHECK_TOOL
1113 @itemx AC_CHECK_PROG
1114 @itemx AC_CHECK_PROGS
1115 @itemx AC_PATH_PROG
1116 @itemx AC_PATH_PROGS
1117 For each of these macros, the first argument is automatically defined as
1118 a variable in each generated @file{Makefile.in}.  @xref{Setting Output
1119 Variables, , Setting Output Variables, autoconf, The Autoconf Manual},
1120 and @ref{Generic Programs, , Generic Program Checks, autoconf, The
1121 Autoconf Manual}.
1122 @cvindex AC_SUBST
1123 @cvindex AC_CHECK_TOOL
1124 @cvindex AC_CHECK_PROG
1125 @cvindex AC_CHECK_PROGS
1126 @cvindex AC_PATH_PROG
1127 @cvindex AC_PATH_PROGS
1129 @end table
1132 @node Invoking aclocal, Macros, Optional, configure
1133 @section Auto-generating aclocal.m4
1135 @cindex Invoking aclocal
1136 @cindex aclocal, Invoking
1138 Automake includes a number of Autoconf macros which can be used in your
1139 package; some of them are actually required by Automake in certain
1140 situations.  These macros must be defined in your @file{aclocal.m4};
1141 otherwise they will not be seen by @code{autoconf}.
1143 The @code{aclocal} program will automatically generate @file{aclocal.m4}
1144 files based on the contents of @file{configure.in}.  This provides a
1145 convenient way to get Automake-provided macros, without having to
1146 search around.  Also, the @code{aclocal} mechanism is extensible for use
1147 by other packages.
1149 At startup, @code{aclocal} scans all the @file{.m4} files it can find,
1150 looking for macro definitions.  Then it scans @file{configure.in}.  Any
1151 mention of one of the macros found in the first step causes that macro,
1152 and any macros it in turn requires, to be put into @file{aclocal.m4}.
1154 The contents of @file{acinclude.m4}, if it exists, are also
1155 automatically included in @file{aclocal.m4}.  This is useful for
1156 incorporating local macros into @file{configure}.
1158 @code{aclocal} tries to be smart about looking for new @code{AC_DEFUN}s
1159 in the files it scans.  It will warn if it finds duplicates.  It also
1160 tries to copy the full text of the scanned file into @file{aclocal.m4},
1161 including both @samp{#} and @samp{dnl} comments.  If you want to make a
1162 comment which will be completely ignored by @code{aclocal}, use
1163 @samp{##} as the comment leader.
1165 @code{aclocal} accepts the following options:
1167 @table @code
1168 @item --acdir=@var{dir}
1169 @opindex --acdir
1170 Look for the macro files in @var{dir} instead of the installation
1171 directory.  This is typically used for debugging.
1173 @item --help
1174 @opindex --help
1175 Print a summary of the command line options and exit.
1177 @item -I @var{dir}
1178 @opindex -I
1179 Add the directory @var{dir} to the list of directories searched for
1180 @file{.m4} files.
1182 @item --output=@var{file}
1183 @opindex --output
1184 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1186 @item --print-ac-dir
1187 @opindex --print-ac-dir
1188 Prints the name of the directory which @code{aclocal} will search to
1189 find the @file{.m4} files.  When this option is given, normal processing
1190 is suppressed.  This option can be used by a package to determine where
1191 to install a macro file.
1193 @item --verbose
1194 @opindex --verbose
1195 Print the names of the files it examines.
1197 @item --version
1198 @opindex --version
1199 Print the version number of Automake and exit.
1200 @end table
1203 @node Macros, Extending aclocal, Invoking aclocal, configure
1204 @section Autoconf macros supplied with Automake
1206 @c consider generating this node automatically from m4 files.
1208 @table @code
1209 @item AM_CONFIG_HEADER
1210 Automake will generate rules to automatically regenerate the config
1211 header.  If you do use this macro, you must create the file
1212 @file{stamp-h.in} in your source directory.  It can be empty.
1213 @cvindex AM_CONFIG_HEADER
1215 @item AM_ENABLE_MULTILIB
1216 This is used when a ``multilib'' library is being built.  A
1217 @dfn{multilib} library is one that is built multiple times, once per
1218 target flag combination.  This is only useful when the library is
1219 intended to be cross-compiled.  The first optional argument is the name
1220 of the @file{Makefile} being generated; it defaults to @samp{Makefile}.
1221 The second option argument is used to find the top source directory; it
1222 defaults to the empty string (generally this should not be used unless
1223 you are familiar with the internals).
1225 @item AM_FUNC_STRTOD
1226 If the @code{strtod} function is not available, or does not work
1227 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
1228 variable @code{LIBOBJS}.
1229 @cvindex AM_FUNC_STRTOD
1231 @item AM_FUNC_ERROR_AT_LINE
1232 If the function @code{error_at_line} is not found, then add
1233 @file{error.o} to @code{LIBOBJS}.
1234 @cvindex AM_FUNC_ERROR_AT_LINE
1236 @item AM_FUNC_OBSTACK
1237 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
1238 @samp{LIBOBJS}.
1239 @cvindex AM_FUNC_OBSTACK
1241 @item AM_C_PROTOTYPES
1242 Check to see if function prototypes are understood by the compiler.  If
1243 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1244 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
1245 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
1246 values to implement automatic de-ANSI-fication.
1247 @cvindex AM_C_PROTOTYPES
1249 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1250 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1251 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
1252 found in @file{<termios.h>}.
1253 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1255 @item AM_INIT_AUTOMAKE
1256 Runs many macros that most @file{configure.in}'s need.  This macro has
1257 two required arguments, the package and the version number.  By default
1258 this macro @code{AC_DEFINE}'s @samp{PACKAGE} and @samp{VERSION}.  This
1259 can be avoided by passing in a non-empty third argument.
1261 @item AM_PATH_LISPDIR
1262 Searches for the program @code{emacs}, and, if found, sets the output
1263 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1264 @cvindex AM_PATH_LISPDIR
1266 @item AM_PROG_CC_STDC
1267 If the C compiler in not in ANSI C mode by default, try to add an option
1268 to output variable @code{CC} to make it so.  This macro tries various
1269 options that select ANSI C on some system or another.  It considers the
1270 compiler to be in ANSI C mode if it handles function prototypes correctly.
1272 If you use this macro, you should check after calling it whether the C
1273 compiler has been set to accept ANSI C; if not, the shell variable
1274 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
1275 code in ANSI C, you can make an un-ANSIfied copy of it by using the
1276 @code{ansi2knr} option (@pxref{ANSI}).
1278 @item AM_PROG_LEX
1279 @cindex HP-UX 10, lex problems
1280 @cindex lex problems with HP-UX 10
1281 Like @code{AC_PROG_LEX} with @code{AC_DECL_YYTEXT} (@pxref{Particular
1282 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}),
1283 but uses the @code{missing} script on systems that do not have
1284 @code{lex}.  @samp{HP-UX 10} is one such system.
1286 @item AM_PROG_GCJ
1287 This macro finds the @code{gcj} program or causes an error.  It sets
1288 @samp{GCJ} and @samp{GCJFLAGS}.  @code{gcj} is the Java front-end to the
1289 GNU C compiler.
1290 @cvindex AM_PROG_GCJ
1292 @item AM_SANITY_CHECK
1293 This checks to make sure that a file created in the build directory is
1294 newer than a file in the source directory.  This can fail on systems
1295 where the clock is set incorrectly.  This macro is automatically run
1296 from @code{AM_INIT_AUTOMAKE}.
1298 @item AM_SYS_POSIX_TERMIOS
1299 @cvindex am_cv_sys_posix_termios
1300 @cindex POSIX termios headers
1301 @cindex termios POSIX headers
1302 Check to see if POSIX termios headers and functions are available on the
1303 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1304 @samp{yes}.  If not, set the variable to @samp{no}.
1306 @item AM_TYPE_PTRDIFF_T
1307 @cvindex HAVE_PTRDIFF_T
1308 @vindex ptrdiff_t
1309 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
1310 @file{<stddef.h>}.
1312 @item AM_WITH_DMALLOC
1313 @cvindex WITH_DMALLOC
1314 @cindex dmalloc, support for
1315 @opindex --with-dmalloc
1316 Add support for the
1317 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1318 package.  If the user configures with @samp{--with-dmalloc}, then define
1319 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1321 @item AM_WITH_REGEX
1322 @cvindex WITH_REGEX
1323 @opindex --with-regex
1324 @cindex regex package
1325 @cindex rx package
1326 Adds @samp{--with-regex} to the @code{configure} command line.  If
1327 specified (the default), then the @samp{regex} regular expression
1328 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1329 @samp{WITH_REGEX} is defined..  If @samp{--without-regex} is given, then
1330 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1331 into @samp{LIBOBJS}.
1333 @end table
1336 @node Extending aclocal,  , Macros, configure
1337 @section Writing your own aclocal macros
1339 @cindex aclocal, extending
1340 @cindex Extending aclocal
1342 The @code{aclocal} program doesn't have any built-in knowledge of any
1343 macros, so it is easy to extend it with your own macros.
1345 This is mostly used for libraries which want to supply their own
1346 Autoconf macros for use by other programs.  For instance the
1347 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1348 should be used by any package using @code{gettext}.  When the library is
1349 installed, it installs this macro so that @code{aclocal} will find it.
1351 A file of macros should be a series of @code{AC_DEFUN}'s.  The
1352 @code{aclocal} programs also understands @code{AC_REQUIRE}, so it is
1353 safe to put each macro in a separate file.  @xref{Prerequisite Macros, ,
1354 , autoconf, The Autoconf Manual}, and @ref{Macro Definitions, , ,
1355 autoconf, The Autoconf Manual}.
1357 A macro file's name should end in @file{.m4}.  Such files should be
1358 installed in @file{$(datadir)/aclocal}.
1361 @node Top level, Rebuilding, configure, Top
1362 @chapter The top-level @file{Makefile.am}
1364 @cindex SUBDIRS, explained
1366 In packages with subdirectories, the top level @file{Makefile.am} must
1367 tell Automake which subdirectories are to be built.  This is done via
1368 the @code{SUBDIRS} variable.
1369 @vindex SUBDIRS
1371 The @code{SUBDIRS} macro holds a list of subdirectories in which
1372 building of various sorts can occur.  Many targets (e.g. @code{all}) in
1373 the generated @file{Makefile} will run both locally and in all specified
1374 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1375 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1376 (after configuration).  This allows inclusion of libraries from packages
1377 which do not use Automake (such as @code{gettext}).  The directories
1378 mentioned in @code{SUBDIRS} must be direct children of the current
1379 directory.  For instance, you cannot put @samp{src/subdir} into
1380 @code{SUBDIRS}.
1382 In packages that use subdirectories, the top-level @file{Makefile.am} is
1383 often very short.  For instance, here is the @file{Makefile.am} from the
1384 GNU Hello distribution:
1386 @example
1387 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1388 SUBDIRS = doc intl po src tests
1389 @end example
1391 @cindex SUBDIRS, overriding
1392 @cindex Overriding SUBDIRS
1394 It is possible to override the @code{SUBDIRS} variable if, like in the
1395 case of GNU @code{Inetutils}, you want to only build a subset of the
1396 entire package.  In your @file{Makefile.am} include:
1398 @example
1399 SUBDIRS = @@MY_SUBDIRS@@
1400 @end example
1402 Then in your @file{configure.in} you can specify:
1404 @example
1405 MY_SUBDIRS = "src doc lib po"
1406 AC_SUBST(MY_SUBDIRS)
1407 @end example
1409 (Note that we don't use the variable name @code{SUBDIRS} in our
1410 @file{configure.in}; that would cause Automake to believe that every
1411 @file{Makefile.in} should recurse into the listed subdirectories.)
1413 The upshot of this is that Automake is tricked into building the package
1414 to take the subdirs, but doesn't actually bind that list until
1415 @code{configure} is run.
1417 Although the @code{SUBDIRS} macro can contain configure substitutions
1418 (e.g. @samp{@@DIRS@@}); Automake itself does not actually examine the
1419 contents of this variable.
1421 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1422 @code{AC_PROG_MAKE_SET}.
1424 The use of @code{SUBDIRS} is not restricted to just the top-level
1425 @file{Makefile.am}.  Automake can be used to construct packages of
1426 arbitrary depth.
1428 By default, Automake generates @file{Makefiles} which work depth-first
1429 (@samp{postfix}).  However, it is possible to change this ordering.  You
1430 can do this by putting @samp{.} into @code{SUBDIRS}.  For instance,
1431 putting @samp{.}  first will cause a @samp{prefix} ordering of
1432 directories.
1434 Sometimes, such as when running @code{make dist}, you want all possible
1435 subdirectories to be examined.  In this case Automake will use
1436 @code{DIST_SUBDIRS}, instead of @code{SUBDIRS}, to determine where to
1437 recurse.  This variable will also be used when the user runs
1438 @code{distclean} or @code{maintainer-clean}.  It should be set to the
1439 full list of subdirectories in the project.  If this macro is not set,
1440 Automake will attempt to set it for you.
1443 @node Rebuilding, Programs, Top level, Top
1444 @chapter Rebuilding Makefiles
1446 Automake generates rules to automatically rebuild @file{Makefile}s,
1447 @file{configure}, and other derived files like @file{Makefile.in}.
1449 If you are using @code{AM_MAINTAINER_MODE} in @file{configure.in}, then
1450 these automatic rebuilding rules are only enabled in maintainer mode.
1452 Sometimes you need to run @code{aclocal} with an argument like @code{-I}
1453 to tell it where to find @file{.m4} files.  Since sometimes @code{make}
1454 will automatically run @code{aclocal}, you need a way to specify these
1455 arguments.  You can do this by defining @code{ACLOCAL_AMFLAGS}; this
1456 holds arguments which are passed verbatim to @code{aclocal}.  This macro
1457 is only useful in the top-level @file{Makefile.am}.
1458 @cindex ACLOCAL_AMFLAGS
1461 @node Programs, Other objects, Rebuilding, Top
1462 @chapter Building Programs and Libraries
1464 A large part of Automake's functionality is dedicated to making it easy
1465 to build programs and libraries.
1467 @menu
1468 * A Program::                   Building a program
1469 * A Library::                   Building a library
1470 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1471 * A Shared Library::            Building a Libtool library
1472 * Program variables::           Variables used when building a program
1473 * Yacc and Lex::                Yacc and Lex support
1474 * C++ Support::
1475 * Fortran 77 Support::
1476 * Java Support::
1477 * Support for Other Languages::
1478 * ANSI::                        Automatic de-ANSI-fication
1479 * Dependencies::                Automatic dependency tracking
1480 @end menu
1483 @node A Program, A Library, Programs, Programs
1484 @section Building a program
1486 @cindex PROGRAMS, bindir
1487 @vindex bin_PROGRAMS
1488 @vindex sbin_PROGRAMS
1489 @vindex libexec_PROGRAMS
1490 @vindex pkglib_PROGRAMS
1491 @vindex noinst_PROGRAMS
1493 In a directory containing source that gets built into a program (as
1494 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1495 can be installed in @code{bindir}, @code{sbindir}, @code{libexecdir},
1496 @code{pkglibdir}, or not at all (@samp{noinst}).
1498 For instance:
1500 @example
1501 bin_PROGRAMS = hello
1502 @end example
1504 In this simple case, the resulting @file{Makefile.in} will contain code
1505 to generate a program named @code{hello}.  The variable
1506 @code{hello_SOURCES} is used to specify which source files get built
1507 into an executable:
1509 @example
1510 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
1511 @end example
1513 This causes each mentioned @samp{.c} file to be compiled into the
1514 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1516 @cindex _SOURCES primary, defined
1517 @cindex SOURCES primary, defined
1518 @cindex Primary variable, SOURCES
1520 If @samp{@var{prog}_SOURCES} is needed, but not specified, then it
1521 defaults to the single file @file{prog.c}.
1522 @vindex _SOURCES
1523 @vindex SOURCES
1525 Multiple programs can be built in a single directory.  Multiple programs
1526 can share a single source file, which must be listed in each
1527 @samp{_SOURCES} definition.
1529 @cindex Header files in _SOURCES
1530 @cindex _SOURCES and header files
1532 Header files listed in a @samp{_SOURCES} definition will be included in
1533 the distribution but otherwise ignored.  In case it isn't obvious, you
1534 should not include the header file generated by @file{configure} in an
1535 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1536 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1537 and Lex}.
1539 @cindex EXTRA_prog_SOURCES, defined
1541 Automake must know all the source files that could possibly go into a
1542 program, even if not all the files are built in every circumstance.
1543 Any files which are only conditionally built should be listed in the
1544 appropriate @samp{EXTRA_} variable.  For instance, if
1545 @file{hello-linux.c} were conditionally included in @code{hello}, the
1546 @file{Makefile.am} would contain:
1548 @example
1549 EXTRA_hello_SOURCES = hello-linux.c
1550 @end example
1552 Similarly, sometimes it is useful to determine the programs that are to
1553 be built at configure time.  For instance, GNU @code{cpio} only builds
1554 @code{mt} and @code{rmt} under special circumstances.
1556 @cindex EXTRA_PROGRAMS, defined
1558 In this case, you must notify Automake of all the programs that can
1559 possibly be built, but at the same time cause the generated
1560 @file{Makefile.in} to use the programs specified by @code{configure}.
1561 This is done by having @code{configure} substitute values into each
1562 @samp{_PROGRAMS} definition, while listing all optionally built programs
1563 in @code{EXTRA_PROGRAMS}.
1564 @vindex EXTRA_PROGRAMS
1566 If you need to link against libraries that are not found by
1567 @code{configure}, you can use @code{LDADD} to do so.  This variable
1568 actually can be used to add any options to the linker command line.
1569 @vindex LDADD
1571 @cindex prog_LDADD, defined
1573 Sometimes, multiple programs are built in one directory but do not share
1574 the same link-time requirements.  In this case, you can use the
1575 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1576 program as it appears in some @samp{_PROGRAMS} variable, and usually
1577 written in lowercase) to override the global @code{LDADD}.  If this
1578 variable exists for a given program, then that program is not linked
1579 using @code{LDADD}.
1580 @vindex _LDADD
1582 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
1583 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1584 built in the same directory, and has no such link requirement.  Also,
1585 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1586 is what cpio's @file{src/Makefile.am} looks like (abridged):
1588 @example
1589 bin_PROGRAMS = cpio pax @@MT@@
1590 libexec_PROGRAMS = @@RMT@@
1591 EXTRA_PROGRAMS = mt rmt
1593 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1594 rmt_LDADD =
1596 cpio_SOURCES = @dots{}
1597 pax_SOURCES = @dots{}
1598 mt_SOURCES = @dots{}
1599 rmt_SOURCES = @dots{}
1600 @end example
1602 @cindex _LDFLAGS, defined
1604 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
1605 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
1606 @samp{-dlpreopen}).  So, use the @samp{@var{prog}_LDFLAGS} variable for
1607 this purpose.
1608 @vindex _LDFLAGS
1610 @cindex _DEPENDENCIES, defined
1612 It is also occasionally useful to have a program depend on some other
1613 target which is not actually part of that program.  This can be done
1614 using the @samp{@var{prog}_DEPENDENCIES} variable.  Each program depends
1615 on the contents of such a variable, but no further interpretation is
1616 done.
1618 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
1619 Automake.  The automatically-assigned value is the contents of
1620 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
1621 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed.  The
1622 configure substitutions that are left in are only @samp{@@LIBOBJS@@} and
1623 @samp{@@ALLOCA@@}; these are left because it is known that they will not
1624 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
1625 generated.
1628 @node A Library, LIBOBJS, A Program, Programs
1629 @section Building a library
1631 @cindex _LIBRARIES primary, defined
1632 @cindex LIBRARIES primary, defined
1633 @cindex Primary variable, LIBRARIES
1635 @vindex lib_LIBRARIES
1636 @vindex pkglib_LIBRARIES
1637 @vindex noinst_LIBRARIES
1639 Building a library is much like building a program.  In this case, the
1640 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1641 @code{libdir} or @code{pkglibdir}.
1643 @xref{A Shared Library}, for information on how to build shared
1644 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1646 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1647 For instance to create a library named @file{libcpio.a}, but not install
1648 it, you would write:
1650 @example
1651 noinst_LIBRARIES = libcpio.a
1652 @end example
1654 The sources that go into a library are determined exactly as they are
1655 for programs, via the @samp{_SOURCES} variables.  Note that the library
1656 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1657 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1658 not @samp{liblob.a_SOURCES}.
1660 @cindex _LIBADD primary, defined
1661 @cindex LIBADD primary, defined
1662 @cindex Primary variable, LIBADD
1664 Extra objects can be added to a library using the
1665 @samp{@var{library}_LIBADD} variable.  This should be used for objects
1666 determined by @code{configure}.  Again from @code{cpio}:
1667 @vindex _LIBADD
1668 @vindex LIBADD
1670 @example
1671 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1672 @end example
1674 In addition, sources for extra objects that will not exist until
1675 configure-time must be added to the @code{BUILT_SOURCES} variable
1676 (@pxref{Sources}).
1679 @node LIBOBJS, A Shared Library, A Library, Programs
1680 @section Special handling for LIBOBJS and ALLOCA
1682 @cindex @@LIBOBJS@@, special handling
1683 @cindex @@ALLOCA@@, special handling
1685 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1686 @code{@@ALLOCA@@}, and uses this information, plus the list of
1687 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1688 include the appropriate source files in the distribution (@pxref{Dist}).
1689 These source files are also automatically handled in the
1690 dependency-tracking scheme; see @xref{Dependencies}.
1692 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1693 @samp{_LDADD} or @samp{_LIBADD} variable.
1696 @node A Shared Library, Program variables, LIBOBJS, Programs
1697 @section Building a Shared Library
1699 @cindex Shared libraries, support for
1701 Building shared libraries is a relatively complex matter.  For this
1702 reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
1703 Libtool Manual}) was created to help build shared libraries in a
1704 platform-independent way.
1706 @cindex _LTLIBRARIES primary, defined
1707 @cindex LTLIBRARIES primary, defined
1708 @cindex Primary variable, LTLIBRARIES
1709 @cindex Example of shared libraries
1711 @cindex suffix .la, defined
1713 Automake uses Libtool to build libraries declared with the
1714 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1715 of shared libraries to build.  For instance, to create a library named
1716 @file{libgettext.a} and its corresponding shared libraries, and install
1717 them in @samp{libdir}, write:
1719 @example
1720 lib_LTLIBRARIES = libgettext.la
1721 @end example
1723 @vindex lib_LTLIBRARIES
1724 @vindex pkglib_LTLIBRARIES
1725 @vindex noinst_LTLIBRARIES
1726 @vindex check_LTLIBRARIES
1728 @cindex check_LTLIBRARIES, not allowed
1730 Note that shared libraries @emph{must} be installed, so
1731 @code{check_LTLIBRARIES} is not allowed.  However,
1732 @code{noinst_LTLIBRARIES} is allowed.  This feature should be used for
1733 libtool ``convenience libraries''.
1735 @cindex suffix .lo, defined
1737 For each library, the @samp{@var{library}_LIBADD} variable contains the
1738 names of extra libtool objects (@file{.lo} files) to add to the shared
1739 library.  The @samp{@var{library}_LDFLAGS} variable contains any
1740 additional libtool flags, such as @samp{-version-info} or
1741 @samp{-static}.
1743 @cindex @@LTLIBOBJS@@, special handling
1745 Where an ordinary library might include @code{@@LIBOBJS@@}, a libtool
1746 library must use @code{@@LTLIBOBJS@@}.  This is required because the
1747 object files that libtool operates on do not necessarily end in
1748 @file{.o}.  The libtool manual contains more details on this topic.
1750 For libraries installed in some directory, Automake will automatically
1751 supply the appropriate @samp{-rpath} option.  However, for libraries
1752 determined at configure time (and thus mentioned in
1753 @code{EXTRA_LTLIBRARIES}), Automake does not know the eventual
1754 installation directory; for such libraries you must add the
1755 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
1756 hand.
1758 Ordinarily, Automake requires that a shared library's name start with
1759 @samp{lib}.  However, if you are building a dynamically loadable module
1760 then you might wish to use a "nonstandard" name.  In this case, put
1761 @code{-module} into the @samp{_LDFLAGS} variable.
1763 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1764 libtool, The Libtool Manual}, for more information.
1767 @node Program variables, Yacc and Lex, A Shared Library, Programs
1768 @section Variables used when building a program
1770 Occasionally it is useful to know which @file{Makefile} variables
1771 Automake uses for compilations; for instance you might need to do your
1772 own compilation in some special cases.
1774 Some variables are inherited from Autoconf; these are @code{CC},
1775 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1776 @code{LIBS}.
1777 @vindex LDFLAGS
1779 There are some additional variables which Automake itself defines:
1781 @vtable @code
1782 @item INCLUDES
1783 A list of @samp{-I} options.  This can be set in your @file{Makefile.am}
1784 if you have special directories you want to look in.  Automake already
1785 provides some @samp{-I} options automatically.  In particular it
1786 generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I} pointing to
1787 the directory holding @file{config.h} (if you've used
1788 @code{AC_CONFIG_HEADER} or @code{AM_CONFIG_HEADER}).  You can disable
1789 the default @samp{-I} options using the @samp{nostdinc} option.
1791 @code{INCLUDES} can actually be used for other @code{cpp} options
1792 besides @samp{-I}.  For instance, it is sometimes used to pass arbitrary
1793 @samp{-D} options to the compiler.
1795 @item COMPILE
1796 This is the command used to actually compile a C source file.  The
1797 filename is appended to form the complete command line.
1799 @item LINK
1800 This is the command used to actually link a C program.
1801 @end vtable
1804 @node Yacc and Lex, C++ Support, Program variables, Programs
1805 @section Yacc and Lex support
1807 Automake has somewhat idiosyncratic support for Yacc and Lex.
1809 Automake assumes that the @file{.c} file generated by @code{yacc} (or
1810 @code{lex}) should be named using the basename of the input file.  That
1811 is, for a yacc source file @file{foo.y}, Automake will cause the
1812 intermediate file to be named @file{foo.c} (as opposed to
1813 @file{y.tab.c}, which is more traditional).
1815 The extension of a yacc source file is used to determine the extension
1816 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
1817 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1818 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1819 @samp{.cxx}.
1821 Likewise, lex source files can be used to generate @samp{C} or
1822 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
1823 @samp{.lxx} are recognized.
1825 You should never explicitly mention the intermediate (@samp{C} or
1826 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1827 file.
1829 The intermediate files generated by @code{yacc} (or @code{lex}) will be
1830 included in any distribution that is made.  That way the user doesn't
1831 need to have @code{yacc} or @code{lex}.
1833 If a @code{yacc} source file is seen, then your @file{configure.in} must
1834 define the variable @samp{YACC}.  This is most easily done by invoking
1835 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
1836 Program Checks, autoconf, The Autoconf Manual}).
1838 Similarly, if a @code{lex} source file is seen, then your
1839 @file{configure.in} must define the variable @samp{LEX}.  You can use
1840 @samp{AC_PROG_LEX} to do this (@pxref{Particular Programs, , Particular
1841 Program Checks, autoconf, The Autoconf Manual}).  Automake's @code{lex}
1842 support also requires that you use the @samp{AC_DECL_YYTEXT}
1843 macro---automake needs to know the value of @samp{LEX_OUTPUT_ROOT}.
1844 This is all handled for you if you use the @code{AM_PROG_LEX} macro
1845 (@pxref{Macros}).
1847 @cindex ylwrap
1848 @cindex yacc, multiple parsers
1849 @cindex Multiple yacc parsers
1850 @cindex Multiple lex lexers
1851 @cindex lex, multiple lexers
1854 Automake makes it possible to include multiple @code{yacc} (or
1855 @code{lex}) source files in a single program.  Automake uses a small
1856 program called @code{ylwrap} to run @code{yacc} (or @code{lex}) in a
1857 subdirectory.  This is necessary because yacc's output filename is
1858 fixed, and a parallel make could conceivably invoke more than one
1859 instance of @code{yacc} simultaneously.  The @code{ylwrap} program is
1860 distributed with Automake.  It should appear in the directory specified
1861 by @samp{AC_CONFIG_AUX_DIR} (@pxref{Input, , Finding `configure' Input,
1862 autoconf, The Autoconf Manual}), or the current directory if that macro
1863 is not used in @file{configure.in}.
1865 For @code{yacc}, simply managing locking is insufficient.  The output of
1866 @code{yacc} always uses the same symbol names internally, so it isn't
1867 possible to link two @code{yacc} parsers into the same executable.
1869 We recommend using the following renaming hack used in @code{gdb}:
1870 @example
1871 #define yymaxdepth c_maxdepth
1872 #define yyparse c_parse
1873 #define yylex   c_lex
1874 #define yyerror c_error
1875 #define yylval  c_lval
1876 #define yychar  c_char
1877 #define yydebug c_debug
1878 #define yypact  c_pact
1879 #define yyr1    c_r1
1880 #define yyr2    c_r2
1881 #define yydef   c_def
1882 #define yychk   c_chk
1883 #define yypgo   c_pgo
1884 #define yyact   c_act
1885 #define yyexca  c_exca
1886 #define yyerrflag c_errflag
1887 #define yynerrs c_nerrs
1888 #define yyps    c_ps
1889 #define yypv    c_pv
1890 #define yys     c_s
1891 #define yy_yys  c_yys
1892 #define yystate c_state
1893 #define yytmp   c_tmp
1894 #define yyv     c_v
1895 #define yy_yyv  c_yyv
1896 #define yyval   c_val
1897 #define yylloc  c_lloc
1898 #define yyreds  c_reds
1899 #define yytoks  c_toks
1900 #define yylhs   c_yylhs
1901 #define yylen   c_yylen
1902 #define yydefred c_yydefred
1903 #define yydgoto c_yydgoto
1904 #define yysindex c_yysindex
1905 #define yyrindex c_yyrindex
1906 #define yygindex c_yygindex
1907 #define yytable  c_yytable
1908 #define yycheck  c_yycheck
1909 #define yyname   c_yyname
1910 #define yyrule   c_yyrule
1911 @end example
1913 For each define, replace the @samp{c_} prefix with whatever you like.
1914 These defines work for @code{bison}, @code{byacc}, and traditional
1915 @code{yacc}s.  If you find a parser generator that uses a symbol not
1916 covered here, please report the new name so it can be added to the list.
1919 @node C++ Support, Fortran 77 Support, Yacc and Lex, Programs
1920 @section C++ Support
1922 @cindex C++ support
1923 @cindex Support for C++
1925 Automake includes full support for C++.
1927 Any package including C++ code must define the output variable
1928 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
1929 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
1930 Program Checks, autoconf, The Autoconf Manual}).
1932 A few additional variables are defined when a C++ source file is seen:
1934 @vtable @code
1935 @item CXX
1936 The name of the C++ compiler.
1938 @item CXXFLAGS
1939 Any flags to pass to the C++ compiler.
1941 @item CXXCOMPILE
1942 The command used to actually compile a C++ source file.  The file name
1943 is appended to form the complete command line.
1945 @item CXXLINK
1946 The command used to actually link a C++ program.
1947 @end vtable
1950 @node Fortran 77 Support, Java Support, C++ Support, Programs
1951 @comment  node-name,  next,  previous,  up
1952 @section Fortran 77 Support
1954 @cindex Fortran 77 support
1955 @cindex Support for Fortran 77
1957 Automake includes full support for Fortran 77.
1959 Any package including Fortran 77 code must define the output variable
1960 @samp{F77} in @file{configure.in}; the simplest way to do this is to use
1961 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
1962 Program Checks, autoconf, The Autoconf Manual}).  @xref{Fortran 77 and
1963 Autoconf}.
1965 A few additional variables are defined when a Fortran 77 source file is
1966 seen:
1968 @vtable @code
1970 @item F77
1971 The name of the Fortran 77 compiler.
1973 @item FFLAGS
1974 Any flags to pass to the Fortran 77 compiler.
1976 @item RFLAGS
1977 Any flags to pass to the Ratfor compiler.
1979 @item F77COMPILE
1980 The command used to actually compile a Fortran 77 source file.  The file
1981 name is appended to form the complete command line.
1983 @item FLINK
1984 The command used to actually link a pure Fortran 77 program or shared
1985 library.
1987 @end vtable
1989 Automake can handle preprocessing Fortran 77 and Ratfor source files in
1990 addition to compiling them@footnote{Much, if not most, of the
1991 information in the following sections pertaining to preprocessing
1992 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
1993 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}.  Automake
1994 also contains some support for creating programs and shared libraries
1995 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
1996 Fortran 77 With C and C++}).
1998 These issues are covered in the following sections.
2000 @menu
2001 * Preprocessing Fortran 77::
2002 * Compiling Fortran 77 Files::
2003 * Mixing Fortran 77 With C and C++::
2004 * Fortran 77 and Autoconf::
2005 @end menu
2008 @node Preprocessing Fortran 77, Compiling Fortran 77 Files, Fortran 77 Support, Fortran 77 Support
2009 @comment  node-name,  next,  previous,  up
2010 @subsection Preprocessing Fortran 77
2012 @cindex Preprocessing Fortran 77
2013 @cindex Fortran 77, Preprocessing
2014 @cindex Ratfor programs
2016 @file{N.f} is made automatically from @file{N.F} or @file{N.r}.  This
2017 rule runs just the preprocessor to convert a preprocessable Fortran 77
2018 or Ratfor source file into a strict Fortran 77 source file.  The precise
2019 command used is as follows:
2021 @table @file
2023 @item .F
2024 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2026 @item .r
2027 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2029 @end table
2032 @node Compiling Fortran 77 Files, Mixing Fortran 77 With C and C++, Preprocessing Fortran 77, Fortran 77 Support
2033 @comment  node-name,  next,  previous,  up
2034 @subsection Compiling Fortran 77 Files
2036 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
2037 @file{N.r} by running the Fortran 77 compiler.  The precise command used
2038 is as follows:
2040 @table @file
2042 @item .f
2043 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
2045 @item .F
2046 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2048 @item .r
2049 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2051 @end table
2054 @node Mixing Fortran 77 With C and C++, Fortran 77 and Autoconf, Compiling Fortran 77 Files, Fortran 77 Support
2055 @comment  node-name,  next,  previous,  up
2056 @subsection Mixing Fortran 77 With C and C++
2058 @cindex Fortran 77, mixing with C and C++
2059 @cindex Mixing Fortran 77 with C and C++
2060 @cindex Linking Fortran 77 with C and C++
2061 @cindex cfortran
2062 @cindex Mixing Fortran 77 with C and/or C++
2064 Automake currently provides @emph{limited} support for creating programs
2065 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
2066 However, there are many other issues related to mixing Fortran 77 with
2067 other languages that are @emph{not} (currently) handled by Automake, but
2068 that are handled by other packages@footnote{For example,
2069 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
2070 addresses all of these inter-language issues, and runs under nearly all
2071 Fortran 77, C and C++ compilers on nearly all platforms.  However,
2072 @code{cfortran} is not yet Free Software, but it will be in the next
2073 major release.}.
2075 @page
2076 Automake can help in two ways:
2078 @enumerate
2079 @item
2080 Automatic selection of the linker depending on which combinations of
2081 source code.
2083 @item
2084 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
2085 @samp{-l}) to pass to the automatically selected linker in order to link
2086 in the appropriate Fortran 77 intrinsic and run-time libraries.
2088 @cindex FLIBS, defined
2089 These extra Fortran 77 linker flags are supplied in the output variable
2090 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
2091 supplied with newer versions of Autoconf (Autoconf version 2.13 and
2092 later).  @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
2093 Autoconf}.
2094 @end enumerate
2096 If Automake detects that a program or shared library (as mentioned in
2097 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
2098 code that is a mixture of Fortran 77 and C and/or C++, then it requires
2099 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
2100 @file{configure.in}, and that either @code{$(FLIBS)} or @code{@@FLIBS@@}
2101 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
2102 (for shared libraries) variables.  It is the responsibility of the
2103 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
2104 or @code{@@FLIBS@@} appears in the appropriate @code{_LDADD} or
2105 @code{_LIBADD} variable.
2107 @cindex Mixed language example
2108 @cindex Example, mixed language
2110 For example, consider the following @file{Makefile.am}:
2112 @example
2113 bin_PROGRAMS = foo
2114 foo_SOURCES  = main.cc foo.f
2115 foo_LDADD    = libfoo.la @@FLIBS@@
2117 pkglib_LTLIBRARIES = libfoo.la
2118 libfoo_la_SOURCES  = bar.f baz.c zardoz.cc
2119 libfoo_la_LIBADD   = $(FLIBS)
2120 @end example
2122 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
2123 is mentioned in @file{configure.in}.  Also, if @code{@@FLIBS@@} hadn't
2124 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
2125 Automake would have issued a warning.
2128 @page
2129 @menu
2130 * How the Linker is Chosen::
2131 @end menu
2133 @node How the Linker is Chosen,  , Mixing Fortran 77 With C and C++, Mixing Fortran 77 With C and C++
2134 @comment  node-name,  next,  previous,  up
2135 @subsubsection How the Linker is Chosen
2137 @cindex Automatic linker selection
2138 @cindex Selecting the linker automatically
2140 The following diagram demonstrates under what conditions a particular
2141 linker is chosen by Automake.
2143 For example, if Fortran 77, C and C++ source code were to be compiled
2144 into a program, then the C++ linker will be used.  In this case, if the
2145 C or Fortran 77 linkers required any special libraries that weren't
2146 included by the C++ linker, then they must be manually added to an
2147 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
2148 @file{Makefile.am}.
2150 @example
2151                      \              Linker
2152           source      \
2153            code        \     C        C++     Fortran
2154      -----------------  +---------+---------+---------+
2155                         |         |         |         |
2156      C                  |    x    |         |         |
2157                         |         |         |         |
2158                         +---------+---------+---------+
2159                         |         |         |         |
2160          C++            |         |    x    |         |
2161                         |         |         |         |
2162                         +---------+---------+---------+
2163                         |         |         |         |
2164                Fortran  |         |         |    x    |
2165                         |         |         |         |
2166                         +---------+---------+---------+
2167                         |         |         |         |
2168      C + C++            |         |    x    |         |
2169                         |         |         |         |
2170                         +---------+---------+---------+
2171                         |         |         |         |
2172      C +       Fortran  |         |         |    x    |
2173                         |         |         |         |
2174                         +---------+---------+---------+
2175                         |         |         |         |
2176          C++ + Fortran  |         |    x    |         |
2177                         |         |         |         |
2178                         +---------+---------+---------+
2179                         |         |         |         |
2180      C + C++ + Fortran  |         |    x    |         |
2181                         |         |         |         |
2182                         +---------+---------+---------+
2183 @end example
2186 @node Fortran 77 and Autoconf,  , Mixing Fortran 77 With C and C++, Fortran 77 Support
2187 @comment  node-name,  next,  previous,  up
2188 @subsection Fortran 77 and Autoconf
2190 The current Automake support for Fortran 77 requires a recent enough
2191 version Autoconf that also includes support for Fortran 77.  Full
2192 Fortran 77 support was added to Autoconf 2.13, so you will want to use
2193 that version of Autoconf or later.
2196 @node Java Support, Support for Other Languages, Fortran 77 Support, Programs
2197 @comment  node-name,  next,  previous,  up
2198 @section Java Support
2200 @cindex Java support
2201 @cindex Support for Java
2203 Automake includes support for compiled Java, using @code{gcj}, the Java
2204 front end to the GNU C compiler.
2206 Any package including Java code to be compiled must define the output
2207 variable @samp{GCJ} in @file{configure.in}; the variable @samp{GCJFLAGS}
2208 must also be defined somehow (either in @file{configure.in} or
2209 @file{Makefile.am}).  The simplest way to do this is to use the
2210 @code{AM_PROG_GCJ} macro.
2212 By default, programs including Java source files are linked with
2213 @code{gcj}.
2216 @node Support for Other Languages, ANSI, Java Support, Programs
2217 @comment  node-name,  next,  previous,  up
2218 @section Support for Other Languages
2220 Automake currently only includes full support for C, C++ (@pxref{C++
2221 Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java
2222 (@pxref{Java Support}).  There is only rudimentary support for other
2223 languages, support for which will be improved based on user demand.
2225 @c FIXME: mention suffix rule processing here.
2228 @node ANSI, Dependencies, Support for Other Languages, Programs
2229 @section Automatic de-ANSI-fication
2231 @cindex de-ANSI-fication, defined
2233 Although the GNU standards allow the use of ANSI C, this can have the
2234 effect of limiting portability of a package to some older compilers
2235 (notably SunOS).
2237 Automake allows you to work around this problem on such machines by
2238 @dfn{de-ANSI-fying} each source file before the actual compilation takes
2239 place.
2241 @vindex AUTOMAKE_OPTIONS
2242 @opindex ansi2knr
2244 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
2245 (@pxref{Options}) contains the option @code{ansi2knr} then code to
2246 handle de-ANSI-fication is inserted into the generated
2247 @file{Makefile.in}.
2249 This causes each C source file in the directory to be treated as ANSI C.
2250 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
2251 is available, the @code{ansi2knr} program is used to convert the source
2252 files into K&R C, which is then compiled.
2254 The @code{ansi2knr} program is simple-minded.  It assumes the source
2255 code will be formatted in a particular way; see the @code{ansi2knr} man
2256 page for details.
2258 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
2259 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
2260 these files are distributed with Automake.  Also, the package
2261 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}
2262 (@pxref{Macros}).
2263 @cvindex AM_C_PROTOTYPES
2265 Automake also handles finding the @code{ansi2knr} support files in some
2266 other directory in the current package.  This is done by prepending the
2267 relative path to the appropriate directory to the @code{ansi2knr}
2268 option.  For instance, suppose the package has ANSI C code in the
2269 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
2270 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
2271 @file{src/Makefile.am}:
2273 @example
2274 AUTOMAKE_OPTIONS = ../lib/ansi2knr
2275 @end example
2277 If no directory prefix is given, the files are assumed to be in the
2278 current directory.
2280 Files mentioned in @code{LIBOBJS} which need de-ANSI-fication will not
2281 be automatically handled.  That's because @code{configure} will generate
2282 an object name like @file{regex.o}, while @code{make} will be looking
2283 for @file{regex_.o} (when de-ANSI-fying).  Eventually this problem will
2284 be fixed via @code{autoconf} magic, but for now you must put this code
2285 into your @file{configure.in}, just before the @code{AC_OUTPUT} call:
2287 @example
2288 # This is necessary so that .o files in LIBOBJS are also built via
2289 # the ANSI2KNR-filtering rules.
2290 LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
2291 @end example
2294 @node Dependencies,  , ANSI, Programs
2295 @section Automatic dependency tracking
2297 As a developer it is often painful to continually update the
2298 @file{Makefile.in} whenever the include-file dependencies change in a
2299 project.  Automake supplies a way to automatically track dependency
2300 changes, and distribute the dependencies in the generated
2301 @file{Makefile.in}.
2303 Currently this support requires the use of GNU @code{make} and
2304 @code{gcc}.  It might become possible in the future to supply a
2305 different dependency generating program, if there is enough demand.  In
2306 the meantime, this mode is enabled by default if any C program or
2307 library is defined in the current directory, so you may get a @samp{Must
2308 be a separator} error from non-GNU make.
2310 @trindex dist
2312 When you decide to make a distribution, the @code{dist} target will
2313 re-run @code{automake} with @samp{--include-deps} and other options.
2314 @xref{Invoking Automake}, and @ref{Options}.  This will cause the
2315 previously generated dependencies to be inserted into the generated
2316 @file{Makefile.in}, and thus into the distribution.  This step also
2317 turns off inclusion of the dependency generation code, so that those who
2318 download your distribution but don't use GNU @code{make} and @code{gcc}
2319 will not get errors.
2321 @vindex OMIT_DEPENDENCIES
2323 When added to the @file{Makefile.in}, the dependencies have all
2324 system-specific dependencies automatically removed.  This can be done by
2325 listing the files in @samp{OMIT_DEPENDENCIES}.  For instance all
2326 references to system header files are removed by Automake.  Sometimes it
2327 is useful to specify that a certain header file should be removed.  For
2328 instance if your @file{configure.in} uses @samp{AM_WITH_REGEX}, then any
2329 dependency on @file{rx.h} or @file{regex.h} should be removed, because
2330 the correct one cannot be known until the user configures the package.
2332 As it turns out, Automake is actually smart enough to handle the
2333 particular case of the regular expression header.  It will also
2334 automatically omit @file{libintl.h} if @samp{AM_GNU_GETTEXT} is used.
2336 @vindex AUTOMAKE_OPTIONS
2337 @opindex no-dependencies
2339 Automatic dependency tracking can be suppressed by putting
2340 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
2342 If you unpack a distribution made by @code{make dist}, and you want to
2343 turn on the dependency-tracking code again, simply re-run
2344 @code{automake}.
2346 The actual dependency files are put under the build directory, in a
2347 subdirectory named @file{.deps}.  These dependencies are machine
2348 specific.  It is safe to delete them if you like; they will be
2349 automatically recreated during the next build.
2352 @node Other objects, Other GNU Tools, Programs, Top
2353 @chapter Other Derived Objects
2355 Automake can handle derived objects which are not C programs.  Sometimes
2356 the support for actually building such objects must be explicitly
2357 supplied, but Automake will still automatically handle installation and
2358 distribution.
2360 @menu
2361 * Scripts::                     Executable scripts
2362 * Headers::                     Header files
2363 * Data::                        Architecture-independent data files
2364 * Sources::                     Derived sources
2365 @end menu
2368 @node Scripts, Headers, Other objects, Other objects
2369 @section Executable Scripts
2371 @cindex _SCRIPTS primary, defined
2372 @cindex SCRIPTS primary, defined
2373 @cindex Primary variable, SCRIPTS
2375 It is possible to define and install programs which are scripts.  Such
2376 programs are listed using the @samp{SCRIPTS} primary name.  Automake
2377 doesn't define any dependencies for scripts; the @file{Makefile.am}
2378 should include the appropriate rules.
2379 @vindex SCRIPTS
2381 Automake does not assume that scripts are derived objects; such objects
2382 must be deleted by hand (@pxref{Clean}).
2384 The @code{automake} program itself is a Perl script that is generated at
2385 configure time from @file{automake.in}.  Here is how this is handled:
2387 @example
2388 bin_SCRIPTS = automake
2389 @end example
2391 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
2392 for it is automatically generated.
2394 @cindex SCRIPTS, installation directories
2395 @cindex Installing scripts
2397 @vindex bin_SCRIPTS
2398 @vindex sbin_SCRIPTS
2399 @vindex libexec_SCRIPTS
2400 @vindex pkgdata_SCRIPTS
2401 @vindex noinst_SCRIPTS
2403 Script objects can be installed in @code{bindir}, @code{sbindir},
2404 @code{libexecdir}, or @code{pkgdatadir}.
2407 @node Headers, Data, Scripts, Other objects
2408 @section Header files
2410 @cindex _HEADERS primary, defined
2411 @cindex HEADERS primary, defined
2412 @cindex Primary variable, HEADERS
2414 @vindex noinst_HEADERS
2416 Header files are specified by the @samp{HEADERS} family of variables.
2417 Generally header files are not installed, so the @code{noinst_HEADERS}
2418 variable will be the most used.
2419 @vindex HEADERS
2421 All header files must be listed somewhere; missing ones will not appear
2422 in the distribution.  Often it is clearest to list uninstalled headers
2423 with the rest of the sources for a program.  @xref{A Program}.  Headers
2424 listed in a @samp{_SOURCES} variable need not be listed in any
2425 @samp{_HEADERS} variable.
2427 @cindex HEADERS, installation directories
2428 @cindex Installing headers
2430 @vindex include_HEADERS
2431 @vindex oldinclude_HEADERS
2432 @vindex pkginclude_HEADERS
2434 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
2435 @code{pkgincludedir}.
2438 @node Data, Sources, Headers, Other objects
2439 @section Architecture-independent data files
2441 @cindex _DATA primary, defined
2442 @cindex DATA primary, defined
2443 @cindex Primary variable, DATA
2445 Automake supports the installation of miscellaneous data files using the
2446 @samp{DATA} family of variables.
2447 @vindex DATA
2449 @vindex data_DATA
2450 @vindex sysconf_DATA
2451 @vindex sharedstate_DATA
2452 @vindex localstate_DATA
2453 @vindex pkgdata_DATA
2455 Such data can be installed in the directories @code{datadir},
2456 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
2457 @code{pkgdatadir}.
2459 By default, data files are @emph{not} included in a distribution.
2461 Here is how Automake installs its auxiliary data files:
2463 @example
2464 pkgdata_DATA = clean-kr.am clean.am @dots{}
2465 @end example
2468 @node Sources,  , Data, Other objects
2469 @section Built sources
2471 @cindex BUILT_SOURCES, defined
2473 Occasionally a file which would otherwise be called @samp{source}
2474 (e.g. a C @samp{.h} file) is actually derived from some other file.
2475 Such files should be listed in the @code{BUILT_SOURCES} variable.
2476 @vindex BUILT_SOURCES
2478 @code{BUILT_SOURCES} is actually a bit of a misnomer, as any file which
2479 must be created early in the build process can be listed in this
2480 variable.
2482 A source file listed in @code{BUILT_SOURCES} is created before the other
2483 @code{all} targets are made.  However, such a source file is not
2484 compiled unless explicitly requested by mentioning it in some other
2485 @samp{_SOURCES} variable.
2488 @node Other GNU Tools, Documentation, Other objects, Top
2489 @chapter Other GNU Tools
2491 Since Automake is primarily intended to generate @file{Makefile.in}s for
2492 use in GNU programs, it tries hard to interoperate with other GNU tools.
2494 @menu
2495 * Emacs Lisp::                  Emacs Lisp
2496 * gettext::                     Gettext
2497 * Guile::                       Guile
2498 * Libtool::                     Libtool
2499 * Java::                        Java
2500 * Python::                      Python
2501 @end menu
2504 @node Emacs Lisp, gettext, Other GNU Tools, Other GNU Tools
2505 @section Emacs Lisp
2507 @cindex _LISP primary, defined
2508 @cindex LISP primary, defined
2509 @cindex Primary variable, LISP
2511 @vindex LISP
2512 @vindex lisp_LISP
2513 @vindex noinst_LISP
2515 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
2516 is used to hold a list of @file{.el} files.  Possible prefixes for this
2517 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
2518 @code{lisp_LISP} is defined, then @file{configure.in} must run
2519 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
2521 @vindex ELCFILES
2523 By default Automake will byte-compile all Emacs Lisp source files using
2524 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
2525 byte-compiling, simply define the variable @code{ELCFILES} to be empty.
2526 Byte-compiled Emacs Lisp files are not portable among all versions of
2527 Emacs, so it makes sense to turn this off if you expect sites to have
2528 more than one version of Emacs installed.  Furthermore, many packages
2529 don't actually benefit from byte-compilation.  Still, we recommend that
2530 you leave it enabled by default.  It is probably better for sites with
2531 strange setups to cope for themselves than to make the installation less
2532 nice for everybody else.
2535 @node gettext, Guile, Emacs Lisp, Other GNU Tools
2536 @section Gettext
2538 @cindex GNU Gettext support
2539 @cindex Gettext support
2540 @cindex Support for GNU Gettext
2542 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
2543 turns on support for GNU gettext, a message catalog system for
2544 internationalization
2545 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
2547 The @code{gettext} support in Automake requires the addition of two
2548 subdirectories to the package, @file{intl} and @file{po}.  Automake
2549 insures that these directories exist and are mentioned in
2550 @code{SUBDIRS}.
2552 Furthermore, Automake checks that the definition of @code{ALL_LINGUAS}
2553 in @file{configure.in} corresponds to all the valid @file{.po} files,
2554 and nothing more.
2557 @node Guile, Libtool, gettext, Other GNU Tools
2558 @section Guile
2560 Automake provides some automatic support for writing Guile modules.
2561 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
2562 macro is used in @file{configure.in}.
2564 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
2565 macro is understood to mean:
2566 @itemize @bullet
2567 @item
2568 @code{AM_INIT_AUTOMAKE} is run.
2570 @item
2571 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
2572 @end itemize
2574 As the Guile module code matures, no doubt the Automake support will
2575 grow as well.
2578 @node Libtool, Java, Guile, Other GNU Tools
2579 @section Libtool
2581 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
2582 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
2583 @xref{A Shared Library}.
2586 @node Java, Python, Libtool, Other GNU Tools
2587 @section Java
2589 @cindex _JAVA primary, defined
2590 @cindex JAVA primary, defined
2591 @cindex Primary variable, JAVA
2593 Automake provides some minimal support for Java compilation with the
2594 @samp{JAVA} primary.
2596 Any @file{.java} files listed in a @samp{_JAVA} variable will be
2597 compiled with @code{JAVAC} at build time.  By default, @file{.class}
2598 files are not included in the distribution.
2600 @cindex JAVA restrictions
2601 @cindex Restrictions for JAVA
2603 Currently Automake enforces the restriction that only one @samp{_JAVA}
2604 primary can be used in a given @file{Makefile.am}.  The reason for this
2605 restriction is that, in general, it isn't possible to know which
2606 @file{.class} files were generated from which @file{.java} files -- so
2607 it would be impossible to know which files to install where.
2609 @node Python,  , Java, Other GNU Tools
2610 @section Python
2612 @cindex _PYTHON primary, defined
2613 @cindex PYTHON primary, defined
2614 @cindex Primary variable, PYTHON
2617 Automake provides support for Python modules.  Automake will turn on
2618 Python support if the @code{AM_CHECK_PYTHON} macro is used in
2619 @file{configure.in}.  The @samp{PYTHON} primary is used to hold a list
2620 of @file{.py} files.  Possible prefixes for this primary are
2621 @samp{python_} and @samp{noinst_}.  Note that if @code{python_PYTHON} is
2622 defined, then @file{configure.in} must run @code{AM_CHECK_PYTHON}.
2624 @code{AM_CHECK_PYTHON} takes a single argument --- either the word
2625 @samp{module} or @samp{package}.  The first installs files directly into
2626 the @file{site-packages} directory and is used when the @file{.py[co]}
2627 files must be on the @code{PYTHONPATH}.  The second is used for modules
2628 distributed as a package, which should be installed in a subdirectory
2629 of @file{site-packages} and contain the @file{__init__.py} file.  The
2630 subdirectory name is the same as the name given by @samp{PACKAGE}.
2633 @code{AM_CHECK_PYTHON} creates several output variables based on the
2634 Python installation found during configuration.
2636 @table @samp
2637 @item PYTHON
2638 The name of the Python executable.
2640 @item PYTHON_VERSION
2641 The Python version number, in the form @var{major}.@var{minor}
2642 (e.g. @samp{1.5}).  This is currently the value of
2643 @code{sys.version[:3]}.
2645 @item PYTHON_PREFIX
2646 The string @code{$prefix}.  This term may be used in future work
2647 which needs the contents of Python's @code{sys.prefix}, but general
2648 consensus is to always use the value from configure.
2650 @item PYTHON_EXEC_PREFIX
2651 The string @code{$exec_prefix}.  This term may be used in future work
2652 which needs the contents of Python's @code{sys.exec_prefix}, but general
2653 consensus is to always use the value from configure.
2655 @item PYTHON_PLATFORM
2656 The canonical name used by Python to describe the operating system, as
2657 given by @code{sys.platform}.  This value is sometimes needed when
2658 building Python extensions.
2660 @item pythondir
2661 The directory name for the top of the standard Python library.
2663 @item PYTHON_SITE
2664 The location of the platform-independent @file{site-packages} directory,
2665 where `module' files are installed.  Note that older versions of Python
2666 (pre-1.5) used @file{$prefix/lib/site-python} so future versions of
2667 Automake's Python support may provide backwards compatibility.
2669 @item PYTHON_SITE_PACKAGE
2670 The string @code{$PYTHON_SITE/$PACKAGE}.  This is the default
2671 installation directory for a Python `package.'
2673 @item PYTHON_SITE_INSTALL
2674 The top-level directory in which the Python files will be installed.  It
2675 will be the value of either @samp{PYTHON_SITE} or @samp{PYTHON_PACKAGE}
2676 depending on the argument given to @code{AM_CHECK_PYTHON}.
2678 @item PYTHON_SITE_EXEC
2679 The location of the platform-dependent @file{site-packages} directory,
2680 where shared library extensions should be placed.  Note that older
2681 versions of Python (pre-1.5) used @file{sharedmodules} so future version
2682 of Automake's Python support may provide backwards compatibility.
2684 @end table
2686 @vindex PYCFILES
2687 @vindex PYOFILES
2689 By default Automake will byte-compile all Python source files to both
2690 @file{.pyc} and @file{.pyo} forms.  If you wish to avoid generating the
2691 optimized byte-code files, simply define the variable @code{PYOFILES} to
2692 be empty.  Similarly, if you don't wish to generate the standard
2693 byte-compiled files, define the variable @code{PYCFILES} to be empty.
2696 @node Documentation, Install, Other GNU Tools, Top
2697 @chapter Building documentation
2699 Currently Automake provides support for Texinfo and man pages.
2701 @menu
2702 * Texinfo::                     Texinfo
2703 * Man pages::                   Man pages
2704 @end menu
2707 @node Texinfo, Man pages, Documentation, Documentation
2708 @section Texinfo
2710 @cindex _TEXINFOS primary, defined
2711 @cindex TEXINFOS primary, defined
2712 @cindex Primary variable, TEXINFOS
2714 If the current directory contains Texinfo source, you must declare it
2715 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
2716 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
2717 here.  Note that any Texinfo source file must end in the @file{.texi} or
2718 @file{.texinfo} extension.
2719 @vindex TEXINFOS
2720 @vindex info_TEXINFOS
2722 @cindex Texinfo macro, VERSION
2723 @cindex Texinfo macro, UPDATED
2724 @cindex Texinfo macro, EDITION
2726 @cindex VERSION Texinfo macro
2727 @cindex UPDATED Texinfo macro
2728 @cindex EDITION Texinfo macro
2730 @cindex mdate-sh
2732 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
2733 that file will be automatically generated.  The file @file{version.texi}
2734 defines three Texinfo macros you can reference: @code{EDITION},
2735 @code{VERSION}, and @code{UPDATED}.  The first two hold the version
2736 number of your package (but are kept separate for clarity); the last is
2737 the date the primary file was last modified.  The @file{version.texi}
2738 support requires the @code{mdate-sh} program; this program is supplied
2739 with Automake and automatically included when @code{automake} is invoked
2740 with the @code{--add-missing} option.
2742 If you have multiple Texinfo files, and you want to use the
2743 @file{version.texi} feature, then you have to have a separate version
2744 file for each Texinfo file.  Automake will treat any include in a
2745 Texinfo file that matches @samp{vers*.texi} just as an automatically
2746 generated version file.
2748 Sometimes an info file actually depends on more than one @file{.texi}
2749 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
2750 @file{gpl.texi}.  You can tell Automake about these dependencies using
2751 the @code{@var{texi}_TEXINFOS} variable.  Here is how GNU Hello does it:
2752 @vindex TEXINFOS
2753 @vindex _TEXINFOS
2755 @example
2756 info_TEXINFOS = hello.texi
2757 hello_TEXINFOS = gpl.texi
2758 @end example
2760 @cindex texinfo.tex
2762 By default, Automake requires the file @file{texinfo.tex} to appear in
2763 the same directory as the Texinfo source.  However, if you used
2764 @code{AC_CONFIG_AUX_DIR} in @file{configure.in} (@pxref{Input, , Finding
2765 `configure' Input, autoconf, The Autoconf Manual}), then
2766 @file{texinfo.tex} is looked for there.  Automake supplies
2767 @file{texinfo.tex} if @samp{--add-missing} is given.
2769 @vindex TEXINFO_TEX
2771 If your package has Texinfo files in many directories, you can use the
2772 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
2773 @file{texinfo.tex} for your package.  The value of this variable should
2774 be the relative path from the current @file{Makefile.am} to
2775 @file{texinfo.tex}:
2777 @example
2778 TEXINFO_TEX = ../doc/texinfo.tex
2779 @end example
2781 @opindex no-texinfo.tex
2783 The option @samp{no-texinfo.tex} can be used to eliminate the
2784 requirement for @file{texinfo.tex}.  Use of the variable
2785 @code{TEXINFO_TEX} is preferable, however, because that allows the
2786 @code{dvi} target to still work.
2788 @cindex Target, install-info
2789 @cindex Target, noinstall-info
2790 @cindex install-info target
2791 @cindex noinstall-info target
2793 @opindex no-installinfo
2794 @trindex install-info
2796 Automake generates an @code{install-info} target; some people apparently
2797 use this.  By default, info pages are installed by @samp{make install}.
2798 This can be prevented via the @code{no-installinfo} option.
2801 @node Man pages,  , Texinfo, Documentation
2802 @section Man pages
2804 @cindex _MANS primary, defined
2805 @cindex MANS primary, defined
2806 @cindex Primary variable, MANS
2808 A package can also include man pages (but see the GNU standards on this
2809 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.)  Man
2810 pages are declared using the @samp{MANS} primary.  Generally the
2811 @code{man_MANS} macro is used.  Man pages are automatically installed in
2812 the correct subdirectory of @code{mandir}, based on the file extension.
2813 @vindex MANS
2814 @vindex man_MANS
2816 File extensions such as @samp{.1c} are handled by looking for the valid
2817 part of the extension and using that to determine the correct
2818 subdirectory of @code{mandir}.  Valid section names are the digits
2819 @samp{0} through @samp{9}, and the letters @samp{l} and @samp{n}.
2821 Sometimes developers prefer to name a man page something like
2822 @file{foo.man} in the source, and then rename it to have the correct
2823 suffix, e.g. @file{foo.1}, when installing the file.  Automake also
2824 supports this mode.  For a valid section named @var{SECTION}, there is a
2825 corresponding directory named @samp{man@var{SECTION}dir}, and a
2826 corresponding @samp{_MANS} variable.  Files listed in such a variable
2827 are installed in the indicated section.  If the file already has a
2828 valid suffix, then it is installed as-is; otherwise the file suffix is
2829 changed to match the section.
2831 For instance, consider this example:
2832 @example
2833 man1_MANS = rename.man thesame.1 alsothesame.1c
2834 @end example
2836 In this case, @file{rename.man} will be renamed to @file{rename.1} when
2837 installed, but the other files will keep their names.
2839 @cindex Target, install-man
2840 @cindex Target, noinstall-man
2841 @cindex install-man target
2842 @cindex noinstall-man target
2844 @c Use @samp{make install} per documentation: (texi)code.
2845 By default, man pages are installed by @samp{make install}.  However,
2846 since the GNU project does not require man pages, many maintainers do
2847 not expend effort to keep the man pages up to date.  In these cases, the
2848 @code{no-installman} option will prevent the man pages from being
2849 installed by default.  The user can still explicitly install them via
2850 @samp{make install-man}.
2851 @opindex no-installman
2852 @trindex install-man
2854 Here is how the documentation is handled in GNU @code{cpio} (which
2855 includes both Texinfo documentation and man pages):
2857 @example
2858 info_TEXINFOS = cpio.texi
2859 man_MANS = cpio.1 mt.1
2860 EXTRA_DIST = $(man_MANS)
2861 @end example
2863 Texinfo source and info pages are all considered to be source for the
2864 purposes of making a distribution.
2866 Man pages are not currently considered to be source, because it is not
2867 uncommon for man pages to be automatically generated.  For the same
2868 reason, they are not automatically included in the distribution.
2871 @node Install, Clean, Documentation, Top
2872 @chapter What Gets Installed
2874 @cindex Installation support
2875 @cindex make install support
2877 Naturally, Automake handles the details of actually installing your
2878 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
2879 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
2880 automatically installed in the appropriate places.
2882 Automake also handles installing any specified info and man pages.
2884 Automake generates separate @code{install-data} and @code{install-exec}
2885 targets, in case the installer is installing on multiple machines which
2886 share directory structure---these targets allow the machine-independent
2887 parts to be installed only once.  The @code{install} target depends on
2888 both of these targets.
2889 @trindex install-data
2890 @trindex install-exec
2891 @trindex install
2893 Automake also generates an @code{uninstall} target, an
2894 @code{installdirs} target, and an @code{install-strip} target.
2895 @trindex uninstall
2896 @trindex installdirs
2897 @trindex install-strip
2899 It is possible to extend this mechanism by defining an
2900 @code{install-exec-local} or @code{install-data-local} target.  If these
2901 targets exist, they will be run at @samp{make install} time.
2902 @trindex install-exec-local
2903 @trindex install-data-local
2905 Variables using the standard directory prefixes @samp{data},
2906 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
2907 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
2908 installed by @samp{install-data}.
2910 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
2911 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
2912 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
2913 @samp{install-exec}.
2915 Any variable using a user-defined directory prefix with @samp{exec} in
2916 the name (e.g. @samp{myexecbin_PROGRAMS} is installed by
2917 @samp{install-exec}.  All other user-defined prefixes are installed by
2918 @samp{install-data}.
2920 @vindex DESTDIR
2921 Automake generates support for the @samp{DESTDIR} variable in all
2922 install rules.  @samp{DESTDIR} is used during the @samp{make install}
2923 step to relocate install objects into a staging area.  Each object and
2924 path is prefixed with the value of @samp{DESTDIR} before being copied
2925 into the install area.  Here is an example of typical DESTDIR usage:
2927 @example
2928 make DESTDIR=/tmp/staging install
2929 @end example
2931 This places install objects in a directory tree built under
2932 @file{/tmp/staging}.  If @file{/gnu/bin/foo} and
2933 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
2934 would install @file{/tmp/staging/gnu/bin/foo} and
2935 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
2937 This feature is commonly used to build install images and packages.  For
2938 more information, see @ref{Makefile Conventions, , , standards, The GNU
2939 Coding Standards}.
2942 @node Clean, Dist, Install, Top
2943 @chapter What Gets Cleaned
2945 @cindex make clean support
2947 The GNU Makefile Standards specify a number of different clean rules.
2948 @c FIXME xref
2949 Generally the files that can be cleaned are determined automatically by
2950 Automake.  Of course, Automake also recognizes some variables that can
2951 be defined to specify additional files to clean.  These variables are
2952 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
2953 @code{MAINTAINERCLEANFILES}.
2954 @vindex MOSTLYCLEANFILES
2955 @vindex CLEANFILES
2956 @vindex DISTCLEANFILES
2957 @vindex MAINTAINERCLEANFILES
2960 @node Dist, Tests, Clean, Top
2961 @chapter What Goes in a Distribution
2963 @cindex make dist
2964 @cindex make distcheck
2966 The @code{dist} target in the generated @file{Makefile.in} can be used
2967 to generate a gzip'd @code{tar} file for distribution.  The tar file is
2968 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
2969 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
2970 @cvindex PACKAGE
2971 @cvindex VERSION
2972 @trindex dist
2973 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
2974 is run.  The default setting is @samp{--best}.
2976 For the most part, the files to distribute are automatically found by
2977 Automake: all source files are automatically included in a distribution,
2978 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
2979 has a built-in list of commonly used files which, if present in the
2980 current directory, are automatically included.  This list is printed by
2981 @samp{automake --help}.  Also, files which are read by @code{configure}
2982 (i.e. the source files corresponding to the files specified in the
2983 @code{AC_OUTPUT} invocation) are automatically distributed.
2985 Still, sometimes there are files which must be distributed, but which
2986 are not covered in the automatic rules.  These files should be listed in
2987 the @code{EXTRA_DIST} variable.  You can mention files from
2988 subdirectories in @code{EXTRA_DIST}.  You can also mention a directory
2989 there; in this case the entire directory will be recursively copied into
2990 the distribution.  Please note that this will also copy
2991 @emph{everything} in the directory, including CVS/RCS version control
2992 files.
2994 @vindex EXTRA_DIST
2996 Sometimes you need tighter control over what does @emph{not} go into the
2997 distribution; for instance you might have source files which are
2998 generated and which you do not want to distribute.  In this case
2999 Automake gives fine-grained control using the @samp{dist} and
3000 @samp{nodist} prefixes.  Any primary or @samp{_SOURCES} variable can be
3001 prefixed with @samp{dist_} to add the listed files to the distribution.
3002 Similarly, @samp{nodist_} can be used to omit the files from the
3003 distribution.
3004 @vindex dist_
3005 @vindex nodist_
3007 As an example, here is how you would cause some data to be distributed
3008 while leaving some source code out of the distribution:
3010 @example
3011 dist_data_DATA = distribute-this
3012 bin_PROGRAMS = foo
3013 nodist_foo_SOURCES = do-not-distribute.c
3014 @end example
3016 Another way to to use this is for removing unnecessary files that get
3017 recursively included by specifying a directory in EXTRA_DIST:
3019 @example
3020 EXTRA_DIST = doc
3022 dist-hook:
3023         rm -rf `find $(distdir)/doc -name CVS`
3024 @end example
3026 If you define @code{SUBDIRS}, Automake will recursively include the
3027 subdirectories in the distribution.  If @code{SUBDIRS} is defined
3028 conditionally (@pxref{Conditionals}), Automake will normally include all
3029 directories that could possibly appear in @code{SUBDIRS} in the
3030 distribution.  If you need to specify the set of directories
3031 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
3032 list of subdirectories to include in the distribution.
3033 @vindex DIST_SUBDIRS
3035 @trindex dist-hook
3037 Occasionally it is useful to be able to change the distribution before
3038 it is packaged up.  If the @code{dist-hook} target exists, it is run
3039 after the distribution directory is filled, but before the actual tar
3040 (or shar) file is created.  One way to use this is for distributing
3041 files in subdirectories for which a new @file{Makefile.am} is overkill:
3043 @example
3044 dist-hook:
3045         mkdir $(distdir)/random
3046         cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
3047 @end example
3049 Automake also generates a @code{distcheck} target which can be of help
3050 to ensure that a given distribution will actually work.
3051 @code{distcheck} makes a distribution, and then tries to do a
3052 @code{VPATH} build.
3053 @trindex distcheck
3055 If the target @code{distcheck-hook} is defined in your
3056 @file{Makefile.am}, then it will be invoked by @code{distcheck} after
3057 the new distribution has been unpacked, but before the unpacked copy is
3058 configured and built.  Your @code{distcheck-hook} can do almost
3059 anything, though as always caution is advised.  Generally this hook is
3060 used to check for potential distribution errors not caught by the
3061 standard mechanism.
3064 @node Tests, Options, Dist, Top
3065 @chapter Support for test suites
3067 @cindex Test suites
3068 @cindex make check
3070 Automake supports two forms of test suites.
3072 If the variable @code{TESTS} is defined, its value is taken to be a list
3073 of programs to run in order to do the testing.  The programs can either
3074 be derived objects or source objects; the generated rule will look both
3075 in @code{srcdir} and @file{.}.  Programs needing data files should look
3076 for them in @code{srcdir} (which is both an environment variable and a
3077 make variable) so they work when building in a separate directory
3078 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
3079 Manual}), and in particular for the @code{distcheck} target
3080 (@pxref{Dist}).
3082 @cindex Exit status 77, special interpretation
3084 The number of failures will be printed at the end of the run.  If a
3085 given test program exits with a status of 77, then its result is ignored
3086 in the final count.  This feature allows non-portable tests to be
3087 ignored in environments where they don't make sense.
3089 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
3090 variables for the test run; the environment variable @code{srcdir} is
3091 set in the rule.  If all your test programs are scripts, you can also
3092 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
3093 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
3094 @vindex TESTS
3095 @vindex TESTS_ENVIRONMENT
3097 If @uref{ftp://prep.ai.mit.edu/pub/gnu/dejagnu-1.3.tar.gz,
3098 @samp{dejagnu}} appears in @code{AUTOMAKE_OPTIONS}, then a
3099 @code{dejagnu}-based test suite is assumed.  The variable
3100 @code{DEJATOOL} is a list of names which are passed, one at a time, as
3101 the @code{--tool} argument to @code{runtest} invocations; it defaults to
3102 the name of the package.
3104 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
3105 @code{--srcdir} flags that are passed to dejagnu by default; this can be
3106 overridden if necessary.
3107 @vindex RUNTESTDEFAULTFLAGS
3109 The variables @code{EXPECT}, @code{RUNTEST} and @code{RUNTESTFLAGS} can
3110 also be overridden to provide project-specific values.  For instance,
3111 you will need to do this if you are testing a compiler toolchain,
3112 because the default values do not take into account host and target
3113 names.
3114 @opindex dejagnu
3115 @vindex DEJATOOL
3116 @vindex EXPECT
3117 @vindex RUNTEST
3118 @vindex RUNTESTFLAGS
3119 @c FIXME xref dejagnu
3121 If you're not using dejagnu, you may define the variable
3122 @samp{XFAIL_TESTS} to a list of tests (usually a subset of @samp{TESTS})
3123 that are expected to fail.  This will reverse the result of those tests.
3125 In either case, the testing is done via @samp{make check}.
3128 @node Options, Miscellaneous, Tests, Top
3129 @chapter Changing Automake's Behavior
3131 Various features of Automake can be controlled by options in the
3132 @file{Makefile.am}.  Such options are listed in a special variable named
3133 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
3134 @vindex AUTOMAKE_OPTIONS
3136 @table @asis
3137 @item @code{gnits}
3138 @itemx @code{gnu}
3139 @itemx @code{foreign}
3140 @item @code{cygnus}
3141 @cindex Option, gnits
3142 @cindex Option, gnu
3143 @cindex Option, foreign
3144 @cindex Option, cygnus
3146 Set the strictness as appropriate.  The @code{gnits} option also implies
3147 @code{readme-alpha} and @code{check-news}.
3149 @item @code{ansi2knr}
3150 @itemx @code{path/ansi2knr}
3151 @cindex Option, ansi2knr
3152 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceded by a
3153 path, the generated @file{Makefile.in} will look in the specified
3154 directory to find the @file{ansi2knr} program.  Generally the path
3155 should be a relative path to another directory in the same distribution
3156 (though Automake currently does not check this).
3158 @item @code{check-news}
3159 @cindex Option, check-news
3160 Cause @code{make dist} to fail unless the current version number appears
3161 in the first few lines of the @file{NEWS} file.
3163 @item @code{dejagnu}
3164 @cindex Option, dejagnu
3165 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
3167 @item @code{dist-bzip2}
3168 @cindex Option, dist-bzip2
3169 Generate a @code{dist-bzip2} target as well as the ordinary @code{dist}
3170 target.  This new target will create a bzip2 tar archive of the
3171 distribution.  bzip2 archives are frequently smaller than even gzipped
3172 archives.
3173 @trindex dist-bzip2
3175 @item @code{dist-shar}
3176 @cindex Option, dist-shar
3177 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
3178 target.  This new target will create a shar archive of the
3179 distribution.
3180 @trindex dist-shar
3182 @item @code{dist-zip}
3183 @cindex Option, dist-zip
3184 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
3185 target.  This new target will create a zip archive of the distribution.
3186 @trindex dist-zip
3188 @item @code{dist-tarZ}
3189 @cindex Option, dist-tarZ
3190 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
3191 target.  This new target will create a compressed tar archive of the
3192 distribution.
3193 @trindex dist-tarZ
3195 @item @code{no-dependencies}
3196 @cindex Option, no-dependencies
3197 This is similar to using @samp{--include-deps} on the command line, but
3198 is useful for those situations where you don't have the necessary bits
3199 to make automatic dependency tracking work @xref{Dependencies}.  In this
3200 case the effect is to effectively disable automatic dependency tracking.
3202 @item @code{no-installinfo}
3203 @cindex Option, no-installinfo
3204 The generated @file{Makefile.in} will not cause info pages to be built
3205 or installed by default.  However, @code{info} and @code{install-info}
3206 targets will still be available.  This option is disallowed at
3207 @samp{GNU} strictness and above.
3208 @trindex info
3209 @trindex install-info
3211 @item @code{no-installman}
3212 @cindex Option, no-installman
3213 The generated @file{Makefile.in} will not cause man pages to be
3214 installed by default.  However, an @code{install-man} target will still
3215 be available for optional installation.  This option is disallowed at
3216 @samp{GNU} strictness and above.
3217 @trindex install-man
3219 @item @code{nostdinc}
3220 @cindex Option, nostdinc
3221 This option can be used to disable the standard @samp{-I} options which
3222 are ordinarily automatically provided by Automake.
3224 @item @code{no-texinfo.tex}
3225 @cindex Option, no-texinfo
3226 Don't require @file{texinfo.tex}, even if there are texinfo files in
3227 this directory.
3229 @item @code{readme-alpha}
3230 @cindex Option, readme-alpha
3231 If this release is an alpha release, and the file @file{README-alpha}
3232 exists, then it will be added to the distribution.  If this option is
3233 given, version numbers are expected to follow one of two forms.  The
3234 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
3235 element is a number; the final period and number should be left off for
3236 non-alpha releases.  The second form is
3237 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
3238 letter; it should be omitted for non-alpha releases.
3240 @item @var{version}
3241 @cindex Option, version
3242 A version number (e.g. @samp{0.30}) can be specified.  If Automake is not
3243 newer than the version specified, creation of the @file{Makefile.in}
3244 will be suppressed.
3245 @end table
3247 Unrecognized options are diagnosed by @code{automake}.
3250 @node Miscellaneous, Include, Options, Top
3251 @chapter Miscellaneous Rules
3253 There are a few rules and variables that didn't fit anywhere else.
3255 @menu
3256 * Tags::                        Interfacing to etags and mkid
3257 * Suffixes::                    Handling new file extensions
3258 @end menu
3261 @node Tags, Suffixes, Miscellaneous, Miscellaneous
3262 @section Interfacing to @code{etags}
3264 @cindex TAGS support
3266 Automake will generate rules to generate @file{TAGS} files for use with
3267 GNU Emacs under some circumstances.
3269 If any C, C++ or Fortran 77 source code or headers are present, then
3270 @code{tags} and @code{TAGS} targets will be generated for the directory.
3271 @trindex tags
3273 At the topmost directory of a multi-directory package, a @code{tags}
3274 target file will be generated which, when run, will generate a
3275 @file{TAGS} file that includes by reference all @file{TAGS} files from
3276 subdirectories.
3278 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
3279 will be generated.  This variable is intended for use in directories
3280 which contain taggable source that @code{etags} does not understand.
3281 @vindex ETAGS_ARGS
3283 Here is how Automake generates tags for its source, and for nodes in its
3284 Texinfo file:
3286 @example
3287 ETAGS_ARGS = automake.in --lang=none \
3288  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
3289 @end example
3291 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
3292 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
3293 are added directly to the dependencies for the @code{tags} target.
3294 @vindex TAGS_DEPENDENCIES
3296 Automake will also generate an @code{ID} target which will run
3297 @code{mkid} on the source.  This is only supported on a
3298 directory-by-directory basis.
3299 @trindex id
3301 Automake also supports the GNU Global Tags program.  The @code{GTAGS}
3302 target runs Global Tags automatically and puts the result in the top
3303 build directory.
3306 @node Suffixes,  , Tags, Miscellaneous
3307 @section Handling new file extensions
3309 @cindex Adding new SUFFIXES
3310 @cindex SUFFIXES, adding
3312 It is sometimes useful to introduce a new implicit rule to handle a file
3313 type that Automake does not know about.  If this is done, you must
3314 notify GNU Make of the new suffixes.  This can be done by putting a list
3315 of new suffixes in the @code{SUFFIXES} variable.
3316 @vindex SUFFIXES
3318 For instance, currently Automake does not provide any Java support.  If
3319 you wrote a macro to generate @samp{.class} files from @samp{.java}
3320 source files, you would also need to add these suffixes to the list:
3322 @example
3323 SUFFIXES = .java .class
3324 @end example
3326 Any given @code{SUFFIXES} go at the start of the generated suffixes
3327 list, followed by automake generated suffixes not already in the list.
3330 @node Include, Conditionals, Miscellaneous, Top
3331 @chapter Include
3333 @cmindex include
3334 To include another file (perhaps for common rules),
3335 the following syntax is supported:
3337 include ($(srcdir)|$(top_srcdir))/filename
3339 Using files in the current directory:
3340 @example
3341 include $(srcdir)/Makefile.extra
3342 @end example
3344 @example
3345 include Makefile.generated
3346 @end example
3348 Using a file in the top level directory:
3349 @example
3350 include $(top_srcdir)/filename
3351 @end example
3354 @node Conditionals, Gnits, Include, Top
3355 @chapter Conditionals
3357 @cindex Conditionals
3359 Automake supports a simple type of conditionals.
3361 @cvindex AM_CONDITIONAL
3362 Before using a conditional, you must define it by using
3363 @code{AM_CONDITIONAL} in the @code{configure.in} file (@pxref{Macros}).
3365 @defmac AM_CONDITIONAL (@var{conditional}, @var{condition})
3366 The conditional name, @var{conditional}, should be a simple string
3367 starting with a letter and containing only letters, digits, and
3368 underscores.  It must be different from @samp{TRUE} and @samp{FALSE}
3369 which are reserved by Automake.
3371 The shell @var{condition} (suitable for use in a shell @code{if}
3372 statement) is evaluated when @code{configure} is run.
3373 @end defmac
3375 @cindex --enable-debug, example
3376 @cindex Example conditional --enable-debug
3377 @cindex Conditional example,  --enable-debug
3379 Conditionals typically depend upon options which the user provides to
3380 the @code{configure} script.  Here is an example of how to write a
3381 conditional which is true if the user uses the @samp{--enable-debug}
3382 option.
3384 @example
3385 AC_ARG_ENABLE(debug,
3386 [  --enable-debug    Turn on debugging],
3387 [case "$@{enableval@}" in
3388   yes) debug=true ;;
3389   no)  debug=false ;;
3390   *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
3391 esac],[debug=false])
3392 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
3393 @end example
3395 Here is an example of how to use that conditional in @file{Makefile.am}:
3397 @cmindex if
3398 @cmindex endif
3399 @cmindex else
3401 @example
3402 if DEBUG
3403 DBG = debug
3404 else
3405 DBG =
3406 endif
3407 noinst_PROGRAMS = $(DBG)
3408 @end example
3410 This trivial example could also be handled using EXTRA_PROGRAMS
3411 (@pxref{A Program}).
3413 You may only test a single variable in an @code{if} statement, possibly
3414 negated using @samp{!}.  The @code{else} statement may be omitted.
3415 Conditionals may be nested to any depth.  You may specify an argument to
3416 @code{else} in which case it must be the negation of the condition used
3417 for the current @code{if}.  Similarly you may specify the condition
3418 which is closed by an @code{end}:
3420 @example
3421 if DEBUG
3422 DBG = debug
3423 else !DEBUG
3424 DBG =
3425 endif !DEBUG
3426 @end example
3428 @noindent
3429 Unbalanced conditions are errors.
3431 Note that conditionals in Automake are not the same as conditionals in
3432 GNU Make.  Automake conditionals are checked at configure time by the
3433 @file{configure} script, and affect the translation from
3434 @file{Makefile.in} to @file{Makefile}.  They are based on options passed
3435 to @file{configure} and on results that @file{configure} has discovered
3436 about the host system.  GNU Make conditionals are checked at @code{make}
3437 time, and are based on variables passed to the make program or defined
3438 in the @file{Makefile}.
3440 Automake conditionals will work with any make program.
3443 @node Gnits, Cygnus, Conditionals, Top
3444 @chapter The effect of @code{--gnu} and @code{--gnits}
3446 @cindex --gnu, required files
3447 @cindex --gnu, complete description
3449 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
3450 variable) causes @code{automake} to check the following:
3452 @itemize @bullet
3453 @item
3454 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
3455 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
3456 directory of the package.
3458 @item
3459 The options @samp{no-installman} and @samp{no-installinfo} are
3460 prohibited.
3461 @end itemize
3463 Note that this option will be extended in the future to do even more
3464 checking; it is advisable to be familiar with the precise requirements
3465 of the GNU standards.  Also, @samp{--gnu} can require certain
3466 non-standard GNU programs to exist for use by various maintainer-only
3467 targets; for instance in the future @code{pathchk} might be required for
3468 @samp{make dist}.
3470 @cindex --gnits, complete description
3472 The @samp{--gnits} option does everything that @samp{--gnu} does, and
3473 checks the following as well:
3475 @itemize @bullet
3476 @item
3477 @samp{make dist} will check to make sure the @file{NEWS} file has been
3478 updated to the current version.
3480 @item
3481 @samp{VERSION} is checked to make sure its format complies with Gnits
3482 standards.
3483 @c FIXME xref when standards are finished
3485 @item
3486 @cindex README-alpha
3487 If @samp{VERSION} indicates that this is an alpha release, and the file
3488 @file{README-alpha} appears in the topmost directory of a package, then
3489 it is included in the distribution.  This is done in @samp{--gnits}
3490 mode, and no other, because this mode is the only one where version
3491 number formats are constrained, and hence the only mode where Automake
3492 can automatically determine whether @file{README-alpha} should be
3493 included.
3495 @item
3496 The file @file{THANKS} is required.
3497 @end itemize
3500 @node Cygnus, Extending, Gnits, Top
3501 @chapter The effect of @code{--cygnus}
3503 @cindex Cygnus strictness
3505 Cygnus Solutions has slightly different rules for how a
3506 @file{Makefile.in} is to be constructed.  Passing @samp{--cygnus} to
3507 @code{automake} will cause any generated @file{Makefile.in} to comply
3508 with Cygnus rules.
3510 Here are the precise effects of @samp{--cygnus}:
3512 @itemize @bullet
3513 @item
3514 Info files are always created in the build directory, and not in the
3515 source directory.
3517 @item
3518 @file{texinfo.tex} is not required if a Texinfo source file is
3519 specified.  The assumption is that the file will be supplied, but in a
3520 place that Automake cannot find.  This assumption is an artifact of how
3521 Cygnus packages are typically bundled.
3523 @item
3524 @samp{make dist} will look for files in the build directory as well as
3525 the source directory.  This is required to support putting info files
3526 into the build directory.
3528 @item
3529 Certain tools will be searched for in the build tree as well as in the
3530 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
3531 @code{makeinfo} and @code{texi2dvi}.
3533 @item
3534 @code{--foreign} is implied.
3536 @item
3537 The options @samp{no-installinfo} and @samp{no-dependencies} are
3538 implied.
3540 @item
3541 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
3542 required.
3544 @item
3545 The @code{check} target doesn't depend on @code{all}.
3546 @end itemize
3548 GNU maintainers are advised to use @samp{gnu} strictness in preference
3549 to the special Cygnus mode.
3552 @node Extending, Distributing, Cygnus, Top
3553 @chapter When Automake Isn't Enough
3555 Automake's implicit copying semantics means that many problems can be
3556 worked around by simply adding some @code{make} targets and rules to
3557 @file{Makefile.in}.  Automake will ignore these additions.
3559 @cindex -local targets
3560 @cindex local targets
3562 There are some caveats to doing this.  Although you can overload a
3563 target already used by Automake, it is often inadvisable, particularly
3564 in the topmost directory of a package with subdirectories.  However,
3565 various useful targets have a @samp{-local} version you can specify in
3566 your @file{Makefile.in}.  Automake will supplement the standard target
3567 with these user-supplied targets.
3569 @trindex  all-local
3570 @trindex  info-local
3571 @trindex  dvi-local
3572 @trindex  check-local
3573 @trindex  install-data-local
3574 @trindex  install-exec-local
3575 @trindex  uninstall-local
3576 @trindex  mostlyclean-local
3577 @trindex  clean-local
3578 @trindex  distclean-local
3580 The targets that support a local version are @code{all}, @code{info},
3581 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
3582 @code{uninstall}, and the various @code{clean} targets
3583 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
3584 @code{maintainer-clean}).  Note that there are no
3585 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
3586 use @code{uninstall-local}.  It doesn't make sense to uninstall just
3587 data or just executables.
3588 @trindex all
3589 @trindex info
3590 @trindex dvi
3591 @trindex check
3592 @trindex install-data
3593 @trindex install-exec
3594 @trindex uninstall
3596 For instance, here is one way to install a file in @file{/etc}:
3598 @example
3599 install-data-local:
3600         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
3601 @end example
3603 @cindex -hook targets
3604 @cindex hook targets
3606 Some targets also have a way to run another target, called a @dfn{hook},
3607 after their work is done.  The hook is named after the principal target,
3608 with @samp{-hook} appended.  The targets allowing hooks are
3609 @code{install-data}, @code{install-exec}, @code{dist}, and
3610 @code{distcheck}.
3611 @trindex install-data-hook
3612 @trindex install-exec-hook
3613 @trindex dist-hook
3615 For instance, here is how to create a hard link to an installed program:
3617 @example
3618 install-exec-hook:
3619         ln $(bindir)/program $(bindir)/proglink
3620 @end example
3622 @c FIXME should include discussion of variables you can use in these
3623 @c rules
3626 @node Distributing, Macro and Variable Index, Extending, Top
3627 @chapter Distributing @file{Makefile.in}s
3629 Automake places no restrictions on the distribution of the resulting
3630 @file{Makefile.in}s.  We still encourage software authors to distribute
3631 their work under terms like those of the GPL, but doing so is not
3632 required to use Automake.
3634 Some of the files that can be automatically installed via the
3635 @code{--add-missing} switch do fall under the GPL; examine each file
3636 to see.
3639 @page
3640 @node Macro and Variable Index, General Index, Distributing, Top
3641 @unnumbered Macro and Variable Index
3643 @printindex vr
3646 @page
3647 @node General Index,  , Macro and Variable Index, Top
3648 @unnumbered General Index
3650 @printindex cp
3653 @page
3654 @contents
3655 @bye