/autotools/automake.html_node/Third_002dParty-Makefiles.html
HTML | 272 lines | 216 code | 15 blank | 41 comment | 0 complexity | 379940b4930b6e7ff55ed072cfb890ef MD5 | raw file
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!--
- This manual is for GNU Automake (version 1.15,
- 31 December 2014), a program that creates GNU standards-compliant
- Makefiles from template files.
- Copyright (C) 1995-2014 Free Software Foundation, Inc.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License,
- Version 1.3 or any later version published by the Free Software
- Foundation; with no Invariant Sections, with no Front-Cover texts,
- and with no Back-Cover Texts. A copy of the license is included in the
- section entitled "GNU Free Documentation License."
- -->
- <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
- <head>
- <title>automake: Third-Party Makefiles</title>
- <meta name="description" content="automake: Third-Party Makefiles">
- <meta name="keywords" content="automake: Third-Party Makefiles">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Indices.html#Indices" rel="index" title="Indices">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="Not-Enough.html#Not-Enough" rel="up" title="Not Enough">
- <link href="Distributing.html#Distributing" rel="next" title="Distributing">
- <link href="Extending.html#Extending" rel="prev" title="Extending">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.indentedblock {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style:oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nocodebreak {white-space:nowrap}
- span.nolinebreak {white-space:nowrap}
- span.roman {font-family:serif; font-weight:normal}
- span.sansserif {font-family:sans-serif; font-weight:normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
- </head>
- <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <a name="Third_002dParty-Makefiles"></a>
- <div class="header">
- <p>
- Previous: <a href="Extending.html#Extending" accesskey="p" rel="prev">Extending</a>, Up: <a href="Not-Enough.html#Not-Enough" accesskey="u" rel="up">Not Enough</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html#Indices" title="Index" rel="index">Index</a>]</p>
- </div>
- <hr>
- <a name="Third_002dParty-Makefiles-1"></a>
- <h3 class="section">23.2 Third-Party <samp>Makefile</samp>s</h3>
- <a name="index-Third_002dparty-packages_002c-interfacing-with"></a>
- <a name="index-Interfacing-with-third_002dparty-packages"></a>
- <p>In most projects all <samp>Makefile</samp>s are generated by Automake. In
- some cases, however, projects need to embed subdirectories with
- handwritten <samp>Makefile</samp>s. For instance, one subdirectory could be
- a third-party project with its own build system, not using Automake.
- </p>
- <p>It is possible to list arbitrary directories in <code>SUBDIRS</code> or
- <code>DIST_SUBDIRS</code> provided each of these directories has a
- <samp>Makefile</samp> that recognizes all the following recursive targets.
- </p>
- <a name="index-recursive-targets-and-third_002dparty-Makefiles"></a>
- <p>When a user runs one of these targets, that target is run recursively
- in all subdirectories. This is why it is important that even
- third-party <samp>Makefile</samp>s support them.
- </p>
- <dl compact="compact">
- <dt><code>all</code></dt>
- <dd><p>Compile the entire package. This is the default target in
- Automake-generated <samp>Makefile</samp>s, but it does not need to be the
- default in third-party <samp>Makefile</samp>s.
- </p>
- </dd>
- <dt><code>distdir</code></dt>
- <dd><a name="index-distdir"></a>
- <a name="index-distdir-2"></a>
- <a name="index-top_005fdistdir-1"></a>
- <p>Copy files to distribute into ‘<samp>$(distdir)</samp>’, before a tarball is
- constructed. Of course this target is not required if the
- <samp>no-dist</samp> option (see <a href="Options.html#Options">Options</a>) is used.
- </p>
- <p>The variables ‘<samp>$(top_distdir)</samp>’ and ‘<samp>$(distdir)</samp>’
- (see <a href="The-dist-Hook.html#The-dist-Hook">The dist Hook</a>) will be passed from the outer package to the subpackage
- when the <code>distdir</code> target is invoked. These two variables have
- been adjusted for the directory that is being recursed into, so they
- are ready to use.
- </p>
- </dd>
- <dt><code>install</code></dt>
- <dt><code>install-data</code></dt>
- <dt><code>install-exec</code></dt>
- <dt><code>uninstall</code></dt>
- <dd><p>Install or uninstall files (see <a href="Install.html#Install">Install</a>).
- </p>
- </dd>
- <dt><code>install-dvi</code></dt>
- <dt><code>install-html</code></dt>
- <dt><code>install-info</code></dt>
- <dt><code>install-ps</code></dt>
- <dt><code>install-pdf</code></dt>
- <dd><p>Install only some specific documentation format (see <a href="Texinfo.html#Texinfo">Texinfo</a>).
- </p>
- </dd>
- <dt><code>installdirs</code></dt>
- <dd><p>Create install directories, but do not install any files.
- </p>
- </dd>
- <dt><code>check</code></dt>
- <dt><code>installcheck</code></dt>
- <dd><p>Check the package (see <a href="Tests.html#Tests">Tests</a>).
- </p>
- </dd>
- <dt><code>mostlyclean</code></dt>
- <dt><code>clean</code></dt>
- <dt><code>distclean</code></dt>
- <dt><code>maintainer-clean</code></dt>
- <dd><p>Cleaning rules (see <a href="Clean.html#Clean">Clean</a>).
- </p>
- </dd>
- <dt><code>dvi</code></dt>
- <dt><code>pdf</code></dt>
- <dt><code>ps</code></dt>
- <dt><code>info</code></dt>
- <dt><code>html</code></dt>
- <dd><p>Build the documentation in various formats (see <a href="Texinfo.html#Texinfo">Texinfo</a>).
- </p>
- </dd>
- <dt><code>tags</code></dt>
- <dt><code>ctags</code></dt>
- <dd><p>Build <samp>TAGS</samp> and <samp>CTAGS</samp> (see <a href="Tags.html#Tags">Tags</a>).
- </p></dd>
- </dl>
- <p>If you have ever used Gettext in a project, this is a good example of
- how third-party <samp>Makefile</samp>s can be used with Automake. The
- <samp>Makefile</samp>s <code>gettextize</code> puts in the <samp>po/</samp> and
- <samp>intl/</samp> directories are handwritten <samp>Makefile</samp>s that
- implement all of these targets. That way they can be added to
- <code>SUBDIRS</code> in Automake packages.
- </p>
- <p>Directories that are only listed in <code>DIST_SUBDIRS</code> but not in
- <code>SUBDIRS</code> need only the <code>distclean</code>,
- <code>maintainer-clean</code>, and <code>distdir</code> rules (see <a href="Conditional-Subdirectories.html#Conditional-Subdirectories">Conditional Subdirectories</a>).
- </p>
- <p>Usually, many of these rules are irrelevant to the third-party
- subproject, but they are required for the whole package to work. It’s
- OK to have a rule that does nothing, so if you are integrating a
- third-party project with no documentation or tag support, you could
- simply augment its <samp>Makefile</samp> as follows:
- </p>
- <div class="example">
- <pre class="example">EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags
- .PHONY: $(EMPTY_AUTOMAKE_TARGETS)
- $(EMPTY_AUTOMAKE_TARGETS):
- </pre></div>
- <p>Another aspect of integrating third-party build systems is whether
- they support VPATH builds (see <a href="VPATH-Builds.html#VPATH-Builds">VPATH Builds</a>). Obviously if the
- subpackage does not support VPATH builds the whole package will not
- support VPATH builds. This in turns means that ‘<samp>make distcheck</samp>’
- will not work, because it relies on VPATH builds. Some people can
- live without this (actually, many Automake users have never heard of
- ‘<samp>make distcheck</samp>’). Other people may prefer to revamp the
- existing <samp>Makefile</samp>s to support VPATH. Doing so does not
- necessarily require Automake, only Autoconf is needed (see <a href="http://www.gnu.org/software/autoconf/manual/html_node/Build-Directories.html#Build-Directories">Build Directories</a> in <cite>The Autoconf Manual</cite>).
- The necessary substitutions: ‘<samp>@srcdir@</samp>’, ‘<samp>@top_srcdir@</samp>’,
- and ‘<samp>@top_builddir@</samp>’ are defined by <samp>configure</samp> when it
- processes a <samp>Makefile</samp> (see <a href="http://www.gnu.org/software/autoconf/manual/html_node/Preset-Output-Variables.html#Preset-Output-Variables">Preset
- Output Variables</a> in <cite>The Autoconf Manual</cite>), they are not
- computed by the Makefile like the aforementioned ‘<samp>$(distdir)</samp>’ and
- ‘<samp>$(top_distdir)</samp>’ variables.
- </p>
- <p>It is sometimes inconvenient to modify a third-party <samp>Makefile</samp>
- to introduce the above required targets. For instance, one may want to
- keep the third-party sources untouched to ease upgrades to new
- versions.
- </p>
- <a name="index-GNUmakefile-including-Makefile"></a>
- <p>Here are two other ideas. If GNU make is assumed, one possibility is
- to add to that subdirectory a <samp>GNUmakefile</samp> that defines the
- required targets and includes the third-party <samp>Makefile</samp>. For
- this to work in VPATH builds, <samp>GNUmakefile</samp> must lie in the build
- directory; the easiest way to do this is to write a
- <samp>GNUmakefile.in</samp> instead, and have it processed with
- <code>AC_CONFIG_FILES</code> from the outer package. For example if we
- assume <samp>Makefile</samp> defines all targets except the documentation
- targets, and that the <code>check</code> target is actually called
- <code>test</code>, we could write <samp>GNUmakefile</samp> (or
- <samp>GNUmakefile.in</samp>) like this:
- </p>
- <div class="example">
- <pre class="example"># First, include the real Makefile
- include Makefile
- # Then, define the other targets needed by Automake Makefiles.
- .PHONY: dvi pdf ps info html check
- dvi pdf ps info html:
- check: test
- </pre></div>
- <a name="index-Proxy-Makefile-for-third_002dparty-packages"></a>
- <p>A similar idea that does not use <code>include</code> is to write a proxy
- <samp>Makefile</samp> that dispatches rules to the real <samp>Makefile</samp>,
- either with ‘<samp>$(MAKE) -f Makefile.real $(AM_MAKEFLAGS) target</samp>’ (if
- it’s OK to rename the original <samp>Makefile</samp>) or with ‘<samp>cd
- subdir && $(MAKE) $(AM_MAKEFLAGS) target</samp>’ (if it’s OK to store the
- subdirectory project one directory deeper). The good news is that
- this proxy <samp>Makefile</samp> can be generated with Automake. All we
- need are <samp>-local</samp> targets (see <a href="Extending.html#Extending">Extending</a>) that perform the
- dispatch. Of course the other Automake features are available, so you
- could decide to let Automake perform distribution or installation.
- Here is a possible <samp>Makefile.am</samp>:
- </p>
- <div class="example">
- <pre class="example">all-local:
- cd subdir && $(MAKE) $(AM_MAKEFLAGS) all
- check-local:
- cd subdir && $(MAKE) $(AM_MAKEFLAGS) test
- clean-local:
- cd subdir && $(MAKE) $(AM_MAKEFLAGS) clean
- # Assuming the package knows how to install itself
- install-data-local:
- cd subdir && $(MAKE) $(AM_MAKEFLAGS) install-data
- install-exec-local:
- cd subdir && $(MAKE) $(AM_MAKEFLAGS) install-exec
- uninstall-local:
- cd subdir && $(MAKE) $(AM_MAKEFLAGS) uninstall
- # Distribute files from here.
- EXTRA_DIST = subdir/Makefile subdir/program.c ...
- </pre></div>
- <p>Pushing this idea to the extreme, it is also possible to ignore the
- subproject build system and build everything from this proxy
- <samp>Makefile.am</samp>. This might sound very sensible if you need VPATH
- builds but the subproject does not support them.
- </p>
- <hr>
- <div class="header">
- <p>
- Previous: <a href="Extending.html#Extending" accesskey="p" rel="prev">Extending</a>, Up: <a href="Not-Enough.html#Not-Enough" accesskey="u" rel="up">Not Enough</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Indices.html#Indices" title="Index" rel="index">Index</a>]</p>
- </div>
- </body>
- </html>