Nothing
[automake.git] / automake.texi
blob72dffbfc1ad242f0d538d21b3ba557d3f27c5773
1 \input texinfo   @c -*-texinfo-*-
2 @c %**start of header
3 @setfilename automake.info
4 @settitle automake
5 @setchapternewpage off
6 @c %**end of header
8 @include version.texi
10 @ifinfo
11 @format
12 START-INFO-DIR-ENTRY
13 * automake: (automake).         Making Makefile.in's
14 END-INFO-DIR-ENTRY
15 @end format
16 @end ifinfo
18 @ifinfo
19 This file documents GNU automake @value{VERSION}
21 Copyright (C) 1995 Free Software Foundation, Inc.
23 Permission is granted to make and distribute verbatim copies of
24 this manual provided the copyright notice and this permission notice
25 are preserved on all copies.
27 @ignore
28 Permission is granted to process this file through TeX and print the
29 results, provided the printed document carries copying permission
30 notice identical to this one except for the removal of this paragraph
33 @end ignore
34 Permission is granted to copy and distribute modified versions of this
35 manual under the conditions for verbatim copying, provided that the entire
36 resulting derived work is distributed under the terms of a permission
37 notice identical to this one.
39 Permission is granted to copy and distribute translations of this manual
40 into another language, under the above conditions for modified versions,
41 except that this permission notice may be stated in a translation approved
42 by the Foundation.
43 @end ifinfo
46 @titlepage
47 @title GNU Automake
48 @subtitle For version @value{VERSION}, @value{UPDATED}
49 @c copyright page
50 @page
51 @vskip 0pt plus 1filll
52 Copyright @copyright{} 1995 Free Software Foundation, Inc.
53 @sp 2
54 This is the first edition of the GNU Automake documentation,@*
55 and is consistent with GNU Automake @value{VERSION}.@*
56 @sp 2
57 Published by the Free Software Foundation @*
58 675 Massachusetts Avenue, @*
59 Cambridge, MA 02139 USA @*
61 Permission is granted to make and distribute verbatim copies of
62 this manual provided the copyright notice and this permission notice
63 are preserved on all copies.
65 Permission is granted to copy and distribute modified versions of this
66 manual under the conditions for verbatim copying, provided that the entire
67 resulting derived work is distributed under the terms of a permission
68 notice identical to this one.
70 Permission is granted to copy and distribute translations of this manual
71 into another language, under the above conditions for modified versions,
72 except that this permission notice may be stated in a translation
73 approved by the Free Software Foundation.
74 @end titlepage
76 @ifinfo
77 @node Top, Introduction, (dir), (dir)
78 @comment  node-name,  next,  previous,  up
79 @top GNU Automake
81 This file documents the GNU Automake package for creating GNU
82 Standards-compliant Makefiles from template files.  This edition
83 documents version @value{VERSION}.
85 @menu
86 * Introduction::                Automake's purpose
87 * Details::                     Creating an Automake template file
88 * Invoking automake::           Creating a Makefile.in
89 * Distributing::                Distributing generated Makefile.ins
90 * Future::                      Some ideas for the future.
91 * Some index::                  Index of variables
92 @end menu
94 @end ifinfo
96 @node Introduction
97 @chapter Introduction
99 The GNU Makefile Standards Document
100 (@pxref{Makefile Conventions, , Makefile Conventions, standards.info, The
101 GNU Coding Standards})
102 is long, complicated,
103 and subject to change.  The goal of Automake is to remove the burden of
104 Makefile maintenance from back the individual GNU maintainer (and put it
105 on the back of the Automake maintainer).
107 Typical Automake input files are simply a series of macro definitions.
108 Automake processes these files to produce @file{Makefile.in}s which are
109 distribution-ready.
111 Automake does force some structure on the package maintainer.  However,
112 it is felt that this (minor) inconvenience is more than offset by
113 Automake's convenience.
116 @node Details
117 @chapter Making @code{automake} templates
119 @menu
120 * Generalities::                General overview
121 * configure::                   Automake and configure
122 * Depth::                       Types of package hierarchy
123 * Naming::                      The uniform naming scheme
124 * Programs::                    Building programs
125 * ANSI::                        Automatic de-ANSI-fication
126 * Scripts::                     Building scripts
127 * Libraries::                   Building libraries
128 * Headers::                     Header files
129 * Data::                        Data files.
130 * Docs::                        Specifying documentation files
131 * Install::                     What gets installed
132 * Clean::                       What gets cleaned
133 * Distribution::                What gets distributed
134 * Tags::                        TAGS files
135 * Dependencies::                Automatic dependency tracking
136 * Options::                     Setting options.
137 * Extending::                   If the defaults aren't enough
138 @end menu
140 @node Generalities
141 @section General use of Automake
143 @code{Automake} is a tool for automatically generating
144 @file{Makefile.in}s from files called @file{Makefile.am}.  The
145 @file{Makefile.am} is basically a series of @code{make} macro
146 definitions (with the occasional rule thrown in).  The generated
147 @file{Makefile.in}s are compliant with the GNU Makefile standards.
149 There should be one @file{Makefile.am} per directory of a project
150 (though it is possible to incorporate directories that don't use
151 @code{automake} if necessary).
153 @code{automake} assumes the package in question uses @code{autoconf}.
156 @node configure
157 @section How @code{automake} and @code{configure} interact
159 Automake enforces a certain amount of structure on the package
160 maintainer.  One such item is its requirement that the
161 @file{configure.in} for the package define the variables @samp{PACKAGE}
162 and @samp{VERSION}.
164 @var{PACKAGE} should be the name of the package as it appears when
165 bundled for distribution.  For instance, Automake defines @samp{PACKAGE}
166 to be @samp{automake}.
168 @var{VERSION} should be the version number of the release being worked
169 on.  We recommend that you make @file{configure.in} the only place you
170 define the version number for your package; this makes releases simpler.
172 Here is an example of what to put in @file{configure.in}:
174 @example
175 PACKAGE=cpio
176 VERSION=2.3.911
177 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
178 AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
179 AC_SUBST(PACKAGE)
180 AC_SUBST(VERSION)
181 @end example
183 @code{automake} also assumes that your @file{configure} script will
184 define the variable @samp{INSTALL_SCRIPT}.  Until this is incorporated
185 in @code{autoconf}'s @samp{AC_PROG_INSTALL} macro, you can use this
186 replacement instead:
188 @example
189 ## --------------------------------------------------------- ##
190 ## Use AC_PROG_INSTALL, supplementing it with INSTALL_SCRIPT ##
191 ## substitution.                                             ##
192 ## --------------------------------------------------------- ##
194 AC_DEFUN(fp_PROG_INSTALL,
195 [AC_PROG_INSTALL
196 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='$@{INSTALL@} -m 755'
197 AC_SUBST(INSTALL_SCRIPT)dnl
199 @end example
201 @code{automake} requires this macro if you install any scripts.
202 Otherwise only @code{AC_PROG_INSTALL} is required.
204 @code{automake} also assumes your @file{configure.in} calls
205 @samp{AC_ARG_PROGRAM}.
208 @node Depth
209 @section Types of directory hierarchy
211 @code{automake} supports three kinds of directory hierarcy: ``flat'',
212 ``shallow'', and ``deep''.
214 A flat package is one in which all the files are in a single directory.
215 The @file{Makefile.am} for such a package by definition lacks a
216 @samp{SUBDIRS} macro.  An example of such a package is @code{termutils}.
218 A deep package is one in which all the source lies in subdirectories;
219 the top level directory contains mainly configuration information.  GNU
220 cpio is a good example of such a package (as is GNU @code{tar}, although
221 it does not presently use @code{automake}).  The top level
222 @file{Makefile.am} for a deep package will contain a @samp{SUBDIRS}
223 macro, but no other macros to define objects which are built.
224 Typically, @samp{PROGRAMS} is defined in @file{src/Makefile.am}.
226 A shallow package is one in which the primary source resides in the
227 top-level directory, while various parts (typically libraries) reside in
228 subdirectories.  @code{automake} is one such package (as is GNU
229 @code{make}, which does not currently use @code{automake}).
232 The @samp{SUBDIRS} macro holds a list of subdirectories in which
233 building of various sorts can occur.  Many targets (eg @samp{all}) in
234 the generated @file{Makefile} will run both locally and in all specified
235 subdirectories.  Note that the directories listed in @samp{SUBDIRS} are
236 not required to contain @file{Makefile.am}s; only @file{Makefile}s
237 (after configuration).  This allows inclusion of libraries from packages
238 which do not use @code{automake} (such as @code{gettext}).
240 If @samp{SUBDIRS} is defined, then your @file{configure.in} must include
241 @code{AC_PROG_MAKE_SET}.
243 FIXME supply complete list of recursive targets?
246 @node Naming
247 @section The uniform naming scheme
249 @code{Automake} uses a uniform naming scheme to make it easy to decide
250 how programs are built, and how they are installed.  This scheme also
251 supports @code{configure}-time determination of what should be built.
253 There are certain variables which are used at @code{make} time to
254 determine which objects are to be built.  For instance, @samp{PROGRAMS}
255 holds a list of programs which are to be compiled and linked.  These
256 variables are called ``primary'' variables.
258 A different set of variables are used to decide where the built objects
259 should be installed.  These variables are named after the primary
260 variables, but have a prefix indicating which standard directory should
261 be used as the installation directory.  The standard directory names are
262 given in the GNU standards (FIXME xref).  @code{automake} extends this
263 list with @samp{pkglibdir}, @samp{pkgincludedir}, and @samp{pkgdatadir};
264 these are the same as the non-@samp{pkg} versions, but with
265 @code{@@PACKAGE@@} appended.
267 For instance, @code{cpio} decides at configure time which programs are
268 built.  Some of the programs are installed in @samp{bindir}, and some
269 are installed in @samp{sbindir}:
271 @example
272 PROGRAMS = @@PROGRAMS@@
273 bin_PROGRAMS = cpio pax
274 sbin_PROGRAMS = rmt mt
275 @end example
277 Note that the common ``dir'' suffix is left off when constructing the
278 variable names; thus one writes @samp{bin_PROGRAMS} and not
279 @samp{bindir_PROGRAMS}.
281 Not every sort of object can be installed in every directory.
282 @code{automake} will flag those attempts it finds in error.
284 The special prefix @code{noinst} indicates that the objects in question
285 should not be installed at all.
287 Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
288 @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS}, @samp{MANS}, and
289 @samp{TEXINFOS}.
292 @node Programs
293 @section Which Programs Are Built
295 In a directory containing source that gets built into a program (as
296 opposed to a library), the @samp{PROGRAMS} variable is used:
298 @example
299 PROGRAMS = hello
300 @end example
302 In this simple case, the resulting @file{Makefile.in} will contain code
303 to generate a program named @code{hello}.  The variable
304 @samp{@var{prog}_SOURCES} is used to specify which source files get built
305 into an executable:
307 @example
308 hello_SOURCES = hello.c
309 @end example
311 This causes @file{hello.o} to be built from @code{hello.c} at compile
312 time, and then linked into @file{hello}.
314 If @samp{@var{prog}_SOURCES} is not specified, then it defaults to the
315 single file @samp{@var{prog}.c}.
317 Multiple programs can be built in a single directory -- simply list them
318 all in the @samp{PROGRAMS} definition.  Multiple programs can share a
319 single source file.  The source file must be listed in each ``_SOURCES''
320 definition.
322 Sometimes it is useful to determine the programs that are to be built at
323 configure time.  For instance, GNU @code{cpio} only builts @code{mt} and
324 @code{rmt} under special circumstances.
326 In this case, you must notify @code{Automake} of all the programs that
327 can possibly be built, but at the same time cause the generated
328 @file{Makefile.in} to use the programs specified by @code{configure}.
329 This is done trivially by making the @code{PROGRAMS} variable determined
330 at configure time, and letting @code{automake} look in the install
331 variables for the static list of programs.
333 If you need to link against libraries that are not found by
334 @code{configure}, you can use @samp{LDADD} to do so.  This variable
335 actually can be used to add any options to the linker command line.
337 Sometimes, multiple programs are built in one directory but do not share
338 the same link-time requirements.  In this case, you can use the
339 @samp{@var{prog}_LDADD} variable (where @var{PROG} is the name of the
340 program as it appears in @samp{PROGRAMS}) to override the global
341 @samp{LDADD}.  (If this variable exists for a given program, then that
342 program is not linked using @samp{LDADD}.)
344 For instance, in GNU @code{cpio}, @code{pax}, @code{cpio}, and @code{mt} are
345 linked against the library @file{libcpio.a}.  However, @code{rmt} is
346 built in the same directory, and has no such link requirement.  Thus:
348 @example
349 LDADD = ../lib/libcpio.a @@INTLLIBS@@
350 rmt_LDADD =
351 @end example
353 @node Scripts
354 @section Programs Which are Scripts
356 It is possible to define and install programs which are scripts.  Such
357 programs should be listed in the @samp{SCRIPTS} variable.
358 @code{automake} doesn't define any dependencies for scripts; the
359 @file{Makefile.am} should include the appropriate rules.
361 @code{automake} does assume that objects listed in the @samp{SCRIPTS}
362 macro are derived objects; such objects are deleted by @code{make clean}.
364 @code{automake} itself is a script that is generated at configure time
365 from @file{automake.in}.  Here is how this is handled:
367 @example
368 bin_SCRIPTS = automake
369 @end example
371 FIXME xref to rebuilding things listed in AC_OUTPUT
373 Script objects can be installed in @samp{bindir}, @samp{sbindir}, or
374 @samp{libexecdir}.
377 @node Libraries
378 @section Building Libraries
380 The @samp{LIBRARIES} variable holds the names of libraries to be built
381 in the current directory.
383 For a given library @samp{zot}, the sources are taken to be in
384 @samp{zot_SOURCES}, just as for programs.  Note that libraries and
385 programs share one namespace in @code{automake}: one directory cannot
386 contain both a library (``liblob.a'') and a program (``lob'') with the
387 same name.
389 Here is how the @file{libcpio.a} library is built in the GNU @code{cpio}
390 distribution's @file{lib} subdirectory:
392 @example
393 noinst_LIBRARIES = cpio
394 cpio_SOURCES = dirname.c dstring.c error.c filemode.c \
395 getopt.c getopt1.c idcache.c makepath.c octal.c \
396 stpcpy.c stripslash.c userspec.c xmalloc.c xstrdup.c
397 @end example
399 Extra objects can be added to a library using the @code{library_LIBADD}
400 variable.  This should be used for objects determined by
401 @code{configure}.  Again from @code{cpio}:
403 @example
404 cpio_LIBADD = @@LIBOBJS@@ @@ALLOCA@@
405 @end example
407 Library objects can be installed in @samp{libdir} or @samp{pkglibdir}.
410 @node Headers
411 @section Header files
413 Header files are specified by the @samp{HEADERS} family of variables.
414 Generally header files are not installed, so the @samp{noinst_HEADERS}
415 variable will be the most used.
417 All header files must be listed somewhere; missing ones will not appear
418 in the distribution.
420 You can also put conditionally compiled source file names into a
421 @samp{HEADERS} variable.  (This will probably change in a future
422 release).
425 @node Data
426 @section Architecture-independent data files
428 @code{automake} supports the installation of miscellaneous data files
429 using the @samp{DATA} family of variables.
431 Such data can be installed in the directories @code{datadir},
432 @code{sysconfdir}, @code{sharedstatedir}, @code{localstatedir}, or
433 @code{pkgdatadir}.
435 All such data files are included in the distribution.  (FIXME, this is
436 probably a bug)
438 Here is how @code{autoconf} installs its auxiliary data files:
440 @example
441 pkgdata_DATA = clean-kr.am clean.am compile-kr.am compile-vars.am \
442 compile.am data.am depend.am dist-subd-top.am dist-subd-vars.am \
443 dist-subd.am dist-vars.am dist.am footer.am header-vars.am header.am \
444 libscripts.am libprograms.am libraries-vars.am libraries.am library.am \
445 mans-vars.am mans.am packagedata.am program.am programs.am remake-hdr.am \
446 remake-subd.am remake.am scripts.am subdirs.am tags.am tags-subd.am \
447 texinfos-vars.am texinfos.am hack-make.sed nl-remove.sed
448 @end example
451 @node Docs
452 @section Texinfo and Man Pages
454 @subsection Texinfo
455 If the current directory contains Texinfo source, you must declare it
456 with the @samp{TEXINFOS} primary.  Generally Texinfo files are converted
457 into info, and thus the @samp{info_TEXINFOS} macro is most commonly used
458 here.
459 Note that any Texinfo source file must end in the @file{.texi} extension
460 (@file{.texinfo} won't work).
462 If the @file{.texi} file ``@@include''s @file{version.texi}, then that
463 file will be automatically generated.  @file{version.texi} defines three
464 Texinfo macros you can reference: @samp{EDITION}, @samp{VERSION}, and
465 @samp{UPDATED}.  The first two hold the version number of your package
466 (but are kept separate for clarity); the last is the date the primary
467 file was last modified.
468 The @file{version.texi} support requires a version of @code{date} that
469 accepts the @samp{-r} (read time from a file) option.
471 Sometimes an info file actually depends on more than one @file{.texi}
472 file.  For instance, in the @samp{xdvik} distribution,
473 @file{kpathsea.texi} includes the files @file{install.texi},
474 @file{copying.texi}, and @file{freedom.texi}.  You can tell
475 @code{automake} about these dependencies using the @samp{texi_TEXINFOS}
476 variable.  Here is how @samp{xdvik} could do it:
478 @example
479 info_TEXINFOS = kpathsea.texi
480 kpathsea_TEXINFOS = install.texi copying.texi freedom.texi
481 @end example
483 @code{automake} might be modified to detect these dependencies
484 automatically.
486 Currently @code{automake} can only handle one primary @file{.texi} file.
487 This restriction will be lifted if it proves too onerous.
489 @code{automake} will warn if a directory containing Texinfo source does
490 not also contain the file @file{texinfo.tex}.  (I'm not sure if this is
491 a good rule or not.  Comments?)
493 In the future, @code{automake} will probably be modified to support
494 generating @samp{HTML} from Texinfo source.
497 @subsection Man pages
498 A package can also include man pages.  (Though see the GNU standards on
499 this matter.  FIXME xref).
500 Man pages are declared using the @samp{MANS} primary.  Generally the
501 @samp{man_MANS} macro is used.
503 By default, man pages are installed by @code{make install}.  However,
504 since the GNU project does not require man pages, many maintainers do
505 not expend effort to keep the man pages up to date.  In these cases, the
506 @samp{no-installman} option will prevent the man pages from being
507 installed by default.  (The user can still install them via
508 @code{make install-man})
511 Here is how the documentation is handled in GNU @code{cpio} (which includes
512 both Texinfo documentation and man pages):
514 @example
515 TEXINFOS = cpio.texi
516 MANS = cpio.1 mt.1
517 @end example
519 Texinfo source, info pages and man pages are all considered to be
520 ``source'' for the purposes of making a distribution.
523 @node ANSI
524 @section Automatic de-ANSI-fication of Source
526 If the @samp{AUTOMAKE_OPTIONS} variable contains the @samp{ansi2knr}
527 option, then code to handle automatic de-ANSI-fication is included in
528 the generated @file{Makefile.in}.  This will also happen if
529 @file{Makefile.am} includes the text @samp{@@kr@@}, but this use is
530 deprecated and will go away eventually.
532 @c FIXME xref to options here.
534 This means that each C source file will be treated as ANSI C.  If no
535 ANSI C compiler is available on the build system, then the code will be
536 turned into K&R C before compilation.
538 Each directory that uses automatic de-ANSI-fication must include the
539 source files @file{ansi2knr.c} and @file{ansi2knr.1}.  Also, your
540 @file{configure} script must define the variables @samp{U} and
541 @samp{ANSI2KNR}.  Here is a snippet you can add to @file{aclocal.m4} to
542 achieve this:
544 @example
545 ## ------------------------------- ##
546 ## Check for function prototypes.  ##
547 ## ------------------------------- ##
549 AC_DEFUN(fp_C_PROTOTYPES,
550 [AC_REQUIRE([fp_PROG_CC_STDC])
551 AC_MSG_CHECKING([for function prototypes])
552 if test "$ac_cv_prog_cc_stdc" != no; then
553   AC_MSG_RESULT(yes)
554   AC_DEFINE(PROTOTYPES)
555   U= ANSI2KNR=
556 else
557   AC_MSG_RESULT(no)
558   U=_ ANSI2KNR=./ansi2knr
560 AC_SUBST(U)dnl
561 AC_SUBST(ANSI2KNR)dnl
565 ## ----------------------------------------- ##
566 ## ANSIfy the C compiler whenever possible.  ##
567 ## ----------------------------------------- ##
569 # @@defmac AC_PROG_CC_STDC
570 # @@maindex PROG_CC_STDC
571 # @@ovindex CC
572 # If the C compiler in not in ANSI C mode by default, try to add an option
573 # to output variable @@code@{CC@} to make it so.  This macro tries various
574 # options that select ANSI C on some system or another.  It considers the
575 # compiler to be in ANSI C mode if it defines @@code@{__STDC__@} to 1 and
576 # handles function prototypes correctly.
578 # If you use this macro, you should check after calling it whether the C
579 # compiler has been set to accept ANSI C; if not, the shell variable
580 # @@code@{ac_cv_prog_cc_stdc@} is set to @@samp@{no@}.  If you wrote your source
581 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
582 # program @@code@{ansi2knr@}, which comes with Ghostscript.
583 # @@end defmac
585 AC_DEFUN(fp_PROG_CC_STDC,
586 [AC_MSG_CHECKING(for $@{CC-cc@} option to accept ANSI C)
587 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
588 [ac_cv_prog_cc_stdc=no
589 ac_save_CFLAGS="$CFLAGS"
590 # Don't try gcc -ansi; that turns off useful extensions and
591 # breaks some systems' header files.
592 # AIX                   -qlanglvl=ansi
593 # Ultrix and OSF/1      -std1
594 # HP-UX                 -Aa -D_HPUX_SOURCE
595 # SVR4                  -Xc
596 for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc
598   CFLAGS="$ac_save_CFLAGS $ac_arg"
599   AC_TRY_COMPILE(
600 [#if !defined(__STDC__) || __STDC__ != 1
601 choke me
602 #endif
603 ], [int test (int i, double x);
604 struct s1 @{int (*f) (int a);@};
605 struct s2 @{int (*f) (double a);@};],
606 [ac_cv_prog_cc_stdc="$ac_arg"; break])
607 done
608 CFLAGS="$ac_save_CFLAGS"
610 AC_MSG_RESULT($ac_cv_prog_cc_stdc)
611 case "x$ac_cv_prog_cc_stdc" in
612   x|xno) ;;
613   *) CC="$CC $ac_cv_prog_cc_stdc" ;;
614 esac
616 @end example
619 @node Install
620 @section What Gets Installed
622 Naturally, @code{automake} handles the details of actually installing
623 your program once it has been built.  All @code{PROGRAMS},
624 @code{SCRIPTS}, @code{LIBRARIES}, @code{DATA} and @code{HEADERS} are
625 automatically installed in the appropriate places.
627 @code{automake} also handles installing any specified info and man
628 pages.
630 FIXME xref to Extending node here; sometimes you need to install more.
632 @code{automake} generates separate @samp{install-data} and
633 @samp{install-exec} targets, in case the installer is installing on
634 multiple machines which share directory structure -- these targets allow
635 the machine-independent parts to be installed only once.
637 @code{automake} also generates an @samp{uninstall} target, and an
638 @samp{installdirs} target.
641 @node Clean
642 @section Clean targets
644 The GNU Makefile Standards specify a number of different clean rules.
645 Generally the files that can cleaned are determined automatically by
646 @code{automake}.  Of course, @code{automake} also recognizes some
647 variables that can be defined to specify additional files to clean.
648 These variables are @samp{MOSTLYCLEANFILES}, @samp{CLEANFILES},
649 @samp{DISTCLEANFILES}, and @samp{MAINTAINERCLEANFILES}.
652 @node Distribution
653 @section Building a Release
655 The @samp{dist} target in the generated @file{Makefile.in} can be used
656 to generate a gzip'd tar file for distribution.  The tar file is named
657 based on the @var{PACKAGE} and @var{VERSION} variables.
659 For the most part, the files to distribute are automatically found by
660 @code{automake}: all source files are automatically included in a
661 distribution, as are all @file{Makefile.am}s and @file{Makefile.in}s.
662 @code{automake} also has a built-in list of commonly used files which,
663 if present in the current directory, are automatically included.  This
664 list is printed by @code{automake --help}.
666 Still, sometimes there are files which must be distributed, but which
667 are not covered in the automatic rules.  These files should be listed in
668 the @samp{DIST_OTHER} variable.
670 For instance, in the @code{automake} distribution,
671 @file{automake.in} (the source to
672 @code{automake}) is not found automatically.  So in the
673 @file{Makefile.am}, we have:
675 @example
676 DIST_OTHER = automake.in
677 @end example
679 FIXME: describe DIST_SUBDIRS or not?  It is a hack which might go away.
681 @node Tags
682 @section Interfacing to @code{etags}
684 @code{automake} will generate rules to generate @file{TAGS} files for
685 use with GNU Emacs under some circumstances.
687 If any C source code or headers are present, then a @file{TAGS} file
688 will be generated for the directory.
690 At the topmost directory of a multi-directory package, a @file{TAGS}
691 file will be generated that will include by reference all @file{TAGS}
692 files from subdirectories.
694 Also, if the variable @samp{ETAGS_ARGS} is defined, a @file{TAGS} file
695 will be generated.  This variable is intended for use in directories
696 which contain taggable source that @code{etags} does not understand.
698 Here is how @code{automake} generates tags for its source, and for nodes
699 in its Texinfo file:
701 @example
702 ETAGS_ARGS = automake.in --lang=none \
703  --regex='/^@@node[ \t]+\([^,]+\)/\1/' automake.texi
704 @end example
707 @node Dependencies
708 @section Automatic dependency tracking
710 As a developer it is often painful to continually update the
711 @file{Makefile.in} whenever the include-file dependencies change in a
712 project.  @code{automake} supplies a way to automatically track
713 dependency changes, and distribute the dependencies in the generated
714 @file{Makefile.in}.
716 Currently this support requires the use of @code{GNU make} and
717 @code{gcc}.  It might become possible in the future to supply a
718 different dependency generating program, if there is enough demand.
720 This mode is enabled by default if any C program or library is defined
721 in the current directory.
723 When you decide to make a distribution, the @samp{dist} target will
724 re-run @code{automake} with the @samp{--include-deps} option.  This
725 causes the previously generated dependencies to be inserted into the
726 generated @file{Makefile.in}, and thus into the distribution.
727 @samp{--include-deps} also turns off inclusion of the dependency
728 generation code.
730 This mode can be suppressed by putting @samp{no-dependencies} in the
731 variable @samp{AUTOMAKE_OPTIONS}.
734 @node Options
735 @section Setting options
737 Various features of Automake can be controlled by options in the
738 @file{Makefile.am}.  Such options are listed in a special variable named
739 @samp{AUTOMAKE_OPTIONS}.  Currently understood options are:
741 @table @samp
742 @item gnits
743 @item gnu
744 @item normal
745 The same as the corresponding @samp{--strictness} option.
747 @item no-installman
748 The generated @file{Makefile.in} will not cause man pages to be
749 installed by default.  However, an @samp{install-man} target will still
750 be available for optional installation.
752 @item ansi2knr
753 Turn on automatic de-ANSI-fication.
755 @item dist-shar
756 Generate a @samp{dist-shar} target as well as the ordinary @samp{dist}
757 target.
759 @item no-dependencies
760 This is similar to using @samp{--include-deps} on the command line, but
761 is useful for those situations where you don't have the necessary bits
762 to make automatic dependency tracking work @xref{Dependencies}.  In this
763 case the effect is to effectively disable automatic dependency tracking.
765 @item version
766 A version number (eg @samp{0.30}) can be specified.  If Automake is not
767 newer than the version specified, creation of the @file{Makefile.in}
768 will be suppressed.
769 @end table
771 @node Extending
772 @section When Automake Isn't Enough
774 Sometimes @code{automake} isn't enough.  Then you just lose.
776 Actually, @code{automake}s implicit copying semantics means that many
777 problems can be worked around by simply adding some @code{make} targets
778 and rules to @file{Makefile.in}.  @code{automake} will ignore these
779 additions.
781 There are some caveats to doing this.  You can't overload a target
782 already used by @code{automake}.  However, various useful targets have a
783 ``-local'' version you can specify in your @file{Makefile.in}.
785 The targets that support a local version are @samp{all}, @samp{info},
786 @samp{dvi}, @samp{check}, @samp{install-data}, @samp{install-exec}, and
787 @samp{uninstall}.
789 For instance, here is how to install a file in @file{/etc}:
791 @example
792 install-data-local:
793         $(INSTALL_DATA) $(srcdir)/afile /etc/afile
794 @end example
797 @node Invoking automake
798 @chapter Using @code{automake} to Create @file{Makefile.in}
800 There are basically two modes in which @code{automake} can be run.
802 In the first, most common, mode, @code{automake} is simply run without
803 any arguments.  It will determine which @file{Makefile.am}s exist by
804 looking in the current directory and immediate subdirectories, and will
805 automatically build @file{Makefile.in}s in these directories.
807 In the second mode, @code{automake} is run with the name of one or more
808 @file{Makefile}s as arguments.  It then rebuilds the corresponding
809 @file{Makefile.in}s from the (also) corresponding @file{Makefile.am}s.
810 This second mode is most often used by @code{make} itself, when it
811 notices that a @code{Makefile.in} is out of date.
814 @node Distributing
815 @chapter Distributing @file{Makefile.in}s
817 Automake places no restrictions on the distribution of the resulting
818 @file{Makefile.in}s.  We still encourage software authors to distribute
819 their work under terms like those of the GPL, but doing so is not
820 required to use Automake.
822 Some of the files that can be automatically installed via the
823 @samp{--install-missing} switch do fall under the GPL; examine each file
824 to see.
827 @node Future
828 @chapter Some ideas for the future
830 Here are some things that might happen in the future:
832 @itemize @bullet
833 @item
834 Better error checking would be good.  Automake has been moving in this
835 direction for a while.
837 @item
838 The manual could stand updating.
840 @item
841 HTML support.
843 @item
844 The output will be cleaned up.
845 @end itemize
847 @node Some index
848 @chapter Nothing yet
850 @bye
852 NOTES:
854 * Need section on operation of automake: it reads Makefile.am and COPIES
855 the contents.  This section should include info on SUFFIXES, because
856 that is usually only needed when copying in additional targets (?)