source: vendor/automake/1.4-p6/automake.texi@ 3124

Last change on this file since 3124 was 3124, checked in by bird, 18 years ago

automake 1.4-p6

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