* space.test: New file.
[automake.git] / automake.texi
blob78e16e32f4939163a58a36360504025f98e959a3
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename automake.info
4 @settitle automake
5 @setchapternewpage off
6 @c %**end of header
8 @include version.texi
10 @dircategory GNU admin
11 @direntry
12 * automake: (automake).         Making Makefile.in's
13 @end direntry
15 @dircategory Individual utilities
16 @direntry
17 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4
18 @end direntry
20 @ifinfo
21 This file documents GNU automake @value{VERSION}
23 Copyright 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 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 @ifinfo
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.in
116 * Top level::                   The top-level Makefile.am
117 * Programs::                    Building programs and libraries
118 * Other objects::               Other derived objects
119 * Other GNU Tools::             Other GNU Tools
120 * Documentation::               Building documentation
121 * Install::                     What gets installed
122 * Clean::                       What gets cleaned
123 * Dist::                        What goes in a distribution
124 * Tests::                       Support for test suites
125 * Options::                     Changing Automake's behavior
126 * Miscellaneous::               Miscellaneous rules
127 * Include::                     Including extra files in an Automake template.
128 * Conditionals::                Conditionals
129 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
130 * Cygnus::                      The effect of @code{--cygnus}
131 * Extending::                   Extending Automake
132 * Distributing::                Distributing the Makefile.in
133 * Future::                      Some ideas for the future
134 * Macro and Variable Index::    
135 * General Index::               
136 @end menu
138 @end ifinfo
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.
171 @cindex Automake requirements
172 @cindex Requirements, Automake
174 Automake requires @code{perl} in order to generate the
175 @file{Makefile.in}s.  However, the distributions created by Automake are
176 fully GNU standards-compliant, and do not require @code{perl} in order
177 to be built.
179 @cindex BUGS, reporting
180 @cindex Reporting BUGS
181 @cindex E-mail, bug reports
183 Mail suggestions and bug reports for Automake to
184 @email{bug-automake@@gnu.org}.
187 @node Generalities, Examples, Introduction, Top
188 @chapter General ideas
190 The following sections cover a few basic ideas that will help you
191 understand how Automake works.
193 @menu
194 * General Operation::           General operation of Automake
195 * Depth::                       The kinds of packages
196 * Strictness::                  Standards conformance checking
197 * Uniform::                     The Uniform Naming Scheme
198 * Canonicalization::            How derived variables are named
199 @end menu
202 @node General Operation, Depth, Generalities, Generalities
203 @section General Operation
205 Automake works by reading a @file{Makefile.am} and generating a
206 @file{Makefile.in}.  Certain macros and targets defined in the
207 @file{Makefile.am} instruct Automake to generate more specialized code;
208 for instance, a @samp{bin_PROGRAMS} macro definition will cause targets
209 for compiling and linking programs to be generated.
211 @cindex Non-standard targets
212 @cindex cvs-dist, non-standard example
213 @trindex cvs-dist
215 The macro definitions and targets in the @file{Makefile.am} are copied
216 verbatim into the generated file.  This allows you to add arbitrary code
217 into the generated @file{Makefile.in}.  For instance the Automake
218 distribution includes a non-standard @code{cvs-dist} target, which the
219 Automake maintainer uses to make distributions from his source control
220 system.
222 @cindex GNU make extensions
224 Note that GNU make extensions are not recognized by Automake.  Using
225 such extensions in a @file{Makefile.am} will lead to errors or confusing
226 behavior.
228 Automake tries to group comments with adjoining targets and macro
229 definitions in an intelligent way.
231 @cindex Make targets, overriding
232 @cindex Overriding make targets
234 A target defined in @file{Makefile.am} generally overrides any such
235 target of a similar name that would be automatically generated by
236 @code{automake}.  Although this is a supported feature, it is generally
237 best to avoid making use of it, as sometimes the generated rules are
238 very particular.
240 @cindex Macros, overriding
241 @cindex Overriding make macros
243 Similarly, a macro defined in @file{Makefile.am} will override any
244 definition of the macro that @code{automake} would ordinarily create.
245 This feature is more often useful than the ability to override a target
246 definition.  Be warned that many of the macros generated by
247 @code{automake} are considered to be for internal use only, and their
248 names might change in future releases.
250 @cindex Recursive operation of Automake
251 @cindex Automake, recursive operation
252 @cindex Example of recursive operation
254 When examining a macro definition, Automake will recursively examine
255 macros referenced in the definition.  For example, if Automake is
256 looking at the content of @code{foo_SOURCES} in this snippet
258 @example
259 xs = a.c b.c
260 foo_SOURCES = c.c $(xs)
261 @end example
263 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
264 contents of @code{foo_SOURCES}.
266 @cindex ## (special Automake comment)
267 @cindex Special Automake comment
268 @cindex Comment, special to Automake
270 Automake also allows a form of comment which is @emph{not} copied into
271 the output; all lines beginning with @samp{##} are completely ignored by
272 Automake.
274 It is customary to make the first line of @file{Makefile.am} read:
276 @cindex Makefile.am, first line
277 @cindex First line of Makefile.am
279 @example
280 ## Process this file with automake to produce Makefile.in
281 @end example
283 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
284 @c I don't know quite what to say.
286 @c FIXME document customary ordering of Makefile.am here!
289 @node Depth, Strictness, General Operation, Generalities
290 @section Depth
292 @cindex Flat package
293 @cindex Package, Flat
294 @cindex Shallow package
295 @cindex Package, shallow
296 @cindex Deep package
297 @cindex Package, deep
299 @code{automake} supports three kinds of directory hierarchy:
300 @samp{flat}, @samp{shallow}, and @samp{deep}.
302 A @dfn{flat} package is one in which all the files are in a single
303 directory.  The @file{Makefile.am} for such a package by definition
304 lacks a @code{SUBDIRS} macro.  An example of such a package is
305 @code{termutils}.
306 @vindex SUBDIRS
308 @cindex SUBDIRS, deep package
310 A @dfn{deep} package is one in which all the source lies in
311 subdirectories; the top level directory contains mainly configuration
312 information.  GNU @code{cpio} is a good example of such a package, as is
313 GNU @code{tar}.  The top level @file{Makefile.am} for a deep package
314 will contain a @code{SUBDIRS} macro, but no other macros to define
315 objects which are built.
317 A @dfn{shallow} package is one in which the primary source resides in
318 the top-level directory, while various parts (typically libraries)
319 reside in subdirectories.  Automake is one such package (as is GNU
320 @code{make}, which does not currently use @code{automake}).
323 @node Strictness, Uniform, Depth, Generalities
324 @section Strictness
326 @cindex Non-GNU packages
328 While Automake is intended to be used by maintainers of GNU packages, it
329 does make some effort to accommodate those who wish to use it, but do
330 not want to use all the GNU conventions.
332 @cindex Strictness, defined
333 @cindex Strictness, foreign
334 @cindex foreign strictness
335 @cindex Strictness, gnu
336 @cindex gnits strictness
337 @cindex Strictness, gnits
338 @cindex gnits strictness
340 To this end, Automake supports three levels of @dfn{strictness}---the
341 strictness indicating how stringently Automake should check standards
342 conformance.
344 The valid strictness levels are:
346 @table @samp
347 @item foreign
348 Automake will check for only those things which are absolutely
349 required for proper operations.  For instance, whereas GNU standards
350 dictate the existence of a @file{NEWS} file, it will not be required in
351 this mode.  The name comes from the fact that Automake is intended to be
352 used for GNU programs; these relaxed rules are not the standard mode of
353 operation.
355 @item gnu
356 Automake will check---as much as possible---for compliance to the GNU
357 standards for packages.  This is the default.
359 @item gnits
360 Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
361 standards}.  These are based on the GNU standards, but are even more
362 detailed.  Unless you are a Gnits standards contributor, it is
363 recommended that you avoid this option until such time as the Gnits
364 standard is actually published.
365 @end table
367 For more information on the precise implications of the strictness
368 level, see @ref{Gnits}.
371 @node Uniform, Canonicalization, Strictness, Generalities
372 @section The Uniform Naming Scheme
374 @cindex Uniform naming scheme
376 Automake macros (from here on referred to as @emph{variables}) generally
377 follow a @dfn{uniform naming scheme} that makes it easy to decide how
378 programs (and other derived objects) are built, and how they are
379 installed.  This scheme also supports @code{configure} time
380 determination of what should be built.
382 @cindex _PROGRAMS primary variable
383 @cindex PROGRAMS primary variable
384 @cindex Primary variable, PROGRAMS
386 @cindex Primary variable, defined
388 At @code{make} time, certain variables are used to determine which
389 objects are to be built.  These variables are called @dfn{primary
390 variables}.  For instance, the primary variable @code{PROGRAMS} holds a
391 list of programs which are to be compiled and linked.
392 @vindex PROGRAMS
394 @cindex pkglibdir, defined
395 @cindex pkgincludedir, defined
396 @cindex pkgdatadir, defined
398 @vindex pkglibdir
399 @vindex pkgincludedir
400 @vindex pkgdatadir
402 A different set of variables is used to decide where the built objects
403 should be installed.  These variables are named after the primary
404 variables, but have a prefix indicating which standard directory should
405 be used as the installation directory.  The standard directory names are
406 given in the GNU standards (@pxref{Directory Variables, , , standards,
407 The GNU Coding Standards}).  Automake extends this list with
408 @code{pkglibdir}, @code{pkgincludedir}, and @code{pkgdatadir}; these are
409 the same as the non-@samp{pkg} versions, but with @samp{@@PACKAGE@@}
410 appended.  For instance, @code{pkglibdir} is defined as
411 @code{$(libdir)/@@PACKAGE@@}.
412 @cvindex PACKAGE
414 @cindex EXTRA_, prepending
416 For each primary, there is one additional variable named by prepending
417 @samp{EXTRA_} to the primary name.  This variable is used to list
418 objects which may or may not be built, depending on what
419 @code{configure} decides.  This variable is required because Automake
420 must statically know the entire list of objects that may be built in
421 order to generate a @file{Makefile.in} that will work in all cases.
423 @cindex EXTRA_PROGRAMS, defined
424 @cindex Example, EXTRA_PROGRAMS
425 @cindex cpio example
427 For instance, @code{cpio} decides at configure time which programs are
428 built.  Some of the programs are installed in @code{bindir}, and some
429 are installed in @code{sbindir}:
431 @example
432 EXTRA_PROGRAMS = mt rmt
433 bin_PROGRAMS = cpio pax
434 sbin_PROGRAMS = @@PROGRAMS@@
435 @end example
437 Defining a primary variable without a prefix (e.g. @code{PROGRAMS}) is
438 an error.
440 Note that the common @samp{dir} suffix is left off when constructing the
441 variable names; thus one writes @samp{bin_PROGRAMS} and not
442 @samp{bindir_PROGRAMS}.
444 Not every sort of object can be installed in every directory.  Automake
445 will flag those attempts it finds in error.  Automake will also diagnose
446 obvious misspellings in directory names.
448 @cindex Extending list of installation directories
449 @cindex Installation directories, extending list
451 Sometimes the standard directories---even as augmented by Automake---
452 are not enough.  In particular it is sometimes useful, for clarity, to
453 install objects in a subdirectory of some predefined directory.  To this
454 end, Automake allows you to extend the list of possible installation
455 directories.  A given prefix (e.g. @samp{zar}) is valid if a variable of
456 the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
458 @cindex HTML support, example
460 For instance, until HTML support is part of Automake, you could use this
461 to install raw HTML documentation:
463 @example
464 htmldir = $(prefix)/html
465 html_DATA = automake.html
466 @end example
468 @cindex noinst primary prefix, definition
470 The special prefix @samp{noinst} indicates that the objects in question
471 should not be installed at all.
473 @cindex check primary prefix, definition
475 The special prefix @samp{check} indicates that the objects in question
476 should not be built until the @code{make check} command is run.
478 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
479 @samp{LISP}, @samp{PYTHON}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS},
480 @samp{MANS}, and @samp{TEXINFOS}.
481 @vindex PROGRAMS
482 @vindex LIBRARIES
483 @vindex LISP
484 @vindex PYTHON
485 @vindex SCRIPTS
486 @vindex DATA
487 @vindex HEADERS
488 @vindex MANS
489 @vindex TEXINFOS
492 @node Canonicalization,  , Uniform, Generalities
493 @section How derived variables are named
495 @cindex canonicalizing Automake macros
497 Sometimes a Makefile variable name is derived from some text the user
498 supplies.  For instance, program names are rewritten into Makefile macro
499 names.  Automake canonicalizes this text, so that it does not have to
500 follow Makefile macro naming rules.  All characters in the name except
501 for letters, numbers, and the underscore are turned into underscores
502 when making macro references.  For example, if your program is named
503 @code{sniff-glue}, the derived variable name would be
504 @code{sniff_glue_SOURCES}, not @code{sniff-glue_SOURCES}.
506 @node Examples, Invoking Automake, Generalities, Top
507 @chapter Some example packages
509 @menu
510 * Complete::                    A simple example, start to finish
511 * Hello::                       A classic program
512 * etags::                       Building etags and ctags
513 @end menu
516 @node Complete, Hello, Examples, Examples
517 @section A simple example, start to finish
519 @cindex Complete example
521 Let's suppose you just finished writing @code{zardoz}, a program to make
522 your head float from vortex to vortex.  You've been using Autoconf to
523 provide a portability framework, but your @file{Makefile.in}s have been
524 ad-hoc.  You want to make them bulletproof, so you turn to Automake.
526 @cindex AM_INIT_AUTOMAKE, example use
528 The first step is to update your @file{configure.in} to include the
529 commands that @code{automake} needs.  The way to do this is to add an
530 @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
532 @example
533 AM_INIT_AUTOMAKE(zardoz, 1.0)
534 @end example
536 Since your program doesn't have any complicating factors (e.g., it
537 doesn't use @code{gettext}, it doesn't want to build a shared library),
538 you're done with this part.  That was easy!
540 @cindex aclocal program, introduction
541 @cindex aclocal.m4, preexisting
542 @cindex acinclude.m4, defined
544 Now you must regenerate @file{configure}.  But to do that, you'll need
545 to tell @code{autoconf} how to find the new macro you've used.  The
546 easiest way to do this is to use the @code{aclocal} program to generate
547 your @file{aclocal.m4} for you.  But wait... you already have an
548 @file{aclocal.m4}, because you had to write some hairy macros for your
549 program.  The @code{aclocal} program lets you put your own macros into
550 @file{acinclude.m4}, so simply rename and then run:
552 @example
553 mv aclocal.m4 acinclude.m4
554 aclocal
555 autoconf
556 @end example
558 @cindex zardoz example
560 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
561 Since @code{zardoz} is a user program, you want to install it where the
562 rest of the user programs go.  Additionally, @code{zardoz} has some
563 Texinfo documentation.  Your @file{configure.in} script uses
564 @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
565 So here's what you'd write:
567 @example
568 bin_PROGRAMS = zardoz
569 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
570 zardoz_LDADD = @@LIBOBJS@@
572 info_TEXINFOS = zardoz.texi
573 @end example
575 Now you can run @code{automake --add-missing} to generate your
576 @file{Makefile.in} and grab any auxiliary files you might need, and
577 you're done!
580 @node Hello, etags, Complete, Examples
581 @section A classic program
583 @cindex Example, GNU Hello
584 @cindex Hello example
585 @cindex GNU Hello, example
587 @uref{ftp://prep.ai.mit.edu/pub/gnu/hello-1.3.tar.gz, GNU hello} is
588 renowned for its classic simplicity and versatility.  This section shows
589 how Automake could be used with the GNU Hello package.  The examples
590 below are from the latest beta version of GNU Hello, but with all of the
591 maintainer-only code stripped out, as well as all copyright comments.
593 Of course, GNU Hello is somewhat more featureful than your traditional
594 two-liner.  GNU Hello is internationalized, does option processing, and
595 has a manual and a test suite.  GNU Hello is a deep package.
597 @cindex configure.in, from GNU Hello
598 @cindex GNU Hello, configure.in
599 @cindex Hello, configure.in
601 Here is the @file{configure.in} from GNU Hello:
603 @example
604 dnl Process this file with autoconf to produce a configure script.
605 AC_INIT(src/hello.c)
606 AM_INIT_AUTOMAKE(hello, 1.3.11)
607 AM_CONFIG_HEADER(config.h)
609 dnl Set of available languages.
610 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
612 dnl Checks for programs.
613 AC_PROG_CC
614 AC_ISC_POSIX
616 dnl Checks for libraries.
618 dnl Checks for header files.
619 AC_STDC_HEADERS
620 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
622 dnl Checks for library functions.
623 AC_FUNC_ALLOCA
625 dnl Check for st_blksize in struct stat
626 AC_ST_BLKSIZE
628 dnl internationalization macros
629 AM_GNU_GETTEXT
630 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
631            src/Makefile tests/Makefile tests/hello],
632    [chmod +x tests/hello])
633 @end example
635 The @samp{AM_} macros are provided by Automake (or the Gettext library);
636 the rest are standard Autoconf macros.
639 The top-level @file{Makefile.am}:
641 @example
642 EXTRA_DIST = BUGS ChangeLog.O
643 SUBDIRS = doc intl po src tests
644 @end example
646 As you can see, all the work here is really done in subdirectories.
648 The @file{po} and @file{intl} directories are automatically generated
649 using @code{gettextize}; they will not be discussed here.
651 @cindex Texinfo file handling example
652 @cindex Example, handling Texinfo files
654 In @file{doc/Makefile.am} we see:
656 @example
657 info_TEXINFOS = hello.texi
658 hello_TEXINFOS = gpl.texi
659 @end example
661 This is sufficient to build, install, and distribute the GNU Hello
662 manual.
664 @cindex Regression test example
665 @cindex Example, regression test
667 Here is @file{tests/Makefile.am}:
669 @example
670 TESTS = hello
671 EXTRA_DIST = hello.in testdata
672 @end example
674 The script @file{hello} is generated by @code{configure}, and is the
675 only test case.  @code{make check} will run this test.
677 @cindex INCLUDES, example usage
679 Last we have @file{src/Makefile.am}, where all the real work is done:
681 @example
682 bin_PROGRAMS = hello
683 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
684 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
685 localedir = $(datadir)/locale
686 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
687 @end example
690 @node etags,  , Hello, Examples
691 @section Building etags and ctags
693 @cindex Example, ctags and etags
694 @cindex ctags Example
695 @cindex etags Example
697 Here is another, trickier example.  It shows how to generate two
698 programs (@code{ctags} and @code{etags}) from the same source file
699 (@file{etags.c}).  The difficult part is that each compilation of
700 @file{etags.c} requires different @code{cpp} flags.
702 @example
703 bin_PROGRAMS = etags ctags
704 ctags_SOURCES =
705 ctags_LDADD = ctags.o
707 etags.o: etags.c
708         $(COMPILE) -DETAGS_REGEXPS -c etags.c
710 ctags.o: etags.c
711         $(COMPILE) -DCTAGS -o ctags.o -c etags.c
712 @end example
714 Note that @code{ctags_SOURCES} is defined to be empty---that way no
715 implicit value is substituted.  The implicit value, however, is used to
716 generate @code{etags} from @file{etags.o}.
718 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
719 @code{ctags_DEPENDENCIES} is generated by Automake.
721 The above rules won't work if your compiler doesn't accept both
722 @samp{-c} and @samp{-o}.  The simplest fix for this is to introduce a
723 bogus dependency (to avoid problems with a parallel @code{make}):
725 @example
726 etags.o: etags.c ctags.o
727         $(COMPILE) -DETAGS_REGEXPS -c etags.c
729 ctags.o: etags.c
730         $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
731 @end example
733 Also, these explicit rules do not work if the de-ANSI-fication feature
734 is used (@pxref{ANSI}).  Supporting de-ANSI-fication requires a little
735 more work:
737 @example
738 etags._o: etags._c ctags.o
739         $(COMPILE) -DETAGS_REGEXPS -c etags.c
741 ctags._o: etags._c
742         $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o
743 @end example
746 @node Invoking Automake, configure, Examples, Top
747 @chapter Creating a @file{Makefile.in}
749 @cindex Multiple configure.in files
750 @cindex Invoking Automake
751 @cindex Automake, invoking
753 To create all the @file{Makefile.in}s for a package, run the
754 @code{automake} program in the top level directory, with no arguments.
755 @code{automake} will automatically find each appropriate
756 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
757 and generate the corresponding @file{Makefile.in}.  Note that
758 @code{automake} has a rather simplistic view of what constitutes a
759 package; it assumes that a package has only one @file{configure.in}, at
760 the top.  If your package has multiple @file{configure.in}s, then you
761 must run @code{automake} in each directory holding a
762 @file{configure.in}.
764 You can optionally give @code{automake} an argument; @file{.am} is
765 appended to the argument and the result is used as the name of the input
766 file.  This feature is generally only used to automatically rebuild an
767 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
768 be run from the topmost directory of a project, even if being used to
769 regenerate the @file{Makefile.in} in some subdirectory.  This is
770 necessary because @code{automake} must scan @file{configure.in}, and
771 because @code{automake} uses the knowledge that a @file{Makefile.in} is
772 in a subdirectory to change its behavior in some cases.
774 @cindex Automake options
775 @cindex Options, Automake
777 @code{automake} accepts the following options:
779 @cindex Extra files distributed with Automake
780 @cindex Files distributed with Automake
781 @cindex config.guess
783 @table @samp
784 @item -a
785 @itemx --add-missing
786 @opindex -a
787 @opindex --add-missing
788 Automake requires certain common files to exist in certain situations;
789 for instance @file{config.guess} is required if @file{configure.in} runs
790 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
791 files; this option will cause the missing ones to be automatically added
792 to the package, whenever possible.  In general if Automake tells you a
793 file is missing, try using this option.  By default Automake tries to
794 make a symbolic link pointing to its own copy of the missing file; this
795 can be changed with @code{--copy}.
797 @item --amdir=@var{dir}
798 @opindex --amdir
799 Look for Automake data files in directory @var{dir} instead of in the
800 installation directory.  This is typically used for debugging.
802 @item --build-dir=@var{dir}
803 @opindex --build-dir
804 Tell Automake where the build directory is.  This option is used when
805 including dependencies into a @file{Makefile.in} generated by @code{make
806 dist}; it should not be used otherwise.
808 @item -c
809 @item --copy
810 When used with @code{--add-missing}, causes installed files to be
811 copied.  The default is to make a symbolic link.
813 @item --cygnus
814 @opindex --cygnus
815 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
816 of GNU or Gnits rules.  For more information, see @ref{Cygnus}.
818 @item --force-missing
819 @opindex --force-missing
820 When used with @code{--add-missing}, causes standard files to be rebuilt
821 even if they already exist in the source tree.  This involves removing
822 the file from the source tree before creating the new symlink (or, with
823 @code{--copy}, copying the new file).
825 @item --foreign
826 @opindex --foreign
827 Set the global strictness to @samp{foreign}.  For more information, see
828 @ref{Strictness}.
830 @item --gnits
831 @opindex --gnits
832 Set the global strictness to @samp{gnits}.  For more information, see
833 @ref{Gnits}.
835 @item --gnu
836 @opindex --gnu
837 Set the global strictness to @samp{gnu}.  For more information, see
838 @ref{Gnits}.  This is the default strictness.
840 @item --help
841 @opindex --help
842 Print a summary of the command line options and exit.
844 @item -i
845 @itemx --include-deps
846 @opindex -i
847 @opindex --include-deps
848 Include all automatically generated dependency information
849 (@pxref{Dependencies}) in the generated
850 @file{Makefile.in}.  This is generally done when making a distribution;
851 see @ref{Dist}.
853 @item --generate-deps
854 @opindex --generate-deps
855 Generate a file concatenating all automatically generated dependency
856 information (@pxref{Dependencies}) into one file, @file{.dep_segment}.
857 This is generally done when making a distribution; see @ref{Dist}.  It
858 is useful when maintaining a @file{SMakefile} or makefiles for other
859 platforms (@file{Makefile.DOS}, etc.)  It can only be used in
860 conjunction with @samp{--include-deps}, @samp{--srcdir-name}, and
861 @samp{--build-dir}.  Note that if this option is given, no other
862 processing is done.
864 @item --no-force
865 @opindex --no-force
866 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
867 @file{configure.in}.  This option causes it to only update those
868 @file{Makefile.in}s which are out of date with respect to one of their
869 dependents.
871 @item -o @var{dir}
872 @itemx --output-dir=@var{dir}
873 @opindex -o
874 @opindex --output-dir
875 Put the generated @file{Makefile.in} in the directory @var{dir}.
876 Ordinarily each @file{Makefile.in} is created in the directory of the
877 corresponding @file{Makefile.am}.  This option is used when making
878 distributions.
880 @item --srcdir-name=@var{dir}
881 @opindex --srcdir-name
882 Tell Automake the name of the source directory associated with the
883 current build.  This option is used when including dependencies into a
884 @file{Makefile.in} generated by @code{make dist}; it should not be used
885 otherwise.
887 @item -v
888 @itemx --verbose
889 @opindex -v
890 @opindex --verbose
891 Cause Automake to print information about which files are being read or
892 created.
894 @item --version
895 @opindex --version
896 Print the version number of Automake and exit.
897 @end table
900 @node configure, Top level, Invoking Automake, Top
901 @chapter Scanning @file{configure.in}
903 @cindex configure.in, scanning
904 @cindex Scanning configure.in
906 Automake scans the package's @file{configure.in} to determine certain
907 information about the package.  Some @code{autoconf} macros are required
908 and some variables must be defined in @file{configure.in}.  Automake
909 will also use information from @file{configure.in} to further tailor its
910 output.
912 Automake also supplies some Autoconf macros to make the maintenance
913 easier.  These macros can automatically be put into your
914 @file{aclocal.m4} using the @code{aclocal} program.
916 @menu
917 * Requirements::                Configuration requirements
918 * Optional::                    Other things Automake recognizes
919 * Invoking aclocal::            Auto-generating aclocal.m4
920 * Macros::                      Autoconf macros supplied with Automake
921 * Extending aclocal::           Writing your own aclocal macros
922 @end menu
925 @node Requirements, Optional, configure, configure
926 @section Configuration requirements
928 @cindex Automake requirements
929 @cindex Requirements of Automake
931 The one real requirement of Automake is that your @file{configure.in}
932 call @code{AM_INIT_AUTOMAKE}.  This macro does several things which are
933 required for proper Automake operation.
934 @cvindex AM_INIT_AUTOMAKE
936 Here are the other macros which Automake requires but which are not run
937 by @code{AM_INIT_AUTOMAKE}:
939 @cindex AC_OUTPUT, scanning
941 @table @code
942 @item AC_OUTPUT
943 Automake uses this to determine which files to create (@pxref{Output, ,
944 Creating Output Files, autoconf, The Autoconf Manual}).  Listed files
945 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
946 files are treated differently.  Currently the only difference is that a
947 @file{Makefile} is removed by @code{make distclean}, while other files
948 are removed by @code{make clean}.
949 @c FIXME: this is in violation of standards!
950 @cvindex AC_OUTPUT
951 @end table
954 @node Optional, Invoking aclocal, Requirements, configure
955 @section Other things Automake recognizes
957 @cindex Macros Automake recognizes
958 @cindex Recognized macros by Automake
960 Automake will also recognize the use of certain macros and tailor the
961 generated @file{Makefile.in} appropriately.  Currently recognized macros
962 and their effects are:
964 @table @code
965 @item AC_CONFIG_HEADER
966 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
967 to @code{AC_CONFIG_HEADER} (@pxref{Configuration Headers, ,
968 Configuration Header Files, autoconf, The Autoconf Manual}), but does
969 some useful Automake-specific work.
970 @cvindex AC_CONFIG_HEADER
972 @item AC_CONFIG_AUX_DIR
973 Automake will look for various helper scripts, such as
974 @file{mkinstalldirs}, in the directory named in this macro invocation.
975 If not seen, the scripts are looked for in their @samp{standard}
976 locations (either the top source directory, or in the source directory
977 corresponding to the current @file{Makefile.am}, whichever is
978 appropriate).  @xref{Input, , Finding `configure' Input, autoconf, The
979 Autoconf Manual}.
980 @cvindex AC_CONFIG_AUX_DIR
981 FIXME: give complete list of things looked for in this directory
983 @item AC_PATH_XTRA
984 Automake will insert definitions for the variables defined by
985 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
986 or library.  @xref{System Services, , System Services, autoconf, The
987 Autoconf Manual}.
988 @cvindex AC_PATH_XTRA
990 @item AC_CANONICAL_HOST
991 @itemx AC_CHECK_TOOL
992 Automake will ensure that @file{config.guess} and @file{config.sub}
993 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
994 @samp{host_triplet} are introduced.  See both @ref{Canonicalizing, ,
995 Getting the Canonical System Type, autoconf, The Autoconf Manual}, and
996 @ref{Generic Programs, , Generic Program Checks, autoconf, The Autoconf
997 Manual}.
998 @c fixme xref autoconf docs.
999 @cvindex AC_CANONICAL_HOST
1000 @cvindex AC_CHECK_TOOL
1001 @vindex host_alias
1002 @vindex host_triplet
1004 @item AC_CANONICAL_SYSTEM
1005 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
1006 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
1007 @xref{Canonicalizing, , Getting the Canonical System Type, autoconf, The
1008 Autoconf Manual}.
1009 @cvindex AC_CANONICAL_SYSTEM
1010 @vindex build_alias
1011 @vindex target_alias
1013 @item AC_FUNC_ALLOCA
1014 @itemx AC_FUNC_GETLOADAVG
1015 @itemx AC_FUNC_MEMCMP
1016 @itemx AC_STRUCT_ST_BLOCKS
1017 @itemx AC_FUNC_FNMATCH
1018 @itemx AC_FUNC_MKTIME
1019 @itemx AM_FUNC_STRTOD
1020 @itemx AC_REPLACE_FUNCS
1021 @itemx AC_REPLACE_GNU_GETOPT
1022 @itemx AM_WITH_REGEX
1023 Automake will ensure that the appropriate dependencies are generated for
1024 the objects corresponding to these macros.  Also, Automake will verify
1025 that the appropriate source files are part of the distribution.  Note
1026 that Automake does not come with any of the C sources required to use
1027 these macros, so @code{automake -a} will not install the sources.
1028 @xref{A Library}, for more information.  Also, see @ref{Particular
1029 Functions, , Particular Function Checks, autoconf, The Autoconf Manual}.
1030 @cvindex AC_FUNC_ALLOCA
1031 @cvindex AC_FUNC_GETLOADAVG
1032 @cvindex AC_FUNC_MEMCMP
1033 @cvindex AC_STRUCT_ST_BLOCKS
1034 @cvindex AC_FUNC_FNMATCH
1035 @cvindex AC_FUNC_FNMATCH
1036 @cvindex AC_REPLACE_FUNCS
1037 @cvindex AC_REPLACE_GNU_GETOPT
1038 @cvindex AM_FUNC_STRTOD
1039 @cvindex AM_WITH_REGEX
1040 @cvindex AC_FUNC_MKTIME
1042 @item LIBOBJS
1043 Automake will detect statements which put @file{.o} files into
1044 @code{LIBOBJS}, and will treat these additional files as if they were
1045 discovered via @code{AC_REPLACE_FUNCS}.  @xref{Generic Functions, ,
1046 Generic Function Checks, autoconf, The Autoconf Manual}.
1047 @cvindex LIBOBJS
1049 @item AC_PROG_RANLIB
1050 This is required if any libraries are built in the package.
1051 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1052 Autoconf Manual}.
1053 @cvindex AC_PROG_RANLIB
1055 @item AC_PROG_CXX
1056 This is required if any C++ source is included.  @xref{Particular
1057 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1058 @cvindex AC_PROG_CXX
1060 @item AC_PROG_F77
1061 This is required if any Fortran 77 source is included.  This macro is
1062 distributed with Autoconf version 2.13 and later.  @xref{Particular
1063 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}.
1064 @cvindex AC_PROG_F77
1066 @item AC_F77_LIBRARY_LDFLAGS
1067 This is required for programs and shared libraries that are a mixture of
1068 languages that include Fortran 77 (@pxref{Mixing Fortran 77 With C and
1069 C++}).  @xref{Macros, , Autoconf macros supplied with Automake}.
1070 @cvindex AC_F77_LIBRARY_LDFLAGS
1072 @item AC_PROG_LIBTOOL
1073 Automake will turn on processing for @code{libtool} (@pxref{Top, ,
1074 Introduction, libtool, The Libtool Manual}).
1075 @cvindex AC_PROG_LIBTOOL
1077 @item AC_PROG_YACC
1078 If a Yacc source file is seen, then you must either use this macro or
1079 define the variable @samp{YACC} in @file{configure.in}.  The former is
1080 preferred (@pxref{Particular Programs, , Particular Program Checks,
1081 autoconf, The Autoconf Manual}).
1082 @cvindex AC_PROG_YACC
1083 @cvindex YACC
1085 @item AC_DECL_YYTEXT
1086 This macro is required if there is Lex source in the package.
1087 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1088 Autoconf Manual}.
1089 @cvindex AC_DECL_YYTEXT
1091 @item AC_PROG_LEX
1092 If a Lex source file is seen, then this macro must be used.
1093 @xref{Particular Programs, , Particular Program Checks, autoconf, The
1094 Autoconf Manual}.
1095 @cvindex AC_PROG_LEX
1097 @item ALL_LINGUAS
1098 If Automake sees that this variable is set in @file{configure.in}, it
1099 will check the @file{po} directory to ensure that all the named
1100 @samp{.po} files exist, and that all the @samp{.po} files that exist are
1101 named.
1102 @cvindex ALL_LINGUAS
1104 @item AM_C_PROTOTYPES
1105 This is required when using automatic de-ANSI-fication; see @ref{ANSI}.
1106 @cvindex AM_C_PROTOTYPES
1108 @item AM_GNU_GETTEXT
1109 This macro is required for packages which use GNU gettext
1110 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
1111 this macro it ensures that the package meets some of gettext's
1112 requirements.
1113 @cvindex AM_GNU_GETTEXT
1115 @item AM_MAINTAINER_MODE
1116 @opindex --enable-maintainer-mode
1117 This macro adds a @samp{--enable-maintainer-mode} option to
1118 @code{configure}.  If this is used, @code{automake} will cause
1119 @samp{maintainer-only} rules to be turned off by default in the
1120 generated @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits}
1121 mode (@pxref{Gnits}).  This macro defines the @samp{MAINTAINER_MODE}
1122 conditional, which you can use in your own @file{Makefile.am}.
1123 @cvindex AM_MAINTAINER_MODE
1125 @item AC_SUBST
1126 @itemx AC_CHECK_TOOL
1127 @itemx AC_CHECK_PROG
1128 @itemx AC_CHECK_PROGS
1129 @itemx AC_PATH_PROG
1130 @itemx AC_PATH_PROGS
1131 For each of these macros, the first argument is automatically defined as
1132 a variable in each generated @file{Makefile.in}.  @xref{Setting Output
1133 Variables, , Setting Output Variables, autoconf, The Autoconf Manual},
1134 and @ref{Generic Programs, , Generic Program Checks, autoconf, The
1135 Autoconf Manual}.
1136 @cvindex AC_SUBST
1137 @cvindex AC_CHECK_TOOL
1138 @cvindex AC_CHECK_PROG
1139 @cvindex AC_CHECK_PROGS
1140 @cvindex AC_PATH_PROG
1141 @cvindex AC_PATH_PROGS
1143 @end table
1146 @node Invoking aclocal, Macros, Optional, configure
1147 @section Auto-generating aclocal.m4
1149 @cindex Invoking aclocal
1150 @cindex aclocal, Invoking
1152 Automake includes a number of Autoconf macros which can be used in your
1153 package; some of them are actually required by Automake in certain
1154 situations.  These macros must be defined in your @file{aclocal.m4};
1155 otherwise they will not be seen by @code{autoconf}.
1157 The @code{aclocal} program will automatically generate @file{aclocal.m4}
1158 files based on the contents of @file{configure.in}.  This provides a
1159 convenient way to get Automake-provided macros, without having to
1160 search around.  Also, the @code{aclocal} mechanism is extensible for use
1161 by other packages.
1163 At startup, @code{aclocal} scans all the @file{.m4} files it can find,
1164 looking for macro definitions.  Then it scans @file{configure.in}.  Any
1165 mention of one of the macros found in the first step causes that macro,
1166 and any macros it in turn requires, to be put into @file{aclocal.m4}.
1168 The contents of @file{acinclude.m4}, if it exists, are also
1169 automatically included in @file{aclocal.m4}.  This is useful for
1170 incorporating local macros into @file{configure}.
1172 @code{aclocal} accepts the following options:
1174 @table @code
1175 @item --acdir=@var{dir}
1176 @opindex --acdir
1177 Look for the macro files in @var{dir} instead of the installation
1178 directory.  This is typically used for debugging.
1180 @item --help
1181 @opindex --help
1182 Print a summary of the command line options and exit.
1184 @item -I @var{dir}
1185 @opindex -I
1186 Add the directory @var{dir} to the list of directories searched for
1187 @file{.m4} files.
1189 @item --output=@var{file}
1190 @opindex --output
1191 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1193 @item --print-ac-dir
1194 @opindex --print-ac-dir
1195 Prints the name of the directory which @code{aclocal} will search to
1196 find the @file{.m4} files.  When this option is given, normal processing
1197 is suppressed.  This option can be used by a package to determine where
1198 to install a macro file.
1200 @item --verbose
1201 @opindex --verbose
1202 Print the names of the files it examines.
1204 @item --version
1205 @opindex --version
1206 Print the version number of Automake and exit.
1207 @end table
1210 @node Macros, Extending aclocal, Invoking aclocal, configure
1211 @section Autoconf macros supplied with Automake
1213 @c consider generating this node automatically from m4 files.
1215 @table @code
1216 @item AM_CONFIG_HEADER
1217 Automake will generate rules to automatically regenerate the config
1218 header.  If you do use this macro, you must create the file
1219 @file{stamp-h.in} in your source directory.  It can be empty.
1220 @cvindex AM_CONFIG_HEADER
1222 @item AM_ENABLE_MULTILIB
1223 This is used when a ``multilib'' library is being built.  A
1224 @dfn{multilib} library is one that is built multiple times, once per
1225 target flag combination.  This is only useful when the library is
1226 intended to be cross-compiled.  The first optional argument is the name
1227 of the @file{Makefile} being generated; it defaults to @samp{Makefile}.
1228 The second option argument is used to find the top source directory; it
1229 defaults to the empty string (generally this should not be used unless
1230 you are familiar with the internals).
1232 @item AM_FUNC_STRTOD
1233 If the @code{strtod} function is not available, or does not work
1234 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
1235 variable @code{LIBOBJS}.
1236 @cvindex AM_FUNC_STRTOD
1238 @item AM_FUNC_ERROR_AT_LINE
1239 If the function @code{error_at_line} is not found, then add
1240 @file{error.o} to @code{LIBOBJS}.
1241 @cvindex AM_FUNC_ERROR_AT_LINE
1243 @item AM_FUNC_OBSTACK
1244 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
1245 @samp{LIBOBJS}.
1246 @cvindex AM_FUNC_OBSTACK
1248 @item AM_C_PROTOTYPES
1249 Check to see if function prototypes are understood by the compiler.  If
1250 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1251 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
1252 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
1253 values to implement automatic de-ANSI-fication.
1254 @cvindex AM_C_PROTOTYPES
1256 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1257 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1258 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
1259 found in @file{<termios.h>}.
1260 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1262 @item AM_INIT_AUTOMAKE
1263 Runs many macros that most @file{configure.in}'s need.  This macro has
1264 two required arguments, the package and the version number.  By default
1265 this macro @code{AC_DEFINE}'s @samp{PACKAGE} and @samp{VERSION}.  This
1266 can be avoided by passing in a non-empty third argument.
1268 @item AM_PATH_LISPDIR
1269 Searches for the program @code{emacs}, and, if found, sets the output
1270 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1271 @cvindex AM_PATH_LISPDIR
1273 @item AM_PROG_CC_STDC
1274 If the C compiler in not in ANSI C mode by default, try to add an option
1275 to output variable @code{CC} to make it so.  This macro tries various
1276 options that select ANSI C on some system or another.  It considers the
1277 compiler to be in ANSI C mode if it handles function prototypes correctly.
1279 If you use this macro, you should check after calling it whether the C
1280 compiler has been set to accept ANSI C; if not, the shell variable
1281 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
1282 code in ANSI C, you can make an un-ANSIfied copy of it by using the
1283 @code{ansi2knr} option (@pxref{ANSI}).
1285 @item AM_PROG_LEX
1286 @cindex HP-UX 10, lex problems
1287 @cindex lex problems with HP-UX 10
1288 Like @code{AC_PROG_LEX} with @code{AC_DECL_YYTEXT} (@pxref{Particular
1289 Programs, , Particular Program Checks, autoconf, The Autoconf Manual}),
1290 but uses the @code{missing} script on systems that do not have
1291 @code{lex}.  @samp{HP-UX 10} is one such system.
1293 @item AM_PROG_GCJ
1294 This macro finds the @code{gcj} program or causes an error.  It sets
1295 @samp{GCJ} and @samp{GCJFLAGS}.  @code{gcj} is the Java front-end to the
1296 GNU C compiler.
1297 @cvindex AM_PROG_GCJ
1299 @item AM_SANITY_CHECK
1300 This checks to make sure that a file created in the build directory is
1301 newer than a file in the source directory.  This can fail on systems
1302 where the clock is set incorrectly.  This macro is automatically run
1303 from @code{AM_INIT_AUTOMAKE}.
1305 @item AM_SYS_POSIX_TERMIOS
1306 @cvindex am_cv_sys_posix_termios
1307 @cindex POSIX termios headers
1308 @cindex termios POSIX headers
1309 Check to see if POSIX termios headers and functions are available on the
1310 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1311 @samp{yes}.  If not, set the variable to @samp{no}.
1313 @item AM_TYPE_PTRDIFF_T
1314 @cvindex HAVE_PTRDIFF_T
1315 @vindex ptrdiff_t
1316 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
1317 @file{<stddef.h>}.
1319 @item AM_WITH_DMALLOC
1320 @cvindex WITH_DMALLOC
1321 @cindex dmalloc, support for
1322 @opindex --with-dmalloc
1323 Add support for the
1324 @uref{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz, dmalloc}
1325 package.  If the user configures with @samp{--with-dmalloc}, then define
1326 @code{WITH_DMALLOC} and add @samp{-ldmalloc} to @code{LIBS}.
1328 @item AM_WITH_REGEX
1329 @cvindex WITH_REGEX
1330 @opindex --with-regex
1331 @cindex regex package
1332 @cindex rx package
1333 Adds @samp{--with-regex} to the @code{configure} command line.  If
1334 specified (the default), then the @samp{regex} regular expression
1335 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1336 @samp{WITH_REGEX} is defined..  If @samp{--without-regex} is given, then
1337 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1338 into @samp{LIBOBJS}.
1340 @end table
1343 @node Extending aclocal,  , Macros, configure
1344 @section Writing your own aclocal macros
1346 @cindex aclocal, extending
1347 @cindex Extending aclocal
1349 The @code{aclocal} program doesn't have any built-in knowledge of any
1350 macros, so it is easy to extend it with your own macros.
1352 This is mostly used for libraries which want to supply their own
1353 Autoconf macros for use by other programs.  For instance the
1354 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1355 should be used by any package using @code{gettext}.  When the library is
1356 installed, it installs this macro so that @code{aclocal} will find it.
1358 A file of macros should be a series of @code{AC_DEFUN}'s.  The
1359 @code{aclocal} programs also understands @code{AC_REQUIRE}, so it is
1360 safe to put each macro in a separate file.  @xref{Prerequisite Macros, ,
1361 , autoconf, The Autoconf Manual}, and @ref{Macro Definitions, , ,
1362 autoconf, The Autoconf Manual}.
1364 A macro file's name should end in @file{.m4}.  Such files should be
1365 installed in @file{$(datadir)/aclocal}.
1368 @node Top level, Programs, configure, Top
1369 @chapter The top-level @file{Makefile.am}
1371 @cindex SUBDIRS, explained
1373 In non-flat packages, the top level @file{Makefile.am} must tell
1374 Automake which subdirectories are to be built.  This is done via the
1375 @code{SUBDIRS} variable.
1376 @vindex SUBDIRS
1378 The @code{SUBDIRS} macro holds a list of subdirectories in which
1379 building of various sorts can occur.  Many targets (e.g. @code{all}) in
1380 the generated @file{Makefile} will run both locally and in all specified
1381 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1382 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1383 (after configuration).  This allows inclusion of libraries from packages
1384 which do not use Automake (such as @code{gettext}).  The directories
1385 mentioned in @code{SUBDIRS} must be direct children of the current
1386 directory.  For instance, you cannot put @samp{src/subdir} into
1387 @code{SUBDIRS}.
1389 In a deep package, the top-level @file{Makefile.am} is often very short.
1390 For instance, here is the @file{Makefile.am} from the GNU Hello
1391 distribution:
1393 @example
1394 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1395 SUBDIRS = doc intl po src tests
1396 @end example
1398 @cindex SUBDIRS, overriding
1399 @cindex Overriding SUBDIRS
1401 It is possible to override the @code{SUBDIRS} variable if, like in the
1402 case of GNU @code{Inetutils}, you want to only build a subset of the
1403 entire package.  In your @file{Makefile.am} include:
1405 @example
1406 SUBDIRS = @@MY_SUBDIRS@@
1407 @end example
1409 Then in your @file{configure.in} you can specify:
1411 @example
1412 MY_SUBDIRS = "src doc lib po"
1413 AC_SUBST(MY_SUBDIRS)
1414 @end example
1416 (Note that we don't use the variable name @code{SUBDIRS} in our
1417 @file{configure.in}; that would cause Automake to believe that every
1418 @file{Makefile.in} should recurse into the listed subdirectories.)
1420 The upshot of this is that Automake is tricked into building the package
1421 to take the subdirs, but doesn't actually bind that list until
1422 @code{configure} is run.
1424 Although the @code{SUBDIRS} macro can contain configure substitutions
1425 (e.g. @samp{@@DIRS@@}); Automake itself does not actually examine the
1426 contents of this variable.
1428 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1429 @code{AC_PROG_MAKE_SET}.
1431 The use of @code{SUBDIRS} is not restricted to just the top-level
1432 @file{Makefile.am}.  Automake can be used to construct packages of
1433 arbitrary depth.
1435 By default, Automake generates @file{Makefiles} which work depth-first
1436 (@samp{postfix}).  However, it is possible to change this ordering.  You
1437 can do this by putting @samp{.} into @code{SUBDIRS}.  For instance,
1438 putting @samp{.}  first will cause a @samp{prefix} ordering of
1439 directories.
1442 @node Programs, Other objects, Top level, Top
1443 @chapter Building Programs and Libraries
1445 A large part of Automake's functionality is dedicated to making it easy
1446 to build programs and libraries.
1448 @menu
1449 * A Program::                   Building a program
1450 * A Library::                   Building a library
1451 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1452 * A Shared Library::            Building a Libtool library
1453 * Program variables::           Variables used when building a program
1454 * Yacc and Lex::                Yacc and Lex support
1455 * C++ Support::                 
1456 * Fortran 77 Support::          
1457 * Java Support::
1458 * Support for Other Languages::  
1459 * ANSI::                        Automatic de-ANSI-fication
1460 * Dependencies::                Automatic dependency tracking
1461 @end menu
1464 @node A Program, A Library, Programs, Programs
1465 @section Building a program
1467 @cindex PROGRAMS, bindir
1468 @vindex bin_PROGRAMS
1469 @vindex sbin_PROGRAMS
1470 @vindex libexec_PROGRAMS
1471 @vindex pkglib_PROGRAMS
1472 @vindex noinst_PROGRAMS
1474 In a directory containing source that gets built into a program (as
1475 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1476 can be installed in @code{bindir}, @code{sbindir}, @code{libexecdir},
1477 @code{pkglibdir}, or not at all (@samp{noinst}).
1479 For instance:
1481 @example
1482 bin_PROGRAMS = hello
1483 @end example
1485 In this simple case, the resulting @file{Makefile.in} will contain code
1486 to generate a program named @code{hello}.  The variable
1487 @code{hello_SOURCES} is used to specify which source files get built
1488 into an executable:
1490 @example
1491 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
1492 @end example
1494 This causes each mentioned @samp{.c} file to be compiled into the
1495 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1497 @cindex _SOURCES primary, defined
1498 @cindex SOURCES primary, defined
1499 @cindex Primary variable, SOURCES
1501 If @samp{@var{prog}_SOURCES} is needed, but not specified, then it
1502 defaults to the single file @file{prog.c}.
1503 @vindex _SOURCES
1504 @vindex SOURCES
1506 Multiple programs can be built in a single directory.  Multiple programs
1507 can share a single source file, which must be listed in each
1508 @samp{_SOURCES} definition.
1510 @cindex Header files in _SOURCES
1511 @cindex _SOURCES and header files
1513 Header files listed in a @samp{_SOURCES} definition will be included in
1514 the distribution but otherwise ignored.  In case it isn't obvious, you
1515 should not include the header file generated by @file{configure} in an
1516 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1517 (@samp{.l}) and Yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1518 and Lex}.
1520 @cindex EXTRA_prog_SOURCES, defined
1522 Automake must know all the source files that could possibly go into a
1523 program, even if not all the files are built in every circumstance.
1524 Any files which are only conditionally built should be listed in the
1525 appropriate @samp{EXTRA_} variable.  For instance, if
1526 @file{hello-linux.c} were conditionally included in @code{hello}, the
1527 @file{Makefile.am} would contain:
1529 @example
1530 EXTRA_hello_SOURCES = hello-linux.c
1531 @end example
1533 Similarly, sometimes it is useful to determine the programs that are to
1534 be built at configure time.  For instance, GNU @code{cpio} only builds
1535 @code{mt} and @code{rmt} under special circumstances.
1537 @cindex EXTRA_PROGRAMS, defined
1539 In this case, you must notify Automake of all the programs that can
1540 possibly be built, but at the same time cause the generated
1541 @file{Makefile.in} to use the programs specified by @code{configure}.
1542 This is done by having @code{configure} substitute values into each
1543 @samp{_PROGRAMS} definition, while listing all optionally built programs
1544 in @code{EXTRA_PROGRAMS}.
1545 @vindex EXTRA_PROGRAMS
1547 If you need to link against libraries that are not found by
1548 @code{configure}, you can use @code{LDADD} to do so.  This variable
1549 actually can be used to add any options to the linker command line.
1550 @vindex LDADD
1552 @cindex prog_LDADD, defined
1554 Sometimes, multiple programs are built in one directory but do not share
1555 the same link-time requirements.  In this case, you can use the
1556 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1557 program as it appears in some @samp{_PROGRAMS} variable, and usually
1558 written in lowercase) to override the global @code{LDADD}.  If this
1559 variable exists for a given program, then that program is not linked
1560 using @code{LDADD}.
1561 @vindex _LDADD
1563 For instance, in GNU cpio, @code{pax}, @code{cpio} and @code{mt} are
1564 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1565 built in the same directory, and has no such link requirement.  Also,
1566 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1567 is what cpio's @file{src/Makefile.am} looks like (abridged):
1569 @example
1570 bin_PROGRAMS = cpio pax @@MT@@
1571 libexec_PROGRAMS = @@RMT@@
1572 EXTRA_PROGRAMS = mt rmt
1574 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1575 rmt_LDADD =
1577 cpio_SOURCES = @dots{}
1578 pax_SOURCES = @dots{}
1579 mt_SOURCES = @dots{}
1580 rmt_SOURCES = @dots{}
1581 @end example
1583 @cindex _LDFLAGS, defined
1585 @samp{@var{prog}_LDADD} is inappropriate for passing program-specific
1586 linker flags (except for @samp{-l}, @samp{-L}, @samp{-dlopen} and
1587 @samp{-dlpreopen}).  So, use the @samp{@var{prog}_LDFLAGS} variable for
1588 this purpose.
1589 @vindex _LDFLAGS
1591 @cindex _DEPENDENCIES, defined
1593 It is also occasionally useful to have a program depend on some other
1594 target which is not actually part of that program.  This can be done
1595 using the @samp{@var{prog}_DEPENDENCIES} variable.  Each program depends
1596 on the contents of such a variable, but no further interpretation is
1597 done.
1599 If @samp{@var{prog}_DEPENDENCIES} is not supplied, it is computed by
1600 Automake.  The automatically-assigned value is the contents of
1601 @samp{@var{prog}_LDADD}, with most configure substitutions, @samp{-l},
1602 @samp{-L}, @samp{-dlopen} and @samp{-dlpreopen} options removed.  The
1603 configure substitutions that are left in are only @samp{@@LIBOBJS@@} and
1604 @samp{@@ALLOCA@@}; these are left because it is known that they will not
1605 cause an invalid value for @samp{@var{prog}_DEPENDENCIES} to be
1606 generated.
1609 @node A Library, LIBOBJS, A Program, Programs
1610 @section Building a library
1612 @cindex _LIBRARIES primary, defined
1613 @cindex LIBRARIES primary, defined
1614 @cindex Primary variable, LIBRARIES
1616 @vindex lib_LIBRARIES
1617 @vindex pkglib_LIBRARIES
1618 @vindex noinst_LIBRARIES
1620 Building a library is much like building a program.  In this case, the
1621 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1622 @code{libdir} or @code{pkglibdir}.
1624 @xref{A Shared Library}, for information on how to build shared
1625 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1627 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1628 For instance to create a library named @file{libcpio.a}, but not install
1629 it, you would write:
1631 @example
1632 noinst_LIBRARIES = libcpio.a
1633 @end example
1635 The sources that go into a library are determined exactly as they are
1636 for programs, via the @samp{_SOURCES} variables.  Note that the library
1637 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1638 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1639 not @samp{liblob.a_SOURCES}.
1641 @cindex _LIBADD primary, defined
1642 @cindex LIBADD primary, defined
1643 @cindex Primary variable, LIBADD
1645 Extra objects can be added to a library using the
1646 @samp{@var{library}_LIBADD} variable.  This should be used for objects
1647 determined by @code{configure}.  Again from @code{cpio}:
1648 @vindex _LIBADD
1649 @vindex LIBADD
1651 @example
1652 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1653 @end example
1655 In addition, sources for extra objects that will not exist until
1656 configure-time must be added to the @code{BUILT_SOURCES} variable
1657 (@pxref{Sources}).
1660 @node LIBOBJS, A Shared Library, A Library, Programs
1661 @section Special handling for LIBOBJS and ALLOCA
1663 @cindex @@LIBOBJS@@, special handling
1664 @cindex @@ALLOCA@@, special handling
1666 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1667 @code{@@ALLOCA@@}, and uses this information, plus the list of
1668 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1669 include the appropriate source files in the distribution (@pxref{Dist}).
1670 These source files are also automatically handled in the
1671 dependency-tracking scheme; see @xref{Dependencies}.
1673 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1674 @samp{_LDADD} or @samp{_LIBADD} variable.
1677 @node A Shared Library, Program variables, LIBOBJS, Programs
1678 @section Building a Shared Library
1680 @cindex Shared libraries, support for
1682 Building shared libraries is a relatively complex matter.  For this
1683 reason, GNU Libtool (@pxref{Top, , Introduction, libtool, The
1684 Libtool Manual}) was created to help build shared libraries in a
1685 platform-independent way.
1687 @cindex _LTLIBRARIES primary, defined
1688 @cindex LTLIBRARIES primary, defined
1689 @cindex Primary variable, LTLIBRARIES
1690 @cindex Example of shared libraries
1692 @cindex suffix .la, defined
1694 Automake uses Libtool to build libraries declared with the
1695 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1696 of shared libraries to build.  For instance, to create a library named
1697 @file{libgettext.a} and its corresponding shared libraries, and install
1698 them in @samp{libdir}, write:
1700 @example
1701 lib_LTLIBRARIES = libgettext.la
1702 @end example
1704 @vindex lib_LTLIBRARIES
1705 @vindex pkglib_LTLIBRARIES
1706 @vindex noinst_LTLIBRARIES
1707 @vindex check_LTLIBRARIES
1709 @cindex check_LTLIBRARIES, not allowed
1711 Note that shared libraries @emph{must} be installed, so
1712 @code{check_LTLIBRARIES} is not allowed.  However,
1713 @code{noinst_LTLIBRARIES} is allowed.  This feature should be used for
1714 libtool ``convenience libraries''.
1716 @cindex suffix .lo, defined
1718 For each library, the @samp{@var{library}_LIBADD} variable contains the
1719 names of extra libtool objects (@file{.lo} files) to add to the shared
1720 library.  The @samp{@var{library}_LDFLAGS} variable contains any
1721 additional libtool flags, such as @samp{-version-info} or
1722 @samp{-static}.
1724 @cindex @@LTLIBOBJS@@, special handling
1726 Where an ordinary library might include @code{@@LIBOBJS@@}, a libtool
1727 library must use @code{@@LTLIBOBJS@@}.  This is required because the
1728 object files that libtool operates on do not necessarily end in
1729 @file{.o}.  The libtool manual contains more details on this topic.
1731 For libraries installed in some directory, Automake will automatically
1732 supply the appropriate @samp{-rpath} option.  However, for libraries
1733 determined at configure time (and thus mentioned in
1734 @code{EXTRA_LTLIBRARIES}), Automake does not know the eventual
1735 installation directory; for such libraries you must add the
1736 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
1737 hand.
1739 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1740 libtool, The Libtool Manual}, for more information.
1743 @node Program variables, Yacc and Lex, A Shared Library, Programs
1744 @section Variables used when building a program
1746 Occasionally it is useful to know which @file{Makefile} variables
1747 Automake uses for compilations; for instance you might need to do your
1748 own compilation in some special cases.
1750 Some variables are inherited from Autoconf; these are @code{CC},
1751 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1752 @code{LIBS}.
1753 @vindex LDFLAGS
1755 There are some additional variables which Automake itself defines:
1757 @vtable @code
1758 @item INCLUDES
1759 A list of @samp{-I} options.  This can be set in your @file{Makefile.am}
1760 if you have special directories you want to look in.  Automake already
1761 provides some @samp{-I} options automatically.  In particular it
1762 generates @samp{-I$(srcdir)}, @samp{-I.}, and a @samp{-I} pointing to
1763 the directory holding @file{config.h} (if you've used
1764 @code{AC_CONFIG_HEADER} or @code{AM_CONFIG_HEADER}).  You can disable
1765 the default @samp{-I} options using the @samp{nostdinc} option.
1767 @code{INCLUDES} can actually be used for other @code{cpp} options
1768 besides @samp{-I}.  For instance, it is sometimes used to pass arbitrary
1769 @samp{-D} options to the compiler.
1771 @item COMPILE
1772 This is the command used to actually compile a C source file.  The
1773 filename is appended to form the complete command line.
1775 @item LINK
1776 This is the command used to actually link a C program.
1777 @end vtable
1780 @node Yacc and Lex, C++ Support, Program variables, Programs
1781 @section Yacc and Lex support
1783 Automake has somewhat idiosyncratic support for Yacc and Lex.
1785 Automake assumes that the @file{.c} file generated by @code{yacc} (or
1786 @code{lex}) should be named using the basename of the input file.  That
1787 is, for a yacc source file @file{foo.y}, Automake will cause the
1788 intermediate file to be named @file{foo.c} (as opposed to
1789 @file{y.tab.c}, which is more traditional).
1791 The extension of a yacc source file is used to determine the extension
1792 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
1793 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1794 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1795 @samp{.cxx}.
1797 Likewise, lex source files can be used to generate @samp{C} or
1798 @samp{C++}; the extensions @samp{.l}, @samp{.ll}, @samp{.l++}, and
1799 @samp{.lxx} are recognized.
1801 You should never explicitly mention the intermediate (@samp{C} or
1802 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1803 file.
1805 The intermediate files generated by @code{yacc} (or @code{lex}) will be
1806 included in any distribution that is made.  That way the user doesn't
1807 need to have @code{yacc} or @code{lex}.
1809 If a @code{yacc} source file is seen, then your @file{configure.in} must
1810 define the variable @samp{YACC}.  This is most easily done by invoking
1811 the macro @samp{AC_PROG_YACC} (@pxref{Particular Programs, , Particular
1812 Program Checks, autoconf, The Autoconf Manual}).
1814 Similarly, if a @code{lex} source file is seen, then your
1815 @file{configure.in} must define the variable @samp{LEX}.  You can use
1816 @samp{AC_PROG_LEX} to do this (@pxref{Particular Programs, , Particular
1817 Program Checks, autoconf, The Autoconf Manual}).  Automake's @code{lex}
1818 support also requires that you use the @samp{AC_DECL_YYTEXT}
1819 macro---automake needs to know the value of @samp{LEX_OUTPUT_ROOT}.
1820 This is all handled for you if you use the @code{AM_PROG_LEX} macro
1821 (@pxref{Macros}).
1823 @cindex ylwrap
1824 @cindex yacc, multiple parsers
1825 @cindex Multiple yacc parsers
1826 @cindex Multiple lex lexers
1827 @cindex lex, multiple lexers
1830 Automake makes it possible to include multiple @code{yacc} (or
1831 @code{lex}) source files in a single program.  Automake uses a small
1832 program called @code{ylwrap} to run @code{yacc} (or @code{lex}) in a
1833 subdirectory.  This is necessary because yacc's output filename is
1834 fixed, and a parallel make could conceivably invoke more than one
1835 instance of @code{yacc} simultaneously.  The @code{ylwrap} program is
1836 distributed with Automake.  It should appear in the directory specified
1837 by @samp{AC_CONFIG_AUX_DIR} (@pxref{Input, , Finding `configure' Input,
1838 autoconf, The Autoconf Manual}), or the current directory if that macro
1839 is not used in @file{configure.in}.
1841 For @code{yacc}, simply managing locking is insufficient.  The output of
1842 @code{yacc} always uses the same symbol names internally, so it isn't
1843 possible to link two @code{yacc} parsers into the same executable.
1845 We recommend using the following renaming hack used in @code{gdb}:
1846 @example
1847 #define yymaxdepth c_maxdepth
1848 #define yyparse c_parse
1849 #define yylex   c_lex
1850 #define yyerror c_error
1851 #define yylval  c_lval
1852 #define yychar  c_char
1853 #define yydebug c_debug
1854 #define yypact  c_pact  
1855 #define yyr1    c_r1                    
1856 #define yyr2    c_r2                    
1857 #define yydef   c_def           
1858 #define yychk   c_chk           
1859 #define yypgo   c_pgo           
1860 #define yyact   c_act           
1861 #define yyexca  c_exca
1862 #define yyerrflag c_errflag
1863 #define yynerrs c_nerrs
1864 #define yyps    c_ps
1865 #define yypv    c_pv
1866 #define yys     c_s
1867 #define yy_yys  c_yys
1868 #define yystate c_state
1869 #define yytmp   c_tmp
1870 #define yyv     c_v
1871 #define yy_yyv  c_yyv
1872 #define yyval   c_val
1873 #define yylloc  c_lloc
1874 #define yyreds  c_reds
1875 #define yytoks  c_toks
1876 #define yylhs   c_yylhs
1877 #define yylen   c_yylen
1878 #define yydefred c_yydefred
1879 #define yydgoto c_yydgoto
1880 #define yysindex c_yysindex
1881 #define yyrindex c_yyrindex
1882 #define yygindex c_yygindex
1883 #define yytable  c_yytable
1884 #define yycheck  c_yycheck
1885 #define yyname   c_yyname
1886 #define yyrule   c_yyrule
1887 @end example
1889 For each define, replace the @samp{c_} prefix with whatever you like.
1890 These defines work for @code{bison}, @code{byacc}, and traditional
1891 @code{yacc}s.  If you find a parser generator that uses a symbol not
1892 covered here, please report the new name so it can be added to the list.
1895 @node C++ Support, Fortran 77 Support, Yacc and Lex, Programs
1896 @section C++ Support
1898 @cindex C++ support
1899 @cindex Support for C++
1901 Automake includes full support for C++.
1903 Any package including C++ code must define the output variable
1904 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
1905 the @code{AC_PROG_CXX} macro (@pxref{Particular Programs, , Particular
1906 Program Checks, autoconf, The Autoconf Manual}).
1908 A few additional variables are defined when a C++ source file is seen:
1910 @vtable @code
1911 @item CXX
1912 The name of the C++ compiler.
1914 @item CXXFLAGS
1915 Any flags to pass to the C++ compiler.
1917 @item CXXCOMPILE
1918 The command used to actually compile a C++ source file.  The file name
1919 is appended to form the complete command line.
1921 @item CXXLINK
1922 The command used to actually link a C++ program.
1923 @end vtable
1926 @node Fortran 77 Support, Java Support, C++ Support, Programs
1927 @comment  node-name,  next,  previous,  up
1928 @section Fortran 77 Support
1930 @cindex Fortran 77 support
1931 @cindex Support for Fortran 77
1933 Automake includes full support for Fortran 77.
1935 Any package including Fortran 77 code must define the output variable
1936 @samp{F77} in @file{configure.in}; the simplest way to do this is to use
1937 the @code{AC_PROG_F77} macro (@pxref{Particular Programs, , Particular
1938 Program Checks, autoconf, The Autoconf Manual}).  @xref{Fortran 77 and
1939 Autoconf}.
1941 A few additional variables are defined when a Fortran 77 source file is
1942 seen:
1944 @vtable @code
1946 @item F77
1947 The name of the Fortran 77 compiler.
1949 @item FFLAGS
1950 Any flags to pass to the Fortran 77 compiler.
1952 @item RFLAGS
1953 Any flags to pass to the Ratfor compiler.
1955 @item F77COMPILE
1956 The command used to actually compile a Fortran 77 source file.  The file
1957 name is appended to form the complete command line.
1959 @item FLINK
1960 The command used to actually link a pure Fortran 77 program or shared
1961 library.
1963 @end vtable
1965 Automake can handle preprocessing Fortran 77 and Ratfor source files in
1966 addition to compiling them@footnote{Much, if not most, of the
1967 information in the following sections pertaining to preprocessing
1968 Fortran 77 programs was taken almost verbatim from @ref{Catalogue of
1969 Rules, , Catalogue of Rules, make, The GNU Make Manual}.}.  Automake
1970 also contains some support for creating programs and shared libraries
1971 that are a mixture of Fortran 77 and other languages (@pxref{Mixing
1972 Fortran 77 With C and C++}).
1974 These issues are covered in the following sections.
1976 @menu
1977 * Preprocessing Fortran 77::    
1978 * Compiling Fortran 77 Files::  
1979 * Mixing Fortran 77 With C and C++::  
1980 * Fortran 77 and Autoconf::     
1981 @end menu
1984 @node Preprocessing Fortran 77, Compiling Fortran 77 Files, Fortran 77 Support, Fortran 77 Support
1985 @comment  node-name,  next,  previous,  up
1986 @subsection Preprocessing Fortran 77
1988 @cindex Preprocessing Fortran 77
1989 @cindex Fortran 77, Preprocessing
1990 @cindex Ratfor programs
1992 @file{N.f} is made automatically from @file{N.F} or @file{N.r}.  This
1993 rule runs just the preprocessor to convert a preprocessable Fortran 77
1994 or Ratfor source file into a strict Fortran 77 source file.  The precise
1995 command used is as follows:
1997 @table @file
1999 @item .F
2000 @code{$(F77) -F $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2002 @item .r
2003 @code{$(F77) -F $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2005 @end table
2008 @node Compiling Fortran 77 Files, Mixing Fortran 77 With C and C++, Preprocessing Fortran 77, Fortran 77 Support
2009 @comment  node-name,  next,  previous,  up
2010 @subsection Compiling Fortran 77 Files
2012 @file{N.o} is made automatically from @file{N.f}, @file{N.F} or
2013 @file{N.r} by running the Fortran 77 compiler.  The precise command used
2014 is as follows:
2016 @table @file
2018 @item .f
2019 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS)}
2021 @item .F
2022 @code{$(F77) -c $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_FFLAGS) $(FFLAGS)}
2024 @item .r
2025 @code{$(F77) -c $(AM_FFLAGS) $(FFLAGS) $(AM_RFLAGS) $(RFLAGS)}
2027 @end table
2030 @node Mixing Fortran 77 With C and C++, Fortran 77 and Autoconf, Compiling Fortran 77 Files, Fortran 77 Support
2031 @comment  node-name,  next,  previous,  up
2032 @subsection Mixing Fortran 77 With C and C++
2034 @cindex Fortran 77, mixing with C and C++
2035 @cindex Mixing Fortran 77 with C and C++
2036 @cindex Linking Fortran 77 with C and C++
2037 @cindex cfortran
2038 @cindex Mixing Fortran 77 with C and/or C++
2040 Automake currently provides @emph{limited} support for creating programs
2041 and shared libraries that are a mixture of Fortran 77 and C and/or C++.
2042 However, there are many other issues related to mixing Fortran 77 with
2043 other languages that are @emph{not} (currently) handled by Automake, but
2044 that are handled by other packages@footnote{For example,
2045 @uref{http://www-zeus.desy.de/~burow/cfortran/, the cfortran package}
2046 addresses all of these inter-language issues, and runs under nearly all
2047 Fortran 77, C and C++ compilers on nearly all platforms.  However,
2048 @code{cfortran} is not yet Free Software, but it will be in the next
2049 major release.}.
2051 @page
2052 Automake can help in two ways:
2054 @enumerate
2055 @item
2056 Automatic selection of the linker depending on which combinations of
2057 source code.
2059 @item
2060 Automatic selection of the appropriate linker flags (e.g. @samp{-L} and
2061 @samp{-l}) to pass to the automatically selected linker in order to link
2062 in the appropriate Fortran 77 intrinsic and run-time libraries.
2064 @cindex FLIBS, defined
2065 These extra Fortran 77 linker flags are supplied in the output variable
2066 @code{FLIBS} by the @code{AC_F77_LIBRARY_LDFLAGS} Autoconf macro
2067 supplied with newer versions of Autoconf (Autoconf version 2.13 and
2068 later).  @xref{Fortran 77 Compiler Characteristics, , , autoconf, The
2069 Autoconf}.
2070 @end enumerate
2072 If Automake detects that a program or shared library (as mentioned in
2073 some @code{_PROGRAMS} or @code{_LTLIBRARIES} primary) contains source
2074 code that is a mixture of Fortran 77 and C and/or C++, then it requires
2075 that the macro @code{AC_F77_LIBRARY_LDFLAGS} be called in
2076 @file{configure.in}, and that either @code{$(FLIBS)} or @code{@@FLIBS@@}
2077 appear in the appropriate @code{_LDADD} (for programs) or @code{_LIBADD}
2078 (for shared libraries) variables.  It is the responsibility of the
2079 person writing the @file{Makefile.am} to make sure that @code{$(FLIBS)}
2080 or @code{@@FLIBS@@} appears in the appropriate @code{_LDADD} or
2081 @code{_LIBADD} variable.
2083 @cindex Mixed language example
2084 @cindex Example, mixed language
2086 For example, consider the following @file{Makefile.am}:
2088 @example
2089 bin_PROGRAMS = foo
2090 foo_SOURCES  = main.cc foo.f
2091 foo_LDADD    = libfoo.la @@FLIBS@@
2093 pkglib_LTLIBRARIES = libfoo.la
2094 libfoo_la_SOURCES  = bar.f baz.c zardoz.cc
2095 libfoo_la_LIBADD   = $(FLIBS)
2096 @end example
2098 In this case, Automake will insist that @code{AC_F77_LIBRARY_LDFLAGS}
2099 is mentioned in @file{configure.in}.  Also, if @code{@@FLIBS@@} hadn't
2100 been mentioned in @code{foo_LDADD} and @code{libfoo_la_LIBADD}, then
2101 Automake would have issued a warning.
2104 @page
2105 @menu
2106 * How the Linker is Chosen::    
2107 @end menu
2109 @node How the Linker is Chosen,  , Mixing Fortran 77 With C and C++, Mixing Fortran 77 With C and C++
2110 @comment  node-name,  next,  previous,  up
2111 @subsubsection How the Linker is Chosen
2113 @cindex Automatic linker selection
2114 @cindex Selecting the linker automatically
2116 The following diagram demonstrates under what conditions a particular
2117 linker is chosen by Automake.
2119 For example, if Fortran 77, C and C++ source code were to be compiled
2120 into a program, then the C++ linker will be used.  In this case, if the
2121 C or Fortran 77 linkers required any special libraries that weren't
2122 included by the C++ linker, then they must be manually added to an
2123 @code{_LDADD} or @code{_LIBADD} variable by the user writing the
2124 @file{Makefile.am}.
2126 @example
2127                      \              Linker
2128           source      \
2129            code        \     C        C++     Fortran
2130      -----------------  +---------+---------+---------+
2131                         |         |         |         |
2132      C                  |    x    |         |         |
2133                         |         |         |         |
2134                         +---------+---------+---------+
2135                         |         |         |         |
2136          C++            |         |    x    |         |
2137                         |         |         |         |
2138                         +---------+---------+---------+
2139                         |         |         |         |
2140                Fortran  |         |         |    x    |
2141                         |         |         |         |
2142                         +---------+---------+---------+
2143                         |         |         |         |
2144      C + C++            |         |    x    |         |
2145                         |         |         |         |
2146                         +---------+---------+---------+
2147                         |         |         |         |
2148      C +       Fortran  |         |         |    x    |
2149                         |         |         |         |
2150                         +---------+---------+---------+
2151                         |         |         |         |
2152          C++ + Fortran  |         |    x    |         |
2153                         |         |         |         |
2154                         +---------+---------+---------+
2155                         |         |         |         |
2156      C + C++ + Fortran  |         |    x    |         |
2157                         |         |         |         |
2158                         +---------+---------+---------+
2159 @end example
2162 @node Fortran 77 and Autoconf,  , Mixing Fortran 77 With C and C++, Fortran 77 Support
2163 @comment  node-name,  next,  previous,  up
2164 @subsection Fortran 77 and Autoconf
2166 The current Automake support for Fortran 77 requires a recent enough
2167 version Autoconf that also includes support for Fortran 77.  Full
2168 Fortran 77 support was added to Autoconf 2.13, so you will want to use
2169 that version of Autoconf or later.
2172 @node Java Support, Support for Other Languages, Fortran 77 Support, Programs
2173 @comment  node-name,  next,  previous,  up
2175 Automake includes support for compiled Java, using @code{gcj}, the Java
2176 front end to the GNU C compiler.
2178 Any package including Java code to be compiled must define the output
2179 variable @samp{GCJ} in @file{configure.in}; the variable @samp{GCJFLAGS}
2180 must also be defined somehow (either in @file{configure.in} or
2181 @file{Makefile.am}).  The simplest way to do this is to use the
2182 @code{AM_PROG_GCJ} macro.
2184 By default, programs including Java source files are linked with
2185 @code{gcj}.
2188 @node Support for Other Languages, ANSI, Java Support, Programs
2189 @comment  node-name,  next,  previous,  up
2190 @section Support for Other Languages
2192 Automake currently only includes full support for C, C++ (@pxref{C++
2193 Support}), Fortran 77 (@pxref{Fortran 77 Support}), and Java
2194 (@pxref{Java Support}).  There is only rudimentary support for other
2195 languages, support for which will be improved based on user demand.
2197 @c FIXME: mention suffix rule processing here.
2200 @node ANSI, Dependencies, Support for Other Languages, Programs
2201 @section Automatic de-ANSI-fication
2203 @cindex de-ANSI-fication, defined
2205 Although the GNU standards allow the use of ANSI C, this can have the
2206 effect of limiting portability of a package to some older compilers
2207 (notably SunOS).
2209 Automake allows you to work around this problem on such machines by
2210 @dfn{de-ANSI-fying} each source file before the actual compilation takes
2211 place.
2213 @vindex AUTOMAKE_OPTIONS
2214 @opindex ansi2knr
2216 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
2217 (@pxref{Options}) contains the option @code{ansi2knr} then code to
2218 handle de-ANSI-fication is inserted into the generated
2219 @file{Makefile.in}.
2221 This causes each C source file in the directory to be treated as ANSI C.
2222 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
2223 is available, the @code{ansi2knr} program is used to convert the source
2224 files into K&R C, which is then compiled.
2226 The @code{ansi2knr} program is simple-minded.  It assumes the source
2227 code will be formatted in a particular way; see the @code{ansi2knr} man
2228 page for details.
2230 Support for de-ANSI-fication requires the source files @file{ansi2knr.c}
2231 and @file{ansi2knr.1} to be in the same package as the ANSI C source;
2232 these files are distributed with Automake.  Also, the package
2233 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}
2234 (@pxref{Macros}).
2235 @cvindex AM_C_PROTOTYPES
2237 Automake also handles finding the @code{ansi2knr} support files in some
2238 other directory in the current package.  This is done by prepending the
2239 relative path to the appropriate directory to the @code{ansi2knr}
2240 option.  For instance, suppose the package has ANSI C code in the
2241 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
2242 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
2243 @file{src/Makefile.am}:
2245 @example
2246 AUTOMAKE_OPTIONS = ../lib/ansi2knr
2247 @end example
2249 If no directory prefix is given, the files are assumed to be in the
2250 current directory.
2252 Files mentioned in @code{LIBOBJS} which need de-ANSI-fication will not
2253 be automatically handled.  That's because @code{configure} will generate
2254 an object name like @file{regex.o}, while @code{make} will be looking
2255 for @file{regex_.o} (when de-ANSI-fying).  Eventually this problem will
2256 be fixed via @code{autoconf} magic, but for now you must put this code
2257 into your @file{configure.in}, just before the @code{AC_OUTPUT} call:
2259 @example
2260 # This is necessary so that .o files in LIBOBJS are also built via
2261 # the ANSI2KNR-filtering rules.
2262 LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
2263 @end example
2266 @node Dependencies,  , ANSI, Programs
2267 @section Automatic dependency tracking
2269 As a developer it is often painful to continually update the
2270 @file{Makefile.in} whenever the include-file dependencies change in a
2271 project.  Automake supplies a way to automatically track dependency
2272 changes, and distribute the dependencies in the generated
2273 @file{Makefile.in}.
2275 Currently this support requires the use of GNU @code{make} and
2276 @code{gcc}.  It might become possible in the future to supply a
2277 different dependency generating program, if there is enough demand.  In
2278 the meantime, this mode is enabled by default if any C program or
2279 library is defined in the current directory, so you may get a @samp{Must
2280 be a separator} error from non-GNU make.
2282 @trindex dist
2284 When you decide to make a distribution, the @code{dist} target will
2285 re-run @code{automake} with @samp{--include-deps} and other options.
2286 @xref{Invoking Automake}, and @ref{Options}.  This will cause the
2287 previously generated dependencies to be inserted into the generated
2288 @file{Makefile.in}, and thus into the distribution.  This step also
2289 turns off inclusion of the dependency generation code, so that those who
2290 download your distribution but don't use GNU @code{make} and @code{gcc}
2291 will not get errors.
2293 @vindex OMIT_DEPENDENCIES
2295 When added to the @file{Makefile.in}, the dependencies have all
2296 system-specific dependencies automatically removed.  This can be done by
2297 listing the files in @samp{OMIT_DEPENDENCIES}.  For instance all
2298 references to system header files are removed by Automake.  Sometimes it
2299 is useful to specify that a certain header file should be removed.  For
2300 instance if your @file{configure.in} uses @samp{AM_WITH_REGEX}, then any
2301 dependency on @file{rx.h} or @file{regex.h} should be removed, because
2302 the correct one cannot be known until the user configures the package.
2304 As it turns out, Automake is actually smart enough to handle the
2305 particular case of the regular expression header.  It will also
2306 automatically omit @file{libintl.h} if @samp{AM_GNU_GETTEXT} is used.
2308 @vindex AUTOMAKE_OPTIONS
2309 @opindex no-dependencies
2311 Automatic dependency tracking can be suppressed by putting
2312 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
2314 If you unpack a distribution made by @code{make dist}, and you want to
2315 turn on the dependency-tracking code again, simply re-run
2316 @code{automake}.
2318 The actual dependency files are put under the build directory, in a
2319 subdirectory named @file{.deps}.  These dependencies are machine
2320 specific.  It is safe to delete them if you like; they will be
2321 automatically recreated during the next build.
2324 @node Other objects, Other GNU Tools, Programs, Top
2325 @chapter Other Derived Objects
2327 Automake can handle derived objects which are not C programs.  Sometimes
2328 the support for actually building such objects must be explicitly
2329 supplied, but Automake will still automatically handle installation and
2330 distribution.
2332 @menu
2333 * Scripts::                     Executable scripts
2334 * Headers::                     Header files
2335 * Data::                        Architecture-independent data files
2336 * Sources::                     Derived sources
2337 @end menu
2340 @node Scripts, Headers, Other objects, Other objects
2341 @section Executable Scripts
2343 @cindex _SCRIPTS primary, defined
2344 @cindex SCRIPTS primary, defined
2345 @cindex Primary variable, SCRIPTS
2347 It is possible to define and install programs which are scripts.  Such
2348 programs are listed using the @samp{SCRIPTS} primary name.  Automake
2349 doesn't define any dependencies for scripts; the @file{Makefile.am}
2350 should include the appropriate rules.
2351 @vindex SCRIPTS
2353 Automake does not assume that scripts are derived objects; such objects
2354 must be deleted by hand (@pxref{Clean}).
2356 The @code{automake} program itself is a Perl script that is generated at
2357 configure time from @file{automake.in}.  Here is how this is handled:
2359 @example
2360 bin_SCRIPTS = automake
2361 @end example
2363 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
2364 for it is automatically generated.
2366 @cindex SCRIPTS, installation directories
2367 @cindex Installing scripts
2369 @vindex bin_SCRIPTS
2370 @vindex sbin_SCRIPTS
2371 @vindex libexec_SCRIPTS
2372 @vindex pkgdata_SCRIPTS
2373 @vindex noinst_SCRIPTS
2375 Script objects can be installed in @code{bindir}, @code{sbindir},
2376 @code{libexecdir}, or @code{pkgdatadir}.
2379 @node Headers, Data, Scripts, Other objects
2380 @section Header files
2382 @cindex _HEADERS primary, defined
2383 @cindex HEADERS primary, defined
2384 @cindex Primary variable, HEADERS
2386 @vindex noinst_HEADERS
2388 Header files are specified by the @samp{HEADERS} family of variables.
2389 Generally header files are not installed, so the @code{noinst_HEADERS}
2390 variable will be the most used.
2391 @vindex HEADERS
2393 All header files must be listed somewhere; missing ones will not appear
2394 in the distribution.  Often it is clearest to list uninstalled headers
2395 with the rest of the sources for a program.  @xref{A Program}.  Headers
2396 listed in a @samp{_SOURCES} variable need not be listed in any
2397 @samp{_HEADERS} variable.
2399 @cindex HEADERS, installation directories
2400 @cindex Installing headers
2402 @vindex include_HEADERS
2403 @vindex oldinclude_HEADERS
2404 @vindex pkginclude_HEADERS
2406 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
2407 @code{pkgincludedir}.
2410 @node Data, Sources, Headers, Other objects
2411 @section Architecture-independent data files
2413 @cindex _DATA primary, defined
2414 @cindex DATA primary, defined
2415 @cindex Primary variable, DATA
2417 Automake supports the installation of miscellaneous data files using the
2418 @samp{DATA} family of variables.
2419 @vindex DATA
2421 @vindex data_DATA
2422 @vindex sysconf_DATA
2423 @vindex sharedstate_DATA
2424 @vindex localstate_DATA
2425 @vindex pkgdata_DATA
2427 Such data can be installed in the directories @code{datadir},
2428 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
2429 @code{pkgdatadir}.
2431 By default, data files are @emph{not} included in a distribution.
2433 Here is how Automake installs its auxiliary data files:
2435 @example
2436 pkgdata_DATA = clean-kr.am clean.am @dots{}
2437 @end example
2440 @node Sources,  , Data, Other objects
2441 @section Built sources
2443 @cindex BUILT_SOURCES, defined
2445 Occasionally a file which would otherwise be called @samp{source}
2446 (e.g. a C @samp{.h} file) is actually derived from some other file.
2447 Such files should be listed in the @code{BUILT_SOURCES} variable.
2448 @vindex BUILT_SOURCES
2450 Built sources are also not compiled by default.  You must explicitly
2451 mention them in some other @samp{_SOURCES} variable for this to happen.
2453 Note that, in some cases, @code{BUILT_SOURCES} will work in somewhat
2454 surprising ways.  In order to get the built sources to work with
2455 automatic dependency tracking, the @file{Makefile} must depend on
2456 @code{$(BUILT_SOURCES)}.  This can cause these sources to be rebuilt at
2457 what might seem like funny times.
2460 @node Other GNU Tools, Documentation, Other objects, Top
2461 @chapter Other GNU Tools
2463 Since Automake is primarily intended to generate @file{Makefile.in}s for
2464 use in GNU programs, it tries hard to interoperate with other GNU tools.
2466 @menu
2467 * Emacs Lisp::                  Emacs Lisp
2468 * gettext::                     Gettext
2469 * Guile::                       Guile
2470 * Libtool::                     Libtool
2471 * Java::                        Java
2472 * Python::                      Python
2473 @end menu
2476 @node Emacs Lisp, gettext, Other GNU Tools, Other GNU Tools
2477 @section Emacs Lisp
2479 @cindex _LISP primary, defined
2480 @cindex LISP primary, defined
2481 @cindex Primary variable, LISP
2483 @vindex LISP
2484 @vindex lisp_LISP
2485 @vindex noinst_LISP
2487 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
2488 is used to hold a list of @file{.el} files.  Possible prefixes for this
2489 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
2490 @code{lisp_LISP} is defined, then @file{configure.in} must run
2491 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
2493 @vindex ELCFILES
2495 By default Automake will byte-compile all Emacs Lisp source files using
2496 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
2497 byte-compiling, simply define the variable @code{ELCFILES} to be empty.
2498 Byte-compiled Emacs Lisp files are not portable among all versions of
2499 Emacs, so it makes sense to turn this off if you expect sites to have
2500 more than one version of Emacs installed.  Furthermore, many packages
2501 don't actually benefit from byte-compilation.  Still, we recommend that
2502 you leave it enabled by default.  It is probably better for sites with
2503 strange setups to cope for themselves than to make the installation less
2504 nice for everybody else.
2507 @node gettext, Guile, Emacs Lisp, Other GNU Tools
2508 @section Gettext
2510 @cindex GNU Gettext support
2511 @cindex Gettext support
2512 @cindex Support for GNU Gettext
2514 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
2515 turns on support for GNU gettext, a message catalog system for
2516 internationalization
2517 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
2519 The @code{gettext} support in Automake requires the addition of two
2520 subdirectories to the package, @file{intl} and @file{po}.  Automake
2521 insures that these directories exist and are mentioned in
2522 @code{SUBDIRS}.
2524 Furthermore, Automake checks that the definition of @code{ALL_LINGUAS}
2525 in @file{configure.in} corresponds to all the valid @file{.po} files,
2526 and nothing more.
2529 @node Guile, Libtool, gettext, Other GNU Tools
2530 @section Guile
2532 Automake provides some automatic support for writing Guile modules.
2533 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
2534 macro is used in @file{configure.in}.
2536 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
2537 macro is understood to mean:
2538 @itemize @bullet
2539 @item
2540 @code{AM_INIT_AUTOMAKE} is run.
2542 @item
2543 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
2544 @end itemize
2546 As the Guile module code matures, no doubt the Automake support will
2547 grow as well.
2550 @node Libtool, Java, Guile, Other GNU Tools
2551 @section Libtool
2553 Automake provides support for GNU Libtool (@pxref{Top, , Introduction,
2554 libtool, The Libtool Manual}) with the @samp{LTLIBRARIES} primary.
2555 @xref{A Shared Library}.
2558 @node Java, Python, Libtool, Other GNU Tools
2559 @section Java
2561 @cindex _JAVA primary, defined
2562 @cindex JAVA primary, defined
2563 @cindex Primary variable, JAVA
2565 Automake provides some minimal support for Java compilation with the
2566 @samp{JAVA} primary.
2568 Any @file{.java} files listed in a @samp{_JAVA} variable will be
2569 compiled with @code{JAVAC} at build time.  By default, @file{.class}
2570 files are not included in the distribution.
2572 @cindex JAVA restrictions
2573 @cindex Restrictions for JAVA
2575 Currently Automake enforces the restriction that only one @samp{_JAVA}
2576 primary can be used in a given @file{Makefile.am}.  The reason for this
2577 restriction is that, in general, it isn't possible to know which
2578 @file{.class} files were generated from which @file{.java} files -- so
2579 it would be impossible to know which files to install where.
2581 @node Python,  , Java, Other GNU Tools
2582 @section Python
2584 @cindex _PYTHON primary, defined
2585 @cindex PYTHON primary, defined
2586 @cindex Primary variable, PYTHON
2589 Automake provides support for Python modules.  Automake will turn on
2590 Python support if the @code{AM_CHECK_PYTHON} macro is used in
2591 @file{configure.in}.  The @samp{PYTHON} primary is used to hold a list
2592 of @file{.py} files.  Possible prefixes for this primary are
2593 @samp{python_} and @samp{noinst_}.  Note that if @code{python_PYTHON} is
2594 defined, then @file{configure.in} must run @code{AM_CHECK_PYTHON}.
2596 @code{AM_CHECK_PYTHON} takes a single argument --- either the word
2597 @samp{module} or @samp{package}.  The first installs files directly into
2598 the @file{site-packages} directory and is used when the @file{.py[co]}
2599 files must be on the @code{PYTHONPATH}.  The second is used for modules
2600 distributed as a package, which should be installed in a subdirectory
2601 of @file{site-packages} and contain the @file{__init__.py} file.  The
2602 subdirectory name is the same as the name given by @samp{PACKAGE}.
2605 @code{AM_CHECK_PYTHON} creates several output variables based on the
2606 Python installation found during configuration.
2608 @table @samp
2609 @item PYTHON
2610 The name of the Python executable.
2612 @item PYTHON_VERSION
2613 The Python version number, in the form @var{major}.@var{minor}
2614 (e.g. @samp{1.5}).  This is currently the value of
2615 @code{sys.version[:3]}.
2617 @item PYTHON_PREFIX
2618 The string @code{$prefix}.  This term may be used in future work
2619 which needs the contents of Python's @code{sys.prefix}, but general
2620 consensus is to always use the value from configure.
2622 @item PYTHON_EXEC_PREFIX
2623 The string @code{$exec_prefix}.  This term may be used in future work
2624 which needs the contents of Python's @code{sys.exec_prefix}, but general
2625 consensus is to always use the value from configure.
2627 @item PYTHON_PLATFORM
2628 The canonical name used by Python to describe the operating system, as
2629 given by @code{sys.platform}.  This value is sometimes needed when
2630 building Python extensions.
2632 @item pythondir
2633 The directory name for the top of the standard Python library.
2635 @item PYTHON_SITE
2636 The location of the platform-independent @file{site-packages} directory,
2637 where `module' files are installed.  Note that older versions of Python
2638 (pre-1.5) used @file{$prefix/lib/site-python} so future versions of
2639 Automake's Python support may provide backwards compatibility.
2641 @item PYTHON_SITE_PACKAGE
2642 The string @code{$PYTHON_SITE/$PACKAGE}.  This is the default
2643 installation directory for a Python `package.'
2645 @item PYTHON_SITE_INSTALL
2646 The top-level directory in which the Python files will be installed.  It
2647 will be the value of either @samp{PYTHON_SITE} or @samp{PYTHON_PACKAGE}
2648 depending on the argument given to @code{AM_CHECK_PYTHON}.
2650 @item PYTHON_SITE_EXEC
2651 The location of the platform-dependent @file{site-packages} directory,
2652 where shared library extensions should be placed.  Note that older
2653 versions of Python (pre-1.5) used @file{sharedmodules} so future version
2654 of Automake's Python support may provide backwards compatibility.
2656 @end table
2658 @vindex PYCFILES
2659 @vindex PYOFILES
2661 By default Automake will byte-compile all Python source files to both
2662 @file{.pyc} and @file{.pyo} forms.  If you wish to avoid generating the
2663 optimized byte-code files, simply define the variable @code{PYOFILES} to
2664 be empty.  Similarly, if you don't wish to generate the standard
2665 byte-compiled files, define the variable @code{PYCFILES} to be empty.
2668 @node Documentation, Install, Other GNU Tools, Top
2669 @chapter Building documentation
2671 Currently Automake provides support for Texinfo and man pages.
2673 @menu
2674 * Texinfo::                     Texinfo
2675 * Man pages::                   Man pages
2676 @end menu
2679 @node Texinfo, Man pages, Documentation, Documentation
2680 @section Texinfo
2682 @cindex _TEXINFOS primary, defined
2683 @cindex TEXINFOS primary, defined
2684 @cindex Primary variable, TEXINFOS
2686 If the current directory contains Texinfo source, you must declare it
2687 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
2688 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
2689 here.  Note that any Texinfo source file must end in the @file{.texi} or
2690 @file{.texinfo} extension.
2691 @vindex TEXINFOS
2692 @vindex info_TEXINFOS
2694 @cindex Texinfo macro, VERSION
2695 @cindex Texinfo macro, UPDATED
2696 @cindex Texinfo macro, EDITION
2698 @cindex VERSION Texinfo macro
2699 @cindex UPDATED Texinfo macro
2700 @cindex EDITION Texinfo macro
2702 @cindex mdate-sh
2704 If the @file{.texi} file @code{@@include}s @file{version.texi}, then
2705 that file will be automatically generated.  The file @file{version.texi}
2706 defines three Texinfo macros you can reference: @code{EDITION},
2707 @code{VERSION}, and @code{UPDATED}.  The first two hold the version
2708 number of your package (but are kept separate for clarity); the last is
2709 the date the primary file was last modified.  The @file{version.texi}
2710 support requires the @code{mdate-sh} program; this program is supplied
2711 with Automake and automatically included when @code{automake} is invoked
2712 with the @code{--add-missing} option.
2714 If you have multiple Texinfo files, and you want to use the
2715 @file{version.texi} feature, then you have to have a separate version
2716 file for each Texinfo file.  Automake will treat any include in a
2717 Texinfo file that matches @samp{vers*.texi} just as an automatically
2718 generated version file.
2720 Sometimes an info file actually depends on more than one @file{.texi}
2721 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
2722 @file{gpl.texi}.  You can tell Automake about these dependencies using
2723 the @code{@var{texi}_TEXINFOS} variable.  Here is how GNU Hello does it:
2724 @vindex TEXINFOS
2725 @vindex _TEXINFOS
2727 @example
2728 info_TEXINFOS = hello.texi
2729 hello_TEXINFOS = gpl.texi
2730 @end example
2732 @cindex texinfo.tex
2734 By default, Automake requires the file @file{texinfo.tex} to appear in
2735 the same directory as the Texinfo source.  However, if you used
2736 @code{AC_CONFIG_AUX_DIR} in @file{configure.in} (@pxref{Input, , Finding
2737 `configure' Input, autoconf, The Autoconf Manual}), then
2738 @file{texinfo.tex} is looked for there.  Automake supplies
2739 @file{texinfo.tex} if @samp{--add-missing} is given.
2741 @vindex TEXINFO_TEX
2743 If your package has Texinfo files in many directories, you can use the
2744 variable @code{TEXINFO_TEX} to tell Automake where to find the canonical
2745 @file{texinfo.tex} for your package.  The value of this variable should
2746 be the relative path from the current @file{Makefile.am} to
2747 @file{texinfo.tex}:
2749 @example
2750 TEXINFO_TEX = ../doc/texinfo.tex
2751 @end example
2753 @opindex no-texinfo.tex
2755 The option @samp{no-texinfo.tex} can be used to eliminate the
2756 requirement for @file{texinfo.tex}.  Use of the variable
2757 @code{TEXINFO_TEX} is preferable, however, because that allows the
2758 @code{dvi} target to still work.
2760 @cindex Target, install-info
2761 @cindex Target, noinstall-info
2762 @cindex install-info target
2763 @cindex noinstall-info target
2765 @opindex no-installinfo
2766 @trindex install-info
2768 Automake generates an @code{install-info} target; some people apparently
2769 use this.  By default, info pages are installed by @samp{make install}.
2770 This can be prevented via the @code{no-installinfo} option.
2773 @node Man pages,  , Texinfo, Documentation
2774 @section Man pages
2776 @cindex _MANS primary, defined
2777 @cindex MANS primary, defined
2778 @cindex Primary variable, MANS
2780 A package can also include man pages (but see the GNU standards on this
2781 matter, @ref{Man Pages, , , standards, The GNU Coding Standards}.)  Man
2782 pages are declared using the @samp{MANS} primary.  Generally the
2783 @code{man_MANS} macro is used.  Man pages are automatically installed in
2784 the correct subdirectory of @code{mandir}, based on the file extension.
2785 They are not automatically included in the distribution.
2786 @vindex MANS
2787 @vindex man_MANS
2789 @cindex Target, install-man
2790 @cindex Target, noinstall-man
2791 @cindex install-man target
2792 @cindex noinstall-man target
2794 @c Use @samp{make install} per documentation: (texi)code.
2795 By default, man pages are installed by @samp{make install}.  However,
2796 since the GNU project does not require man pages, many maintainers do
2797 not expend effort to keep the man pages up to date.  In these cases, the
2798 @code{no-installman} option will prevent the man pages from being
2799 installed by default.  The user can still explicitly install them via
2800 @samp{make install-man}.
2801 @opindex no-installman
2802 @trindex install-man
2804 Here is how the documentation is handled in GNU @code{cpio} (which
2805 includes both Texinfo documentation and man pages):
2807 @example
2808 info_TEXINFOS = cpio.texi
2809 man_MANS = cpio.1 mt.1
2810 EXTRA_DIST = $(man_MANS)
2811 @end example
2813 Texinfo source and info pages are all considered to be source for the
2814 purposes of making a distribution.
2816 Man pages are not currently considered to be source, because it is not
2817 uncommon for man pages to be automatically generated.  For the same
2818 reason, they are not automatically included in the distribution.
2821 @node Install, Clean, Documentation, Top
2822 @chapter What Gets Installed
2824 @cindex Installation support
2825 @cindex make install support
2827 Naturally, Automake handles the details of actually installing your
2828 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
2829 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
2830 automatically installed in the appropriate places.
2832 Automake also handles installing any specified info and man pages.
2834 Automake generates separate @code{install-data} and @code{install-exec}
2835 targets, in case the installer is installing on multiple machines which
2836 share directory structure---these targets allow the machine-independent
2837 parts to be installed only once.  The @code{install} target depends on
2838 both of these targets.
2839 @trindex install-data
2840 @trindex install-exec
2841 @trindex install
2843 Automake also generates an @code{uninstall} target, an
2844 @code{installdirs} target, and an @code{install-strip} target.
2845 @trindex uninstall
2846 @trindex installdirs
2847 @trindex install-strip
2849 It is possible to extend this mechanism by defining an
2850 @code{install-exec-local} or @code{install-data-local} target.  If these
2851 targets exist, they will be run at @samp{make install} time.
2852 @trindex install-exec-local
2853 @trindex install-data-local
2855 Variables using the standard directory prefixes @samp{data},
2856 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
2857 @samp{pkgdata}, or @samp{pkginclude} (e.g. @samp{data_DATA}) are
2858 installed by @samp{install-data}.
2860 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
2861 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
2862 @samp{pkglib} (e.g. @samp{bin_PROGRAMS}) are installed by
2863 @samp{install-exec}.
2865 Any variable using a user-defined directory prefix with @samp{exec} in
2866 the name (e.g. @samp{myexecbin_PROGRAMS} is installed by
2867 @samp{install-exec}.  All other user-defined prefixes are installed by
2868 @samp{install-data}.
2870 @vindex DESTDIR
2871 Automake generates support for the @samp{DESTDIR} variable in all
2872 install rules.  @samp{DESTDIR} is used during the @samp{make install}
2873 step to relocate install objects into a staging area.  Each object and
2874 path is prefixed with the value of @samp{DESTDIR} before being copied
2875 into the install area.  Here is an example of typical DESTDIR usage:
2877 @example
2878 make DESTDIR=/tmp/staging install
2879 @end example
2881 This places install objects in a directory tree built under
2882 @file{/tmp/staging}.  If @file{/gnu/bin/foo} and
2883 @file{/gnu/share/aclocal/foo.m4} are to be installed, the above command
2884 would install @file{/tmp/staging/gnu/bin/foo} and
2885 @file{/tmp/staging/gnu/share/aclocal/foo.m4}.
2887 This feature is commonly used to build install images and packages.  For
2888 more information, see @ref{Makefile Conventions, , , standards, The GNU
2889 Coding Standards}.
2892 @node Clean, Dist, Install, Top
2893 @chapter What Gets Cleaned
2895 @cindex make clean support
2897 The GNU Makefile Standards specify a number of different clean rules.
2898 @c FIXME xref
2899 Generally the files that can be cleaned are determined automatically by
2900 Automake.  Of course, Automake also recognizes some variables that can
2901 be defined to specify additional files to clean.  These variables are
2902 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
2903 @code{MAINTAINERCLEANFILES}.
2904 @vindex MOSTLYCLEANFILES
2905 @vindex CLEANFILES
2906 @vindex DISTCLEANFILES
2907 @vindex MAINTAINERCLEANFILES
2910 @node Dist, Tests, Clean, Top
2911 @chapter What Goes in a Distribution
2913 @cindex make dist
2914 @cindex make distcheck
2916 The @code{dist} target in the generated @file{Makefile.in} can be used
2917 to generate a gzip'd @code{tar} file for distribution.  The tar file is
2918 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
2919 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
2920 @cvindex PACKAGE
2921 @cvindex VERSION
2922 @trindex dist
2923 You can use the @code{make} variable @samp{GZIP_ENV} to control how gzip
2924 is run.  The default setting is @samp{--best}.
2926 For the most part, the files to distribute are automatically found by
2927 Automake: all source files are automatically included in a distribution,
2928 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
2929 has a built-in list of commonly used files which, if present in the
2930 current directory, are automatically included.  This list is printed by
2931 @samp{automake --help}.  Also, files which are read by @code{configure}
2932 (i.e. the source files corresponding to the files specified in the
2933 @code{AC_OUTPUT} invocation) are automatically distributed.
2935 Still, sometimes there are files which must be distributed, but which
2936 are not covered in the automatic rules.  These files should be listed in
2937 the @code{EXTRA_DIST} variable.  You can mention files from
2938 subdirectories in @code{EXTRA_DIST}.  You can also mention a directory
2939 there; in this case the entire directory will be recursively copied into
2940 the distribution.
2941 @vindex EXTRA_DIST
2943 Sometimes you need tighter control over what does @emph{not} go into the
2944 distribution; for instance you might have source files which are
2945 generated and which you do not want to distribute.  In this case
2946 Automake gives fine-grained control using the @samp{dist} and
2947 @samp{nodist} prefixes.  Any primary or @samp{_SOURCES} variable can be
2948 prefixed with @samp{dist_} to add the listed files to the distribution.
2949 Similarly, @samp{nodist_} can be used to omit the files from the
2950 distribution.
2951 @vindex dist_
2952 @vindex nodist_
2954 As an example, here is how you would cause some data to be distributed
2955 while leaving some source code out of the distribution:
2957 @example
2958 dist_data_DATA = distribute-this
2959 bin_PROGRAMS = foo
2960 nodist_foo_SOURCES = do-not-distribute.c
2961 @end example
2963 If you define @code{SUBDIRS}, Automake will recursively include the
2964 subdirectories in the distribution.  If @code{SUBDIRS} is defined
2965 conditionally (@pxref{Conditionals}), Automake will normally include all
2966 directories that could possibly appear in @code{SUBDIRS} in the
2967 distribution.  If you need to specify the set of directories
2968 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
2969 list of subdirectories to include in the distribution.
2970 @vindex DIST_SUBDIRS
2972 @trindex dist-hook
2974 Occasionally it is useful to be able to change the distribution before
2975 it is packaged up.  If the @code{dist-hook} target exists, it is run
2976 after the distribution directory is filled, but before the actual tar
2977 (or shar) file is created.  One way to use this is for distributing
2978 files in subdirectories for which a new @file{Makefile.am} is overkill:
2980 @example
2981 dist-hook:
2982         mkdir $(distdir)/random
2983         cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
2984 @end example
2986 Automake also generates a @code{distcheck} target which can be of help
2987 to ensure that a given distribution will actually work.
2988 @code{distcheck} makes a distribution, and then tries to do a
2989 @code{VPATH} build.
2990 @trindex distcheck
2991 @c FIXME: document distcheck-hook here
2994 @node Tests, Options, Dist, Top
2995 @chapter Support for test suites
2997 @cindex Test suites
2998 @cindex make check
3000 Automake supports two forms of test suites.
3002 If the variable @code{TESTS} is defined, its value is taken to be a list
3003 of programs to run in order to do the testing.  The programs can either
3004 be derived objects or source objects; the generated rule will look both
3005 in @code{srcdir} and @file{.}.  Programs needing data files should look
3006 for them in @code{srcdir} (which is both an environment variable and a
3007 make variable) so they work when building in a separate directory
3008 (@pxref{Build Directories, , Build Directories , autoconf, The Autoconf
3009 Manual}), and in particular for the @code{distcheck} target
3010 (@pxref{Dist}).
3012 @cindex Exit status 77, special interpretation
3014 The number of failures will be printed at the end of the run.  If a
3015 given test program exits with a status of 77, then its result is ignored
3016 in the final count.  This feature allows non-portable tests to be
3017 ignored in environments where they don't make sense.
3019 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
3020 variables for the test run; the environment variable @code{srcdir} is
3021 set in the rule.  If all your test programs are scripts, you can also
3022 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (e.g.
3023 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
3024 @vindex TESTS
3025 @vindex TESTS_ENVIRONMENT
3027 If @uref{ftp://prep.ai.mit.edu/pub/gnu/dejagnu-1.3.tar.gz,
3028 @samp{dejagnu}} appears in @code{AUTOMAKE_OPTIONS}, then a
3029 @code{dejagnu}-based test suite is assumed.  The variable
3030 @code{DEJATOOL} is a list of names which are passed, one at a time, as
3031 the @code{--tool} argument to @code{runtest} invocations; it defaults to
3032 the name of the package.
3034 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
3035 @code{--srcdir} flags that are passed to dejagnu by default; this can be
3036 overridden if necessary.
3037 @vindex RUNTESTDEFAULTFLAGS
3039 The variables @code{EXPECT}, @code{RUNTEST} and @code{RUNTESTFLAGS} can
3040 also be overridden to provide project-specific values.  For instance,
3041 you will need to do this if you are testing a compiler toolchain,
3042 because the default values do not take into account host and target
3043 names.
3044 @opindex dejagnu
3045 @vindex DEJATOOL
3046 @vindex EXPECT
3047 @vindex RUNTEST
3048 @vindex RUNTESTFLAGS
3049 @c FIXME xref dejagnu
3051 If you're not using dejagnu, you may define the variable
3052 @samp{XFAIL_TESTS} to a list of tests (usually a subset of @samp{TESTS})
3053 that are expected to fail.  This will reverse the result of those tests.
3055 In either case, the testing is done via @samp{make check}.
3058 @node Options, Miscellaneous, Tests, Top
3059 @chapter Changing Automake's Behavior
3061 Various features of Automake can be controlled by options in the
3062 @file{Makefile.am}.  Such options are listed in a special variable named
3063 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
3064 @vindex AUTOMAKE_OPTIONS
3066 @table @asis
3067 @item @code{gnits}
3068 @itemx @code{gnu}
3069 @itemx @code{foreign}
3070 @item @code{cygnus}
3071 @cindex Option, gnits
3072 @cindex Option, gnu
3073 @cindex Option, foreign
3074 @cindex Option, cygnus
3076 Set the strictness as appropriate.  The @code{gnits} option also implies
3077 @code{readme-alpha} and @code{check-news}.
3079 @item @code{ansi2knr}
3080 @itemx @code{path/ansi2knr}
3081 @cindex Option, ansi2knr
3082 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceded by a
3083 path, the generated @file{Makefile.in} will look in the specified
3084 directory to find the @file{ansi2knr} program.  Generally the path
3085 should be a relative path to another directory in the same distribution
3086 (though Automake currently does not check this).
3088 @item @code{check-news}
3089 @cindex Option, check-news
3090 Cause @code{make dist} to fail unless the current version number appears
3091 in the first few lines of the @file{NEWS} file.
3093 @item @code{dejagnu}
3094 @cindex Option, dejagnu
3095 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
3097 @item @code{dist-bzip2}
3098 @cindex Option, dist-bzip2
3099 Generate a @code{dist-bzip2} target as well as the ordinary @code{dist}
3100 target.  This new target will create a bzip2 tar archive of the
3101 distribution.  bzip2 archives are frequently smaller than even gzipped
3102 archives.
3103 @trindex dist-bzip2
3105 @item @code{dist-shar}
3106 @cindex Option, dist-shar
3107 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
3108 target.  This new target will create a shar archive of the
3109 distribution.
3110 @trindex dist-shar
3112 @item @code{dist-zip}
3113 @cindex Option, dist-zip
3114 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
3115 target.  This new target will create a zip archive of the distribution.
3116 @trindex dist-zip
3118 @item @code{dist-tarZ}
3119 @cindex Option, dist-tarZ
3120 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
3121 target.  This new target will create a compressed tar archive of the
3122 distribution.
3123 @trindex dist-tarZ
3125 @item @code{no-dependencies}
3126 @cindex Option, no-dependencies
3127 This is similar to using @samp{--include-deps} on the command line, but
3128 is useful for those situations where you don't have the necessary bits
3129 to make automatic dependency tracking work @xref{Dependencies}.  In this
3130 case the effect is to effectively disable automatic dependency tracking.
3132 @item @code{no-installinfo}
3133 @cindex Option, no-installinfo
3134 The generated @file{Makefile.in} will not cause info pages to be built
3135 or installed by default.  However, @code{info} and @code{install-info}
3136 targets will still be available.  This option is disallowed at
3137 @samp{GNU} strictness and above.
3138 @trindex info
3139 @trindex install-info
3141 @item @code{no-installman}
3142 @cindex Option, no-installman
3143 The generated @file{Makefile.in} will not cause man pages to be
3144 installed by default.  However, an @code{install-man} target will still
3145 be available for optional installation.  This option is disallowed at
3146 @samp{GNU} strictness and above.
3147 @trindex install-man
3149 @item @code{nostdinc}
3150 @cindex Option, nostdinc
3151 This option can be used to disable the standard @samp{-I} options which
3152 are ordinarily automatically provided by Automake.
3154 @item @code{no-texinfo.tex}
3155 @cindex Option, no-texinfo
3156 Don't require @file{texinfo.tex}, even if there are texinfo files in
3157 this directory.
3159 @item @code{readme-alpha}
3160 @cindex Option, readme-alpha
3161 If this release is an alpha release, and the file @file{README-alpha}
3162 exists, then it will be added to the distribution.  If this option is
3163 given, version numbers are expected to follow one of two forms.  The
3164 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
3165 element is a number; the final period and number should be left off for
3166 non-alpha releases.  The second form is
3167 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
3168 letter; it should be omitted for non-alpha releases.
3170 @item @var{version}
3171 @cindex Option, version
3172 A version number (e.g. @samp{0.30}) can be specified.  If Automake is not
3173 newer than the version specified, creation of the @file{Makefile.in}
3174 will be suppressed.
3175 @end table
3177 Unrecognized options are diagnosed by @code{automake}.
3180 @node Miscellaneous, Include, Options, Top
3181 @chapter Miscellaneous Rules
3183 There are a few rules and variables that didn't fit anywhere else.
3185 @menu
3186 * Tags::                        Interfacing to etags and mkid
3187 * Suffixes::                    Handling new file extensions
3188 @end menu
3191 @node Tags, Suffixes, Miscellaneous, Miscellaneous
3192 @section Interfacing to @code{etags}
3194 @cindex TAGS support
3196 Automake will generate rules to generate @file{TAGS} files for use with
3197 GNU Emacs under some circumstances.
3199 If any C, C++ or Fortran 77 source code or headers are present, then
3200 @code{tags} and @code{TAGS} targets will be generated for the directory.
3201 @trindex tags
3203 At the topmost directory of a multi-directory package, a @code{tags}
3204 target file will be generated which, when run, will generate a
3205 @file{TAGS} file that includes by reference all @file{TAGS} files from
3206 subdirectories.
3208 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
3209 will be generated.  This variable is intended for use in directories
3210 which contain taggable source that @code{etags} does not understand.
3211 @vindex ETAGS_ARGS
3213 Here is how Automake generates tags for its source, and for nodes in its
3214 Texinfo file:
3216 @example
3217 ETAGS_ARGS = automake.in --lang=none \
3218  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
3219 @end example
3221 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
3222 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
3223 are added directly to the dependencies for the @code{tags} target.
3224 @vindex TAGS_DEPENDENCIES
3226 Automake will also generate an @code{ID} target which will run
3227 @code{mkid} on the source.  This is only supported on a
3228 directory-by-directory basis.
3229 @trindex id
3232 @node Suffixes,  , Tags, Miscellaneous
3233 @section Handling new file extensions
3235 @cindex Adding new SUFFIXES
3236 @cindex SUFFIXES, adding
3238 It is sometimes useful to introduce a new implicit rule to handle a file
3239 type that Automake does not know about.  If this is done, you must
3240 notify GNU Make of the new suffixes.  This can be done by putting a list
3241 of new suffixes in the @code{SUFFIXES} variable.
3242 @vindex SUFFIXES
3244 For instance, currently Automake does not provide any Java support.  If
3245 you wrote a macro to generate @samp{.class} files from @samp{.java}
3246 source files, you would also need to add these suffixes to the list:
3248 @example
3249 SUFFIXES = .java .class
3250 @end example
3253 @node Include, Conditionals, Miscellaneous, Top
3254 @chapter Include
3256 @cmindex include
3257 To include another file (perhaps for common rules),
3258 the following syntax is supported:
3260 include ($(srcdir)|$(top_srcdir))/filename
3262 Using files in the current directory:
3263 @example
3264 include $(srcdir)/Makefile.extra
3265 @end example
3267 @example
3268 include Makefile.generated
3269 @end example
3271 Using a file in the top level directory:
3272 @example
3273 include $(top_srcdir)/filename
3274 @end example
3277 @node Conditionals, Gnits, Include, Top
3278 @chapter Conditionals
3280 @cindex Conditionals
3282 Automake supports a simple type of conditionals.
3284 @cvindex AM_CONDITIONAL
3285 Before using a conditional, you must define it by using
3286 @code{AM_CONDITIONAL} in the @code{configure.in} file (@pxref{Macros}).
3287 The @code{AM_CONDITIONAL} macro takes two arguments.
3289 The first argument to @code{AM_CONDITIONAL} is the name of the
3290 conditional.  This should be a simple string starting with a letter and
3291 containing only letters, digits, and underscores.
3293 The second argument to @code{AM_CONDITIONAL} is a shell condition,
3294 suitable for use in a shell @code{if} statement.  The condition is
3295 evaluated when @code{configure} is run.
3297 @cindex --enable-debug, example
3298 @cindex Example conditional --enable-debug
3299 @cindex Conditional example,  --enable-debug
3301 Conditionals typically depend upon options which the user provides to
3302 the @code{configure} script.  Here is an example of how to write a
3303 conditional which is true if the user uses the @samp{--enable-debug}
3304 option.
3306 @example
3307 AC_ARG_ENABLE(debug,
3308 [  --enable-debug    Turn on debugging],
3309 [case "$@{enableval@}" in
3310   yes) debug=true ;;
3311   no)  debug=false ;;
3312   *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
3313 esac],[debug=false])
3314 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
3315 @end example
3317 Here is an example of how to use that conditional in @file{Makefile.am}:
3319 @cmindex if
3320 @cmindex endif
3321 @cmindex else
3323 @example
3324 if DEBUG
3325 DBG = debug
3326 else
3327 DBG =
3328 endif
3329 noinst_PROGRAMS = $(DBG)
3330 @end example
3332 This trivial example could also be handled using EXTRA_PROGRAMS
3333 (@pxref{A Program}).
3335 You may only test a single variable in an @code{if} statement.  The
3336 @code{else} statement may be omitted.  Conditionals may be nested to any
3337 depth.
3339 Note that conditionals in Automake are not the same as conditionals in
3340 GNU Make.  Automake conditionals are checked at configure time by the
3341 @file{configure} script, and affect the translation from
3342 @file{Makefile.in} to @file{Makefile}.  They are based on options passed
3343 to @file{configure} and on results that @file{configure} has discovered
3344 about the host system.  GNU Make conditionals are checked at @code{make}
3345 time, and are based on variables passed to the make program or defined
3346 in the @file{Makefile}.
3348 Automake conditionals will work with any make program.
3351 @node Gnits, Cygnus, Conditionals, Top
3352 @chapter The effect of @code{--gnu} and @code{--gnits}
3354 @cindex --gnu, required files
3355 @cindex --gnu, complete description
3357 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
3358 variable) causes @code{automake} to check the following:
3360 @itemize @bullet
3361 @item
3362 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
3363 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
3364 directory of the package.
3366 @item
3367 The options @samp{no-installman} and @samp{no-installinfo} are
3368 prohibited.
3369 @end itemize
3371 Note that this option will be extended in the future to do even more
3372 checking; it is advisable to be familiar with the precise requirements
3373 of the GNU standards.  Also, @samp{--gnu} can require certain
3374 non-standard GNU programs to exist for use by various maintainer-only
3375 targets; for instance in the future @code{pathchk} might be required for
3376 @samp{make dist}.
3378 @cindex --gnits, complete description
3380 The @samp{--gnits} option does everything that @samp{--gnu} does, and
3381 checks the following as well:
3383 @itemize @bullet
3384 @item
3385 @samp{make dist} will check to make sure the @file{NEWS} file has been
3386 updated to the current version.
3388 @item
3389 @samp{VERSION} is checked to make sure its format complies with Gnits
3390 standards.
3391 @c FIXME xref when standards are finished
3393 @item
3394 @cindex README-alpha
3395 If @samp{VERSION} indicates that this is an alpha release, and the file
3396 @file{README-alpha} appears in the topmost directory of a package, then
3397 it is included in the distribution.  This is done in @samp{--gnits}
3398 mode, and no other, because this mode is the only one where version
3399 number formats are constrained, and hence the only mode where Automake
3400 can automatically determine whether @file{README-alpha} should be
3401 included.
3403 @item
3404 The file @file{THANKS} is required.
3405 @end itemize
3408 @node Cygnus, Extending, Gnits, Top
3409 @chapter The effect of @code{--cygnus}
3411 @cindex Cygnus strictness
3413 Cygnus Solutions has slightly different rules for how a
3414 @file{Makefile.in} is to be constructed.  Passing @samp{--cygnus} to
3415 @code{automake} will cause any generated @file{Makefile.in} to comply
3416 with Cygnus rules.
3418 Here are the precise effects of @samp{--cygnus}:
3420 @itemize @bullet
3421 @item
3422 Info files are always created in the build directory, and not in the
3423 source directory.
3425 @item
3426 @file{texinfo.tex} is not required if a Texinfo source file is
3427 specified.  The assumption is that the file will be supplied, but in a
3428 place that Automake cannot find.  This assumption is an artifact of how
3429 Cygnus packages are typically bundled.
3431 @item
3432 @samp{make dist} will look for files in the build directory as well as
3433 the source directory.  This is required to support putting info files
3434 into the build directory.
3436 @item
3437 Certain tools will be searched for in the build tree as well as in the
3438 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
3439 @code{makeinfo} and @code{texi2dvi}.
3441 @item
3442 @code{--foreign} is implied.
3444 @item
3445 The options @samp{no-installinfo} and @samp{no-dependencies} are
3446 implied.
3448 @item
3449 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
3450 required.
3452 @item
3453 The @code{check} target doesn't depend on @code{all}.
3454 @end itemize
3456 GNU maintainers are advised to use @samp{gnu} strictness in preference
3457 to the special Cygnus mode.
3460 @node Extending, Distributing, Cygnus, Top
3461 @chapter When Automake Isn't Enough
3463 Automake's implicit copying semantics means that many problems can be
3464 worked around by simply adding some @code{make} targets and rules to
3465 @file{Makefile.in}.  Automake will ignore these additions.
3467 @cindex -local targets
3468 @cindex local targets
3470 There are some caveats to doing this.  Although you can overload a
3471 target already used by Automake, it is often inadvisable, particularly
3472 in the topmost directory of a non-flat package.  However, various useful
3473 targets have a @samp{-local} version you can specify in your
3474 @file{Makefile.in}.  Automake will supplement the standard target with
3475 these user-supplied targets.
3477 @trindex  all-local
3478 @trindex  info-local
3479 @trindex  dvi-local
3480 @trindex  check-local
3481 @trindex  install-data-local
3482 @trindex  install-exec-local
3483 @trindex  uninstall-local
3484 @trindex  mostlyclean-local
3485 @trindex  clean-local
3486 @trindex  distclean-local
3488 The targets that support a local version are @code{all}, @code{info},
3489 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
3490 @code{uninstall}, and the various @code{clean} targets
3491 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
3492 @code{maintainer-clean}).  Note that there are no
3493 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
3494 use @code{uninstall-local}.  It doesn't make sense to uninstall just
3495 data or just executables.
3496 @trindex all
3497 @trindex info
3498 @trindex dvi
3499 @trindex check
3500 @trindex install-data
3501 @trindex install-exec
3502 @trindex uninstall
3504 For instance, here is one way to install a file in @file{/etc}:
3506 @example
3507 install-data-local:
3508         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
3509 @end example
3511 @cindex -hook targets
3512 @cindex hook targets
3514 Some targets also have a way to run another target, called a @dfn{hook},
3515 after their work is done.  The hook is named after the principal target,
3516 with @samp{-hook} appended.  The targets allowing hooks are
3517 @code{install-data}, @code{install-exec}, @code{dist}, and
3518 @code{distcheck}.
3519 @trindex install-data-hook
3520 @trindex install-exec-hook
3521 @trindex dist-hook
3523 For instance, here is how to create a hard link to an installed program:
3525 @example
3526 install-exec-hook:
3527         ln $(bindir)/program $(bindir)/proglink
3528 @end example
3530 @c FIXME should include discussion of variables you can use in these
3531 @c rules
3534 @node Distributing, Future, Extending, Top
3535 @chapter Distributing @file{Makefile.in}s
3537 Automake places no restrictions on the distribution of the resulting
3538 @file{Makefile.in}s.  We still encourage software authors to distribute
3539 their work under terms like those of the GPL, but doing so is not
3540 required to use Automake.
3542 Some of the files that can be automatically installed via the
3543 @code{--add-missing} switch do fall under the GPL; examine each file
3544 to see.
3547 @node Future, Macro and Variable Index, Distributing, Top
3548 @chapter Some ideas for the future
3550 @cindex Future directions
3552 Here are some things that might happen in the future:
3554 @itemize @bullet
3555 @item
3556 HTML support.
3558 @item
3559 The output will be cleaned up.  For instance, only variables which are
3560 actually used will appear in the generated @file{Makefile.in}.
3562 @item
3563 There will be support for automatically recoding a distribution.  The
3564 intent is to allow a maintainer to use whatever character set is most
3565 convenient locally, but for all distributions to be Unicode or
3566 @w{ISO 10646} with the UTF-8 encoding.
3568 @cindex Guile rewrite
3570 @item
3571 Rewrite in Guile.  This won't happen in the near future, but it will
3572 eventually happen.
3573 @end itemize
3576 @page
3577 @node Macro and Variable Index, General Index, Future, Top
3578 @unnumbered Macro and Variable Index
3580 @printindex vr
3583 @page
3584 @node General Index,  , Macro and Variable Index, Top
3585 @unnumbered General Index
3587 @printindex cp
3590 @page
3591 @contents
3592 @bye