| 1 | \input texinfo @c -*-texinfo-*-
|
|---|
| 2 | @c %**start of header
|
|---|
| 3 | @setfilename automake.info
|
|---|
| 4 | @settitle automake
|
|---|
| 5 | @setchapternewpage off
|
|---|
| 6 | @c %**end of header
|
|---|
| 7 |
|
|---|
| 8 | @include version.texi
|
|---|
| 9 |
|
|---|
| 10 | @dircategory GNU admin
|
|---|
| 11 | @direntry
|
|---|
| 12 | * automake: (automake). Making Makefile.in's
|
|---|
| 13 | @end direntry
|
|---|
| 14 |
|
|---|
| 15 | @dircategory Individual utilities
|
|---|
| 16 | @direntry
|
|---|
| 17 | * aclocal: (automake)Invoking aclocal. Generating aclocal.m4
|
|---|
| 18 | @end direntry
|
|---|
| 19 |
|
|---|
| 20 | @ifinfo
|
|---|
| 21 | This file documents GNU automake @value{VERSION}
|
|---|
| 22 |
|
|---|
| 23 | Copyright (C) 1995, 96, 97, 98 Free Software Foundation, Inc.
|
|---|
| 24 |
|
|---|
| 25 | Permission is granted to make and distribute verbatim copies of
|
|---|
| 26 | this manual provided the copyright notice and this permission notice
|
|---|
| 27 | are preserved on all copies.
|
|---|
| 28 |
|
|---|
| 29 | @ignore
|
|---|
| 30 | Permission is granted to process this file through TeX and print the
|
|---|
| 31 | results, provided the printed document carries copying permission
|
|---|
| 32 | notice identical to this one except for the removal of this paragraph
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | @end ignore
|
|---|
| 36 | Permission is granted to copy and distribute modified versions of this
|
|---|
| 37 | manual under the conditions for verbatim copying, provided that the entire
|
|---|
| 38 | resulting derived work is distributed under the terms of a permission
|
|---|
| 39 | notice identical to this one.
|
|---|
| 40 |
|
|---|
| 41 | Permission is granted to copy and distribute translations of this manual
|
|---|
| 42 | into another language, under the above conditions for modified versions,
|
|---|
| 43 | except that this permission notice may be stated in a translation approved
|
|---|
| 44 | by the Foundation.
|
|---|
| 45 | @end ifinfo
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | @titlepage
|
|---|
| 49 | @title GNU Automake
|
|---|
| 50 | @subtitle For version @value{VERSION}, @value{UPDATED}
|
|---|
| 51 | @author David MacKenzie and Tom Tromey
|
|---|
| 52 |
|
|---|
| 53 | @page
|
|---|
| 54 | @vskip 0pt plus 1filll
|
|---|
| 55 | Copyright @copyright{} 1995, 96 Free Software Foundation, Inc.
|
|---|
| 56 | @sp 2
|
|---|
| 57 | This is the first edition of the GNU Automake documentation,@*
|
|---|
| 58 | and is consistent with GNU Automake @value{VERSION}.@*
|
|---|
| 59 | @sp 2
|
|---|
| 60 | Published by the Free Software Foundation @*
|
|---|
| 61 | 59 Temple Place - Suite 330, @*
|
|---|
| 62 | Boston, MA 02111-1307 USA @*
|
|---|
| 63 |
|
|---|
| 64 | Permission is granted to make and distribute verbatim copies of
|
|---|
| 65 | this manual provided the copyright notice and this permission notice
|
|---|
| 66 | are preserved on all copies.
|
|---|
| 67 |
|
|---|
| 68 | Permission is granted to copy and distribute modified versions of this
|
|---|
| 69 | manual under the conditions for verbatim copying, provided that the entire
|
|---|
| 70 | resulting derived work is distributed under the terms of a permission
|
|---|
| 71 | notice identical to this one.
|
|---|
| 72 |
|
|---|
| 73 | Permission is granted to copy and distribute translations of this manual
|
|---|
| 74 | into another language, under the above conditions for modified versions,
|
|---|
| 75 | except that this permission notice may be stated in a translation
|
|---|
| 76 | approved by the Free Software Foundation.
|
|---|
| 77 | @end titlepage
|
|---|
| 78 |
|
|---|
| 79 | @c Define an index of configure 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 |
|
|---|
| 106 | This file documents the GNU Automake package for creating GNU
|
|---|
| 107 | Standards-compliant Makefiles from template files. This edition
|
|---|
| 108 | documents 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 |
|
|---|
| 144 | Automake is a tool for automatically generating @file{Makefile.in}s from
|
|---|
| 145 | files called @file{Makefile.am}. Each @file{Makefile.am} is basically a
|
|---|
| 146 | series of @code{make} macro definitions (with rules being thrown in
|
|---|
| 147 | occasionally). The generated @file{Makefile.in}s are compliant with the
|
|---|
| 148 | GNU Makefile standards.
|
|---|
| 149 |
|
|---|
| 150 | @cindex GNU Makefile standards
|
|---|
| 151 |
|
|---|
| 152 | The GNU Makefile Standards Document
|
|---|
| 153 | (@pxref{Makefile Conventions, , , standards, The GNU Coding Standards})
|
|---|
| 154 | is long, complicated, and subject to change. The goal of Automake is to
|
|---|
| 155 | remove the burden of Makefile maintenance from the back of the
|
|---|
| 156 | individual GNU maintainer (and put it on the back of the Automake
|
|---|
| 157 | maintainer).
|
|---|
| 158 |
|
|---|
| 159 | The typical Automake input file is simply a series of macro definitions.
|
|---|
| 160 | Each such file is processed to create a @file{Makefile.in}. There
|
|---|
| 161 | should generally be one @file{Makefile.am} per directory of a project.
|
|---|
| 162 |
|
|---|
| 163 | @cindex Constraints of Automake
|
|---|
| 164 | @cindex Automake constraints
|
|---|
| 165 |
|
|---|
| 166 | Automake does constrain a project in certain ways; for instance it
|
|---|
| 167 | assumes that the project uses Autoconf (@pxref{Top, , Introduction,
|
|---|
| 168 | autoconf, The Autoconf Manual}), and enforces certain restrictions on
|
|---|
| 169 | the @file{configure.in} contents.
|
|---|
| 170 |
|
|---|
| 171 | @cindex Automake requirements
|
|---|
| 172 | @cindex Requirements, Automake
|
|---|
| 173 |
|
|---|
| 174 | Automake requires @code{perl} in order to generate the
|
|---|
| 175 | @file{Makefile.in}s. However, the distributions created by Automake are
|
|---|
| 176 | fully GNU standards-compliant, and do not require @code{perl} in order
|
|---|
| 177 | to be built.
|
|---|
| 178 |
|
|---|
| 179 | @cindex BUGS, reporting
|
|---|
| 180 | @cindex Reporting BUGS
|
|---|
| 181 | @cindex E-mail, bug reports
|
|---|
| 182 |
|
|---|
| 183 | Mail 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 |
|
|---|
| 190 | The following sections cover a few basic ideas that will help you
|
|---|
| 191 | understand 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 |
|
|---|
| 205 | Automake works by reading a @file{Makefile.am} and generating a
|
|---|
| 206 | @file{Makefile.in}. Certain macros and targets defined in the
|
|---|
| 207 | @file{Makefile.am} instruct Automake to generate more specialized code;
|
|---|
| 208 | for instance, a @samp{bin_PROGRAMS} macro definition will cause targets
|
|---|
| 209 | for compiling and linking programs to be generated.
|
|---|
| 210 |
|
|---|
| 211 | @cindex Non-standard targets
|
|---|
| 212 | @cindex cvs-dist, non-standard example
|
|---|
| 213 | @trindex cvs-dist
|
|---|
| 214 |
|
|---|
| 215 | The macro definitions and targets in the @file{Makefile.am} are copied
|
|---|
| 216 | verbatim into the generated file. This allows you to add arbitrary code
|
|---|
| 217 | into the generated @file{Makefile.in}. For instance the Automake
|
|---|
| 218 | distribution includes a non-standard @code{cvs-dist} target, which the
|
|---|
| 219 | Automake maintainer uses to make distributions from his source control
|
|---|
| 220 | system.
|
|---|
| 221 |
|
|---|
| 222 | @cindex GNU make extensions
|
|---|
| 223 |
|
|---|
| 224 | Note that GNU make extensions are not recognized by Automake. Using
|
|---|
| 225 | such extensions in a @file{Makefile.am} will lead to errors or confusing
|
|---|
| 226 | behavior.
|
|---|
| 227 |
|
|---|
| 228 | Automake tries to group comments with adjoining targets and macro
|
|---|
| 229 | definitions in an intelligent way.
|
|---|
| 230 |
|
|---|
| 231 | @cindex Make targets, overriding
|
|---|
| 232 | @cindex Overriding make targets
|
|---|
| 233 |
|
|---|
| 234 | A target defined in @file{Makefile.am} generally overrides any such
|
|---|
| 235 | target of a similar name that would be automatically generated by
|
|---|
| 236 | @code{automake}. Although this is a supported feature, it is generally
|
|---|
| 237 | best to avoid making use of it, as sometimes the generated rules are
|
|---|
| 238 | very particular.
|
|---|
| 239 |
|
|---|
| 240 | @cindex Macros, overriding
|
|---|
| 241 | @cindex Overriding make macros
|
|---|
| 242 |
|
|---|
| 243 | Similarly, a macro defined in @file{Makefile.am} will override any
|
|---|
| 244 | definition of the macro that @code{automake} would ordinarily create.
|
|---|
| 245 | This feature is more often useful than the ability to override a target
|
|---|
| 246 | definition. Be warned that many of the macros generated by
|
|---|
| 247 | @code{automake} are considered to be for internal use only, and their
|
|---|
| 248 | names might change in future releases.
|
|---|
| 249 |
|
|---|
| 250 | @cindex Recursive operation of Automake
|
|---|
| 251 | @cindex Automake, recursive operation
|
|---|
| 252 | @cindex Example of recursive operation
|
|---|
| 253 |
|
|---|
| 254 | When examining a macro definition, Automake will recursively examine
|
|---|
| 255 | macros referenced in the definition. For example, if Automake is
|
|---|
| 256 | looking at the content of @code{foo_SOURCES} in this snippet
|
|---|
| 257 |
|
|---|
| 258 | @example
|
|---|
| 259 | xs = a.c b.c
|
|---|
| 260 | foo_SOURCES = c.c $(xs)
|
|---|
| 261 | @end example
|
|---|
| 262 |
|
|---|
| 263 | it would use the files @file{a.c}, @file{b.c}, and @file{c.c} as the
|
|---|
| 264 | contents of @code{foo_SOURCES}.
|
|---|
| 265 |
|
|---|
| 266 | @cindex ## (special Automake comment)
|
|---|
| 267 | @cindex Special Automake comment
|
|---|
| 268 | @cindex Comment, special to Automake
|
|---|
| 269 |
|
|---|
| 270 | Automake also allows a form of comment which is @emph{not} copied into
|
|---|
| 271 | the output; all lines beginning with @samp{##} are completely ignored by
|
|---|
| 272 | Automake.
|
|---|
| 273 |
|
|---|
| 274 | It 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 |
|
|---|
| 302 | A @dfn{flat} package is one in which all the files are in a single
|
|---|
| 303 | directory. The @file{Makefile.am} for such a package by definition
|
|---|
| 304 | lacks a @code{SUBDIRS} macro. An example of such a package is
|
|---|
| 305 | @code{termutils}.
|
|---|
| 306 | @vindex SUBDIRS
|
|---|
| 307 |
|
|---|
| 308 | @cindex SUBDIRS, deep package
|
|---|
| 309 |
|
|---|
| 310 | A @dfn{deep} package is one in which all the source lies in
|
|---|
| 311 | subdirectories; the top level directory contains mainly configuration
|
|---|
| 312 | information. GNU @code{cpio} is a good example of such a package, as is
|
|---|
| 313 | GNU @code{tar}. The top level @file{Makefile.am} for a deep package
|
|---|
| 314 | will contain a @code{SUBDIRS} macro, but no other macros to define
|
|---|
| 315 | objects which are built.
|
|---|
| 316 |
|
|---|
| 317 | A @dfn{shallow} package is one in which the primary source resides in
|
|---|
| 318 | the top-level directory, while various parts (typically libraries)
|
|---|
| 319 | reside in subdirectories. Automake is one such package (as is GNU
|
|---|
| 320 | @code{make}, which does not currently use @code{automake}).
|
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 | @node Strictness, Uniform, Depth, Generalities
|
|---|
| 324 | @section Strictness
|
|---|
| 325 |
|
|---|
| 326 | @cindex Non-GNU packages
|
|---|
| 327 |
|
|---|
| 328 | While Automake is intended to be used by maintainers of GNU packages, it
|
|---|
| 329 | does make some effort to accommodate those who wish to use it, but do
|
|---|
| 330 | not want to use all the GNU conventions.
|
|---|
| 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 |
|
|---|
| 340 | To this end, Automake supports three levels of @dfn{strictness}---the
|
|---|
| 341 | strictness indicating how stringently Automake should check standards
|
|---|
| 342 | conformance.
|
|---|
| 343 |
|
|---|
| 344 | The valid strictness levels are:
|
|---|
| 345 |
|
|---|
| 346 | @table @samp
|
|---|
| 347 | @item foreign
|
|---|
| 348 | Automake will check for only those things which are absolutely
|
|---|
| 349 | required for proper operations. For instance, whereas GNU standards
|
|---|
| 350 | dictate the existence of a @file{NEWS} file, it will not be required in
|
|---|
| 351 | this mode. The name comes from the fact that Automake is intended to be
|
|---|
| 352 | used for GNU programs; these relaxed rules are not the standard mode of
|
|---|
| 353 | operation.
|
|---|
| 354 |
|
|---|
| 355 | @item gnu
|
|---|
| 356 | Automake will check---as much as possible---for compliance to the GNU
|
|---|
| 357 | standards for packages. This is the default.
|
|---|
| 358 |
|
|---|
| 359 | @item gnits
|
|---|
| 360 | Automake will check for compliance to the as-yet-unwritten @dfn{Gnits
|
|---|
| 361 | standards}. These are based on the GNU standards, but are even more
|
|---|
| 362 | detailed. Unless you are a Gnits standards contributor, it is
|
|---|
| 363 | recommended that you avoid this option until such time as the Gnits
|
|---|
| 364 | standard is actually published.
|
|---|
| 365 | @end table
|
|---|
| 366 |
|
|---|
| 367 | For more information on the precise implications of the strictness
|
|---|
| 368 | level, see @ref{Gnits}.
|
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 | @node Uniform, Canonicalization, Strictness, Generalities
|
|---|
| 372 | @section The Uniform Naming Scheme
|
|---|
| 373 |
|
|---|
| 374 | @cindex Uniform naming scheme
|
|---|
| 375 |
|
|---|
| 376 | Automake macros (from here on referred to as @emph{variables}) generally
|
|---|
| 377 | follow a @dfn{uniform naming scheme} that makes it easy to decide how
|
|---|
| 378 | programs (and other derived objects) are built, and how they are
|
|---|
| 379 | installed. This scheme also supports @code{configure} time
|
|---|
| 380 | determination of what should be built.
|
|---|
| 381 |
|
|---|
| 382 | @cindex _PROGRAMS primary variable
|
|---|
| 383 | @cindex PROGRAMS primary variable
|
|---|
| 384 | @cindex Primary variable, PROGRAMS
|
|---|
| 385 |
|
|---|
| 386 | @cindex Primary variable, defined
|
|---|
| 387 |
|
|---|
| 388 | At @code{make} time, certain variables are used to determine which
|
|---|
| 389 | objects are to be built. These variables are called @dfn{primary
|
|---|
| 390 | variables}. For instance, the primary variable @code{PROGRAMS} holds a
|
|---|
| 391 | list of programs which are to be compiled and linked.
|
|---|
| 392 | @vindex PROGRAMS
|
|---|
| 393 |
|
|---|
| 394 | @cindex pkglibdir, defined
|
|---|
| 395 | @cindex pkgincludedir, defined
|
|---|
| 396 | @cindex pkgdatadir, defined
|
|---|
| 397 |
|
|---|
| 398 | @vindex pkglibdir
|
|---|
| 399 | @vindex pkgincludedir
|
|---|
| 400 | @vindex pkgdatadir
|
|---|
| 401 |
|
|---|
| 402 | A different set of variables is used to decide where the built objects
|
|---|
| 403 | should be installed. These variables are named after the primary
|
|---|
| 404 | variables, but have a prefix indicating which standard directory should
|
|---|
| 405 | be used as the installation directory. The standard directory names are
|
|---|
| 406 | given in the GNU standards (@pxref{Directory Variables, , , standards,
|
|---|
| 407 | The GNU Coding Standards}). Automake extends this list with
|
|---|
| 408 | @code{pkglibdir}, @code{pkgincludedir}, and @code{pkgdatadir}; these are
|
|---|
| 409 | the same as the non-@samp{pkg} versions, but with @samp{@@PACKAGE@@}
|
|---|
| 410 | appended. For instance, @code{pkglibdir} is defined as
|
|---|
| 411 | @code{$(datadir)/@@PACKAGE@@}.
|
|---|
| 412 | @cvindex PACKAGE
|
|---|
| 413 |
|
|---|
| 414 | @cindex EXTRA_, prepending
|
|---|
| 415 |
|
|---|
| 416 | For each primary, there is one additional variable named by prepending
|
|---|
| 417 | @samp{EXTRA_} to the primary name. This variable is used to list
|
|---|
| 418 | objects which may or may not be built, depending on what
|
|---|
| 419 | @code{configure} decides. This variable is required because Automake
|
|---|
| 420 | must statically know the entire list of objects that may be built in
|
|---|
| 421 | order to generate a @file{Makefile.in} that will work in all cases.
|
|---|
| 422 |
|
|---|
| 423 | @cindex EXTRA_PROGRAMS, defined
|
|---|
| 424 | @cindex Example, EXTRA_PROGRAMS
|
|---|
| 425 | @cindex cpio example
|
|---|
| 426 |
|
|---|
| 427 | For instance, @code{cpio} decides at configure time which programs are
|
|---|
| 428 | built. Some of the programs are installed in @code{bindir}, and some
|
|---|
| 429 | are installed in @code{sbindir}:
|
|---|
| 430 |
|
|---|
| 431 | @example
|
|---|
| 432 | EXTRA_PROGRAMS = mt rmt
|
|---|
| 433 | bin_PROGRAMS = cpio pax
|
|---|
| 434 | sbin_PROGRAMS = @@PROGRAMS@@
|
|---|
| 435 | @end example
|
|---|
| 436 |
|
|---|
| 437 | Defining a primary variable without a prefix (e.g. @code{PROGRAMS}) is
|
|---|
| 438 | an error.
|
|---|
| 439 |
|
|---|
| 440 | Note that the common @samp{dir} suffix is left off when constructing the
|
|---|
| 441 | variable names; thus one writes @samp{bin_PROGRAMS} and not
|
|---|
| 442 | @samp{bindir_PROGRAMS}.
|
|---|
| 443 |
|
|---|
| 444 | Not every sort of object can be installed in every directory. Automake
|
|---|
| 445 | will flag those attempts it finds in error. Automake will also diagnose
|
|---|
| 446 | obvious misspellings in directory names.
|
|---|
| 447 |
|
|---|
| 448 | @cindex Extending list of installation directories
|
|---|
| 449 | @cindex Installation directories, extending list
|
|---|
| 450 |
|
|---|
| 451 | Sometimes the standard directories---even as augmented by Automake---
|
|---|
| 452 | are not enough. In particular it is sometimes useful, for clarity, to
|
|---|
| 453 | install objects in a subdirectory of some predefined directory. To this
|
|---|
| 454 | end, Automake allows you to extend the list of possible installation
|
|---|
| 455 | directories. A given prefix (e.g. @samp{zar}) is valid if a variable of
|
|---|
| 456 | the same name with @samp{dir} appended is defined (e.g. @code{zardir}).
|
|---|
| 457 |
|
|---|
| 458 | @cindex HTML support, example
|
|---|
| 459 |
|
|---|
| 460 | For instance, until HTML support is part of Automake, you could use this
|
|---|
| 461 | to install raw HTML documentation:
|
|---|
| 462 |
|
|---|
| 463 | @example
|
|---|
| 464 | htmldir = $(prefix)/html
|
|---|
| 465 | html_DATA = automake.html
|
|---|
| 466 | @end example
|
|---|
| 467 |
|
|---|
| 468 | @cindex noinst primary prefix, definition
|
|---|
| 469 |
|
|---|
| 470 | The special prefix @samp{noinst} indicates that the objects in question
|
|---|
| 471 | should not be installed at all.
|
|---|
| 472 |
|
|---|
| 473 | @cindex check primary prefix, definition
|
|---|
| 474 |
|
|---|
| 475 | The special prefix @samp{check} indicates that the objects in question
|
|---|
| 476 | should not be built until the @code{make check} command is run.
|
|---|
| 477 |
|
|---|
| 478 | Possible primary names are @samp{PROGRAMS}, @samp{LIBRARIES},
|
|---|
| 479 | @samp{LISP}, @samp{SCRIPTS}, @samp{DATA}, @samp{HEADERS}, @samp{MANS},
|
|---|
| 480 | and @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 |
|
|---|
| 496 | Sometimes a Makefile variable name is derived from some text the user
|
|---|
| 497 | supplies. For instance, program names are rewritten into Makefile macro
|
|---|
| 498 | names. Automake canonicalizes this text, so that it does not have to
|
|---|
| 499 | follow Makefile macro naming rules. All characters in the name except
|
|---|
| 500 | for letters, numbers, and the underscore are turned into underscores
|
|---|
| 501 | when 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 |
|
|---|
| 521 | Let's suppose you just finished writing @code{zardoz}, a program to make
|
|---|
| 522 | your head float from vortex to vortex. You've been using Autoconf to
|
|---|
| 523 | provide a portability framework, but your @file{Makefile.in}s have been
|
|---|
| 524 | ad-hoc. You want to make them bulletproof, so you turn to Automake.
|
|---|
| 525 |
|
|---|
| 526 | @cindex AM_INIT_AUTOMAKE, example use
|
|---|
| 527 |
|
|---|
| 528 | The first step is to update your @file{configure.in} to include the
|
|---|
| 529 | commands that @code{automake} needs. The simplest way to do this is to
|
|---|
| 530 | add an @code{AM_INIT_AUTOMAKE} call just after @code{AC_INIT}:
|
|---|
| 531 |
|
|---|
| 532 | @example
|
|---|
| 533 | AM_INIT_AUTOMAKE(zardoz, 1.0)
|
|---|
| 534 | @end example
|
|---|
| 535 |
|
|---|
| 536 | Since your program doesn't have any complicating factors (e.g., it
|
|---|
| 537 | doesn't use @code{gettext}, it doesn't want to build a shared library),
|
|---|
| 538 | you're done with this part. That was easy!
|
|---|
| 539 |
|
|---|
| 540 | @cindex aclocal program, introduction
|
|---|
| 541 | @cindex aclocal.m4, preexisting
|
|---|
| 542 | @cindex acinclude.m4, defined
|
|---|
| 543 |
|
|---|
| 544 | Now you must regenerate @file{configure}. But to do that, you'll need
|
|---|
| 545 | to tell @code{autoconf} how to find the new macro you've used. The
|
|---|
| 546 | easiest way to do this is to use the @code{aclocal} program to generate
|
|---|
| 547 | your @file{aclocal.m4} for you. But wait... you already have an
|
|---|
| 548 | @file{aclocal.m4}, because you had to write some hairy macros for your
|
|---|
| 549 | program. The @code{aclocal} program lets you put your own macros into
|
|---|
| 550 | @file{acinclude.m4}, so simply rename and then run:
|
|---|
| 551 |
|
|---|
| 552 | @example
|
|---|
| 553 | mv aclocal.m4 acinclude.m4
|
|---|
| 554 | aclocal
|
|---|
| 555 | autoconf
|
|---|
| 556 | @end example
|
|---|
| 557 |
|
|---|
| 558 | @cindex zardoz example
|
|---|
| 559 |
|
|---|
| 560 | Now it is time to write your @file{Makefile.am} for @code{zardoz}.
|
|---|
| 561 | Since @code{zardoz} is a user program, you want to install it where the
|
|---|
| 562 | rest of the user programs go. Additionally, @code{zardoz} has some
|
|---|
| 563 | Texinfo documentation. Your @file{configure.in} script uses
|
|---|
| 564 | @code{AC_REPLACE_FUNCS}, so you need to link against @samp{@@LIBOBJS@@}.
|
|---|
| 565 | So here's what you'd write:
|
|---|
| 566 |
|
|---|
| 567 | @example
|
|---|
| 568 | bin_PROGRAMS = zardoz
|
|---|
| 569 | zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
|
|---|
| 570 | zardoz_LDADD = @@LIBOBJS@@
|
|---|
| 571 |
|
|---|
| 572 | info_TEXINFOS = zardoz.texi
|
|---|
| 573 | @end example
|
|---|
| 574 |
|
|---|
| 575 | Now you can run @code{automake --add-missing} to generate your
|
|---|
| 576 | @file{Makefile.in} and grab any auxiliary files you might need, and
|
|---|
| 577 | you're done!
|
|---|
| 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
|
|---|
| 588 | renowned for its classic simplicity and versatility. This section shows
|
|---|
| 589 | how Automake could be used with the GNU Hello package. The examples
|
|---|
| 590 | below are from the latest beta version of GNU Hello, but with all of the
|
|---|
| 591 | maintainer-only code stripped out, as well as all copyright comments.
|
|---|
| 592 |
|
|---|
| 593 | Of course, GNU Hello is somewhat more featureful than your traditional
|
|---|
| 594 | two-liner. GNU Hello is internationalized, does option processing, and
|
|---|
| 595 | has a manual and a test suite. GNU Hello is a deep package.
|
|---|
| 596 |
|
|---|
| 597 | @cindex configure.in, from GNU Hello
|
|---|
| 598 | @cindex GNU Hello, configure.in
|
|---|
| 599 | @cindex Hello, configure.in
|
|---|
| 600 |
|
|---|
| 601 | Here is the @file{configure.in} from GNU Hello:
|
|---|
| 602 |
|
|---|
| 603 | @example
|
|---|
| 604 | dnl Process this file with autoconf to produce a configure script.
|
|---|
| 605 | AC_INIT(src/hello.c)
|
|---|
| 606 | AM_INIT_AUTOMAKE(hello, 1.3.11)
|
|---|
| 607 | AM_CONFIG_HEADER(config.h)
|
|---|
| 608 |
|
|---|
| 609 | dnl Set of available languages.
|
|---|
| 610 | ALL_LINGUAS="de fr es ko nl no pl pt sl sv"
|
|---|
| 611 |
|
|---|
| 612 | dnl Checks for programs.
|
|---|
| 613 | AC_PROG_CC
|
|---|
| 614 | AC_ISC_POSIX
|
|---|
| 615 |
|
|---|
| 616 | dnl Checks for libraries.
|
|---|
| 617 |
|
|---|
| 618 | dnl Checks for header files.
|
|---|
| 619 | AC_STDC_HEADERS
|
|---|
| 620 | AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)
|
|---|
| 621 |
|
|---|
| 622 | dnl Checks for library functions.
|
|---|
| 623 | AC_FUNC_ALLOCA
|
|---|
| 624 |
|
|---|
| 625 | dnl Check for st_blksize in struct stat
|
|---|
| 626 | AC_ST_BLKSIZE
|
|---|
| 627 |
|
|---|
| 628 | dnl internationalization macros
|
|---|
| 629 | AM_GNU_GETTEXT
|
|---|
| 630 | AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
|
|---|
| 631 | src/Makefile tests/Makefile tests/hello],
|
|---|
| 632 | [chmod +x tests/hello])
|
|---|
| 633 | @end example
|
|---|
| 634 |
|
|---|
| 635 | The @samp{AM_} macros are provided by Automake (or the Gettext library);
|
|---|
| 636 | the rest are standard Autoconf macros.
|
|---|
| 637 |
|
|---|
| 638 |
|
|---|
| 639 | The top-level @file{Makefile.am}:
|
|---|
| 640 |
|
|---|
| 641 | @example
|
|---|
| 642 | EXTRA_DIST = BUGS ChangeLog.O
|
|---|
| 643 | SUBDIRS = doc intl po src tests
|
|---|
| 644 | @end example
|
|---|
| 645 |
|
|---|
| 646 | As you can see, all the work here is really done in subdirectories.
|
|---|
| 647 |
|
|---|
| 648 | The @file{po} and @file{intl} directories are automatically generated
|
|---|
| 649 | using @code{gettextize}; they will not be discussed here.
|
|---|
| 650 |
|
|---|
| 651 | @cindex Texinfo file handling example
|
|---|
| 652 | @cindex Example, handling Texinfo files
|
|---|
| 653 |
|
|---|
| 654 | In @file{doc/Makefile.am} we see:
|
|---|
| 655 |
|
|---|
| 656 | @example
|
|---|
| 657 | info_TEXINFOS = hello.texi
|
|---|
| 658 | hello_TEXINFOS = gpl.texi
|
|---|
| 659 | @end example
|
|---|
| 660 |
|
|---|
| 661 | This is sufficient to build, install, and distribute the GNU Hello
|
|---|
| 662 | manual.
|
|---|
| 663 |
|
|---|
| 664 | @cindex Regression test example
|
|---|
| 665 | @cindex Example, regression test
|
|---|
| 666 |
|
|---|
| 667 | Here is @file{tests/Makefile.am}:
|
|---|
| 668 |
|
|---|
| 669 | @example
|
|---|
| 670 | TESTS = hello
|
|---|
| 671 | EXTRA_DIST = hello.in testdata
|
|---|
| 672 | @end example
|
|---|
| 673 |
|
|---|
| 674 | The script @file{hello} is generated by @code{configure}, and is the
|
|---|
| 675 | only test case. @code{make check} will run this test.
|
|---|
| 676 |
|
|---|
| 677 | @cindex INCLUDES, example usage
|
|---|
| 678 |
|
|---|
| 679 | Last we have @file{src/Makefile.am}, where all the real work is done:
|
|---|
| 680 |
|
|---|
| 681 | @example
|
|---|
| 682 | bin_PROGRAMS = hello
|
|---|
| 683 | hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
|
|---|
| 684 | hello_LDADD = @@INTLLIBS@@ @@ALLOCA@@
|
|---|
| 685 | localedir = $(datadir)/locale
|
|---|
| 686 | INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
|
|---|
| 687 | @end example
|
|---|
| 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 |
|
|---|
| 697 | Here is another, trickier example. It shows how to generate two
|
|---|
| 698 | programs (@code{ctags} and @code{etags}) from the same source file
|
|---|
| 699 | (@file{etags.c}). The difficult part is that each compilation of
|
|---|
| 700 | @file{etags.c} requires different @code{cpp} flags.
|
|---|
| 701 |
|
|---|
| 702 | @example
|
|---|
| 703 | bin_PROGRAMS = etags ctags
|
|---|
| 704 | ctags_SOURCES =
|
|---|
| 705 | ctags_LDADD = ctags.o
|
|---|
| 706 |
|
|---|
| 707 | etags.o: etags.c
|
|---|
| 708 | $(COMPILE) -DETAGS_REGEXPS -c etags.c
|
|---|
| 709 |
|
|---|
| 710 | ctags.o: etags.c
|
|---|
| 711 | $(COMPILE) -DCTAGS -o ctags.o -c etags.c
|
|---|
| 712 | @end example
|
|---|
| 713 |
|
|---|
| 714 | Note that @code{ctags_SOURCES} is defined to be empty---that way no
|
|---|
| 715 | implicit value is substituted. The implicit value, however, is used to
|
|---|
| 716 | generate @code{etags} from @file{etags.o}.
|
|---|
| 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 |
|
|---|
| 721 | The above rules won't work if your compiler doesn't accept both
|
|---|
| 722 | @samp{-c} and @samp{-o}. The simplest fix for this is to introduce a
|
|---|
| 723 | bogus dependency (to avoid problems with a parallel @code{make}):
|
|---|
| 724 |
|
|---|
| 725 | @example
|
|---|
| 726 | etags.o: etags.c ctags.o
|
|---|
| 727 | $(COMPILE) -DETAGS_REGEXPS -c etags.c
|
|---|
| 728 |
|
|---|
| 729 | ctags.o: etags.c
|
|---|
| 730 | $(COMPILE) -DCTAGS -c etags.c && mv etags.o ctags.o
|
|---|
| 731 | @end example
|
|---|
| 732 |
|
|---|
| 733 | Also, these explicit rules do not work if the de-ANSI-fication feature
|
|---|
| 734 | is used (@pxref{ANSI}). Supporting de-ANSI-fication requires a little
|
|---|
| 735 | more work:
|
|---|
| 736 |
|
|---|
| 737 | @example
|
|---|
| 738 | etags._o: etags._c ctags.o
|
|---|
| 739 | $(COMPILE) -DETAGS_REGEXPS -c etags.c
|
|---|
| 740 |
|
|---|
| 741 | ctags._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 |
|
|---|
| 753 | To create all the @file{Makefile.in}s for a package, run the
|
|---|
| 754 | @code{automake} program in the top level directory, with no arguments.
|
|---|
| 755 | @code{automake} will automatically find each appropriate
|
|---|
| 756 | @file{Makefile.am} (by scanning @file{configure.in}; @pxref{configure})
|
|---|
| 757 | and generate the corresponding @file{Makefile.in}. Note that
|
|---|
| 758 | @code{automake} has a rather simplistic view of what constitutes a
|
|---|
| 759 | package; it assumes that a package has only one @file{configure.in}, at
|
|---|
| 760 | the top. If your package has multiple @file{configure.in}s, then you
|
|---|
| 761 | must run @code{automake} in each directory holding a
|
|---|
| 762 | @file{configure.in}.
|
|---|
| 763 |
|
|---|
| 764 | You can optionally give @code{automake} an argument; @file{.am} is
|
|---|
| 765 | appended to the argument and the result is used as the name of the input
|
|---|
| 766 | file. This feature is generally only used to automatically rebuild an
|
|---|
| 767 | out-of-date @file{Makefile.in}. Note that @code{automake} must always
|
|---|
| 768 | be run from the topmost directory of a project, even if being used to
|
|---|
| 769 | regenerate the @file{Makefile.in} in some subdirectory. This is
|
|---|
| 770 | necessary because @code{automake} must scan @file{configure.in}, and
|
|---|
| 771 | because @code{automake} uses the knowledge that a @file{Makefile.in} is
|
|---|
| 772 | in a subdirectory to change its behavior in some cases.
|
|---|
| 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
|
|---|
| 788 | Automake requires certain common files to exist in certain situations;
|
|---|
| 789 | for instance @file{config.guess} is required if @file{configure.in} runs
|
|---|
| 790 | @code{AC_CANONICAL_HOST}. Automake is distributed with several of these
|
|---|
| 791 | files; this option will cause the missing ones to be automatically added
|
|---|
| 792 | to the package, whenever possible. In general if Automake tells you a
|
|---|
| 793 | file is missing, try using this option. By default Automake tries to
|
|---|
| 794 | make a symbolic link pointing to its own copy of the missing file; this
|
|---|
| 795 | can be changed with @code{--copy}.
|
|---|
| 796 |
|
|---|
| 797 | @item --amdir=@var{dir}
|
|---|
| 798 | @opindex --amdir
|
|---|
| 799 | Look for Automake data files in directory @var{dir} instead of in the
|
|---|
| 800 | installation directory. This is typically used for debugging.
|
|---|
| 801 |
|
|---|
| 802 | @item --build-dir=@var{dir}
|
|---|
| 803 | @opindex --build-dir
|
|---|
| 804 | Tell Automake where the build directory is. This option is used when
|
|---|
| 805 | including dependencies into a @file{Makefile.in} generated by @code{make
|
|---|
| 806 | dist}; it should not be used otherwise.
|
|---|
|
|---|