* automake.texi (Dist): Document EXTRA_DIST change.
[platform/upstream/automake.git] / automake.texi
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
7
8 @include version.texi
9
10 @dircategory GNU admin
11 @direntry
12 * automake: (automake).         Making Makefile.in's
13 @end direntry
14
15 @dircategory Individual utilities
16 @direntry
17 * aclocal: (automake)Invoking aclocal.          Generating aclocal.m4
18 @end direntry
19
20 @ifinfo
21 This file documents GNU automake @value{VERSION}
22
23 Copyright (C) 1995, 96, 97, 98 Free Software Foundation, Inc.
24
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.
28
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
33
34
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.
40
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
46
47
48 @titlepage
49 @title GNU Automake
50 @subtitle For version @value{VERSION}, @value{UPDATED}
51 @author David MacKenzie and Tom Tromey
52
53 @page
54 @vskip 0pt plus 1filll
55 Copyright @copyright{} 1995, 96 Free Software Foundation, Inc.
56 @sp 2
57 This is the first edition of the GNU Automake documentation,@*
58 and is consistent with GNU Automake @value{VERSION}.@*
59 @sp 2
60 Published by the Free Software Foundation @*
61 59 Temple Place - Suite 330, @*
62 Boston, MA 02111-1307 USA @*
63
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.
67
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.
72
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
78
79 @c Define an index of configure variables.
80 @defcodeindex cv
81 @c Define an index of options.
82 @defcodeindex op
83 @c Define an index of targets.
84 @defcodeindex tr
85
86 @c Put everything in one index (arbitrarily chosen to be the concept index).
87 @syncodeindex cv cp
88 @syncodeindex op cp
89 @syncodeindex tr cp
90 @syncodeindex vr cp
91
92 @ifinfo
93 @node Top, Introduction, (dir), (dir)
94 @comment  node-name,  next,  previous,  up
95 @top GNU Automake
96
97 This file documents the GNU Automake package for creating GNU
98 Standards-compliant Makefiles from template files.  This edition
99 documents version @value{VERSION}.
100
101 @menu
102 * Introduction::                Automake's purpose
103 * Generalities::                General ideas
104 * Examples::                    Some example packages
105 * Invoking Automake::           Creating a Makefile.in
106 * configure::                   Scanning configure.in
107 * Top level::                   The top-level Makefile.am
108 * Programs::                    Building programs and libraries
109 * Other objects::               Other derived objects
110 * Other GNU Tools::             Other GNU Tools
111 * Documentation::               Building documentation
112 * Install::                     What gets installed
113 * Clean::                       What gets cleaned
114 * Dist::                        What goes in a distribution
115 * Tests::                       Support for test suites
116 * Options::                     Changing Automake's behavior
117 * Miscellaneous::               Miscellaneous rules
118 * Conditionals::                Conditionals
119 * Gnits::                       The effect of @code{--gnu} and @code{--gnits}
120 * Cygnus::                      The effect of @code{--cygnus}
121 * Extending::                   Extending Automake
122 * Distributing::                Distributing the Makefile.in
123 * Future::                      Some ideas for the future
124 * Index::                       General index
125
126  --- The Detailed Node Listing ---
127
128 General ideas
129
130 * General Operation::           General operation of Automake
131 * Depth::                       The kinds of packages
132 * Strictness::                  Standards conformance checking
133 * Uniform::                     The Uniform Naming Scheme
134 * Canonicalization::            How derived variables are named
135
136 Some example packages
137
138 * Complete::                    A simple example, start to finish
139 * Hello::                       A classic program
140 * etags::                       Building etags and ctags
141
142 Scanning @file{configure.in}
143
144 * Requirements::                Configuration requirements
145 * Optional::                    Other things Automake recognizes
146 * Invoking aclocal::            Auto-generating aclocal.m4
147 * Macros::                      Autoconf macros supplied with Automake
148 * Extending aclocal::           Writing your own aclocal macros
149
150 Building Programs and Libraries
151
152 * A Program::                   Building a program
153 * A Library::                   Building a library
154 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
155 * A Shared Library::            Building a Libtool library
156 * Program variables::           Variables used when building a program
157 * Yacc and Lex::                Yacc and Lex support
158 * C++::                         
159 * ANSI::                        Automatic de-ANSI-fication
160 * Dependencies::                Automatic dependency tracking
161
162 Other Derived Objects
163
164 * Scripts::                     Executable scripts
165 * Headers::                     Header files
166 * Data::                        Architecture-independent data files
167 * Sources::                     Derived sources
168
169 Other GNU Tools
170
171 * Emacs Lisp::                  Emacs Lisp
172 * gettext::                     Gettext
173 * Guile::                       Guile
174 * Libtool::                     Libtool
175 * Java::                        Java
176
177 Building documentation
178
179 * Texinfo::                     Texinfo
180 * Man pages::                   Man pages
181
182 Miscellaneous Rules
183
184 * Tags::                        Interfacing to etags and mkid
185 * Suffixes::                    Handling new file extensions
186 @end menu
187
188 @end ifinfo
189
190 @node Introduction, Generalities, Top, Top
191 @chapter Introduction
192
193 Automake is a tool for automatically generating @file{Makefile.in}s from
194 files called @file{Makefile.am}.  Each @file{Makefile.am} is basically a
195 series of @code{make} macro definitions (with rules being thrown in
196 occasionally).  The generated @file{Makefile.in}s are compliant with the
197 GNU Makefile standards.
198
199 The GNU Makefile Standards Document
200 (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
201 is long, complicated, and subject to change.  The goal of Automake is to
202 remove the burden of Makefile maintenance from the back of the
203 individual GNU maintainer (and put it on the back of the Automake
204 maintainer).
205
206 The typical Automake input files is simply a series of macro
207 definitions.  Each such file is processed to create a
208 @file{Makefile.in}.  There should generally be one @file{Makefile.am}
209 per directory of a project.
210
211 Automake does constrain a project in certain ways; for instance it
212 assumes that the project uses Autoconf
213 (@pxref{Top, , The Autoconf Manual, autoconf, The Autoconf Manual}),
214 and enforces certain restrictions on the @file{configure.in} contents.
215
216 Automake requires @code{perl} in order to generate the
217 @file{Makefile.in}s.  However, the distributions created by Automake are
218 fully GNU standards-compliant, and do not require @code{perl} in order
219 to be built.
220
221 Mail suggestions and bug reports for Automake to
222 @email{bug-automake@@gnu.org}.
223
224
225 @node Generalities, Examples, Introduction, Top
226 @chapter General ideas
227
228 There are a few basic ideas that will help understand how Automake
229 works.
230
231 @menu
232 * General Operation::           General operation of Automake
233 * Depth::                       The kinds of packages
234 * Strictness::                  Standards conformance checking
235 * Uniform::                     The Uniform Naming Scheme
236 * Canonicalization::            How derived variables are named
237 @end menu
238
239 @node General Operation, Depth, Generalities, Generalities
240 @section General Operation
241
242 Automake works by reading a @file{Makefile.am} and generating a
243 @file{Makefile.in}.  Certain macros and targets defined in the
244 @file{Makefile.am} instruct automake to generate more specialized code;
245 for instances a @samp{bin_PROGRAMS} macro definition will cause targets
246 for compiling and linking to be generated.
247
248 The macro definitions and targets in the @file{Makefile.am} are copied
249 into the generated file.  This allows you to add arbitrary code into the
250 generated @file{Makefile.in}.  For instance the Automake distribution
251 includes a non-standard @code{cvs-dist} target, which the Automake
252 maintainer uses to make distributions from his source control system.
253
254 Note that GNU make extensions are not recognized by Automake.  Using
255 such extensions in a @file{Makefile.am} will lead to errors or confusing
256 behavior.
257
258 Automake tries to group comments with adjoining targets (or variable
259 definitions) in an intelligent way.
260
261 A target defined in @file{Makefile.am} generally overrides any such
262 target of a similar name that would be automatically generated by
263 @code{automake}.  Although this is a supported feature, it is generally
264 best to avoid making use of it, as sometimes the generated rules are
265 very particular.
266
267 Similarly, a variable defined in @file{Makefile.am} will override any
268 definition of the variable that @code{automake} would ordinarily create.
269 This feature is more often useful than the ability to override a target
270 definition.  Be warned that many of the variables generated by
271 @code{automake} are considered to be for internal use only, and their
272 names might change in future releases.
273
274 When examining a variable definition, Automake will recursively examine
275 variables referenced in the definition.  E.g., if Automake is looking at
276 the content of @samp{foo_SOURCES} in this snippet
277
278 @example
279 xs = a.c b.c
280 foo_SOURCES = c.c $(xs)
281 @end example
282
283 it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
284 contents of @samp{foo_SOURCES}.
285
286 Automake also allows a form of comment which is @emph{not} copied into
287 the output; all lines beginning with @samp{##} are completely ignored by
288 Automake.
289
290 It is customary to make the first line of @file{Makefile.am} read:
291
292 @example
293 ## Process this file with automake to produce Makefile.in
294 @end example
295
296 @c FIXME discuss putting a copyright into Makefile.am here?  I would but
297 @c I don't know quite what to say.
298
299 @c FIXME document customary ordering of Makefile.am here!
300
301
302
303 @node Depth, Strictness, General Operation, Generalities
304 @section Depth
305 @code{automake} supports three kinds of directory hierarchy: ``flat'',
306 ``shallow'', and ``deep''.
307
308 A @dfn{flat} package is one in which all the files are in a single
309 directory.  The @file{Makefile.am} for such a package by definition
310 lacks a @code{SUBDIRS} macro.  An example of such a package is
311 @code{termutils}.
312 @vindex SUBDIRS
313
314 A @dfn{deep} package is one in which all the source lies in
315 subdirectories; the top level directory contains mainly configuration
316 information.  GNU cpio is a good example of such a package, as is GNU
317 @code{tar}.  The top level @file{Makefile.am} for a deep package will
318 contain a @code{SUBDIRS} macro, but no other macros to define objects
319 which are built.
320
321 A @dfn{shallow} package is one in which the primary source resides in
322 the top-level directory, while various parts (typically libraries)
323 reside in subdirectories.  Automake is one such package (as is GNU
324 @code{make}, which does not currently use @code{automake}).
325
326
327 @node Strictness, Uniform, Depth, Generalities
328 @section Strictness
329 While Automake is intended to be used by maintainers of GNU packages, it
330 does make some effort to accommodate those who wish to use it, but do
331 not want to use all the GNU conventions.
332
333 To this end, Automake supports three levels of @dfn{strictness}---the
334 strictness indicating how stringently Automake should check standards
335 conformance.
336
337 The valid strictness levels are:
338
339 @table @samp
340 @item foreign
341 Automake will check for only those things which are absolutely
342 required for proper operations.  For instance, whereas GNU standards
343 dictate the existence of a @file{NEWS} file, it will not be required in
344 this mode.  The name comes from the fact that Automake is intended to be
345 used for GNU programs; these relaxed rules are not the standard mode of
346 operation.
347
348 @item gnu
349 Automake will check---as much as possible---for compliance to the GNU
350 standards for packages.  This is the default.
351
352 @item gnits
353 Automake will check for compliance to the as-yet-unwritten Gnits
354 standards.  These are based on the GNU standards, but are even more
355 detailed.  Unless you are a Gnits standards contributor, it is
356 recommended that you avoid this option until such time as the Gnits
357 standard is actually published.
358 @end table
359
360 For more information on the precise implications of the strictness
361 level, see @xref{Gnits}.
362
363
364 @node Uniform, Canonicalization, Strictness, Generalities
365 @section The Uniform Naming Scheme
366 Automake variables generally follow a uniform naming scheme that makes
367 it easy to decide how programs (and other derived objects) are built,
368 and how they are installed.  This scheme also supports @code{configure}
369 time determination of what should be built.
370
371 At @code{make} time, certain variables are used to determine which
372 objects are to be built.  These variables are called @dfn{primary}
373 variables.  For instance, the primary variable @code{PROGRAMS} holds a
374 list of programs which are to be compiled and linked.
375 @vindex PROGRAMS
376
377 A different set of variables is used to decide where the built objects
378 should be installed.  These variables are named after the primary
379 variables, but have a prefix indicating which standard directory should
380 be used as the installation directory.  The standard directory names are
381 given in the GNU standards
382 (@pxref{Directory Variables, , , standards, The GNU Coding
383 Standards}).
384 Automake extends this list with @code{pkglibdir}, @code{pkgincludedir},
385 and @code{pkgdatadir}; these are the same as the non-@samp{pkg}
386 versions, but with @samp{@@PACKAGE@@} appended.  For instance,
387 @code{pkglibdir} is defined as @code{$(datadir)/@@PACKAGE@@}.
388 @cvindex PACKAGE
389
390 For each primary, there is one additional variable named by prepending
391 @samp{EXTRA_} to the primary name.  This variable is used to list
392 objects which may or may not be built, depending on what
393 @code{configure} decides.  This variable is required because Automake
394 must statically know the entire list of objects to be built in order to
395 generate a @file{Makefile.in} that will work in all cases.
396
397 For instance, @code{cpio} decides at configure time which programs are
398 built.  Some of the programs are installed in @code{bindir}, and some
399 are installed in @code{sbindir}:
400
401 @example
402 EXTRA_PROGRAMS = mt rmt
403 bin_PROGRAMS = cpio pax
404 sbin_PROGRAMS = @@PROGRAMS@@
405 @end example
406
407 Defining a primary variable without a prefix (eg @code{PROGRAMS}) is an
408 error.
409
410 Note that the common @samp{dir} suffix is left off when constructing the
411 variable names; thus one writes @samp{bin_PROGRAMS} and not
412 @samp{bindir_PROGRAMS}.
413
414 Not every sort of object can be installed in every directory.  Automake
415 will flag those attempts it finds in error.  Automake will also diagnose
416 obvious misspellings in directory names.
417
418 Sometimes the standard directories---even as augmented by Automake---
419 are not enough.  In particular it is sometimes useful, for clarity, to
420 install objects in a subdirectory of some predefined directory.  To this
421 end, Automake allows you to extend the list of possible installation
422 directories.  A given prefix (eg @samp{zar}) is valid if a variable of
423 the same name with @samp{dir} appended is defined (eg @samp{zardir}).
424
425 For instance, until HTML support is part of Automake, you could use this
426 to install raw HTML documentation:
427
428 @example
429 htmldir = $(prefix)/html
430 html_DATA = automake.html
431 @end example
432
433 The special prefix @samp{noinst} indicates that the objects in question
434 should not be installed at all.
435
436 The special prefix @samp{check} indicates that the objects in question
437 should not be built until the @code{make check} command is run.
438
439 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
440 @samp{LISP}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS}, @samp{MANS},
441 and @samp{TEXINFOS}.
442 @vindex PROGRAMS
443 @vindex LIBRARIES
444 @vindex LISP
445 @vindex SCRIPTS
446 @vindex DATA
447 @vindex HEADERS
448 @vindex MANS
449 @vindex TEXINFOS
450
451
452 @node Canonicalization,  , Uniform, Generalities
453 @section How derived variables are named
454
455 Sometimes a Makefile variable name is derived from some text the user
456 supplies.  For instance program names are rewritten into Makefile macro
457 names.  Automake canonicalizes this text, so that it does not have to
458 follow Makefile variable naming rules.  All characters in the name
459 except for letters, numbers, and the underscore are turned into
460 underscores when making macro references.  E.g., if your program is named
461 @code{sniff-glue}, the derived variable name would be
462 @code{sniff_glue_SOURCES}, not @code{sniff-glue_SOURCES}.
463
464
465 @node Examples, Invoking Automake, Generalities, Top
466 @chapter Some example packages
467
468 @menu
469 * Complete::                    A simple example, start to finish
470 * Hello::                       A classic program
471 * etags::                       Building etags and ctags
472 @end menu
473
474 @node Complete, Hello, Examples, Examples
475 @section A simple example, start to finish
476
477 Let's suppose you just finished writing @code{zardoz}, a program to make
478 your head float from vortex to vortex.  You've been using
479 @code{autoconf} to provide a portability framework, but your
480 @file{Makefile.in}s have been ad-hoc.  You want to make them
481 bulletproof, so you turn to @code{automake}.
482
483 The first step is to update your @file{configure.in} to include the
484 commands that @code{automake} needs.  The simplest way to do this is to
485 add an @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
486
487 @example
488 AM_INIT_AUTOMAKE(zardoz, 1.0)
489 @end example
490
491 Since your program doesn't have any complicating factors (e.g., it
492 doesn't use @code{gettext}, it doesn't want to build a shared library),
493 you're done with this part.  That was easy!
494
495 Now you must regenerate @file{configure}.  But to do that, you'll need
496 to tell @code{autoconf} how to find the new macro you've used.  The
497 easiest way to do this is to use the @code{aclocal} program to generate
498 your @file{aclocal.m4} for you.  But wait... you already have an
499 @file{aclocal.m4}, because you had to write some hairy macros for your
500 program.  @code{aclocal} lets you put your own macros into
501 @file{acinclude.m4}, so simply rename and then run:
502
503 @example
504 mv aclocal.m4 acinclude.m4
505 aclocal
506 autoconf
507 @end example
508
509 Now it is time to write your @file{Makefile.am} for @code{zardoz}.
510 @code{zardoz} is a user program, so you want to install it where the
511 rest of the user programs go.  @code{zardoz} also has some Texinfo
512 documentation.  Your @file{configure.in} script uses
513 @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
514 So here's what you'd write:
515
516 @example
517 bin_PROGRAMS = zardoz
518 zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
519 zardoz_LDADD = @@LIBOBJS@@
520
521 info_TEXINFOS = zardoz.texi
522 @end example
523
524 Now you can run @code{automake --add-missing} to generate your
525 @file{Makefile.in} and grab any auxiliary files you might need, and
526 you're done!
527
528
529 @node Hello, etags, Complete, Examples
530 @section A classic program
531
532 @code{hello} is renowned for its classic simplicity and versatility.
533 This section shows how Automake could be used with the Hello package.
534 The examples below are from the latest GNU Hello, but all the
535 maintainer-only code has been stripped out, as well as all copyright
536 comments.
537
538 Of course, GNU Hello is somewhat more featureful than your traditional
539 two-liner.  GNU Hello is internationalized, does option processing, and
540 has a manual and a test suite.  GNU Hello is a deep package.
541
542 Here is the @file{configure.in} from GNU Hello:
543
544 @example
545 dnl Process this file with autoconf to produce a configure script.
546 AC_INIT(src/hello.c)
547 AM_INIT_AUTOMAKE(hello, 1.3.11)
548 AM_CONFIG_HEADER(config.h)
549
550 dnl Set of available languages.
551 ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
552
553 dnl Checks for programs.
554 AC_PROG_CC
555 AC_ISC_POSIX
556
557 dnl Checks for libraries.
558
559 dnl Checks for header files.
560 AC_STDC_HEADERS
561 AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
562
563 dnl Checks for library functions.
564 AC_FUNC_ALLOCA
565
566 dnl Check for st_blksize in struct stat
567 AC_ST_BLKSIZE
568
569 dnl internationalization macros
570 AM_GNU_GETTEXT
571 AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
572            src/Makefile tests/Makefile tests/hello],
573    [chmod +x tests/hello])
574 @end example
575
576 The @samp{AM_} macros are provided by Automake (or the Gettext library);
577 the rest are standard Autoconf macros.
578
579
580 The top-level @file{Makefile.am}:
581
582 @example
583 EXTRA_DIST = BUGS ChangeLog.O
584 SUBDIRS = doc intl po src tests
585 @end example
586
587 As you can see, all the work here is really done in subdirectories.
588
589 The @file{po} and @file{intl} directories are automatically generated
590 using @code{gettextize}; they will not be discussed here.
591
592 In @file{doc/Makefile.am} we see:
593
594 @example
595 info_TEXINFOS = hello.texi
596 hello_TEXINFOS = gpl.texi
597 @end example
598
599 This is sufficient to build, install, and distribute the Hello manual.
600
601
602 Here is @file{tests/Makefile.am}:
603
604 @example
605 TESTS = hello
606 EXTRA_DIST = hello.in testdata
607 @end example
608
609 The script @file{hello} is generated by @code{configure}, and is the
610 only test case.  @code{make check} will run this test.
611
612 Last we have @file{src/Makefile.am}, where all the real work is done:
613
614 @example
615 bin_PROGRAMS = hello
616 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
617 hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
618 localedir = $(datadir)/locale
619 INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
620 @end example
621
622
623 @node etags,  , Hello, Examples
624 @section Building etags and ctags
625
626 Here is another, trickier example.  It shows how to generate two
627 programs (@code{ctags} and @code{etags}) from the same source file
628 (@file{etags.c}).  The difficult part is that each compilation of
629 @file{etags.c} requires different @code{cpp} flags.
630
631 @example
632 bin_PROGRAMS = etags ctags
633 ctags_SOURCES =
634 ctags_LDADD = ctags.o
635
636 etags.o: etags.c
637         $(COMPILE) -DETAGS_REGEXPS -c etags.c
638
639 ctags.o: etags.c
640         $(COMPILE) -DCTAGS -o ctags.o -c etags.c
641 @end example
642
643 Note that @code{ctags_SOURCES} is defined to be empty---that way no
644 implicit value is substituted.  The implicit value, however, is used to
645 generate @code{etags} from @file{etags.o}.
646
647 @code{ctags_LDADD} is used to get @file{ctags.o} into the link line.
648 @code{ctags_DEPENDENCIES} is generated by Automake.
649
650 The above rules won't work if your compiler doesn't accept both
651 @samp{-c} and @samp{-o}.  The simplest fix for this is to introduce a
652 bogus dependency (to avoid problems with a parallel @code{make}):
653
654 @example
655 etags.o: etags.c ctags.o
656         $(COMPILE) -DETAGS_REGEXPS -c etags.c
657
658 ctags.o: etags.c
659         $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
660 @end example
661
662 Also, these explicit rules do not work if the de-ANSI-fication feature
663 is used; supporting that requires a little more work:
664
665 @example
666 etags._o: etags._c ctags.o
667         $(COMPILE) -DETAGS_REGEXPS -c etags.c
668
669 ctags._o: etags._c
670         $(COMPILE) -DCTAGS -c etags.c && mv etags._o ctags.o
671 @end example
672
673
674 @node Invoking Automake, configure, Examples, Top
675 @chapter Creating a @file{Makefile.in}
676
677 To create all the @file{Makefile.in}s for a package, run the
678 @code{automake} program in the top level directory, with no arguments.
679 @code{automake} will automatically find each appropriate
680 @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
681 and generate the corresponding @file{Makefile.in}.  Note that
682 @code{automake} has a rather simplistic view of what constitutes a
683 package; it assumes that a package has only one @file{configure.in}, at
684 the top.  If your package has multiple @file{configure.in}s, then you
685 must run @code{automake} in each directory holding a
686 @file{configure.in}.
687
688 You can optionally give @code{automake} an argument; @samp{.am} is
689 appended to the argument and the result is used as the name of the input
690 file.  This feature is generally only used to automatically rebuild an
691 out-of-date @file{Makefile.in}.  Note that @code{automake} must always
692 be run from the topmost directory of a project, even if being used to
693 regenerate the @file{Makefile.in} in some subdirectory.  This is
694 necessary because @code{automake} must scan @file{configure.in}, and
695 because @code{automake} uses the knowledge that a @file{Makefile.in} is
696 in a subdirectory to change its behavior in some cases.
697
698 @code{automake} accepts the following options:
699
700 @table @code
701 @item -a
702 @itemx --add-missing
703 Automake requires certain common files to exist in certain situations;
704 for instance @file{config.guess} is required if @file{configure.in} runs
705 @code{AC_CANONICAL_HOST}.  Automake is distributed with several of these
706 files; this option will cause the missing ones to be automatically added
707 to the package, whenever possible.  In general if Automake tells you a
708 file is missing, try using this option.  By default Automake tries to
709 make a symbolic link pointing to its own copy of the missing file; this
710 can be changed with @code{--copy}.
711
712 @item --amdir=@var{dir}
713 Look for Automake data files in directory @var{dir} instead of in the
714 installation directory.  This is typically used for debugging.
715
716 @item --build-dir=@var{dir}
717 Tell Automake where the build directory is.  This option is used when
718 including dependencies into a @file{Makefile.in} generated by @code{make
719 dist}; it should not be used otherwise.
720
721 @item -c
722 @item --copy
723 When used with @code{--add-missing}, causes installed files to be
724 copied.  The default is to make a symbolic link.
725
726 @item --cygnus
727 Causes the generated @file{Makefile.in}s to follow Cygnus rules, instead
728 of GNU or Gnits rules.  @xref{Cygnus} for more information.
729
730 @item --foreign
731 Set the global strictness to @samp{foreign}.  @xref{Strictness} for more
732 information.
733
734 @item --gnits
735 Set the global strictness to @samp{gnits}.  @xref{Gnits} for more
736 information.
737
738 @item --gnu
739 Set the global strictness to @samp{gnu}.  @xref{Gnits} for more
740 information.  This is the default strictness.
741
742 @item --help
743 Print a summary of the command line options and exit.
744
745 @item -i
746 @itemx --include-deps
747 Include all automatically generated dependency information
748 (@pxref{Dependencies}) in the generated
749 @file{Makefile.in}.  This is generally done when making a distribution;
750 see @ref{Dist}.
751
752 @item --generate-deps
753 Generate a file concatenating all automatically generated dependency
754 information (@pxref{Dependencies}) into one file, @file{.dep_segment}.
755 This is generally done when making a distribution; see @ref{Dist}.  It
756 is useful when maintaining a @file{SMakefile} or makefiles for other
757 platforms (@file{Makefile.DOS}, etc.)  It can only be used in
758 conjunction with @code{--include-deps}, @code{--srcdir-name}, and
759 @code{--build-dir}.  Note that if this option is given, no other
760 processing is done.
761
762 @item --no-force
763 Ordinarily @code{automake} creates all @file{Makefile.in}s mentioned in
764 @file{configure.in}.  This option causes it to only update those
765 @file{Makefile.in}s which are out of date with respect to one of their
766 dependents.
767
768 @item -o @var{dir}
769 @itemx --output-dir=@var{dir}
770 Put the generated @file{Makefile.in} in the directory @var{dir}.
771 Ordinarily each @file{Makefile.in} is created in the directory of the
772 corresponding @file{Makefile.am}.  This option is used when making
773 distributions.
774
775 @item --srcdir-name=@var{dir}
776 Tell Automake the name of the source directory associated with the
777 current build.  This option is used when including dependencies into a
778 @file{Makefile.in} generated by @code{make dist}; it should not be used
779 otherwise.
780
781 @item -v
782 @itemx --verbose
783 Cause Automake to print information about which files are being read or
784 created.
785
786 @item --version
787 Print the version number of Automake and exit.
788 @end table
789
790
791 @node configure, Top level, Invoking Automake, Top
792 @chapter Scanning @file{configure.in}
793
794 Automake scans the package's @file{configure.in} to determine certain
795 information about the package.  Some @code{autoconf} macros are required
796 and some variables must be defined in @file{configure.in}.  Automake
797 will also use information from @file{configure.in} to further tailor its
798 output.
799
800 Automake also supplies some @code{autoconf} macros to make the
801 maintenance easier.  These macros can automatically be put into your
802 @file{aclocal.m4} using the @code{aclocal} program.
803
804 @menu
805 * Requirements::                Configuration requirements
806 * Optional::                    Other things Automake recognizes
807 * Invoking aclocal::            Auto-generating aclocal.m4
808 * Macros::                      Autoconf macros supplied with Automake
809 * Extending aclocal::           Writing your own aclocal macros
810 @end menu
811
812
813 @node Requirements, Optional, configure, configure
814 @section Configuration requirements
815
816 The simplest way to meet the basic Automake requirements is to use the
817 macro @code{AM_INIT_AUTOMAKE} (@pxref{Macros}).  But if you prefer, you
818 can do the required steps by hand:
819 @cvindex AM_INIT_AUTOMAKE
820
821 @itemize @bullet
822 @item
823 Define the variables @code{PACKAGE} and @code{VERSION} with
824 @code{AC_SUBST}.
825 @cvindex PACKAGE
826 @cvindex VERSION
827 @code{PACKAGE} should be the name of the package as it appears when
828 bundled for distribution.  For instance, Automake defines @code{PACKAGE}
829 to be @samp{automake}.  @code{VERSION} should be the version number of
830 the release that is being developed.  We recommend that you make
831 @file{configure.in} the only place in your package where the version
832 number is defined; this makes releases simpler.
833
834 Automake doesn't do any interpretation of @code{PACKAGE} or
835 @code{VERSION}, except in @samp{Gnits} mode (@pxref{Gnits}).
836
837 @item
838 Use the macro @code{AC_ARG_PROGRAM} if a program or script is installed.
839 @cvindex AC_ARG_PROGRAM
840
841 @item
842 Use @code{AC_PROG_MAKE_SET} if the package is not flat.
843 @cvindex AC_PROG_MAKE_SET
844
845 @item
846 Use @code{AM_SANITY_CHECK} to make sure the build environment is sane.
847
848 @item
849 Use @code{AM_PROG_INSTALL} if any scripts (@pxref{Scripts}) are
850 installed by the package.  Otherwise, use @code{AC_PROG_INSTALL}.
851 @cvindex AC_PROG_INSTALL
852 @cvindex AM_PROG_INSTALL
853
854 @item
855 Use @code{AM_MISSING_PROG} to see whether the programs @code{aclocal},
856 @code{autoconf}, @code{automake}, @code{autoheader}, and @code{makeinfo}
857 are in the build environment.  Here is how this is done:
858 @example
859 missing_dir=`cd $ac_aux_dir && pwd`
860 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
861 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
862 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
863 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
864 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
865 @end example
866 @end itemize
867
868
869 Here are the other macros which Automake requires but which are not run
870 by @code{AM_INIT_AUTOMAKE}:
871
872 @table @code
873 @item AC_OUTPUT
874 Automake uses this to determine which files to create.  Listed files
875 named @code{Makefile} are treated as @file{Makefile}s.  Other listed
876 files are treated differently.  Currently the only difference is that a
877 @file{Makefile} is removed by @code{make distclean}, while other files
878 are removed by @code{make clean}.
879 @c FIXME: this is in violation of standards!
880 @cvindex AC_OUTPUT
881 @end table
882
883 @node Optional, Invoking aclocal, Requirements, configure
884 @section Other things Automake recognizes
885
886 Automake will also recognize the use of certain macros and tailor the
887 generated @file{Makefile.in} appropriately.  Currently recognized macros
888 and their effects are:
889
890 @table @code
891 @item AC_CONFIG_HEADER
892 Automake requires the use of @code{AM_CONFIG_HEADER}, which is similar
893 to @code{AC_CONFIG_HEADER} but does some useful Automake-specific work.
894 @cvindex AC_CONFIG_HEADER
895
896 @item AC_CONFIG_AUX_DIR
897 Automake will look for various helper scripts, such as
898 @file{mkinstalldirs}, in the directory named in this macro invocation.
899 If not seen, the scripts are looked for in their ``standard'' locations
900 (either the top source directory, or in the source directory
901 corresponding to the current @file{Makefile.am}, whichever is
902 appropriate).
903 @cvindex AC_CONFIG_AUX_DIR
904 FIXME: give complete list of things looked for in this directory
905
906 @item AC_PATH_XTRA
907 Automake will insert definitions for the variables defined by
908 @code{AC_PATH_XTRA} into each @file{Makefile.in} that builds a C program
909 or library.
910 @cvindex AC_PATH_XTRA
911
912 @item AC_CANONICAL_HOST
913 @itemx AC_CHECK_TOOL
914 Automake will ensure that @file{config.guess} and @file{config.sub}
915 exist.  Also, the @file{Makefile} variables @samp{host_alias} and
916 @samp{host_triplet} are introduced.
917 @c fixme xref autoconf docs.
918 @cvindex AC_CANONICAL_HOST
919 @cvindex AC_CHECK_TOOL
920 @vindex host_alias
921 @vindex host_triplet
922
923 @item AC_CANONICAL_SYSTEM
924 This is similar to @code{AC_CANONICAL_HOST}, but also defines the
925 @file{Makefile} variables @samp{build_alias} and @samp{target_alias}.
926 @cvindex AC_CANONICAL_SYSTEM
927 @vindex build_alias
928 @vindex target_alias
929
930 @item AC_FUNC_ALLOCA
931 @itemx AC_FUNC_GETLOADAVG
932 @itemx AC_FUNC_MEMCMP
933 @itemx AC_STRUCT_ST_BLOCKS
934 @itemx AC_FUNC_FNMATCH
935 @itemx AM_FUNC_STRTOD
936 @itemx AC_REPLACE_FUNCS
937 @itemx AC_REPLACE_GNU_GETOPT
938 @itemx AM_WITH_REGEX
939 Automake will ensure that the appropriate dependencies are generated for
940 the objects corresponding to these macros.  Also, Automake will verify
941 that the appropriate source files are part of the distribution.  Note
942 that Automake does not come with any of the C sources required to use
943 these macros, so @code{automake -a} will not install the sources.
944 @xref{A Library} for more information.
945 @cvindex AC_FUNC_ALLOCA
946 @cvindex AC_FUNC_GETLOADAVG
947 @cvindex AC_FUNC_MEMCMP
948 @cvindex AC_STRUCT_ST_BLOCKS
949 @cvindex AC_FUNC_FNMATCH
950 @cvindex AC_FUNC_FNMATCH
951 @cvindex AC_REPLACE_FUNCS
952 @cvindex AC_REPLACE_GNU_GETOPT
953 @cvindex AM_FUNC_STRTOD
954 @cvindex AM_WITH_REGEX
955
956 @item LIBOBJS
957 Automake will detect statements which put @samp{.o} files into
958 @code{LIBOBJS}, and will treat these additional files as if they were
959 discovered via @code{AC_REPLACE_FUNCS}.
960 @cvindex LIBOBJS
961
962 @item AC_PROG_RANLIB
963 This is required if any libraries are built in the package.
964 @cvindex AC_PROG_RANLIB
965
966 @item AC_PROG_CXX
967 This is required if any C++ source is included.
968 @cvindex AC_PROG_CXX
969
970 @item AM_PROG_LIBTOOL
971 Automake will turn on processing for @code{libtool} (@pxref{Top, , The
972 Libtool Manual, libtool, The Libtool Manual}).
973 @cvindex AM_PROG_LIBTOOL
974
975 @item AC_PROG_YACC
976 If a Yacc source file is seen, then you must either use this macro or
977 define the variable @samp{YACC} in @file{configure.in}.  The former is
978 preferred.
979 @cvindex AC_PROG_YACC
980 @cvindex YACC
981
982 @item AC_DECL_YYTEXT
983 This macro is required if there is Lex source in the package.
984 @cvindex AC_DECL_YYTEXT
985
986 @item AC_PROG_LEX
987 If a Lex source file is seen, then this macro must be used.
988 @cvindex AC_PROG_LEX
989
990 @item ALL_LINGUAS
991 If Automake sees that this variable is set in @file{configure.in}, it
992 will check the @file{po} directory to ensure that all the named
993 @samp{.po} files exist, and that all the @samp{.po} files that exist are
994 named.
995 @cvindex ALL_LINGUAS
996
997 @item AM_C_PROTOTYPES
998 This is required when using automatic de-ANSI-fication, see @ref{ANSI}.
999 @cvindex AM_C_PROTOTYPES
1000
1001 @item AM_GNU_GETTEXT
1002 This macro is required for packages which use GNU gettext
1003 (@pxref{gettext}).  It is distributed with gettext.  If Automake sees
1004 this macro it ensures that the package meets some of gettext's
1005 requirements.
1006 @cvindex AM_GNU_GETTEXT
1007
1008 @item AM_MAINTAINER_MODE
1009 This macro adds a @samp{--enable-maintainer-mode} option to
1010 @code{configure}.  If this is used, @code{automake} will cause
1011 ``maintainer-only'' rules to be turned off by default in the generated
1012 @file{Makefile.in}s.  This macro is disallowed in @samp{Gnits} mode
1013 (@pxref{Gnits}).
1014 @cvindex AM_MAINTAINER_MODE
1015
1016 @item AC_SUBST
1017 @itemx AC_CHECK_TOOL
1018 @itemx AC_CHECK_PROG
1019 @itemx AC_CHECK_PROGS
1020 @itemx AC_PATH_PROG
1021 @itemx AC_PATH_PROGS
1022 For each of these macros, the first argument is automatically defined as
1023 a variable in each generated @file{Makefile.in}.
1024 @cvindex AC_SUBST
1025 @cvindex AC_CHECK_TOOL
1026 @cvindex AC_CHECK_PROG
1027 @cvindex AC_CHECK_PROGS
1028 @cvindex AC_PATH_PROG
1029 @cvindex AC_PATH_PROGS
1030
1031 @end table
1032
1033
1034 @node Invoking aclocal, Macros, Optional, configure
1035 @section Auto-generating aclocal.m4
1036
1037 Automake includes a number of Autoconf macros which can be used in your
1038 package; some of them are actually required by Automake in certain
1039 situations.  These macros must be defined in your @file{aclocal.m4};
1040 otherwise they will not be seen by @code{autoconf}.
1041
1042 The @code{aclocal} program will automatically generate @file{aclocal.m4}
1043 files based on the contents of @file{configure.in}.  This provides a
1044 convenient way to get Automake-provided macros, without having to
1045 search around.  Also, the @code{aclocal} mechanism is extensible for use
1046 by other packages.
1047
1048 At startup, @code{aclocal} scans all the @samp{.m4} files it can find,
1049 looking for macro definitions.  Then it scans @file{configure.in}.  Any
1050 mention of one of the macros found in the first step causes that macro,
1051 and any macros it in turn requires, to be put into @file{aclocal.m4}.
1052
1053 The contents of @file{acinclude.m4}, if it exists, are also
1054 automatically included in @file{aclocal.m4}.  This is useful for
1055 incorporating local macros into @file{configure}.
1056
1057 @code{aclocal} accepts the following options:
1058
1059 @table @code
1060 @item --acdir=@var{dir}
1061 Look for the macro files in @var{dir} instead of the installation
1062 directory.  This is typically used for debugging.
1063
1064 @item --help
1065 Print a summary of the command line options and exit.
1066
1067 @item -I @var{dir}
1068 Add the directory @var{dir} to the list of directories searched for
1069 @samp{.m4} files.
1070
1071 @item --output=@var{file}
1072 Cause the output to be put into @var{file} instead of @file{aclocal.m4}.
1073
1074 @item --print-ac-dir
1075 Prints the name of the directory which @code{aclocal} will search to
1076 find the @samp{m4} files.  When this option is given, normal processing
1077 is suppressed.  This option can be used by a package to determine where
1078 to install a macro file.
1079
1080 @item --verbose
1081 Print the names of the files it examines.
1082
1083 @item --version
1084 Print the version number of Automake and exit.
1085 @end table
1086
1087
1088 @node Macros, Extending aclocal, Invoking aclocal, configure
1089 @section Autoconf macros supplied with Automake
1090
1091 @c consider generating this node automatically from m4 files.
1092
1093 @table @code
1094 @item AM_CONFIG_HEADER
1095 Automake will generate rules to automatically regenerate the config
1096 header.  If you do use this macro, you must create the file
1097 @file{stamp-h.in} in your source directory.  It can be empty.
1098 @cvindex AM_CONFIG_HEADER
1099
1100 @item AM_CYGWIN32
1101 Check to see if this @code{configure} is being run in the
1102 @samp{Cygwin32} environment.  (FIXME xref).  If so, define output
1103 variable @code{EXEEXT} to @samp{.exe}; otherwise define it to the empty
1104 string.  Automake recognizes this macro and uses it to generate
1105 @file{Makefile.in}s which will automatically work under @samp{Cygwin32}.
1106 In the @samp{Cygwin32} environment, @code{gcc} generates executables
1107 whose names end in @samp{.exe}, even if this was not specified on the
1108 command line.  Automake adds special code to @file{Makefile.in} to
1109 gracefully deal with this.
1110
1111 @item AM_FUNC_STRTOD
1112 If the @code{strtod} function is not available, or does not work
1113 correctly (like the one on SunOS 5.4), add @file{strtod.o} to output
1114 variable @code{LIBOBJS}.
1115 @cvindex AM_FUNC_STRTOD
1116
1117 @item AM_FUNC_ERROR_AT_LINE
1118 If the function @code{error_at_line} is not found, then add
1119 @file{error.o} to @code{LIBOBJS}.
1120 @cvindex AM_FUNC_ERROR_AT_LINE
1121
1122 @item AM_FUNC_MKTIME
1123 Check for a working @code{mktime} function.  If not found, add
1124 @file{mktime.o} to @samp{LIBOBJS}.
1125 @cvindex AM_FUNC_MKTIME
1126
1127 @item AM_FUNC_OBSTACK
1128 Check for the GNU obstacks code; if not found, add @file{obstack.o} to
1129 @samp{LIBOBJS}.
1130 @cvindex AM_FUNC_OBSTACK
1131
1132 @item AM_C_PROTOTYPES
1133 Check to see if function prototypes are understood by the compiler.  If
1134 so, define @samp{PROTOTYPES} and set the output variables @samp{U} and
1135 @samp{ANSI2KNR} to the empty string.  Otherwise, set @samp{U} to
1136 @samp{_} and @samp{ANSI2KNR} to @samp{./ansi2knr}.  Automake uses these
1137 values to implement automatic de-ANSI-fication.
1138 @cvindex AM_C_PROTOTYPES
1139
1140 @item AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1141 If the use of @code{TIOCGWINSZ} requires @file{<sys/ioctl.h>}, then
1142 define @code{GWINSZ_IN_SYS_IOCTL}.  Otherwise @code{TIOCGWINSZ} can be
1143 found in @file{<termios.h>}.
1144 @cvindex AM_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
1145
1146 @item AM_INIT_AUTOMAKE
1147 Runs many macros that most @file{configure.in}'s need.  This macro has
1148 two required arguments, the package and the version number.  By default
1149 this macro @code{AC_DEFINE}'s @samp{PACKAGE} and @samp{VERSION}.  This
1150 can be avoided by passing in a non-empty third argument.
1151
1152 @item AM_PATH_LISPDIR
1153 Searches for the program @code{emacs}, and, if found, sets the output
1154 variable @code{lispdir} to the full path to Emacs' site-lisp directory.
1155 @cvindex AM_PATH_LISPDIR
1156
1157 @item AM_PROG_CC_STDC
1158 If the C compiler in not in ANSI C mode by default, try to add an option
1159 to output variable @code{CC} to make it so.  This macro tries various
1160 options that select ANSI C on some system or another.  It considers the
1161 compiler to be in ANSI C mode if it handles function prototypes correctly.
1162
1163 If you use this macro, you should check after calling it whether the C
1164 compiler has been set to accept ANSI C; if not, the shell variable
1165 @code{am_cv_prog_cc_stdc} is set to @samp{no}.  If you wrote your source
1166 code in ANSI C, you can make an un-ANSIfied copy of it by using the
1167 @code{ansi2knr} option.
1168 @cvindex AM_PROG_CC_STDC
1169
1170 @item AM_PROG_INSTALL
1171 Like @code{AC_PROG_INSTALL}, but also defines @code{INSTALL_SCRIPT}.
1172 @cvindex AM_PROG_INSTALL
1173
1174 @item AM_PROG_LEX
1175 Like @code{AC_PROG_LEX} with @code{AC_DECL_YYTEXT}, but uses the
1176 @code{missing} script on systems that do not have lex.  @samp{HP-UX 10}
1177 is one such system.
1178 @cvindex AM_PROG_LEX
1179
1180 @item AM_SANITY_CHECK
1181 This checks to make sure that a file created in the build directory is
1182 newer than a file in the source directory.  This can fail on systems
1183 where the clock is set incorrectly.  This macro is automatically run
1184 from @code{AM_INIT_AUTOMAKE}.
1185 @cvindex AM_SANITY_CHECK
1186
1187 @item AM_SYS_POSIX_TERMIOS
1188 Check to see if POSIX termios headers and functions are available on the
1189 system.  If so, set the shell variable @code{am_cv_sys_posix_termios} to
1190 @samp{yes}.  If not, set the variable to @samp{no}.
1191 @cvindex AM_SYS_POSIX_TERMIOS
1192
1193 @item AM_TYPE_PTRDIFF_T
1194 Define @samp{HAVE_PTRDIFF_T} if the type @samp{ptrdiff_t} is defined in
1195 @file{<stddef.h>}.
1196 @cvindex AM_TYPE_PTRDIFF_T
1197
1198 @item AM_WITH_DMALLOC
1199 Add support for the @code{dmalloc} package.  If the user configures with
1200 @samp{--with-dmalloc}, then define @code{WITH_DMALLOC} and add
1201 @samp{-ldmalloc} to @code{LIBS}.  The @code{dmalloc} package can be
1202 found at @url{ftp://ftp.letters.com/src/dmalloc/dmalloc.tar.gz}
1203 @cvindex AM_WITH_DMALLOC
1204
1205 @item AM_WITH_REGEX
1206 Adds @samp{--with-regex} to the @code{configure} command line.  If
1207 specified (the default), then the @samp{regex} regular expression
1208 library is used, @file{regex.o} is put into @samp{LIBOBJS}, and
1209 @samp{WITH_REGEX} is defined..  If @samp{--without-regex} is given, then
1210 the @samp{rx} regular expression library is used, and @file{rx.o} is put
1211 into @samp{LIBOBJS}.
1212 @cvindex AM_WITH_REGEX
1213 @end table
1214
1215
1216 @node Extending aclocal,  , Macros, configure
1217 @section Writing your own aclocal macros
1218
1219 Aclocal doesn't have any built-in knowledge of any macros, so it is easy
1220 to extend it with your own macros.
1221
1222 This is mostly used for libraries which want to supply their own
1223 Autoconf macros for use by other programs.  For instance the
1224 @code{gettext} library supplies a macro @code{AM_GNU_GETTEXT} which
1225 should be used by any package using @code{gettext}.  When the library is
1226 installed, it installs this macro so that @code{aclocal} will find it.
1227
1228 A file of macros should be a series of @code{AC_DEFUN}'s.  Aclocal also
1229 understands @code{AC_REQUIRE}, so it is safe to put each macro in a
1230 separate file.
1231
1232 A macro file's name should end in @samp{.m4}.  Such files should be
1233 installed in @file{$(datadir)/aclocal}.
1234
1235 @node Top level, Programs, configure, Top
1236 @chapter The top-level @file{Makefile.am}
1237
1238 In non-flat packages, the top level @file{Makefile.am} must tell
1239 Automake which subdirectories are to be built.  This is done via the
1240 @code{SUBDIRS} variable.
1241 @vindex SUBDIRS
1242
1243 The @code{SUBDIRS} macro holds a list of subdirectories in which
1244 building of various sorts can occur.  Many targets (eg @code{all}) in
1245 the generated @file{Makefile} will run both locally and in all specified
1246 subdirectories.  Note that the directories listed in @code{SUBDIRS} are
1247 not required to contain @file{Makefile.am}s; only @file{Makefile}s
1248 (after configuration).  This allows inclusion of libraries from packages
1249 which do not use Automake (such as @code{gettext}).  The directories
1250 mentioned in @code{SUBDIRS} must be direct children of the current
1251 directory.  For instance, you cannot put @samp{src/subdir} into
1252 @code{SUBDIRS}.
1253
1254 In a deep package, the top-level @file{Makefile.am} is often very short.
1255 For instance, here is the @file{Makefile.am} from the Hello
1256 distribution:
1257
1258 @example
1259 EXTRA_DIST = BUGS ChangeLog.O README-alpha
1260 SUBDIRS = doc intl po src tests
1261 @end example
1262
1263 It is possible to override the @code{SUBDIRS} variable if, like in the
1264 case of GNU @code{Inetutils}, you want to only build a subset of the
1265 entire package.  In your @file{Makefile.am} include:
1266
1267 @example
1268 SUBDIRS = @@SUBDIRS@@
1269 @end example
1270
1271 Then in your @file{configure.in} you can specify:
1272
1273 @example
1274 SUBDIRS = "src doc lib po"
1275 AC_SUBST(SUBDIRS)
1276 @end example
1277
1278 The upshot of this is that automake is tricked into building the package
1279 to take the subdirs, but doesn't actually bind that list until
1280 @code{configure} is run.
1281
1282
1283 @code{SUBDIRS} can contain configure substitutions (eg @samp{@@DIRS@@});
1284 Automake itself does not actually examine the contents of this variable.
1285
1286 If @code{SUBDIRS} is defined, then your @file{configure.in} must include
1287 @code{AC_PROG_MAKE_SET}.
1288
1289 The use of @code{SUBDIRS} is not restricted to just the top-level
1290 @file{Makefile.am}.  Automake can be used to construct packages of
1291 arbitrary depth.
1292
1293
1294 @node Programs, Other objects, Top level, Top
1295 @chapter Building Programs and Libraries
1296
1297 A large part of Automake's functionality is dedicated to making it easy
1298 to build C programs and libraries.
1299
1300 @menu
1301 * A Program::                   Building a program
1302 * A Library::                   Building a library
1303 * LIBOBJS::                     Special handling for LIBOBJS and ALLOCA
1304 * A Shared Library::            Building a Libtool library
1305 * Program variables::           Variables used when building a program
1306 * Yacc and Lex::                Yacc and Lex support
1307 * C++::                         
1308 * ANSI::                        Automatic de-ANSI-fication
1309 * Dependencies::                Automatic dependency tracking
1310 @end menu
1311
1312
1313 @node A Program, A Library, Programs, Programs
1314 @section Building a program
1315
1316 In a directory containing source that gets built into a program (as
1317 opposed to a library), the @samp{PROGRAMS} primary is used.  Programs
1318 can be installed in @samp{bindir}, @samp{sbindir}, @samp{libexecdir},
1319 @samp{pkglibdir}, or not at all (@samp{noinst}).
1320
1321 For instance:
1322
1323 @example
1324 bin_PROGRAMS = hello
1325 @end example
1326
1327 In this simple case, the resulting @file{Makefile.in} will contain code
1328 to generate a program named @code{hello}.  The variable
1329 @code{hello_SOURCES} is used to specify which source files get built
1330 into an executable:
1331
1332 @example
1333 hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h 
1334 @end example
1335
1336 This causes each mentioned @samp{.c} file to be compiled into the
1337 corresponding @samp{.o}.  Then all are linked to produce @file{hello}.
1338
1339 If @samp{prog_SOURCES} is needed, but not specified, then it defaults to
1340 the single file @file{prog.c}.  In the example above, the definition of
1341 @code{hello_SOURCES} is actually redundant.
1342 @vindex _SOURCES
1343 @vindex SOURCES
1344
1345 Multiple programs can be built in a single directory.  Multiple programs
1346 can share a single source file.  The source file must be listed in each
1347 @samp{_SOURCES} definition.
1348
1349 Header files listed in a @samp{_SOURCES} definition will be included in
1350 the distribution but otherwise ignored.  In case it isn't obvious, you
1351 should not include the header file generated by @file{configure} in an
1352 @samp{_SOURCES} variable; this file should not be distributed.  Lex
1353 (@samp{.l}) and yacc (@samp{.y}) files can also be listed; see @ref{Yacc
1354 and Lex}.
1355
1356 Automake must know all the source files that could possibly go into a
1357 program, even if not all the files are built in every circumstance.
1358 Any files which are only conditionally built should be listed in the
1359 appropriate @samp{EXTRA_} variable.  For instance, if
1360 @file{hello-linux.c} were conditionally included in @code{hello}, the
1361 @file{Makefile.am} would contain:
1362
1363 @example
1364 EXTRA_hello_SOURCES = hello-linux.c
1365 @end example
1366
1367 Similarly, sometimes it is useful to determine the programs that are to
1368 be built at configure time.  For instance, GNU @code{cpio} only builds
1369 @code{mt} and @code{rmt} under special circumstances.
1370
1371 In this case, you must notify @code{automake} of all the programs that
1372 can possibly be built, but at the same time cause the generated
1373 @file{Makefile.in} to use the programs specified by @code{configure}.
1374 This is done by having @code{configure} substitute values into each
1375 @samp{_PROGRAMS} definition, while listing all optionally built programs in
1376 @code{EXTRA_PROGRAMS}.
1377 @vindex EXTRA_PROGRAMS
1378
1379 If you need to link against libraries that are not found by
1380 @code{configure}, you can use @code{LDADD} to do so.  This variable
1381 actually can be used to add any options to the linker command line.
1382 @vindex LDADD
1383
1384 Sometimes, multiple programs are built in one directory but do not share
1385 the same link-time requirements.  In this case, you can use the
1386 @samp{@var{prog}_LDADD} variable (where @var{prog} is the name of the
1387 program as it appears in some @samp{_PROGRAMS} variable, and usually
1388 written in lowercase) to override the global @code{LDADD}.  (If this
1389 variable exists for a given program, then that program is not linked
1390 using @code{LDADD}.)
1391 @vindex _LDADD
1392
1393 For instance, in GNU cpio, @code{pax}, @code{cpio}, and @code{mt} are
1394 linked against the library @file{libcpio.a}.  However, @code{rmt} is
1395 built in the same directory, and has no such link requirement.  Also,
1396 @code{mt} and @code{rmt} are only built on certain architectures.  Here
1397 is what cpio's @file{src/Makefile.am} looks like (abridged):
1398
1399 @example
1400 bin_PROGRAMS = cpio pax @@MT@@
1401 libexec_PROGRAMS = @@RMT@@
1402 EXTRA_PROGRAMS = mt rmt
1403
1404 LDADD = ../lib/libcpio.a @@INTLLIBS@@
1405 rmt_LDADD =
1406
1407 cpio_SOURCES = @dots{}
1408 pax_SOURCES = @dots{}
1409 mt_SOURCES = @dots{}
1410 rmt_SOURCES = @dots{}
1411 @end example
1412
1413 @samp{prog_LDADD} is inappropriate for passing program-specific linker
1414 flags (except for @samp{-l} and @samp{-L}).  So, use the
1415 @samp{prog_LDFLAGS} variable for this purpose.
1416 @vindex _LDFLAGS
1417
1418 It is also occasionally useful to have a program depend on some other
1419 target which is not actually part of that program.  This can be done
1420 using the @samp{prog_DEPENDENCIES} variable.  Each program depends on
1421 the contents of such a variable, but no further interpretation is done.
1422
1423 If @samp{prog_DEPENDENCIES} is not supplied, it is computed by Automake.
1424 The automatically-assigned value is the contents of @samp{prog_LDADD},
1425 with most configure substitutions, @samp{-l}, and @samp{-L} options
1426 removed.  The configure substitutions that are left in are only
1427 @samp{@@LIBOBJS@@} and @samp{@@ALLOCA@@}; these are left because it is
1428 known that they will not cause an invalid value for
1429 @samp{prog_DEPENDENCIES} to be generated.
1430
1431
1432 @node A Library, LIBOBJS, A Program, Programs
1433 @section Building a library
1434
1435 Building a library is much like building a program.  In this case, the
1436 name of the primary is @samp{LIBRARIES}.  Libraries can be installed in
1437 @code{libdir} or @code{pkglibdir}.
1438
1439 @xref{A Shared Library}, for information on how to build shared
1440 libraries using Libtool and the @samp{LTLIBRARIES} primary.
1441
1442 Each @samp{_LIBRARIES} variable is a list of the libraries to be built.
1443 For instance to create a library named @file{libcpio.a}, but not install
1444 it, you would write:
1445
1446 @example
1447 noinst_LIBRARIES = libcpio.a
1448 @end example
1449
1450 The sources that go into a library are determined exactly as they are
1451 for programs, via the @samp{_SOURCES} variables.  Note that the library
1452 name is canonicalized (@pxref{Canonicalization}), so the @samp{_SOURCES}
1453 variable corresponding to @file{liblob.a} is @samp{liblob_a_SOURCES},
1454 not @samp{liblob.a_SOURCES}.
1455
1456 Extra objects can be added to a library using the @samp{library_LIBADD}
1457 variable.  This should be used for objects determined by
1458 @code{configure}.  Again from cpio:
1459 @vindex _LIBADD
1460 @vindex LIBADD
1461
1462 @example
1463 libcpio_a_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
1464 @end example
1465
1466 @node LIBOBJS, A Shared Library, A Library, Programs
1467 @section Special handling for LIBOBJS and ALLOCA
1468
1469 Automake explicitly recognizes the use of @code{@@LIBOBJS@@} and
1470 @code{@@ALLOCA@@}, and uses this information, plus the list of
1471 @code{LIBOBJS} files derived from @file{configure.in} to automatically
1472 include the appropriate source files in the distribution (@pxref{Dist}).
1473 These source files are also automatically handled in the
1474 dependency-tracking scheme, see @xref{Dependencies}.
1475
1476 @code{@@LIBOBJS@@} and @code{@@ALLOCA@@} are specially recognized in any
1477 @samp{_LDADD} or @samp{_LIBADD} variable.
1478
1479 @node A Shared Library, Program variables, LIBOBJS, Programs
1480 @section Building a Shared Library
1481
1482 Building shared libraries is a relatively complex matter.  For this
1483 reason, GNU Libtool (@pxref{Top, , The Libtool Manual, libtool, The
1484 Libtool Manual}) was created to help build shared libraries in a
1485 platform-independent way.
1486
1487 Automake uses Libtool to build libraries declared with the
1488 @samp{LTLIBRARIES} primary.  Each @samp{_LTLIBRARIES} variable is a list
1489 of shared libraries to build.  For instance, to create a library named
1490 @file{libgettext.a} and its corresponding shared libraries, and install
1491 them in @samp{libdir}, write:
1492
1493 @example
1494 lib_LTLIBRARIES = libgettext.la
1495 @end example
1496
1497 Note that shared libraries @emph{must} be installed, so
1498 @samp{noinst_LTLIBRARIES} and @samp{check_LTLIBRARIES} are not allowed.
1499
1500 For each library, the @samp{library_LIBADD} variable contains the names
1501 of extra libtool objects (@samp{.lo} files) to add to the shared
1502 library.  The @samp{library_LDFLAGS} variable contains any additional
1503 libtool flags, such as @samp{-version-info} or @samp{-static}.
1504
1505 Where an ordinary library might include @code{@@LIBOBJS@@}, a libtool
1506 library must use @code{@@LTLIBOBJS@@}.  This is required because the
1507 object files that libtool operates on do not necessarily end in
1508 @samp{.o}.  The libtool manual contains more details on this topic.
1509
1510 For libraries installed in some directory, @code{automake} will
1511 automatically supply the appropriate @samp{-rpath} option.  However, for
1512 libraries determined at configure time (and thus mentioned in
1513 @code{EXTRA_LTLIBRARIES}), @code{automake} does not know the eventual
1514 installation directory; for such libraries you must add the
1515 @samp{-rpath} option to the appropriate @samp{_LDFLAGS} variable by
1516 hand.
1517
1518 @xref{Using Automake, Using Automake with Libtool, The Libtool Manual,
1519 libtool, The Libtool Manual}, for more information.
1520
1521 @node Program variables, Yacc and Lex, A Shared Library, Programs
1522 @section Variables used when building a program
1523
1524 Occasionally it is useful to know which @file{Makefile} variables
1525 Automake uses for compilations; for instance you might need to do your
1526 own compilation in some special cases.
1527
1528 Some variables are inherited from Autoconf; these are @code{CC},
1529 @code{CFLAGS}, @code{CPPFLAGS}, @code{DEFS}, @code{LDFLAGS}, and
1530 @code{LIBS}.
1531 @vindex LDFLAGS
1532
1533 There are some additional variables which Automake itself defines:
1534
1535 @table @code
1536 @item INCLUDES
1537 A list of @samp{-I} options.  This can be set in your @file{Makefile.am}
1538 if you have special directories you want to look in.  @code{automake}
1539 already provides some @samp{-I} options automatically.  In particular it
1540 generates @samp{-I$(srcdir)} and a @samp{-I} pointing to the directory
1541 holding @file{config.h} (if you've used @code{AC_CONFIG_HEADER} or
1542 @code{AM_CONFIG_HEADER}).
1543
1544 @code{INCLUDES} can actually be used for other @code{cpp} options
1545 besides @samp{-I}.  For instance, it is sometimes used to pass arbitrary
1546 @samp{-D} options to the compiler.
1547
1548 @item COMPILE
1549 This is the command used to actually compile a C source file.  The
1550 filename is appended to form the complete command line.
1551
1552 @item LINK
1553 This is the command used to actually link a C program.
1554 @end table
1555
1556
1557 @node Yacc and Lex, C++, Program variables, Programs
1558 @section Yacc and Lex support
1559
1560 Automake has somewhat idiosyncratic support for Yacc and Lex.
1561
1562 Automake assumes that the @samp{.c} file generated by yacc (or lex)
1563 should be named using the basename of the input file.  That is, for a
1564 yacc source file @file{foo.y}, automake will cause the intermediate file
1565 to be named @file{foo.c} (as opposed to @file{y.tab.c}, which is more
1566 traditional).
1567
1568 The extension of a yacc source file is used to determine the extension
1569 of the resulting @samp{C} or @samp{C++} file.  Files with the extension
1570 @samp{.y} will be turned into @samp{.c} files; likewise, @samp{.yy} will
1571 become @samp{.cc}; @samp{.y++}, @samp{c++}; and @samp{.yxx},
1572 @samp{.cxx}.  Likewise, lex source files can be used to generate
1573 @samp{C} or @samp{C++}; the extensions @samp{.l}, @samp{.ll},
1574 @samp{.l++}, and @samp{.lxx} are recognized.
1575
1576 You should never explicitly mention the intermediate (@samp{C} or
1577 @samp{C++}) file in any @samp{SOURCES} variable; only list the source
1578 file.
1579
1580 The intermediate files generated by yacc (or lex) will be included in
1581 any distribution that is made.  That way the user doesn't need to have
1582 yacc or lex.
1583
1584 If a yacc source file is seen, then your @file{configure.in} must define
1585 the variable @samp{YACC}.  This is most easily done by invoking the
1586 macro @samp{AC_PROG_YACC}.
1587
1588 Similarly, if a lex source file is seen, then your @file{configure.in}
1589 must define the variable @samp{LEX}.  You can use @samp{AC_PROG_LEX} to
1590 do this.  Automake's lex support also requires that you use the
1591 @samp{AC_DECL_YYTEXT} macro---automake needs to know the value of
1592 @samp{LEX_OUTPUT_ROOT}.
1593
1594 Automake makes it possible to include multiple yacc (or lex) source
1595 files in a single program.  Automake uses a small program called
1596 @code{ylwrap} to run @code{yacc} (or @code{lex}) in a subdirectory.
1597 This is necessary because yacc's output filename is fixed, and a
1598 parallel make could conceivably invoke more than one instance of
1599 @code{yacc} simultaneously.  @code{ylwrap} is distributed with automake.
1600 It should appear in the directory specified by @samp{AC_CONFIG_AUX_DIR},
1601 or the current directory if that macro is not used in
1602 @file{configure.in}.
1603
1604 For @code{yacc}, simply managing locking is insufficient.  @code{yacc}
1605 output also always uses the same symbol names internally, so it isn't
1606 possible to link two @code{yacc} parsers into the same executable.
1607
1608 We recommend using the following renaming hack used in @code{gdb}:
1609 @example
1610 #define yymaxdepth c_maxdepth
1611 #define yyparse c_parse
1612 #define yylex   c_lex
1613 #define yyerror c_error
1614 #define yylval  c_lval
1615 #define yychar  c_char
1616 #define yydebug c_debug
1617 #define yypact  c_pact  
1618 #define yyr1    c_r1                    
1619 #define yyr2    c_r2                    
1620 #define yydef   c_def           
1621 #define yychk   c_chk           
1622 #define yypgo   c_pgo           
1623 #define yyact   c_act           
1624 #define yyexca  c_exca
1625 #define yyerrflag c_errflag
1626 #define yynerrs c_nerrs
1627 #define yyps    c_ps
1628 #define yypv    c_pv
1629 #define yys     c_s
1630 #define yy_yys  c_yys
1631 #define yystate c_state
1632 #define yytmp   c_tmp
1633 #define yyv     c_v
1634 #define yy_yyv  c_yyv
1635 #define yyval   c_val
1636 #define yylloc  c_lloc
1637 #define yyreds  c_reds
1638 #define yytoks  c_toks
1639 #define yylhs   c_yylhs
1640 #define yylen   c_yylen
1641 #define yydefred c_yydefred
1642 #define yydgoto c_yydgoto
1643 #define yysindex c_yysindex
1644 #define yyrindex c_yyrindex
1645 #define yygindex c_yygindex
1646 #define yytable  c_yytable
1647 #define yycheck  c_yycheck
1648 #define yyname   c_yyname
1649 #define yyrule   c_yyrule
1650 @end example
1651
1652 For each define, replace the @samp{c_} prefix with whatever you like.
1653 These defines work for @code{bison}, @code{byacc}, and traditional
1654 @code{yacc}s.  If you find a parser generator that uses a symbol not
1655 covered here, please report the new name so it can be added to the list.
1656
1657
1658 @node C++, ANSI, Yacc and Lex, Programs
1659 @section C++ and other languages
1660
1661 Automake includes full support for C++, and rudimentary support for
1662 other languages.  Support for other languages will be improved based on
1663 demand.
1664
1665 Any package including C++ code must define the output variable
1666 @samp{CXX} in @file{configure.in}; the simplest way to do this is to use
1667 the @code{AC_PROG_CXX} macro.
1668
1669 A few additional variables are defined when a C++ source file is seen:
1670
1671 @table @code
1672 @item CXX
1673 The name of the C++ compiler.
1674 @vindex CXX
1675
1676 @item CXXFLAGS
1677 Any flags to pass to the C++ compiler.
1678 @vindex CXXFLAGS
1679
1680 @item CXXCOMPILE
1681 The command used to actually compile a C++ source file.  The file name
1682 is appended to form the complete command line.
1683 @vindex CXXCOMPILE
1684
1685 @item CXXLINK
1686 The command used to actually link a C++ program.
1687 @vindex CXXLINK
1688 @end table
1689
1690
1691 @node ANSI, Dependencies, C++, Programs
1692 @section Automatic de-ANSI-fication
1693
1694 Although the GNU standards allow the use of ANSI C, this can have the
1695 effect of limiting portability of a package to some older compilers
1696 (notably SunOS).
1697
1698 Automake allows you to work around this problem on such machines by
1699 ``de-ANSI-fying'' each source file before the actual compilation takes
1700 place.
1701
1702 If the @file{Makefile.am} variable @code{AUTOMAKE_OPTIONS}
1703 @vindex AUTOMAKE_OPTIONS
1704 (@ref{Options}) contains the option @code{ansi2knr}
1705 @opindex ansi2knr
1706 then code to handle de-ANSI-fication is inserted into the generated
1707 @file{Makefile.in}.
1708
1709 This causes each C source file in the directory to be treated as ANSI C.
1710 If an ANSI C compiler is available, it is used.  If no ANSI C compiler
1711 is available, the @code{ansi2knr} program is used to convert the source
1712 files into K&R C, which is then compiled.
1713
1714 The @code{ansi2knr} program is simple-minded.  It assumes the source
1715 code will be formatted in a particular way; see the @code{ansi2knr} man
1716 page for details.
1717
1718 De-ANSI-fication support requires the source files @file{ansi2knr.c} and
1719 @file{ansi2knr.1} to be in the same package as the ANSI C source; these
1720 files are distributed with Automake.  Also, the package
1721 @file{configure.in} must call the macro @code{AM_C_PROTOTYPES}.
1722 @cvindex AM_C_PROTOTYPES
1723
1724 Automake also handles finding the @code{ansi2knr} support files in some
1725 other directory in the current package.  This is done by prepending the
1726 relative path to the appropriate directory to the @code{ansi2knr}
1727 option.  For instance, suppose the package has ANSI C code in the
1728 @file{src} and @file{lib} subdirs.  The files @file{ansi2knr.c} and
1729 @file{ansi2knr.1} appear in @file{lib}.  Then this could appear in
1730 @file{src/Makefile.am}:
1731
1732 @example
1733 AUTOMAKE_OPTIONS = ../lib/ansi2knr
1734 @end example
1735
1736 If no directory prefix is given, the files are assumed to be in the
1737 current directory.
1738
1739 Files mentioned in @code{LIBOBJS} which need de-ANSI-fication will not
1740 be automatically handled.  That's because @code{configure} will generate
1741 an object name like @file{regex.o}, while @code{make} will be looking
1742 for @file{regex_.o} (when de-ANSI-fying).  Eventually this problem will
1743 be fixed via @code{autoconf} magic, but for now you must put this code
1744 into your @file{configure.in}, just before the @code{AC_OUTPUT} call:
1745
1746 @example
1747 # This is necessary so that .o files in LIBOBJS are also built via
1748 # the ANSI2KNR-filtering rules.
1749 LIBOBJS=`echo $LIBOBJS|sed 's/\.o /\$U.o /g;s/\.o$/\$U.o/'`
1750 @end example
1751
1752
1753 @node Dependencies,  , ANSI, Programs
1754 @section Automatic dependency tracking
1755
1756 As a developer it is often painful to continually update the
1757 @file{Makefile.in} whenever the include-file dependencies change in a
1758 project.  @code{automake} supplies a way to automatically track
1759 dependency changes, and distribute the dependencies in the generated
1760 @file{Makefile.in}.
1761
1762 Currently this support requires the use of GNU @code{make} and
1763 @code{gcc}.  It might become possible in the future to supply a
1764 different dependency generating program, if there is enough demand.  In
1765 the meantime, this mode is enabled by default if any C program or
1766 library is defined in the current directory, so you may get a @samp{Must
1767 be a separator} error from non-GNU make.
1768
1769 When you decide to make a distribution, the @code{dist} target will
1770 @trindex dist
1771 re-run @code{automake} with @samp{--include-deps} and other options.
1772 This will cause the previously generated dependencies to be inserted
1773 into the generated @file{Makefile.in}, and thus into the distribution.
1774 This step also turns off inclusion of the dependency generation code, so
1775 that those who download your distribution but don't use GNU @code{make}
1776 and @code{gcc} will not get errors.
1777
1778 When added to the @file{Makefile.in}, the dependencies have all
1779 system-specific dependencies automatically removed.  This can be done by
1780 listing the files in @samp{OMIT_DEPENDENCIES}.
1781 @vindex OMIT_DEPENDENCIES
1782 For instance all references to system header files are removed by
1783 @code{automake}.  Sometimes it is useful to specify that a certain
1784 header file should be removed.  For instance if your @file{configure.in}
1785 uses @samp{AM_WITH_REGEX}, then any dependency on @file{rx.h} or
1786 @file{regex.h} should be removed, because the correct one cannot be
1787 known until the user configures the package.
1788
1789 As it turns out, @code{automake} is actually smart enough to handle the
1790 particular case of the regular expression header.  It will also
1791 automatically omit @file{libintl.h} if @samp{AM_GNU_GETTEXT} is used.
1792
1793 Automatic dependency tracking can be suppressed by putting
1794 @code{no-dependencies} in the variable @code{AUTOMAKE_OPTIONS}.
1795 @vindex AUTOMAKE_OPTIONS
1796 @opindex no-dependencies
1797
1798 If you unpack a distribution made by @code{make dist}, and you want to
1799 turn on the dependency-tracking code again, simply re-run
1800 @code{automake}.
1801
1802 The actual dependency files are put under the build directory, in a
1803 subdirectory named @file{.deps}.  These dependencies are machine
1804 specific.  It is safe to delete them if you like; they will be
1805 automatically recreated during the next build.
1806
1807
1808 @node Other objects, Other GNU Tools, Programs, Top
1809 @chapter Other Derived Objects
1810
1811 Automake can handle derived objects which are not C programs.  Sometimes
1812 the support for actually building such objects must be explicitly
1813 supplied, but Automake will still automatically handle installation and
1814 distribution.
1815
1816 @menu
1817 * Scripts::                     Executable scripts
1818 * Headers::                     Header files
1819 * Data::                        Architecture-independent data files
1820 * Sources::                     Derived sources
1821 @end menu
1822
1823
1824 @node Scripts, Headers, Other objects, Other objects
1825 @section Executable Scripts
1826
1827 It is possible to define and install programs which are scripts.  Such
1828 programs are listed using the @samp{SCRIPTS} primary name.
1829 @code{automake} doesn't define any dependencies for scripts; the
1830 @file{Makefile.am} should include the appropriate rules.
1831 @vindex SCRIPTS
1832
1833 @code{automake} does not assume that scripts are derived objects; such
1834 objects must be deleted by hand; see @ref{Clean} for more information.
1835
1836 @code{automake} itself is a script that is generated at configure time
1837 from @file{automake.in}.  Here is how this is handled:
1838
1839 @example
1840 bin_SCRIPTS = automake
1841 @end example
1842
1843 Since @code{automake} appears in the @code{AC_OUTPUT} macro, a target
1844 for it is automatically generated.
1845
1846 Script objects can be installed in @code{bindir}, @code{sbindir},
1847 @code{libexecdir}, or @code{pkgdatadir}.
1848
1849
1850 @node Headers, Data, Scripts, Other objects
1851 @section Header files
1852
1853 Header files are specified by the @samp{HEADERS} family of variables.
1854 Generally header files are not installed, so the @code{noinst_HEADERS}
1855 variable will be the most used.
1856 @vindex HEADERS
1857
1858 All header files must be listed somewhere; missing ones will not appear
1859 in the distribution.  Often it is clearest to list uninstalled headers
1860 with the rest of the sources for a program.  @xref{A Program}.  Headers
1861 listed in a @samp{_SOURCES} variable need not be listed in any
1862 @samp{_HEADERS} variable.
1863
1864 Headers can be installed in @code{includedir}, @code{oldincludedir}, or
1865 @code{pkgincludedir}.
1866
1867
1868 @node Data, Sources, Headers, Other objects
1869 @section Architecture-independent data files
1870
1871 Automake supports the installation of miscellaneous data files using the
1872 @samp{DATA} family of variables.
1873 @vindex DATA
1874
1875 Such data can be installed in the directories @code{datadir},
1876 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
1877 @code{pkgdatadir}.
1878
1879 By default, data files are not included in a distribution.
1880
1881 Here is how @code{automake} installs its auxiliary data files:
1882
1883 @example
1884 pkgdata_DATA = clean-kr.am clean.am @dots{}
1885 @end example
1886
1887
1888 @node Sources,  , Data, Other objects
1889 @section Built sources
1890
1891 Occasionally a file which would otherwise be called ``source'' (eg a C
1892 @samp{.h} file) is actually derived from some other file.  Such files
1893 should be listed in the @code{BUILT_SOURCES} variable.
1894 @vindex BUILT_SOURCES
1895
1896 Built sources are also not compiled by default.  You must explicitly
1897 mention them in some other @samp{_SOURCES} variable for this to happen.
1898
1899 Note that, in some cases, @code{BUILT_SOURCES} will work in somewhat
1900 suprising ways.  In order to get the built sources to work with
1901 automatic dependency tracking, the @file{Makefile} must depend on
1902 @code{$(BUILT_SOURCES)}.  This can cause these sources to be rebuilt at
1903 what might seem like funny times.
1904
1905
1906 @node Other GNU Tools, Documentation, Other objects, Top
1907 @chapter Other GNU Tools
1908
1909 Since Automake is primarily intended to generate @file{Makefile.in}s for
1910 use in GNU programs, it tries hard to interoperate with other GNU tools.
1911
1912 @menu
1913 * Emacs Lisp::                  Emacs Lisp
1914 * gettext::                     Gettext
1915 * Guile::                       Guile
1916 * Libtool::                     Libtool
1917 * Java::                        Java
1918 @end menu
1919
1920 @node Emacs Lisp, gettext, Other GNU Tools, Other GNU Tools
1921 @section Emacs Lisp
1922
1923 Automake provides some support for Emacs Lisp.  The @samp{LISP} primary
1924 is used to hold a list of @samp{.el} files.  Possible prefixes for this
1925 primary are @samp{lisp_} and @samp{noinst_}.  Note that if
1926 @code{lisp_LISP} is defined, then @file{configure.in} must run
1927 @code{AM_PATH_LISPDIR} (@pxref{Macros}).
1928 @vindex LISP
1929 @vindex lisp_LISP
1930 @vindex noinst_LISP
1931
1932 By default Automake will byte-compile all Emacs Lisp source files using
1933 the Emacs found by @code{AM_PATH_LISPDIR}.  If you wish to avoid
1934 byte-compiling, simply define the variable @samp{ELCFILES} to be empty.
1935 @vindex ELCFILES
1936 Byte-compiled Emacs Lisp files are not portable among all versions of
1937 Emacs, so it makes sense to turn this off if you expect sites to have
1938 more than one version of Emacs installed.  Furthermore, many packages
1939 don't actually benefit from byte-compilation.  Still, we recommand that
1940 you leave it enabled by default.  It is probably better for sites with
1941 strange setups to cope for themselves than to make the installation less
1942 nice for everybody else.
1943
1944 @node gettext, Guile, Emacs Lisp, Other GNU Tools
1945 @section Gettext
1946
1947 If @code{AM_GNU_GETTEXT} is seen in @file{configure.in}, then Automake
1948 turns on support for GNU gettext, a message catalog system for
1949 internationalization
1950 (@pxref{GNU Gettext, , , gettext, GNU gettext utilities}).
1951
1952 The @code{gettext} support in Automake requires the addition of two
1953 subdirectories to the package, @file{intl} and @file{po}.  Automake
1954 ensure that these directories exist and are mentioned in @code{SUBDIRS}.
1955
1956 Furthermore, Automake checks that the definition of @samp{ALL_LINGUAS}
1957 in @file{configure.in} corresponds to all the valid @samp{.po} files,
1958 and nothing more.
1959
1960
1961 @node Guile, Libtool, gettext, Other GNU Tools
1962 @section Guile
1963
1964 Automake provides some automatic support for writing Guile modules.
1965 Automake will turn on Guile support if the @code{AM_INIT_GUILE_MODULE}
1966 macro is used in @file{configure.in}.
1967
1968 Right now Guile support just means that the @code{AM_INIT_GUILE_MODULE}
1969 macro is understood to mean:
1970 @itemize @bullet
1971 @item
1972 @code{AM_INIT_AUTOMAKE} is run.
1973
1974 @item
1975 @code{AC_CONFIG_AUX_DIR} is run, with a path of @file{..}.
1976 @end itemize
1977
1978 As the Guile module code matures, no doubt the Automake support will
1979 grow as well.
1980
1981 @node Libtool, Java, Guile, Other GNU Tools
1982 @section Libtool
1983
1984 Automake provides support for GNU Libtool (@pxref{Top, , The Libtool
1985 Manual, libtool, The Libtool Manual}) with the @samp{LTLIBRARIES}
1986 primary.  @xref{A Shared Library}.
1987
1988 @node Java, , Libtool, Other GNU Tools
1989 @section Java
1990
1991 Automake provides some minimal support for Java compilation with the
1992 @samp{JAVA} primary.
1993
1994 Any @samp{.java} files listed in a @samp{_JAVA} variable will be
1995 compiled with @code{JAVAC} at build time.  By default, @samp{.class}
1996 files are not included in the distribution.
1997
1998 Currently Automake enforces the restriction that only one @samp{_JAVA}
1999 primary can be used in a given @file{Makefile.am}.  The reason for this
2000 restriction is that, in general, it isn't possible to know which
2001 @samp{.class} files were generated from which @samp{.java} files -- so
2002 it would be impossible to know which files to install where.
2003
2004
2005 @node Documentation, Install, Other GNU Tools, Top
2006 @chapter Building documentation
2007
2008 Currently Automake provides support for Texinfo and man pages.
2009
2010 @menu
2011 * Texinfo::                     Texinfo
2012 * Man pages::                   Man pages
2013 @end menu
2014
2015
2016 @node Texinfo, Man pages, Documentation, Documentation
2017 @section Texinfo
2018
2019 If the current directory contains Texinfo source, you must declare it
2020 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
2021 into info, and thus the @code{info_TEXINFOS} macro is most commonly used
2022 here.  Note that any Texinfo source file must end in the @samp{.texi} or
2023 @samp{.texinfo} extension.
2024 @vindex TEXINFOS
2025 @vindex info_TEXINFOS
2026
2027 If the @samp{.texi} file @code{@@include}s @file{version.texi}, then that
2028 file will be automatically generated.  @file{version.texi} defines three
2029 Texinfo macros you can reference: @code{EDITION}, @code{VERSION}, and
2030 @code{UPDATED}.  The first two hold the version number of your package
2031 (but are kept separate for clarity); the last is the date the primary
2032 file was last modified.  The @file{version.texi} support requires the
2033 @code{mdate-sh} program; this program is supplied with Automake.
2034
2035 Sometimes an info file actually depends on more than one @samp{.texi}
2036 file.  For instance, in GNU Hello, @file{hello.texi} includes the file
2037 @file{gpl.texi}.  You can tell Automake about these dependencies using
2038 the @samp{@var{texi}_TEXINFOS} variable.  Here is how Hello does it:
2039 @vindex TEXINFOS
2040 @vindex _TEXINFOS
2041
2042 @example
2043 info_TEXINFOS = hello.texi
2044 hello_TEXINFOS = gpl.texi
2045 @end example
2046
2047 By default, Automake requires the file @file{texinfo.tex} to appear in
2048 the same directory as the Texinfo source.  However, if you used
2049 @code{AC_CONFIG_AUX_DIR} in @file{configure.in}, then @file{texinfo.tex}
2050 is looked for there.  Automake supplies @file{texinfo.tex} if
2051 @samp{--add-missing} is given.
2052
2053 If your package has Texinfo files in many directories, you can use the
2054 variable @code{TEXINFO_TEX} to tell automake where to find the canonical
2055 @file{texinfo.tex} for your package.  The value of this variable should
2056 be the relative path from the current @file{Makefile.am} to
2057 @file{texinfo.tex}:
2058
2059 @example
2060 TEXINFO_TEX = ../doc/texinfo.tex
2061 @end example
2062
2063 The option @samp{no-texinfo.tex} can be used to eliminate the
2064 requirement for @file{texinfo.tex}.  Use of the variable
2065 @code{TEXINFO_TEX} is preferable, however, because that allows the
2066 @code{dvi} target to still work.
2067
2068 Automake generates an @code{install-info} target; some people apparently
2069 use this.  By default, info pages are installed by @samp{make install}.
2070 This can be prevented via the @code{no-installinfo} option.
2071
2072
2073 @node Man pages,  , Texinfo, Documentation
2074 @section Man pages
2075
2076 A package can also include man pages.  (Though see the GNU standards on
2077 this matter, @ref{Man Pages, , , standards, The GNU Coding
2078 Standards}.)  Man pages are declared using the @samp{MANS} primary.
2079 Generally the @code{man_MANS} macro is used.  Man pages are
2080 automatically installed in the correct subdirectory of @code{mandir},
2081 based on the file extension.
2082 @vindex MANS
2083 @vindex man_MANS
2084
2085 @c Use @samp{make install} per documentation: (texi)code.
2086 By default, man pages are installed by @samp{make install}.  However,
2087 since the GNU project does not require man pages, many maintainers do
2088 not expend effort to keep the man pages up to date.  In these cases, the
2089 @code{no-installman} option will prevent the man pages from being
2090 installed by default.  The user can still explicitly install them via
2091 @samp{make install-man}.
2092 @opindex no-installman
2093 @trindex install-man
2094
2095 Here is how the documentation is handled in GNU @code{cpio} (which
2096 includes both Texinfo documentation and man pages):
2097
2098 @example
2099 info_TEXINFOS = cpio.texi
2100 man_MANS = cpio.1 mt.1
2101 @end example
2102
2103 Texinfo source and info pages are all considered to be source for the
2104 purposes of making a distribution.
2105
2106 Man pages are not currently considered to be source, because it is not
2107 uncommon for man pages to be automatically generated.
2108
2109
2110 @node Install, Clean, Documentation, Top
2111 @chapter What Gets Installed
2112
2113 Naturally, Automake handles the details of actually installing your
2114 program once it has been built.  All @code{PROGRAMS}, @code{SCRIPTS},
2115 @code{LIBRARIES}, @code{LISP}, @code{DATA} and @code{HEADERS} are
2116 automatically installed in the appropriate places.
2117
2118 Automake also handles installing any specified info and man pages.
2119
2120 Automake generates separate @code{install-data} and @code{install-exec}
2121 targets, in case the installer is installing on multiple machines which
2122 share directory structure---these targets allow the machine-independent
2123 parts to be installed only once.  The @code{install} target depends on
2124 both of these targets.
2125 @trindex install-data
2126 @trindex install-exec
2127 @trindex install
2128
2129 Automake also generates an @code{uninstall} target, an
2130 @code{installdirs} target, and an @code{install-strip} target.
2131 @trindex uninstall
2132 @trindex installdirs
2133 @trindex install-strip
2134
2135 It is possible to extend this mechanism by defining an
2136 @code{install-exec-local} or @code{install-data-local} target.  If these
2137 targets exist, they will be run at @samp{make install} time.
2138 @trindex install-exec-local
2139 @trindex install-data-local
2140
2141 Variables using the standard directory prefixes @samp{data},
2142 @samp{info}, @samp{man}, @samp{include}, @samp{oldinclude},
2143 @samp{pkgdata}, or @samp{pkginclude} (eg @samp{data_DATA}) are installed
2144 by @samp{install-data}.
2145
2146 Variables using the standard directory prefixes @samp{bin}, @samp{sbin},
2147 @samp{libexec}, @samp{sysconf}, @samp{localstate}, @samp{lib}, or
2148 @samp{pkglib} (eg @samp{bin_PROGRAMS}) are installed by
2149 @samp{install-exec}.
2150
2151 Any variable using a user-defined directory prefix with @samp{exec} in
2152 the name (eg @samp{myexecbin_PROGRAMS} is installed by
2153 @samp{install-exec}.  All other user-defined prefixes are installed by
2154 @samp{install-data}.
2155
2156 Automake generates support for the @samp{DESTDIR} variable in all
2157 install rules; see @xref{Makefile Conventions, , , standards, The GNU
2158 Coding Standards}.
2159 @vindex DESTDIR
2160
2161
2162 @node Clean, Dist, Install, Top
2163 @chapter What Gets Cleaned
2164
2165 The GNU Makefile Standards specify a number of different clean rules.
2166 @c FIXME xref
2167 Generally the files that can cleaned are determined automatically by
2168 Automake.  Of course, Automake also recognizes some variables that can
2169 be defined to specify additional files to clean.  These variables are
2170 @code{MOSTLYCLEANFILES}, @code{CLEANFILES}, @code{DISTCLEANFILES}, and
2171 @code{MAINTAINERCLEANFILES}.
2172 @vindex MOSTLYCLEANFILES
2173 @vindex CLEANFILES
2174 @vindex DISTCLEANFILES
2175 @vindex MAINTAINERCLEANFILES
2176
2177
2178 @node Dist, Tests, Clean, Top
2179 @chapter What Goes in a Distribution
2180
2181 The @code{dist} target in the generated @file{Makefile.in} can be used
2182 to generate a gzip'd @code{tar} file for distribution.  The tar file is
2183 named based on the @samp{PACKAGE} and @samp{VERSION} variables; more
2184 precisely it is named @samp{@var{package}-@var{version}.tar.gz}.
2185 @cvindex PACKAGE
2186 @cvindex VERSION
2187 @trindex dist
2188
2189 For the most part, the files to distribute are automatically found by
2190 Automake: all source files are automatically included in a distribution,
2191 as are all @file{Makefile.am}s and @file{Makefile.in}s.  Automake also
2192 has a built-in list of commonly used files which, if present in the
2193 current directory, are automatically included.  This list is printed by
2194 @samp{automake --help}.  Also, files which are read by @code{configure}
2195 (ie, the source files corresponding to the files specified in the
2196 @code{AC_OUTPUT} invocation) are automatically distributed.
2197
2198 Still, sometimes there are files which must be distributed, but which
2199 are not covered in the automatic rules.  These files should be listed in
2200 the @code{EXTRA_DIST} variable.  You can mention files from
2201 subdirectories in @code{EXTRA_DIST}.  You can also mention a directory
2202 there; in this case the entire directory will be recursively copied into
2203 the distribution.
2204 @vindex EXTRA_DIST
2205
2206 If you define @code{SUBDIRS}, automake will recursively include the
2207 subdirectories in the distribution.  If @code{SUBDIRS} is defined
2208 conditionally (@pxref{Conditionals}), automake will normally include all
2209 directories that could possibly appear in @code{SUBDIRS} in the
2210 distribution.  If you need to specify the set of directories
2211 conditionally, you can set the variable @code{DIST_SUBDIRS} to the exact
2212 list of subdirectories to include in the distribution.
2213 @vindex DIST_SUBDIRS
2214
2215 Occasionally it is useful to be able to change the distribution before
2216 it is packaged up.  If the @code{dist-hook} target exists, it is run
2217 after the distribution directory is filled, but before the actual tar
2218 (or shar) file is created.  One way to use this is for distributing
2219 files in subdirectories for which a new @file{Makefile.am} is overkill:
2220
2221 @example
2222 dist-hook:
2223         mkdir $(distdir)/random
2224         cp -p $(srcdir)/random/a1 $(srcdir)/random/a2 $(distdir)/random
2225 @end example
2226
2227 Automake also generates a @code{distcheck} target which can be help to
2228 ensure that a given distribution will actually work.  @code{distcheck}
2229 makes a distribution, and then tries to do a @code{VPATH} build.
2230 @trindex distcheck
2231 @c FIXME: document distcheck-hook here
2232
2233 @node Tests, Options, Dist, Top
2234 @chapter Support for test suites
2235
2236 Automake supports a two forms of test suite.
2237
2238 If the variable @code{TESTS} is defined, its value is taken to be a list
2239 of programs to run in order to do the testing.  The programs can either
2240 be derived objects or source objects; the generated rule will look both
2241 in @var{srcdir} and @file{.}.  Programs needing data files should look
2242 for them in @var{srcdir} (which is both an environment variable and a
2243 make variable) so they work when building in a separate directory
2244 (@pxref{Build Directories,, Build Directories ,autoconf, Autoconf}),
2245 and in particular for the
2246 @code{distcheck} target (@pxref{Dist}).
2247
2248 The number of failures will be printed at the end of the run.  If a
2249 given test program exits with a status of 77, then its result is ignored
2250 in the final count.  This feature allows non-portable tests to be
2251 ignored in environments where they don't make sense.
2252
2253 The variable @code{TESTS_ENVIRONMENT} can be used to set environment
2254 variables for the test run; the environment variable @code{srcdir} is
2255 set in the rule.  If all your test programs are scripts, you can also
2256 set @code{TESTS_ENVIRONMENT} to an invocation of the shell (eg
2257 @samp{$(SHELL) -x}); this can be useful for debugging the tests.
2258 @vindex TESTS
2259 @vindex TESTS_ENVIRONMENT
2260
2261 If @samp{dejagnu} appears in @code{AUTOMAKE_OPTIONS}, then the a
2262 @code{dejagnu}-based test suite is assumed.  The value of the variable
2263 @code{DEJATOOL} is passed as the @code{--tool} argument to
2264 @code{runtest}; it defaults to the name of the package.
2265
2266 The variable @code{RUNTESTDEFAULTFLAGS} holds the @code{--tool} and
2267 @code{--srcdir} flags that are passed to dejagnu by default; this can be
2268 overridden if necessary.
2269 @vindex RUNTESTDEFAULTFLAGS
2270
2271 The variables @code{EXPECT}, @code{RUNTEST} and @code{RUNTESTFLAGS} can
2272 also be overridden to provide project-specific values.  For instance,
2273 you will need to do this if you are testing a compiler toolchain,
2274 because the default values do not take into account host and target
2275 names.
2276 @opindex dejagnu
2277 @vindex DEJATOOL
2278 @vindex EXPECT
2279 @vindex RUNTEST
2280 @vindex RUNTESTFLAGS
2281 @c FIXME xref dejagnu
2282
2283 In either case, the testing is done via @samp{make check}.
2284
2285
2286 @node Options, Miscellaneous, Tests, Top
2287 @chapter Changing Automake's Behavior
2288
2289 Various features of Automake can be controlled by options in the
2290 @file{Makefile.am}.  Such options are listed in a special variable named
2291 @code{AUTOMAKE_OPTIONS}.  Currently understood options are:
2292 @vindex AUTOMAKE_OPTIONS
2293
2294 @table @asis
2295 @item @code{gnits}
2296 @itemx @code{gnu}
2297 @itemx @code{foreign}
2298 @item @code{cygnus}
2299 Set the strictness as appropriate.  The @code{gnits} option also implies
2300 @code{readme-alpha} and @code{check-news}.
2301
2302 @item @code{ansi2knr}
2303 @itemx @code{path/ansi2knr}
2304 Turn on automatic de-ANSI-fication.  @xref{ANSI}.  If preceeded by a
2305 path, the generated @file{Makefile.in} will look in the specified
2306 directory to find the @file{ansi2knr} program.  Generally the path
2307 should be a relative path to another directory in the same distribution
2308 (though Automake currently does not check this).
2309
2310 @item @code{check-news}
2311 Cause @code{make dist} to fail unless the current version number appears
2312 in the first few lines of the @file{NEWS} file.
2313
2314 @item @code{dejagnu}
2315 Cause @code{dejagnu}-specific rules to be generated.  @xref{Tests}.
2316
2317 @item @code{dist-shar}
2318 Generate a @code{dist-shar} target as well as the ordinary @code{dist}
2319 target.  This new target will create a shar archive of the
2320 distribution.
2321 @trindex dist-shar
2322
2323 @item @code{dist-zip}
2324 Generate a @code{dist-zip} target as well as the ordinary @code{dist}
2325 target.  This new target will create a zip archive of the distribution.
2326 @trindex dist-zip
2327
2328 @item @code{dist-tarZ}
2329 Generate a @code{dist-tarZ} target as well as the ordinary @code{dist}
2330 target.  This new target will create a compressed tar archive of the
2331 distribution; a traditional @code{tar} and @code{compress} will be
2332 assumed.  Warning: if you are actually using @code{GNU tar}, then the
2333 generated archive might contain nonportable constructs.
2334 @trindex dist-tarZ
2335
2336 @item @code{no-dependencies}
2337 This is similar to using @samp{--include-deps} on the command line, but
2338 is useful for those situations where you don't have the necessary bits
2339 to make automatic dependency tracking work @xref{Dependencies}.  In this
2340 case the effect is to effectively disable automatic dependency tracking.
2341
2342 @item @code{no-installinfo}
2343 The generated @file{Makefile.in} will not cause info pages to be built
2344 or installed by default.  However, @code{info} and @code{install-info}
2345 targets will still be available.  This option is disallowed at
2346 @samp{GNU} strictness and above.
2347 @trindex info
2348 @trindex install-info
2349
2350 @item @code{no-installman}
2351 The generated @file{Makefile.in} will not cause man pages to be
2352 installed by default.  However, an @code{install-man} target will still
2353 be available for optional installation.  This option is disallowed at
2354 @samp{GNU} strictness and above.
2355 @trindex install-man
2356
2357 @item @code{no-texinfo.tex}
2358 Don't require @file{texinfo.tex}, even if there are texinfo files in
2359 this directory.
2360
2361 @item @code{readme-alpha}
2362 If this release is an alpha release, and the file @file{README-alpha}
2363 exists, then it will be added to the distribution.  If this option is
2364 given, version numbers are expected to follow one of two forms.  The
2365 first form is @samp{@var{MAJOR}.@var{MINOR}.@var{ALPHA}}, where each
2366 element is a number; the final period and number should be left off for
2367 non-alpha releases.  The second form is
2368 @samp{@var{MAJOR}.@var{MINOR}@var{ALPHA}}, where @var{ALPHA} is a
2369 letter; it should be omitted for non-alpha releases.
2370
2371 @item @var{version}
2372 A version number (eg @samp{0.30}) can be specified.  If Automake is not
2373 newer than the version specified, creation of the @file{Makefile.in}
2374 will be suppressed.
2375 @end table
2376
2377 Unrecognized options are diagnosed by @code{automake}.
2378
2379
2380 @node Miscellaneous, Conditionals, Options, Top
2381 @chapter Miscellaneous Rules
2382
2383 There are a few rules and variables that didn't fit anywhere else.
2384
2385 @menu
2386 * Tags::                        Interfacing to etags and mkid
2387 * Suffixes::                    Handling new file extensions
2388 @end menu
2389
2390
2391 @node Tags, Suffixes, Miscellaneous, Miscellaneous
2392 @section Interfacing to @code{etags}
2393
2394 @code{automake} will generate rules to generate @file{TAGS} files for
2395 use with GNU Emacs under some circumstances.
2396
2397 If any C source code or headers are present, then @code{tags} and
2398 @code{TAGS} targets will be generated for the directory.
2399 @trindex tags
2400
2401 At the topmost directory of a multi-directory package, a @code{tags}
2402 target file will be generated which, when run, will generate a
2403 @file{TAGS} file that includes by reference all @file{TAGS} files from
2404 subdirectories.
2405
2406 Also, if the variable @code{ETAGS_ARGS} is defined, a @code{tags} target
2407 will be generated.  This variable is intended for use in directories
2408 which contain taggable source that @code{etags} does not understand.
2409 @vindex ETAGS_ARGS
2410
2411 Here is how Automake generates tags for its source, and for nodes in its
2412 Texinfo file:
2413
2414 @example
2415 ETAGS_ARGS = automake.in --lang=none \
2416  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
2417 @end example
2418
2419 If you add filenames to @samp{ETAGS_ARGS}, you will probably also
2420 want to set @samp{TAGS_DEPENDENCIES}.  The contents of this variable
2421 are added directly to the dependencies for the @code{tags} target.
2422 @vindex TAGS_DEPENDENCIES
2423
2424 Automake will also generate an @code{ID} target which will run
2425 @code{mkid} on the source.  This is only supported on a
2426 directory-by-directory basis.
2427 @trindex id
2428
2429
2430 @node Suffixes,  , Tags, Miscellaneous
2431 @section Handling new file extensions
2432
2433 It is sometimes useful to introduce a new implicit rule to handle a file
2434 type that Automake does not know about.  If this is done, you must
2435 notify GNU Make of the new suffixes.  This can be done by putting a list
2436 of new suffixes in the @code{SUFFIXES} variable.
2437 @vindex SUFFIXES
2438
2439 For instance, currently automake does not provide any Java support.  If
2440 you wrote a macro to generate @samp{.class} files from @samp{.java}
2441 source files, you would also need to add these suffixes to the list:
2442
2443 @example
2444 SUFFIXES = .java .class
2445 @end example
2446
2447 @node Conditionals, Gnits, Miscellaneous, Top
2448 @chapter Conditionals
2449
2450 Automake supports a simple type of conditionals.
2451
2452 @cvindex AM_CONDITIONAL
2453 Before using a conditional, you must define it by using
2454 @code{AM_CONDITIONAL} in the @code{configure.in} file.  The
2455 @code{AM_CONDITIONAL} macro takes two arguments.
2456
2457 The first argument to @code{AM_CONDITIONAL} is the name of the
2458 conditional.  This should be a simple string starting with a letter and
2459 containing only letters, digits, and underscores.
2460
2461 The second argument to @code{AM_CONDITIONAL} is a shell condition,
2462 suitable for use in a shell if statement.  The condition is evaluated
2463 when @code{configure} is run.
2464
2465 Conditionals typically depend upon options which the user provides to
2466 the @code{configure} script.  Here is an example of how to write a
2467 conditional which is true if the user uses the @samp{--enable-debug}
2468 option.
2469
2470 @example
2471 AC_ARG_ENABLE(debug,
2472 [  --enable-debug    Turn on debugging],
2473 [case "$@{enableval@}" in
2474   yes) debug=true ;;
2475   no)  debug=false ;;
2476   *) AC_MSG_ERROR(bad value $@{enableval@} for --enable-debug) ;;
2477 esac],[debug=false])
2478 AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
2479 @end example
2480
2481 Here is an example of how to use that conditional in @file{Makefile.am}:
2482
2483 @example
2484 if DEBUG
2485 DBG = debug
2486 else
2487 DBG =
2488 endif
2489 noinst_PROGRAMS = $(DBG)
2490 @end example
2491
2492 This trivial example could also be handled using EXTRA_PROGRAMS
2493 (@pxref{A Program}).
2494
2495 You may only test a single variable in an @code{if} statement.  The
2496 @code{else} statement may be omitted.  Conditionals may be nested to any
2497 depth.
2498
2499 Note that conditionals in Automake are not the same as conditionals in
2500 GNU Make.  Automake conditionals are checked at configure time by the
2501 @file{configure} script, and affect the translation from
2502 @file{Makefile.in} to @file{Makefile}.  They are based on options passed
2503 to @file{configure} and on results that @file{configure} has discovered
2504 about the host system.  GNU Make conditionals are checked at make time,
2505 and are based on variables passed to the make program or defined in the
2506 @file{Makefile}.
2507
2508 Automake conditionals will work with any make program.
2509
2510 @node Gnits, Cygnus, Conditionals, Top
2511 @chapter The effect of @code{--gnu} and @code{--gnits}
2512
2513 The @samp{--gnu} option (or @samp{gnu} in the @samp{AUTOMAKE_OPTIONS}
2514 variable) causes @code{automake} to check the following:
2515
2516 @itemize @bullet
2517 @item
2518 The files @file{INSTALL}, @file{NEWS}, @file{README}, @file{COPYING},
2519 @file{AUTHORS}, and @file{ChangeLog} are required at the topmost
2520 directory of the package.
2521
2522 @item
2523 The options @samp{no-installman} and @samp{no-installinfo} are
2524 prohibited.
2525 @end itemize
2526
2527 Note that this option will be extended in the future to do even more
2528 checking; it is advisable to be familiar with the precise requirements
2529 of the GNU standards.  Also, @samp{--gnu} can require certain
2530 non-standard GNU programs to exist for use by various maintainer-only
2531 targets; for instance in the future @code{pathchk} might be required for
2532 @samp{make dist}.
2533
2534 The @samp{--gnits} option does everything that @samp{--gnu} does, and
2535 checks the following as well:
2536
2537 @itemize @bullet
2538 @item
2539 @samp{make dist} will check to make sure the @file{NEWS} file has been
2540 updated to the current version.
2541
2542 @item
2543 The file @file{COPYING.LIB} is prohibited.  The LGPL is apparently
2544 considered a failed experiment.
2545
2546 @item
2547 @samp{VERSION} is checked to make sure its format complies with Gnits
2548 standards.
2549 @c FIXME xref when standards are finished
2550
2551 @item
2552 If @samp{VERSION} indicates that this is an alpha release, and the file
2553 @file{README-alpha} appears in the topmost directory of a package, then
2554 it is included in the distribution.  This is done in @samp{--gnits}
2555 mode, and no other, because this mode is the only one where version
2556 number formats are constrained, and hence the only mode where
2557 @code{automake} can automatically determine whether @file{README-alpha}
2558 should be included.
2559
2560 @item
2561 The file @file{THANKS} is required.
2562 @end itemize
2563
2564
2565 @node Cygnus, Extending, Gnits, Top
2566 @chapter The effect of @code{--cygnus}
2567
2568 Cygnus Solutions has slightly different rules for how a
2569 @file{Makefile.in} is to be constructed.  Passing @samp{--cygnus} to
2570 @code{automake} will cause any generated @file{Makefile.in} to comply
2571 with Cygnus rules.
2572
2573 Here are the precise effects of @samp{--cygnus}:
2574
2575 @itemize @bullet
2576 @item
2577 Info files are always created in the build directory, and not in the
2578 source directory.
2579
2580 @item
2581 @file{texinfo.tex} is not required if a Texinfo source file is
2582 specified.  The assumption is that the file will be supplied, but in a
2583 place that @code{automake} cannot find.  This assumption is an artifact
2584 of how Cygnus packages are typically bundled.
2585
2586 @item
2587 @samp{make dist} will look for files in the build directory as well as
2588 the source directory.  This is required to support putting info files
2589 into the build directory.
2590
2591 @item
2592 Certain tools will be searched for in the build tree as well as in the
2593 user's @samp{PATH}.  These tools are @code{runtest}, @code{expect},
2594 @code{makeinfo} and @code{texi2dvi}.
2595
2596 @item
2597 @code{--foreign} is implied.
2598
2599 @item
2600 The options @samp{no-installinfo} and @samp{no-dependencies} are
2601 implied.
2602
2603 @item
2604 The macros @samp{AM_MAINTAINER_MODE} and @samp{AM_CYGWIN32} are
2605 required.
2606
2607 @item
2608 The @code{check} target doesn't depend on @code{all}.
2609 @end itemize
2610
2611 GNU maintainers are advised to use @samp{gnu} strictness in preference
2612 to the special Cygnus mode.
2613
2614
2615 @node Extending, Distributing, Cygnus, Top
2616 @chapter When Automake Isn't Enough
2617
2618 Automake's implicit copying semantics means that many problems can be
2619 worked around by simply adding some @code{make} targets and rules to
2620 @file{Makefile.in}.  @code{automake} will ignore these additions.
2621
2622 There are some caveats to doing this.  Although you can overload a
2623 target already used by @code{automake}, it is often inadvisable,
2624 particularly in the topmost directory of a non-flat package.  However,
2625 various useful targets have a @samp{-local} version you can specify in your
2626 @file{Makefile.in}.  Automake will supplement the standard target with
2627 these user-supplied targets.
2628
2629 The targets that support a local version are @code{all}, @code{info},
2630 @code{dvi}, @code{check}, @code{install-data}, @code{install-exec},
2631 @code{uninstall}, and the various @code{clean} targets
2632 (@code{mostlyclean}, @code{clean}, @code{distclean}, and
2633 @code{maintainer-clean}).  Note that there are no
2634 @code{uninstall-exec-local} or @code{uninstall-data-local} targets; just
2635 use @code{uninstall-local}.  It doesn't make sense to uninstall just
2636 data or just executables.
2637 @trindex all
2638 @trindex info
2639 @trindex dvi
2640 @trindex check
2641 @trindex install-data
2642 @trindex install-exec
2643 @trindex uninstall
2644
2645 For instance, here is one way to install a file in @file{/etc}:
2646
2647 @example
2648 install-data-local:
2649         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
2650 @end example
2651
2652 Some targets also have a way to run another target, called a @dfn{hook},
2653 after their work is done.  The hook is named after the principal target,
2654 with @samp{-hook} appended.  The targets allowing hooks are
2655 @code{install-data}, @code{install-exec}, @code{dist}, and
2656 @code{distcheck}.
2657 @trindex install-data-hook
2658 @trindex install-exec-hook
2659 @trindex dist-hook
2660
2661 For instance, here is how to create a hard link to an installed program:
2662
2663 @example
2664 install-exec-hook:
2665         ln $(bindir)/program $(bindir)/proglink
2666 @end example
2667
2668 @c FIXME should include discussion of variables you can use in these
2669 @c rules
2670
2671
2672 @node Distributing, Future, Extending, Top
2673 @chapter Distributing @file{Makefile.in}s
2674
2675 Automake places no restrictions on the distribution of the resulting
2676 @file{Makefile.in}s.  We still encourage software authors to distribute
2677 their work under terms like those of the GPL, but doing so is not
2678 required to use Automake.
2679
2680 Some of the files that can be automatically installed via the
2681 @code{--add-missing} switch do fall under the GPL; examine each file
2682 to see.
2683
2684
2685 @node Future, Index, Distributing, Top
2686 @chapter Some ideas for the future
2687
2688 Here are some things that might happen in the future:
2689
2690 @itemize @bullet
2691 @item
2692 HTML support.
2693
2694 @item
2695 The output will be cleaned up.  For instance, only variables which are
2696 actually used will appear in the generated @file{Makefile.in}.
2697
2698 @item
2699 There will be support for automatically recoding a distribution.  The
2700 intent is to allow a maintainer to use whatever character set is most
2701 convenient locally, but for all distributions to be Unicode or
2702 @w{ISO 10646} with the UTF-8 encoding.
2703
2704 @item
2705 Support for automatically generating packages (eg Debian packages, RPM
2706 packages, Solaris packages, etc).  This will happen more quickly if
2707 someone with package-building experience can tell me what would be
2708 helpful.
2709
2710 @item
2711 Rewrite in Guile.  This won't happen in the near future, but it will
2712 eventually happen.
2713 @end itemize
2714
2715 @node Index,  , Future, Top
2716 @unnumbered Index
2717
2718 @printindex cp
2719
2720 @contents
2721 @bye